Skip to content

Commit 3c3d163

Browse files
authored
Feature/transfer token (#4)
* implement transferToken method and few other improvements * `increaseAllowance` and `allowance` methods * returning txHash for L1 transactions
1 parent 7723ccc commit 3c3d163

File tree

13 files changed

+159
-99
lines changed

13 files changed

+159
-99
lines changed

lib/networks/client.d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TxFee } from './transaction';
22
/** Account number or address */
3-
export declare type AccountId = number | string;
3+
export type AccountId = number | string;
44
export declare abstract class Client {
55
transactionUrl: string;
66
abstract getAddress(): Promise<string>;
@@ -18,10 +18,12 @@ export declare abstract class Client {
1818
* @param to destination address
1919
* @param amount as base unit
2020
*/
21-
abstract transfer(to: string, amount: string): Promise<void>;
22-
transferToken(tokenAddress: string, to: string, amount: string): Promise<void>;
23-
mint(tokenAddres: string, amount: string): Promise<void>;
24-
approve(tokenAddress: string, spender: string, amount: string): Promise<void>;
21+
abstract transfer(to: string, amount: string): Promise<string>;
22+
transferToken(tokenAddress: string, to: string, amount: string): Promise<string>;
23+
mint(tokenAddres: string, amount: string): Promise<string>;
24+
approve(tokenAddress: string, spender: string, amount: string): Promise<string>;
25+
increaseAllowance(tokenAddress: string, spender: string, additionalAmount: string): Promise<string>;
26+
allowance(tokenAddress: string, spender: string): Promise<bigint>;
2527
getTransactionUrl(hash: string): string;
2628
/**
2729
*

lib/networks/client.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/networks/client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/networks/evm/client.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ export declare class EthereumClient extends Client {
1515
getTokenBalance(tokenAddress: string): Promise<string>;
1616
getTokenNonce(tokenAddress: string): Promise<string>;
1717
getTokenName(tokenAddress: string): Promise<string>;
18-
transferToken(tokenAddress: string, to: string, amount: string): Promise<void>;
19-
transfer(to: string, amount: string): Promise<void>;
18+
transfer(to: string, amount: string): Promise<string>;
2019
/**
2120
* Converts ether to Wei.
2221
* @param amount in Ether
@@ -28,8 +27,11 @@ export declare class EthereumClient extends Client {
2827
*/
2928
fromBaseUnit(amount: string): string;
3029
estimateTxFee(): Promise<TxFee>;
31-
mint(minterAddress: string, amount: string): Promise<void>;
32-
approve(tokenAddress: string, spender: string, amount: string): Promise<void>;
30+
mint(minterAddress: string, amount: string): Promise<string>;
31+
transferToken(tokenAddress: string, to: string, amount: string): Promise<string>;
32+
approve(tokenAddress: string, spender: string, amount: string): Promise<string>;
33+
increaseAllowance(tokenAddress: string, spender: string, additionalAmount: string): Promise<string>;
34+
allowance(tokenAddress: string, spender: string): Promise<bigint>;
3335
sign(data: string): Promise<string>;
3436
signTypedData(data: object): Promise<string>;
3537
}

lib/networks/evm/client.js

Lines changed: 47 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/networks/evm/client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/networks/polkadot/client.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export declare class PolkadotClient extends Client {
1717
getAddress(): Promise<string>;
1818
getPublicKey(): Promise<string>;
1919
getBalance(): Promise<string>;
20-
transfer(to: string, amount: string): Promise<void>;
20+
transfer(to: string, amount: string): Promise<string>;
2121
/**
2222
* Converts DOT to Planck.
2323
* @param amount in Ether
@@ -28,7 +28,7 @@ export declare class PolkadotClient extends Client {
2828
* @param amount in Wei
2929
*/
3030
fromBaseUnit(amount: string): string;
31-
mint(tokenAddress: string, amount: string): Promise<void>;
31+
mint(tokenAddress: string, amount: string): Promise<string>;
3232
/** Expects a hex string and returns a hex string */
3333
sign(data: string): Promise<string>;
3434
}

lib/networks/polkadot/client.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/networks/polkadot/client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zeropool-support-js",
3-
"version": "0.5.4",
3+
"version": "0.6.0",
44
"license": "MIT",
55
"author": "Dmitry Vdovin <voidxnull@gmail.com>",
66
"homepage": "https://github.com/zeropoolnetwork/zeropool-api-js",

0 commit comments

Comments
 (0)