Skip to content

Commit

Permalink
Aarc SDK version 0.2.0-beta.1 (#50)
Browse files Browse the repository at this point in the history
* tests and safe deploy fun

* internal functions mocking

* tests updated

* Signer fix and biconomy get wallets function (#20)

* signer constructor requirement removed

* biconomy get all wallets function added

* types added for multiple params

* testing workflow added

* Sdk bug fixes (#21)

* nft tokenId added

* types file name change

* readme update

* nft transfer gasless updated

* package version changes

* Update README.md

* Update README.md - CRITICAL (#26)

Updated the rebranded form link

* Update README.md (#24)

* Update README.md

Fixed typo

* relayer key added

---------

Co-authored-by: Anshul Yadav <55681256+anshulforyou@users.noreply.github.com>

* estimation implementation for both non gasless and gasless flow (#25)

* gas estimation addition

* fixes

* fixes and tests update

* sig transfer file removed

* insufficient balance unit test added

---------

Co-authored-by: Anshul Yadav <55681256+anshulforyou@users.noreply.github.com>

* Nft edge cases fix (#29)

* duplicate entry bug fix

* amount edge case fix

* optimised and refactored the code

* nft tests updated for gas estimation

* types check added (#30)

* Feat/linting enabled (#31)

* types check added

* linting enabled fix

* pre hook commit

* Cosmetic/code refactoring (#33)

* code division

* native token refactor

* Permit2 transactions refactor

* test fix for not a function issue and some lint rule

* test failed fix added

* minor fixes

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>

* readme bugfix

* test script for both gasless and non gasless and bug fixes (#32)

* test script for both gasless and non gasless and bug fixes

* test fixes

* only balances flag addition

* added scripts as pre-commit hook

* merge changes

* fixes and scripts update

* url fix

---------

Co-authored-by: Anshul Yadav <55681256+anshulforyou@users.noreply.github.com>

* Update README.md (#37)

Updated the booking link with the new team Calendly link.

* Fix/gasless bug (#36)

* gasless bug

* test update

* transaction messages

* formatting

* bug fix

* test fixes

* single permit2 unit test added

* lint changes

* POLYGON fix for USDC permit

* permitToken wait bug fix

* error fix

---------

Co-authored-by: Anshul Yadav <55681256+anshulforyou@users.noreply.github.com>

* arbitrum goerli support added (#38)

* arbitrum goerli support added

* arbitrum goerli scripts added and tested

* version update

* minor changes

* Feat/wallet deployment (#41)

* walelt deployment and native transfer

* formatting

* safe bug fix

* bug fixes

* permit bug fix (#42)

* permit bug fix

* transfer available tokens

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>

* package version update

* readme updated (#45)

* readme updated

* wallet deploy bug fixes

* formatting changes

---------

Co-authored-by: Anshul Yadav <55681256+anshulforyou@users.noreply.github.com>

* minor fixes

* Feat/gasless gelato (#46)

* readme updated

* gasless endpoint integration

* tokenInfo changed to array

* url updated

* test fixes

* gasless updates in sdk

* forward implementation (#48)

* foward implementation

* fixes

* fixes added

* test fix and gasPrice endpoint consumption

* Feat/forward (#51)

* readme updated

* gasless endpoint integration

* tokenInfo changed to array

* url updated

* test fixes

* gasless updates in sdk

* foward implementation

* fixes

* fixes added

* test fix and gasPrice endpoint consumption

* final fixes

* url update

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>
Co-authored-by: Ari <52634803+theblackmace@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 5, 2024
1 parent 3120d73 commit fe3699c
Show file tree
Hide file tree
Showing 18 changed files with 1,644 additions and 594 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ npm run test
npm run build
npm run execute:nongasless
npm run execute:gasless
npm run execute:forward
git add .

18 changes: 16 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test": "jest",
"execute:gasless": "ts-node scripts/Gasless.ts",
"execute:nongasless": "ts-node scripts/NonGasless.ts",
"execute:forward": "ts-node scripts/Forward.ts",
"prepare": "husky install"
},
"lint-staged": {
Expand All @@ -20,7 +21,8 @@
"npm run format",
"npm run test",
"npm run execute:nongasless",
"npm run execute:gasless"
"npm run execute:gasless",
"npm run execute:forward"
]
},
"husky": {
Expand Down Expand Up @@ -65,15 +67,17 @@
"@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",
"@types/node": "^20.8.7",
"@uniswap/permit2-sdk": "^1.2.0",
"big.js": "^6.2.1",
"dotenv": "^16.3.1",
"ethers": "^5.7.2",
"rimraf": "^5.0.5",
"solidity-math": "^0.1.0"
}
}
}
29 changes: 22 additions & 7 deletions scripts/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ 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 || ""


export enum ChainID {
POLYGON_MAINNET = 137,
GOERLI = 5,
MUMBAI = 80001,
ARBITRUM_GOERLI = 421613,
Expand All @@ -22,7 +24,8 @@ export enum TokenName {
USDA1 = 'USDA1',
USDA2 = 'USDA2',
USDB = 'USDB',
USDC = 'USDC'
USDC = 'USDC',
USDT = 'USDT'
}

export const nativeTokenAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
Expand All @@ -31,33 +34,45 @@ export interface TokenAddresses {
[ChainID.GOERLI]: Record<TokenName, TokenInfo>;
[ChainID.MUMBAI]: Record<TokenName, TokenInfo>;
[ChainID.ARBITRUM_GOERLI]: Record<TokenName, TokenInfo>;
[ChainID.POLYGON_MAINNET]: Record<TokenName, TokenInfo>;
}

export const tokenAddresses: TokenAddresses = {
[ChainID.GOERLI]: {
[TokenName.USDA1]: { address: '0xbb8dB535d685F2742D6e84EC391c63e6a1Ce3593', decimals: 6 },
[TokenName.USDA2]: { address: '0xf4Ca1a280ebCcdaEBf80E3C128e55DE01fAbD893', decimals: 6 },
[TokenName.USDB]: { address: '0x2055b06Db421F17C19C655Fd4A1c325e8514aF67', decimals: 8 },
[TokenName.USDC]: { address: '0xd2a94832CF0a4c1A793f630264E984389C3EF48F', decimals: 18 }
[TokenName.USDC]: { address: '0xd2a94832CF0a4c1A793f630264E984389C3EF48F', decimals: 18 },
[TokenName.USDT]: { address: '', decimals: 6 }
},
[ChainID.MUMBAI]: {
[TokenName.USDA1]: { address: '0xbB8bb7E16d8F03969d49fd3ED0efd13E65C8f5B5', decimals: 6 },
[TokenName.USDA2]: { address: '0x203fa10731d98444fD59DA46705321080bA99824', decimals: 6 },
[TokenName.USDB]: { address: '0x2D6d85C69e92F3008d9f06Ddf8Bac054783687B4', decimals: 8 },
[TokenName.USDC]: { address: '0xb18059aA6483bA71D6d3DfAbaD53616b00EA2ABA', decimals: 18 }
[TokenName.USDC]: { address: '0xb18059aA6483bA71D6d3DfAbaD53616b00EA2ABA', decimals: 18 },
[TokenName.USDT]: { address: '', decimals: 6 }
},
[ChainID.ARBITRUM_GOERLI]: {
[TokenName.USDA1]: { address: '0x11900998de6b0C32F0bB148c6865635dfc28A528', decimals: 6 },
[TokenName.USDA2]: { address: '0x889b795C64CdA1E9fAC1fA623E7F82A73306b690', decimals: 6 },
[TokenName.USDB]: { address: '0x7C96ab4B90d59CE5e51f673242651018a4432672', decimals: 8 },
[TokenName.USDC]: { address: '0xe47a4524ad3142dE28F2F8F88b4317a439Ea89a9', decimals: 18 }
[TokenName.USDC]: { address: '0xe47a4524ad3142dE28F2F8F88b4317a439Ea89a9', decimals: 18 },
[TokenName.USDT]: { address: '', decimals: 6 }
},
};
[ChainID.POLYGON_MAINNET]: {
[TokenName.USDA1]: { address: '', decimals: 6 },
[TokenName.USDA2]: { address: '', decimals: 6 },
[TokenName.USDB]: { address: '', decimals: 8 },
[TokenName.USDC]: { address: '0x2791bcA1f2de4661ed88a30c99a7a9449AA84174', decimals: 6 },
[TokenName.USDT]: { address: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f', decimals: 6 }
}
};

export const nativeTokenAddresses = {
[ChainID.GOERLI] : '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
[ChainID.GOERLI]: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
[ChainID.MUMBAI]: '0x0000000000000000000000000000000000001010',
[ChainID.ARBITRUM_GOERLI] : '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
[ChainID.POLYGON_MAINNET]: '0x0000000000000000000000000000000000001010',
[ChainID.ARBITRUM_GOERLI]: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',

}

Expand Down
67 changes: 67 additions & 0 deletions scripts/Forward.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { BigNumber, ethers } from "ethers";
import { AarcSDK } from '../src';
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 { PERMIT2_CONTRACT_ADDRESS } from "../src/utils/Constants";
import { hashMessage } from "@ethersproject/hash"

export const decreaseAllowances = async () => {
let provider = new ethers.providers.JsonRpcProvider(RPC_URL);
let signer = new ethers.Wallet(PRIVATE_KEY, provider);
const chainId: ChainID = (await provider.getNetwork()).chainId

for (const tokenName in tokenAddresses[chainId]) {
const { address } = tokenAddresses[chainId][tokenName as keyof typeof TokenName];
const tokenContract = new ethers.Contract(
address,
ERC20_ABI,
signer,
);
try {
await tokenContract.decreaseAllowance(PERMIT2_CONTRACT_ADDRESS, ethers.constants.MaxUint256)
console.log(tokenName, 'Allowance decreased successfully');

} catch (error) {
console.error('error decreasing token', error)
}
}
}

export const mintAndTransferErc20Tokens = async () => {
let provider = new ethers.providers.JsonRpcProvider(RPC_URL);
let signer = new ethers.Wallet(PRIVATE_KEY, provider);
let eoaAddress = signer.address;
const chainId: ChainID = (await provider.getNetwork()).chainId
console.log(' chainId ', chainId);


let aarcSDK = new AarcSDK({
rpcUrl: RPC_URL,
chainId,
apiKey: API_KEY,
});
const resultSet = await aarcSDK.executeForwardTransaction({
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") },
]
})
console.log('ResultSet ', resultSet);
}


const executeTransfers = async () => {
validateEnvironmentVariables()
// await decreaseAllowances()
await mintAndTransferErc20Tokens()
};

executeTransfers().then(() => {
console.log('All transfers executed successfully.');
}).catch((error) => {
console.error('Error during transfers:', error);
});
Loading

0 comments on commit fe3699c

Please sign in to comment.