diff --git a/bridge_ui/package-lock.json b/bridge_ui/package-lock.json index b26b2c820..141069d46 100644 --- a/bridge_ui/package-lock.json +++ b/bridge_ui/package-lock.json @@ -10,9 +10,9 @@ "dependencies": { "@alephium/token-list": "0.0.12", "@alephium/walletconnect-qrcode-modal": "0.1.0", - "@alephium/web3": "^1.11.0", - "@alephium/web3-react": "^1.11.0", - "@alephium/wormhole-sdk": "^0.3.7", + "@alephium/web3": "^1.11.1", + "@alephium/web3-react": "^1.11.1", + "@alephium/wormhole-sdk": "^0.4.0", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.11.2", "@material-ui/lab": "^4.0.0-alpha.60", @@ -100,11 +100,11 @@ } }, "node_modules/@alephium/get-extension-wallet": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/get-extension-wallet/-/get-extension-wallet-1.11.0.tgz", - "integrity": "sha512-ORmYq4SE4eWs3vVpxB86fjVEc6blAxOB/foC0D2CHliMloHCpXsHDGz5D/Cch5KmDNjLZjJ7yGok3PgrazNTUg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/get-extension-wallet/-/get-extension-wallet-1.11.1.tgz", + "integrity": "sha512-echynHnFKtdx5PbZDgNxtfOTM/UfPrfxR8KLncGb94PinOKCXYfcQZO2C/tJ4hCHJKVVmpPhCAohFwF3vVIIcA==", "dependencies": { - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "bowser": "^2.11.0" } }, @@ -167,12 +167,12 @@ } }, "node_modules/@alephium/walletconnect-provider": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/walletconnect-provider/-/walletconnect-provider-1.11.0.tgz", - "integrity": "sha512-Wc86+PSjMfwVesJQwaAcytasbvdw309AvZzMWlyqfgFSadXBBo7TXB2IcgcUnBVCWunPLA3zjydEreC6pYc/Lg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/walletconnect-provider/-/walletconnect-provider-1.11.1.tgz", + "integrity": "sha512-1cnd5JMS3Go1UJxnybqOWLF+aMAVjTkqc2rf8ndNFWxlBVEqwwT+J8AevCuCBE70/l7oyHWsCpVUC6ev0HOaiA==", "dependencies": { - "@alephium/web3": "^1.11.0", - "@alephium/web3-wallet": "^1.11.0", + "@alephium/web3": "^1.11.1", + "@alephium/web3-wallet": "^1.11.1", "@walletconnect/core": "2.17.2", "@walletconnect/keyvaluestorage": "1.1.1", "@walletconnect/sign-client": "2.17.2", @@ -586,9 +586,9 @@ } }, "node_modules/@alephium/web3": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.0.tgz", - "integrity": "sha512-vT4Kd/5sGUuKdfHzy+BLenOuVMPPpZXV7arNEgNZYdgYs5AnT3MTzCmJBbVosn9WeEipfb/p2x4xjAjMKffMYQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.1.tgz", + "integrity": "sha512-aAyxLw2OfsQD4t33T7gE6wfeFXqeQApgp1x5pLYWbKgn+DMlJbEC/jFrxTuOztQByrv9Fr3ApxNZ5CISWkJQCA==", "dependencies": { "@noble/secp256k1": "1.7.1", "base-x": "4.0.0", @@ -608,12 +608,12 @@ } }, "node_modules/@alephium/web3-react": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3-react/-/web3-react-1.11.0.tgz", - "integrity": "sha512-KX7xyU/vyKOKx9OBVHCG7TsWEwlUHWRb4oO/mXp/ma6fjzOf1+JjcU5Q+FQxWm4DyRDMmjg6qO1YUcY7lC+2Ww==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3-react/-/web3-react-1.11.1.tgz", + "integrity": "sha512-g/qj6XadlFhb/BdGJltWen47rC9lEQ4oLz7kiflKbSyquELIvJe81T0ktQhoFDkvQTEzwnXWGCnNGGmy1BKw6Q==", "dependencies": { - "@alephium/get-extension-wallet": "^1.11.0", - "@alephium/walletconnect-provider": "^1.11.0", + "@alephium/get-extension-wallet": "^1.11.1", + "@alephium/walletconnect-provider": "^1.11.1", "@alephium/walletconnect-qrcode-modal": "^0.1.0", "buffer": "^6.0.3", "detect-browser": "^5.3.0", @@ -647,11 +647,11 @@ } }, "node_modules/@alephium/web3-wallet": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3-wallet/-/web3-wallet-1.11.0.tgz", - "integrity": "sha512-6xtcB7ip++YMYZaOcDidvXJ/S8NDdS1pKuyTma363odRRO7T3ksuhkGw5Nhl96FA/muLjZCTtwT1RcJdqtNZ+w==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3-wallet/-/web3-wallet-1.11.1.tgz", + "integrity": "sha512-ysWUl379yhmMn3mi0KkCH2Y6tki+KxpJQyL+rWmt8GVea+TuRZbtXw0YG9Vx3Ok59iLGiZJIcU98/LDtVeMB+g==", "dependencies": { - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "@noble/secp256k1": "1.7.1", "@types/node": "^16.18.23", "bip32": "3.1.0", @@ -766,18 +766,13 @@ } }, "node_modules/@alephium/wormhole-sdk": { - "version": "0.3.7", - "resolved": "https://registry.npmjs.org/@alephium/wormhole-sdk/-/wormhole-sdk-0.3.7.tgz", - "integrity": "sha512-viPppas59caIJpOhW6X78Rh9cdsOUYQ65MQz4z+E1eiwYUpETrkm/k+X4c9HI9APQTc5CIfJ/nvQJmvl5qiBJg==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@alephium/wormhole-sdk/-/wormhole-sdk-0.4.0.tgz", + "integrity": "sha512-Za2KueU5qMLoQpXyn+fgmZMmHQz6TogDJpwlk9lFjTTC4w38wRViN4Ea2GiBpA5z9IiK28bCJSL3qAs+XtZJ+g==", "dependencies": { "@alephium/token-list": "0.0.11", - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "@improbable-eng/grpc-web": "^0.14.0", - "@solana/spl-token": "^0.1.8", - "@solana/web3.js": "^1.24.0", - "@terra-money/terra.js": "^3.0.7", - "algosdk": "2.4.0", - "axios": "^0.24.0", "bech32": "^2.0.0", "bs58": "^5.0.0", "ethers": "^5.6.8", @@ -810,14 +805,6 @@ "google-protobuf": "^3.14.0" } }, - "node_modules/@alephium/wormhole-sdk/node_modules/axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", - "dependencies": { - "follow-redirects": "^1.14.4" - } - }, "node_modules/@alephium/wormhole-sdk/node_modules/bech32": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", @@ -7876,6 +7863,7 @@ "node_modules/@terra-money/terra.js": { "version": "3.0.7", "license": "MIT", + "peer": true, "dependencies": { "@terra-money/terra.proto": "^0.1.7", "axios": "^0.24.0", @@ -7898,17 +7886,20 @@ "node_modules/@terra-money/terra.js/node_modules/axios": { "version": "0.24.0", "license": "MIT", + "peer": true, "dependencies": { "follow-redirects": "^1.14.4" } }, "node_modules/@terra-money/terra.js/node_modules/bech32": { "version": "2.0.0", - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/@terra-money/terra.proto": { "version": "0.1.7", "license": "Apache-2.0", + "peer": true, "dependencies": { "google-protobuf": "^3.17.3", "long": "^4.0.0", @@ -42069,6 +42060,7 @@ "node_modules/tmp": { "version": "0.2.1", "license": "MIT", + "peer": true, "dependencies": { "rimraf": "^3.0.0" }, @@ -45584,11 +45576,11 @@ } }, "@alephium/get-extension-wallet": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/get-extension-wallet/-/get-extension-wallet-1.11.0.tgz", - "integrity": "sha512-ORmYq4SE4eWs3vVpxB86fjVEc6blAxOB/foC0D2CHliMloHCpXsHDGz5D/Cch5KmDNjLZjJ7yGok3PgrazNTUg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/get-extension-wallet/-/get-extension-wallet-1.11.1.tgz", + "integrity": "sha512-echynHnFKtdx5PbZDgNxtfOTM/UfPrfxR8KLncGb94PinOKCXYfcQZO2C/tJ4hCHJKVVmpPhCAohFwF3vVIIcA==", "requires": { - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "bowser": "^2.11.0" } }, @@ -45638,12 +45630,12 @@ } }, "@alephium/walletconnect-provider": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/walletconnect-provider/-/walletconnect-provider-1.11.0.tgz", - "integrity": "sha512-Wc86+PSjMfwVesJQwaAcytasbvdw309AvZzMWlyqfgFSadXBBo7TXB2IcgcUnBVCWunPLA3zjydEreC6pYc/Lg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/walletconnect-provider/-/walletconnect-provider-1.11.1.tgz", + "integrity": "sha512-1cnd5JMS3Go1UJxnybqOWLF+aMAVjTkqc2rf8ndNFWxlBVEqwwT+J8AevCuCBE70/l7oyHWsCpVUC6ev0HOaiA==", "requires": { - "@alephium/web3": "^1.11.0", - "@alephium/web3-wallet": "^1.11.0", + "@alephium/web3": "^1.11.1", + "@alephium/web3-wallet": "^1.11.1", "@walletconnect/core": "2.17.2", "@walletconnect/keyvaluestorage": "1.1.1", "@walletconnect/sign-client": "2.17.2", @@ -45909,9 +45901,9 @@ } }, "@alephium/web3": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.0.tgz", - "integrity": "sha512-vT4Kd/5sGUuKdfHzy+BLenOuVMPPpZXV7arNEgNZYdgYs5AnT3MTzCmJBbVosn9WeEipfb/p2x4xjAjMKffMYQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.1.tgz", + "integrity": "sha512-aAyxLw2OfsQD4t33T7gE6wfeFXqeQApgp1x5pLYWbKgn+DMlJbEC/jFrxTuOztQByrv9Fr3ApxNZ5CISWkJQCA==", "requires": { "@noble/secp256k1": "1.7.1", "base-x": "4.0.0", @@ -45983,12 +45975,12 @@ } }, "@alephium/web3-react": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3-react/-/web3-react-1.11.0.tgz", - "integrity": "sha512-KX7xyU/vyKOKx9OBVHCG7TsWEwlUHWRb4oO/mXp/ma6fjzOf1+JjcU5Q+FQxWm4DyRDMmjg6qO1YUcY7lC+2Ww==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3-react/-/web3-react-1.11.1.tgz", + "integrity": "sha512-g/qj6XadlFhb/BdGJltWen47rC9lEQ4oLz7kiflKbSyquELIvJe81T0ktQhoFDkvQTEzwnXWGCnNGGmy1BKw6Q==", "requires": { - "@alephium/get-extension-wallet": "^1.11.0", - "@alephium/walletconnect-provider": "^1.11.0", + "@alephium/get-extension-wallet": "^1.11.1", + "@alephium/walletconnect-provider": "^1.11.1", "@alephium/walletconnect-qrcode-modal": "^0.1.0", "buffer": "^6.0.3", "detect-browser": "^5.3.0", @@ -46015,11 +46007,11 @@ } }, "@alephium/web3-wallet": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3-wallet/-/web3-wallet-1.11.0.tgz", - "integrity": "sha512-6xtcB7ip++YMYZaOcDidvXJ/S8NDdS1pKuyTma363odRRO7T3ksuhkGw5Nhl96FA/muLjZCTtwT1RcJdqtNZ+w==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3-wallet/-/web3-wallet-1.11.1.tgz", + "integrity": "sha512-ysWUl379yhmMn3mi0KkCH2Y6tki+KxpJQyL+rWmt8GVea+TuRZbtXw0YG9Vx3Ok59iLGiZJIcU98/LDtVeMB+g==", "requires": { - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "@noble/secp256k1": "1.7.1", "@types/node": "^16.18.23", "bip32": "3.1.0", @@ -46054,18 +46046,13 @@ } }, "@alephium/wormhole-sdk": { - "version": "0.3.7", - "resolved": "https://registry.npmjs.org/@alephium/wormhole-sdk/-/wormhole-sdk-0.3.7.tgz", - "integrity": "sha512-viPppas59caIJpOhW6X78Rh9cdsOUYQ65MQz4z+E1eiwYUpETrkm/k+X4c9HI9APQTc5CIfJ/nvQJmvl5qiBJg==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@alephium/wormhole-sdk/-/wormhole-sdk-0.4.0.tgz", + "integrity": "sha512-Za2KueU5qMLoQpXyn+fgmZMmHQz6TogDJpwlk9lFjTTC4w38wRViN4Ea2GiBpA5z9IiK28bCJSL3qAs+XtZJ+g==", "requires": { "@alephium/token-list": "0.0.11", - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "@improbable-eng/grpc-web": "^0.14.0", - "@solana/spl-token": "^0.1.8", - "@solana/web3.js": "^1.24.0", - "@terra-money/terra.js": "^3.0.7", - "algosdk": "2.4.0", - "axios": "^0.24.0", "bech32": "^2.0.0", "bs58": "^5.0.0", "ethers": "^5.6.8", @@ -46091,14 +46078,6 @@ "browser-headers": "^0.4.1" } }, - "axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", - "requires": { - "follow-redirects": "^1.14.4" - } - }, "bech32": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", @@ -50714,6 +50693,7 @@ }, "@terra-money/terra.js": { "version": "3.0.7", + "peer": true, "requires": { "@terra-money/terra.proto": "^0.1.7", "axios": "^0.24.0", @@ -50732,17 +50712,20 @@ "dependencies": { "axios": { "version": "0.24.0", + "peer": true, "requires": { "follow-redirects": "^1.14.4" } }, "bech32": { - "version": "2.0.0" + "version": "2.0.0", + "peer": true } } }, "@terra-money/terra.proto": { "version": "0.1.7", + "peer": true, "requires": { "google-protobuf": "^3.17.3", "long": "^4.0.0", @@ -74697,6 +74680,7 @@ }, "tmp": { "version": "0.2.1", + "peer": true, "requires": { "rimraf": "^3.0.0" } diff --git a/bridge_ui/package.json b/bridge_ui/package.json index 18fef52bd..7eb9b8ebe 100644 --- a/bridge_ui/package.json +++ b/bridge_ui/package.json @@ -4,9 +4,9 @@ "private": true, "dependencies": { "@alephium/token-list": "0.0.12", - "@alephium/web3": "^1.11.0", - "@alephium/web3-react": "^1.11.0", - "@alephium/wormhole-sdk": "^0.3.7", + "@alephium/web3": "^1.11.1", + "@alephium/web3-react": "^1.11.1", + "@alephium/wormhole-sdk": "^0.4.0", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.11.2", "@material-ui/lab": "^4.0.0-alpha.60", diff --git a/bridge_ui/src/App.js b/bridge_ui/src/App.js index 4127bf374..3b9409bd4 100644 --- a/bridge_ui/src/App.js +++ b/bridge_ui/src/App.js @@ -1,8 +1,3 @@ -import { - CHAIN_ID_BSC, - CHAIN_ID_ETH, - CHAIN_ID_SOLANA, -} from "@alephium/wormhole-sdk"; import { AppBar, Container, @@ -29,9 +24,6 @@ import { import Attest from "./components/Attest"; import Footer from "./components/Footer"; import HeaderText from "./components/HeaderText"; -import Migration from "./components/Migration"; -import EvmQuickMigrate from "./components/Migration/EvmQuickMigrate"; -import SolanaQuickMigrate from "./components/Migration/SolanaQuickMigrate"; import Recovery from "./components/Recovery"; import Stats from "./components/Stats"; import CustodyAddresses from "./components/Stats/CustodyAddresses"; @@ -39,7 +31,6 @@ import TokenOriginVerifier from "./components/TokenOriginVerifier"; import Transactions from "./components/Transactions"; import Transfer from "./components/Transfer"; import UnwrapNative from "./components/UnwrapNative"; -import WithdrawTokensTerra from "./components/WithdrawTokensTerra"; import { useBetaContext } from "./contexts/BetaContext"; import Alephium from "./icons/alephium.svg"; import { CLUSTER } from "./utils/consts"; @@ -280,30 +271,9 @@ function App() { - - - - - - - - - - - - - - - - - - - - - diff --git a/bridge_ui/src/components/Attest/Create.tsx b/bridge_ui/src/components/Attest/Create.tsx index 95070d1d5..cff41e614 100644 --- a/bridge_ui/src/components/Attest/Create.tsx +++ b/bridge_ui/src/components/Attest/Create.tsx @@ -1,4 +1,3 @@ -import { CHAIN_ID_TERRA } from "@alephium/wormhole-sdk"; import { CircularProgress, makeStyles } from "@material-ui/core"; import { useTranslation } from "react-i18next"; import { useSelector } from "react-redux"; @@ -12,7 +11,6 @@ import { } from "../../store/selectors"; import ButtonWithLoader from "../ButtonWithLoader"; import KeyAndBalance from "../KeyAndBalance"; -import TerraFeeDenomPicker from "../TerraFeeDenomPicker"; import WaitingForWalletMessage from "./WaitingForWalletMessage"; const useStyles = makeStyles((theme) => ({ @@ -47,9 +45,6 @@ function Create() { return ( <> - {targetChain === CHAIN_ID_TERRA && ( - - )} {foreignAssetInfo.isFetching ? ( <>
diff --git a/bridge_ui/src/components/Attest/Send.tsx b/bridge_ui/src/components/Attest/Send.tsx index e5bb70de2..6b5e28ed4 100644 --- a/bridge_ui/src/components/Attest/Send.tsx +++ b/bridge_ui/src/components/Attest/Send.tsx @@ -1,4 +1,4 @@ -import { CHAIN_ID_ALEPHIUM, CHAIN_ID_SOLANA, CHAIN_ID_TERRA, waitAlphTxConfirmed } from "@alephium/wormhole-sdk"; +import { CHAIN_ID_ALEPHIUM, CHAIN_ID_SOLANA, waitAlphTxConfirmed } from "@alephium/wormhole-sdk"; import { Alert } from "@material-ui/lab"; import { Link, makeStyles } from "@material-ui/core"; import { useCallback, useMemo, useState } from "react"; @@ -18,7 +18,6 @@ import KeyAndBalance from "../KeyAndBalance"; import TransactionProgress from "../TransactionProgress"; import WaitingForWalletMessage from "./WaitingForWalletMessage"; import { ALEPHIUM_ATTEST_TOKEN_CONSISTENCY_LEVEL, SOLANA_TOKEN_METADATA_PROGRAM_URL } from "../../utils/consts"; -import TerraFeeDenomPicker from "../TerraFeeDenomPicker"; import { createLocalTokenPool } from "../../utils/alephium"; import { useWallet } from "@alephium/web3-react"; import { useSnackbar } from "notistack"; @@ -125,9 +124,6 @@ function Send() { return ( <> - {sourceChain === CHAIN_ID_TERRA && ( - - )} ({ - spacer: { - height: "2rem", - }, - containerDiv: { - textAlign: "center", - padding: theme.spacing(2), - }, - lineItem: { - display: "flex", - flexWrap: "nowrap", - justifyContent: "space-between", - "& > *": { - alignSelf: "flex-start", - width: "max-content", - }, - }, - flexGrow: { - flewGrow: 1, - }, - mainPaper: { - backgroundColor: COLORS.whiteWithTransparency, - textAlign: "center", - padding: "2rem", - "& > h, p ": { - margin: ".5rem", - }, - }, - hidden: { - display: "none", - }, - divider: { - margin: "2rem 0rem 2rem 0rem", - }, - balance: { - display: "inline-block", - }, - convertButton: { - alignSelf: "flex-end", - }, -})); - -//TODO move elsewhere -export const compareWithDecimalOffset = ( - valueA: string, - decimalsA: number, - valueB: string, - decimalsB: number -) => { - //find which is larger, and offset by that amount - const decimalsBasis = decimalsA > decimalsB ? decimalsA : decimalsB; - const normalizedA = parseUnits(valueA, decimalsBasis).toBigInt(); - const normalizedB = parseUnits(valueB, decimalsBasis).toBigInt(); - - if (normalizedA < normalizedB) { - return -1; - } else if (normalizedA === normalizedB) { - return 0; - } else { - return 1; - } -}; - -function EvmMigrationLineItem({ - chainId, - migratorAddress, - onLoadComplete, -}: { - chainId: ChainId; - migratorAddress: string; - onLoadComplete: () => void; -}) { - const { t } = useTranslation(); - const classes = useStyles(); - const { enqueueSnackbar } = useSnackbar(); - const { signer, signerAddress } = useEthereumProvider(); - const poolInfo = useEthereumMigratorInformation( - migratorAddress, - signer, - signerAddress, - false - ); - const [loaded, setLoaded] = useState(false); - const [migrationIsProcessing, setMigrationIsProcessing] = useState(false); - const [transaction, setTransaction] = useState(""); - const [error, setError] = useState(""); - const fromSymbol = poolInfo?.data?.fromSymbol; - const toSymbol = poolInfo?.data?.toSymbol; - - const sufficientPoolBalance = - poolInfo.data && - compareWithDecimalOffset( - poolInfo.data.fromWalletBalance, - poolInfo.data.fromDecimals, - poolInfo.data.toPoolBalance, - poolInfo.data.toDecimals - ) !== 1; - - useEffect(() => { - if (!loaded && (poolInfo.data || poolInfo.error)) { - onLoadComplete(); - setLoaded(true); - } - }, [loaded, poolInfo, onLoadComplete]); - - //TODO use transaction loader - const migrateTokens = useCallback(async () => { - if (!poolInfo.data) { - enqueueSnackbar(null, { - content: {t("Could not migrate the tokens.")}, - }); //Should never be hit - return; - } - try { - const migrationAmountAbs = parseUnits( - poolInfo.data.fromWalletBalance, - poolInfo.data.fromDecimals - ); - setMigrationIsProcessing(true); - await poolInfo.data.fromToken.approve( - poolInfo.data.migrator.address, - migrationAmountAbs - ); - const transaction = await poolInfo.data.migrator.migrate( - migrationAmountAbs - ); - await transaction.wait(); - setTransaction(transaction.hash); - enqueueSnackbar(null, { - content: ( - {t("Successfully migrated the tokens.")} - ), - }); - setMigrationIsProcessing(false); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {t("Could not migrate the tokens.")}, - }); - setMigrationIsProcessing(false); - setError("Failed to send the transaction."); - } - }, [poolInfo.data, enqueueSnackbar, t]); - - if (!poolInfo.data) { - return null; - } else if (transaction) { - return ( -
-
- - {t("Successfully migrated your tokens. They will become available once this transaction confirms.")} - - -
-
- ); - } else { - return ( -
-
- - {t("Current Token")} - - - {poolInfo.data.fromWalletBalance} - - -
-
- - {t("will become")} - - -
-
- - {t("Wormhole Token")} - - - {poolInfo.data.fromWalletBalance} - - -
-
- - {t("Convert")} - -
-
- ); - } -} - -const getAddressBalances = async ( - signer: Signer, - signerAddress: string, - addresses: string[] -): Promise> => { - try { - const promises: Promise[] = []; - const output = new Map(); - addresses.forEach((address) => { - const factory = ethers_contracts.TokenImplementation__factory.connect(address, signer); - promises.push( - factory.balanceOf(signerAddress).then( - (result) => { - output.set(address, result); - }, - (error) => { - output.set(address, null); - } - ) - ); - }); - await Promise.all(promises); - return output; - } catch (e) { - return Promise.reject("Unable to retrieve token balances."); - } -}; - -export default function EvmQuickMigrate({ chainId }: { chainId: ChainId }) { - const classes = useStyles(); - const { signer, signerAddress } = useEthereumProvider(); - const { isReady } = useIsWalletReady(chainId); - const migrationMap = useMemo(() => getMigrationAssetMap(chainId), [chainId]); - const eligibleTokens = useMemo( - () => Array.from(migrationMap.keys()), - [migrationMap] - ); - const [migrators, setMigrators] = useState(null); - const [migratorsError, setMigratorsError] = useState(""); - const [migratorsLoading, setMigratorsLoading] = useState(false); - - //This is for a callback into the line items, so a loader can be displayed while - //they are loading - //TODO don't just swallow loading errors. - const [migratorsFinishedLoading, setMigratorsFinishedLoading] = useState(0); - const reportLoadComplete = useCallback(() => { - setMigratorsFinishedLoading((prevState) => prevState + 1); - }, []); - const isLoading = - migratorsLoading || - (migrators && - migrators.length && - migratorsFinishedLoading < migrators.length); - - useEffect(() => { - if (isReady && signer && signerAddress) { - let cancelled = false; - setMigratorsLoading(true); - setMigratorsError(""); - getAddressBalances(signer, signerAddress, eligibleTokens).then( - (result) => { - if (!cancelled) { - const migratorAddresses = []; - for (const tokenAddress of result.keys()) { - if (result.get(tokenAddress) && result.get(tokenAddress)?.gt(0)) { - const migratorAddress = migrationMap.get( - getAddress(tokenAddress) - ); - if (migratorAddress) { - migratorAddresses.push(migratorAddress); - } - } - } - setMigratorsFinishedLoading(0); - setMigrators(migratorAddresses); - setMigratorsLoading(false); - } - }, - (error) => { - if (!cancelled) { - setMigratorsLoading(false); - setMigratorsError( - "Failed to retrieve available token information." - ); - } - } - ); - - return () => { - cancelled = true; - }; - } - }, [isReady, signer, signerAddress, eligibleTokens, migrationMap]); - - const hasEligibleAssets = migrators && migrators.length > 0; - const chainName = CHAINS_BY_ID[chainId]?.name; - - const content = ( -
- - {`This page allows you to convert certain wrapped tokens ${ - chainName ? "on " + chainName : "" - } into - Wormhole V2 tokens.`} - - - {!isReady ? ( - Please connect your wallet. - ) : migratorsError ? ( - {migratorsError} - ) : ( - <> -
- -
- - {hasEligibleAssets - ? "You have some assets that are eligible for migration! Click the 'Convert' button to swap them for Wormhole tokens." - : "You don't have any assets eligible for migration."} - -
- {migrators?.map((address) => { - return ( - - ); - })} -
- - )} -
- ); - - return ( - - - Migrate Assets - - {content} - - ); -} diff --git a/bridge_ui/src/components/Migration/EvmWorkflow.tsx b/bridge_ui/src/components/Migration/EvmWorkflow.tsx deleted file mode 100644 index 0c57abee3..000000000 --- a/bridge_ui/src/components/Migration/EvmWorkflow.tsx +++ /dev/null @@ -1,247 +0,0 @@ -import { ChainId } from "@alephium/wormhole-sdk"; -import { CircularProgress, makeStyles, Typography } from "@material-ui/core"; -import { Alert } from "@material-ui/lab"; -import { parseUnits } from "ethers/lib/utils"; -import { useSnackbar } from "notistack"; -import { useCallback, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { useEthereumProvider } from "../../contexts/EthereumProviderContext"; -import useEthereumMigratorInformation from "../../hooks/useEthereumMigratorInformation"; -import useIsWalletReady from "../../hooks/useIsWalletReady"; -import ButtonWithLoader from "../ButtonWithLoader"; -import EthereumSignerKey from "../EthereumSignerKey"; -import NumberTextField from "../NumberTextField"; -import ShowTx from "../ShowTx"; -import SmartAddress from "../SmartAddress"; - -const useStyles = makeStyles((theme) => ({ - spacer: { - height: "2rem", - }, - containerDiv: { - textAlign: "center", - padding: theme.spacing(2), - }, -})); - -export default function EvmWorkflow({ - chainId, - migratorAddress, -}: { - chainId: ChainId; - migratorAddress: string; -}) { - const { t } = useTranslation(); - const classes = useStyles(); - const { enqueueSnackbar } = useSnackbar(); - const { signer, signerAddress } = useEthereumProvider(); - const { isReady } = useIsWalletReady(chainId); - const [toggleRefresh, setToggleRefresh] = useState(false); - const forceRefresh = useCallback( - () => setToggleRefresh((prevState) => !prevState), - [] - ); - const poolInfo = useEthereumMigratorInformation( - migratorAddress, - signer, - signerAddress, - toggleRefresh - ); - const fromWalletBalance = poolInfo.data?.fromWalletBalance; - - const [migrationAmount, setMigrationAmount] = useState(""); - const [migrationIsProcessing, setMigrationIsProcessing] = useState(false); - const [error, setError] = useState(""); - const [transaction, setTransaction] = useState(null); - - const fromParse = (amount: string) => { - try { - if (!poolInfo.data?.fromDecimals || !migrationAmount) { - return BigInt(0); - } - return parseUnits(amount, poolInfo.data.fromDecimals).toBigInt(); - } catch (e) { - return BigInt(0); - } - }; - - const hasRequisiteData = poolInfo.data; - const amountGreaterThanZero = fromParse(migrationAmount) > BigInt(0); - const sufficientFromTokens = - fromWalletBalance && - migrationAmount && - fromParse(migrationAmount) <= fromParse(fromWalletBalance); - const sufficientPoolBalance = - poolInfo.data?.toPoolBalance && - migrationAmount && - parseFloat(migrationAmount) <= parseFloat(poolInfo.data.toPoolBalance); - - const isReadyToTransfer = - isReady && - amountGreaterThanZero && - sufficientFromTokens && - sufficientPoolBalance && - hasRequisiteData; - - const getNotReadyCause = () => { - if (!isReady) { - return t("Connect your wallet to proceed."); - } else if (poolInfo.error) { - return t("Unable to retrieve necessary information. This asset may not be supported."); - } else if (!migrationAmount) { - return t("Enter an amount to transfer."); - } else if (!amountGreaterThanZero) { - return t("The transfer amount must be greater than zero."); - } else if (!sufficientFromTokens) { - return t("There are not sufficient funds in your wallet for this transfer."); - } else if (!sufficientPoolBalance) { - return t("There are not sufficient funds in the pool for this transfer."); - } else { - return ""; - } - }; - - const handleAmountChange = useCallback( - (event: any) => setMigrationAmount(event.target.value), - [setMigrationAmount] - ); - const handleMaxClick = useCallback(() => { - if (fromWalletBalance) { - setMigrationAmount(fromWalletBalance); - } - }, [fromWalletBalance]); - - const migrateTokens = useCallback(async () => { - if (!poolInfo.data) { - enqueueSnackbar(null, { - content: {t("Could not migrate the tokens.")}, - }); //Should never be hit - return; - } - try { - setMigrationIsProcessing(true); - setError(""); - await poolInfo.data.fromToken.approve( - poolInfo.data.migrator.address, - parseUnits(migrationAmount, poolInfo.data.fromDecimals) - ); - const transaction = await poolInfo.data.migrator.migrate( - parseUnits(migrationAmount, poolInfo.data.fromDecimals) - ); - await transaction.wait(); - setTransaction(transaction.hash); - forceRefresh(); - enqueueSnackbar(null, { - content: ( - {t("Successfully migrated the tokens.")} - ), - }); - setMigrationIsProcessing(false); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {t("Could not migrate the tokens.")}, - }); - setMigrationIsProcessing(false); - setError(t("Failed to send the transaction.")); - } - }, [poolInfo.data, enqueueSnackbar, t, migrationAmount, forceRefresh]); - - //TODO tokenName - const toTokenPretty = ( - - ); - const fromTokenPretty = ( - - ); - const poolPretty = ( - - ); - - const fatalError = poolInfo.error - ? t("Unable to retrieve necessary information. This asset may not be supported.") - : null; - - const explainerContent = ( -
- {t("This action will convert")} - - {fromTokenPretty} {`(${t('Balance')}: ${fromWalletBalance || ""})`} - -
- {t("to")} - - {toTokenPretty} {`(${t('Balance')}: ${poolInfo.data?.toWalletBalance || ""})`} - -
- {t("Utilizing this pool")} - - {poolPretty} {`(${t('Balance')}: ${poolInfo.data?.toPoolBalance || ""})`} - -
- ); - - const mainWorkflow = ( - <> - {explainerContent} -
- - - {!transaction && ( - - {migrationAmount && isReadyToTransfer - ? t('Migrate {{ tokensAmount }} Tokens', { tokensAmount: migrationAmount }) - : t('Migrate')} - - )} - - {(error || !isReadyToTransfer) && ( - {error || getNotReadyCause()} - )} - {transaction ? ( - <> - - {t("Successfully migrated your tokens! They will be available once this transaction confirms.")} - - - - ) : null} - - ); - - return ( -
- - {!isReady ? ( - {t("Please connect your wallet.")} - ) : poolInfo.isLoading ? ( - - ) : fatalError ? ( - {fatalError} - ) : ( - mainWorkflow - )} -
- ); -} diff --git a/bridge_ui/src/components/Migration/SolanaQuickMigrate.tsx b/bridge_ui/src/components/Migration/SolanaQuickMigrate.tsx deleted file mode 100644 index 439e3e9b8..000000000 --- a/bridge_ui/src/components/Migration/SolanaQuickMigrate.tsx +++ /dev/null @@ -1,383 +0,0 @@ -import { CHAIN_ID_SOLANA } from "@alephium/wormhole-sdk"; -import { - CircularProgress, - Container, - makeStyles, - Paper, - Typography, -} from "@material-ui/core"; -import ArrowRightAltIcon from "@material-ui/icons/ArrowRightAlt"; -import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; -import { - AccountInfo, - Connection, - ParsedAccountData, - PublicKey, -} from "@solana/web3.js"; -import { useCallback, useEffect, useMemo, useState } from "react"; -import { useTranslation } from "react-i18next"; -import useIsWalletReady from "../../hooks/useIsWalletReady"; -import useSolanaMigratorInformation from "../../hooks/useSolanaMigratorInformation"; -import i18n from "../../i18n"; -import { COLORS } from "../../muiTheme"; -import { - CHAINS_BY_ID, - getMigrationAssetMap, - SOLANA_HOST, -} from "../../utils/consts"; -import ButtonWithLoader from "../ButtonWithLoader"; -import HeaderText from "../HeaderText"; -import ShowTx from "../ShowTx"; -import SmartAddress from "../SmartAddress"; -import SolanaCreateAssociatedAddress from "../SolanaCreateAssociatedAddress"; -import SolanaWalletKey from "../SolanaWalletKey"; - -const useStyles = makeStyles((theme) => ({ - spacer: { - height: "2rem", - }, - containerDiv: { - textAlign: "center", - padding: theme.spacing(2), - }, - centered: { - textAlign: "center", - }, - lineItem: { - display: "flex", - flexWrap: "nowrap", - justifyContent: "space-between", - "& > *": { - alignSelf: "flex-start", - width: "max-content", - }, - }, - flexGrow: { - flewGrow: 1, - }, - mainPaper: { - backgroundColor: COLORS.whiteWithTransparency, - textAlign: "center", - padding: "2rem", - "& > h, p ": { - margin: ".5rem", - }, - }, - hidden: { - display: "none", - }, - divider: { - margin: "2rem 0rem 2rem 0rem", - }, - balance: { - display: "inline-block", - }, - convertButton: { - alignSelf: "flex-end", - }, -})); - -function SolanaMigrationLineItem({ - migratorInfo, - onLoadComplete, -}: { - migratorInfo: DefaultAssociatedTokenAccountInfo; - onLoadComplete: () => void; -}) { - const { t } = useTranslation(); - const classes = useStyles(); - const poolInfo = useSolanaMigratorInformation( - migratorInfo.fromMintKey, - migratorInfo.toMintKey, - migratorInfo.defaultFromTokenAccount - ); - - const [migrationIsProcessing, setMigrationIsProcessing] = useState(false); - const [transaction, setTransaction] = useState(""); - const [migrationError, setMigrationError] = useState(""); - - const handleMigrateClick = useCallback(() => { - if (!poolInfo.data) { - return; - } - setMigrationIsProcessing(true); - setMigrationError(""); - poolInfo.data - .migrateTokens(poolInfo.data.fromAssociatedTokenAccountBalance) - .then((result) => { - setMigrationIsProcessing(false); - setTransaction(result); - }) - .catch((e) => { - setMigrationError(t("Unable to perform migration.")); - setMigrationIsProcessing(false); - }); - }, [poolInfo.data, t]); - - const precheckError = - poolInfo.data && - poolInfo.data.getNotReadyCause( - poolInfo.data.fromAssociatedTokenAccountBalance - ); - - useEffect(() => { - if (poolInfo.data || poolInfo.error) { - onLoadComplete(); - } - }, [poolInfo, onLoadComplete]); - - if (!poolInfo.data) { - return ( -
-
- - {t("Failed to load migration information for token")} - - -
-
- ); - } else if (transaction) { - return ( -
-
- - {t("Successfully migrated your tokens. They will become available once this transaction confirms.")} - - -
-
- ); - } else { - return ( -
-
- - {t("Current Token")} - - - {poolInfo.data.fromAssociatedTokenAccountBalance} - - -
-
- - {t("will become")} - - -
-
- - {t("Wormhole Token")} - - - {poolInfo.data.fromAssociatedTokenAccountBalance} - - -
- {!poolInfo.data.toAssociatedTokenAccountExists ? ( -
- -
- ) : ( -
- - {t("Convert")} - -
- )} -
- ); - } -} - -type DefaultAssociatedTokenAccountInfo = { - fromMintKey: string; - toMintKey: string; - defaultFromTokenAccount: string; - fromAccountInfo: AccountInfo | null; -}; - -const getTokenBalances = async ( - walletAddress: string, - migrationMap: Map -): Promise => { - try { - const connection = new Connection(SOLANA_HOST); - const output: DefaultAssociatedTokenAccountInfo[] = []; - const tokenAccounts = await connection.getParsedTokenAccountsByOwner( - new PublicKey(walletAddress), - { programId: TOKEN_PROGRAM_ID }, - "confirmed" - ); - tokenAccounts.value.forEach((item) => { - if ( - item.account != null && - item.account.data?.parsed?.info?.tokenAmount?.uiAmountString && - item.account.data?.parsed.info?.tokenAmount?.amount !== "0" - ) { - const fromMintKey = item.account.data.parsed.info.mint; - const toMintKey = migrationMap.get(fromMintKey); - if (toMintKey) { - output.push({ - fromMintKey, - toMintKey: toMintKey, - defaultFromTokenAccount: item.pubkey.toString(), - fromAccountInfo: item.account, - }); - } - } - }); - - return output; - } catch (e) { - console.error(e); - return Promise.reject(i18n.t("Unable to retrieve token balances.")); - } -}; - -export default function SolanaQuickMigrate() { - const { t } = useTranslation(); - const chainId = CHAIN_ID_SOLANA; - const classes = useStyles(); - const { isReady, walletAddress } = useIsWalletReady(chainId); - const migrationMap = useMemo(() => getMigrationAssetMap(chainId), [chainId]); - const [migrators, setMigrators] = useState< - DefaultAssociatedTokenAccountInfo[] | null - >(null); - const [migratorsError, setMigratorsError] = useState(""); - const [migratorsLoading, setMigratorsLoading] = useState(false); - - //This is for a callback into the line items, so a loader can be displayed while - //they are loading - //TODO don't just swallow loading errors. - const [migratorsFinishedLoading, setMigratorsFinishedLoading] = useState(0); - const reportLoadComplete = useCallback(() => { - setMigratorsFinishedLoading((prevState) => prevState + 1); - }, []); - const isLoading = - migratorsLoading || - (migrators && - migrators.length && - migratorsFinishedLoading < migrators.length); - - useEffect(() => { - if (isReady && walletAddress) { - let cancelled = false; - setMigratorsLoading(true); - setMigratorsError(""); - getTokenBalances(walletAddress, migrationMap).then( - (result) => { - if (!cancelled) { - setMigratorsFinishedLoading(0); - setMigrators(result.filter((x) => x.fromAccountInfo && x)); - setMigratorsLoading(false); - } - }, - (error) => { - if (!cancelled) { - setMigratorsLoading(false); - setMigratorsError( - t("Failed to retrieve available token information.") - ); - } - } - ); - - return () => { - cancelled = true; - }; - } - }, [isReady, walletAddress, migrationMap, t]); - - const hasEligibleAssets = migrators && migrators.length > 0; - const chainName = CHAINS_BY_ID[chainId]?.name; - - const content = ( -
- - {chainName ? - t('This page allows you to convert certain wrapped tokens on {{ chainName }} into Wormhole V2 tokens.', { chainName }) : - t('This page allows you to convert certain wrapped tokens into Wormhole V2 tokens.') } - - - {!isReady ? ( - {t("Please connect your wallet.")} - ) : migratorsError ? ( - {migratorsError} - ) : ( - <> -
- -
- - {hasEligibleAssets - ? t("You have some assets that are eligible for migration! Click the 'Convert' button to swap them for Wormhole tokens.") - : t("You don't have any assets eligible for migration.")} - -
- {migrators?.map((info) => { - return ( - - ); - })} -
- - )} -
- ); - - return ( - - - {t("Migrate Assets")} - - {content} - - ); -} diff --git a/bridge_ui/src/components/Migration/SolanaWorkflow.tsx b/bridge_ui/src/components/Migration/SolanaWorkflow.tsx deleted file mode 100644 index 77befb73b..000000000 --- a/bridge_ui/src/components/Migration/SolanaWorkflow.tsx +++ /dev/null @@ -1,507 +0,0 @@ -import { CHAIN_ID_SOLANA } from "@alephium/wormhole-sdk"; -import migrateTokensTx from "@alephium/wormhole-sdk/lib/esm/migration/migrateTokens"; -import getPoolAddress from "@alephium/wormhole-sdk/lib/esm/migration/poolAddress"; -import getToCustodyAddress from "@alephium/wormhole-sdk/lib/esm/migration/toCustodyAddress"; -import { makeStyles, Typography } from "@material-ui/core"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - Token, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { Connection, PublicKey } from "@solana/web3.js"; -import { parseUnits } from "ethers/lib/utils"; -import { useCallback, useEffect, useMemo, useState } from "react"; -import { useSolanaWallet } from "../../contexts/SolanaWalletContext"; -import useIsWalletReady from "../../hooks/useIsWalletReady"; -import useMetaplexData from "../../hooks/useMetaplexData"; -import useSolanaTokenMap from "../../hooks/useSolanaTokenMap"; -import { COLORS } from "../../muiTheme"; -import { MIGRATION_PROGRAM_ADDRESS, SOLANA_HOST } from "../../utils/consts"; -import { getMultipleAccounts, signSendAndConfirm } from "../../utils/solana"; -import ButtonWithLoader from "../ButtonWithLoader"; -import NumberTextField from "../NumberTextField"; -import ShowTx from "../ShowTx"; -import SmartAddress from "../SmartAddress"; -import SolanaCreateAssociatedAddress, { - useAssociatedAccountExistsState, -} from "../SolanaCreateAssociatedAddress"; -import SolanaWalletKey from "../SolanaWalletKey"; - -const useStyles = makeStyles(() => ({ - mainPaper: { - backgroundColor: COLORS.whiteWithTransparency, - textAlign: "center", - padding: "2rem", - "& > h, p ": { - margin: ".5rem", - }, - }, - divider: { - margin: "2rem 0rem 2rem 0rem", - }, - spacer: { - height: "2rem", - }, -})); - -//TODO move to utils/solana -const getDecimals = async ( - connection: Connection, - mint: string, - setter: (decimals: number | undefined) => void -) => { - setter(undefined); - if (mint) { - try { - const pk = new PublicKey(mint); - const info = await connection.getParsedAccountInfo(pk); - // @ts-ignore - const decimals = info.value?.data.parsed.info.decimals; - setter(decimals); - } catch (e) { - console.log(`Unable to determine decimals of ${mint}`); - } - } -}; - -//TODO move to utils/solana -const getBalance = async ( - connection: Connection, - address: string | undefined, - setter: (balance: string | undefined) => void -) => { - setter(undefined); - if (address) { - try { - const pk = new PublicKey(address); - const info = await connection.getParsedAccountInfo(pk); - // @ts-ignore - const balance = info.value?.data.parsed.info.tokenAmount.uiAmountString; - setter(balance); - } catch (e) { - console.log(`Unable to determine balance of ${address}`); - } - } -}; - -export default function Workflow({ - fromMint, - toMint, - fromTokenAccount, -}: { - fromMint: string; - toMint: string; - fromTokenAccount: string; -}) { - const classes = useStyles(); - - const connection = useMemo( - () => new Connection(SOLANA_HOST, "confirmed"), - [] - ); - const wallet = useSolanaWallet(); - const { isReady } = useIsWalletReady(CHAIN_ID_SOLANA); - const solanaTokenMap = useSolanaTokenMap(); - const metaplexArray = useMemo(() => [fromMint, toMint], [fromMint, toMint]); - const metaplexData = useMetaplexData(metaplexArray); - - const [poolAddress, setPoolAddress] = useState(""); - const [poolExists, setPoolExists] = useState(undefined); - const [fromTokenAccountBalance, setFromTokenAccountBalance] = useState< - string | undefined - >(undefined); - const [toTokenAccount, setToTokenAccount] = useState( - undefined - ); - const [toTokenAccountBalance, setToTokenAccountBalance] = useState< - string | undefined - >(undefined); - const [fromMintDecimals, setFromMintDecimals] = useState( - undefined - ); - - const { - associatedAccountExists: fromTokenAccountExists, - //setAssociatedAccountExists: setFromTokenAccountExists, - } = useAssociatedAccountExistsState( - CHAIN_ID_SOLANA, - fromMint, - fromTokenAccount - ); - const { - associatedAccountExists: toTokenAccountExists, - setAssociatedAccountExists: setToTokenAccountExists, - } = useAssociatedAccountExistsState(CHAIN_ID_SOLANA, toMint, toTokenAccount); - - const [toCustodyAddress, setToCustodyAddress] = useState( - undefined - ); - const [toCustodyBalance, setToCustodyBalance] = useState( - undefined - ); - - const [migrationAmount, setMigrationAmount] = useState(""); - const [migrationIsProcessing, setMigrationIsProcessing] = useState(false); - const [error, setError] = useState(""); - const [transaction, setTransaction] = useState(null); - - /* Effects - */ - useEffect(() => { - getDecimals(connection, fromMint, setFromMintDecimals); - }, [connection, fromMint]); - - //Retrieve user balance when fromTokenAccount changes - useEffect(() => { - // TODO: cancellable - if (fromTokenAccount && fromTokenAccountExists) { - getBalance(connection, fromTokenAccount, setFromTokenAccountBalance); - } else { - setFromTokenAccountBalance(undefined); - } - }, [ - connection, - fromTokenAccountExists, - fromTokenAccount, - setFromTokenAccountBalance, - ]); - - useEffect(() => { - // TODO: cancellable - if (toTokenAccount && toTokenAccountExists) { - getBalance(connection, toTokenAccount, setToTokenAccountBalance); - } else { - setToTokenAccountBalance(undefined); - } - }, [ - connection, - toTokenAccountExists, - toTokenAccount, - setFromTokenAccountBalance, - ]); - - useEffect(() => { - // TODO: cancellable - if (toCustodyAddress) { - getBalance(connection, toCustodyAddress, setToCustodyBalance); - } else { - setToCustodyBalance(undefined); - } - }, [connection, toCustodyAddress, setToCustodyBalance]); - - //Retrieve pool address on selectedTokens change - useEffect(() => { - if (toMint && fromMint) { - setPoolAddress(""); - setPoolExists(undefined); - getPoolAddress(MIGRATION_PROGRAM_ADDRESS, fromMint, toMint).then( - (result) => { - const key = new PublicKey(result).toString(); - setPoolAddress(key); - }, - (error) => console.log("Could not calculate pool address.") - ); - } - }, [toMint, fromMint, setPoolAddress]); - - //Retrieve the poolAccount every time the pool address changes. - useEffect(() => { - if (poolAddress) { - setPoolExists(undefined); - try { - getMultipleAccounts( - connection, - [new PublicKey(poolAddress)], - "confirmed" - ).then((result) => { - if (result.length && result[0] !== null) { - setPoolExists(true); - } else if (result.length && result[0] === null) { - setPoolExists(false); - setError("There is no swap pool for this token."); - } else { - setError( - "unexpected error in fetching pool address. Please reload and try again" - ); - } - }); - } catch (e) { - setError("Could not fetch pool address"); - } - } - }, [connection, poolAddress]); - - //Set relevant information derived from poolAddress - useEffect(() => { - if (poolAddress) { - getToCustodyAddress(MIGRATION_PROGRAM_ADDRESS, poolAddress) - .then((result: any) => - setToCustodyAddress(new PublicKey(result).toString()) - ) - .catch((e) => { - setToCustodyAddress(undefined); - }); - } else { - setToCustodyAddress(undefined); - } - }, [poolAddress]); - - useEffect(() => { - if (wallet?.publicKey && toMint) { - Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, - new PublicKey(toMint), - wallet?.publicKey || new PublicKey([]) - ).then( - (result) => { - setToTokenAccount(result.toString()); - }, - (error) => {} - ); - } - }, [toMint, wallet?.publicKey]); - /* - End effects - */ - - const migrateTokens = useCallback(async () => { - try { - setError(""); - const instruction = await migrateTokensTx( - connection, - wallet?.publicKey?.toString() || "", - MIGRATION_PROGRAM_ADDRESS, - fromMint, - toMint, - fromTokenAccount || "", - toTokenAccount || "", - parseUnits(migrationAmount, fromMintDecimals).toBigInt() - ); - setMigrationIsProcessing(true); - signSendAndConfirm(wallet, connection, instruction).then( - (transaction: any) => { - setMigrationIsProcessing(false); - setTransaction(transaction); - }, - (error) => { - console.log(error); - setError("Could not complete the migrateTokens transaction."); - setMigrationIsProcessing(false); - } - ); - } catch (e) { - console.log(e); - setError("Could not complete the migrateTokens transaction."); - setMigrationIsProcessing(false); - } - }, [ - connection, - fromMint, - fromTokenAccount, - migrationAmount, - toMint, - toTokenAccount, - wallet, - fromMintDecimals, - ]); - - const fromParse = (amount: string) => { - try { - return parseUnits(amount, fromMintDecimals).toBigInt(); - } catch (e) { - return BigInt(0); - } - }; - - const hasRequisiteData = fromMint && toMint && poolAddress && poolExists; - const accountsReady = - fromTokenAccountExists && toTokenAccountExists && poolExists; - const amountGreaterThanZero = fromParse(migrationAmount) > BigInt(0); - const sufficientFromTokens = - fromTokenAccountBalance && - migrationAmount && - fromParse(migrationAmount) <= fromParse(fromTokenAccountBalance); - const sufficientPoolBalance = - toCustodyBalance && - migrationAmount && - parseFloat(migrationAmount) <= parseFloat(toCustodyBalance); - - const isReadyToTransfer = - isReady && - amountGreaterThanZero && - sufficientFromTokens && - sufficientPoolBalance && - accountsReady && - hasRequisiteData; - - const getNotReadyCause = () => { - if (!fromMint || !toMint || !poolAddress || !poolExists) { - return "This asset is not supported."; - } else if (!isReady) { - return "Wallet is not connected."; - } else if (!toTokenAccountExists || !fromTokenAccountExists) { - return "You have not created the necessary token accounts."; - } else if (!migrationAmount) { - return "Enter an amount to transfer."; - } else if (!amountGreaterThanZero) { - return "Enter an amount greater than zero."; - } else if (!sufficientFromTokens) { - return "There are not sufficient funds in your wallet for this transfer."; - } else if (!sufficientPoolBalance) { - return "There are not sufficient funds in the pool for this transfer."; - } else { - return ""; - } - }; - - const handleAmountChange = useCallback( - (event: any) => setMigrationAmount(event.target.value), - [setMigrationAmount] - ); - const handleMaxClick = useCallback(() => { - if (fromTokenAccountBalance) { - setMigrationAmount(fromTokenAccountBalance); - } - }, [fromTokenAccountBalance]); - - const getMetadata = (address: string) => { - const tokenMapItem = solanaTokenMap.data?.find( - (x) => x.address === address - ); - const metaplexItem = metaplexData.data?.get(address); - - return { - symbol: tokenMapItem?.symbol || metaplexItem?.data?.symbol || undefined, - name: tokenMapItem?.name || metaplexItem?.data?.name || undefined, - logo: tokenMapItem?.logoURI || metaplexItem?.data?.uri || undefined, - }; - }; - - const toMetadata = getMetadata(toMint); - const fromMetadata = getMetadata(fromMint); - - const toMintPretty = ( - - ); - const fromMintPretty = ( - - ); - - return ( -
- -
- {fromTokenAccount && toTokenAccount ? ( - <> - - This will migrate - {fromMintPretty} - tokens in this account: - - - - {`(Balance: ${fromTokenAccountBalance}${ - fromMetadata.symbol && " " + fromMetadata.symbol - })`} - -
- - into - {toMintPretty} - tokens in this account: - - - - - {toTokenAccountExists - ? ` (Balance: ${toTokenAccountBalance}${ - (toMetadata.symbol && " " + toMetadata.symbol) || "" - })` - : " (Not created yet)"} - - - - {poolAddress && toCustodyAddress && toCustodyBalance ? ( - <> -
- - Using pool - - holding tokens in this account: - - - - {` (Balance: ${toCustodyBalance}${ - toMetadata.symbol && " " + toMetadata.symbol - })`} - - - ) : null} - - ) : null} -
- - - {!transaction && ( - - {migrationAmount && isReadyToTransfer - ? "Migrate " + migrationAmount + " Tokens" - : "Migrate"} - - )} - {(error || !isReadyToTransfer) && ( - {error || getNotReadyCause()} - )} - {transaction ? ( - <> - - Successfully migrated your tokens! They will be available once this - transaction confirms. - - - - ) : null} -
- ); -} diff --git a/bridge_ui/src/components/Migration/index.tsx b/bridge_ui/src/components/Migration/index.tsx deleted file mode 100644 index 1296df4ab..000000000 --- a/bridge_ui/src/components/Migration/index.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import { - ChainId, - CHAIN_ID_BSC, - CHAIN_ID_ETH, - CHAIN_ID_SOLANA, -} from "@alephium/wormhole-sdk"; -import { getAddress } from "@ethersproject/address"; -import { Container, makeStyles, Paper, Typography } from "@material-ui/core"; -import { PublicKey } from "@solana/web3.js"; -import { useTranslation } from "react-i18next"; -import { withRouter } from "react-router"; -import { RouteComponentProps } from "react-router-dom"; -import { COLORS } from "../../muiTheme"; -import { getMigrationAssetMap, MIGRATION_ASSET_MAP } from "../../utils/consts"; -import HeaderText from "../HeaderText"; -import EvmWorkflow from "./EvmWorkflow"; -import SolanaWorkflow from "./SolanaWorkflow"; - -const useStyles = makeStyles(() => ({ - mainPaper: { - backgroundColor: COLORS.whiteWithTransparency, - textAlign: "center", - padding: "2rem", - "& > h, p ": { - margin: ".5rem", - }, - }, - divider: { - margin: "2rem 0rem 2rem 0rem", - }, - spacer: { - height: "2rem", - }, -})); - -interface RouteParams { - legacyAsset: string; - fromTokenAccount: string; -} - -interface Migration extends RouteComponentProps { - chainId: ChainId; -} - -const SolanaRoot: React.FC = (props) => { - const { t } = useTranslation(); - const legacyAsset: string = props.match.params.legacyAsset; - const fromTokenAccount: string = props.match.params.fromTokenAccount; - const targetAsset: string | undefined = MIGRATION_ASSET_MAP.get(legacyAsset); - - let fromMint: string | undefined = ""; - let toMint: string | undefined = ""; - let fromTokenAcct: string | undefined = ""; - try { - fromMint = legacyAsset && new PublicKey(legacyAsset).toString(); - toMint = targetAsset && new PublicKey(targetAsset).toString(); - fromTokenAcct = - fromTokenAccount && new PublicKey(fromTokenAccount).toString(); - } catch (e) {} - - let content = null; - - if (!fromMint || !toMint) { - content = ( - - {t("This asset is not eligible for migration.")} - - ); - } else if (!fromTokenAcct) { - content = ( - - {t("Invalid token account.")} - - ); - } else { - content = ( - - ); - } - - return content; -}; - -const EthereumRoot: React.FC = (props) => { - const { t } = useTranslation(); - const legacyAsset: string = props.match.params.legacyAsset; - const assetMap = getMigrationAssetMap(props.chainId); - const targetPool = assetMap.get(getAddress(legacyAsset)); - - let content = null; - if (!legacyAsset || !targetPool) { - content = ( - - {t("This asset is not eligible for migration.")} - - ); - } else { - content = ( - - ); - } - - return content; -}; - -const MigrationRoot: React.FC = (props) => { - const { t } = useTranslation(); - const classes = useStyles(); - let content = null; - - if (props.chainId === CHAIN_ID_SOLANA) { - content = ; - } else if (props.chainId === CHAIN_ID_ETH || props.chainId === CHAIN_ID_BSC) { - content = ; - } - - return ( - - - {t("Migrate Assets")} - - {content} - - ); -}; - -export default withRouter(MigrationRoot); diff --git a/bridge_ui/src/components/NFT/Redeem.tsx b/bridge_ui/src/components/NFT/Redeem.tsx index 7c585825b..e000b4e0f 100644 --- a/bridge_ui/src/components/NFT/Redeem.tsx +++ b/bridge_ui/src/components/NFT/Redeem.tsx @@ -1,4 +1,4 @@ -import { CHAIN_ID_SOLANA, CHAIN_ID_TERRA } from "@alephium/wormhole-sdk"; +import { CHAIN_ID_SOLANA } from "@alephium/wormhole-sdk"; import { useSelector } from "react-redux"; import { useHandleNFTRedeem } from "../../hooks/useHandleNFTRedeem"; import useIsWalletReady from "../../hooks/useIsWalletReady"; @@ -8,7 +8,6 @@ import ButtonWithLoader from "../ButtonWithLoader"; import KeyAndBalance from "../KeyAndBalance"; import SolanaTPSWarning from "../SolanaTPSWarning"; import StepDescription from "../StepDescription"; -import TerraFeeDenomPicker from "../TerraFeeDenomPicker"; import WaitingForWalletMessage from "./WaitingForWalletMessage"; function Redeem() { @@ -19,9 +18,6 @@ function Redeem() { <> Receive the NFT on the target chain - {targetChain === CHAIN_ID_TERRA && ( - - )} {targetChain === CHAIN_ID_SOLANA && CLUSTER === "mainnet" && ( )} diff --git a/bridge_ui/src/components/NFT/Send.tsx b/bridge_ui/src/components/NFT/Send.tsx index 685533175..123129790 100644 --- a/bridge_ui/src/components/NFT/Send.tsx +++ b/bridge_ui/src/components/NFT/Send.tsx @@ -16,7 +16,6 @@ import KeyAndBalance from "../KeyAndBalance"; import ShowTx from "../ShowTx"; import SolanaTPSWarning from "../SolanaTPSWarning"; import StepDescription from "../StepDescription"; -import TerraFeeDenomPicker from "../TerraFeeDenomPicker"; import TransactionProgress from "../TransactionProgress"; import WaitingForWalletMessage from "./WaitingForWalletMessage"; @@ -44,9 +43,6 @@ function Send() { Transfer the NFT to the Wormhole Token Bridge. - {sourceChain === CHAIN_ID_TERRA && ( - - )} This will initiate the transfer on {CHAINS_BY_ID[sourceChain].name} and wait for finalization. If you navigate away from this page before diff --git a/bridge_ui/src/components/NFTOriginVerifier.tsx b/bridge_ui/src/components/NFTOriginVerifier.tsx index 773841243..b4a3a774d 100644 --- a/bridge_ui/src/components/NFTOriginVerifier.tsx +++ b/bridge_ui/src/components/NFTOriginVerifier.tsx @@ -12,11 +12,7 @@ import { isEVMChain, uint8ArrayToHex, } from "@alephium/wormhole-sdk"; -import { - getOriginalAssetEth, - getOriginalAssetSol, - WormholeWrappedNFTInfo, -} from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; +import { getOriginalAssetEth, WormholeWrappedNFTInfo } from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; import { Button, Card, @@ -29,21 +25,17 @@ import { } from "@material-ui/core"; import { Launch } from "@material-ui/icons"; import { Alert } from "@material-ui/lab"; -import { Connection } from "@solana/web3.js"; import { useCallback, useEffect, useState } from "react"; import { useBetaContext } from "../contexts/BetaContext"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; import useIsWalletReady from "../hooks/useIsWalletReady"; -import { getMetaplexData } from "../hooks/useMetaplexData"; import { COLORS } from "../muiTheme"; import { NFTParsedTokenAccount } from "../store/nftSlice"; import { BETA_CHAINS, CHAINS_BY_ID, CHAINS_WITH_NFT_SUPPORT, - getNFTBridgeAddressForChain, - SOLANA_HOST, - SOL_NFT_BRIDGE_ADDRESS, + getNFTBridgeAddressForChain } from "../utils/consts"; import { ethNFTToNFTParsedTokenAccount, @@ -156,45 +148,6 @@ export default function NFTOriginVerifier() { } else { setLookupError("Invalid address"); } - } else if (lookupChain === CHAIN_ID_SOLANA && lookupAsset) { - (async () => { - try { - setIsLoading(true); - const [metadata] = await getMetaplexData([lookupAsset]); - if (metadata) { - const connection = new Connection(SOLANA_HOST, "confirmed"); - const info = await getOriginalAssetSol( - connection, - SOL_NFT_BRIDGE_ADDRESS, - lookupAsset - ); - if (!cancelled) { - setIsLoading(false); - setParsedTokenAccount({ - amount: "0", - decimals: 0, - mintKey: lookupAsset, - publicKey: "", - uiAmount: 0, - uiAmountString: "0", - uri: metadata.data.uri, - }); - setOriginInfo(info); - } - } else { - if (!cancelled) { - setIsLoading(false); - setLookupError("Error fetching metadata"); - } - } - } catch (e) { - console.error(e); - if (!cancelled) { - setIsLoading(false); - setLookupError("Invalid token"); - } - } - })(); } return () => { cancelled = true; diff --git a/bridge_ui/src/components/Recovery.tsx b/bridge_ui/src/components/Recovery.tsx index 166a8ae7b..2a8bb48f8 100644 --- a/bridge_ui/src/components/Recovery.tsx +++ b/bridge_ui/src/components/Recovery.tsx @@ -2,25 +2,15 @@ import { ChainId, CHAIN_ID_ALEPHIUM, CHAIN_ID_ACALA, - CHAIN_ID_ALGORAND, CHAIN_ID_KARURA, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, - getEmitterAddressAlgorand, getEmitterAddressEth, - getEmitterAddressSolana, - getEmitterAddressTerra, hexToNativeAssetString, hexToNativeString, hexToUint8Array, isEVMChain, - parseSequenceFromLogAlgorand, parseSequenceFromLogEth, - parseSequenceFromLogSolana, - parseSequenceFromLogTerra, uint8ArrayToHex, parseTargetChainFromLogEth, - CHAIN_ID_UNSET, TransferToken, TransferNFT, deserializeTransferTokenVAA, @@ -41,9 +31,6 @@ import { } from "@material-ui/core"; import { ExpandMore } from "@material-ui/icons"; import { Alert } from "@material-ui/lab"; -import { Connection } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import algosdk from "algosdk"; import axios from "axios"; import { ethers } from "ethers"; import { useSnackbar } from "notistack"; @@ -61,8 +48,6 @@ import { getAlphTxInfoByTxId } from "../utils/alephium"; import { ALEPHIUM_MINIMAL_CONSISTENCY_LEVEL, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, CHAINS, CHAINS_BY_ID, CHAINS_WITH_NFT_SUPPORT, @@ -70,11 +55,6 @@ import { getNFTBridgeAddressForChain, getTokenBridgeAddressForChain, RELAY_URL_EXTENSION, - SOLANA_HOST, - SOL_NFT_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_HOST, - TERRA_TOKEN_BRIDGE_ADDRESS, WORMHOLE_RPC_HOSTS } from "../utils/consts"; import { getSignedVAAWithRetry } from "../utils/getSignedVAAWithRetry"; @@ -106,52 +86,6 @@ const useStyles = makeStyles((theme) => ({ }, })); -async function algo(tx: string, enqueueSnackbar: any) { - try { - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - const pendingInfo = await algodClient - .pendingTransactionInformation(tx) - .do(); - let confirmedTxInfo: Record | undefined = undefined; - // This is the code from waitForConfirmation - if (pendingInfo !== undefined) { - if ( - pendingInfo["confirmed-round"] !== null && - pendingInfo["confirmed-round"] > 0 - ) { - //Got the completed Transaction - confirmedTxInfo = pendingInfo; - } - } - if (!confirmedTxInfo) { - throw new Error(i18n.t("Transaction not found or not confirmed")); - } - const sequence = parseSequenceFromLogAlgorand(confirmedTxInfo); - if (!sequence) { - throw new Error(i18n.t("Sequence not found")); - } - const emitterAddress = getEmitterAddressAlgorand(ALGORAND_TOKEN_BRIDGE_ID); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_ALGORAND, - emitterAddress, - CHAIN_ID_UNSET, - sequence, - WORMHOLE_RPC_HOSTS.length - ); - return { vaa: uint8ArrayToHex(vaaBytes), error: null }; - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - return { vaa: null, error: parseError(e) }; - } -} - async function evm( provider: ethers.providers.Web3Provider, tx: string, @@ -195,62 +129,6 @@ async function evm( } } -async function solana(tx: string, enqueueSnackbar: any, nft: boolean) { - try { - const connection = new Connection(SOLANA_HOST, "confirmed"); - const info = await connection.getTransaction(tx); - if (!info) { - throw new Error(i18n.t("An error occurred while fetching the transaction info")); - } - const sequence = parseSequenceFromLogSolana(info); - const emitterAddress = await getEmitterAddressSolana( - nft ? SOL_NFT_BRIDGE_ADDRESS : SOL_TOKEN_BRIDGE_ADDRESS - ); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_SOLANA, - emitterAddress, - CHAIN_ID_UNSET, - sequence.toString(), - WORMHOLE_RPC_HOSTS.length - ); - return { vaa: uint8ArrayToHex(vaaBytes), error: null }; - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - return { vaa: null, error: parseError(e) }; - } -} - -async function terra(tx: string, enqueueSnackbar: any) { - try { - const lcd = new LCDClient(TERRA_HOST); - const info = await lcd.tx.txInfo(tx); - const sequence = parseSequenceFromLogTerra(info); - if (!sequence) { - throw new Error(i18n.t("Sequence not found")); - } - const emitterAddress = await getEmitterAddressTerra( - TERRA_TOKEN_BRIDGE_ADDRESS - ); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_TERRA, - emitterAddress, - CHAIN_ID_UNSET, - sequence, - WORMHOLE_RPC_HOSTS.length - ); - return { vaa: uint8ArrayToHex(vaaBytes), error: null }; - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - return { vaa: null, error: parseError(e) }; - } -} - async function alephium(wallet: Wallet, txId: string, enqueueSnackbar: any) { try { if (wallet.nodeProvider === undefined) { @@ -501,40 +379,6 @@ export default function Recovery() { } } })(); - } else if (recoverySourceChain === CHAIN_ID_SOLANA) { - setRecoverySourceTxError(""); - setRecoverySourceTxIsLoading(true); - (async () => { - const { vaa, error } = await solana( - recoverySourceTx, - enqueueSnackbar, - isNFT - ); - if (!cancelled) { - setRecoverySourceTxIsLoading(false); - if (vaa) { - setRecoverySignedVAA(vaa); - } - if (error) { - setRecoverySourceTxError(error); - } - } - })(); - } else if (recoverySourceChain === CHAIN_ID_TERRA) { - setRecoverySourceTxError(""); - setRecoverySourceTxIsLoading(true); - (async () => { - const { vaa, error } = await terra(recoverySourceTx, enqueueSnackbar); - if (!cancelled) { - setRecoverySourceTxIsLoading(false); - if (vaa) { - setRecoverySignedVAA(vaa); - } - if (error) { - setRecoverySourceTxError(error); - } - } - })(); } else if (recoverySourceChain === CHAIN_ID_ALEPHIUM && isReady) { setRecoverySourceTxError(""); setRecoverySourceTxIsLoading(true); @@ -550,21 +394,6 @@ export default function Recovery() { } } })(alphWallet.nodeProvider); - } else if (recoverySourceChain === CHAIN_ID_ALGORAND) { - setRecoverySourceTxError(""); - setRecoverySourceTxIsLoading(true); - (async () => { - const { vaa, error } = await algo(recoverySourceTx, enqueueSnackbar); - if (!cancelled) { - setRecoverySourceTxIsLoading(false); - if (vaa) { - setRecoverySignedVAA(vaa); - } - if (error) { - setRecoverySourceTxError(error); - } - } - })(); } return () => { cancelled = true; diff --git a/bridge_ui/src/components/SmartAddress.tsx b/bridge_ui/src/components/SmartAddress.tsx index 84d9fbeb7..48efb7f54 100644 --- a/bridge_ui/src/components/SmartAddress.tsx +++ b/bridge_ui/src/components/SmartAddress.tsx @@ -14,7 +14,6 @@ import { CHAIN_ID_POLYGON, CHAIN_ID_SOLANA, CHAIN_ID_TERRA, - isNativeDenom, CHAIN_ID_ACALA, CHAIN_ID_ALEPHIUM, } from "@alephium/wormhole-sdk"; @@ -27,7 +26,6 @@ import useCopyToClipboard from "../hooks/useCopyToClipboard"; import { ParsedTokenAccount } from "../store/transferSlice"; import { CLUSTER, WETH_ADDRESS, getExplorerName } from "../utils/consts"; import { shortenAddress } from "../utils/solana"; -import { formatNativeDenom } from "../utils/terra"; import { addressFromContractId, ALPH_TOKEN_ID, isBase58 } from "@alephium/web3"; import { useTranslation } from "react-i18next"; @@ -92,16 +90,13 @@ export default function SmartAddress({ const { t } = useTranslation(); const classes = useStyles(); const isNativeETH = chainId === CHAIN_ID_ETH && address?.toLowerCase() === WETH_ADDRESS.toLowerCase() - const isNativeTerra = chainId === CHAIN_ID_TERRA && isNativeDenom(address); const isNativeALPH = chainId === CHAIN_ID_ALEPHIUM && address === ALPH_TOKEN_ID const useableAddress = parsedTokenAccount?.mintKey || address || ""; - const useableSymbol = isNativeTerra - ? formatNativeDenom(address) - : isNativeETH + const useableSymbol = isNativeETH ? 'ETH' : parsedTokenAccount?.symbol || symbol || ""; // const useableLogo = logo || isNativeTerra ? getNativeTerraIcon(useableSymbol) : null - const isNative = parsedTokenAccount?.isNativeAsset || isNativeETH || isNativeTerra || isNativeALPH || false; + const isNative = parsedTokenAccount?.isNativeAsset || isNativeETH || isNativeALPH || false; const addressShort = shortenAddress(useableAddress) || ""; const useableName = isNative diff --git a/bridge_ui/src/components/SolanaCreateAssociatedAddress.tsx b/bridge_ui/src/components/SolanaCreateAssociatedAddress.tsx index 01c43d7b2..70e927f36 100644 --- a/bridge_ui/src/components/SolanaCreateAssociatedAddress.tsx +++ b/bridge_ui/src/components/SolanaCreateAssociatedAddress.tsx @@ -1,10 +1,8 @@ import { ChainId, CHAIN_ID_SOLANA, - getForeignAssetSolana, hexToNativeAssetString, hexToNativeString, - hexToUint8Array, } from "@alephium/wormhole-sdk"; import { Button, Typography } from "@material-ui/core"; import { Alert } from "@material-ui/lab"; @@ -23,7 +21,7 @@ import { selectTransferOriginChain, selectTransferTargetAddressHex, } from "../store/selectors"; -import { SOLANA_HOST, SOL_TOKEN_BRIDGE_ADDRESS } from "../utils/consts"; +import { SOLANA_HOST } from "../utils/consts"; import parseError from "../utils/parseError"; import { signSendAndConfirm } from "../utils/solana"; import ButtonWithLoader from "./ButtonWithLoader"; @@ -183,27 +181,11 @@ export function SolanaCreateAssociatedAddressAlternate() { const [targetAsset, setTargetAsset] = useState(null); useEffect(() => { - let cancelled = false; if (!(originChain && originAsset && addressHex && base58TargetAddress)) { setTargetAsset(null); } else if (originChain === CHAIN_ID_SOLANA && base58OriginAddress) { setTargetAsset(base58OriginAddress); - } else { - getForeignAssetSolana( - connection, - SOL_TOKEN_BRIDGE_ADDRESS, - originChain, - hexToUint8Array(originAsset) - ).then((result) => { - if (!cancelled) { - setTargetAsset(result); - } - }); } - - return () => { - cancelled = true; - }; }, [ originChain, originAsset, diff --git a/bridge_ui/src/components/TerraFeeDenomPicker.tsx b/bridge_ui/src/components/TerraFeeDenomPicker.tsx deleted file mode 100644 index 820bdd26d..000000000 --- a/bridge_ui/src/components/TerraFeeDenomPicker.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import { - MenuItem, - makeStyles, - TextField, - Typography, - ListItemIcon, -} from "@material-ui/core"; -import { useConnectedWallet } from "@terra-money/wallet-provider"; -import { useMemo } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { setTerraFeeDenom } from "../store/feeSlice"; -import { selectTerraFeeDenom } from "../store/selectors"; -import useTerraNativeBalances from "../hooks/useTerraNativeBalances"; -import { formatNativeDenom, getNativeTerraIcon } from "../utils/terra"; - -const useStyles = makeStyles((theme) => ({ - feePickerContainer: { - display: "flex", - flexDirection: "column", - margin: `${theme.spacing(1)}px auto`, - maxWidth: 200, - width: "100%", - }, - select: { - "& .MuiSelect-root": { - display: "flex", - alignItems: "center", - }, - }, - listItemIcon: { - minWidth: 40, - }, - icon: { - height: 24, - maxWidth: 24, - }, -})); - -type TerraFeeDenomPickerProps = { - disabled: boolean; -}; - -export default function TerraFeeDenomPicker(props: TerraFeeDenomPickerProps) { - const terraFeeDenom = useSelector(selectTerraFeeDenom); - const wallet = useConnectedWallet(); - const { balances } = useTerraNativeBalances(wallet?.walletAddress); - const dispatch = useDispatch(); - const classes = useStyles(); - - const feeDenomItems = useMemo(() => { - const items = []; - if (balances) { - for (const [denom, amount] of Object.entries(balances)) { - if (amount === "0") continue; - const symbol = formatNativeDenom(denom); - if (symbol) { - items.push({ - denom, - symbol, - icon: getNativeTerraIcon(symbol), - }); - } - } - } - // prevent an out-of-range value from being selected - if (!items.find((item) => item.denom === terraFeeDenom)) { - const symbol = formatNativeDenom(terraFeeDenom); - items.push({ - denom: terraFeeDenom, - symbol, - icon: getNativeTerraIcon(symbol), - }); - } - return items; - }, [balances, terraFeeDenom]); - - return ( -
- Fee Denomination - dispatch(setTerraFeeDenom(event.target.value))} - disabled={props.disabled} - className={classes.select} - > - {feeDenomItems.map((item) => { - return ( - - - {item.symbol} - - {item.symbol} - - ); - })} - -
- ); -} diff --git a/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx b/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx index 7434182b0..49906ae48 100644 --- a/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx +++ b/bridge_ui/src/components/TokenSelectors/SourceTokenSelector.tsx @@ -32,7 +32,6 @@ import AlgoTokenPicker from "./AlgoTokenPicker"; import EvmTokenPicker from "./EvmTokenPicker"; import RefreshButtonWrapper from "./RefreshButtonWrapper"; import SolanaTokenPicker from "./SolanaTokenPicker"; -import TerraTokenPicker from "./TerraTokenPicker"; type TokenSelectorProps = { disabled: boolean; @@ -112,14 +111,6 @@ export const TokenSelector = (props: TokenSelectorProps) => { chainId={lookupChain} nft={nft} /> - ) : lookupChain === CHAIN_ID_TERRA ? ( - ) : lookupChain === CHAIN_ID_ALEPHIUM ? ( void; - tokenAccounts: DataWrapper | undefined; - disabled: boolean; - resetAccounts: (() => void) | undefined; -}; - -const returnsFalse = () => false; - -export default function TerraTokenPicker(props: TerraTokenPickerProps) { - const { value, onChange, disabled } = props; - const { walletAddress } = useIsWalletReady(CHAIN_ID_TERRA); - const nativeRefresh = useRef<() => void>(() => {}); - const { balances, isLoading: nativeIsLoading } = useTerraNativeBalances( - walletAddress, - nativeRefresh - ); - - const resetAccountWrapper = useCallback(() => { - //we can currently skip calling this as we don't read from sourceParsedTokenAccounts - //resetAccounts && resetAccounts(); - nativeRefresh.current(); - }, []); - const isLoading = nativeIsLoading; // || (tokenMap?.isFetching || false); - - const onChangeWrapper = useCallback( - async (account: NFTParsedTokenAccount | null) => { - if (account === null) { - onChange(null); - return Promise.resolve(); - } - onChange(account); - return Promise.resolve(); - }, - [onChange] - ); - - const terraTokenArray = useMemo(() => { - const balancesItems = - balances && walletAddress - ? Object.keys(balances).map((denom) => - // ({ - // protocol: "native", - // symbol: formatNativeDenom(denom), - // token: denom, - // icon: getNativeTerraIcon(formatNativeDenom(denom)), - // balance: balances[denom], - // } as TerraTokenMetadata) - - //TODO support non-natives in the SUPPORTED_TERRA_TOKENS - //This token account makes a lot of assumptions - createParsedTokenAccount( - walletAddress, - denom, - balances[denom], //amount - NATIVE_TERRA_DECIMALS, //TODO actually get decimals rather than hardcode - 0, //uiAmount is unused - formatUnits(balances[denom], NATIVE_TERRA_DECIMALS), //uiAmountString - formatNativeDenom(denom), // symbol - undefined, //name - getNativeTerraIcon(formatNativeDenom(denom)), //logo - true //is native asset - ) - ) - : []; - return balancesItems.filter((metadata) => - SUPPORTED_TERRA_TOKENS.includes(metadata.mintKey) - ); - // const values = tokenMap.data?.mainnet; - // const tokenMapItems = Object.values(values || {}) || []; - // return [...balancesItems, ...tokenMapItems]; - }, [ - walletAddress, - balances, - // tokenMap - ]); - - //TODO this only supports non-native assets. Native assets come from the hook. - //TODO correlate against token list to get metadata - const lookupTerraAddress = useCallback( - (lookupAsset: string) => { - if (!walletAddress) { - return Promise.reject("Wallet not connected"); - } - const lcd = new LCDClient(TERRA_HOST); - return lcd.wasm - .contractQuery(lookupAsset, { - token_info: {}, - }) - .then((info: any) => - lcd.wasm - .contractQuery(lookupAsset, { - balance: { - address: walletAddress, - }, - }) - .then((balance: any) => { - if (balance && info) { - return createParsedTokenAccount( - walletAddress, - lookupAsset, - balance.balance.toString(), - info.decimals, - Number(formatUnits(balance.balance, info.decimals)), - formatUnits(balance.balance, info.decimals), - info.symbol, - info.name - ); - } else { - throw new Error("Failed to retrieve Terra account."); - } - }) - ) - .catch(() => { - return Promise.reject(); - }); - }, - [walletAddress] - ); - - const isSearchableAddress = useCallback((address: string) => { - return isValidTerraAddress(address) && !isNativeDenom(address); - }, []); - - const RenderComp = useCallback( - ({ account }: { account: NFTParsedTokenAccount }) => { - return BasicAccountRender(account, returnsFalse, false); - }, - [] - ); - - return ( - - ); -} diff --git a/bridge_ui/src/components/Transfer/Redeem.tsx b/bridge_ui/src/components/Transfer/Redeem.tsx index e4193cc36..8633b41cb 100644 --- a/bridge_ui/src/components/Transfer/Redeem.tsx +++ b/bridge_ui/src/components/Transfer/Redeem.tsx @@ -13,7 +13,6 @@ import { CHAIN_ID_OASIS, CHAIN_ID_POLYGON, CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, isEVMChain, WSOL_ADDRESS, } from "@alephium/wormhole-sdk"; @@ -61,7 +60,6 @@ import SmartAddress from "../SmartAddress"; import { SolanaCreateAssociatedAddressAlternate } from "../SolanaCreateAssociatedAddress"; import SolanaTPSWarning from "../SolanaTPSWarning"; import StepDescription from "../StepDescription"; -import TerraFeeDenomPicker from "../TerraFeeDenomPicker"; import AddToMetamask from "./AddToMetamask"; import RedeemPreview from "./RedeemPreview"; import WaitingForWalletMessage from "./WaitingForWalletMessage"; @@ -253,9 +251,6 @@ function Redeem() { const nonRelayContent = ( <> - {targetChain === CHAIN_ID_TERRA && ( - - )} {isNativeEligible && ( - {sourceChain === CHAIN_ID_TERRA && ( - - )} {t("This will initiate the transfer on {{ chainName }} and wait for finalization. If you navigate away from this page before completing Step 4, you will have to perform the recovery workflow to complete the transfer.", { chainName: CHAINS_BY_ID[sourceChain].name })} diff --git a/bridge_ui/src/components/WithdrawTokensTerra.tsx b/bridge_ui/src/components/WithdrawTokensTerra.tsx deleted file mode 100644 index c4637ce84..000000000 --- a/bridge_ui/src/components/WithdrawTokensTerra.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { useCallback, useState } from "react"; -import { MsgExecuteContract } from "@terra-money/terra.js"; -import { - ConnectedWallet, - useConnectedWallet, -} from "@terra-money/wallet-provider"; -import { - SUPPORTED_TERRA_TOKENS, - TERRA_TOKEN_BRIDGE_ADDRESS, -} from "../utils/consts"; -import TerraWalletKey from "./TerraWalletKey"; -import { - Container, - FormControl, - InputLabel, - makeStyles, - MenuItem, - Paper, - Select, - Typography, -} from "@material-ui/core"; -import { postWithFees, waitForTerraExecution } from "../utils/terra"; -import ButtonWithLoader from "./ButtonWithLoader"; -import { useSnackbar } from "notistack"; -import { Alert } from "@material-ui/lab"; -import { useSelector } from "react-redux"; -import { selectTerraFeeDenom } from "../store/selectors"; -import TerraFeeDenomPicker from "./TerraFeeDenomPicker"; -import HeaderText from "./HeaderText"; -import { COLORS } from "../muiTheme"; - -const useStyles = makeStyles((theme) => ({ - formControl: { - display: "flex", - margin: `${theme.spacing(1)}px auto`, - width: "100%", - maxWidth: 400, - textAlign: "center", - }, - mainPaper: { - backgroundColor: COLORS.whiteWithTransparency, - textAlign: "center", - padding: "2rem", - "& > h, p ": { - margin: ".5rem", - }, - }, -})); - -const withdraw = async ( - wallet: ConnectedWallet, - token: string, - feeDenom: string -) => { - const withdraw = new MsgExecuteContract( - wallet.walletAddress, - TERRA_TOKEN_BRIDGE_ADDRESS, - { - withdraw_tokens: { - asset: { - native_token: { - denom: token, - }, - }, - }, - }, - {} - ); - const txResult = await postWithFees( - wallet, - [withdraw], - "Wormhole - Withdraw Tokens", - [feeDenom] - ); - await waitForTerraExecution(txResult); -}; - -export default function WithdrawTokensTerra() { - const wallet = useConnectedWallet(); - const [token, setToken] = useState(SUPPORTED_TERRA_TOKENS[0]); - const [isLoading, setIsLoading] = useState(false); - const classes = useStyles(); - const { enqueueSnackbar } = useSnackbar(); - const feeDenom = useSelector(selectTerraFeeDenom); - - const handleClick = useCallback(() => { - if (wallet) { - (async () => { - setIsLoading(true); - try { - await withdraw(wallet, token, feeDenom); - enqueueSnackbar(null, { - content: Transaction confirmed., - }); - } catch (e) { - enqueueSnackbar(null, { - content: Error withdrawing tokens., - }); - console.error(e); - } - setIsLoading(false); - })(); - } - }, [wallet, token, enqueueSnackbar, feeDenom]); - - return ( - - Withdraw Tokens - - - Withdraw tokens from the Terra token bridge - - - - Token - - - - Withdraw - - - - - ); -} diff --git a/bridge_ui/src/hooks/useCheckIfWormholeWrapped.ts b/bridge_ui/src/hooks/useCheckIfWormholeWrapped.ts index 5085302d7..7e5646c20 100644 --- a/bridge_ui/src/hooks/useCheckIfWormholeWrapped.ts +++ b/bridge_ui/src/hooks/useCheckIfWormholeWrapped.ts @@ -1,13 +1,7 @@ import { ChainId, CHAIN_ID_ALEPHIUM, - CHAIN_ID_ALGORAND, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, - getOriginalAssetAlgorand, getOriginalAssetEth, - getOriginalAssetSol, - getOriginalAssetTerra, isEVMChain, uint8ArrayToHex, WormholeWrappedInfo, @@ -15,10 +9,7 @@ import { } from "@alephium/wormhole-sdk"; import { getOriginalAssetEth as getOriginalAssetEthNFT, - getOriginalAssetSol as getOriginalAssetSolNFT, } from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; -import { Connection } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; import { useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; @@ -34,18 +25,11 @@ import { } from "../store/selectors"; import { setSourceWormholeWrappedInfo as setTransferSourceWormholeWrappedInfo } from "../store/transferSlice"; import { - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getNFTBridgeAddressForChain, - getTokenBridgeAddressForChain, - SOLANA_HOST, - SOL_NFT_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_HOST, + getTokenBridgeAddressForChain } from "../utils/consts"; import { NodeProvider } from '@alephium/web3' import { getAlephiumTokenWrappedInfo } from "../utils/alephium"; -import { Algodv2 } from "algosdk"; import { errorDataWrapper, fetchDataWrapper, receiveDataWrapper } from "../store/helpers"; import { useWallet } from "@alephium/web3-react"; import { useTranslation } from "react-i18next"; @@ -148,48 +132,6 @@ function useCheckIfWormholeWrapped(nft?: boolean) { } } } - if (sourceChain === CHAIN_ID_SOLANA && sourceAsset) { - try { - dispatch(setSourceWormholeWrappedInfo(fetchDataWrapper())); - const connection = new Connection(SOLANA_HOST, "confirmed"); - const wrappedInfo = makeStateSafe( - await (nft - ? getOriginalAssetSolNFT( - connection, - SOL_NFT_BRIDGE_ADDRESS, - sourceAsset - ) - : getOriginalAssetSol( - connection, - SOL_TOKEN_BRIDGE_ADDRESS, - sourceAsset - )) - ); - if (!cancelled) { - dispatch(setSourceWormholeWrappedInfo(receiveDataWrapper(wrappedInfo))); - } - } catch (e) { - if (!cancelled) { - dispatch(setSourceWormholeWrappedInfo(errorDataWrapper(`${t('Failed to get source asset info from solana')}, ${t('Error')}: ${e}`))); - } - } - } - if (sourceChain === CHAIN_ID_TERRA && sourceAsset) { - try { - dispatch(setSourceWormholeWrappedInfo(fetchDataWrapper())); - const lcd = new LCDClient(TERRA_HOST); - const wrappedInfo = makeStateSafe( - await getOriginalAssetTerra(lcd, sourceAsset) - ); - if (!cancelled) { - dispatch(setSourceWormholeWrappedInfo(receiveDataWrapper(wrappedInfo))); - } - } catch (e) { - if (!cancelled) { - dispatch(setSourceWormholeWrappedInfo(errorDataWrapper(`${t('Failed to get source asset info from terra')}, ${t('Error')}: ${e}`))); - } - } - } if (sourceChain === CHAIN_ID_ALEPHIUM && sourceAsset && alphWallet?.nodeProvider !== undefined) { try { dispatch(setSourceWormholeWrappedInfo(fetchDataWrapper())); @@ -203,30 +145,6 @@ function useCheckIfWormholeWrapped(nft?: boolean) { } } } - if (sourceChain === CHAIN_ID_ALGORAND && sourceAsset) { - try { - dispatch(setSourceWormholeWrappedInfo(fetchDataWrapper())); - const algodClient = new Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - const wrappedInfo = makeStateSafe( - await getOriginalAssetAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - BigInt(sourceAsset) - ) - ); - if (!cancelled) { - dispatch(setSourceWormholeWrappedInfo(receiveDataWrapper(wrappedInfo))); - } - } catch (e) { - if (!cancelled) { - dispatch(setSourceWormholeWrappedInfo(errorDataWrapper(`${t('Failed to get source asset info from algorand')}, ${t('Error')}: ${e}`))); - } - } - } })(); return () => { cancelled = true; diff --git a/bridge_ui/src/hooks/useFetchForeignAsset.ts b/bridge_ui/src/hooks/useFetchForeignAsset.ts index ffe84c184..0b20e2cd0 100644 --- a/bridge_ui/src/hooks/useFetchForeignAsset.ts +++ b/bridge_ui/src/hooks/useFetchForeignAsset.ts @@ -1,20 +1,12 @@ import { ChainId, CHAIN_ID_ALEPHIUM, - CHAIN_ID_ALGORAND, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, getForeignAssetAlephium, - getForeignAssetAlgorand, getForeignAssetEth, - getForeignAssetSolana, - getForeignAssetTerra, hexToUint8Array, isEVMChain, nativeToHexString, } from "@alephium/wormhole-sdk"; -import { Connection } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; import { ethers } from "ethers"; import { useCallback, useEffect, useMemo, useState } from "react"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; @@ -22,17 +14,10 @@ import { DataWrapper } from "../store/helpers"; import { ALEPHIUM_BRIDGE_GROUP_INDEX, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getEvmChainId, - getTokenBridgeAddressForChain, - SOLANA_HOST, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_HOST, - TERRA_TOKEN_BRIDGE_ADDRESS, + getTokenBridgeAddressForChain } from "../utils/consts"; import useIsWalletReady from "./useIsWalletReady"; -import { Algodv2 } from "algosdk"; import { useWallet } from "@alephium/web3-react"; import { useTranslation } from "react-i18next"; @@ -133,40 +118,6 @@ function useFetchForeignAsset( ALEPHIUM_BRIDGE_GROUP_INDEX ) } - : foreignChain === CHAIN_ID_TERRA - ? () => { - const lcd = new LCDClient(TERRA_HOST); - return getForeignAssetTerra( - TERRA_TOKEN_BRIDGE_ADDRESS, - lcd, - originChain, - hexToUint8Array(originAssetHex) - ); - } - : foreignChain === CHAIN_ID_SOLANA - ? () => { - const connection = new Connection(SOLANA_HOST, "confirmed"); - return getForeignAssetSolana( - connection, - SOL_TOKEN_BRIDGE_ADDRESS, - originChain, - hexToUint8Array(originAssetHex) - ); - } - : foreignChain === CHAIN_ID_ALGORAND - ? () => { - const algodClient = new Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - return getForeignAssetAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - originChain, - originAssetHex - ); - } : () => Promise.resolve(null); getterFunc() diff --git a/bridge_ui/src/hooks/useFetchTargetAsset.ts b/bridge_ui/src/hooks/useFetchTargetAsset.ts index 93f1eff20..70ff2b41a 100644 --- a/bridge_ui/src/hooks/useFetchTargetAsset.ts +++ b/bridge_ui/src/hooks/useFetchTargetAsset.ts @@ -1,27 +1,13 @@ import { ChainId, CHAIN_ID_ALEPHIUM, - CHAIN_ID_ALGORAND, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, getForeignAssetAlephium, - getForeignAssetAlgorand, getForeignAssetEth, - getForeignAssetSolana, - getForeignAssetTerra, hexToNativeAssetString, hexToUint8Array, isEVMChain, } from "@alephium/wormhole-sdk"; -import { - getForeignAssetEth as getForeignAssetEthNFT, - getForeignAssetSol as getForeignAssetSolNFT, -} from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; -import { BigNumber } from "@ethersproject/bignumber"; -import { arrayify } from "@ethersproject/bytes"; -import { Connection } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import algosdk from "algosdk"; +import { getForeignAssetEth as getForeignAssetEthNFT } from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; import { ethers } from "ethers"; import { useCallback, useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; @@ -47,16 +33,9 @@ import { setTargetAsset as setTransferTargetAsset } from "../store/transferSlice import { ALEPHIUM_BRIDGE_GROUP_INDEX, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getEvmChainId, getNFTBridgeAddressForChain, getTokenBridgeAddressForChain, - SOLANA_HOST, - SOL_NFT_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_HOST, - TERRA_TOKEN_BRIDGE_ADDRESS, } from "../utils/consts"; import { useWallet } from "@alephium/web3-react"; import { useTranslation } from "react-i18next"; @@ -189,73 +168,6 @@ function useFetchTargetAsset(nft?: boolean) { } } } - if (targetChain === CHAIN_ID_SOLANA && originChain && originAsset) { - dispatch(setTargetAsset(fetchDataWrapper())); - try { - const connection = new Connection(SOLANA_HOST, "confirmed"); - const asset = await (nft - ? getForeignAssetSolNFT( - SOL_NFT_BRIDGE_ADDRESS, - originChain, - hexToUint8Array(originAsset), - arrayify(BigNumber.from(tokenId || "0")) - ) - : getForeignAssetSolana( - connection, - SOL_TOKEN_BRIDGE_ADDRESS, - originChain, - hexToUint8Array(originAsset) - )); - if (!cancelled) { - dispatch( - setTargetAsset( - receiveDataWrapper({ doesExist: !!asset, address: asset }) - ) - ); - setArgs(); - } - } catch (e) { - if (!cancelled) { - dispatch( - setTargetAsset( - errorDataWrapper( - t("Unable to determine existence of wrapped asset") - ) - ) - ); - } - } - } - if (targetChain === CHAIN_ID_TERRA && originChain && originAsset) { - dispatch(setTargetAsset(fetchDataWrapper())); - try { - const lcd = new LCDClient(TERRA_HOST); - const asset = await getForeignAssetTerra( - TERRA_TOKEN_BRIDGE_ADDRESS, - lcd, - originChain, - hexToUint8Array(originAsset) - ); - if (!cancelled) { - dispatch( - setTargetAsset( - receiveDataWrapper({ doesExist: !!asset, address: asset }) - ) - ); - setArgs(); - } - } catch (e) { - if (!cancelled) { - dispatch( - setTargetAsset( - errorDataWrapper( - t("Unable to determine existence of wrapped asset") - ) - ) - ); - } - } - } if (targetChain === CHAIN_ID_ALEPHIUM && originChain && originAsset && alphWallet?.nodeProvider !== undefined) { dispatch(setTargetAsset(fetchDataWrapper())) try { @@ -284,45 +196,6 @@ function useFetchTargetAsset(nft?: boolean) { } } } - if (targetChain === CHAIN_ID_ALGORAND && originChain && originAsset) { - dispatch(setTargetAsset(fetchDataWrapper())); - try { - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - const asset = await getForeignAssetAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - originChain, - originAsset - ); - console.log("foreign asset algo:", asset); - if (!cancelled) { - dispatch( - setTargetAsset( - receiveDataWrapper({ - doesExist: !!asset, - address: asset === null ? asset : asset.toString(), - }) - ) - ); - setArgs(); - } - } catch (e) { - console.error(e); - if (!cancelled) { - dispatch( - setTargetAsset( - errorDataWrapper( - t("Unable to determine existence of wrapped asset") - ) - ) - ); - } - } - } })(); return () => { cancelled = true; diff --git a/bridge_ui/src/hooks/useGetIsTransferCompleted.ts b/bridge_ui/src/hooks/useGetIsTransferCompleted.ts index 28c67c99e..59ab0e938 100644 --- a/bridge_ui/src/hooks/useGetIsTransferCompleted.ts +++ b/bridge_ui/src/hooks/useGetIsTransferCompleted.ts @@ -1,19 +1,10 @@ import { CHAIN_ID_ALEPHIUM, - CHAIN_ID_ALGORAND, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, - getIsTransferCompletedAlgorand, getIsTransferCompletedEth, - getIsTransferCompletedSolana, - getIsTransferCompletedTerra, getIsTransferCompletedAlph, isEVMChain, getTokenBridgeForChainId, } from "@alephium/wormhole-sdk"; -import { Connection } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import algosdk from "algosdk"; import { useEffect, useState } from "react"; import { useSelector } from "react-redux"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; @@ -26,13 +17,8 @@ import { import { ALEPHIUM_BRIDGE_GROUP_INDEX, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getEvmChainId, - getTokenBridgeAddressForChain, - SOLANA_HOST, - TERRA_GAS_PRICES_URL, - TERRA_HOST, + getTokenBridgeAddressForChain } from "../utils/consts"; import useIsWalletReady from "./useIsWalletReady"; import useTransferSignedVAA from "./useTransferSignedVAA"; @@ -116,43 +102,6 @@ export default function useGetIsTransferCompleted( setIsLoading(false); } })(); - } else if (targetChain === CHAIN_ID_SOLANA) { - setIsLoading(true); - (async () => { - try { - const connection = new Connection(SOLANA_HOST, "confirmed"); - transferCompleted = await getIsTransferCompletedSolana( - getTokenBridgeAddressForChain(targetChain), - signedVAA, - connection - ); - } catch (error) { - console.error(error); - } - if (!cancelled) { - setIsTransferCompleted(transferCompleted); - setIsLoading(false); - } - })(); - } else if (targetChain === CHAIN_ID_TERRA) { - setIsLoading(true); - (async () => { - try { - const lcdClient = new LCDClient(TERRA_HOST); - transferCompleted = await getIsTransferCompletedTerra( - getTokenBridgeAddressForChain(targetChain), - signedVAA, - lcdClient, - TERRA_GAS_PRICES_URL - ); - } catch (error) { - console.error(error); - } - if (!cancelled) { - setIsTransferCompleted(transferCompleted); - setIsLoading(false); - } - })(); } else if (targetChain === CHAIN_ID_ALEPHIUM && alphWallet.connectionStatus === 'connected') { setIsLoading(true); (async () => { @@ -177,28 +126,6 @@ export default function useGetIsTransferCompleted( setIsLoading(false) } })() - } else if (targetChain === CHAIN_ID_ALGORAND) { - setIsLoading(true); - (async () => { - try { - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - transferCompleted = await getIsTransferCompletedAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - signedVAA - ); - } catch (error) { - console.error(error); - } - if (!cancelled) { - setIsTransferCompleted(transferCompleted); - setIsLoading(false); - } - })(); } } return () => { diff --git a/bridge_ui/src/hooks/useGetTargetParsedTokenAccounts.ts b/bridge_ui/src/hooks/useGetTargetParsedTokenAccounts.ts index 64e9dd0ab..d355902a4 100644 --- a/bridge_ui/src/hooks/useGetTargetParsedTokenAccounts.ts +++ b/bridge_ui/src/hooks/useGetTargetParsedTokenAccounts.ts @@ -1,14 +1,5 @@ -import { - CHAIN_ID_ALEPHIUM, - CHAIN_ID_ALGORAND, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, - isEVMChain, - isNativeDenom -} from "@alephium/wormhole-sdk"; +import { CHAIN_ID_ALEPHIUM, CHAIN_ID_ALGORAND, CHAIN_ID_SOLANA, isEVMChain } from "@alephium/wormhole-sdk"; import { Connection, PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import { useConnectedWallet } from "@terra-money/wallet-provider"; import { formatUnits } from "ethers/lib/utils"; import { useEffect, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; @@ -24,10 +15,8 @@ import { setTargetParsedTokenAccount } from "../store/transferSlice"; import { ALGORAND_HOST, getEvmChainId, - SOLANA_HOST, - TERRA_HOST, + SOLANA_HOST } from "../utils/consts"; -import { NATIVE_TERRA_DECIMALS } from "../utils/terra"; import { createParsedTokenAccount } from "./useGetSourceParsedTokenAccounts"; import useMetadata from "./useMetadata"; import { Algodv2 } from "algosdk"; @@ -44,7 +33,6 @@ function useGetTargetParsedTokenAccounts() { ); const solanaWallet = useSolanaWallet(); const solPK = solanaWallet?.publicKey; - const terraWallet = useConnectedWallet(); const alphWallet = useWallet(); const { provider, @@ -100,75 +88,6 @@ function useGetTargetParsedTokenAccounts() { ) } } - if (targetChain === CHAIN_ID_TERRA && terraWallet) { - const lcd = new LCDClient(TERRA_HOST); - if (isNativeDenom(targetAsset)) { - lcd.bank - .balance(terraWallet.walletAddress) - .then(([coins]) => { - const balance = coins.get(targetAsset)?.amount?.toString(); - if (balance && !cancelled) { - dispatch( - setTargetParsedTokenAccount( - createParsedTokenAccount( - "", - "", - balance, - NATIVE_TERRA_DECIMALS, - Number(formatUnits(balance, NATIVE_TERRA_DECIMALS)), - formatUnits(balance, NATIVE_TERRA_DECIMALS), - symbol, - tokenName, - logo - ) - ) - ); - } - }) - .catch(() => { - if (!cancelled) { - // TODO: error state - } - }); - } else { - lcd.wasm - .contractQuery(targetAsset, { - token_info: {}, - }) - .then((info: any) => - lcd.wasm - .contractQuery(targetAsset, { - balance: { - address: terraWallet.walletAddress, - }, - }) - .then((balance: any) => { - if (balance && info && !cancelled) { - dispatch( - setTargetParsedTokenAccount( - createParsedTokenAccount( - "", - "", - balance.balance.toString(), - info.decimals, - Number(formatUnits(balance.balance, info.decimals)), - formatUnits(balance.balance, info.decimals), - symbol, - tokenName, - logo - ) - ) - ); - } - }) - ) - .catch(() => { - if (!cancelled) { - // TODO: error state - } - }); - } - } if (targetChain === CHAIN_ID_SOLANA && solPK) { let mint; try { @@ -304,7 +223,6 @@ function useGetTargetParsedTokenAccounts() { signerAddress, solanaWallet, solPK, - terraWallet, alphWallet, hasCorrectEvmNetwork, hasResolvedMetadata, diff --git a/bridge_ui/src/hooks/useHandleAttest.tsx b/bridge_ui/src/hooks/useHandleAttest.tsx index d7f26d5b7..a48b7ecc7 100644 --- a/bridge_ui/src/hooks/useHandleAttest.tsx +++ b/bridge_ui/src/hooks/useHandleAttest.tsx @@ -1,44 +1,22 @@ import { attestFromAlph, - attestFromAlgorand, - attestFromSolana, - attestFromTerra, ChainId, - CHAIN_ID_ALGORAND, CHAIN_ID_KLAYTN, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, CHAIN_ID_ALEPHIUM, - getEmitterAddressAlgorand, getEmitterAddressEth, - getEmitterAddressSolana, - getEmitterAddressTerra, isEVMChain, - parseSequenceFromLogAlgorand, parseSequenceFromLogEth, - parseSequenceFromLogSolana, - parseSequenceFromLogTerra, uint8ArrayToHex, parseTargetChainFromLogEth, CHAIN_ID_ETH, CHAIN_ID_BSC } from "@alephium/wormhole-sdk"; -import { CHAIN_ID_UNSET } from "@alephium/wormhole-sdk/lib/esm"; import { Alert } from "@material-ui/lab"; -import { WalletContextState } from "@solana/wallet-adapter-react"; -import { Connection, PublicKey } from "@solana/web3.js"; -import { - ConnectedWallet, - useConnectedWallet, -} from "@terra-money/wallet-provider"; -import algosdk from "algosdk"; import { Signer } from "ethers"; import { useSnackbar } from "notistack"; import { useCallback, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { useAlgorandContext } from "../contexts/AlgorandWalletContext"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; -import { useSolanaWallet } from "../contexts/SolanaWalletContext"; import { setAttestTx, setIsSending, @@ -50,89 +28,22 @@ import { selectAttestIsSending, selectAttestIsTargetComplete, selectAttestSourceAsset, - selectAttestSourceChain, - selectTerraFeeDenom, + selectAttestSourceChain } from "../store/selectors"; import { getAndCheckLocalTokenInfo, isValidAlephiumTokenId, waitALPHTxConfirmed, waitTxConfirmedAndGetTxInfo } from "../utils/alephium"; -import { signSendAndConfirmAlgorand } from "../utils/algorand"; import { ALEPHIUM_ATTEST_TOKEN_CONSISTENCY_LEVEL, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, ALEPHIUM_MESSAGE_FEE, - ALGORAND_BRIDGE_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getBridgeAddressForChain, getTokenBridgeAddressForChain, - SOLANA_HOST, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_TOKEN_BRIDGE_ADDRESS } from "../utils/consts"; import { getSignedVAAWithRetry } from "../utils/getSignedVAAWithRetry"; import parseError from "../utils/parseError"; -import { signSendAndConfirm } from "../utils/solana"; -import { postWithFees, waitForTerraExecution } from "../utils/terra"; import { attestFromEthWithoutWait, waitEVMTxConfirmed, checkETHToken, checkBSCToken } from "../utils/evm"; import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react"; import i18n from "../i18n"; -async function algo( - dispatch: any, - enqueueSnackbar: any, - senderAddr: string, - sourceAsset: string -) { - dispatch(setIsSending(true)); - try { - console.log("ALGO", sourceAsset); - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - const txs = await attestFromAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - ALGORAND_BRIDGE_ID, - senderAddr, - BigInt(sourceAsset) - ); - const result = await signSendAndConfirmAlgorand(algodClient, txs); - const sequence = parseSequenceFromLogAlgorand(result); - // TODO: fill these out correctly - dispatch( - setAttestTx({ - id: txs[txs.length - 1].tx.txID(), - blockHeight: result["confirmed-round"], - }) - ); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - const emitterAddress = getEmitterAddressAlgorand(ALGORAND_TOKEN_BRIDGE_ID); - enqueueSnackbar(null, { - content: {i18n.t('Fetching VAA')}, - }); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_ALGORAND, - emitterAddress, - CHAIN_ID_UNSET, - sequence - ); - dispatch(setSignedVAAHex(uint8ArrayToHex(vaaBytes))); - enqueueSnackbar(null, { - content: {i18n.t('Fetched Signed VAA')}, - }); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsSending(false)); - } -} - async function evm( dispatch: any, enqueueSnackbar: any, @@ -203,110 +114,6 @@ async function evm( } } -async function solana( - dispatch: any, - enqueueSnackbar: any, - solPK: PublicKey, - sourceAsset: string, - wallet: WalletContextState -) { - dispatch(setIsSending(true)); - try { - const connection = new Connection(SOLANA_HOST, "confirmed"); - const transaction = await attestFromSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - solPK.toString(), - sourceAsset - ); - const txid = await signSendAndConfirm(wallet, connection, transaction); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - const info = await connection.getTransaction(txid); - if (!info) { - // TODO: error state - throw new Error(i18n.t("An error occurred while fetching the transaction info")); - } - dispatch(setAttestTx({ id: txid, blockHeight: info.slot })); - const sequence = parseSequenceFromLogSolana(info); - const emitterAddress = await getEmitterAddressSolana( - SOL_TOKEN_BRIDGE_ADDRESS - ); - enqueueSnackbar(null, { - content: {i18n.t('Fetching VAA')}, - }); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_SOLANA, - emitterAddress, - CHAIN_ID_UNSET, - sequence - ); - dispatch(setSignedVAAHex(uint8ArrayToHex(vaaBytes))); - enqueueSnackbar(null, { - content: {i18n.t('Fetched Signed VAA')}, - }); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsSending(false)); - } -} - -async function terra( - dispatch: any, - enqueueSnackbar: any, - wallet: ConnectedWallet, - asset: string, - feeDenom: string -) { - dispatch(setIsSending(true)); - try { - const msg = await attestFromTerra( - TERRA_TOKEN_BRIDGE_ADDRESS, - wallet.terraAddress, - asset - ); - const result = await postWithFees(wallet, [msg], "Create Wrapped", [ - feeDenom, - ]); - const info = await waitForTerraExecution(result); - dispatch(setAttestTx({ id: info.txhash, blockHeight: info.height })); - enqueueSnackbar(null, { - content: Transaction confirmed, - }); - const sequence = parseSequenceFromLogTerra(info); - if (!sequence) { - throw new Error("Sequence not found"); - } - const emitterAddress = await getEmitterAddressTerra( - TERRA_TOKEN_BRIDGE_ADDRESS - ); - enqueueSnackbar(null, { - content: Fetching VAA, - }); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_TERRA, - emitterAddress, - CHAIN_ID_UNSET, - sequence - ); - dispatch(setSignedVAAHex(uint8ArrayToHex(vaaBytes))); - enqueueSnackbar(null, { - content: Fetched Signed VAA, - }); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsSending(false)); - } -} - async function alephium( dispatch: any, enqueueSnackbar: any, @@ -371,24 +178,13 @@ export function useHandleAttest() { const isSending = useSelector(selectAttestIsSending); const isSendComplete = useSelector(selectAttestIsSendComplete); const { signer } = useEthereumProvider(); - const solanaWallet = useSolanaWallet(); - const solPK = solanaWallet?.publicKey; - const terraWallet = useConnectedWallet(); - const terraFeeDenom = useSelector(selectTerraFeeDenom); const alphWallet = useWallet(); - const { accounts: algoAccounts } = useAlgorandContext(); const disabled = !isTargetComplete || isSending || isSendComplete; const handleAttestClick = useCallback(() => { if (isEVMChain(sourceChain) && !!signer) { evm(dispatch, enqueueSnackbar, signer, sourceAsset, sourceChain); - } else if (sourceChain === CHAIN_ID_SOLANA && !!solanaWallet && !!solPK) { - solana(dispatch, enqueueSnackbar, solPK, sourceAsset, solanaWallet); - } else if (sourceChain === CHAIN_ID_TERRA && !!terraWallet) { - terra(dispatch, enqueueSnackbar, terraWallet, sourceAsset, terraFeeDenom); } else if (sourceChain === CHAIN_ID_ALEPHIUM && !!alphWallet) { alephium(dispatch, enqueueSnackbar, alphWallet, sourceAsset) - } else if (sourceChain === CHAIN_ID_ALGORAND && algoAccounts[0]) { - algo(dispatch, enqueueSnackbar, algoAccounts[0].address, sourceAsset); } else { } }, [ @@ -396,13 +192,8 @@ export function useHandleAttest() { enqueueSnackbar, sourceChain, signer, - solanaWallet, - solPK, - terraWallet, alphWallet, - sourceAsset, - terraFeeDenom, - algoAccounts, + sourceAsset ]); return useMemo( () => ({ diff --git a/bridge_ui/src/hooks/useHandleCreateWrapped.tsx b/bridge_ui/src/hooks/useHandleCreateWrapped.tsx index 36c9aa86d..413b42e19 100644 --- a/bridge_ui/src/hooks/useHandleCreateWrapped.tsx +++ b/bridge_ui/src/hooks/useHandleCreateWrapped.tsx @@ -1,65 +1,35 @@ import { ChainId, CHAIN_ID_ACALA, - CHAIN_ID_ALGORAND, CHAIN_ID_KARURA, CHAIN_ID_KLAYTN, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, CHAIN_ID_ALEPHIUM, - createWrappedOnAlgorand, - createWrappedOnSolana, - createWrappedOnTerra, isEVMChain, - updateWrappedOnSolana, createRemoteTokenPoolOnAlph, updateRemoteTokenPoolOnAlph, - updateWrappedOnTerra, getAttestTokenHandlerId } from "@alephium/wormhole-sdk"; import { Alert } from "@material-ui/lab"; -import { WalletContextState } from "@solana/wallet-adapter-react"; -import { Connection } from "@solana/web3.js"; -import { - ConnectedWallet, - useConnectedWallet, -} from "@terra-money/wallet-provider"; -import algosdk from "algosdk"; import { Signer } from "ethers"; import { useSnackbar } from "notistack"; import { useCallback, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { useAlgorandContext } from "../contexts/AlgorandWalletContext"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; -import { useSolanaWallet } from "../contexts/SolanaWalletContext"; import { setCreateTx, setIsCreating, setIsWalletApproved } from "../store/attestSlice"; import { selectAttestIsCreating, selectAttestSourceChain, - selectAttestTargetChain, - selectTerraFeeDenom, + selectAttestTargetChain } from "../store/selectors"; -import { signSendAndConfirmAlgorand } from "../utils/algorand"; import { ACALA_HOST, - ALGORAND_BRIDGE_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getTokenBridgeAddressForChain, KARURA_HOST, - MAX_VAA_UPLOAD_RETRIES_SOLANA, - SOLANA_HOST, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_TOKEN_BRIDGE_ADDRESS, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, ALEPHIUM_BRIDGE_GROUP_INDEX, } from "../utils/consts"; import { getKaruraGasParams } from "../utils/karura"; import parseError from "../utils/parseError"; -import { postVaaWithRetry } from "../utils/postVaa"; -import { signSendAndConfirm } from "../utils/solana"; -import { postWithFees } from "../utils/terra"; import { waitALPHTxConfirmed } from "../utils/alephium"; import useAttestSignedVAA from "./useAttestSignedVAA"; import { createWrappedOnEthWithoutWait, updateWrappedOnEthWithoutWait } from "../utils/evm"; @@ -67,44 +37,6 @@ import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react"; import { MINIMAL_CONTRACT_DEPOSIT } from "@alephium/web3"; import i18n from "../i18n"; -async function algo( - dispatch: any, - enqueueSnackbar: any, - senderAddr: string, - signedVAA: Uint8Array -) { - dispatch(setIsCreating(true)); - try { - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - const txs = await createWrappedOnAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - ALGORAND_BRIDGE_ID, - senderAddr, - signedVAA - ); - const result = await signSendAndConfirmAlgorand(algodClient, txs); - dispatch( - setCreateTx({ - id: txs[txs.length - 1].tx.txID(), - blockHeight: result["confirmed-round"], - }) - ); - enqueueSnackbar(null, { - content: Transaction confirmed, - }); - } catch (e) { - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsCreating(false)); - } -} - async function evm( dispatch: any, enqueueSnackbar: any, @@ -154,98 +86,6 @@ async function evm( } } -async function solana( - dispatch: any, - enqueueSnackbar: any, - wallet: WalletContextState, - payerAddress: string, // TODO: we may not need this since we have wallet - signedVAA: Uint8Array, - shouldUpdate: boolean -) { - dispatch(setIsCreating(true)); - try { - if (!wallet.signTransaction) { - throw new Error("wallet.signTransaction is undefined"); - } - const connection = new Connection(SOLANA_HOST, "confirmed"); - await postVaaWithRetry( - connection, - wallet.signTransaction, - SOL_BRIDGE_ADDRESS, - payerAddress, - Buffer.from(signedVAA), - MAX_VAA_UPLOAD_RETRIES_SOLANA - ); - const transaction = shouldUpdate - ? await updateWrappedOnSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - payerAddress, - signedVAA - ) - : await createWrappedOnSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - payerAddress, - signedVAA - ); - const txid = await signSendAndConfirm(wallet, connection, transaction); - // TODO: didn't want to make an info call we didn't need, can we get the block without it by modifying the above call? - dispatch(setCreateTx({ id: txid, blockHeight: 1 })); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - } catch (e) { - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsCreating(false)); - } -} - -async function terra( - dispatch: any, - enqueueSnackbar: any, - wallet: ConnectedWallet, - signedVAA: Uint8Array, - shouldUpdate: boolean, - feeDenom: string -) { - dispatch(setIsCreating(true)); - try { - const msg = shouldUpdate - ? await updateWrappedOnTerra( - TERRA_TOKEN_BRIDGE_ADDRESS, - wallet.terraAddress, - signedVAA - ) - : await createWrappedOnTerra( - TERRA_TOKEN_BRIDGE_ADDRESS, - wallet.terraAddress, - signedVAA - ); - const result = await postWithFees( - wallet, - [msg], - "Wormhole - Create Wrapped", - [feeDenom] - ); - dispatch( - setCreateTx({ id: result.result.txhash, blockHeight: result.result.height }) - ); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - } catch (e) { - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsCreating(false)); - } -} - async function alephium( dispatch: any, enqueueSnackbar: any, @@ -285,15 +125,10 @@ export function useHandleCreateWrapped(shouldUpdate: boolean) { const { enqueueSnackbar } = useSnackbar(); const sourceChain = useSelector(selectAttestSourceChain); const targetChain = useSelector(selectAttestTargetChain); - const solanaWallet = useSolanaWallet(); - const solPK = solanaWallet?.publicKey; const signedVAA = useAttestSignedVAA(); const isCreating = useSelector(selectAttestIsCreating); const { signer } = useEthereumProvider(); - const terraWallet = useConnectedWallet(); - const terraFeeDenom = useSelector(selectTerraFeeDenom); const alphWallet = useWallet(); - const { accounts: algoAccounts } = useAlgorandContext(); const handleCreateClick = useCallback(() => { if (isEVMChain(targetChain) && !!signer && !!signedVAA) { evm( @@ -304,29 +139,6 @@ export function useHandleCreateWrapped(shouldUpdate: boolean) { targetChain, shouldUpdate ); - } else if ( - targetChain === CHAIN_ID_SOLANA && - !!solanaWallet && - !!solPK && - !!signedVAA - ) { - solana( - dispatch, - enqueueSnackbar, - solanaWallet, - solPK.toString(), - signedVAA, - shouldUpdate - ); - } else if (targetChain === CHAIN_ID_TERRA && !!terraWallet && !!signedVAA) { - terra( - dispatch, - enqueueSnackbar, - terraWallet, - signedVAA, - shouldUpdate, - terraFeeDenom - ); } else if (targetChain === CHAIN_ID_ALEPHIUM && !!alphWallet && !!signedVAA) { alephium( dispatch, @@ -336,12 +148,6 @@ export function useHandleCreateWrapped(shouldUpdate: boolean) { signedVAA, shouldUpdate ) - } else if ( - targetChain === CHAIN_ID_ALGORAND && - algoAccounts[0] && - !!signedVAA - ) { - algo(dispatch, enqueueSnackbar, algoAccounts[0]?.address, signedVAA); } else { // enqueueSnackbar( // "Creating wrapped tokens on this chain is not yet supported", @@ -355,15 +161,10 @@ export function useHandleCreateWrapped(shouldUpdate: boolean) { enqueueSnackbar, sourceChain, targetChain, - solanaWallet, - solPK, - terraWallet, alphWallet, signedVAA, signer, - shouldUpdate, - terraFeeDenom, - algoAccounts, + shouldUpdate ]); return useMemo( () => ({ diff --git a/bridge_ui/src/hooks/useHandleNFTRedeem.tsx b/bridge_ui/src/hooks/useHandleNFTRedeem.tsx index 8dc7160dc..59b86375c 100644 --- a/bridge_ui/src/hooks/useHandleNFTRedeem.tsx +++ b/bridge_ui/src/hooks/useHandleNFTRedeem.tsx @@ -3,45 +3,21 @@ import { CHAIN_ID_ACALA, CHAIN_ID_KARURA, CHAIN_ID_KLAYTN, - CHAIN_ID_SOLANA, - getClaimAddressSolana, - isEVMChain + isEVMChain, + redeemOnEth } from "@alephium/wormhole-sdk"; -import { - createMetaOnSolana, - getForeignAssetSol, - isNFTVAASolanaNative, - redeemOnEth, - redeemOnSolana, -} from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; -import { arrayify } from "@ethersproject/bytes"; import { Alert } from "@material-ui/lab"; -import { WalletContextState } from "@solana/wallet-adapter-react"; -import { Connection } from "@solana/web3.js"; -import { BigNumber, Signer } from "ethers"; +import { Signer } from "ethers"; import { useSnackbar } from "notistack"; import { useCallback, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; -import { useSolanaWallet } from "../contexts/SolanaWalletContext"; import { setIsRedeeming, setRedeemTx } from "../store/nftSlice"; import { selectNFTIsRedeeming, selectNFTTargetChain } from "../store/selectors"; -import { - ACALA_HOST, - getNFTBridgeAddressForChain, - KARURA_HOST, - MAX_VAA_UPLOAD_RETRIES_SOLANA, - SOLANA_HOST, - SOL_BRIDGE_ADDRESS, - SOL_NFT_BRIDGE_ADDRESS, -} from "../utils/consts"; +import { ACALA_HOST, getNFTBridgeAddressForChain, KARURA_HOST } from "../utils/consts"; import { getKaruraGasParams } from "../utils/karura"; -import { getMetadataAddress } from "../utils/metaplex"; import parseError from "../utils/parseError"; -import { postVaaWithRetry } from "../utils/postVaa"; -import { signSendAndConfirm } from "../utils/solana"; import useNFTSignedVAA from "./useNFTSignedVAA"; -import { deserializeTransferNFTVAA } from "@alephium/wormhole-sdk/lib/esm"; async function evm( dispatch: any, @@ -82,104 +58,16 @@ async function evm( } } -async function solana( - dispatch: any, - enqueueSnackbar: any, - wallet: WalletContextState, - payerAddress: string, //TODO: we may not need this since we have wallet - signedVAA: Uint8Array -) { - dispatch(setIsRedeeming(true)); - try { - if (!wallet.signTransaction) { - throw new Error("wallet.signTransaction is undefined"); - } - const connection = new Connection(SOLANA_HOST, "confirmed"); - const claimAddress = await getClaimAddressSolana( - SOL_NFT_BRIDGE_ADDRESS, - signedVAA - ); - const claimInfo = await connection.getAccountInfo(claimAddress); - let txid; - if (!claimInfo) { - await postVaaWithRetry( - connection, - wallet.signTransaction, - SOL_BRIDGE_ADDRESS, - payerAddress, - Buffer.from(signedVAA), - MAX_VAA_UPLOAD_RETRIES_SOLANA - ); - // TODO: how do we retry in between these steps - const transaction = await redeemOnSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_NFT_BRIDGE_ADDRESS, - payerAddress, - signedVAA - ); - txid = await signSendAndConfirm(wallet, connection, transaction); - // TODO: didn't want to make an info call we didn't need, can we get the block without it by modifying the above call? - } - const isNative = await isNFTVAASolanaNative(signedVAA); - if (!isNative) { - const payload = deserializeTransferNFTVAA(signedVAA).body.payload - const mintAddress = await getForeignAssetSol( - SOL_NFT_BRIDGE_ADDRESS, - payload.originChain, - payload.originAddress, - arrayify(BigNumber.from(payload.tokenId)) - ); - const [metadataAddress] = await getMetadataAddress(mintAddress); - const metadata = await connection.getAccountInfo(metadataAddress); - if (!metadata) { - const transaction = await createMetaOnSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_NFT_BRIDGE_ADDRESS, - payerAddress, - signedVAA - ); - txid = await signSendAndConfirm(wallet, connection, transaction); - } - } - dispatch(setRedeemTx({ id: txid || "", blockHeight: 1 })); - enqueueSnackbar(null, { - content: Transaction confirmed, - }); - } catch (e) { - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsRedeeming(false)); - } -} - export function useHandleNFTRedeem() { const dispatch = useDispatch(); const { enqueueSnackbar } = useSnackbar(); const targetChain = useSelector(selectNFTTargetChain); - const solanaWallet = useSolanaWallet(); - const solPK = solanaWallet?.publicKey; const { signer } = useEthereumProvider(); const signedVAA = useNFTSignedVAA(); const isRedeeming = useSelector(selectNFTIsRedeeming); const handleRedeemClick = useCallback(() => { if (isEVMChain(targetChain) && !!signer && signedVAA) { evm(dispatch, enqueueSnackbar, signer, signedVAA, targetChain); - } else if ( - targetChain === CHAIN_ID_SOLANA && - !!solanaWallet && - !!solPK && - signedVAA - ) { - solana( - dispatch, - enqueueSnackbar, - solanaWallet, - solPK.toString(), - signedVAA - ); } else { } }, [ @@ -187,9 +75,7 @@ export function useHandleNFTRedeem() { enqueueSnackbar, targetChain, signer, - signedVAA, - solanaWallet, - solPK, + signedVAA ]); return useMemo( () => ({ diff --git a/bridge_ui/src/hooks/useHandleNFTTransfer.tsx b/bridge_ui/src/hooks/useHandleNFTTransfer.tsx index 58f5749c0..2d5860f39 100644 --- a/bridge_ui/src/hooks/useHandleNFTTransfer.tsx +++ b/bridge_ui/src/hooks/useHandleNFTTransfer.tsx @@ -1,29 +1,18 @@ import { ChainId, CHAIN_ID_KLAYTN, - CHAIN_ID_SOLANA, getEmitterAddressEth, - getEmitterAddressSolana, - hexToUint8Array, isEVMChain, parseSequenceFromLogEth, - parseSequenceFromLogSolana, uint8ArrayToHex, } from "@alephium/wormhole-sdk"; -import { - transferFromEth, - transferFromSolana, -} from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; +import { transferFromEth } from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; import { Alert } from "@material-ui/lab"; -import { WalletContextState } from "@solana/wallet-adapter-react"; -import { Connection } from "@solana/web3.js"; -import { BigNumber, Signer } from "ethers"; -import { arrayify, zeroPad } from "ethers/lib/utils"; +import { Signer } from "ethers"; import { useSnackbar } from "notistack"; import { useCallback, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; -import { useSolanaWallet } from "../contexts/SolanaWalletContext"; import { setIsSending, setSignedVAAHex, @@ -33,9 +22,6 @@ import { selectNFTIsSendComplete, selectNFTIsSending, selectNFTIsTargetComplete, - selectNFTOriginAsset, - selectNFTOriginChain, - selectNFTOriginTokenId, selectNFTSourceAsset, selectNFTSourceChain, selectNFTSourceParsedTokenAccount, @@ -43,14 +29,10 @@ import { } from "../store/selectors"; import { getBridgeAddressForChain, - getNFTBridgeAddressForChain, - SOLANA_HOST, - SOL_BRIDGE_ADDRESS, - SOL_NFT_BRIDGE_ADDRESS, + getNFTBridgeAddressForChain } from "../utils/consts"; import { getSignedVAAWithRetry } from "../utils/getSignedVAAWithRetry"; import parseError from "../utils/parseError"; -import { signSendAndConfirm } from "../utils/solana"; import useNFTTargetAddressHex from "./useNFTTargetAddress"; async function evm( @@ -114,74 +96,6 @@ async function evm( } } -async function solana( - dispatch: any, - enqueueSnackbar: any, - wallet: WalletContextState, - payerAddress: string, //TODO: we may not need this since we have wallet - fromAddress: string, - mintAddress: string, - targetChain: ChainId, - targetAddress: Uint8Array, - originAddressStr?: string, - originChain?: ChainId, - originTokenId?: string -) { - dispatch(setIsSending(true)); - try { - const connection = new Connection(SOLANA_HOST, "confirmed"); - const originAddress = originAddressStr - ? zeroPad(hexToUint8Array(originAddressStr), 32) - : undefined; - const transaction = await transferFromSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_NFT_BRIDGE_ADDRESS, - payerAddress, - fromAddress, - mintAddress, - targetAddress, - targetChain, - originAddress, - originChain, - arrayify(BigNumber.from(originTokenId || "0")) - ); - const txid = await signSendAndConfirm(wallet, connection, transaction); - enqueueSnackbar(null, { - content: Transaction confirmed, - }); - const info = await connection.getTransaction(txid); - if (!info) { - throw new Error("An error occurred while fetching the transaction info"); - } - dispatch(setTransferTx({ id: txid, blockHeight: info.slot })); - const sequence = parseSequenceFromLogSolana(info); - const emitterAddress = await getEmitterAddressSolana( - SOL_NFT_BRIDGE_ADDRESS - ); - enqueueSnackbar(null, { - content: Fetching VAA, - }); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_SOLANA, - emitterAddress, - targetChain, - sequence - ); - - dispatch(setSignedVAAHex(uint8ArrayToHex(vaaBytes))); - enqueueSnackbar(null, { - content: Fetched Signed VAA, - }); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsSending(false)); - } -} - export function useHandleNFTTransfer() { const dispatch = useDispatch(); const { enqueueSnackbar } = useSnackbar(); @@ -191,21 +105,12 @@ export function useHandleNFTTransfer() { selectNFTSourceParsedTokenAccount ); const sourceTokenId = nftSourceParsedTokenAccount?.tokenId || ""; // this should exist by this step for NFT transfers - const originChain = useSelector(selectNFTOriginChain); - const originAsset = useSelector(selectNFTOriginAsset); - const originTokenId = useSelector(selectNFTOriginTokenId); const targetChain = useSelector(selectNFTTargetChain); const targetAddress = useNFTTargetAddressHex(); const isTargetComplete = useSelector(selectNFTIsTargetComplete); const isSending = useSelector(selectNFTIsSending); const isSendComplete = useSelector(selectNFTIsSendComplete); const { signer } = useEthereumProvider(); - const solanaWallet = useSolanaWallet(); - const solPK = solanaWallet?.publicKey; - const sourceParsedTokenAccount = useSelector( - selectNFTSourceParsedTokenAccount - ); - const sourceTokenPublicKey = sourceParsedTokenAccount?.publicKey; const disabled = !isTargetComplete || isSending || isSendComplete; const handleTransferClick = useCallback(() => { // TODO: we should separate state for transaction vs fetching vaa @@ -226,27 +131,6 @@ export function useHandleNFTTransfer() { targetAddress, sourceChain ); - } else if ( - sourceChain === CHAIN_ID_SOLANA && - !!solanaWallet && - !!solPK && - !!sourceAsset && - !!sourceTokenPublicKey && - !!targetAddress - ) { - solana( - dispatch, - enqueueSnackbar, - solanaWallet, - solPK.toString(), - sourceTokenPublicKey, - sourceAsset, - targetChain, - targetAddress, - originAsset, - originChain, - originTokenId - ); } else { } }, [ @@ -254,16 +138,10 @@ export function useHandleNFTTransfer() { enqueueSnackbar, sourceChain, signer, - solanaWallet, - solPK, - sourceTokenPublicKey, sourceAsset, sourceTokenId, targetChain, - targetAddress, - originAsset, - originChain, - originTokenId, + targetAddress ]); return useMemo( () => ({ diff --git a/bridge_ui/src/hooks/useHandleRedeem.tsx b/bridge_ui/src/hooks/useHandleRedeem.tsx index c21744470..ff99d8575 100644 --- a/bridge_ui/src/hooks/useHandleRedeem.tsx +++ b/bridge_ui/src/hooks/useHandleRedeem.tsx @@ -1,14 +1,7 @@ import { ChainId, - CHAIN_ID_ALGORAND, CHAIN_ID_KLAYTN, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, isEVMChain, - redeemAndUnwrapOnSolana, - redeemOnAlgorand, - redeemOnSolana, - redeemOnTerra, CHAIN_ID_ALEPHIUM, uint8ArrayToHex, getTokenBridgeForChainId, @@ -20,52 +13,25 @@ import { redeemOnAlph } from "@alephium/wormhole-sdk"; import { Alert } from "@material-ui/lab"; -import { WalletContextState } from "@solana/wallet-adapter-react"; -import { Connection } from "@solana/web3.js"; -import { - ConnectedWallet, - useConnectedWallet, -} from "@terra-money/wallet-provider"; -import algosdk from "algosdk"; import axios from "axios"; import { Signer } from "ethers"; import { useSnackbar } from "notistack"; import { useCallback, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { useAlgorandContext } from "../contexts/AlgorandWalletContext"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; -import { useSolanaWallet } from "../contexts/SolanaWalletContext"; -import { - selectTerraFeeDenom, - selectTransferIsRedeeming, - selectTransferRecoverySourceTxId, - selectTransferSourceChain, - selectTransferTargetChain, -} from "../store/selectors"; +import { selectTransferIsRedeeming, selectTransferTargetChain } from "../store/selectors"; import { setIsRedeemedViaRelayer, setIsRedeeming, setIsRedeemingViaRelayer, setIsWalletApproved, setRedeemCompleted, setRedeemTx } from "../store/transferSlice"; -import { signSendAndConfirmAlgorand } from "../utils/algorand"; import { ACALA_RELAY_URL, ALEPHIUM_BRIDGE_GROUP_INDEX, ALEPHIUM_BRIDGE_REWARD_ROUTER_ID, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, - ALGORAND_BRIDGE_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getTokenBridgeAddressForChain, - MAX_VAA_UPLOAD_RETRIES_SOLANA, - SOLANA_HOST, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_TOKEN_BRIDGE_ADDRESS, CLUSTER, RELAYER_HOST, BSC_TOKENS_FOR_REWARD, } from "../utils/consts"; import parseError from "../utils/parseError"; -import { postVaaWithRetry } from "../utils/postVaa"; -import { signSendAndConfirm } from "../utils/solana"; -import { postWithFees } from "../utils/terra"; import { getEmitterChainId, waitALPHTxConfirmed } from "../utils/alephium"; import useTransferSignedVAA from "./useTransferSignedVAA"; import { redeemOnEthNativeWithoutWait, redeemOnEthWithoutWait } from "../utils/evm"; @@ -73,54 +39,13 @@ import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react"; import { SignerProvider } from "@alephium/web3"; import i18n from "../i18n"; -async function algo( - dispatch: any, - enqueueSnackbar: any, - senderAddr: string, - signedVAA: Uint8Array -) { - dispatch(setIsRedeeming(true)); - try { - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - const txs = await redeemOnAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - ALGORAND_BRIDGE_ID, - signedVAA, - senderAddr - ); - const result = await signSendAndConfirmAlgorand(algodClient, txs); - // TODO: fill these out correctly - dispatch( - setRedeemTx({ - id: txs[txs.length - 1].tx.txID(), - blockHeight: result["confirmed-round"], - }) - ); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - } catch (e) { - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsRedeeming(false)); - } -} - async function evm( dispatch: any, enqueueSnackbar: any, signer: Signer, signedVAA: Uint8Array, isNative: boolean, - targetChainId: ChainId, - sourceChainId: ChainId, - sourceTxId: string | undefined + targetChainId: ChainId ) { dispatch(setIsRedeeming(true)); try { @@ -158,92 +83,6 @@ async function evm( } } -async function solana( - dispatch: any, - enqueueSnackbar: any, - wallet: WalletContextState, - payerAddress: string, //TODO: we may not need this since we have wallet - signedVAA: Uint8Array, - isNative: boolean -) { - dispatch(setIsRedeeming(true)); - try { - if (!wallet.signTransaction) { - throw new Error("wallet.signTransaction is undefined"); - } - const connection = new Connection(SOLANA_HOST, "confirmed"); - await postVaaWithRetry( - connection, - wallet.signTransaction, - SOL_BRIDGE_ADDRESS, - payerAddress, - Buffer.from(signedVAA), - MAX_VAA_UPLOAD_RETRIES_SOLANA - ); - // TODO: how do we retry in between these steps - const transaction = isNative - ? await redeemAndUnwrapOnSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - payerAddress, - signedVAA - ) - : await redeemOnSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - payerAddress, - signedVAA - ); - const txid = await signSendAndConfirm(wallet, connection, transaction); - // TODO: didn't want to make an info call we didn't need, can we get the block without it by modifying the above call? - dispatch(setRedeemTx({ id: txid, blockHeight: 1 })); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - } catch (e) { - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsRedeeming(false)); - } -} - -async function terra( - dispatch: any, - enqueueSnackbar: any, - wallet: ConnectedWallet, - signedVAA: Uint8Array, - feeDenom: string -) { - dispatch(setIsRedeeming(true)); - try { - const msg = await redeemOnTerra( - TERRA_TOKEN_BRIDGE_ADDRESS, - wallet.terraAddress, - signedVAA - ); - const result = await postWithFees( - wallet, - [msg], - "Wormhole - Complete Transfer", - [feeDenom] - ); - dispatch( - setRedeemTx({ id: result.result.txhash, blockHeight: result.result.height }) - ); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - } catch (e) { - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsRedeeming(false)); - } -} - async function redeemViaRelayer( dispatch: any, signer: SignerProvider, @@ -354,102 +193,37 @@ export function useHandleRedeem() { const dispatch = useDispatch(); const { enqueueSnackbar } = useSnackbar(); const targetChain = useSelector(selectTransferTargetChain); - const sourceChain = useSelector(selectTransferSourceChain); - const recoverySourceTxId = useSelector(selectTransferRecoverySourceTxId); - const solanaWallet = useSolanaWallet(); - const solPK = solanaWallet?.publicKey; const { signer } = useEthereumProvider(); - const terraWallet = useConnectedWallet(); - const terraFeeDenom = useSelector(selectTerraFeeDenom); const alphWallet = useWallet(); - const { accounts: algoAccounts } = useAlgorandContext(); const signedVAA = useTransferSignedVAA(); const isRedeeming = useSelector(selectTransferIsRedeeming); const handleRedeemClick = useCallback(() => { if (isEVMChain(targetChain) && !!signer && signedVAA) { - evm(dispatch, enqueueSnackbar, signer, signedVAA, false, targetChain, sourceChain, recoverySourceTxId); - } else if ( - targetChain === CHAIN_ID_SOLANA && - !!solanaWallet && - !!solPK && - signedVAA - ) { - solana( - dispatch, - enqueueSnackbar, - solanaWallet, - solPK.toString(), - signedVAA, - false - ); - } else if (targetChain === CHAIN_ID_TERRA && !!terraWallet && signedVAA) { - terra(dispatch, enqueueSnackbar, terraWallet, signedVAA, terraFeeDenom); + evm(dispatch, enqueueSnackbar, signer, signedVAA, false, targetChain); } else if (targetChain === CHAIN_ID_ALEPHIUM && !!alphWallet && signedVAA) { alephium(dispatch, enqueueSnackbar, alphWallet, signedVAA) - } else if ( - targetChain === CHAIN_ID_ALGORAND && - algoAccounts[0] && - !!signedVAA - ) { - algo(dispatch, enqueueSnackbar, algoAccounts[0]?.address, signedVAA); } else { } }, [ dispatch, enqueueSnackbar, - sourceChain, - recoverySourceTxId, targetChain, signer, signedVAA, - solanaWallet, - solPK, - terraWallet, - terraFeeDenom, - alphWallet, - algoAccounts, + alphWallet ]); const handleRedeemNativeClick = useCallback(() => { if (isEVMChain(targetChain) && !!signer && signedVAA) { - evm(dispatch, enqueueSnackbar, signer, signedVAA, true, targetChain, sourceChain, recoverySourceTxId); - } else if ( - targetChain === CHAIN_ID_SOLANA && - !!solanaWallet && - !!solPK && - signedVAA - ) { - solana( - dispatch, - enqueueSnackbar, - solanaWallet, - solPK.toString(), - signedVAA, - true - ); - } else if (targetChain === CHAIN_ID_TERRA && !!terraWallet && signedVAA) { - terra(dispatch, enqueueSnackbar, terraWallet, signedVAA, terraFeeDenom); //TODO isNative = true - } else if ( - targetChain === CHAIN_ID_ALGORAND && - algoAccounts[0] && - !!signedVAA - ) { - algo(dispatch, enqueueSnackbar, algoAccounts[0]?.address, signedVAA); + evm(dispatch, enqueueSnackbar, signer, signedVAA, true, targetChain); } else { } }, [ dispatch, enqueueSnackbar, targetChain, - sourceChain, - recoverySourceTxId, signer, - signedVAA, - solanaWallet, - solPK, - terraWallet, - terraFeeDenom, - algoAccounts, + signedVAA ]); const handleAcalaRelayerRedeemClick = useCallback(async () => { diff --git a/bridge_ui/src/hooks/useHandleTransfer.tsx b/bridge_ui/src/hooks/useHandleTransfer.tsx index 5dc48c7c5..75885bcbf 100644 --- a/bridge_ui/src/hooks/useHandleTransfer.tsx +++ b/bridge_ui/src/hooks/useHandleTransfer.tsx @@ -1,46 +1,22 @@ import { ChainId, CHAIN_ID_ALEPHIUM, - CHAIN_ID_ALGORAND, CHAIN_ID_KLAYTN, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, - getEmitterAddressAlgorand, getEmitterAddressEth, - getEmitterAddressSolana, - getEmitterAddressTerra, - hexToUint8Array, isEVMChain, - parseSequenceFromLogAlgorand, parseSequenceFromLogEth, - parseSequenceFromLogSolana, - parseSequenceFromLogTerra, - transferFromAlgorand, - transferFromSolana, - transferFromTerra, - transferNativeSol, uint8ArrayToHex, transferRemoteTokenFromAlph, transferLocalTokenFromAlph } from "@alephium/wormhole-sdk"; import { Alert } from "@material-ui/lab"; -import { WalletContextState } from "@solana/wallet-adapter-react"; -import { Connection } from "@solana/web3.js"; -import { - ConnectedWallet, - useConnectedWallet, -} from "@terra-money/wallet-provider"; -import algosdk from "algosdk"; import { Signer } from "ethers"; -import { parseUnits, zeroPad } from "ethers/lib/utils"; +import { parseUnits } from "ethers/lib/utils"; import { useSnackbar } from "notistack"; import { useCallback, useMemo } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { useAlgorandContext } from "../contexts/AlgorandWalletContext"; import { useEthereumProvider } from "../contexts/EthereumProviderContext"; -import { useSolanaWallet } from "../contexts/SolanaWalletContext"; import { - selectTerraFeeDenom, selectTransferAmount, selectTransferIsSendComplete, selectTransferIsSending, @@ -60,27 +36,17 @@ import { setRecoverySourceTxId, setIsWalletApproved } from "../store/transferSlice"; -import { signSendAndConfirmAlgorand } from "../utils/algorand"; import { ALEPHIUM_MINIMAL_CONSISTENCY_LEVEL, ALEPHIUM_TOKEN_BRIDGE_CONTRACT_ID, alphArbiterFee, ALEPHIUM_MESSAGE_FEE, - ALGORAND_BRIDGE_ID, - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getBridgeAddressForChain, getTokenBridgeAddressForChain, - SOLANA_HOST, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_TOKEN_BRIDGE_ADDRESS, ALEPHIUM_BRIDGE_GROUP_INDEX, } from "../utils/consts"; import { getSignedVAAWithRetry } from "../utils/getSignedVAAWithRetry"; import parseError from "../utils/parseError"; -import { signSendAndConfirm } from "../utils/solana"; -import { postWithFees, waitForTerraExecution } from "../utils/terra"; import useTransferTargetAddressHex from "./useTransferTargetAddress"; import { validateAlephiumRecipientAddress, waitALPHTxConfirmed, waitTxConfirmedAndGetTxInfo } from "../utils/alephium"; import { ExecuteScriptResult } from "@alephium/web3"; @@ -88,73 +54,6 @@ import { transferFromEthNativeWithoutWait, transferFromEthWithoutWait, waitEVMTx import { useWallet, Wallet as AlephiumWallet } from "@alephium/web3-react"; import i18n from "../i18n"; -async function algo( - dispatch: any, - enqueueSnackbar: any, - senderAddr: string, - tokenAddress: string, - decimals: number, - amount: string, - recipientChain: ChainId, - recipientAddress: Uint8Array, - chainId: ChainId, - relayerFee?: string -) { - dispatch(setIsSending(true)); - try { - const baseAmountParsed = parseUnits(amount, decimals); - const feeParsed = parseUnits(relayerFee || "0", decimals); - const transferAmountParsed = baseAmountParsed.add(feeParsed); - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - const txs = await transferFromAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - ALGORAND_BRIDGE_ID, - senderAddr, - BigInt(tokenAddress), - transferAmountParsed.toBigInt(), - uint8ArrayToHex(recipientAddress), - recipientChain, - feeParsed.toBigInt() - ); - const result = await signSendAndConfirmAlgorand(algodClient, txs); - const sequence = parseSequenceFromLogAlgorand(result); - dispatch( - setTransferTx({ - id: txs[txs.length - 1].tx.txID(), - blockHeight: result["confirmed-round"], - }) - ); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - const emitterAddress = getEmitterAddressAlgorand(ALGORAND_TOKEN_BRIDGE_ID); - enqueueSnackbar(null, { - content: {i18n.t('Fetching VAA')}, - }); - const { vaaBytes } = await getSignedVAAWithRetry( - chainId, - emitterAddress, - recipientChain, - sequence - ); - dispatch(setSignedVAAHex(uint8ArrayToHex(vaaBytes))); - enqueueSnackbar(null, { - content: {i18n.t('Fetched Signed VAA')}, - }); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsSending(false)); - } -} - async function evm( dispatch: any, enqueueSnackbar: any, @@ -249,94 +148,6 @@ async function evm( } } -async function solana( - dispatch: any, - enqueueSnackbar: any, - wallet: WalletContextState, - payerAddress: string, //TODO: we may not need this since we have wallet - fromAddress: string, - mintAddress: string, - amount: string, - decimals: number, - targetChain: ChainId, - targetAddress: Uint8Array, - isNative: boolean, - originAddressStr?: string, - originChain?: ChainId, - relayerFee?: string -) { - dispatch(setIsSending(true)); - try { - const connection = new Connection(SOLANA_HOST, "confirmed"); - const baseAmountParsed = parseUnits(amount, decimals); - const feeParsed = parseUnits(relayerFee || "0", decimals); - const transferAmountParsed = baseAmountParsed.add(feeParsed); - const originAddress = originAddressStr - ? zeroPad(hexToUint8Array(originAddressStr), 32) - : undefined; - const promise = isNative - ? transferNativeSol( - connection, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - payerAddress, - transferAmountParsed.toBigInt(), - targetAddress, - targetChain, - feeParsed.toBigInt() - ) - : transferFromSolana( - connection, - SOL_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - payerAddress, - fromAddress, - mintAddress, - transferAmountParsed.toBigInt(), - targetAddress, - targetChain, - originAddress, - originChain, - undefined, - feeParsed.toBigInt() - ); - const transaction = await promise; - const txid = await signSendAndConfirm(wallet, connection, transaction); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - const info = await connection.getTransaction(txid); - if (!info) { - throw new Error("An error occurred while fetching the transaction info"); - } - dispatch(setTransferTx({ id: txid, blockHeight: info.slot })); - const sequence = parseSequenceFromLogSolana(info); - const emitterAddress = await getEmitterAddressSolana( - SOL_TOKEN_BRIDGE_ADDRESS - ); - enqueueSnackbar(null, { - content: {i18n.t('Fetching VAA')}, - }); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_SOLANA, - emitterAddress, - targetChain, - sequence - ); - - dispatch(setSignedVAAHex(uint8ArrayToHex(vaaBytes))); - enqueueSnackbar(null, { - content: {i18n.t('Fetched Signed VAA')}, - }); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsSending(false)); - } -} - async function alephium( dispatch: any, enqueueSnackbar: any, @@ -415,74 +226,6 @@ async function alephium( } } -async function terra( - dispatch: any, - enqueueSnackbar: any, - wallet: ConnectedWallet, - asset: string, - amount: string, - decimals: number, - targetChain: ChainId, - targetAddress: Uint8Array, - feeDenom: string, - relayerFee?: string -) { - dispatch(setIsSending(true)); - try { - const baseAmountParsed = parseUnits(amount, decimals); - const feeParsed = parseUnits(relayerFee || "0", decimals); - const transferAmountParsed = baseAmountParsed.add(feeParsed); - const msgs = await transferFromTerra( - wallet.terraAddress, - TERRA_TOKEN_BRIDGE_ADDRESS, - asset, - transferAmountParsed.toString(), - targetChain, - targetAddress, - feeParsed.toString() - ); - - const result = await postWithFees( - wallet, - msgs, - "Wormhole - Initiate Transfer", - [feeDenom] - ); - - const info = await waitForTerraExecution(result); - dispatch(setTransferTx({ id: info.txhash, blockHeight: info.height })); - enqueueSnackbar(null, { - content: {i18n.t('Transaction confirmed')}, - }); - const sequence = parseSequenceFromLogTerra(info); - if (!sequence) { - throw new Error("Sequence not found"); - } - const emitterAddress = await getEmitterAddressTerra( - TERRA_TOKEN_BRIDGE_ADDRESS - ); - enqueueSnackbar(null, { - content: {i18n.t('Fetching VAA')}, - }); - const { vaaBytes } = await getSignedVAAWithRetry( - CHAIN_ID_TERRA, - emitterAddress, - targetChain, - sequence - ); - enqueueSnackbar(null, { - content: {i18n.t('Fetched Signed VAA')}, - }); - dispatch(setSignedVAAHex(uint8ArrayToHex(vaaBytes))); - } catch (e) { - console.error(e); - enqueueSnackbar(null, { - content: {parseError(e)}, - }); - dispatch(setIsSending(false)); - } -} - export function useHandleTransfer() { const dispatch = useDispatch(); const { enqueueSnackbar } = useSnackbar(); @@ -497,19 +240,13 @@ export function useHandleTransfer() { const isSending = useSelector(selectTransferIsSending); const isSendComplete = useSelector(selectTransferIsSendComplete); const { signer } = useEthereumProvider(); - const solanaWallet = useSolanaWallet(); - const solPK = solanaWallet?.publicKey; - const terraWallet = useConnectedWallet(); const alphWallet = useWallet(); - const terraFeeDenom = useSelector(selectTerraFeeDenom); - const { accounts: algoAccounts } = useAlgorandContext(); const sourceParsedTokenAccount = useSelector( selectTransferSourceParsedTokenAccount ); const relayerFee = useSelector(selectTransferRelayerFee); console.log("relayerFee", relayerFee); - const sourceTokenPublicKey = sourceParsedTokenAccount?.publicKey; const decimals = sourceParsedTokenAccount?.decimals; const isNative = sourceParsedTokenAccount?.isNativeAsset || false; const disabled = !isTargetComplete || isSending || isSendComplete; @@ -536,69 +273,6 @@ export function useHandleTransfer() { sourceChain, relayerFee ); - } else if ( - sourceChain === CHAIN_ID_SOLANA && - !!solanaWallet && - !!solPK && - !!sourceAsset && - !!sourceTokenPublicKey && - !!targetAddress && - decimals !== undefined - ) { - solana( - dispatch, - enqueueSnackbar, - solanaWallet, - solPK.toString(), - sourceTokenPublicKey, - sourceAsset, - amount, - decimals, - targetChain, - targetAddress, - isNative, - originAsset, - originChain, - relayerFee - ); - } else if ( - sourceChain === CHAIN_ID_TERRA && - !!terraWallet && - !!sourceAsset && - decimals !== undefined && - !!targetAddress - ) { - terra( - dispatch, - enqueueSnackbar, - terraWallet, - sourceAsset, - amount, - decimals, - targetChain, - targetAddress, - terraFeeDenom, - relayerFee - ); - } else if ( - sourceChain === CHAIN_ID_ALGORAND && - algoAccounts[0] && - !!sourceAsset && - decimals !== undefined && - !!targetAddress - ) { - algo( - dispatch, - enqueueSnackbar, - algoAccounts[0].address, - sourceAsset, - decimals, - amount, - targetChain, - targetAddress, - sourceChain, - relayerFee - ); } else if ( sourceChain === CHAIN_ID_ALEPHIUM && !!alphWallet && @@ -627,11 +301,7 @@ export function useHandleTransfer() { sourceChain, signer, relayerFee, - solanaWallet, - solPK, - terraWallet, alphWallet, - sourceTokenPublicKey, sourceAsset, amount, decimals, @@ -639,9 +309,7 @@ export function useHandleTransfer() { targetAddress, originAsset, originChain, - isNative, - terraFeeDenom, - algoAccounts, + isNative ]); return useMemo( () => ({ diff --git a/bridge_ui/src/hooks/useOriginalAsset.ts b/bridge_ui/src/hooks/useOriginalAsset.ts index 302ab92e4..1e2584b23 100644 --- a/bridge_ui/src/hooks/useOriginalAsset.ts +++ b/bridge_ui/src/hooks/useOriginalAsset.ts @@ -1,13 +1,8 @@ import { ChainId, CHAIN_ID_ALEPHIUM, - CHAIN_ID_ALGORAND, CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, - getOriginalAssetAlgorand, getOriginalAssetEth, - getOriginalAssetSol, - getOriginalAssetTerra, hexToNativeAssetString, isEVMChain, uint8ArrayToHex, @@ -15,13 +10,9 @@ import { } from "@alephium/wormhole-sdk"; import { getOriginalAssetEth as getOriginalAssetEthNFT, - getOriginalAssetSol as getOriginalAssetSolNFT, WormholeWrappedNFTInfo, } from "@alephium/wormhole-sdk/lib/esm/nft_bridge"; import { Web3Provider } from "@ethersproject/providers"; -import { Connection } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import { Algodv2 } from "algosdk"; import { ethers } from "ethers"; import { useCallback, useEffect, useMemo, useState } from "react"; import { @@ -30,15 +21,9 @@ import { } from "../contexts/EthereumProviderContext"; import { DataWrapper } from "../store/helpers"; import { - ALGORAND_HOST, - ALGORAND_TOKEN_BRIDGE_ID, getNFTBridgeAddressForChain, getTokenBridgeAddressForChain, - SOLANA_HOST, - SOLANA_SYSTEM_PROGRAM_ADDRESS, - SOL_NFT_BRIDGE_ADDRESS, - SOL_TOKEN_BRIDGE_ADDRESS, - TERRA_HOST, + SOLANA_SYSTEM_PROGRAM_ADDRESS } from "../utils/consts"; import useIsWalletReady from "./useIsWalletReady"; import { NodeProvider } from "@alephium/web3"; @@ -68,30 +53,9 @@ export async function getOriginalAssetToken( foreignNativeStringAddress, foreignChain ); - } else if (foreignChain === CHAIN_ID_SOLANA) { - const connection = new Connection(SOLANA_HOST, "confirmed"); - promise = await getOriginalAssetSol( - connection, - SOL_TOKEN_BRIDGE_ADDRESS, - foreignNativeStringAddress - ); - } else if (foreignChain === CHAIN_ID_TERRA) { - const lcd = new LCDClient(TERRA_HOST); - promise = await getOriginalAssetTerra(lcd, foreignNativeStringAddress); } else if (foreignChain === CHAIN_ID_ALEPHIUM && alphNodeProvider) { const tokenId = tryGetContractId(foreignNativeStringAddress) promise = await getAlephiumTokenWrappedInfo(tokenId, alphNodeProvider) - } else if (foreignChain === CHAIN_ID_ALGORAND) { - const algodClient = new Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort - ); - promise = await getOriginalAssetAlgorand( - algodClient, - ALGORAND_TOKEN_BRIDGE_ID, - BigInt(foreignNativeStringAddress) - ); } } catch (e) { promise = Promise.reject(i18n.t("Invalid foreign arguments.")); @@ -118,13 +82,6 @@ export async function getOriginalAssetNFT( tokenId, foreignChain ); - } else if (foreignChain === CHAIN_ID_SOLANA) { - const connection = new Connection(SOLANA_HOST, "confirmed"); - promise = getOriginalAssetSolNFT( - connection, - SOL_NFT_BRIDGE_ADDRESS, - foreignNativeStringAddress - ); } } catch (e) { promise = Promise.reject(i18n.t("Invalid foreign arguments.")); diff --git a/bridge_ui/src/hooks/useSolanaMigratorInformation.tsx b/bridge_ui/src/hooks/useSolanaMigratorInformation.tsx deleted file mode 100644 index 3e0d279e5..000000000 --- a/bridge_ui/src/hooks/useSolanaMigratorInformation.tsx +++ /dev/null @@ -1,430 +0,0 @@ -import { CHAIN_ID_SOLANA } from "@alephium/wormhole-sdk"; -import migrateTokensTx from "@alephium/wormhole-sdk/lib/esm/migration/migrateTokens"; -import getPoolAddress from "@alephium/wormhole-sdk/lib/esm/migration/poolAddress"; -import getToCustodyAddress from "@alephium/wormhole-sdk/lib/esm/migration/toCustodyAddress"; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - Token, - TOKEN_PROGRAM_ID, -} from "@solana/spl-token"; -import { Connection, PublicKey } from "@solana/web3.js"; -import { parseUnits } from "ethers/lib/utils"; -import { useCallback, useEffect, useMemo, useState } from "react"; -import { useAssociatedAccountExistsState } from "../components/SolanaCreateAssociatedAddress"; -import { useSolanaWallet } from "../contexts/SolanaWalletContext"; -import useIsWalletReady from "../hooks/useIsWalletReady"; -import useMetaplexData from "../hooks/useMetaplexData"; -import useSolanaTokenMap from "../hooks/useSolanaTokenMap"; -import { DataWrapper } from "../store/helpers"; -import { MIGRATION_PROGRAM_ADDRESS, SOLANA_HOST } from "../utils/consts"; -import { getMultipleAccounts, signSendAndConfirm } from "../utils/solana"; - -const getDecimals = async ( - connection: Connection, - mint: string, - setter: (decimals: number | undefined) => void -) => { - setter(undefined); - if (mint) { - try { - const pk = new PublicKey(mint); - const info = await connection.getParsedAccountInfo(pk); - // @ts-ignore - const decimals = info.value?.data.parsed.info.decimals; - setter(decimals); - } catch (e) { - console.log(`Unable to determine decimals of ${mint}`); - } - } -}; - -const getBalance = async ( - connection: Connection, - address: string | undefined, - setter: (balance: string | undefined) => void -) => { - setter(undefined); - if (address) { - try { - const pk = new PublicKey(address); - const info = await connection.getParsedAccountInfo(pk); - // @ts-ignore - const balance = info.value?.data.parsed.info.tokenAmount.uiAmountString; - setter(balance); - } catch (e) { - console.log(`Unable to determine balance of ${address}`); - } - } -}; - -//If the pool doesn't exist in this app, it's an error. -export type SolanaMigratorInformation = { - poolAddress: string; - fromMint: string; - toMint: string; - fromMintDecimals: number; - fromAssociatedTokenAccountExists: boolean; - toAssociatedTokenAccountExists: boolean; - setToTokenAccountExists: any; - fromAssociatedTokenAccount: string; - toAssociatedTokenAccount: string; - fromAssociatedTokenAccountBalance: string; - toAssociatedTokenAccountBalance: string | null; - toCustodyAddress: string; - toCustodyBalance: string; - - fromName: string | null; - fromSymbol: string | null; - fromLogo: string | null; - toName: string | null; - toSymbol: string | null; - toLogo: string | null; - - getNotReadyCause: (amount: string) => string | null; - - migrateTokens: (amount: string) => Promise; -}; - -//TODO refactor the workflow page to use this hook -export default function useSolanaMigratorInformation( - fromMint: string, - toMint: string, - fromTokenAccount: string -): DataWrapper { - const connection = useMemo( - () => new Connection(SOLANA_HOST, "confirmed"), - [] - ); - const wallet = useSolanaWallet(); - const { isReady } = useIsWalletReady(CHAIN_ID_SOLANA, false); - const solanaTokenMap = useSolanaTokenMap(); - const metaplexArray = useMemo(() => [fromMint, toMint], [fromMint, toMint]); - const metaplexData = useMetaplexData(metaplexArray); - - const [poolAddress, setPoolAddress] = useState(""); - const [poolExists, setPoolExists] = useState(undefined); - const [fromTokenAccountBalance, setFromTokenAccountBalance] = useState< - string | undefined - >(undefined); - const [toTokenAccount, setToTokenAccount] = useState( - undefined - ); - const [toTokenAccountBalance, setToTokenAccountBalance] = useState< - string | undefined - >(undefined); - const [fromMintDecimals, setFromMintDecimals] = useState( - undefined - ); - - const { - associatedAccountExists: fromTokenAccountExists, - //setAssociatedAccountExists: setFromTokenAccountExists, - } = useAssociatedAccountExistsState( - CHAIN_ID_SOLANA, - fromMint, - fromTokenAccount - ); - const { - associatedAccountExists: toTokenAccountExists, - setAssociatedAccountExists: setToTokenAccountExists, - } = useAssociatedAccountExistsState(CHAIN_ID_SOLANA, toMint, toTokenAccount); - - const [toCustodyAddress, setToCustodyAddress] = useState( - undefined - ); - const [toCustodyBalance, setToCustodyBalance] = useState( - undefined - ); - - const [error, setError] = useState(""); - - /* Effects - */ - useEffect(() => { - getDecimals(connection, fromMint, setFromMintDecimals); - }, [connection, fromMint]); - - //Retrieve user balance when fromTokenAccount changes - useEffect(() => { - // TODO: cancellable - if (fromTokenAccount && fromTokenAccountExists) { - getBalance(connection, fromTokenAccount, setFromTokenAccountBalance); - } else { - setFromTokenAccountBalance(undefined); - } - }, [ - connection, - fromTokenAccountExists, - fromTokenAccount, - setFromTokenAccountBalance, - ]); - - useEffect(() => { - // TODO: cancellable - if (toTokenAccount && toTokenAccountExists) { - getBalance(connection, toTokenAccount, setToTokenAccountBalance); - } else { - setToTokenAccountBalance(undefined); - } - }, [ - connection, - toTokenAccountExists, - toTokenAccount, - setFromTokenAccountBalance, - ]); - - useEffect(() => { - // TODO: cancellable - if (toCustodyAddress) { - getBalance(connection, toCustodyAddress, setToCustodyBalance); - } else { - setToCustodyBalance(undefined); - } - }, [connection, toCustodyAddress, setToCustodyBalance]); - - //Retrieve pool address on selectedTokens change - useEffect(() => { - if (toMint && fromMint) { - setPoolAddress(""); - setPoolExists(undefined); - getPoolAddress(MIGRATION_PROGRAM_ADDRESS, fromMint, toMint).then( - (result) => { - const key = new PublicKey(result).toString(); - setPoolAddress(key); - }, - (error) => console.log("Could not calculate pool address.") - ); - } - }, [toMint, fromMint, setPoolAddress]); - - //Retrieve the poolAccount every time the pool address changes. - useEffect(() => { - if (poolAddress) { - setPoolExists(undefined); - try { - getMultipleAccounts( - connection, - [new PublicKey(poolAddress)], - "confirmed" - ).then((result) => { - if (result.length && result[0] !== null) { - setPoolExists(true); - } else if (result.length && result[0] === null) { - setPoolExists(false); - setError("There is no swap pool for this token."); - } else { - setError( - "unexpected error in fetching pool address. Please reload and try again" - ); - } - }); - } catch (e) { - setError("Could not fetch pool address"); - } - } - }, [connection, poolAddress]); - - //Set relevant information derived from poolAddress - useEffect(() => { - if (poolAddress) { - getToCustodyAddress(MIGRATION_PROGRAM_ADDRESS, poolAddress) - .then((result: any) => - setToCustodyAddress(new PublicKey(result).toString()) - ) - .catch((e) => { - setToCustodyAddress(undefined); - }); - } else { - setToCustodyAddress(undefined); - } - }, [poolAddress]); - - useEffect(() => { - if (wallet && wallet.publicKey && toMint) { - Token.getAssociatedTokenAddress( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, - new PublicKey(toMint), - wallet.publicKey || new PublicKey([]) - ).then( - (result) => { - setToTokenAccount(result.toString()); - }, - (error) => {} - ); - } - }, [toMint, wallet]); - /* - End effects - */ - - const migrateTokens = useCallback( - async (amount) => { - const instruction = await migrateTokensTx( - connection, - wallet.publicKey?.toString() || "", - MIGRATION_PROGRAM_ADDRESS, - fromMint, - toMint, - fromTokenAccount || "", - toTokenAccount || "", - parseUnits(amount, fromMintDecimals).toBigInt() - ); - return await signSendAndConfirm(wallet, connection, instruction); - }, - [ - connection, - fromMint, - fromTokenAccount, - toMint, - toTokenAccount, - wallet, - fromMintDecimals, - ] - ); - - const fromParse = useCallback( - (amount: string) => { - try { - return parseUnits(amount, fromMintDecimals).toBigInt(); - } catch (e) { - return BigInt(0); - } - }, - [fromMintDecimals] - ); - - const getNotReadyCause = useCallback( - (amount: string) => { - const hasRequisiteData = fromMint && toMint && poolAddress && poolExists; - const accountsReady = fromTokenAccountExists && toTokenAccountExists; - const amountGreaterThanZero = fromParse(amount) > BigInt(0); - const sufficientFromTokens = - fromTokenAccountBalance && - amount && - fromParse(amount) <= fromParse(fromTokenAccountBalance); - const sufficientPoolBalance = - toCustodyBalance && - amount && - parseFloat(amount) <= parseFloat(toCustodyBalance); - - if (!hasRequisiteData) { - return "This asset is not supported."; - } else if (!isReady) { - return "Wallet is not connected."; - } else if (!accountsReady) { - return "You have not created the necessary token accounts."; - } else if (!amount) { - return "Enter an amount to transfer."; - } else if (!amountGreaterThanZero) { - return "Enter an amount greater than zero."; - } else if (!sufficientFromTokens) { - return "There are not sufficient funds in your wallet for this transfer."; - } else if (!sufficientPoolBalance) { - return "There are not sufficient funds in the pool for this transfer."; - } else { - return ""; - } - }, - [ - fromMint, - fromParse, - fromTokenAccountBalance, - fromTokenAccountExists, - isReady, - poolAddress, - poolExists, - toCustodyBalance, - toMint, - toTokenAccountExists, - ] - ); - - const getMetadata = useCallback( - (address: string) => { - const tokenMapItem = solanaTokenMap.data?.find( - (x) => x.address === address - ); - const metaplexItem = metaplexData.data?.get(address); - - return { - symbol: tokenMapItem?.symbol || metaplexItem?.data?.symbol || undefined, - name: tokenMapItem?.name || metaplexItem?.data?.name || undefined, - logo: tokenMapItem?.logoURI || metaplexItem?.data?.uri || undefined, - }; - }, - [metaplexData.data, solanaTokenMap.data] - ); - - const isFetching = solanaTokenMap.isFetching || metaplexData.isFetching; //TODO add loading state on the actual Solana information - const hasRequisiteData = !!( - fromMintDecimals !== null && - fromMintDecimals !== undefined && - toTokenAccount && - fromTokenAccountBalance && - toCustodyAddress && - toCustodyBalance - ); - - const output: DataWrapper = useMemo(() => { - let data: SolanaMigratorInformation | null = null; - if (hasRequisiteData) { - data = { - poolAddress, - fromMint, - toMint, - fromMintDecimals, - fromAssociatedTokenAccountExists: fromTokenAccountExists, - toAssociatedTokenAccountExists: toTokenAccountExists, - fromAssociatedTokenAccount: fromTokenAccount, - toAssociatedTokenAccount: toTokenAccount, - fromAssociatedTokenAccountBalance: fromTokenAccountBalance, - toAssociatedTokenAccountBalance: toTokenAccountBalance || null, - toCustodyAddress, - toCustodyBalance, - - fromName: getMetadata(fromMint)?.name || null, - fromSymbol: getMetadata(fromMint)?.symbol || null, - fromLogo: getMetadata(fromMint)?.logo || null, - toName: getMetadata(toMint)?.name || null, - toSymbol: getMetadata(toMint)?.symbol || null, - toLogo: getMetadata(toMint)?.logo || null, - - setToTokenAccountExists, - - getNotReadyCause: getNotReadyCause, - - migrateTokens, - }; - } - - return { - isFetching: isFetching, - error: error || !hasRequisiteData, - receivedAt: null, - data, - }; - }, [ - error, - isFetching, - hasRequisiteData, - poolAddress, - fromMint, - toMint, - fromMintDecimals, - fromTokenAccountExists, - toTokenAccountExists, - fromTokenAccount, - toTokenAccount, - fromTokenAccountBalance, - toTokenAccountBalance, - toCustodyAddress, - toCustodyBalance, - getMetadata, - getNotReadyCause, - migrateTokens, - setToTokenAccountExists, - ]); - - return output; -} diff --git a/bridge_ui/src/hooks/useSyncTargetAddress.ts b/bridge_ui/src/hooks/useSyncTargetAddress.ts index 907e593dc..cc4b20821 100644 --- a/bridge_ui/src/hooks/useSyncTargetAddress.ts +++ b/bridge_ui/src/hooks/useSyncTargetAddress.ts @@ -1,9 +1,7 @@ import { - canonicalAddress, CHAIN_ID_ALEPHIUM, CHAIN_ID_ALGORAND, CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, isEVMChain, uint8ArrayToHex, } from "@alephium/wormhole-sdk"; @@ -102,18 +100,6 @@ function useSyncTargetAddress(shouldFire: boolean, nft?: boolean) { } } })(); - } else if ( - targetChain === CHAIN_ID_TERRA && - terraWallet && - terraWallet.walletAddress - ) { - dispatch( - setTargetAddressHex( - uint8ArrayToHex( - zeroPad(canonicalAddress(terraWallet.walletAddress), 32) - ) - ) - ); } else if(targetChain === CHAIN_ID_ALEPHIUM && alphWallet.connectionStatus === 'connected') { dispatch(setTargetAddressHex(uint8ArrayToHex(base58.decode(alphWallet.account.address)))) } else if (targetChain === CHAIN_ID_ALGORAND && algoAccounts[0]) { diff --git a/bridge_ui/src/hooks/useTransactionFees.tsx b/bridge_ui/src/hooks/useTransactionFees.tsx index 0341decb0..310af7faf 100644 --- a/bridge_ui/src/hooks/useTransactionFees.tsx +++ b/bridge_ui/src/hooks/useTransactionFees.tsx @@ -18,7 +18,6 @@ import { TERRA_HOST, } from "../utils/consts"; import { getMultipleAccountsRPC } from "../utils/solana"; -import { NATIVE_TERRA_DECIMALS } from "../utils/terra"; import useIsWalletReady from "./useIsWalletReady"; import { LCDClient } from "@terra-money/terra.js"; import { NodeProvider } from "@alephium/web3"; @@ -163,8 +162,6 @@ const toBalanceString = (balance: bigint | undefined, chainId: ChainId) => { return formatUnits(balance, 18); //wei decimals } else if (chainId === CHAIN_ID_SOLANA) { return formatUnits(balance, 9); //lamports to sol decmals - } else if (chainId === CHAIN_ID_TERRA) { - return formatUnits(balance, NATIVE_TERRA_DECIMALS); } }; @@ -343,13 +340,6 @@ function EthGasEstimateSummary({ ); } -const terraEstimatesByContract = { - transfer: { - lowGasEstimate: BigInt(400000), - highGasEstimate: BigInt(700000), - }, -}; - export const evmEstimatesByContract = { transfer: { lowGasEstimate: BigInt(250000), @@ -402,37 +392,6 @@ export async function getGasEstimates( return output; } -function TerraGasEstimateSummary({ methodType }: { methodType: MethodType }) { - if (methodType === "transfer") { - const lowEstimate = formatUnits( - terraEstimatesByContract.transfer.lowGasEstimate, - NATIVE_TERRA_DECIMALS - ); - const highEstimate = formatUnits( - terraEstimatesByContract.transfer.highGasEstimate, - NATIVE_TERRA_DECIMALS - ); - return ( - -
- Est. Fees: {lowEstimate} - {highEstimate} - {" UST"} -
-
- ); - } else { - return null; - } -} - export function GasEstimateSummary({ methodType, chainId, @@ -450,8 +409,6 @@ export function GasEstimateSummary({ priceQuote={priceQuote} /> ); - } else if (chainId === CHAIN_ID_TERRA) { - return ; } else { return null; } diff --git a/bridge_ui/src/utils/algorand.ts b/bridge_ui/src/utils/algorand.ts deleted file mode 100644 index 4c0daf32d..000000000 --- a/bridge_ui/src/utils/algorand.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { TransactionSignerPair } from "@alephium/wormhole-sdk/lib/esm/algorand"; -import MyAlgoConnect from "@randlabs/myalgo-connect"; -import { Algodv2, assignGroupID, waitForConfirmation } from "algosdk"; -import { ALGORAND_WAIT_FOR_CONFIRMATIONS } from "./consts"; - -export async function signSendAndConfirmAlgorand( - algodClient: Algodv2, - txs: TransactionSignerPair[] -) { - const myAlgoConnect = new MyAlgoConnect(); - assignGroupID(txs.map((tx) => tx.tx)); - const signedTxns: Uint8Array[] = []; - const lsigSignedTxns: Uint8Array[] = []; - const walletUnsignedTxns: Uint8Array[] = []; - // sign all the lsigs - for (const lsigTx of txs) { - if (lsigTx.signer) { - lsigSignedTxns.push(await lsigTx.signer.signTxn(lsigTx.tx)); - } - } - // assemble the txs for the wallet to sign - for (const walletTx of txs) { - if (!walletTx.signer) { - walletUnsignedTxns.push(walletTx.tx.toByte()); - } - } - const walletSignedTxns = await myAlgoConnect.signTransaction( - walletUnsignedTxns - ); - let lsigIdx = 0; - let walletIdx = 0; - for (const originalTx of txs) { - if (originalTx.signer) { - signedTxns.push(lsigSignedTxns[lsigIdx++]); - } else { - signedTxns.push(walletSignedTxns[walletIdx++].blob); - } - } - await algodClient.sendRawTransaction(signedTxns).do(); - const result = await waitForConfirmation( - algodClient, - txs[txs.length - 1].tx.txID(), - ALGORAND_WAIT_FOR_CONFIRMATIONS - ); - return result; -} diff --git a/bridge_ui/src/utils/postVaa.ts b/bridge_ui/src/utils/postVaa.ts deleted file mode 100644 index 6106ef23a..000000000 --- a/bridge_ui/src/utils/postVaa.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { chunks, importCoreWasm, ixFromRust } from "@alephium/wormhole-sdk"; -import { sendAndConfirmTransactionsWithRetry } from "@alephium/wormhole-sdk/lib/esm/utils/solana"; -import { - Connection, - Keypair, - PublicKey, - Transaction, - TransactionInstruction, -} from "@solana/web3.js"; - -export async function postVaaWithRetry( - connection: Connection, - signTransaction: (transaction: Transaction) => Promise, - bridge_id: string, - payer: string, - vaa: Buffer, - maxRetries: number -) { - const unsignedTransactions: Transaction[] = []; - const signature_set = Keypair.generate(); - const instructions = await createVerifySignaturesInstructions( - connection, - bridge_id, - payer, - vaa, - signature_set - ); - const finalInstruction = await createPostVaaInstruction( - bridge_id, - payer, - vaa, - signature_set - ); - if (!finalInstruction) { - return Promise.reject("Failed to construct the transaction."); - } - - //The verify signatures instructions can be batched into groups of 2 safely, - //reducing the total number of transactions. - const batchableChunks = chunks(instructions, 2); - batchableChunks.forEach((chunk) => { - let transaction; - if (chunk.length === 1) { - transaction = new Transaction().add(chunk[0]); - } else { - transaction = new Transaction().add(chunk[0], chunk[1]); - } - unsignedTransactions.push(transaction); - }); - - //the postVaa instruction can only execute after the verifySignature transactions have - //successfully completed. - const finalTransaction = new Transaction().add(finalInstruction); - - //The signature_set keypair also needs to sign the verifySignature transactions, thus a wrapper is needed. - const partialSignWrapper = (transaction: Transaction) => { - transaction.partialSign(signature_set); - return signTransaction(transaction); - }; - - await sendAndConfirmTransactionsWithRetry( - connection, - partialSignWrapper, - payer, - unsignedTransactions, - maxRetries - ); - //While the signature_set is used to create the final instruction, it doesn't need to sign it. - await sendAndConfirmTransactionsWithRetry( - connection, - signTransaction, - payer, - [finalTransaction], - maxRetries - ); - - return Promise.resolve(); -} - -/* - This returns an array of instructions required to verify the signatures of a VAA, and upload it to the blockchain. - signature_set should be a new keypair, and also needs to partial sign the transaction when these instructions are submitted. - */ -export async function createVerifySignaturesInstructions( - connection: Connection, - bridge_id: string, - payer: string, - vaa: Buffer, - signature_set: Keypair -): Promise { - const output: TransactionInstruction[] = []; - const { - guardian_set_address, - parse_guardian_set, - parse_vaa, - verify_signatures_ix, - } = await importCoreWasm(); - const { guardian_set_index } = parse_vaa(new Uint8Array(vaa)); - let guardian_addr = new PublicKey( - guardian_set_address(bridge_id, guardian_set_index) - ); - let acc = await connection.getAccountInfo(guardian_addr); - if (acc?.data === undefined) { - return output; - } - let guardian_data = parse_guardian_set(new Uint8Array(acc?.data)); - - let txs = verify_signatures_ix( - bridge_id, - payer, - guardian_set_index, - guardian_data, - signature_set.publicKey.toString(), - vaa - ); - // Add transfer instruction to transaction - for (let tx of txs) { - let ixs: Array = tx.map((v: any) => { - return ixFromRust(v); - }); - output.push(ixs[0], ixs[1]); - } - return output; -} - -/* - This will return the postVaaInstruction. This should only be executed after the verifySignaturesInstructions have been executed. - signatureSetKeypair should be the same keypair used for verifySignaturesInstructions, but does not need to partialSign the transaction - when this instruction is submitted. - */ -export async function createPostVaaInstruction( - bridge_id: string, - payer: string, - vaa: Buffer, - signatureSetKeypair: Keypair -): Promise { - const { post_vaa_ix } = await importCoreWasm(); - return ixFromRust( - post_vaa_ix(bridge_id, payer, signatureSetKeypair.publicKey.toString(), vaa) - ); -} - -/* - @deprecated - Instead, either use postVaaWithRetry or create, sign, and send the verifySignaturesInstructions & postVaaInstruction yourself. - - This function is equivalent to a postVaaWithRetry with a maxRetries of 0. - */ -export async function postVaa( - connection: Connection, - signTransaction: (transaction: Transaction) => Promise, - bridge_id: string, - payer: string, - vaa: Buffer -) { - const { - guardian_set_address, - parse_guardian_set, - parse_vaa, - post_vaa_ix, - verify_signatures_ix, - } = await importCoreWasm(); - const { guardian_set_index } = parse_vaa(new Uint8Array(vaa)); - let guardian_addr = new PublicKey( - guardian_set_address(bridge_id, guardian_set_index) - ); - let acc = await connection.getAccountInfo(guardian_addr); - if (acc?.data === undefined) { - return; - } - let guardian_data = parse_guardian_set(new Uint8Array(acc?.data)); - - let signature_set = Keypair.generate(); - let txs = verify_signatures_ix( - bridge_id, - payer, - guardian_set_index, - guardian_data, - signature_set.publicKey.toString(), - vaa - ); - // Add transfer instruction to transaction - for (let tx of txs) { - let ixs: Array = tx.map((v: any) => { - return ixFromRust(v); - }); - let transaction = new Transaction().add(...ixs); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payer); - transaction.partialSign(signature_set); - - // Sign transaction, broadcast, and confirm - const signed = await signTransaction(transaction); - const txid = await connection.sendRawTransaction(signed.serialize()); - await connection.confirmTransaction(txid); - } - - let ix = ixFromRust( - post_vaa_ix(bridge_id, payer, signature_set.publicKey.toString(), vaa) - ); - let transaction = new Transaction().add(ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payer); - - const signed = await signTransaction(transaction); - const txid = await connection.sendRawTransaction(signed.serialize()); - await connection.confirmTransaction(txid); -} diff --git a/bridge_ui/src/utils/terra.ts b/bridge_ui/src/utils/terra.ts deleted file mode 100644 index e9b43a3c1..000000000 --- a/bridge_ui/src/utils/terra.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { - canonicalAddress, - isNativeDenom, - isNativeTerra, -} from "@alephium/wormhole-sdk"; -import { formatUnits } from "@ethersproject/units"; -import { LCDClient, isTxError } from "@terra-money/terra.js"; -import { ConnectedWallet, TxResult } from "@terra-money/wallet-provider"; -import axios from "axios"; -// import { TerraTokenMetadata } from "../hooks/useTerraTokenMap"; -import { TERRA_GAS_PRICES_URL, TERRA_HOST } from "./consts"; - -export const NATIVE_TERRA_DECIMALS = 6; -export const LUNA_CLASSIC_SYMBOL = "LUNC" - -export const getNativeTerraIcon = (symbol = "") => - `https://assets.terra.money/icon/60/${ - symbol === LUNA_CLASSIC_SYMBOL ? "Luna" : symbol.slice(0, symbol.length - 1) - }.png`; - -// inspired by https://github.com/terra-money/station/blob/dca7de43958ce075c6e46605622203b9859b0e14/src/lib/utils/format.ts#L38 -export const formatNativeDenom = (denom = ""): string => { - const unit = denom.slice(1).toUpperCase(); - const isValidTerra = isNativeTerra(denom); - return denom === "uluna" - ? LUNA_CLASSIC_SYMBOL - : isValidTerra - ? unit.slice(0, 2) + "TC" - : ""; -}; - -export const formatTerraNativeBalance = (balance = ""): string => - formatUnits(balance, 6); - -export async function waitForTerraExecution(transaction: TxResult) { - const lcd = new LCDClient(TERRA_HOST); - let info; - while (!info) { - await new Promise((resolve) => setTimeout(resolve, 1000)); - try { - info = await lcd.tx.txInfo(transaction.result.txhash); - } catch (e) { - console.error(e); - } - } - if (isTxError(info)) { - throw new Error( - `Tx ${transaction.result.txhash}: error code ${info.code}: ${info.raw_log}` - ); - } - return info; -} - -export const isValidTerraAddress = (address: string) => { - if (isNativeDenom(address)) { - return true; - } - try { - const startsWithTerra = address && address.startsWith("terra"); - const isParseable = canonicalAddress(address); - const isLength20 = isParseable.length === 20; - return !!(startsWithTerra && isParseable && isLength20); - } catch (error) { - return false; - } -}; - -export async function postWithFees( - wallet: ConnectedWallet, - msgs: any[], - memo: string, - feeDenoms: string[] -) { - // don't try/catch, let errors propagate - const lcd = new LCDClient(TERRA_HOST); - //let gasPrices = await lcd.config.gasPrices //Unsure if the values returned from this are hardcoded or not. - //Thus, we are going to pull it directly from the current FCD. - const gasPrices = await axios - .get(TERRA_GAS_PRICES_URL) - .then((result) => result.data); - - const account = await lcd.auth.accountInfo(wallet.walletAddress); - - const feeEstimate = await lcd.tx.estimateFee( - [ - { - sequenceNumber: account.getSequenceNumber(), - publicKey: account.getPublicKey(), - }, - ], - { - msgs: [...msgs], - memo, - feeDenoms, - gasPrices, - } - ); - - const result = await wallet.post({ - msgs: [...msgs], - memo, - feeDenoms, - gasPrices, - fee: feeEstimate, - }); - - return result; -} diff --git a/sdk/js/package-lock.json b/sdk/js/package-lock.json index d3b959c17..ba41c4916 100644 --- a/sdk/js/package-lock.json +++ b/sdk/js/package-lock.json @@ -1,22 +1,17 @@ { "name": "@alephium/wormhole-sdk", - "version": "0.3.7", + "version": "0.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@alephium/wormhole-sdk", - "version": "0.3.7", + "version": "0.4.0", "license": "Apache-2.0", "dependencies": { "@alephium/token-list": "0.0.11", - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "@improbable-eng/grpc-web": "^0.14.0", - "@solana/spl-token": "^0.1.8", - "@solana/web3.js": "^1.24.0", - "@terra-money/terra.js": "^3.0.7", - "algosdk": "2.4.0", - "axios": "^0.24.0", "bech32": "^2.0.0", "bs58": "^5.0.0", "ethers": "^5.6.8", @@ -56,9 +51,9 @@ } }, "node_modules/@alephium/web3": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.0.tgz", - "integrity": "sha512-vT4Kd/5sGUuKdfHzy+BLenOuVMPPpZXV7arNEgNZYdgYs5AnT3MTzCmJBbVosn9WeEipfb/p2x4xjAjMKffMYQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.1.tgz", + "integrity": "sha512-aAyxLw2OfsQD4t33T7gE6wfeFXqeQApgp1x5pLYWbKgn+DMlJbEC/jFrxTuOztQByrv9Fr3ApxNZ5CISWkJQCA==", "dependencies": { "@noble/secp256k1": "1.7.1", "base-x": "4.0.0", @@ -563,17 +558,6 @@ "@babel/core": "^7.0.0-0" } }, - "node_modules/@babel/runtime": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.3.tgz", - "integrity": "sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug==", - "dependencies": { - "regenerator-runtime": "^0.13.4" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/template": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.0.tgz", @@ -2083,123 +2067,6 @@ "@sinonjs/commons": "^1.7.0" } }, - "node_modules/@solana/buffer-layout": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.0.tgz", - "integrity": "sha512-lR0EMP2HC3+Mxwd4YcnZb0smnaDw7Bl2IQWZiTevRH5ZZBZn6VRWn3/92E3qdU4SSImJkA6IDHawOHAnx/qUvQ==", - "dependencies": { - "buffer": "~6.0.3" - }, - "engines": { - "node": ">=5.10" - } - }, - "node_modules/@solana/spl-token": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.1.8.tgz", - "integrity": "sha512-LZmYCKcPQDtJgecvWOgT/cnoIQPWjdH+QVyzPcFvyDUiT0DiRjZaam4aqNUyvchLFhzgunv3d9xOoyE34ofdoQ==", - "dependencies": { - "@babel/runtime": "^7.10.5", - "@solana/web3.js": "^1.21.0", - "bn.js": "^5.1.0", - "buffer": "6.0.3", - "buffer-layout": "^1.2.0", - "dotenv": "10.0.0" - }, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@solana/web3.js": { - "version": "1.43.1", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.43.1.tgz", - "integrity": "sha512-s6TRcWz3rYvxM8gg1eQmUAUJQeoXIFMG9MbSWb/uRrLU0q7Xd9Ic1PNbACp1n1O0wyCogTAyFWXXPK476aIVSg==", - "dependencies": { - "@babel/runtime": "^7.12.5", - "@ethersproject/sha2": "^5.5.0", - "@solana/buffer-layout": "^4.0.0", - "bigint-buffer": "^1.1.5", - "bn.js": "^5.0.0", - "borsh": "^0.7.0", - "bs58": "^4.0.1", - "buffer": "6.0.1", - "cross-fetch": "^3.1.4", - "fast-stable-stringify": "^1.0.0", - "jayson": "^3.4.4", - "js-sha3": "^0.8.0", - "rpc-websockets": "^7.4.2", - "secp256k1": "^4.0.2", - "superstruct": "^0.14.2", - "tweetnacl": "^1.0.0" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@solana/web3.js/node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "dependencies": { - "base-x": "^3.0.2" - } - }, - "node_modules/@solana/web3.js/node_modules/buffer": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.1.tgz", - "integrity": "sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/@terra-money/terra.js": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@terra-money/terra.js/-/terra.js-3.0.7.tgz", - "integrity": "sha512-moeVBWqIPZaV0HmCY127Y9H/MsuFtH1VgW0xEvDQWqu1jpKhK5CtPHMLKNje3mKSjU8A7vXZ8hlW3KobqP2poQ==", - "dependencies": { - "@terra-money/terra.proto": "^0.1.7", - "axios": "^0.24.0", - "bech32": "^2.0.0", - "bip32": "^2.0.6", - "bip39": "^3.0.3", - "bufferutil": "^4.0.3", - "decimal.js": "^10.2.1", - "jscrypto": "^1.0.1", - "readable-stream": "^3.6.0", - "secp256k1": "^4.0.2", - "tmp": "^0.2.1", - "utf-8-validate": "^5.0.5", - "ws": "^7.5.5" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@terra-money/terra.proto": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz", - "integrity": "sha512-NXD7f6pQCulvo6+mv6MAPzhOkUzRjgYVuHZE/apih+lVnPG5hDBU0rRYnOGGofwvKT5/jQoOENnFn/gioWWnyQ==", - "dependencies": { - "google-protobuf": "^3.17.3", - "long": "^4.0.0", - "protobufjs": "~6.11.2" - } - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -2274,14 +2141,6 @@ "@types/node": "*" } }, - "node_modules/@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/elliptic": { "version": "6.4.14", "resolved": "https://registry.npmjs.org/@types/elliptic/-/elliptic-6.4.14.tgz", @@ -2291,16 +2150,6 @@ "@types/bn.js": "*" } }, - "node_modules/@types/express-serve-static-core": { - "version": "4.17.28", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz", - "integrity": "sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig==", - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*" - } - }, "node_modules/@types/graceful-fs": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", @@ -2344,11 +2193,6 @@ "pretty-format": "^27.0.0" } }, - "node_modules/@types/lodash": { - "version": "4.14.182", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz", - "integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==" - }, "node_modules/@types/long": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", @@ -2371,16 +2215,6 @@ "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==", "dev": true }, - "node_modules/@types/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" - }, - "node_modules/@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" - }, "node_modules/@types/react": { "version": "17.0.19", "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.19.tgz", @@ -2404,14 +2238,6 @@ "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "dev": true }, - "node_modules/@types/ws": { - "version": "7.4.7", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", - "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/yargs": { "version": "16.0.4", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", @@ -2493,34 +2319,6 @@ "node": ">= 6.0.0" } }, - "node_modules/algo-msgpack-with-bigint": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/algo-msgpack-with-bigint/-/algo-msgpack-with-bigint-2.1.1.tgz", - "integrity": "sha512-F1tGh056XczEaEAqu7s+hlZUDWwOBT70Eq0lfMpBP2YguSQVyxRbprLq5rELXKQOyOaixTWYhMeMQMzP0U5FoQ==", - "engines": { - "node": ">= 10" - } - }, - "node_modules/algosdk": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/algosdk/-/algosdk-2.4.0.tgz", - "integrity": "sha512-sENe6IyUqvhQprfS/7gJAkPC5sX2LI5uc+gXaKNgzKp72UEyXYSoN3h4MZkOlCrOcTSWTJW7605tYgg8nFkflw==", - "dependencies": { - "algo-msgpack-with-bigint": "^2.1.1", - "buffer": "^6.0.3", - "cross-fetch": "^3.1.5", - "hi-base32": "^0.5.1", - "js-sha256": "^0.9.0", - "js-sha3": "^0.8.0", - "js-sha512": "^0.8.0", - "json-bigint": "^1.0.0", - "tweetnacl": "^1.0.3", - "vlq": "^2.0.4" - }, - "engines": { - "node": ">=16.0.0" - } - }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -2613,14 +2411,6 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, - "node_modules/axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", - "dependencies": { - "follow-redirects": "^1.14.4" - } - }, "node_modules/babel-jest": { "version": "27.3.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.3.1.tgz", @@ -2811,52 +2601,14 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "node_modules/base-x": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz", - "integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/bech32": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", "integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==" }, - "node_modules/bigint-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", - "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", - "hasInstallScript": true, - "dependencies": { - "bindings": "^1.3.0" - }, - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/bignumber.js": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", @@ -2865,52 +2617,6 @@ "node": "*" } }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, - "node_modules/bip32": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz", - "integrity": "sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==", - "dependencies": { - "@types/node": "10.12.18", - "bs58check": "^2.1.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "tiny-secp256k1": "^1.1.3", - "typeforce": "^1.11.5", - "wif": "^2.0.6" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/bip32/node_modules/@types/node": { - "version": "10.12.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", - "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" - }, - "node_modules/bip39": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.0.4.tgz", - "integrity": "sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw==", - "dependencies": { - "@types/node": "11.11.6", - "create-hash": "^1.1.0", - "pbkdf2": "^3.0.9", - "randombytes": "^2.0.1" - } - }, - "node_modules/bip39/node_modules/@types/node": { - "version": "11.11.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.11.6.tgz", - "integrity": "sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==" - }, "node_modules/blakejs": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", @@ -2921,28 +2627,11 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, - "node_modules/borsh": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", - "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", - "dependencies": { - "bn.js": "^5.2.0", - "bs58": "^4.0.0", - "text-encoding-utf-8": "^1.0.2" - } - }, - "node_modules/borsh/node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "dependencies": { - "base-x": "^3.0.2" - } - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3154,24 +2843,6 @@ "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz", "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==" }, - "node_modules/bs58check": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", - "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", - "dependencies": { - "bs58": "^4.0.0", - "create-hash": "^1.1.0", - "safe-buffer": "^5.1.2" - } - }, - "node_modules/bs58check/node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", - "dependencies": { - "base-x": "^3.0.2" - } - }, "node_modules/bser": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", @@ -3181,43 +2852,12 @@ "node-int64": "^0.4.0" } }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, - "node_modules/buffer-layout": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz", - "integrity": "sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==", - "engines": { - "node": ">=4.5" - } - }, "node_modules/buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -3228,6 +2868,8 @@ "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.3.tgz", "integrity": "sha512-yEYTwGndELGvfXsImMBLop58eaGW+YdONi1fNjTINSY98tmMmFijBG6WXgdkfuLNt4imzQNtIE+eBp1PVpMCSw==", "hasInstallScript": true, + "optional": true, + "peer": true, "dependencies": { "node-gyp-build": "^4.2.0" } @@ -3385,12 +3027,14 @@ "node_modules/commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "node_modules/convert-source-map": { "version": "1.8.0", @@ -3580,7 +3224,8 @@ "node_modules/decimal.js": { "version": "10.3.1", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", - "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" + "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==", + "dev": true }, "node_modules/dedent": { "version": "0.7.0", @@ -3603,17 +3248,6 @@ "node": ">=0.10.0" } }, - "node_modules/delay": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", - "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -3695,14 +3329,6 @@ "node": ">=8" } }, - "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", - "engines": { - "node": ">=10" - } - }, "node_modules/electron-to-chromium": { "version": "1.3.889", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.889.tgz", @@ -3769,19 +3395,6 @@ "node": ">=0.10.0" } }, - "node_modules/es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" - }, - "node_modules/es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "dependencies": { - "es6-promise": "^4.0.3" - } - }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -3985,14 +3598,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/eyes": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", - "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=", - "engines": { - "node": "> 0.1.90" - } - }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -4005,11 +3610,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "node_modules/fast-stable-stringify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", - "integrity": "sha1-XFVDRisiru79NtBbNOUceMuG0xM=" - }, "node_modules/fb-watchman": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz", @@ -4019,11 +3619,6 @@ "bser": "2.1.1" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -4076,25 +3671,6 @@ "node": ">=8" } }, - "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, "node_modules/form-data": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", @@ -4144,7 +3720,8 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, "node_modules/fsevents": { "version": "2.3.2", @@ -4209,6 +3786,7 @@ "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -4236,7 +3814,8 @@ "node_modules/google-protobuf": { "version": "3.17.3", "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.17.3.tgz", - "integrity": "sha512-OVPzcSWIAJ+d5yiHyeaLrdufQtrvaBrF4JQg+z8ynTkbO3uFcujqXszTumqg1cGsAsjkWnI+M5B1xZ19yR4Wyg==" + "integrity": "sha512-OVPzcSWIAJ+d5yiHyeaLrdufQtrvaBrF4JQg+z8ynTkbO3uFcujqXszTumqg1cGsAsjkWnI+M5B1xZ19yR4Wyg==", + "peer": true }, "node_modules/graceful-fs": { "version": "4.2.11", @@ -4286,11 +3865,6 @@ "minimalistic-assert": "^1.0.1" } }, - "node_modules/hi-base32": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/hi-base32/-/hi-base32-0.5.1.tgz", - "integrity": "sha512-EmBBpvdYh/4XxsnUybsPag6VikPYnN30td+vQk+GI3qpahVEG9+gTkG0aXVxTjBqQ5T6ijbWIu77O+C5WFWsnA==" - }, "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -4367,25 +3941,6 @@ "node": ">=0.10.0" } }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, "node_modules/import-local": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.3.tgz", @@ -4415,6 +3970,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -4499,14 +4055,6 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "node_modules/isomorphic-ws": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", - "peerDependencies": { - "ws": "*" - } - }, "node_modules/istanbul-lib-coverage": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", @@ -4611,47 +4159,6 @@ "node": ">=8" } }, - "node_modules/jayson": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/jayson/-/jayson-3.6.6.tgz", - "integrity": "sha512-f71uvrAWTtrwoww6MKcl9phQTC+56AopLyEenWvKVAIMz+q0oVGj6tenLZ7Z6UiPBkJtKLj4kt0tACllFQruGQ==", - "dependencies": { - "@types/connect": "^3.4.33", - "@types/express-serve-static-core": "^4.17.9", - "@types/lodash": "^4.14.159", - "@types/node": "^12.12.54", - "@types/ws": "^7.4.4", - "commander": "^2.20.3", - "delay": "^5.0.0", - "es6-promisify": "^5.0.0", - "eyes": "^0.1.8", - "isomorphic-ws": "^4.0.1", - "json-stringify-safe": "^5.0.1", - "JSONStream": "^1.3.5", - "lodash": "^4.17.20", - "uuid": "^8.3.2", - "ws": "^7.4.5" - }, - "bin": { - "jayson": "bin/jayson.js" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jayson/node_modules/@types/node": { - "version": "12.20.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.52.tgz", - "integrity": "sha512-cfkwWw72849SNYp3Zx0IcIs25vABmFh73xicxhCkTcvtZQeIez15PpwQN8fY3RD7gv1Wrxlc9MEtfMORZDEsGw==" - }, - "node_modules/jayson/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/jest": { "version": "27.3.1", "resolved": "https://registry.npmjs.org/jest/-/jest-27.3.1.tgz", @@ -6349,21 +5856,11 @@ "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.6.1.tgz", "integrity": "sha512-Frdq2+tRRGLQUIQOgsIGSCd1VePCS2fsddTG5dTCqR0JHgltXWfsxnY0gIXPoMeRmdom6Oyq+UMOFg5suduOjQ==" }, - "node_modules/js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, "node_modules/js-sha3": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" }, - "node_modules/js-sha512": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/js-sha512/-/js-sha512-0.8.0.tgz", - "integrity": "sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -6383,14 +5880,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/jscrypto": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/jscrypto/-/jscrypto-1.0.2.tgz", - "integrity": "sha512-r+oNJLGTv1nkNMBBq3c70xYrFDgJOYVgs2OHijz5Ht+0KJ0yObD0oYxC9mN72KLzVfXw+osspg6t27IZvuTUxw==", - "bin": { - "jscrypto": "bin/cli.js" - } - }, "node_modules/jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -6449,19 +5938,6 @@ "node": ">=4" } }, - "node_modules/json-bigint": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", - "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", - "dependencies": { - "bignumber.js": "^9.0.0" - } - }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -6484,29 +5960,6 @@ "graceful-fs": "^4.1.6" } }, - "node_modules/jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "engines": [ - "node >= 0.2.0" - ] - }, - "node_modules/JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dependencies": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - }, - "bin": { - "JSONStream": "bin.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -6553,7 +6006,8 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true }, "node_modules/lodash.memoize": { "version": "4.1.2", @@ -6707,6 +6161,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -6741,22 +6196,12 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/nan": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", - "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==" - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "node_modules/node-addon-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" - }, "node_modules/node-fetch": { "version": "2.6.12", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", @@ -6799,6 +6244,8 @@ "version": "4.2.3", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", + "optional": true, + "peer": true, "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", @@ -6848,6 +6295,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "dependencies": { "wrappy": "1" } @@ -6972,6 +6420,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -7208,11 +6657,6 @@ "node": ">= 6" } }, - "node_modules/regenerator-runtime": { - "version": "0.13.9", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -7269,6 +6713,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, "dependencies": { "glob": "^7.1.3" }, @@ -7288,53 +6733,6 @@ "inherits": "^2.0.1" } }, - "node_modules/rpc-websockets": { - "version": "7.4.18", - "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.4.18.tgz", - "integrity": "sha512-bVu+4qM5CkGVlTqJa6FaAxLbb5uRnyH4te7yjFvoCzbnif7PT4BcvXtNTprHlNvsH+/StB81zUQicxMrUrIomA==", - "dependencies": { - "@babel/runtime": "^7.17.2", - "eventemitter3": "^4.0.7", - "uuid": "^8.3.2", - "ws": "^8.5.0" - }, - "funding": { - "type": "paypal", - "url": "https://paypal.me/kozjak" - }, - "optionalDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - } - }, - "node_modules/rpc-websockets/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/rpc-websockets/node_modules/ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/rxjs": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz", @@ -7385,24 +6783,10 @@ "node": ">=10" } }, - "node_modules/scrypt-js": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", - "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" - }, - "node_modules/secp256k1": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz", - "integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==", - "hasInstallScript": true, - "dependencies": { - "elliptic": "^6.5.2", - "node-addon-api": "^2.0.0", - "node-gyp-build": "^4.2.0" - }, - "engines": { - "node": ">=10.0.0" - } + "node_modules/scrypt-js": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", + "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" }, "node_modules/semver": { "version": "5.7.1", @@ -7596,11 +6980,6 @@ "node": ">=6" } }, - "node_modules/superstruct": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz", - "integrity": "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==" - }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -7710,54 +7089,12 @@ "node": ">=0.12.0" } }, - "node_modules/text-encoding-utf-8": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", - "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" - }, "node_modules/throat": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/throat/-/throat-6.0.1.tgz", "integrity": "sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==", "dev": true }, - "node_modules/through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" - }, - "node_modules/tiny-secp256k1": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz", - "integrity": "sha512-FmqJZGduTyvsr2cF3375fqGHUovSwDi/QytexX1Se4BPuPZpTE5Ftp5fg+EFSuEf3lhZqgCRjEG3ydUQ/aNiwA==", - "hasInstallScript": true, - "dependencies": { - "bindings": "^1.3.0", - "bn.js": "^4.11.8", - "create-hmac": "^1.1.7", - "elliptic": "^6.4.0", - "nan": "^2.13.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/tiny-secp256k1/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - }, - "node_modules/tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", - "dependencies": { - "rimraf": "^3.0.0" - }, - "engines": { - "node": ">=8.17.0" - } - }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -7937,11 +7274,6 @@ "typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev" } }, - "node_modules/tweetnacl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" - }, "node_modules/type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -8025,11 +7357,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typeforce": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.18.0.tgz", - "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" - }, "node_modules/typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", @@ -8064,6 +7391,8 @@ "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.5.tgz", "integrity": "sha512-+pnxRYsS/axEpkrrEpzYfNZGXp0IjC/9RIxwM5gntY4Koi8SHmUGSfxfWqxZdRxrtaoVstuOzUp/rbs3JSPELQ==", "hasInstallScript": true, + "optional": true, + "peer": true, "dependencies": { "node-gyp-build": "^4.2.0" } @@ -8096,11 +7425,6 @@ "node": ">= 8" } }, - "node_modules/vlq": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vlq/-/vlq-2.0.4.tgz", - "integrity": "sha512-aodjPa2wPQFkra1G8CzJBTHXhgk3EVSwxSWXNPr1fgdFLUb8kvLV1iEb6rFgasIsjP82HWI6dsb5Io26DDnasA==" - }, "node_modules/w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", @@ -8184,14 +7508,6 @@ "node": ">= 8" } }, - "node_modules/wif": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/wif/-/wif-2.0.6.tgz", - "integrity": "sha1-CNP1IFbGZnkplyb63g1DKudLRwQ=", - "dependencies": { - "bs58check": "<3.0.0" - } - }, "node_modules/word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -8254,7 +7570,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "node_modules/write-file-atomic": { "version": "3.0.3", @@ -8272,6 +7589,7 @@ "version": "7.5.7", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "dev": true, "engines": { "node": ">=8.3.0" }, @@ -8353,9 +7671,9 @@ } }, "@alephium/web3": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.0.tgz", - "integrity": "sha512-vT4Kd/5sGUuKdfHzy+BLenOuVMPPpZXV7arNEgNZYdgYs5AnT3MTzCmJBbVosn9WeEipfb/p2x4xjAjMKffMYQ==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@alephium/web3/-/web3-1.11.1.tgz", + "integrity": "sha512-aAyxLw2OfsQD4t33T7gE6wfeFXqeQApgp1x5pLYWbKgn+DMlJbEC/jFrxTuOztQByrv9Fr3ApxNZ5CISWkJQCA==", "requires": { "@noble/secp256k1": "1.7.1", "base-x": "4.0.0", @@ -8740,14 +8058,6 @@ "@babel/helper-plugin-utils": "^7.14.5" } }, - "@babel/runtime": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.18.3.tgz", - "integrity": "sha512-38Y8f7YUhce/K7RMwTp7m0uCumpv9hZkitCbBClqQIow1qSbCvGkcegKOXpEWCQLfWmevgRiWokZ1GkpfhbZug==", - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, "@babel/template": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.0.tgz", @@ -9766,99 +9076,6 @@ "@sinonjs/commons": "^1.7.0" } }, - "@solana/buffer-layout": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.0.tgz", - "integrity": "sha512-lR0EMP2HC3+Mxwd4YcnZb0smnaDw7Bl2IQWZiTevRH5ZZBZn6VRWn3/92E3qdU4SSImJkA6IDHawOHAnx/qUvQ==", - "requires": { - "buffer": "~6.0.3" - } - }, - "@solana/spl-token": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.1.8.tgz", - "integrity": "sha512-LZmYCKcPQDtJgecvWOgT/cnoIQPWjdH+QVyzPcFvyDUiT0DiRjZaam4aqNUyvchLFhzgunv3d9xOoyE34ofdoQ==", - "requires": { - "@babel/runtime": "^7.10.5", - "@solana/web3.js": "^1.21.0", - "bn.js": "^5.1.0", - "buffer": "6.0.3", - "buffer-layout": "^1.2.0", - "dotenv": "10.0.0" - } - }, - "@solana/web3.js": { - "version": "1.43.1", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.43.1.tgz", - "integrity": "sha512-s6TRcWz3rYvxM8gg1eQmUAUJQeoXIFMG9MbSWb/uRrLU0q7Xd9Ic1PNbACp1n1O0wyCogTAyFWXXPK476aIVSg==", - "requires": { - "@babel/runtime": "^7.12.5", - "@ethersproject/sha2": "^5.5.0", - "@solana/buffer-layout": "^4.0.0", - "bigint-buffer": "^1.1.5", - "bn.js": "^5.0.0", - "borsh": "^0.7.0", - "bs58": "^4.0.1", - "buffer": "6.0.1", - "cross-fetch": "^3.1.4", - "fast-stable-stringify": "^1.0.0", - "jayson": "^3.4.4", - "js-sha3": "^0.8.0", - "rpc-websockets": "^7.4.2", - "secp256k1": "^4.0.2", - "superstruct": "^0.14.2", - "tweetnacl": "^1.0.0" - }, - "dependencies": { - "bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "requires": { - "base-x": "^3.0.2" - } - }, - "buffer": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.1.tgz", - "integrity": "sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ==", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - } - } - }, - "@terra-money/terra.js": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/@terra-money/terra.js/-/terra.js-3.0.7.tgz", - "integrity": "sha512-moeVBWqIPZaV0HmCY127Y9H/MsuFtH1VgW0xEvDQWqu1jpKhK5CtPHMLKNje3mKSjU8A7vXZ8hlW3KobqP2poQ==", - "requires": { - "@terra-money/terra.proto": "^0.1.7", - "axios": "^0.24.0", - "bech32": "^2.0.0", - "bip32": "^2.0.6", - "bip39": "^3.0.3", - "bufferutil": "^4.0.3", - "decimal.js": "^10.2.1", - "jscrypto": "^1.0.1", - "readable-stream": "^3.6.0", - "secp256k1": "^4.0.2", - "tmp": "^0.2.1", - "utf-8-validate": "^5.0.5", - "ws": "^7.5.5" - } - }, - "@terra-money/terra.proto": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-0.1.7.tgz", - "integrity": "sha512-NXD7f6pQCulvo6+mv6MAPzhOkUzRjgYVuHZE/apih+lVnPG5hDBU0rRYnOGGofwvKT5/jQoOENnFn/gioWWnyQ==", - "requires": { - "google-protobuf": "^3.17.3", - "long": "^4.0.0", - "protobufjs": "~6.11.2" - } - }, "@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -9922,14 +9139,6 @@ "@types/node": "*" } }, - "@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", - "requires": { - "@types/node": "*" - } - }, "@types/elliptic": { "version": "6.4.14", "resolved": "https://registry.npmjs.org/@types/elliptic/-/elliptic-6.4.14.tgz", @@ -9939,16 +9148,6 @@ "@types/bn.js": "*" } }, - "@types/express-serve-static-core": { - "version": "4.17.28", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz", - "integrity": "sha512-P1BJAEAW3E2DJUlkgq4tOL3RyMunoWXqbSCygWo5ZIWTjUgN1YnaXWW4VWl/oc8vs/XoYibEGBKP0uZyF4AHig==", - "requires": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*" - } - }, "@types/graceful-fs": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", @@ -9992,11 +9191,6 @@ "pretty-format": "^27.0.0" } }, - "@types/lodash": { - "version": "4.14.182", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz", - "integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==" - }, "@types/long": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", @@ -10019,16 +9213,6 @@ "integrity": "sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==", "dev": true }, - "@types/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==" - }, - "@types/range-parser": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", - "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==" - }, "@types/react": { "version": "17.0.19", "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.19.tgz", @@ -10052,14 +9236,6 @@ "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", "dev": true }, - "@types/ws": { - "version": "7.4.7", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", - "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", - "requires": { - "@types/node": "*" - } - }, "@types/yargs": { "version": "16.0.4", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", @@ -10125,28 +9301,6 @@ "debug": "4" } }, - "algo-msgpack-with-bigint": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/algo-msgpack-with-bigint/-/algo-msgpack-with-bigint-2.1.1.tgz", - "integrity": "sha512-F1tGh056XczEaEAqu7s+hlZUDWwOBT70Eq0lfMpBP2YguSQVyxRbprLq5rELXKQOyOaixTWYhMeMQMzP0U5FoQ==" - }, - "algosdk": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/algosdk/-/algosdk-2.4.0.tgz", - "integrity": "sha512-sENe6IyUqvhQprfS/7gJAkPC5sX2LI5uc+gXaKNgzKp72UEyXYSoN3h4MZkOlCrOcTSWTJW7605tYgg8nFkflw==", - "requires": { - "algo-msgpack-with-bigint": "^2.1.1", - "buffer": "^6.0.3", - "cross-fetch": "^3.1.5", - "hi-base32": "^0.5.1", - "js-sha256": "^0.9.0", - "js-sha3": "^0.8.0", - "js-sha512": "^0.8.0", - "json-bigint": "^1.0.0", - "tweetnacl": "^1.0.3", - "vlq": "^2.0.4" - } - }, "ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -10223,14 +9377,6 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, - "axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", - "requires": { - "follow-redirects": "^1.14.4" - } - }, "babel-jest": { "version": "27.3.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.3.1.tgz", @@ -10377,86 +9523,19 @@ "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" - }, - "base-x": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz", - "integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==", - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "bech32": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", "integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==" }, - "bigint-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", - "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", - "requires": { - "bindings": "^1.3.0" - } - }, "bignumber.js": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", "integrity": "sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==" }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "requires": { - "file-uri-to-path": "1.0.0" - } - }, - "bip32": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz", - "integrity": "sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==", - "requires": { - "@types/node": "10.12.18", - "bs58check": "^2.1.1", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "tiny-secp256k1": "^1.1.3", - "typeforce": "^1.11.5", - "wif": "^2.0.6" - }, - "dependencies": { - "@types/node": { - "version": "10.12.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", - "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" - } - } - }, - "bip39": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.0.4.tgz", - "integrity": "sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw==", - "requires": { - "@types/node": "11.11.6", - "create-hash": "^1.1.0", - "pbkdf2": "^3.0.9", - "randombytes": "^2.0.1" - }, - "dependencies": { - "@types/node": { - "version": "11.11.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-11.11.6.tgz", - "integrity": "sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==" - } - } - }, "blakejs": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", @@ -10467,30 +9546,11 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, - "borsh": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", - "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", - "requires": { - "bn.js": "^5.2.0", - "bs58": "^4.0.0", - "text-encoding-utf-8": "^1.0.2" - }, - "dependencies": { - "bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "requires": { - "base-x": "^3.0.2" - } - } - } - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -10687,26 +9747,6 @@ } } }, - "bs58check": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", - "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", - "requires": { - "bs58": "^4.0.0", - "create-hash": "^1.1.0", - "safe-buffer": "^5.1.2" - }, - "dependencies": { - "bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", - "requires": { - "base-x": "^3.0.2" - } - } - } - }, "bser": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", @@ -10716,26 +9756,12 @@ "node-int64": "^0.4.0" } }, - "buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, "buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, - "buffer-layout": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz", - "integrity": "sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==" - }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -10745,6 +9771,8 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.3.tgz", "integrity": "sha512-yEYTwGndELGvfXsImMBLop58eaGW+YdONi1fNjTINSY98tmMmFijBG6WXgdkfuLNt4imzQNtIE+eBp1PVpMCSw==", + "optional": true, + "peer": true, "requires": { "node-gyp-build": "^4.2.0" } @@ -10873,12 +9901,14 @@ "commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "convert-source-map": { "version": "1.8.0", @@ -11050,7 +10080,8 @@ "decimal.js": { "version": "10.3.1", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz", - "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==" + "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==", + "dev": true }, "dedent": { "version": "0.7.0", @@ -11070,11 +10101,6 @@ "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", "dev": true }, - "delay": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", - "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==" - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -11142,11 +10168,6 @@ } } }, - "dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" - }, "electron-to-chromium": { "version": "1.3.889", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.889.tgz", @@ -11208,19 +10229,6 @@ } } }, - "es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" - }, - "es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "requires": { - "es6-promise": "^4.0.3" - } - }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -11369,11 +10377,6 @@ } } }, - "eyes": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", - "integrity": "sha1-Ys8SAjTGg3hdkCNIqADvPgzCC8A=" - }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -11386,11 +10389,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "fast-stable-stringify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", - "integrity": "sha1-XFVDRisiru79NtBbNOUceMuG0xM=" - }, "fb-watchman": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz", @@ -11400,11 +10398,6 @@ "bser": "2.1.1" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -11447,11 +10440,6 @@ "path-exists": "^4.0.0" } }, - "follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" - }, "form-data": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", @@ -11492,7 +10480,8 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, "fsevents": { "version": "2.3.2", @@ -11535,6 +10524,7 @@ "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -11553,7 +10543,8 @@ "google-protobuf": { "version": "3.17.3", "resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.17.3.tgz", - "integrity": "sha512-OVPzcSWIAJ+d5yiHyeaLrdufQtrvaBrF4JQg+z8ynTkbO3uFcujqXszTumqg1cGsAsjkWnI+M5B1xZ19yR4Wyg==" + "integrity": "sha512-OVPzcSWIAJ+d5yiHyeaLrdufQtrvaBrF4JQg+z8ynTkbO3uFcujqXszTumqg1cGsAsjkWnI+M5B1xZ19yR4Wyg==", + "peer": true }, "graceful-fs": { "version": "4.2.11", @@ -11594,11 +10585,6 @@ "minimalistic-assert": "^1.0.1" } }, - "hi-base32": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/hi-base32/-/hi-base32-0.5.1.tgz", - "integrity": "sha512-EmBBpvdYh/4XxsnUybsPag6VikPYnN30td+vQk+GI3qpahVEG9+gTkG0aXVxTjBqQ5T6ijbWIu77O+C5WFWsnA==" - }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -11660,11 +10646,6 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" - }, "import-local": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.3.tgz", @@ -11685,6 +10666,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -11751,12 +10733,6 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isomorphic-ws": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", - "requires": {} - }, "istanbul-lib-coverage": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", @@ -11840,40 +10816,6 @@ "istanbul-lib-report": "^3.0.0" } }, - "jayson": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/jayson/-/jayson-3.6.6.tgz", - "integrity": "sha512-f71uvrAWTtrwoww6MKcl9phQTC+56AopLyEenWvKVAIMz+q0oVGj6tenLZ7Z6UiPBkJtKLj4kt0tACllFQruGQ==", - "requires": { - "@types/connect": "^3.4.33", - "@types/express-serve-static-core": "^4.17.9", - "@types/lodash": "^4.14.159", - "@types/node": "^12.12.54", - "@types/ws": "^7.4.4", - "commander": "^2.20.3", - "delay": "^5.0.0", - "es6-promisify": "^5.0.0", - "eyes": "^0.1.8", - "isomorphic-ws": "^4.0.1", - "json-stringify-safe": "^5.0.1", - "JSONStream": "^1.3.5", - "lodash": "^4.17.20", - "uuid": "^8.3.2", - "ws": "^7.4.5" - }, - "dependencies": { - "@types/node": { - "version": "12.20.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.52.tgz", - "integrity": "sha512-cfkwWw72849SNYp3Zx0IcIs25vABmFh73xicxhCkTcvtZQeIez15PpwQN8fY3RD7gv1Wrxlc9MEtfMORZDEsGw==" - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" - } - } - }, "jest": { "version": "27.3.1", "resolved": "https://registry.npmjs.org/jest/-/jest-27.3.1.tgz", @@ -13141,21 +12083,11 @@ "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.6.1.tgz", "integrity": "sha512-Frdq2+tRRGLQUIQOgsIGSCd1VePCS2fsddTG5dTCqR0JHgltXWfsxnY0gIXPoMeRmdom6Oyq+UMOFg5suduOjQ==" }, - "js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, "js-sha3": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" }, - "js-sha512": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/js-sha512/-/js-sha512-0.8.0.tgz", - "integrity": "sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ==" - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -13172,11 +12104,6 @@ "esprima": "^4.0.0" } }, - "jscrypto": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/jscrypto/-/jscrypto-1.0.2.tgz", - "integrity": "sha512-r+oNJLGTv1nkNMBBq3c70xYrFDgJOYVgs2OHijz5Ht+0KJ0yObD0oYxC9mN72KLzVfXw+osspg6t27IZvuTUxw==" - }, "jsdom": { "version": "16.7.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", @@ -13218,19 +12145,6 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", "dev": true }, - "json-bigint": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", - "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", - "requires": { - "bignumber.js": "^9.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, "json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -13247,20 +12161,6 @@ "graceful-fs": "^4.1.6" } }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=" - }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } - }, "kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -13295,7 +12195,8 @@ "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true }, "lodash.memoize": { "version": "4.1.2", @@ -13426,6 +12327,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -13451,22 +12353,12 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "nan": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", - "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==" - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "node-addon-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" - }, "node-fetch": { "version": "2.6.12", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", @@ -13499,7 +12391,9 @@ "node-gyp-build": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", - "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==" + "integrity": "sha512-MN6ZpzmfNCRM+3t57PTJHgHyw/h4OWnZ6mR8P5j/uZtqQr46RRuDE/P+g3n0YR/AiYXeWixZZzaip77gdICfRg==", + "optional": true, + "peer": true }, "node-int64": { "version": "0.4.0", @@ -13538,6 +12432,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } @@ -13633,7 +12528,8 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true }, "path-key": { "version": "3.1.1", @@ -13818,11 +12714,6 @@ "util-deprecate": "^1.0.1" } }, - "regenerator-runtime": { - "version": "0.13.9", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -13864,6 +12755,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, "requires": { "glob": "^7.1.3" } @@ -13877,32 +12769,6 @@ "inherits": "^2.0.1" } }, - "rpc-websockets": { - "version": "7.4.18", - "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.4.18.tgz", - "integrity": "sha512-bVu+4qM5CkGVlTqJa6FaAxLbb5uRnyH4te7yjFvoCzbnif7PT4BcvXtNTprHlNvsH+/StB81zUQicxMrUrIomA==", - "requires": { - "@babel/runtime": "^7.17.2", - "bufferutil": "^4.0.1", - "eventemitter3": "^4.0.7", - "utf-8-validate": "^5.0.2", - "uuid": "^8.3.2", - "ws": "^8.5.0" - }, - "dependencies": { - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" - }, - "ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", - "requires": {} - } - } - }, "rxjs": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.4.tgz", @@ -13943,16 +12809,6 @@ "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", "integrity": "sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA==" }, - "secp256k1": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.2.tgz", - "integrity": "sha512-UDar4sKvWAksIlfX3xIaQReADn+WFnHvbVujpcbr+9Sf/69odMwy2MUsz5CKLQgX9nsIyrjuxL2imVyoNHa3fg==", - "requires": { - "elliptic": "^6.5.2", - "node-addon-api": "^2.0.0", - "node-gyp-build": "^4.2.0" - } - }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -14107,11 +12963,6 @@ "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true }, - "superstruct": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz", - "integrity": "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==" - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -14198,49 +13049,12 @@ } } }, - "text-encoding-utf-8": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", - "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" - }, "throat": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/throat/-/throat-6.0.1.tgz", "integrity": "sha512-8hmiGIJMDlwjg7dlJ4yKGLK8EsYqKgPWbG3b4wjJddKNwc7N7Dpn08Df4szr/sZdMVeOstrdYSsqzX6BYbcB+w==", "dev": true }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" - }, - "tiny-secp256k1": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz", - "integrity": "sha512-FmqJZGduTyvsr2cF3375fqGHUovSwDi/QytexX1Se4BPuPZpTE5Ftp5fg+EFSuEf3lhZqgCRjEG3ydUQ/aNiwA==", - "requires": { - "bindings": "^1.3.0", - "bn.js": "^4.11.8", - "create-hmac": "^1.1.7", - "elliptic": "^6.4.0", - "nan": "^2.13.2" - }, - "dependencies": { - "bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" - } - } - }, - "tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", - "requires": { - "rimraf": "^3.0.0" - } - }, "tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -14359,11 +13173,6 @@ "tslib": "^1.8.1" } }, - "tweetnacl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" - }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -14428,11 +13237,6 @@ "is-typedarray": "^1.0.0" } }, - "typeforce": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.18.0.tgz", - "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" - }, "typescript": { "version": "4.9.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", @@ -14456,6 +13260,8 @@ "version": "5.0.5", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.5.tgz", "integrity": "sha512-+pnxRYsS/axEpkrrEpzYfNZGXp0IjC/9RIxwM5gntY4Koi8SHmUGSfxfWqxZdRxrtaoVstuOzUp/rbs3JSPELQ==", + "optional": true, + "peer": true, "requires": { "node-gyp-build": "^4.2.0" } @@ -14484,11 +13290,6 @@ } } }, - "vlq": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vlq/-/vlq-2.0.4.tgz", - "integrity": "sha512-aodjPa2wPQFkra1G8CzJBTHXhgk3EVSwxSWXNPr1fgdFLUb8kvLV1iEb6rFgasIsjP82HWI6dsb5Io26DDnasA==" - }, "w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", @@ -14557,14 +13358,6 @@ "isexe": "^2.0.0" } }, - "wif": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/wif/-/wif-2.0.6.tgz", - "integrity": "sha1-CNP1IFbGZnkplyb63g1DKudLRwQ=", - "requires": { - "bs58check": "<3.0.0" - } - }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -14611,7 +13404,8 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "write-file-atomic": { "version": "3.0.3", @@ -14629,6 +13423,7 @@ "version": "7.5.7", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "dev": true, "requires": {} }, "xml-name-validator": { diff --git a/sdk/js/package.json b/sdk/js/package.json index 391286107..15904dd8e 100644 --- a/sdk/js/package.json +++ b/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@alephium/wormhole-sdk", - "version": "0.3.7", + "version": "0.4.0", "description": "SDK for interacting with Alephium Wormhole", "homepage": "https://wormholenetwork.com", "main": "./lib/cjs/index.js", @@ -13,7 +13,7 @@ "build-contracts": "npm run build --prefix ../../ethereum && node scripts/copyContracts.js && typechain --target=ethers-v5 --out-dir=src/ethers-contracts contracts/*.json", "build-abis": "typechain --target=ethers-v5 --out-dir=src/ethers-contracts/abi src/abi/Wormhole.abi.json", "build-deps": "npm run build-abis && npm run build-contracts", - "build-lib": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node scripts/copyEthersTypes.js && node scripts/copyWasm.js", + "build-lib": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node scripts/copyEthersTypes.js", "build-all": "npm run build-deps && npm run build-lib", "test": "jest --config jestconfig.json --verbose", "test-ci": "jest --config jestconfig.json --verbose --setupFiles ./ci-config.js --forceExit", @@ -30,9 +30,7 @@ "bridge", "token", "sdk", - "solana", "ethereum", - "terra", "bsc" ], "author": "certusone", @@ -56,14 +54,9 @@ }, "dependencies": { "ethers": "^5.6.8", - "@alephium/web3": "^1.11.0", + "@alephium/web3": "^1.11.1", "@alephium/token-list": "0.0.11", "@improbable-eng/grpc-web": "^0.14.0", - "@solana/spl-token": "^0.1.8", - "@solana/web3.js": "^1.24.0", - "@terra-money/terra.js": "^3.0.7", - "algosdk": "2.4.0", - "axios": "^0.24.0", "bech32": "^2.0.0", "bs58": "^5.0.0", "fs-extra": "^10.1.0", diff --git a/sdk/js/scripts/copyWasm.js b/sdk/js/scripts/copyWasm.js deleted file mode 100644 index 5e15f2c2b..000000000 --- a/sdk/js/scripts/copyWasm.js +++ /dev/null @@ -1,67 +0,0 @@ -const fs = require("fs"); -["lib/esm", "lib/cjs"].forEach((buildPath) => { - fs.copyFileSync( - `src/solana/core/bridge_bg.wasm`, - `${buildPath}/solana/core/bridge_bg.wasm` - ); - fs.copyFileSync( - `src/solana/core-node/bridge_bg.wasm`, - `${buildPath}/solana/core-node/bridge_bg.wasm` - ); - fs.copyFileSync( - `src/solana/core/bridge_bg.wasm.d.ts`, - `${buildPath}/solana/core/bridge_bg.wasm.d.ts` - ); - fs.copyFileSync( - `src/solana/core-node/bridge_bg.wasm.d.ts`, - `${buildPath}/solana/core-node/bridge_bg.wasm.d.ts` - ); - fs.copyFileSync( - `src/solana/nft/nft_bridge_bg.wasm`, - `${buildPath}/solana/nft/nft_bridge_bg.wasm` - ); - fs.copyFileSync( - `src/solana/nft-node/nft_bridge_bg.wasm`, - `${buildPath}/solana/nft-node/nft_bridge_bg.wasm` - ); - fs.copyFileSync( - `src/solana/nft/nft_bridge_bg.wasm.d.ts`, - `${buildPath}/solana/nft/nft_bridge_bg.wasm.d.ts` - ); - fs.copyFileSync( - `src/solana/nft-node/nft_bridge_bg.wasm.d.ts`, - `${buildPath}/solana/nft-node/nft_bridge_bg.wasm.d.ts` - ); - fs.copyFileSync( - `src/solana/token/token_bridge_bg.wasm`, - `${buildPath}/solana/token/token_bridge_bg.wasm` - ); - fs.copyFileSync( - `src/solana/token-node/token_bridge_bg.wasm`, - `${buildPath}/solana/token-node/token_bridge_bg.wasm` - ); - fs.copyFileSync( - `src/solana/token/token_bridge_bg.wasm.d.ts`, - `${buildPath}/solana/token/token_bridge_bg.wasm.d.ts` - ); - fs.copyFileSync( - `src/solana/token-node/token_bridge_bg.wasm.d.ts`, - `${buildPath}/solana/token-node/token_bridge_bg.wasm.d.ts` - ); - fs.copyFileSync( - `src/solana/migration/wormhole_migration_bg.wasm`, - `${buildPath}/solana/migration/wormhole_migration_bg.wasm` - ); - fs.copyFileSync( - `src/solana/migration-node/wormhole_migration_bg.wasm`, - `${buildPath}/solana/migration-node/wormhole_migration_bg.wasm` - ); - fs.copyFileSync( - `src/solana/migration/wormhole_migration_bg.wasm.d.ts`, - `${buildPath}/solana/migration/wormhole_migration_bg.wasm.d.ts` - ); - fs.copyFileSync( - `src/solana/migration-node/wormhole_migration_bg.wasm.d.ts`, - `${buildPath}/solana/migration-node/wormhole_migration_bg.wasm.d.ts` - ); -}); diff --git a/sdk/js/src/algorand/Algorand.ts b/sdk/js/src/algorand/Algorand.ts deleted file mode 100644 index 6149bed8b..000000000 --- a/sdk/js/src/algorand/Algorand.ts +++ /dev/null @@ -1,964 +0,0 @@ -// Algorand.ts - -import algosdk, { - Algodv2, - bigIntToBytes, - decodeAddress, - encodeAddress, - getApplicationAddress, - LogicSigAccount, - makeApplicationCallTxnFromObject, - makeApplicationOptInTxnFromObject, - makeAssetTransferTxnWithSuggestedParamsFromObject, - makePaymentTxnWithSuggestedParamsFromObject, - OnApplicationComplete, - signLogicSigTransaction, - Transaction, -} from "algosdk"; - -import abi from "algosdk"; - -import { BigNumber } from "ethers"; -import { keccak256 } from "ethers/lib/utils"; -import { getEmitterAddressAlgorand } from "../bridge"; -import { - ChainId, - CHAIN_ID_ALGORAND, - hexToUint8Array, - textToHexString, - textToUint8Array, - uint8ArrayToHex, -} from "../utils"; -import { safeBigIntToNumber } from "../utils/bigint"; -import { PopulateData, TmplSig } from "./TmplSig"; - -const SEED_AMT: number = 1002000; -const ZERO_PAD_BYTES = - "0000000000000000000000000000000000000000000000000000000000000000"; -const MAX_KEYS: number = 15; -const MAX_BYTES_PER_KEY: number = 127; -const BITS_PER_BYTE: number = 8; - -export const BITS_PER_KEY: number = MAX_BYTES_PER_KEY * BITS_PER_BYTE; -const MAX_BYTES: number = MAX_BYTES_PER_KEY * MAX_KEYS; -export const MAX_BITS: number = BITS_PER_BYTE * MAX_BYTES; -const MAX_SIGS_PER_TXN: number = 9; - -const ALGO_VERIFY_HASH = - "EZATROXX2HISIRZDRGXW4LRQ46Z6IUJYYIHU3PJGP7P5IQDPKVX42N767A"; -const ALGO_VERIFY = new Uint8Array([ - 6, 32, 4, 1, 0, 32, 20, 38, 1, 0, 49, 32, 50, 3, 18, 68, 49, 1, 35, 18, 68, - 49, 16, 129, 6, 18, 68, 54, 26, 1, 54, 26, 3, 54, 26, 2, 136, 0, 3, 68, 34, - 67, 53, 2, 53, 1, 53, 0, 40, 53, 240, 40, 53, 241, 52, 0, 21, 53, 5, 35, 53, - 3, 35, 53, 4, 52, 3, 52, 5, 12, 65, 0, 68, 52, 1, 52, 0, 52, 3, 129, 65, 8, - 34, 88, 23, 52, 0, 52, 3, 34, 8, 36, 88, 52, 0, 52, 3, 129, 33, 8, 36, 88, 7, - 0, 53, 241, 53, 240, 52, 2, 52, 4, 37, 88, 52, 240, 52, 241, 80, 2, 87, 12, - 20, 18, 68, 52, 3, 129, 66, 8, 53, 3, 52, 4, 37, 8, 53, 4, 66, 255, 180, 34, - 137, -]); - -let accountExistsCache = new Set<[bigint, string]>(); - -type Signer = { - addr: string; - signTxn(txn: Transaction): Promise; -}; - -export type TransactionSignerPair = { - tx: Transaction; - signer: Signer | null; -}; - -export type OptInResult = { - addr: string; - txs: TransactionSignerPair[]; -}; - -/** - * Return the message fee for the core bridge - * @param client An Algodv2 client - * @param bridgeId The application ID of the core bridge - * @returns The message fee for the core bridge - */ -export async function getMessageFee( - client: Algodv2, - bridgeId: bigint -): Promise { - const applInfo: Record = await client - .getApplicationByID(safeBigIntToNumber(bridgeId)) - .do(); - const globalState = applInfo["params"]["global-state"]; - const key: string = Buffer.from("MessageFee", "binary").toString("base64"); - let ret = BigInt(0); - globalState.forEach((el: any) => { - if (el["key"] === key) { - ret = BigInt(el["value"]["uint"]); - return; - } - }); - return ret; -} - -/** - * Checks to see it the account exists for the application - * @param client An Algodv2 client - * @param appId Application ID - * @param acctAddr Account address to check - * @returns true, if account exists for application. Otherwise, returns false - */ -export async function accountExists( - client: Algodv2, - appId: bigint, - acctAddr: string -): Promise { - if (accountExistsCache.has([appId, acctAddr])) return true; - - let ret = false; - try { - const acctInfo = await client.accountInformation(acctAddr).do(); - const als: Record[] = acctInfo["apps-local-state"]; - if (!als) { - return ret; - } - als.forEach((app) => { - if (BigInt(app["id"]) === appId) { - accountExistsCache.add([appId, acctAddr]); - ret = true; - return; - } - }); - } catch (e) {} - return ret; -} - -export type LogicSigAccountInfo = { - lsa: LogicSigAccount; - doesExist: boolean; -}; - -/** - * Calculates the logic sig account for the application - * @param client An Algodv2 client - * @param appId Application ID - * @param appIndex Application index - * @param emitterId Emitter address - * @returns LogicSigAccountInfo - */ -export async function calcLogicSigAccount( - client: algosdk.Algodv2, - appId: bigint, - appIndex: bigint, - emitterId: string -): Promise { - let data: PopulateData = { - addrIdx: appIndex, - appAddress: getEmitterAddressAlgorand(appId), - appId: appId, - emitterId: emitterId, - }; - - const ts: TmplSig = new TmplSig(client); - const lsa: LogicSigAccount = await ts.populate(data); - const sigAddr: string = lsa.address(); - - const doesExist: boolean = await accountExists(client, appId, sigAddr); - return { - lsa, - doesExist, - }; -} - -/** - * Calculates the logic sig account for the application - * @param client An Algodv2 client - * @param senderAddr Sender address - * @param appId Application ID - * @param appIndex Application index - * @param emitterId Emitter address - * @returns Address and array of TransactionSignerPairs - */ -export async function optin( - client: Algodv2, - senderAddr: string, - appId: bigint, - appIndex: bigint, - emitterId: string -): Promise { - const appAddr: string = getApplicationAddress(appId); - - // Check to see if we need to create this - const { doesExist, lsa } = await calcLogicSigAccount( - client, - appId, - appIndex, - emitterId - ); - const sigAddr: string = lsa.address(); - let txs: TransactionSignerPair[] = []; - if (!doesExist) { - // These are the suggested params from the system - const params = await client.getTransactionParams().do(); - const seedTxn = makePaymentTxnWithSuggestedParamsFromObject({ - from: senderAddr, - to: sigAddr, - amount: SEED_AMT, - suggestedParams: params, - }); - seedTxn.fee = seedTxn.fee * 2; - txs.push({ tx: seedTxn, signer: null }); - const optinTxn = makeApplicationOptInTxnFromObject({ - from: sigAddr, - suggestedParams: params, - appIndex: safeBigIntToNumber(appId), - rekeyTo: appAddr, - }); - optinTxn.fee = 0; - txs.push({ - tx: optinTxn, - signer: { - addr: lsa.address(), - signTxn: (txn: Transaction) => - Promise.resolve(signLogicSigTransaction(txn, lsa).blob), - }, - }); - - accountExistsCache.add([appId, lsa.address()]); - } - return { - addr: sigAddr, - txs, - }; -} - -function extract3(buffer: Uint8Array, start: number, size: number) { - return buffer.slice(start, start + size); -} - -/** - * Parses the VAA into a Map - * @param vaa The VAA to be parsed - * @returns The ParsedVAA containing the parsed elements of the VAA - */ -type ParsedVAA = { - version: number; - index: number; - siglen: number; - signatures: Uint8Array; - sigs: Uint8Array[]; - digest: Uint8Array; - timestamp: number; - nonce: number; - chainRaw: string; - chain: number; - emitter: string; - sequence: bigint; - consistency: number; - Meta: - | "Unknown" - | "TokenBridge" - | "TokenBridge RegisterChain" - | "TokenBridge UpgradeContract" - | "CoreGovernance" - | "TokenBridge Attest" - | "TokenBridge Transfer" - | "TokenBridge Transfer With Payload"; - module?: Uint8Array; - action?: number; - targetChain?: number; - EmitterChainID?: number; - targetEmitter?: Uint8Array; - newContract?: Uint8Array; - NewGuardianSetIndex?: number; - Type?: number; - Contract?: string; - FromChain?: number; - Decimals?: number; - Symbol?: Uint8Array; - Name?: Uint8Array; - Amount?: Uint8Array; - ToAddress?: Uint8Array; - ToChain?: number; - Fee?: Uint8Array; - Payload?: Uint8Array; -}; -export function _parseVAAAlgorand(vaa: Uint8Array): ParsedVAA { - let ret = {} as ParsedVAA; - let buf = Buffer.from(vaa); - ret.version = buf.readIntBE(0, 1); - ret.index = buf.readIntBE(1, 4); - ret.siglen = buf.readIntBE(5, 1); - const siglen = ret.siglen; - if (siglen) { - ret.signatures = extract3(vaa, 6, siglen * 66); - } - const sigs: Uint8Array[] = []; - for (let i = 0; i < siglen; i++) { - const start = 6 + i * 66; - const len = 66; - const sigBuf = extract3(vaa, start, len); - sigs.push(sigBuf); - } - ret.sigs = sigs; - let off = siglen * 66 + 6; - ret.digest = vaa.slice(off); // This is what is actually signed... - ret.timestamp = buf.readIntBE(off, 4); - off += 4; - ret.nonce = buf.readIntBE(off, 4); - off += 4; - ret.chainRaw = Buffer.from(extract3(vaa, off, 2)).toString("hex"); - ret.chain = buf.readIntBE(off, 2); - off += 2; - ret.emitter = Buffer.from(extract3(vaa, off, 32)).toString("hex"); - off += 32; - ret.sequence = buf.readBigUInt64BE(off); - off += 8; - ret.consistency = buf.readIntBE(off, 1); - off += 1; - - ret.Meta = "Unknown"; - - if ( - !Buffer.compare( - extract3(buf, off, 32), - Buffer.from( - "000000000000000000000000000000000000000000546f6b656e427269646765", - "hex" - ) - ) - ) { - ret.Meta = "TokenBridge"; - ret.module = extract3(vaa, off, 32); - off += 32; - ret.action = buf.readIntBE(off, 1); - off += 1; - if (ret.action === 1) { - ret.Meta = "TokenBridge RegisterChain"; - ret.targetChain = buf.readIntBE(off, 2); - off += 2; - ret.EmitterChainID = buf.readIntBE(off, 2); - off += 2; - ret.targetEmitter = extract3(vaa, off, 32); - off += 32; - } else if (ret.action === 2) { - ret.Meta = "TokenBridge UpgradeContract"; - ret.targetChain = buf.readIntBE(off, 2); - off += 2; - ret.newContract = extract3(vaa, off, 32); - off += 32; - } - } else if ( - !Buffer.compare( - extract3(buf, off, 32), - Buffer.from( - "00000000000000000000000000000000000000000000000000000000436f7265", - "hex" - ) - ) - ) { - ret.Meta = "CoreGovernance"; - ret.module = extract3(vaa, off, 32); - off += 32; - ret.action = buf.readIntBE(off, 1); - off += 1; - ret.targetChain = buf.readIntBE(off, 2); - off += 2; - ret.NewGuardianSetIndex = buf.readIntBE(off, 4); - } - - // ret.len=vaa.slice(off).length) - // ret.act=buf.readIntBE(off, 1)) - - if (vaa.slice(off).length === 100 && buf.readIntBE(off, 1) === 2) { - ret.Meta = "TokenBridge Attest"; - ret.Type = buf.readIntBE(off, 1); - off += 1; - ret.Contract = uint8ArrayToHex(extract3(vaa, off, 32)); - off += 32; - ret.FromChain = buf.readIntBE(off, 2); - off += 2; - ret.Decimals = buf.readIntBE(off, 1); - off += 1; - ret.Symbol = extract3(vaa, off, 32); - off += 32; - ret.Name = extract3(vaa, off, 32); - } - - if (vaa.slice(off).length === 133 && buf.readIntBE(off, 1) === 1) { - ret.Meta = "TokenBridge Transfer"; - ret.Type = buf.readIntBE(off, 1); - off += 1; - ret.Amount = extract3(vaa, off, 32); - off += 32; - ret.Contract = uint8ArrayToHex(extract3(vaa, off, 32)); - off += 32; - ret.FromChain = buf.readIntBE(off, 2); - off += 2; - ret.ToAddress = extract3(vaa, off, 32); - off += 32; - ret.ToChain = buf.readIntBE(off, 2); - off += 2; - ret.Fee = extract3(vaa, off, 32); - } - - if (off >= buf.length) { - return ret; - } - if (buf.readIntBE(off, 1) === 3) { - ret.Meta = "TokenBridge Transfer With Payload"; - ret.Type = buf.readIntBE(off, 1); - off += 1; - ret.Amount = extract3(vaa, off, 32); - off += 32; - ret.Contract = uint8ArrayToHex(extract3(vaa, off, 32)); - off += 32; - ret.FromChain = buf.readIntBE(off, 2); - off += 2; - ret.ToAddress = extract3(vaa, off, 32); - off += 32; - ret.ToChain = buf.readIntBE(off, 2); - off += 2; - ret.Fee = extract3(vaa, off, 32); - off += 32; - ret.Payload = vaa.slice(off); - } - - return ret; -} - -/** - * Returns the local data for an application ID - * @param client Algodv2 client - * @param appId Application ID of interest - * @param address Address of the account - * @returns Uint8Array of data squirreled away - */ -export async function decodeLocalState( - client: Algodv2, - appId: bigint, - address: string -): Promise { - let app_state = null; - const ai = await client.accountInformation(address).do(); - for (const app of ai["apps-local-state"]) { - if (BigInt(app["id"]) === appId) { - app_state = app["key-value"]; - break; - } - } - - let ret = Buffer.alloc(0); - let empty = Buffer.alloc(0); - if (app_state) { - const e = Buffer.alloc(127); - const m = Buffer.from("meta"); - - let sk: string[] = []; - let vals: Map = new Map(); - for (const kv of app_state) { - const k = Buffer.from(kv["key"], "base64"); - const key: number = k.readInt8(); - if (!Buffer.compare(k, m)) { - continue; - } - const v: Buffer = Buffer.from(kv["value"]["bytes"], "base64"); - if (Buffer.compare(v, e)) { - vals.set(key.toString(), v); - sk.push(key.toString()); - } - } - - sk.sort((a, b) => a.localeCompare(b, "en", { numeric: true })); - - sk.forEach((v) => { - ret = Buffer.concat([ret, vals.get(v) || empty]); - }); - } - return new Uint8Array(ret); -} - -/** - * Checks if the asset has been opted in by the receiver - * @param client Algodv2 client - * @param asset Algorand asset index - * @param receiver Account address - * @returns True if the asset was opted in, else false - */ -export async function assetOptinCheck( - client: Algodv2, - asset: bigint, - receiver: string -): Promise { - const acctInfo = await client.accountInformation(receiver).do(); - const assets: Array = acctInfo.assets; - let ret = false; - assets.forEach((a) => { - const assetId = BigInt(a["asset-id"]); - if (assetId === asset) { - ret = true; - return; - } - }); - return ret; -} - -class SubmitVAAState { - vaaMap: ParsedVAA; - accounts: string[]; - txs: TransactionSignerPair[]; - guardianAddr: string; - - constructor( - vaaMap: ParsedVAA, - accounts: string[], - txs: TransactionSignerPair[], - guardianAddr: string - ) { - this.vaaMap = vaaMap; - this.accounts = accounts; - this.txs = txs; - this.guardianAddr = guardianAddr; - } -} - -/** - * Submits just the header of the VAA - * @param client AlgodV2 client - * @param bridgeId Application ID of the core bridge - * @param vaa The VAA (Just the header is used) - * @param senderAddr Sending account address - * @param appid Application ID - * @returns Current VAA state - */ -export async function submitVAAHeader( - client: Algodv2, - bridgeId: bigint, - vaa: Uint8Array, - senderAddr: string, - appid: bigint -): Promise { - // A lot of our logic here depends on parseVAA and knowing what the payload is.. - const parsedVAA = _parseVAAAlgorand(vaa); - const seq: bigint = parsedVAA.sequence / BigInt(MAX_BITS); - const chainRaw: string = parsedVAA.chainRaw; // TODO: this needs to be a hex string - const em: string = parsedVAA.emitter; // TODO: this needs to be a hex string - const index: number = parsedVAA.index; - - let txs: TransactionSignerPair[] = []; - // "seqAddr" - const { addr: seqAddr, txs: seqOptInTxs } = await optin( - client, - senderAddr, - appid, - seq, - chainRaw + em - ); - txs.push(...seqOptInTxs); - const guardianPgmName = textToHexString("guardian"); - // And then the signatures to help us verify the vaa_s - // "guardianAddr" - const { addr: guardianAddr, txs: guardianOptInTxs } = await optin( - client, - senderAddr, - bridgeId, - BigInt(index), - guardianPgmName - ); - txs.push(...guardianOptInTxs); - let accts: string[] = [seqAddr, guardianAddr]; - - // When we attest for a new token, we need some place to store the info... later we will need to - // mirror the other way as well - const keys: Uint8Array = await decodeLocalState( - client, - bridgeId, - guardianAddr - ); - - const params: algosdk.SuggestedParams = await client - .getTransactionParams() - .do(); - - // We don't pass the entire payload in but instead just pass it pre digested. This gets around size - // limitations with lsigs AND reduces the cost of the entire operation on a conjested network by reducing the - // bytes passed into the transaction - // This is a 2 pass digest - const digest = keccak256(keccak256(parsedVAA.digest)).slice(2); - - // How many signatures can we process in a single txn... we can do 9! - // There are likely upwards of 19 signatures. So, we ned to split things up - const numSigs: number = parsedVAA.siglen; - let numTxns: number = Math.floor(numSigs / MAX_SIGS_PER_TXN) + 1; - - const SIG_LEN: number = 66; - const BSIZE: number = SIG_LEN * MAX_SIGS_PER_TXN; - const signatures: Uint8Array = parsedVAA.signatures; - const verifySigArg: Uint8Array = textToUint8Array("verifySigs"); - const lsa = new LogicSigAccount(ALGO_VERIFY); - for (let nt = 0; nt < numTxns; nt++) { - let sigs: Uint8Array = signatures.slice(nt * BSIZE); - if (sigs.length > BSIZE) { - sigs = sigs.slice(0, BSIZE); - } - - // The keyset is the set of guardians that correspond - // to the current set of signatures in this loop. - // Each signature in 20 bytes and comes from decodeLocalState() - const GuardianKeyLen: number = 20; - const numSigsThisTxn = sigs.length / SIG_LEN; - let arraySize: number = numSigsThisTxn * GuardianKeyLen; - let keySet: Uint8Array = new Uint8Array(arraySize); - for (let i = 0; i < numSigsThisTxn; i++) { - // The first byte of the sig is the relative index of that signature in the signatures array - // Use that index to get the appropriate guardian key - const idx = sigs[i * SIG_LEN]; - const key = keys.slice( - idx * GuardianKeyLen + 1, - (idx + 1) * GuardianKeyLen + 1 - ); - keySet.set(key, i * 20); - } - - const appTxn = makeApplicationCallTxnFromObject({ - appArgs: [verifySigArg, sigs, keySet, hexToUint8Array(digest)], - accounts: accts, - appIndex: safeBigIntToNumber(bridgeId), - from: ALGO_VERIFY_HASH, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }); - appTxn.fee = 0; - txs.push({ - tx: appTxn, - signer: { - addr: lsa.address(), - signTxn: (txn: Transaction) => - Promise.resolve(signLogicSigTransaction(txn, lsa).blob), - }, - }); - } - const appTxn = makeApplicationCallTxnFromObject({ - appArgs: [textToUint8Array("verifyVAA"), vaa], - accounts: accts, - appIndex: safeBigIntToNumber(bridgeId), - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }); - appTxn.fee = appTxn.fee * (1 + numTxns); - txs.push({ tx: appTxn, signer: null }); - - return new SubmitVAAState(parsedVAA, accts, txs, guardianAddr); -} - -/** - * Submits the VAA to the application - * @param client AlgodV2 client - * @param tokenBridgeId Application ID of the token bridge - * @param bridgeId Application ID of the core bridge - * @param vaa The VAA to be submitted - * @param senderAddr Sending account address - * @returns Confirmation log - */ -export async function _submitVAAAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - bridgeId: bigint, - vaa: Uint8Array, - senderAddr: string -): Promise { - let sstate = await submitVAAHeader( - client, - bridgeId, - vaa, - senderAddr, - tokenBridgeId - ); - - let parsedVAA = sstate.vaaMap; - let accts = sstate.accounts; - let txs = sstate.txs; - - // If this happens to be setting up a new guardian set, we probably need it as well... - if ( - parsedVAA.Meta === "CoreGovernance" && - parsedVAA.action === 2 && - parsedVAA.NewGuardianSetIndex !== undefined - ) { - const ngsi = parsedVAA.NewGuardianSetIndex; - const guardianPgmName = textToHexString("guardian"); - // "newGuardianAddr" - const { addr: newGuardianAddr, txs: newGuardianOptInTxs } = await optin( - client, - senderAddr, - bridgeId, - BigInt(ngsi), - guardianPgmName - ); - accts.push(newGuardianAddr); - txs.unshift(...newGuardianOptInTxs); - } - - // When we attest for a new token, we need some place to store the info... later we will need to - // mirror the other way as well - const meta = parsedVAA.Meta; - let chainAddr: string = ""; - if ( - (meta === "TokenBridge Attest" || - meta === "TokenBridge Transfer" || - meta === "TokenBridge Transfer With Payload") && - parsedVAA.Contract !== undefined - ) { - if (parsedVAA.FromChain !== CHAIN_ID_ALGORAND && parsedVAA.FromChain) { - // "TokenBridge chainAddr" - const result = await optin( - client, - senderAddr, - tokenBridgeId, - BigInt(parsedVAA.FromChain), - parsedVAA.Contract - ); - chainAddr = result.addr; - txs.unshift(...result.txs); - } else { - const assetId = hexToNativeAssetBigIntAlgorand(parsedVAA.Contract); - // "TokenBridge native chainAddr" - const result = await optin( - client, - senderAddr, - tokenBridgeId, - assetId, - textToHexString("native") - ); - chainAddr = result.addr; - txs.unshift(...result.txs); - } - accts.push(chainAddr); - } - - const params: algosdk.SuggestedParams = await client - .getTransactionParams() - .do(); - - if (meta === "CoreGovernance") { - txs.push({ - tx: makeApplicationCallTxnFromObject({ - appArgs: [textToUint8Array("governance"), vaa], - accounts: accts, - appIndex: safeBigIntToNumber(bridgeId), - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - txs.push({ - tx: makeApplicationCallTxnFromObject({ - appArgs: [textToUint8Array("nop"), bigIntToBytes(5, 8)], - appIndex: safeBigIntToNumber(bridgeId), - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - } - if ( - meta === "TokenBridge RegisterChain" || - meta === "TokenBridge UpgradeContract" - ) { - txs.push({ - tx: makeApplicationCallTxnFromObject({ - appArgs: [textToUint8Array("governance"), vaa], - accounts: accts, - appIndex: safeBigIntToNumber(tokenBridgeId), - foreignApps: [safeBigIntToNumber(bridgeId)], - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - } - - if (meta === "TokenBridge Attest") { - let asset: Uint8Array = await decodeLocalState( - client, - tokenBridgeId, - chainAddr - ); - let foreignAssets: number[] = []; - if (asset.length > 8) { - const tmp = Buffer.from(asset.slice(0, 8)); - foreignAssets.push(safeBigIntToNumber(tmp.readBigUInt64BE(0))); - } - txs.push({ - tx: makePaymentTxnWithSuggestedParamsFromObject({ - from: senderAddr, - to: chainAddr, - amount: 100000, - suggestedParams: params, - }), - signer: null, - }); - let buf: Uint8Array = new Uint8Array(1); - buf[0] = 0x01; - txs.push({ - tx: makeApplicationCallTxnFromObject({ - appArgs: [textToUint8Array("nop"), buf], - appIndex: safeBigIntToNumber(tokenBridgeId), - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - - buf = new Uint8Array(1); - buf[0] = 0x02; - txs.push({ - tx: makeApplicationCallTxnFromObject({ - appArgs: [textToUint8Array("nop"), buf], - appIndex: safeBigIntToNumber(tokenBridgeId), - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - - txs.push({ - tx: makeApplicationCallTxnFromObject({ - accounts: accts, - appArgs: [textToUint8Array("receiveAttest"), vaa], - appIndex: safeBigIntToNumber(tokenBridgeId), - foreignAssets: foreignAssets, - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - txs[txs.length - 1].tx.fee = txs[txs.length - 1].tx.fee * 2; - } - - if ( - (meta === "TokenBridge Transfer" || - meta === "TokenBridge Transfer With Payload") && - parsedVAA.Contract !== undefined - ) { - let foreignAssets: number[] = []; - let a: number = 0; - if (parsedVAA.FromChain !== CHAIN_ID_ALGORAND) { - let asset = await decodeLocalState(client, tokenBridgeId, chainAddr); - - if (asset.length > 8) { - const tmp = Buffer.from(asset.slice(0, 8)); - a = safeBigIntToNumber(tmp.readBigUInt64BE(0)); - } - } else { - a = parseInt(parsedVAA.Contract, 16); - } - - // The receiver needs to be optin in to receive the coins... Yeah, the relayer pays for this - - let aid = 0; - let addr = ""; - - if (parsedVAA.ToAddress !== undefined) { - if (parsedVAA.ToChain === 8 && parsedVAA.Type === 3) { - aid = Number( - hexToNativeAssetBigIntAlgorand(uint8ArrayToHex(parsedVAA.ToAddress)) - ); - addr = getApplicationAddress(aid); - } else { - addr = encodeAddress(parsedVAA.ToAddress); - } - } - - if (a !== 0) { - foreignAssets.push(a); - if (!(await assetOptinCheck(client, BigInt(a), addr))) { - if (senderAddr != addr) { - throw new Error( - "cannot ASA optin for somebody else (asset " + a.toString() + ")" - ); - } - - txs.unshift({ - tx: makeAssetTransferTxnWithSuggestedParamsFromObject({ - amount: 0, - assetIndex: a, - from: senderAddr, - suggestedParams: params, - to: senderAddr, - }), - signer: null, - }); - } - } - accts.push(addr); - txs.push({ - tx: makeApplicationCallTxnFromObject({ - accounts: accts, - appArgs: [textToUint8Array("completeTransfer"), vaa], - appIndex: safeBigIntToNumber(tokenBridgeId), - foreignAssets: foreignAssets, - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - - // We need to cover the inner transactions - if ( - parsedVAA.Fee !== undefined && - Buffer.compare(parsedVAA.Fee, Buffer.from(ZERO_PAD_BYTES, "hex")) === 0 - ) - txs[txs.length - 1].tx.fee = txs[txs.length - 1].tx.fee * 2; - else txs[txs.length - 1].tx.fee = txs[txs.length - 1].tx.fee * 3; - - if (meta === "TokenBridge Transfer With Payload") { - txs[txs.length - 1].tx.appForeignApps = [aid]; - - let m = abi.ABIMethod.fromSignature("portal_transfer(byte[])byte[]"); - - txs.push({ - tx: makeApplicationCallTxnFromObject({ - appArgs: [ - m.getSelector(), - (m.args[0].type as abi.ABIType).encode(vaa), - ], - appIndex: aid, - foreignAssets: foreignAssets, - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: params, - }), - signer: null, - }); - } - } - - return txs; -} - -export function uint8ArrayToNativeStringAlgorand(a: Uint8Array): string { - return encodeAddress(a); -} - -export function hexToNativeStringAlgorand(s: string): string { - return uint8ArrayToNativeStringAlgorand(hexToUint8Array(s)); -} - -export function nativeStringToHexAlgorand(s: string): string { - return uint8ArrayToHex(decodeAddress(s).publicKey); -} - -export function hexToNativeAssetBigIntAlgorand(s: string): bigint { - return BigNumber.from(hexToUint8Array(s)).toBigInt(); -} - -export function hexToNativeAssetStringAlgorand(s: string): string { - return BigNumber.from(hexToUint8Array(s)).toString(); -} diff --git a/sdk/js/src/algorand/BigVarint.ts b/sdk/js/src/algorand/BigVarint.ts deleted file mode 100644 index 2b657f332..000000000 --- a/sdk/js/src/algorand/BigVarint.ts +++ /dev/null @@ -1,67 +0,0 @@ -// Forever grateful to https://github.com/joeltg/big-varint/blob/main/src/unsigned.ts -const LIMIT = BigInt(0x7f); - -export function encodingLength(value: bigint): number { - let i = 0; - - for (; value >= BigInt(0x80); i++) { - value >>= BigInt(7); - } - - return i + 1; -} - -export function encode( - i: bigint, - buffer?: ArrayBuffer, - byteOffset?: number -): Uint8Array { - if (i < BigInt(0)) { - throw new RangeError("value must be unsigned"); - } - - const byteLength = encodingLength(i); - buffer = buffer || new ArrayBuffer(byteLength); - byteOffset = byteOffset || 0; - if (buffer.byteLength < byteOffset + byteLength) { - throw new RangeError( - "the buffer is too small to encode the number at the offset" - ); - } - - const array = new Uint8Array(buffer, byteOffset); - - let offset = 0; - while (LIMIT < i) { - array[offset++] = Number(i & LIMIT) | 0x80; - i >>= BigInt(7); - } - - array[offset] = Number(i); - - return array; -} - -export function encodeHex( - i: bigint, - buffer?: ArrayBuffer, - byteOffset?: number -): string { - return Buffer.from(encode(i, buffer, byteOffset)).toString("hex"); -} - -export function decode(data: Uint8Array, offset = 0): bigint { - let i = BigInt(0); - let n = 0; - let b: number; - do { - b = data[offset + n]; - if (b === undefined) { - throw new RangeError("offset out of range"); - } - - i += BigInt(b & 0x7f) << BigInt(n * 7); - n++; - } while (0x80 <= b); - return i; -} diff --git a/sdk/js/src/algorand/TmplSig.ts b/sdk/js/src/algorand/TmplSig.ts deleted file mode 100644 index 59d0ea998..000000000 --- a/sdk/js/src/algorand/TmplSig.ts +++ /dev/null @@ -1,60 +0,0 @@ -import algosdk, { LogicSigAccount } from "algosdk"; -import { id } from "ethers/lib/utils"; -import { hexToUint8Array } from "../utils"; -import { encodeHex } from "./BigVarint"; - -// This is the data structure to be populated in the call to populate() below -// Yes, it needs to be filled out before calling populate() -interface IPopulateData { - appId: bigint; - appAddress: string; - addrIdx: bigint; - emitterId: string; -} -export type PopulateData = Required; - -export class TmplSig { - algoClient: algosdk.Algodv2; - sourceHash: string; - bytecode: Uint8Array; - - constructor(algoClient: algosdk.Algodv2) { - this.algoClient = algoClient; - this.sourceHash = ""; - this.bytecode = new Uint8Array(); - } - - async compile(source: string) { - const hash = id(source); - if (hash !== this.sourceHash) { - const response = await this.algoClient.compile(source).do(); - this.bytecode = new Uint8Array(Buffer.from(response.result, "base64")); - this.sourceHash = hash; - } - } - - /** - * Populate data in the TEAL source and return the LogicSig object based on the resulting compiled bytecode. - * @param data The data to populate fields with. - * @notes emitterId must be prefixed with '0x'. appAddress must be decoded with algoSDK and prefixed with '0x'. - * @returns A LogicSig object. - */ - - async populate(data: PopulateData): Promise { - const byteString: string = [ - "0620010181", - encodeHex(data.addrIdx), - "4880", - encodeHex(BigInt(data.emitterId.length / 2)), - data.emitterId, - "483110810612443119221244311881", - encodeHex(data.appId), - "1244312080", - encodeHex(BigInt(data.appAddress.length / 2)), - data.appAddress, - "124431018100124431093203124431153203124422", - ].join(""); - this.bytecode = hexToUint8Array(byteString); - return new LogicSigAccount(this.bytecode); - } -} diff --git a/sdk/js/src/algorand/index.ts b/sdk/js/src/algorand/index.ts deleted file mode 100644 index 3cc28ad7e..000000000 --- a/sdk/js/src/algorand/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Algorand"; diff --git a/sdk/js/src/algorand/testlib.ts b/sdk/js/src/algorand/testlib.ts deleted file mode 100644 index 536cd9489..000000000 --- a/sdk/js/src/algorand/testlib.ts +++ /dev/null @@ -1,518 +0,0 @@ -/** - * - * Copyright 2022 Wormhole Project Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import { - ChainId, - CHAIN_ID_AVAX, - CHAIN_ID_BSC, - CHAIN_ID_ETH, - CHAIN_ID_FANTOM, - CHAIN_ID_OASIS, - CHAIN_ID_POLYGON, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, -} from "../utils"; - -const web3EthAbi = require("web3-eth-abi"); -const web3Utils = require("web3-utils"); -const elliptic = require("elliptic"); - -export class TestLib { - zeroBytes: string; - - singleGuardianKey: string[] = ["beFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe"]; - - singleGuardianPrivKey: string[] = [ - "cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0", - ]; - - constructor() { - this.zeroBytes = - "0000000000000000000000000000000000000000000000000000000000000000"; - } - - hexStringToUint8Array(hs: string): Uint8Array { - if (hs.length % 2 === 1) { - // prepend a 0 - hs = "0" + hs; - } - const buf = Buffer.from(hs, "hex"); - const retval = Uint8Array.from(buf); - return retval; - } - - uint8ArrayToHexString(arr: Uint8Array, add0x: boolean) { - const ret: string = Buffer.from(arr).toString("hex"); - if (!add0x) { - return ret; - } - return "0x" + ret; - } - - guardianKeys: string[] = [ - "52A26Ce40F8CAa8D36155d37ef0D5D783fc614d2", - "389A74E8FFa224aeAD0778c786163a7A2150768C", - "B4459EA6482D4aE574305B239B4f2264239e7599", - "072491bd66F63356090C11Aae8114F5372aBf12B", - "51280eA1fd2B0A1c76Ae29a7d54dda68860A2bfF", - "fa9Aa60CfF05e20E2CcAA784eE89A0A16C2057CB", - "e42d59F8FCd86a1c5c4bA351bD251A5c5B05DF6A", - "4B07fF9D5cE1A6ed58b6e9e7d6974d1baBEc087e", - "c8306B84235D7b0478c61783C50F990bfC44cFc0", - "C8C1035110a13fe788259A4148F871b52bAbcb1B", - "58A2508A20A7198E131503ce26bBE119aA8c62b2", - "8390820f04ddA22AFe03be1c3bb10f4ba6CF94A0", - "1FD6e97387C34a1F36DE0f8341E9D409E06ec45b", - "255a41fC2792209CB998A8287204D40996df9E54", - "bA663B12DD23fbF4FbAC618Be140727986B3BBd0", - "79040E577aC50486d0F6930e160A5C75FD1203C6", - "3580D2F00309A9A85efFAf02564Fc183C0183A96", - "3869795913D3B6dBF3B24a1C7654672c69A23c35", - "1c0Cc52D7673c52DE99785741344662F5b2308a0", - ]; - - guardianPrivKeys: string[] = [ - "563d8d2fd4e701901d3846dee7ae7a92c18f1975195264d676f8407ac5976757", - "8d97f25916a755df1d9ef74eb4dbebc5f868cb07830527731e94478cdc2b9d5f", - "9bd728ad7617c05c31382053b57658d4a8125684c0098f740a054d87ddc0e93b", - "5a02c4cd110d20a83a7ce8d1a2b2ae5df252b4e5f6781c7855db5cc28ed2d1b4", - "93d4e3b443bf11f99a00901222c032bd5f63cf73fc1bcfa40829824d121be9b2", - "ea40e40c63c6ff155230da64a2c44fcd1f1c9e50cacb752c230f77771ce1d856", - "87eaabe9c27a82198e618bca20f48f9679c0f239948dbd094005e262da33fe6a", - "61ffed2bff38648a6d36d6ed560b741b1ca53d45391441124f27e1e48ca04770", - "bd12a242c6da318fef8f98002efb98efbf434218a78730a197d981bebaee826e", - "20d3597bb16525b6d09e5fb56feb91b053d961ab156f4807e37d980f50e71aff", - "344b313ffbc0199ff6ca08cacdaf5dc1d85221e2f2dc156a84245bd49b981673", - "848b93264edd3f1a521274ca4da4632989eb5303fd15b14e5ec6bcaa91172b05", - "c6f2046c1e6c172497fc23bd362104e2f4460d0f61984938fa16ef43f27d93f6", - "693b256b1ee6b6fb353ba23274280e7166ab3be8c23c203cc76d716ba4bc32bf", - "13c41508c0da03018d61427910b9922345ced25e2bbce50652e939ee6e5ea56d", - "460ee0ee403be7a4f1eb1c63dd1edaa815fbaa6cf0cf2344dcba4a8acf9aca74", - "b25148579b99b18c8994b0b86e4dd586975a78fa6e7ad6ec89478d7fbafd2683", - "90d7ac6a82166c908b8cf1b352f3c9340a8d1f2907d7146fb7cd6354a5436cca", - "b71d23908e4cf5d6cd973394f3a4b6b164eb1065785feee612efdfd8d30005ed", - ]; - - encoder(type: string, val: any) { - if (type == "uint8") - return web3EthAbi - .encodeParameter("uint8", val) - .substring(2 + (64 - 2)); - if (type == "uint16") - return web3EthAbi - .encodeParameter("uint16", val) - .substring(2 + (64 - 4)); - if (type == "uint32") - return web3EthAbi - .encodeParameter("uint32", val) - .substring(2 + (64 - 8)); - if (type == "uint64") - return web3EthAbi - .encodeParameter("uint64", val) - .substring(2 + (64 - 16)); - if (type == "uint128") - return web3EthAbi - .encodeParameter("uint128", val) - .substring(2 + (64 - 32)); - if (type == "uint256" || type == "bytes32") - return web3EthAbi - .encodeParameter(type, val) - .substring(2 + (64 - 64)); - } - - ord(c: any) { - return c.charCodeAt(0); - } - - genGuardianSetUpgrade( - signers: any, - guardianSet: number, - targetSet: number, - nonce: number, - seq: number, - guardianKeys: string[] - ): string { - const b = [ - "0x", - this.zeroBytes.slice(0, 28 * 2), - this.encoder("uint8", this.ord("C")), - this.encoder("uint8", this.ord("o")), - this.encoder("uint8", this.ord("r")), - this.encoder("uint8", this.ord("e")), - this.encoder("uint8", 2), - this.encoder("uint16", 0), - this.encoder("uint32", targetSet), - this.encoder("uint8", guardianKeys.length), - ]; - - guardianKeys.forEach((x) => { - b.push(x); - }); - - let emitter = "0x" + this.zeroBytes.slice(0, 31 * 2) + "04"; - let seconds = Math.floor(new Date().getTime() / 1000.0); - - return this.createSignedVAA( - guardianSet, - signers, - seconds, - nonce, - 1, - emitter, - seq, - 32, - b.join("") - ); - } - - genGSetFee( - signers: any, - guardianSet: number, - nonce: number, - seq: number, - amt: number - ) { - const b = [ - "0x", - this.zeroBytes.slice(0, 28 * 2), - this.encoder("uint8", this.ord("C")), - this.encoder("uint8", this.ord("o")), - this.encoder("uint8", this.ord("r")), - this.encoder("uint8", this.ord("e")), - this.encoder("uint8", 3), - this.encoder("uint16", 8), - this.encoder("uint256", Math.floor(amt)), - ]; - - let emitter = "0x" + this.zeroBytes.slice(0, 31 * 2) + "04"; - - var seconds = Math.floor(new Date().getTime() / 1000.0); - - return this.createSignedVAA( - guardianSet, - signers, - seconds, - nonce, - 1, - emitter, - seq, - 32, - b.join("") - ); - } - - genGFeePayout( - signers: any, - guardianSet: number, - nonce: number, - seq: number, - amt: number, - dest: Uint8Array - ) { - const b = [ - "0x", - this.zeroBytes.slice(0, 28 * 2), - this.encoder("uint8", this.ord("C")), - this.encoder("uint8", this.ord("o")), - this.encoder("uint8", this.ord("r")), - this.encoder("uint8", this.ord("e")), - this.encoder("uint8", 4), - this.encoder("uint16", 8), - this.encoder("uint256", Math.floor(amt)), - this.uint8ArrayToHexString(dest, false), - ]; - - let emitter = "0x" + this.zeroBytes.slice(0, 31 * 2) + "04"; - - var seconds = Math.floor(new Date().getTime() / 1000.0); - - return this.createSignedVAA( - guardianSet, - signers, - seconds, - nonce, - 1, - emitter, - seq, - 32, - b.join("") - ); - } - - getTokenEmitter(chain: number): string { - if (chain === CHAIN_ID_SOLANA) { - return "ec7372995d5cc8732397fb0ad35c0121e0eaa90d26f828a534cab54391b3a4f5"; - } - if (chain === CHAIN_ID_ETH) { - return "0000000000000000000000003ee18b2214aff97000d974cf647e7c347e8fa585"; - } - if (chain === CHAIN_ID_TERRA) { - return "0000000000000000000000007cf7b764e38a0a5e967972c1df77d432510564e2"; - } - if (chain === CHAIN_ID_BSC) { - return "000000000000000000000000b6f6d86a8f9879a9c87f643768d9efc38c1da6e7"; - } - if (chain === CHAIN_ID_POLYGON) { - return "0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde"; - } - if (chain === CHAIN_ID_AVAX) { - return "0000000000000000000000000e082f06ff657d94310cb8ce8b0d9a04541d8052"; - } - if (chain === CHAIN_ID_OASIS) { - return "0000000000000000000000005848c791e09901b40a9ef749f2a6735b418d7564"; - } - if (chain === CHAIN_ID_FANTOM) { - return "0000000000000000000000007C9Fc5741288cDFdD83CeB07f3ea7e22618D79D2"; - } - return ""; - } - - getNftEmitter(chain: ChainId): string { - if (chain === CHAIN_ID_SOLANA) { - return "0def15a24423e1edd1a5ab16f557b9060303ddbab8c803d2ee48f4b78a1cfd6b"; - } - if (chain === CHAIN_ID_ETH) { - return "0000000000000000000000006ffd7ede62328b3af38fcd61461bbfc52f5651fe"; - } - if (chain === CHAIN_ID_BSC) { - return "0000000000000000000000005a58505a96d1dbf8df91cb21b54419fc36e93fde"; - } - if (chain === CHAIN_ID_POLYGON) { - return "00000000000000000000000090bbd86a6fe93d3bc3ed6335935447e75fab7fcf"; - } - if (chain === CHAIN_ID_AVAX) { - return "000000000000000000000000f7b6737ca9c4e08ae573f75a97b73d7a813f5de5"; - } - if (chain === CHAIN_ID_OASIS) { - return "00000000000000000000000004952D522Ff217f40B5Ef3cbF659EcA7b952a6c1"; - } - if (chain === CHAIN_ID_FANTOM) { - return "000000000000000000000000A9c7119aBDa80d4a4E0C06C8F4d8cF5893234535"; - } - return ""; - } - - genRegisterChain( - signers: any, - guardianSet: number, - nonce: number, - seq: number, - chain: string - ) { - const b = [ - "0x", - this.zeroBytes.slice(0, (32 - 11) * 2), - this.encoder("uint8", this.ord("T")), - this.encoder("uint8", this.ord("o")), - this.encoder("uint8", this.ord("k")), - this.encoder("uint8", this.ord("e")), - this.encoder("uint8", this.ord("n")), - this.encoder("uint8", this.ord("B")), - this.encoder("uint8", this.ord("r")), - this.encoder("uint8", this.ord("i")), - this.encoder("uint8", this.ord("d")), - this.encoder("uint8", this.ord("g")), - this.encoder("uint8", this.ord("e")), - this.encoder("uint8", 1), - this.encoder("uint16", 0), - this.encoder("uint16", chain), - this.getTokenEmitter(parseInt(chain)), - ]; - let emitter = "0x" + this.zeroBytes.slice(0, 31 * 2) + "04"; - - var seconds = Math.floor(new Date().getTime() / 1000.0); - - return this.createSignedVAA( - guardianSet, - signers, - seconds, - nonce, - 1, - emitter, - seq, - 32, - b.join("") - ); - } - - genAssetMeta( - signers: any, - guardianSet: number, - nonce: number, - seq: number, - tokenAddress: string, - chain: number, - decimals: number, - symbol: string, - name: string - ) { - const b = [ - "0x", - this.encoder("uint8", 2), - this.zeroBytes.slice(0, 64 - tokenAddress.length), - tokenAddress, - this.encoder("uint16", chain), - this.encoder("uint8", decimals), - Buffer.from(symbol).toString("hex"), - this.zeroBytes.slice(0, (32 - symbol.length) * 2), - Buffer.from(name).toString("hex"), - this.zeroBytes.slice(0, (32 - name.length) * 2), - ]; - - // console.log(b.join()) - // console.log(b.join('').length) - - let emitter = "0x" + this.getTokenEmitter(chain); - let seconds = Math.floor(new Date().getTime() / 1000.0); - - return this.createSignedVAA( - guardianSet, - signers, - seconds, - nonce, - chain, - emitter, - seq, - 32, - b.join("") - ); - } - - genTransfer( - signers: any, - guardianSet: number, - nonce: number, - seq: number, - amount: number, - tokenAddress: string, - tokenChain: number, - toAddress: string, - toChain: number, - fee: number - ) { - const b = [ - "0x", - this.encoder("uint8", 1), - this.encoder("uint256", Math.floor(amount * 100000000)), - this.zeroBytes.slice(0, 64 - tokenAddress.length), - tokenAddress, - this.encoder("uint16", tokenChain), - this.zeroBytes.slice(0, 64 - toAddress.length), - toAddress, - this.encoder("uint16", toChain), - this.encoder("uint256", Math.floor(fee * 100000000)), - ]; - - let emitter = "0x" + this.getTokenEmitter(tokenChain); - let seconds = Math.floor(new Date().getTime() / 1000.0); - - return this.createSignedVAA( - guardianSet, - signers, - seconds, - nonce, - tokenChain, - emitter, - seq, - 32, - b.join("") - ); - } - - /** - * Create a packed and signed VAA for testing. - * See https://github.com/certusone/wormhole/blob/dev.v2/design/0001_generic_message_passing.md - * - * @param {} guardianSetIndex The guardian set index - * @param {*} signers The list of private keys for signing the VAA - * @param {*} timestamp The timestamp of VAA - * @param {*} nonce The nonce. - * @param {*} emitterChainId The emitter chain identifier - * @param {*} emitterAddress The emitter chain address, prefixed with 0x - * @param {*} sequence The sequence. - * @param {*} consistencyLevel The reported consistency level - * @param {*} payload This VAA Payload hex string, prefixed with 0x - */ - createSignedVAA( - guardianSetIndex: number, - signers: any, - timestamp: number, - nonce: number, - emitterChainId: number, - emitterAddress: string, - sequence: number, - consistencyLevel: number, - payload: string - ) { - console.log(typeof payload); - - const body = [ - this.encoder("uint32", timestamp), - this.encoder("uint32", nonce), - this.encoder("uint16", emitterChainId), - this.encoder("bytes32", emitterAddress), - this.encoder("uint64", sequence), - this.encoder("uint8", consistencyLevel), - payload.substring(2), - ]; - - const hash = web3Utils.keccak256( - web3Utils.keccak256("0x" + body.join("")) - ); - - let signatures = ""; - - for (const i in signers) { - // eslint-disable-next-line new-cap - const ec = new elliptic.ec("secp256k1"); - const key = ec.keyFromPrivate(signers[i]); - const signature = key.sign(hash.substr(2), { canonical: true }); - - const packSig = [ - this.encoder("uint8", i), - this.zeroPadBytes(signature.r.toString(16), 32), - this.zeroPadBytes(signature.s.toString(16), 32), - this.encoder("uint8", signature.recoveryParam), - ]; - - signatures += packSig.join(""); - } - - const vm = [ - this.encoder("uint8", 1), - this.encoder("uint32", guardianSetIndex), - this.encoder("uint8", signers.length), - - signatures, - body.join(""), - ].join(""); - - return vm; - } - - zeroPadBytes(value: string, length: number) { - while (value.length < 2 * length) { - value = "0" + value; - } - return value; - } -} - -module.exports = { - TestLib, -}; diff --git a/sdk/js/src/bridge/getClaimAddress.ts b/sdk/js/src/bridge/getClaimAddress.ts deleted file mode 100644 index 24cf2a1bf..000000000 --- a/sdk/js/src/bridge/getClaimAddress.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { PublicKey } from "@solana/web3.js"; -import { importCoreWasm } from "../solana/wasm"; - -export async function getClaimAddressSolana( - programAddress: string, - signedVAA: Uint8Array -) { - const { claim_address } = await importCoreWasm(); - return new PublicKey(claim_address(programAddress, signedVAA)); -} diff --git a/sdk/js/src/bridge/getEmitterAddress.ts b/sdk/js/src/bridge/getEmitterAddress.ts index b93f4fd73..b1559c493 100644 --- a/sdk/js/src/bridge/getEmitterAddress.ts +++ b/sdk/js/src/bridge/getEmitterAddress.ts @@ -1,9 +1,5 @@ -import { PublicKey } from "@solana/web3.js"; -import { decodeAddress, getApplicationAddress } from "algosdk"; import { bech32 } from "bech32"; import { arrayify, BytesLike, Hexable, zeroPad } from "ethers/lib/utils"; -import { importTokenWasm } from "../solana/wasm"; -import { uint8ArrayToHex } from "../utils"; export function getEmitterAddressEth( contractAddress: number | BytesLike | Hexable @@ -11,22 +7,8 @@ export function getEmitterAddressEth( return Buffer.from(zeroPad(arrayify(contractAddress), 32)).toString("hex"); } -export async function getEmitterAddressSolana(programAddress: string) { - const { emitter_address } = await importTokenWasm(); - return Buffer.from( - zeroPad(new PublicKey(emitter_address(programAddress)).toBytes(), 32) - ).toString("hex"); -} - export async function getEmitterAddressTerra(programAddress: string) { return Buffer.from( zeroPad(bech32.fromWords(bech32.decode(programAddress).words), 32) ).toString("hex"); } - -export function getEmitterAddressAlgorand(appId: bigint): string { - const appAddr: string = getApplicationAddress(appId); - const decAppAddr: Uint8Array = decodeAddress(appAddr).publicKey; - const aa: string = uint8ArrayToHex(decAppAddr); - return aa; -} diff --git a/sdk/js/src/bridge/index.ts b/sdk/js/src/bridge/index.ts index e9ddb3bf7..e19d443fb 100644 --- a/sdk/js/src/bridge/index.ts +++ b/sdk/js/src/bridge/index.ts @@ -1,4 +1,3 @@ -export * from "./getClaimAddress"; export * from "./getEmitterAddress"; export * from "./getSignedVAAHash"; export * from "./parseSequenceFromLog"; diff --git a/sdk/js/src/bridge/parseSequenceFromLog.ts b/sdk/js/src/bridge/parseSequenceFromLog.ts index 621149f69..6fcb06224 100644 --- a/sdk/js/src/bridge/parseSequenceFromLog.ts +++ b/sdk/js/src/bridge/parseSequenceFromLog.ts @@ -1,5 +1,3 @@ -import { TransactionResponse } from "@solana/web3.js"; -import { TxInfo } from "@terra-money/terra.js"; import { BigNumber, ContractReceipt } from "ethers"; import { Implementation__factory } from "../ethers-contracts"; import { node } from "@alephium/web3"; @@ -71,77 +69,3 @@ export function parseSequencesFromLogEth( return sequence.toString(); }); } - -export function parseSequenceFromLogTerra(info: TxInfo): string { - // Scan for the Sequence attribute in all the outputs of the transaction. - // TODO: Make this not horrible. - let sequence = ""; - const jsonLog = JSON.parse(info.raw_log); - jsonLog.map((row: any) => { - row.events.map((event: any) => { - event.attributes.map((attribute: any) => { - if (attribute.key === "message.sequence") { - sequence = attribute.value; - } - }); - }); - }); - return sequence.toString(); -} - -export function parseSequencesFromLogTerra(info: TxInfo): string[] { - // Scan for the Sequence attribute in all the outputs of the transaction. - // TODO: Make this not horrible. - const sequences: string[] = []; - const jsonLog = JSON.parse(info.raw_log); - jsonLog.map((row: any) => { - row.events.map((event: any) => { - event.attributes.map((attribute: any) => { - if (attribute.key === "message.sequence") { - sequences.push(attribute.value.toString()); - } - }); - }); - }); - return sequences; -} - -const SOLANA_SEQ_LOG = "Program log: Sequence: "; -export function parseSequenceFromLogSolana(info: TransactionResponse) { - // TODO: better parsing, safer - const sequence = info.meta?.logMessages - ?.filter((msg) => msg.startsWith(SOLANA_SEQ_LOG))?.[0] - ?.replace(SOLANA_SEQ_LOG, ""); - if (!sequence) { - throw new Error("sequence not found"); - } - return sequence.toString(); -} - -export function parseSequencesFromLogSolana(info: TransactionResponse) { - // TODO: better parsing, safer - return info.meta?.logMessages - ?.filter((msg) => msg.startsWith(SOLANA_SEQ_LOG)) - .map((msg) => msg.replace(SOLANA_SEQ_LOG, "")); -} - -export function parseSequenceFromLogAlgorand( - result: Record -): string { - let sequence = ""; - if (result["inner-txns"]) { - const innerTxns: [] = result["inner-txns"]; - class iTxn { - "local-state-delta": [[Object]]; - logs: Buffer[] | undefined; - "pool-eror": string; - txn: { txn: [Object] } | undefined; - } - innerTxns.forEach((txn: iTxn) => { - if (txn.logs) { - sequence = BigNumber.from(txn.logs[0].slice(0, 8)).toString(); - } - }); - } - return sequence; -} diff --git a/sdk/js/src/index.ts b/sdk/js/src/index.ts index 28ca07cf0..4a1f5ab70 100644 --- a/sdk/js/src/index.ts +++ b/sdk/js/src/index.ts @@ -1,17 +1,12 @@ -export * from "./solana"; -export * from "./terra"; export * from "./rpc"; export * from "./utils"; export * from "./bridge"; export * from "./token_bridge"; export * as ethers_contracts from "./ethers-contracts"; -export * as solana from "./solana"; -export * as terra from "./terra"; export * as rpc from "./rpc"; export * as utils from "./utils"; export * as bridge from "./bridge"; export * as token_bridge from "./token_bridge"; export * as nft_bridge from "./nft_bridge"; -export * as algorand from "./algorand"; export * as alephium_contracts from "./alephium-contracts/ts"; diff --git a/sdk/js/src/migration/addLiquidity.ts b/sdk/js/src/migration/addLiquidity.ts deleted file mode 100644 index 0f017d9af..000000000 --- a/sdk/js/src/migration/addLiquidity.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Token, TOKEN_PROGRAM_ID, u64 } from "@solana/spl-token"; -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; -import { ixFromRust } from "../solana"; -import { importMigrationWasm } from "../solana/wasm"; - -export default async function addLiquidity( - connection: Connection, - payerAddress: string, - program_id: string, - from_mint: string, - to_mint: string, - liquidity_token_account: string, - lp_share_token_account: string, - amount: BigInt -) { - const { authority_address, add_liquidity } = await importMigrationWasm(); - const approvalIx = Token.createApproveInstruction( - TOKEN_PROGRAM_ID, - new PublicKey(liquidity_token_account), - new PublicKey(authority_address(program_id)), - new PublicKey(payerAddress), - [], - new u64(amount.toString(16), 16) - ); - const ix = ixFromRust( - add_liquidity( - program_id, - from_mint, - to_mint, - liquidity_token_account, - lp_share_token_account, - amount.valueOf() - ) - ); - const transaction = new Transaction().add(approvalIx, ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} diff --git a/sdk/js/src/migration/authorityAddress.ts b/sdk/js/src/migration/authorityAddress.ts deleted file mode 100644 index ba657172e..000000000 --- a/sdk/js/src/migration/authorityAddress.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { importMigrationWasm } from "../solana/wasm"; - -export default async function authorityAddress(program_id: string) { - const { authority_address } = await importMigrationWasm(); - return authority_address(program_id); -} diff --git a/sdk/js/src/migration/claimShares.ts b/sdk/js/src/migration/claimShares.ts deleted file mode 100644 index 7470e9151..000000000 --- a/sdk/js/src/migration/claimShares.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Token, TOKEN_PROGRAM_ID, u64 } from "@solana/spl-token"; -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; -import { ixFromRust } from "../solana"; -import { importMigrationWasm } from "../solana/wasm"; - -export default async function claimShares( - connection: Connection, - payerAddress: string, - program_id: string, - from_mint: string, - to_mint: string, - output_token_account: string, - lp_share_token_account: string, - amount: BigInt -) { - const { authority_address, claim_shares } = await importMigrationWasm(); - const approvalIx = Token.createApproveInstruction( - TOKEN_PROGRAM_ID, - new PublicKey(lp_share_token_account), - new PublicKey(authority_address(program_id)), - new PublicKey(payerAddress), - [], - new u64(amount.toString(16), 16) - ); - const ix = ixFromRust( - claim_shares( - program_id, - from_mint, - to_mint, - output_token_account, - lp_share_token_account, - amount.valueOf() - ) - ); - const transaction = new Transaction().add(approvalIx, ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} diff --git a/sdk/js/src/migration/createPool.ts b/sdk/js/src/migration/createPool.ts deleted file mode 100644 index 7235e95f6..000000000 --- a/sdk/js/src/migration/createPool.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; -import { ixFromRust } from "../solana"; -import { importMigrationWasm } from "../solana/wasm"; - -export default async function createPool( - connection: Connection, - payerAddress: string, - program_id: string, - payer: string, - from_mint: string, - to_mint: string -) { - const { create_pool } = await importMigrationWasm(); - const ix = ixFromRust(create_pool(program_id, payer, from_mint, to_mint)); - const transaction = new Transaction().add(ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} diff --git a/sdk/js/src/migration/fromCustodyAddress.ts b/sdk/js/src/migration/fromCustodyAddress.ts deleted file mode 100644 index 43b4652da..000000000 --- a/sdk/js/src/migration/fromCustodyAddress.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { importMigrationWasm } from "../solana/wasm"; - -export default async function fromCustodyAddress( - program_id: string, - pool: string -) { - const { from_custody_address } = await importMigrationWasm(); - return from_custody_address(program_id, pool); -} diff --git a/sdk/js/src/migration/migrateTokens.ts b/sdk/js/src/migration/migrateTokens.ts deleted file mode 100644 index 7a4ea7254..000000000 --- a/sdk/js/src/migration/migrateTokens.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Token, TOKEN_PROGRAM_ID, u64 } from "@solana/spl-token"; -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; -import { ixFromRust } from "../solana"; -import { importMigrationWasm } from "../solana/wasm"; - -export default async function migrateTokens( - connection: Connection, - payerAddress: string, - program_id: string, - from_mint: string, - to_mint: string, - input_token_account: string, - output_token_account: string, - amount: BigInt -) { - const { authority_address, migrate_tokens } = await importMigrationWasm(); - const approvalIx = Token.createApproveInstruction( - TOKEN_PROGRAM_ID, - new PublicKey(input_token_account), - new PublicKey(authority_address(program_id)), - new PublicKey(payerAddress), - [], - new u64(amount.toString(16), 16) - ); - const ix = ixFromRust( - migrate_tokens( - program_id, - from_mint, - to_mint, - input_token_account, - output_token_account, - amount.valueOf() - ) - ); - const transaction = new Transaction().add(approvalIx, ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} diff --git a/sdk/js/src/migration/parsePool.ts b/sdk/js/src/migration/parsePool.ts deleted file mode 100644 index fcfb37717..000000000 --- a/sdk/js/src/migration/parsePool.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { importMigrationWasm } from "../solana/wasm"; - -export default async function parsePool(data: Uint8Array) { - const { parse_pool } = await importMigrationWasm(); - return parse_pool(data); -} diff --git a/sdk/js/src/migration/poolAddress.ts b/sdk/js/src/migration/poolAddress.ts deleted file mode 100644 index 0d1aaf7d3..000000000 --- a/sdk/js/src/migration/poolAddress.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { importMigrationWasm } from "../solana/wasm"; - -export default async function poolAddress( - program_id: string, - from_mint: string, - to_mint: string -) { - const { pool_address } = await importMigrationWasm(); - return pool_address(program_id, from_mint, to_mint); -} diff --git a/sdk/js/src/migration/removeLiquidity.ts b/sdk/js/src/migration/removeLiquidity.ts deleted file mode 100644 index ef3292ae3..000000000 --- a/sdk/js/src/migration/removeLiquidity.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Token, TOKEN_PROGRAM_ID, u64 } from "@solana/spl-token"; -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; -import { ixFromRust } from "../solana"; -import { importMigrationWasm } from "../solana/wasm"; - -export default async function removeLiquidity( - connection: Connection, - payerAddress: string, - program_id: string, - from_mint: string, - to_mint: string, - liquidity_token_account: string, - lp_share_token_account: string, - amount: BigInt -) { - const { authority_address, remove_liquidity } = await importMigrationWasm(); - const approvalIx = Token.createApproveInstruction( - TOKEN_PROGRAM_ID, - new PublicKey(lp_share_token_account), - new PublicKey(authority_address(program_id)), - new PublicKey(payerAddress), - [], - new u64(amount.toString(16), 16) - ); - const ix = ixFromRust( - remove_liquidity( - program_id, - from_mint, - to_mint, - liquidity_token_account, - lp_share_token_account, - amount.valueOf() - ) - ); - const transaction = new Transaction().add(approvalIx, ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} diff --git a/sdk/js/src/migration/shareMintAddress.ts b/sdk/js/src/migration/shareMintAddress.ts deleted file mode 100644 index eda0d1f8a..000000000 --- a/sdk/js/src/migration/shareMintAddress.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { importMigrationWasm } from "../solana/wasm"; - -export default async function shareMintAddress( - program_id: string, - pool: string -) { - const { share_mint_address } = await importMigrationWasm(); - return share_mint_address(program_id, pool); -} diff --git a/sdk/js/src/migration/toCustodyAddress.ts b/sdk/js/src/migration/toCustodyAddress.ts deleted file mode 100644 index 32be18a6b..000000000 --- a/sdk/js/src/migration/toCustodyAddress.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { importMigrationWasm } from "../solana/wasm"; - -export default async function toCustodyAddress( - program_id: string, - pool: string -) { - const { to_custody_address } = await importMigrationWasm(); - return to_custody_address(program_id, pool); -} diff --git a/sdk/js/src/nft_bridge/getForeignAsset.ts b/sdk/js/src/nft_bridge/getForeignAsset.ts index a1528e71e..1ce3624fc 100644 --- a/sdk/js/src/nft_bridge/getForeignAsset.ts +++ b/sdk/js/src/nft_bridge/getForeignAsset.ts @@ -1,10 +1,7 @@ -import { PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; import { ethers } from "ethers"; import { fromUint8Array } from "js-base64"; import { CHAIN_ID_SOLANA } from ".."; import { NFTBridge__factory } from "../ethers-contracts"; -import { importNftWasm } from "../solana/wasm"; import { ChainId, ChainName, coalesceChainId } from "../utils"; /** @@ -38,64 +35,3 @@ export async function getForeignAssetEth( return null; } } - -/** - * Returns a foreign asset address on Terra for a provided native chain and asset address - * @param tokenBridgeAddress - * @param client - * @param originChain - * @param originAsset - * @returns - */ -export async function getForeignAssetTerra( - tokenBridgeAddress: string, - client: LCDClient, - originChain: ChainId, - originAsset: Uint8Array -): Promise { - const originChainId = coalesceChainId(originChain); - try { - const address = - originChain == CHAIN_ID_SOLANA - ? "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=" - : fromUint8Array(originAsset); - const result: { address: string } = await client.wasm.contractQuery( - tokenBridgeAddress, - { - wrapped_registry: { - chain: originChainId, - address, - }, - } - ); - return result.address; - } catch (e) { - return null; - } -} - -/** - * Returns a foreign asset address on Solana for a provided native chain and asset address - * @param tokenBridgeAddress - * @param originChain - * @param originAsset zero pad to 32 bytes - * @returns - */ -export async function getForeignAssetSol( - tokenBridgeAddress: string, - originChain: ChainId | ChainName, - originAsset: Uint8Array, - tokenId: Uint8Array -): Promise { - const originChainId = coalesceChainId(originChain); - const { wrapped_address } = await importNftWasm(); - const wrappedAddress = wrapped_address( - tokenBridgeAddress, - originAsset, - originChainId, - tokenId - ); - const wrappedAddressPK = new PublicKey(wrappedAddress); - // we don't require NFT accounts to exist, so don't check them. - return wrappedAddressPK.toString(); -} diff --git a/sdk/js/src/nft_bridge/getIsTransferCompleted.ts b/sdk/js/src/nft_bridge/getIsTransferCompleted.ts index bb0e1a245..626da6e9c 100644 --- a/sdk/js/src/nft_bridge/getIsTransferCompleted.ts +++ b/sdk/js/src/nft_bridge/getIsTransferCompleted.ts @@ -1,12 +1,6 @@ import { ethers } from "ethers"; import { NFTBridge__factory } from "../ethers-contracts"; import { getSignedVAAHash } from "../bridge"; -import { importCoreWasm } from "../solana/wasm"; -import { Connection, PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import axios from "axios"; -import { redeemOnTerra } from "."; -import { TERRA_REDEEMED_CHECK_WALLET_ADDRESS } from ".."; export async function getIsTransferCompletedEth( nftBridgeAddress: string, @@ -17,55 +11,3 @@ export async function getIsTransferCompletedEth( const signedVAAHash = getSignedVAAHash(signedVAA); return await nftBridge.isTransferCompleted(signedVAAHash); } - -export async function getIsTransferCompletedTerra( - nftBridgeAddress: string, - signedVAA: Uint8Array, - client: LCDClient, - gasPriceUrl: string -) { - const msg = await redeemOnTerra( - nftBridgeAddress, - TERRA_REDEEMED_CHECK_WALLET_ADDRESS, - signedVAA - ); - // TODO: remove gasPriceUrl and just use the client's gas prices - const gasPrices = await axios.get(gasPriceUrl).then((result) => result.data); - const account = await client.auth.accountInfo( - TERRA_REDEEMED_CHECK_WALLET_ADDRESS - ); - try { - await client.tx.estimateFee( - [ - { - sequenceNumber: account.getSequenceNumber(), - publicKey: account.getPublicKey(), - }, - ], - { - msgs: [msg], - memo: "already redeemed calculation", - feeDenoms: ["uluna"], - gasPrices, - } - ); - } catch (e: any) { - // redeemed if the VAA was already executed - return e.response.data.message.includes("VaaAlreadyExecuted"); - } - return false; -} - -export async function getIsTransferCompletedSolana( - nftBridgeAddress: string, - signedVAA: Uint8Array, - connection: Connection -) { - const { claim_address } = await importCoreWasm(); - const claimAddress = await claim_address(nftBridgeAddress, signedVAA); - const claimInfo = await connection.getAccountInfo( - new PublicKey(claimAddress), - "confirmed" - ); - return !!claimInfo; -} diff --git a/sdk/js/src/nft_bridge/getIsWrappedAsset.ts b/sdk/js/src/nft_bridge/getIsWrappedAsset.ts index 7cd1f4937..a7b32b6e1 100644 --- a/sdk/js/src/nft_bridge/getIsWrappedAsset.ts +++ b/sdk/js/src/nft_bridge/getIsWrappedAsset.ts @@ -1,7 +1,5 @@ -import { Connection, PublicKey } from "@solana/web3.js"; import { ethers } from "ethers"; import { Bridge__factory } from "../ethers-contracts"; -import { importNftWasm } from "../solana/wasm"; /** * Returns whether or not an asset address on Ethereum is a wormhole wrapped asset @@ -19,28 +17,3 @@ export async function getIsWrappedAssetEth( const tokenBridge = Bridge__factory.connect(tokenBridgeAddress, provider); return await tokenBridge.isWrappedAsset(assetAddress); } - -/** - * Returns whether or not an asset on Solana is a wormhole wrapped asset - * @param connection - * @param tokenBridgeAddress - * @param mintAddress - * @returns - */ -export async function getIsWrappedAssetSol( - connection: Connection, - tokenBridgeAddress: string, - mintAddress: string -) { - if (!mintAddress) return false; - const { wrapped_meta_address } = await importNftWasm(); - const wrappedMetaAddress = wrapped_meta_address( - tokenBridgeAddress, - new PublicKey(mintAddress).toBytes() - ); - const wrappedMetaAddressPK = new PublicKey(wrappedMetaAddress); - const wrappedMetaAccountInfo = await connection.getAccountInfo( - wrappedMetaAddressPK - ); - return !!wrappedMetaAccountInfo; -} diff --git a/sdk/js/src/nft_bridge/getOriginalAsset.ts b/sdk/js/src/nft_bridge/getOriginalAsset.ts index fdb25bc11..604a0ccb0 100644 --- a/sdk/js/src/nft_bridge/getOriginalAsset.ts +++ b/sdk/js/src/nft_bridge/getOriginalAsset.ts @@ -1,15 +1,10 @@ -import { Connection, PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; import { BigNumber, ethers } from "ethers"; import { arrayify, zeroPad } from "ethers/lib/utils"; -import { canonicalAddress, WormholeWrappedInfo } from ".."; import { TokenImplementation__factory } from "../ethers-contracts"; -import { importNftWasm } from "../solana/wasm"; import { ChainId, ChainName, CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, coalesceChainId, } from "../utils"; import { getIsWrappedAssetEth } from "./getIsWrappedAsset"; @@ -66,59 +61,6 @@ export async function getOriginalAssetEth( }; } -/** - * Returns a origin chain and asset address on {originChain} for a provided Wormhole wrapped address - * @param connection - * @param tokenBridgeAddress - * @param mintAddress - * @returns - */ -export async function getOriginalAssetSol( - connection: Connection, - tokenBridgeAddress: string, - mintAddress: string -): Promise { - if (mintAddress) { - // TODO: share some of this with getIsWrappedAssetSol, like a getWrappedMetaAccountAddress or something - const { parse_wrapped_meta, wrapped_meta_address } = await importNftWasm(); - const wrappedMetaAddress = wrapped_meta_address( - tokenBridgeAddress, - new PublicKey(mintAddress).toBytes() - ); - const wrappedMetaAddressPK = new PublicKey(wrappedMetaAddress); - const wrappedMetaAccountInfo = await connection.getAccountInfo( - wrappedMetaAddressPK - ); - if (wrappedMetaAccountInfo) { - const parsed = parse_wrapped_meta(wrappedMetaAccountInfo.data); - const token_id_arr = parsed.token_id as BigUint64Array; - const token_id_bytes = []; - for (let elem of token_id_arr.reverse()) { - token_id_bytes.push(...bigToUint8Array(elem)); - } - const token_id = BigNumber.from(token_id_bytes).toString(); - return { - isWrapped: true, - chainId: parsed.chain, - assetAddress: parsed.token_address, - tokenId: token_id, - }; - } - } - try { - return { - isWrapped: false, - chainId: CHAIN_ID_SOLANA, - assetAddress: new PublicKey(mintAddress).toBytes(), - }; - } catch (e) {} - return { - isWrapped: false, - chainId: CHAIN_ID_SOLANA, - assetAddress: new Uint8Array(32), - }; -} - // Derived from https://www.jackieli.dev/posts/bigint-to-uint8array/ const big0 = BigInt(0); const big1 = BigInt(1); @@ -148,32 +90,3 @@ function bigToUint8Array(big: bigint) { } return u8; } - -export async function getOriginalAssetTerra( - client: LCDClient, - wrappedAddress: string -): Promise { - try { - const result: { - asset_address: string; - asset_chain: ChainId; - bridge: string; - } = await client.wasm.contractQuery(wrappedAddress, { - wrapped_asset_info: {}, - }); - if (result) { - return { - isWrapped: true, - chainId: result.asset_chain, - assetAddress: new Uint8Array( - Buffer.from(result.asset_address, "base64") - ), - }; - } - } catch (e) {} - return { - isWrapped: false, - chainId: CHAIN_ID_TERRA, - assetAddress: zeroPad(canonicalAddress(wrappedAddress), 32), - }; -} diff --git a/sdk/js/src/nft_bridge/redeem.ts b/sdk/js/src/nft_bridge/redeem.ts index 18aee1cb6..eba5b7457 100644 --- a/sdk/js/src/nft_bridge/redeem.ts +++ b/sdk/js/src/nft_bridge/redeem.ts @@ -1,11 +1,5 @@ -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; -import { MsgExecuteContract } from "@terra-money/terra.js"; import { ethers, Overrides } from "ethers"; -import { fromUint8Array } from "js-base64"; -import { CHAIN_ID_SOLANA } from ".."; import { Bridge__factory } from "../ethers-contracts"; -import { ixFromRust } from "../solana"; -import { importCoreWasm, importNftWasm } from "../solana/wasm"; export async function redeemOnEth( tokenBridgeAddress: string, @@ -18,92 +12,3 @@ export async function redeemOnEth( const receipt = await v.wait(); return receipt; } - -export async function isNFTVAASolanaNative( - signedVAA: Uint8Array -): Promise { - const { parse_vaa } = await importCoreWasm(); - const parsedVAA = parse_vaa(signedVAA); - const isSolanaNative = - Buffer.from(new Uint8Array(parsedVAA.payload)).readUInt16BE(33) === - CHAIN_ID_SOLANA; - return isSolanaNative; -} - -export async function redeemOnSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - signedVAA: Uint8Array -): Promise { - const isSolanaNative = await isNFTVAASolanaNative(signedVAA); - const { complete_transfer_wrapped_ix, complete_transfer_native_ix } = - await importNftWasm(); - const ixs = []; - if (isSolanaNative) { - ixs.push( - ixFromRust( - complete_transfer_native_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - payerAddress, //TODO: allow for a different address than payer - signedVAA - ) - ) - ); - } else { - ixs.push( - ixFromRust( - complete_transfer_wrapped_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - payerAddress, //TODO: allow for a different address than payer - signedVAA - ) - ) - ); - } - const transaction = new Transaction().add(...ixs); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} - -export async function createMetaOnSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - signedVAA: Uint8Array -): Promise { - const { complete_transfer_wrapped_meta_ix } = await importNftWasm(); - const ix = ixFromRust( - complete_transfer_wrapped_meta_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - signedVAA - ) - ); - const transaction = new Transaction().add(ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} - -export async function redeemOnTerra( - tokenBridgeAddress: string, - walletAddress: string, - signedVAA: Uint8Array -): Promise { - return new MsgExecuteContract(walletAddress, tokenBridgeAddress, { - submit_vaa: { - data: fromUint8Array(signedVAA), - }, - }); -} diff --git a/sdk/js/src/nft_bridge/transfer.ts b/sdk/js/src/nft_bridge/transfer.ts index 5aae70106..f95fee680 100644 --- a/sdk/js/src/nft_bridge/transfer.ts +++ b/sdk/js/src/nft_bridge/transfer.ts @@ -1,14 +1,9 @@ -import { Token, TOKEN_PROGRAM_ID } from "@solana/spl-token"; -import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js"; -import { MsgExecuteContract } from "@terra-money/terra.js"; import { ethers, Overrides } from "ethers"; import { NFTBridge__factory, NFTImplementation__factory, } from "../ethers-contracts"; -import { getBridgeFeeIx, ixFromRust } from "../solana"; -import { importNftWasm } from "../solana/wasm"; -import { ChainId, ChainName, CHAIN_ID_SOLANA, coalesceChainId, createNonce } from "../utils"; +import { ChainId, ChainName, coalesceChainId, createNonce } from "../utils"; export async function transferFromEth( tokenBridgeAddress: string, @@ -35,119 +30,3 @@ export async function transferFromEth( const receipt = await v.wait(); return receipt; } - -export async function transferFromSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - fromAddress: string, - mintAddress: string, - targetAddress: Uint8Array, - targetChain: ChainId | ChainName, - originAddress?: Uint8Array, - originChain?: ChainId | ChainName, - originTokenId?: Uint8Array -): Promise { - const originChainId: ChainId | undefined = originChain ? coalesceChainId(originChain) : undefined - const nonce = createNonce().readUInt32LE(0); - const transferIx = await getBridgeFeeIx( - connection, - bridgeAddress, - payerAddress - ); - const { - transfer_native_ix, - transfer_wrapped_ix, - approval_authority_address, - } = await importNftWasm(); - const approvalIx = Token.createApproveInstruction( - TOKEN_PROGRAM_ID, - new PublicKey(fromAddress), - new PublicKey(approval_authority_address(tokenBridgeAddress)), - new PublicKey(payerAddress), - [], - Number(1) - ); - let messageKey = Keypair.generate(); - const isSolanaNative = - originChain === undefined || originChain === CHAIN_ID_SOLANA; - if (!isSolanaNative && (!originAddress || !originTokenId)) { - throw new Error( - "originAddress and originTokenId are required when specifying originChain" - ); - } - const ix = ixFromRust( - isSolanaNative - ? transfer_native_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - fromAddress, - mintAddress, - nonce, - targetAddress, - coalesceChainId(targetChain) - ) - : transfer_wrapped_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - fromAddress, - payerAddress, - originChainId as number, // checked by isSolanaNative - originAddress as Uint8Array, // checked by throw - originTokenId as Uint8Array, // checked by throw - nonce, - targetAddress, - coalesceChainId(targetChain) - ) - ); - const transaction = new Transaction().add(transferIx, approvalIx, ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - transaction.partialSign(messageKey); - return transaction; -} - -export async function transferFromTerra( - walletAddress: string, - tokenBridgeAddress: string, - tokenAddress: string, - tokenID: string, - recipientChain: ChainId | ChainName, - recipientAddress: Uint8Array -): Promise { - const recipientChainId = coalesceChainId(recipientChain) - const nonce = Math.round(Math.random() * 100000); - return [ - new MsgExecuteContract( - walletAddress, - tokenAddress, - { - approve: { - spender: tokenBridgeAddress, - token_id: tokenID, - }, - }, - {} - ), - new MsgExecuteContract( - walletAddress, - tokenBridgeAddress, - { - initiate_transfer: { - contract_addr: tokenAddress, - token_id: tokenID, - recipient_chain: recipientChainId, - recipient: Buffer.from(recipientAddress).toString("base64"), - nonce: nonce, - }, - }, - {} - ), - ]; -} diff --git a/sdk/js/src/solana/core-node/bridge.d.ts b/sdk/js/src/solana/core-node/bridge.d.ts deleted file mode 100644 index 202f87933..000000000 --- a/sdk/js/src/solana/core-node/bridge.d.ts +++ /dev/null @@ -1,375 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} payer -* @param {string} emitter -* @param {string} message -* @param {number} nonce -* @param {Uint8Array} msg -* @param {string} consistency -* @returns {any} -*/ -export function post_message_ix(program_id: string, payer: string, emitter: string, message: string, nonce: number, msg: Uint8Array, consistency: string): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {string} signature_set -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function post_vaa_ix(program_id: string, payer: string, signature_set: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function update_guardian_set_ix(program_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function set_fees_ix(program_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function transfer_fees_ix(program_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id: string, payer: string, spill: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {number} guardian_set_index -* @param {any} guardian_set -* @param {string} signature_set -* @param {Uint8Array} vaa_data -* @returns {any} -*/ -export function verify_signatures_ix(program_id: string, payer: string, guardian_set_index: number, guardian_set: any, signature_set: string, vaa_data: Uint8Array): any; -/** -* @param {string} bridge -* @param {number} index -* @returns {Uint8Array} -*/ -export function guardian_set_address(bridge: string, index: number): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_guardian_set(data: Uint8Array): any; -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -export function state_address(bridge: string): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_state(data: Uint8Array): any; -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -export function fee_collector_address(bridge: string): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} vaa -* @returns {Uint8Array} -*/ -export function claim_address(program_id: string, vaa: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_posted_message(data: Uint8Array): any; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_vaa(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/core-node/bridge.js b/sdk/js/src/solana/core-node/bridge.js deleted file mode 100644 index 55086cfb9..000000000 --- a/sdk/js/src/solana/core-node/bridge.js +++ /dev/null @@ -1,1369 +0,0 @@ -let imports = {}; -imports['__wbindgen_placeholder__'] = module.exports; -let wasm; -const { TextEncoder, TextDecoder } = require(`util`); - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -function getObject(idx) { return heap[idx]; } - -let WASM_VECTOR_LEN = 0; - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -let cachedTextEncoder = new TextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let heap_next = heap.length; - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {string} program_id -* @param {string} payer -* @param {string} emitter -* @param {string} message -* @param {number} nonce -* @param {Uint8Array} msg -* @param {string} consistency -* @returns {any} -*/ -module.exports.post_message_ix = function(program_id, payer, emitter, message, nonce, msg, consistency) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(emitter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(consistency, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ret = wasm.post_message_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, nonce, ptr4, len4, ptr5, len5); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} payer -* @param {string} signature_set -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.post_vaa_ix = function(program_id, payer, signature_set, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(signature_set, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.post_vaa_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.update_guardian_set_ix = function(program_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.update_guardian_set_ix(ptr0, len0, ptr1, len1, ptr2, len2); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.set_fees_ix = function(program_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.set_fees_ix(ptr0, len0, ptr1, len1, ptr2, len2); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.transfer_fees_ix = function(program_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.transfer_fees_ix(ptr0, len0, ptr1, len1, ptr2, len2); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.upgrade_contract_ix = function(program_id, payer, spill, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(spill, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.upgrade_contract_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} payer -* @param {number} guardian_set_index -* @param {any} guardian_set -* @param {string} signature_set -* @param {Uint8Array} vaa_data -* @returns {any} -*/ -module.exports.verify_signatures_ix = function(program_id, payer, guardian_set_index, guardian_set, signature_set, vaa_data) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(signature_set, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa_data, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.verify_signatures_ix(ptr0, len0, ptr1, len1, guardian_set_index, addHeapObject(guardian_set), ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} bridge -* @param {number} index -* @returns {Uint8Array} -*/ -module.exports.guardian_set_address = function(bridge, index) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(bridge, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.guardian_set_address(retptr, ptr0, len0, index); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_guardian_set = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_guardian_set(ptr0, len0); - return takeObject(ret); -}; - -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -module.exports.state_address = function(bridge) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(bridge, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.state_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_state = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_state(ptr0, len0); - return takeObject(ret); -}; - -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -module.exports.fee_collector_address = function(bridge) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(bridge, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.fee_collector_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {Uint8Array} vaa -* @returns {Uint8Array} -*/ -module.exports.claim_address = function(program_id, vaa) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.claim_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_posted_message = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_posted_message(ptr0, len0); - return takeObject(ret); -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_vaa = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_vaa(ptr0, len0); - return takeObject(ret); -}; - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -module.exports.init = function() { - wasm.init(); -}; - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Hash = Hash; -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -module.exports.Instruction = Instruction; -/** -*/ -class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -module.exports.Instructions = Instructions; -/** -*/ -class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -module.exports.Message = Message; -/** -*/ -class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Pubkey = Pubkey; - -class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_systeminstruction_free(ptr); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} -module.exports.SystemInstruction = SystemInstruction; - -module.exports.__wbindgen_json_serialize = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = JSON.stringify(obj === undefined ? null : obj); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); -}; - -module.exports.__wbindgen_json_parse = function(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_instruction_new = function(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -module.exports.__wbg_pubkey_new = function(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_string_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_is_undefined = function(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -module.exports.__wbindgen_number_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -module.exports.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -module.exports.__wbg_debug_fda1f49ea6af7a1d = function(arg0) { - console.debug(getObject(arg0)); -}; - -module.exports.__wbg_error_8ff19d586a987aef = function(arg0) { - console.error(getObject(arg0)); -}; - -module.exports.__wbg_info_c8f1b00be4ef10bc = function(arg0) { - console.info(getObject(arg0)); -}; - -module.exports.__wbg_log_e8ba7b992c7ad0eb = function(arg0) { - console.log(getObject(arg0)); -}; - -module.exports.__wbg_warn_0227db1aa6989248 = function(arg0) { - console.warn(getObject(arg0)); -}; - -module.exports.__wbg_new_693216e109162396 = function() { - const ret = new Error(); - return addHeapObject(ret); -}; - -module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -module.exports.__wbg_new_94fb1279cf6afea5 = function() { - const ret = new Array(); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_is_function = function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -module.exports.__wbindgen_is_object = function(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -module.exports.__wbg_next_cabb70b365520721 = function(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -module.exports.__wbg_next_bf3d83fc18df496e = function() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_done_040f966faa9a72b3 = function(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -module.exports.__wbg_value_419afbd9b9574c4c = function(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -module.exports.__wbg_iterator_4832ef1f15b0382b = function() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -module.exports.__wbg_get_a9cab131e3152c49 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_call_ae78342adc33730a = function() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_newwithlength_e80fb11cf19c1628 = function(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_561aac756158708c = function(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -module.exports.__wbg_isArray_6721f2e508996340 = function(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -module.exports.__wbg_push_40c6a90f1805aa90 = function(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -module.exports.__wbg_values_b1b9e8c63dbe01c2 = function(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -module.exports.__wbg_buffer_7af23f65f6c64548 = function(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -module.exports.__wbg_new_cc9018bd6f283b6f = function(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -module.exports.__wbg_length_0acb1cf9bbaf8519 = function(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -module.exports.__wbg_instanceof_Uint8Array_edb92795fc0c63b4 = function(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -module.exports.__wbindgen_debug_string = function(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_throw = function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -module.exports.__wbindgen_memory = function() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - -const path = require('path').join(__dirname, 'bridge_bg.wasm'); -const bytes = require('fs').readFileSync(path); - -const wasmModule = new WebAssembly.Module(bytes); -const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -wasm = wasmInstance.exports; -module.exports.__wasm = wasm; - diff --git a/sdk/js/src/solana/core-node/bridge_bg.wasm b/sdk/js/src/solana/core-node/bridge_bg.wasm deleted file mode 100644 index 98bdb57cf..000000000 Binary files a/sdk/js/src/solana/core-node/bridge_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/core-node/bridge_bg.wasm.d.ts b/sdk/js/src/solana/core-node/bridge_bg.wasm.d.ts deleted file mode 100644 index e46f2dcea..000000000 --- a/sdk/js/src/solana/core-node/bridge_bg.wasm.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function post_message_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number): number; -export function post_vaa_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function update_guardian_set_ix(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function set_fees_ix(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function transfer_fees_ix(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function upgrade_contract_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function verify_signatures_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function guardian_set_address(a: number, b: number, c: number, d: number): void; -export function parse_guardian_set(a: number, b: number): number; -export function state_address(a: number, b: number, c: number): void; -export function parse_state(a: number, b: number): number; -export function fee_collector_address(a: number, b: number, c: number): void; -export function claim_address(a: number, b: number, c: number, d: number, e: number): void; -export function parse_posted_message(a: number, b: number): number; -export function parse_vaa(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function init(): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/core-node/package.json b/sdk/js/src/solana/core-node/package.json deleted file mode 100644 index fdb438e49..000000000 --- a/sdk/js/src/solana/core-node/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "wormhole-bridge-solana", - "description": "Wormhole bridge core contract", - "version": "0.1.0", - "files": [ - "bridge_bg.wasm", - "bridge.js", - "bridge_bg.js", - "bridge.d.ts" - ], - "main": "bridge.js", - "types": "bridge.d.ts" -} \ No newline at end of file diff --git a/sdk/js/src/solana/core/bridge.d.ts b/sdk/js/src/solana/core/bridge.d.ts deleted file mode 100644 index 202f87933..000000000 --- a/sdk/js/src/solana/core/bridge.d.ts +++ /dev/null @@ -1,375 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} payer -* @param {string} emitter -* @param {string} message -* @param {number} nonce -* @param {Uint8Array} msg -* @param {string} consistency -* @returns {any} -*/ -export function post_message_ix(program_id: string, payer: string, emitter: string, message: string, nonce: number, msg: Uint8Array, consistency: string): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {string} signature_set -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function post_vaa_ix(program_id: string, payer: string, signature_set: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function update_guardian_set_ix(program_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function set_fees_ix(program_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function transfer_fees_ix(program_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id: string, payer: string, spill: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {number} guardian_set_index -* @param {any} guardian_set -* @param {string} signature_set -* @param {Uint8Array} vaa_data -* @returns {any} -*/ -export function verify_signatures_ix(program_id: string, payer: string, guardian_set_index: number, guardian_set: any, signature_set: string, vaa_data: Uint8Array): any; -/** -* @param {string} bridge -* @param {number} index -* @returns {Uint8Array} -*/ -export function guardian_set_address(bridge: string, index: number): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_guardian_set(data: Uint8Array): any; -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -export function state_address(bridge: string): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_state(data: Uint8Array): any; -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -export function fee_collector_address(bridge: string): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} vaa -* @returns {Uint8Array} -*/ -export function claim_address(program_id: string, vaa: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_posted_message(data: Uint8Array): any; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_vaa(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/core/bridge.js b/sdk/js/src/solana/core/bridge.js deleted file mode 100644 index b717be1dd..000000000 --- a/sdk/js/src/solana/core/bridge.js +++ /dev/null @@ -1,2 +0,0 @@ -import * as wasm from "./bridge_bg.wasm"; -export * from "./bridge_bg.js"; \ No newline at end of file diff --git a/sdk/js/src/solana/core/bridge_bg.js b/sdk/js/src/solana/core/bridge_bg.js deleted file mode 100644 index 60e378e36..000000000 --- a/sdk/js/src/solana/core/bridge_bg.js +++ /dev/null @@ -1,1355 +0,0 @@ -import * as wasm from './bridge_bg.wasm'; - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -function getObject(idx) { return heap[idx]; } - -let WASM_VECTOR_LEN = 0; - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; - -let cachedTextEncoder = new lTextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let heap_next = heap.length; - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; - -let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {string} program_id -* @param {string} payer -* @param {string} emitter -* @param {string} message -* @param {number} nonce -* @param {Uint8Array} msg -* @param {string} consistency -* @returns {any} -*/ -export function post_message_ix(program_id, payer, emitter, message, nonce, msg, consistency) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(emitter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(consistency, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ret = wasm.post_message_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, nonce, ptr4, len4, ptr5, len5); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} payer -* @param {string} signature_set -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function post_vaa_ix(program_id, payer, signature_set, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(signature_set, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.post_vaa_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function update_guardian_set_ix(program_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.update_guardian_set_ix(ptr0, len0, ptr1, len1, ptr2, len2); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function set_fees_ix(program_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.set_fees_ix(ptr0, len0, ptr1, len1, ptr2, len2); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function transfer_fees_ix(program_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.transfer_fees_ix(ptr0, len0, ptr1, len1, ptr2, len2); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id, payer, spill, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(spill, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.upgrade_contract_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} payer -* @param {number} guardian_set_index -* @param {any} guardian_set -* @param {string} signature_set -* @param {Uint8Array} vaa_data -* @returns {any} -*/ -export function verify_signatures_ix(program_id, payer, guardian_set_index, guardian_set, signature_set, vaa_data) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(signature_set, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa_data, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.verify_signatures_ix(ptr0, len0, ptr1, len1, guardian_set_index, addHeapObject(guardian_set), ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} bridge -* @param {number} index -* @returns {Uint8Array} -*/ -export function guardian_set_address(bridge, index) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(bridge, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.guardian_set_address(retptr, ptr0, len0, index); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_guardian_set(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_guardian_set(ptr0, len0); - return takeObject(ret); -} - -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -export function state_address(bridge) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(bridge, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.state_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_state(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_state(ptr0, len0); - return takeObject(ret); -} - -/** -* @param {string} bridge -* @returns {Uint8Array} -*/ -export function fee_collector_address(bridge) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(bridge, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.fee_collector_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {Uint8Array} vaa -* @returns {Uint8Array} -*/ -export function claim_address(program_id, vaa) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.claim_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_posted_message(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_posted_message(ptr0, len0); - return takeObject(ret); -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_vaa(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_vaa(ptr0, len0); - return takeObject(ret); -} - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -export function init() { - wasm.init(); -} - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -export class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -/** -*/ -export class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -/** -*/ -export class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -/** -*/ -export class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} - -export class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} - -export function __wbindgen_json_serialize(arg0, arg1) { - const obj = getObject(arg1); - const ret = JSON.stringify(obj === undefined ? null : obj); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_object_drop_ref(arg0) { - takeObject(arg0); -}; - -export function __wbindgen_json_parse(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -export function __wbg_instruction_new(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_string_new(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -export function __wbg_pubkey_new(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_string_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_is_undefined(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -export function __wbindgen_number_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -export function __wbindgen_number_new(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -export function __wbg_debug_fda1f49ea6af7a1d(arg0) { - console.debug(getObject(arg0)); -}; - -export function __wbg_error_8ff19d586a987aef(arg0) { - console.error(getObject(arg0)); -}; - -export function __wbg_info_c8f1b00be4ef10bc(arg0) { - console.info(getObject(arg0)); -}; - -export function __wbg_log_e8ba7b992c7ad0eb(arg0) { - console.log(getObject(arg0)); -}; - -export function __wbg_warn_0227db1aa6989248(arg0) { - console.warn(getObject(arg0)); -}; - -export function __wbg_new_693216e109162396() { - const ret = new Error(); - return addHeapObject(ret); -}; - -export function __wbg_stack_0ddaca5d1abfb52f(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbg_error_09919627ac0992f5(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -export function __wbg_new_94fb1279cf6afea5() { - const ret = new Array(); - return addHeapObject(ret); -}; - -export function __wbindgen_is_function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -export function __wbindgen_is_object(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -export function __wbg_next_cabb70b365520721(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -export function __wbg_next_bf3d83fc18df496e() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_done_040f966faa9a72b3(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -export function __wbg_value_419afbd9b9574c4c(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -export function __wbg_iterator_4832ef1f15b0382b() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -export function __wbg_get_a9cab131e3152c49() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_call_ae78342adc33730a() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_newwithlength_e80fb11cf19c1628(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -export function __wbg_set_561aac756158708c(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -export function __wbg_isArray_6721f2e508996340(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -export function __wbg_push_40c6a90f1805aa90(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -export function __wbg_values_b1b9e8c63dbe01c2(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -export function __wbg_buffer_7af23f65f6c64548(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -export function __wbg_new_cc9018bd6f283b6f(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -export function __wbg_set_f25e869e4565d2a2(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -export function __wbg_length_0acb1cf9bbaf8519(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -export function __wbg_instanceof_Uint8Array_edb92795fc0c63b4(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -export function __wbindgen_debug_string(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_throw(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -export function __wbindgen_memory() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - diff --git a/sdk/js/src/solana/core/bridge_bg.wasm b/sdk/js/src/solana/core/bridge_bg.wasm deleted file mode 100644 index 6c02930a7..000000000 Binary files a/sdk/js/src/solana/core/bridge_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/core/bridge_bg.wasm.d.ts b/sdk/js/src/solana/core/bridge_bg.wasm.d.ts deleted file mode 100644 index e46f2dcea..000000000 --- a/sdk/js/src/solana/core/bridge_bg.wasm.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function post_message_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number): number; -export function post_vaa_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function update_guardian_set_ix(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function set_fees_ix(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function transfer_fees_ix(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function upgrade_contract_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function verify_signatures_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function guardian_set_address(a: number, b: number, c: number, d: number): void; -export function parse_guardian_set(a: number, b: number): number; -export function state_address(a: number, b: number, c: number): void; -export function parse_state(a: number, b: number): number; -export function fee_collector_address(a: number, b: number, c: number): void; -export function claim_address(a: number, b: number, c: number, d: number, e: number): void; -export function parse_posted_message(a: number, b: number): number; -export function parse_vaa(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function init(): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/core/package.json b/sdk/js/src/solana/core/package.json deleted file mode 100644 index 997383687..000000000 --- a/sdk/js/src/solana/core/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "wormhole-bridge-solana", - "description": "Wormhole bridge core contract", - "version": "0.1.0", - "files": [ - "bridge_bg.wasm", - "bridge.js", - "bridge.d.ts" - ], - "module": "bridge.js", - "types": "bridge.d.ts", - "sideEffects": false -} \ No newline at end of file diff --git a/sdk/js/src/solana/getBridgeFeeIx.ts b/sdk/js/src/solana/getBridgeFeeIx.ts deleted file mode 100644 index 0a2067dc5..000000000 --- a/sdk/js/src/solana/getBridgeFeeIx.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Connection, PublicKey, SystemProgram } from "@solana/web3.js"; -import { importCoreWasm } from "./wasm"; - -export async function getBridgeFeeIx( - connection: Connection, - bridgeAddress: string, - payerAddress: string -) { - const bridge = await importCoreWasm(); - const feeAccount = await bridge.fee_collector_address(bridgeAddress); - const bridgeStatePK = new PublicKey(bridge.state_address(bridgeAddress)); - const bridgeStateAccountInfo = await connection.getAccountInfo(bridgeStatePK); - if (bridgeStateAccountInfo?.data === undefined) { - throw new Error("bridge state not found"); - } - const bridgeState = bridge.parse_state( - new Uint8Array(bridgeStateAccountInfo?.data) - ); - const transferIx = SystemProgram.transfer({ - fromPubkey: new PublicKey(payerAddress), - toPubkey: new PublicKey(feeAccount), - lamports: bridgeState.config.fee, - }); - return transferIx; -} diff --git a/sdk/js/src/solana/index.ts b/sdk/js/src/solana/index.ts deleted file mode 100644 index 9fd69ee14..000000000 --- a/sdk/js/src/solana/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from "./getBridgeFeeIx"; -export { - createPostVaaInstruction as createPostVaaInstructionSolana, - createVerifySignaturesInstructions as createVerifySignaturesInstructionsSolana, - postVaa as postVaaSolana, - postVaaWithRetry as postVaaSolanaWithRetry, -} from "./postVaa"; -export * from "./rust"; -export * from "./wasm"; diff --git a/sdk/js/src/solana/migration-node/package.json b/sdk/js/src/solana/migration-node/package.json deleted file mode 100644 index ed2cb9650..000000000 --- a/sdk/js/src/solana/migration-node/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "wormhole-migration", - "description": "Created with Rocksalt", - "version": "0.1.0", - "files": [ - "wormhole_migration_bg.wasm", - "wormhole_migration.js", - "wormhole_migration_bg.js", - "wormhole_migration.d.ts" - ], - "main": "wormhole_migration.js", - "types": "wormhole_migration.d.ts" -} \ No newline at end of file diff --git a/sdk/js/src/solana/migration-node/wormhole_migration.d.ts b/sdk/js/src/solana/migration-node/wormhole_migration.d.ts deleted file mode 100644 index 108fdbc40..000000000 --- a/sdk/js/src/solana/migration-node/wormhole_migration.d.ts +++ /dev/null @@ -1,358 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function add_liquidity(program_id: string, from_mint: string, to_mint: string, liquidity_token_account: string, lp_share_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function remove_liquidity(program_id: string, from_mint: string, to_mint: string, liquidity_token_account: string, lp_share_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} output_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function claim_shares(program_id: string, from_mint: string, to_mint: string, output_token_account: string, lp_share_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {string} from_mint -* @param {string} to_mint -* @returns {any} -*/ -export function create_pool(program_id: string, payer: string, from_mint: string, to_mint: string): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} input_token_account -* @param {string} output_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function migrate_tokens(program_id: string, from_mint: string, to_mint: string, input_token_account: string, output_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @returns {Uint8Array} -*/ -export function pool_address(program_id: string, from_mint: string, to_mint: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function authority_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function share_mint_address(program_id: string, pool: string): Uint8Array; -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function from_custody_address(program_id: string, pool: string): Uint8Array; -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function to_custody_address(program_id: string, pool: string): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_pool(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/migration-node/wormhole_migration.js b/sdk/js/src/solana/migration-node/wormhole_migration.js deleted file mode 100644 index a44416c02..000000000 --- a/sdk/js/src/solana/migration-node/wormhole_migration.js +++ /dev/null @@ -1,1345 +0,0 @@ -let imports = {}; -imports['__wbindgen_placeholder__'] = module.exports; -let wasm; -const { TextDecoder, TextEncoder } = require(`util`); - -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -let heap_next = heap.length; - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { return heap[idx]; } - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let WASM_VECTOR_LEN = 0; - -let cachedTextEncoder = new TextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -module.exports.add_liquidity = function(program_id, from_mint, to_mint, liquidity_token_account, lp_share_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(liquidity_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(lp_share_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.add_liquidity(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -module.exports.remove_liquidity = function(program_id, from_mint, to_mint, liquidity_token_account, lp_share_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(liquidity_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(lp_share_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.remove_liquidity(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} output_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -module.exports.claim_shares = function(program_id, from_mint, to_mint, output_token_account, lp_share_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(output_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(lp_share_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.claim_shares(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} payer -* @param {string} from_mint -* @param {string} to_mint -* @returns {any} -*/ -module.exports.create_pool = function(program_id, payer, from_mint, to_mint) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.create_pool(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} input_token_account -* @param {string} output_token_account -* @param {BigInt} amount -* @returns {any} -*/ -module.exports.migrate_tokens = function(program_id, from_mint, to_mint, input_token_account, output_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(input_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(output_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.migrate_tokens(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -}; - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @returns {Uint8Array} -*/ -module.exports.pool_address = function(program_id, from_mint, to_mint) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - wasm.pool_address(retptr, ptr0, len0, ptr1, len1, ptr2, len2); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v3 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v3; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -module.exports.authority_address = function(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.authority_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -module.exports.share_mint_address = function(program_id, pool) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(pool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.share_mint_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -module.exports.from_custody_address = function(program_id, pool) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(pool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.from_custody_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -module.exports.to_custody_address = function(program_id, pool) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(pool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.to_custody_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_pool = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_pool(ptr0, len0); - return takeObject(ret); -}; - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -module.exports.init = function() { - wasm.init(); -}; - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Hash = Hash; -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -module.exports.Instruction = Instruction; -/** -*/ -class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -module.exports.Instructions = Instructions; -/** -*/ -class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -module.exports.Message = Message; -/** -*/ -class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Pubkey = Pubkey; - -class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_systeminstruction_free(ptr); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} -module.exports.SystemInstruction = SystemInstruction; - -module.exports.__wbindgen_json_parse = function(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_instruction_new = function(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); -}; - -module.exports.__wbg_pubkey_new = function(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_string_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_is_undefined = function(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -module.exports.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_number_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -module.exports.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -module.exports.__wbg_debug_fda1f49ea6af7a1d = function(arg0) { - console.debug(getObject(arg0)); -}; - -module.exports.__wbg_error_8ff19d586a987aef = function(arg0) { - console.error(getObject(arg0)); -}; - -module.exports.__wbg_info_c8f1b00be4ef10bc = function(arg0) { - console.info(getObject(arg0)); -}; - -module.exports.__wbg_log_e8ba7b992c7ad0eb = function(arg0) { - console.log(getObject(arg0)); -}; - -module.exports.__wbg_warn_0227db1aa6989248 = function(arg0) { - console.warn(getObject(arg0)); -}; - -module.exports.__wbg_new_693216e109162396 = function() { - const ret = new Error(); - return addHeapObject(ret); -}; - -module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -module.exports.__wbg_new_94fb1279cf6afea5 = function() { - const ret = new Array(); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_is_function = function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -module.exports.__wbindgen_is_object = function(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -module.exports.__wbg_next_cabb70b365520721 = function(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -module.exports.__wbg_next_bf3d83fc18df496e = function() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_done_040f966faa9a72b3 = function(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -module.exports.__wbg_value_419afbd9b9574c4c = function(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -module.exports.__wbg_iterator_4832ef1f15b0382b = function() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -module.exports.__wbg_get_a9cab131e3152c49 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_call_ae78342adc33730a = function() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_newwithlength_e80fb11cf19c1628 = function(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_561aac756158708c = function(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -module.exports.__wbg_isArray_6721f2e508996340 = function(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -module.exports.__wbg_push_40c6a90f1805aa90 = function(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -module.exports.__wbg_values_b1b9e8c63dbe01c2 = function(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -module.exports.__wbg_buffer_7af23f65f6c64548 = function(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -module.exports.__wbg_new_cc9018bd6f283b6f = function(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -module.exports.__wbg_length_0acb1cf9bbaf8519 = function(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -module.exports.__wbg_instanceof_Uint8Array_edb92795fc0c63b4 = function(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -module.exports.__wbindgen_debug_string = function(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_throw = function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -module.exports.__wbindgen_memory = function() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - -const path = require('path').join(__dirname, 'wormhole_migration_bg.wasm'); -const bytes = require('fs').readFileSync(path); - -const wasmModule = new WebAssembly.Module(bytes); -const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -wasm = wasmInstance.exports; -module.exports.__wasm = wasm; - diff --git a/sdk/js/src/solana/migration-node/wormhole_migration_bg.wasm b/sdk/js/src/solana/migration-node/wormhole_migration_bg.wasm deleted file mode 100644 index 7212ef7dd..000000000 Binary files a/sdk/js/src/solana/migration-node/wormhole_migration_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/migration-node/wormhole_migration_bg.wasm.d.ts b/sdk/js/src/solana/migration-node/wormhole_migration_bg.wasm.d.ts deleted file mode 100644 index d3e976714..000000000 --- a/sdk/js/src/solana/migration-node/wormhole_migration_bg.wasm.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function add_liquidity(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function remove_liquidity(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function claim_shares(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function create_pool(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function migrate_tokens(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function pool_address(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; -export function authority_address(a: number, b: number, c: number): void; -export function share_mint_address(a: number, b: number, c: number, d: number, e: number): void; -export function from_custody_address(a: number, b: number, c: number, d: number, e: number): void; -export function to_custody_address(a: number, b: number, c: number, d: number, e: number): void; -export function parse_pool(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function init(): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/migration/package.json b/sdk/js/src/solana/migration/package.json deleted file mode 100644 index 988cd938e..000000000 --- a/sdk/js/src/solana/migration/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "wormhole-migration", - "description": "Created with Rocksalt", - "version": "0.1.0", - "files": [ - "wormhole_migration_bg.wasm", - "wormhole_migration.js", - "wormhole_migration.d.ts" - ], - "module": "wormhole_migration.js", - "types": "wormhole_migration.d.ts", - "sideEffects": false -} \ No newline at end of file diff --git a/sdk/js/src/solana/migration/wormhole_migration.d.ts b/sdk/js/src/solana/migration/wormhole_migration.d.ts deleted file mode 100644 index 108fdbc40..000000000 --- a/sdk/js/src/solana/migration/wormhole_migration.d.ts +++ /dev/null @@ -1,358 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function add_liquidity(program_id: string, from_mint: string, to_mint: string, liquidity_token_account: string, lp_share_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function remove_liquidity(program_id: string, from_mint: string, to_mint: string, liquidity_token_account: string, lp_share_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} output_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function claim_shares(program_id: string, from_mint: string, to_mint: string, output_token_account: string, lp_share_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} payer -* @param {string} from_mint -* @param {string} to_mint -* @returns {any} -*/ -export function create_pool(program_id: string, payer: string, from_mint: string, to_mint: string): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} input_token_account -* @param {string} output_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function migrate_tokens(program_id: string, from_mint: string, to_mint: string, input_token_account: string, output_token_account: string, amount: BigInt): any; -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @returns {Uint8Array} -*/ -export function pool_address(program_id: string, from_mint: string, to_mint: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function authority_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function share_mint_address(program_id: string, pool: string): Uint8Array; -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function from_custody_address(program_id: string, pool: string): Uint8Array; -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function to_custody_address(program_id: string, pool: string): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_pool(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/migration/wormhole_migration.js b/sdk/js/src/solana/migration/wormhole_migration.js deleted file mode 100644 index 909f7fa0c..000000000 --- a/sdk/js/src/solana/migration/wormhole_migration.js +++ /dev/null @@ -1,2 +0,0 @@ -import * as wasm from "./wormhole_migration_bg.wasm"; -export * from "./wormhole_migration_bg.js"; \ No newline at end of file diff --git a/sdk/js/src/solana/migration/wormhole_migration_bg.js b/sdk/js/src/solana/migration/wormhole_migration_bg.js deleted file mode 100644 index f5a46c4b6..000000000 --- a/sdk/js/src/solana/migration/wormhole_migration_bg.js +++ /dev/null @@ -1,1331 +0,0 @@ -import * as wasm from './wormhole_migration_bg.wasm'; - -const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; - -let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -let heap_next = heap.length; - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { return heap[idx]; } - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let WASM_VECTOR_LEN = 0; - -const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; - -let cachedTextEncoder = new lTextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function add_liquidity(program_id, from_mint, to_mint, liquidity_token_account, lp_share_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(liquidity_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(lp_share_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.add_liquidity(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} liquidity_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function remove_liquidity(program_id, from_mint, to_mint, liquidity_token_account, lp_share_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(liquidity_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(lp_share_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.remove_liquidity(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} output_token_account -* @param {string} lp_share_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function claim_shares(program_id, from_mint, to_mint, output_token_account, lp_share_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(output_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(lp_share_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.claim_shares(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} payer -* @param {string} from_mint -* @param {string} to_mint -* @returns {any} -*/ -export function create_pool(program_id, payer, from_mint, to_mint) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.create_pool(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @param {string} input_token_account -* @param {string} output_token_account -* @param {BigInt} amount -* @returns {any} -*/ -export function migrate_tokens(program_id, from_mint, to_mint, input_token_account, output_token_account, amount) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(input_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(output_token_account, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low5 = u32CvtShim[0]; - const high5 = u32CvtShim[1]; - const ret = wasm.migrate_tokens(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, low5, high5); - return takeObject(ret); -} - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} program_id -* @param {string} from_mint -* @param {string} to_mint -* @returns {Uint8Array} -*/ -export function pool_address(program_id, from_mint, to_mint) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(from_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(to_mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - wasm.pool_address(retptr, ptr0, len0, ptr1, len1, ptr2, len2); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v3 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v3; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function authority_address(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.authority_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function share_mint_address(program_id, pool) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(pool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.share_mint_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function from_custody_address(program_id, pool) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(pool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.from_custody_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {string} pool -* @returns {Uint8Array} -*/ -export function to_custody_address(program_id, pool) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(pool, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.to_custody_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_pool(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_pool(ptr0, len0); - return takeObject(ret); -} - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -export function init() { - wasm.init(); -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -export class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -/** -*/ -export class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -/** -*/ -export class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -/** -*/ -export class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} - -export class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} - -export function __wbindgen_json_parse(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -export function __wbg_instruction_new(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_object_drop_ref(arg0) { - takeObject(arg0); -}; - -export function __wbg_pubkey_new(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_string_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_is_undefined(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -export function __wbindgen_string_new(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -export function __wbindgen_number_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -export function __wbindgen_number_new(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -export function __wbg_debug_fda1f49ea6af7a1d(arg0) { - console.debug(getObject(arg0)); -}; - -export function __wbg_error_8ff19d586a987aef(arg0) { - console.error(getObject(arg0)); -}; - -export function __wbg_info_c8f1b00be4ef10bc(arg0) { - console.info(getObject(arg0)); -}; - -export function __wbg_log_e8ba7b992c7ad0eb(arg0) { - console.log(getObject(arg0)); -}; - -export function __wbg_warn_0227db1aa6989248(arg0) { - console.warn(getObject(arg0)); -}; - -export function __wbg_new_693216e109162396() { - const ret = new Error(); - return addHeapObject(ret); -}; - -export function __wbg_stack_0ddaca5d1abfb52f(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbg_error_09919627ac0992f5(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -export function __wbg_new_94fb1279cf6afea5() { - const ret = new Array(); - return addHeapObject(ret); -}; - -export function __wbindgen_is_function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -export function __wbindgen_is_object(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -export function __wbg_next_cabb70b365520721(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -export function __wbg_next_bf3d83fc18df496e() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_done_040f966faa9a72b3(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -export function __wbg_value_419afbd9b9574c4c(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -export function __wbg_iterator_4832ef1f15b0382b() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -export function __wbg_get_a9cab131e3152c49() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_call_ae78342adc33730a() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_newwithlength_e80fb11cf19c1628(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -export function __wbg_set_561aac756158708c(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -export function __wbg_isArray_6721f2e508996340(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -export function __wbg_push_40c6a90f1805aa90(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -export function __wbg_values_b1b9e8c63dbe01c2(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -export function __wbg_buffer_7af23f65f6c64548(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -export function __wbg_new_cc9018bd6f283b6f(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -export function __wbg_set_f25e869e4565d2a2(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -export function __wbg_length_0acb1cf9bbaf8519(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -export function __wbg_instanceof_Uint8Array_edb92795fc0c63b4(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -export function __wbindgen_debug_string(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_throw(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -export function __wbindgen_memory() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - diff --git a/sdk/js/src/solana/migration/wormhole_migration_bg.wasm b/sdk/js/src/solana/migration/wormhole_migration_bg.wasm deleted file mode 100644 index ed2c1e5bb..000000000 Binary files a/sdk/js/src/solana/migration/wormhole_migration_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/migration/wormhole_migration_bg.wasm.d.ts b/sdk/js/src/solana/migration/wormhole_migration_bg.wasm.d.ts deleted file mode 100644 index d3e976714..000000000 --- a/sdk/js/src/solana/migration/wormhole_migration_bg.wasm.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function add_liquidity(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function remove_liquidity(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function claim_shares(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function create_pool(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function migrate_tokens(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number): number; -export function pool_address(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; -export function authority_address(a: number, b: number, c: number): void; -export function share_mint_address(a: number, b: number, c: number, d: number, e: number): void; -export function from_custody_address(a: number, b: number, c: number, d: number, e: number): void; -export function to_custody_address(a: number, b: number, c: number, d: number, e: number): void; -export function parse_pool(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function init(): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/nft-node/nft_bridge.d.ts b/sdk/js/src/solana/nft-node/nft_bridge.d.ts deleted file mode 100644 index da9342cb4..000000000 --- a/sdk/js/src/solana/nft-node/nft_bridge.d.ts +++ /dev/null @@ -1,386 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_native_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, mint: string, nonce: number, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {Uint8Array} token_id -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, from_owner: string, token_chain: number, token_address: Uint8Array, token_id: Uint8Array, nonce: number, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_native_ix(program_id: string, bridge_id: string, payer: string, to_authority: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, to_authority: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_wrapped_meta_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id: string, bridge_id: string, payer: string, spill: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function register_chain_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function emitter_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function approval_authority_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @param {Uint8Array} token_id -* @returns {Uint8Array} -*/ -export function wrapped_address(program_id: string, token_address: Uint8Array, token_chain: number, token_id: Uint8Array): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function wrapped_meta_address(program_id: string, mint_address: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function spl_meta_address(mint_address: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_wrapped_meta(data: Uint8Array): any; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_endpoint_registration(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/nft-node/nft_bridge.js b/sdk/js/src/solana/nft-node/nft_bridge.js deleted file mode 100644 index 9897df8c9..000000000 --- a/sdk/js/src/solana/nft-node/nft_bridge.js +++ /dev/null @@ -1,1402 +0,0 @@ -let imports = {}; -imports['__wbindgen_placeholder__'] = module.exports; -let wasm; -const { TextDecoder, TextEncoder } = require(`util`); - -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -let heap_next = heap.length; - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { return heap[idx]; } - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let WASM_VECTOR_LEN = 0; - -let cachedTextEncoder = new TextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -module.exports.transfer_native_ix = function(program_id, bridge_id, payer, message, from, mint, nonce, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - const ret = wasm.transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, nonce, ptr6, len6, target_chain); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {Uint8Array} token_id -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -module.exports.transfer_wrapped_ix = function(program_id, bridge_id, payer, message, from, from_owner, token_chain, token_address, token_id, nonce, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(from_owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - const ptr7 = passArray8ToWasm0(token_id, wasm.__wbindgen_malloc); - const len7 = WASM_VECTOR_LEN; - const ptr8 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len8 = WASM_VECTOR_LEN; - const ret = wasm.transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, token_chain, ptr6, len6, ptr7, len7, nonce, ptr8, len8, target_chain); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.complete_transfer_native_ix = function(program_id, bridge_id, payer, to_authority, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(to_authority, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.complete_transfer_wrapped_ix = function(program_id, bridge_id, payer, to_authority, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(to_authority, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.complete_transfer_wrapped_meta_ix = function(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_wrapped_meta_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.upgrade_contract_ix = function(program_id, bridge_id, payer, spill, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(spill, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.upgrade_contract_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.register_chain_ix = function(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.register_chain_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -module.exports.emitter_address = function(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.emitter_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -module.exports.approval_authority_address = function(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.approval_authority_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @param {Uint8Array} token_id -* @returns {Uint8Array} -*/ -module.exports.wrapped_address = function(program_id, token_address, token_chain, token_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(token_id, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - wasm.wrapped_address(retptr, ptr0, len0, ptr1, len1, token_chain, ptr2, len2); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v3 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v3; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -module.exports.wrapped_meta_address = function(program_id, mint_address) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(mint_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.wrapped_meta_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -module.exports.spl_meta_address = function(mint_address) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(mint_address, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.spl_meta_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_wrapped_meta = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_wrapped_meta(ptr0, len0); - return takeObject(ret); -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_endpoint_registration = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_endpoint_registration(ptr0, len0); - return takeObject(ret); -}; - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -module.exports.init = function() { - wasm.init(); -}; - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Hash = Hash; -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -module.exports.Instruction = Instruction; -/** -*/ -class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -module.exports.Instructions = Instructions; -/** -*/ -class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -module.exports.Message = Message; -/** -*/ -class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Pubkey = Pubkey; - -class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_systeminstruction_free(ptr); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} -module.exports.SystemInstruction = SystemInstruction; - -module.exports.__wbindgen_json_parse = function(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_instruction_new = function(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); -}; - -module.exports.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -module.exports.__wbg_pubkey_new = function(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_string_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_is_undefined = function(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -module.exports.__wbindgen_number_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -module.exports.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -module.exports.__wbg_debug_fda1f49ea6af7a1d = function(arg0) { - console.debug(getObject(arg0)); -}; - -module.exports.__wbg_error_8ff19d586a987aef = function(arg0) { - console.error(getObject(arg0)); -}; - -module.exports.__wbg_info_c8f1b00be4ef10bc = function(arg0) { - console.info(getObject(arg0)); -}; - -module.exports.__wbg_log_e8ba7b992c7ad0eb = function(arg0) { - console.log(getObject(arg0)); -}; - -module.exports.__wbg_warn_0227db1aa6989248 = function(arg0) { - console.warn(getObject(arg0)); -}; - -module.exports.__wbg_new_693216e109162396 = function() { - const ret = new Error(); - return addHeapObject(ret); -}; - -module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -module.exports.__wbg_new_94fb1279cf6afea5 = function() { - const ret = new Array(); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_is_function = function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -module.exports.__wbindgen_is_object = function(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -module.exports.__wbg_next_cabb70b365520721 = function(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -module.exports.__wbg_next_bf3d83fc18df496e = function() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_done_040f966faa9a72b3 = function(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -module.exports.__wbg_value_419afbd9b9574c4c = function(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -module.exports.__wbg_iterator_4832ef1f15b0382b = function() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -module.exports.__wbg_get_a9cab131e3152c49 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_call_ae78342adc33730a = function() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_newwithlength_e80fb11cf19c1628 = function(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_561aac756158708c = function(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -module.exports.__wbg_isArray_6721f2e508996340 = function(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -module.exports.__wbg_push_40c6a90f1805aa90 = function(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -module.exports.__wbg_values_b1b9e8c63dbe01c2 = function(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -module.exports.__wbg_buffer_7af23f65f6c64548 = function(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -module.exports.__wbg_new_cc9018bd6f283b6f = function(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -module.exports.__wbg_length_0acb1cf9bbaf8519 = function(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -module.exports.__wbg_instanceof_Uint8Array_edb92795fc0c63b4 = function(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -module.exports.__wbindgen_debug_string = function(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_throw = function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -module.exports.__wbindgen_memory = function() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - -const path = require('path').join(__dirname, 'nft_bridge_bg.wasm'); -const bytes = require('fs').readFileSync(path); - -const wasmModule = new WebAssembly.Module(bytes); -const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -wasm = wasmInstance.exports; -module.exports.__wasm = wasm; - diff --git a/sdk/js/src/solana/nft-node/nft_bridge_bg.wasm b/sdk/js/src/solana/nft-node/nft_bridge_bg.wasm deleted file mode 100644 index b911fa18d..000000000 Binary files a/sdk/js/src/solana/nft-node/nft_bridge_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/nft-node/nft_bridge_bg.wasm.d.ts b/sdk/js/src/solana/nft-node/nft_bridge_bg.wasm.d.ts deleted file mode 100644 index 80c2bc8f9..000000000 --- a/sdk/js/src/solana/nft-node/nft_bridge_bg.wasm.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number): number; -export function transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number): number; -export function complete_transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function complete_transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function complete_transfer_wrapped_meta_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function upgrade_contract_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function register_chain_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function emitter_address(a: number, b: number, c: number): void; -export function approval_authority_address(a: number, b: number, c: number): void; -export function wrapped_address(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; -export function wrapped_meta_address(a: number, b: number, c: number, d: number, e: number): void; -export function spl_meta_address(a: number, b: number, c: number): void; -export function parse_wrapped_meta(a: number, b: number): number; -export function parse_endpoint_registration(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function init(): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/nft-node/package.json b/sdk/js/src/solana/nft-node/package.json deleted file mode 100644 index 1e275fa75..000000000 --- a/sdk/js/src/solana/nft-node/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "nft-bridge", - "description": "Created with Rocksalt", - "version": "0.1.0", - "files": [ - "nft_bridge_bg.wasm", - "nft_bridge.js", - "nft_bridge_bg.js", - "nft_bridge.d.ts" - ], - "main": "nft_bridge.js", - "types": "nft_bridge.d.ts" -} \ No newline at end of file diff --git a/sdk/js/src/solana/nft/nft_bridge.d.ts b/sdk/js/src/solana/nft/nft_bridge.d.ts deleted file mode 100644 index da9342cb4..000000000 --- a/sdk/js/src/solana/nft/nft_bridge.d.ts +++ /dev/null @@ -1,386 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_native_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, mint: string, nonce: number, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {Uint8Array} token_id -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, from_owner: string, token_chain: number, token_address: Uint8Array, token_id: Uint8Array, nonce: number, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_native_ix(program_id: string, bridge_id: string, payer: string, to_authority: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, to_authority: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_wrapped_meta_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id: string, bridge_id: string, payer: string, spill: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function register_chain_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function emitter_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function approval_authority_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @param {Uint8Array} token_id -* @returns {Uint8Array} -*/ -export function wrapped_address(program_id: string, token_address: Uint8Array, token_chain: number, token_id: Uint8Array): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function wrapped_meta_address(program_id: string, mint_address: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function spl_meta_address(mint_address: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_wrapped_meta(data: Uint8Array): any; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_endpoint_registration(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/nft/nft_bridge.js b/sdk/js/src/solana/nft/nft_bridge.js deleted file mode 100644 index 500b4a7b9..000000000 --- a/sdk/js/src/solana/nft/nft_bridge.js +++ /dev/null @@ -1,2 +0,0 @@ -import * as wasm from "./nft_bridge_bg.wasm"; -export * from "./nft_bridge_bg.js"; \ No newline at end of file diff --git a/sdk/js/src/solana/nft/nft_bridge_bg.js b/sdk/js/src/solana/nft/nft_bridge_bg.js deleted file mode 100644 index 861acb6c3..000000000 --- a/sdk/js/src/solana/nft/nft_bridge_bg.js +++ /dev/null @@ -1,1388 +0,0 @@ -import * as wasm from './nft_bridge_bg.wasm'; - -const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; - -let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -let heap_next = heap.length; - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { return heap[idx]; } - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let WASM_VECTOR_LEN = 0; - -const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; - -let cachedTextEncoder = new lTextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_native_ix(program_id, bridge_id, payer, message, from, mint, nonce, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - const ret = wasm.transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, nonce, ptr6, len6, target_chain); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {Uint8Array} token_id -* @param {number} nonce -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_wrapped_ix(program_id, bridge_id, payer, message, from, from_owner, token_chain, token_address, token_id, nonce, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(from_owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - const ptr7 = passArray8ToWasm0(token_id, wasm.__wbindgen_malloc); - const len7 = WASM_VECTOR_LEN; - const ptr8 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len8 = WASM_VECTOR_LEN; - const ret = wasm.transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, token_chain, ptr6, len6, ptr7, len7, nonce, ptr8, len8, target_chain); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_native_ix(program_id, bridge_id, payer, to_authority, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(to_authority, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} to_authority -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_wrapped_ix(program_id, bridge_id, payer, to_authority, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(to_authority, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function complete_transfer_wrapped_meta_ix(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_wrapped_meta_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id, bridge_id, payer, spill, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(spill, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.upgrade_contract_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function register_chain_ix(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.register_chain_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function emitter_address(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.emitter_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function approval_authority_address(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.approval_authority_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @param {Uint8Array} token_id -* @returns {Uint8Array} -*/ -export function wrapped_address(program_id, token_address, token_chain, token_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passArray8ToWasm0(token_id, wasm.__wbindgen_malloc); - const len2 = WASM_VECTOR_LEN; - wasm.wrapped_address(retptr, ptr0, len0, ptr1, len1, token_chain, ptr2, len2); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v3 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v3; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function wrapped_meta_address(program_id, mint_address) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(mint_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.wrapped_meta_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function spl_meta_address(mint_address) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(mint_address, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.spl_meta_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_wrapped_meta(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_wrapped_meta(ptr0, len0); - return takeObject(ret); -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_endpoint_registration(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_endpoint_registration(ptr0, len0); - return takeObject(ret); -} - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -export function init() { - wasm.init(); -} - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -export class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -/** -*/ -export class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -/** -*/ -export class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -/** -*/ -export class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} - -export class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} - -export function __wbindgen_json_parse(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -export function __wbg_instruction_new(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_object_drop_ref(arg0) { - takeObject(arg0); -}; - -export function __wbindgen_string_new(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -export function __wbg_pubkey_new(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_string_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_is_undefined(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -export function __wbindgen_number_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -export function __wbindgen_number_new(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -export function __wbg_debug_fda1f49ea6af7a1d(arg0) { - console.debug(getObject(arg0)); -}; - -export function __wbg_error_8ff19d586a987aef(arg0) { - console.error(getObject(arg0)); -}; - -export function __wbg_info_c8f1b00be4ef10bc(arg0) { - console.info(getObject(arg0)); -}; - -export function __wbg_log_e8ba7b992c7ad0eb(arg0) { - console.log(getObject(arg0)); -}; - -export function __wbg_warn_0227db1aa6989248(arg0) { - console.warn(getObject(arg0)); -}; - -export function __wbg_new_693216e109162396() { - const ret = new Error(); - return addHeapObject(ret); -}; - -export function __wbg_stack_0ddaca5d1abfb52f(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbg_error_09919627ac0992f5(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -export function __wbg_new_94fb1279cf6afea5() { - const ret = new Array(); - return addHeapObject(ret); -}; - -export function __wbindgen_is_function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -export function __wbindgen_is_object(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -export function __wbg_next_cabb70b365520721(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -export function __wbg_next_bf3d83fc18df496e() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_done_040f966faa9a72b3(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -export function __wbg_value_419afbd9b9574c4c(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -export function __wbg_iterator_4832ef1f15b0382b() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -export function __wbg_get_a9cab131e3152c49() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_call_ae78342adc33730a() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_newwithlength_e80fb11cf19c1628(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -export function __wbg_set_561aac756158708c(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -export function __wbg_isArray_6721f2e508996340(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -export function __wbg_push_40c6a90f1805aa90(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -export function __wbg_values_b1b9e8c63dbe01c2(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -export function __wbg_buffer_7af23f65f6c64548(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -export function __wbg_new_cc9018bd6f283b6f(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -export function __wbg_set_f25e869e4565d2a2(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -export function __wbg_length_0acb1cf9bbaf8519(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -export function __wbg_instanceof_Uint8Array_edb92795fc0c63b4(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -export function __wbindgen_debug_string(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_throw(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -export function __wbindgen_memory() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - diff --git a/sdk/js/src/solana/nft/nft_bridge_bg.wasm b/sdk/js/src/solana/nft/nft_bridge_bg.wasm deleted file mode 100644 index cccf4fe4f..000000000 Binary files a/sdk/js/src/solana/nft/nft_bridge_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/nft/nft_bridge_bg.wasm.d.ts b/sdk/js/src/solana/nft/nft_bridge_bg.wasm.d.ts deleted file mode 100644 index 80c2bc8f9..000000000 --- a/sdk/js/src/solana/nft/nft_bridge_bg.wasm.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number): number; -export function transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number): number; -export function complete_transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function complete_transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function complete_transfer_wrapped_meta_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function upgrade_contract_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function register_chain_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function emitter_address(a: number, b: number, c: number): void; -export function approval_authority_address(a: number, b: number, c: number): void; -export function wrapped_address(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; -export function wrapped_meta_address(a: number, b: number, c: number, d: number, e: number): void; -export function spl_meta_address(a: number, b: number, c: number): void; -export function parse_wrapped_meta(a: number, b: number): number; -export function parse_endpoint_registration(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function init(): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/nft/package.json b/sdk/js/src/solana/nft/package.json deleted file mode 100644 index 91c01a527..000000000 --- a/sdk/js/src/solana/nft/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "nft-bridge", - "description": "Created with Rocksalt", - "version": "0.1.0", - "files": [ - "nft_bridge_bg.wasm", - "nft_bridge.js", - "nft_bridge.d.ts" - ], - "module": "nft_bridge.js", - "types": "nft_bridge.d.ts", - "sideEffects": false -} \ No newline at end of file diff --git a/sdk/js/src/solana/postVaa.ts b/sdk/js/src/solana/postVaa.ts deleted file mode 100644 index 5a7b03088..000000000 --- a/sdk/js/src/solana/postVaa.ts +++ /dev/null @@ -1,212 +0,0 @@ -import { - Connection, - Keypair, - PublicKey, - Transaction, - TransactionInstruction, -} from "@solana/web3.js"; -import { chunks } from ".."; -import { sendAndConfirmTransactionsWithRetry } from "../utils/solana"; -import { ixFromRust } from "./rust"; -import { importCoreWasm } from "./wasm"; - -export async function postVaaWithRetry( - connection: Connection, - signTransaction: (transaction: Transaction) => Promise, - bridge_id: string, - payer: string, - vaa: Buffer, - maxRetries: number -) { - const unsignedTransactions: Transaction[] = []; - const signature_set = Keypair.generate(); - const instructions = await createVerifySignaturesInstructions( - connection, - bridge_id, - payer, - vaa, - signature_set - ); - const finalInstruction = await createPostVaaInstruction( - bridge_id, - payer, - vaa, - signature_set - ); - if (!finalInstruction) { - return Promise.reject("Failed to construct the transaction."); - } - - //The verify signatures instructions can be batched into groups of 2 safely, - //reducing the total number of transactions. - const batchableChunks = chunks(instructions, 2); - batchableChunks.forEach((chunk) => { - let transaction; - if (chunk.length === 1) { - transaction = new Transaction().add(chunk[0]); - } else { - transaction = new Transaction().add(chunk[0], chunk[1]); - } - unsignedTransactions.push(transaction); - }); - - //the postVaa instruction can only execute after the verifySignature transactions have - //successfully completed. - const finalTransaction = new Transaction().add(finalInstruction); - - //The signature_set keypair also needs to sign the verifySignature transactions, thus a wrapper is needed. - const partialSignWrapper = (transaction: Transaction) => { - transaction.partialSign(signature_set); - return signTransaction(transaction); - }; - - await sendAndConfirmTransactionsWithRetry( - connection, - partialSignWrapper, - payer, - unsignedTransactions, - maxRetries - ); - //While the signature_set is used to create the final instruction, it doesn't need to sign it. - await sendAndConfirmTransactionsWithRetry( - connection, - signTransaction, - payer, - [finalTransaction], - maxRetries - ); - - return Promise.resolve(); -} - -/* -This returns an array of instructions required to verify the signatures of a VAA, and upload it to the blockchain. -signature_set should be a new keypair, and also needs to partial sign the transaction when these instructions are submitted. -*/ -export async function createVerifySignaturesInstructions( - connection: Connection, - bridge_id: string, - payer: string, - vaa: Buffer, - signature_set: Keypair -): Promise { - const output: TransactionInstruction[] = []; - const { - guardian_set_address, - parse_guardian_set, - parse_vaa, - verify_signatures_ix, - } = await importCoreWasm(); - const { guardian_set_index } = parse_vaa(new Uint8Array(vaa)); - let guardian_addr = new PublicKey( - guardian_set_address(bridge_id, guardian_set_index) - ); - let acc = await connection.getAccountInfo(guardian_addr); - if (acc?.data === undefined) { - return output; - } - let guardian_data = parse_guardian_set(new Uint8Array(acc?.data)); - - let txs = verify_signatures_ix( - bridge_id, - payer, - guardian_set_index, - guardian_data, - signature_set.publicKey.toString(), - vaa - ); - // Add transfer instruction to transaction - for (let tx of txs) { - let ixs: Array = tx.map((v: any) => { - return ixFromRust(v); - }); - output.push(ixs[0], ixs[1]); - } - return output; -} - -/* -This will return the postVaaInstruction. This should only be executed after the verifySignaturesInstructions have been executed. -signatureSetKeypair should be the same keypair used for verifySignaturesInstructions, but does not need to partialSign the transaction -when this instruction is submitted. -*/ -export async function createPostVaaInstruction( - bridge_id: string, - payer: string, - vaa: Buffer, - signatureSetKeypair: Keypair -): Promise { - const { post_vaa_ix } = await importCoreWasm(); - return ixFromRust( - post_vaa_ix(bridge_id, payer, signatureSetKeypair.publicKey.toString(), vaa) - ); -} - -/* - @deprecated - Instead, either use postVaaWithRetry or create, sign, and send the verifySignaturesInstructions & postVaaInstruction yourself. - - This function is equivalent to a postVaaWithRetry with a maxRetries of 0. -*/ -export async function postVaa( - connection: Connection, - signTransaction: (transaction: Transaction) => Promise, - bridge_id: string, - payer: string, - vaa: Buffer -) { - const { - guardian_set_address, - parse_guardian_set, - parse_vaa, - post_vaa_ix, - verify_signatures_ix, - } = await importCoreWasm(); - const { guardian_set_index } = parse_vaa(new Uint8Array(vaa)); - let guardian_addr = new PublicKey( - guardian_set_address(bridge_id, guardian_set_index) - ); - let acc = await connection.getAccountInfo(guardian_addr); - if (acc?.data === undefined) { - return; - } - let guardian_data = parse_guardian_set(new Uint8Array(acc?.data)); - - let signature_set = Keypair.generate(); - let txs = verify_signatures_ix( - bridge_id, - payer, - guardian_set_index, - guardian_data, - signature_set.publicKey.toString(), - vaa - ); - // Add transfer instruction to transaction - for (let tx of txs) { - let ixs: Array = tx.map((v: any) => { - return ixFromRust(v); - }); - let transaction = new Transaction().add(...ixs); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payer); - transaction.partialSign(signature_set); - - // Sign transaction, broadcast, and confirm - const signed = await signTransaction(transaction); - const txid = await connection.sendRawTransaction(signed.serialize()); - await connection.confirmTransaction(txid); - } - - let ix = ixFromRust( - post_vaa_ix(bridge_id, payer, signature_set.publicKey.toString(), vaa) - ); - let transaction = new Transaction().add(ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payer); - - const signed = await signTransaction(transaction); - const txid = await connection.sendRawTransaction(signed.serialize()); - await connection.confirmTransaction(txid); -} diff --git a/sdk/js/src/solana/rust.ts b/sdk/js/src/solana/rust.ts deleted file mode 100644 index c08b256bb..000000000 --- a/sdk/js/src/solana/rust.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { - AccountMeta, - PublicKey, - TransactionInstruction, -} from "@solana/web3.js"; -// begin from clients\solana\main.ts -export function ixFromRust(data: any): TransactionInstruction { - const keys: AccountMeta[] = data.accounts.map(accountMetaFromRust); - return new TransactionInstruction({ - programId: new PublicKey(data.program_id), - data: Buffer.from(data.data), - keys, - }); -} - -function accountMetaFromRust(meta: any): AccountMeta { - return { - pubkey: new PublicKey(meta.pubkey), - isSigner: meta.is_signer, - isWritable: meta.is_writable, - }; -} -// end from clients\solana\main.ts diff --git a/sdk/js/src/solana/token-node/package.json b/sdk/js/src/solana/token-node/package.json deleted file mode 100644 index 8674574e2..000000000 --- a/sdk/js/src/solana/token-node/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "token-bridge", - "description": "Created with Rocksalt", - "version": "0.1.0", - "files": [ - "token_bridge_bg.wasm", - "token_bridge.js", - "token_bridge_bg.js", - "token_bridge.d.ts" - ], - "main": "token_bridge.js", - "types": "token_bridge.d.ts" -} \ No newline at end of file diff --git a/sdk/js/src/solana/token-node/token_bridge.d.ts b/sdk/js/src/solana/token-node/token_bridge.d.ts deleted file mode 100644 index 1f3e58a88..000000000 --- a/sdk/js/src/solana/token-node/token_bridge.d.ts +++ /dev/null @@ -1,432 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} mint -* @param {number} nonce -* @returns {any} -*/ -export function attest_ix(program_id: string, bridge_id: string, payer: string, message: string, mint: string, nonce: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_native_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, mint: string, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -export function transfer_native_with_payload_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, mint: string, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number, payload: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, from_owner: string, token_chain: number, token_address: Uint8Array, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -export function transfer_wrapped_with_payload_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, from_owner: string, token_chain: number, token_address: Uint8Array, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number, payload: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -export function complete_transfer_native_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array, fee_recipient?: string): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -export function complete_transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array, fee_recipient?: string): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function create_wrapped_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id: string, bridge_id: string, payer: string, spill: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function register_chain_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function emitter_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function custody_signer(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function approval_authority_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @returns {Uint8Array} -*/ -export function wrapped_address(program_id: string, token_address: Uint8Array, token_chain: number): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function wrapped_meta_address(program_id: string, mint_address: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_wrapped_meta(data: Uint8Array): any; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_endpoint_registration(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/token-node/token_bridge.js b/sdk/js/src/solana/token-node/token_bridge.js deleted file mode 100644 index bd0807d82..000000000 --- a/sdk/js/src/solana/token-node/token_bridge.js +++ /dev/null @@ -1,1523 +0,0 @@ -let imports = {}; -imports['__wbindgen_placeholder__'] = module.exports; -let wasm; -const { TextDecoder, TextEncoder } = require(`util`); - -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -let heap_next = heap.length; - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { return heap[idx]; } - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let WASM_VECTOR_LEN = 0; - -let cachedTextEncoder = new TextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} mint -* @param {number} nonce -* @returns {any} -*/ -module.exports.attest_ix = function(program_id, bridge_id, payer, message, mint, nonce) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.attest_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, nonce); - return takeObject(ret); -}; - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -module.exports.transfer_native_ix = function(program_id, bridge_id, payer, message, from, mint, nonce, amount, fee, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low6 = u32CvtShim[0]; - const high6 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - const ptr8 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len8 = WASM_VECTOR_LEN; - const ret = wasm.transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, nonce, low6, high6, low7, high7, ptr8, len8, target_chain); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -module.exports.transfer_native_with_payload_ix = function(program_id, bridge_id, payer, message, from, mint, nonce, amount, fee, target_address, target_chain, payload) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low6 = u32CvtShim[0]; - const high6 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - const ptr8 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len8 = WASM_VECTOR_LEN; - const ptr9 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc); - const len9 = WASM_VECTOR_LEN; - const ret = wasm.transfer_native_with_payload_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, nonce, low6, high6, low7, high7, ptr8, len8, target_chain, ptr9, len9); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -module.exports.transfer_wrapped_ix = function(program_id, bridge_id, payer, message, from, from_owner, token_chain, token_address, nonce, amount, fee, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(from_owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low8 = u32CvtShim[0]; - const high8 = u32CvtShim[1]; - const ptr9 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len9 = WASM_VECTOR_LEN; - const ret = wasm.transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, token_chain, ptr6, len6, nonce, low7, high7, low8, high8, ptr9, len9, target_chain); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -module.exports.transfer_wrapped_with_payload_ix = function(program_id, bridge_id, payer, message, from, from_owner, token_chain, token_address, nonce, amount, fee, target_address, target_chain, payload) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(from_owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low8 = u32CvtShim[0]; - const high8 = u32CvtShim[1]; - const ptr9 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len9 = WASM_VECTOR_LEN; - const ptr10 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc); - const len10 = WASM_VECTOR_LEN; - const ret = wasm.transfer_wrapped_with_payload_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, token_chain, ptr6, len6, nonce, low7, high7, low8, high8, ptr9, len9, target_chain, ptr10, len10); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -module.exports.complete_transfer_native_ix = function(program_id, bridge_id, payer, vaa, fee_recipient) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - var ptr4 = isLikeNone(fee_recipient) ? 0 : passStringToWasm0(fee_recipient, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -module.exports.complete_transfer_wrapped_ix = function(program_id, bridge_id, payer, vaa, fee_recipient) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - var ptr4 = isLikeNone(fee_recipient) ? 0 : passStringToWasm0(fee_recipient, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.create_wrapped_ix = function(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.create_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.upgrade_contract_ix = function(program_id, bridge_id, payer, spill, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(spill, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.upgrade_contract_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -}; - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -module.exports.register_chain_ix = function(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.register_chain_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -}; - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -module.exports.emitter_address = function(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.emitter_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -module.exports.custody_signer = function(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.custody_signer(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -module.exports.approval_authority_address = function(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.approval_authority_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @returns {Uint8Array} -*/ -module.exports.wrapped_address = function(program_id, token_address, token_chain) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.wrapped_address(retptr, ptr0, len0, ptr1, len1, token_chain); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -module.exports.wrapped_meta_address = function(program_id, mint_address) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(mint_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.wrapped_meta_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_wrapped_meta = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_wrapped_meta(ptr0, len0); - return takeObject(ret); -}; - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -module.exports.parse_endpoint_registration = function(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_endpoint_registration(ptr0, len0); - return takeObject(ret); -}; - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -module.exports.init = function() { - wasm.init(); -}; - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Hash = Hash; -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -module.exports.Instruction = Instruction; -/** -*/ -class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -module.exports.Instructions = Instructions; -/** -*/ -class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -module.exports.Message = Message; -/** -*/ -class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Pubkey = Pubkey; - -class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_systeminstruction_free(ptr); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} -module.exports.SystemInstruction = SystemInstruction; - -module.exports.__wbindgen_json_parse = function(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_instruction_new = function(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_object_drop_ref = function(arg0) { - takeObject(arg0); -}; - -module.exports.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -module.exports.__wbg_pubkey_new = function(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_string_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_is_undefined = function(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -module.exports.__wbindgen_number_get = function(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -module.exports.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -module.exports.__wbg_debug_fda1f49ea6af7a1d = function(arg0) { - console.debug(getObject(arg0)); -}; - -module.exports.__wbg_error_8ff19d586a987aef = function(arg0) { - console.error(getObject(arg0)); -}; - -module.exports.__wbg_info_c8f1b00be4ef10bc = function(arg0) { - console.info(getObject(arg0)); -}; - -module.exports.__wbg_log_e8ba7b992c7ad0eb = function(arg0) { - console.log(getObject(arg0)); -}; - -module.exports.__wbg_warn_0227db1aa6989248 = function(arg0) { - console.warn(getObject(arg0)); -}; - -module.exports.__wbg_new_693216e109162396 = function() { - const ret = new Error(); - return addHeapObject(ret); -}; - -module.exports.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbg_error_09919627ac0992f5 = function(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -module.exports.__wbg_new_94fb1279cf6afea5 = function() { - const ret = new Array(); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_is_function = function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -module.exports.__wbindgen_is_object = function(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -module.exports.__wbg_next_cabb70b365520721 = function(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -module.exports.__wbg_next_bf3d83fc18df496e = function() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_done_040f966faa9a72b3 = function(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -module.exports.__wbg_value_419afbd9b9574c4c = function(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -module.exports.__wbg_iterator_4832ef1f15b0382b = function() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -module.exports.__wbg_get_a9cab131e3152c49 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_call_ae78342adc33730a = function() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -module.exports.__wbg_newwithlength_e80fb11cf19c1628 = function(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_561aac756158708c = function(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -module.exports.__wbg_isArray_6721f2e508996340 = function(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -module.exports.__wbg_push_40c6a90f1805aa90 = function(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -module.exports.__wbg_values_b1b9e8c63dbe01c2 = function(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -module.exports.__wbg_buffer_7af23f65f6c64548 = function(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -module.exports.__wbg_new_cc9018bd6f283b6f = function(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -module.exports.__wbg_length_0acb1cf9bbaf8519 = function(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -module.exports.__wbg_instanceof_Uint8Array_edb92795fc0c63b4 = function(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -module.exports.__wbindgen_debug_string = function(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -module.exports.__wbindgen_throw = function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -module.exports.__wbindgen_memory = function() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - -const path = require('path').join(__dirname, 'token_bridge_bg.wasm'); -const bytes = require('fs').readFileSync(path); - -const wasmModule = new WebAssembly.Module(bytes); -const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -wasm = wasmInstance.exports; -module.exports.__wasm = wasm; - diff --git a/sdk/js/src/solana/token-node/token_bridge_bg.wasm b/sdk/js/src/solana/token-node/token_bridge_bg.wasm deleted file mode 100644 index fe6e7aea4..000000000 Binary files a/sdk/js/src/solana/token-node/token_bridge_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/token-node/token_bridge_bg.wasm.d.ts b/sdk/js/src/solana/token-node/token_bridge_bg.wasm.d.ts deleted file mode 100644 index d1cb41d91..000000000 --- a/sdk/js/src/solana/token-node/token_bridge_bg.wasm.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function attest_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): number; -export function transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number): number; -export function transfer_native_with_payload_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number): number; -export function transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number): number; -export function transfer_wrapped_with_payload_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number): number; -export function complete_transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function complete_transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function create_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function upgrade_contract_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function register_chain_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function emitter_address(a: number, b: number, c: number): void; -export function custody_signer(a: number, b: number, c: number): void; -export function approval_authority_address(a: number, b: number, c: number): void; -export function wrapped_address(a: number, b: number, c: number, d: number, e: number, f: number): void; -export function wrapped_meta_address(a: number, b: number, c: number, d: number, e: number): void; -export function parse_wrapped_meta(a: number, b: number): number; -export function parse_endpoint_registration(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function init(): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/token/package.json b/sdk/js/src/solana/token/package.json deleted file mode 100644 index 47c255ba6..000000000 --- a/sdk/js/src/solana/token/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "token-bridge", - "description": "Created with Rocksalt", - "version": "0.1.0", - "files": [ - "token_bridge_bg.wasm", - "token_bridge.js", - "token_bridge.d.ts" - ], - "module": "token_bridge.js", - "types": "token_bridge.d.ts", - "sideEffects": false -} \ No newline at end of file diff --git a/sdk/js/src/solana/token/token_bridge.d.ts b/sdk/js/src/solana/token/token_bridge.d.ts deleted file mode 100644 index 1f3e58a88..000000000 --- a/sdk/js/src/solana/token/token_bridge.d.ts +++ /dev/null @@ -1,432 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} mint -* @param {number} nonce -* @returns {any} -*/ -export function attest_ix(program_id: string, bridge_id: string, payer: string, message: string, mint: string, nonce: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_native_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, mint: string, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -export function transfer_native_with_payload_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, mint: string, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number, payload: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, from_owner: string, token_chain: number, token_address: Uint8Array, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -export function transfer_wrapped_with_payload_ix(program_id: string, bridge_id: string, payer: string, message: string, from: string, from_owner: string, token_chain: number, token_address: Uint8Array, nonce: number, amount: BigInt, fee: BigInt, target_address: Uint8Array, target_chain: number, payload: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -export function complete_transfer_native_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array, fee_recipient?: string): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -export function complete_transfer_wrapped_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array, fee_recipient?: string): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function create_wrapped_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id: string, bridge_id: string, payer: string, spill: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function register_chain_ix(program_id: string, bridge_id: string, payer: string, vaa: Uint8Array): any; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function emitter_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function custody_signer(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function approval_authority_address(program_id: string): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @returns {Uint8Array} -*/ -export function wrapped_address(program_id: string, token_address: Uint8Array, token_chain: number): Uint8Array; -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function wrapped_meta_address(program_id: string, mint_address: Uint8Array): Uint8Array; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_wrapped_meta(data: Uint8Array): any; -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_endpoint_registration(data: Uint8Array): any; -/** -* Initialize Javascript logging and panic handler -*/ -export function init(): void; -/** -*/ -export class Hash { - free(): void; -/** -* Create a new Hash object -* -* * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the hash -* @returns {string} -*/ - toString(): string; -/** -* Checks if two `Hash`s are equal -* @param {Hash} other -* @returns {boolean} -*/ - equals(other: Hash): boolean; -/** -* Return the `Uint8Array` representation of the hash -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - free(): void; -} -/** -*/ -export class Instructions { - free(): void; -/** -*/ - constructor(); -/** -* @param {Instruction} instruction -*/ - push(instruction: Instruction): void; -} -/** -*/ -export class Message { - free(): void; -/** -* The id of a recent ledger entry. -*/ - recent_blockhash: Hash; -} -/** -*/ -export class Pubkey { - free(): void; -/** -* Create a new Pubkey object -* -* * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` -* @param {any} value -*/ - constructor(value: any); -/** -* Return the base58 string representation of the public key -* @returns {string} -*/ - toString(): string; -/** -* Check if a `Pubkey` is on the ed25519 curve. -* @returns {boolean} -*/ - isOnCurve(): boolean; -/** -* Checks if two `Pubkey`s are equal -* @param {Pubkey} other -* @returns {boolean} -*/ - equals(other: Pubkey): boolean; -/** -* Return the `Uint8Array` representation of the public key -* @returns {Uint8Array} -*/ - toBytes(): Uint8Array; -/** -* Derive a Pubkey from another Pubkey, string seed, and a program id -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Pubkey} -*/ - static createWithSeed(base: Pubkey, seed: string, owner: Pubkey): Pubkey; -/** -* Derive a program address from seeds and a program id -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {Pubkey} -*/ - static createProgramAddress(seeds: any[], program_id: Pubkey): Pubkey; -/** -* Find a valid program address -* -* Returns: -* * `[PubKey, number]` - the program address and bump seed -* @param {any[]} seeds -* @param {Pubkey} program_id -* @returns {any} -*/ - static findProgramAddress(seeds: any[], program_id: Pubkey): any; -} -export class SystemInstruction { - free(): void; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccount(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} lamports -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static createAccountWithSeed(from_pubkey: Pubkey, to_pubkey: Pubkey, base: Pubkey, seed: string, lamports: BigInt, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assign(pubkey: Pubkey, owner: Pubkey): Instruction; -/** -* @param {Pubkey} pubkey -* @param {Pubkey} base -* @param {string} seed -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static assignWithSeed(pubkey: Pubkey, base: Pubkey, seed: string, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transfer(from_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} from_base -* @param {string} from_seed -* @param {Pubkey} from_owner -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static transferWithSeed(from_pubkey: Pubkey, from_base: Pubkey, from_seed: string, from_owner: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} pubkey -* @param {BigInt} space -* @returns {Instruction} -*/ - static allocate(pubkey: Pubkey, space: BigInt): Instruction; -/** -* @param {Pubkey} address -* @param {Pubkey} base -* @param {string} seed -* @param {BigInt} space -* @param {Pubkey} owner -* @returns {Instruction} -*/ - static allocateWithSeed(address: Pubkey, base: Pubkey, seed: string, space: BigInt, owner: Pubkey): Instruction; -/** -* @param {Pubkey} from_pubkey -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authority -* @param {BigInt} lamports -* @returns {Array} -*/ - static createNonceAccount(from_pubkey: Pubkey, nonce_pubkey: Pubkey, authority: Pubkey, lamports: BigInt): Array; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @returns {Instruction} -*/ - static advanceNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} to_pubkey -* @param {BigInt} lamports -* @returns {Instruction} -*/ - static withdrawNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, to_pubkey: Pubkey, lamports: BigInt): Instruction; -/** -* @param {Pubkey} nonce_pubkey -* @param {Pubkey} authorized_pubkey -* @param {Pubkey} new_authority -* @returns {Instruction} -*/ - static authorizeNonceAccount(nonce_pubkey: Pubkey, authorized_pubkey: Pubkey, new_authority: Pubkey): Instruction; -} diff --git a/sdk/js/src/solana/token/token_bridge.js b/sdk/js/src/solana/token/token_bridge.js deleted file mode 100644 index 99eb88aa4..000000000 --- a/sdk/js/src/solana/token/token_bridge.js +++ /dev/null @@ -1,2 +0,0 @@ -import * as wasm from "./token_bridge_bg.wasm"; -export * from "./token_bridge_bg.js"; \ No newline at end of file diff --git a/sdk/js/src/solana/token/token_bridge_bg.js b/sdk/js/src/solana/token/token_bridge_bg.js deleted file mode 100644 index 2d469304a..000000000 --- a/sdk/js/src/solana/token/token_bridge_bg.js +++ /dev/null @@ -1,1509 +0,0 @@ -import * as wasm from './token_bridge_bg.wasm'; - -const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; - -let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachegetUint8Memory0 = null; -function getUint8Memory0() { - if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { - cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachegetUint8Memory0; -} - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - -const heap = new Array(32).fill(undefined); - -heap.push(undefined, null, true, false); - -let heap_next = heap.length; - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { return heap[idx]; } - -function dropObject(idx) { - if (idx < 36) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let WASM_VECTOR_LEN = 0; - -const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; - -let cachedTextEncoder = new lTextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length); - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len); - - const mem = getUint8Memory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3); - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -let cachegetInt32Memory0 = null; -function getInt32Memory0() { - if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { - cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); - } - return cachegetInt32Memory0; -} - -let cachegetFloat64Memory0 = null; -function getFloat64Memory0() { - if (cachegetFloat64Memory0 === null || cachegetFloat64Memory0.buffer !== wasm.memory.buffer) { - cachegetFloat64Memory0 = new Float64Array(wasm.memory.buffer); - } - return cachegetFloat64Memory0; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} mint -* @param {number} nonce -* @returns {any} -*/ -export function attest_ix(program_id, bridge_id, payer, message, mint, nonce) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.attest_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, nonce); - return takeObject(ret); -} - -const u32CvtShim = new Uint32Array(2); - -const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer); - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1); - getUint8Memory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_native_ix(program_id, bridge_id, payer, message, from, mint, nonce, amount, fee, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low6 = u32CvtShim[0]; - const high6 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - const ptr8 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len8 = WASM_VECTOR_LEN; - const ret = wasm.transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, nonce, low6, high6, low7, high7, ptr8, len8, target_chain); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} mint -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -export function transfer_native_with_payload_ix(program_id, bridge_id, payer, message, from, mint, nonce, amount, fee, target_address, target_chain, payload) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(mint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low6 = u32CvtShim[0]; - const high6 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - const ptr8 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len8 = WASM_VECTOR_LEN; - const ptr9 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc); - const len9 = WASM_VECTOR_LEN; - const ret = wasm.transfer_native_with_payload_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, nonce, low6, high6, low7, high7, ptr8, len8, target_chain, ptr9, len9); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @returns {any} -*/ -export function transfer_wrapped_ix(program_id, bridge_id, payer, message, from, from_owner, token_chain, token_address, nonce, amount, fee, target_address, target_chain) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(from_owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low8 = u32CvtShim[0]; - const high8 = u32CvtShim[1]; - const ptr9 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len9 = WASM_VECTOR_LEN; - const ret = wasm.transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, token_chain, ptr6, len6, nonce, low7, high7, low8, high8, ptr9, len9, target_chain); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} message -* @param {string} from -* @param {string} from_owner -* @param {number} token_chain -* @param {Uint8Array} token_address -* @param {number} nonce -* @param {BigInt} amount -* @param {BigInt} fee -* @param {Uint8Array} target_address -* @param {number} target_chain -* @param {Uint8Array} payload -* @returns {any} -*/ -export function transfer_wrapped_with_payload_ix(program_id, bridge_id, payer, message, from, from_owner, token_chain, token_address, nonce, amount, fee, target_address, target_chain, payload) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passStringToWasm0(from, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len4 = WASM_VECTOR_LEN; - const ptr5 = passStringToWasm0(from_owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len5 = WASM_VECTOR_LEN; - const ptr6 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len6 = WASM_VECTOR_LEN; - uint64CvtShim[0] = amount; - const low7 = u32CvtShim[0]; - const high7 = u32CvtShim[1]; - uint64CvtShim[0] = fee; - const low8 = u32CvtShim[0]; - const high8 = u32CvtShim[1]; - const ptr9 = passArray8ToWasm0(target_address, wasm.__wbindgen_malloc); - const len9 = WASM_VECTOR_LEN; - const ptr10 = passArray8ToWasm0(payload, wasm.__wbindgen_malloc); - const len10 = WASM_VECTOR_LEN; - const ret = wasm.transfer_wrapped_with_payload_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, token_chain, ptr6, len6, nonce, low7, high7, low8, high8, ptr9, len9, target_chain, ptr10, len10); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -export function complete_transfer_native_ix(program_id, bridge_id, payer, vaa, fee_recipient) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - var ptr4 = isLikeNone(fee_recipient) ? 0 : passStringToWasm0(fee_recipient, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_native_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @param {string | undefined} fee_recipient -* @returns {any} -*/ -export function complete_transfer_wrapped_ix(program_id, bridge_id, payer, vaa, fee_recipient) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - var ptr4 = isLikeNone(fee_recipient) ? 0 : passStringToWasm0(fee_recipient, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len4 = WASM_VECTOR_LEN; - const ret = wasm.complete_transfer_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function create_wrapped_ix(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.create_wrapped_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {string} spill -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function upgrade_contract_ix(program_id, bridge_id, payer, spill, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passStringToWasm0(spill, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len3 = WASM_VECTOR_LEN; - const ptr4 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len4 = WASM_VECTOR_LEN; - const ret = wasm.upgrade_contract_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4); - return takeObject(ret); -} - -/** -* @param {string} program_id -* @param {string} bridge_id -* @param {string} payer -* @param {Uint8Array} vaa -* @returns {any} -*/ -export function register_chain_ix(program_id, bridge_id, payer, vaa) { - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(bridge_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(payer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ptr3 = passArray8ToWasm0(vaa, wasm.__wbindgen_malloc); - const len3 = WASM_VECTOR_LEN; - const ret = wasm.register_chain_ix(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3); - return takeObject(ret); -} - -function getArrayU8FromWasm0(ptr, len) { - return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function emitter_address(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.emitter_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function custody_signer(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.custody_signer(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @returns {Uint8Array} -*/ -export function approval_authority_address(program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.approval_authority_address(retptr, ptr0, len0); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {Uint8Array} token_address -* @param {number} token_chain -* @returns {Uint8Array} -*/ -export function wrapped_address(program_id, token_address, token_chain) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(token_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.wrapped_address(retptr, ptr0, len0, ptr1, len1, token_chain); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {string} program_id -* @param {Uint8Array} mint_address -* @returns {Uint8Array} -*/ -export function wrapped_meta_address(program_id, mint_address) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(mint_address, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - wasm.wrapped_meta_address(retptr, ptr0, len0, ptr1, len1); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_wrapped_meta(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_wrapped_meta(ptr0, len0); - return takeObject(ret); -} - -/** -* @param {Uint8Array} data -* @returns {any} -*/ -export function parse_endpoint_registration(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_endpoint_registration(ptr0, len0); - return takeObject(ret); -} - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} -/** -* Initialize Javascript logging and panic handler -*/ -export function init() { - wasm.init(); -} - -let cachegetUint32Memory0 = null; -function getUint32Memory0() { - if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { - cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); - } - return cachegetUint32Memory0; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4); - const mem = getUint32Memory0(); - for (let i = 0; i < array.length; i++) { - mem[ptr / 4 + i] = addHeapObject(array[i]); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -/** -*/ -export class Hash { - - static __wrap(ptr) { - const obj = Object.create(Hash.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_hash_free(ptr); - } - /** - * Create a new Hash object - * - * * `value` - optional hash as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Hash.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the hash - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Checks if two `Hash`s are equal - * @param {Hash} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Hash); - const ret = wasm.hash_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the hash - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.hash_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -/** -* A directive for a single invocation of a Solana program. -* -* An instruction specifies which program it is calling, which accounts it may -* read or modify, and additional data that serves as input to the program. One -* or more instructions are included in transactions submitted by Solana -* clients. Instructions are also used to describe [cross-program -* invocations][cpi]. -* -* [cpi]: https://docs.solana.com/developing/programming-model/calling-between-programs -* -* During execution, a program will receive a list of account data as one of -* its arguments, in the same order as specified during `Instruction` -* construction. -* -* While Solana is agnostic to the format of the instruction data, it has -* built-in support for serialization via [`borsh`] and [`bincode`]. -* -* [`borsh`]: https://docs.rs/borsh/latest/borsh/ -* [`bincode`]: https://docs.rs/bincode/latest/bincode/ -* -* # Specifying account metadata -* -* When constructing an [`Instruction`], a list of all accounts that may be -* read or written during the execution of that instruction must be supplied as -* [`AccountMeta`] values. -* -* Any account whose data may be mutated by the program during execution must -* be specified as writable. During execution, writing to an account that was -* not specified as writable will cause the transaction to fail. Writing to an -* account that is not owned by the program will cause the transaction to fail. -* -* Any account whose lamport balance may be mutated by the program during -* execution must be specified as writable. During execution, mutating the -* lamports of an account that was not specified as writable will cause the -* transaction to fail. While _subtracting_ lamports from an account not owned -* by the program will cause the transaction to fail, _adding_ lamports to any -* account is allowed, as long is it is mutable. -* -* Accounts that are not read or written by the program may still be specified -* in an `Instruction`'s account list. These will affect scheduling of program -* execution by the runtime, but will otherwise be ignored. -* -* When building a transaction, the Solana runtime coalesces all accounts used -* by all instructions in that transaction, along with accounts and permissions -* required by the runtime, into a single account list. Some accounts and -* account permissions required by the runtime to process a transaction are -* _not_ required to be included in an `Instruction`s account list. These -* include: -* -* - The program ID — it is a separate field of `Instruction` -* - The transaction's fee-paying account — it is added during [`Message`] -* construction. A program may still require the fee payer as part of the -* account list if it directly references it. -* -* [`Message`]: crate::message::Message -* -* Programs may require signatures from some accounts, in which case they -* should be specified as signers during `Instruction` construction. The -* program must still validate during execution that the account is a signer. -*/ -export class Instruction { - - static __wrap(ptr) { - const obj = Object.create(Instruction.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instruction_free(ptr); - } -} -/** -*/ -export class Instructions { - - static __wrap(ptr) { - const obj = Object.create(Instructions.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_instructions_free(ptr); - } - /** - */ - constructor() { - const ret = wasm.instructions_constructor(); - return Instructions.__wrap(ret); - } - /** - * @param {Instruction} instruction - */ - push(instruction) { - _assertClass(instruction, Instruction); - var ptr0 = instruction.ptr; - instruction.ptr = 0; - wasm.instructions_push(this.ptr, ptr0); - } -} -/** -*/ -export class Message { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_message_free(ptr); - } - /** - * The id of a recent ledger entry. - */ - get recent_blockhash() { - const ret = wasm.__wbg_get_message_recent_blockhash(this.ptr); - return Hash.__wrap(ret); - } - /** - * The id of a recent ledger entry. - * @param {Hash} arg0 - */ - set recent_blockhash(arg0) { - _assertClass(arg0, Hash); - var ptr0 = arg0.ptr; - arg0.ptr = 0; - wasm.__wbg_set_message_recent_blockhash(this.ptr, ptr0); - } -} -/** -*/ -export class Pubkey { - - static __wrap(ptr) { - const obj = Object.create(Pubkey.prototype); - obj.ptr = ptr; - - return obj; - } - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_pubkey_free(ptr); - } - /** - * Create a new Pubkey object - * - * * `value` - optional public key as a base58 encoded string, `Uint8Array`, `[number]` - * @param {any} value - */ - constructor(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_constructor(retptr, addHeapObject(value)); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return the base58 string representation of the public key - * @returns {string} - */ - toString() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toString(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); - } - } - /** - * Check if a `Pubkey` is on the ed25519 curve. - * @returns {boolean} - */ - isOnCurve() { - const ret = wasm.pubkey_isOnCurve(this.ptr); - return ret !== 0; - } - /** - * Checks if two `Pubkey`s are equal - * @param {Pubkey} other - * @returns {boolean} - */ - equals(other) { - _assertClass(other, Pubkey); - const ret = wasm.pubkey_equals(this.ptr, other.ptr); - return ret !== 0; - } - /** - * Return the `Uint8Array` representation of the public key - * @returns {Uint8Array} - */ - toBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.pubkey_toBytes(retptr, this.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var v0 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1); - return v0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a Pubkey from another Pubkey, string seed, and a program id - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Pubkey} - */ - static createWithSeed(base, seed, owner) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - wasm.pubkey_createWithSeed(retptr, base.ptr, ptr0, len0, owner.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Derive a program address from seeds and a program id - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {Pubkey} - */ - static createProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_createProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return Pubkey.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Find a valid program address - * - * Returns: - * * `[PubKey, number]` - the program address and bump seed - * @param {any[]} seeds - * @param {Pubkey} program_id - * @returns {any} - */ - static findProgramAddress(seeds, program_id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(seeds, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(program_id, Pubkey); - wasm.pubkey_findProgramAddress(retptr, ptr0, len0, program_id.ptr); - var r0 = getInt32Memory0()[retptr / 4 + 0]; - var r1 = getInt32Memory0()[retptr / 4 + 1]; - var r2 = getInt32Memory0()[retptr / 4 + 2]; - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} - -export class SystemInstruction { - - __destroy_into_raw() { - const ptr = this.ptr; - this.ptr = 0; - - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccount(from_pubkey, to_pubkey, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccount(from_pubkey.ptr, to_pubkey.ptr, low0, high0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} lamports - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static createAccountWithSeed(from_pubkey, to_pubkey, base, seed, lamports, space, owner) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - uint64CvtShim[0] = space; - const low2 = u32CvtShim[0]; - const high2 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_createAccountWithSeed(from_pubkey.ptr, to_pubkey.ptr, base.ptr, ptr0, len0, low1, high1, low2, high2, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assign(pubkey, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assign(pubkey.ptr, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {Pubkey} base - * @param {string} seed - * @param {Pubkey} owner - * @returns {Instruction} - */ - static assignWithSeed(pubkey, base, seed, owner) { - _assertClass(pubkey, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_assignWithSeed(pubkey.ptr, base.ptr, ptr0, len0, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transfer(from_pubkey, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transfer(from_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} from_base - * @param {string} from_seed - * @param {Pubkey} from_owner - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static transferWithSeed(from_pubkey, from_base, from_seed, from_owner, to_pubkey, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(from_base, Pubkey); - const ptr0 = passStringToWasm0(from_seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(from_owner, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - const ret = wasm.systeminstruction_transferWithSeed(from_pubkey.ptr, from_base.ptr, ptr0, len0, from_owner.ptr, to_pubkey.ptr, low1, high1); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} pubkey - * @param {BigInt} space - * @returns {Instruction} - */ - static allocate(pubkey, space) { - _assertClass(pubkey, Pubkey); - uint64CvtShim[0] = space; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_allocate(pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} address - * @param {Pubkey} base - * @param {string} seed - * @param {BigInt} space - * @param {Pubkey} owner - * @returns {Instruction} - */ - static allocateWithSeed(address, base, seed, space, owner) { - _assertClass(address, Pubkey); - _assertClass(base, Pubkey); - const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - uint64CvtShim[0] = space; - const low1 = u32CvtShim[0]; - const high1 = u32CvtShim[1]; - _assertClass(owner, Pubkey); - const ret = wasm.systeminstruction_allocateWithSeed(address.ptr, base.ptr, ptr0, len0, low1, high1, owner.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} from_pubkey - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authority - * @param {BigInt} lamports - * @returns {Array} - */ - static createNonceAccount(from_pubkey, nonce_pubkey, authority, lamports) { - _assertClass(from_pubkey, Pubkey); - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authority, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_createNonceAccount(from_pubkey.ptr, nonce_pubkey.ptr, authority.ptr, low0, high0); - return takeObject(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @returns {Instruction} - */ - static advanceNonceAccount(nonce_pubkey, authorized_pubkey) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - const ret = wasm.systeminstruction_advanceNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} to_pubkey - * @param {BigInt} lamports - * @returns {Instruction} - */ - static withdrawNonceAccount(nonce_pubkey, authorized_pubkey, to_pubkey, lamports) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(to_pubkey, Pubkey); - uint64CvtShim[0] = lamports; - const low0 = u32CvtShim[0]; - const high0 = u32CvtShim[1]; - const ret = wasm.systeminstruction_withdrawNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, to_pubkey.ptr, low0, high0); - return Instruction.__wrap(ret); - } - /** - * @param {Pubkey} nonce_pubkey - * @param {Pubkey} authorized_pubkey - * @param {Pubkey} new_authority - * @returns {Instruction} - */ - static authorizeNonceAccount(nonce_pubkey, authorized_pubkey, new_authority) { - _assertClass(nonce_pubkey, Pubkey); - _assertClass(authorized_pubkey, Pubkey); - _assertClass(new_authority, Pubkey); - const ret = wasm.systeminstruction_authorizeNonceAccount(nonce_pubkey.ptr, authorized_pubkey.ptr, new_authority.ptr); - return Instruction.__wrap(ret); - } -} - -export function __wbindgen_json_parse(arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -export function __wbg_instruction_new(arg0) { - const ret = Instruction.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_object_drop_ref(arg0) { - takeObject(arg0); -}; - -export function __wbindgen_string_new(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -export function __wbg_pubkey_new(arg0) { - const ret = Pubkey.__wrap(arg0); - return addHeapObject(ret); -}; - -export function __wbindgen_string_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_is_undefined(arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -export function __wbindgen_number_get(arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof(obj) === 'number' ? obj : undefined; - getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; - getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); -}; - -export function __wbindgen_number_new(arg0) { - const ret = arg0; - return addHeapObject(ret); -}; - -export function __wbg_debug_fda1f49ea6af7a1d(arg0) { - console.debug(getObject(arg0)); -}; - -export function __wbg_error_8ff19d586a987aef(arg0) { - console.error(getObject(arg0)); -}; - -export function __wbg_info_c8f1b00be4ef10bc(arg0) { - console.info(getObject(arg0)); -}; - -export function __wbg_log_e8ba7b992c7ad0eb(arg0) { - console.log(getObject(arg0)); -}; - -export function __wbg_warn_0227db1aa6989248(arg0) { - console.warn(getObject(arg0)); -}; - -export function __wbg_new_693216e109162396() { - const ret = new Error(); - return addHeapObject(ret); -}; - -export function __wbg_stack_0ddaca5d1abfb52f(arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbg_error_09919627ac0992f5(arg0, arg1) { - try { - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(arg0, arg1); - } -}; - -export function __wbg_new_94fb1279cf6afea5() { - const ret = new Array(); - return addHeapObject(ret); -}; - -export function __wbindgen_is_function(arg0) { - const ret = typeof(getObject(arg0)) === 'function'; - return ret; -}; - -export function __wbindgen_is_object(arg0) { - const val = getObject(arg0); - const ret = typeof(val) === 'object' && val !== null; - return ret; -}; - -export function __wbg_next_cabb70b365520721(arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); -}; - -export function __wbg_next_bf3d83fc18df496e() { return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_done_040f966faa9a72b3(arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -export function __wbg_value_419afbd9b9574c4c(arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -export function __wbg_iterator_4832ef1f15b0382b() { - const ret = Symbol.iterator; - return addHeapObject(ret); -}; - -export function __wbg_get_a9cab131e3152c49() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_call_ae78342adc33730a() { return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); -}, arguments) }; - -export function __wbg_newwithlength_e80fb11cf19c1628(arg0) { - const ret = new Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -export function __wbg_set_561aac756158708c(arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); -}; - -export function __wbg_isArray_6721f2e508996340(arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -export function __wbg_push_40c6a90f1805aa90(arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -export function __wbg_values_b1b9e8c63dbe01c2(arg0) { - const ret = getObject(arg0).values(); - return addHeapObject(ret); -}; - -export function __wbg_buffer_7af23f65f6c64548(arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -export function __wbg_new_cc9018bd6f283b6f(arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -export function __wbg_set_f25e869e4565d2a2(arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -export function __wbg_length_0acb1cf9bbaf8519(arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -export function __wbg_instanceof_Uint8Array_edb92795fc0c63b4(arg0) { - const ret = getObject(arg0) instanceof Uint8Array; - return ret; -}; - -export function __wbindgen_debug_string(arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len0; - getInt32Memory0()[arg0 / 4 + 0] = ptr0; -}; - -export function __wbindgen_throw(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -export function __wbindgen_memory() { - const ret = wasm.memory; - return addHeapObject(ret); -}; - diff --git a/sdk/js/src/solana/token/token_bridge_bg.wasm b/sdk/js/src/solana/token/token_bridge_bg.wasm deleted file mode 100644 index 128d1f756..000000000 Binary files a/sdk/js/src/solana/token/token_bridge_bg.wasm and /dev/null differ diff --git a/sdk/js/src/solana/token/token_bridge_bg.wasm.d.ts b/sdk/js/src/solana/token/token_bridge_bg.wasm.d.ts deleted file mode 100644 index d1cb41d91..000000000 --- a/sdk/js/src/solana/token/token_bridge_bg.wasm.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const memory: WebAssembly.Memory; -export function attest_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): number; -export function transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number): number; -export function transfer_native_with_payload_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number): number; -export function transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number): number; -export function transfer_wrapped_with_payload_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number): number; -export function complete_transfer_native_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function complete_transfer_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function create_wrapped_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function upgrade_contract_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function register_chain_ix(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function emitter_address(a: number, b: number, c: number): void; -export function custody_signer(a: number, b: number, c: number): void; -export function approval_authority_address(a: number, b: number, c: number): void; -export function wrapped_address(a: number, b: number, c: number, d: number, e: number, f: number): void; -export function wrapped_meta_address(a: number, b: number, c: number, d: number, e: number): void; -export function parse_wrapped_meta(a: number, b: number): number; -export function parse_endpoint_registration(a: number, b: number): number; -export function __wbg_message_free(a: number): void; -export function __wbg_get_message_recent_blockhash(a: number): number; -export function __wbg_set_message_recent_blockhash(a: number, b: number): void; -export function init(): void; -export function __wbg_instruction_free(a: number): void; -export function __wbg_pubkey_free(a: number): void; -export function systeminstruction_createAccount(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createAccountWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): number; -export function systeminstruction_assign(a: number, b: number): number; -export function systeminstruction_assignWithSeed(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_transfer(a: number, b: number, c: number, d: number): number; -export function systeminstruction_transferWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number; -export function systeminstruction_allocate(a: number, b: number, c: number): number; -export function systeminstruction_allocateWithSeed(a: number, b: number, c: number, d: number, e: number, f: number, g: number): number; -export function systeminstruction_createNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_advanceNonceAccount(a: number, b: number): number; -export function systeminstruction_withdrawNonceAccount(a: number, b: number, c: number, d: number, e: number): number; -export function systeminstruction_authorizeNonceAccount(a: number, b: number, c: number): number; -export function pubkey_constructor(a: number, b: number): void; -export function pubkey_toString(a: number, b: number): void; -export function pubkey_isOnCurve(a: number): number; -export function pubkey_equals(a: number, b: number): number; -export function pubkey_toBytes(a: number, b: number): void; -export function pubkey_createWithSeed(a: number, b: number, c: number, d: number, e: number): void; -export function pubkey_createProgramAddress(a: number, b: number, c: number, d: number): void; -export function pubkey_findProgramAddress(a: number, b: number, c: number, d: number): void; -export function __wbg_instructions_free(a: number): void; -export function instructions_constructor(): number; -export function instructions_push(a: number, b: number): void; -export function __wbg_hash_free(a: number): void; -export function hash_constructor(a: number, b: number): void; -export function hash_toString(a: number, b: number): void; -export function hash_equals(a: number, b: number): number; -export function hash_toBytes(a: number, b: number): void; -export function __wbindgen_malloc(a: number): number; -export function __wbindgen_realloc(a: number, b: number, c: number): number; -export function __wbindgen_add_to_stack_pointer(a: number): number; -export function __wbindgen_free(a: number, b: number): void; -export function __wbindgen_exn_store(a: number): void; diff --git a/sdk/js/src/solana/wasm.ts b/sdk/js/src/solana/wasm.ts deleted file mode 100644 index f2231d0ab..000000000 --- a/sdk/js/src/solana/wasm.ts +++ /dev/null @@ -1,38 +0,0 @@ -const coreWasms = { - bundler: async () => await import("./core/bridge"), - node: async () => await import("./core-node/bridge"), -}; -const migrationWasms = { - bundler: async () => await import("./migration/wormhole_migration"), - node: async () => await import("./migration-node/wormhole_migration"), -}; -const nftWasms = { - bundler: async () => await import("./nft/nft_bridge"), - node: async () => await import("./nft-node/nft_bridge"), -}; -const tokenWasms = { - bundler: async () => await import("./token/token_bridge"), - node: async () => await import("./token-node/token_bridge"), -}; -let importDefaultCoreWasm = coreWasms.bundler; -let importDefaultMigrationWasm = migrationWasms.bundler; -let importDefaultNftWasm = nftWasms.bundler; -let importDefaultTokenWasm = tokenWasms.bundler; -export function setDefaultWasm(type: "bundler" | "node") { - importDefaultCoreWasm = coreWasms[type]; - importDefaultMigrationWasm = migrationWasms[type]; - importDefaultNftWasm = nftWasms[type]; - importDefaultTokenWasm = tokenWasms[type]; -} -export async function importCoreWasm() { - return await importDefaultCoreWasm(); -} -export async function importMigrationWasm() { - return await importDefaultMigrationWasm(); -} -export async function importNftWasm() { - return await importDefaultNftWasm(); -} -export async function importTokenWasm() { - return await importDefaultTokenWasm(); -} diff --git a/sdk/js/src/terra/address.ts b/sdk/js/src/terra/address.ts deleted file mode 100644 index e7730f7f8..000000000 --- a/sdk/js/src/terra/address.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { zeroPad } from "@ethersproject/bytes"; -import { bech32 } from "bech32"; - -export function canonicalAddress(humanAddress: string) { - return new Uint8Array(bech32.fromWords(bech32.decode(humanAddress).words)); -} -export function humanAddress(canonicalAddress: Uint8Array) { - return bech32.encode("terra", bech32.toWords(canonicalAddress)); -} - -// from https://github.com/terra-money/station/blob/dca7de43958ce075c6e46605622203b9859b0e14/src/lib/utils/is.ts#L12 -export const isNativeTerra = (string = "") => - string.startsWith("u") && string.length === 4; - -// from https://github.com/terra-money/station/blob/dca7de43958ce075c6e46605622203b9859b0e14/src/lib/utils/is.ts#L20 -export const isNativeDenom = (string = "") => - isNativeTerra(string) || string === "uluna"; - -export function buildNativeId(denom: string): Uint8Array { - const bytes = []; - for (let i = 0; i < denom.length; i++) { - bytes.push(denom.charCodeAt(i)); - } - const padded = zeroPad(new Uint8Array(bytes), 32); - padded[0] = 1; - return padded; -} diff --git a/sdk/js/src/terra/index.ts b/sdk/js/src/terra/index.ts deleted file mode 100644 index ce667bbed..000000000 --- a/sdk/js/src/terra/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./address"; diff --git a/sdk/js/src/token_bridge/attest.ts b/sdk/js/src/token_bridge/attest.ts index 1142b9c2c..bda5a50b8 100644 --- a/sdk/js/src/token_bridge/attest.ts +++ b/sdk/js/src/token_bridge/attest.ts @@ -1,21 +1,5 @@ -import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js"; -import { MsgExecuteContract } from "@terra-money/terra.js"; -import { - Algodv2, - bigIntToBytes, - decodeAddress, - getApplicationAddress, - makeApplicationCallTxnFromObject, - makePaymentTxnWithSuggestedParamsFromObject, - OnApplicationComplete, - SuggestedParams, -} from "algosdk"; import { ethers, PayableOverrides } from "ethers"; -import { isNativeDenom } from ".."; -import { getMessageFee, optin, TransactionSignerPair } from "../algorand"; import { Bridge__factory } from "../ethers-contracts"; -import { getBridgeFeeIx, ixFromRust } from "../solana"; -import { importTokenWasm } from "../solana/wasm"; import { textToHexString, textToUint8Array, uint8ArrayToHex, utf8StringTo32Bytes } from "../utils"; import { safeBigIntToNumber } from "../utils/bigint"; import { createNonce } from "../utils/createNonce"; @@ -69,170 +53,3 @@ export async function attestFromEth( const receipt = await v.wait(); return receipt; } - -export async function attestFromTerra( - tokenBridgeAddress: string, - walletAddress: string, - asset: string -): Promise { - const nonce = Math.round(Math.random() * 100000); - const isNativeAsset = isNativeDenom(asset); - return new MsgExecuteContract(walletAddress, tokenBridgeAddress, { - create_asset_meta: { - asset_info: isNativeAsset - ? { - native_token: { denom: asset }, - } - : { - token: { - contract_addr: asset, - }, - }, - nonce: nonce, - }, - }); -} - -export async function attestFromSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - mintAddress: string -): Promise { - const nonce = createNonce().readUInt32LE(0); - const transferIx = await getBridgeFeeIx( - connection, - bridgeAddress, - payerAddress - ); - const { attest_ix } = await importTokenWasm(); - const messageKey = Keypair.generate(); - const ix = ixFromRust( - attest_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - mintAddress, - nonce - ) - ); - const transaction = new Transaction().add(transferIx, ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - transaction.partialSign(messageKey); - return transaction; -} - -/** - * Attest an already created asset - * If you create a new asset on algorand and want to transfer it elsewhere, - * you create an attestation for it on algorand... pass that vaa to the target chain.. - * submit it.. then you can transfer from algorand to that target chain - * @param client An Algodv2 client - * @param tokenBridgeId The ID of the token bridge - * @param senderAcct The account paying fees - * @param assetId The asset index - * @returns Transaction ID - */ -export async function attestFromAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - bridgeId: bigint, - senderAddr: string, - assetId: bigint -): Promise { - const tbAddr: string = getApplicationAddress(tokenBridgeId); - const decTbAddr: Uint8Array = decodeAddress(tbAddr).publicKey; - const aa: string = uint8ArrayToHex(decTbAddr); - const txs: TransactionSignerPair[] = []; - // "attestFromAlgorand::emitterAddr" - const { addr: emitterAddr, txs: emitterOptInTxs } = await optin( - client, - senderAddr, - bridgeId, - BigInt(0), - aa - ); - txs.push(...emitterOptInTxs); - let wormhole: boolean = false; - let creatorAcctInfo: any = false; - let creatorAddr = ""; - const bPgmName: Uint8Array = textToUint8Array("attestToken"); - - if (assetId !== BigInt(0)) { - const assetInfo = await client - .getAssetByID(safeBigIntToNumber(assetId)) - .do(); - creatorAddr = assetInfo.params.creator; - creatorAcctInfo = await client.accountInformation(creatorAddr).do(); - wormhole = creatorAcctInfo["auth-addr"] === tbAddr; - } else { - wormhole = false; - } - - if (!wormhole) { - // "notWormhole" - const result = await optin( - client, - senderAddr, - tokenBridgeId, - assetId, - textToHexString("native") - ); - creatorAddr = result.addr; - txs.push(...result.txs); - } - const suggParams: SuggestedParams = await client.getTransactionParams().do(); - - const firstTxn = makeApplicationCallTxnFromObject({ - from: senderAddr, - appIndex: safeBigIntToNumber(tokenBridgeId), - onComplete: OnApplicationComplete.NoOpOC, - appArgs: [textToUint8Array("nop")], - suggestedParams: suggParams, - }); - txs.push({ tx: firstTxn, signer: null }); - - const mfee = await getMessageFee(client, bridgeId); - if (mfee > BigInt(0)) { - const feeTxn = makePaymentTxnWithSuggestedParamsFromObject({ - from: senderAddr, - suggestedParams: suggParams, - to: getApplicationAddress(tokenBridgeId), - amount: mfee, - }); - txs.push({ tx: feeTxn, signer: null }); - } - - let accts: string[] = [ - emitterAddr, - creatorAddr, - getApplicationAddress(bridgeId), - ]; - - if (creatorAcctInfo) { - accts.push(creatorAcctInfo["address"]); - } - - let appTxn = makeApplicationCallTxnFromObject({ - appArgs: [bPgmName, bigIntToBytes(assetId, 8)], - accounts: accts, - appIndex: safeBigIntToNumber(tokenBridgeId), - foreignApps: [safeBigIntToNumber(bridgeId)], - foreignAssets: [safeBigIntToNumber(assetId)], - from: senderAddr, - onComplete: OnApplicationComplete.NoOpOC, - suggestedParams: suggParams, - }); - if (mfee > BigInt(0)) { - appTxn.fee *= 3; - } else { - appTxn.fee *= 2; - } - txs.push({ tx: appTxn, signer: null }); - - return txs; -} diff --git a/sdk/js/src/token_bridge/createWrapped.ts b/sdk/js/src/token_bridge/createWrapped.ts index 90f80dad7..d7b6f308d 100644 --- a/sdk/js/src/token_bridge/createWrapped.ts +++ b/sdk/js/src/token_bridge/createWrapped.ts @@ -1,13 +1,6 @@ import { ALPH_TOKEN_ID, binToHex, DUST_AMOUNT, ExecuteScriptResult, SignerProvider } from "@alephium/web3"; -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; -import { MsgExecuteContract } from "@terra-money/terra.js"; -import { Algodv2 } from "algosdk"; import { ethers, Overrides } from "ethers"; -import { fromUint8Array } from "js-base64"; -import { TransactionSignerPair, _submitVAAAlgorand } from "../algorand"; import { Bridge__factory } from "../ethers-contracts"; -import { ixFromRust } from "../solana"; -import { importTokenWasm } from "../solana/wasm"; import { CreateRemoteTokenPool, CreateLocalTokenPool } from "../alephium-contracts/ts/scripts"; export async function createRemoteTokenPoolOnAlph( @@ -60,54 +53,3 @@ export async function createWrappedOnEth( const receipt = await v.wait(); return receipt; } - -export async function createWrappedOnTerra( - tokenBridgeAddress: string, - walletAddress: string, - signedVAA: Uint8Array -): Promise { - return new MsgExecuteContract(walletAddress, tokenBridgeAddress, { - submit_vaa: { - data: fromUint8Array(signedVAA), - }, - }); -} - -export async function createWrappedOnSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - signedVAA: Uint8Array -): Promise { - const { create_wrapped_ix } = await importTokenWasm(); - const ix = ixFromRust( - create_wrapped_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - signedVAA - ) - ); - const transaction = new Transaction().add(ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} - -export async function createWrappedOnAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - bridgeId: bigint, - senderAddr: string, - attestVAA: Uint8Array -): Promise { - return await _submitVAAAlgorand( - client, - tokenBridgeId, - bridgeId, - attestVAA, - senderAddr - ); -} diff --git a/sdk/js/src/token_bridge/getForeignAsset.ts b/sdk/js/src/token_bridge/getForeignAsset.ts index 803fc452c..8d63babc9 100644 --- a/sdk/js/src/token_bridge/getForeignAsset.ts +++ b/sdk/js/src/token_bridge/getForeignAsset.ts @@ -1,22 +1,7 @@ import { binToHex, NodeProvider } from "@alephium/web3"; -import { Connection, PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import { Algodv2 } from "algosdk"; import { ethers } from "ethers"; -import { fromUint8Array } from "js-base64"; -import { - calcLogicSigAccount, - decodeLocalState, - hexToNativeAssetBigIntAlgorand, -} from "../algorand"; import { Bridge__factory } from "../ethers-contracts"; -import { importTokenWasm } from "../solana/wasm"; -import { - ChainId, - ChainName, - CHAIN_ID_ALGORAND, - coalesceChainId, -} from "../utils"; +import { ChainId, ChainName, coalesceChainId } from "../utils"; import { contractExists, getTokenPoolId } from "./alephium"; export async function getForeignAssetAlephium( @@ -59,83 +44,3 @@ export async function getForeignAssetEth( return null; } } - -export async function getForeignAssetTerra( - tokenBridgeAddress: string, - client: LCDClient, - originChain: ChainId | ChainName, - originAsset: Uint8Array -): Promise { - try { - const result: { address: string } = await client.wasm.contractQuery( - tokenBridgeAddress, - { - wrapped_registry: { - chain: coalesceChainId(originChain), - address: fromUint8Array(originAsset), - }, - } - ); - return result.address; - } catch (e) { - return null; - } -} - -/** - * Returns a foreign asset address on Solana for a provided native chain and asset address - * @param connection - * @param tokenBridgeAddress - * @param originChain - * @param originAsset zero pad to 32 bytes - * @returns - */ -export async function getForeignAssetSolana( - connection: Connection, - tokenBridgeAddress: string, - originChain: ChainId | ChainName, - originAsset: Uint8Array -): Promise { - const { wrapped_address } = await importTokenWasm(); - const wrappedAddress = wrapped_address( - tokenBridgeAddress, - originAsset, - coalesceChainId(originChain) - ); - const wrappedAddressPK = new PublicKey(wrappedAddress); - const wrappedAssetAccountInfo = await connection.getAccountInfo( - wrappedAddressPK - ); - return wrappedAssetAccountInfo ? wrappedAddressPK.toString() : null; -} - -export async function getForeignAssetAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - chain: ChainId | ChainName, - contract: string -): Promise { - const chainId = coalesceChainId(chain); - if (chainId === CHAIN_ID_ALGORAND) { - return hexToNativeAssetBigIntAlgorand(contract); - } else { - let { lsa, doesExist } = await calcLogicSigAccount( - client, - tokenBridgeId, - BigInt(chainId), - contract - ); - if (!doesExist) { - return null; - } - let asset: Uint8Array = await decodeLocalState( - client, - tokenBridgeId, - lsa.address() - ); - if (asset.length > 8) { - const tmp = Buffer.from(asset.slice(0, 8)); - return tmp.readBigUInt64BE(0); - } else return null; - } -} diff --git a/sdk/js/src/token_bridge/getIsTransferCompleted.ts b/sdk/js/src/token_bridge/getIsTransferCompleted.ts index 12c4409ea..da80d7931 100644 --- a/sdk/js/src/token_bridge/getIsTransferCompleted.ts +++ b/sdk/js/src/token_bridge/getIsTransferCompleted.ts @@ -1,22 +1,8 @@ -import { Connection, PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import { Algodv2, bigIntToBytes } from "algosdk"; -import axios from "axios"; import { ethers } from "ethers"; -import { redeemOnTerra } from "."; -import { TERRA_REDEEMED_CHECK_WALLET_ADDRESS } from ".."; import { extractSequenceFromVAA } from "../utils"; import { addressFromContractId, subContractId } from "@alephium/web3"; -import { - BITS_PER_KEY, - calcLogicSigAccount, - MAX_BITS, - _parseVAAAlgorand, -} from "../algorand"; import { getSignedVAAHash } from "../bridge"; import { Bridge__factory } from "../ethers-contracts"; -import { importCoreWasm } from "../solana/wasm"; -import { safeBigIntToNumber } from "../utils/bigint"; import { zeroPad } from "./alephium"; import { TokenBridgeForChain } from "../alephium-contracts/ts/TokenBridgeForChain"; import { UnexecutedSequence } from "../alephium-contracts/ts/UnexecutedSequence"; @@ -93,137 +79,3 @@ export async function getIsTransferCompletedEth( const signedVAAHash = getSignedVAAHash(signedVAA); return await tokenBridge.isTransferCompleted(signedVAAHash); } - -export async function getIsTransferCompletedTerra( - tokenBridgeAddress: string, - signedVAA: Uint8Array, - client: LCDClient, - gasPriceUrl: string -): Promise { - const msg = await redeemOnTerra( - tokenBridgeAddress, - TERRA_REDEEMED_CHECK_WALLET_ADDRESS, - signedVAA - ); - // TODO: remove gasPriceUrl and just use the client's gas prices - const gasPrices = await axios.get(gasPriceUrl).then((result) => result.data); - const account = await client.auth.accountInfo( - TERRA_REDEEMED_CHECK_WALLET_ADDRESS - ); - try { - await client.tx.estimateFee( - [ - { - sequenceNumber: account.getSequenceNumber(), - publicKey: account.getPublicKey(), - }, - ], - { - msgs: [msg], - memo: "already redeemed calculation", - feeDenoms: ["uluna"], - gasPrices, - } - ); - } catch (e: any) { - // redeemed if the VAA was already executed - return e.response.data.message.includes("VaaAlreadyExecuted"); - } - return false; -} - -export async function getIsTransferCompletedSolana( - tokenBridgeAddress: string, - signedVAA: Uint8Array, - connection: Connection -): Promise { - const { claim_address } = await importCoreWasm(); - const claimAddress = await claim_address(tokenBridgeAddress, signedVAA); - const claimInfo = await connection.getAccountInfo( - new PublicKey(claimAddress), - "confirmed" - ); - return !!claimInfo; -} - -// Algorand - -/** - * This function is used to check if a VAA has been redeemed by looking at a specific bit. - * @param client AlgodV2 client - * @param appId Application Id - * @param addr Wallet address. Someone has to pay for this. - * @param seq The sequence number of the redemption - * @returns true, if the bit was set and VAA was redeemed, false otherwise. - */ -async function checkBitsSet( - client: Algodv2, - appId: bigint, - addr: string, - seq: bigint -): Promise { - let retval: boolean = false; - let appState: any[] = []; - const acctInfo = await client.accountInformation(addr).do(); - const als = acctInfo["apps-local-state"]; - als.forEach((app: any) => { - if (BigInt(app["id"]) === appId) { - appState = app["key-value"]; - } - }); - if (appState.length === 0) { - return retval; - } - - const BIG_MAX_BITS: bigint = BigInt(MAX_BITS); - const BIG_EIGHT: bigint = BigInt(8); - // Start on a MAX_BITS boundary - const start: bigint = (seq / BIG_MAX_BITS) * BIG_MAX_BITS; - // beg should be in the range [0..MAX_BITS] - const beg: number = safeBigIntToNumber(seq - start); - // s should be in the range [0..15] - const s: number = Math.floor(beg / BITS_PER_KEY); - const b: number = Math.floor((beg - s * BITS_PER_KEY) / 8); - - const key = Buffer.from(bigIntToBytes(s, 1)).toString("base64"); - appState.forEach((kv) => { - if (kv["key"] === key) { - const v = Buffer.from(kv["value"]["bytes"], "base64"); - const bt = 1 << safeBigIntToNumber(seq % BIG_EIGHT); - retval = (v[b] & bt) != 0; - return; - } - }); - return retval; -} - -/** - *

Returns true if this transfer was completed on Algorand

- * @param client AlgodV2 client - * @param appId Most likely the Token bridge ID - * @param signedVAA VAA to check - * @param wallet The account paying the bill for this (it isn't free) - * @returns true if VAA has been redeemed, false otherwise - */ -export async function getIsTransferCompletedAlgorand( - client: Algodv2, - appId: bigint, - signedVAA: Uint8Array -): Promise { - const parsedVAA = _parseVAAAlgorand(signedVAA); - const seq: bigint = parsedVAA.sequence; - const chainRaw: string = parsedVAA.chainRaw; // this needs to be a hex string - const em: string = parsedVAA.emitter; // this needs to be a hex string - const { doesExist, lsa } = await calcLogicSigAccount( - client, - appId, - seq / BigInt(MAX_BITS), - chainRaw + em - ); - if (!doesExist) { - return false; - } - const seqAddr = lsa.address(); - const retVal: boolean = await checkBitsSet(client, appId, seqAddr, seq); - return retVal; -} diff --git a/sdk/js/src/token_bridge/getIsWrappedAsset.ts b/sdk/js/src/token_bridge/getIsWrappedAsset.ts index 6d1bcfb95..5c742d719 100644 --- a/sdk/js/src/token_bridge/getIsWrappedAsset.ts +++ b/sdk/js/src/token_bridge/getIsWrappedAsset.ts @@ -1,10 +1,5 @@ -import { Connection, PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import { Algodv2, getApplicationAddress } from "algosdk"; import { ethers } from "ethers"; import { Bridge__factory } from "../ethers-contracts"; -import { importTokenWasm } from "../solana/wasm"; -import { safeBigIntToNumber } from "../utils/bigint"; /** * Returns whether or not an asset address on Ethereum is a wormhole wrapped asset @@ -22,60 +17,3 @@ export async function getIsWrappedAssetEth( const tokenBridge = Bridge__factory.connect(tokenBridgeAddress, provider); return await tokenBridge.isWrappedAsset(assetAddress); } - -// TODO: this doesn't seem right -export async function getIsWrappedAssetTerra( - tokenBridgeAddress: string, - client: LCDClient, - assetAddress: string -): Promise { - return false; -} - -/** - * Returns whether or not an asset on Solana is a wormhole wrapped asset - * @param connection - * @param tokenBridgeAddress - * @param mintAddress - * @returns - */ -export async function getIsWrappedAssetSol( - connection: Connection, - tokenBridgeAddress: string, - mintAddress: string -): Promise { - if (!mintAddress) return false; - const { wrapped_meta_address } = await importTokenWasm(); - const wrappedMetaAddress = wrapped_meta_address( - tokenBridgeAddress, - new PublicKey(mintAddress).toBytes() - ); - const wrappedMetaAddressPK = new PublicKey(wrappedMetaAddress); - const wrappedMetaAccountInfo = await connection.getAccountInfo( - wrappedMetaAddressPK - ); - return !!wrappedMetaAccountInfo; -} - -/** - * Returns whethor or not an asset on Algorand is a wormhole wrapped asset - * @param client Algodv2 client - * @param tokenBridgeId token bridge ID - * @param assetId Algorand asset index - * @returns true if the asset is wrapped - */ -export async function getIsWrappedAssetAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - assetId: bigint -): Promise { - if (assetId === BigInt(0)) { - return false; - } - const tbAddr: string = getApplicationAddress(tokenBridgeId); - const assetInfo = await client.getAssetByID(safeBigIntToNumber(assetId)).do(); - const creatorAddr = assetInfo.params.creator; - const creatorAcctInfo = await client.accountInformation(creatorAddr).do(); - const wormhole: boolean = creatorAcctInfo["auth-addr"] === tbAddr; - return wormhole; -} diff --git a/sdk/js/src/token_bridge/getOriginalAsset.ts b/sdk/js/src/token_bridge/getOriginalAsset.ts index 857fe8f84..85d5bff21 100644 --- a/sdk/js/src/token_bridge/getOriginalAsset.ts +++ b/sdk/js/src/token_bridge/getOriginalAsset.ts @@ -1,26 +1,8 @@ -import { Connection, PublicKey } from "@solana/web3.js"; -import { LCDClient } from "@terra-money/terra.js"; -import { Algodv2 } from "algosdk"; import { ethers } from "ethers"; import { arrayify, zeroPad } from "ethers/lib/utils"; -import { decodeLocalState } from "../algorand"; import { TokenImplementation__factory } from "../ethers-contracts"; -import { importTokenWasm } from "../solana/wasm"; -import { buildNativeId, canonicalAddress, isNativeDenom } from "../terra"; -import { - ChainId, - ChainName, - CHAIN_ID_ALGORAND, - CHAIN_ID_SOLANA, - CHAIN_ID_TERRA, - coalesceChainId, - hexToUint8Array, -} from "../utils"; -import { safeBigIntToNumber } from "../utils/bigint"; -import { - getIsWrappedAssetAlgorand, - getIsWrappedAssetEth, -} from "./getIsWrappedAsset"; +import { ChainId, ChainName, coalesceChainId } from "../utils"; +import { getIsWrappedAssetEth } from "./getIsWrappedAsset"; // TODO: remove `as ChainId` and return number in next minor version as we can't ensure it will match our type definition export interface WormholeWrappedInfo { @@ -66,121 +48,3 @@ export async function getOriginalAssetEth( assetAddress: zeroPad(arrayify(wrappedAddress), 32), }; } - -export async function getOriginalAssetTerra( - client: LCDClient, - wrappedAddress: string -): Promise { - if (isNativeDenom(wrappedAddress)) { - return { - isWrapped: false, - chainId: CHAIN_ID_TERRA, - assetAddress: buildNativeId(wrappedAddress), - }; - } - try { - const result: { - asset_address: string; - asset_chain: ChainId; - bridge: string; - } = await client.wasm.contractQuery(wrappedAddress, { - wrapped_asset_info: {}, - }); - if (result) { - return { - isWrapped: true, - chainId: result.asset_chain, - assetAddress: new Uint8Array( - Buffer.from(result.asset_address, "base64") - ), - }; - } - } catch (e) {} - return { - isWrapped: false, - chainId: CHAIN_ID_TERRA, - assetAddress: zeroPad(canonicalAddress(wrappedAddress), 32), - }; -} - -/** - * Returns a origin chain and asset address on {originChain} for a provided Wormhole wrapped address - * @param connection - * @param tokenBridgeAddress - * @param mintAddress - * @returns - */ -export async function getOriginalAssetSol( - connection: Connection, - tokenBridgeAddress: string, - mintAddress: string -): Promise { - if (mintAddress) { - // TODO: share some of this with getIsWrappedAssetSol, like a getWrappedMetaAccountAddress or something - const { parse_wrapped_meta, wrapped_meta_address } = - await importTokenWasm(); - const wrappedMetaAddress = wrapped_meta_address( - tokenBridgeAddress, - new PublicKey(mintAddress).toBytes() - ); - const wrappedMetaAddressPK = new PublicKey(wrappedMetaAddress); - const wrappedMetaAccountInfo = await connection.getAccountInfo( - wrappedMetaAddressPK - ); - if (wrappedMetaAccountInfo) { - const parsed = parse_wrapped_meta(wrappedMetaAccountInfo.data); - return { - isWrapped: true, - chainId: parsed.chain, - assetAddress: parsed.token_address, - }; - } - } - try { - return { - isWrapped: false, - chainId: CHAIN_ID_SOLANA, - assetAddress: new PublicKey(mintAddress).toBytes(), - }; - } catch (e) {} - return { - isWrapped: false, - chainId: CHAIN_ID_SOLANA, - assetAddress: new Uint8Array(32), - }; -} - -/** - * Returns an origin chain and asset address on {originChain} for a provided Wormhole wrapped address - * @param client Algodv2 client - * @param tokenBridgeId Application ID of the token bridge - * @param assetId Algorand asset index - * @returns wrapped wormhole information structure - */ -export async function getOriginalAssetAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - assetId: bigint -): Promise { - let retVal: WormholeWrappedInfo = { - isWrapped: false, - chainId: CHAIN_ID_ALGORAND, - assetAddress: new Uint8Array(), - }; - retVal.isWrapped = await getIsWrappedAssetAlgorand( - client, - tokenBridgeId, - assetId - ); - if (!retVal.isWrapped) { - retVal.assetAddress = zeroPad(arrayify(ethers.BigNumber.from(assetId)), 32); - return retVal; - } - const assetInfo = await client.getAssetByID(safeBigIntToNumber(assetId)).do(); - const lsa = assetInfo.params.creator; - const dls = await decodeLocalState(client, tokenBridgeId, lsa); - const dlsBuffer: Buffer = Buffer.from(dls); - retVal.chainId = dlsBuffer.readInt16BE(92) as ChainId; - retVal.assetAddress = new Uint8Array(dlsBuffer.slice(60, 60 + 32)); - return retVal; -} diff --git a/sdk/js/src/token_bridge/redeem.ts b/sdk/js/src/token_bridge/redeem.ts index 8d8253253..7fd82018a 100644 --- a/sdk/js/src/token_bridge/redeem.ts +++ b/sdk/js/src/token_bridge/redeem.ts @@ -1,31 +1,10 @@ import { binToHex, DUST_AMOUNT, ExecuteScriptResult, SignerProvider } from "@alephium/web3"; -import { AccountLayout, Token, TOKEN_PROGRAM_ID, u64 } from "@solana/spl-token"; -import { - Connection, - Keypair, - PublicKey, - SystemProgram, - Transaction, -} from "@solana/web3.js"; -import { MsgExecuteContract } from "@terra-money/terra.js"; -import { Algodv2 } from "algosdk"; import { ethers, Overrides } from "ethers"; -import { fromUint8Array } from "js-base64"; import { CompleteTransfer, CompleteTransferWithReward } from "../alephium-contracts/ts/scripts"; -import { TransactionSignerPair, _submitVAAAlgorand } from "../algorand"; import { Bridge__factory } from "../ethers-contracts"; -import { ixFromRust } from "../solana"; -import { importCoreWasm, importTokenWasm } from "../solana/wasm"; -import { - CHAIN_ID_SOLANA, - WSOL_ADDRESS, - WSOL_DECIMALS, - MAX_VAA_DECIMALS, - CHAIN_ID_BSC, - CHAIN_ID_ALEPHIUM, -} from "../utils"; -import { hexToNativeString, tryUint8ArrayToNative, uint8ArrayToHex } from "../utils/array"; -import { deserializeTransferTokenVAA, TransferToken, VAA } from "../utils/vaa"; +import { CHAIN_ID_BSC, CHAIN_ID_ALEPHIUM } from "../utils"; +import { tryUint8ArrayToNative } from "../utils/array"; +import { TransferToken, VAA } from "../utils/vaa"; export async function redeemOnAlphWithReward( signerProvider: SignerProvider, @@ -106,173 +85,3 @@ export async function redeemOnEthNative( const receipt = await v.wait(); return receipt; } - -export async function redeemOnTerra( - tokenBridgeAddress: string, - walletAddress: string, - signedVAA: Uint8Array -) { - return new MsgExecuteContract(walletAddress, tokenBridgeAddress, { - submit_vaa: { - data: fromUint8Array(signedVAA), - }, - }); -} - -export async function redeemAndUnwrapOnSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - signedVAA: Uint8Array -) { - const { complete_transfer_native_ix } = await importTokenWasm(); - const parsedVAA = deserializeTransferTokenVAA(signedVAA) - const parsedPayload = parsedVAA.body.payload - const targetAddress = hexToNativeString( - uint8ArrayToHex(parsedPayload.targetAddress), - CHAIN_ID_SOLANA - ); - if (!targetAddress) { - throw new Error("Failed to read the target address."); - } - const targetPublicKey = new PublicKey(targetAddress); - const targetAmount = - parsedPayload.amount * - BigInt(WSOL_DECIMALS - MAX_VAA_DECIMALS) * - BigInt(10); - const rentBalance = await Token.getMinBalanceRentForExemptAccount(connection); - const mintPublicKey = new PublicKey(WSOL_ADDRESS); - const payerPublicKey = new PublicKey(payerAddress); - const ancillaryKeypair = Keypair.generate(); - - const completeTransferIx = ixFromRust( - complete_transfer_native_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - signedVAA - ) - ); - - //This will create a temporary account where the wSOL will be moved - const createAncillaryAccountIx = SystemProgram.createAccount({ - fromPubkey: payerPublicKey, - newAccountPubkey: ancillaryKeypair.publicKey, - lamports: rentBalance, //spl token accounts need rent exemption - space: AccountLayout.span, - programId: TOKEN_PROGRAM_ID, - }); - - //Initialize the account as a WSOL account, with the original payerAddress as owner - const initAccountIx = await Token.createInitAccountInstruction( - TOKEN_PROGRAM_ID, - mintPublicKey, - ancillaryKeypair.publicKey, - payerPublicKey - ); - - //Send in the amount of wSOL which we want converted to SOL - const balanceTransferIx = Token.createTransferInstruction( - TOKEN_PROGRAM_ID, - targetPublicKey, - ancillaryKeypair.publicKey, - payerPublicKey, - [], - new u64(targetAmount.toString(16), 16) - ); - - //Close the ancillary account for cleanup. Payer address receives any remaining funds - const closeAccountIx = Token.createCloseAccountInstruction( - TOKEN_PROGRAM_ID, - ancillaryKeypair.publicKey, //account to close - payerPublicKey, //Remaining funds destination - payerPublicKey, //authority - [] - ); - - const { blockhash } = await connection.getRecentBlockhash(); - const transaction = new Transaction(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - transaction.add(completeTransferIx); - transaction.add(createAncillaryAccountIx); - transaction.add(initAccountIx); - transaction.add(balanceTransferIx); - transaction.add(closeAccountIx); - transaction.partialSign(ancillaryKeypair); - return transaction; -} - -export async function redeemOnSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - signedVAA: Uint8Array, - feeRecipientAddress?: string -) { - const { parse_vaa } = await importCoreWasm(); - const parsedVAA = parse_vaa(signedVAA); - const isSolanaNative = - Buffer.from(new Uint8Array(parsedVAA.payload)).readUInt16BE(65) === - CHAIN_ID_SOLANA; - const { complete_transfer_wrapped_ix, complete_transfer_native_ix } = - await importTokenWasm(); - const ixs = []; - if (isSolanaNative) { - ixs.push( - ixFromRust( - complete_transfer_native_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - signedVAA, - feeRecipientAddress - ) - ) - ); - } else { - ixs.push( - ixFromRust( - complete_transfer_wrapped_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - signedVAA, - feeRecipientAddress - ) - ) - ); - } - const transaction = new Transaction().add(...ixs); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - return transaction; -} - -/** - * This basically just submits the VAA to Algorand - * @param client AlgodV2 client - * @param tokenBridgeId Token bridge ID - * @param bridgeId Core bridge ID - * @param vaa The VAA to be redeemed - * @param acct Sending account - * @returns Transaction ID(s) - */ -export async function redeemOnAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - bridgeId: bigint, - vaa: Uint8Array, - senderAddr: string -): Promise { - return await _submitVAAAlgorand( - client, - tokenBridgeId, - bridgeId, - vaa, - senderAddr - ); -} diff --git a/sdk/js/src/token_bridge/transfer.ts b/sdk/js/src/token_bridge/transfer.ts index ccb035ab3..0178ab3f6 100644 --- a/sdk/js/src/token_bridge/transfer.ts +++ b/sdk/js/src/token_bridge/transfer.ts @@ -1,50 +1,18 @@ import { ALPH_TOKEN_ID, DUST_AMOUNT, ExecuteScriptResult, SignerProvider } from "@alephium/web3"; -import { AccountLayout, Token, TOKEN_PROGRAM_ID, u64 } from "@solana/spl-token"; -import { - Connection, - Keypair, - PublicKey, - SystemProgram, - Transaction as SolanaTransaction, -} from "@solana/web3.js"; -import { MsgExecuteContract } from "@terra-money/terra.js"; -import { - Algodv2, - bigIntToBytes, - getApplicationAddress, - makeApplicationCallTxnFromObject, - makeAssetTransferTxnWithSuggestedParamsFromObject, - makePaymentTxnWithSuggestedParamsFromObject, - OnApplicationComplete, - SuggestedParams, - Transaction as AlgorandTransaction, -} from "algosdk"; -import { BigNumber, ethers, Overrides, PayableOverrides } from "ethers"; -import { isNativeDenom } from ".."; +import { ethers, Overrides, PayableOverrides } from "ethers"; import { TransferLocal, TransferRemote } from "../alephium-contracts/ts/scripts"; -import { - assetOptinCheck, - getMessageFee, - optin, - TransactionSignerPair, -} from "../algorand"; -import { getEmitterAddressAlgorand } from "../bridge"; import { Bridge__factory, TokenImplementation__factory, } from "../ethers-contracts"; -import { getBridgeFeeIx, ixFromRust } from "../solana"; -import { importTokenWasm } from "../solana/wasm"; import { ChainId, ChainName, CHAIN_ID_ALEPHIUM, - CHAIN_ID_SOLANA, coalesceChainId, createNonce, hexToUint8Array, - textToUint8Array, - WSOL_ADDRESS, + textToUint8Array } from "../utils"; import { safeBigIntToNumber } from "../utils/bigint"; @@ -191,487 +159,3 @@ export async function transferFromEthNative( const receipt = await v.wait(); return receipt; } - -export async function transferFromTerra( - walletAddress: string, - tokenBridgeAddress: string, - tokenAddress: string, - amount: string, - recipientChain: ChainId | ChainName, - recipientAddress: Uint8Array, - relayerFee: string = "0", - payload: Uint8Array | null = null -) { - const recipientChainId = coalesceChainId(recipientChain); - const nonce = Math.round(Math.random() * 100000); - const isNativeAsset = isNativeDenom(tokenAddress); - const mk_initiate_transfer = (info: object) => - payload - ? { - initiate_transfer_with_payload: { - asset: { - amount, - info, - }, - recipient_chain: recipientChainId, - recipient: Buffer.from(recipientAddress).toString("base64"), - fee: relayerFee, - nonce: nonce, - payload: payload, - }, - } - : { - initiate_transfer: { - asset: { - amount, - info, - }, - recipient_chain: recipientChainId, - recipient: Buffer.from(recipientAddress).toString("base64"), - fee: relayerFee, - nonce: nonce, - }, - }; - return isNativeAsset - ? [ - new MsgExecuteContract( - walletAddress, - tokenBridgeAddress, - { - deposit_tokens: {}, - }, - { [tokenAddress]: amount } - ), - new MsgExecuteContract( - walletAddress, - tokenBridgeAddress, - mk_initiate_transfer({ - native_token: { - denom: tokenAddress, - }, - }), - {} - ), - ] - : [ - new MsgExecuteContract( - walletAddress, - tokenAddress, - { - increase_allowance: { - spender: tokenBridgeAddress, - amount: amount, - expires: { - never: {}, - }, - }, - }, - {} - ), - new MsgExecuteContract( - walletAddress, - tokenBridgeAddress, - mk_initiate_transfer({ - token: { - contract_addr: tokenAddress, - }, - }), - {} - ), - ]; -} - -export async function transferNativeSol( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - amount: BigInt, - targetAddress: Uint8Array, - targetChain: ChainId | ChainName, - relayerFee: BigInt = BigInt(0), - payload: Uint8Array | null = null -) { - //https://github.com/solana-labs/solana-program-library/blob/master/token/js/client/token.js - const rentBalance = await Token.getMinBalanceRentForExemptAccount(connection); - const mintPublicKey = new PublicKey(WSOL_ADDRESS); - const payerPublicKey = new PublicKey(payerAddress); - const ancillaryKeypair = Keypair.generate(); - - //This will create a temporary account where the wSOL will be created. - const createAncillaryAccountIx = SystemProgram.createAccount({ - fromPubkey: payerPublicKey, - newAccountPubkey: ancillaryKeypair.publicKey, - lamports: rentBalance, //spl token accounts need rent exemption - space: AccountLayout.span, - programId: TOKEN_PROGRAM_ID, - }); - - //Send in the amount of SOL which we want converted to wSOL - const initialBalanceTransferIx = SystemProgram.transfer({ - fromPubkey: payerPublicKey, - lamports: Number(amount), - toPubkey: ancillaryKeypair.publicKey, - }); - //Initialize the account as a WSOL account, with the original payerAddress as owner - const initAccountIx = await Token.createInitAccountInstruction( - TOKEN_PROGRAM_ID, - mintPublicKey, - ancillaryKeypair.publicKey, - payerPublicKey - ); - - //Normal approve & transfer instructions, except that the wSOL is sent from the ancillary account. - const { - transfer_native_ix, - transfer_native_with_payload_ix, - approval_authority_address, - } = await importTokenWasm(); - const nonce = createNonce().readUInt32LE(0); - const transferIx = await getBridgeFeeIx( - connection, - bridgeAddress, - payerAddress - ); - const approvalIx = Token.createApproveInstruction( - TOKEN_PROGRAM_ID, - ancillaryKeypair.publicKey, - new PublicKey(approval_authority_address(tokenBridgeAddress)), - payerPublicKey, //owner - [], - new u64(amount.toString(16), 16) - ); - let messageKey = Keypair.generate(); - - const ix = ixFromRust( - payload !== null - ? transfer_native_with_payload_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - ancillaryKeypair.publicKey.toString(), - WSOL_ADDRESS, - nonce, - amount.valueOf(), - relayerFee.valueOf(), - targetAddress, - coalesceChainId(targetChain), - payload - ) - : transfer_native_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - ancillaryKeypair.publicKey.toString(), - WSOL_ADDRESS, - nonce, - amount.valueOf(), - relayerFee.valueOf(), - targetAddress, - coalesceChainId(targetChain) - ) - ); - - //Close the ancillary account for cleanup. Payer address receives any remaining funds - const closeAccountIx = Token.createCloseAccountInstruction( - TOKEN_PROGRAM_ID, - ancillaryKeypair.publicKey, //account to close - payerPublicKey, //Remaining funds destination - payerPublicKey, //authority - [] - ); - - const { blockhash } = await connection.getRecentBlockhash(); - const transaction = new SolanaTransaction(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - transaction.add(createAncillaryAccountIx); - transaction.add(initialBalanceTransferIx); - transaction.add(initAccountIx); - transaction.add(transferIx, approvalIx, ix); - transaction.add(closeAccountIx); - transaction.partialSign(messageKey); - transaction.partialSign(ancillaryKeypair); - return transaction; -} - -export async function transferFromSolana( - connection: Connection, - bridgeAddress: string, - tokenBridgeAddress: string, - payerAddress: string, - fromAddress: string, - mintAddress: string, - amount: BigInt, - targetAddress: Uint8Array, - targetChain: ChainId | ChainName, - originAddress?: Uint8Array, - originChain?: ChainId | ChainName, - fromOwnerAddress?: string, - relayerFee: BigInt = BigInt(0), - payload: Uint8Array | null = null -) { - const originChainId: ChainId | undefined = originChain - ? coalesceChainId(originChain) - : undefined; - const nonce = createNonce().readUInt32LE(0); - const transferIx = await getBridgeFeeIx( - connection, - bridgeAddress, - payerAddress - ); - const { - transfer_native_ix, - transfer_wrapped_ix, - transfer_native_with_payload_ix, - transfer_wrapped_with_payload_ix, - approval_authority_address, - } = await importTokenWasm(); - const approvalIx = Token.createApproveInstruction( - TOKEN_PROGRAM_ID, - new PublicKey(fromAddress), - new PublicKey(approval_authority_address(tokenBridgeAddress)), - new PublicKey(fromOwnerAddress || payerAddress), - [], - new u64(amount.toString(16), 16) - ); - let messageKey = Keypair.generate(); - const isSolanaNative = - originChainId === undefined || originChainId === CHAIN_ID_SOLANA; - if (!isSolanaNative && !originAddress) { - throw new Error("originAddress is required when specifying originChain"); - } - const ix = ixFromRust( - isSolanaNative - ? payload !== null - ? transfer_native_with_payload_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - fromAddress, - mintAddress, - nonce, - amount.valueOf(), - relayerFee.valueOf(), - targetAddress, - coalesceChainId(targetChain), - payload - ) - : transfer_native_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - fromAddress, - mintAddress, - nonce, - amount.valueOf(), - relayerFee.valueOf(), - targetAddress, - coalesceChainId(targetChain) - ) - : payload !== null - ? transfer_wrapped_with_payload_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - fromAddress, - fromOwnerAddress || payerAddress, - originChainId as number, // checked by isSolanaNative - originAddress as Uint8Array, // checked by throw - nonce, - amount.valueOf(), - relayerFee.valueOf(), - targetAddress, - coalesceChainId(targetChain), - payload - ) - : transfer_wrapped_ix( - tokenBridgeAddress, - bridgeAddress, - payerAddress, - messageKey.publicKey.toString(), - fromAddress, - fromOwnerAddress || payerAddress, - originChainId as number, // checked by isSolanaNative - originAddress as Uint8Array, // checked by throw - nonce, - amount.valueOf(), - relayerFee.valueOf(), - targetAddress, - coalesceChainId(targetChain) - ) - ); - const transaction = new SolanaTransaction().add(transferIx, approvalIx, ix); - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payerAddress); - transaction.partialSign(messageKey); - return transaction; -} - -/** - * Transfers an asset from Algorand to a receiver on another chain - * @param client AlgodV2 client - * @param tokenBridgeId Application ID of the token bridge - * @param bridgeId Application ID of the core bridge - * @param sender Sending account - * @param assetId Asset index - * @param qty Quantity to transfer - * @param receiver Receiving account - * @param chain Reeiving chain - * @param fee Transfer fee - * @param payload payload for payload3 transfers - * @returns Sequence number of confirmation - */ -export async function transferFromAlgorand( - client: Algodv2, - tokenBridgeId: bigint, - bridgeId: bigint, - senderAddr: string, - assetId: bigint, - qty: bigint, - receiver: string, - chain: ChainId | ChainName, - fee: bigint, - payload: Uint8Array | null = null -): Promise { - const recipientChainId = coalesceChainId(chain); - const tokenAddr: string = getApplicationAddress(tokenBridgeId); - const applAddr: string = getEmitterAddressAlgorand(tokenBridgeId); - const txs: TransactionSignerPair[] = []; - // "transferAsset" - const { addr: emitterAddr, txs: emitterOptInTxs } = await optin( - client, - senderAddr, - bridgeId, - BigInt(0), - applAddr - ); - txs.push(...emitterOptInTxs); - let creator; - let creatorAcctInfo: any; - let wormhole: boolean = false; - if (assetId !== BigInt(0)) { - const assetInfo: Record = await client - .getAssetByID(safeBigIntToNumber(assetId)) - .do(); - creator = assetInfo["params"]["creator"]; - creatorAcctInfo = await client.accountInformation(creator).do(); - const authAddr: string = creatorAcctInfo["auth-addr"]; - if (authAddr === tokenAddr) { - wormhole = true; - } - } - - const params: SuggestedParams = await client.getTransactionParams().do(); - const msgFee: bigint = await getMessageFee(client, bridgeId); - if (msgFee > 0) { - const payTxn: AlgorandTransaction = - makePaymentTxnWithSuggestedParamsFromObject({ - from: senderAddr, - suggestedParams: params, - to: getApplicationAddress(tokenBridgeId), - amount: msgFee, - }); - txs.push({ tx: payTxn, signer: null }); - } - if (!wormhole) { - const bNat = Buffer.from("native", "binary").toString("hex"); - // "creator" - const result = await optin( - client, - senderAddr, - tokenBridgeId, - assetId, - bNat - ); - creator = result.addr; - txs.push(...result.txs); - } - if ( - assetId !== BigInt(0) && - !(await assetOptinCheck(client, assetId, creator)) - ) { - // Looks like we need to optin - const payTxn: AlgorandTransaction = - makePaymentTxnWithSuggestedParamsFromObject({ - from: senderAddr, - to: creator, - amount: 100000, - suggestedParams: params, - }); - txs.push({ tx: payTxn, signer: null }); - // The tokenid app needs to do the optin since it has signature authority - const bOptin: Uint8Array = textToUint8Array("optin"); - let txn = makeApplicationCallTxnFromObject({ - from: senderAddr, - appIndex: safeBigIntToNumber(tokenBridgeId), - onComplete: OnApplicationComplete.NoOpOC, - appArgs: [bOptin, bigIntToBytes(assetId, 8)], - foreignAssets: [safeBigIntToNumber(assetId)], - accounts: [creator], - suggestedParams: params, - }); - txn.fee *= 2; - txs.push({ tx: txn, signer: null }); - } - const t = makeApplicationCallTxnFromObject({ - from: senderAddr, - appIndex: safeBigIntToNumber(tokenBridgeId), - onComplete: OnApplicationComplete.NoOpOC, - appArgs: [textToUint8Array("nop")], - suggestedParams: params, - }); - txs.push({ tx: t, signer: null }); - - let accounts: string[] = []; - if (assetId === BigInt(0)) { - const t = makePaymentTxnWithSuggestedParamsFromObject({ - from: senderAddr, - to: creator, - amount: qty, - suggestedParams: params, - }); - txs.push({ tx: t, signer: null }); - accounts = [emitterAddr, creator, creator]; - } else { - const t = makeAssetTransferTxnWithSuggestedParamsFromObject({ - from: senderAddr, - to: creator, - suggestedParams: params, - amount: qty, - assetIndex: safeBigIntToNumber(assetId), - }); - txs.push({ tx: t, signer: null }); - accounts = [emitterAddr, creator, creatorAcctInfo["address"]]; - } - let args = [ - textToUint8Array("sendTransfer"), - bigIntToBytes(assetId, 8), - bigIntToBytes(qty, 8), - hexToUint8Array(receiver), - bigIntToBytes(recipientChainId, 8), - bigIntToBytes(fee, 8), - ]; - if (payload !== null) { - args.push(payload); - } - let acTxn = makeApplicationCallTxnFromObject({ - from: senderAddr, - appIndex: safeBigIntToNumber(tokenBridgeId), - onComplete: OnApplicationComplete.NoOpOC, - appArgs: args, - foreignApps: [safeBigIntToNumber(bridgeId)], - foreignAssets: [safeBigIntToNumber(assetId)], - accounts: accounts, - suggestedParams: params, - }); - acTxn.fee *= 2; - txs.push({ tx: acTxn, signer: null }); - return txs; -} diff --git a/sdk/js/src/token_bridge/updateWrapped.ts b/sdk/js/src/token_bridge/updateWrapped.ts index 3e6b9db01..2dbceaedc 100644 --- a/sdk/js/src/token_bridge/updateWrapped.ts +++ b/sdk/js/src/token_bridge/updateWrapped.ts @@ -1,10 +1,5 @@ import { binToHex, ExecuteScriptResult, SignerProvider } from "@alephium/web3"; import { ethers, Overrides } from "ethers"; -import { - createWrappedOnAlgorand, - createWrappedOnSolana, - createWrappedOnTerra, -} from "."; import { UpdateRemoteTokenPool } from "../alephium-contracts/ts/scripts"; import { Bridge__factory } from "../ethers-contracts"; @@ -32,9 +27,3 @@ export async function updateWrappedOnEth( const receipt = await v.wait(); return receipt; } - -export const updateWrappedOnTerra = createWrappedOnTerra; - -export const updateWrappedOnSolana = createWrappedOnSolana; - -export const updateWrappedOnAlgorand = createWrappedOnAlgorand; diff --git a/sdk/js/src/utils/array.ts b/sdk/js/src/utils/array.ts index 4c70b351b..c5fc60439 100644 --- a/sdk/js/src/utils/array.ts +++ b/sdk/js/src/utils/array.ts @@ -1,23 +1,16 @@ import { arrayify, zeroPad } from "@ethersproject/bytes"; -import { PublicKey } from "@solana/web3.js"; import { hexValue, hexZeroPad, stripZeros } from "ethers/lib/utils"; -import { - hexToNativeAssetStringAlgorand, - nativeStringToHexAlgorand, - uint8ArrayToNativeStringAlgorand, -} from "../algorand"; -import { canonicalAddress, humanAddress, isNativeDenom } from "../terra"; import { ChainId, ChainName, CHAIN_ID_ALEPHIUM, CHAIN_ID_ALGORAND, CHAIN_ID_NEAR, - CHAIN_ID_SOLANA, CHAIN_ID_TERRA, CHAIN_ID_UNSET, coalesceChainId, isEVMChain, + CHAIN_ID_SOLANA, } from "./consts"; /** @@ -64,16 +57,11 @@ export const tryUint8ArrayToNative = ( if (isEVMChain(chainId)) { return hexZeroPad(hexValue(a), 20); } else if (chainId === CHAIN_ID_SOLANA) { - return new PublicKey(a).toString(); + throw new Error(`Not supported`) } else if (chainId === CHAIN_ID_TERRA) { - const h = uint8ArrayToHex(a); - if (isHexNativeTerra(h)) { - return nativeTerraHexToDenom(h); - } else { - return humanAddress(a.slice(-20)); // terra expects 20 bytes, not 32 - } + throw new Error(`Not supported`) } else if (chainId === CHAIN_ID_ALGORAND) { - return uint8ArrayToNativeStringAlgorand(a); + throw new Error(`Not supported`) } else if (chainId === CHAIN_ID_NEAR) { throw Error("uint8ArrayToNative: Near not supported yet."); } else if (chainId === CHAIN_ID_ALEPHIUM) { @@ -94,11 +82,12 @@ export const tryUint8ArrayToNative = ( * * @throws if address is not the right length for the given chain */ -export const tryHexToNativeAssetString = (h: string, c: ChainId): string => - c === CHAIN_ID_ALGORAND - ? // Algorand assets are represented by their asset ids, not an address - hexToNativeAssetStringAlgorand(h) - : tryHexToNativeString(h, c); +export const tryHexToNativeAssetString = (h: string, c: ChainId): string => { + if (c === CHAIN_ID_ALGORAND) { + throw new Error(`Not supported`) + } + return tryHexToNativeString(h, c); +} /** * @@ -170,20 +159,11 @@ export const tryNativeToHexString = ( if (isEVMChain(chainId)) { return uint8ArrayToHex(zeroPad(arrayify(address), 32)); } else if (chainId === CHAIN_ID_SOLANA) { - return uint8ArrayToHex(zeroPad(new PublicKey(address).toBytes(), 32)); + throw new Error(`Not supported`) } else if (chainId === CHAIN_ID_TERRA) { - if (isNativeDenom(address)) { - return ( - "01" + - uint8ArrayToHex( - zeroPad(new Uint8Array(Buffer.from(address, "ascii")), 31) - ) - ); - } else { - return uint8ArrayToHex(zeroPad(canonicalAddress(address), 32)); - } + throw new Error(`Not supported`) } else if (chainId === CHAIN_ID_ALGORAND) { - return nativeStringToHexAlgorand(address); + throw new Error(`Not supported`) } else if (chainId === CHAIN_ID_NEAR) { throw Error("hexToNativeString: Near not supported yet."); } else if (chainId === CHAIN_ID_ALEPHIUM) { diff --git a/sdk/js/src/utils/solana.ts b/sdk/js/src/utils/solana.ts deleted file mode 100644 index 53b041a9b..000000000 --- a/sdk/js/src/utils/solana.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { Connection, PublicKey, Transaction } from "@solana/web3.js"; - -/* - The transactions provided to this function should be ready to be sent. - This function will only add the feePayer and blockhash, and then sign, send, and confirm the transaction. -*/ -export async function sendAndConfirmTransactionsWithRetry( - connection: Connection, - signTransaction: (transaction: Transaction) => Promise, - payer: string, - unsignedTransactions: Transaction[], - maxRetries: number = 0 -) { - if (!(unsignedTransactions && unsignedTransactions.length)) { - return Promise.reject("No transactions provided to send."); - } - let currentRetries = 0; - let currentIndex = 0; - const transactionReceipts = []; - while ( - !(currentIndex >= unsignedTransactions.length) && - !(currentRetries > maxRetries) - ) { - let transaction = unsignedTransactions[currentIndex]; - let signed = null; - try { - const { blockhash } = await connection.getRecentBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = new PublicKey(payer); - } catch (e) { - console.error(e); - currentRetries++; - //Behavior after this is undefined, so best just to restart and try again. - continue; - } - try { - signed = await signTransaction(transaction); - } catch (e) { - //Eject here because this is most likely an intentional rejection from the user, or a genuine unrecoverable failure. - return Promise.reject("Failed to sign transaction."); - } - try { - const txid = await connection.sendRawTransaction(signed.serialize()); - const receipt = await connection.confirmTransaction(txid); - transactionReceipts.push(receipt); - currentIndex++; - } catch (e) { - console.error(e); - currentRetries++; - } - } - - if (currentRetries > maxRetries) { - return Promise.reject("Reached the maximum number of retries."); - } else { - return Promise.resolve(transactionReceipts); - } -}