This commit is contained in:
tim
2024-10-22 03:42:08 -04:00
parent 82fccc1be3
commit d33eca6931
12 changed files with 101 additions and 40 deletions

View File

@@ -156,16 +156,6 @@ export async function connectWallet(chainId) {
}
export async function switchChain(chainId) {
if (useWalletStore().chainId === chainId)
return
await window.ethereum.request({
"method": "wallet_switchEthereumChain",
"params": [{"chainId": '0x' + chainId.toString(16)}]
})
}
function discoverVaults(owner) {
const s = useStore()
console.log('discoverVaults', owner)
@@ -522,7 +512,67 @@ function upgradeError(e) {
console.error('error while upgrading vault', e)
}
export async function upgradeVault(vault, impl) {
pendTransaction(upgradeSender(vault, impl), upgradeError)
}
const _chainInfos = {
// Arbitrum One
42161: {
"chainId": "0xa4b1",
"chainName": "Arbitrum One",
"rpcUrls": ["https://arbitrum-mainnet.infura.io"],
"blockExplorerUrls": ['https://explorer.arbitrum.io'],
"nativeCurrency": {
"name": "Ethereum",
"symbol": "ETH",
"decimals": 18
}
},
1337: {
"chainId": "0x539",
"chainName": "Dexorder Alpha Testnet",
"rpcUrls": ["https://rpc.alpha.dexorder.trade"],
"nativeCurrency": {
"name": "Test Ethereum",
"symbol": "TETH",
"decimals": 18
}
},
31337: {
"chainId": "0x7a69",
"chainName": "Mockchain",
"rpcUrls": ["http://localhost:8545"],
"nativeCurrency": {
"name": "Test Ethereum",
"symbol": "TETH",
"decimals": 18
}
},
}
export async function switchChain(chainId) {
if (useWalletStore().chainId === chainId)
return
await window.ethereum.request({
"method": "wallet_switchEthereumChain",
"params": [{"chainId": '0x' + chainId.toString(16)}]
})
}
export async function addNetwork(chainId) {
const info = _chainInfos[chainId]
if (!info) {
console.log(`No info to add chain ${chainId}`)
return
}
await window.ethereum.request({
"method": "wallet_addEthereumChain",
"params": [info]
});
}