@1inch/fusion-sdk 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/fusion-api.d.ts +25 -16
- package/api/fusion-api.js +36 -26
- package/api/index.d.ts +4 -4
- package/api/index.js +8 -8
- package/api/orders/index.d.ts +3 -3
- package/api/orders/index.js +7 -7
- package/api/orders/order-api.spec.d.ts +1 -1
- package/api/orders/order-api.spec.js +479 -395
- package/api/orders/order-api.spec.js.map +1 -1
- package/api/orders/orders.api.d.ts +24 -10
- package/api/orders/orders.api.js +30 -28
- package/api/orders/orders.request.d.ts +22 -18
- package/api/orders/orders.request.js +40 -31
- package/api/orders/types.d.ts +59 -57
- package/api/orders/types.js +17 -16
- package/api/orders/types.js.map +1 -1
- package/api/pagination.d.ts +7 -7
- package/api/pagination.js +10 -10
- package/api/pagination.spec.d.ts +1 -1
- package/api/pagination.spec.js +28 -21
- package/api/params.d.ts +3 -1
- package/api/params.js +25 -19
- package/api/quoter/index.d.ts +5 -5
- package/api/quoter/index.js +9 -9
- package/api/quoter/preset.d.ts +13 -13
- package/api/quoter/preset.js +19 -17
- package/api/quoter/quote/index.d.ts +3 -3
- package/api/quoter/quote/index.js +7 -7
- package/api/quoter/quote/order-params.d.ts +6 -6
- package/api/quoter/quote/order-params.js +12 -12
- package/api/quoter/quote/quote.d.ts +26 -21
- package/api/quoter/quote/quote.js +85 -52
- package/api/quoter/quote/quote.js.map +1 -1
- package/api/quoter/quote/types.d.ts +4 -4
- package/api/quoter/quote/types.js +3 -3
- package/api/quoter/quoter.api.d.ts +12 -9
- package/api/quoter/quoter.api.js +19 -19
- package/api/quoter/quoter.api.spec.d.ts +1 -1
- package/api/quoter/quoter.api.spec.js +32 -23
- package/api/quoter/quoter.api.spec.js.map +1 -1
- package/api/quoter/quoter.request.d.ts +11 -11
- package/api/quoter/quoter.request.js +28 -26
- package/api/quoter/types.d.ts +45 -44
- package/api/quoter/types.js +10 -10
- package/api/quoter/types.js.map +1 -1
- package/api/relayer/index.d.ts +3 -3
- package/api/relayer/index.js +7 -7
- package/api/relayer/relayer.api.d.ts +12 -9
- package/api/relayer/relayer.api.js +13 -13
- package/api/relayer/relayer.api.spec.d.ts +1 -1
- package/api/relayer/relayer.api.spec.js +96 -79
- package/api/relayer/relayer.request.d.ts +8 -8
- package/api/relayer/relayer.request.js +10 -10
- package/api/relayer/types.d.ts +9 -9
- package/api/relayer/types.js +3 -3
- package/api/types.d.ts +17 -15
- package/api/types.js +3 -3
- package/auction-calculator/auction-calculator.d.ts +22 -13
- package/auction-calculator/auction-calculator.js +70 -45
- package/auction-calculator/auction-calculator.spec.d.ts +1 -1
- package/auction-calculator/auction-calculator.spec.js +45 -32
- package/auction-calculator/calc.d.ts +8 -2
- package/auction-calculator/calc.js +12 -12
- package/auction-calculator/constants.d.ts +1 -1
- package/auction-calculator/constants.js +5 -5
- package/auction-calculator/index.d.ts +3 -3
- package/auction-calculator/index.js +7 -7
- package/auction-salt/auction-salt.d.ts +9 -9
- package/auction-salt/auction-salt.js +34 -23
- package/auction-salt/auction.salt.spec.d.ts +1 -1
- package/auction-salt/auction.salt.spec.js +38 -27
- package/auction-salt/index.d.ts +3 -3
- package/auction-salt/index.js +7 -7
- package/auction-salt/parser/constants.d.ts +9 -9
- package/auction-salt/parser/constants.js +33 -14
- package/auction-salt/parser/index.d.ts +2 -2
- package/auction-salt/parser/index.js +6 -6
- package/auction-salt/parser/parser.d.ts +6 -6
- package/auction-salt/parser/parser.js +33 -22
- package/auction-salt/types.d.ts +6 -6
- package/auction-salt/types.js +3 -3
- package/auction-suffix/auction-suffix.d.ts +9 -9
- package/auction-suffix/auction-suffix.js +36 -23
- package/auction-suffix/auction-suffix.spec.d.ts +1 -1
- package/auction-suffix/auction-suffix.spec.js +20 -15
- package/auction-suffix/constants.d.ts +1 -1
- package/auction-suffix/constants.js +5 -5
- package/auction-suffix/encoder.d.ts +15 -6
- package/auction-suffix/encoder.js +45 -28
- package/auction-suffix/index.d.ts +5 -5
- package/auction-suffix/index.js +9 -9
- package/auction-suffix/parser/constants.d.ts +13 -13
- package/auction-suffix/parser/constants.js +30 -17
- package/auction-suffix/parser/errors.d.ts +1 -2
- package/auction-suffix/parser/errors.js +6 -7
- package/auction-suffix/parser/index.d.ts +4 -4
- package/auction-suffix/parser/index.js +8 -8
- package/auction-suffix/parser/parser.d.ts +28 -8
- package/auction-suffix/parser/parser.js +162 -81
- package/auction-suffix/parser/types.d.ts +22 -22
- package/auction-suffix/parser/types.js +3 -3
- package/auction-suffix/types.d.ts +12 -12
- package/auction-suffix/types.js +3 -3
- package/connector/blockchain/blockchain-provider.connector.d.ts +6 -3
- package/connector/blockchain/blockchain-provider.connector.js +3 -3
- package/connector/blockchain/index.d.ts +3 -3
- package/connector/blockchain/index.js +7 -7
- package/connector/blockchain/private-key-provider.connector.d.ts +15 -10
- package/connector/blockchain/private-key-provider.connector.js +12 -12
- package/connector/blockchain/private-key-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/private-key-provider.connector.spec.js +36 -23
- package/connector/blockchain/web3-provider-connector.d.ts +13 -8
- package/connector/blockchain/web3-provider-connector.js +12 -9
- package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/web3-provider.connector.spec.js +37 -26
- package/connector/http/axios-provider.connector.d.ts +3 -3
- package/connector/http/axios-provider.connector.js +13 -13
- package/connector/http/axios-provider.connector.spec.d.ts +1 -1
- package/connector/http/axios-provider.connector.spec.js +37 -31
- package/connector/http/http-provider.connector.d.ts +2 -2
- package/connector/http/http-provider.connector.js +3 -3
- package/connector/http/index.d.ts +2 -2
- package/connector/http/index.js +6 -6
- package/connector/index.d.ts +2 -2
- package/connector/index.js +6 -6
- package/constants.d.ts +10 -6
- package/constants.js +23 -16
- package/fusion-order/fusion-order.d.ts +17 -7
- package/fusion-order/fusion-order.js +14 -12
- package/fusion-order/fusion-order.spec.d.ts +1 -1
- package/fusion-order/fusion-order.spec.js +27 -22
- package/fusion-order/index.d.ts +1 -1
- package/fusion-order/index.js +5 -5
- package/index.d.ts +11 -11
- package/index.js +15 -15
- package/limit-order/eip712/domain.d.ts +10 -9
- package/limit-order/eip712/domain.js +28 -23
- package/limit-order/eip712/eip712.types.d.ts +19 -15
- package/limit-order/eip712/eip712.types.js +3 -3
- package/limit-order/eip712/index.d.ts +3 -3
- package/limit-order/eip712/index.js +7 -7
- package/limit-order/eip712/order-typed-data-builder.d.ts +17 -6
- package/limit-order/eip712/order-typed-data-builder.js +34 -19
- package/limit-order/index.d.ts +4 -4
- package/limit-order/index.js +8 -8
- package/limit-order/interactions-factory.d.ts +1 -1
- package/limit-order/interactions-factory.js +6 -6
- package/limit-order/limit-order.d.ts +31 -25
- package/limit-order/limit-order.js +103 -50
- package/limit-order/limit-order.spec.d.ts +1 -1
- package/limit-order/limit-order.spec.js +75 -51
- package/limit-order/parser/constants.d.ts +9 -9
- package/limit-order/parser/constants.js +5 -5
- package/limit-order/parser/index.d.ts +3 -3
- package/limit-order/parser/index.js +7 -7
- package/limit-order/parser/parser.d.ts +5 -2
- package/limit-order/parser/parser.js +23 -18
- package/limit-order/parser/types.d.ts +3 -3
- package/limit-order/parser/types.js +3 -3
- package/limit-order/predicate-factory.d.ts +9 -5
- package/limit-order/predicate-factory.js +40 -24
- package/limit-order/predicate-factory.spec.d.ts +1 -1
- package/limit-order/predicate-factory.spec.js +44 -29
- package/limit-order/types.d.ts +29 -29
- package/limit-order/types.js +3 -3
- package/limit-order/utils.d.ts +1 -1
- package/limit-order/utils.js +6 -6
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +6 -6
- package/sdk/sdk.d.ts +29 -11
- package/sdk/sdk.js +48 -38
- package/sdk/types.d.ts +27 -27
- package/sdk/types.js +3 -3
- package/settlement/encoders/constants.d.ts +1 -1
- package/settlement/encoders/constants.js +5 -5
- package/settlement/encoders/fill-order.encoder.d.ts +2 -2
- package/settlement/encoders/fill-order.encoder.js +26 -12
- package/settlement/encoders/index.d.ts +3 -3
- package/settlement/encoders/index.js +7 -7
- package/settlement/encoders/settlement.encoder.d.ts +13 -4
- package/settlement/encoders/settlement.encoder.js +41 -19
- package/settlement/index.d.ts +4 -4
- package/settlement/index.js +8 -8
- package/settlement/settlement.d.ts +8 -5
- package/settlement/settlement.js +28 -14
- package/settlement/settlement.spec.d.ts +1 -1
- package/settlement/settlement.spec.js +45 -35
- package/settlement/signature-patcher.d.ts +1 -1
- package/settlement/signature-patcher.js +19 -16
- package/settlement/types.d.ts +13 -13
- package/settlement/types.js +3 -3
- package/utils.d.ts +6 -6
- package/utils.js +29 -23
- package/validations.d.ts +2 -2
- package/validations.js +14 -15
|
@@ -1,413 +1,497 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const tslib_1 = require(
|
|
4
|
-
const constants_1 = require(
|
|
5
|
-
const sdk_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
const tslib_1 = require('tslib')
|
|
4
|
+
const constants_1 = require('../../constants')
|
|
5
|
+
const sdk_1 = require('../../sdk/sdk')
|
|
6
6
|
function createHttpProviderFake(mock) {
|
|
7
7
|
const httpProvider = {
|
|
8
8
|
get: jest.fn().mockImplementationOnce(() => {
|
|
9
|
-
return Promise.resolve(mock)
|
|
9
|
+
return Promise.resolve(mock)
|
|
10
10
|
}),
|
|
11
11
|
post: jest.fn().mockImplementation(() => {
|
|
12
|
-
return Promise.resolve(null)
|
|
12
|
+
return Promise.resolve(null)
|
|
13
13
|
})
|
|
14
|
-
}
|
|
15
|
-
return httpProvider
|
|
14
|
+
}
|
|
15
|
+
return httpProvider
|
|
16
16
|
}
|
|
17
17
|
describe(__filename, () => {
|
|
18
18
|
describe('getActiveOrders', () => {
|
|
19
|
-
it('success', () =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
it('success', () =>
|
|
20
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const expected = {
|
|
22
|
+
items: [
|
|
23
|
+
{
|
|
24
|
+
orderHash:
|
|
25
|
+
'0xe07193d683bb70f7c9a45001b863dd9058146849bdd47951b6d0ed13b1fd8396',
|
|
26
|
+
signature:
|
|
27
|
+
'0x21ef770f9bedbb97542033bd3b1a2ad611917567102545c93ce66668b8524b7c609bead7829113e104be41fbbd14fea027c85bc4668214b81d52f02c2f9010551b',
|
|
28
|
+
deadline: '2023-01-31T11:01:02.000Z',
|
|
29
|
+
auctionStartDate: '2023-01-31T10:58:02.000Z',
|
|
30
|
+
auctionEndDate: '2023-01-31T11:01:02.000Z',
|
|
31
|
+
remainingMakerAmount: '57684207067582695',
|
|
32
|
+
order: {
|
|
33
|
+
salt: '45162296565521316310143660684688589556990590668045350709106347387233721386087',
|
|
34
|
+
maker: '0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1',
|
|
35
|
+
offsets:
|
|
36
|
+
'2048955946929424286921227713067743020696385405755235979139736848564224',
|
|
37
|
+
receiver:
|
|
38
|
+
'0x08b067ad41e45babe5bbb52fc2fe7f692f628b06',
|
|
39
|
+
makerAsset:
|
|
40
|
+
'0xe68a2c0eef74b5d8d2975bbf7a681226e4d7473c',
|
|
41
|
+
takerAsset:
|
|
42
|
+
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
43
|
+
interactions:
|
|
44
|
+
'0x63592c2b0000000000000000000000000000000000000000000000000000000063d8f4ee08b067ad41e45babe5bbb52fc2fe7f692f628b06315b47a8c3780434b153667588db4ca628526e20006c00c26a001800c44c63d8f41684d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f416cfa62f77920d6383be12c91c71bd403599e1116ff486570012',
|
|
45
|
+
makingAmount: '57684207067582695',
|
|
46
|
+
takingAmount: '116032349855081688885',
|
|
47
|
+
allowedSender:
|
|
48
|
+
'0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
orderHash:
|
|
53
|
+
'0xc359131e97c4cd1e01e1cd0ddeb16dd636c34fb294f53fd2f3e3ce8cb1c8482e',
|
|
54
|
+
signature:
|
|
55
|
+
'0x986c196d603d9c07faa1a5d3167a008a21850d5d9922da8a0f7e48225fdfd4a27f477d16f5078b5fad68205685a0a0dce40ac337a6f4376996e37f95e66a1a921b',
|
|
56
|
+
deadline: '2023-01-31T11:01:06.000Z',
|
|
57
|
+
auctionStartDate: '2023-01-31T10:58:11.000Z',
|
|
58
|
+
auctionEndDate: '2023-01-31T11:01:11.000Z',
|
|
59
|
+
remainingMakerAmount: '470444951856649710700841',
|
|
60
|
+
order: {
|
|
61
|
+
salt: '45162296808160836322731793320280672051161012167252717657723413939965365979370',
|
|
62
|
+
maker: '0xe2b43fbd64f4bb4dc99a8d48ad41cfab90621567',
|
|
63
|
+
offsets:
|
|
64
|
+
'970558080243398695134547109586957793750899628853613079895592438595584',
|
|
65
|
+
receiver:
|
|
66
|
+
'0x0000000000000000000000000000000000000000',
|
|
67
|
+
makerAsset:
|
|
68
|
+
'0x2e85ae1c47602f7927bcabc2ff99c40aa222ae15',
|
|
69
|
+
takerAsset:
|
|
70
|
+
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
71
|
+
interactions:
|
|
72
|
+
'0x2cc2878d000063d8f4f2000000000000e2b43fbd64f4bb4dc99a8d48ad41cfab906215670000000084d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f475cfa62f77920d6383be12c91c71bd403599e1116fffffffff10',
|
|
73
|
+
makingAmount: '470444951856649710700841',
|
|
74
|
+
takingAmount: '363417063831796476',
|
|
75
|
+
allowedSender:
|
|
76
|
+
'0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
77
|
+
}
|
|
39
78
|
}
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
79
|
+
],
|
|
80
|
+
meta: {
|
|
81
|
+
totalItems: 11,
|
|
82
|
+
currentPage: 1,
|
|
83
|
+
itemsPerPage: 2,
|
|
84
|
+
totalPages: 6
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const url = 'https://test.com'
|
|
88
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
89
|
+
const sdk = new sdk_1.FusionSDK({
|
|
90
|
+
url,
|
|
91
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
92
|
+
httpProvider
|
|
93
|
+
})
|
|
94
|
+
const response = yield sdk.getActiveOrders({page: 1, limit: 2})
|
|
95
|
+
expect(response).toEqual(expected)
|
|
96
|
+
expect(httpProvider.get).toHaveBeenLastCalledWith(
|
|
97
|
+
`${url}/orders/v1.0/1/order/active/?page=1&limit=2`
|
|
98
|
+
)
|
|
99
|
+
}))
|
|
100
|
+
it('passes without providing args', () =>
|
|
101
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const expected = {
|
|
103
|
+
items: [
|
|
104
|
+
{
|
|
105
|
+
orderHash:
|
|
106
|
+
'0xe07193d683bb70f7c9a45001b863dd9058146849bdd47951b6d0ed13b1fd8396',
|
|
107
|
+
signature:
|
|
108
|
+
'0x21ef770f9bedbb97542033bd3b1a2ad611917567102545c93ce66668b8524b7c609bead7829113e104be41fbbd14fea027c85bc4668214b81d52f02c2f9010551b',
|
|
109
|
+
deadline: '2023-01-31T11:01:02.000Z',
|
|
110
|
+
auctionStartDate: '2023-01-31T10:58:02.000Z',
|
|
111
|
+
auctionEndDate: '2023-01-31T11:01:02.000Z',
|
|
112
|
+
order: {
|
|
113
|
+
salt: '45162296565521316310143660684688589556990590668045350709106347387233721386087',
|
|
114
|
+
maker: '0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1',
|
|
115
|
+
offsets:
|
|
116
|
+
'2048955946929424286921227713067743020696385405755235979139736848564224',
|
|
117
|
+
receiver:
|
|
118
|
+
'0x08b067ad41e45babe5bbb52fc2fe7f692f628b06',
|
|
119
|
+
makerAsset:
|
|
120
|
+
'0xe68a2c0eef74b5d8d2975bbf7a681226e4d7473c',
|
|
121
|
+
takerAsset:
|
|
122
|
+
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
123
|
+
interactions:
|
|
124
|
+
'0x63592c2b0000000000000000000000000000000000000000000000000000000063d8f4ee08b067ad41e45babe5bbb52fc2fe7f692f628b06315b47a8c3780434b153667588db4ca628526e20006c00c26a001800c44c63d8f41684d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f416cfa62f77920d6383be12c91c71bd403599e1116ff486570012',
|
|
125
|
+
makingAmount: '57684207067582695',
|
|
126
|
+
takingAmount: '116032349855081688885',
|
|
127
|
+
allowedSender:
|
|
128
|
+
'0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
orderHash:
|
|
133
|
+
'0xc359131e97c4cd1e01e1cd0ddeb16dd636c34fb294f53fd2f3e3ce8cb1c8482e',
|
|
134
|
+
signature:
|
|
135
|
+
'0x986c196d603d9c07faa1a5d3167a008a21850d5d9922da8a0f7e48225fdfd4a27f477d16f5078b5fad68205685a0a0dce40ac337a6f4376996e37f95e66a1a921b',
|
|
136
|
+
deadline: '2023-01-31T11:01:06.000Z',
|
|
137
|
+
auctionStartDate: '2023-01-31T10:58:11.000Z',
|
|
138
|
+
auctionEndDate: '2023-01-31T11:01:11.000Z',
|
|
139
|
+
order: {
|
|
140
|
+
salt: '45162296808160836322731793320280672051161012167252717657723413939965365979370',
|
|
141
|
+
maker: '0xe2b43fbd64f4bb4dc99a8d48ad41cfab90621567',
|
|
142
|
+
offsets:
|
|
143
|
+
'970558080243398695134547109586957793750899628853613079895592438595584',
|
|
144
|
+
receiver:
|
|
145
|
+
'0x0000000000000000000000000000000000000000',
|
|
146
|
+
makerAsset:
|
|
147
|
+
'0x2e85ae1c47602f7927bcabc2ff99c40aa222ae15',
|
|
148
|
+
takerAsset:
|
|
149
|
+
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
150
|
+
interactions:
|
|
151
|
+
'0x2cc2878d000063d8f4f2000000000000e2b43fbd64f4bb4dc99a8d48ad41cfab906215670000000084d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f475cfa62f77920d6383be12c91c71bd403599e1116fffffffff10',
|
|
152
|
+
makingAmount: '470444951856649710700841',
|
|
153
|
+
takingAmount: '363417063831796476',
|
|
154
|
+
allowedSender:
|
|
155
|
+
'0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
156
|
+
}
|
|
58
157
|
}
|
|
158
|
+
],
|
|
159
|
+
meta: {
|
|
160
|
+
totalItems: 11,
|
|
161
|
+
currentPage: 1,
|
|
162
|
+
itemsPerPage: 2,
|
|
163
|
+
totalPages: 6
|
|
59
164
|
}
|
|
60
|
-
],
|
|
61
|
-
meta: {
|
|
62
|
-
totalItems: 11,
|
|
63
|
-
currentPage: 1,
|
|
64
|
-
itemsPerPage: 2,
|
|
65
|
-
totalPages: 6
|
|
66
165
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
166
|
+
const url = 'https://test.com'
|
|
167
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
168
|
+
const sdk = new sdk_1.FusionSDK({
|
|
169
|
+
url,
|
|
170
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
171
|
+
httpProvider
|
|
172
|
+
})
|
|
173
|
+
const response = yield sdk.getActiveOrders()
|
|
174
|
+
expect(response).toEqual(expected)
|
|
175
|
+
expect(httpProvider.get).toHaveBeenLastCalledWith(
|
|
176
|
+
`${url}/orders/v1.0/1/order/active/?`
|
|
177
|
+
)
|
|
178
|
+
}))
|
|
179
|
+
})
|
|
180
|
+
describe('getOrderStatus', () => {
|
|
181
|
+
it('success', () =>
|
|
182
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
const url = 'https://test.com'
|
|
184
|
+
const expected = {
|
|
185
|
+
order: {
|
|
186
|
+
salt: '45144194282371711345892930501725766861375817078109214409479816083205610767025',
|
|
187
|
+
maker: '0x6f250c769001617aff9bdf4b9fd878062e94af83',
|
|
188
|
+
offsets:
|
|
189
|
+
'970558080243398695134547109586957793750899628853613079895592438595584',
|
|
190
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
191
|
+
makerAsset:
|
|
192
|
+
'0x6eb15148d0ea88433dd8088a3acc515d27e36c1b',
|
|
193
|
+
takerAsset:
|
|
194
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
195
|
+
interactions:
|
|
196
|
+
'0x2cc2878d000063ceb60f0000000000006f250c769001617aff9bdf4b9fd878062e94af83006c00c2fe001800c44c0000000084d99aa569d93a9ca187d83734c8c4a519c4e9b1ffffffff0a',
|
|
197
|
+
makingAmount: '2246481050155000',
|
|
198
|
+
takingAmount: '349837736598',
|
|
199
|
+
allowedSender:
|
|
200
|
+
'0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
201
|
+
},
|
|
202
|
+
cancelTx: null,
|
|
203
|
+
points: null,
|
|
204
|
+
auctionStartDate: 1674491231,
|
|
205
|
+
auctionDuration: 180,
|
|
206
|
+
initialRateBump: 50484,
|
|
207
|
+
status: 'filled',
|
|
208
|
+
createdAt: '2023-01-23T16:26:38.803Z',
|
|
209
|
+
fromTokenToUsdPrice: '0.01546652159249409068',
|
|
210
|
+
toTokenToUsdPrice: '1.00135361305236370022',
|
|
211
|
+
fills: [
|
|
212
|
+
{
|
|
213
|
+
txHash: '0xcdd81e6860fc038d4fe8549efdf18488154667a2088d471cdaa7d492f24178a1',
|
|
214
|
+
filledMakerAmount: '2246481050155001',
|
|
215
|
+
filledAuctionTakerAmount: '351593117428'
|
|
99
216
|
}
|
|
217
|
+
],
|
|
218
|
+
isNativeCurrency: false
|
|
219
|
+
}
|
|
220
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
221
|
+
const sdk = new sdk_1.FusionSDK({
|
|
222
|
+
url,
|
|
223
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
224
|
+
httpProvider
|
|
225
|
+
})
|
|
226
|
+
const orderHash = `0x1beee023ab933cf5446c298eadadb61c05705f2156ef5b2db36c160b36f31ce4`
|
|
227
|
+
const response = yield sdk.getOrderStatus(orderHash)
|
|
228
|
+
expect(response).toEqual(expected)
|
|
229
|
+
expect(httpProvider.get).toHaveBeenLastCalledWith(
|
|
230
|
+
`${url}/orders/v1.0/1/order/status/${orderHash}`
|
|
231
|
+
)
|
|
232
|
+
}))
|
|
233
|
+
it('throws an error when the string is not hexadecimal', () =>
|
|
234
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
235
|
+
const url = 'https://test.com'
|
|
236
|
+
const expected = {
|
|
237
|
+
order: {
|
|
238
|
+
salt: '45144194282371711345892930501725766861375817078109214409479816083205610767025',
|
|
239
|
+
maker: '0x6f250c769001617aff9bdf4b9fd878062e94af83',
|
|
240
|
+
offsets:
|
|
241
|
+
'970558080243398695134547109586957793750899628853613079895592438595584',
|
|
242
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
243
|
+
makerAsset:
|
|
244
|
+
'0x6eb15148d0ea88433dd8088a3acc515d27e36c1b',
|
|
245
|
+
takerAsset:
|
|
246
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
247
|
+
interactions:
|
|
248
|
+
'0x2cc2878d000063ceb60f0000000000006f250c769001617aff9bdf4b9fd878062e94af83006c00c2fe001800c44c0000000084d99aa569d93a9ca187d83734c8c4a519c4e9b1ffffffff0a',
|
|
249
|
+
makingAmount: '2246481050155000',
|
|
250
|
+
takingAmount: '349837736598',
|
|
251
|
+
allowedSender:
|
|
252
|
+
'0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
100
253
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
makingAmount: '470444951856649710700841',
|
|
116
|
-
takingAmount: '363417063831796476',
|
|
117
|
-
allowedSender: '0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
254
|
+
cancelTx: null,
|
|
255
|
+
points: null,
|
|
256
|
+
auctionStartDate: 1674491231,
|
|
257
|
+
auctionDuration: 180,
|
|
258
|
+
initialRateBump: 50484,
|
|
259
|
+
status: 'filled',
|
|
260
|
+
createdAt: '2023-01-23T16:26:38.803Z',
|
|
261
|
+
fromTokenToUsdPrice: '0.01546652159249409068',
|
|
262
|
+
toTokenToUsdPrice: '1.00135361305236370022',
|
|
263
|
+
fills: [
|
|
264
|
+
{
|
|
265
|
+
txHash: '0xcdd81e6860fc038d4fe8549efdf18488154667a2088d471cdaa7d492f24178a1',
|
|
266
|
+
filledMakerAmount: '2246481050155001',
|
|
267
|
+
filledAuctionTakerAmount: '351593117428'
|
|
118
268
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
meta: {
|
|
122
|
-
totalItems: 11,
|
|
123
|
-
currentPage: 1,
|
|
124
|
-
itemsPerPage: 2,
|
|
125
|
-
totalPages: 6
|
|
269
|
+
],
|
|
270
|
+
isNativeCurrency: false
|
|
126
271
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
httpProvider
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
offsets: '970558080243398695134547109586957793750899628853613079895592438595584',
|
|
192
|
-
receiver: '0x0000000000000000000000000000000000000000',
|
|
193
|
-
makerAsset: '0x6eb15148d0ea88433dd8088a3acc515d27e36c1b',
|
|
194
|
-
takerAsset: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
195
|
-
interactions: '0x2cc2878d000063ceb60f0000000000006f250c769001617aff9bdf4b9fd878062e94af83006c00c2fe001800c44c0000000084d99aa569d93a9ca187d83734c8c4a519c4e9b1ffffffff0a',
|
|
196
|
-
makingAmount: '2246481050155000',
|
|
197
|
-
takingAmount: '349837736598',
|
|
198
|
-
allowedSender: '0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
199
|
-
},
|
|
200
|
-
cancelTx: null,
|
|
201
|
-
points: null,
|
|
202
|
-
auctionStartDate: 1674491231,
|
|
203
|
-
auctionDuration: 180,
|
|
204
|
-
initialRateBump: 50484,
|
|
205
|
-
status: 'filled',
|
|
206
|
-
createdAt: '2023-01-23T16:26:38.803Z',
|
|
207
|
-
fromTokenToUsdPrice: '0.01546652159249409068',
|
|
208
|
-
toTokenToUsdPrice: '1.00135361305236370022',
|
|
209
|
-
fills: [
|
|
210
|
-
{
|
|
211
|
-
txHash: '0xcdd81e6860fc038d4fe8549efdf18488154667a2088d471cdaa7d492f24178a1',
|
|
212
|
-
filledMakerAmount: '2246481050155001',
|
|
213
|
-
filledAuctionTakerAmount: '351593117428'
|
|
214
|
-
}
|
|
215
|
-
],
|
|
216
|
-
isNativeCurrency: false
|
|
217
|
-
};
|
|
218
|
-
const httpProvider = createHttpProviderFake(expected);
|
|
219
|
-
const sdk = new sdk_1.FusionSDK({
|
|
220
|
-
url,
|
|
221
|
-
network: constants_1.NetworkEnum.ETHEREUM,
|
|
222
|
-
httpProvider
|
|
223
|
-
});
|
|
224
|
-
const orderHash = `0x1beee023ab933cf5446c298eaddb61c0-5705f2156ef5b2db36c160b36f31ce4`;
|
|
225
|
-
const promise = sdk.getOrderStatus(orderHash);
|
|
226
|
-
yield expect(promise).rejects.toThrow(/orderHash have to be hex/);
|
|
227
|
-
}));
|
|
228
|
-
it('throws an error when the string length is not equals 66', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
229
|
-
const url = 'https://test.com';
|
|
230
|
-
const expected = {
|
|
231
|
-
order: {
|
|
232
|
-
salt: '45144194282371711345892930501725766861375817078109214409479816083205610767025',
|
|
233
|
-
maker: '0x6f250c769001617aff9bdf4b9fd878062e94af83',
|
|
234
|
-
offsets: '970558080243398695134547109586957793750899628853613079895592438595584',
|
|
235
|
-
receiver: '0x0000000000000000000000000000000000000000',
|
|
236
|
-
makerAsset: '0x6eb15148d0ea88433dd8088a3acc515d27e36c1b',
|
|
237
|
-
takerAsset: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
238
|
-
interactions: '0x2cc2878d000063ceb60f0000000000006f250c769001617aff9bdf4b9fd878062e94af83006c00c2fe001800c44c0000000084d99aa569d93a9ca187d83734c8c4a519c4e9b1ffffffff0a',
|
|
239
|
-
makingAmount: '2246481050155000',
|
|
240
|
-
takingAmount: '349837736598',
|
|
241
|
-
allowedSender: '0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
242
|
-
},
|
|
243
|
-
cancelTx: null,
|
|
244
|
-
points: null,
|
|
245
|
-
auctionStartDate: 1674491231,
|
|
246
|
-
auctionDuration: 180,
|
|
247
|
-
initialRateBump: 50484,
|
|
248
|
-
status: 'filled',
|
|
249
|
-
createdAt: '2023-01-23T16:26:38.803Z',
|
|
250
|
-
fromTokenToUsdPrice: '0.01546652159249409068',
|
|
251
|
-
toTokenToUsdPrice: '1.00135361305236370022',
|
|
252
|
-
fills: [
|
|
253
|
-
{
|
|
254
|
-
txHash: '0xcdd81e6860fc038d4fe8549efdf18488154667a2088d471cdaa7d492f24178a1',
|
|
255
|
-
filledMakerAmount: '2246481050155001',
|
|
256
|
-
filledAuctionTakerAmount: '351593117428'
|
|
257
|
-
}
|
|
258
|
-
],
|
|
259
|
-
isNativeCurrency: false
|
|
260
|
-
};
|
|
261
|
-
const httpProvider = createHttpProviderFake(expected);
|
|
262
|
-
const sdk = new sdk_1.FusionSDK({
|
|
263
|
-
url,
|
|
264
|
-
network: constants_1.NetworkEnum.ETHEREUM,
|
|
265
|
-
httpProvider
|
|
266
|
-
});
|
|
267
|
-
const orderHash = `0x1beee023ab933cf5446c298eadasdasdb61c0x5705f2156ef5b2db36c160b36f31ce4`;
|
|
268
|
-
const promise = sdk.getOrderStatus(orderHash);
|
|
269
|
-
yield expect(promise).rejects.toThrow(/orderHash length should be equals 66/);
|
|
270
|
-
}));
|
|
271
|
-
});
|
|
272
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
273
|
+
const sdk = new sdk_1.FusionSDK({
|
|
274
|
+
url,
|
|
275
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
276
|
+
httpProvider
|
|
277
|
+
})
|
|
278
|
+
const orderHash = `0x1beee023ab933cf5446c298eaddb61c0-5705f2156ef5b2db36c160b36f31ce4`
|
|
279
|
+
const promise = sdk.getOrderStatus(orderHash)
|
|
280
|
+
yield expect(promise).rejects.toThrow(
|
|
281
|
+
/orderHash have to be hex/
|
|
282
|
+
)
|
|
283
|
+
}))
|
|
284
|
+
it('throws an error when the string length is not equals 66', () =>
|
|
285
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
286
|
+
const url = 'https://test.com'
|
|
287
|
+
const expected = {
|
|
288
|
+
order: {
|
|
289
|
+
salt: '45144194282371711345892930501725766861375817078109214409479816083205610767025',
|
|
290
|
+
maker: '0x6f250c769001617aff9bdf4b9fd878062e94af83',
|
|
291
|
+
offsets:
|
|
292
|
+
'970558080243398695134547109586957793750899628853613079895592438595584',
|
|
293
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
294
|
+
makerAsset:
|
|
295
|
+
'0x6eb15148d0ea88433dd8088a3acc515d27e36c1b',
|
|
296
|
+
takerAsset:
|
|
297
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
298
|
+
interactions:
|
|
299
|
+
'0x2cc2878d000063ceb60f0000000000006f250c769001617aff9bdf4b9fd878062e94af83006c00c2fe001800c44c0000000084d99aa569d93a9ca187d83734c8c4a519c4e9b1ffffffff0a',
|
|
300
|
+
makingAmount: '2246481050155000',
|
|
301
|
+
takingAmount: '349837736598',
|
|
302
|
+
allowedSender:
|
|
303
|
+
'0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
304
|
+
},
|
|
305
|
+
cancelTx: null,
|
|
306
|
+
points: null,
|
|
307
|
+
auctionStartDate: 1674491231,
|
|
308
|
+
auctionDuration: 180,
|
|
309
|
+
initialRateBump: 50484,
|
|
310
|
+
status: 'filled',
|
|
311
|
+
createdAt: '2023-01-23T16:26:38.803Z',
|
|
312
|
+
fromTokenToUsdPrice: '0.01546652159249409068',
|
|
313
|
+
toTokenToUsdPrice: '1.00135361305236370022',
|
|
314
|
+
fills: [
|
|
315
|
+
{
|
|
316
|
+
txHash: '0xcdd81e6860fc038d4fe8549efdf18488154667a2088d471cdaa7d492f24178a1',
|
|
317
|
+
filledMakerAmount: '2246481050155001',
|
|
318
|
+
filledAuctionTakerAmount: '351593117428'
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
isNativeCurrency: false
|
|
322
|
+
}
|
|
323
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
324
|
+
const sdk = new sdk_1.FusionSDK({
|
|
325
|
+
url,
|
|
326
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
327
|
+
httpProvider
|
|
328
|
+
})
|
|
329
|
+
const orderHash = `0x1beee023ab933cf5446c298eadasdasdb61c0x5705f2156ef5b2db36c160b36f31ce4`
|
|
330
|
+
const promise = sdk.getOrderStatus(orderHash)
|
|
331
|
+
yield expect(promise).rejects.toThrow(
|
|
332
|
+
/orderHash length should be equals 66/
|
|
333
|
+
)
|
|
334
|
+
}))
|
|
335
|
+
})
|
|
272
336
|
describe('getOrdersByMaker', () => {
|
|
273
|
-
it('success', () =>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
337
|
+
it('success', () =>
|
|
338
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
339
|
+
const url = 'https://test.com'
|
|
340
|
+
const expected = {
|
|
341
|
+
meta: {
|
|
342
|
+
totalItems: 247,
|
|
343
|
+
currentPage: 1,
|
|
344
|
+
itemsPerPage: 1,
|
|
345
|
+
totalPages: 247
|
|
346
|
+
},
|
|
347
|
+
items: [
|
|
348
|
+
{
|
|
349
|
+
orderHash:
|
|
350
|
+
'0xe8c38b4ef9c96c12290709be98f5b6cb932233ad767137ee7506aa71687c960e',
|
|
351
|
+
status: 'filled',
|
|
352
|
+
makerAsset:
|
|
353
|
+
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
354
|
+
takerAsset:
|
|
355
|
+
'0x111111111117dc0aa78b770fa6a738034120c302',
|
|
356
|
+
makerAmount: '351336830606',
|
|
357
|
+
fills: [
|
|
358
|
+
{
|
|
359
|
+
txHash: '0x3e049a432a426e73a22b5ee19327bbfb0706c34b48eba68ff114ccfb215b5bae',
|
|
360
|
+
filledMakerAmount: '351336830606',
|
|
361
|
+
filledAuctionTakerAmount:
|
|
362
|
+
'895661510910730845524061'
|
|
363
|
+
}
|
|
364
|
+
],
|
|
365
|
+
points: null,
|
|
366
|
+
cancelTx: null,
|
|
367
|
+
isNativeCurrency: false,
|
|
368
|
+
auctionStartDate: 1672989075,
|
|
369
|
+
auctionDuration: 180,
|
|
370
|
+
initialRateBump: 50515
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
375
|
+
const sdk = new sdk_1.FusionSDK({
|
|
376
|
+
url,
|
|
377
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
378
|
+
httpProvider
|
|
379
|
+
})
|
|
380
|
+
const address = '0xfa80cd9b3becc0b4403b0f421384724f2810775f'
|
|
381
|
+
const response = yield sdk.getOrdersByMaker({
|
|
382
|
+
address,
|
|
383
|
+
limit: 1,
|
|
384
|
+
page: 1
|
|
385
|
+
})
|
|
386
|
+
expect(response).toEqual(expected)
|
|
387
|
+
expect(httpProvider.get).toHaveBeenLastCalledWith(
|
|
388
|
+
`${url}/orders/v1.0/1/order/maker/${address}/?limit=1&page=1`
|
|
389
|
+
)
|
|
390
|
+
}))
|
|
391
|
+
it('handles the case when no pagination params was passed', () =>
|
|
392
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
393
|
+
const url = 'https://test.com'
|
|
394
|
+
const expected = {
|
|
395
|
+
meta: {
|
|
396
|
+
totalItems: 247,
|
|
397
|
+
currentPage: 1,
|
|
398
|
+
itemsPerPage: 1,
|
|
399
|
+
totalPages: 247
|
|
400
|
+
},
|
|
401
|
+
items: [
|
|
402
|
+
{
|
|
403
|
+
orderHash:
|
|
404
|
+
'0xe8c38b4ef9c96c12290709be98f5b6cb932233ad767137ee7506aa71687c960e',
|
|
405
|
+
status: 'filled',
|
|
406
|
+
makerAsset:
|
|
407
|
+
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
408
|
+
takerAsset:
|
|
409
|
+
'0x111111111117dc0aa78b770fa6a738034120c302',
|
|
410
|
+
makerAmount: '351336830606',
|
|
411
|
+
fills: [
|
|
412
|
+
{
|
|
413
|
+
txHash: '0x3e049a432a426e73a22b5ee19327bbfb0706c34b48eba68ff114ccfb215b5bae',
|
|
414
|
+
filledMakerAmount: '351336830606',
|
|
415
|
+
filledAuctionTakerAmount:
|
|
416
|
+
'895661510910730845524061'
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
points: null,
|
|
420
|
+
cancelTx: null,
|
|
421
|
+
isNativeCurrency: false,
|
|
422
|
+
auctionStartDate: 1672989075,
|
|
423
|
+
auctionDuration: 180,
|
|
424
|
+
initialRateBump: 50515
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
429
|
+
const sdk = new sdk_1.FusionSDK({
|
|
430
|
+
url,
|
|
431
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
432
|
+
httpProvider
|
|
433
|
+
})
|
|
434
|
+
const address = '0xfa80cd9b3becc0b4403b0f421384724f2810775f'
|
|
435
|
+
const response = yield sdk.getOrdersByMaker({
|
|
436
|
+
address
|
|
437
|
+
})
|
|
438
|
+
expect(response).toEqual(expected)
|
|
439
|
+
expect(httpProvider.get).toHaveBeenLastCalledWith(
|
|
440
|
+
`${url}/orders/v1.0/1/order/maker/${address}/?`
|
|
441
|
+
)
|
|
442
|
+
}))
|
|
443
|
+
it('throws an error with invalid address', () =>
|
|
444
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
445
|
+
const url = 'https://test.com'
|
|
446
|
+
const expected = {
|
|
447
|
+
meta: {
|
|
448
|
+
totalItems: 247,
|
|
449
|
+
currentPage: 1,
|
|
450
|
+
itemsPerPage: 1,
|
|
451
|
+
totalPages: 247
|
|
452
|
+
},
|
|
453
|
+
items: [
|
|
454
|
+
{
|
|
455
|
+
orderHash:
|
|
456
|
+
'0xe8c38b4ef9c96c12290709be98f5b6cb932233ad767137ee7506aa71687c960e',
|
|
457
|
+
status: 'filled',
|
|
458
|
+
makerAsset:
|
|
459
|
+
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
460
|
+
takerAsset:
|
|
461
|
+
'0x111111111117dc0aa78b770fa6a738034120c302',
|
|
462
|
+
makerAmount: '351336830606',
|
|
463
|
+
fills: [
|
|
464
|
+
{
|
|
465
|
+
txHash: '0x3e049a432a426e73a22b5ee19327bbfb0706c34b48eba68ff114ccfb215b5bae',
|
|
466
|
+
filledMakerAmount: '351336830606',
|
|
467
|
+
filledAuctionTakerAmount:
|
|
468
|
+
'895661510910730845524061'
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
points: null,
|
|
472
|
+
cancelTx: null,
|
|
473
|
+
isNativeCurrency: false,
|
|
474
|
+
auctionStartDate: 1672989075,
|
|
475
|
+
auctionDuration: 180,
|
|
476
|
+
initialRateBump: 50515
|
|
477
|
+
}
|
|
478
|
+
]
|
|
479
|
+
}
|
|
480
|
+
const httpProvider = createHttpProviderFake(expected)
|
|
481
|
+
const sdk = new sdk_1.FusionSDK({
|
|
482
|
+
url,
|
|
483
|
+
network: constants_1.NetworkEnum.ETHEREUM,
|
|
484
|
+
httpProvider
|
|
485
|
+
})
|
|
486
|
+
const address =
|
|
487
|
+
'0xfa80cd9b3becc0b4403b0f42138472ewewewewewewew2810775f'
|
|
488
|
+
const promise = sdk.getOrdersByMaker({
|
|
489
|
+
address,
|
|
490
|
+
limit: 1,
|
|
491
|
+
page: 1
|
|
492
|
+
})
|
|
493
|
+
yield expect(promise).rejects.toThrow(/is invalid address/)
|
|
494
|
+
}))
|
|
495
|
+
})
|
|
496
|
+
})
|
|
497
|
+
//# sourceMappingURL=order-api.spec.js.map
|