@agglayer/sdk 1.0.0-beta.27 → 1.0.0-beta.29
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 +2 -0
- package/dist/index.d.mts +16 -7
- package/dist/index.d.ts +16 -7
- package/dist/index.js +78 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -215,6 +215,7 @@ const bridgeAssetTx = await bridge.buildBridgeAsset(
|
|
|
215
215
|
const claimAssetTx = await bridge.buildClaimAssetFromHash(
|
|
216
216
|
'0xBridgeTxHash123456789012345678901234567890123456789012345678',
|
|
217
217
|
11155111, // source network where bridge tx occurred
|
|
218
|
+
10000, // leaf index for the claim proof
|
|
218
219
|
0, // bridge event index in tx (usually 0)
|
|
219
220
|
'0xFromAddress12345678901234567890123456789012345' // claimer address
|
|
220
221
|
);
|
|
@@ -250,6 +251,7 @@ const bridgeMessageTx = await bridge.buildBridgeMessage(
|
|
|
250
251
|
const claimMessageTx = await bridge.buildClaimMessageFromHash(
|
|
251
252
|
'0xBridgeMessageTxHash12345678901234567890123456789012345678901234',
|
|
252
253
|
11155111, // source network
|
|
254
|
+
10000, // leaf index for the claim proof
|
|
253
255
|
0, // message event index
|
|
254
256
|
'0xFromAddress12345678901234567890123456789012345' // claimer
|
|
255
257
|
);
|
package/dist/index.d.mts
CHANGED
|
@@ -59,6 +59,10 @@ interface TokenInfo {
|
|
|
59
59
|
interface TokenReference {
|
|
60
60
|
readonly address: string;
|
|
61
61
|
readonly chainId: number;
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly symbol: string;
|
|
64
|
+
readonly decimals: number;
|
|
65
|
+
readonly logoURI?: string;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -131,11 +135,11 @@ interface RoutePreferences {
|
|
|
131
135
|
interface FeeCost {
|
|
132
136
|
readonly name: string;
|
|
133
137
|
readonly description?: string;
|
|
134
|
-
readonly token: TokenInfo;
|
|
135
138
|
readonly amount: string;
|
|
136
139
|
readonly amountUSD?: string;
|
|
137
140
|
readonly percentage?: string;
|
|
138
141
|
readonly included: boolean;
|
|
142
|
+
readonly token: TokenReference;
|
|
139
143
|
}
|
|
140
144
|
interface GasCost {
|
|
141
145
|
readonly type: 'SEND' | 'APPROVAL' | 'EXECUTION';
|
|
@@ -279,7 +283,8 @@ declare enum TransactionStatus {
|
|
|
279
283
|
CLAIMED = "CLAIMED",
|
|
280
284
|
REFUND_IN_PROGRESS = "REFUND_IN_PROGRESS",
|
|
281
285
|
REFUNDED = "REFUNDED",
|
|
282
|
-
FAILED = "FAILED"
|
|
286
|
+
FAILED = "FAILED",
|
|
287
|
+
PARTIAL = "PARTIAL"
|
|
283
288
|
}
|
|
284
289
|
interface Token {
|
|
285
290
|
name: string;
|
|
@@ -729,7 +734,7 @@ declare abstract class BaseContract {
|
|
|
729
734
|
/**
|
|
730
735
|
* Estimate gas for transaction
|
|
731
736
|
*/
|
|
732
|
-
protected estimateGas(data: Hex, to: string, from?: string): Promise<string>;
|
|
737
|
+
protected estimateGas(data: Hex, to: string, from?: string, value?: bigint): Promise<string>;
|
|
733
738
|
}
|
|
734
739
|
|
|
735
740
|
declare class ERC20 extends BaseContract {
|
|
@@ -769,19 +774,21 @@ declare class ERC20 extends BaseContract {
|
|
|
769
774
|
*
|
|
770
775
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
771
776
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
777
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
772
778
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
773
779
|
* @param from - From address for the claim transaction
|
|
774
780
|
*/
|
|
775
|
-
claimAsset(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
781
|
+
claimAsset(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
776
782
|
/**
|
|
777
783
|
* Claim message from bridge transaction hash
|
|
778
784
|
*
|
|
779
785
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
780
786
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
787
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
781
788
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
782
789
|
* @param from - From address for the claim transaction
|
|
783
790
|
*/
|
|
784
|
-
claimMessage(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
791
|
+
claimMessage(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
785
792
|
/**
|
|
786
793
|
* Get bridge event info from transaction hash
|
|
787
794
|
*
|
|
@@ -841,19 +848,21 @@ declare class Bridge extends BaseContract {
|
|
|
841
848
|
*
|
|
842
849
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
843
850
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
851
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
844
852
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
845
853
|
* @param from - From address for the claim transaction
|
|
846
854
|
*/
|
|
847
|
-
buildClaimAssetFromHash(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
855
|
+
buildClaimAssetFromHash(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
848
856
|
/**
|
|
849
857
|
* Build claim message transaction from bridge transaction hash
|
|
850
858
|
*
|
|
851
859
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
852
860
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
861
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
853
862
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
854
863
|
* @param from - From address for the claim transaction
|
|
855
864
|
*/
|
|
856
|
-
buildClaimMessageFromHash(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
865
|
+
buildClaimMessageFromHash(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
857
866
|
/**
|
|
858
867
|
* Get bridge event info from transaction hash
|
|
859
868
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,10 @@ interface TokenInfo {
|
|
|
59
59
|
interface TokenReference {
|
|
60
60
|
readonly address: string;
|
|
61
61
|
readonly chainId: number;
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly symbol: string;
|
|
64
|
+
readonly decimals: number;
|
|
65
|
+
readonly logoURI?: string;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -131,11 +135,11 @@ interface RoutePreferences {
|
|
|
131
135
|
interface FeeCost {
|
|
132
136
|
readonly name: string;
|
|
133
137
|
readonly description?: string;
|
|
134
|
-
readonly token: TokenInfo;
|
|
135
138
|
readonly amount: string;
|
|
136
139
|
readonly amountUSD?: string;
|
|
137
140
|
readonly percentage?: string;
|
|
138
141
|
readonly included: boolean;
|
|
142
|
+
readonly token: TokenReference;
|
|
139
143
|
}
|
|
140
144
|
interface GasCost {
|
|
141
145
|
readonly type: 'SEND' | 'APPROVAL' | 'EXECUTION';
|
|
@@ -279,7 +283,8 @@ declare enum TransactionStatus {
|
|
|
279
283
|
CLAIMED = "CLAIMED",
|
|
280
284
|
REFUND_IN_PROGRESS = "REFUND_IN_PROGRESS",
|
|
281
285
|
REFUNDED = "REFUNDED",
|
|
282
|
-
FAILED = "FAILED"
|
|
286
|
+
FAILED = "FAILED",
|
|
287
|
+
PARTIAL = "PARTIAL"
|
|
283
288
|
}
|
|
284
289
|
interface Token {
|
|
285
290
|
name: string;
|
|
@@ -729,7 +734,7 @@ declare abstract class BaseContract {
|
|
|
729
734
|
/**
|
|
730
735
|
* Estimate gas for transaction
|
|
731
736
|
*/
|
|
732
|
-
protected estimateGas(data: Hex, to: string, from?: string): Promise<string>;
|
|
737
|
+
protected estimateGas(data: Hex, to: string, from?: string, value?: bigint): Promise<string>;
|
|
733
738
|
}
|
|
734
739
|
|
|
735
740
|
declare class ERC20 extends BaseContract {
|
|
@@ -769,19 +774,21 @@ declare class ERC20 extends BaseContract {
|
|
|
769
774
|
*
|
|
770
775
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
771
776
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
777
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
772
778
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
773
779
|
* @param from - From address for the claim transaction
|
|
774
780
|
*/
|
|
775
|
-
claimAsset(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
781
|
+
claimAsset(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
776
782
|
/**
|
|
777
783
|
* Claim message from bridge transaction hash
|
|
778
784
|
*
|
|
779
785
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
780
786
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
787
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
781
788
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
782
789
|
* @param from - From address for the claim transaction
|
|
783
790
|
*/
|
|
784
|
-
claimMessage(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
791
|
+
claimMessage(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
785
792
|
/**
|
|
786
793
|
* Get bridge event info from transaction hash
|
|
787
794
|
*
|
|
@@ -841,19 +848,21 @@ declare class Bridge extends BaseContract {
|
|
|
841
848
|
*
|
|
842
849
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
843
850
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
851
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
844
852
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
845
853
|
* @param from - From address for the claim transaction
|
|
846
854
|
*/
|
|
847
|
-
buildClaimAssetFromHash(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
855
|
+
buildClaimAssetFromHash(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
848
856
|
/**
|
|
849
857
|
* Build claim message transaction from bridge transaction hash
|
|
850
858
|
*
|
|
851
859
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
852
860
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
861
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
853
862
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
854
863
|
* @param from - From address for the claim transaction
|
|
855
864
|
*/
|
|
856
|
-
buildClaimMessageFromHash(transactionHash: string, sourceNetworkId: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
865
|
+
buildClaimMessageFromHash(transactionHash: string, sourceNetworkId: number, leafIndex: number, bridgeIndex?: number, from?: string): Promise<TransactionParams>;
|
|
857
866
|
/**
|
|
858
867
|
* Get bridge event info from transaction hash
|
|
859
868
|
*
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,8 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AggLayerSDK: () => AggLayerSDK,
|
|
24
24
|
ApiError: () => ApiError,
|
|
25
|
-
SDK_MODES: () => SDK_MODES
|
|
25
|
+
SDK_MODES: () => SDK_MODES,
|
|
26
|
+
TransactionStatus: () => TransactionStatus
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(index_exports);
|
|
28
29
|
|
|
@@ -49,7 +50,7 @@ var ChainRegistry = class _ChainRegistry {
|
|
|
49
50
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
50
51
|
blockExplorer: { name: "Etherscan", url: "https://etherscan.io" },
|
|
51
52
|
bridgeAddress: "",
|
|
52
|
-
proofApiUrl: "https://api
|
|
53
|
+
proofApiUrl: "https://bridge-hub-api.polygon.technology/mainnet/",
|
|
53
54
|
isTestnet: false
|
|
54
55
|
});
|
|
55
56
|
this.registerChain({
|
|
@@ -63,7 +64,7 @@ var ChainRegistry = class _ChainRegistry {
|
|
|
63
64
|
url: "https://katanascan.com"
|
|
64
65
|
},
|
|
65
66
|
bridgeAddress: "",
|
|
66
|
-
proofApiUrl: "https://api
|
|
67
|
+
proofApiUrl: "https://bridge-hub-api.polygon.technology/mainnet/",
|
|
67
68
|
isTestnet: false
|
|
68
69
|
});
|
|
69
70
|
this.registerChain({
|
|
@@ -77,7 +78,7 @@ var ChainRegistry = class _ChainRegistry {
|
|
|
77
78
|
url: "https://sepolia.etherscan.io"
|
|
78
79
|
},
|
|
79
80
|
bridgeAddress: "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582",
|
|
80
|
-
proofApiUrl: "https://api
|
|
81
|
+
proofApiUrl: "https://bridge-hub-api.polygon.technology/testnet/",
|
|
81
82
|
isTestnet: true
|
|
82
83
|
});
|
|
83
84
|
}
|
|
@@ -276,11 +277,12 @@ var BaseContract = class {
|
|
|
276
277
|
/**
|
|
277
278
|
* Estimate gas for transaction
|
|
278
279
|
*/
|
|
279
|
-
async estimateGas(data, to, from) {
|
|
280
|
+
async estimateGas(data, to, from, value) {
|
|
280
281
|
const gasEstimate = await this.client.estimateGas({
|
|
281
282
|
account: from,
|
|
282
283
|
to,
|
|
283
|
-
data
|
|
284
|
+
data,
|
|
285
|
+
value
|
|
284
286
|
});
|
|
285
287
|
return gasEstimate.toString();
|
|
286
288
|
}
|
|
@@ -637,6 +639,21 @@ var bridgeAbi = [
|
|
|
637
639
|
}
|
|
638
640
|
];
|
|
639
641
|
|
|
642
|
+
// src/constants.ts
|
|
643
|
+
var ARC_API_BASE_URL = "https://arc-api.polygon.technology";
|
|
644
|
+
var ARC_API_DEFAULT_TIMEOUT = 3e4;
|
|
645
|
+
var LIFI_API_BASE_URL = "https://li.quest";
|
|
646
|
+
var LIFI_API_DEFAULT_TIMEOUT = 5e3;
|
|
647
|
+
var DEFAULT_CHAINS_PER_PAGE = 100;
|
|
648
|
+
var DEFAULT_CHAINS_WITH_TOKENS_PER_PAGE = 1;
|
|
649
|
+
var MAX_TRANSACTIONS_PER_PAGE = 100;
|
|
650
|
+
var NETWORKS = {
|
|
651
|
+
ETHEREUM: 1,
|
|
652
|
+
KATANA: 747474
|
|
653
|
+
};
|
|
654
|
+
var DEFAULT_NETWORK = NETWORKS.ETHEREUM;
|
|
655
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
656
|
+
|
|
640
657
|
// src/native/bridge/build.ts
|
|
641
658
|
async function buildBridgeAsset(ctx, destinationNetwork, destinationAddress, amount, token, forceUpdateGlobalExitRoot, permitData = "0x", from) {
|
|
642
659
|
const data = (0, import_viem3.encodeFunctionData)({
|
|
@@ -651,17 +668,23 @@ async function buildBridgeAsset(ctx, destinationNetwork, destinationAddress, amo
|
|
|
651
668
|
permitData
|
|
652
669
|
]
|
|
653
670
|
});
|
|
671
|
+
const isNativeETH = token.toLowerCase() === ZERO_ADDRESS;
|
|
672
|
+
const value = isNativeETH ? amount : void 0;
|
|
654
673
|
const [nonce, gas] = await Promise.all([
|
|
655
674
|
ctx.getNonce(from),
|
|
656
|
-
ctx.estimateGas(data, ctx.bridgeAddress, from)
|
|
675
|
+
ctx.estimateGas(data, ctx.bridgeAddress, from, value)
|
|
657
676
|
]);
|
|
658
|
-
|
|
677
|
+
const result = {
|
|
659
678
|
from,
|
|
660
679
|
to: ctx.bridgeAddress,
|
|
661
680
|
data,
|
|
662
681
|
gas,
|
|
663
682
|
nonce
|
|
664
683
|
};
|
|
684
|
+
if (isNativeETH) {
|
|
685
|
+
result.value = amount.toString();
|
|
686
|
+
}
|
|
687
|
+
return result;
|
|
665
688
|
}
|
|
666
689
|
async function buildClaimAsset(ctx, smtProofLocalExitRoot, smtProofRollupExitRoot, globalIndex, mainnetExitRoot, rollupExitRoot, originNetwork, originTokenAddress, destinationNetwork, destinationAddress, amount, metadata, from) {
|
|
667
690
|
const data = (0, import_viem3.encodeFunctionData)({
|
|
@@ -856,12 +879,12 @@ var BridgeUtil = class _BridgeUtil {
|
|
|
856
879
|
}
|
|
857
880
|
}
|
|
858
881
|
/**
|
|
859
|
-
* Fetch merkle proof from Polygon's
|
|
882
|
+
* Fetch merkle proof from Polygon's hub API
|
|
860
883
|
*/
|
|
861
|
-
async fetchMerkleProof(networkId, depositCount) {
|
|
884
|
+
async fetchMerkleProof(networkId, depositCount, leafIndex) {
|
|
862
885
|
try {
|
|
863
886
|
const baseUrl = this.proofApiUrl.endsWith("/") ? this.proofApiUrl : `${this.proofApiUrl}/`;
|
|
864
|
-
const url = `${baseUrl}
|
|
887
|
+
const url = `${baseUrl}claim-proof?sourceNetworkId=${networkId}&depositCount=${depositCount}&leafIndex=${leafIndex}`;
|
|
865
888
|
const response = await fetch(url);
|
|
866
889
|
if (!response.ok) {
|
|
867
890
|
throw new Error(
|
|
@@ -869,10 +892,10 @@ var BridgeUtil = class _BridgeUtil {
|
|
|
869
892
|
);
|
|
870
893
|
}
|
|
871
894
|
const data = await response.json();
|
|
872
|
-
if (!data.
|
|
895
|
+
if (data.status !== "success" || !data.data) {
|
|
873
896
|
throw new Error("Invalid response format: missing proof data");
|
|
874
897
|
}
|
|
875
|
-
return data.
|
|
898
|
+
return data.data;
|
|
876
899
|
} catch (error) {
|
|
877
900
|
if (error instanceof Error) {
|
|
878
901
|
throw new Error(`Failed to fetch merkle proof: ${error.message}`);
|
|
@@ -894,7 +917,7 @@ var BridgeUtil = class _BridgeUtil {
|
|
|
894
917
|
/**
|
|
895
918
|
* Build claim payload from transaction hash (user-friendly method)
|
|
896
919
|
*/
|
|
897
|
-
async buildPayloadForClaim(transactionHash, sourceNetworkId, bridgeIndex = 0) {
|
|
920
|
+
async buildPayloadForClaim(transactionHash, sourceNetworkId, leafIndex, bridgeIndex = 0) {
|
|
898
921
|
const bridgeEvent = await this.extractBridgeEvent(
|
|
899
922
|
transactionHash,
|
|
900
923
|
sourceNetworkId,
|
|
@@ -902,18 +925,19 @@ var BridgeUtil = class _BridgeUtil {
|
|
|
902
925
|
);
|
|
903
926
|
const proof = await this.fetchMerkleProof(
|
|
904
927
|
sourceNetworkId,
|
|
905
|
-
bridgeEvent.depositCount
|
|
928
|
+
bridgeEvent.depositCount,
|
|
929
|
+
leafIndex
|
|
906
930
|
);
|
|
907
931
|
const globalIndex = this.computeGlobalIndex(
|
|
908
932
|
bridgeEvent.depositCount,
|
|
909
933
|
sourceNetworkId
|
|
910
934
|
);
|
|
911
935
|
return {
|
|
912
|
-
smtProof: proof.
|
|
913
|
-
smtProofRollup: proof.
|
|
936
|
+
smtProof: proof.proof_local_exit_root,
|
|
937
|
+
smtProofRollup: proof.proof_rollup_exit_root,
|
|
914
938
|
globalIndex: globalIndex.toString(),
|
|
915
|
-
mainnetExitRoot: proof.
|
|
916
|
-
rollupExitRoot: proof.rollup_exit_root,
|
|
939
|
+
mainnetExitRoot: proof.l1_info_tree_leaf.mainnet_exit_root,
|
|
940
|
+
rollupExitRoot: proof.l1_info_tree_leaf.rollup_exit_root,
|
|
917
941
|
originNetwork: bridgeEvent.originNetwork,
|
|
918
942
|
originTokenAddress: bridgeEvent.originTokenAddress,
|
|
919
943
|
destinationNetwork: bridgeEvent.destinationNetwork,
|
|
@@ -925,10 +949,11 @@ var BridgeUtil = class _BridgeUtil {
|
|
|
925
949
|
/**
|
|
926
950
|
* Build claim asset parameters from transaction hash
|
|
927
951
|
*/
|
|
928
|
-
async buildClaimAssetParams(transactionHash, sourceNetworkId, bridgeIndex = 0) {
|
|
952
|
+
async buildClaimAssetParams(transactionHash, sourceNetworkId, leafIndex, bridgeIndex = 0) {
|
|
929
953
|
const payload = await this.buildPayloadForClaim(
|
|
930
954
|
transactionHash,
|
|
931
955
|
sourceNetworkId,
|
|
956
|
+
leafIndex,
|
|
932
957
|
bridgeIndex
|
|
933
958
|
);
|
|
934
959
|
return {
|
|
@@ -948,10 +973,11 @@ var BridgeUtil = class _BridgeUtil {
|
|
|
948
973
|
/**
|
|
949
974
|
* Build claim message parameters from transaction hash
|
|
950
975
|
*/
|
|
951
|
-
async buildClaimMessageParams(transactionHash, sourceNetworkId, bridgeIndex = 0) {
|
|
976
|
+
async buildClaimMessageParams(transactionHash, sourceNetworkId, leafIndex, bridgeIndex = 0) {
|
|
952
977
|
const payload = await this.buildPayloadForClaim(
|
|
953
978
|
transactionHash,
|
|
954
979
|
sourceNetworkId,
|
|
980
|
+
leafIndex,
|
|
955
981
|
bridgeIndex
|
|
956
982
|
);
|
|
957
983
|
return {
|
|
@@ -998,7 +1024,7 @@ var Bridge = class extends BaseContract {
|
|
|
998
1024
|
return buildBridgeAsset(
|
|
999
1025
|
{
|
|
1000
1026
|
bridgeAddress: this.bridgeAddress,
|
|
1001
|
-
estimateGas: (data, to, from2) => this.estimateGas(data, to, from2),
|
|
1027
|
+
estimateGas: (data, to, from2, value) => this.estimateGas(data, to, from2, value),
|
|
1002
1028
|
getNonce: (address) => this.getNonce(address)
|
|
1003
1029
|
},
|
|
1004
1030
|
params.destinationNetwork,
|
|
@@ -1025,7 +1051,7 @@ var Bridge = class extends BaseContract {
|
|
|
1025
1051
|
return buildClaimAsset(
|
|
1026
1052
|
{
|
|
1027
1053
|
bridgeAddress: this.bridgeAddress,
|
|
1028
|
-
estimateGas: (data, to, from2) => this.estimateGas(data, to, from2),
|
|
1054
|
+
estimateGas: (data, to, from2, value) => this.estimateGas(data, to, from2, value),
|
|
1029
1055
|
getNonce: (address) => this.getNonce(address)
|
|
1030
1056
|
},
|
|
1031
1057
|
params.smtProofLocalExitRoot,
|
|
@@ -1099,7 +1125,7 @@ var Bridge = class extends BaseContract {
|
|
|
1099
1125
|
return buildBridgeMessage(
|
|
1100
1126
|
{
|
|
1101
1127
|
bridgeAddress: this.bridgeAddress,
|
|
1102
|
-
estimateGas: (data, to, from2) => this.estimateGas(data, to, from2),
|
|
1128
|
+
estimateGas: (data, to, from2, value) => this.estimateGas(data, to, from2, value),
|
|
1103
1129
|
getNonce: (address) => this.getNonce(address)
|
|
1104
1130
|
},
|
|
1105
1131
|
params.destinationNetwork,
|
|
@@ -1124,7 +1150,7 @@ var Bridge = class extends BaseContract {
|
|
|
1124
1150
|
return buildClaimMessage(
|
|
1125
1151
|
{
|
|
1126
1152
|
bridgeAddress: this.bridgeAddress,
|
|
1127
|
-
estimateGas: (data, to, from2) => this.estimateGas(data, to, from2),
|
|
1153
|
+
estimateGas: (data, to, from2, value) => this.estimateGas(data, to, from2, value),
|
|
1128
1154
|
getNonce: (address) => this.getNonce(address)
|
|
1129
1155
|
},
|
|
1130
1156
|
params.smtProofLocalExitRoot,
|
|
@@ -1178,14 +1204,16 @@ var Bridge = class extends BaseContract {
|
|
|
1178
1204
|
*
|
|
1179
1205
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
1180
1206
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
1207
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
1181
1208
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
1182
1209
|
* @param from - From address for the claim transaction
|
|
1183
1210
|
*/
|
|
1184
|
-
async buildClaimAssetFromHash(transactionHash, sourceNetworkId, bridgeIndex = 0, from) {
|
|
1211
|
+
async buildClaimAssetFromHash(transactionHash, sourceNetworkId, leafIndex, bridgeIndex = 0, from) {
|
|
1185
1212
|
const bridgeUtil = await BridgeUtil.fromNetworkId(sourceNetworkId);
|
|
1186
1213
|
const params = await bridgeUtil.buildClaimAssetParams(
|
|
1187
1214
|
transactionHash,
|
|
1188
1215
|
sourceNetworkId,
|
|
1216
|
+
leafIndex,
|
|
1189
1217
|
bridgeIndex
|
|
1190
1218
|
);
|
|
1191
1219
|
return this.buildClaimAsset(params, from);
|
|
@@ -1195,14 +1223,16 @@ var Bridge = class extends BaseContract {
|
|
|
1195
1223
|
*
|
|
1196
1224
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
1197
1225
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
1226
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
1198
1227
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
1199
1228
|
* @param from - From address for the claim transaction
|
|
1200
1229
|
*/
|
|
1201
|
-
async buildClaimMessageFromHash(transactionHash, sourceNetworkId, bridgeIndex = 0, from) {
|
|
1230
|
+
async buildClaimMessageFromHash(transactionHash, sourceNetworkId, leafIndex, bridgeIndex = 0, from) {
|
|
1202
1231
|
const bridgeUtil = await BridgeUtil.fromNetworkId(sourceNetworkId);
|
|
1203
1232
|
const params = await bridgeUtil.buildClaimMessageParams(
|
|
1204
1233
|
transactionHash,
|
|
1205
1234
|
sourceNetworkId,
|
|
1235
|
+
leafIndex,
|
|
1206
1236
|
bridgeIndex
|
|
1207
1237
|
);
|
|
1208
1238
|
return this.buildClaimMessage(params, from);
|
|
@@ -1360,14 +1390,16 @@ var ERC20 = class extends BaseContract {
|
|
|
1360
1390
|
*
|
|
1361
1391
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
1362
1392
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
1393
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
1363
1394
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
1364
1395
|
* @param from - From address for the claim transaction
|
|
1365
1396
|
*/
|
|
1366
|
-
async claimAsset(transactionHash, sourceNetworkId, bridgeIndex = 0, from) {
|
|
1397
|
+
async claimAsset(transactionHash, sourceNetworkId, leafIndex, bridgeIndex = 0, from) {
|
|
1367
1398
|
const bridge = this.getBridge();
|
|
1368
1399
|
return bridge.buildClaimAssetFromHash(
|
|
1369
1400
|
transactionHash,
|
|
1370
1401
|
sourceNetworkId,
|
|
1402
|
+
leafIndex,
|
|
1371
1403
|
bridgeIndex,
|
|
1372
1404
|
from
|
|
1373
1405
|
);
|
|
@@ -1377,14 +1409,16 @@ var ERC20 = class extends BaseContract {
|
|
|
1377
1409
|
*
|
|
1378
1410
|
* @param transactionHash - Hash of the bridge transaction on the source network
|
|
1379
1411
|
* @param sourceNetworkId - Network ID of the source network (where bridge tx happened)
|
|
1412
|
+
* @param leafIndex - Leaf index for the claim proof
|
|
1380
1413
|
* @param bridgeIndex - Index of bridge event in transaction (default: 0)
|
|
1381
1414
|
* @param from - From address for the claim transaction
|
|
1382
1415
|
*/
|
|
1383
|
-
async claimMessage(transactionHash, sourceNetworkId, bridgeIndex = 0, from) {
|
|
1416
|
+
async claimMessage(transactionHash, sourceNetworkId, leafIndex, bridgeIndex = 0, from) {
|
|
1384
1417
|
const bridge = this.getBridge();
|
|
1385
1418
|
return bridge.buildClaimMessageFromHash(
|
|
1386
1419
|
transactionHash,
|
|
1387
1420
|
sourceNetworkId,
|
|
1421
|
+
leafIndex,
|
|
1388
1422
|
bridgeIndex,
|
|
1389
1423
|
from
|
|
1390
1424
|
);
|
|
@@ -1421,22 +1455,6 @@ var ERC20 = class extends BaseContract {
|
|
|
1421
1455
|
|
|
1422
1456
|
// src/native/index.ts
|
|
1423
1457
|
var import_viem6 = require("viem");
|
|
1424
|
-
|
|
1425
|
-
// src/constants.ts
|
|
1426
|
-
var ARC_API_BASE_URL = "https://arc-api.polygon.technology";
|
|
1427
|
-
var ARC_API_DEFAULT_TIMEOUT = 3e4;
|
|
1428
|
-
var LIFI_API_BASE_URL = "https://li.quest";
|
|
1429
|
-
var LIFI_API_DEFAULT_TIMEOUT = 5e3;
|
|
1430
|
-
var DEFAULT_CHAINS_PER_PAGE = 100;
|
|
1431
|
-
var DEFAULT_CHAINS_WITH_TOKENS_PER_PAGE = 1;
|
|
1432
|
-
var MAX_TRANSACTIONS_PER_PAGE = 100;
|
|
1433
|
-
var NETWORKS = {
|
|
1434
|
-
ETHEREUM: 1,
|
|
1435
|
-
KATANA: 747474
|
|
1436
|
-
};
|
|
1437
|
-
var DEFAULT_NETWORK = NETWORKS.ETHEREUM;
|
|
1438
|
-
|
|
1439
|
-
// src/native/index.ts
|
|
1440
1458
|
var NativeClient = class {
|
|
1441
1459
|
constructor(config) {
|
|
1442
1460
|
this.config = config;
|
|
@@ -1540,6 +1558,19 @@ var SDK_MODES = {
|
|
|
1540
1558
|
NATIVE: "NATIVE"
|
|
1541
1559
|
};
|
|
1542
1560
|
|
|
1561
|
+
// src/types/core/arcApi/arcApiTransactions.ts
|
|
1562
|
+
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
|
1563
|
+
TransactionStatus2["BRIDGED"] = "BRIDGED";
|
|
1564
|
+
TransactionStatus2["LEAF_INCLUDED"] = "LEAF_INCLUDED";
|
|
1565
|
+
TransactionStatus2["READY_TO_CLAIM"] = "READY_TO_CLAIM";
|
|
1566
|
+
TransactionStatus2["CLAIMED"] = "CLAIMED";
|
|
1567
|
+
TransactionStatus2["REFUND_IN_PROGRESS"] = "REFUND_IN_PROGRESS";
|
|
1568
|
+
TransactionStatus2["REFUNDED"] = "REFUNDED";
|
|
1569
|
+
TransactionStatus2["FAILED"] = "FAILED";
|
|
1570
|
+
TransactionStatus2["PARTIAL"] = "PARTIAL";
|
|
1571
|
+
return TransactionStatus2;
|
|
1572
|
+
})(TransactionStatus || {});
|
|
1573
|
+
|
|
1543
1574
|
// src/core/utils/httpClient.ts
|
|
1544
1575
|
var HttpClient = class {
|
|
1545
1576
|
constructor(config) {
|
|
@@ -2180,6 +2211,7 @@ var AggLayerSDK = class {
|
|
|
2180
2211
|
0 && (module.exports = {
|
|
2181
2212
|
AggLayerSDK,
|
|
2182
2213
|
ApiError,
|
|
2183
|
-
SDK_MODES
|
|
2214
|
+
SDK_MODES,
|
|
2215
|
+
TransactionStatus
|
|
2184
2216
|
});
|
|
2185
2217
|
//# sourceMappingURL=index.js.map
|