aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Agosti <francesco.agosti93@gmail.com>2018-09-26 21:34:26 +0800
committerGitHub <noreply@github.com>2018-09-26 21:34:26 +0800
commitc429409ed7a77a67368850f2e736126da0d213dd (patch)
tree08819f84186a0acf84411eca7c874e5164cf378f
parent13aa98f0f3431e4ea4db07794a06304c237e8d45 (diff)
parentf15751d800d813e97b72a861547a9caa1d0d5e56 (diff)
downloaddexon-sol-tools-c429409ed7a77a67368850f2e736126da0d213dd.tar.gz
dexon-sol-tools-c429409ed7a77a67368850f2e736126da0d213dd.tar.zst
dexon-sol-tools-c429409ed7a77a67368850f2e736126da0d213dd.zip
Merge pull request #1091 from 0xProject/feature/sra-spec/order-config-to-post-and-other-bugs
[connect][sra-spec] Update sra-spec and connect to have /order_config be a POST and other small improvements
-rw-r--r--packages/connect/CHANGELOG.json9
-rw-r--r--packages/connect/src/http_client.ts2
-rw-r--r--packages/connect/test/http_client_test.ts6
-rw-r--r--packages/sra-spec/package.json4
-rw-r--r--packages/sra-spec/src/api.ts2
-rw-r--r--packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts7
-rw-r--r--packages/sra-spec/src/examples/relayerApiOrder.ts7
-rw-r--r--packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts7
-rw-r--r--packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts14
-rw-r--r--packages/sra-spec/src/examples/relayerApiOrdersResponse.ts7
-rw-r--r--packages/sra-spec/src/examples/signedOrder.ts5
-rw-r--r--packages/sra-spec/src/md/introduction.md6
12 files changed, 46 insertions, 30 deletions
diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json
index 9de956d4d..4106be881 100644
--- a/packages/connect/CHANGELOG.json
+++ b/packages/connect/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "3.0.0",
+ "changes": [
+ {
+ "note": "Change /order_config request to a POST instead of GET",
+ "pr": 1091
+ }
+ ]
+ },
+ {
"timestamp": 1537907159,
"version": "2.0.4",
"changes": [
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
index 8a68d6c23..bbd0d2042 100644
--- a/packages/connect/src/http_client.ts
+++ b/packages/connect/src/http_client.ts
@@ -149,7 +149,7 @@ export class HttpClient implements Client {
params: requestOpts,
payload: request,
};
- const responseJson = await this._requestAsync('/order_config', HttpRequestType.Get, httpRequestOpts);
+ const responseJson = await this._requestAsync('/order_config', HttpRequestType.Post, httpRequestOpts);
const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson);
return fees;
}
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
index 83b77021a..e9fc9372e 100644
--- a/packages/connect/test/http_client_test.ts
+++ b/packages/connect/test/http_client_test.ts
@@ -148,12 +148,12 @@ describe('HttpClient', () => {
};
const url = `${relayUrl}/order_config`;
it('gets order config', async () => {
- fetchMock.get(url, orderConfigResponseJSON);
+ fetchMock.post(url, orderConfigResponseJSON);
const fees = await relayerClient.getOrderConfigAsync(request);
expect(fees).to.be.deep.equal(orderConfigResponse);
});
it('does not mutate input', async () => {
- fetchMock.get(url, orderConfigResponseJSON);
+ fetchMock.post(url, orderConfigResponseJSON);
const makerAssetAmountBefore = request.makerAssetAmount;
const takerAssetAmountBefore = request.takerAssetAmount;
const expirationTimeSecondsBefore = request.expirationTimeSeconds;
@@ -163,7 +163,7 @@ describe('HttpClient', () => {
expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds);
});
it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, { test: 'dummy' });
+ fetchMock.post(url, { test: 'dummy' });
expect(relayerClient.getOrderConfigAsync(request)).to.be.rejected();
});
});
diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json
index f16711ea0..d4e89db53 100644
--- a/packages/sra-spec/package.json
+++ b/packages/sra-spec/package.json
@@ -9,7 +9,7 @@
"types": "lib/src/index.d.ts",
"scripts": {
"serve": "redoc-cli serve lib/api.json --watch",
- "watch_without_deps": "run-p build-json:watch serve",
+ "watch_without_deps": "run-p build:watch serve",
"lint": "tslint --project .",
"test": "swagger-cli validate lib/api.json",
"rebuild_and_test": "run-s clean build test",
@@ -19,7 +19,7 @@
"clean": "shx rm -rf lib",
"build": "tsc -b && yarn copy_md_files && yarn build-json",
"build-json": "node ./lib/build_scripts/buildJson",
- "build-json:watch": "chokidar 'src/**/*' -c 'yarn build-json' ",
+ "build:watch": "chokidar 'src/**/*' -c 'yarn build' ",
"copy_md_files": "copyfiles -u 2 './src/md/**/*.md' ./lib/src/md",
"deploy-site": "discharge deploy"
},
diff --git a/packages/sra-spec/src/api.ts b/packages/sra-spec/src/api.ts
index f80d343d8..7cecb0369 100644
--- a/packages/sra-spec/src/api.ts
+++ b/packages/sra-spec/src/api.ts
@@ -249,7 +249,7 @@ export const api: OpenApiSpec = {
},
},
'/v2/order_config': {
- get: {
+ post: {
description: `Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: \`senderAddress\`, \`feeRecipientAddress\`, \`makerFee\`, \`takerFee\`. `,
operationId: 'getOrderConfig',
parameters: generateParameters([], false),
diff --git a/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts b/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts
index 9eead5239..3ab7b29c0 100644
--- a/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts
+++ b/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts
@@ -8,13 +8,14 @@ export const relayerApiAssetDataPairsResponse = {
minAmount: '0',
maxAmount: '10000000000000000000',
precision: 5,
- assetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
+ assetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
},
assetDataB: {
minAmount: '0',
- maxAmount: '50000000000000000000',
+ maxAmount: '1',
precision: 5,
- assetData: '0x0257179264389b814a946f3e92105513705ca6b990',
+ assetData:
+ '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
},
},
],
diff --git a/packages/sra-spec/src/examples/relayerApiOrder.ts b/packages/sra-spec/src/examples/relayerApiOrder.ts
index 31181d677..e3ae66dc3 100644
--- a/packages/sra-spec/src/examples/relayerApiOrder.ts
+++ b/packages/sra-spec/src/examples/relayerApiOrder.ts
@@ -5,13 +5,14 @@ export const relayerApiOrder = {
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
makerAssetAmount: '10000000000000000',
- takerAssetAmount: '20000000000000000',
+ takerAssetAmount: '1',
makerFee: '100000000000000',
takerFee: '200000000000000',
expirationTimeSeconds: '1532560590',
salt: '1532559225',
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
+ makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
+ takerAssetData:
+ '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
},
diff --git a/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts b/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts
index 5251d5b4d..cca68b84d 100644
--- a/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts
+++ b/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts
@@ -2,9 +2,10 @@ export const relayerApiOrderConfigPayload = {
makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
makerAssetAmount: '10000000000000000',
- takerAssetAmount: '20000000000000000',
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
+ takerAssetAmount: '1',
+ makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
+ takerAssetData:
+ '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
expirationTimeSeconds: '1532560590',
};
diff --git a/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts b/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts
index 40c09eff9..7f0772649 100644
--- a/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts
+++ b/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts
@@ -11,13 +11,14 @@ export const relayerApiOrderbookResponse = {
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
makerAssetAmount: '10000000000000000',
- takerAssetAmount: '20000000000000000',
+ takerAssetAmount: '1',
makerFee: '100000000000000',
takerFee: '200000000000000',
expirationTimeSeconds: '1532560590',
salt: '1532559225',
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
+ makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
+ takerAssetData:
+ '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
},
@@ -37,13 +38,14 @@ export const relayerApiOrderbookResponse = {
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
makerAssetAmount: '20000000000000000',
- takerAssetAmount: '10000000000000000',
+ takerAssetAmount: '1',
makerFee: '200000000000000',
takerFee: '100000000000000',
expirationTimeSeconds: '1532560590',
salt: '1532559225',
- makerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
- takerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
+ makerAssetData:
+ '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
+ takerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891',
},
diff --git a/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts b/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts
index ac16e7e34..eb66b8e81 100644
--- a/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts
+++ b/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts
@@ -10,13 +10,14 @@ export const relayerApiOrdersResponse = {
feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
makerAssetAmount: '10000000000000000',
- takerAssetAmount: '20000000000000000',
+ takerAssetAmount: '1',
makerFee: '100000000000000',
takerFee: '200000000000000',
expirationTimeSeconds: '1532560590',
salt: '1532559225',
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
+ makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
+ takerAssetData:
+ '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
},
diff --git a/packages/sra-spec/src/examples/signedOrder.ts b/packages/sra-spec/src/examples/signedOrder.ts
index 440566027..8513c398f 100644
--- a/packages/sra-spec/src/examples/signedOrder.ts
+++ b/packages/sra-spec/src/examples/signedOrder.ts
@@ -9,8 +9,9 @@ export const signedOrder = {
takerFee: '200000000000000',
expirationTimeSeconds: '1532560590',
salt: '1532559225',
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
+ makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498',
+ takerAssetData:
+ '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063',
exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
};
diff --git a/packages/sra-spec/src/md/introduction.md b/packages/sra-spec/src/md/introduction.md
index 6f733c9ab..f27186f41 100644
--- a/packages/sra-spec/src/md/introduction.md
+++ b/packages/sra-spec/src/md/introduction.md
@@ -180,7 +180,7 @@ The identifier for the Proxy uses a similar scheme to [ABI function selectors](h
```js
// ERC20 Proxy ID 0xf47261b0
bytes4(keccak256('ERC20Token(address)'));
-// ERC721 Proxy ID 0x08e937fa
+// ERC721 Proxy ID 0x02571792
bytes4(keccak256('ERC721Token(address,uint256)'));
```
@@ -192,10 +192,10 @@ For example, encoding the ERC20 token contract (address: 0x1dc4c1cefef38a777b15a
0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48
```
-Encoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc74099f40e84`), token id (id: `99`, which hex encoded is `0x63`) and the ERC721 Transfer Proxy (id: 0x08e937fa) would be:
+Encoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc74099f40e84`), token id (id: `99`, which hex encoded is `0x63`) and the ERC721 Transfer Proxy (id: 0x02571792) would be:
```bash
-0x08e937fa000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063
+0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063
```
For more information see [the Asset Proxy](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#erc20proxy) section of the v2 spec and the [Ethereum ABI Spec](https://solidity.readthedocs.io/en/develop/abi-spec.html).