From 145aaaf83a257b2042ef65beb3547c620bbcac46 Mon Sep 17 00:00:00 2001 From: D Date: Thu, 19 Dec 2024 17:29:43 +0500 Subject: [PATCH] chore(vechain): enabled --- src/config.ts | 24 +++++++++++----------- src/handler/chains/evm/utils/getBalance.ts | 14 ++++++++++++- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/config.ts b/src/config.ts index e1e2cf2..6aa30f1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -155,7 +155,7 @@ export const bridgeTestChains = [ { chain: "VECHAIN", rpcURL: "https://sync-testnet.veblocks.net", - nativeCoinSymbol: "VET", + nativeCoinSymbol: "VTHO", intialFund: "50000000000000000", contractAddress: "0x7111eb5f8d9dA472e9608f2ab3De275C040D60B2", chainType: "vechain", @@ -406,17 +406,17 @@ export const prodBridgeConfig: IBridgeConfig = { nativeCoinSymbol: "SCRT", rpcURL: "https://rpc.ankr.com/http/scrt_cosmos", }, - // { - // chain: "VECHAIN", - // rpcURL: "https://mainnet.veblocks.net", - // nativeCoinSymbol: "VET", - // intialFund: "50000000000000000", - // contractAddress: "0x4c14CF6Eb11978F0A90B369107Aa7F5A08994428", - // chainType: "vechain", - // lastBlock: 20407625, - // decimals: 18, - // blockChunks: 1000, - // }, + { + chain: "VECHAIN", + rpcURL: "https://mainnet.veblocks.net", + nativeCoinSymbol: "VTHO", + intialFund: "50000000000000000000", + contractAddress: "0x4c14CF6Eb11978F0A90B369107Aa7F5A08994428", + chainType: "vechain", + lastBlock: 20407625, + decimals: 18, + blockChunks: 1000, + }, ], storageConfig: { chain: "OP", diff --git a/src/handler/chains/evm/utils/getBalance.ts b/src/handler/chains/evm/utils/getBalance.ts index 6727dbd..6522338 100644 --- a/src/handler/chains/evm/utils/getBalance.ts +++ b/src/handler/chains/evm/utils/getBalance.ts @@ -1,4 +1,5 @@ -import type { Signer } from "ethers"; +import { Driver, SimpleNet } from "@vechain/connex-driver"; +import { BrowserProvider, type Signer } from "ethers"; import { useMutexAndRelease } from "../../../utils"; import type { EVMProviderFetch } from "../types"; @@ -7,6 +8,17 @@ export default async function getBalance( fetchProvider: EVMProviderFetch, ) { return useMutexAndRelease(fetchProvider, async (provider) => { + if (provider instanceof BrowserProvider) { + const net = new SimpleNet( + process.env.NETWORK === "testnet" + ? "https://sync-testnet.veblocks.net" + : "https://mainnet.vecha.in", + ); + const driver = await Driver.connect(net); + return BigInt( + (await driver.getAccount(await signer.getAddress(), "")).energy, + ); + } return provider.getBalance(await signer.getAddress()); }); }