diff --git a/src/config.ts b/src/config.ts index aec8dd4..76d2b64 100644 --- a/src/config.ts +++ b/src/config.ts @@ -74,6 +74,16 @@ export const bridgeTestChains = [ nativeCoinSymbol: "EGLD", lastBlock: 4757826, }, + { + chainType: "icp", + chain: "ICP", + contractAddress: "bw4dl-smaaa-aaaaa-qaacq-cai", + decimals: 9, + intialFund: "100000000", + lastBlock: 0, + nativeCoinSymbol: "ICP", + rpcURL: "https://tools.xp.network/", + }, ] as const satisfies TChain[]; export const storageTestnetConfig: IEvmChainConfig = { diff --git a/src/contractsTypes/icp/bridge/bridge.did b/src/contractsTypes/icp/bridge/bridge.did deleted file mode 100644 index fbc8856..0000000 --- a/src/contractsTypes/icp/bridge/bridge.did +++ /dev/null @@ -1,86 +0,0 @@ -type XPBridge = - service { - acceptCycles: () -> (); - add_validator: (AddValidator, vec SignerAndSignature) -> (); - availableCycles: () -> (nat) query; - blacklist_validator: (BlacklistValidator, vec SignerAndSignature) -> (); - claim_nft: (ClaimData, vec SignerAndSignature) -> (text); - claim_validator_rewards: (text) -> (nat64, nat64); - encode_add_validator: (AddValidator) -> (blob) query; - encode_blacklist_validator: (BlacklistValidator) -> (blob) query; - encode_claim_data: (ClaimData) -> (blob) query; - get_blacklisted_validators: (text) -> (opt bool) query; - get_claimed_data: (text) -> (opt ClaimedEvent) query; - get_hash_from_nonce: (nat) -> (opt text) query; - get_locked_data: (text) -> (opt LockedEvent) query; - get_nonce: () -> (nat) query; - get_validator: (text) -> (opt Validator) query; - get_validator_count: () -> (nat) query; - init: () -> (); - lock_nft: (principal, nat, text, text) -> (text); - }; -type Validator = - record { - address: principal; - pending_rewards: nat64; - }; -type SignerAndSignature = - record { - signature: text; - signer: text; - }; -type LockedEvent = - record { - destination_chain: text; - destination_user_address: text; - nft_type: text; - source_chain: text; - source_nft_contract_address: principal; - token_amount: nat; - token_id: nat; - }; -type ClaimedEvent = - record { - lock_tx_chain: text; - nft_contract: principal; - source_chain: text; - token_id: nat; - transaction_hash: text; - }; -type ClaimData = - record { - destination_chain: text; - destination_user_address: principal; - fee: nat64; - lock_tx_chain: text; - metadata: text; - name: text; - nft_type: text; - royalty: nat; - royalty_receiver: principal; - source_chain: text; - source_nft_contract_address: text; - symbol: text; - token_amount: nat; - token_id: nat; - transaction_hash: text; - }; -type BlacklistValidator = - record { - "principal": principal; - public_key: text; - }; -type AddValidator = - record { - "principal": principal; - public_key: text; - }; -service : (record { - chain_type: text; - collection_deployer: principal; - storage_deployer: principal; - validators: vec record { - text; - principal; - }; - }) -> XPBridge diff --git a/src/contractsTypes/icp/bridge/bridge.did.js b/src/contractsTypes/icp/bridge/bridge.did.js deleted file mode 100644 index 60cd96b..0000000 --- a/src/contractsTypes/icp/bridge/bridge.did.js +++ /dev/null @@ -1,118 +0,0 @@ -export const idlFactory = ({ IDL }) => { - const AddValidator = IDL.Record({ - 'principal' : IDL.Principal, - 'public_key' : IDL.Text, - }); - const SignerAndSignature = IDL.Record({ - 'signature' : IDL.Text, - 'signer' : IDL.Text, - }); - const BlacklistValidator = IDL.Record({ - 'principal' : IDL.Principal, - 'public_key' : IDL.Text, - }); - const ClaimData = IDL.Record({ - 'fee' : IDL.Nat64, - 'source_chain' : IDL.Text, - 'lock_tx_chain' : IDL.Text, - 'transaction_hash' : IDL.Text, - 'token_amount' : IDL.Nat, - 'destination_chain' : IDL.Text, - 'token_id' : IDL.Nat, - 'source_nft_contract_address' : IDL.Text, - 'metadata' : IDL.Text, - 'name' : IDL.Text, - 'nft_type' : IDL.Text, - 'royalty' : IDL.Nat, - 'royalty_receiver' : IDL.Principal, - 'destination_user_address' : IDL.Principal, - 'symbol' : IDL.Text, - }); - const ClaimedEvent = IDL.Record({ - 'source_chain' : IDL.Text, - 'lock_tx_chain' : IDL.Text, - 'transaction_hash' : IDL.Text, - 'token_id' : IDL.Nat, - 'nft_contract' : IDL.Principal, - }); - const LockedEvent = IDL.Record({ - 'source_chain' : IDL.Text, - 'token_amount' : IDL.Nat, - 'destination_chain' : IDL.Text, - 'token_id' : IDL.Nat, - 'source_nft_contract_address' : IDL.Principal, - 'nft_type' : IDL.Text, - 'destination_user_address' : IDL.Text, - }); - const Validator = IDL.Record({ - 'address' : IDL.Principal, - 'pending_rewards' : IDL.Nat64, - }); - const XPBridge = IDL.Service({ - 'acceptCycles' : IDL.Func([], [], []), - 'add_validator' : IDL.Func( - [AddValidator, IDL.Vec(SignerAndSignature)], - [], - [], - ), - 'availableCycles' : IDL.Func([], [IDL.Nat], ['query']), - 'blacklist_validator' : IDL.Func( - [BlacklistValidator, IDL.Vec(SignerAndSignature)], - [], - [], - ), - 'claim_nft' : IDL.Func( - [ClaimData, IDL.Vec(SignerAndSignature)], - [IDL.Text], - [], - ), - 'claim_validator_rewards' : IDL.Func( - [IDL.Text], - [IDL.Nat64, IDL.Nat64], - [], - ), - 'encode_add_validator' : IDL.Func( - [AddValidator], - [IDL.Vec(IDL.Nat8)], - ['query'], - ), - 'encode_blacklist_validator' : IDL.Func( - [BlacklistValidator], - [IDL.Vec(IDL.Nat8)], - ['query'], - ), - 'encode_claim_data' : IDL.Func([ClaimData], [IDL.Vec(IDL.Nat8)], ['query']), - 'get_blacklisted_validators' : IDL.Func( - [IDL.Text], - [IDL.Opt(IDL.Bool)], - ['query'], - ), - 'get_claimed_data' : IDL.Func( - [IDL.Text], - [IDL.Opt(ClaimedEvent)], - ['query'], - ), - 'get_hash_from_nonce' : IDL.Func([IDL.Nat], [IDL.Opt(IDL.Text)], ['query']), - 'get_locked_data' : IDL.Func([IDL.Text], [IDL.Opt(LockedEvent)], ['query']), - 'get_nonce' : IDL.Func([], [IDL.Nat], ['query']), - 'get_validator' : IDL.Func([IDL.Text], [IDL.Opt(Validator)], ['query']), - 'get_validator_count' : IDL.Func([], [IDL.Nat], ['query']), - 'init' : IDL.Func([], [], []), - 'lock_nft' : IDL.Func( - [IDL.Principal, IDL.Nat, IDL.Text, IDL.Text], - [IDL.Text], - [], - ), - }); - return XPBridge; -}; -export const init = ({ IDL }) => { - return [ - IDL.Record({ - 'storage_deployer' : IDL.Principal, - 'collection_deployer' : IDL.Principal, - 'chain_type' : IDL.Text, - 'validators' : IDL.Vec(IDL.Tuple(IDL.Text, IDL.Principal)), - }), - ]; -}; diff --git a/src/contractsTypes/icp/bridge/bridge.ts b/src/contractsTypes/icp/bridge/bridge.ts new file mode 100644 index 0000000..2874e94 --- /dev/null +++ b/src/contractsTypes/icp/bridge/bridge.ts @@ -0,0 +1,112 @@ +//@ts-nocheck generated code cope + +export const idlFactory = ({ IDL }) => { + const AddValidator = IDL.Record({ + principal: IDL.Principal, + public_key: IDL.Text, + }); + const SignerAndSignature = IDL.Record({ + signature: IDL.Text, + signer: IDL.Text, + }); + const BlacklistValidator = IDL.Record({ + principal: IDL.Principal, + public_key: IDL.Text, + }); + const ClaimData = IDL.Record({ + fee: IDL.Nat64, + source_chain: IDL.Text, + lock_tx_chain: IDL.Text, + transaction_hash: IDL.Text, + token_amount: IDL.Nat, + destination_chain: IDL.Text, + token_id: IDL.Nat, + source_nft_contract_address: IDL.Text, + metadata: IDL.Text, + name: IDL.Text, + nft_type: IDL.Text, + royalty: IDL.Nat, + royalty_receiver: IDL.Principal, + destination_user_address: IDL.Principal, + symbol: IDL.Text, + }); + const ClaimedEvent = IDL.Record({ + source_chain: IDL.Text, + lock_tx_chain: IDL.Text, + transaction_hash: IDL.Text, + token_id: IDL.Nat, + nft_contract: IDL.Principal, + }); + const LockedEvent = IDL.Record({ + source_chain: IDL.Text, + token_amount: IDL.Nat, + destination_chain: IDL.Text, + token_id: IDL.Nat, + source_nft_contract_address: IDL.Principal, + nft_type: IDL.Text, + destination_user_address: IDL.Text, + }); + const Validator = IDL.Record({ + address: IDL.Principal, + pending_rewards: IDL.Nat64, + }); + const XPBridge = IDL.Service({ + acceptCycles: IDL.Func([], [], []), + add_validator: IDL.Func( + [AddValidator, IDL.Vec(SignerAndSignature)], + [], + [] + ), + availableCycles: IDL.Func([], [IDL.Nat], ["query"]), + blacklist_validator: IDL.Func( + [BlacklistValidator, IDL.Vec(SignerAndSignature)], + [], + [] + ), + claim_nft: IDL.Func( + [ClaimData, IDL.Vec(SignerAndSignature)], + [IDL.Text], + [] + ), + claim_validator_rewards: IDL.Func([IDL.Text], [IDL.Nat64, IDL.Nat64], []), + encode_add_validator: IDL.Func( + [AddValidator], + [IDL.Vec(IDL.Nat8)], + ["query"] + ), + encode_blacklist_validator: IDL.Func( + [BlacklistValidator], + [IDL.Vec(IDL.Nat8)], + ["query"] + ), + encode_claim_data: IDL.Func([ClaimData], [IDL.Vec(IDL.Nat8)], ["query"]), + get_blacklisted_validators: IDL.Func( + [IDL.Text], + [IDL.Opt(IDL.Bool)], + ["query"] + ), + get_claimed_data: IDL.Func([IDL.Text], [IDL.Opt(ClaimedEvent)], ["query"]), + get_hash_from_nonce: IDL.Func([IDL.Nat], [IDL.Opt(IDL.Text)], ["query"]), + get_locked_data: IDL.Func([IDL.Text], [IDL.Opt(LockedEvent)], ["query"]), + get_nonce: IDL.Func([], [IDL.Nat], ["query"]), + get_validator: IDL.Func([IDL.Text], [IDL.Opt(Validator)], ["query"]), + get_validator_count: IDL.Func([], [IDL.Nat], ["query"]), + init: IDL.Func([], [], []), + lock_nft: IDL.Func( + [IDL.Principal, IDL.Nat, IDL.Text, IDL.Text], + [IDL.Text], + [] + ), + }); + return XPBridge; +}; +export const init = ({ IDL }) => { + return [ + IDL.Record({ + storage_deployer: IDL.Principal, + collection_deployer: IDL.Principal, + chain_type: IDL.Text, + validators: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Principal)), + }), + ]; +}; diff --git a/src/contractsTypes/icp/bridge/bridge.did.d.ts b/src/contractsTypes/icp/bridge/bridge.types.ts similarity index 100% rename from src/contractsTypes/icp/bridge/bridge.did.d.ts rename to src/contractsTypes/icp/bridge/bridge.types.ts diff --git a/src/contractsTypes/icp/bridge/index.d.ts b/src/contractsTypes/icp/bridge/index.d.ts deleted file mode 100644 index fa3015d..0000000 --- a/src/contractsTypes/icp/bridge/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { - ActorSubclass, - HttpAgentOptions, - ActorConfig, - Agent, -} from "@dfinity/agent"; -import type { Principal } from "@dfinity/principal"; -import type { IDL } from "@dfinity/candid"; - -import { _SERVICE } from './bridge.did'; - -export declare const idlFactory: IDL.InterfaceFactory; -export declare const canisterId: string; - -export declare interface CreateActorOptions { - /** - * @see {@link Agent} - */ - agent?: Agent; - /** - * @see {@link HttpAgentOptions} - */ - agentOptions?: HttpAgentOptions; - /** - * @see {@link ActorConfig} - */ - actorOptions?: ActorConfig; -} - -/** - * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. - * @constructs {@link ActorSubClass} - * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to - * @param {CreateActorOptions} options - see {@link CreateActorOptions} - * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions - * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent - * @see {@link HttpAgentOptions} - * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor - * @see {@link ActorConfig} - */ -export declare const createActor: ( - canisterId: string | Principal, - options?: CreateActorOptions -) => ActorSubclass<_SERVICE>; - -/** - * Intialized Actor using default settings, ready to talk to a canister using its candid interface - * @constructs {@link ActorSubClass} - */ -export declare const bridge: ActorSubclass<_SERVICE>; diff --git a/src/contractsTypes/icp/bridge/index.js b/src/contractsTypes/icp/bridge/index.js deleted file mode 100644 index 1c7c27b..0000000 --- a/src/contractsTypes/icp/bridge/index.js +++ /dev/null @@ -1,42 +0,0 @@ -import { Actor, HttpAgent } from "@dfinity/agent"; - -// Imports and re-exports candid interface -import { idlFactory } from "./bridge.did.js"; -export { idlFactory } from "./bridge.did.js"; - -/* CANISTER_ID is replaced by webpack based on node environment - * Note: canister environment variable will be standardized as - * process.env.CANISTER_ID_ - * beginning in dfx 0.15.0 - */ -export const canisterId = - process.env.CANISTER_ID_BRIDGE; - -export const createActor = (canisterId, options = {}) => { - const agent = options.agent || new HttpAgent({ ...options.agentOptions }); - - if (options.agent && options.agentOptions) { - console.warn( - "Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." - ); - } - - // Fetch root key for certificate validation during development - if (process.env.DFX_NETWORK !== "ic") { - agent.fetchRootKey().catch((err) => { - console.warn( - "Unable to fetch root key. Check to ensure that your local replica is running" - ); - console.error(err); - }); - } - - // Creates an actor with using the candid interface and the HttpAgent - return Actor.createActor(idlFactory, { - agent, - canisterId, - ...options.actorOptions, - }); -}; - -export const bridge = canisterId ? createActor(canisterId) : undefined; diff --git a/src/deps.ts b/src/deps.ts index 63df280..9834c1a 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -22,11 +22,14 @@ import { raise, tonHandler } from "./handler/ton"; import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; import { DirectSecp256k1Wallet } from "@cosmjs/proto-signing"; +import { HttpAgent } from "@dfinity/agent"; +import { Ed25519KeyIdentity } from "@dfinity/identity"; import type { EntityManager } from "@mikro-orm/sqlite"; import axios, { type AxiosInstance } from "axios"; import { ERC20Staking__factory } from "./contractsTypes/evm"; import { cosmWasmHandler } from "./handler/cosmos"; import { evmStakingHandler } from "./handler/evm/stakingHandler"; +import { icpHandler } from "./handler/icp"; import type { LogInstance, THandler } from "./handler/types"; import MikroOrmConfig from "./mikro-orm.config"; import { Block } from "./persistence/entities/block"; @@ -38,6 +41,8 @@ import type { IEvmWallet, IGeneratedWallets, IHederaChainConfig, + IICPChainConfig, + IICPWallet, IMultiversXChainConfig, IMultiversXWallet, ISecretChainConfig, @@ -136,6 +141,46 @@ export async function configStakingHandler( ); } +export async function configIcpHandler( + conf: IICPChainConfig, + storage: BridgeStorage, + em: EntityManager, + icpWallet: IICPWallet, + serverLinkHandler: AxiosInstance | undefined, + icpLogger: LogInstance, + staking: ERC20Staking, + validatorAddress: string, +): Promise { + const lb = await em.findOne(Block, { + chain: conf.chain, + contractAddress: conf.contractAddress, + }); + const identity = Ed25519KeyIdentity.fromSecretKey( + Buffer.from(icpWallet.privateKey, "hex"), + ); + const agent = await HttpAgent.create({ + host: conf.rpcURL, + identity, + }); + await agent.fetchRootKey(); + return icpHandler({ + agent, + bridge: conf.contractAddress, + chainIdent: "ICP", + chainType: "icp", + decimals: 9, + em: em.fork(), + identity, + initialFunds: BigInt(conf.intialFund), + lastBlock_: lb?.lastBlock ?? conf.lastBlock, + logger: icpLogger, + serverLinkHandler, + validatorAddress, + storage, + staking, + }); +} + export async function configTezosHandler( conf: ITezosChainConfig, storage: BridgeStorage, @@ -409,6 +454,21 @@ export async function configDeps( ) : undefined; + const icpc = config.bridgeChains.find((e) => e.chainType === "icp"); + + const icp = icpc + ? await configIcpHandler( + icpc, + storage, + em.fork(), + secrets.icpWallet, + serverLinkHandler, + logger.getSubLogger({ name: "ICP" }), + staking, + secrets.evmWallet.address, + ) + : undefined; + return { storage, em, @@ -471,6 +531,7 @@ export async function configDeps( scrt, mx, ton, + icp, ].filter((e) => e !== undefined) as THandler[], }; } diff --git a/src/handler/icp/index.ts b/src/handler/icp/index.ts index 6451906..ab8e937 100644 --- a/src/handler/icp/index.ts +++ b/src/handler/icp/index.ts @@ -1,6 +1,8 @@ +import { Actor, type ActorSubclass } from "@dfinity/agent"; import { LedgerCanister } from "@dfinity/ledger-icp"; import { Principal } from "@dfinity/principal"; -import { createActor } from "../../contractsTypes/icp/bridge"; +import { idlFactory as BridgeIDL } from "../../contractsTypes/icp/bridge/bridge"; +import type { _SERVICE } from "../../contractsTypes/icp/bridge/bridge.types"; import pollForLockEvents from "../poller"; import { raise } from "../ton"; import type { THandler } from "../types"; @@ -28,12 +30,19 @@ export function icpHandler({ serverLinkHandler, logger, identity, + staking, + validatorAddress, }: ICPHandlerParams): THandler { - const bc = createActor(bridge, { - agentOptions: { - identity, + const bc = Actor.createActorWithExtendedDetails<_SERVICE>( + BridgeIDL, + { + canisterId: bridge, + agent, }, - }); + { + certificate: false, + }, + ) as ActorSubclass<_SERVICE>; const lc = LedgerCanister.create({ agent, canisterId: Principal.fromText("ryjl3-tyaaa-aaaaa-aaaba-cai"), @@ -66,7 +75,15 @@ export function icpHandler({ selfIsValidator: () => selfIsValidator(bc, identity), listenForLockEvents: (cb, iter) => listenForLockEvents(cb, iter, lastBlock_, bc, em, logger), - addSelfAsValidator: () => addSelfAsValidator(storage, bc, identity, logger), + addSelfAsValidator: () => + addSelfAsValidator( + storage, + bc, + identity, + logger, + staking, + validatorAddress, + ), getBalance: () => getBalance(lc, identity), nftData: (tid, ctr) => nftData(tid, ctr, agent, logger), decimals: BigInt(10 ** decimals), diff --git a/src/handler/icp/types/index.ts b/src/handler/icp/types/index.ts index 9482df8..9dd450c 100644 --- a/src/handler/icp/types/index.ts +++ b/src/handler/icp/types/index.ts @@ -3,7 +3,7 @@ import type { Ed25519KeyIdentity } from "@dfinity/identity"; import type { EntityManager } from "@mikro-orm/sqlite"; import type { AxiosInstance } from "axios"; import type { TSupportedChainTypes, TSupportedChains } from "../../../config"; -import type { BridgeStorage } from "../../../contractsTypes/evm"; +import type { BridgeStorage, ERC20Staking } from "../../../contractsTypes/evm"; import type { LogInstance } from "../../types"; export type ICPHandlerParams = { @@ -19,4 +19,6 @@ export type ICPHandlerParams = { chainIdent: TSupportedChains; serverLinkHandler: AxiosInstance | undefined; logger: LogInstance; + staking: ERC20Staking; + validatorAddress: string; }; diff --git a/src/handler/icp/utils/addSelfAsValidator.ts b/src/handler/icp/utils/addSelfAsValidator.ts index a3380ca..02d7729 100644 --- a/src/handler/icp/utils/addSelfAsValidator.ts +++ b/src/handler/icp/utils/addSelfAsValidator.ts @@ -1,7 +1,7 @@ import type { ActorSubclass } from "@dfinity/agent"; import type { Ed25519KeyIdentity } from "@dfinity/identity"; -import type { BridgeStorage } from "../../../contractsTypes/evm"; -import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.did"; +import type { BridgeStorage, ERC20Staking } from "../../../contractsTypes/evm"; +import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.types"; import type { LogInstance } from "../../types"; import { ProcessDelayMilliseconds, @@ -14,7 +14,24 @@ export default async function addSelfAsValidator( bridge: ActorSubclass<_SERVICE>, identity: Ed25519KeyIdentity, logger: LogInstance, + staking: ERC20Staking, + validatorAddress: string, ): Promise<"success" | "failure"> { + const stakedAmt = await staking.stakingBalances(validatorAddress); + if (stakedAmt > 0n) { + const add = await staking.addNewChains([ + { + chainType: "icp", + validatorAddress: `${identity.getPrincipal()},${Buffer.from( + identity.getPublicKey().toRaw(), + ).toString("hex")}`, + }, + ]); + const receipt = await add.wait(); + logger.info( + `Added self as new chain at hash: ${receipt?.hash}. BN: ${receipt?.blockNumber}`, + ); + } const publicKey = Buffer.from(identity.getPublicKey().toRaw()).toString( "hex", ); diff --git a/src/handler/icp/utils/listenForLockEvents.ts b/src/handler/icp/utils/listenForLockEvents.ts index d7d8286..fa1e6ea 100644 --- a/src/handler/icp/utils/listenForLockEvents.ts +++ b/src/handler/icp/utils/listenForLockEvents.ts @@ -1,7 +1,8 @@ +import { setTimeout } from "node:timers/promises"; import { Actor, type ActorSubclass } from "@dfinity/agent"; import type { EntityManager } from "@mikro-orm/sqlite"; import type { EventBuilder } from "../.."; -import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.did"; +import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.types"; import { Block } from "../../../persistence/entities/block"; import type { LockEventIter, LogInstance } from "../../types"; @@ -24,6 +25,7 @@ export default async function listenForLockEvents( if (latestBlockNumber <= lastBlock) { logger.trace(`0 TXs after nonce ${lastBlock}. Awaiting 10s`); + await setTimeout(10000); continue; } const newTxNonce = lastBlock + 1; @@ -31,7 +33,7 @@ export default async function listenForLockEvents( if (!hash) continue; const [log] = await bc.get_locked_data(hash); if (!log) continue; - lastBlock = latestBlockNumber; + lastBlock = newTxNonce; const { destination_chain, destination_user_address, @@ -63,6 +65,6 @@ export default async function listenForLockEvents( await em.flush(); } catch (e) { logger.error(`${e} while listening for events. Sleeping for 10 seconds`); - await new Promise((resolve) => setTimeout(resolve, 10000)); + await setTimeout(10000); } } diff --git a/src/handler/icp/utils/selfIsValidator.ts b/src/handler/icp/utils/selfIsValidator.ts index bd47bda..d885615 100644 --- a/src/handler/icp/utils/selfIsValidator.ts +++ b/src/handler/icp/utils/selfIsValidator.ts @@ -1,6 +1,6 @@ import type { ActorSubclass } from "@dfinity/agent"; import type { Ed25519KeyIdentity } from "@dfinity/identity"; -import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.did"; +import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.types"; export default async function selfIsValidator( client: ActorSubclass<_SERVICE>, diff --git a/src/handler/icp/utils/signClaimData.ts b/src/handler/icp/utils/signClaimData.ts index 76ff20b..633c380 100644 --- a/src/handler/icp/utils/signClaimData.ts +++ b/src/handler/icp/utils/signClaimData.ts @@ -2,7 +2,7 @@ import type { ActorSubclass } from "@dfinity/agent"; import type { Ed25519KeyIdentity } from "@dfinity/identity"; import { Principal } from "@dfinity/principal"; import * as ed from "@noble/ed25519"; -import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.did"; +import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.types"; import type { TNftTransferDetailsObject } from "../../types"; export default async function signClaimData( diff --git a/src/handler/icp/utils/signData.ts b/src/handler/icp/utils/signData.ts index 9e817e2..fedde40 100644 --- a/src/handler/icp/utils/signData.ts +++ b/src/handler/icp/utils/signData.ts @@ -2,7 +2,7 @@ import type { ActorSubclass } from "@dfinity/agent"; import type { Ed25519KeyIdentity } from "@dfinity/identity"; import { Principal } from "@dfinity/principal"; import * as ed from "@noble/ed25519"; -import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.did"; +import type { _SERVICE } from "../../../contractsTypes/icp/bridge/bridge.types"; export default async function signData( buf: string, diff --git a/src/types/index.ts b/src/types/index.ts index a0ffcc8..f3f89e0 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -138,6 +138,11 @@ type ICosmWasmChainConfig = { walletPrefix: string; } & IChainConfig; +export type IICPChainConfig = { + chainType: "icp"; + rpcURL: string; +} & IChainConfig; + type TChain = | IMultiversXChainConfig | IEvmChainConfig @@ -145,7 +150,8 @@ type TChain = | ISecretChainConfig | ITezosChainConfig | IHederaChainConfig - | ICosmWasmChainConfig; + | ICosmWasmChainConfig + | IICPChainConfig; type IBridgeConfig = { bridgeChains: TChain[];