UNPKG

barterjs-sdk

Version:
38 lines (37 loc) 2.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createMCSInstance = void 0; const chains_1 = require("../../constants/chains"); const RelayCrossChainService_1 = require("../mcs/RelayCrossChainService"); const addresses_1 = require("../../constants/addresses"); const MAPCrossChainService_json_1 = __importDefault(require("../../abis/MAPCrossChainService.json")); const MAPCrossChainServiceRelay_json_1 = __importDefault(require("../../abis/MAPCrossChainServiceRelay.json")); const EVMCrossChainService_1 = require("../mcs/EVMCrossChainService"); const NearCrossChainService_1 = require("../mcs/NearCrossChainService"); function createMCSInstance(chainId, options) { switch (chainId) { case chains_1.ChainId.MAP: case chains_1.ChainId.MAP_TEST: if (options.signerOrProvider == undefined) { throw new Error('signer is not provided for MAP chain'); } return new RelayCrossChainService_1.RelayCrossChainService(addresses_1.MCS_CONTRACT_ADDRESS_SET[(0, chains_1.ID_TO_CHAIN_ID)(chainId)], MAPCrossChainServiceRelay_json_1.default.abi, options.signerOrProvider); case chains_1.ChainId.ETH_PRIV: case chains_1.ChainId.BSC_TEST: if (options.signerOrProvider == undefined) { throw new Error(`signer is not provided for chain: ${chainId}`); } return new EVMCrossChainService_1.EVMCrossChainService(addresses_1.MCS_CONTRACT_ADDRESS_SET[(0, chains_1.ID_TO_CHAIN_ID)(chainId)], MAPCrossChainService_json_1.default.abi, options.signerOrProvider); case chains_1.ChainId.NEAR_TESTNET: if (options.nearProvider == undefined) { throw new Error('near config is not provided'); } return new NearCrossChainService_1.NearCrossChainService(options.nearProvider); default: throw new Error(`chainId: ${chainId} is not supported yet`); } } exports.createMCSInstance = createMCSInstance;