All files / src/connect/tx types.ts

100% Statements 3/3
100% Branches 1/1
100% Functions 1/1
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90        3x                                                                                                                                                                          
import type { StacksNetwork } from 'micro-stacks/network';
import type { ClarityAbi, ClarityValue } from 'micro-stacks/clarity';
import type { PostConditionMode, PostCondition } from 'micro-stacks/transactions';
 
export enum TransactionTypes {
  ContractCall = 'contract_call',
  ContractDeploy = 'smart_contract',
  STXTransfer = 'token_transfer',
}
 
export interface TransactionOptionsBase {
  privateKey?: string;
  appDetails?: {
    name: string;
    icon: string;
  };
  postConditionMode?: PostConditionMode;
  postConditions?: (string | PostCondition)[];
  network?: StacksNetwork;
  stxAddress?: string;
  sponsored?: boolean;
  attachment?: string;
}
 
export interface TransactionPayloadBase {
  appDetails?: {
    name: string;
    icon: string;
  };
  stxAddress?: string;
  network?: StacksNetwork;
  publicKey?: string | null;
  postConditionMode?: PostConditionMode;
  postConditions?: (string | PostCondition)[];
  onFinish?: (data: any) => void;
  onCancel?: (error: any) => void;
}
 
/**
 * Contract Deploy
 */
 
export interface ContractDeployTxOptions extends TransactionOptionsBase {
  contractName: string;
  codeBody: string;
}
 
export interface ContractDeployTxPayload extends TransactionPayloadBase {
  contractName: string;
  codeBody: string;
  txType: TransactionTypes.ContractDeploy;
}
 
/**
 * Contract Call
 */
export interface ContractCallTxOptions extends TransactionOptionsBase {
  contractAddress: string;
  contractName: string;
  functionName: string;
  functionArgs: string[] | ClarityValue[];
  validateWithAbi?: boolean | ClarityAbi;
}
 
export interface ContractCallTxPayload extends TransactionPayloadBase {
  contractAddress: string;
  contractName: string;
  functionName: string;
  functionArgs: (string | ClarityValue)[];
  txType: TransactionTypes.ContractCall;
}
 
/**
 * STX transfer
 */
 
export interface StxTransferTxOptions extends TransactionOptionsBase {
  recipient: string;
  amount: bigint | string;
  memo?: string;
  onFinish?: (data: any) => void;
}
 
export interface StxTransferTxPayload extends TransactionPayloadBase {
  recipient: string;
  amount: string;
  memo?: string;
  txType: TransactionTypes.STXTransfer;
}