@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.
Files changed (196) hide show
  1. package/api/fusion-api.d.ts +25 -16
  2. package/api/fusion-api.js +36 -26
  3. package/api/index.d.ts +4 -4
  4. package/api/index.js +8 -8
  5. package/api/orders/index.d.ts +3 -3
  6. package/api/orders/index.js +7 -7
  7. package/api/orders/order-api.spec.d.ts +1 -1
  8. package/api/orders/order-api.spec.js +479 -395
  9. package/api/orders/order-api.spec.js.map +1 -1
  10. package/api/orders/orders.api.d.ts +24 -10
  11. package/api/orders/orders.api.js +30 -28
  12. package/api/orders/orders.request.d.ts +22 -18
  13. package/api/orders/orders.request.js +40 -31
  14. package/api/orders/types.d.ts +59 -57
  15. package/api/orders/types.js +17 -16
  16. package/api/orders/types.js.map +1 -1
  17. package/api/pagination.d.ts +7 -7
  18. package/api/pagination.js +10 -10
  19. package/api/pagination.spec.d.ts +1 -1
  20. package/api/pagination.spec.js +28 -21
  21. package/api/params.d.ts +3 -1
  22. package/api/params.js +25 -19
  23. package/api/quoter/index.d.ts +5 -5
  24. package/api/quoter/index.js +9 -9
  25. package/api/quoter/preset.d.ts +13 -13
  26. package/api/quoter/preset.js +19 -17
  27. package/api/quoter/quote/index.d.ts +3 -3
  28. package/api/quoter/quote/index.js +7 -7
  29. package/api/quoter/quote/order-params.d.ts +6 -6
  30. package/api/quoter/quote/order-params.js +12 -12
  31. package/api/quoter/quote/quote.d.ts +26 -21
  32. package/api/quoter/quote/quote.js +85 -52
  33. package/api/quoter/quote/quote.js.map +1 -1
  34. package/api/quoter/quote/types.d.ts +4 -4
  35. package/api/quoter/quote/types.js +3 -3
  36. package/api/quoter/quoter.api.d.ts +12 -9
  37. package/api/quoter/quoter.api.js +19 -19
  38. package/api/quoter/quoter.api.spec.d.ts +1 -1
  39. package/api/quoter/quoter.api.spec.js +32 -23
  40. package/api/quoter/quoter.api.spec.js.map +1 -1
  41. package/api/quoter/quoter.request.d.ts +11 -11
  42. package/api/quoter/quoter.request.js +28 -26
  43. package/api/quoter/types.d.ts +45 -44
  44. package/api/quoter/types.js +10 -10
  45. package/api/quoter/types.js.map +1 -1
  46. package/api/relayer/index.d.ts +3 -3
  47. package/api/relayer/index.js +7 -7
  48. package/api/relayer/relayer.api.d.ts +12 -9
  49. package/api/relayer/relayer.api.js +13 -13
  50. package/api/relayer/relayer.api.spec.d.ts +1 -1
  51. package/api/relayer/relayer.api.spec.js +96 -79
  52. package/api/relayer/relayer.request.d.ts +8 -8
  53. package/api/relayer/relayer.request.js +10 -10
  54. package/api/relayer/types.d.ts +9 -9
  55. package/api/relayer/types.js +3 -3
  56. package/api/types.d.ts +17 -15
  57. package/api/types.js +3 -3
  58. package/auction-calculator/auction-calculator.d.ts +22 -13
  59. package/auction-calculator/auction-calculator.js +70 -45
  60. package/auction-calculator/auction-calculator.spec.d.ts +1 -1
  61. package/auction-calculator/auction-calculator.spec.js +45 -32
  62. package/auction-calculator/calc.d.ts +8 -2
  63. package/auction-calculator/calc.js +12 -12
  64. package/auction-calculator/constants.d.ts +1 -1
  65. package/auction-calculator/constants.js +5 -5
  66. package/auction-calculator/index.d.ts +3 -3
  67. package/auction-calculator/index.js +7 -7
  68. package/auction-salt/auction-salt.d.ts +9 -9
  69. package/auction-salt/auction-salt.js +34 -23
  70. package/auction-salt/auction.salt.spec.d.ts +1 -1
  71. package/auction-salt/auction.salt.spec.js +38 -27
  72. package/auction-salt/index.d.ts +3 -3
  73. package/auction-salt/index.js +7 -7
  74. package/auction-salt/parser/constants.d.ts +9 -9
  75. package/auction-salt/parser/constants.js +33 -14
  76. package/auction-salt/parser/index.d.ts +2 -2
  77. package/auction-salt/parser/index.js +6 -6
  78. package/auction-salt/parser/parser.d.ts +6 -6
  79. package/auction-salt/parser/parser.js +33 -22
  80. package/auction-salt/types.d.ts +6 -6
  81. package/auction-salt/types.js +3 -3
  82. package/auction-suffix/auction-suffix.d.ts +9 -9
  83. package/auction-suffix/auction-suffix.js +36 -23
  84. package/auction-suffix/auction-suffix.spec.d.ts +1 -1
  85. package/auction-suffix/auction-suffix.spec.js +20 -15
  86. package/auction-suffix/constants.d.ts +1 -1
  87. package/auction-suffix/constants.js +5 -5
  88. package/auction-suffix/encoder.d.ts +15 -6
  89. package/auction-suffix/encoder.js +45 -28
  90. package/auction-suffix/index.d.ts +5 -5
  91. package/auction-suffix/index.js +9 -9
  92. package/auction-suffix/parser/constants.d.ts +13 -13
  93. package/auction-suffix/parser/constants.js +30 -17
  94. package/auction-suffix/parser/errors.d.ts +1 -2
  95. package/auction-suffix/parser/errors.js +6 -7
  96. package/auction-suffix/parser/index.d.ts +4 -4
  97. package/auction-suffix/parser/index.js +8 -8
  98. package/auction-suffix/parser/parser.d.ts +28 -8
  99. package/auction-suffix/parser/parser.js +162 -81
  100. package/auction-suffix/parser/types.d.ts +22 -22
  101. package/auction-suffix/parser/types.js +3 -3
  102. package/auction-suffix/types.d.ts +12 -12
  103. package/auction-suffix/types.js +3 -3
  104. package/connector/blockchain/blockchain-provider.connector.d.ts +6 -3
  105. package/connector/blockchain/blockchain-provider.connector.js +3 -3
  106. package/connector/blockchain/index.d.ts +3 -3
  107. package/connector/blockchain/index.js +7 -7
  108. package/connector/blockchain/private-key-provider.connector.d.ts +15 -10
  109. package/connector/blockchain/private-key-provider.connector.js +12 -12
  110. package/connector/blockchain/private-key-provider.connector.spec.d.ts +1 -1
  111. package/connector/blockchain/private-key-provider.connector.spec.js +36 -23
  112. package/connector/blockchain/web3-provider-connector.d.ts +13 -8
  113. package/connector/blockchain/web3-provider-connector.js +12 -9
  114. package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -1
  115. package/connector/blockchain/web3-provider.connector.spec.js +37 -26
  116. package/connector/http/axios-provider.connector.d.ts +3 -3
  117. package/connector/http/axios-provider.connector.js +13 -13
  118. package/connector/http/axios-provider.connector.spec.d.ts +1 -1
  119. package/connector/http/axios-provider.connector.spec.js +37 -31
  120. package/connector/http/http-provider.connector.d.ts +2 -2
  121. package/connector/http/http-provider.connector.js +3 -3
  122. package/connector/http/index.d.ts +2 -2
  123. package/connector/http/index.js +6 -6
  124. package/connector/index.d.ts +2 -2
  125. package/connector/index.js +6 -6
  126. package/constants.d.ts +10 -6
  127. package/constants.js +23 -16
  128. package/fusion-order/fusion-order.d.ts +17 -7
  129. package/fusion-order/fusion-order.js +14 -12
  130. package/fusion-order/fusion-order.spec.d.ts +1 -1
  131. package/fusion-order/fusion-order.spec.js +27 -22
  132. package/fusion-order/index.d.ts +1 -1
  133. package/fusion-order/index.js +5 -5
  134. package/index.d.ts +11 -11
  135. package/index.js +15 -15
  136. package/limit-order/eip712/domain.d.ts +10 -9
  137. package/limit-order/eip712/domain.js +28 -23
  138. package/limit-order/eip712/eip712.types.d.ts +19 -15
  139. package/limit-order/eip712/eip712.types.js +3 -3
  140. package/limit-order/eip712/index.d.ts +3 -3
  141. package/limit-order/eip712/index.js +7 -7
  142. package/limit-order/eip712/order-typed-data-builder.d.ts +17 -6
  143. package/limit-order/eip712/order-typed-data-builder.js +34 -19
  144. package/limit-order/index.d.ts +4 -4
  145. package/limit-order/index.js +8 -8
  146. package/limit-order/interactions-factory.d.ts +1 -1
  147. package/limit-order/interactions-factory.js +6 -6
  148. package/limit-order/limit-order.d.ts +31 -25
  149. package/limit-order/limit-order.js +103 -50
  150. package/limit-order/limit-order.spec.d.ts +1 -1
  151. package/limit-order/limit-order.spec.js +75 -51
  152. package/limit-order/parser/constants.d.ts +9 -9
  153. package/limit-order/parser/constants.js +5 -5
  154. package/limit-order/parser/index.d.ts +3 -3
  155. package/limit-order/parser/index.js +7 -7
  156. package/limit-order/parser/parser.d.ts +5 -2
  157. package/limit-order/parser/parser.js +23 -18
  158. package/limit-order/parser/types.d.ts +3 -3
  159. package/limit-order/parser/types.js +3 -3
  160. package/limit-order/predicate-factory.d.ts +9 -5
  161. package/limit-order/predicate-factory.js +40 -24
  162. package/limit-order/predicate-factory.spec.d.ts +1 -1
  163. package/limit-order/predicate-factory.spec.js +44 -29
  164. package/limit-order/types.d.ts +29 -29
  165. package/limit-order/types.js +3 -3
  166. package/limit-order/utils.d.ts +1 -1
  167. package/limit-order/utils.js +6 -6
  168. package/package.json +1 -1
  169. package/sdk/index.d.ts +2 -2
  170. package/sdk/index.js +6 -6
  171. package/sdk/sdk.d.ts +29 -11
  172. package/sdk/sdk.js +48 -38
  173. package/sdk/types.d.ts +27 -27
  174. package/sdk/types.js +3 -3
  175. package/settlement/encoders/constants.d.ts +1 -1
  176. package/settlement/encoders/constants.js +5 -5
  177. package/settlement/encoders/fill-order.encoder.d.ts +2 -2
  178. package/settlement/encoders/fill-order.encoder.js +26 -12
  179. package/settlement/encoders/index.d.ts +3 -3
  180. package/settlement/encoders/index.js +7 -7
  181. package/settlement/encoders/settlement.encoder.d.ts +13 -4
  182. package/settlement/encoders/settlement.encoder.js +41 -19
  183. package/settlement/index.d.ts +4 -4
  184. package/settlement/index.js +8 -8
  185. package/settlement/settlement.d.ts +8 -5
  186. package/settlement/settlement.js +28 -14
  187. package/settlement/settlement.spec.d.ts +1 -1
  188. package/settlement/settlement.spec.js +45 -35
  189. package/settlement/signature-patcher.d.ts +1 -1
  190. package/settlement/signature-patcher.js +19 -16
  191. package/settlement/types.d.ts +13 -13
  192. package/settlement/types.js +3 -3
  193. package/utils.d.ts +6 -6
  194. package/utils.js +29 -23
  195. package/validations.d.ts +2 -2
  196. package/validations.js +14 -15
@@ -1,413 +1,497 @@
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");
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', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
20
- const expected = {
21
- items: [
22
- {
23
- orderHash: '0xe07193d683bb70f7c9a45001b863dd9058146849bdd47951b6d0ed13b1fd8396',
24
- signature: '0x21ef770f9bedbb97542033bd3b1a2ad611917567102545c93ce66668b8524b7c609bead7829113e104be41fbbd14fea027c85bc4668214b81d52f02c2f9010551b',
25
- deadline: '2023-01-31T11:01:02.000Z',
26
- auctionStartDate: '2023-01-31T10:58:02.000Z',
27
- auctionEndDate: '2023-01-31T11:01:02.000Z',
28
- order: {
29
- salt: '45162296565521316310143660684688589556990590668045350709106347387233721386087',
30
- maker: '0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1',
31
- offsets: '2048955946929424286921227713067743020696385405755235979139736848564224',
32
- receiver: '0x08b067ad41e45babe5bbb52fc2fe7f692f628b06',
33
- makerAsset: '0xe68a2c0eef74b5d8d2975bbf7a681226e4d7473c',
34
- takerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
35
- interactions: '0x63592c2b0000000000000000000000000000000000000000000000000000000063d8f4ee08b067ad41e45babe5bbb52fc2fe7f692f628b06315b47a8c3780434b153667588db4ca628526e20006c00c26a001800c44c63d8f41684d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f416cfa62f77920d6383be12c91c71bd403599e1116ff486570012',
36
- makingAmount: '57684207067582695',
37
- takingAmount: '116032349855081688885',
38
- allowedSender: '0xa88800cd213da5ae406ce248380802bd53b47647'
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
- orderHash: '0xc359131e97c4cd1e01e1cd0ddeb16dd636c34fb294f53fd2f3e3ce8cb1c8482e',
43
- signature: '0x986c196d603d9c07faa1a5d3167a008a21850d5d9922da8a0f7e48225fdfd4a27f477d16f5078b5fad68205685a0a0dce40ac337a6f4376996e37f95e66a1a921b',
44
- deadline: '2023-01-31T11:01:06.000Z',
45
- auctionStartDate: '2023-01-31T10:58:11.000Z',
46
- auctionEndDate: '2023-01-31T11:01:11.000Z',
47
- order: {
48
- salt: '45162296808160836322731793320280672051161012167252717657723413939965365979370',
49
- maker: '0xe2b43fbd64f4bb4dc99a8d48ad41cfab90621567',
50
- offsets: '970558080243398695134547109586957793750899628853613079895592438595584',
51
- receiver: '0x0000000000000000000000000000000000000000',
52
- makerAsset: '0x2e85ae1c47602f7927bcabc2ff99c40aa222ae15',
53
- takerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
54
- interactions: '0x2cc2878d000063d8f4f2000000000000e2b43fbd64f4bb4dc99a8d48ad41cfab906215670000000084d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f475cfa62f77920d6383be12c91c71bd403599e1116fffffffff10',
55
- makingAmount: '470444951856649710700841',
56
- takingAmount: '363417063831796476',
57
- allowedSender: '0xa88800cd213da5ae406ce248380802bd53b47647'
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
- const url = 'https://test.com';
69
- const httpProvider = createHttpProviderFake(expected);
70
- const sdk = new sdk_1.FusionSDK({
71
- url,
72
- network: constants_1.NetworkEnum.ETHEREUM,
73
- httpProvider
74
- });
75
- const response = yield sdk.getActiveOrders({ page: 1, limit: 2 });
76
- expect(response).toEqual(expected);
77
- expect(httpProvider.get).toHaveBeenLastCalledWith(`${url}/orders/v1.0/1/order/active/?page=1&limit=2`);
78
- }));
79
- it('passes without providing args', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
80
- const expected = {
81
- items: [
82
- {
83
- orderHash: '0xe07193d683bb70f7c9a45001b863dd9058146849bdd47951b6d0ed13b1fd8396',
84
- signature: '0x21ef770f9bedbb97542033bd3b1a2ad611917567102545c93ce66668b8524b7c609bead7829113e104be41fbbd14fea027c85bc4668214b81d52f02c2f9010551b',
85
- deadline: '2023-01-31T11:01:02.000Z',
86
- auctionStartDate: '2023-01-31T10:58:02.000Z',
87
- auctionEndDate: '2023-01-31T11:01:02.000Z',
88
- order: {
89
- salt: '45162296565521316310143660684688589556990590668045350709106347387233721386087',
90
- maker: '0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1',
91
- offsets: '2048955946929424286921227713067743020696385405755235979139736848564224',
92
- receiver: '0x08b067ad41e45babe5bbb52fc2fe7f692f628b06',
93
- makerAsset: '0xe68a2c0eef74b5d8d2975bbf7a681226e4d7473c',
94
- takerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
95
- interactions: '0x63592c2b0000000000000000000000000000000000000000000000000000000063d8f4ee08b067ad41e45babe5bbb52fc2fe7f692f628b06315b47a8c3780434b153667588db4ca628526e20006c00c26a001800c44c63d8f41684d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f416cfa62f77920d6383be12c91c71bd403599e1116ff486570012',
96
- makingAmount: '57684207067582695',
97
- takingAmount: '116032349855081688885',
98
- allowedSender: '0xa88800cd213da5ae406ce248380802bd53b47647'
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
- orderHash: '0xc359131e97c4cd1e01e1cd0ddeb16dd636c34fb294f53fd2f3e3ce8cb1c8482e',
103
- signature: '0x986c196d603d9c07faa1a5d3167a008a21850d5d9922da8a0f7e48225fdfd4a27f477d16f5078b5fad68205685a0a0dce40ac337a6f4376996e37f95e66a1a921b',
104
- deadline: '2023-01-31T11:01:06.000Z',
105
- auctionStartDate: '2023-01-31T10:58:11.000Z',
106
- auctionEndDate: '2023-01-31T11:01:11.000Z',
107
- order: {
108
- salt: '45162296808160836322731793320280672051161012167252717657723413939965365979370',
109
- maker: '0xe2b43fbd64f4bb4dc99a8d48ad41cfab90621567',
110
- offsets: '970558080243398695134547109586957793750899628853613079895592438595584',
111
- receiver: '0x0000000000000000000000000000000000000000',
112
- makerAsset: '0x2e85ae1c47602f7927bcabc2ff99c40aa222ae15',
113
- takerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
114
- interactions: '0x2cc2878d000063d8f4f2000000000000e2b43fbd64f4bb4dc99a8d48ad41cfab906215670000000084d99aa569d93a9ca187d83734c8c4a519c4e9b163d8f475cfa62f77920d6383be12c91c71bd403599e1116fffffffff10',
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
- const url = 'https://test.com';
129
- const httpProvider = createHttpProviderFake(expected);
130
- const sdk = new sdk_1.FusionSDK({
131
- url,
132
- network: constants_1.NetworkEnum.ETHEREUM,
133
- httpProvider
134
- });
135
- const response = yield sdk.getActiveOrders();
136
- expect(response).toEqual(expected);
137
- expect(httpProvider.get).toHaveBeenLastCalledWith(`${url}/orders/v1.0/1/order/active/?`);
138
- }));
139
- });
140
- describe('getOrderStatus', () => {
141
- it('success', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
142
- const url = 'https://test.com';
143
- const expected = {
144
- order: {
145
- salt: '45144194282371711345892930501725766861375817078109214409479816083205610767025',
146
- maker: '0x6f250c769001617aff9bdf4b9fd878062e94af83',
147
- offsets: '970558080243398695134547109586957793750899628853613079895592438595584',
148
- receiver: '0x0000000000000000000000000000000000000000',
149
- makerAsset: '0x6eb15148d0ea88433dd8088a3acc515d27e36c1b',
150
- takerAsset: '0xdac17f958d2ee523a2206206994597c13d831ec7',
151
- interactions: '0x2cc2878d000063ceb60f0000000000006f250c769001617aff9bdf4b9fd878062e94af83006c00c2fe001800c44c0000000084d99aa569d93a9ca187d83734c8c4a519c4e9b1ffffffff0a',
152
- makingAmount: '2246481050155000',
153
- takingAmount: '349837736598',
154
- allowedSender: '0xa88800cd213da5ae406ce248380802bd53b47647'
155
- },
156
- cancelTx: null,
157
- points: null,
158
- auctionStartDate: 1674491231,
159
- auctionDuration: 180,
160
- initialRateBump: 50484,
161
- status: 'filled',
162
- createdAt: '2023-01-23T16:26:38.803Z',
163
- fromTokenToUsdPrice: '0.01546652159249409068',
164
- toTokenToUsdPrice: '1.00135361305236370022',
165
- fills: [
166
- {
167
- txHash: '0xcdd81e6860fc038d4fe8549efdf18488154667a2088d471cdaa7d492f24178a1',
168
- filledMakerAmount: '2246481050155001',
169
- filledAuctionTakerAmount: '351593117428'
170
- }
171
- ],
172
- isNativeCurrency: false
173
- };
174
- const httpProvider = createHttpProviderFake(expected);
175
- const sdk = new sdk_1.FusionSDK({
176
- url,
177
- network: constants_1.NetworkEnum.ETHEREUM,
178
- httpProvider
179
- });
180
- const orderHash = `0x1beee023ab933cf5446c298eadadb61c05705f2156ef5b2db36c160b36f31ce4`;
181
- const response = yield sdk.getOrderStatus(orderHash);
182
- expect(response).toEqual(expected);
183
- expect(httpProvider.get).toHaveBeenLastCalledWith(`${url}/orders/v1.0/1/order/status/${orderHash}`);
184
- }));
185
- it('throws an error when the string is not hexadecimal', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
186
- const url = 'https://test.com';
187
- const expected = {
188
- order: {
189
- salt: '45144194282371711345892930501725766861375817078109214409479816083205610767025',
190
- maker: '0x6f250c769001617aff9bdf4b9fd878062e94af83',
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', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
274
- const url = 'https://test.com';
275
- const expected = {
276
- meta: {
277
- totalItems: 247,
278
- currentPage: 1,
279
- itemsPerPage: 1,
280
- totalPages: 247
281
- },
282
- items: [
283
- {
284
- orderHash: '0xe8c38b4ef9c96c12290709be98f5b6cb932233ad767137ee7506aa71687c960e',
285
- status: 'filled',
286
- makerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
287
- takerAsset: '0x111111111117dc0aa78b770fa6a738034120c302',
288
- makerAmount: '351336830606',
289
- fills: [
290
- {
291
- txHash: '0x3e049a432a426e73a22b5ee19327bbfb0706c34b48eba68ff114ccfb215b5bae',
292
- filledMakerAmount: '351336830606',
293
- filledAuctionTakerAmount: '895661510910730845524061'
294
- }
295
- ],
296
- points: null,
297
- cancelTx: null,
298
- isNativeCurrency: false,
299
- auctionStartDate: 1672989075,
300
- auctionDuration: 180,
301
- initialRateBump: 50515
302
- }
303
- ]
304
- };
305
- const httpProvider = createHttpProviderFake(expected);
306
- const sdk = new sdk_1.FusionSDK({
307
- url,
308
- network: constants_1.NetworkEnum.ETHEREUM,
309
- httpProvider
310
- });
311
- const address = '0xfa80cd9b3becc0b4403b0f421384724f2810775f';
312
- const response = yield sdk.getOrdersByMaker({
313
- address,
314
- limit: 1,
315
- page: 1
316
- });
317
- expect(response).toEqual(expected);
318
- expect(httpProvider.get).toHaveBeenLastCalledWith(`${url}/orders/v1.0/1/order/maker/${address}/?limit=1&page=1`);
319
- }));
320
- it('handles the case when no pagination params was passed', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
321
- const url = 'https://test.com';
322
- const expected = {
323
- meta: {
324
- totalItems: 247,
325
- currentPage: 1,
326
- itemsPerPage: 1,
327
- totalPages: 247
328
- },
329
- items: [
330
- {
331
- orderHash: '0xe8c38b4ef9c96c12290709be98f5b6cb932233ad767137ee7506aa71687c960e',
332
- status: 'filled',
333
- makerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
334
- takerAsset: '0x111111111117dc0aa78b770fa6a738034120c302',
335
- makerAmount: '351336830606',
336
- fills: [
337
- {
338
- txHash: '0x3e049a432a426e73a22b5ee19327bbfb0706c34b48eba68ff114ccfb215b5bae',
339
- filledMakerAmount: '351336830606',
340
- filledAuctionTakerAmount: '895661510910730845524061'
341
- }
342
- ],
343
- points: null,
344
- cancelTx: null,
345
- isNativeCurrency: false,
346
- auctionStartDate: 1672989075,
347
- auctionDuration: 180,
348
- initialRateBump: 50515
349
- }
350
- ]
351
- };
352
- const httpProvider = createHttpProviderFake(expected);
353
- const sdk = new sdk_1.FusionSDK({
354
- url,
355
- network: constants_1.NetworkEnum.ETHEREUM,
356
- httpProvider
357
- });
358
- const address = '0xfa80cd9b3becc0b4403b0f421384724f2810775f';
359
- const response = yield sdk.getOrdersByMaker({
360
- address
361
- });
362
- expect(response).toEqual(expected);
363
- expect(httpProvider.get).toHaveBeenLastCalledWith(`${url}/orders/v1.0/1/order/maker/${address}/?`);
364
- }));
365
- it('throws an error with invalid address', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
366
- const url = 'https://test.com';
367
- const expected = {
368
- meta: {
369
- totalItems: 247,
370
- currentPage: 1,
371
- itemsPerPage: 1,
372
- totalPages: 247
373
- },
374
- items: [
375
- {
376
- orderHash: '0xe8c38b4ef9c96c12290709be98f5b6cb932233ad767137ee7506aa71687c960e',
377
- status: 'filled',
378
- makerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
379
- takerAsset: '0x111111111117dc0aa78b770fa6a738034120c302',
380
- makerAmount: '351336830606',
381
- fills: [
382
- {
383
- txHash: '0x3e049a432a426e73a22b5ee19327bbfb0706c34b48eba68ff114ccfb215b5bae',
384
- filledMakerAmount: '351336830606',
385
- filledAuctionTakerAmount: '895661510910730845524061'
386
- }
387
- ],
388
- points: null,
389
- cancelTx: null,
390
- isNativeCurrency: false,
391
- auctionStartDate: 1672989075,
392
- auctionDuration: 180,
393
- initialRateBump: 50515
394
- }
395
- ]
396
- };
397
- const httpProvider = createHttpProviderFake(expected);
398
- const sdk = new sdk_1.FusionSDK({
399
- url,
400
- network: constants_1.NetworkEnum.ETHEREUM,
401
- httpProvider
402
- });
403
- const address = '0xfa80cd9b3becc0b4403b0f42138472ewewewewewewew2810775f';
404
- const promise = sdk.getOrdersByMaker({
405
- address,
406
- limit: 1,
407
- page: 1
408
- });
409
- yield expect(promise).rejects.toThrow(/is invalid address/);
410
- }));
411
- });
412
- });
413
- //# sourceMappingURL=order-api.spec.js.map
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