@ixily/activ
Version:
Alpha Capture Trade Idea Verification. Blockchain ownership proven trade ideas and strategies.
33 lines • 1.29 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeSureChainMatches = exports.makeSureChainMatchesContract = exports.CHAIN_IDS = void 0;
const web3_1 = __importDefault(require("web3"));
const __1 = require("../../");
const CHAIN_IDS = (index) => {
return __1.CHAIN_IDS_OPTS[index];
};
exports.CHAIN_IDS = CHAIN_IDS;
const makeSureChainMatchesContract = async (contract) => {
return (0, exports.makeSureChainMatches)(contract.recipe.chain);
};
exports.makeSureChainMatchesContract = makeSureChainMatchesContract;
const makeSureChainMatches = async (chain) => {
const chainId = (0, exports.CHAIN_IDS)(chain);
try {
if (typeof window !== 'undefined') {
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: web3_1.default.utils.toHex(chainId) }],
});
}
}
catch (err) {
console.error(err);
throw new Error('Contract Tool Error: Could not switch to chain ' + chainId);
}
};
exports.makeSureChainMatches = makeSureChainMatches;
//# sourceMappingURL=contract.tool.js.map