Module: Solana::Ruby::Kit::Programs
- Extended by:
- T::Sig
- Defined in:
- lib/solana/ruby/kit/programs.rb,
lib/solana/ruby/kit/programs/system_program.rb,
lib/solana/ruby/kit/programs/associated_token_account.rb
Defined Under Namespace
Modules: AssociatedTokenAccount, SystemProgram
Class Method Summary
collapse
Class Method Details
.get_program_error_code(err) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/solana/ruby/kit/programs.rb', line 30
def get_program_error_code(err)
return nil unless err.is_a?(Hash)
instruction_error = err['InstructionError']
return nil unless instruction_error.is_a?(Array) && instruction_error.length == 2
inner = instruction_error[1]
return nil unless inner.is_a?(Hash) && inner.key?('Custom')
Kernel.Integer(inner['Custom'])
rescue TypeError, ArgumentError
nil
end
|
.program_error?(err, expected_code: nil) ⇒ Boolean
20
21
22
23
24
25
|
# File 'lib/solana/ruby/kit/programs.rb', line 20
def program_error?(err, expected_code: nil)
code = get_program_error_code(err)
return false if code.nil?
expected_code ? code == expected_code : true
end
|