karura and acala testnet support

This commit is contained in:
Evan Gray 2022-03-02 20:11:00 +00:00 committed by Evan Gray
parent 7f8a92f416
commit 7d64e40b93
8 changed files with 353 additions and 29 deletions

View File

@ -8,7 +8,7 @@
"name": "test_ui",
"version": "0.1.0",
"dependencies": {
"@certusone/wormhole-sdk": "^0.2.0",
"@certusone/wormhole-sdk": "^0.2.1",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
@ -67,15 +67,14 @@
},
"../sdk/js": {
"name": "@certusone/wormhole-sdk",
"version": "0.1.5",
"version": "0.2.1",
"extraneous": true,
"license": "Apache-2.0",
"dependencies": {
"@improbable-eng/grpc-web": "^0.14.0",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "^1.24.0",
"@terra-money/terra.js": "^2.0.14",
"@terra-money/wallet-provider": "^2.2.0",
"@terra-money/terra.js": "^3.0.7",
"axios": "^0.24.0",
"bech32": "^2.0.0",
"js-base64": "^3.6.1",
@ -97,7 +96,8 @@
"ts-jest": "^27.0.7",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.3.5"
"typescript": "^4.3.5",
"web3": "^1.6.1"
}
},
"node_modules/@apollo/client": {
@ -2006,9 +2006,9 @@
}
},
"node_modules/@certusone/wormhole-sdk": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.2.0.tgz",
"integrity": "sha512-M5DnyPbt8Wm2gSG596yH3Fw1cXulQSzJ/4b1wVeQBrZ4g2s0ztSLgSctUGTGwR4wacK5R1IeGo9jfn29KBmdwA==",
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.2.1.tgz",
"integrity": "sha512-L85tiUHwnH4nbUEDgQtS2hNm3Q0IsUP29Z/DGbN2zggdvR0KTC6nLQ+LufCM6IcdUQYpYuwXjOYKD1Et8qc0mw==",
"dependencies": {
"@improbable-eng/grpc-web": "^0.14.0",
"@solana/spl-token": "^0.1.8",
@ -2046,9 +2046,9 @@
"integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg=="
},
"node_modules/@certusone/wormhole-sdk/node_modules/rxjs": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz",
"integrity": "sha512-h5M3Hk78r6wAheJF0a5YahB1yRQKCsZ4MsGdZ5O9ETbVtjPcScGfrMmoOq7EBsCRzd4BDkvDJ7ogP8Sz5tTFiQ==",
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz",
"integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==",
"dependencies": {
"tslib": "^2.1.0"
}
@ -46140,9 +46140,9 @@
}
},
"@certusone/wormhole-sdk": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.2.0.tgz",
"integrity": "sha512-M5DnyPbt8Wm2gSG596yH3Fw1cXulQSzJ/4b1wVeQBrZ4g2s0ztSLgSctUGTGwR4wacK5R1IeGo9jfn29KBmdwA==",
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.2.1.tgz",
"integrity": "sha512-L85tiUHwnH4nbUEDgQtS2hNm3Q0IsUP29Z/DGbN2zggdvR0KTC6nLQ+LufCM6IcdUQYpYuwXjOYKD1Et8qc0mw==",
"requires": {
"@improbable-eng/grpc-web": "^0.14.0",
"@solana/spl-token": "^0.1.8",
@ -46177,9 +46177,9 @@
"integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg=="
},
"rxjs": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz",
"integrity": "sha512-h5M3Hk78r6wAheJF0a5YahB1yRQKCsZ4MsGdZ5O9ETbVtjPcScGfrMmoOq7EBsCRzd4BDkvDJ7ogP8Sz5tTFiQ==",
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz",
"integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==",
"requires": {
"tslib": "^2.1.0"
}

View File

@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@certusone/wormhole-sdk": "^0.2.0",
"@certusone/wormhole-sdk": "^0.2.1",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",

View File

@ -42,8 +42,6 @@ function Create() {
shouldUpdate || false
);
console.log("foreign asset info", foreignAssetInfo);
return (
<>
<KeyAndBalance chainId={targetChain} />

View File

@ -1,16 +1,19 @@
import {
ChainId,
CHAIN_ID_ACALA,
CHAIN_ID_KARURA,
CHAIN_ID_SOLANA,
CHAIN_ID_TERRA,
createWrappedOnEth,
createWrappedOnSolana,
createWrappedOnTerra,
updateWrappedOnEth,
updateWrappedOnTerra,
updateWrappedOnSolana,
postVaaSolanaWithRetry,
isEVMChain,
postVaaSolanaWithRetry,
updateWrappedOnEth,
updateWrappedOnSolana,
updateWrappedOnTerra,
} from "@certusone/wormhole-sdk";
import { Alert } from "@material-ui/lab";
import { WalletContextState } from "@solana/wallet-adapter-react";
import { Connection } from "@solana/web3.js";
import {
@ -23,7 +26,6 @@ import { useCallback, useMemo } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useEthereumProvider } from "../contexts/EthereumProviderContext";
import { useSolanaWallet } from "../contexts/SolanaWalletContext";
import useAttestSignedVAA from "./useAttestSignedVAA";
import { setCreateTx, setIsCreating } from "../store/attestSlice";
import {
selectAttestIsCreating,
@ -31,17 +33,20 @@ import {
selectTerraFeeDenom,
} from "../store/selectors";
import {
ACALA_HOST,
getTokenBridgeAddressForChain,
KARURA_HOST,
MAX_VAA_UPLOAD_RETRIES_SOLANA,
SOLANA_HOST,
SOL_BRIDGE_ADDRESS,
SOL_TOKEN_BRIDGE_ADDRESS,
TERRA_TOKEN_BRIDGE_ADDRESS,
} from "../utils/consts";
import { getKaruraGasParams } from "../utils/karura";
import parseError from "../utils/parseError";
import { signSendAndConfirm } from "../utils/solana";
import { Alert } from "@material-ui/lab";
import { postWithFees } from "../utils/terra";
import useAttestSignedVAA from "./useAttestSignedVAA";
async function evm(
dispatch: any,
@ -53,16 +58,25 @@ async function evm(
) {
dispatch(setIsCreating(true));
try {
// Karura and Acala need gas params for contract deploys
const overrides =
chainId === CHAIN_ID_KARURA
? await getKaruraGasParams(KARURA_HOST)
: chainId === CHAIN_ID_ACALA
? await getKaruraGasParams(ACALA_HOST)
: {};
const receipt = shouldUpdate
? await updateWrappedOnEth(
getTokenBridgeAddressForChain(chainId),
signer,
signedVAA
signedVAA,
overrides
)
: await createWrappedOnEth(
getTokenBridgeAddressForChain(chainId),
signer,
signedVAA
signedVAA,
overrides
);
dispatch(
setCreateTx({ id: receipt.transactionHash, block: receipt.blockNumber })

View File

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 490 490"
fill="none"
version="1.1"
id="svg65"
sodipodi:docname="acala.svg"
width="490"
height="490"
inkscape:version="1.1.1 (c3084ef, 2021-09-22)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview67"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="0.89506656"
inkscape:cx="638.5"
inkscape:cy="245.23316"
inkscape:window-width="2560"
inkscape:window-height="1387"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="1"
inkscape:current-layer="svg65" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M 245,490 C 380.31,490 490,380.31 490,245 490,109.69 380.31,0 245,0 109.69,0 0,109.69 0,245 0,380.31 109.69,490 245,490 Z m 1,-23 C 368.607,467 468,367.607 468,245 468,122.393 368.607,23 246,23 123.393,23 24,122.393 24,245 c 0,122.607 99.393,222 222,222 z m -1,-17 C 358.218,450 450,358.218 450,245 450,131.782 358.218,40 245,40 131.782,40 40,131.782 40,245 c 0,113.218 91.782,205 205,205 z m 0.5,-25 C 345.187,425 426,344.187 426,244.5 426,144.813 345.187,64 245.5,64 145.813,64 65,144.813 65,244.5 65,344.187 145.813,425 245.5,425 Z M 235.313,98.664 365.988,325.36 380,301.05 263.338,98.664 Z M 110,300.641 221.842,106.615 l 0.231,0.4 0.22,-0.382 132.54,229.932 h -28.025 l -33.484,-58.088 c -15.215,-4.81 -31.414,-7.404 -48.22,-7.404 -8.663,0 -17.117,0.605 -25.336,1.812 l 16.14,-27.956 c 3.047,-0.149 6.113,-0.224 9.196,-0.224 10.267,0 20.339,0.831 30.154,2.43 l -53.195,-92.284 -98.05,170.099 z m 76.035,-2.949 50.256,-87.186 -14.012,-24.309 -86.676,150.367 h 28.025 l 0.266,-0.462 c 24.037,-14.472 51.619,-21.787 81.737,-21.787 19.232,0 37.67,3.397 54.747,9.625 l -18.775,-32.52 a 187.142,187.142 0 0 0 -35.972,-3.472 c -20.842,0 -40.885,3.425 -59.596,9.744 z"
fill="url(#Acala_new_logo_svg__paint0_linear)"
id="path9"
style="fill:url(#Acala_new_logo_svg__paint0_linear)" />
<defs
id="defs63">
<linearGradient
id="Acala_new_logo_svg__paint0_linear"
x1="462.5"
y1="490"
x2="101"
y2="43.5"
gradientUnits="userSpaceOnUse">
<stop
stop-color="#5A81FF"
id="stop21" />
<stop
offset="0.524"
stop-color="#E40C5B"
id="stop23" />
<stop
offset="1"
stop-color="#FF4C3B"
id="stop25" />
</linearGradient>
<linearGradient
id="Acala_new_logo_svg__paint1_linear"
x1="1285.41"
y1="352.18399"
x2="1228.36"
y2="60.854"
gradientUnits="userSpaceOnUse">
<stop
offset="0.024"
stop-color="#645AFF"
id="stop28" />
<stop
offset="0.484"
stop-color="#E40C5B"
id="stop30" />
<stop
offset="1"
stop-color="#FF4C3B"
id="stop32" />
</linearGradient>
<linearGradient
id="Acala_new_logo_svg__paint2_linear"
x1="1285.41"
y1="352.18399"
x2="1228.36"
y2="60.854"
gradientUnits="userSpaceOnUse">
<stop
offset="0.024"
stop-color="#645AFF"
id="stop35" />
<stop
offset="0.484"
stop-color="#E40C5B"
id="stop37" />
<stop
offset="1"
stop-color="#FF4C3B"
id="stop39" />
</linearGradient>
<linearGradient
id="Acala_new_logo_svg__paint3_linear"
x1="1285.41"
y1="352.18399"
x2="1228.36"
y2="60.854"
gradientUnits="userSpaceOnUse">
<stop
offset="0.024"
stop-color="#645AFF"
id="stop42" />
<stop
offset="0.484"
stop-color="#E40C5B"
id="stop44" />
<stop
offset="1"
stop-color="#FF4C3B"
id="stop46" />
</linearGradient>
<linearGradient
id="Acala_new_logo_svg__paint4_linear"
x1="1285.41"
y1="352.18399"
x2="1228.36"
y2="60.854"
gradientUnits="userSpaceOnUse">
<stop
offset="0.024"
stop-color="#645AFF"
id="stop49" />
<stop
offset="0.484"
stop-color="#E40C5B"
id="stop51" />
<stop
offset="1"
stop-color="#FF4C3B"
id="stop53" />
</linearGradient>
<linearGradient
id="Acala_new_logo_svg__paint5_linear"
x1="1285.41"
y1="352.18399"
x2="1228.36"
y2="60.854"
gradientUnits="userSpaceOnUse">
<stop
offset="0.024"
stop-color="#645AFF"
id="stop56" />
<stop
offset="0.484"
stop-color="#E40C5B"
id="stop58" />
<stop
offset="1"
stop-color="#FF4C3B"
id="stop60" />
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 26.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1"
id="svg60" inkscape:version="1.1.1 (c3084ef, 2021-09-22)" sodipodi:docname="karura.svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 32"
style="enable-background:new 0 0 32 32;" xml:space="preserve">
<style type="text/css">
.st0{fill:url(#path9_00000183207226421243246130000000649871513633350020_);}
.st1{fill:url(#path11_00000111907511177103573740000007277726760468908191_);}
</style>
<sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="namedview62" inkscape:current-layer="svg60" inkscape:cx="95" inkscape:cy="15.958005" inkscape:pagecheckerboard="0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="966" inkscape:window-maximized="1" inkscape:window-width="1728" inkscape:window-x="0" inkscape:window-y="38" inkscape:zoom="6.0157895" pagecolor="#ffffff" showgrid="false">
</sodipodi:namedview>
<linearGradient id="path9_00000135687841366068396460000015766857612384780460_" gradientUnits="userSpaceOnUse" x1="30.603" y1="3.1183" x2="9.0668" y2="26.527" gradientTransform="matrix(1 0 0 -1 0 34)">
<stop offset="0" style="stop-color:#E40C5B"/>
<stop offset="1" style="stop-color:#FF4C3B"/>
</linearGradient>
<path id="path9" style="fill:url(#path9_00000135687841366068396460000015766857612384780460_);" d="M22.1,2l-8.6,7.8
c-0.9,0.8-2.1,1.3-3.3,1.3l-2.6,0l0-9.1H3v26h2.5c1.4,0,2.7-0.8,3.4-2c0,0,0,0,0,0c0.5-0.8,0.7-2.5,0.6-3.6
c-0.1-2.5-0.5-3.2-0.5-3.2C9,21,7.2,21.1,7.2,21.1c1.3-1.2,0.6-2.2,0.6-2.2c-2.3,1.6-2.9-0.1-2.9-0.3c0.1,0.1,0.7,0.6,2-1.1
c1.3-1.8,3.1-4.8,4.2-5.6c1.1-0.8,2.2-0.7,2.2-0.7s0.6-0.8,2.2-1.5c1.6-0.7,2.6,0.3,2.6,0.3c-1.6,1.3-3.9,3.5-4,6.6
c-0.1,2.5,5.4,6.9,4.4,13.3c0.6-1.5,0.8-2.9,0.6-4.7c-0.2-1.5-1.1-4.5-1.1-4.5l5.2,7.2H29L17.7,12.4L29,2H22.1z"/>
<linearGradient id="path11_00000141442106739365556190000001809957881644179604_" gradientUnits="userSpaceOnUse" x1="12.4138" y1="20.1852" x2="10.8888" y2="21.8552" gradientTransform="matrix(1 0 0 -1 0 34)">
<stop offset="0" style="stop-color:#E40C5B"/>
<stop offset="1" style="stop-color:#FF4C3B"/>
</linearGradient>
<path id="path11" style="fill:url(#path11_00000141442106739365556190000001809957881644179604_);" d="M10.9,12.8
c-0.4,0.7-0.4,0.9-0.4,0.9s1.5-0.2,1.9-2C12.3,11.7,11.4,12,10.9,12.8L10.9,12.8z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,10 +1,12 @@
import {
ChainId,
CHAIN_ID_ACALA,
CHAIN_ID_AVAX,
CHAIN_ID_BSC,
CHAIN_ID_ETH,
CHAIN_ID_ETHEREUM_ROPSTEN,
CHAIN_ID_FANTOM,
CHAIN_ID_KARURA,
CHAIN_ID_OASIS,
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA,
@ -13,10 +15,12 @@ import {
} from "@certusone/wormhole-sdk";
import { clusterApiUrl } from "@solana/web3.js";
import { getAddress } from "ethers/lib/utils";
import acalaIcon from "../icons/acala.svg";
import avaxIcon from "../icons/avax.svg";
import bscIcon from "../icons/bsc.svg";
import ethIcon from "../icons/eth.svg";
import fantomIcon from "../icons/fantom.svg";
import karuraIcon from "../icons/karura.svg";
import oasisIcon from "../icons/oasis-network-rose-logo.svg";
import polygonIcon from "../icons/polygon.svg";
import solanaIcon from "../icons/solana.svg";
@ -80,6 +84,11 @@ export const CHAINS: ChainInfo[] =
]
: CLUSTER === "testnet"
? [
{
id: CHAIN_ID_ACALA,
name: "Acala",
logo: acalaIcon,
},
{
id: CHAIN_ID_AVAX,
name: "Avalanche",
@ -105,6 +114,11 @@ export const CHAINS: ChainInfo[] =
name: "Fantom",
logo: fantomIcon,
},
{
id: CHAIN_ID_KARURA,
name: "Karura",
logo: karuraIcon,
},
{
id: CHAIN_ID_OASIS,
name: "Oasis",
@ -158,7 +172,9 @@ export const CHAINS_WITH_NFT_SUPPORT = CHAINS.filter(
id === CHAIN_ID_POLYGON ||
id === CHAIN_ID_OASIS ||
id === CHAIN_ID_SOLANA ||
id === CHAIN_ID_FANTOM
id === CHAIN_ID_FANTOM ||
id === CHAIN_ID_KARURA ||
id === CHAIN_ID_ACALA
);
export type ChainsById = { [key in ChainId]: ChainInfo };
export const CHAINS_BY_ID: ChainsById = CHAINS.reduce((obj, chain) => {
@ -184,6 +200,10 @@ export const getDefaultNativeCurrencySymbol = (chainId: ChainId) =>
? "ROSE"
: chainId === CHAIN_ID_FANTOM
? "FTM"
: chainId === CHAIN_ID_KARURA
? "KAR"
: chainId === CHAIN_ID_ACALA
? "ACA"
: "";
export const getExplorerName = (chainId: ChainId) =>
chainId === CHAIN_ID_ETH || chainId === CHAIN_ID_ETHEREUM_ROPSTEN
@ -226,6 +246,10 @@ export const OASIS_NETWORK_CHAIN_ID =
CLUSTER === "mainnet" ? 42262 : CLUSTER === "testnet" ? 42261 : 1381;
export const FANTOM_NETWORK_CHAIN_ID =
CLUSTER === "mainnet" ? 250 : CLUSTER === "testnet" ? 4002 : 1381;
export const KARURA_NETWORK_CHAIN_ID =
CLUSTER === "mainnet" ? 686 : CLUSTER === "testnet" ? 686 : 1381;
export const ACALA_NETWORK_CHAIN_ID =
CLUSTER === "mainnet" ? 787 : CLUSTER === "testnet" ? 787 : 1381;
export const getEvmChainId = (chainId: ChainId) =>
chainId === CHAIN_ID_ETH
? ETH_NETWORK_CHAIN_ID
@ -241,6 +265,10 @@ export const getEvmChainId = (chainId: ChainId) =>
? OASIS_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_FANTOM
? FANTOM_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_KARURA
? KARURA_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_ACALA
? ACALA_NETWORK_CHAIN_ID
: undefined;
export const SOLANA_HOST = process.env.REACT_APP_SOLANA_API_URL
? process.env.REACT_APP_SOLANA_API_URL
@ -268,6 +296,18 @@ export const TERRA_HOST =
chainID: "columbus-5",
name: "localterra",
};
export const KARURA_HOST =
CLUSTER === "mainnet"
? ""
: CLUSTER === "testnet"
? "http://103.253.145.222:8545"
: "";
export const ACALA_HOST =
CLUSTER === "mainnet"
? ""
: CLUSTER === "testnet"
? "http://157.245.252.103:8545"
: "";
export const ETH_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B"
@ -394,6 +434,48 @@ export const FANTOM_TOKEN_BRIDGE_ADDRESS = getAddress(
? "0x599CEa2204B4FaECd584Ab1F2b6aCA137a0afbE8"
: "0x0290FB167208Af455bB137780163b7B7a9a10C16"
);
export const KARURA_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0xE4eacc10990ba3308DdCC72d985f2a27D20c7d03"
: "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550"
);
export const KARURA_NFT_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0x0A693c2D594292B6Eb89Cb50EFe4B0b63Dd2760D"
: "0x26b4afb60d6c903165150c6f0aa14f8016be4aec"
);
export const KARURA_TOKEN_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0xd11De1f930eA1F7Dd0290Fe3a2e35b9C91AEFb37"
: "0x0290FB167208Af455bB137780163b7B7a9a10C16"
);
export const ACALA_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0x4377B49d559c0a9466477195C6AdC3D433e265c0"
: "0xC89Ce4735882C9F0f0FE26686c53074E09B0D550"
);
export const ACALA_NFT_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0x96f1335e0AcAB3cfd9899B30b2374e25a2148a6E"
: "0x26b4afb60d6c903165150c6f0aa14f8016be4aec"
);
export const ACALA_TOKEN_BRIDGE_ADDRESS = getAddress(
CLUSTER === "mainnet"
? "0x0000000000000000000000000000000000000000"
: CLUSTER === "testnet"
? "0xebA00cbe08992EdD08ed7793E07ad6063c807004"
: "0x0290FB167208Af455bB137780163b7B7a9a10C16"
);
export const SOL_BRIDGE_ADDRESS =
CLUSTER === "mainnet"
? "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"
@ -472,6 +554,10 @@ export const getBridgeAddressForChain = (chainId: ChainId) =>
? OASIS_BRIDGE_ADDRESS
: chainId === CHAIN_ID_FANTOM
? FANTOM_BRIDGE_ADDRESS
: chainId === CHAIN_ID_KARURA
? KARURA_BRIDGE_ADDRESS
: chainId === CHAIN_ID_ACALA
? ACALA_BRIDGE_ADDRESS
: "";
export const getNFTBridgeAddressForChain = (chainId: ChainId) =>
chainId === CHAIN_ID_SOLANA
@ -490,6 +576,10 @@ export const getNFTBridgeAddressForChain = (chainId: ChainId) =>
? OASIS_NFT_BRIDGE_ADDRESS
: chainId === CHAIN_ID_FANTOM
? FANTOM_NFT_BRIDGE_ADDRESS
: chainId === CHAIN_ID_KARURA
? KARURA_NFT_BRIDGE_ADDRESS
: chainId === CHAIN_ID_ACALA
? ACALA_NFT_BRIDGE_ADDRESS
: "";
export const getTokenBridgeAddressForChain = (chainId: ChainId) =>
chainId === CHAIN_ID_SOLANA
@ -510,6 +600,10 @@ export const getTokenBridgeAddressForChain = (chainId: ChainId) =>
? OASIS_TOKEN_BRIDGE_ADDRESS
: chainId === CHAIN_ID_FANTOM
? FANTOM_TOKEN_BRIDGE_ADDRESS
: chainId === CHAIN_ID_KARURA
? KARURA_TOKEN_BRIDGE_ADDRESS
: chainId === CHAIN_ID_ACALA
? ACALA_TOKEN_BRIDGE_ADDRESS
: "";
export const COVALENT_API_KEY = process.env.REACT_APP_COVALENT_API_KEY
@ -524,6 +618,8 @@ export const COVALENT_AVAX = CLUSTER === "devnet" ? 137 : AVAX_NETWORK_CHAIN_ID;
export const COVALENT_OASIS = CLUSTER === "devnet" ? null : null;
export const COVALENT_FANTOM =
CLUSTER === "devnet" ? 250 : FANTOM_NETWORK_CHAIN_ID;
export const COVALENT_KARURA = CLUSTER === "devnet" ? null : null;
export const COVALENT_ACALA = CLUSTER === "devnet" ? null : null;
export const COVALENT_GET_TOKENS_URL = (
chainId: ChainId,
walletAddress: string,
@ -543,6 +639,10 @@ export const COVALENT_GET_TOKENS_URL = (
? COVALENT_OASIS
: chainId === CHAIN_ID_FANTOM
? COVALENT_FANTOM
: chainId === CHAIN_ID_KARURA
? COVALENT_KARURA
: chainId === CHAIN_ID_ACALA
? COVALENT_ACALA
: "";
// https://www.covalenthq.com/docs/api/#get-/v1/{chain_id}/address/{address}/balances_v2/
return `https://api.covalenthq.com/v1/${chainNum}/address/${walletAddress}/balances_v2/?key=${COVALENT_API_KEY}${

View File

@ -0,0 +1,22 @@
import axios from "axios";
export async function getKaruraGasParams(rpc: string): Promise<{
gasPrice: number;
gasLimit: number;
}> {
const gasLimit = 21000000;
const storageLimit = 64001;
const res = (
await axios.post(rpc, {
id: 0,
jsonrpc: "2.0",
method: "eth_getEthGas",
params: [gasLimit, storageLimit],
})
).data.result;
return {
gasLimit: parseInt(res.gasLimit, 16),
gasPrice: parseInt(res.gasPrice, 16),
};
}