Skip to content

Commit

Permalink
Aarc SDK 0.0.9 beta (#49)
Browse files Browse the repository at this point in the history
* Readme update (#27)

* 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>

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>
Co-authored-by: Ari <52634803+theblackmace@users.noreply.github.com>

* SDK Version 0.0.1-beta.5 (#34)

* 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>

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>
Co-authored-by: Ari <52634803+theblackmace@users.noreply.github.com>

* version beta-5 package changes

* Update README.md

* Aarc SDK 0.0.1-beta.6 (#39)

* 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

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>
Co-authored-by: Ari <52634803+theblackmace@users.noreply.github.com>

* SDK 0.0.8 (#43)

* 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

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>
Co-authored-by: Ari <52634803+theblackmace@users.noreply.github.com>

* Aarc-SDK 0.0.9 version (#47)

* 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

---------

Co-authored-by: talhamalik883 <talhamalik883@gmail.com>
Co-authored-by: Ari <52634803+theblackmace@users.noreply.github.com>

* Version 9 changes

---------

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

46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,31 @@ Output:
]
```

## 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.



```typescript
import { WALLET_TYPE } from "aarc-sdk/dist/utils/AarcTypes";

await aarcSDK.transferNativeAndDeploy({
owner: EOA_ADDRESS,
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.
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
```

## 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.

Expand Down Expand Up @@ -167,6 +192,27 @@ const newBiconomySCWAddress = await aarcSDK.generateBiconomySCW(
// Returns a counterfactual address for the new Biconomy wallet
```

## 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.

#### 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
import { WALLET_TYPE } from "aarc-sdk/dist/utils/AarcTypes";

await aarcSDK.deployWallet({
owner: EOA_ADDRESS,
walletType: WALLET_TYPE, // WALLET_TYPE.SAFE or WALLET_TYPE.BICONOMY
signer: signer, // ethers.signer object
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
})
```

#### More coming soon

## License
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aarc-sdk",
"version": "0.0.1-beta.8",
"version": "0.0.1-beta.9",
"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": {
Expand Down Expand Up @@ -34,7 +34,6 @@
"assets transfer",
"gasless",
"biconomy",
"gelato",
"uniswap",
"permit",
"protocol",
Expand Down
51 changes: 23 additions & 28 deletions src/AarcSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
TransactionsResponse,
WALLET_TYPE,
DeployWalletDto,
NativeTransferDeployWalletDto,
} from './utils/AarcTypes';
import { PERMIT2_BATCH_TRANSFER_ABI } from './utils/abis/Permit2BatchTransfer.abi';
import { PERMIT2_SINGLE_TRANSFER_ABI } from './utils/abis/Permit2SingleTransfer.abi';
Expand Down Expand Up @@ -95,28 +96,32 @@ class AarcSDK {
return this.safe.generateSafeSCW(config, saltNonce);
}

deploySafeSCW(
signer: Signer,
owner: string,
saltNonce?: number,
): Promise<string> {
return this.safe.deploySafeSCW(signer, owner, saltNonce);
}
deployWallet(deployWalletDto: DeployWalletDto): Promise<string> {
const {
walletType,
owner,
signer,
deploymentWalletIndex = 0,
} = deployWalletDto;

async deployBiconomyScw(
signer: Signer,
owner: string,
nonce: number = 0,
): Promise<string> {
return this.biconomy.deployBiconomyScw(signer, this.chainId, owner, nonce);
if (walletType === WALLET_TYPE.SAFE) {
return this.safe.deploySafeSCW(signer, owner, deploymentWalletIndex);
} else {
return this.biconomy.deployBiconomyScw(
signer,
this.chainId,
owner,
deploymentWalletIndex,
);
}
}

async transferNativeAndDeploy(
deployWalletDto: DeployWalletDto,
nativeTransferDeployWalletDto: NativeTransferDeployWalletDto,
): Promise<MigrationResponse[]> {
const response: MigrationResponse[] = [];
try {
const { receiver, amount, owner, signer } = deployWalletDto;
const { receiver, amount, owner, signer } = nativeTransferDeployWalletDto;
let amountToTransfer = BigNumber.from(0);

if (!signer) {
Expand All @@ -138,8 +143,9 @@ class AarcSDK {
}

try {
const walletDeploymentResponse =
await this.deployWallet(deployWalletDto);
const walletDeploymentResponse = await this.deployWallet(
nativeTransferDeployWalletDto,
);
Logger.log('walletDeploymentResponse ', walletDeploymentResponse);
response.push({
tokenAddress: '',
Expand Down Expand Up @@ -186,17 +192,6 @@ class AarcSDK {
}
}

deployWallet(deployWalletDto: DeployWalletDto): Promise<string> {
const { walletType, owner, signer, deploymentWalletIndex } =
deployWalletDto;

if (walletType === WALLET_TYPE.SAFE) {
return this.deploySafeSCW(signer, owner, deploymentWalletIndex);
} else {
return this.deployBiconomyScw(signer, owner, deploymentWalletIndex);
}
}

/**
* @description this function will return balances of ERC-20, ERC-721 and native tokens
* @param balancesDto
Expand Down
4 changes: 0 additions & 4 deletions src/providers/Biconomy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ class Biconomy {
nonce: number = 0,
): Promise<string> {
// Input validation
if (!(signer instanceof Signer)) {
throw new Error('Invalid signer');
}

if (typeof chainId !== 'number' || chainId <= 0) {
throw new Error('Invalid chainId');
}
Expand Down
7 changes: 7 additions & 0 deletions src/utils/AarcTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export enum WALLET_TYPE {
}

export type DeployWalletDto = {
walletType: WALLET_TYPE;
owner: string;
signer: Signer;
deploymentWalletIndex?: number;
};

export type NativeTransferDeployWalletDto = {
walletType: WALLET_TYPE;
owner: string;
receiver: string;
Expand Down

0 comments on commit 9640fdb

Please sign in to comment.