@1inch/fusion-sdk 0.0.6 → 0.0.8

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