Skip to content

Commit

Permalink
Functions to fund smart wallet or P2P address with either the native …
Browse files Browse the repository at this point in the history
…token or a specific ERC20 (#106)

* BAC-1191 topup methods sdk

* BAC-1191 topup methods sdk

* BAC-1191 topup methods sdk

* BAC-1191 topup methods sdk

* BAC-1191 topup methods sdk

* BAC-1191 topup methods sdk

* BAC-1191 topup methods sdk

* BAC-1191 fix

* BAC-1191 add exception, decimal

* BAC-1191 decimal fix

* BAC-1191 parameter update

* BAC-1191 transferToken update

* BAC-1191 fix typo

* BAC-1191 if not computeContractAccount on topup

* BAC-1191 if not computeContractAccount on topup

* BAC-1191 rename method isContractAccount

* BAC-1191 update conditions is contract account

* BAC-1191 update contract ERC20Token abi

* BAC-1191 format

* BAC-1191 remove default value for token contract decimals

* BAC-1191 wallet provider update

* BAC-1191 test update

* BAC-1191 udpate test and contract top up

* BAC-1191 update version

* BAC-1191 update version

Co-authored-by: riccardo <[email protected]>
  • Loading branch information
riccardopillar and riccardo-ravaro authored Mar 9, 2022
1 parent 30feaf5 commit dbd3a2c
Show file tree
Hide file tree
Showing 14 changed files with 8,587 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
workspace.code-workspace

# node
node_modules
Expand Down
3 changes: 2 additions & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"11-external-contracts": "../node_modules/.bin/ts-node ./src/11-external-contracts",
"12-exchange": "../node_modules/.bin/ts-node ./src/12-exchange",
"13-transactions": "../node_modules/.bin/ts-node ./src/13-transactions",
"14-delayed-transactions": "../node_modules/.bin/ts-node ./src/14-delayed-transactions"
"14-delayed-transactions": "../node_modules/.bin/ts-node ./src/14-delayed-transactions",
"15-topup-fuctions": "../node_modules/.bin/ts-node ./src/15-topup-fuctions"
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion examples/src/03-contract-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { logger, topUpAccount, getBalance, randomAddress } from './common';

async function main(): Promise<void> {
const wallet = Wallet.createRandom();

logger.log('wallet', wallet.address);

const sdk = new Sdk(wallet);
Expand Down
30 changes: 30 additions & 0 deletions examples/src/15-topup-fuctions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Wallet, getDefaultProvider, providers } from 'ethers';
import { EnvNames, NetworkNames, Sdk } from '../../src';
import { logger, deployToken, getPrivateKeyWallet, balanceOf } from './common';

async function main(): Promise<void> {

// default hardhat local network signer privatekey
let privateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
const wallet = getPrivateKeyWallet(privateKey,NetworkNames.LocalA);

const sdk = new Sdk(wallet);
await sdk.computeContractAccount({sync: false});
const tokenAddress = await deployToken(wallet);

await balanceOf(wallet, tokenAddress);

await sdk.topUp("10");

await sdk.topUpP2P("10");

await sdk.topUpToken("1",tokenAddress);
await balanceOf(wallet, tokenAddress);

await sdk.topUpTokenP2P("1",tokenAddress);
await balanceOf(wallet, tokenAddress);
}

main()
.catch(logger.error)
.finally(() => process.exit());
Loading

0 comments on commit dbd3a2c

Please sign in to comment.