quartz/wallet/node_modules/@3rdweb/sdk/dist/modules/token.d.ts
2022-03-04 20:05:23 +08:00

222 lines
7.2 KiB
TypeScript

import { Coin } from "@3rdweb/contracts";
import { TransactionReceipt } from "@ethersproject/providers";
import { BigNumber, BigNumberish } from "ethers";
import { ModuleType, Role } from "../common";
import { Currency, CurrencyValue } from "../common/currency";
import { ModuleWithRoles } from "../core/module";
import { MetadataURIOrObject } from "../core/types";
import { ITransferable } from "../interfaces/contracts/ITransferable";
export interface ITokenMintArgs {
address: string;
amount: BigNumberish;
}
export interface ITokenMintFromArgs extends ITokenMintArgs {
fromAddress: string;
}
/**
* Create a standard crypto token or crypto currency.
*
* @example
*
* ```javascript
* import { ThirdwebSDK } from "@3rdweb/sdk";
*
* // You can switch out this provider with any wallet or provider setup you like.
* const provider = ethers.Wallet.createRandom();
* const sdk = new ThirdwebSDK(provider);
* const module = sdk.getTokenModule("{{module_address}}");
* ```
*
* @public
*/
export declare class TokenModule extends ModuleWithRoles<Coin> implements ITransferable {
static moduleType: ModuleType;
static roles: readonly ["admin", "minter", "pauser", "transfer"];
/**
* @override
* @internal
*/
protected getModuleRoles(): readonly Role[];
/**
* @internal
*/
protected connectContract(): Coin;
/**
* @internal
*/
protected getModuleType(): ModuleType;
get(): Promise<Currency>;
getValue(value: BigNumberish): Promise<CurrencyValue>;
totalSupply(): Promise<BigNumber>;
balance(): Promise<CurrencyValue>;
/**
* Get Token Balance
*
* @remarks Get a wallets token balance.
*
* @example
* ```javascript
* // Address of the wallet to check token balance
* const address = "{{wallet_address}}";
*
* const balance = await module.balanceOf(address);
* console.log(balance);
* ```
*
* @returns The balance of a specific wallet.
*/
balanceOf(address: string): Promise<CurrencyValue>;
allowance(spender: string): Promise<BigNumber>;
/**
* Get Token Allowance
*
* @remarks Get the allowance of one wallet over another's funds - the allowance of a different address for a token is the amount of tokens that the wallet is allowed to spend on behalf of the connected wallet.
*
* @example
* ```javascript
* // Address of the wallet who owns the funds
* const address = "{{wallet_address}}";
*
* // Address of the wallet to check token allowance
* const otherAddress = "0x...";
*
* const allowance = await module.allowanceOf(address, otherAddress);
* console.log(allowance);
* ```
*
* @returns The allowance of one wallet over anothers funds.
*/
allowanceOf(owner: string, spender: string): Promise<BigNumber>;
/**
* Get your wallet voting power for the current checkpoints
*
* @returns the amount of voting power in tokens
*/
getVoteBalance(): Promise<BigNumber>;
getVoteBalanceOf(account: string): Promise<BigNumber>;
/**
* Get your voting delegatee address
*
* @returns the address of your vote delegatee
*/
getDelegation(): Promise<string>;
getDelegationOf(account: string): Promise<string>;
/**
* Lets you delegate your voting power to the delegateeAddress
*
* @param delegateeAddress - delegatee wallet address
* @alpha
*/
delegateTo(delegateeAddress: string): Promise<TransactionReceipt>;
/**
* Transfer Tokens
*
* @remarks Transfer tokens from the connected wallet to another wallet.
*
* @example
* ```javascript
* // Address of the wallet you want to send the tokens to
* const toAddress = "0x...";
*
* // The amount of tokens you want to send
* const amount = 0;
*
* await module.transfer(toAddress, amount);
* ```
*/
transfer(to: string, amount: BigNumberish): Promise<TransactionReceipt>;
setAllowance(spender: string, amount: BigNumber): Promise<TransactionReceipt>;
mint(amount: BigNumberish): Promise<void>;
/**
* Mint Tokens
*
* @remarks Mint tokens to a specified address
*
* @example
* ```javascript
* // Address of the wallet you want to mint the tokens to
* const toAddress = "{{wallet_address}}";
*
* // The amount of this token you want to mint
* const amount = ethers.utils.parseEther("1.5");
*
* await module.mintTo(toAddress, amount);
* ```
*/
mintTo(to: string, amount: BigNumberish): Promise<void>;
/**
* Mint Tokens To Many Wallets
*
* @remarks Mint tokens to many different wallets
*
* @example
* ```javascript
* // Data of the tokens you want to mint
* const data = [
* {
* address: "{{wallet_address}}", // Address to mint tokens to
* amount: 100, // How many tokens to mint to specified address
* },
* {
* address: "0x...",
* amount: 100,
* }
* ]
*
* await module.mintBatchTo(data);
* ```
*/
mintBatchTo(args: ITokenMintArgs[]): Promise<void>;
/**
* Lets you get a all token holders and their corresponding balances
* @beta - This can be very slow for large numbers of token holders
* @param queryParams - Optional query params
* @returns - A JSON object of all token holders and their corresponding balances
*/
getAllHolderBalances(): Promise<Record<string, BigNumber>>;
/**
* Burn Tokens
*
* @remarks Burn tokens held by the connected wallet
*
* @example
* ```javascript
* // The amount of this token you want to burn
* const amount = 100;
*
* await module.burn(amount);
* ```
*/
burn(amount: BigNumberish): Promise<TransactionReceipt>;
burnFrom(from: string, amount: BigNumberish): Promise<TransactionReceipt>;
/**
* Transfer Tokens From Address
*
* @remarks Transfer tokens from one wallet to another
*
* @example
* ```javascript
* // Address of the wallet sending the tokens
* const fromAddress = "{{wallet_address}}";
* // Address of the wallet you want to send the tokens to
* const toAddress = "0x...";
* // The number of tokens you want to send
* const amount = 100
*
* // Note that the connected wallet must have approval to transfer the tokens of the fromAddress
* await module.transferFrom(fromAddress, toAddress, amount);
* ```
*/
transferFrom(from: string, to: string, amount: BigNumberish): Promise<TransactionReceipt>;
setModuleMetadata(metadata: MetadataURIOrObject): Promise<TransactionReceipt>;
transferBatch(args: ITokenMintArgs[]): Promise<void>;
transferFromBatch(args: ITokenMintFromArgs[]): Promise<void>;
isTransferRestricted(): Promise<boolean>;
setRestrictedTransfer(restricted?: boolean): Promise<TransactionReceipt>;
}
/**
* @deprecated - see {@link TokenModule}
*/
export declare class CurrencyModule extends TokenModule {
}