@allbridge/bridge-core-sdk 3.27.0-beta.1 → 3.27.0-beta.3

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 (56) hide show
  1. package/dist/browser/index.js +2 -2
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/esm/index.js +2 -2
  6. package/dist/esm/index.js.map +4 -4
  7. package/dist/src/client/core-api/api-client.js +1 -0
  8. package/dist/src/client/core-api/api-client.js.map +1 -1
  9. package/dist/src/client/core-api/core-api-mapper.js +31 -0
  10. package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
  11. package/dist/src/client/core-api/core-api.model.d.ts +12 -2
  12. package/dist/src/client/core-api/core-api.model.js.map +1 -1
  13. package/dist/src/index.d.ts +6 -0
  14. package/dist/src/index.js +6 -0
  15. package/dist/src/index.js.map +1 -1
  16. package/dist/src/models/index.d.ts +12 -4
  17. package/dist/src/models/index.js +4 -0
  18. package/dist/src/models/index.js.map +1 -1
  19. package/dist/src/services/bridge/alg/index.js +52 -43
  20. package/dist/src/services/bridge/alg/index.js.map +1 -1
  21. package/dist/src/services/bridge/evm/index.d.ts +1 -0
  22. package/dist/src/services/bridge/evm/index.js +103 -33
  23. package/dist/src/services/bridge/evm/index.js.map +1 -1
  24. package/dist/src/services/bridge/index.d.ts +2 -2
  25. package/dist/src/services/bridge/index.js +10 -4
  26. package/dist/src/services/bridge/index.js.map +1 -1
  27. package/dist/src/services/bridge/models/bridge.model.d.ts +11 -4
  28. package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
  29. package/dist/src/services/bridge/raw-bridge-transaction-builder.js +1 -1
  30. package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
  31. package/dist/src/services/bridge/srb/index.js +36 -28
  32. package/dist/src/services/bridge/srb/index.js.map +1 -1
  33. package/dist/src/services/bridge/stx/index.js +23 -14
  34. package/dist/src/services/bridge/stx/index.js.map +1 -1
  35. package/dist/src/services/bridge/sui/index.js +166 -138
  36. package/dist/src/services/bridge/sui/index.js.map +1 -1
  37. package/dist/src/services/bridge/trx/index.js +98 -70
  38. package/dist/src/services/bridge/trx/index.js.map +1 -1
  39. package/dist/src/services/bridge/utils.js +69 -8
  40. package/dist/src/services/bridge/utils.js.map +1 -1
  41. package/dist/src/services/models/abi/PayerWithAbr.d.ts +203 -0
  42. package/dist/src/services/models/abi/PayerWithAbr.js +266 -0
  43. package/dist/src/services/models/abi/PayerWithAbr.js.map +1 -0
  44. package/dist/src/services/token/index.js +2 -2
  45. package/dist/src/services/token/index.js.map +1 -1
  46. package/dist/src/services/token/models/token.model.d.ts +4 -4
  47. package/dist/src/services/token/models/token.model.js.map +1 -1
  48. package/dist/src/tokens-info/tokens-info.model.d.ts +17 -0
  49. package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
  50. package/dist/src/utils/utils.d.ts +2 -0
  51. package/dist/src/utils/utils.js +11 -0
  52. package/dist/src/utils/utils.js.map +1 -1
  53. package/dist/src/version.d.ts +1 -1
  54. package/dist/src/version.js +1 -1
  55. package/dist/src/version.js.map +1 -1
  56. package/package.json +1 -1
@@ -0,0 +1,203 @@
1
+ declare const artifact: {
2
+ readonly abi: readonly [{
3
+ readonly inputs: readonly [{
4
+ readonly internalType: "address";
5
+ readonly name: "_abrTokenAddress";
6
+ readonly type: "address";
7
+ }, {
8
+ readonly internalType: "uint256";
9
+ readonly name: "_chainPrecision";
10
+ readonly type: "uint256";
11
+ }];
12
+ readonly stateMutability: "nonpayable";
13
+ readonly type: "constructor";
14
+ }, {
15
+ readonly anonymous: false;
16
+ readonly inputs: readonly [{
17
+ readonly indexed: true;
18
+ readonly internalType: "address";
19
+ readonly name: "previousOwner";
20
+ readonly type: "address";
21
+ }, {
22
+ readonly indexed: true;
23
+ readonly internalType: "address";
24
+ readonly name: "newOwner";
25
+ readonly type: "address";
26
+ }];
27
+ readonly name: "OwnershipTransferred";
28
+ readonly type: "event";
29
+ }, {
30
+ readonly stateMutability: "payable";
31
+ readonly type: "fallback";
32
+ }, {
33
+ readonly inputs: readonly [];
34
+ readonly name: "abrToken";
35
+ readonly outputs: readonly [{
36
+ readonly internalType: "contract IERC20Metadata";
37
+ readonly name: "";
38
+ readonly type: "address";
39
+ }];
40
+ readonly stateMutability: "view";
41
+ readonly type: "function";
42
+ }, {
43
+ readonly inputs: readonly [{
44
+ readonly internalType: "address";
45
+ readonly name: "_tokenAddress";
46
+ readonly type: "address";
47
+ }, {
48
+ readonly internalType: "address";
49
+ readonly name: "_bridge";
50
+ readonly type: "address";
51
+ }];
52
+ readonly name: "approveBridgeToken";
53
+ readonly outputs: readonly [];
54
+ readonly stateMutability: "nonpayable";
55
+ readonly type: "function";
56
+ }, {
57
+ readonly inputs: readonly [];
58
+ readonly name: "exchangeRate";
59
+ readonly outputs: readonly [{
60
+ readonly internalType: "uint256";
61
+ readonly name: "";
62
+ readonly type: "uint256";
63
+ }];
64
+ readonly stateMutability: "view";
65
+ readonly type: "function";
66
+ }, {
67
+ readonly inputs: readonly [{
68
+ readonly internalType: "uint256";
69
+ readonly name: "_amount";
70
+ readonly type: "uint256";
71
+ }];
72
+ readonly name: "nativeTokensToAbr";
73
+ readonly outputs: readonly [{
74
+ readonly internalType: "uint256";
75
+ readonly name: "";
76
+ readonly type: "uint256";
77
+ }];
78
+ readonly stateMutability: "view";
79
+ readonly type: "function";
80
+ }, {
81
+ readonly inputs: readonly [];
82
+ readonly name: "owner";
83
+ readonly outputs: readonly [{
84
+ readonly internalType: "address";
85
+ readonly name: "";
86
+ readonly type: "address";
87
+ }];
88
+ readonly stateMutability: "view";
89
+ readonly type: "function";
90
+ }, {
91
+ readonly inputs: readonly [{
92
+ readonly internalType: "uint256";
93
+ readonly name: "_id";
94
+ readonly type: "uint256";
95
+ }, {
96
+ readonly internalType: "address";
97
+ readonly name: "_target";
98
+ readonly type: "address";
99
+ }, {
100
+ readonly internalType: "string";
101
+ readonly name: "_signature";
102
+ readonly type: "string";
103
+ }];
104
+ readonly name: "registerTarget";
105
+ readonly outputs: readonly [];
106
+ readonly stateMutability: "nonpayable";
107
+ readonly type: "function";
108
+ }, {
109
+ readonly inputs: readonly [];
110
+ readonly name: "renounceOwnership";
111
+ readonly outputs: readonly [];
112
+ readonly stateMutability: "nonpayable";
113
+ readonly type: "function";
114
+ }, {
115
+ readonly inputs: readonly [{
116
+ readonly internalType: "uint256";
117
+ readonly name: "_newExchangeRate";
118
+ readonly type: "uint256";
119
+ }];
120
+ readonly name: "setExchangeRate";
121
+ readonly outputs: readonly [];
122
+ readonly stateMutability: "nonpayable";
123
+ readonly type: "function";
124
+ }, {
125
+ readonly inputs: readonly [{
126
+ readonly internalType: "uint256";
127
+ readonly name: "id";
128
+ readonly type: "uint256";
129
+ }];
130
+ readonly name: "targets";
131
+ readonly outputs: readonly [{
132
+ readonly internalType: "address";
133
+ readonly name: "target";
134
+ readonly type: "address";
135
+ }, {
136
+ readonly internalType: "bytes4";
137
+ readonly name: "selector";
138
+ readonly type: "bytes4";
139
+ }];
140
+ readonly stateMutability: "view";
141
+ readonly type: "function";
142
+ }, {
143
+ readonly inputs: readonly [{
144
+ readonly internalType: "address";
145
+ readonly name: "newOwner";
146
+ readonly type: "address";
147
+ }];
148
+ readonly name: "transferOwnership";
149
+ readonly outputs: readonly [];
150
+ readonly stateMutability: "nonpayable";
151
+ readonly type: "function";
152
+ }, {
153
+ readonly inputs: readonly [{
154
+ readonly internalType: "address";
155
+ readonly name: "_token";
156
+ readonly type: "address";
157
+ }, {
158
+ readonly internalType: "uint256";
159
+ readonly name: "_amount";
160
+ readonly type: "uint256";
161
+ }, {
162
+ readonly internalType: "uint256";
163
+ readonly name: "_abrAmount";
164
+ readonly type: "uint256";
165
+ }, {
166
+ readonly internalType: "uint256";
167
+ readonly name: "_targetId";
168
+ readonly type: "uint256";
169
+ }, {
170
+ readonly internalType: "bytes";
171
+ readonly name: "_params";
172
+ readonly type: "bytes";
173
+ }];
174
+ readonly name: "transferTokensAndCallTarget";
175
+ readonly outputs: readonly [];
176
+ readonly stateMutability: "payable";
177
+ readonly type: "function";
178
+ }, {
179
+ readonly inputs: readonly [{
180
+ readonly internalType: "uint256";
181
+ readonly name: "amount";
182
+ readonly type: "uint256";
183
+ }];
184
+ readonly name: "withdrawGas";
185
+ readonly outputs: readonly [];
186
+ readonly stateMutability: "nonpayable";
187
+ readonly type: "function";
188
+ }, {
189
+ readonly inputs: readonly [{
190
+ readonly internalType: "address";
191
+ readonly name: "tokenAddress";
192
+ readonly type: "address";
193
+ }];
194
+ readonly name: "withdrawTokens";
195
+ readonly outputs: readonly [];
196
+ readonly stateMutability: "nonpayable";
197
+ readonly type: "function";
198
+ }, {
199
+ readonly stateMutability: "payable";
200
+ readonly type: "receive";
201
+ }];
202
+ };
203
+ export default artifact;
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const artifact = {
4
+ abi: [
5
+ {
6
+ inputs: [
7
+ {
8
+ internalType: "address",
9
+ name: "_abrTokenAddress",
10
+ type: "address",
11
+ },
12
+ {
13
+ internalType: "uint256",
14
+ name: "_chainPrecision",
15
+ type: "uint256",
16
+ },
17
+ ],
18
+ stateMutability: "nonpayable",
19
+ type: "constructor",
20
+ },
21
+ {
22
+ anonymous: false,
23
+ inputs: [
24
+ {
25
+ indexed: true,
26
+ internalType: "address",
27
+ name: "previousOwner",
28
+ type: "address",
29
+ },
30
+ {
31
+ indexed: true,
32
+ internalType: "address",
33
+ name: "newOwner",
34
+ type: "address",
35
+ },
36
+ ],
37
+ name: "OwnershipTransferred",
38
+ type: "event",
39
+ },
40
+ {
41
+ stateMutability: "payable",
42
+ type: "fallback",
43
+ },
44
+ {
45
+ inputs: [],
46
+ name: "abrToken",
47
+ outputs: [
48
+ {
49
+ internalType: "contract IERC20Metadata",
50
+ name: "",
51
+ type: "address",
52
+ },
53
+ ],
54
+ stateMutability: "view",
55
+ type: "function",
56
+ },
57
+ {
58
+ inputs: [
59
+ {
60
+ internalType: "address",
61
+ name: "_tokenAddress",
62
+ type: "address",
63
+ },
64
+ {
65
+ internalType: "address",
66
+ name: "_bridge",
67
+ type: "address",
68
+ },
69
+ ],
70
+ name: "approveBridgeToken",
71
+ outputs: [],
72
+ stateMutability: "nonpayable",
73
+ type: "function",
74
+ },
75
+ {
76
+ inputs: [],
77
+ name: "exchangeRate",
78
+ outputs: [
79
+ {
80
+ internalType: "uint256",
81
+ name: "",
82
+ type: "uint256",
83
+ },
84
+ ],
85
+ stateMutability: "view",
86
+ type: "function",
87
+ },
88
+ {
89
+ inputs: [
90
+ {
91
+ internalType: "uint256",
92
+ name: "_amount",
93
+ type: "uint256",
94
+ },
95
+ ],
96
+ name: "nativeTokensToAbr",
97
+ outputs: [
98
+ {
99
+ internalType: "uint256",
100
+ name: "",
101
+ type: "uint256",
102
+ },
103
+ ],
104
+ stateMutability: "view",
105
+ type: "function",
106
+ },
107
+ {
108
+ inputs: [],
109
+ name: "owner",
110
+ outputs: [
111
+ {
112
+ internalType: "address",
113
+ name: "",
114
+ type: "address",
115
+ },
116
+ ],
117
+ stateMutability: "view",
118
+ type: "function",
119
+ },
120
+ {
121
+ inputs: [
122
+ {
123
+ internalType: "uint256",
124
+ name: "_id",
125
+ type: "uint256",
126
+ },
127
+ {
128
+ internalType: "address",
129
+ name: "_target",
130
+ type: "address",
131
+ },
132
+ {
133
+ internalType: "string",
134
+ name: "_signature",
135
+ type: "string",
136
+ },
137
+ ],
138
+ name: "registerTarget",
139
+ outputs: [],
140
+ stateMutability: "nonpayable",
141
+ type: "function",
142
+ },
143
+ {
144
+ inputs: [],
145
+ name: "renounceOwnership",
146
+ outputs: [],
147
+ stateMutability: "nonpayable",
148
+ type: "function",
149
+ },
150
+ {
151
+ inputs: [
152
+ {
153
+ internalType: "uint256",
154
+ name: "_newExchangeRate",
155
+ type: "uint256",
156
+ },
157
+ ],
158
+ name: "setExchangeRate",
159
+ outputs: [],
160
+ stateMutability: "nonpayable",
161
+ type: "function",
162
+ },
163
+ {
164
+ inputs: [
165
+ {
166
+ internalType: "uint256",
167
+ name: "id",
168
+ type: "uint256",
169
+ },
170
+ ],
171
+ name: "targets",
172
+ outputs: [
173
+ {
174
+ internalType: "address",
175
+ name: "target",
176
+ type: "address",
177
+ },
178
+ {
179
+ internalType: "bytes4",
180
+ name: "selector",
181
+ type: "bytes4",
182
+ },
183
+ ],
184
+ stateMutability: "view",
185
+ type: "function",
186
+ },
187
+ {
188
+ inputs: [
189
+ {
190
+ internalType: "address",
191
+ name: "newOwner",
192
+ type: "address",
193
+ },
194
+ ],
195
+ name: "transferOwnership",
196
+ outputs: [],
197
+ stateMutability: "nonpayable",
198
+ type: "function",
199
+ },
200
+ {
201
+ inputs: [
202
+ {
203
+ internalType: "address",
204
+ name: "_token",
205
+ type: "address",
206
+ },
207
+ {
208
+ internalType: "uint256",
209
+ name: "_amount",
210
+ type: "uint256",
211
+ },
212
+ {
213
+ internalType: "uint256",
214
+ name: "_abrAmount",
215
+ type: "uint256",
216
+ },
217
+ {
218
+ internalType: "uint256",
219
+ name: "_targetId",
220
+ type: "uint256",
221
+ },
222
+ {
223
+ internalType: "bytes",
224
+ name: "_params",
225
+ type: "bytes",
226
+ },
227
+ ],
228
+ name: "transferTokensAndCallTarget",
229
+ outputs: [],
230
+ stateMutability: "payable",
231
+ type: "function",
232
+ },
233
+ {
234
+ inputs: [
235
+ {
236
+ internalType: "uint256",
237
+ name: "amount",
238
+ type: "uint256",
239
+ },
240
+ ],
241
+ name: "withdrawGas",
242
+ outputs: [],
243
+ stateMutability: "nonpayable",
244
+ type: "function",
245
+ },
246
+ {
247
+ inputs: [
248
+ {
249
+ internalType: "address",
250
+ name: "tokenAddress",
251
+ type: "address",
252
+ },
253
+ ],
254
+ name: "withdrawTokens",
255
+ outputs: [],
256
+ stateMutability: "nonpayable",
257
+ type: "function",
258
+ },
259
+ {
260
+ stateMutability: "payable",
261
+ type: "receive",
262
+ },
263
+ ],
264
+ };
265
+ exports.default = artifact;
266
+ //# sourceMappingURL=PayerWithAbr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PayerWithAbr.js","sourceRoot":"","sources":["../../../../../src/services/models/abi/PayerWithAbr.ts"],"names":[],"mappings":";;AAAA,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE;QACH;YACE,MAAM,EAAE;gBACN;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,kBAAkB;oBACxB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,iBAAiB;oBACvB,IAAI,EAAE,SAAS;iBAChB;aACF;YACD,eAAe,EAAE,YAAY;YAC7B,IAAI,EAAE,aAAa;SACpB;QACD;YACE,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE;gBACN;oBACE,OAAO,EAAE,IAAI;oBACb,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,eAAe;oBACrB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,OAAO,EAAE,IAAI;oBACb,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,SAAS;iBAChB;aACF;YACD,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,OAAO;SACd;QACD;YACE,eAAe,EAAE,SAAS;YAC1B,IAAI,EAAE,UAAU;SACjB;QACD;YACE,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACP;oBACE,YAAY,EAAE,yBAAyB;oBACvC,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,SAAS;iBAChB;aACF;YACD,eAAe,EAAE,MAAM;YACvB,IAAI,EAAE,UAAU;SACjB;QACD;YACE,MAAM,EAAE;gBACN;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,eAAe;oBACrB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,SAAS;oBACvB,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B,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,SAAS;iBAChB;gBACD;oBACE,YAAY,EAAE,OAAO;oBACrB,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,OAAO;iBACd;aACF;YACD,IAAI,EAAE,6BAA6B;YACnC,OAAO,EAAE,EAAE;YACX,eAAe,EAAE,SAAS;YAC1B,IAAI,EAAE,UAAU;SACjB;QACD;YACE,MAAM,EAAE;gBACN;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,SAAS;iBAChB;aACF;YACD,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,EAAE;YACX,eAAe,EAAE,YAAY;YAC7B,IAAI,EAAE,UAAU;SACjB;QACD;YACE,MAAM,EAAE;gBACN;oBACE,YAAY,EAAE,SAAS;oBACvB,IAAI,EAAE,cAAc;oBACpB,IAAI,EAAE,SAAS;iBAChB;aACF;YACD,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,EAAE;YACX,eAAe,EAAE,YAAY;YAC7B,IAAI,EAAE,UAAU;SACjB;QACD;YACE,eAAe,EAAE,SAAS;YAC1B,IAAI,EAAE,SAAS;SAChB;KACF;CACO,CAAC;AACX,kBAAe,QAAQ,CAAC","sourcesContent":["const artifact = {\n abi: [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"_abrTokenAddress\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"_chainPrecision\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"nonpayable\",\n type: \"constructor\",\n },\n {\n anonymous: false,\n inputs: [\n {\n indexed: true,\n internalType: \"address\",\n name: \"previousOwner\",\n type: \"address\",\n },\n {\n indexed: true,\n internalType: \"address\",\n name: \"newOwner\",\n type: \"address\",\n },\n ],\n name: \"OwnershipTransferred\",\n type: \"event\",\n },\n {\n stateMutability: \"payable\",\n type: \"fallback\",\n },\n {\n inputs: [],\n name: \"abrToken\",\n outputs: [\n {\n internalType: \"contract IERC20Metadata\",\n name: \"\",\n type: \"address\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"_tokenAddress\",\n type: \"address\",\n },\n {\n internalType: \"address\",\n name: \"_bridge\",\n type: \"address\",\n },\n ],\n name: \"approveBridgeToken\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"exchangeRate\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"_amount\",\n type: \"uint256\",\n },\n ],\n name: \"nativeTokensToAbr\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"owner\",\n outputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"_id\",\n type: \"uint256\",\n },\n {\n internalType: \"address\",\n name: \"_target\",\n type: \"address\",\n },\n {\n internalType: \"string\",\n name: \"_signature\",\n type: \"string\",\n },\n ],\n name: \"registerTarget\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"renounceOwnership\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"_newExchangeRate\",\n type: \"uint256\",\n },\n ],\n name: \"setExchangeRate\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"id\",\n type: \"uint256\",\n },\n ],\n name: \"targets\",\n outputs: [\n {\n internalType: \"address\",\n name: \"target\",\n type: \"address\",\n },\n {\n internalType: \"bytes4\",\n name: \"selector\",\n type: \"bytes4\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"newOwner\",\n type: \"address\",\n },\n ],\n name: \"transferOwnership\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"_token\",\n type: \"address\",\n },\n {\n internalType: \"uint256\",\n name: \"_amount\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"_abrAmount\",\n type: \"uint256\",\n },\n {\n internalType: \"uint256\",\n name: \"_targetId\",\n type: \"uint256\",\n },\n {\n internalType: \"bytes\",\n name: \"_params\",\n type: \"bytes\",\n },\n ],\n name: \"transferTokensAndCallTarget\",\n outputs: [],\n stateMutability: \"payable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"amount\",\n type: \"uint256\",\n },\n ],\n name: \"withdrawGas\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"tokenAddress\",\n type: \"address\",\n },\n ],\n name: \"withdrawTokens\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n stateMutability: \"payable\",\n type: \"receive\",\n },\n ],\n} as const;\nexport default artifact;\n"]}
@@ -37,14 +37,14 @@ class DefaultTokenService {
37
37
  }
38
38
  async approve(provider, approveData) {
39
39
  if (approveData.amount) {
40
- (0, utils_1.validateAmountGtZero)(approveData.amount);
40
+ (0, utils_1.validateAmountGteZero)(approveData.amount);
41
41
  (0, utils_1.validateAmountDecimals)("amount", approveData.amount, approveData.token.decimals);
42
42
  }
43
43
  return this.getChainTokenService(approveData.token.chainSymbol, approveData.owner, provider).approve(this.prepareApproveParams(approveData));
44
44
  }
45
45
  async buildRawTransactionApprove(approveData, provider) {
46
46
  if (approveData.amount) {
47
- (0, utils_1.validateAmountGtZero)(approveData.amount);
47
+ (0, utils_1.validateAmountGteZero)(approveData.amount);
48
48
  (0, utils_1.validateAmountDecimals)("amount", approveData.amount, approveData.token.decimals);
49
49
  }
50
50
  return this.getChainTokenService(approveData.token.chainSymbol, approveData.owner, provider).buildRawTransactionApprove(this.prepareApproveParams(approveData));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/token/index.ts"],"names":[],"mappings":";;;AAAA,qEAAmE;AAEnE,mCAA6B;AAC7B,qCAAkC;AAClC,+BAA4B;AAC5B,yCAAsC;AAEtC,uCAAgF;AAChF,yCAA6D;AAC7D,yDAA2F;AAC3F,6CAAiF;AAIjF,+BAAwC;AACxC,+BAAwC;AAUxC,+BAA2C;AAC3C,+BAAwC;AACxC,+BAAwC;AACxC,+BAAwC;AACxC,+BAAyC;AAgBzC,MAAa,mBAAmB;IAEnB;IACA;IACA;IAHX,YACW,GAAwB,EACxB,iBAAoC,EACpC,MAA+B;QAF/B,QAAG,GAAH,GAAG,CAAqB;QACxB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAyB;IACvC,CAAC;IAEJ,KAAK,CAAC,YAAY,CAAC,MAA0B,EAAE,QAAmB;QAChE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,YAAY,CACjH,MAAM,CACP,CAAC;QACF,OAAO,IAAA,qCAAuB,EAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,MAA4B,EAAE,QAAmB;QACpE,IAAA,4BAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpC,IAAA,8BAAsB,EAAC,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CAAC,KAAK,CAAC,WAAW;YAC1C,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,YAAG,EAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;SACxF,CAAC;IACJ,CAAC;CACF;AAzID,kDAyIC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { Algodv2 } from \"algosdk\";\nimport { Big } from \"big.js\";\nimport { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { Chains } from \"../../chains\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { AllbridgeCoreSdkOptions, ChainType, EssentialWeb3 } from \"../../index\";\nimport { AmountFormat, AmountFormatted } from \"../../models\";\nimport { convertFloatAmountToInt, convertIntAmountToFloat } from \"../../utils/calculation\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { GetNativeTokenBalanceParams } from \"../bridge/models\";\nimport { NodeRpcUrlsConfig } from \"../index\";\nimport { Provider, RawTransaction, TransactionResponse } from \"../models\";\nimport { AlgTokenService } from \"./alg\";\nimport { EvmTokenService } from \"./evm\";\nimport {\n ApproveParams,\n ApproveParamsDto,\n ChainTokenService,\n CheckAllowanceParams,\n CheckAllowanceParamsDto,\n GetAllowanceParams,\n GetTokenBalanceParams,\n} from \"./models\";\nimport { SolanaTokenService } from \"./sol\";\nimport { SrbTokenService } from \"./srb\";\nimport { StxTokenService } from \"./stx\";\nimport { SuiTokenService } from \"./sui\";\nimport { TronTokenService } from \"./trx\";\n\nexport interface TokenService {\n getAllowance(params: GetAllowanceParams, provider?: Provider): Promise<string>;\n\n checkAllowance(params: CheckAllowanceParams, provider?: Provider): Promise<boolean>;\n\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n buildRawTransactionApprove(approveData: ApproveParams, provider?: Provider): Promise<RawTransaction>;\n\n getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string>;\n\n getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted>;\n}\n\nexport class DefaultTokenService implements TokenService {\n constructor(\n readonly api: AllbridgeCoreClient,\n readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n readonly params: AllbridgeCoreSdkOptions\n ) {}\n\n async getAllowance(params: GetAllowanceParams, provider?: Provider): Promise<string> {\n const allowanceInt = await this.getChainTokenService(params.token.chainSymbol, params.owner, provider).getAllowance(\n params\n );\n return convertIntAmountToFloat(allowanceInt, params.token.decimals).toFixed();\n }\n\n async checkAllowance(params: CheckAllowanceParams, provider?: Provider): Promise<boolean> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.token.decimals);\n return this.getChainTokenService(params.token.chainSymbol, params.owner, provider).checkAllowance(\n this.prepareCheckAllowanceParams(params)\n );\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n if (approveData.amount) {\n validateAmountGtZero(approveData.amount);\n validateAmountDecimals(\"amount\", approveData.amount, approveData.token.decimals);\n }\n return this.getChainTokenService(approveData.token.chainSymbol, approveData.owner, provider).approve(\n this.prepareApproveParams(approveData)\n );\n }\n\n async buildRawTransactionApprove(approveData: ApproveParams, provider?: Provider): Promise<RawTransaction> {\n if (approveData.amount) {\n validateAmountGtZero(approveData.amount);\n validateAmountDecimals(\"amount\", approveData.amount, approveData.token.decimals);\n }\n return this.getChainTokenService(\n approveData.token.chainSymbol,\n approveData.owner,\n provider\n ).buildRawTransactionApprove(this.prepareApproveParams(approveData));\n }\n\n async getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string> {\n const tokenBalance = await this.getChainTokenService(\n params.token.chainSymbol,\n params.account,\n provider\n ).getTokenBalance(params);\n if (params.token.decimals) {\n return convertIntAmountToFloat(tokenBalance, params.token.decimals).toFixed();\n }\n return tokenBalance;\n }\n\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted> {\n const tokenBalance = await this.getChainTokenService(\n params.chainSymbol,\n params.account,\n provider\n ).getNativeTokenBalance(params);\n return {\n [AmountFormat.INT]: tokenBalance,\n [AmountFormat.FLOAT]: convertIntAmountToFloat(\n tokenBalance,\n Chains.getChainDecimalsByType(Chains.getChainProperty(params.chainSymbol).chainType)\n ).toFixed(),\n };\n }\n\n private getChainTokenService(chainSymbol: string, ownerAddress: string, provider?: Provider): ChainTokenService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmTokenService(provider as EssentialWeb3, this.api);\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmTokenService(new Web3(nodeRpcUrl), this.api);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronTokenService(provider as TronWeb, this.api);\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const tronWeb = new TronWeb({ fullHost: nodeRpcUrl });\n tronWeb.setAddress(ownerAddress);\n return new TronTokenService(tronWeb, this.api);\n }\n }\n case ChainType.SOLANA: {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new SolanaTokenService(nodeRpcUrl, this.api);\n }\n case ChainType.SRB: {\n return new SrbTokenService(this.nodeRpcUrlsConfig, this.params, this.api);\n }\n case ChainType.SUI: {\n return new SuiTokenService(this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol), this.api);\n }\n case ChainType.ALG: {\n if (provider) {\n const algod = provider as Algodv2;\n const algorand = AlgorandClient.fromClients({ algod });\n return new AlgTokenService(algorand, this.api);\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const algorand = AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n return new AlgTokenService(algorand, this.api);\n }\n }\n case ChainType.STX: {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new StxTokenService(nodeRpcUrl, this.params, this.api);\n }\n }\n }\n\n prepareCheckAllowanceParams(params: CheckAllowanceParams): CheckAllowanceParamsDto {\n return {\n ...params,\n amount: convertFloatAmountToInt(params.amount, params.token.decimals),\n };\n }\n\n private prepareApproveParams(approveData: ApproveParams): ApproveParamsDto {\n return {\n tokenAddress: approveData.token.tokenAddress,\n owner: approveData.owner,\n spender: approveData.spender,\n chainSymbol: approveData.token.chainSymbol,\n amount: approveData.amount == undefined ? undefined : Big(approveData.amount).toFixed(),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/token/index.ts"],"names":[],"mappings":";;;AAAA,qEAAmE;AAEnE,mCAA6B;AAC7B,qCAAkC;AAClC,+BAA4B;AAC5B,yCAAsC;AAEtC,uCAAgF;AAChF,yCAA6D;AAC7D,yDAA2F;AAC3F,6CAAwG;AAIxG,+BAAwC;AACxC,+BAAwC;AAUxC,+BAA2C;AAC3C,+BAAwC;AACxC,+BAAwC;AACxC,+BAAwC;AACxC,+BAAyC;AAgBzC,MAAa,mBAAmB;IAEnB;IACA;IACA;IAHX,YACW,GAAwB,EACxB,iBAAoC,EACpC,MAA+B;QAF/B,QAAG,GAAH,GAAG,CAAqB;QACxB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAyB;IACvC,CAAC;IAEJ,KAAK,CAAC,YAAY,CAAC,MAA0B,EAAE,QAAmB;QAChE,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,YAAY,CACjH,MAAM,CACP,CAAC;QACF,OAAO,IAAA,qCAAuB,EAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;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;YACL,YAAY,EAAE,WAAW,CAAC,KAAK,CAAC,YAAY;YAC5C,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,WAAW;YAC1C,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,YAAG,EAAC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;SACxF,CAAC;IACJ,CAAC;CACF;AAzID,kDAyIC","sourcesContent":["import { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { Algodv2 } from \"algosdk\";\nimport { Big } from \"big.js\";\nimport { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { Chains } from \"../../chains\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { AllbridgeCoreSdkOptions, ChainType, EssentialWeb3 } from \"../../index\";\nimport { AmountFormat, AmountFormatted } from \"../../models\";\nimport { convertFloatAmountToInt, convertIntAmountToFloat } from \"../../utils/calculation\";\nimport { validateAmountDecimals, validateAmountGteZero, validateAmountGtZero } from \"../../utils/utils\";\nimport { GetNativeTokenBalanceParams } from \"../bridge/models\";\nimport { NodeRpcUrlsConfig } from \"../index\";\nimport { Provider, RawTransaction, TransactionResponse } from \"../models\";\nimport { AlgTokenService } from \"./alg\";\nimport { EvmTokenService } from \"./evm\";\nimport {\n ApproveParams,\n ApproveParamsDto,\n ChainTokenService,\n CheckAllowanceParams,\n CheckAllowanceParamsDto,\n GetAllowanceParams,\n GetTokenBalanceParams,\n} from \"./models\";\nimport { SolanaTokenService } from \"./sol\";\nimport { SrbTokenService } from \"./srb\";\nimport { StxTokenService } from \"./stx\";\nimport { SuiTokenService } from \"./sui\";\nimport { TronTokenService } from \"./trx\";\n\nexport interface TokenService {\n getAllowance(params: GetAllowanceParams, provider?: Provider): Promise<string>;\n\n checkAllowance(params: CheckAllowanceParams, provider?: Provider): Promise<boolean>;\n\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n buildRawTransactionApprove(approveData: ApproveParams, provider?: Provider): Promise<RawTransaction>;\n\n getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string>;\n\n getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted>;\n}\n\nexport class DefaultTokenService implements TokenService {\n constructor(\n readonly api: AllbridgeCoreClient,\n readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n readonly params: AllbridgeCoreSdkOptions\n ) {}\n\n async getAllowance(params: GetAllowanceParams, provider?: Provider): Promise<string> {\n const allowanceInt = await this.getChainTokenService(params.token.chainSymbol, params.owner, provider).getAllowance(\n params\n );\n return convertIntAmountToFloat(allowanceInt, params.token.decimals).toFixed();\n }\n\n async checkAllowance(params: CheckAllowanceParams, provider?: Provider): Promise<boolean> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.token.decimals);\n return this.getChainTokenService(params.token.chainSymbol, params.owner, provider).checkAllowance(\n this.prepareCheckAllowanceParams(params)\n );\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n if (approveData.amount) {\n validateAmountGteZero(approveData.amount);\n validateAmountDecimals(\"amount\", approveData.amount, approveData.token.decimals);\n }\n return this.getChainTokenService(approveData.token.chainSymbol, approveData.owner, provider).approve(\n this.prepareApproveParams(approveData)\n );\n }\n\n async buildRawTransactionApprove(approveData: ApproveParams, provider?: Provider): Promise<RawTransaction> {\n if (approveData.amount) {\n validateAmountGteZero(approveData.amount);\n validateAmountDecimals(\"amount\", approveData.amount, approveData.token.decimals);\n }\n return this.getChainTokenService(\n approveData.token.chainSymbol,\n approveData.owner,\n provider\n ).buildRawTransactionApprove(this.prepareApproveParams(approveData));\n }\n\n async getTokenBalance(params: GetTokenBalanceParams, provider?: Provider): Promise<string> {\n const tokenBalance = await this.getChainTokenService(\n params.token.chainSymbol,\n params.account,\n provider\n ).getTokenBalance(params);\n if (params.token.decimals) {\n return convertIntAmountToFloat(tokenBalance, params.token.decimals).toFixed();\n }\n return tokenBalance;\n }\n\n async getNativeTokenBalance(params: GetNativeTokenBalanceParams, provider?: Provider): Promise<AmountFormatted> {\n const tokenBalance = await this.getChainTokenService(\n params.chainSymbol,\n params.account,\n provider\n ).getNativeTokenBalance(params);\n return {\n [AmountFormat.INT]: tokenBalance,\n [AmountFormat.FLOAT]: convertIntAmountToFloat(\n tokenBalance,\n Chains.getChainDecimalsByType(Chains.getChainProperty(params.chainSymbol).chainType)\n ).toFixed(),\n };\n }\n\n private getChainTokenService(chainSymbol: string, ownerAddress: string, provider?: Provider): ChainTokenService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmTokenService(provider as EssentialWeb3, this.api);\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmTokenService(new Web3(nodeRpcUrl), this.api);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronTokenService(provider as TronWeb, this.api);\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const tronWeb = new TronWeb({ fullHost: nodeRpcUrl });\n tronWeb.setAddress(ownerAddress);\n return new TronTokenService(tronWeb, this.api);\n }\n }\n case ChainType.SOLANA: {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new SolanaTokenService(nodeRpcUrl, this.api);\n }\n case ChainType.SRB: {\n return new SrbTokenService(this.nodeRpcUrlsConfig, this.params, this.api);\n }\n case ChainType.SUI: {\n return new SuiTokenService(this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol), this.api);\n }\n case ChainType.ALG: {\n if (provider) {\n const algod = provider as Algodv2;\n const algorand = AlgorandClient.fromClients({ algod });\n return new AlgTokenService(algorand, this.api);\n } else {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const algorand = AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n return new AlgTokenService(algorand, this.api);\n }\n }\n case ChainType.STX: {\n const nodeRpcUrl = this.nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new StxTokenService(nodeRpcUrl, this.params, this.api);\n }\n }\n }\n\n prepareCheckAllowanceParams(params: CheckAllowanceParams): CheckAllowanceParamsDto {\n return {\n ...params,\n amount: convertFloatAmountToInt(params.amount, params.token.decimals),\n };\n }\n\n private prepareApproveParams(approveData: ApproveParams): ApproveParamsDto {\n return {\n tokenAddress: approveData.token.tokenAddress,\n owner: approveData.owner,\n spender: approveData.spender,\n chainSymbol: approveData.token.chainSymbol,\n amount: approveData.amount == undefined ? undefined : Big(approveData.amount).toFixed(),\n };\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { Big } from "big.js";
2
2
  import { FeePaymentMethod } from "../../../models";
3
- import { TokenWithChainDetails } from "../../../tokens-info";
3
+ import { TokenCoreFields } from "../../../tokens-info";
4
4
  export interface ApproveParams {
5
5
  /**
6
6
  * The token info
7
7
  */
8
- token: TokenWithChainDetails;
8
+ token: TokenCoreFields;
9
9
  /**
10
10
  * The address of the token owner who is granting permission to use tokens
11
11
  * to the spender
@@ -27,7 +27,7 @@ export interface GetTokenBalanceParams {
27
27
  * The address for which we will find out the token balance
28
28
  */
29
29
  account: string;
30
- token: TokenWithChainDetails;
30
+ token: TokenCoreFields;
31
31
  }
32
32
  export interface CheckAllowanceParams extends GetAllowanceParams {
33
33
  /**
@@ -36,7 +36,7 @@ export interface CheckAllowanceParams extends GetAllowanceParams {
36
36
  amount: string | number | Big;
37
37
  }
38
38
  export interface GetAllowanceParams {
39
- token: TokenWithChainDetails;
39
+ token: TokenCoreFields;
40
40
  spender: string;
41
41
  owner: string;
42
42
  gasFeePaymentMethod?: FeePaymentMethod;
@@ -1 +1 @@
1
- {"version":3,"file":"token.model.js","sourceRoot":"","sources":["../../../../../src/services/token/models/token.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { TokenWithChainDetails } from \"../../../tokens-info\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenWithChainDetails;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n * to the spender\n */\n owner: string;\n\n /**\n * The address of the contract that is being granted permission to use tokens\n */\n spender: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenWithChainDetails;\n}\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\nexport interface GetAllowanceParams {\n token: TokenWithChainDetails;\n spender: string;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface ApproveParamsDto {\n tokenAddress: string;\n chainSymbol: string;\n owner: string;\n spender: string;\n /**\n * Integer amount of tokens to approve.\n */\n amount?: string;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\n/**\n * @internal\n */\nexport interface CheckAllowanceParamsDto extends GetAllowanceParamsDto {\n /**\n * The integer amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n"]}
1
+ {"version":3,"file":"token.model.js","sourceRoot":"","sources":["../../../../../src/services/token/models/token.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { TokenCoreFields } from \"../../../tokens-info\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenCoreFields;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n * to the spender\n */\n owner: string;\n\n /**\n * The address of the contract that is being granted permission to use tokens\n */\n spender: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenCoreFields;\n}\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\nexport interface GetAllowanceParams {\n token: TokenCoreFields;\n spender: string;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface ApproveParamsDto {\n tokenAddress: string;\n chainSymbol: string;\n owner: string;\n spender: string;\n /**\n * Integer amount of tokens to approve.\n */\n amount?: string;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\n/**\n * @internal\n */\nexport interface CheckAllowanceParamsDto extends GetAllowanceParamsDto {\n /**\n * The integer amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n"]}
@@ -9,6 +9,17 @@ import { Messenger } from "../client/core-api/core-api.model";
9
9
  */
10
10
  export type ChainDetailsMap = Record<string, ChainDetailsWithTokens>;
11
11
  export type ChainDetailsMapWithFlags = Record<string, ChainDetailsWithTokensWithFlags>;
12
+ export interface AbrPayerChainInfo {
13
+ /**
14
+ * ABR proxy for paying fees with ABR
15
+ */
16
+ payerAddress: string;
17
+ abrToken: TokenCoreFields;
18
+ /**
19
+ * Availability to pay by abr
20
+ */
21
+ payerAvailability: AbrPayerAvailability;
22
+ }
12
23
  /**
13
24
  * Contains some blockchain details
14
25
  */
@@ -38,6 +49,10 @@ export interface ChainDetails extends BasicChainProperties {
38
49
  * Yield contract address
39
50
  */
40
51
  yieldAddress?: string;
52
+ /**
53
+ * ABR payer chain info
54
+ */
55
+ abrPayer?: AbrPayerChainInfo;
41
56
  /**
42
57
  * Average transfer time to other blockchains
43
58
  */
@@ -191,6 +206,7 @@ export interface TokenWithChainDetails extends Token, Omit<ChainDetails, "name">
191
206
  */
192
207
  chainName: string;
193
208
  }
209
+ export type TokenCoreFields = Pick<TokenWithChainDetails, "tokenAddress" | "chainSymbol" | "decimals" | "originTokenAddress">;
194
210
  export interface TokenWithChainDetailsWithFlags extends TokenWithChainDetails {
195
211
  flags: {
196
212
  swap: boolean;
@@ -234,6 +250,7 @@ export interface PoolInfo {
234
250
  */
235
251
  imbalance: string;
236
252
  }
253
+ export type AbrPayerAvailability = Partial<Record<Messenger, boolean>>;
237
254
  /**
238
255
  * Type representing transfer times for various blockchain chains.
239
256
  *