@aryze/reforge-sdk
Version:
SDK for interacting with reForge from ARYZE.
252 lines (241 loc) • 24.4 kB
JavaScript
import { ethers } from 'ethers';
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
var ABI = [{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:false,inputs:[{indexed:false,internalType:"address",name:"previousAdmin",type:"address"},{indexed:false,internalType:"address",name:"newAdmin",type:"address"}],name:"AdminChanged",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"owner",type:"address"},{indexed:true,internalType:"address",name:"spender",type:"address"},{indexed:false,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"beacon",type:"address"}],name:"BeaconUpgraded",type:"event"},{anonymous:false,inputs:[{indexed:false,internalType:"address",name:"account",type:"address"}],name:"BridgePaused",type:"event"},{anonymous:false,inputs:[{indexed:false,internalType:"address",name:"account",type:"address"}],name:"BridgeUnpaused",type:"event"},{anonymous:false,inputs:[{indexed:false,internalType:"uint8",name:"version",type:"uint8"}],name:"Initialized",type:"event"},{anonymous:false,inputs:[{indexed:false,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"account",type:"address"},{indexed:false,internalType:"uint256",name:"amount",type:"uint256"},{indexed:true,internalType:"string",name:"transaction",type:"string"}],name:"Reforged",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:true,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:true,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:true,internalType:"address",name:"account",type:"address"},{indexed:true,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:true,internalType:"address",name:"account",type:"address"},{indexed:true,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"account",type:"address"},{indexed:false,internalType:"uint256",name:"amount",type:"uint256"},{indexed:false,internalType:"uint256",name:"fromChainId",type:"uint256"},{indexed:true,internalType:"uint256",name:"destinationChainId",type:"uint256"},{indexed:true,internalType:"address",name:"destinationToken",type:"address"}],name:"SentToChain",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"from",type:"address"},{indexed:true,internalType:"address",name:"to",type:"address"},{indexed:false,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:false,inputs:[{indexed:false,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{anonymous:false,inputs:[{indexed:false,internalType:"address",name:"account",type:"address"}],name:"Unwhitelisted",type:"event"},{anonymous:false,inputs:[{indexed:true,internalType:"address",name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{anonymous:false,inputs:[{indexed:false,internalType:"address",name:"acoount",type:"address"}],name:"Whitelisted",type:"event"},{inputs:[],name:"ADMIN_eEUR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"BRIDGE_OWNER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"MINTER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PAUSER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"UPGRADER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"token",type:"address"}],name:"addSameToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"addToWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"bridgeFee",outputs:[{internalType:"uint256",name:"",type:"uint256"},{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"bridgePause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"bridgePaused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"bridgeUnpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"burnFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"subtractedValue",type:"uint256"}],name:"decreaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"feeTreasury",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"addedValue",type:"uint256"}],name:"increaseAllowance",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"isWhitelisted",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"minimumFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"minimumSentToChainAmount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"fee",type:"uint256"},{internalType:"string",name:"rate",type:"string"},{internalType:"uint256",name:"sourceChainId",type:"uint256"},{internalType:"string",name:"transaction",type:"string"}],name:"reforge",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"removeFromWhitelist",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"chainId",type:"uint256"}],name:"removeSameToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"chainId",type:"uint256"}],name:"sameToken",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"destinationChainId",type:"uint256"},{internalType:"address",name:"destinationToken",type:"address"}],name:"sendToChain",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"percent",type:"uint256"}],name:"setBridgeFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address payable",name:"account",type:"address"}],name:"setBridgeOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"setFeeTreasury",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"setMinimumFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"setMinimumSentToChainAmount",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"}],name:"upgradeTo",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newImplementation",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"}];
var BRIDGE_SUPPORTED_CHAINS_HEX;
(function (BRIDGE_SUPPORTED_CHAINS_HEX) {
BRIDGE_SUPPORTED_CHAINS_HEX["BINANCE"] = "0x38";
BRIDGE_SUPPORTED_CHAINS_HEX["MAINNET"] = "0x1";
BRIDGE_SUPPORTED_CHAINS_HEX["POLYGON"] = "0x89";
})(BRIDGE_SUPPORTED_CHAINS_HEX || (BRIDGE_SUPPORTED_CHAINS_HEX = {}));
var BRIDGE_SUPPORTED_CHAINS_TEST_HEX;
(function (BRIDGE_SUPPORTED_CHAINS_TEST_HEX) {
BRIDGE_SUPPORTED_CHAINS_TEST_HEX["BINANCE_TESTNET"] = "0x61";
BRIDGE_SUPPORTED_CHAINS_TEST_HEX["GOERLI"] = "0x5";
BRIDGE_SUPPORTED_CHAINS_TEST_HEX["MUMBAI"] = "0x13881";
})(BRIDGE_SUPPORTED_CHAINS_TEST_HEX || (BRIDGE_SUPPORTED_CHAINS_TEST_HEX = {}));
Object.values(BRIDGE_SUPPORTED_CHAINS_HEX).filter((e) => e.includes('0x'));
Object.values(BRIDGE_SUPPORTED_CHAINS_TEST_HEX).filter((e) => e.includes('0x'));
///
/// ADDRESSES SHOULD BE lowercase !!!
///
const eEUR = {
[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]: '0x735fa792e731a2e8f83f32eb539841b7b72e6d8f',
[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]: '0x735fa792e731a2e8f83f32eb539841b7b72e6d8f',
[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]: '0x735fa792e731a2e8f83f32eb539841b7b72e6d8f',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]: '0xc61e8563d354c4870d3526361d8531d79cd5dfe3',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI]: '0x3fa9effea5dfbf68d5db48fae322fe892d3750ff',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI]: '0x3c6af76181891a6f0f438d4d0fc1474f0e8ca9a0'
};
/// ADDRESSES SHOULD BE lowercase !!!
const eUSD = {
[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]: '0xa4335da338ec4c07c391fc1a9bf75f306adadc08',
[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]: '0xa4335da338ec4c07c391fc1a9bf75f306adadc08',
[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]: '0xa4335da338ec4c07c391fc1a9bf75f306adadc08',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]: '0x035ddaee2b88c2842f94dafd77ea83bf79c7d348',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI]: '0x4a631e9117133c5f87fd9c051fe67e4f90575fab',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI]: '0xab77d4eb4f6e7ac52dea9a859a36901564c6d02c'
};
/// ADDRESSES SHOULD BE lowercase !!!
const eGBP = {
[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]: '0xd711d7d893de57dc13ff465763218770bd42db1d',
[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]: '0xd711d7d893de57dc13ff465763218770bd42db1d',
[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]: '0xd711d7d893de57dc13ff465763218770bd42db1d',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]: '0xcb10c030865c4778b7f3304b91e0f3ce6c95b19f',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI]: '0x4f64b762ce2b76e77595c502e028a6eb570ddb2a',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI]: '0x259a8e32765925efaabde188754bea0389469083'
};
/// ADDRESSES SHOULD BE lowercase !!!
const eSGD = {
[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]: '0x58a849e1f3c7044bb317db4611269c352c53d399',
[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]: '0x58a849e1f3c7044bb317db4611269c352c53d399',
[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]: '0x58a849e1f3c7044bb317db4611269c352c53d399',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]: '',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI]: '',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI]: ''
};
/// ADDRESSES SHOULD BE lowercase !!!
const RYZE = {
[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]: '0x640bb7b0716a3c58b29f83a10e0b4b51580693d3',
[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]: '0x640bb7b0716a3c58b29f83a10e0b4b51580693d3',
[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]: '0xfe58138156dee3eaef5e6d113210dbf460b61df1',
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]: '0x5e5c7fefb51332defc6bd895f7395278e5991fe6'
};
/// ADDRESSES SHOULD BE lowercase !!!
const SUPPORTED_TOKEN_IDS = {
[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]: {
RYZE: RYZE[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eSGD: eSGD[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]
},
[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]: {
RYZE: RYZE[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eSGD: eSGD[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]
},
[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]: {
RYZE: RYZE[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eSGD: eSGD[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]
},
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]: {
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]
},
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI]: {
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI]
},
[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI]: {
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI]
}
};
const SUPPORTED_TOKEN_NAMES = {
BINANCE: {
RYZE: RYZE[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE],
eSGD: eSGD[BRIDGE_SUPPORTED_CHAINS_HEX.BINANCE]
},
MAINNET: {
RYZE: RYZE[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET],
eSGD: eSGD[BRIDGE_SUPPORTED_CHAINS_HEX.MAINNET]
},
POLYGON: {
RYZE: RYZE[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON],
eSGD: eSGD[BRIDGE_SUPPORTED_CHAINS_HEX.POLYGON]
},
BINANCE_TESTNET: {
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.BINANCE_TESTNET]
},
GOERLI: {
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.GOERLI]
},
MUMBAI: {
eEUR: eEUR[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI],
eUSD: eUSD[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI],
eGBP: eGBP[BRIDGE_SUPPORTED_CHAINS_TEST_HEX.MUMBAI]
}
};
const prepareReforge = (sourceAmount, sourceToken, destinationToken, destinationChainId, sourceRpcUrl) => {
try {
const provider = new ethers.JsonRpcProvider(sourceRpcUrl);
const contract = new ethers.Contract(sourceToken, ABI, provider);
const parsedAmount = ethers.parseEther(sourceAmount);
const txRequest = contract.interface.encodeFunctionData('sendToChain', [
parsedAmount,
destinationChainId,
destinationToken
]);
return { status: true, tx: txRequest };
}
catch (error) {
console.error('Failed to encode transaction data:', error);
return { status: false, error: error.message || 'An unknown error occurred' };
}
};
const executeReforgeAsync = (request) => __awaiter(void 0, void 0, void 0, function* () {
try {
let wallet = request.walletData.signer;
if (!request.walletData.signer && request.walletData.rpcUrl != '' && request.walletData.privateKey != '') {
const provider = new ethers.JsonRpcProvider(request.walletData.rpcUrl);
try {
yield provider._detectNetwork();
}
catch (err) {
console.log(err);
throw new Error('Wallet data incorrect! Please provide correct RPC and PRIVATE KEY!');
}
wallet = new ethers.Wallet(request.walletData.privateKey || '', provider);
}
if (!wallet) {
throw new Error('Wallet data incorrect! Provide signer or RPC with PRIVATE KEY!');
}
const txResponse = yield wallet.sendTransaction(request);
console.log(`Transaction hash: ${txResponse.hash}`);
// Wait for the transaction to be mined
const receipt = yield txResponse.wait();
console.log(`Transaction confirmed in block ${receipt === null || receipt === void 0 ? void 0 : receipt.blockNumber}`);
return { status: true, reciept: receipt };
}
catch (error) {
console.error(`Error sending transaction: ${error.message}`);
return { status: false, error: error.message };
}
});
const executeReforge = (request) => __awaiter(void 0, void 0, void 0, function* () {
try {
let wallet = request.walletData.signer;
if (!request.walletData.signer && request.walletData.rpcUrl != '' && request.walletData.privateKey != '') {
const provider = new ethers.JsonRpcProvider(request.walletData.rpcUrl);
try {
yield provider._detectNetwork();
}
catch (err) {
console.log(err);
throw new Error('Wallet data incorrect! Please provide correct RPC and PRIVATE KEY!');
}
wallet = new ethers.Wallet(request.walletData.privateKey || '', provider);
}
if (!wallet) {
throw new Error('Wallet data incorrect! Provide signer or RPC with PRIVATE KEY!');
}
const txResponse = yield wallet.sendTransaction(request);
console.log(`Transaction hash: ${txResponse.hash}`);
return { status: true, tx: txResponse };
}
catch (error) {
console.error(`Error sending transaction: ${error.message}`);
return { status: false, error: error.message };
}
});
const SUPPORTED_CHAINS = BRIDGE_SUPPORTED_CHAINS_HEX;
const SUPPORTED_TEST_CHAINS = BRIDGE_SUPPORTED_CHAINS_TEST_HEX;
const TOKEN_IDS = SUPPORTED_TOKEN_IDS;
const TOKEN_NAMES = SUPPORTED_TOKEN_NAMES;
export { SUPPORTED_CHAINS, SUPPORTED_TEST_CHAINS, TOKEN_IDS, TOKEN_NAMES, executeReforge, executeReforgeAsync, prepareReforge };