get chain-id

This commit is contained in:
liangping 2023-09-13 17:19:59 +08:00
parent b0ebf40312
commit 7643ebce55

View File

@ -95,8 +95,14 @@ async function initParamsForKeplr() {
async function initSnap() { async function initSnap() {
const chain = selected.value const chain = selected.value
const [token] = chain.assets const [token] = chain.assets
if(!chain.endpoints?.rest?.at(0)) throw new Error("Endpoint does not set");
const client = CosmosRestClient.newDefault(chain.endpoints.rest?.at(0)?.address || "")
const b = await client.getBaseBlockLatest()
const chainId = b.block.header.chain_id
conf.value = JSON.stringify({ conf.value = JSON.stringify({
chainId: chain.chainId, chainId,
chainName: chain.chainName, chainName: chain.chainName,
bech32Config: { bech32Config: {
bech32PrefixAccAddr: chain.bech32Prefix, bech32PrefixAccAddr: chain.bech32Prefix,