Skip to content

Commit

Permalink
fix tx unit error in bsc&heco
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemener committed Apr 2, 2021
1 parent 297c7de commit efdf53b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
23 changes: 7 additions & 16 deletions src/api/ethereumdapp_imkey_web3.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,23 @@ const MAINNET_CHAIN_ID = 1

contextBridge.exposeInMainWorld('imKeyManager', {
accounts: () => {
const res = ipcRenderer.sendSync('message-from-get-address')
const allAccounts = res.result
const ethAccounts = allAccounts
.filter((x) => x.chain === 'Ethereum')
.map((x) => x.address)
const ethchainId = allAccounts
.filter((x) => x.chain === 'Ethereum')
.map((x) => x.chainId)
const ethrpcUrl = allAccounts
.filter((x) => x.chain === 'Ethereum')
.map((x) => x.rpcUrl)
let account = allAccounts.find((x) => x.chain === 'Ethereum')
return {
accounts: ethAccounts,
chainId: ethchainId[0],
rpcUrl: ethrpcUrl[0],
accounts: [account.address],
chainId: account.chainId,
rpcUrl: account.rpcUrl,
headers: {
agent: 'ios:2.4.2:2'
}
},
symbol: account.symbol
}
},
callNativeApi: async (data) => {
const ret = ipcRenderer.sendSync('showMessageBoxSync', JSON.stringify(data))
if (ret === 0) {
return await ipcRenderer.sendSync('message-from-get-api', data)
} else {

}
}
})
Expand Down
10 changes: 5 additions & 5 deletions src/api/imkey_web3_provider.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ function renderDeviceManagerHandler () {
if (WalletAddress.result[i].chain === 'Ethereum') {
WalletAddress.result[i].chainId = args.chainId
WalletAddress.result[i].rpcUrl = args.rpcUrl
WalletAddress.result[i].symbol = args.symbol
}
}
event.returnValue = WalletAddress
Expand Down
12 changes: 8 additions & 4 deletions src/renderer/store/dapps.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,22 @@ export const DAPPS_Polkadot = [
export const DAPPS_Config = {
ETH: {
chainId: 1,
rpcUrl: 'https://mainnet-eth.token.im'
rpcUrl: 'https://mainnet-eth.token.im',
symbol: 'ETH'
},
BSC: {
chainId: 56,
rpcUrl: 'https://bsc-dataseed1.ninicoin.io'
rpcUrl: 'https://bsc-dataseed1.ninicoin.io',
symbol: 'BNB'
},
HECO: {
chainId: 128,
rpcUrl: 'https://http-mainnet.Hecochain.com'
rpcUrl: 'https://http-mainnet.Hecochain.com',
symbol: 'HT'
},
Polkadot: {
chainId: '',
rpcUrl: ''
rpcUrl: '',
symbol: ''
}
}
12 changes: 6 additions & 6 deletions src/worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,29 +207,29 @@ ipcRenderer.on('message-from-main', (event, arg) => {
path: "m/44'/60'/0'/0/0"
})
if (!response.isSuccess) {
coinAddressArray.push({ chain: 'Ethereum', address: '', chainId: 1, rpcUrl: 'https://mainnet-eth.token.im' })
coinAddressArray.push({ chain: 'Ethereum', address: '', chainId: 1, rpcUrl: 'https://mainnet-eth.token.im', symbol:'ETH'})
} else {
coinAddressArray.push({ chain: 'Ethereum', address: response.result.address, chainId: 1, rpcUrl: 'https://mainnet-eth.token.im' })
coinAddressArray.push({ chain: 'Ethereum', address: response.result.address, chainId: 1, rpcUrl: 'https://mainnet-eth.token.im', symbol:'ETH' })
}
}
if (coinNameArr[i] === 'Polkadot') {
response = walletApi.getDOTAddress({
path: "m/44'/354'/0'/0'/0'"
})
if (!response.isSuccess) {
coinAddressArray.push({ chain: 'Polkadot', address: '', chainId: 'Polkadot', rpcUrl: '' })
coinAddressArray.push({ chain: 'Polkadot', address: '', chainId: 'Polkadot', rpcUrl: '', symbol:'' })
} else {
coinAddressArray.push({ chain: 'Polkadot', address: response.result.address, chainId: 'Polkadot', rpcUrl: '' })
coinAddressArray.push({ chain: 'Polkadot', address: response.result.address, chainId: 'Polkadot', rpcUrl: '', symbol:''})
}
}
if (coinNameArr[i] === 'Kusama') {
response = walletApi.getKSMAddress({
path: "m/44'/434'/0'/0'/0'"
})
if (!response.isSuccess) {
coinAddressArray.push({ chain: 'Kusama', address: '', chainId: 'Kusama', rpcUrl: '' })
coinAddressArray.push({ chain: 'Kusama', address: '', chainId: 'Kusama', rpcUrl: '', symbol:'' })
} else {
coinAddressArray.push({ chain: 'Kusama', address: response.result.address, chainId: 'Kusama', rpcUrl: '' })
coinAddressArray.push({ chain: 'Kusama', address: response.result.address, chainId: 'Kusama', rpcUrl: '', symbol:'' })
}
}
}
Expand Down

0 comments on commit efdf53b

Please sign in to comment.