Skip to content

Commit

Permalink
fix(vechain): fix vechain add self as validator
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadusmanuet committed Dec 10, 2024
1 parent 0145906 commit cbf347f
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 1,541 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@ton/ton": "^13.9.0",
"@vechain/connex-driver": "^2.0.8",
"@vechain/connex-framework": "^2.0.8",
"@vechain/web3-providers-connex": "^1.1.2",
"@xp/cosmos-client": "git+https://github.com/XP-NETWORK/cosmos-client#bleeding-edge",
"async-mutex": "^0.5.0",
"axios": "^1.6.7",
Expand All @@ -66,7 +67,7 @@
"chalk": "4",
"dotenv": "^16.4.5",
"elysia": "^1.0.25",
"ethers": "^6.11.1",
"ethers": "^6.10.0",
"express": "^4.19.2",
"fp-ts": "^2.16.6",
"http-status-codes": "^2.3.0",
Expand All @@ -83,7 +84,6 @@
"tonweb": "^0.0.62",
"tslog": "^4.9.3",
"web3-eth-accounts": "^4.1.1",
"web3-providers-connex": "^0.3.1",
"xp-decentralized-sdk": "git+https://github.com/XP-NETWORK/xp-decentralized-client-library#bleeding-edge",
"zod": "^3.22.4"
}
Expand Down
2 changes: 1 addition & 1 deletion src/deps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function configDeps(
new NonceManager(stakingSigner),
);
const orm = await MikroORM.init(MikroOrmConfig);
await orm.schema.updateSchema();
// await orm.schema.updateSchema();
await runMigrationsIfAny(orm.getMigrator(), logger);
const em = orm.em;
const serverLinkHandler = process.env.SERVER_LINK
Expand Down
16 changes: 10 additions & 6 deletions src/handler/chains/evm/config-vechain.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { EntityManager } from "@mikro-orm/sqlite";
import { Driver, SimpleNet } from "@vechain/connex-driver";
import { Driver, SimpleNet, SimpleWallet } from "@vechain/connex-driver";
import { Framework } from "@vechain/connex-framework";
import * as thor from "@vechain/web3-providers-connex";
import { Mutex } from "async-mutex";
import type { AxiosInstance } from "axios";
import { BrowserProvider, Wallet } from "ethers";
import { privateKeyToAccount } from "web3-eth-accounts";
import * as thor from "web3-providers-connex";
import type { TSupportedChainTypes, TSupportedChains } from "../../../config";
import type { BridgeStorage, ERC20Staking } from "../../../contractsTypes/evm";
import { Block } from "../../../persistence/entities/block";
Expand All @@ -29,14 +29,18 @@ export async function configVechainHandler(
});
const mutex = new Mutex();
const net = new SimpleNet(conf.rpcURL);
const driver = await Driver.connect(net);
const simpleWalletObj = new SimpleWallet();
simpleWalletObj.import(wallet.privateKey);
const driver = await Driver.connect(net, simpleWalletObj);
const connexObj = new Framework(driver);
const provider = thor.ethers.modifyProvider(
new BrowserProvider(
new thor.ConnexProvider({
new thor.Provider({
connex: connexObj,
}) as never,
) as never,
net,
wallet: simpleWalletObj,
}),
),
);
const fetchProvider = async () => {
const release = await mutex.acquire();
Expand Down
9 changes: 8 additions & 1 deletion src/handler/chains/evm/handler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ContractRunner } from "ethers";
import { raise } from "xp-decentralized-sdk";
import { type Bridge, Bridge__factory } from "../../../contractsTypes/evm";
import pollForLockEvents from "../../poller";
Expand Down Expand Up @@ -35,7 +36,13 @@ export function evmHandler({
}: EVMHandlerParams): THandler {
const bc = async (): Promise<[Bridge, MutexReleaser]> => {
const [provider, release] = await fetchProvider();
const contract = Bridge__factory.connect(bridge, signer.connect(provider));
let runner: ContractRunner;
if (chainIdent === "VECHAIN") {
runner = await provider.getSigner(signer.address);
} else {
runner = signer.connect(provider);
}
const contract = Bridge__factory.connect(bridge, runner);
return [contract, release];
};
return {
Expand Down
Loading

0 comments on commit cbf347f

Please sign in to comment.