UNPKG

@tokamak-network/thanos-sdk

Version:
60 lines 2.56 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.USDCBridgeAdapter = void 0; const core_utils_1 = require("@tokamak-network/core-utils"); const ethers_1 = require("ethers"); const L1UsdcBridge_json_1 = __importDefault(require("@tokamak-network/thanos-contracts/forge-artifacts/L1UsdcBridge.sol/L1UsdcBridge.json")); const L2UsdcBridge_json_1 = __importDefault(require("@tokamak-network/thanos-contracts/forge-artifacts/L2UsdcBridge.sol/L2UsdcBridge.json")); const utils_1 = require("../utils"); const standard_bridge_1 = require("./standard-bridge"); class USDCBridgeAdapter extends standard_bridge_1.StandardBridgeAdapter { constructor(opts) { super(opts); this.l1Bridge = new ethers_1.Contract((0, utils_1.toAddress)(opts.l1Bridge), L1UsdcBridge_json_1.default.abi, this.messenger.l1Provider); this.l2Bridge = new ethers_1.Contract((0, utils_1.toAddress)(opts.l2Bridge), L2UsdcBridge_json_1.default.abi, this.messenger.l2Provider); } async supportsTokenPair(l1Token, l2Token) { const l1Bridge = new ethers_1.Contract(this.l1Bridge.address, [ { inputs: [], name: 'l1Usdc', outputs: [ { internalType: 'address', name: '', type: 'address', }, ], stateMutability: 'view', type: 'function', }, { inputs: [], name: 'l2Usdc', outputs: [ { internalType: 'address', name: '', type: 'address', }, ], stateMutability: 'view', type: 'function', }, ], this.messenger.l1Provider); const allowedL1Token = await l1Bridge.l1Usdc(); if (!(0, core_utils_1.hexStringEquals)(allowedL1Token, (0, utils_1.toAddress)(l1Token))) { return false; } const allowedL2Token = await l1Bridge.l2Usdc(); if (!(0, core_utils_1.hexStringEquals)(allowedL2Token, (0, utils_1.toAddress)(l2Token))) { return false; } return true; } } exports.USDCBridgeAdapter = USDCBridgeAdapter; //# sourceMappingURL=usdc-bridge.js.map