@tiplink/api
Version:
Api for creating and sending TipLinks
77 lines (76 loc) • 2.69 kB
TypeScript
import { Connection, PublicKey, Transaction } from "@solana/web3.js";
import { Mint } from "@solana/spl-token";
interface CreateWithReceiverArgs {
connection: Connection;
amount: number;
toEmail: string;
depositor: PublicKey;
receiverTipLink: PublicKey;
mint?: Mint;
depositorTa?: PublicKey;
allowDepositorOffCurve?: boolean;
}
interface CreateWithApiArgs {
connection: Connection;
amount: number;
toEmail: string;
depositor: PublicKey;
apiKey: string;
mint?: Mint;
depositorTa?: PublicKey;
allowDepositorOffCurve?: boolean;
}
interface GetWithReceiverArgs {
connection: Connection;
pda: PublicKey;
receiverEmail: string;
}
interface GetWithApiArgs {
connection: Connection;
pda: PublicKey;
apiKey: string;
}
export declare function getEscrowReceiverTipLink(connection: Connection, pda: PublicKey): Promise<PublicKey | undefined>;
/**
* Represents an on-chain escrow that can be withdrawn by the original depositor or a TipLink, e-mailed to a recipient.
* The depositor does not see the TipLink, enabling multi-sig. (Otherwise, one signer could unilaterally withdraw the funds to themselves.)
*
* @remarks EscrowTipLinks currently only support SOL and SPL assets.
*/
export declare class EscrowTipLink {
toEmail: string;
receiverTipLink: PublicKey;
amount: number;
depositor: PublicKey;
escrowId: PublicKey;
pda: PublicKey;
mint?: Mint;
depositorTa?: PublicKey;
get depositorUrl(): URL;
private constructor();
/**
* Creates an EscrowTipLink instance to be deposited.
*
* @param depositorTa - Overrides for non-ATA cases
*/
static create(args: CreateWithReceiverArgs | CreateWithApiArgs): Promise<EscrowTipLink>;
/**
* Creates an EscrowTipLink instance from a deposited, on-chain escrow.
*
* To get data for withdrawn / closed escrows, use `parseEscrowIx`,
* `parseEscrowTx`, or `getAllRecordedEscrowActions`, the last of which should be called
* on backends and cached for performance.
*/
static get(args: GetWithReceiverArgs | GetWithApiArgs): Promise<EscrowTipLink | undefined>;
private depositLamportTx;
private depositSplTx;
depositTx(connection: Connection): Promise<Transaction>;
private withdrawLamportTx;
private withdrawSplTx;
/**
* @param dest - The owner account, *not* the token account (if an SPL escrow)
* @param allowDestOffCurve - Allow calculated ATA to be off-curve (if an SPL escrow)
*/
withdrawTx(connection: Connection, authority: PublicKey, dest: PublicKey, allowDestOffCurve?: boolean): Promise<Transaction>;
}
export {};