@agglayer/sdk 1.0.0-beta.15 → 1.0.0-beta.17
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/index.d.mts +76 -19
- package/dist/index.d.ts +76 -19
- package/dist/index.js +127 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,7 @@ type ApiResponse<T = unknown> = SuccessResponse<T> | ErrorResponse;
|
|
|
19
19
|
interface SuccessResponse<T = unknown> {
|
|
20
20
|
readonly status: 'success';
|
|
21
21
|
readonly data: T;
|
|
22
|
+
readonly pagination?: OffsetPagination | CursorPagination;
|
|
22
23
|
}
|
|
23
24
|
interface ErrorResponse {
|
|
24
25
|
readonly status: 'error';
|
|
@@ -27,6 +28,16 @@ interface ErrorResponse {
|
|
|
27
28
|
readonly code: number;
|
|
28
29
|
readonly details?: Record<string, unknown>;
|
|
29
30
|
}
|
|
31
|
+
interface Pagination {
|
|
32
|
+
readonly total?: number;
|
|
33
|
+
readonly limit?: number;
|
|
34
|
+
}
|
|
35
|
+
interface OffsetPagination extends Pagination {
|
|
36
|
+
readonly offset?: number;
|
|
37
|
+
}
|
|
38
|
+
interface CursorPagination extends Pagination {
|
|
39
|
+
readonly nextStartAfterCursor?: string;
|
|
40
|
+
}
|
|
30
41
|
|
|
31
42
|
/**
|
|
32
43
|
* Arc API Tokens Types
|
|
@@ -67,6 +78,11 @@ interface IChain {
|
|
|
67
78
|
name: string;
|
|
68
79
|
symbol: string;
|
|
69
80
|
decimals: number;
|
|
81
|
+
address: string;
|
|
82
|
+
logoURI: string;
|
|
83
|
+
priceUSD: string;
|
|
84
|
+
originTokenAddress?: string;
|
|
85
|
+
originChainId?: number;
|
|
70
86
|
};
|
|
71
87
|
networkId?: number;
|
|
72
88
|
bridgeAddress?: string;
|
|
@@ -78,13 +94,27 @@ type ChainsQueryParams = {
|
|
|
78
94
|
readonly withSupportedTokens?: boolean;
|
|
79
95
|
readonly chainIds?: readonly number[];
|
|
80
96
|
readonly limit?: number;
|
|
81
|
-
readonly
|
|
97
|
+
readonly offset?: number;
|
|
82
98
|
};
|
|
83
99
|
type ChainsResponse = {
|
|
84
100
|
readonly chains: IChain[];
|
|
85
|
-
readonly nextStartAfter?: number;
|
|
86
101
|
};
|
|
87
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Arc API Unsigned Transaction Types
|
|
105
|
+
*
|
|
106
|
+
* Defines the core request and response types for the tokens.
|
|
107
|
+
*/
|
|
108
|
+
interface UnsignedTransaction {
|
|
109
|
+
readonly to: string;
|
|
110
|
+
readonly data: string;
|
|
111
|
+
readonly value: string;
|
|
112
|
+
readonly gasLimit: string;
|
|
113
|
+
readonly gasPrice?: string;
|
|
114
|
+
readonly chainId: number;
|
|
115
|
+
readonly from?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
88
118
|
/**
|
|
89
119
|
* Arc API Routes Types
|
|
90
120
|
*
|
|
@@ -166,15 +196,6 @@ interface Step {
|
|
|
166
196
|
readonly includedSteps: Step[] | null;
|
|
167
197
|
readonly relatedSteps: string[] | null;
|
|
168
198
|
}
|
|
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
199
|
interface ProviderMetadata {
|
|
179
200
|
readonly lifi?: {
|
|
180
201
|
readonly integrator: string | null;
|
|
@@ -214,7 +235,7 @@ interface Route {
|
|
|
214
235
|
readonly feeCosts: FeeCost[];
|
|
215
236
|
readonly gasCosts: GasCost[];
|
|
216
237
|
readonly steps: Step[];
|
|
217
|
-
readonly transactionRequest?:
|
|
238
|
+
readonly transactionRequest?: UnsignedTransaction;
|
|
218
239
|
readonly providerMetadata: ProviderMetadata;
|
|
219
240
|
readonly riskFactors: RiskFactors | null;
|
|
220
241
|
readonly createdAt: number;
|
|
@@ -293,7 +314,7 @@ interface Transaction {
|
|
|
293
314
|
};
|
|
294
315
|
}
|
|
295
316
|
interface TransactionsRequestQueryParams {
|
|
296
|
-
readonly
|
|
317
|
+
readonly address?: string;
|
|
297
318
|
readonly sorceNetworkIds?: string;
|
|
298
319
|
readonly destinationNetworkIds?: string;
|
|
299
320
|
readonly limit?: number;
|
|
@@ -301,7 +322,6 @@ interface TransactionsRequestQueryParams {
|
|
|
301
322
|
}
|
|
302
323
|
type TransactionsResponse = {
|
|
303
324
|
transactions: Transaction[];
|
|
304
|
-
nextStartAfter?: number;
|
|
305
325
|
};
|
|
306
326
|
|
|
307
327
|
/**
|
|
@@ -311,7 +331,19 @@ type TransactionsResponse = {
|
|
|
311
331
|
*/
|
|
312
332
|
|
|
313
333
|
type BuildTransactionRequestBody = Step;
|
|
314
|
-
type BuildTransactionResponse =
|
|
334
|
+
type BuildTransactionResponse = UnsignedTransaction;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Arc API Build Claim Transaction Types
|
|
338
|
+
*
|
|
339
|
+
* Defines the core request and response types for the build claim transaction endpoint.
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
type BuildClaimTransactionRequestParam = {
|
|
343
|
+
sourceNetworkId: number;
|
|
344
|
+
depositCount: number;
|
|
345
|
+
};
|
|
346
|
+
type BuildClaimTransactionResponse = UnsignedTransaction;
|
|
315
347
|
|
|
316
348
|
/**
|
|
317
349
|
* Chain Types
|
|
@@ -747,19 +779,32 @@ declare class CoreClient {
|
|
|
747
779
|
private config;
|
|
748
780
|
private arcApiService;
|
|
749
781
|
constructor(config: CoreConfig);
|
|
782
|
+
/**
|
|
783
|
+
* Generic pagination helper for chains API calls (limit and offset based pagination)
|
|
784
|
+
* Handles automatic pagination to fetch all available data
|
|
785
|
+
* @param params - Parameters for the chains API call
|
|
786
|
+
* @param pageSize - Number of items per page (defaults to DEFAULT_CHAINS_PER_PAGE)
|
|
787
|
+
*/
|
|
788
|
+
private getAllChainsPaginated;
|
|
750
789
|
/**
|
|
751
790
|
* Get all chains metadata from AggLayer API
|
|
791
|
+
* Handles pagination automatically to fetch all available chains
|
|
752
792
|
*/
|
|
753
793
|
getAllChains(): Promise<ChainsResponse>;
|
|
754
794
|
/**
|
|
755
795
|
* Get chain metadata by id from AggLayer API
|
|
796
|
+
* Handles pagination automatically to fetch all available chain metadata
|
|
756
797
|
* @param ids - the ids of the chains to get metadata for
|
|
757
798
|
*/
|
|
758
799
|
getChainMetadataByChainIds(ids: number[]): Promise<ChainsResponse>;
|
|
759
800
|
/**
|
|
760
801
|
* Get all tokens from AggLayer API
|
|
802
|
+
*
|
|
803
|
+
* Developer Note: This method is not recommended to use frequently or from frontend.
|
|
804
|
+
* As it can be very slow and resource intensive.
|
|
805
|
+
* It is recommended to use getChainDataAndTokensByChainIds instead.
|
|
761
806
|
*/
|
|
762
|
-
|
|
807
|
+
getAllTokens(): Promise<ChainsResponse>;
|
|
763
808
|
/**
|
|
764
809
|
* Get chain data and tokens by AggLayer API
|
|
765
810
|
* @param ids - the ids of the chains to get data and tokens for
|
|
@@ -770,9 +815,21 @@ declare class CoreClient {
|
|
|
770
815
|
*/
|
|
771
816
|
getRoutes(routesRequestParams: RoutesRequestParams): Promise<RoutesResponse>;
|
|
772
817
|
/**
|
|
773
|
-
*
|
|
818
|
+
* Get calldata from a route
|
|
819
|
+
* If route has transactionRequest field, return it directly as calldata
|
|
820
|
+
* Otherwise, call buildTransaction on route.steps[0] and return that as calldata
|
|
821
|
+
*/
|
|
822
|
+
getUnsignedTransaction(route: Route): Promise<UnsignedTransaction>;
|
|
823
|
+
/**
|
|
824
|
+
* Get calldata for claim step
|
|
825
|
+
* Needs to be called separately as claim step is not part of route.
|
|
826
|
+
*
|
|
827
|
+
* @developer Note: Do not misinterpret network ID as chain ID.
|
|
828
|
+
*
|
|
829
|
+
* @param sourceNetworkId - The source network ID where the transfer was initiated.
|
|
830
|
+
* @param depositCount - The deposit count associated with the transfer.
|
|
774
831
|
*/
|
|
775
|
-
|
|
832
|
+
getClaimUnsignedTransaction(buildClaimTxParams: BuildClaimTransactionRequestParam): Promise<UnsignedTransaction>;
|
|
776
833
|
/**
|
|
777
834
|
* Get all transactions via web sockets
|
|
778
835
|
*/
|
|
@@ -800,4 +857,4 @@ declare class AggLayerSDK {
|
|
|
800
857
|
getNative(): NativeClient;
|
|
801
858
|
}
|
|
802
859
|
|
|
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
|
|
860
|
+
export { AggLayerSDK, type ApiResponse, type BaseContractConfig, type BridgeAssetParams, type BridgeConfig, type BridgeMessageParams, type BridgeOptions, type BuildClaimTransactionRequestParam, type BuildClaimTransactionResponse, type BuildTransactionRequestBody, type BuildTransactionResponse, type ChainConfig, type ChainsQueryParams, type ChainsResponse, type ClaimAssetParams, type ClaimMessageParams, type CoreConfig, type CursorPagination, type CustomChainConfig, type ERC20Config, type ErrorResponse, type FeeCost, type GasCost, type IChain, type IsClaimedParams, type NativeConfig, type OffsetPagination, type OriginTokenInfoParams, type Pagination, 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 TransactionsRequestQueryParams, type TransactionsResponse, type WrappedTokenParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ type ApiResponse<T = unknown> = SuccessResponse<T> | ErrorResponse;
|
|
|
19
19
|
interface SuccessResponse<T = unknown> {
|
|
20
20
|
readonly status: 'success';
|
|
21
21
|
readonly data: T;
|
|
22
|
+
readonly pagination?: OffsetPagination | CursorPagination;
|
|
22
23
|
}
|
|
23
24
|
interface ErrorResponse {
|
|
24
25
|
readonly status: 'error';
|
|
@@ -27,6 +28,16 @@ interface ErrorResponse {
|
|
|
27
28
|
readonly code: number;
|
|
28
29
|
readonly details?: Record<string, unknown>;
|
|
29
30
|
}
|
|
31
|
+
interface Pagination {
|
|
32
|
+
readonly total?: number;
|
|
33
|
+
readonly limit?: number;
|
|
34
|
+
}
|
|
35
|
+
interface OffsetPagination extends Pagination {
|
|
36
|
+
readonly offset?: number;
|
|
37
|
+
}
|
|
38
|
+
interface CursorPagination extends Pagination {
|
|
39
|
+
readonly nextStartAfterCursor?: string;
|
|
40
|
+
}
|
|
30
41
|
|
|
31
42
|
/**
|
|
32
43
|
* Arc API Tokens Types
|
|
@@ -67,6 +78,11 @@ interface IChain {
|
|
|
67
78
|
name: string;
|
|
68
79
|
symbol: string;
|
|
69
80
|
decimals: number;
|
|
81
|
+
address: string;
|
|
82
|
+
logoURI: string;
|
|
83
|
+
priceUSD: string;
|
|
84
|
+
originTokenAddress?: string;
|
|
85
|
+
originChainId?: number;
|
|
70
86
|
};
|
|
71
87
|
networkId?: number;
|
|
72
88
|
bridgeAddress?: string;
|
|
@@ -78,13 +94,27 @@ type ChainsQueryParams = {
|
|
|
78
94
|
readonly withSupportedTokens?: boolean;
|
|
79
95
|
readonly chainIds?: readonly number[];
|
|
80
96
|
readonly limit?: number;
|
|
81
|
-
readonly
|
|
97
|
+
readonly offset?: number;
|
|
82
98
|
};
|
|
83
99
|
type ChainsResponse = {
|
|
84
100
|
readonly chains: IChain[];
|
|
85
|
-
readonly nextStartAfter?: number;
|
|
86
101
|
};
|
|
87
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Arc API Unsigned Transaction Types
|
|
105
|
+
*
|
|
106
|
+
* Defines the core request and response types for the tokens.
|
|
107
|
+
*/
|
|
108
|
+
interface UnsignedTransaction {
|
|
109
|
+
readonly to: string;
|
|
110
|
+
readonly data: string;
|
|
111
|
+
readonly value: string;
|
|
112
|
+
readonly gasLimit: string;
|
|
113
|
+
readonly gasPrice?: string;
|
|
114
|
+
readonly chainId: number;
|
|
115
|
+
readonly from?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
88
118
|
/**
|
|
89
119
|
* Arc API Routes Types
|
|
90
120
|
*
|
|
@@ -166,15 +196,6 @@ interface Step {
|
|
|
166
196
|
readonly includedSteps: Step[] | null;
|
|
167
197
|
readonly relatedSteps: string[] | null;
|
|
168
198
|
}
|
|
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
199
|
interface ProviderMetadata {
|
|
179
200
|
readonly lifi?: {
|
|
180
201
|
readonly integrator: string | null;
|
|
@@ -214,7 +235,7 @@ interface Route {
|
|
|
214
235
|
readonly feeCosts: FeeCost[];
|
|
215
236
|
readonly gasCosts: GasCost[];
|
|
216
237
|
readonly steps: Step[];
|
|
217
|
-
readonly transactionRequest?:
|
|
238
|
+
readonly transactionRequest?: UnsignedTransaction;
|
|
218
239
|
readonly providerMetadata: ProviderMetadata;
|
|
219
240
|
readonly riskFactors: RiskFactors | null;
|
|
220
241
|
readonly createdAt: number;
|
|
@@ -293,7 +314,7 @@ interface Transaction {
|
|
|
293
314
|
};
|
|
294
315
|
}
|
|
295
316
|
interface TransactionsRequestQueryParams {
|
|
296
|
-
readonly
|
|
317
|
+
readonly address?: string;
|
|
297
318
|
readonly sorceNetworkIds?: string;
|
|
298
319
|
readonly destinationNetworkIds?: string;
|
|
299
320
|
readonly limit?: number;
|
|
@@ -301,7 +322,6 @@ interface TransactionsRequestQueryParams {
|
|
|
301
322
|
}
|
|
302
323
|
type TransactionsResponse = {
|
|
303
324
|
transactions: Transaction[];
|
|
304
|
-
nextStartAfter?: number;
|
|
305
325
|
};
|
|
306
326
|
|
|
307
327
|
/**
|
|
@@ -311,7 +331,19 @@ type TransactionsResponse = {
|
|
|
311
331
|
*/
|
|
312
332
|
|
|
313
333
|
type BuildTransactionRequestBody = Step;
|
|
314
|
-
type BuildTransactionResponse =
|
|
334
|
+
type BuildTransactionResponse = UnsignedTransaction;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Arc API Build Claim Transaction Types
|
|
338
|
+
*
|
|
339
|
+
* Defines the core request and response types for the build claim transaction endpoint.
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
type BuildClaimTransactionRequestParam = {
|
|
343
|
+
sourceNetworkId: number;
|
|
344
|
+
depositCount: number;
|
|
345
|
+
};
|
|
346
|
+
type BuildClaimTransactionResponse = UnsignedTransaction;
|
|
315
347
|
|
|
316
348
|
/**
|
|
317
349
|
* Chain Types
|
|
@@ -747,19 +779,32 @@ declare class CoreClient {
|
|
|
747
779
|
private config;
|
|
748
780
|
private arcApiService;
|
|
749
781
|
constructor(config: CoreConfig);
|
|
782
|
+
/**
|
|
783
|
+
* Generic pagination helper for chains API calls (limit and offset based pagination)
|
|
784
|
+
* Handles automatic pagination to fetch all available data
|
|
785
|
+
* @param params - Parameters for the chains API call
|
|
786
|
+
* @param pageSize - Number of items per page (defaults to DEFAULT_CHAINS_PER_PAGE)
|
|
787
|
+
*/
|
|
788
|
+
private getAllChainsPaginated;
|
|
750
789
|
/**
|
|
751
790
|
* Get all chains metadata from AggLayer API
|
|
791
|
+
* Handles pagination automatically to fetch all available chains
|
|
752
792
|
*/
|
|
753
793
|
getAllChains(): Promise<ChainsResponse>;
|
|
754
794
|
/**
|
|
755
795
|
* Get chain metadata by id from AggLayer API
|
|
796
|
+
* Handles pagination automatically to fetch all available chain metadata
|
|
756
797
|
* @param ids - the ids of the chains to get metadata for
|
|
757
798
|
*/
|
|
758
799
|
getChainMetadataByChainIds(ids: number[]): Promise<ChainsResponse>;
|
|
759
800
|
/**
|
|
760
801
|
* Get all tokens from AggLayer API
|
|
802
|
+
*
|
|
803
|
+
* Developer Note: This method is not recommended to use frequently or from frontend.
|
|
804
|
+
* As it can be very slow and resource intensive.
|
|
805
|
+
* It is recommended to use getChainDataAndTokensByChainIds instead.
|
|
761
806
|
*/
|
|
762
|
-
|
|
807
|
+
getAllTokens(): Promise<ChainsResponse>;
|
|
763
808
|
/**
|
|
764
809
|
* Get chain data and tokens by AggLayer API
|
|
765
810
|
* @param ids - the ids of the chains to get data and tokens for
|
|
@@ -770,9 +815,21 @@ declare class CoreClient {
|
|
|
770
815
|
*/
|
|
771
816
|
getRoutes(routesRequestParams: RoutesRequestParams): Promise<RoutesResponse>;
|
|
772
817
|
/**
|
|
773
|
-
*
|
|
818
|
+
* Get calldata from a route
|
|
819
|
+
* If route has transactionRequest field, return it directly as calldata
|
|
820
|
+
* Otherwise, call buildTransaction on route.steps[0] and return that as calldata
|
|
821
|
+
*/
|
|
822
|
+
getUnsignedTransaction(route: Route): Promise<UnsignedTransaction>;
|
|
823
|
+
/**
|
|
824
|
+
* Get calldata for claim step
|
|
825
|
+
* Needs to be called separately as claim step is not part of route.
|
|
826
|
+
*
|
|
827
|
+
* @developer Note: Do not misinterpret network ID as chain ID.
|
|
828
|
+
*
|
|
829
|
+
* @param sourceNetworkId - The source network ID where the transfer was initiated.
|
|
830
|
+
* @param depositCount - The deposit count associated with the transfer.
|
|
774
831
|
*/
|
|
775
|
-
|
|
832
|
+
getClaimUnsignedTransaction(buildClaimTxParams: BuildClaimTransactionRequestParam): Promise<UnsignedTransaction>;
|
|
776
833
|
/**
|
|
777
834
|
* Get all transactions via web sockets
|
|
778
835
|
*/
|
|
@@ -800,4 +857,4 @@ declare class AggLayerSDK {
|
|
|
800
857
|
getNative(): NativeClient;
|
|
801
858
|
}
|
|
802
859
|
|
|
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
|
|
860
|
+
export { AggLayerSDK, type ApiResponse, type BaseContractConfig, type BridgeAssetParams, type BridgeConfig, type BridgeMessageParams, type BridgeOptions, type BuildClaimTransactionRequestParam, type BuildClaimTransactionResponse, type BuildTransactionRequestBody, type BuildTransactionResponse, type ChainConfig, type ChainsQueryParams, type ChainsResponse, type ClaimAssetParams, type ClaimMessageParams, type CoreConfig, type CursorPagination, type CustomChainConfig, type ERC20Config, type ErrorResponse, type FeeCost, type GasCost, type IChain, type IsClaimedParams, type NativeConfig, type OffsetPagination, type OriginTokenInfoParams, type Pagination, 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 TransactionsRequestQueryParams, type TransactionsResponse, type WrappedTokenParams };
|
package/dist/index.js
CHANGED
|
@@ -1415,6 +1415,9 @@ var NETWORKS = {
|
|
|
1415
1415
|
CARDONA: 2442
|
|
1416
1416
|
};
|
|
1417
1417
|
var DEFAULT_NETWORK = NETWORKS.SEPOLIA;
|
|
1418
|
+
var DEFAULT_CHAINS_PER_PAGE = 100;
|
|
1419
|
+
var DEFAULT_CHAINS_WITH_TOKENS_PER_PAGE = 1;
|
|
1420
|
+
var MAX_TRANSACTIONS_PER_PAGE = 100;
|
|
1418
1421
|
|
|
1419
1422
|
// src/native/index.ts
|
|
1420
1423
|
var NativeClient = class {
|
|
@@ -1643,11 +1646,12 @@ var HttpClient = class {
|
|
|
1643
1646
|
continue;
|
|
1644
1647
|
}
|
|
1645
1648
|
if (Array.isArray(value)) {
|
|
1646
|
-
value.
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1649
|
+
const filteredValues = value.filter(
|
|
1650
|
+
(item) => item !== void 0 && item !== null
|
|
1651
|
+
);
|
|
1652
|
+
if (filteredValues.length > 0) {
|
|
1653
|
+
result[fullKey] = filteredValues.join(",");
|
|
1654
|
+
}
|
|
1651
1655
|
} else if (typeof value === "object") {
|
|
1652
1656
|
Object.assign(
|
|
1653
1657
|
result,
|
|
@@ -1677,16 +1681,17 @@ var ArcApiService = class {
|
|
|
1677
1681
|
this.httpClient = new HttpClient({ baseUrl, timeout });
|
|
1678
1682
|
}
|
|
1679
1683
|
// responsible for both chains metadata and tokens
|
|
1684
|
+
// supports limit/offset based pagination
|
|
1680
1685
|
async chains({
|
|
1681
1686
|
withSupportedTokens = false,
|
|
1682
|
-
limit =
|
|
1683
|
-
|
|
1687
|
+
limit = 10,
|
|
1688
|
+
offset,
|
|
1684
1689
|
chainIds
|
|
1685
1690
|
} = {}) {
|
|
1686
1691
|
return this.httpClient.get("/metadata/chains", {
|
|
1687
1692
|
withSupportedTokens,
|
|
1688
1693
|
limit,
|
|
1689
|
-
|
|
1694
|
+
offset,
|
|
1690
1695
|
chainIds
|
|
1691
1696
|
});
|
|
1692
1697
|
}
|
|
@@ -1699,6 +1704,13 @@ var ArcApiService = class {
|
|
|
1699
1704
|
builtTransactionRequestBody
|
|
1700
1705
|
);
|
|
1701
1706
|
}
|
|
1707
|
+
async buildClaimTransaction(sourceNetworkId, depositCount) {
|
|
1708
|
+
return this.httpClient.get("/routes/build-transaction-for-claim", {
|
|
1709
|
+
sourceNetworkId,
|
|
1710
|
+
depositCount
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
// supports cursor based pagination only
|
|
1702
1714
|
async transactions(transactionsRequestQueryParams) {
|
|
1703
1715
|
return this.httpClient.get("/transactions", {
|
|
1704
1716
|
transactionsRequestQueryParams
|
|
@@ -1722,69 +1734,144 @@ var CoreClient = class {
|
|
|
1722
1734
|
timeout: apiTimeout ?? 3e4
|
|
1723
1735
|
});
|
|
1724
1736
|
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Generic pagination helper for chains API calls (limit and offset based pagination)
|
|
1739
|
+
* Handles automatic pagination to fetch all available data
|
|
1740
|
+
* @param params - Parameters for the chains API call
|
|
1741
|
+
* @param pageSize - Number of items per page (defaults to DEFAULT_CHAINS_PER_PAGE)
|
|
1742
|
+
*/
|
|
1743
|
+
async getAllChainsPaginated(params, pageSize = DEFAULT_CHAINS_PER_PAGE) {
|
|
1744
|
+
const firstResponse = await this.arcApiService.chains({
|
|
1745
|
+
...params,
|
|
1746
|
+
limit: pageSize
|
|
1747
|
+
});
|
|
1748
|
+
if (firstResponse.data.status !== "success") {
|
|
1749
|
+
throw new Error(firstResponse.data.message);
|
|
1750
|
+
}
|
|
1751
|
+
const firstPageData = firstResponse.data.data;
|
|
1752
|
+
const pagination = firstResponse.data.pagination;
|
|
1753
|
+
const firstPageChains = Array.isArray(firstPageData) ? firstPageData : [];
|
|
1754
|
+
if (!pagination?.total || pagination.total <= pageSize) {
|
|
1755
|
+
return {
|
|
1756
|
+
chains: firstPageChains
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
const totalPages = Math.ceil(pagination.total / pageSize);
|
|
1760
|
+
const remainingPages = totalPages - 1;
|
|
1761
|
+
if (remainingPages === 0) {
|
|
1762
|
+
return {
|
|
1763
|
+
chains: firstPageChains
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
const remainingPagePromises = Array.from(
|
|
1767
|
+
{ length: remainingPages },
|
|
1768
|
+
(_, index) => {
|
|
1769
|
+
const offset = (index + 1) * pageSize;
|
|
1770
|
+
return this.arcApiService.chains({
|
|
1771
|
+
...params,
|
|
1772
|
+
limit: pageSize,
|
|
1773
|
+
offset
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
);
|
|
1777
|
+
const remainingResponses = await Promise.all(remainingPagePromises);
|
|
1778
|
+
for (const response of remainingResponses) {
|
|
1779
|
+
if (response.data.status !== "success") {
|
|
1780
|
+
throw new Error(response.data.message);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
const allChains = [
|
|
1784
|
+
...firstPageChains,
|
|
1785
|
+
...remainingResponses.flatMap((response) => {
|
|
1786
|
+
if (response.data.status === "success") {
|
|
1787
|
+
return Array.isArray(response.data.data) ? response.data.data : [];
|
|
1788
|
+
}
|
|
1789
|
+
return [];
|
|
1790
|
+
})
|
|
1791
|
+
];
|
|
1792
|
+
return {
|
|
1793
|
+
chains: allChains
|
|
1794
|
+
};
|
|
1795
|
+
}
|
|
1725
1796
|
/**
|
|
1726
1797
|
* Get all chains metadata from AggLayer API
|
|
1798
|
+
* Handles pagination automatically to fetch all available chains
|
|
1727
1799
|
*/
|
|
1728
1800
|
async getAllChains() {
|
|
1729
|
-
|
|
1730
|
-
if (response.data.status === "success") {
|
|
1731
|
-
return response.data.data;
|
|
1732
|
-
}
|
|
1733
|
-
throw new Error(response.data.message);
|
|
1801
|
+
return this.getAllChainsPaginated({});
|
|
1734
1802
|
}
|
|
1735
1803
|
/**
|
|
1736
1804
|
* Get chain metadata by id from AggLayer API
|
|
1805
|
+
* Handles pagination automatically to fetch all available chain metadata
|
|
1737
1806
|
* @param ids - the ids of the chains to get metadata for
|
|
1738
1807
|
*/
|
|
1739
1808
|
async getChainMetadataByChainIds(ids) {
|
|
1740
|
-
|
|
1741
|
-
if (response.data.status === "success") {
|
|
1742
|
-
return response.data.data;
|
|
1743
|
-
}
|
|
1744
|
-
throw new Error(response.data.message);
|
|
1809
|
+
return this.getAllChainsPaginated({ chainIds: ids });
|
|
1745
1810
|
}
|
|
1746
1811
|
/**
|
|
1747
1812
|
* Get all tokens from AggLayer API
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1813
|
+
*
|
|
1814
|
+
* Developer Note: This method is not recommended to use frequently or from frontend.
|
|
1815
|
+
* As it can be very slow and resource intensive.
|
|
1816
|
+
* It is recommended to use getChainDataAndTokensByChainIds instead.
|
|
1817
|
+
*/
|
|
1818
|
+
async getAllTokens() {
|
|
1819
|
+
return this.getAllChainsPaginated(
|
|
1820
|
+
{ withSupportedTokens: true },
|
|
1821
|
+
DEFAULT_CHAINS_WITH_TOKENS_PER_PAGE
|
|
1822
|
+
);
|
|
1757
1823
|
}
|
|
1758
1824
|
/**
|
|
1759
1825
|
* Get chain data and tokens by AggLayer API
|
|
1760
1826
|
* @param ids - the ids of the chains to get data and tokens for
|
|
1761
1827
|
*/
|
|
1762
1828
|
async getChainDataAndTokensByChainIds(ids) {
|
|
1763
|
-
|
|
1829
|
+
return this.getAllChainsPaginated({
|
|
1764
1830
|
chainIds: ids,
|
|
1765
1831
|
withSupportedTokens: true
|
|
1766
1832
|
});
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Get all routes from AggLayer API
|
|
1836
|
+
*/
|
|
1837
|
+
async getRoutes(routesRequestParams) {
|
|
1838
|
+
const response = await this.arcApiService.routes(routesRequestParams);
|
|
1767
1839
|
if (response.data.status === "success") {
|
|
1768
1840
|
return response.data.data;
|
|
1769
1841
|
}
|
|
1770
1842
|
throw new Error(response.data.message);
|
|
1771
1843
|
}
|
|
1772
1844
|
/**
|
|
1773
|
-
* Get
|
|
1845
|
+
* Get calldata from a route
|
|
1846
|
+
* If route has transactionRequest field, return it directly as calldata
|
|
1847
|
+
* Otherwise, call buildTransaction on route.steps[0] and return that as calldata
|
|
1774
1848
|
*/
|
|
1775
|
-
async
|
|
1776
|
-
|
|
1849
|
+
async getUnsignedTransaction(route) {
|
|
1850
|
+
if (route.transactionRequest) {
|
|
1851
|
+
return route.transactionRequest;
|
|
1852
|
+
}
|
|
1853
|
+
if (route.steps.length === 0 || !route.steps[0]) {
|
|
1854
|
+
throw new Error("Route has no steps to build transaction from");
|
|
1855
|
+
}
|
|
1856
|
+
const response = await this.arcApiService.buildTransaction(route.steps[0]);
|
|
1777
1857
|
if (response.data.status === "success") {
|
|
1778
1858
|
return response.data.data;
|
|
1779
1859
|
}
|
|
1780
1860
|
throw new Error(response.data.message);
|
|
1781
1861
|
}
|
|
1782
1862
|
/**
|
|
1783
|
-
*
|
|
1863
|
+
* Get calldata for claim step
|
|
1864
|
+
* Needs to be called separately as claim step is not part of route.
|
|
1865
|
+
*
|
|
1866
|
+
* @developer Note: Do not misinterpret network ID as chain ID.
|
|
1867
|
+
*
|
|
1868
|
+
* @param sourceNetworkId - The source network ID where the transfer was initiated.
|
|
1869
|
+
* @param depositCount - The deposit count associated with the transfer.
|
|
1784
1870
|
*/
|
|
1785
|
-
async
|
|
1786
|
-
const response = await this.arcApiService.
|
|
1787
|
-
|
|
1871
|
+
async getClaimUnsignedTransaction(buildClaimTxParams) {
|
|
1872
|
+
const response = await this.arcApiService.buildClaimTransaction(
|
|
1873
|
+
buildClaimTxParams.sourceNetworkId,
|
|
1874
|
+
buildClaimTxParams.depositCount
|
|
1788
1875
|
);
|
|
1789
1876
|
if (response.data.status === "success") {
|
|
1790
1877
|
return response.data.data;
|
|
@@ -1795,6 +1882,11 @@ var CoreClient = class {
|
|
|
1795
1882
|
* Get all transactions via web sockets
|
|
1796
1883
|
*/
|
|
1797
1884
|
async getTransactions(transactionsRequestQueryParams) {
|
|
1885
|
+
if (transactionsRequestQueryParams.limit && transactionsRequestQueryParams.limit > MAX_TRANSACTIONS_PER_PAGE) {
|
|
1886
|
+
throw new Error(
|
|
1887
|
+
`Limit cannot be greater than ${MAX_TRANSACTIONS_PER_PAGE}`
|
|
1888
|
+
);
|
|
1889
|
+
}
|
|
1798
1890
|
const response = await this.arcApiService.transactions(
|
|
1799
1891
|
transactionsRequestQueryParams
|
|
1800
1892
|
);
|