diff --git a/README.md b/README.md index 2e8d7f2..bcf295b 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ The Aarc SDK is a TypeScript library that makes it easy for developers to transf - ERC20Permit support for streamlined token approvals. - Gasless transactions using Relayers (EIP2771). +# Getting Started + ## Prerequisites - Node.js (v12.x or later) - Basic understanding of Ethereum and smart contracts. @@ -18,11 +20,15 @@ Install ethers.js and Aarc SDK using npm: npm install ethers@5.7.2 aarc-sdk ``` -# Getting Started - ## Get the API Key -To use Aarc SDK, an API key is required. Fill out [this form](https://rebrand.ly/aarc-api) to get the API Key on your email instantly! +To use Aarc SDK, an API key is required. Get the **API Key** from the [Dashboard](https://dashboard.aarc.xyz/). +You can learn about gettign the API Key from [here](https://docs.aarc.xyz/developer-docs/integration-guide/setup-and-installation). + +![Dashboard Image](./readme_assets/1.png) + +> [!NOTE] +We only accept funds on **Polygon Mainnet** & **Polygon Mumbai Testnet**. However, these funds can be transacted on any supported mainnet or testnet. ## Initialise the SDK @@ -39,8 +45,34 @@ let aarcSDK = new AarcSDK({ ``` # Usage - -## Fetching token balances +- [Aarc SDK](#aarc-sdk) + - [Features of the SDK](#features-of-the-sdk) +- [Getting Started](#getting-started) + - [Prerequisites](#prerequisites) + - [Installation](#installation) + - [Get the API Key](#get-the-api-key) + - [Initialise the SDK](#initialise-the-sdk) +- [Usage](#usage) + - [Fetching Token Balances](#fetching-token-balances) + - [Migrate Assets](#migrate-assets) + - [Output](#output) + - [Migrate Assets \[With Gasless Flow\]](#migrate-assets-with-gasless-flow) + - [Output:](#output-1) + - [Migrate of Assets \[Pay Gas with Stables\]](#migrate-of-assets-pay-gas-with-stables) + - [Moving Native Tokens and Wallet Deployment](#moving-native-tokens-and-wallet-deployment) + - [Smart Wallet Integration](#smart-wallet-integration) + - [Safe Smart Wallet](#safe-smart-wallet) + - [Fetching Existing Safes:](#fetching-existing-safes) + - [Creating a New Safe Wallet:](#creating-a-new-safe-wallet) + - [Biconomy Smart Wallet](#biconomy-smart-wallet) + - [Fetching Biconomy Smart Wallets:](#fetching-biconomy-smart-wallets) + - [Creating a New Biconomy Wallet:](#creating-a-new-biconomy-wallet) + - [Smart Wallet Deployment](#smart-wallet-deployment) + - [More coming soon 👀](#more-coming-soon-) + - [License](#license) + - [Support and Feedback](#support-and-feedback) + +## Fetching Token Balances Retrieve balances of all tokens in an EOA wallet: @@ -52,7 +84,8 @@ let balances = await aarcSDK.fetchBalances( ); ``` -## Moving Assets + +## Migrate Assets Transfer tokens from EOA to any receiver wallet address: @@ -64,7 +97,7 @@ await aarcSDK.executeMigration({ [ { tokenAddress:TOKEN1_ADDRESS, - amount?:TOKEN1_AMOUNT, // ethers.BigNumber in case of erc20 and native token + amount?:TOKEN1_AMOUNT, // Vaule in HEX as String tokenIds?: string[] // tokenIds for nfts }, ... @@ -73,23 +106,23 @@ await aarcSDK.executeMigration({ // Returns the response given below ``` -Output: +### Output ```bash [ { - tokenAddress, - amount, - message, - txHash, - tokenId + tokenAddress: string; + taskId?: string; + amount?:string + message: string; + txHash?: string; + tokenId?: string; }, - ... ] ``` -### Moving Assets without gas +## Migrate Assets [With Gasless Flow] -Transfer tokens from EOA to any receiver wallet address without gas fees. Please note that we use Gelato Relayer to provide the gasless functionality. Please get the Gelato [API Key](https://docs.gelato.network/developer-services/relay/payment-and-fees/1balance-and-relay) to use the gasless functionality. +Transfer tokens from EOA to any receiver wallet address **without paying gas fees**. ```typescript await aarcSDK.executeMigrationGasless({ @@ -99,39 +132,52 @@ await aarcSDK.executeMigrationGasless({ [ { tokenAddress:TOKEN1_ADDRESS, - amount?:TOKEN1_AMOUNT, // ethers.BigNumber in case of erc20 and native token + amount?:TOKEN1_AMOUNT, // Vaule in HEX as String tokenIds?: string[] // tokenIds for nfts }, ... - ], - gelatoApiKey: GELATO_RELAYER_API_KEY // Use the link above to get the gelato relayer key + ] }) // Returns the response given below ``` -Output: +### Output: ```bash [ { - tokenAddress, - amount, - message, - txHash, - tokenId + tokenAddress: string; + taskId?: string; + amount?:string + message: string; + txHash?: string; + tokenId?: string; }, - ... ] ``` +## Migrate of Assets [Pay Gas with Stables] + +Transfer tokens from EOA to any receiver wallet address by **paying gas in Stable Coins.** + +```typescript +await aarcSDK.executeForwardTransaction({ + senderSigner: signer, + receiverAddress:"0x786E6045eacb96cAe0259cd761e151b68B85bdA7" + }); +``` + +> [!NOTE] +AARC SDK currently supports a few of the Stable Tokens on different networks. You can check about them [here](https://docs.aarc.xyz/developer-docs/integration-guide/usage/assets-migration/user-pays-gas-with-erc20-tokens-forwarder-flow#supported-networks-and-tokens). + + ## Moving Native Tokens and Wallet Deployment The following code snippet demonstrates a method to transfer native tokens while simultaneously deploying a wallet using the aarcSDK. -This code snippet illustrates a process to transfer native tokens and deploy a wallet concurrently using the aarcSDK. Essential parameters such as the owner's address (EOA_ADDRESS), the type of wallet to deploy (WALLET_TYPE), the signer (ethers.signer object), the receiver's wallet address (RECEIVER_WALLET_ADDRESS), an optional amount of tokens to transfer (amount), and an index for deploying multiple wallets under the same EOA (deploymentWalletIndex) are included. - -#### NOTE -If the wallet corresponding to the provided owner address (EOA_ADDRESS) and index (deploymentWalletIndex) is already deployed, the deployment process will not occur, and only the token transfer will be executed. +This code snippet illustrates a process to transfer native tokens and deploy a wallet concurrently using the `aarcSDK`. Essential parameters such as the owner's address (`EOA_ADDRESS`), the type of wallet to deploy (`WALLET_TYPE`), the `signer` (ethers.signer object), the receiver's wallet address (`RECEIVER_WALLET_ADDRESS`), an optional amount of tokens to transfer (`amount`), and an index for deploying multiple wallets under the same EOA (`deploymentWalletIndex`) are included. +> [!NOTE] +If the wallet corresponding to the provided owner address (`EOA_ADDRESS`) and index (`deploymentWalletIndex`) is already deployed, the deployment process will not occur, and only the token transfer will be executed. ```typescript @@ -142,7 +188,7 @@ await aarcSDK.transferNativeAndDeploy({ walletType: WALLET_TYPE, // WALLET_TYPE.SAFE or WALLET_TYPE.BICONOMY signer: signer, // ethers.signer object receiverAddress: RECEIVER_WALLET_ADDRESS, - amount: BigNumber, // Optional. if not paseed 80% of native tokens will get transferred. + amount?: string, // Optional. Vaule in HEX as String if not paseed 80% of native tokens will get transferred. deploymentWalletIndex: 0 // Optional -- Number: Since an EOA, can be used to deploy multiple wallets. you can supply any index and it will deploy wallet for you }) // Returns the response given below @@ -151,9 +197,9 @@ await aarcSDK.transferNativeAndDeploy({ ## Smart Wallet Integration The Aarc SDK seamlessly integrates with different smart wallets. It currently supports Safe and Biconomy smart wallets and will add more options in the future. -### Safe smart wallet +### Safe Smart Wallet -Fetching Existing Safes: +#### Fetching Existing Safes: Retrieve a list of all Safe smart wallets associated with the user's EOA: ```typescript @@ -161,7 +207,7 @@ const safes = await aarcSDK.getAllSafes(owner: string); // owner's eoaAddress // This returns an array of Safe wallet addresses ``` -Creating a New Safe Wallet: +#### Creating a New Safe Wallet: Generate a new Safe smart wallet. The address returned is a counterfactual address, and the wallet needs to be deployed later. Asset migration can be directed to this address even before deployment. ```typescript @@ -174,7 +220,7 @@ const newSafeAddress = await aarcSDK.generateSafeSCW( ### Biconomy Smart Wallet -Fetching Biconomy Smart Wallets: +#### Fetching Biconomy Smart Wallets: Retrieve a list of all Biconomy smart wallets associated with the user's EOA: ```typescript @@ -182,7 +228,7 @@ const biconomySWs = await aarcSDK.getAllBiconomySCWs(owner: string); // owner's // This returns an array of Biconomy wallet addresses ``` -Creating a New Biconomy Wallet: +#### Creating a New Biconomy Wallet: Similar to the Safe wallet, you can create a Biconomy smart wallet. The address provided is also a counterfactual address, requiring later deployment. The migration process can target this address immediately. ```typescript @@ -192,14 +238,14 @@ const newBiconomySCWAddress = await aarcSDK.generateBiconomySCW( // Returns a counterfactual address for the new Biconomy wallet ``` -## Wallet Deployment +## Smart Wallet Deployment You have the capability to deploy Biconomy or Safe wallets by utilizing the provided code snippets. -The code snippet below showcases how to deploy a wallet using the AarcSDK. It involves specifying essential parameters such as the owner's address (EOA_ADDRESS), the type of wallet to deploy (WALLET_TYPE.BICONOMY or WALLET_TYPE.SAFE), the signer (ethers.signer object), and an optional index for deploying multiple wallets under the same EOA. +The code snippet below showcases how to deploy a wallet using the AarcSDK. It involves specifying essential parameters such as the owner's address (`EOA_ADDRESS`), the type of wallet to deploy (`WALLET_TYPE.BICONOMY` or `WALLET_TYPE.SAFE`), the `signer` (ethers.signer object), and an optional index for deploying multiple wallets under the same EOA. -#### NOTE -If the wallet corresponding to the provided owner address (EOA_ADDRESS) and index (deploymentWalletIndex) is already deployed, the deployment process will not occur. +> [!NOTE] +If the wallet corresponding to the provided owner address (`EOA_ADDRESS`) and index (`deploymentWalletIndex`) is already deployed, the deployment process will not occur. ```typescript @@ -213,7 +259,7 @@ await aarcSDK.deployWallet({ }) ``` -#### More coming soon +### More coming soon 👀 ## License This project is licensed under the MIT License - see the [LICENSE](./LICENSE.md) for details. diff --git a/package-lock.json b/package-lock.json index a88f4ae..75cda85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,18 @@ { "name": "aarc-sdk", - "version": "0.0.1-beta.8", + "version": "0.2.0-beta.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "aarc-sdk", - "version": "0.0.1-beta.8", + "version": "0.2.0-beta.3", "license": "MIT", "dependencies": { "@biconomy/account": "^3.1.0", "@biconomy/modules": "^3.1.0", "@biconomy/node-client": "^3.1.0", "@ethersproject/hash": "^5.7.0", - "@gelatonetwork/relay-sdk": "^5.5.2", "@safe-global/api-kit": "^1.3.1", "@safe-global/protocol-kit": "^1.3.0", "@safe-global/safe-deployments": "^1.28.0", @@ -75,11 +74,6 @@ "resolved": "https://registry.npmjs.org/@account-abstraction/contracts/-/contracts-0.4.0.tgz", "integrity": "sha512-gj8231zGnvyhMhU2Ek/szS2Yg6Km9dcSj994g3YsMPxfIRUhXlr6cP0Qae+emS+MAS5s5PCM5C/WpgnZEpvpMA==" }, - "node_modules/@adraffy/ens-normalize": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz", - "integrity": "sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==" - }, "node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -1717,122 +1711,6 @@ "node": ">=14" } }, - "node_modules/@gelatonetwork/relay-sdk": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@gelatonetwork/relay-sdk/-/relay-sdk-5.5.2.tgz", - "integrity": "sha512-+uOzvYZ0F5mP1rE1AFuTJ+mP8M2uBdytvoWMJBGKYix4qiSkuAkJY1Mm8GzddIx5ZjeUrMNvLPtPEv304H/3wQ==", - "dependencies": { - "axios": "0.27.2", - "ethers": "6.7.0", - "isomorphic-ws": "^5.0.0", - "ws": "^8.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@gelatonetwork/relay-sdk/node_modules/@noble/hashes": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz", - "integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ] - }, - "node_modules/@gelatonetwork/relay-sdk/node_modules/@types/node": { - "version": "18.15.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", - "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" - }, - "node_modules/@gelatonetwork/relay-sdk/node_modules/aes-js": { - "version": "4.0.0-beta.5", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", - "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==" - }, - "node_modules/@gelatonetwork/relay-sdk/node_modules/axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", - "dependencies": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" - } - }, - "node_modules/@gelatonetwork/relay-sdk/node_modules/ethers": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.7.0.tgz", - "integrity": "sha512-pxt5hK82RNwcTX2gOZP81t6qVPVspnkpeivwEgQuK9XUvbNtghBnT8GNIb/gPh+WnVSfi8cXC9XlfT8sqc6D6w==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/ethers-io/" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@adraffy/ens-normalize": "1.9.2", - "@noble/hashes": "1.1.2", - "@noble/secp256k1": "1.7.1", - "@types/node": "18.15.13", - "aes-js": "4.0.0-beta.5", - "tslib": "2.4.0", - "ws": "8.5.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@gelatonetwork/relay-sdk/node_modules/ethers/node_modules/ws": { - "version": "8.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", - "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", - "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/@gelatonetwork/relay-sdk/node_modules/tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" - }, - "node_modules/@gelatonetwork/relay-sdk/node_modules/ws": { - "version": "8.14.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", - "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/@humanwhocodes/config-array": { "version": "0.11.13", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", @@ -2468,7 +2346,8 @@ "type": "individual", "url": "https://paulmillr.com/funding/" } - ] + ], + "peer": true }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", @@ -8564,14 +8443,6 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, - "node_modules/isomorphic-ws": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz", - "integrity": "sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==", - "peerDependencies": { - "ws": "*" - } - }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", diff --git a/package.json b/package.json index 4473530..884d795 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aarc-sdk", - "version": "0.2.0-beta.1", + "version": "0.2.0-beta.4", "description": "The Aarc SDK is a TypeScript library that makes it easy for developers to transfer assets from Externally Owned Accounts (EOA) to any destination address. It simplifies the asset transfer process by supporting various token standards, such as ERC20 and ERC721, and offering custom flows like batched transactions, gasless transactions, and paying gas fees with the same asset being moved. Additionally, it enables custom contract interaction within the same transaction using permit2(), allowing for direct swaps and bridge functionality.", "main": "dist/index.js", "scripts": { @@ -13,7 +13,8 @@ "execute:gasless": "ts-node scripts/Gasless.ts", "execute:nongasless": "ts-node scripts/NonGasless.ts", "execute:forward": "ts-node scripts/Forward.ts", - "prepare": "husky install" + "prepare": "husky install", + "publish": "npm run build && npm publish" }, "lint-staged": { "*.{js,jsx,ts,tsx,json,css,scss,md}": [ @@ -69,7 +70,6 @@ "@biconomy/modules": "^3.1.0", "@biconomy/node-client": "^3.1.0", "@ethersproject/hash": "^5.7.0", - "@gelatonetwork/relay-sdk": "^5.5.2", "@safe-global/api-kit": "^1.3.1", "@safe-global/protocol-kit": "^1.3.0", "@safe-global/safe-deployments": "^1.28.0", diff --git a/readme_assets/1.png b/readme_assets/1.png new file mode 100644 index 0000000..5cc1c53 Binary files /dev/null and b/readme_assets/1.png differ diff --git a/scripts/Constants.ts b/scripts/Constants.ts index 601c35f..43e87db 100644 --- a/scripts/Constants.ts +++ b/scripts/Constants.ts @@ -4,7 +4,6 @@ dotenv.config(); export const PRIVATE_KEY = process.env.PRIVATE_KEY || ""; export const RPC_URL = process.env.RPC_URL || ""; export const API_KEY = process.env.API_KEY || ""; -export const GELATO_API_KEY = process.env.GELATO_API_KEY || ""; export const DAPP_API_KEY = process.env.DAPP_API_KEY || "" @@ -85,7 +84,6 @@ export const validateEnvironmentVariables = () => { if (!PRIVATE_KEY) missingVariables.push('PRIVATE_KEY'); if (!RPC_URL) missingVariables.push('RPC_URL'); if (!API_KEY) missingVariables.push('API_KEY'); - if (!GELATO_API_KEY) missingVariables.push('GELATO_API_KEY'); if (missingVariables.length > 0) { throw new Error(`Missing environment variables: ${missingVariables.join(', ')}`); diff --git a/scripts/Forward.ts b/scripts/Forward.ts index c672617..dce4134 100644 --- a/scripts/Forward.ts +++ b/scripts/Forward.ts @@ -44,10 +44,10 @@ export const mintAndTransferErc20Tokens = async () => { senderSigner: signer, receiverAddress: "0x786E6045eacb96cAe0259cd761e151b68B85bdA7", transferTokenDetails: [ - { tokenAddress: tokenAddresses[chainId].USDA1.address, amount: BigNumber.from("100000000") }, - { tokenAddress: tokenAddresses[chainId].USDB.address, amount: BigNumber.from("100000000") }, - { tokenAddress: tokenAddresses[chainId].USDA2.address, amount: BigNumber.from("500000000") }, - { tokenAddress: tokenAddresses[chainId].USDC.address, amount: BigNumber.from("300000") }, + { tokenAddress: tokenAddresses[chainId].USDA1.address, amount: BigNumber.from("100000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDB.address, amount: BigNumber.from("100000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDA2.address, amount: BigNumber.from("500000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDC.address, amount: BigNumber.from("300000")._hex }, ] }) console.log('ResultSet ', resultSet); diff --git a/scripts/Gasless.ts b/scripts/Gasless.ts index 91eba7b..143f9c1 100644 --- a/scripts/Gasless.ts +++ b/scripts/Gasless.ts @@ -63,6 +63,10 @@ export const mintAndTransferErc20Tokens = async () => { for (const tokenName in tokenAddresses[chainId]) { console.log(' tokenName ', tokenName); const { address, decimals } = tokenAddresses[chainId][tokenName as keyof typeof TokenName]; + + if (!address) + continue + const token = balances.data.find(token => { return token.token_address.toLowerCase() === address.toLowerCase() }) @@ -87,10 +91,10 @@ export const mintAndTransferErc20Tokens = async () => { senderSigner: signer, receiverAddress: "0x786E6045eacb96cAe0259cd761e151b68B85bdA7", transferTokenDetails: [ - { tokenAddress: tokenAddresses[chainId].USDA1.address, amount: BigNumber.from("100000000") }, - { tokenAddress: tokenAddresses[chainId].USDB.address, amount: BigNumber.from("100000000") }, - { tokenAddress: tokenAddresses[chainId].USDA2.address, amount: BigNumber.from("500000000") }, - { tokenAddress: tokenAddresses[chainId].USDC.address, amount: BigNumber.from("30000") }, + { tokenAddress: tokenAddresses[chainId].USDA1.address, amount: BigNumber.from("100000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDB.address, amount: BigNumber.from("100000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDA2.address, amount: BigNumber.from("500000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDC.address, amount: BigNumber.from("30000")._hex }, ] }) console.log('ResultSet ', resultSet); @@ -146,7 +150,7 @@ export const transferErc20Tokens = async () => { if (token) { - transferTokenDetails.push({ tokenAddress: address, amount: token.balance }) + transferTokenDetails.push({ tokenAddress: address, amount: (token.balance)._hex }) } } @@ -166,7 +170,7 @@ export const transferErc20Tokens = async () => { !('message' in result && typeof result.message === 'string') || !('taskId' in result && typeof result.taskId === 'string') || (result.message !== 'Transaction sent' && - result.message !== 'Supplied token does not exist' && + result.message !== 'Insufficient balance' && result.message !== 'Transaction Added to Queue' && result.message !== 'Token Permit tx Sent') ) { @@ -209,7 +213,7 @@ export const transferFullNativeOnly = async () => { const resultSet = await aarcSDK.executeMigrationGasless({ senderSigner: signer, receiverAddress: '0x786E6045eacb96cAe0259cd761e151b68B85bdA7', - transferTokenDetails: [{ tokenAddress: '0x0000000000000000000000000000000000001010', amount: BigNumber.from(1000) }] + transferTokenDetails: [{ tokenAddress: '0x0000000000000000000000000000000000001010', amount: BigNumber.from(1000)._hex }] }) console.log('ResultSet ', resultSet); @@ -303,7 +307,7 @@ export const transferNftsOnly = async () => { !('message' in result && typeof result.message === 'string') || !('txHash' in result && typeof result.txHash === 'string') || (result.message !== 'Transaction sent' && - result.message !== 'Supplied token does not exist' && + result.message !== 'Insufficient balance' && result.message !== 'Nft transfer tx sent') ) { throw new Error('Nft Transfer Failed'); diff --git a/scripts/NonGasless.ts b/scripts/NonGasless.ts index e963d98..f37a73e 100644 --- a/scripts/NonGasless.ts +++ b/scripts/NonGasless.ts @@ -1,6 +1,6 @@ import { BigNumber, ethers } from "ethers"; import { AarcSDK } from '../src'; -import { RPC_URL, PRIVATE_KEY, API_KEY, GELATO_API_KEY, nativeTokenAddress, tokenAddresses, TokenName, ChainID, nativeTokenAddresses, MUMBAI_NFT_ADDRESS, validateEnvironmentVariables } from "./Constants"; +import { RPC_URL, PRIVATE_KEY, API_KEY, tokenAddresses, TokenName, ChainID, nativeTokenAddresses, MUMBAI_NFT_ADDRESS, validateEnvironmentVariables } from "./Constants"; import { ERC20_ABI } from '../src/utils/abis/ERC20.abi'; import { ERC721_ABI } from "../src/utils/abis/ERC721.abi"; import { delay } from "../src/helpers"; @@ -65,10 +65,10 @@ export const transferErc20Tokens = async () => { senderSigner: signer, receiverAddress: "0x786E6045eacb96cAe0259cd761e151b68B85bdA7", transferTokenDetails: [ - { tokenAddress: tokenAddresses[chainId].USDA1.address, amount: BigNumber.from("100000000") }, - { tokenAddress: tokenAddresses[chainId].USDB.address, amount: BigNumber.from("100000000") }, - { tokenAddress: tokenAddresses[chainId].USDA2.address, amount: BigNumber.from("500000000") }, - { tokenAddress: tokenAddresses[chainId].USDC.address, amount: BigNumber.from("30000000000000000") }, + { tokenAddress: tokenAddresses[chainId].USDA1.address, amount: BigNumber.from("100000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDB.address, amount: BigNumber.from("100000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDA2.address, amount: BigNumber.from("500000000")._hex }, + { tokenAddress: tokenAddresses[chainId].USDC.address, amount: BigNumber.from("30000000000000000")._hex }, ], }) console.log('ResultSet ', resultSet); @@ -126,7 +126,7 @@ export const transferFullNativeOnly = async () => { const resultSet = await aarcSDK.executeMigration({ senderSigner: signer, receiverAddress: '0x786E6045eacb96cAe0259cd761e151b68B85bdA7', - transferTokenDetails: [{tokenAddress: '0x0000000000000000000000000000000000001010', amount: BigNumber.from(1000)}], + transferTokenDetails: [{tokenAddress: '0x0000000000000000000000000000000000001010', amount: BigNumber.from(1000)._hex}], }) console.log('ResultSet ', resultSet); diff --git a/src/AarcSDK.ts b/src/AarcSDK.ts index c46c736..ebff954 100644 --- a/src/AarcSDK.ts +++ b/src/AarcSDK.ts @@ -34,7 +34,6 @@ import { } from './utils/AarcTypes'; import { PERMIT2_BATCH_TRANSFER_ABI } from './utils/abis/Permit2BatchTransfer.abi'; import { PERMIT2_SINGLE_TRANSFER_ABI } from './utils/abis/Permit2SingleTransfer.abi'; -import { GelatoRelay } from '@gelatonetwork/relay-sdk'; import Biconomy from './providers/Biconomy'; import Safe from './providers/Safe'; import { PermitHelper } from './helpers/PermitHelper'; @@ -65,7 +64,6 @@ class AarcSDK { safe: Safe; chainId: number; apiKey: string; - relayer: GelatoRelay; ethersProvider!: ethers.providers.JsonRpcProvider; permitHelper: PermitHelper; @@ -85,7 +83,6 @@ class AarcSDK { this.ethersProvider = new ethers.providers.JsonRpcProvider(rpcUrl); // instantiating Gelato Relay SDK - this.relayer = new GelatoRelay(); this.permitHelper = new PermitHelper(rpcUrl, chainId); } @@ -142,7 +139,7 @@ class AarcSDK { } if (amount && BigNumber.from(amount).gt(0)) { - amountToTransfer = amount; + amountToTransfer = BigNumber.from(amount); } else { amountToTransfer = BigNumber.from( await this.ethersProvider.getBalance(owner), @@ -162,7 +159,7 @@ class AarcSDK { Logger.log('walletDeploymentResponse ', walletDeploymentResponse); response.push({ tokenAddress: '', - amount: BigNumber.from(0), + amount: BigNumber.from(0)._hex, message: walletDeploymentResponse.startsWith('0x') ? 'Deployment tx sent' : walletDeploymentResponse, @@ -175,7 +172,7 @@ class AarcSDK { Logger.error(error); response.push({ tokenAddress: '', - amount: amountToTransfer, + amount: amountToTransfer._hex, message: 'Deployment Tx Failed', txHash: '', }); @@ -189,7 +186,7 @@ class AarcSDK { response.push({ tokenAddress: GAS_TOKEN_ADDRESSES[this.chainId as ChainId], - amount: amountToTransfer, + amount: amountToTransfer._hex, message: typeof txHash === 'string' ? 'Token transfer tx sent' @@ -273,7 +270,7 @@ class AarcSDK { response.push({ tokenAddress: tandA.tokenAddress, amount: tandA?.amount, - message: 'Supplied token does not exist', + message: `Insufficient balance`, }); } tandA.tokenAddress = tandA.tokenAddress.toLowerCase(); @@ -379,7 +376,7 @@ class AarcSDK { ); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Insufficient balance for transaction', txHash: '', }); @@ -395,7 +392,7 @@ class AarcSDK { }); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, tokenId: tx.tokenId, message: 'Nft transfer tx sent', txHash: typeof txHash === 'string' ? txHash : '', @@ -405,7 +402,7 @@ class AarcSDK { logError(tx, error); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Nft transfer failed', txHash: '', }); @@ -417,11 +414,11 @@ class AarcSDK { senderSigner: senderSigner, recipientAddress: receiverAddress, tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: BigNumber.from(tx.amount), }); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: BigNumber.from(tx.amount)._hex, message: 'Token transfer tx sent', txHash: typeof txHash === 'string' ? txHash : '', }); @@ -429,7 +426,7 @@ class AarcSDK { logError(tx, error); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Token transfer failed', txHash: '', }); @@ -447,7 +444,7 @@ class AarcSDK { response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Native transfer tx sent', txHash: typeof txHash === 'string' ? txHash : '', }); @@ -455,7 +452,7 @@ class AarcSDK { logError(tx, error); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Native transfer failed', txHash: '', }); @@ -528,7 +525,7 @@ class AarcSDK { response.push({ tokenAddress: tandA.tokenAddress, amount: tandA?.amount, - message: 'Supplied token does not exist', + message: `Insufficient balance`, }); } tandA.tokenAddress = tandA.tokenAddress.toLowerCase(); @@ -615,7 +612,7 @@ class AarcSDK { ); response.push({ tokenAddress: token.token_address, - amount: token.balance, + amount: token.balance._hex, message: 'Permit token failed', txHash: '', }); @@ -660,7 +657,6 @@ class AarcSDK { throw new Error('unable to get data'); } const relayTrxDto: RelayTrxDto = { - relayer: this.relayer, requestData: { chainId: BigInt(this.chainId), target: PERMIT2_CONTRACT_ADDRESS, @@ -729,7 +725,6 @@ class AarcSDK { } const relayTrxDto: RelayTrxDto = { - relayer: this.relayer, requestData: { chainId: BigInt(this.chainId), target: PERMIT2_CONTRACT_ADDRESS, @@ -757,13 +752,13 @@ class AarcSDK { logError( { tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, }, error, ); response.push({ tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, message: 'Transaction Failed', txHash: '', }); @@ -783,7 +778,7 @@ class AarcSDK { if (type === PERMIT_TX_TYPES.PERMIT2_BATCH) { for (let index = 0; index < tokenInfo.length; index++) { const token_address = tokenInfo[index].tokenAddress; - const amount = tokenInfo[index].amount; + const amount = BigNumber.from(tokenInfo[index].amount)._hex; response.push({ taskId, tokenAddress: token_address, @@ -798,7 +793,7 @@ class AarcSDK { response.push({ taskId, tokenAddress: tokenInfo[0].tokenAddress, - amount: tokenInfo[0].amount, + amount: BigNumber.from(tokenInfo[0].amount)._hex, message: typeof status === 'string' ? status : 'Transaction Failed', txHash: '', @@ -809,7 +804,7 @@ class AarcSDK { response.push({ taskId, tokenAddress: tokenInfo[0].tokenAddress, - amount: tokenInfo[0].amount, + amount: BigNumber.from(tokenInfo[0].amount)._hex, message: typeof status === 'string' ? status : 'Transaction Failed', txHash: '', @@ -855,7 +850,7 @@ class AarcSDK { ); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Insufficient balance for transaction', txHash: '', }); @@ -871,7 +866,7 @@ class AarcSDK { }); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, tokenId: tx.tokenId, message: 'Nft transfer tx sent', txHash: typeof txHash === 'string' ? txHash : '', @@ -880,7 +875,7 @@ class AarcSDK { logError(tx, error); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Nft transfer failed', txHash: '', }); @@ -896,7 +891,7 @@ class AarcSDK { }); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Token transfer tx sent', txHash: typeof txHash === 'string' ? txHash : '', }); @@ -904,7 +899,7 @@ class AarcSDK { logError(tx, error); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Token transfer failed', txHash: '', }); @@ -922,7 +917,7 @@ class AarcSDK { response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Native transfer tx sent', txHash: typeof txHash === 'string' ? txHash : '', }); @@ -930,7 +925,7 @@ class AarcSDK { logError(tx, error); response.push({ tokenAddress: tx.tokenAddress, - amount: tx.amount, + amount: tx.amount._hex, message: 'Native transfer failed', txHash: '', }); @@ -1038,10 +1033,23 @@ class AarcSDK { response.push({ tokenAddress: tandA.tokenAddress, amount: tandA?.amount, - message: 'Supplied token does not exist', + message: `Insufficient balance`, }); } tandA.tokenAddress = tandA.tokenAddress.toLowerCase(); + + if ( + matchingToken && + !matchingToken.permitExist && + BigNumber.from(matchingToken.permit2Allowance).eq(BigNumber.from(0)) + ) { + response.push({ + tokenAddress: tandA.tokenAddress.toLowerCase(), + message: `Forward migration is not supported for ${tandA.tokenAddress.toLowerCase()} on the chain ID ${ + this.chainId + }`, + }); + } }); if (transferTokenDetails) { @@ -1142,7 +1150,7 @@ class AarcSDK { ); response.push({ tokenAddress: token.token_address, - amount: token.balance, + amount: token.balance._hex, message: 'Permit token failed', txHash: '', }); @@ -1187,7 +1195,6 @@ class AarcSDK { throw new Error('unable to get data'); } const relayTrxDto: RelayTrxDto = { - relayer: this.relayer, requestData: { chainId: BigInt(this.chainId), target: PERMIT2_CONTRACT_ADDRESS, @@ -1259,7 +1266,6 @@ class AarcSDK { } const relayTrxDto: RelayTrxDto = { - relayer: this.relayer, requestData: { chainId: BigInt(this.chainId), target: PERMIT2_CONTRACT_ADDRESS, @@ -1287,13 +1293,13 @@ class AarcSDK { logError( { tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, }, error, ); response.push({ tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, message: 'Transaction Failed', txHash: '', }); @@ -1315,7 +1321,7 @@ class AarcSDK { if (type === PERMIT_TX_TYPES.PERMIT2_BATCH) { for (let index = 0; index < tokenInfo.length; index++) { const token_address = tokenInfo[index].tokenAddress; - const amount = tokenInfo[index].amount; + const amount = BigNumber.from(tokenInfo[index].amount)._hex; response.push({ taskId, tokenAddress: token_address, @@ -1330,7 +1336,7 @@ class AarcSDK { response.push({ taskId, tokenAddress: tokenInfo[0].tokenAddress, - amount: tokenInfo[0].amount, + amount: BigNumber.from(tokenInfo[0].amount)._hex, message: typeof status === 'string' ? status : 'Transaction Failed', txHash: '', @@ -1341,7 +1347,7 @@ class AarcSDK { response.push({ taskId, tokenAddress: tokenInfo[0].tokenAddress, - amount: tokenInfo[0].amount, + amount: BigNumber.from(tokenInfo[0].amount)._hex, message: typeof status === 'string' ? status : 'Transaction Failed', txHash: '', diff --git a/src/helpers/PermitHelper.ts b/src/helpers/PermitHelper.ts index f9a98aa..82a1b1d 100644 --- a/src/helpers/PermitHelper.ts +++ b/src/helpers/PermitHelper.ts @@ -441,7 +441,7 @@ export class PermitHelper { (token: TokenPermissions) => { response.push({ tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, message: 'Token transfer tx sent', txHash: txInfo.hash, }); @@ -458,13 +458,13 @@ export class PermitHelper { logError( { tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, }, error, ); response.push({ tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, message: 'Token transfer failed', txHash: '', }); @@ -476,7 +476,7 @@ export class PermitHelper { (token: TokenPermissions) => { response.push({ tokenAddress: token.token, - amount: token.amount, + amount: BigNumber.from(token.amount)._hex, message: 'Token transfer failed', txHash: '', }); diff --git a/src/helpers/helper.ts b/src/helpers/helper.ts index 76370be..da406a7 100644 --- a/src/helpers/helper.ts +++ b/src/helpers/helper.ts @@ -164,7 +164,7 @@ export const processTokenData = ( matchingToken.amount !== undefined && BigNumber.from(matchingToken.amount).gt(0) ) { - element.balance = matchingToken.amount; + element.balance = BigNumber.from(matchingToken.amount); } // Case: transferTokenDetails contains amount for token but it's greater than the given allowance @@ -269,7 +269,7 @@ export const processNativeTransfer = async ( matchingToken.amount !== undefined && BigNumber.from(matchingToken.amount).gt(0) ) { - amountTransfer = matchingToken.amount; + amountTransfer = BigNumber.from(matchingToken.amount); } else { const updatedNativeToken = await sdkObject.fetchBalances(owner, true, [ nativeToken[0].token_address, @@ -364,7 +364,7 @@ export const processGasFeeAndTokens = ( const gasFeeInEth = ethers.utils.formatEther(treasuryGasUnits); const gasFeeInUsd = nativePriceInUsd * Number(gasFeeInEth); const tokensToDeduct = BigNumber.from( - parseInt(String(Math.pow(10, treasuryTransaction.decimals) * gasFeeInUsd)), + String(Math.ceil(Math.pow(10, treasuryTransaction.decimals) * gasFeeInUsd)), ); const actualToken = BigNumber.from(currentTrx.balance); @@ -377,7 +377,7 @@ export const processGasFeeAndTokens = ( taskId: '', tokenAddress: currentTrx.token_address, message: 'Token does not have enough balance to pay for fee', - amount: actualToken, + amount: actualToken._hex, txHash: '', }); } else { diff --git a/src/utils/AarcTypes.ts b/src/utils/AarcTypes.ts index 7da4d8c..93c7443 100644 --- a/src/utils/AarcTypes.ts +++ b/src/utils/AarcTypes.ts @@ -1,14 +1,18 @@ -import { BigNumber, BigNumberish, Signer } from 'ethers'; +import { BigNumber, BigNumberish, Signer, BytesLike } from 'ethers'; import { ChainId } from './ChainTypes'; import { PermitTransferFrom, PermitBatchTransferFrom, TokenPermissions, } from '@uniswap/permit2-sdk'; -import { GelatoRelay } from '@gelatonetwork/relay-sdk'; -import { BaseRelayParams } from '@gelatonetwork/relay-sdk/dist/lib/types'; import { PERMIT_TX_TYPES } from './Constants'; +export type BaseRelayParams = { + chainId: bigint; + target: string; + data: BytesLike; +}; + export type Config = { chainId: number; rpcUrl: string; @@ -36,7 +40,7 @@ export type NativeTransferDeployWalletDto = { walletType: WALLET_TYPE; owner: string; receiver: string; - amount?: BigNumber; + amount?: string; signer: Signer; deploymentWalletIndex?: number; }; @@ -121,7 +125,7 @@ export type RelayedTxListResponse = { export type TransferTokenDetails = { tokenAddress: string; - amount?: BigNumber; // for ERC20 + amount?: string; // for ERC20 tokenIds?: string[]; // for ERC721 }; @@ -190,15 +194,9 @@ export type BatchPermitData = { }; export type RelayTrxDto = { - relayer: GelatoRelay; requestData: BaseRelayParams; }; -export type GelatoTxStatusDto = { - relayer: GelatoRelay; - taskId: string; -}; - export type PermitDto = { signer: Signer; chainId: ChainId; @@ -228,7 +226,7 @@ export type PermitDomainDto = { export type MigrationResponse = { tokenAddress: string; taskId?: string; - amount?: BigNumber | BigNumberish; + amount?: string; message: string; txHash?: string; tokenId?: string; diff --git a/tests/AarcSDK.test.ts b/tests/AarcSDK.test.ts index c69de50..219f4ee 100644 --- a/tests/AarcSDK.test.ts +++ b/tests/AarcSDK.test.ts @@ -134,11 +134,11 @@ describe('Aarc SDK executeMigration', () => { transferTokenDetails: [ { tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: BigNumber.from('1000000'), + amount: BigNumber.from('1000000')._hex, }, { tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: BigNumber.from('2000000000'), + amount: BigNumber.from('2000000000')._hex, }, ], receiverAddress: receiver, @@ -164,17 +164,13 @@ describe('Aarc SDK executeMigration', () => { // Verify the content of the response expect(migrationResponse[0]).toEqual({ tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: expect.objectContaining({ - _hex: '0x77359400', - }), - message: 'Supplied token does not exist', + amount: BigNumber.from(0x77359400)._hex, + message: 'Insufficient balance', }); expect(migrationResponse[1]).toEqual({ tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: expect.objectContaining({ - _hex: '0x0f4240', - }), + amount: '0x0f4240', message: 'Token transfer tx sent', txHash: 'token-transfer-0x1234567890', }); @@ -247,9 +243,7 @@ describe('Aarc SDK executeMigration', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', - amount: expect.objectContaining({ - _hex: '0x64', - }), + amount: '0x64', message: 'Native transfer tx sent', txHash: 'native-transfer-0x1234567890', }); @@ -380,19 +374,19 @@ describe('Aarc SDK executeMigration', () => { transferTokenDetails: [ { tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: BigNumber.from('0x1dcd6500'), + amount: BigNumber.from('0x1dcd6500')._hex, }, { tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: BigNumber.from('0x05f5e100'), + amount: BigNumber.from('0x05f5e100')._hex, }, { tokenAddress: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', - amount: BigNumber.from('0x6a94d74f430000'), + amount: BigNumber.from('0x6a94d74f430000')._hex, }, { tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', - amount: BigNumber.from('0x05f5e100'), + amount: BigNumber.from('0x05f5e100')._hex, }, ], receiverAddress: receiver, @@ -415,18 +409,14 @@ describe('Aarc SDK executeMigration', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', - amount: expect.objectContaining({ - hex: '0x989680', - }), + amount: '0x989680', message: 'Token transfer tx sent', txHash: 'permit-token-transfer-0x1234567890', }); expect(migrationResponse[1]).toEqual({ tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: expect.objectContaining({ - hex: '0x174876e800', - }), + amount: '0x174876e800', message: 'Token transfer tx sent', txHash: 'permit-token-transfer-0x1234567890', }); @@ -435,12 +425,12 @@ describe('Aarc SDK executeMigration', () => { senderSigner: signer, recipientAddress: receiver, tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', - amount: BigNumber.from(0x05f5e100), + amount: BigNumber.from('0x05f5e100'), }); expect(migrationResponse[2]).toEqual({ tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', - amount: BigNumber.from(0x05f5e100), + amount: '0x05f5e100', message: 'Token transfer tx sent', txHash: 'token-transfer-0x1234567890', }); @@ -449,12 +439,12 @@ describe('Aarc SDK executeMigration', () => { senderSigner: signer, recipientAddress: receiver, tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: BigNumber.from(0x1dcd6500), + amount: BigNumber.from('0x1dcd6500'), }); expect(migrationResponse[3]).toEqual({ tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: BigNumber.from(0x1dcd6500), + amount: '0x1dcd6500', message: 'Token transfer tx sent', txHash: 'token-transfer-0x1234567890', }); @@ -526,23 +516,21 @@ describe('Aarc SDK executeMigration', () => { senderSigner: signer, recipientAddress: receiver, tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: { type: 'BigNumber', hex: '0x989680' }, + amount: BigNumber.from('0x989680'), }); expect(aarcSDK.permitHelper.performNativeTransfer).toHaveBeenCalledTimes(1); expect(migrationResponse[0]).toEqual({ tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: { type: 'BigNumber', hex: '0x989680' }, + amount: '0x989680', message: 'Token transfer tx sent', txHash: 'token-transfer-0x1234567890', }); expect(migrationResponse[1]).toEqual({ tokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', - amount: expect.objectContaining({ - _hex: '0x7a1200', - }), + amount: '0x7a1200', message: 'Native transfer tx sent', txHash: 'native-transfer-0x1234567890', }); @@ -649,20 +637,14 @@ describe('Aarc SDK executeMigration', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: expect.objectContaining({ - type: 'BigNumber', - hex: '0x989680', - }), + amount: '0x989680', message: 'Token transfer tx sent', txHash: 'permit-token-transfer-0x1234567890', }); expect(migrationResponse[1]).toEqual({ tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: expect.objectContaining({ - type: 'BigNumber', - hex: '0x174876e800', - }), + amount: '0x174876e800', message: 'Token transfer tx sent', txHash: 'permit-token-transfer-0x1234567890', }); @@ -748,11 +730,11 @@ describe('Aarc SDK executeMigration', () => { transferTokenDetails: [ { tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: BigNumber.from('1000000'), + amount: BigNumber.from('0x0f4240')._hex, }, { tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: BigNumber.from('2000000000'), + amount: BigNumber.from('0x77359400')._hex, }, ], receiverAddress: receiver, @@ -767,18 +749,14 @@ describe('Aarc SDK executeMigration', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: expect.objectContaining({ - _hex: '0x0f4240', - }), + amount: '0x0f4240', message: 'Insufficient balance for transaction', txHash: '', }); expect(migrationResponse[1]).toEqual({ tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: expect.objectContaining({ - _hex: '0x77359400', - }), + amount: '0x77359400', message: 'Insufficient balance for transaction', txHash: '', }); diff --git a/tests/Forwarder.test.ts b/tests/Forwarder.test.ts new file mode 100644 index 0000000..6fa2654 --- /dev/null +++ b/tests/Forwarder.test.ts @@ -0,0 +1,339 @@ +import { BigNumber, Signer, ethers } from 'ethers'; +import { AarcSDK } from '../src'; // Adjust the path according to your directory structure +import { PermitHelper } from '../src/helpers/PermitHelper'; // Import the original class +import './EthersMock'; +import { + GELATO_RELAYER_ADDRESS, + PERMIT_TX_TYPES, +} from '../src/utils/Constants'; +import * as helperFunctions from '../src/helpers/helper'; // Import the helper file +import { RelayTxListResponse } from '../src/utils/AarcTypes'; + +jest.mock('../src/helpers/HttpHelper', () => ({ + fetchBalances: jest.fn(), + fetchNativeToUsdPrice: jest.requireActual('../src/helpers/HttpHelper') + .fetchNativeToUsdPrice, + fetchGasPrice: jest.fn(), +})); + +import { fetchBalances, fetchGasPrice } from '../src/helpers/HttpHelper'; + +let aarcSDK: any; + +describe('Aarc SDK executeForwardTransactions', () => { + const receiver = '0xe7a35625b23710C131Fa38c92CF5F7793c50604A'; + + const privateKey = + '29822a62aaeb9a16e9d1fd88412bac4fe37574bbcb245b4232e3b3612496fd96'; + const rpcUrl = 'https://ethereum-goerli.publicnode.com'; + const apiKey = 'd2ded745-c5f5-43d6-9577-869daf62488d'; + const provider = new ethers.providers.JsonRpcProvider(rpcUrl); + const signer = new ethers.Wallet(privateKey, provider); + const eoaAddress = signer.address; + let chainId: number; + + beforeEach(async () => { + (chainId = (await provider.getNetwork()).chainId), + (aarcSDK = new AarcSDK({ + rpcUrl: rpcUrl, + chainId, + apiKey: apiKey, + })); + + aarcSDK.permitHelper = new PermitHelper(rpcUrl, chainId); + jest + .spyOn(aarcSDK.permitHelper, 'performTokenTransfer') + .mockImplementation(() => 'token-transfer-0x1234567890'); + jest + .spyOn(aarcSDK.permitHelper, 'performNFTTransfer') + .mockImplementation(() => 'nft-transfer-0x1234567890'); + jest + .spyOn(aarcSDK.permitHelper, 'performNativeTransfer') + .mockImplementation(() => 'native-transfer-0x1234567890'); + jest + .spyOn(aarcSDK.permitHelper, 'performPermit') + .mockImplementation(() => 'permit-transfer-0x1234567890'); + + jest + .spyOn(aarcSDK.permitHelper, 'getBatchTransferPermitData') + .mockImplementation((batchTransferPermitDto: any) => { + const { spenderAddress } = batchTransferPermitDto; + // Simulate the behavior of the function based on your test requirements + const signature = 'mockedSignature'; // Replace with your mocked signature + + return { + permitBatchTransferFrom: { + permitted: [ + { + token: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', + amount: { type: 'BigNumber', hex: '0x05f5e100' }, + }, + { + token: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + amount: { type: 'BigNumber', hex: '0x1dcd6500' }, + }, + { + token: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', + amount: { type: 'BigNumber', hex: '0x05f5e100' }, + }, + { + token: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', + amount: { type: 'BigNumber', hex: '0x6a94d74f430000' }, + }, + ], + spender: spenderAddress, + deadline: 12345678, + nonce: 6623, + }, + signature, + }; + }); + + jest + .spyOn(aarcSDK.permitHelper, 'getSingleTransferPermitData') + .mockImplementation((singleTransferPermitDto: any) => { + const { spenderAddress } = singleTransferPermitDto; + // Simulate the behavior of the function based on your test requirements + const signature = 'mockedSignature'; // Replace with your mocked signature + + return { + permitTransferFrom: { + permitted: { + token: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + amount: { type: 'BigNumber', hex: '0x1dcd6500' }, + }, + spender: spenderAddress, + deadline: 12345678, + nonce: 6623, + }, + signature, + }; + }); + }, 30000); + + it('should do forwarder migration flow', async () => { + (fetchGasPrice as jest.Mock).mockResolvedValue({ + code: 200, + data: { + gasPrice: 1000000000, + }, + message: 'Success', + }); + + // Mocking the fetchBalances function + (fetchBalances as jest.Mock).mockResolvedValue({ + code: 200, + data: [ + { + decimals: 18, + name: 'ETH', + symbol: 'ETH', + native_token: true, + token_address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', + balance: { type: 'BigNumber', hex: '0x989680' }, + type: 'dust', + nft_data: null, + permit2Allowance: { + type: 'BigNumber', + hex: '0x0', + }, + permitExist: true, + }, + { + decimals: 6, + native_token: false, + name: 'USDA2', + symbol: 'USDA2', + token_address: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + balance: { type: 'BigNumber', hex: '0x1dcd6500' }, + type: 'cryptocurrency', + nft_data: null, + permit2Allowance: { type: 'BigNumber', hex: '0x1dcd650' }, + permitExist: true, + }, + { + decimals: 8, + native_token: false, + name: 'USDB', + symbol: 'USDB', + token_address: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', + balance: { type: 'BigNumber', hex: '0x05f5e100' }, + type: 'cryptocurrency', + nft_data: null, + permit2Allowance: { type: 'BigNumber', hex: '-0x01' }, + permitExist: true, + }, + { + decimals: 18, + native_token: false, + name: 'USDC', + symbol: 'USDC', + token_address: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', + balance: { type: 'BigNumber', hex: '0x6a94d74f430000' }, + type: 'cryptocurrency', + nft_data: null, + permit2Allowance: { type: 'BigNumber', hex: '-0x01' }, + permitExist: true, + }, + { + decimals: 6, + native_token: false, + name: 'USDA1', + symbol: 'USDA1', + token_address: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', + balance: { type: 'BigNumber', hex: '0x05f5e100' }, + type: 'cryptocurrency', + nft_data: null, + permit2Allowance: { type: 'BigNumber', hex: '0x00' }, + permitExist: true, + }, + ], + message: 'Success', + }); + jest + .spyOn(helperFunctions, 'makeForwardCall') + .mockImplementation(async (chainId, relayTxList) => { + const resultSet: RelayTxListResponse[] = [ + { + type: PERMIT_TX_TYPES.PERMIT, + tokenInfo: [ + { + tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + amount: BigNumber.from(ethers.constants.MaxUint256), + }, + ], + taskId: 'permit-tx-123456', + status: 'permit-hash-12345', + }, + { + type: PERMIT_TX_TYPES.PERMIT, + tokenInfo: [ + { + tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', + amount: BigNumber.from(ethers.constants.MaxUint256), + }, + ], + taskId: 'permit-tx-123456', + status: 'permit-hash-12345', + }, + { + type: PERMIT_TX_TYPES.PERMIT2_BATCH, + tokenInfo: [ + { + tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', + amount: BigNumber.from(0x05f5e100), + }, + { + tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + amount: BigNumber.from(0x1dcd6500), + }, + { + tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', + amount: BigNumber.from(0x05f5e100), + }, + { + tokenAddress: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', + amount: BigNumber.from(0x1dcd6500), + }, + ], + taskId: 'permit-batch-tx-123456', + status: 'permit-batch-hash-12345', + }, + ]; + return resultSet; + }); + const executeMigrationDto = { + senderSigner: signer, + transferTokenDetails: [ + { + tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + amount: BigNumber.from('0x1dcd6500'), + }, + { + tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', + amount: BigNumber.from('0x05f5e100'), + }, + { + tokenAddress: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', + amount: BigNumber.from('0x1dcd6500'), + }, + { + tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', + amount: BigNumber.from('0x05f5e100'), + }, + ], + receiverAddress: receiver, + }; + + const migrationResponse = + await aarcSDK.executeForwardTransaction(executeMigrationDto); + expect(Array.isArray(migrationResponse)).toBe(true); + expect(migrationResponse).toHaveLength(7); + + expect(aarcSDK.permitHelper.performPermit).toHaveBeenCalled(); + expect(aarcSDK.permitHelper.performPermit).toHaveBeenCalledTimes(2); + expect(aarcSDK.permitHelper.performPermit).toHaveBeenCalledWith({ + signer, + chainId, + eoaAddress, + tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + }); + expect(aarcSDK.permitHelper.getBatchTransferPermitData).toHaveBeenCalled(); + expect(migrationResponse[0]).toEqual({ + tokenAddress: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', + amount: BigNumber.from(0x1dcd6500)._hex, + message: 'Token does not have enough balance to pay for fee', + taskId: '', + txHash: '', + }); + + expect(migrationResponse[1]).toEqual({ + tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + amount: BigNumber.from(ethers.constants.MaxUint256)._hex, + message: 'permit-hash-12345', + taskId: 'permit-tx-123456', + txHash: '', + }); + + expect(migrationResponse[2]).toEqual({ + tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', + amount: BigNumber.from(ethers.constants.MaxUint256)._hex, + message: 'permit-hash-12345', + taskId: 'permit-tx-123456', + txHash: '', + }); + + // Verify the content of the response + expect(migrationResponse[3]).toEqual({ + tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', + amount: BigNumber.from(0x05f5e100)._hex, + message: 'permit-batch-hash-12345', + taskId: 'permit-batch-tx-123456', + txHash: '', + }); + + expect(migrationResponse[4]).toEqual({ + tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', + amount: BigNumber.from(0x1dcd6500)._hex, + message: 'permit-batch-hash-12345', + taskId: 'permit-batch-tx-123456', + txHash: '', + }); + + expect(migrationResponse[5]).toEqual({ + tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', + amount: BigNumber.from(0x05f5e100)._hex, + message: 'permit-batch-hash-12345', + taskId: 'permit-batch-tx-123456', + txHash: '', + }); + + expect(migrationResponse[6]).toEqual({ + tokenAddress: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', + amount: BigNumber.from(0x1dcd6500)._hex, + message: 'permit-batch-hash-12345', + taskId: 'permit-batch-tx-123456', + txHash: '', + }); + }, 30000); +}); diff --git a/tests/Gasless.test.ts b/tests/Gasless.test.ts index 0f72465..50c4ef8 100644 --- a/tests/Gasless.test.ts +++ b/tests/Gasless.test.ts @@ -584,7 +584,7 @@ describe('Aarc SDK executeMigrationGasless', () => { expect(aarcSDK.permitHelper.getBatchTransferPermitData).toHaveBeenCalled(); expect(migrationResponse[0]).toEqual({ tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: BigNumber.from(ethers.constants.MaxUint256), + amount: BigNumber.from(ethers.constants.MaxUint256)._hex, message: 'permit-hash-12345', taskId: 'permit-tx-123456', txHash: '', @@ -592,7 +592,7 @@ describe('Aarc SDK executeMigrationGasless', () => { expect(migrationResponse[1]).toEqual({ tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', - amount: BigNumber.from(ethers.constants.MaxUint256), + amount: BigNumber.from(ethers.constants.MaxUint256)._hex, message: 'permit-hash-12345', taskId: 'permit-tx-123456', txHash: '', @@ -601,7 +601,7 @@ describe('Aarc SDK executeMigrationGasless', () => { // Verify the content of the response expect(migrationResponse[2]).toEqual({ tokenAddress: '0xbb8bb7e16d8f03969d49fd3ed0efd13e65c8f5b5', - amount: BigNumber.from(0x05f5e100), + amount: BigNumber.from(0x05f5e100)._hex, message: 'permit-batch-hash-12345', taskId: 'permit-batch-tx-123456', txHash: '', @@ -609,7 +609,7 @@ describe('Aarc SDK executeMigrationGasless', () => { expect(migrationResponse[3]).toEqual({ tokenAddress: '0xf4ca1a280ebccdaebf80e3c128e55de01fabd893', - amount: BigNumber.from(0x1dcd6500), + amount: BigNumber.from(0x1dcd6500)._hex, message: 'permit-batch-hash-12345', taskId: 'permit-batch-tx-123456', txHash: '', @@ -617,7 +617,7 @@ describe('Aarc SDK executeMigrationGasless', () => { expect(migrationResponse[4]).toEqual({ tokenAddress: '0xbb8db535d685f2742d6e84ec391c63e6a1ce3593', - amount: BigNumber.from(0x05f5e100), + amount: BigNumber.from(0x05f5e100)._hex, message: 'permit-batch-hash-12345', taskId: 'permit-batch-tx-123456', txHash: '', @@ -625,7 +625,7 @@ describe('Aarc SDK executeMigrationGasless', () => { expect(migrationResponse[5]).toEqual({ tokenAddress: '0xb18059aa6483ba71d6d3dfabad53616b00ea2aba', - amount: BigNumber.from(0x1dcd6500), + amount: BigNumber.from(0x1dcd6500)._hex, message: 'permit-batch-hash-12345', taskId: 'permit-batch-tx-123456', txHash: '', diff --git a/tests/Native.test.ts b/tests/Native.test.ts index d3280f4..d68eb2f 100644 --- a/tests/Native.test.ts +++ b/tests/Native.test.ts @@ -111,9 +111,7 @@ describe('Aarc SDK executeMigration', () => { expect(aarcSDK.permitHelper.performNativeTransfer).toHaveBeenCalledTimes(1); expect(migrationResponse[0]).toEqual({ tokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', - amount: expect.objectContaining({ - _hex: '0x989680', - }), + amount: '0x989680', message: 'Native transfer tx sent', txHash: 'native-transfer-0x1234567890', }); @@ -155,9 +153,7 @@ describe('Aarc SDK executeMigration', () => { expect(aarcSDK.permitHelper.performNativeTransfer).toHaveBeenCalledTimes(1); expect(migrationResponse[0]).toEqual({ tokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', - amount: expect.objectContaining({ - _hex: '0x7a1200', - }), + amount: '0x7a1200', message: 'Native transfer tx sent', txHash: 'native-transfer-0x1234567890', }); diff --git a/tests/nftTransfer.test.ts b/tests/nftTransfer.test.ts index 448c0d7..cb5fbca 100644 --- a/tests/nftTransfer.test.ts +++ b/tests/nftTransfer.test.ts @@ -185,7 +185,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '1', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -193,7 +193,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[1]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '2', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -333,7 +333,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '1', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -341,7 +341,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[1]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '2', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -349,7 +349,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[2]).toEqual({ tokenAddress: '0x897ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '4', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -357,7 +357,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[3]).toEqual({ tokenAddress: '0x897ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '8', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -365,7 +365,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[4]).toEqual({ tokenAddress: '0x897ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '11', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -508,7 +508,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '1', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -516,7 +516,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[1]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '2', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -524,7 +524,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[2]).toEqual({ tokenAddress: '0x897ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '4', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -532,7 +532,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[3]).toEqual({ tokenAddress: '0x897ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '8', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -540,7 +540,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[4]).toEqual({ tokenAddress: '0x897ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '11', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -641,7 +641,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[1]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '1', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -744,7 +744,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[1]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '1', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -845,7 +845,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[0]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '1', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890', @@ -853,7 +853,7 @@ describe('Aarc SDK nft transfer', () => { expect(migrationResponse[1]).toEqual({ tokenAddress: '0x932ca55b9ef0b3094e8fa82435b3b4c50d713043', - amount: BigNumber.from(1), + amount: BigNumber.from(1)._hex, tokenId: '2', message: 'Nft transfer tx sent', txHash: 'nft-transfer-0x1234567890',