UNPKG

butterjs-sdk

Version:
37 lines (36 loc) 2.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createMOSInstance = void 0; const chains_1 = require("../../constants/chains"); const RelayOmnichainService_1 = require("../mos/RelayOmnichainService"); const addresses_1 = require("../../constants/addresses"); const MAPOmnichainService_json_1 = __importDefault(require("../../abis/MAPOmnichainService.json")); const MAPOmnichainServiceRelay_json_1 = __importDefault(require("../../abis/MAPOmnichainServiceRelay.json")); const EVMOmnichainService_1 = require("../mos/EVMOmnichainService"); const NearOmnichainService_1 = require("../mos/NearOmnichainService"); function createMOSInstance(chainId, options) { if ((0, chains_1.IS_MAP)(chainId)) { if (options.signerOrProvider == undefined) { throw new Error('signer is not provided for MAP chain'); } return new RelayOmnichainService_1.RelayOmnichainService(addresses_1.MOS_CONTRACT_ADDRESS_SET[(0, chains_1.ID_TO_CHAIN_ID)(chainId)], MAPOmnichainServiceRelay_json_1.default.abi, options.signerOrProvider); } else if ((0, chains_1.IS_EVM)(chainId)) { if (options.signerOrProvider == undefined) { throw new Error(`signer is not provided for chain: ${chainId}`); } return new EVMOmnichainService_1.EVMOmnichainService(addresses_1.MOS_CONTRACT_ADDRESS_SET[(0, chains_1.ID_TO_CHAIN_ID)(chainId)], MAPOmnichainService_json_1.default.abi, options.signerOrProvider); } else if ((0, chains_1.IS_NEAR)(chainId)) { if (options.nearProvider == undefined) { throw new Error('near config is not provided'); } return new NearOmnichainService_1.NearOmnichainService(options.nearProvider); } else throw new Error(`chainId: ${chainId} is not supported yet`); } exports.createMOSInstance = createMOSInstance;