From c53a4469ce05f6e655793eb269f01811d62eb61f Mon Sep 17 00:00:00 2001 From: Kozer4 Date: Mon, 12 Aug 2024 17:16:16 +0300 Subject: [PATCH] lint & prettier --- ...pprove-and-send-tx-gas-fee-with-stables.ts | 98 +++++---- .../evm/evm-build-approve-and-send-tx.ts | 86 +++++--- .../src/usage/bridge/evm/evm-build-swap-tx.ts | 83 +++++--- .../usage/bridge/evm/evm-check-allowance.ts | 73 ++++--- .../usage/bridge/evm/evm-send-full-example.ts | 81 +++++--- .../usage/bridge/solana/sol-build-send-tx.ts | 98 +++++---- .../usage/bridge/srb/srb-send-full-example.ts | 195 +++++++++++------- examples/src/usage/get-tokens-info.ts | 8 +- examples/src/utils/env.ts | 2 +- examples/src/utils/utils.ts | 2 +- examples/src/utils/web3.ts | 16 +- rest-api/src/service/sdk.service.ts | 1 - 12 files changed, 448 insertions(+), 295 deletions(-) diff --git a/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx-gas-fee-with-stables.ts b/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx-gas-fee-with-stables.ts index bd7db63..7eb7886 100644 --- a/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx-gas-fee-with-stables.ts +++ b/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx-gas-fee-with-stables.ts @@ -1,72 +1,92 @@ -import Web3 from "web3"; -import * as dotenv from "dotenv"; -import axios from "axios"; -import { getEnvVar } from "../../../utils/env"; -import { sendRawTransaction } from "../../../utils/web3"; -import { Big } from "big.js"; -import { ensure } from "../../../utils/utils"; -import { TransactionConfig } from "web3-core"; +import Web3 from 'web3'; +import * as dotenv from 'dotenv'; +import axios from 'axios'; +import { getEnvVar } from '../../../utils/env'; +import { sendRawTransaction } from '../../../utils/web3'; +import { Big } from 'big.js'; +import { ensure } from '../../../utils/utils'; +import { TransactionConfig } from 'web3-core'; -dotenv.config({ path: ".env" }); +dotenv.config({ path: '.env' }); const main = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); // sender address - const fromAddress = getEnvVar("ETH_ACCOUNT_ADDRESS"); + const fromAddress = getEnvVar('ETH_ACCOUNT_ADDRESS'); // recipient address - const toAddress = getEnvVar("POL_ACCOUNT_ADDRESS"); + const toAddress = getEnvVar('POL_ACCOUNT_ADDRESS'); // configure web3 - const web3 = new Web3(getEnvVar("WEB3_PROVIDER_URL")); - const account = web3.eth.accounts.privateKeyToAccount(getEnvVar("ETH_PRIVATE_KEY")); + const web3 = new Web3(getEnvVar('WEB3_PROVIDER_URL')); + const account = web3.eth.accounts.privateKeyToAccount( + getEnvVar('ETH_PRIVATE_KEY'), + ); web3.eth.accounts.wallet.add(account); const chains = (await axios.get(`${baseUrl}/chains`)).data; const sourceChain = chains['ETH']; - const sourceTokenInfo = ensure(sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const sourceTokenInfo = ensure( + sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === 'USDC'), + ); const destinationChain = chains['POL']; - const destinationTokenInfo = ensure(destinationChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const destinationTokenInfo = ensure( + destinationChain.tokens.find( + (tokenInfo: any) => tokenInfo.symbol === 'USDC', + ), + ); - const amountToSendInt = parseFloat("5") * (10 ** sourceTokenInfo.decimals); - const gasFeeOptions = (await axios.get( - `${baseUrl}/gas/fee` - + `?sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfo.tokenAddress}` - + `&messenger=ALLBRIDGE` - )).data; + const amountToSendInt = parseFloat('5') * 10 ** sourceTokenInfo.decimals; + const gasFeeOptions = ( + await axios.get( + `${baseUrl}/gas/fee` + + `?sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfo.tokenAddress}` + + `&messenger=ALLBRIDGE`, + ) + ).data; const gasFeeAmount = ensure(gasFeeOptions['stablecoin']); // authorize the bridge to transfer tokens from sender's address - const rawTransactionApprove = await axios.get(`${baseUrl}/raw/approve?ownerAddress=${fromAddress}&tokenAddress=${sourceTokenInfo.tokenAddress}`); - const approveTxReceipt = await sendRawTransaction(web3, rawTransactionApprove.data as TransactionConfig); - console.log("approve tx id:", approveTxReceipt.transactionHash); + const rawTransactionApprove = await axios.get( + `${baseUrl}/raw/approve?ownerAddress=${fromAddress}&tokenAddress=${sourceTokenInfo.tokenAddress}`, + ); + const approveTxReceipt = await sendRawTransaction( + web3, + rawTransactionApprove.data as TransactionConfig, + ); + console.log('approve tx id:', approveTxReceipt.transactionHash); const gasFeeAmountInt = gasFeeAmount.int; - const totalAmountInt = new Big(amountToSendInt).add(gasFeeAmountInt).toFixed(); + const totalAmountInt = new Big(amountToSendInt) + .add(gasFeeAmountInt) + .toFixed(); console.log( - `Sending ${amountToSendInt} ${sourceTokenInfo.symbol} (gas fee ${gasFeeAmountInt} ${sourceTokenInfo.symbol}). Total amount: ${totalAmountInt} ${sourceTokenInfo.symbol}` + `Sending ${amountToSendInt} ${sourceTokenInfo.symbol} (gas fee ${gasFeeAmountInt} ${sourceTokenInfo.symbol}). Total amount: ${totalAmountInt} ${sourceTokenInfo.symbol}`, ); // initiate transfer const rawTransactionTransfer = await axios.get( - `${baseUrl}/raw/bridge?amount=${totalAmountInt}` - + `&sender=${fromAddress}` - + `&recipient=${toAddress}` - + `&sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfo.tokenAddress}` - + `&messenger=ALLBRIDGE` - + `&feePaymentMethod=WITH_STABLECOIN` - + `&fee=${gasFeeAmount.int}` + `${baseUrl}/raw/bridge?amount=${totalAmountInt}` + + `&sender=${fromAddress}` + + `&recipient=${toAddress}` + + `&sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfo.tokenAddress}` + + `&messenger=ALLBRIDGE` + + `&feePaymentMethod=WITH_STABLECOIN` + + `&fee=${gasFeeAmount.int}`, ); - const txReceipt = await sendRawTransaction(web3, rawTransactionTransfer.data as TransactionConfig); - console.log("tx id:", txReceipt.transactionHash); + const txReceipt = await sendRawTransaction( + web3, + rawTransactionTransfer.data as TransactionConfig, + ); + console.log('tx id:', txReceipt.transactionHash); }; main() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); diff --git a/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx.ts b/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx.ts index 50bad65..a17d58e 100644 --- a/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx.ts +++ b/examples/src/usage/bridge/evm/evm-build-approve-and-send-tx.ts @@ -1,58 +1,76 @@ -import Web3 from "web3"; -import * as dotenv from "dotenv"; -import axios from "axios"; -import { getEnvVar } from "../../../utils/env"; -import { sendRawTransaction } from "../../../utils/web3"; -import { ensure } from "../../../utils/utils"; -import { TransactionConfig } from "web3-core"; - -dotenv.config({ path: ".env" }); +import Web3 from 'web3'; +import * as dotenv from 'dotenv'; +import axios from 'axios'; +import { getEnvVar } from '../../../utils/env'; +import { sendRawTransaction } from '../../../utils/web3'; +import { ensure } from '../../../utils/utils'; +import { TransactionConfig } from 'web3-core'; + +dotenv.config({ path: '.env' }); const main = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); // sender address - const fromAddress = getEnvVar("ETH_ACCOUNT_ADDRESS"); + const fromAddress = getEnvVar('ETH_ACCOUNT_ADDRESS'); // recipient address - const toAddress = getEnvVar("TRX_ACCOUNT_ADDRESS"); + const toAddress = getEnvVar('TRX_ACCOUNT_ADDRESS'); // configure web3 - const web3 = new Web3(getEnvVar("WEB3_PROVIDER_URL")); - const account = web3.eth.accounts.privateKeyToAccount(getEnvVar("ETH_PRIVATE_KEY")); + const web3 = new Web3(getEnvVar('WEB3_PROVIDER_URL')); + const account = web3.eth.accounts.privateKeyToAccount( + getEnvVar('ETH_PRIVATE_KEY'), + ); web3.eth.accounts.wallet.add(account); const chains = (await axios.get(`${baseUrl}/chains`)).data; const sourceChain = chains['ETH']; - const sourceTokenInfo = ensure(sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const sourceTokenInfo = ensure( + sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === 'USDC'), + ); - const destinationChain = chains["TRX"]; - const destinationTokenInfo = ensure(destinationChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDT")); + const destinationChain = chains['TRX']; + const destinationTokenInfo = ensure( + destinationChain.tokens.find( + (tokenInfo: any) => tokenInfo.symbol === 'USDT', + ), + ); - const amount = parseFloat("1.01") * (10 ** sourceTokenInfo.decimals); + const amount = parseFloat('1.01') * 10 ** sourceTokenInfo.decimals; // authorize the bridge to transfer tokens from sender's address - const rawTransactionApprove = await axios.get(`${baseUrl}/raw/approve?ownerAddress=${fromAddress}&tokenAddress=${sourceTokenInfo.tokenAddress}`); - const approveTxReceipt = await sendRawTransaction(web3, rawTransactionApprove.data as TransactionConfig); - console.log("approve tx id:", approveTxReceipt.transactionHash); + const rawTransactionApprove = await axios.get( + `${baseUrl}/raw/approve?ownerAddress=${fromAddress}&tokenAddress=${sourceTokenInfo.tokenAddress}`, + ); + const approveTxReceipt = await sendRawTransaction( + web3, + rawTransactionApprove.data as TransactionConfig, + ); + console.log('approve tx id:', approveTxReceipt.transactionHash); // initiate transfer const rawTransactionTransfer = await axios.get( - `${baseUrl}/raw/bridge?amount=${amount}` - + `&sender=${fromAddress}` - + `&recipient=${toAddress}` - + `&sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfo.tokenAddress}` - + `&messenger=ALLBRIDGE` - + `&feePaymentMethod=WITH_NATIVE_CURRENCY` - ); - - console.log(`Sending ${amount / (10 ** sourceTokenInfo.decimals)} ${sourceTokenInfo.symbol}`); - const txReceipt = await sendRawTransaction(web3, rawTransactionTransfer.data as TransactionConfig); - console.log("tx id:", txReceipt.transactionHash); + `${baseUrl}/raw/bridge?amount=${amount}` + + `&sender=${fromAddress}` + + `&recipient=${toAddress}` + + `&sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfo.tokenAddress}` + + `&messenger=ALLBRIDGE` + + `&feePaymentMethod=WITH_NATIVE_CURRENCY`, + ); + + console.log( + `Sending ${amount / 10 ** sourceTokenInfo.decimals} ${sourceTokenInfo.symbol}`, + ); + const txReceipt = await sendRawTransaction( + web3, + rawTransactionTransfer.data as TransactionConfig, + ); + console.log('tx id:', txReceipt.transactionHash); }; main() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); diff --git a/examples/src/usage/bridge/evm/evm-build-swap-tx.ts b/examples/src/usage/bridge/evm/evm-build-swap-tx.ts index cd193a4..5d8e91a 100644 --- a/examples/src/usage/bridge/evm/evm-build-swap-tx.ts +++ b/examples/src/usage/bridge/evm/evm-build-swap-tx.ts @@ -1,59 +1,74 @@ -import Web3 from "web3"; -import * as dotenv from "dotenv"; -import axios from "axios"; -import { getEnvVar } from "../../../utils/env"; -import { sendRawTransaction } from "../../../utils/web3"; -import { ensure } from "../../../utils/utils"; -import { TransactionConfig } from "web3-core"; - -dotenv.config({ path: ".env" }); +import Web3 from 'web3'; +import * as dotenv from 'dotenv'; +import axios from 'axios'; +import { getEnvVar } from '../../../utils/env'; +import { sendRawTransaction } from '../../../utils/web3'; +import { ensure } from '../../../utils/utils'; +import { TransactionConfig } from 'web3-core'; + +dotenv.config({ path: '.env' }); const main = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); // sender address - const fromAddress = getEnvVar("ETH_ACCOUNT_ADDRESS"); + const fromAddress = getEnvVar('ETH_ACCOUNT_ADDRESS'); // recipient address - const toAddress = getEnvVar("ETH_ACCOUNT_ADDRESS"); + const toAddress = getEnvVar('ETH_ACCOUNT_ADDRESS'); // configure web3 - const web3 = new Web3(getEnvVar("WEB3_PROVIDER_URL")); - const account = web3.eth.accounts.privateKeyToAccount(getEnvVar("ETH_PRIVATE_KEY")); + const web3 = new Web3(getEnvVar('WEB3_PROVIDER_URL')); + const account = web3.eth.accounts.privateKeyToAccount( + getEnvVar('ETH_PRIVATE_KEY'), + ); web3.eth.accounts.wallet.add(account); const chains = (await axios.get(`${baseUrl}/chains`)).data; const sourceChain = chains['ETH']; - const sourceTokenInfo = ensure(sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDT")); + const sourceTokenInfo = ensure( + sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === 'USDT'), + ); const destinationChain = chains['ETH']; - const destinationTokenInfo = ensure(destinationChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const destinationTokenInfo = ensure( + destinationChain.tokens.find( + (tokenInfo: any) => tokenInfo.symbol === 'USDC', + ), + ); - const amount = parseFloat("1.01") * (10 ** sourceTokenInfo.decimals); + const amount = parseFloat('1.01') * 10 ** sourceTokenInfo.decimals; - const minimumReceiveAmount = (await axios.get( - `${baseUrl}/bridge/receive/calculate` - + `?sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfo.tokenAddress}` - + `&amount=${amount}` - + `&messenger=ALLBRIDGE` - )).data; + const minimumReceiveAmount = ( + await axios.get( + `${baseUrl}/bridge/receive/calculate` + + `?sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfo.tokenAddress}` + + `&amount=${amount}` + + `&messenger=ALLBRIDGE`, + ) + ).data; // initiate transfer const rawTransactionTransfer = await axios.get( - `${baseUrl}/raw/swap?amount=${amount}` - + `&sender=${fromAddress}` - + `&recipient=${toAddress}` - + `&sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfo.tokenAddress}` - + `&minimumReceiveAmount=${parseFloat(minimumReceiveAmount.amountReceivedInFloat) * (10 ** sourceTokenInfo.decimals)}` + `${baseUrl}/raw/swap?amount=${amount}` + + `&sender=${fromAddress}` + + `&recipient=${toAddress}` + + `&sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfo.tokenAddress}` + + `&minimumReceiveAmount=${parseFloat(minimumReceiveAmount.amountReceivedInFloat) * 10 ** sourceTokenInfo.decimals}`, ); - console.log(`Swaping ${amount / (10 ** sourceTokenInfo.decimals)} ${sourceTokenInfo.symbol}`); - const txReceipt = await sendRawTransaction(web3, rawTransactionTransfer.data as TransactionConfig); - console.log("tx id:", txReceipt.transactionHash); + console.log( + `Swaping ${amount / 10 ** sourceTokenInfo.decimals} ${sourceTokenInfo.symbol}`, + ); + const txReceipt = await sendRawTransaction( + web3, + rawTransactionTransfer.data as TransactionConfig, + ); + console.log('tx id:', txReceipt.transactionHash); }; main() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); diff --git a/examples/src/usage/bridge/evm/evm-check-allowance.ts b/examples/src/usage/bridge/evm/evm-check-allowance.ts index ee8fd8b..a348f51 100644 --- a/examples/src/usage/bridge/evm/evm-check-allowance.ts +++ b/examples/src/usage/bridge/evm/evm-check-allowance.ts @@ -1,41 +1,52 @@ -import Web3 from "web3"; -import * as dotenv from "dotenv"; -import axios from "axios"; -import { getEnvVar } from "../../../utils/env"; -import { ensure } from "../../../utils/utils"; -import Big from "big.js"; +import Web3 from 'web3'; +import * as dotenv from 'dotenv'; +import axios from 'axios'; +import { getEnvVar } from '../../../utils/env'; +import { ensure } from '../../../utils/utils'; +import Big from 'big.js'; -dotenv.config({ path: ".env" }); +dotenv.config({ path: '.env' }); const main = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); // sender address - const fromAddress = getEnvVar("ETH_ACCOUNT_ADDRESS"); + const fromAddress = getEnvVar('ETH_ACCOUNT_ADDRESS'); // configure web3 - const web3 = new Web3(getEnvVar("WEB3_PROVIDER_URL")); - const account = web3.eth.accounts.privateKeyToAccount(getEnvVar("ETH_PRIVATE_KEY")); + const web3 = new Web3(getEnvVar('WEB3_PROVIDER_URL')); + const account = web3.eth.accounts.privateKeyToAccount( + getEnvVar('ETH_PRIVATE_KEY'), + ); web3.eth.accounts.wallet.add(account); const chains = (await axios.get(`${baseUrl}/chains`)).data; const sourceChain = chains['ETH']; - const sourceTokenInfo = ensure(sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const sourceTokenInfo = ensure( + sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === 'USDC'), + ); const destinationChain = chains['TRX']; - const destinationTokenInfo = ensure(destinationChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDT")); - const amountInt = parseFloat("1.01") * (10 ** sourceTokenInfo.decimals); + const destinationTokenInfo = ensure( + destinationChain.tokens.find( + (tokenInfo: any) => tokenInfo.symbol === 'USDT', + ), + ); + const amountInt = parseFloat('1.01') * 10 ** sourceTokenInfo.decimals; //const gasFeePaymentMethod = 'WITH_STABLECOIN'; const gasFeePaymentMethod = 'WITH_NATIVE_CURRENCY'; let totalAmountInt; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore if (gasFeePaymentMethod === 'WITH_STABLECOIN') { - const gasFeeOptions = (await axios.get( - `${baseUrl}/gas/fee` - + `?sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfo.tokenAddress}` - + `&messenger=ALLBRIDGE` - )).data; + const gasFeeOptions = ( + await axios.get( + `${baseUrl}/gas/fee` + + `?sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfo.tokenAddress}` + + `&messenger=ALLBRIDGE`, + ) + ).data; const gasFeeAmount = ensure(gasFeeOptions['stablecoin']); const gasFeeAmountInt = gasFeeAmount.int; // checking allowance for amount + gas fee @@ -45,26 +56,28 @@ const main = async () => { totalAmountInt = amountInt; } - const allowance = (await axios.get( - `${baseUrl}/check/allowance` - + `?amount=${totalAmountInt}` - + `&ownerAddress=${fromAddress}` - + `&tokenAddress=${sourceTokenInfo.tokenAddress}` - + `&feePaymentMethod=${gasFeePaymentMethod}` - )).data; + const allowance = ( + await axios.get( + `${baseUrl}/check/allowance` + + `?amount=${totalAmountInt}` + + `&ownerAddress=${fromAddress}` + + `&tokenAddress=${sourceTokenInfo.tokenAddress}` + + `&feePaymentMethod=${gasFeePaymentMethod}`, + ) + ).data; if ( // check if tokens already approved allowance ) { - console.log("The granted allowance is enough for the transaction"); + console.log('The granted allowance is enough for the transaction'); } else { - console.log("The granted allowance is NOT enough for the transaction"); + console.log('The granted allowance is NOT enough for the transaction'); } }; main() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); diff --git a/examples/src/usage/bridge/evm/evm-send-full-example.ts b/examples/src/usage/bridge/evm/evm-send-full-example.ts index f836ac1..3561444 100644 --- a/examples/src/usage/bridge/evm/evm-send-full-example.ts +++ b/examples/src/usage/bridge/evm/evm-send-full-example.ts @@ -1,64 +1,79 @@ -import Web3 from "web3"; -import * as dotenv from "dotenv"; -import axios from "axios"; +import Web3 from 'web3'; +import * as dotenv from 'dotenv'; +import axios from 'axios'; import { TransactionConfig } from 'web3-core'; -import { getEnvVar } from "../../../utils/env"; -import { sendRawTransaction } from "../../../utils/web3"; -import { ensure } from "../../../utils/utils"; +import { getEnvVar } from '../../../utils/env'; +import { sendRawTransaction } from '../../../utils/web3'; +import { ensure } from '../../../utils/utils'; -dotenv.config({ path: ".env" }); +dotenv.config({ path: '.env' }); const main = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); // sender address - const fromAddress = getEnvVar("ETH_ACCOUNT_ADDRESS"); + const fromAddress = getEnvVar('ETH_ACCOUNT_ADDRESS'); // recipient address - const toAddress = getEnvVar("TRX_ACCOUNT_ADDRESS"); + const toAddress = getEnvVar('TRX_ACCOUNT_ADDRESS'); // configure web3 - const web3 = new Web3(getEnvVar("WEB3_PROVIDER_URL")); - const account = web3.eth.accounts.privateKeyToAccount(getEnvVar("ETH_PRIVATE_KEY")); + const web3 = new Web3(getEnvVar('WEB3_PROVIDER_URL')); + const account = web3.eth.accounts.privateKeyToAccount( + getEnvVar('ETH_PRIVATE_KEY'), + ); web3.eth.accounts.wallet.add(account); const chains = (await axios.get(`${baseUrl}/chains`)).data; const sourceChain = chains['ETH']; - const sourceTokenInfo = ensure(sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const sourceTokenInfo = ensure( + sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === 'USDC'), + ); const destinationChain = chains['TRX']; - const destinationTokenInfo = ensure(destinationChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDT")); - const amountInt = parseFloat("1.01") * (10 ** sourceTokenInfo.decimals); + const destinationTokenInfo = ensure( + destinationChain.tokens.find( + (tokenInfo: any) => tokenInfo.symbol === 'USDT', + ), + ); + const amountInt = parseFloat('1.01') * 10 ** sourceTokenInfo.decimals; if ( //check if sending tokens already approved - !(await axios.get( - `${baseUrl}/check/allowance` - + `?amount=${amountInt}` - + `&ownerAddress=${fromAddress}` - + `&tokenAddress=${sourceTokenInfo.tokenAddress}` - + `&feePaymentMethod=WITH_NATIVE_CURRENCY` - )).data + !( + await axios.get( + `${baseUrl}/check/allowance` + + `?amount=${amountInt}` + + `&ownerAddress=${fromAddress}` + + `&tokenAddress=${sourceTokenInfo.tokenAddress}` + + `&feePaymentMethod=WITH_NATIVE_CURRENCY`, + ) + ).data ) { // authorize a transfer of tokens from sender's address - await axios.get(`${baseUrl}/raw/approve?ownerAddress=${fromAddress}&tokenAddress=${sourceTokenInfo.tokenAddress}`); + await axios.get( + `${baseUrl}/raw/approve?ownerAddress=${fromAddress}&tokenAddress=${sourceTokenInfo.tokenAddress}`, + ); } // initiate transfer const rawTransactionTransfer = await axios.get( - `${baseUrl}/raw/bridge?amount=${amountInt}` - + `&sender=${fromAddress}` - + `&recipient=${toAddress}` - + `&sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfo.tokenAddress}` - + `&messenger=ALLBRIDGE` - + `&feePaymentMethod=WITH_NATIVE_CURRENCY` + `${baseUrl}/raw/bridge?amount=${amountInt}` + + `&sender=${fromAddress}` + + `&recipient=${toAddress}` + + `&sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfo.tokenAddress}` + + `&messenger=ALLBRIDGE` + + `&feePaymentMethod=WITH_NATIVE_CURRENCY`, + ); + const txReceipt = await sendRawTransaction( + web3, + rawTransactionTransfer.data as TransactionConfig, ); - const txReceipt = await sendRawTransaction(web3, rawTransactionTransfer.data as TransactionConfig); - console.log("Tokens sent:", txReceipt.transactionHash); + console.log('Tokens sent:', txReceipt.transactionHash); }; main() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); diff --git a/examples/src/usage/bridge/solana/sol-build-send-tx.ts b/examples/src/usage/bridge/solana/sol-build-send-tx.ts index 0a92c83..b957987 100644 --- a/examples/src/usage/bridge/solana/sol-build-send-tx.ts +++ b/examples/src/usage/bridge/solana/sol-build-send-tx.ts @@ -1,88 +1,104 @@ import axios from 'axios'; -import * as dotenv from "dotenv"; -import { getEnvVar } from "../../../utils/env"; -import { ensure } from "../../../utils/utils"; +import * as dotenv from 'dotenv'; +import { getEnvVar } from '../../../utils/env'; +import { ensure } from '../../../utils/utils'; import solanaWeb3, { VersionedTransaction } from '@solana/web3.js'; -import bs58 from "bs58"; +import bs58 from 'bs58'; -dotenv.config({ path: ".env" }); +dotenv.config({ path: '.env' }); -const fromAddress = getEnvVar("SOL_ACCOUNT_ADDRESS"); -const privateKey = getEnvVar("SOL_PRIVATE_KEY"); -const toAddressEth = getEnvVar("ETH_ACCOUNT_ADDRESS"); -const solNodeRPCUrl = getEnvVar("SOL_PROVIDER_URL"); +const fromAddress = getEnvVar('SOL_ACCOUNT_ADDRESS'); +const privateKey = getEnvVar('SOL_PRIVATE_KEY'); +const toAddressEth = getEnvVar('ETH_ACCOUNT_ADDRESS'); +const solNodeRPCUrl = getEnvVar('SOL_PROVIDER_URL'); const exampleViaWormhole = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); const chains = (await axios.get(`${baseUrl}/chains`)).data; const sourceChain = chains['SOL']; - const sourceTokenInfo = ensure(sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const sourceTokenInfo = ensure( + sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === 'USDC'), + ); const destinationChainEth = chains['ETH']; - const destinationTokenInfoEth = ensure(destinationChainEth.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDT")); - const amountInt = parseFloat("0.2") * (10 ** sourceTokenInfo.decimals); + const destinationTokenInfoEth = ensure( + destinationChainEth.tokens.find( + (tokenInfo: any) => tokenInfo.symbol === 'USDT', + ), + ); + const amountInt = parseFloat('0.2') * 10 ** sourceTokenInfo.decimals; // initiate transfer using Messenger.WORMHOLE - const raw = (await axios.get( - `${baseUrl}/raw/bridge?amount=${amountInt}` - + `&sender=${fromAddress}` - + `&recipient=${toAddressEth}` - + `&sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfoEth.tokenAddress}` - + `&messenger=WORMHOLE` - + `&feePaymentMethod=WITH_NATIVE_CURRENCY` - )).data; + const raw = ( + await axios.get( + `${baseUrl}/raw/bridge?amount=${amountInt}` + + `&sender=${fromAddress}` + + `&recipient=${toAddressEth}` + + `&sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfoEth.tokenAddress}` + + `&messenger=WORMHOLE` + + `&feePaymentMethod=WITH_NATIVE_CURRENCY`, + ) + ).data; const keypair = solanaWeb3.Keypair.fromSecretKey(bs58.decode(privateKey)); - const transaction = VersionedTransaction.deserialize(Buffer.from(raw,'hex')); + const transaction = VersionedTransaction.deserialize(Buffer.from(raw, 'hex')); transaction.sign([keypair]); - const connection = new solanaWeb3.Connection(solNodeRPCUrl, "confirmed"); + const connection = new solanaWeb3.Connection(solNodeRPCUrl, 'confirmed'); const txid = await connection.sendTransaction(transaction); console.log(`https://explorer.solana.com/tx/${txid}`); }; const exampleViaAllbridge = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); const chains = (await axios.get(`${baseUrl}/chains`)).data; const sourceChain = chains['SOL']; - const sourceTokenInfo = ensure(sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDC")); + const sourceTokenInfo = ensure( + sourceChain.tokens.find((tokenInfo: any) => tokenInfo.symbol === 'USDC'), + ); const destinationChainEth = chains['ETH']; - const destinationTokenInfoEth = ensure(destinationChainEth.tokens.find((tokenInfo: any) => tokenInfo.symbol === "USDT")); - const amountInt = parseFloat("0.3") * (10 ** sourceTokenInfo.decimals); + const destinationTokenInfoEth = ensure( + destinationChainEth.tokens.find( + (tokenInfo: any) => tokenInfo.symbol === 'USDT', + ), + ); + const amountInt = parseFloat('0.3') * 10 ** sourceTokenInfo.decimals; // initiate transfer using Messenger.ALLBRIDGE - const raw = (await axios.get( - `${baseUrl}/raw/bridge?amount=${amountInt}` - + `&sender=${fromAddress}` - + `&recipient=${toAddressEth}` - + `&sourceToken=${sourceTokenInfo.tokenAddress}` - + `&destinationToken=${destinationTokenInfoEth.tokenAddress}` - + `&messenger=ALLBRIDGE` - + `&feePaymentMethod=WITH_NATIVE_CURRENCY` - )).data; + const raw = ( + await axios.get( + `${baseUrl}/raw/bridge?amount=${amountInt}` + + `&sender=${fromAddress}` + + `&recipient=${toAddressEth}` + + `&sourceToken=${sourceTokenInfo.tokenAddress}` + + `&destinationToken=${destinationTokenInfoEth.tokenAddress}` + + `&messenger=ALLBRIDGE` + + `&feePaymentMethod=WITH_NATIVE_CURRENCY`, + ) + ).data; const keypair = solanaWeb3.Keypair.fromSecretKey(bs58.decode(privateKey)); - const transaction = VersionedTransaction.deserialize(Buffer.from(raw,'hex')); + const transaction = VersionedTransaction.deserialize(Buffer.from(raw, 'hex')); transaction.sign([keypair]); - const connection = new solanaWeb3.Connection(solNodeRPCUrl, "confirmed"); + const connection = new solanaWeb3.Connection(solNodeRPCUrl, 'confirmed'); const txid = await connection.sendTransaction(transaction); console.log(`https://explorer.solana.com/tx/${txid}`); }; exampleViaWormhole() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); }); exampleViaAllbridge() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); diff --git a/examples/src/usage/bridge/srb/srb-send-full-example.ts b/examples/src/usage/bridge/srb/srb-send-full-example.ts index c71fd10..ec57698 100644 --- a/examples/src/usage/bridge/srb/srb-send-full-example.ts +++ b/examples/src/usage/bridge/srb/srb-send-full-example.ts @@ -1,4 +1,4 @@ -import Big from "big.js"; +import Big from 'big.js'; import { Asset, Horizon, @@ -8,110 +8,160 @@ import { Transaction, TransactionBuilder, } from '@stellar/stellar-sdk'; -import axios from "axios"; -import { ensure } from "../../../utils/utils"; -import { getEnvVar } from "../../../utils/env"; -import * as dotenv from "dotenv"; +import axios from 'axios'; +import { ensure } from '../../../utils/utils'; +import { getEnvVar } from '../../../utils/env'; +import * as dotenv from 'dotenv'; -dotenv.config({ path: ".env" }); +dotenv.config({ path: '.env' }); -const fromAddress = getEnvVar("SRB_ACCOUNT_ADDRESS"); -const privateKey = getEnvVar("SRB_PRIVATE_KEY"); -const sorobanNetworkPassphrase = getEnvVar("SRB_NETWORK_PASSPHRASE"); -const toAddress = getEnvVar("ETH_ACCOUNT_ADDRESS"); +const fromAddress = getEnvVar('SRB_ACCOUNT_ADDRESS'); +const privateKey = getEnvVar('SRB_PRIVATE_KEY'); +const sorobanNetworkPassphrase = getEnvVar('SRB_NETWORK_PASSPHRASE'); +const toAddress = getEnvVar('ETH_ACCOUNT_ADDRESS'); const FEE = 100; const SEND_TRANSACTION_TIMEOUT = 180; const main = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); const chains = (await axios.get(`${baseUrl}/chains`)).data; - const server = new SorobanRpc.Server(getEnvVar("SRB_NODE_URL")); + const server = new SorobanRpc.Server(getEnvVar('SRB_NODE_URL')); - const sourceToken = ensure(chains['SRB'].tokens.find((t: any) => t.symbol == "USDC")); - const destinationToken = ensure(chains['BSC'].tokens.find((t: any) => t.symbol == "USDT")); - const amount = parseFloat("0.01") * (10 ** sourceToken.decimals); + const sourceToken = ensure( + chains['SRB'].tokens.find((t: any) => t.symbol == 'USDC'), + ); + const destinationToken = ensure( + chains['BSC'].tokens.find((t: any) => t.symbol == 'USDT'), + ); + const amount = parseFloat('0.01') * 10 ** sourceToken.decimals; console.log( - `Sending ${amount / (10 ** sourceToken.decimals)} ${sourceToken.symbol} to ${toAddress} on BSC. ` + `Sending ${amount / 10 ** sourceToken.decimals} ${sourceToken.symbol} to ${toAddress} on BSC. `, ); - const xdrTx: string = (await axios.get( - `${baseUrl}/raw/bridge?amount=${amount}` - + `&sender=${fromAddress}` - + `&recipient=${toAddress}` - + `&sourceToken=${sourceToken.tokenAddress}` - + `&destinationToken=${destinationToken.tokenAddress}` - + `&messenger=ALLBRIDGE` - + `&feePaymentMethod=WITH_NATIVE_CURRENCY` - )).data; + const xdrTx: string = ( + await axios.get( + `${baseUrl}/raw/bridge?amount=${amount}` + + `&sender=${fromAddress}` + + `&recipient=${toAddress}` + + `&sourceToken=${sourceToken.tokenAddress}` + + `&destinationToken=${destinationToken.tokenAddress}` + + `&messenger=ALLBRIDGE` + + `&feePaymentMethod=WITH_NATIVE_CURRENCY`, + ) + ).data; // SendTx const srbKeypair = Keypair.fromSecret(privateKey); - const transaction = TransactionBuilder.fromXDR(xdrTx, sorobanNetworkPassphrase); + const transaction = TransactionBuilder.fromXDR( + xdrTx, + sorobanNetworkPassphrase, + ); transaction.sign(srbKeypair); const signedTx = transaction.toXDR(); try { - const restoreXdrResp = (await axios.get( - `${baseUrl}/raw/stellar/restore?xdrTx=${signedTx}` - + `&sender=${fromAddress}` - )); + const restoreXdrResp = await axios.get( + `${baseUrl}/raw/stellar/restore?xdrTx=${signedTx}` + + `&sender=${fromAddress}`, + ); if (restoreXdrResp.status == 200 && restoreXdrResp.data) { - const restoreXdrTx = TransactionBuilder.fromXDR(restoreXdrResp.data, sorobanNetworkPassphrase) as Transaction; + const restoreXdrTx = TransactionBuilder.fromXDR( + restoreXdrResp.data, + sorobanNetworkPassphrase, + ) as Transaction; restoreXdrTx.sign(srbKeypair); const signedRestoreXdrTx = restoreXdrTx.toXDR(); - const transaction = TransactionBuilder.fromXDR(signedRestoreXdrTx, sorobanNetworkPassphrase) as Transaction; + const transaction = TransactionBuilder.fromXDR( + signedRestoreXdrTx, + sorobanNetworkPassphrase, + ) as Transaction; const sentRestoreXdrTx = await server.sendTransaction(transaction); // Wait for Restore transaction to complete let confirmRestoreXdrTx; - let counter = 10 + let counter = 10; while (counter > 0) { - const getTransactionResponse = await server.getTransaction(sentRestoreXdrTx.hash); + const getTransactionResponse = await server.getTransaction( + sentRestoreXdrTx.hash, + ); confirmRestoreXdrTx = getTransactionResponse; - if (getTransactionResponse.status === SorobanRpc.Api.GetTransactionStatus.FAILED - || getTransactionResponse.status === SorobanRpc.Api.GetTransactionStatus.SUCCESS) { + if ( + getTransactionResponse.status === + SorobanRpc.Api.GetTransactionStatus.FAILED || + getTransactionResponse.status === + SorobanRpc.Api.GetTransactionStatus.SUCCESS + ) { break; } counter--; } - if (!!confirmRestoreXdrTx && confirmRestoreXdrTx.status === SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) { + if ( + !!confirmRestoreXdrTx && + confirmRestoreXdrTx.status === + SorobanRpc.Api.GetTransactionStatus.NOT_FOUND + ) { console.log( `Waited for Restore transaction to complete, but it did not. ` + - `Check the transaction status manually. ` + - `Hash: ${sentRestoreXdrTx.hash}` + `Check the transaction status manually. ` + + `Hash: ${sentRestoreXdrTx.hash}`, + ); + } else if ( + !!confirmRestoreXdrTx && + confirmRestoreXdrTx.status === + SorobanRpc.Api.GetTransactionStatus.FAILED + ) { + console.log( + `Transaction Restore failed. Check the transaction manually.` + + `Hash: ${sentRestoreXdrTx.hash}`, ); - } else if (!!confirmRestoreXdrTx && confirmRestoreXdrTx.status === SorobanRpc.Api.GetTransactionStatus.FAILED) { - console.log(`Transaction Restore failed. Check the transaction manually.` + `Hash: ${sentRestoreXdrTx.hash}`); } else { - console.log(`Transaction Restore Confirmed. Hash: ${sentRestoreXdrTx.hash}`); + console.log( + `Transaction Restore Confirmed. Hash: ${sentRestoreXdrTx.hash}`, + ); } } } catch (e) { console.error(e); } - const tx = TransactionBuilder.fromXDR(signedTx, sorobanNetworkPassphrase) as Transaction; + const tx = TransactionBuilder.fromXDR( + signedTx, + sorobanNetworkPassphrase, + ) as Transaction; const sent = await server.sendTransaction(tx); // Wait for Restore transaction to complete let confirm; - let counter = 10 + let counter = 10; while (counter > 0) { const getTransactionResponse = await server.getTransaction(sent.hash); confirm = getTransactionResponse; - if (getTransactionResponse.status === SorobanRpc.Api.GetTransactionStatus.FAILED - || getTransactionResponse.status === SorobanRpc.Api.GetTransactionStatus.SUCCESS) { + if ( + getTransactionResponse.status === + SorobanRpc.Api.GetTransactionStatus.FAILED || + getTransactionResponse.status === + SorobanRpc.Api.GetTransactionStatus.SUCCESS + ) { break; } counter--; } - if (!!confirm && confirm.status === SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) { + if ( + !!confirm && + confirm.status === SorobanRpc.Api.GetTransactionStatus.NOT_FOUND + ) { console.log( `Waited for transaction to complete, but it did not. ` + - `Check the transaction status manually. ` + - `Hash: ${sent.hash}` + `Check the transaction status manually. ` + + `Hash: ${sent.hash}`, + ); + } else if ( + !!confirm && + confirm.status === SorobanRpc.Api.GetTransactionStatus.FAILED + ) { + console.log( + `Transaction failed. Check the transaction manually.` + + `Hash: ${sent.hash}`, ); - } else if (!!confirm && confirm.status === SorobanRpc.Api.GetTransactionStatus.FAILED) { - console.log(`Transaction failed. Check the transaction manually.` + `Hash: ${sent.hash}`); } else { console.log(`Transaction Confirmed. Hash: ${sent.hash}`); } @@ -119,44 +169,47 @@ const main = async () => { //TrustLine check and Set up for destinationToken if it is SRB const destinationTokenSRB = sourceToken; // simulate destination is srb - const balanceLine = (await axios.get( - `${baseUrl}/check/stellar/balanceline?` - + `token=${destinationTokenSRB.tokenAddress}` - + `&address=${fromAddress}` - )).data; + const balanceLine = ( + await axios.get( + `${baseUrl}/check/stellar/balanceline?` + + `token=${destinationTokenSRB.tokenAddress}` + + `&address=${fromAddress}`, + ) + ).data; console.log(`BalanceLine:`, balanceLine); - const notEnoughBalanceLine = !balanceLine || Big(balanceLine.balance).add(amount).gt(Big(balanceLine.limit)); + const notEnoughBalanceLine = + !balanceLine || + Big(balanceLine.balance).add(amount).gt(Big(balanceLine.limit)); if (notEnoughBalanceLine) { - const stellar = new Horizon.Server(getEnvVar("STLR_NODE_URL")); + const stellar = new Horizon.Server(getEnvVar('STLR_NODE_URL')); const stellarAccount = await stellar.loadAccount(fromAddress); - const [symbol, srbTokenAddress] = sourceToken.originTokenAddress.split(":"); + const [symbol, srbTokenAddress] = sourceToken.originTokenAddress.split(':'); const asset = new Asset(symbol, srbTokenAddress); const changeTrust = Operation.changeTrust({ asset: asset, - limit: "1000000", + limit: '1000000', }); const transaction = new TransactionBuilder(stellarAccount, { fee: FEE.toString(10), networkPassphrase: sorobanNetworkPassphrase, }) - .addOperation(changeTrust) - .setTimeout(SEND_TRANSACTION_TIMEOUT) - .build(); - + .addOperation(changeTrust) + .setTimeout(SEND_TRANSACTION_TIMEOUT) + .build(); //SignTx transaction.sign(srbKeypair); const submit = await stellar.submitTransaction(transaction); - console.log("Submitted change trust tx. Hash:", submit.hash); + console.log('Submitted change trust tx. Hash:', submit.hash); } }; main() -.then(() => { - console.log("Done"); -}) -.catch((e) => { - console.error(e); -}); \ No newline at end of file + .then(() => { + console.log('Done'); + }) + .catch((e) => { + console.error(e); + }); diff --git a/examples/src/usage/get-tokens-info.ts b/examples/src/usage/get-tokens-info.ts index 736e6e1..f00fa88 100644 --- a/examples/src/usage/get-tokens-info.ts +++ b/examples/src/usage/get-tokens-info.ts @@ -1,14 +1,14 @@ -import axios from "axios"; +import axios from 'axios'; import { getEnvVar } from '../utils/env'; const main = async () => { - const baseUrl = getEnvVar("REST_API_URL"); + const baseUrl = getEnvVar('REST_API_URL'); const tokens = await axios.get(`${baseUrl}/tokens`); - console.log("Tokens =", JSON.stringify(tokens.data, null, 2)); + console.log('Tokens =', JSON.stringify(tokens.data, null, 2)); }; main() .then(() => { - console.log("Done"); + console.log('Done'); }) .catch((e) => { console.error(e); diff --git a/examples/src/utils/env.ts b/examples/src/utils/env.ts index 41d554d..23d8f3c 100644 --- a/examples/src/utils/env.ts +++ b/examples/src/utils/env.ts @@ -1,4 +1,4 @@ -import 'dotenv/config' +import 'dotenv/config'; export function getEnvVar(name: string, defaultValue?: string): string { const value = process.env[name]; diff --git a/examples/src/utils/utils.ts b/examples/src/utils/utils.ts index b0c2f2e..eb44107 100644 --- a/examples/src/utils/utils.ts +++ b/examples/src/utils/utils.ts @@ -1,6 +1,6 @@ export function ensure(argument: T | undefined | null): T { if (argument === undefined || argument === null) { - throw new TypeError("This value was promised to be there."); + throw new TypeError('This value was promised to be there.'); } return argument; diff --git a/examples/src/utils/web3.ts b/examples/src/utils/web3.ts index 59da792..34a05c0 100644 --- a/examples/src/utils/web3.ts +++ b/examples/src/utils/web3.ts @@ -1,11 +1,15 @@ -import Web3 from "web3"; -import { Account, TransactionConfig } from "web3-core"; +import Web3 from 'web3'; +import { Account, TransactionConfig } from 'web3-core'; -export async function sendRawTransaction(web3: Web3, rawTransaction: TransactionConfig) { +export async function sendRawTransaction( + web3: Web3, + rawTransaction: TransactionConfig, +) { if (rawTransaction.from === undefined) { - throw Error("rawTransaction.from is undefined"); + throw Error('rawTransaction.from is undefined'); } const gasLimit = await web3.eth.estimateGas(rawTransaction); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const account: Account = web3.eth.accounts.wallet[rawTransaction.from]; const signedTx = await account.signTransaction({ @@ -13,8 +17,8 @@ export async function sendRawTransaction(web3: Web3, rawTransaction: Transaction gas: gasLimit, }); if (signedTx.rawTransaction === undefined) { - throw Error("signedTx.rawTransaction is undefined"); + throw Error('signedTx.rawTransaction is undefined'); } - console.log("Sending transaction", signedTx.transactionHash); + console.log('Sending transaction', signedTx.transactionHash); return web3.eth.sendSignedTransaction(signedTx.rawTransaction); } diff --git a/rest-api/src/service/sdk.service.ts b/rest-api/src/service/sdk.service.ts index 50626f5..654c9c3 100644 --- a/rest-api/src/service/sdk.service.ts +++ b/rest-api/src/service/sdk.service.ts @@ -4,7 +4,6 @@ import { AmountFormatted, ChainDetailsMap, ChainSymbol, - CheckAddressResponse, CheckAllowanceParams, ExtraGasMaxLimitResponse, GasBalanceResponse,