Class: Solace::Instructions::SplToken::CloseAccountInstruction

Inherits:
Object
  • Object
show all
Defined in:
lib/solace/instructions/spl_token/close_account_instruction.rb

Overview

Instruction builder for SPL Token Program CloseAccount.

The CloseAccount instruction closes a token account and transfers all remaining lamports to a destination account. The token account must have a balance of zero.

Instruction discriminator: 9

Accounts:

  1. writable

    Token account to close

  2. writable

    Destination account to receive lamports

  3. signer

    Account authority

Since:

  • 0.1.2

Constant Summary collapse

INSTRUCTION_DISCRIMINATOR =

Instruction discriminator for CloseAccount

Since:

  • 0.1.2

[9].freeze

Class Method Summary collapse

Class Method Details

.build(account_index:, destination_index:, authority_index:, program_index:) ⇒ Solace::Instruction

Builds a CloseAccount instruction

Parameters:

  • account_index (Integer)

    Index of the token account to close

  • destination_index (Integer)

    Index of the destination account

  • authority_index (Integer)

    Index of the account authority

  • program_index (Integer)

    Index of the SPL Token program

Returns:

Since:

  • 0.1.2



30
31
32
33
34
35
36
# File 'lib/solace/instructions/spl_token/close_account_instruction.rb', line 30

def self.build(account_index:, destination_index:, authority_index:, program_index:)
  Solace::Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts = [, destination_index, authority_index]
    ix.data = data
  end
end

.dataArray

Builds the data for a CloseAccount instruction

The BufferLayout is:

- [Instruction Index (1 byte)]

Returns:

  • (Array)

    1-byte instruction index

Since:

  • 0.1.2



44
45
46
# File 'lib/solace/instructions/spl_token/close_account_instruction.rb', line 44

def self.data
  INSTRUCTION_DISCRIMINATOR
end