Class: Solace::Instructions::Token2022::CloseAccountInstruction

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

Overview

Instruction builder for Token-2022 CloseAccount.

Closes a Token-2022 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.5

Constant Summary collapse

INSTRUCTION_DISCRIMINATOR =

Instruction discriminator for CloseAccount

Since:

  • 0.1.5

[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 Token-2022 program

Returns:

Since:

  • 0.1.5



30
31
32
33
34
35
36
# File 'lib/solace/instructions/token_2022/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.5



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

def self.data
  INSTRUCTION_DISCRIMINATOR
end