@rash2x/bridge-widget 0.7.8 → 0.8.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/evaa-bridge.cjs +1 -1
- package/dist/evaa-bridge.mjs +1 -1
- package/dist/{index-DIK7UXln.js → index-CLLLUYbN.js} +2 -2
- package/dist/{index-DIK7UXln.js.map → index-CLLLUYbN.js.map} +1 -1
- package/dist/{index-CEcrJo_G.js → index-Crv1NlUG.js} +286 -8
- package/dist/index-Crv1NlUG.js.map +1 -0
- package/dist/{index-Btnz7slS.cjs → index-DQhIunWv.cjs} +2 -2
- package/dist/{index-Btnz7slS.cjs.map → index-DQhIunWv.cjs.map} +1 -1
- package/dist/{index-bZ0S5sNd.cjs → index-Du1Ins7X.cjs} +286 -8
- package/dist/index-Du1Ins7X.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
- package/dist/index-CEcrJo_G.js.map +0 -1
- package/dist/index-bZ0S5sNd.cjs.map +0 -1
|
@@ -1486,8 +1486,10 @@ function useChainStrategies() {
|
|
|
1486
1486
|
const useWalletSelectModal = zustand.create((set2) => ({
|
|
1487
1487
|
isOpen: false,
|
|
1488
1488
|
addressType: void 0,
|
|
1489
|
-
|
|
1490
|
-
|
|
1489
|
+
lastConnectionAddressType: void 0,
|
|
1490
|
+
onOpen: (addressType) => set2({ isOpen: true, addressType, lastConnectionAddressType: addressType }),
|
|
1491
|
+
onClose: () => set2({ isOpen: false, addressType: void 0 }),
|
|
1492
|
+
setLastConnectionAddressType: (addressType) => set2({ lastConnectionAddressType: addressType })
|
|
1491
1493
|
}));
|
|
1492
1494
|
const truncateToDecimals = (num, decimals) => {
|
|
1493
1495
|
if (!isFinite(num) || isNaN(num)) return "0";
|
|
@@ -5036,6 +5038,197 @@ function getTonClient(customClient, apiKey) {
|
|
|
5036
5038
|
}
|
|
5037
5039
|
return tonClientInstance;
|
|
5038
5040
|
}
|
|
5041
|
+
const NETWORK_CONFIGS = {
|
|
5042
|
+
1: {
|
|
5043
|
+
chainId: "0x1",
|
|
5044
|
+
chainName: "Ethereum Mainnet",
|
|
5045
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5046
|
+
rpcUrls: ["https://eth.llamarpc.com"],
|
|
5047
|
+
blockExplorerUrls: ["https://etherscan.io"]
|
|
5048
|
+
},
|
|
5049
|
+
42161: {
|
|
5050
|
+
chainId: "0xa4b1",
|
|
5051
|
+
chainName: "Arbitrum One",
|
|
5052
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5053
|
+
rpcUrls: ["https://arbitrum.llamarpc.com"],
|
|
5054
|
+
blockExplorerUrls: ["https://arbiscan.io"]
|
|
5055
|
+
},
|
|
5056
|
+
10: {
|
|
5057
|
+
chainId: "0xa",
|
|
5058
|
+
chainName: "Optimism",
|
|
5059
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5060
|
+
rpcUrls: ["https://optimism.llamarpc.com"],
|
|
5061
|
+
blockExplorerUrls: ["https://optimistic.etherscan.io"]
|
|
5062
|
+
},
|
|
5063
|
+
137: {
|
|
5064
|
+
chainId: "0x89",
|
|
5065
|
+
chainName: "Polygon",
|
|
5066
|
+
nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18 },
|
|
5067
|
+
rpcUrls: ["https://polygon.llamarpc.com"],
|
|
5068
|
+
blockExplorerUrls: ["https://polygonscan.com"]
|
|
5069
|
+
},
|
|
5070
|
+
8453: {
|
|
5071
|
+
chainId: "0x2105",
|
|
5072
|
+
chainName: "Base",
|
|
5073
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5074
|
+
rpcUrls: ["https://mainnet.base.org"],
|
|
5075
|
+
blockExplorerUrls: ["https://basescan.org"]
|
|
5076
|
+
},
|
|
5077
|
+
56: {
|
|
5078
|
+
chainId: "0x38",
|
|
5079
|
+
chainName: "BNB Smart Chain",
|
|
5080
|
+
nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
|
|
5081
|
+
rpcUrls: ["https://bsc-dataseed.binance.org"],
|
|
5082
|
+
blockExplorerUrls: ["https://bscscan.com"]
|
|
5083
|
+
},
|
|
5084
|
+
169: {
|
|
5085
|
+
chainId: "0xa9",
|
|
5086
|
+
chainName: "Manta Pacific",
|
|
5087
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5088
|
+
rpcUrls: ["https://pacific-rpc.manta.network/http"],
|
|
5089
|
+
blockExplorerUrls: ["https://pacific-explorer.manta.network"]
|
|
5090
|
+
},
|
|
5091
|
+
204: {
|
|
5092
|
+
chainId: "0xcc",
|
|
5093
|
+
chainName: "opBNB",
|
|
5094
|
+
nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
|
|
5095
|
+
rpcUrls: ["https://opbnb-mainnet-rpc.bnbchain.org"],
|
|
5096
|
+
blockExplorerUrls: ["https://opbnbscan.com"]
|
|
5097
|
+
},
|
|
5098
|
+
1030: {
|
|
5099
|
+
chainId: "0x406",
|
|
5100
|
+
chainName: "Conflux eSpace",
|
|
5101
|
+
nativeCurrency: { name: "CFX", symbol: "CFX", decimals: 18 },
|
|
5102
|
+
rpcUrls: ["https://evm.confluxrpc.com"],
|
|
5103
|
+
blockExplorerUrls: ["https://evm.confluxscan.net"]
|
|
5104
|
+
},
|
|
5105
|
+
5e3: {
|
|
5106
|
+
chainId: "0x1388",
|
|
5107
|
+
chainName: "Mantle",
|
|
5108
|
+
nativeCurrency: { name: "MNT", symbol: "MNT", decimals: 18 },
|
|
5109
|
+
rpcUrls: ["https://rpc.mantle.xyz"],
|
|
5110
|
+
blockExplorerUrls: ["https://explorer.mantle.xyz"]
|
|
5111
|
+
},
|
|
5112
|
+
42220: {
|
|
5113
|
+
chainId: "0xa4ec",
|
|
5114
|
+
chainName: "Celo",
|
|
5115
|
+
nativeCurrency: { name: "CELO", symbol: "CELO", decimals: 18 },
|
|
5116
|
+
rpcUrls: ["https://forno.celo.org"],
|
|
5117
|
+
blockExplorerUrls: ["https://explorer.celo.org"]
|
|
5118
|
+
},
|
|
5119
|
+
59144: {
|
|
5120
|
+
chainId: "0xe708",
|
|
5121
|
+
chainName: "Linea",
|
|
5122
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5123
|
+
rpcUrls: ["https://rpc.linea.build"],
|
|
5124
|
+
blockExplorerUrls: ["https://lineascan.build"]
|
|
5125
|
+
},
|
|
5126
|
+
81457: {
|
|
5127
|
+
chainId: "0x13e31",
|
|
5128
|
+
chainName: "Blast",
|
|
5129
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5130
|
+
rpcUrls: ["https://rpc.blast.io"],
|
|
5131
|
+
blockExplorerUrls: ["https://blastscan.io"]
|
|
5132
|
+
},
|
|
5133
|
+
534352: {
|
|
5134
|
+
chainId: "0x82750",
|
|
5135
|
+
chainName: "Scroll",
|
|
5136
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5137
|
+
rpcUrls: ["https://rpc.scroll.io"],
|
|
5138
|
+
blockExplorerUrls: ["https://scrollscan.com"]
|
|
5139
|
+
},
|
|
5140
|
+
25: {
|
|
5141
|
+
chainId: "0x19",
|
|
5142
|
+
chainName: "Cronos",
|
|
5143
|
+
nativeCurrency: { name: "CRO", symbol: "CRO", decimals: 18 },
|
|
5144
|
+
rpcUrls: ["https://evm.cronos.org"],
|
|
5145
|
+
blockExplorerUrls: ["https://cronoscan.com"]
|
|
5146
|
+
},
|
|
5147
|
+
100: {
|
|
5148
|
+
chainId: "0x64",
|
|
5149
|
+
chainName: "Gnosis",
|
|
5150
|
+
nativeCurrency: { name: "xDAI", symbol: "xDAI", decimals: 18 },
|
|
5151
|
+
rpcUrls: ["https://rpc.gnosischain.com"],
|
|
5152
|
+
blockExplorerUrls: ["https://gnosisscan.io"]
|
|
5153
|
+
},
|
|
5154
|
+
146: {
|
|
5155
|
+
chainId: "0x92",
|
|
5156
|
+
chainName: "Sonic",
|
|
5157
|
+
nativeCurrency: { name: "S", symbol: "S", decimals: 18 },
|
|
5158
|
+
rpcUrls: ["https://rpc.soniclabs.com"],
|
|
5159
|
+
blockExplorerUrls: ["https://sonicscan.org"]
|
|
5160
|
+
},
|
|
5161
|
+
250: {
|
|
5162
|
+
chainId: "0xfa",
|
|
5163
|
+
chainName: "Fantom Opera",
|
|
5164
|
+
nativeCurrency: { name: "FTM", symbol: "FTM", decimals: 18 },
|
|
5165
|
+
rpcUrls: ["https://rpcapi.fantom.network"],
|
|
5166
|
+
blockExplorerUrls: ["https://ftmscan.com"]
|
|
5167
|
+
},
|
|
5168
|
+
324: {
|
|
5169
|
+
chainId: "0x144",
|
|
5170
|
+
chainName: "zkSync Era",
|
|
5171
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5172
|
+
rpcUrls: ["https://mainnet.era.zksync.io"],
|
|
5173
|
+
blockExplorerUrls: ["https://explorer.zksync.io"]
|
|
5174
|
+
},
|
|
5175
|
+
1088: {
|
|
5176
|
+
chainId: "0x440",
|
|
5177
|
+
chainName: "Metis Andromeda",
|
|
5178
|
+
nativeCurrency: { name: "Metis", symbol: "METIS", decimals: 18 },
|
|
5179
|
+
rpcUrls: ["https://andromeda.metis.io/?owner=1088"],
|
|
5180
|
+
blockExplorerUrls: ["https://andromeda-explorer.metis.io"]
|
|
5181
|
+
},
|
|
5182
|
+
1101: {
|
|
5183
|
+
chainId: "0x44d",
|
|
5184
|
+
chainName: "Polygon zkEVM",
|
|
5185
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5186
|
+
rpcUrls: ["https://zkevm-rpc.com"],
|
|
5187
|
+
blockExplorerUrls: ["https://zkevm.polygonscan.com"]
|
|
5188
|
+
},
|
|
5189
|
+
1284: {
|
|
5190
|
+
chainId: "0x504",
|
|
5191
|
+
chainName: "Moonbeam",
|
|
5192
|
+
nativeCurrency: { name: "GLMR", symbol: "GLMR", decimals: 18 },
|
|
5193
|
+
rpcUrls: ["https://rpc.api.moonbeam.network"],
|
|
5194
|
+
blockExplorerUrls: ["https://moonscan.io"]
|
|
5195
|
+
},
|
|
5196
|
+
1285: {
|
|
5197
|
+
chainId: "0x505",
|
|
5198
|
+
chainName: "Moonriver",
|
|
5199
|
+
nativeCurrency: { name: "MOVR", symbol: "MOVR", decimals: 18 },
|
|
5200
|
+
rpcUrls: ["https://rpc.api.moonriver.moonbeam.network"],
|
|
5201
|
+
blockExplorerUrls: ["https://moonriver.moonscan.io"]
|
|
5202
|
+
},
|
|
5203
|
+
2222: {
|
|
5204
|
+
chainId: "0x8ae",
|
|
5205
|
+
chainName: "Kava EVM",
|
|
5206
|
+
nativeCurrency: { name: "KAVA", symbol: "KAVA", decimals: 18 },
|
|
5207
|
+
rpcUrls: ["https://evm.kava.io"],
|
|
5208
|
+
blockExplorerUrls: ["https://explorer.kava.io"]
|
|
5209
|
+
},
|
|
5210
|
+
8217: {
|
|
5211
|
+
chainId: "0x2019",
|
|
5212
|
+
chainName: "Klaytn",
|
|
5213
|
+
nativeCurrency: { name: "KLAY", symbol: "KLAY", decimals: 18 },
|
|
5214
|
+
rpcUrls: ["https://public-en-cypress.klaytn.net"],
|
|
5215
|
+
blockExplorerUrls: ["https://scope.klaytn.com"]
|
|
5216
|
+
},
|
|
5217
|
+
43114: {
|
|
5218
|
+
chainId: "0xa86a",
|
|
5219
|
+
chainName: "Avalanche C-Chain",
|
|
5220
|
+
nativeCurrency: { name: "AVAX", symbol: "AVAX", decimals: 18 },
|
|
5221
|
+
rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
|
|
5222
|
+
blockExplorerUrls: ["https://snowtrace.io"]
|
|
5223
|
+
},
|
|
5224
|
+
1313161554: {
|
|
5225
|
+
chainId: "0x4e454152",
|
|
5226
|
+
chainName: "Aurora",
|
|
5227
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
5228
|
+
rpcUrls: ["https://mainnet.aurora.dev"],
|
|
5229
|
+
blockExplorerUrls: ["https://aurorascan.dev"]
|
|
5230
|
+
}
|
|
5231
|
+
};
|
|
5039
5232
|
function isNativeAddress(addr) {
|
|
5040
5233
|
if (!addr) return false;
|
|
5041
5234
|
const a2 = addr.toLowerCase();
|
|
@@ -5562,12 +5755,67 @@ class EvmChainStrategy {
|
|
|
5562
5755
|
}
|
|
5563
5756
|
return Number(viem.formatUnits(totalFeeWei, 18));
|
|
5564
5757
|
}
|
|
5758
|
+
/**
|
|
5759
|
+
* Switch wallet to the specified chain
|
|
5760
|
+
* If the chain is not in the wallet, attempts to add it
|
|
5761
|
+
*/
|
|
5762
|
+
async switchToChain(chainId) {
|
|
5763
|
+
if (!this.walletClient) {
|
|
5764
|
+
throw new WalletNotConnectedError("evm");
|
|
5765
|
+
}
|
|
5766
|
+
const chainIdHex = `0x${chainId.toString(16)}`;
|
|
5767
|
+
try {
|
|
5768
|
+
await this.walletClient.request({
|
|
5769
|
+
method: "wallet_switchEthereumChain",
|
|
5770
|
+
params: [{ chainId: chainIdHex }]
|
|
5771
|
+
});
|
|
5772
|
+
console.log(`Switched to chain ${chainId}`);
|
|
5773
|
+
} catch (switchError) {
|
|
5774
|
+
const error = switchError;
|
|
5775
|
+
if (error.code === 4902) {
|
|
5776
|
+
const networkConfig = NETWORK_CONFIGS[chainId];
|
|
5777
|
+
if (!networkConfig) {
|
|
5778
|
+
throw new InvalidStepsError(
|
|
5779
|
+
"evm",
|
|
5780
|
+
`No network configuration found for chain ID ${chainId}`
|
|
5781
|
+
);
|
|
5782
|
+
}
|
|
5783
|
+
try {
|
|
5784
|
+
await this.walletClient.request({
|
|
5785
|
+
method: "wallet_addEthereumChain",
|
|
5786
|
+
params: [networkConfig]
|
|
5787
|
+
});
|
|
5788
|
+
console.log(`Added and switched to chain ${chainId}`);
|
|
5789
|
+
} catch (addError) {
|
|
5790
|
+
throw new TransactionFailedError(
|
|
5791
|
+
"evm",
|
|
5792
|
+
`Failed to add network ${networkConfig.chainName}`,
|
|
5793
|
+
void 0,
|
|
5794
|
+
addError instanceof Error ? addError : void 0
|
|
5795
|
+
);
|
|
5796
|
+
}
|
|
5797
|
+
} else {
|
|
5798
|
+
throw toChainStrategyError(switchError, "evm", "network-switch");
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5565
5802
|
async executeSteps(steps, _context, onStepComplete) {
|
|
5566
5803
|
if (!this.isConnected() || !this.walletClient) {
|
|
5567
5804
|
throw new WalletNotConnectedError("evm");
|
|
5568
5805
|
}
|
|
5569
5806
|
this.validateSteps(steps);
|
|
5570
5807
|
try {
|
|
5808
|
+
const firstChainKey = steps[0]?.chainKey;
|
|
5809
|
+
if (firstChainKey && this.config.chainKeyToId) {
|
|
5810
|
+
const requiredChainId = this.config.chainKeyToId[firstChainKey.toLowerCase()];
|
|
5811
|
+
const currentChainId = this.walletClient.chain?.id;
|
|
5812
|
+
if (requiredChainId && currentChainId !== requiredChainId) {
|
|
5813
|
+
console.log(`Switching from chain ${currentChainId} to ${requiredChainId}`);
|
|
5814
|
+
await this.switchToChain(requiredChainId);
|
|
5815
|
+
} else {
|
|
5816
|
+
console.log(`Already on correct chain ${currentChainId}`);
|
|
5817
|
+
}
|
|
5818
|
+
}
|
|
5571
5819
|
let firstTxHash;
|
|
5572
5820
|
const totalSteps = steps.length;
|
|
5573
5821
|
for (let i3 = 0; i3 < steps.length; i3++) {
|
|
@@ -6664,7 +6912,30 @@ const EVM_CHAIN_KEY_TO_ID = {
|
|
|
6664
6912
|
optimism: 10,
|
|
6665
6913
|
polygon: 137,
|
|
6666
6914
|
base: 8453,
|
|
6667
|
-
bsc: 56
|
|
6915
|
+
bsc: 56,
|
|
6916
|
+
manta: 169,
|
|
6917
|
+
opbnb: 204,
|
|
6918
|
+
conflux: 1030,
|
|
6919
|
+
mantle: 5e3,
|
|
6920
|
+
plasma: 9745,
|
|
6921
|
+
monad: 143,
|
|
6922
|
+
celo: 42220,
|
|
6923
|
+
linea: 59144,
|
|
6924
|
+
blast: 81457,
|
|
6925
|
+
scroll: 534352,
|
|
6926
|
+
cronosevm: 25,
|
|
6927
|
+
gnosis: 100,
|
|
6928
|
+
sonic: 146,
|
|
6929
|
+
fantom: 250,
|
|
6930
|
+
zksync: 324,
|
|
6931
|
+
metis: 1088,
|
|
6932
|
+
zkevm: 1101,
|
|
6933
|
+
moonbeam: 1284,
|
|
6934
|
+
moonriver: 1285,
|
|
6935
|
+
kava: 2222,
|
|
6936
|
+
klaytn: 8217,
|
|
6937
|
+
avalanche: 43114,
|
|
6938
|
+
aurora: 1313161554
|
|
6668
6939
|
};
|
|
6669
6940
|
function ChainStrategyProvider({
|
|
6670
6941
|
children,
|
|
@@ -7504,7 +7775,8 @@ const useAutoSelectNetwork = ({
|
|
|
7504
7775
|
evmIsConnected
|
|
7505
7776
|
}) => {
|
|
7506
7777
|
const { hasAnyWallet } = useConnectedWalletsStore();
|
|
7507
|
-
const { chains, setFromChain } = useChainsStore();
|
|
7778
|
+
const { chains, setFromChain, setToChain } = useChainsStore();
|
|
7779
|
+
const { lastConnectionAddressType } = useWalletSelectModal();
|
|
7508
7780
|
const previousHadWallet = React.useRef(hasAnyWallet());
|
|
7509
7781
|
React.useEffect(() => {
|
|
7510
7782
|
const currentHasWallet = hasAnyWallet();
|
|
@@ -7523,7 +7795,11 @@ const useAutoSelectNetwork = ({
|
|
|
7523
7795
|
(chain2) => chain2.chainKey.toLowerCase() === targetChainKey
|
|
7524
7796
|
);
|
|
7525
7797
|
if (matchingChain) {
|
|
7526
|
-
|
|
7798
|
+
if (lastConnectionAddressType === "dst") {
|
|
7799
|
+
setToChain(matchingChain);
|
|
7800
|
+
} else {
|
|
7801
|
+
setFromChain(matchingChain);
|
|
7802
|
+
}
|
|
7527
7803
|
}
|
|
7528
7804
|
}
|
|
7529
7805
|
}
|
|
@@ -7534,7 +7810,9 @@ const useAutoSelectNetwork = ({
|
|
|
7534
7810
|
evmIsConnected,
|
|
7535
7811
|
hasAnyWallet,
|
|
7536
7812
|
chains,
|
|
7537
|
-
setFromChain
|
|
7813
|
+
setFromChain,
|
|
7814
|
+
setToChain,
|
|
7815
|
+
lastConnectionAddressType
|
|
7538
7816
|
]);
|
|
7539
7817
|
};
|
|
7540
7818
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
@@ -26147,7 +26425,7 @@ class WalletConnectModal {
|
|
|
26147
26425
|
}
|
|
26148
26426
|
async initUi() {
|
|
26149
26427
|
if (typeof window !== "undefined") {
|
|
26150
|
-
await Promise.resolve().then(() => require("./index-
|
|
26428
|
+
await Promise.resolve().then(() => require("./index-DQhIunWv.cjs"));
|
|
26151
26429
|
const modal = document.createElement("wcm-modal");
|
|
26152
26430
|
document.body.insertAdjacentElement("beforeend", modal);
|
|
26153
26431
|
OptionsCtrl.setIsUiLoaded(true);
|
|
@@ -27049,4 +27327,4 @@ exports.useSettingsStore = useSettingsStore;
|
|
|
27049
27327
|
exports.useSwapModel = useSwapModel;
|
|
27050
27328
|
exports.useTokensStore = useTokensStore;
|
|
27051
27329
|
exports.useTransactionStore = useTransactionStore;
|
|
27052
|
-
//# sourceMappingURL=index-
|
|
27330
|
+
//# sourceMappingURL=index-Du1Ins7X.cjs.map
|