UNPKG

@civic/sol-did-client

Version:
72 lines (71 loc) 3.21 kB
import { EthSigner, RawDidSolDataAccount } from '../lib/types'; import { Commitment, ConfirmOptions, Connection, PublicKey, Signer, Transaction, TransactionInstruction } from '@solana/web3.js'; import { Idl } from '@coral-xyz/anchor'; import BN from 'bn.js'; import { DidSolDataAccount } from '../lib/wrappers'; import { Wallet } from '@coral-xyz/anchor/dist/cjs/provider'; export declare enum DidSolEthSignStatusType { NotSupported = 0, Unsigned = 1, Signed = 2 } export type BuilderInstruction = { instructionPromise: Promise<TransactionInstruction>; ethSignStatus: DidSolEthSignStatusType; didAccountChangeCallback: (didAccountBefore: RawDidSolDataAccount, sizeBefore: number) => [RawDidSolDataAccount, number]; }; /** * */ export declare abstract class DidSolTransactionBuilder { protected _wallet: Wallet; protected _connection: Connection; protected _confirmOptions: ConfirmOptions; private _partialSigners; private _ethSigner?; private _payer?; private _resizeAuthority; private _initInstruction?; private _resizeInstruction?; private _generalInstructions; private _closeInstruction?; private _postInstructions; private readonly _idlErrors; private readonly _initialWallet; constructor(_wallet: Wallet, _connection: Connection, _confirmOptions: ConfirmOptions, idl: Idl, _partialSigners?: Signer[], _ethSigner?: EthSigner | undefined, _payer?: PublicKey | undefined, _resizeAuthority?: PublicKey); get solWallet(): Wallet; get connection(): Connection; get confirmOptions(): ConfirmOptions; get ethSigner(): EthSigner | undefined; withEthSigner(ethSigner: EthSigner): this; setInitInstruction(initInstruction: BuilderInstruction): void; setResizeInstruction(resizeInstruction: BuilderInstruction): void; setCloseInstruction(closeInstruction: BuilderInstruction): void; addGeneralInstruction(instruction: BuilderInstruction): void; addPostInstruction(instruction: Promise<TransactionInstruction>): void; /** * Clears all prepared Instructions and partialSigners, ethWallet, payer and resizeAuthority. */ clear(): void; clearInstructions(): void; withConnection(connection: Connection): this; withConfirmOptions(confirmOptions: ConfirmOptions): this; withSolWallet(wallet: Wallet): this; withAutomaticAlloc(payer: PublicKey, resizeAuthority?: PublicKey): this; withPartialSigners(...signers: Signer[]): this; abstract getNonce(): Promise<BN>; abstract getDidAccount(): Promise<DidSolDataAccount | null>; abstract getDidAccountWithSize(commitment?: Commitment): Promise<[DidSolDataAccount | null, number]>; abstract resize(size: number, payer: PublicKey, authority: PublicKey): void; abstract initialize(size: number, payer: PublicKey): void; /** * Signs a supported DidSol Instruction with an Ethereum Signer. */ private ethSignInstructions; private getMaxRequiredSize; abstract get didDataAccount(): PublicKey; private setAllocInstruction; instructions(): Promise<TransactionInstruction[]>; transaction(): Promise<Transaction>; rpc(opts?: ConfirmOptions): Promise<string>; }