UNPKG

@civic/sol-did-client

Version:
71 lines (70 loc) 3.64 kB
import { Blockhash, Cluster, Commitment, Connection, NonceInformation, PublicKey, SendOptions, Signer, Transaction, TransactionError, TransactionSignature } from '@solana/web3.js'; export type ExtendedCluster = Cluster | 'localnet' | 'civicnet'; export declare const CIVICNET_CLUSTER_URL = "https://d3ab7dlfud2b5u.cloudfront.net"; export declare const LOCALNET_CLUSTER_URL = "http://localhost:8899"; export type CustomClusterUrlConfig = { [cluster in ExtendedCluster]: string; }; /** * Try to map a generic (optional) string to a ExtendedCluster string * @param cluster optional cluster string */ export declare const clusterFromString: (cluster: string | undefined) => ExtendedCluster | undefined; export declare const getClusterUrl: (cluster: ExtendedCluster, customConfig?: CustomClusterUrlConfig) => string; export declare const getConnectionByCluster: (cluster?: ExtendedCluster, preflightCommitment?: Commitment, customConfig?: CustomClusterUrlConfig) => Connection; export declare const getConnection: (clusterUrl: string, preflightCommitment?: Commitment) => Connection; export interface TransactionHolder { readonly connection: Connection; readonly transaction: Transaction; feePayer(feePayer: PublicKey): this; partialSign(...signers: Signer[]): this; addHashOrNonce(hashOrNonce: HashOrNonce): Promise<this>; } export type HashOrNonce = { recentBlockhash: Blockhash; } | { nonce: NonceInformation; } | 'find'; export declare function addHashOrNonce(transaction: TransactionHolder, hashOrNonce: HashOrNonce): Promise<void>; /** * from `@solana/web3.js` */ export declare class SendableTransaction implements TransactionHolder { readonly connection: Connection; readonly transaction: Transaction; constructor(connection: Connection, transaction: Transaction); withData<T>(data: T | (() => T | Promise<T>)): SendableDataTransaction<T>; send(options?: SendOptions, ...extraSigners: Signer[]): Promise<SentTransaction>; static fromSerialized(connection: Connection, message: Buffer): SendableTransaction; partialSign(...signers: Signer[]): this; addHashOrNonce(hashOrNonce: HashOrNonce): Promise<this>; feePayer(feePayer: PublicKey): this; } export declare class SendableDataTransaction<T> implements TransactionHolder { readonly sendableTransaction: SendableTransaction; readonly data: DataCallback<T>; constructor(sendableTransaction: SendableTransaction, data: DataCallback<T>); get connection(): Connection; get transaction(): Transaction; send(options?: SendOptions, ...extraSigners: Signer[]): Promise<SentDataTransaction<T>>; addHashOrNonce(hashOrNonce: HashOrNonce): Promise<this>; partialSign(...signers: Signer[]): this; feePayer(feePayer: PublicKey): this; } type DataCallback<T> = () => Promise<T>; export type DataOrGeneralDataCallback<T> = T | (() => T | Promise<T>); export declare class SentTransaction { readonly connection: Connection; readonly signature: TransactionSignature; constructor(connection: Connection, signature: TransactionSignature); withData<T>(data: DataOrGeneralDataCallback<T>): SentDataTransaction<T>; confirm(commitment?: Commitment, errorCallback?: (error: TransactionError) => void): Promise<void>; } export declare class SentDataTransaction<T> { readonly sentTransaction: SentTransaction; readonly data: DataCallback<T>; constructor(sentTransaction: SentTransaction, data: DataCallback<T>); get signature(): TransactionSignature; confirm(commitment?: Commitment, errorCallback?: (error: TransactionError) => void): Promise<T | null>; } export {};