@across-protocol/sdk 4.3.143-alpha.1 → 4.3.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/caching/Arweave/ArweaveClient.d.ts +6 -11
- package/dist/cjs/src/caching/Arweave/ArweaveClient.js +79 -102
- package/dist/cjs/src/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/cjs/src/clients/BundleDataClient/utils/SuperstructUtils.d.ts +64 -63
- package/dist/cjs/src/clients/BundleDataClient/utils/SuperstructUtils.js +31 -13
- package/dist/cjs/src/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/src/caching/Arweave/ArweaveClient.d.ts +8 -21
- package/dist/esm/src/caching/Arweave/ArweaveClient.js +89 -119
- package/dist/esm/src/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/esm/src/clients/BundleDataClient/utils/SuperstructUtils.d.ts +64 -63
- package/dist/esm/src/clients/BundleDataClient/utils/SuperstructUtils.js +29 -11
- package/dist/esm/src/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/types/src/caching/Arweave/ArweaveClient.d.ts +8 -21
- package/dist/types/src/caching/Arweave/ArweaveClient.d.ts.map +1 -1
- package/dist/types/src/clients/BundleDataClient/utils/SuperstructUtils.d.ts +64 -63
- package/dist/types/src/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/caching/Arweave/ArweaveClient.ts +88 -134
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +26 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Infer } from "superstruct";
|
|
2
|
-
import { BigNumber, EvmAddress, RawAddress, SvmAddress } from "../../../utils";
|
|
2
|
+
import { BigNumber, EvmAddress, RawAddress, SvmAddress, TvmAddress } from "../../../utils";
|
|
3
|
+
export declare const AddressType: import("superstruct").Struct<SvmAddress | EvmAddress | TvmAddress | RawAddress, null>;
|
|
3
4
|
export declare const SortableEventSS: {
|
|
4
5
|
blockNumber: import("superstruct").Struct<number, null>;
|
|
5
6
|
logIndex: import("superstruct").Struct<number, null>;
|
|
@@ -13,13 +14,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
13
14
|
message: string;
|
|
14
15
|
destinationChainId: number;
|
|
15
16
|
originChainId: number;
|
|
16
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
17
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
18
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
19
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
17
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
18
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
19
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
20
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
20
21
|
inputAmount: BigNumber;
|
|
21
22
|
outputAmount: BigNumber;
|
|
22
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
23
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
23
24
|
quoteTimestamp: number;
|
|
24
25
|
fillDeadline: number;
|
|
25
26
|
depositId: BigNumber;
|
|
@@ -31,7 +32,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
31
32
|
blockNumber: number;
|
|
32
33
|
logIndex: number;
|
|
33
34
|
updatedOutputAmount?: BigNumber | undefined;
|
|
34
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
35
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
35
36
|
updatedMessage?: string | undefined;
|
|
36
37
|
speedUpSignature?: string | undefined;
|
|
37
38
|
txnIndex?: number | undefined;
|
|
@@ -44,23 +45,23 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
44
45
|
fills: {
|
|
45
46
|
destinationChainId: number;
|
|
46
47
|
originChainId: number;
|
|
47
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
48
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
49
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
50
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
48
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
49
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
50
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
51
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
51
52
|
inputAmount: BigNumber;
|
|
52
53
|
outputAmount: BigNumber;
|
|
53
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
54
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
54
55
|
quoteTimestamp: number;
|
|
55
56
|
fillDeadline: number;
|
|
56
57
|
depositId: BigNumber;
|
|
57
58
|
exclusivityDeadline: number;
|
|
58
59
|
repaymentChainId: number;
|
|
59
|
-
relayer: SvmAddress | EvmAddress | RawAddress;
|
|
60
|
+
relayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
60
61
|
messageHash: string;
|
|
61
62
|
relayExecutionInfo: {
|
|
62
63
|
updatedOutputAmount: BigNumber;
|
|
63
|
-
updatedRecipient: SvmAddress | EvmAddress | RawAddress;
|
|
64
|
+
updatedRecipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
64
65
|
updatedMessageHash: string;
|
|
65
66
|
fillType: number;
|
|
66
67
|
updatedMessage?: string | undefined;
|
|
@@ -82,13 +83,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
82
83
|
message: string;
|
|
83
84
|
destinationChainId: number;
|
|
84
85
|
originChainId: number;
|
|
85
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
86
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
87
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
88
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
86
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
87
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
88
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
89
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
89
90
|
inputAmount: BigNumber;
|
|
90
91
|
outputAmount: BigNumber;
|
|
91
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
92
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
92
93
|
quoteTimestamp: number;
|
|
93
94
|
fillDeadline: number;
|
|
94
95
|
depositId: BigNumber;
|
|
@@ -101,7 +102,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
101
102
|
logIndex: number;
|
|
102
103
|
lpFeePct: BigNumber;
|
|
103
104
|
updatedOutputAmount?: BigNumber | undefined;
|
|
104
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
105
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
105
106
|
updatedMessage?: string | undefined;
|
|
106
107
|
speedUpSignature?: string | undefined;
|
|
107
108
|
txnIndex?: number | undefined;
|
|
@@ -114,13 +115,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
114
115
|
message: string;
|
|
115
116
|
destinationChainId: number;
|
|
116
117
|
originChainId: number;
|
|
117
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
118
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
119
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
120
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
118
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
119
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
120
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
121
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
121
122
|
inputAmount: BigNumber;
|
|
122
123
|
outputAmount: BigNumber;
|
|
123
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
124
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
124
125
|
quoteTimestamp: number;
|
|
125
126
|
fillDeadline: number;
|
|
126
127
|
depositId: BigNumber;
|
|
@@ -132,7 +133,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
132
133
|
blockNumber: number;
|
|
133
134
|
logIndex: number;
|
|
134
135
|
updatedOutputAmount?: BigNumber | undefined;
|
|
135
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
136
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
136
137
|
updatedMessage?: string | undefined;
|
|
137
138
|
speedUpSignature?: string | undefined;
|
|
138
139
|
txnIndex?: number | undefined;
|
|
@@ -145,13 +146,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
145
146
|
message: string;
|
|
146
147
|
destinationChainId: number;
|
|
147
148
|
originChainId: number;
|
|
148
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
149
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
150
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
151
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
149
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
150
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
151
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
152
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
152
153
|
inputAmount: BigNumber;
|
|
153
154
|
outputAmount: BigNumber;
|
|
154
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
155
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
155
156
|
quoteTimestamp: number;
|
|
156
157
|
fillDeadline: number;
|
|
157
158
|
depositId: BigNumber;
|
|
@@ -164,7 +165,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
164
165
|
logIndex: number;
|
|
165
166
|
lpFeePct: BigNumber;
|
|
166
167
|
updatedOutputAmount?: BigNumber | undefined;
|
|
167
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
168
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
168
169
|
updatedMessage?: string | undefined;
|
|
169
170
|
speedUpSignature?: string | undefined;
|
|
170
171
|
txnIndex?: number | undefined;
|
|
@@ -178,13 +179,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
178
179
|
message: string;
|
|
179
180
|
destinationChainId: number;
|
|
180
181
|
originChainId: number;
|
|
181
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
182
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
183
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
184
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
182
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
183
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
184
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
185
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
185
186
|
inputAmount: BigNumber;
|
|
186
187
|
outputAmount: BigNumber;
|
|
187
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
188
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
188
189
|
quoteTimestamp: number;
|
|
189
190
|
fillDeadline: number;
|
|
190
191
|
depositId: BigNumber;
|
|
@@ -196,7 +197,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
196
197
|
blockNumber: number;
|
|
197
198
|
logIndex: number;
|
|
198
199
|
updatedOutputAmount?: BigNumber | undefined;
|
|
199
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
200
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
200
201
|
updatedMessage?: string | undefined;
|
|
201
202
|
speedUpSignature?: string | undefined;
|
|
202
203
|
txnIndex?: number | undefined;
|
|
@@ -209,13 +210,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
209
210
|
message: string;
|
|
210
211
|
destinationChainId: number;
|
|
211
212
|
originChainId: number;
|
|
212
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
213
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
214
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
215
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
213
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
214
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
215
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
216
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
216
217
|
inputAmount: BigNumber;
|
|
217
218
|
outputAmount: BigNumber;
|
|
218
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
219
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
219
220
|
quoteTimestamp: number;
|
|
220
221
|
fillDeadline: number;
|
|
221
222
|
depositId: BigNumber;
|
|
@@ -227,7 +228,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
227
228
|
blockNumber: number;
|
|
228
229
|
logIndex: number;
|
|
229
230
|
updatedOutputAmount?: BigNumber | undefined;
|
|
230
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
231
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
231
232
|
updatedMessage?: string | undefined;
|
|
232
233
|
speedUpSignature?: string | undefined;
|
|
233
234
|
txnIndex?: number | undefined;
|
|
@@ -240,13 +241,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
240
241
|
message: string;
|
|
241
242
|
destinationChainId: number;
|
|
242
243
|
originChainId: number;
|
|
243
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
244
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
245
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
246
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
244
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
245
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
246
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
247
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
247
248
|
inputAmount: BigNumber;
|
|
248
249
|
outputAmount: BigNumber;
|
|
249
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
250
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
250
251
|
quoteTimestamp: number;
|
|
251
252
|
fillDeadline: number;
|
|
252
253
|
depositId: BigNumber;
|
|
@@ -259,7 +260,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
259
260
|
logIndex: number;
|
|
260
261
|
lpFeePct: BigNumber;
|
|
261
262
|
updatedOutputAmount?: BigNumber | undefined;
|
|
262
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
263
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
263
264
|
updatedMessage?: string | undefined;
|
|
264
265
|
speedUpSignature?: string | undefined;
|
|
265
266
|
txnIndex?: number | undefined;
|
|
@@ -272,13 +273,13 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
272
273
|
message: string;
|
|
273
274
|
destinationChainId: number;
|
|
274
275
|
originChainId: number;
|
|
275
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
276
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
277
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
278
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
276
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
277
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
278
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
279
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
279
280
|
inputAmount: BigNumber;
|
|
280
281
|
outputAmount: BigNumber;
|
|
281
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
282
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
282
283
|
quoteTimestamp: number;
|
|
283
284
|
fillDeadline: number;
|
|
284
285
|
depositId: BigNumber;
|
|
@@ -291,7 +292,7 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
291
292
|
logIndex: number;
|
|
292
293
|
lpFeePct: BigNumber;
|
|
293
294
|
updatedOutputAmount?: BigNumber | undefined;
|
|
294
|
-
updatedRecipient?: SvmAddress | EvmAddress | RawAddress | undefined;
|
|
295
|
+
updatedRecipient?: SvmAddress | EvmAddress | TvmAddress | RawAddress | undefined;
|
|
295
296
|
updatedMessage?: string | undefined;
|
|
296
297
|
speedUpSignature?: string | undefined;
|
|
297
298
|
txnIndex?: number | undefined;
|
|
@@ -304,23 +305,23 @@ export declare const BundleDataSS: import("superstruct").Struct<{
|
|
|
304
305
|
fills: {
|
|
305
306
|
destinationChainId: number;
|
|
306
307
|
originChainId: number;
|
|
307
|
-
depositor: SvmAddress | EvmAddress | RawAddress;
|
|
308
|
-
recipient: SvmAddress | EvmAddress | RawAddress;
|
|
309
|
-
inputToken: SvmAddress | EvmAddress | RawAddress;
|
|
310
|
-
outputToken: SvmAddress | EvmAddress | RawAddress;
|
|
308
|
+
depositor: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
309
|
+
recipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
310
|
+
inputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
311
|
+
outputToken: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
311
312
|
inputAmount: BigNumber;
|
|
312
313
|
outputAmount: BigNumber;
|
|
313
|
-
exclusiveRelayer: SvmAddress | EvmAddress | RawAddress;
|
|
314
|
+
exclusiveRelayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
314
315
|
quoteTimestamp: number;
|
|
315
316
|
fillDeadline: number;
|
|
316
317
|
depositId: BigNumber;
|
|
317
318
|
exclusivityDeadline: number;
|
|
318
319
|
repaymentChainId: number;
|
|
319
|
-
relayer: SvmAddress | EvmAddress | RawAddress;
|
|
320
|
+
relayer: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
320
321
|
messageHash: string;
|
|
321
322
|
relayExecutionInfo: {
|
|
322
323
|
updatedOutputAmount: BigNumber;
|
|
323
|
-
updatedRecipient: SvmAddress | EvmAddress | RawAddress;
|
|
324
|
+
updatedRecipient: SvmAddress | EvmAddress | TvmAddress | RawAddress;
|
|
324
325
|
updatedMessageHash: string;
|
|
325
326
|
fillType: number;
|
|
326
327
|
updatedMessage?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuperstructUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/clients/BundleDataClient/utils/SuperstructUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAcN,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"SuperstructUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/clients/BundleDataClient/utils/SuperstructUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAcN,MAAM,aAAa,CAAC;AAMrB,OAAO,EAAE,SAAS,EAAQ,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAa,MAAM,gBAAgB,CAAC;AAuB5G,eAAO,MAAM,WAAW,uFAatB,CAAC;AAuBH,eAAO,MAAM,eAAe;;;;;;;CAS3B,CAAC;AA6EF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMvB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@across-protocol/sdk",
|
|
3
3
|
"author": "UMA Team",
|
|
4
|
-
"version": "4.3.143
|
|
4
|
+
"version": "4.3.143",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"homepage": "https://docs.across.to/reference/sdk",
|
|
7
7
|
"repository": {
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@across-protocol/constants": "^3.1.109",
|
|
84
|
-
"@across-protocol/contracts": "5.0.
|
|
84
|
+
"@across-protocol/contracts": "5.0.7",
|
|
85
85
|
"@coral-xyz/anchor": "^0.30.1",
|
|
86
86
|
"@eth-optimism/sdk": "^3.3.1",
|
|
87
87
|
"@ethersproject/bignumber": "^5.7.0",
|
|
@@ -6,104 +6,37 @@ import winston from "winston";
|
|
|
6
6
|
import { ARWEAVE_TAG_APP_NAME, ARWEAVE_TAG_APP_VERSION, DEFAULT_ARWEAVE_STORAGE_ADDRESS } from "../../constants";
|
|
7
7
|
import { BigNumber, delay, fetchWithTimeout, isDefined, jsonReplacerWithBigNumbers, toBN } from "../../utils";
|
|
8
8
|
|
|
9
|
-
export interface ArweaveGatewayConfig {
|
|
10
|
-
host: string;
|
|
11
|
-
protocol?: string;
|
|
12
|
-
port?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const DEFAULT_ARWEAVE_GATEWAYS: ArweaveGatewayConfig[] = [{ host: "arweave.net" }, { host: "ar-io.net" }];
|
|
16
|
-
|
|
17
|
-
interface Gateway {
|
|
18
|
-
client: Arweave;
|
|
19
|
-
url: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
9
|
export class ArweaveClient {
|
|
23
|
-
private
|
|
10
|
+
private client: Arweave;
|
|
11
|
+
private gatewayUrl: string;
|
|
24
12
|
|
|
25
13
|
public constructor(
|
|
26
14
|
private arweaveJWT: JWKInterface,
|
|
27
15
|
private logger: winston.Logger,
|
|
28
|
-
|
|
16
|
+
public gatewayURL = "arweave.net",
|
|
17
|
+
public protocol = "https",
|
|
18
|
+
port = 443,
|
|
29
19
|
private readonly retries = 2,
|
|
30
20
|
private readonly retryDelaySeconds = 1
|
|
31
21
|
) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
this.gateways = gateways.map(({ host, protocol = "https", port = 443 }) => ({
|
|
42
|
-
client: new Arweave({ host, port, protocol, timeout: 20000, logging: false }),
|
|
43
|
-
url: `${protocol}://${host}:${port}`,
|
|
44
|
-
}));
|
|
22
|
+
this.gatewayUrl = `${protocol}://${gatewayURL}:${port}`;
|
|
23
|
+
this.client = new Arweave({
|
|
24
|
+
host: gatewayURL,
|
|
25
|
+
port,
|
|
26
|
+
protocol,
|
|
27
|
+
timeout: 20000,
|
|
28
|
+
logging: false,
|
|
29
|
+
});
|
|
45
30
|
this.logger.debug({
|
|
46
31
|
at: "ArweaveClient:constructor",
|
|
47
32
|
message: "Arweave client initialized",
|
|
48
|
-
|
|
33
|
+
gateway: this.gatewayUrl,
|
|
49
34
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Races a request across all gateways, returning the first successful response.
|
|
54
|
-
* If all gateways fail, throws an error with details from each gateway.
|
|
55
|
-
*/
|
|
56
|
-
private async _raceGateways<T>(label: string, fn: (gw: Gateway) => Promise<T>): Promise<T> {
|
|
57
|
-
try {
|
|
58
|
-
return await Promise.any(this.gateways.map((gw) => this._retryRequest(() => fn(gw), 0)));
|
|
59
|
-
} catch (e) {
|
|
60
|
-
if (e instanceof AggregateError) {
|
|
61
|
-
const details = this.gateways.map((gw, i) => `${gw.url}: ${e.errors[i]}`).join("; ");
|
|
62
|
-
throw new Error(`All Arweave gateways failed for ${label}: ${details}`);
|
|
63
|
-
}
|
|
64
|
-
throw e;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Tries gateways sequentially, returning the first successful response.
|
|
70
|
-
* Used for write operations where we want exactly one successful submission.
|
|
71
|
-
*/
|
|
72
|
-
private async _failoverGateways<T>(label: string, fn: (gw: Gateway) => Promise<T>): Promise<T> {
|
|
73
|
-
const errors: Error[] = [];
|
|
74
|
-
for (const gw of this.gateways) {
|
|
75
|
-
try {
|
|
76
|
-
return await this._retryRequest(() => fn(gw), 0);
|
|
77
|
-
} catch (e) {
|
|
78
|
-
errors.push(e as Error);
|
|
79
|
-
this.logger.debug({
|
|
80
|
-
at: "ArweaveClient:failoverGateways",
|
|
81
|
-
message: `Gateway ${gw.url} failed for ${label}, trying next: ${e}`,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
35
|
+
if (this.retries < 0) {
|
|
36
|
+
throw new Error(`retries cannot be < 0 and must be an integer. Currently set to ${this.retries}`);
|
|
84
37
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private async _retryRequest<T>(request: () => Promise<T>, retryCount: number): Promise<T> {
|
|
90
|
-
try {
|
|
91
|
-
return await request();
|
|
92
|
-
} catch (e) {
|
|
93
|
-
if (retryCount < this.retries) {
|
|
94
|
-
// Implement a slightly aggressive exponential backoff to account for fierce parallelism.
|
|
95
|
-
const baseDelay = this.retryDelaySeconds * Math.pow(2, retryCount);
|
|
96
|
-
const delayS = baseDelay + baseDelay * Math.random();
|
|
97
|
-
this.logger.debug({
|
|
98
|
-
at: "ArweaveClient:retryRequest",
|
|
99
|
-
message: `Arweave request failed, retrying after waiting ${delayS} seconds: ${e}`,
|
|
100
|
-
retryCount,
|
|
101
|
-
});
|
|
102
|
-
await delay(delayS);
|
|
103
|
-
return this._retryRequest(request, retryCount + 1);
|
|
104
|
-
} else {
|
|
105
|
-
throw e;
|
|
106
|
-
}
|
|
38
|
+
if (this.retryDelaySeconds < 0) {
|
|
39
|
+
throw new Error(`delay cannot be < 0. Currently set to ${this.retryDelaySeconds}`);
|
|
107
40
|
}
|
|
108
41
|
}
|
|
109
42
|
|
|
@@ -114,47 +47,46 @@ export class ArweaveClient {
|
|
|
114
47
|
* @param value The value to store
|
|
115
48
|
* @param topicTag An optional topic tag to add to the transaction
|
|
116
49
|
* @returns The transaction ID of the stored value
|
|
50
|
+
* @
|
|
117
51
|
*/
|
|
118
52
|
async set(value: Record<string, unknown>, topicTag?: string | undefined): Promise<string | undefined> {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
// Add tags to the transaction
|
|
126
|
-
transaction.addTag("Content-Type", "application/json");
|
|
127
|
-
transaction.addTag("App-Name", ARWEAVE_TAG_APP_NAME);
|
|
128
|
-
transaction.addTag("App-Version", ARWEAVE_TAG_APP_VERSION.toString());
|
|
129
|
-
if (isDefined(topicTag)) {
|
|
130
|
-
transaction.addTag("Topic", topicTag);
|
|
131
|
-
}
|
|
53
|
+
const transaction = await this.client.createTransaction(
|
|
54
|
+
{ data: JSON.stringify(value, jsonReplacerWithBigNumbers) },
|
|
55
|
+
this.arweaveJWT
|
|
56
|
+
);
|
|
132
57
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
58
|
+
// Add tags to the transaction
|
|
59
|
+
transaction.addTag("Content-Type", "application/json");
|
|
60
|
+
transaction.addTag("App-Name", ARWEAVE_TAG_APP_NAME);
|
|
61
|
+
transaction.addTag("App-Version", ARWEAVE_TAG_APP_VERSION.toString());
|
|
62
|
+
if (isDefined(topicTag)) {
|
|
63
|
+
transaction.addTag("Topic", topicTag);
|
|
64
|
+
}
|
|
137
65
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
at: "ArweaveClient:set",
|
|
143
|
-
message,
|
|
144
|
-
result,
|
|
145
|
-
txn: transaction.id,
|
|
146
|
-
address: await this.getAddress(),
|
|
147
|
-
balance: (await this.getBalance()).toString(),
|
|
148
|
-
});
|
|
149
|
-
throw new Error(message);
|
|
150
|
-
}
|
|
66
|
+
// Sign the transaction
|
|
67
|
+
await this.client.transactions.sign(transaction, this.arweaveJWT);
|
|
68
|
+
// Send the transaction
|
|
69
|
+
const result = await this.client.transactions.post(transaction);
|
|
151
70
|
|
|
71
|
+
// Ensure that the result is successful
|
|
72
|
+
if (result.status !== 200) {
|
|
73
|
+
const message = result?.data?.error?.msg ?? "Unknown error";
|
|
74
|
+
this.logger.error({
|
|
75
|
+
at: "ArweaveClient:set",
|
|
76
|
+
message,
|
|
77
|
+
result,
|
|
78
|
+
txn: transaction.id,
|
|
79
|
+
address: await this.getAddress(),
|
|
80
|
+
balance: (await this.getBalance()).toString(),
|
|
81
|
+
});
|
|
82
|
+
throw new Error(message);
|
|
83
|
+
} else {
|
|
152
84
|
this.logger.debug({
|
|
153
85
|
at: "ArweaveClient:set",
|
|
154
86
|
message: `Arweave transaction posted with ${transaction.id}`,
|
|
155
87
|
});
|
|
156
|
-
|
|
157
|
-
|
|
88
|
+
}
|
|
89
|
+
return transaction.id;
|
|
158
90
|
}
|
|
159
91
|
|
|
160
92
|
/**
|
|
@@ -165,12 +97,15 @@ export class ArweaveClient {
|
|
|
165
97
|
* @returns The record if it exists, otherwise null
|
|
166
98
|
*/
|
|
167
99
|
async get<T>(transactionID: string, validator: Struct<T>): Promise<T | null> {
|
|
168
|
-
//
|
|
100
|
+
// Resolve the URL of the transaction
|
|
101
|
+
const transactionUrl = `${this.gatewayUrl}/${transactionID}`;
|
|
102
|
+
// We should query in via Axios directly to the gateway URL. The reasoning behind this is
|
|
169
103
|
// that the Arweave SDK's `getData` method is too slow and does not provide a way to set a timeout.
|
|
170
104
|
// Therefore, something that could take milliseconds to complete could take tens of minutes.
|
|
171
|
-
const
|
|
172
|
-
return await fetchWithTimeout(
|
|
173
|
-
}
|
|
105
|
+
const request = async () => {
|
|
106
|
+
return await fetchWithTimeout(transactionUrl, {}, {}, 20_000);
|
|
107
|
+
};
|
|
108
|
+
const data = await this._retryRequest(request, 0);
|
|
174
109
|
try {
|
|
175
110
|
// We should validate the data and perform any logical coercion here.
|
|
176
111
|
return create(data, validator);
|
|
@@ -214,15 +149,15 @@ export class ArweaveClient {
|
|
|
214
149
|
) { edges { node { id } } }
|
|
215
150
|
}`;
|
|
216
151
|
|
|
217
|
-
const response = await this.
|
|
218
|
-
const response = await client.api.post<{
|
|
152
|
+
const response = await this._retryRequest(async () => {
|
|
153
|
+
const response = await this.client.api.post<{
|
|
219
154
|
data: { transactions: { edges: { node: { id: string } }[] } };
|
|
220
155
|
}>("/graphql", { query });
|
|
221
156
|
if (!response.ok) {
|
|
222
157
|
throw new Error(`Arweave GraphQL request failed with status ${response.status}`);
|
|
223
158
|
}
|
|
224
159
|
return response;
|
|
225
|
-
});
|
|
160
|
+
}, 0);
|
|
226
161
|
|
|
227
162
|
const entries = response?.data?.data?.transactions?.edges ?? [];
|
|
228
163
|
this.logger.debug({
|
|
@@ -263,9 +198,7 @@ export class ArweaveClient {
|
|
|
263
198
|
* @returns The metadata of the transaction if it exists, otherwise null
|
|
264
199
|
*/
|
|
265
200
|
async getMetadata(transactionID: string): Promise<Record<string, string> | null> {
|
|
266
|
-
const transaction = await this.
|
|
267
|
-
return await client.transactions.get(transactionID);
|
|
268
|
-
});
|
|
201
|
+
const transaction = await this.client.transactions.get(transactionID);
|
|
269
202
|
if (!isDefined(transaction)) {
|
|
270
203
|
return null;
|
|
271
204
|
}
|
|
@@ -283,12 +216,32 @@ export class ArweaveClient {
|
|
|
283
216
|
}
|
|
284
217
|
|
|
285
218
|
/**
|
|
286
|
-
* Returns the address of the signer of the JWT
|
|
287
|
-
* operation and does not require a network call.
|
|
219
|
+
* Returns the address of the signer of the JWT
|
|
288
220
|
* @returns The address of the signer in this client
|
|
289
221
|
*/
|
|
290
222
|
getAddress(): Promise<string> {
|
|
291
|
-
return this.
|
|
223
|
+
return this.client.wallets.jwkToAddress(this.arweaveJWT);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private async _retryRequest<T>(request: () => Promise<T>, retryCount: number): Promise<T> {
|
|
227
|
+
try {
|
|
228
|
+
return await request();
|
|
229
|
+
} catch (e) {
|
|
230
|
+
if (retryCount < this.retries) {
|
|
231
|
+
// Implement a slightly aggressive exponential backoff to account for fierce parallelism.
|
|
232
|
+
const baseDelay = this.retryDelaySeconds * Math.pow(2, retryCount); // ms; attempt = [0, 1, 2, ...]
|
|
233
|
+
const delayS = baseDelay + baseDelay * Math.random();
|
|
234
|
+
this.logger.debug({
|
|
235
|
+
at: "ArweaveClient:retryRequest",
|
|
236
|
+
message: `Arweave request failed, retrying after waiting ${delayS} seconds: ${e}`,
|
|
237
|
+
retryCount,
|
|
238
|
+
});
|
|
239
|
+
await delay(delayS);
|
|
240
|
+
return this._retryRequest(request, retryCount + 1);
|
|
241
|
+
} else {
|
|
242
|
+
throw e;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
292
245
|
}
|
|
293
246
|
|
|
294
247
|
/**
|
|
@@ -297,9 +250,9 @@ export class ArweaveClient {
|
|
|
297
250
|
*/
|
|
298
251
|
async getBalance(): Promise<BigNumber> {
|
|
299
252
|
const address = await this.getAddress();
|
|
300
|
-
|
|
301
|
-
const balanceInFloat = await client.wallets.getBalance(address);
|
|
302
|
-
// @dev The reason we add in the BN.from
|
|
253
|
+
const request = async () => {
|
|
254
|
+
const balanceInFloat = await this.client.wallets.getBalance(address);
|
|
255
|
+
// @dev The reason we add in the BN.from into this retry loop is because the client.getBalance call
|
|
303
256
|
// does not correctly throw an error if the request fails, instead it will return the error string as the
|
|
304
257
|
// balanceInFloat.
|
|
305
258
|
// Sometimes the balance is returned in scientific notation, so we need to
|
|
@@ -311,6 +264,7 @@ export class ArweaveClient {
|
|
|
311
264
|
} else {
|
|
312
265
|
return BigNumber.from(balanceInFloat);
|
|
313
266
|
}
|
|
314
|
-
}
|
|
267
|
+
};
|
|
268
|
+
return await this._retryRequest(request, 0);
|
|
315
269
|
}
|
|
316
270
|
}
|