2023-09-05 04:19:53 +02:00
|
|
|
async function pingWallet() {
|
2023-09-03 14:52:14 +02:00
|
|
|
const address = await current_signer.getAddress();
|
|
|
|
const balance = await current_provider.getBalance(address);
|
|
|
|
let set = STATE.RPC_PING;
|
|
|
|
let rst = 0;
|
|
|
|
let r = {
|
|
|
|
balance: balance,
|
|
|
|
address: address,
|
|
|
|
}
|
|
|
|
if (balance < g_minBalance) {
|
|
|
|
set |= STATE.EVM_BALANCE_LOW;
|
|
|
|
} else {
|
|
|
|
rst = STATE.EVM_BALANCE_LOW;
|
|
|
|
}
|
|
|
|
stateChange(r, set, rst);
|
|
|
|
}
|
2023-09-05 04:19:53 +02:00
|
|
|
|
|
|
|
async function pingRpc() {
|
|
|
|
let provider = undefined;
|
|
|
|
try {
|
|
|
|
provider = await provider_connect('default');
|
|
|
|
} catch(e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
if (!provider) {
|
|
|
|
stateChange('no provider', STATE.RPC_GONE, STATE.LOCAL_KEY_REQUEST);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const network = await current_provider.getNetwork();
|
|
|
|
console.debug('chainid', network.chainId);
|
|
|
|
if (network.chainId != g_chainId) {
|
|
|
|
g_chainId = network.chainId;
|
|
|
|
stateChange({'chainId': g_chainId}, STATE.RPC_CHANGE | STATE.RPC_CONNECT);
|
|
|
|
}
|
|
|
|
}
|