Skip to content

Commit bf77f7d

Browse files
authored
Merge pull request #13 from XP-NETWORK/vechain/add-testnet-config
feat(config::testnet): add vechain testnet config
2 parents 6070261 + c89860a commit bf77f7d

File tree

6 files changed

+304
-30
lines changed

6 files changed

+304
-30
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
"@ton/core": "=0.56.3",
4242
"@ton/crypto": "=3.2.0",
4343
"@ton/ton": "=13.11.1",
44+
"@vechain/connex-driver": "^2.0.8",
45+
"@vechain/connex-framework": "^2.0.8",
46+
"@vechain/web3-providers-connex": "^1.1.2",
4447
"@tzkt/sdk-api": "^2.2.1",
4548
"@xp/cosmos-client": "git+https://github.com/XP-NETWORK/cosmos-client#bleeding-edge",
4649
"aptos": "^1.21.0",

src/factory/config.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { Principal } from "@dfinity/principal";
44
import { ProxyNetworkProvider } from "@multiversx/sdk-network-providers/out";
55
import { TezosToolkit } from "@taquito/taquito";
66
import { TonClient } from "@ton/ton";
7-
import { JsonRpcProvider, ethers } from "ethers";
7+
import { Driver, SimpleNet } from "@vechain/connex-driver";
8+
import { Framework } from "@vechain/connex-framework";
9+
import * as thor from "@vechain/web3-providers-connex";
10+
import { BrowserProvider, JsonRpcProvider, ethers } from "ethers";
811
import { SecretNetworkClient } from "secretjs";
912
import { BridgeStorage__factory } from "../contractsTypes/evm";
1013
import type { TAptosParams } from "../handlers/aptos/types";
@@ -39,17 +42,22 @@ export interface TChainParams {
3942
fantomParams: TEvmParams;
4043
avaxParams: TEvmParams;
4144
casperParams: TCasperParams;
45+
vechainParams: TEvmParams;
4246
}
4347

4448
export namespace ChainFactoryConfigs {
45-
export function TestNet() {
49+
export async function TestNet() {
4650
const skale = new JsonRpcProvider(
4751
"https://testnet.skalenodes.com/v1/juicy-low-small-testnet",
4852
);
4953
const storage = BridgeStorage__factory.connect(
5054
"0x8184bCDC0a4C24D1cB8e054E389660B5b7160186",
5155
skale,
5256
);
57+
const net = new SimpleNet("https://sync-testnet.veblocks.net");
58+
const driver = await Driver.connect(net);
59+
const connexObj = new Framework(driver);
60+
5361
return {
5462
bscParams: {
5563
identifier: Chain.BSC,
@@ -156,6 +164,18 @@ export namespace ChainFactoryConfigs {
156164
storage,
157165
proxy_url: "https://sheltered-crag-76748.herokuapp.com/",
158166
},
167+
vechainParams: {
168+
identifier: Chain.VECHAIN,
169+
provider: new BrowserProvider(
170+
new thor.Provider({
171+
connex: connexObj,
172+
net,
173+
}),
174+
),
175+
bridge: ethers.getAddress("0x7111eb5f8d9dA472e9608f2ab3De275C040D60B2"),
176+
royaltySalePrice: 10000,
177+
storage,
178+
},
159179
} satisfies Partial<TChainParams>;
160180
}
161181

src/factory/factory.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export namespace Chain {
4242
export const FANTOM = "FANTOM";
4343
export const AVALANCHE = "AVALANCHE";
4444
export const CASPER = "CASPER";
45+
export const VECHAIN = "VECHAIN";
4546
}
4647

4748
function mapNonceToParams(chainParams: Partial<TChainParams>): TParamMap {
@@ -64,6 +65,7 @@ function mapNonceToParams(chainParams: Partial<TChainParams>): TParamMap {
6465
cToP.set(Chain.FANTOM, chainParams.fantomParams);
6566
cToP.set(Chain.AVALANCHE, chainParams.avaxParams);
6667
cToP.set(Chain.CASPER, chainParams.casperParams);
68+
cToP.set(Chain.VECHAIN, chainParams.vechainParams);
6769
return cToP;
6870
}
6971

@@ -253,3 +255,6 @@ CHAIN_INFO.set(Chain.AVALANCHE, {
253255
CHAIN_INFO.set(Chain.CASPER, {
254256
constructor: casperHandler,
255257
});
258+
CHAIN_INFO.set(Chain.VECHAIN, {
259+
constructor: evmHandler,
260+
});

src/factory/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ export type MetaMap = {
5656
FANTOM: TEvmMeta;
5757
AVALANCHE: TEvmMeta;
5858
CASPER: TCasperMeta;
59+
VECHAIN: TEvmMeta;
5960
};

src/handlers/evm/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {
2+
BrowserProvider,
23
ContractTransactionResponse,
34
JsonRpcProvider,
45
Overrides,
@@ -53,7 +54,7 @@ export type TEvmHandler = TNftChain<
5354

5455
export type TEvmParams = {
5556
identifier: string;
56-
provider: JsonRpcProvider;
57+
provider: JsonRpcProvider | BrowserProvider;
5758
bridge: string;
5859
royaltySalePrice: number;
5960
storage: BridgeStorage;

0 commit comments

Comments
 (0)