fix: single type declaration for user address
MODIFY
types/index.d.ts
types/index.d.ts
@@ -2,8 +2,7 @@ import { Account, Provider, Eth, Tx, TransactionReceipt, Transaction, PromiEvent
import Web3 from 'web3';
// These types are declared to help you keep track of similar data
-export type UserMaticAddress = string;
-export type UserEthAddress = string;
+export type UserAddress = string;
export type RootTokenAddress = string;
export type ERC20TokenAddress = string;
export type ERC721TokenAddress = string;
@@ -19,7 +18,6 @@ export type MaticChainTransactionId = string;
* * `gasPrice` same as Ethereum sendTransaction
* * `gasLimit` same as Ethereum sendTransaction
* * `nonce` same as Ethereum sendTransaction
- * * `nonce` same as Ethereum sendTransaction
* * `value` contains ETH value. Same as Ethereum sendTransaction.
* * `onTransactionHash` must be function. This function will be called when transaction will be broadcasted.
* * `onReceipt` must be function. This function will be called when transaction will be included in block (when transaction gets confirmed)
@@ -36,7 +34,7 @@ export interface BlockHeader {
number: number;
start: number;
end: number;
- proposer: UserMaticAddress;
+ proposer: UserAddress;
root: string;
createdAt: string;
updatedAt: string;
@@ -95,7 +93,7 @@ export default class Matic {
web3: Web3;
parentWeb3: Web3;
wallet: Account;
- walletAddress: UserMaticAddress;
+ walletAddress: UserAddress;
/**
* Set wallet.
@@ -107,10 +105,10 @@ export default class Matic {
/**
* Get matic token address mapped with mainchain token address.
- * @param address Must be a valid token address
- * @returns Matic address
+ * @param address Must be a valid token address on mainchain
+ * @returns Token address mapped on Matic chain
*/
- getMappedTokenAddress(address: ERC20TokenAddress): Promise<UserMaticAddress>;
+ getMappedTokenAddress(address: ERC20TokenAddress): Promise<ERC20TokenAddress>;
/**
* Get balance of ERC721 token for address.
@@ -119,7 +117,7 @@ export default class Matic {
* @param options (optional) See `TxOptions`. For balance on Main chain, use `parent: true`.
* @returns Balance
*/
- balanceOfERC721(address: UserEthAddress, token: ERC20TokenAddress, options?: TxOptions): Promise<TokenAmount>;
+ balanceOfERC721(address: UserAddress, token: ERC20TokenAddress, options?: TxOptions): Promise<TokenAmount>;
/**
* Get balance of ERC20 token for address.
@@ -128,7 +126,7 @@ export default class Matic {
* @param options (optional) See `TxOptions`. For balance on Main chain, use `parent: true`.
* @returns Balance
*/
- balanceOfERC20(address: UserEthAddress, token: ERC20TokenAddress, options?: TxOptions): Promise<TokenAmount>;
+ balanceOfERC20(address: UserAddress, token: ERC20TokenAddress, options?: TxOptions): Promise<TokenAmount>;
/**
* Get ERC721 tokenId at `index` for `token` and `address`.
@@ -138,7 +136,7 @@ export default class Matic {
* @param options Matic `tokenId`
* @returns Matic tokenId
*/
- tokenOfOwnerByIndexERC721(address: UserEthAddress, token: ERC721TokenAddress, index: number, options?: Tx): TokenId;
+ tokenOfOwnerByIndexERC721(address: UserAddress, token: ERC721TokenAddress, index: number, options?: Tx): TokenId;
/**
* Deposit ethers of the given amount
@@ -166,7 +164,7 @@ export default class Matic {
* @param options See `TxOptions`
* @returns A promise which will be fulfilled when transaction is confirmed (when receipt is generated)
*/
- depositERC20Tokens(token: ERC20TokenAddress, user: UserEthAddress, amount: WeiAmount, options?: TxOptions): PromiEvent<any>;
+ depositERC20Tokens(token: ERC20TokenAddress, user: UserAddress, amount: WeiAmount, options?: TxOptions): PromiEvent<any>;
/**
* Deposit given `tokenId` of `token`
@@ -194,7 +192,7 @@ export default class Matic {
* @param options See `TxOptions`
* @returns A promise which will be fulfilled when transaction is confirmed (when receipt is generated)
*/
- depositERC721Tokens(token: ERC721TokenAddress, user: UserEthAddress, tokenId: TokenId, options?: TxOptions): PromiEvent<any>;
+ depositERC721Tokens(token: ERC721TokenAddress, user: UserAddress, tokenId: TokenId, options?: TxOptions): PromiEvent<any>;
/**
* Deposit given `tokenId` of `token`
@@ -213,7 +211,7 @@ export default class Matic {
* @param options See `TxOptions`. For transfer on Main chain, use `parent: true`.
* @returns A promise which will be fulfilled when transaction is confirmed (when receipt is generated)
*/
- transferTokens(token: ERC20TokenAddress, user: UserEthAddress, amount: WeiAmount, options?: TxOptions): PromiEvent<any>;
+ transferTokens(token: ERC20TokenAddress, user: UserAddress, amount: WeiAmount, options?: TxOptions): PromiEvent<any>;
/**
* Transfer the given `amount` of `token` to `user`.
@@ -223,7 +221,7 @@ export default class Matic {
* @param options See `TxOptions`. For transfer on Main chain, use `parent: true`.
* @returns A promise which will be fulfilled when transaction is confirmed (when receipt is generated)
*/
- transferERC721Tokens(token: ERC721TokenAddress, user: UserEthAddress, tokenId: TokenId, options?: TxOptions): PromiEvent<any>;
+ transferERC721Tokens(token: ERC721TokenAddress, user: UserAddress, tokenId: TokenId, options?: TxOptions): PromiEvent<any>;
/**
* Transfer the given `amount` of ethers to `user`
@@ -234,7 +232,7 @@ export default class Matic {
* * For custom ether transfer on Matic Chain, `use isCustomEth: true`
* @returns A promise which will be fulfilled when transaction is confirmed (when receipt is generated)
*/
- transferEthers(user: UserEthAddress, amount: WeiAmount, options?: TxOptions): PromiEvent<any>; // ! 'user' is called 'to' in index.js, inconsistent
+ transferEthers(user: UserAddress, amount: WeiAmount, options?: TxOptions): PromiEvent<any>; // ! 'user' is called 'to' in index.js, inconsistent
/**
* Start withdraw process with given `amount` for `token`.

fix: single type declaration for user address