@aptos-labs/cross-chain-core 5.0.1 → 5.1.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/dist/index.mjs CHANGED
@@ -504,7 +504,7 @@ var Signer = class {
504
504
  this._claimedTransactionHashes = "";
505
505
  }
506
506
  chain() {
507
- return this._chain.displayName;
507
+ return this._chain.key;
508
508
  }
509
509
  address() {
510
510
  return this._address;
@@ -669,6 +669,9 @@ var WormholeProvider = class {
669
669
  {},
670
670
  wallet
671
671
  );
672
+ logger.log("signer", signer);
673
+ logger.log("wormholeRequest", this.wormholeRequest);
674
+ logger.log("wormholeQuote", this.wormholeQuote);
672
675
  let receipt = await this.wormholeRoute.initiate(
673
676
  this.wormholeRequest,
674
677
  signer,
@@ -874,48 +877,78 @@ var Context = /* @__PURE__ */ ((Context2) => {
874
877
  var testnetChains = {
875
878
  Sepolia: {
876
879
  key: "Sepolia",
877
- id: 10002,
878
880
  context: "Ethereum" /* ETH */,
879
- finalityThreshold: 0,
881
+ chainId: 11155111,
880
882
  displayName: "Sepolia",
881
883
  explorerUrl: "https://sepolia.etherscan.io/",
882
884
  explorerName: "Etherscan",
883
- gasToken: "ETHsepolia",
884
- chainId: 11155111,
885
885
  icon: "Ethereum",
886
- maxBlockSearch: 2e3,
887
886
  symbol: "ETH",
888
- defaultRpc: "https://eth-sepolia.public.blastapi.io",
889
- wrappedGasToken: "0xeef12A83EE5b7161D3873317c8E0E7B76e0B5D9c"
887
+ defaultRpc: "https://eth-sepolia.public.blastapi.io"
888
+ },
889
+ BaseSepolia: {
890
+ key: "BaseSepolia",
891
+ context: "Ethereum" /* ETH */,
892
+ chainId: 84532,
893
+ displayName: "Base Sepolia",
894
+ explorerUrl: "https://sepolia.basescan.org",
895
+ explorerName: "Basescan",
896
+ icon: "BaseSepolia",
897
+ symbol: "BASE",
898
+ defaultRpc: "https://chain-proxy.wallet.coinbase.com?targetName=base-sepolia"
899
+ },
900
+ ArbitrumSepolia: {
901
+ key: "ArbitrumSepolia",
902
+ context: "Ethereum" /* ETH */,
903
+ chainId: 421614,
904
+ displayName: "Arbitrum Sepolia",
905
+ explorerUrl: "https://sepolia.arbiscan.io",
906
+ explorerName: "Etherscan",
907
+ icon: "Arbitrum",
908
+ symbol: "ARB",
909
+ defaultRpc: "https://sepolia-rollup.arbitrum.io/rpc"
910
+ },
911
+ Avalanche: {
912
+ key: "Avalanche",
913
+ context: "Ethereum" /* ETH */,
914
+ chainId: 43113,
915
+ displayName: "Avalanche Fuji",
916
+ explorerUrl: "https://testnet.snowtrace.io",
917
+ explorerName: "Avascan",
918
+ icon: "Avalanche",
919
+ symbol: "AVAX",
920
+ defaultRpc: "https://api.avax-test.network/ext/bc/C/rpc"
921
+ },
922
+ PolygonSepolia: {
923
+ key: "PolygonSepolia",
924
+ context: "Ethereum" /* ETH */,
925
+ chainId: 80002,
926
+ displayName: "Polygon",
927
+ explorerUrl: "https://amoy.polygonscan.com/",
928
+ explorerName: "PolygonScan",
929
+ icon: "Polygon",
930
+ symbol: "MATIC",
931
+ defaultRpc: "https://rpc-amoy.polygon.technology/"
890
932
  },
891
933
  Solana: {
892
934
  key: "Solana",
893
- id: 1,
894
935
  context: "Solana" /* SOLANA */,
895
- finalityThreshold: 32,
896
936
  displayName: "Solana",
897
937
  explorerUrl: "https://explorer.solana.com/",
898
938
  explorerName: "Solana Explorer",
899
- gasToken: "SOL",
900
939
  chainId: 0,
901
940
  icon: "Solana",
902
- maxBlockSearch: 2e3,
903
941
  symbol: "SOL",
904
- defaultRpc: "https://api.devnet.solana.com",
905
- wrappedGasToken: "So11111111111111111111111111111111111111112"
942
+ defaultRpc: "https://api.devnet.solana.com"
906
943
  },
907
944
  Aptos: {
908
945
  key: "Aptos",
909
- id: 22,
910
946
  context: "Aptos" /* APTOS */,
911
- finalityThreshold: 0,
912
947
  displayName: "Aptos",
913
948
  explorerUrl: "https://explorer.aptoslabs.com?network=testnet",
914
949
  explorerName: "Aptos Explorer",
915
- gasToken: "APT",
916
950
  chainId: 0,
917
951
  icon: "Aptos",
918
- maxBlockSearch: 0,
919
952
  symbol: "APT",
920
953
  defaultRpc: "https://fullnode.testnet.aptos.dev"
921
954
  }
@@ -964,6 +997,42 @@ var testnetTokens = {
964
997
  address: "0x69091fbab5f7d635ee7ac5098cf0c1efbe31d68fec0f2cd565e8d168daf52832"
965
998
  },
966
999
  icon: "USDC"
1000
+ },
1001
+ BaseSepolia: {
1002
+ symbol: "USDC",
1003
+ icon: "USDC",
1004
+ decimals: 6,
1005
+ tokenId: {
1006
+ chain: "BaseSepolia",
1007
+ address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
1008
+ }
1009
+ },
1010
+ Avalanche: {
1011
+ symbol: "USDC",
1012
+ icon: "USDC",
1013
+ decimals: 6,
1014
+ tokenId: {
1015
+ chain: "Avalanche",
1016
+ address: "0x5425890298aed601595a70AB815c96711a31Bc65"
1017
+ }
1018
+ },
1019
+ ArbitrumSepolia: {
1020
+ symbol: "USDC",
1021
+ icon: "USDC",
1022
+ decimals: 6,
1023
+ tokenId: {
1024
+ chain: "ArbitrumSepolia",
1025
+ address: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"
1026
+ }
1027
+ },
1028
+ PolygonSepolia: {
1029
+ symbol: "USDC",
1030
+ icon: "USDC",
1031
+ decimals: 6,
1032
+ tokenId: {
1033
+ chain: "PolygonSepolia",
1034
+ address: "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582"
1035
+ }
967
1036
  }
968
1037
  // Sui: {
969
1038
  // symbol: "USDC",
@@ -981,48 +1050,80 @@ var testnetTokens = {
981
1050
  var mainnetChains = {
982
1051
  Ethereum: {
983
1052
  key: "Ethereum",
984
- id: 2,
985
1053
  context: "Ethereum" /* ETH */,
986
- finalityThreshold: 64,
987
1054
  displayName: "Ethereum",
988
1055
  explorerUrl: "https://etherscan.io/",
989
1056
  explorerName: "Etherscan",
990
- gasToken: "ETH",
991
1057
  chainId: 1,
992
1058
  icon: "Ethereum",
993
- maxBlockSearch: 2e3,
994
1059
  symbol: "ETH",
995
1060
  defaultRpc: "https://rpc.ankr.com/eth"
996
1061
  },
997
1062
  Solana: {
998
1063
  key: "Solana",
999
- id: 1,
1000
1064
  context: "Solana" /* SOLANA */,
1001
- finalityThreshold: 32,
1002
1065
  displayName: "Solana",
1003
1066
  explorerUrl: "https://explorer.solana.com/",
1004
1067
  explorerName: "Solana Explorer",
1005
- gasToken: "SOL",
1006
1068
  chainId: 0,
1007
1069
  icon: "Solana",
1008
- maxBlockSearch: 2e3,
1009
1070
  symbol: "SOL",
1010
1071
  defaultRpc: "https://solana-mainnet.rpc.extrnode.com"
1011
1072
  },
1012
1073
  Aptos: {
1013
1074
  key: "Aptos",
1014
- id: 22,
1015
1075
  context: "Aptos" /* APTOS */,
1016
- finalityThreshold: 0,
1017
1076
  displayName: "Aptos",
1018
1077
  explorerUrl: "https://explorer.aptoslabs.com/",
1019
1078
  explorerName: "Aptos Explorer",
1020
- gasToken: "APT",
1021
1079
  chainId: 0,
1022
1080
  icon: "Aptos",
1023
- maxBlockSearch: 0,
1024
1081
  symbol: "APT",
1025
1082
  defaultRpc: "https://fullnode.mainnet.aptos.dev"
1083
+ },
1084
+ Avalanche: {
1085
+ key: "Avalanche",
1086
+ context: "Ethereum" /* ETH */,
1087
+ chainId: 43114,
1088
+ displayName: "Avalanche",
1089
+ explorerUrl: "https://snowtrace.io",
1090
+ explorerName: "Avascan",
1091
+ icon: "Avalanche",
1092
+ symbol: "AVAX",
1093
+ defaultRpc: "https://avalanche-c-chain-rpc.publicnode.com"
1094
+ },
1095
+ Base: {
1096
+ key: "Base",
1097
+ context: "Ethereum" /* ETH */,
1098
+ chainId: 8453,
1099
+ displayName: "Base",
1100
+ explorerUrl: "https://basescan.org",
1101
+ explorerName: "BaseScan",
1102
+ icon: "Base",
1103
+ symbol: "BASE",
1104
+ defaultRpc: "https://mainnet.base.org"
1105
+ },
1106
+ Arbitrum: {
1107
+ key: "Arbitrum",
1108
+ context: "Ethereum" /* ETH */,
1109
+ chainId: 42161,
1110
+ displayName: "Arbitrum",
1111
+ explorerUrl: "https://arbiscan.io/",
1112
+ explorerName: "Arbitrum Explorer",
1113
+ icon: "Arbitrum",
1114
+ symbol: "ARB",
1115
+ defaultRpc: "https://arb1.arbitrum.io/rpc"
1116
+ },
1117
+ Polygon: {
1118
+ key: "Polygon",
1119
+ context: "Ethereum" /* ETH */,
1120
+ chainId: 137,
1121
+ displayName: "Polygon",
1122
+ explorerUrl: "https://polygonscan.com/",
1123
+ explorerName: "PolygonScan",
1124
+ icon: "Polygon",
1125
+ symbol: "MATIC",
1126
+ defaultRpc: "https://polygon-bor-rpc.publicnode.com"
1026
1127
  }
1027
1128
  // Sui: {
1028
1129
  // key: "Sui",
@@ -1069,6 +1170,42 @@ var mainnetTokens = {
1069
1170
  address: "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b"
1070
1171
  },
1071
1172
  icon: "USDC"
1173
+ },
1174
+ Base: {
1175
+ symbol: "USDC",
1176
+ decimals: 6,
1177
+ icon: "USDC",
1178
+ tokenId: {
1179
+ chain: "Base",
1180
+ address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
1181
+ }
1182
+ },
1183
+ Arbitrum: {
1184
+ symbol: "USDC",
1185
+ decimals: 6,
1186
+ icon: "USDC",
1187
+ tokenId: {
1188
+ chain: "Arbitrum",
1189
+ address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831"
1190
+ }
1191
+ },
1192
+ Avalanche: {
1193
+ symbol: "USDC",
1194
+ decimals: 6,
1195
+ icon: "USDC",
1196
+ tokenId: {
1197
+ chain: "Avalanche",
1198
+ address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"
1199
+ }
1200
+ },
1201
+ Polygon: {
1202
+ symbol: "USDC",
1203
+ decimals: 6,
1204
+ icon: "USDC",
1205
+ tokenId: {
1206
+ chain: "Polygon",
1207
+ address: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"
1208
+ }
1072
1209
  }
1073
1210
  // Sui: {
1074
1211
  // symbol: "USDC",
@@ -1097,8 +1234,8 @@ var getSolanaWalletUSDCBalance = async (walletAddress, aptosNetwork, rpc) => {
1097
1234
  const balance = await connection.getTokenAccountBalance(checkAddress);
1098
1235
  return balance.value.uiAmountString ?? (Number(balance.value.amount) / 10 ** balance.value.decimals).toString();
1099
1236
  };
1100
- var getEthereumWalletUSDCBalance = async (walletAddress, aptosNetwork, rpc) => {
1101
- const token = aptosNetwork === Network2.MAINNET ? mainnetTokens["Ethereum"] : testnetTokens["Sepolia"];
1237
+ var getEthereumWalletUSDCBalance = async (walletAddress, aptosNetwork, chain, rpc) => {
1238
+ const token = aptosNetwork === Network2.MAINNET ? mainnetTokens[chain] : testnetTokens[chain];
1102
1239
  const tokenAddress = token.tokenId.address;
1103
1240
  const connection = new JsonRpcProvider(rpc);
1104
1241
  const abi = ["function balanceOf(address owner) view returns (uint256)"];
@@ -1128,6 +1265,20 @@ var getAptosWalletUSDCBalance = async (walletAddress, aptosNetwork) => {
1128
1265
 
1129
1266
  // src/CrossChainCore.ts
1130
1267
  import { NetworkToChainId, NetworkToNodeAPI } from "@aptos-labs/ts-sdk";
1268
+ var EthereumChainIdToTestnetChain = {
1269
+ 11155111: testnetChains.Sepolia,
1270
+ 84532: testnetChains.BaseSepolia,
1271
+ 421614: testnetChains.ArbitrumSepolia,
1272
+ 43113: testnetChains.Avalanche,
1273
+ 80002: testnetChains.PolygonSepolia
1274
+ };
1275
+ var EthereumChainIdToMainnetChain = {
1276
+ 1: mainnetChains.Ethereum,
1277
+ 8453: mainnetChains.Base,
1278
+ 42161: mainnetChains.Arbitrum,
1279
+ 43114: mainnetChains.Avalanche,
1280
+ 137: mainnetChains.Polygon
1281
+ };
1131
1282
  var CrossChainCore = class {
1132
1283
  constructor(args) {
1133
1284
  this._dappConfig = {
@@ -1170,10 +1321,18 @@ var CrossChainCore = class {
1170
1321
  this._dappConfig?.solanaConfig?.rpc ?? this.CHAINS[sourceChain].defaultRpc
1171
1322
  );
1172
1323
  case "Ethereum":
1324
+ case "BaseSepolia":
1173
1325
  case "Sepolia":
1326
+ case "Avalanche":
1327
+ case "ArbitrumSepolia":
1328
+ case "Arbitrum":
1329
+ case "Base":
1330
+ case "PolygonSepolia":
1331
+ case "Polygon":
1174
1332
  return await getEthereumWalletUSDCBalance(
1175
1333
  walletAddress,
1176
1334
  this._dappConfig.aptosNetwork,
1335
+ sourceChain,
1177
1336
  // TODO: maybe let the user config it
1178
1337
  this.CHAINS[sourceChain].defaultRpc
1179
1338
  );
@@ -1189,6 +1348,8 @@ export {
1189
1348
  AptosLocalSigner,
1190
1349
  Context,
1191
1350
  CrossChainCore,
1351
+ EthereumChainIdToMainnetChain,
1352
+ EthereumChainIdToTestnetChain,
1192
1353
  Network4 as Network,
1193
1354
  NetworkToChainId,
1194
1355
  NetworkToNodeAPI,