relayer: support celo and klaytn
This commit is contained in:
parent
8f9cbb98fc
commit
5b09707f70
|
@ -1348,6 +1348,8 @@ export const RELAYER_COMPARE_ASSET: RelayerCompareAsset = {
|
|||
[CHAIN_ID_OASIS]: "oasis-network",
|
||||
[CHAIN_ID_FANTOM]: "fantom",
|
||||
[CHAIN_ID_AURORA]: "ethereum", // Aurora uses bridged ether
|
||||
[CHAIN_ID_KLAYTN]: "klay-token",
|
||||
[CHAIN_ID_CELO]: "celo",
|
||||
} as RelayerCompareAsset;
|
||||
export const getCoinGeckoURL = (coinGeckoId: string) =>
|
||||
`https://api.coingecko.com/api/v3/simple/price?ids=${coinGeckoId}&vs_currencies=usd`;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,8 @@
|
|||
"typescript": "^4.3.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certusone/wormhole-sdk": "^0.2.3",
|
||||
"@celo-tools/celo-ethers-wrapper": "^0.1.0",
|
||||
"@certusone/wormhole-sdk": "^0.3.3",
|
||||
"@certusone/wormhole-spydk": "^0.0.1",
|
||||
"@solana/spl-token": "^0.1.8",
|
||||
"@solana/web3.js": "^1.24.0",
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
import {
|
||||
Bridge__factory,
|
||||
CHAIN_ID_CELO,
|
||||
CHAIN_ID_KLAYTN,
|
||||
CHAIN_ID_POLYGON,
|
||||
getIsTransferCompletedEth,
|
||||
hexToUint8Array,
|
||||
redeemOnEth,
|
||||
redeemOnEthNative,
|
||||
} from "@certusone/wormhole-sdk";
|
||||
import { Signer } from "@ethersproject/abstract-signer";
|
||||
import { ethers } from "ethers";
|
||||
import { ChainConfigInfo } from "../configureEnv";
|
||||
import { getScopedLogger, ScopedLogger } from "../helpers/logHelper";
|
||||
import { PromHelper } from "../helpers/promHelpers";
|
||||
import { CeloProvider, CeloWallet } from "@celo-tools/celo-ethers-wrapper";
|
||||
|
||||
export function newProvider(
|
||||
url: string,
|
||||
|
@ -41,8 +43,16 @@ export async function relayEVM(
|
|||
relayLogger
|
||||
);
|
||||
const signedVaaArray = hexToUint8Array(signedVAA);
|
||||
let provider = newProvider(chainConfigInfo.nodeUrl);
|
||||
const signer: Signer = new ethers.Wallet(walletPrivateKey, provider);
|
||||
let provider = undefined;
|
||||
let signer = undefined;
|
||||
if (chainConfigInfo.chainId === CHAIN_ID_CELO) {
|
||||
provider = new CeloProvider(chainConfigInfo.nodeUrl);
|
||||
await provider.ready;
|
||||
signer = new CeloWallet(walletPrivateKey, provider);
|
||||
} else {
|
||||
provider = newProvider(chainConfigInfo.nodeUrl);
|
||||
signer = new ethers.Wallet(walletPrivateKey, provider);
|
||||
}
|
||||
|
||||
logger.debug("Checking to see if vaa has already been redeemed.");
|
||||
const alreadyRedeemed = await getIsTransferCompletedEth(
|
||||
|
@ -69,14 +79,17 @@ export async function relayEVM(
|
|||
}
|
||||
|
||||
logger.debug("Redeeming.");
|
||||
// look, there's something janky with Polygon + ethers + EIP-1559
|
||||
let overrides = {};
|
||||
if (chainConfigInfo.chainId === CHAIN_ID_POLYGON) {
|
||||
// look, there's something janky with Polygon + ethers + EIP-1559
|
||||
let feeData = await provider.getFeeData();
|
||||
overrides = {
|
||||
maxFeePerGas: feeData.maxFeePerGas?.mul(50) || undefined,
|
||||
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas?.mul(50) || undefined,
|
||||
};
|
||||
} else if (chainConfigInfo.chainId === CHAIN_ID_KLAYTN) {
|
||||
// Klaytn requires specifying gasPrice
|
||||
overrides = { gasPrice: (await signer.getGasPrice()).toString() };
|
||||
}
|
||||
const bridge = Bridge__factory.connect(
|
||||
chainConfigInfo.tokenBridgeAddress,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { ChainId } from "@certusone/wormhole-sdk";
|
||||
|
||||
export const chainIDStrings: { [key in ChainId]: string } = {
|
||||
0: "Unset",
|
||||
1: "Solana",
|
||||
2: "Ethereum",
|
||||
3: "Terra",
|
||||
|
@ -13,5 +14,9 @@ export const chainIDStrings: { [key in ChainId]: string } = {
|
|||
10: "Fantom",
|
||||
11: "Karura",
|
||||
12: "Acala",
|
||||
13: "Klaytn",
|
||||
14: "Celo",
|
||||
15: "NEAR",
|
||||
16: "Moonbeam",
|
||||
10001: "Ropsten",
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue