clients/js: update evm query
This commit is contained in:
parent
aae1ea1c3f
commit
64952c8d85
|
@ -1,5 +1,5 @@
|
||||||
import { BridgeImplementation__factory, CHAINS, Implementation__factory, NFTBridgeImplementation__factory } from "@certusone/wormhole-sdk"
|
import { BridgeImplementation__factory, CHAINS, Implementation__factory, NFTBridgeImplementation__factory } from "@certusone/wormhole-sdk"
|
||||||
import { ethers } from "ethers"
|
import { BigNumber, ethers } from "ethers"
|
||||||
import { NETWORKS } from "./networks"
|
import { NETWORKS } from "./networks"
|
||||||
import { encode, Encoding, impossible, Payload, typeWidth } from "./vaa"
|
import { encode, Encoding, impossible, Payload, typeWidth } from "./vaa"
|
||||||
import { Contracts, CONTRACTS, EVMChainName } from "@certusone/wormhole-sdk"
|
import { Contracts, CONTRACTS, EVMChainName } from "@certusone/wormhole-sdk"
|
||||||
|
@ -44,6 +44,18 @@ export async function query_contract_evm(
|
||||||
}
|
}
|
||||||
result.guardianSetExpiry = await core.getGuardianSetExpiry()
|
result.guardianSetExpiry = await core.getGuardianSetExpiry()
|
||||||
result.chainId = await core.chainId()
|
result.chainId = await core.chainId()
|
||||||
|
// TODO: need new sdk release to expose this function in BridgeImplementation
|
||||||
|
const core2 = new ethers.Contract(contract_address, ["function evmChainId() public view returns (uint256)", "function isFork() public view returns (bool)"], provider)
|
||||||
|
try {
|
||||||
|
result.evmChainId = await core2.evmChainId()
|
||||||
|
} catch (e) {
|
||||||
|
result.evmChainId = null
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
result.isFork = await core2.isFork()
|
||||||
|
} catch (e) {
|
||||||
|
result.isFork = null
|
||||||
|
}
|
||||||
result.governanceChainId = await core.governanceChainId()
|
result.governanceChainId = await core.governanceChainId()
|
||||||
result.governanceContract = await core.governanceContract()
|
result.governanceContract = await core.governanceContract()
|
||||||
result.messageFee = await core.messageFee()
|
result.messageFee = await core.messageFee()
|
||||||
|
@ -63,8 +75,18 @@ export async function query_contract_evm(
|
||||||
result.tokenImplementation = await tb.tokenImplementation()
|
result.tokenImplementation = await tb.tokenImplementation()
|
||||||
result.chainId = await tb.chainId()
|
result.chainId = await tb.chainId()
|
||||||
// TODO: need new sdk release to expose this function in BridgeImplementation
|
// TODO: need new sdk release to expose this function in BridgeImplementation
|
||||||
const tb2 = new ethers.Contract(contract_address, ["function finality() public view returns (uint8)"], provider)
|
const tb2 = new ethers.Contract(contract_address, ["function finality() public view returns (uint8)", "function evmChainId() public view returns (uint256)", "function isFork() public view returns (bool)"], provider)
|
||||||
result.finality = await tb2.finality()
|
result.finality = await tb2.finality()
|
||||||
|
try {
|
||||||
|
result.evmChainId = await tb2.evmChainId()
|
||||||
|
} catch (e) {
|
||||||
|
result.evmChainId = null
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
result.isFork = await tb2.isFork()
|
||||||
|
} catch (e) {
|
||||||
|
result.isFork = null
|
||||||
|
}
|
||||||
result.governanceChainId = await tb.governanceChainId()
|
result.governanceChainId = await tb.governanceChainId()
|
||||||
result.governanceContract = await tb.governanceContract()
|
result.governanceContract = await tb.governanceContract()
|
||||||
result.WETH = await tb.WETH()
|
result.WETH = await tb.WETH()
|
||||||
|
@ -89,8 +111,18 @@ export async function query_contract_evm(
|
||||||
result.tokenImplementation = await nb.tokenImplementation()
|
result.tokenImplementation = await nb.tokenImplementation()
|
||||||
result.chainId = await nb.chainId()
|
result.chainId = await nb.chainId()
|
||||||
// TODO: need new sdk release to expose this function in NFTBridgeImplementation
|
// TODO: need new sdk release to expose this function in NFTBridgeImplementation
|
||||||
const nb2 = new ethers.Contract(contract_address, ["function finality() public view returns (uint8)"], provider)
|
const nb2 = new ethers.Contract(contract_address, ["function finality() public view returns (uint8)", "function evmChainId() public view returns (uint256)", "function isFork() public view returns (bool)"], provider)
|
||||||
result.finality = await nb2.finality()
|
result.finality = await nb2.finality()
|
||||||
|
try {
|
||||||
|
result.evmChainId = await tb2.evmChainId()
|
||||||
|
} catch (e) {
|
||||||
|
result.evmChainId = null
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
result.isFork = await tb2.isFork()
|
||||||
|
} catch (e) {
|
||||||
|
result.isFork = null
|
||||||
|
}
|
||||||
result.governanceChainId = await nb.governanceChainId()
|
result.governanceChainId = await nb.governanceChainId()
|
||||||
result.governanceContract = await nb.governanceContract()
|
result.governanceContract = await nb.governanceContract()
|
||||||
result.registrations = {}
|
result.registrations = {}
|
||||||
|
|
Loading…
Reference in New Issue