Options
All
  • Public
  • Public/Protected
  • All
Menu

Standin for the the [https://phantom.app/ | phantom wallet] to use while testing. Behaves as much as possible as the original which is why care needs to be taken when using it.

The main difference is that no user confirmation is required to approve a transaction or signature.

This means that user approval is automatic!

Hierarchy

Implements

Index

Constructors

Private constructor

  • new PhantomWalletMock(_connectionURL: string, _keypair: Keypair, _commitmentOrConfig?: Commitment | ConnectionConfig): PhantomWalletMock
  • Parameters

    • _connectionURL: string
    • _keypair: Keypair
    • Optional _commitmentOrConfig: Commitment | ConnectionConfig

    Returns PhantomWalletMock

Properties

Private _connection

_connection: undefined | Connection

Private _signer

_signer: Signer

Private _transactionSignatures

_transactionSignatures: string[] = []

Readonly isPhantom

isPhantom: true = true

Other Accessors

connection

  • get connection(): Connection

isConnected

  • get isConnected(): boolean

publicKey

  • get publicKey(): PublicKey

signer

  • get signer(): Signer

TestAPI Accessors

commitment

  • get commitment(): undefined | Commitment

connectionURL

  • get connectionURL(): string

secretKey

  • get secretKey(): string

transactionSignatures

  • get transactionSignatures(): string[]
  • All transactions signatures made since wallet was created ordered oldest to most recent.

    category

    TestAPI

    Returns string[]

Other Methods

_handleDisconnect

  • _handleDisconnect(...args: unknown[]): unknown

_signerFromKeypair

  • _signerFromKeypair(keypair: Keypair): { publicKey: PublicKey; secretKey: Uint8Array }
  • Parameters

    • keypair: Keypair

    Returns { publicKey: PublicKey; secretKey: Uint8Array }

    • publicKey: PublicKey
    • secretKey: Uint8Array

addListener

connect

  • connect(): Promise<void>
  • Connects the wallet to the URL provided on wallet creation. This needs to be called before attempting to sign messages or transactions.

    emits 'connect'

    Returns Promise<void>

disconnect

  • disconnect(): Promise<void>

emit

eventNames

  • Return an array listing the events for which the emitter has registered listeners.

    Returns keyof PhantomWalletEvents[]

listenerCount

  • Return the number of listeners listening to a given event.

    Parameters

    Returns number

listeners

off

on

once

removeAllListeners

removeListener

signAllTransactions

  • signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>

signMessage

  • signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>

signTransaction

  • signTransaction(txIn: Transaction): Promise<Transaction>

Static create

  • create(connectionURL: string, keypair?: Keypair, commitmentOrConfig?: Commitment | ConnectionConfig): PhantomWalletMock

TestAPI Methods

changeWallet

  • changeWallet(keypair: Keypair): void
  • Changes the Wallet to the provided keypair This updates the signer as well.

    Parameters

    • keypair: Keypair

    Returns void

getBalance

  • getBalance(commitment?: Commitment): Promise<number>
  • Fetch the balance for the wallet's account.

    Parameters

    • commitment: Commitment = 'confirmed'

    Returns Promise<number>

getBalanceSol

  • getBalanceSol(commitment?: Commitment): Promise<number>
  • Fetch the balance in Sol for the wallet's account.

    Parameters

    • commitment: Commitment = 'confirmed'

    Returns Promise<number>

getLastConfirmedTransaction

  • getLastConfirmedTransaction(commitment?: Finality): Promise<null | ConfirmedTransaction>
  • Fetches transaction details for the last confirmed transaction signed with this wallet.

    Parameters

    • Optional commitment: Finality

    Returns Promise<null | ConfirmedTransaction>

lastConfirmedTransactionString

  • lastConfirmedTransactionString(commitment?: Finality): Promise<string>
  • Fetches transaction details for the last confirmed transaction signed with this wallet and returns its summary that can be used to log it to the console.

    Parameters

    • Optional commitment: Finality

    Returns Promise<string>

lastConfirmedTransactionSummary

  • lastConfirmedTransactionSummary(commitment?: Finality): Promise<undefined | TransactionSummary>
  • Fetches transaction details for the last confirmed transaction signed with this wallet and returns its summary.

    Parameters

    • Optional commitment: Finality

    Returns Promise<undefined | TransactionSummary>

requestAirdrop

  • requestAirdrop(sol: number): Promise<RpcResponseAndContext<SignatureResult>>
  • Drops sol to the currently connected wallet.

    Parameters

    • sol: number

    Returns Promise<RpcResponseAndContext<SignatureResult>>

Generated using TypeDoc