@taquito/taquito
Version:
High level functionality that builds upon the other packages in the Tezos Typescript Library Suite.
196 lines (195 loc) • 9.85 kB
TypeScript
import { Context } from '../context';
import { ContractAbstraction } from '../contract/contract';
import type { ContractStorageType, DefaultWalletType } from '../contract/contract';
import { SendParams } from '../contract/contract-methods/contract-method-interface';
import type { ContractMethodObject } from '../contract/contract-methods/contract-method-object-param';
import { OpKind, withKind } from '../operations/types';
import { OriginationWalletOperation } from './origination-operation';
import { WalletDelegateParams, WalletFailingNoopParams, WalletIncreasePaidStorageParams, WalletOriginateParams, WalletProvider, WalletTransferParams, WalletStakeParams, WalletUnstakeParams, WalletFinalizeUnstakeParams, WalletTransferTicketParams, WalletRegisterGlobalConstantParams } from './interface';
export interface PKHOption {
forceRefetch?: boolean;
}
export type WalletParamsWithKind = withKind<WalletTransferParams, OpKind.TRANSACTION> | withKind<WalletOriginateParams, OpKind.ORIGINATION> | withKind<WalletDelegateParams, OpKind.DELEGATION> | withKind<WalletIncreasePaidStorageParams, OpKind.INCREASE_PAID_STORAGE> | withKind<WalletTransferTicketParams, OpKind.TRANSFER_TICKET> | withKind<WalletRegisterGlobalConstantParams, OpKind.REGISTER_GLOBAL_CONSTANT>;
export declare class WalletOperationBatch {
private walletProvider;
private context;
private operations;
constructor(walletProvider: WalletProvider, context: Context);
/**
* @description Add a transaction operation to the batch
* @param params Transfer operation parameter
*/
withTransfer(params: WalletTransferParams): this;
/**
* @description Add a contract call to the batch
* @param params Call a contract method
* @param options Generic operation parameters
*/
withContractCall(params: ContractMethodObject<Wallet>, options?: Partial<SendParams>): this;
/**
* @description Add a delegation operation to the batch
* @param params Delegation operation parameter
*/
withDelegation(params: WalletDelegateParams): this;
/**
* @description Add an origination operation to the batch
* @param params Origination operation parameter
*/
withOrigination<TWallet extends DefaultWalletType = DefaultWalletType>(params: WalletOriginateParams<ContractStorageType<TWallet>>): this;
/**
* @description Add an IncreasePaidStorage operation to the batch
* @param param IncreasePaidStorage operation parameter
*/
withIncreasePaidStorage(params: WalletIncreasePaidStorageParams): this;
/**
* @description Add an TransferTicket operation to the batch
* @param param TransferTicket operation parameter
*/
withTransferTicket(params: WalletTransferTicketParams): this;
/**
* @description Add a RegisterGlobalConstant operation to the batch
* @param param RegisterGlobalConstant operation parameter
*/
withRegisterGlobalConstant(params: WalletRegisterGlobalConstantParams): this;
private mapOperation;
/**
* @description Add a group operation to the batch. Operation will be applied in the order they are in the params array
* @param params Operations parameter
* @throws {@link InvalidOperationKindError}
*/
with(params: WalletParamsWithKind[]): this;
/**
* @description Submit batch operation to wallet
*/
send(): Promise<import("./batch-operation").BatchWalletOperation>;
}
export declare class Wallet {
private context;
constructor(context: Context);
private get walletProvider();
private _pkh?;
private _pk?;
/**
* @description Retrieve the PKH of the account that is currently in use by the wallet
* @param option Option to use while fetching the PKH.
* If forceRefetch is specified the wallet provider implementation will refetch the PKH from the wallet
*/
pkh({ forceRefetch }?: PKHOption): Promise<string>;
/**
* @description Retrieve the PK of the account that is currently in use by the wallet
* @param option Option to use while fetching the PK.
* If forceRefetch is specified the wallet provider implementation will refetch the PK from the wallet
*/
pk({ forceRefetch }?: PKHOption): Promise<string>;
private walletCommand;
/**
* @description Originate a new contract according to the script in parameters.
* @returns a OriginationWalletOperation promise object when followed by .send()
* @param originateParams Originate operation parameter
*/
originate<TWallet extends DefaultWalletType = DefaultWalletType>(params: WalletOriginateParams<ContractStorageType<TWallet>>): {
send: () => Promise<OriginationWalletOperation<TWallet>>;
};
/**
* @description Set the delegate for a contract.
* @returns a WalletDelegateParams promise object when followed by .send()
* @param delegateParams operation parameter
*/
setDelegate(params: WalletDelegateParams): {
send: () => Promise<import("./delegation-operation").DelegationWalletOperation>;
};
/**
* @description failing_noop operation that is guaranteed to fail. DISCLAIMER: Not all wallets support signing failing_noop operations.
* @returns Signature for a failing_noop
* @param params operation parameter
*/
signFailingNoop(params: WalletFailingNoopParams): Promise<{
signature: string;
bytes: string;
signedContent: {
branch: string;
contents: {
kind: OpKind;
arbitrary: string;
}[];
};
}>;
/**
* @description Register the current address as delegate.
* @returns a DelegationWalletOperation promise object when followed by .send()
*/
registerDelegate(): {
send: () => Promise<import("./delegation-operation").DelegationWalletOperation>;
};
/**
* @description Transfer tezos tokens from current address to a specific address or call a smart contract.
* @returns a TransactionWalletOperation promise object when followed by .send()
* @param params operation parameter
*/
transfer(params: WalletTransferParams): {
send: () => Promise<import("./transaction-operation").TransactionWalletOperation>;
};
/**
* @description Transfer tezos tickets from current address to a specific address or a smart contract
* @returns a TransferTicketWalletOperation promise object when followed by .send()
* @param params operation parameter
*/
transferTicket(params: WalletTransferTicketParams): {
send: () => Promise<import("./transfer-ticket-operation").TransferTicketWalletOperation>;
};
/**
* @description Stake a given amount for the source address
* @returns a TransactionWalletOperation promise object when followed by .send()
* @param Stake pseudo-operation parameter
*/
stake(params: WalletStakeParams): {
send: () => Promise<import("./transaction-operation").TransactionWalletOperation>;
};
/**
* @description Unstake the given amount. If "everything" is given as amount, unstakes everything from the staking balance.
* Unstaked tez remains frozen for a set amount of cycles (the slashing period) after the operation. Once this period is over,
* the operation "finalize unstake" must be called for the funds to appear in the liquid balance.
* @returns a TransactionWalletOperation promise object when followed by .send()
* @param Unstake pseudo-operation parameter
*/
unstake(params: WalletUnstakeParams): {
send: () => Promise<import("./transaction-operation").TransactionWalletOperation>;
};
/**
* @description Transfer all the finalizable unstaked funds of the source to their liquid balance
* @returns a TransactionWalletOperation promise object when followed by .send()
* @param Finalize_unstake pseudo-operation parameter
*/
finalizeUnstake(params: WalletFinalizeUnstakeParams): {
send: () => Promise<import("./transaction-operation").TransactionWalletOperation>;
};
/**
* @description Increase the paid storage of a smart contract.
* @returns a IncreasePaidStorageWalletOperation promise object when followed by .send()
* @param params operation parameter
*/
increasePaidStorage(params: WalletIncreasePaidStorageParams): {
send: () => Promise<import("./increase-paid-storage-operation").IncreasePaidStorageWalletOperation>;
};
/**
* @description Register a Micheline expression in a global table of constants.
* @returns a RegisterGlobalConstantWalletOperation promise object when followed by .send()
* @param params operation parameter
*/
registerGlobalConstant(params: WalletRegisterGlobalConstantParams): {
send: () => Promise<import("./register-global-constant-operation").RegisterGlobalConstantWalletOperation>;
};
/**
* @description Create a batch of operation
* @returns A batch object from which we can add more operation or send a command to the wallet to execute the batch
* @param params List of operation to initialize the batch with
*/
batch(params?: Parameters<WalletOperationBatch['with']>[0]): WalletOperationBatch;
/**
* @description Create an smart contract abstraction for the address specified. Calling entrypoints with the returned
* smart contract abstraction will leverage the wallet provider to make smart contract calls
* @param address Smart contract address
* @throws {@link InvalidContractAddressError} If the contract address is not valid
*/
at<T extends ContractAbstraction<Wallet>>(address: string, contractAbstractionComposer?: (abs: ContractAbstraction<Wallet>, context: Context) => T): Promise<T>;
}