@agglayer/sdk 0.1.0-beta.0
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/README.md +136 -0
- package/dist/index.d.mts +803 -0
- package/dist/index.d.ts +803 -0
- package/dist/index.js +1863 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1842 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +78 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
import { Chain, PublicClient, Hex } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core Config
|
|
5
|
+
*/
|
|
6
|
+
interface CoreConfig {
|
|
7
|
+
apiBaseUrl?: string;
|
|
8
|
+
apiTimeout?: number;
|
|
9
|
+
websocketBaseUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Arc API Response Types
|
|
14
|
+
*
|
|
15
|
+
* Defines the core response structure for all Arc API endpoints.
|
|
16
|
+
* Uses discriminated unions for type-safe error handling.
|
|
17
|
+
*/
|
|
18
|
+
type ApiResponse<T = unknown> = SuccessResponse<T> | ErrorResponse;
|
|
19
|
+
interface SuccessResponse<T = unknown> {
|
|
20
|
+
readonly status: 'success';
|
|
21
|
+
readonly data: T;
|
|
22
|
+
}
|
|
23
|
+
interface ErrorResponse {
|
|
24
|
+
readonly status: 'error';
|
|
25
|
+
readonly message: string;
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly code: number;
|
|
28
|
+
readonly details?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Arc API Tokens Types
|
|
33
|
+
*
|
|
34
|
+
* Defines the core request and response types for the tokens.
|
|
35
|
+
*/
|
|
36
|
+
interface TokenInfo {
|
|
37
|
+
readonly address: string;
|
|
38
|
+
readonly chainId: number;
|
|
39
|
+
readonly symbol: string;
|
|
40
|
+
readonly decimals: number;
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly coinKey?: string;
|
|
43
|
+
readonly logoURI?: string;
|
|
44
|
+
readonly priceUSD?: string;
|
|
45
|
+
readonly originTokenAddress?: string;
|
|
46
|
+
readonly originTokenNetwork?: number | null;
|
|
47
|
+
}
|
|
48
|
+
interface TokenReference {
|
|
49
|
+
readonly address: string;
|
|
50
|
+
readonly chainId: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Arc API Chains Types
|
|
55
|
+
*
|
|
56
|
+
* Defines the core request and response types for the chains endpoint.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
interface IChain {
|
|
60
|
+
key: string;
|
|
61
|
+
chainType: 'EVM';
|
|
62
|
+
name: string;
|
|
63
|
+
chainId: number;
|
|
64
|
+
logoURI: string;
|
|
65
|
+
blockExplorerUrl: string;
|
|
66
|
+
nativeCurrency: {
|
|
67
|
+
name: string;
|
|
68
|
+
symbol: string;
|
|
69
|
+
decimals: number;
|
|
70
|
+
};
|
|
71
|
+
networkId?: number;
|
|
72
|
+
bridgeAddress?: string;
|
|
73
|
+
supportedRoutes: string[];
|
|
74
|
+
fromTokens?: TokenInfo[];
|
|
75
|
+
toTokens?: TokenInfo[];
|
|
76
|
+
}
|
|
77
|
+
type ChainsQueryParams = {
|
|
78
|
+
readonly withSupportedTokens?: boolean;
|
|
79
|
+
readonly chainIds?: readonly number[];
|
|
80
|
+
readonly limit?: number;
|
|
81
|
+
readonly startAfter?: number;
|
|
82
|
+
};
|
|
83
|
+
type ChainsResponse = {
|
|
84
|
+
readonly chains: IChain[];
|
|
85
|
+
readonly nextStartAfter?: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Arc API Routes Types
|
|
90
|
+
*
|
|
91
|
+
* Defines the core request and response types for the routes endpoint.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
interface RoutePreferences {
|
|
95
|
+
readonly prioritize?: 'COST' | 'SPEED';
|
|
96
|
+
readonly minAmountToReceive?: string;
|
|
97
|
+
readonly gasEstimate?: string;
|
|
98
|
+
readonly excludeProtocols?: readonly string[];
|
|
99
|
+
readonly includeProtocols?: readonly string[];
|
|
100
|
+
}
|
|
101
|
+
interface FeeCost {
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly description?: string;
|
|
104
|
+
readonly token: TokenInfo;
|
|
105
|
+
readonly amount: string;
|
|
106
|
+
readonly amountUSD?: string;
|
|
107
|
+
readonly percentage?: string;
|
|
108
|
+
readonly included: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface GasCost {
|
|
111
|
+
readonly type: 'SEND' | 'APPROVAL' | 'EXECUTION';
|
|
112
|
+
readonly chainId: number;
|
|
113
|
+
readonly price: string;
|
|
114
|
+
readonly estimate: string;
|
|
115
|
+
readonly limit: string;
|
|
116
|
+
readonly amount: string;
|
|
117
|
+
readonly amountUSD?: string;
|
|
118
|
+
readonly token: TokenReference;
|
|
119
|
+
}
|
|
120
|
+
type StepType = 'swap' | 'cross' | 'lifi';
|
|
121
|
+
interface ToolDetails {
|
|
122
|
+
readonly key: string;
|
|
123
|
+
readonly name: string;
|
|
124
|
+
readonly logoURI: string | null;
|
|
125
|
+
readonly webUrl?: string | null;
|
|
126
|
+
}
|
|
127
|
+
interface StepAction {
|
|
128
|
+
readonly fromChainId: number;
|
|
129
|
+
readonly toChainId: number;
|
|
130
|
+
readonly fromAmount: string;
|
|
131
|
+
readonly toAmount: string;
|
|
132
|
+
readonly fromToken: TokenInfo;
|
|
133
|
+
readonly toToken: TokenInfo;
|
|
134
|
+
readonly fromAddress: string | null;
|
|
135
|
+
readonly toAddress: string | null;
|
|
136
|
+
readonly contractAddress?: string | null;
|
|
137
|
+
readonly callData?: string | null;
|
|
138
|
+
readonly value?: string | null;
|
|
139
|
+
readonly slippage?: number;
|
|
140
|
+
readonly destinationGasConsumption?: string;
|
|
141
|
+
readonly destinationCallData?: string;
|
|
142
|
+
readonly toContractAddress?: string;
|
|
143
|
+
readonly toContractCallData?: string;
|
|
144
|
+
readonly toFallbackAddress?: string;
|
|
145
|
+
readonly callDataGasLimit?: string;
|
|
146
|
+
}
|
|
147
|
+
interface StepEstimate {
|
|
148
|
+
readonly tool: string;
|
|
149
|
+
readonly fromAmount: string;
|
|
150
|
+
readonly toAmount: string;
|
|
151
|
+
readonly toAmountMin: string;
|
|
152
|
+
readonly approvalAddress: string | null;
|
|
153
|
+
readonly executionDuration: number | null;
|
|
154
|
+
readonly feeCosts: FeeCost[];
|
|
155
|
+
readonly gasCosts: GasCost[];
|
|
156
|
+
readonly fromAmountUSD?: string | null;
|
|
157
|
+
readonly toAmountUSD?: string | null;
|
|
158
|
+
}
|
|
159
|
+
interface Step {
|
|
160
|
+
readonly id: string;
|
|
161
|
+
readonly type: StepType;
|
|
162
|
+
readonly tool: string;
|
|
163
|
+
readonly toolDetails: ToolDetails;
|
|
164
|
+
readonly action: StepAction;
|
|
165
|
+
readonly estimate: StepEstimate;
|
|
166
|
+
readonly includedSteps: Step[] | null;
|
|
167
|
+
readonly relatedSteps: string[] | null;
|
|
168
|
+
}
|
|
169
|
+
interface TransactionRequest {
|
|
170
|
+
readonly to: string;
|
|
171
|
+
readonly data: string;
|
|
172
|
+
readonly value: string;
|
|
173
|
+
readonly gasLimit: string;
|
|
174
|
+
readonly gasPrice?: string;
|
|
175
|
+
readonly chainId: number;
|
|
176
|
+
readonly from?: string;
|
|
177
|
+
}
|
|
178
|
+
interface ProviderMetadata {
|
|
179
|
+
readonly lifi?: {
|
|
180
|
+
readonly integrator: string | null;
|
|
181
|
+
readonly transactionRequest?: unknown;
|
|
182
|
+
};
|
|
183
|
+
readonly agglayer?: {
|
|
184
|
+
readonly bridgeAddress: string | null;
|
|
185
|
+
};
|
|
186
|
+
readonly [key: string]: unknown;
|
|
187
|
+
}
|
|
188
|
+
type RiskLevel = 'LOW' | 'MEDIUM' | 'HIGH' | null;
|
|
189
|
+
interface RiskFactors {
|
|
190
|
+
readonly slippageRisk: RiskLevel;
|
|
191
|
+
readonly executionRisk: RiskLevel;
|
|
192
|
+
readonly liquidityRisk: RiskLevel;
|
|
193
|
+
}
|
|
194
|
+
interface Route {
|
|
195
|
+
readonly id: string;
|
|
196
|
+
readonly provider: string[];
|
|
197
|
+
readonly isQuote: boolean;
|
|
198
|
+
readonly quoteValidUntil?: number;
|
|
199
|
+
readonly fromChainId: number;
|
|
200
|
+
readonly toChainId: number;
|
|
201
|
+
readonly fromAmount: string;
|
|
202
|
+
readonly toAmount: string;
|
|
203
|
+
readonly toAmountMin: string;
|
|
204
|
+
readonly fromAmountUSD: string | null;
|
|
205
|
+
readonly toAmountUSD: string | null;
|
|
206
|
+
readonly fromToken: TokenInfo;
|
|
207
|
+
readonly toToken: TokenInfo;
|
|
208
|
+
readonly gasCostUSD: string | null;
|
|
209
|
+
readonly totalCostUSD: string | null;
|
|
210
|
+
readonly executionDuration: number | null;
|
|
211
|
+
readonly slippagePercentage: number | null;
|
|
212
|
+
readonly containsSwitchChain: boolean;
|
|
213
|
+
readonly tags: string[];
|
|
214
|
+
readonly feeCosts: FeeCost[];
|
|
215
|
+
readonly gasCosts: GasCost[];
|
|
216
|
+
readonly steps: Step[];
|
|
217
|
+
readonly transactionRequest?: TransactionRequest;
|
|
218
|
+
readonly providerMetadata: ProviderMetadata;
|
|
219
|
+
readonly riskFactors: RiskFactors | null;
|
|
220
|
+
readonly createdAt: number;
|
|
221
|
+
readonly expiresAt: number | null;
|
|
222
|
+
readonly estimatedCompletionTime: number | null;
|
|
223
|
+
}
|
|
224
|
+
interface RouteStep {
|
|
225
|
+
readonly type: 'swap' | 'bridge' | 'transfer';
|
|
226
|
+
readonly protocol: string;
|
|
227
|
+
readonly fromToken: string;
|
|
228
|
+
readonly toToken: string;
|
|
229
|
+
readonly amount: string;
|
|
230
|
+
readonly estimatedAmountOut: string;
|
|
231
|
+
readonly gasEstimate: string;
|
|
232
|
+
readonly metadata?: Record<string, unknown>;
|
|
233
|
+
}
|
|
234
|
+
interface RoutesRequestParams {
|
|
235
|
+
readonly fromChainId: number;
|
|
236
|
+
readonly toChainId: number;
|
|
237
|
+
readonly fromTokenAddress: string;
|
|
238
|
+
readonly toTokenAddress: string;
|
|
239
|
+
readonly amount: string;
|
|
240
|
+
readonly fromAddress: string;
|
|
241
|
+
readonly toAddress?: string;
|
|
242
|
+
readonly slippage?: number;
|
|
243
|
+
readonly preferences?: RoutePreferences;
|
|
244
|
+
}
|
|
245
|
+
type RoutesResponse = readonly Route[];
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Arc API Transactions Types
|
|
249
|
+
*
|
|
250
|
+
* Defines the core request and response types for the transactions endpoint.
|
|
251
|
+
*/
|
|
252
|
+
interface Transaction {
|
|
253
|
+
id: string;
|
|
254
|
+
transactionHash: string;
|
|
255
|
+
bridgeHash: string | null;
|
|
256
|
+
protocols: string[];
|
|
257
|
+
status: string;
|
|
258
|
+
timestamp: number;
|
|
259
|
+
fromAddress: string;
|
|
260
|
+
toAddress: string;
|
|
261
|
+
sending: {
|
|
262
|
+
txHash: string;
|
|
263
|
+
network: {
|
|
264
|
+
chainId: number;
|
|
265
|
+
networkId: number | null;
|
|
266
|
+
};
|
|
267
|
+
timestamp: number;
|
|
268
|
+
token: {
|
|
269
|
+
originTokenAddress: string;
|
|
270
|
+
originTokenNetwork: number | null;
|
|
271
|
+
};
|
|
272
|
+
amount: string;
|
|
273
|
+
includedSteps: unknown[] | null;
|
|
274
|
+
};
|
|
275
|
+
receiving: {
|
|
276
|
+
txHash: string | null;
|
|
277
|
+
network: {
|
|
278
|
+
chainId: number;
|
|
279
|
+
networkId: number | null;
|
|
280
|
+
};
|
|
281
|
+
timestamp: number | null;
|
|
282
|
+
amount: string;
|
|
283
|
+
tokenAddress: string;
|
|
284
|
+
} | null;
|
|
285
|
+
leafType: string | null;
|
|
286
|
+
depositCount: number | null;
|
|
287
|
+
transactionIndex: number | null;
|
|
288
|
+
blockNumber: number | null;
|
|
289
|
+
leafIndex: number | null;
|
|
290
|
+
metadata: {
|
|
291
|
+
integrator: string | null;
|
|
292
|
+
feeCosts: unknown[] | null;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
interface TransactionsRequestQueryParams {
|
|
296
|
+
readonly fromAddress?: string;
|
|
297
|
+
readonly sorceNetworkIds?: string;
|
|
298
|
+
readonly destinationNetworkIds?: string;
|
|
299
|
+
readonly limit?: number;
|
|
300
|
+
readonly startAfter?: number;
|
|
301
|
+
}
|
|
302
|
+
type TransactionsResponse = {
|
|
303
|
+
transactions: Transaction[];
|
|
304
|
+
nextStartAfter?: number;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Arc API Built Transaction Types
|
|
309
|
+
*
|
|
310
|
+
* Defines the core request and response types for the built transaction endpoint.
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
type BuildTransactionRequestBody = Step;
|
|
314
|
+
type BuildTransactionResponse = Route;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Chain Types
|
|
318
|
+
*
|
|
319
|
+
* Types related to blockchain chains and networks
|
|
320
|
+
*/
|
|
321
|
+
interface ChainConfig {
|
|
322
|
+
chainId: number;
|
|
323
|
+
networkId: number;
|
|
324
|
+
name: string;
|
|
325
|
+
rpcUrl: string;
|
|
326
|
+
nativeCurrency: {
|
|
327
|
+
name: string;
|
|
328
|
+
symbol: string;
|
|
329
|
+
decimals: number;
|
|
330
|
+
};
|
|
331
|
+
blockExplorer?: {
|
|
332
|
+
name: string;
|
|
333
|
+
url: string;
|
|
334
|
+
};
|
|
335
|
+
bridgeAddress?: string;
|
|
336
|
+
proofApiUrl?: string;
|
|
337
|
+
isTestnet?: boolean;
|
|
338
|
+
isLocal?: boolean;
|
|
339
|
+
}
|
|
340
|
+
interface CustomChainConfig extends ChainConfig {
|
|
341
|
+
isTestnet?: boolean;
|
|
342
|
+
isLocal?: boolean;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Native Config
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
interface NativeConfig {
|
|
350
|
+
defaultNetwork?: number;
|
|
351
|
+
chains?: ChainConfig[];
|
|
352
|
+
customRpcUrls?: Record<number, string>;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Bridge Types
|
|
357
|
+
*
|
|
358
|
+
* Types related to bridge operations
|
|
359
|
+
*/
|
|
360
|
+
interface BridgeAssetParams {
|
|
361
|
+
destinationNetwork: number;
|
|
362
|
+
destinationAddress: string;
|
|
363
|
+
amount: string;
|
|
364
|
+
token: string;
|
|
365
|
+
forceUpdateGlobalExitRoot: boolean;
|
|
366
|
+
permitData?: string;
|
|
367
|
+
}
|
|
368
|
+
interface BridgeOptions {
|
|
369
|
+
forceUpdateGlobalExitRoot?: boolean;
|
|
370
|
+
permitData?: string;
|
|
371
|
+
gasLimit?: string;
|
|
372
|
+
maxFeePerGas?: string;
|
|
373
|
+
maxPriorityFeePerGas?: string;
|
|
374
|
+
}
|
|
375
|
+
interface ClaimAssetParams {
|
|
376
|
+
smtProofLocalExitRoot: readonly `0x${string}`[];
|
|
377
|
+
smtProofRollupExitRoot: readonly `0x${string}`[];
|
|
378
|
+
globalIndex: bigint;
|
|
379
|
+
mainnetExitRoot: `0x${string}`;
|
|
380
|
+
rollupExitRoot: `0x${string}`;
|
|
381
|
+
originNetwork: number;
|
|
382
|
+
originTokenAddress: string;
|
|
383
|
+
destinationNetwork: number;
|
|
384
|
+
destinationAddress: string;
|
|
385
|
+
amount: bigint;
|
|
386
|
+
metadata: `0x${string}`;
|
|
387
|
+
}
|
|
388
|
+
interface IsClaimedParams {
|
|
389
|
+
leafIndex: number;
|
|
390
|
+
sourceBridgeNetwork: number;
|
|
391
|
+
}
|
|
392
|
+
interface WrappedTokenParams {
|
|
393
|
+
originNetwork: number;
|
|
394
|
+
originTokenAddress: string;
|
|
395
|
+
}
|
|
396
|
+
interface BridgeMessageParams {
|
|
397
|
+
destinationNetwork: number;
|
|
398
|
+
destinationAddress: string;
|
|
399
|
+
forceUpdateGlobalExitRoot: boolean;
|
|
400
|
+
permitData?: string;
|
|
401
|
+
}
|
|
402
|
+
interface ClaimMessageParams {
|
|
403
|
+
smtProofLocalExitRoot: readonly `0x${string}`[];
|
|
404
|
+
smtProofRollupExitRoot: readonly `0x${string}`[];
|
|
405
|
+
globalIndex: bigint;
|
|
406
|
+
mainnetExitRoot: `0x${string}`;
|
|
407
|
+
rollupExitRoot: `0x${string}`;
|
|
408
|
+
originNetwork: number;
|
|
409
|
+
originTokenAddress: string;
|
|
410
|
+
destinationNetwork: number;
|
|
411
|
+
destinationAddress: string;
|
|
412
|
+
amount: bigint;
|
|
413
|
+
metadata: `0x${string}`;
|
|
414
|
+
}
|
|
415
|
+
interface PrecalculatedWrapperParams {
|
|
416
|
+
originNetwork: number;
|
|
417
|
+
originTokenAddress: string;
|
|
418
|
+
}
|
|
419
|
+
interface OriginTokenInfoParams {
|
|
420
|
+
wrappedToken: string;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Contract Types
|
|
425
|
+
*
|
|
426
|
+
* Types related to contract interactions and configurations
|
|
427
|
+
*/
|
|
428
|
+
interface BaseContractConfig {
|
|
429
|
+
rpcUrl: string;
|
|
430
|
+
chainId: number;
|
|
431
|
+
}
|
|
432
|
+
interface ERC20Config extends BaseContractConfig {
|
|
433
|
+
tokenAddress: string;
|
|
434
|
+
}
|
|
435
|
+
interface BridgeConfig extends BaseContractConfig {
|
|
436
|
+
bridgeAddress: string;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Transaction Types
|
|
441
|
+
*
|
|
442
|
+
* Types related to transaction operations
|
|
443
|
+
*/
|
|
444
|
+
interface TransactionParams {
|
|
445
|
+
from?: string | undefined;
|
|
446
|
+
to: string;
|
|
447
|
+
data: string;
|
|
448
|
+
value?: string;
|
|
449
|
+
gas?: string;
|
|
450
|
+
gasPrice?: string;
|
|
451
|
+
maxFeePerGas?: string;
|
|
452
|
+
maxPriorityFeePerGas?: string;
|
|
453
|
+
nonce?: string | undefined;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* SDK Config
|
|
458
|
+
*/
|
|
459
|
+
declare const SDK_MODES: {
|
|
460
|
+
readonly CORE: "CORE";
|
|
461
|
+
readonly NATIVE: "NATIVE";
|
|
462
|
+
};
|
|
463
|
+
type SDKMode = (typeof SDK_MODES)[keyof typeof SDK_MODES];
|
|
464
|
+
|
|
465
|
+
interface SDKConfig {
|
|
466
|
+
mode: SDKMode[];
|
|
467
|
+
core: CoreConfig;
|
|
468
|
+
native: NativeConfig;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Chain Registry
|
|
473
|
+
*
|
|
474
|
+
* Centralized chain configuration management
|
|
475
|
+
*/
|
|
476
|
+
|
|
477
|
+
declare class ChainRegistry {
|
|
478
|
+
private static instance;
|
|
479
|
+
private chains;
|
|
480
|
+
private viemChains;
|
|
481
|
+
private constructor();
|
|
482
|
+
static getInstance(): ChainRegistry;
|
|
483
|
+
private initializeDefaultChains;
|
|
484
|
+
/**
|
|
485
|
+
* Register a new chain
|
|
486
|
+
*/
|
|
487
|
+
registerChain(config: ChainConfig): void;
|
|
488
|
+
/**
|
|
489
|
+
* Get chain configuration by ID
|
|
490
|
+
*/
|
|
491
|
+
getChain(chainId: number): ChainConfig;
|
|
492
|
+
/**
|
|
493
|
+
* Get chain configuration by network ID
|
|
494
|
+
*/
|
|
495
|
+
getChainByNetworkId(networkId: number): ChainConfig;
|
|
496
|
+
/**
|
|
497
|
+
* Get viem chain object by ID
|
|
498
|
+
*/
|
|
499
|
+
getViemChain(chainId: number): Chain;
|
|
500
|
+
/**
|
|
501
|
+
* Get all registered chain IDs
|
|
502
|
+
*/
|
|
503
|
+
getSupportedChainIds(): number[];
|
|
504
|
+
/**
|
|
505
|
+
* Get all registered chains
|
|
506
|
+
*/
|
|
507
|
+
getAllChains(): ChainConfig[];
|
|
508
|
+
/**
|
|
509
|
+
* Check if chain is supported
|
|
510
|
+
*/
|
|
511
|
+
isChainSupported(chainId: number): boolean;
|
|
512
|
+
/**
|
|
513
|
+
* Check if chain is supported by network ID
|
|
514
|
+
*/
|
|
515
|
+
isChainSupportedByNetworkId(networkId: number): boolean;
|
|
516
|
+
/**
|
|
517
|
+
* Get chains by type
|
|
518
|
+
*/
|
|
519
|
+
getChainsByType(type: 'mainnet' | 'testnet' | 'local'): ChainConfig[];
|
|
520
|
+
/**
|
|
521
|
+
* Add custom RPC URL for existing chain
|
|
522
|
+
*/
|
|
523
|
+
addCustomRpcUrl(chainId: number, rpcUrl: string): void;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Bridge Utility Implementation
|
|
528
|
+
*
|
|
529
|
+
* User-friendly bridge operations that abstract complex parameter handling
|
|
530
|
+
*/
|
|
531
|
+
|
|
532
|
+
interface BridgeEventInfo {
|
|
533
|
+
originNetwork: number;
|
|
534
|
+
originTokenAddress: string;
|
|
535
|
+
destinationNetwork: number;
|
|
536
|
+
destinationAddress: string;
|
|
537
|
+
amount: bigint;
|
|
538
|
+
metadata: string;
|
|
539
|
+
depositCount: number;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Base Contract Implementation
|
|
544
|
+
*
|
|
545
|
+
* Shared functionality for contract interactions
|
|
546
|
+
*/
|
|
547
|
+
|
|
548
|
+
declare abstract class BaseContract {
|
|
549
|
+
protected client: PublicClient;
|
|
550
|
+
constructor(config: BaseContractConfig);
|
|
551
|
+
/**
|
|
552
|
+
* Get nonce for an address
|
|
553
|
+
*/
|
|
554
|
+
protected getNonce(address?: string): Promise<string | undefined>;
|
|
555
|
+
/**
|
|
556
|
+
* Estimate gas for transaction
|
|
557
|
+
*/
|
|
558
|
+
protected estimateGas(data: Hex, to: string, from?: string): Promise<string>;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
declare class ERC20 extends BaseContract {
|
|
562
|
+
private tokenAddress;
|
|
563
|
+
private config;
|
|
564
|
+
constructor(config: ERC20Config);
|
|
565
|
+
/**
|
|
566
|
+
* Get ERC20 token balance in wei
|
|
567
|
+
*/
|
|
568
|
+
getBalance(address: string): Promise<string>;
|
|
569
|
+
/**
|
|
570
|
+
* Get allowance in wei
|
|
571
|
+
*/
|
|
572
|
+
getAllowance(owner: string, spender: string): Promise<string>;
|
|
573
|
+
/**
|
|
574
|
+
* Build approve transaction
|
|
575
|
+
*/
|
|
576
|
+
buildApprove(spender: string, amount: string, from?: string): Promise<TransactionParams>;
|
|
577
|
+
/**
|
|
578
|
+
* Build transfer transaction
|
|
579
|
+
*/
|
|
580
|
+
buildTransfer(to: string, amount: string, from?: string): Promise<TransactionParams>;
|
|
581
|
+
/**
|
|
582
|
+
* Build transferFrom transaction
|
|
583
|
+
*/
|
|
584
|
+
buildTransferFrom(from: string, to: string, amount: string, spender?: string): Promise<TransactionParams>;
|
|
585
|
+
/**
|
|
586
|
+
* Bridge this token to another network
|
|
587
|
+
*/
|
|
588
|
+
bridgeTo(destinationNetwork: number, destinationAddress: string, amount: string, from?: string, options?: BridgeOptions): Promise<TransactionParams>;
|
|
589
|
+
/**
|
|
590
|
+
* Get wrapped version of this token on destination network
|
|
591
|
+
*/
|
|
592
|
+
getWrappedToken(): Promise<string>;
|
|
593
|
+
/**
|
|
594
|
+
* Claim asset from bridge transaction hash
|
|
595
|
+
*
|
|
596
|
+
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
597
|
+
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
598
|
+
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
599
|
+
* @param from - From address for the claim transaction
|
|
600
|
+
*/
|
|
601
|
+
claimAsset(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
602
|
+
/**
|
|
603
|
+
* Claim message from bridge transaction hash
|
|
604
|
+
*
|
|
605
|
+
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
606
|
+
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
607
|
+
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
608
|
+
* @param from - From address for the claim transaction
|
|
609
|
+
*/
|
|
610
|
+
claimMessage(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
611
|
+
/**
|
|
612
|
+
* Get bridge event info from transaction hash
|
|
613
|
+
*
|
|
614
|
+
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
615
|
+
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
616
|
+
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
617
|
+
*/
|
|
618
|
+
getBridgeEventInfo(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number): Promise<BridgeEventInfo>;
|
|
619
|
+
private getBridge;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
declare class Bridge extends BaseContract {
|
|
623
|
+
private bridgeAddress;
|
|
624
|
+
constructor(config: BridgeConfig);
|
|
625
|
+
/**
|
|
626
|
+
* Build bridge asset transaction
|
|
627
|
+
*/
|
|
628
|
+
buildBridgeAsset(params: BridgeAssetParams, from?: string): Promise<TransactionParams>;
|
|
629
|
+
/**
|
|
630
|
+
* Build claim asset transaction
|
|
631
|
+
*/
|
|
632
|
+
buildClaimAsset(params: ClaimAssetParams, from?: string): Promise<TransactionParams>;
|
|
633
|
+
/**
|
|
634
|
+
* Check if bridge deposit is claimed
|
|
635
|
+
*/
|
|
636
|
+
isClaimed(params: IsClaimedParams): Promise<boolean>;
|
|
637
|
+
/**
|
|
638
|
+
* Get wrapped token address
|
|
639
|
+
*/
|
|
640
|
+
getWrappedTokenAddress(params: WrappedTokenParams): Promise<string>;
|
|
641
|
+
/**
|
|
642
|
+
* Get network ID
|
|
643
|
+
*/
|
|
644
|
+
getNetworkId(): Promise<number>;
|
|
645
|
+
/**
|
|
646
|
+
* Get bridge contract address
|
|
647
|
+
*/
|
|
648
|
+
getBridgeAddress(): string;
|
|
649
|
+
/**
|
|
650
|
+
* Build bridge message transaction
|
|
651
|
+
*/
|
|
652
|
+
buildBridgeMessage(params: BridgeMessageParams, from?: string): Promise<TransactionParams>;
|
|
653
|
+
/**
|
|
654
|
+
* Build claim message transaction
|
|
655
|
+
*/
|
|
656
|
+
buildClaimMessage(params: ClaimMessageParams, from?: string): Promise<TransactionParams>;
|
|
657
|
+
/**
|
|
658
|
+
* Get precalculated wrapper address
|
|
659
|
+
*/
|
|
660
|
+
getPrecalculatedWrapperAddress(params: PrecalculatedWrapperParams): Promise<string>;
|
|
661
|
+
/**
|
|
662
|
+
* Get origin token info from wrapped token
|
|
663
|
+
*/
|
|
664
|
+
getOriginTokenInfo(params: OriginTokenInfoParams): Promise<readonly [number, string]>;
|
|
665
|
+
/**
|
|
666
|
+
* Build claim asset transaction from bridge transaction hash
|
|
667
|
+
*
|
|
668
|
+
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
669
|
+
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
670
|
+
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
671
|
+
* @param from - From address for the claim transaction
|
|
672
|
+
*/
|
|
673
|
+
buildClaimAssetFromHash(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
674
|
+
/**
|
|
675
|
+
* Build claim message transaction from bridge transaction hash
|
|
676
|
+
*
|
|
677
|
+
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
678
|
+
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
679
|
+
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
680
|
+
* @param from - From address for the claim transaction
|
|
681
|
+
*/
|
|
682
|
+
buildClaimMessageFromHash(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
683
|
+
/**
|
|
684
|
+
* Get bridge event info from transaction hash
|
|
685
|
+
*
|
|
686
|
+
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
687
|
+
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
688
|
+
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
689
|
+
*/
|
|
690
|
+
getBridgeEventInfo(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number): Promise<BridgeEventInfo>;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
declare class NativeClient {
|
|
694
|
+
private config;
|
|
695
|
+
private defaultNetwork;
|
|
696
|
+
constructor(config: NativeConfig);
|
|
697
|
+
/**
|
|
698
|
+
* Get network configuration from chain registry
|
|
699
|
+
* @param networkId - The network ID (chain ID)
|
|
700
|
+
* @returns Chain configuration
|
|
701
|
+
*/
|
|
702
|
+
getNetwork(networkId: number): ChainConfig;
|
|
703
|
+
/**
|
|
704
|
+
* Get all supported networks
|
|
705
|
+
* @returns Array of network IDs
|
|
706
|
+
*/
|
|
707
|
+
getSupportedNetworks(): number[];
|
|
708
|
+
/**
|
|
709
|
+
* Get default network ID
|
|
710
|
+
* @returns Default network ID
|
|
711
|
+
*/
|
|
712
|
+
getDefaultNetwork(): number;
|
|
713
|
+
/**
|
|
714
|
+
* Get chain registry for advanced usage
|
|
715
|
+
*/
|
|
716
|
+
getChainRegistry(): ChainRegistry;
|
|
717
|
+
/**
|
|
718
|
+
* Create an ERC20 instance for a specific token on a specific network
|
|
719
|
+
* @param tokenAddress - The ERC20 token contract address
|
|
720
|
+
* @param networkId - The network ID (optional, uses default if not provided)
|
|
721
|
+
* @returns ERC20 instance
|
|
722
|
+
*/
|
|
723
|
+
erc20(tokenAddress: string, networkId?: number): ERC20;
|
|
724
|
+
/**
|
|
725
|
+
* Get native token balance in wei
|
|
726
|
+
* @param address - The address to check balance for
|
|
727
|
+
* @param networkId - The network ID (optional, uses default if not provided)
|
|
728
|
+
* @returns Native token balance as string
|
|
729
|
+
*/
|
|
730
|
+
getNativeBalance(address: string, networkId?: number): Promise<string>;
|
|
731
|
+
/**
|
|
732
|
+
* Create a Bridge instance for a specific network
|
|
733
|
+
* @param bridgeAddress - The bridge contract address
|
|
734
|
+
* @param networkId - The network ID (optional, uses default if not provided)
|
|
735
|
+
* @returns Bridge instance
|
|
736
|
+
*/
|
|
737
|
+
bridge(bridgeAddress: string, networkId?: number): Bridge;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Core Module
|
|
742
|
+
*
|
|
743
|
+
* Primary interface for users
|
|
744
|
+
*/
|
|
745
|
+
|
|
746
|
+
declare class CoreClient {
|
|
747
|
+
private config;
|
|
748
|
+
private arcApiService;
|
|
749
|
+
constructor(config: CoreConfig);
|
|
750
|
+
/**
|
|
751
|
+
* Get all chains metadata from AggLayer API
|
|
752
|
+
*/
|
|
753
|
+
getAllChains(): Promise<ChainsResponse>;
|
|
754
|
+
/**
|
|
755
|
+
* Get chain metadata by id from AggLayer API
|
|
756
|
+
* @param ids - the ids of the chains to get metadata for
|
|
757
|
+
*/
|
|
758
|
+
getChainMetadataByChainIds(ids: number[]): Promise<ChainsResponse>;
|
|
759
|
+
/**
|
|
760
|
+
* Get all tokens from AggLayer API
|
|
761
|
+
*/
|
|
762
|
+
getTokens(): Promise<ChainsResponse>;
|
|
763
|
+
/**
|
|
764
|
+
* Get chain data and tokens by AggLayer API
|
|
765
|
+
* @param ids - the ids of the chains to get data and tokens for
|
|
766
|
+
*/
|
|
767
|
+
getChainDataAndTokensByChainIds(ids: number[]): Promise<ChainsResponse>;
|
|
768
|
+
/**
|
|
769
|
+
* Get all routes from AggLayer API
|
|
770
|
+
*/
|
|
771
|
+
getRoutes(routesRequestParams: RoutesRequestParams): Promise<RoutesResponse>;
|
|
772
|
+
/**
|
|
773
|
+
* Build transaction from a step object
|
|
774
|
+
*/
|
|
775
|
+
buildTransaction(builtTransactionRequestBody: BuildTransactionRequestBody): Promise<BuildTransactionResponse>;
|
|
776
|
+
/**
|
|
777
|
+
* Get all transactions via web sockets
|
|
778
|
+
*/
|
|
779
|
+
getTransactions(transactionsRequestQueryParams: TransactionsRequestQueryParams): Promise<TransactionsResponse>;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* AggLayer SDK - Main SDK
|
|
784
|
+
*
|
|
785
|
+
* Main SDK that orchestrates different submodules
|
|
786
|
+
*/
|
|
787
|
+
|
|
788
|
+
declare class AggLayerSDK {
|
|
789
|
+
private config;
|
|
790
|
+
private core?;
|
|
791
|
+
private native?;
|
|
792
|
+
constructor(config: SDKConfig);
|
|
793
|
+
/**
|
|
794
|
+
* Get core submodule
|
|
795
|
+
*/
|
|
796
|
+
getCore(): CoreClient;
|
|
797
|
+
/**
|
|
798
|
+
* Get native submodule
|
|
799
|
+
*/
|
|
800
|
+
getNative(): NativeClient;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
export { AggLayerSDK, type ApiResponse, type BaseContractConfig, type BridgeAssetParams, type BridgeConfig, type BridgeMessageParams, type BridgeOptions, type BuildTransactionRequestBody, type BuildTransactionResponse, type ChainConfig, type ChainsQueryParams, type ChainsResponse, type ClaimAssetParams, type ClaimMessageParams, type CoreConfig, type CustomChainConfig, type ERC20Config, type ErrorResponse, type FeeCost, type GasCost, type IChain, type IsClaimedParams, type NativeConfig, type OriginTokenInfoParams, type PrecalculatedWrapperParams, type ProviderMetadata, type RiskFactors, type RiskLevel, type Route, type RoutePreferences, type RouteStep, type RoutesRequestParams, type RoutesResponse, type SDKConfig, type SDKMode, SDK_MODES, type Step, type StepAction, type StepEstimate, type StepType, type SuccessResponse, type TokenInfo, type TokenReference, type ToolDetails, type Transaction, type TransactionParams, type TransactionRequest, type TransactionsRequestQueryParams, type TransactionsResponse, type WrappedTokenParams };
|