Module: Solana::Ruby::Kit::Programs
- Extended by:
- T::Sig
- Defined in:
- lib/solana/ruby/kit/programs.rb
Class Method Summary collapse
Class Method Details
.get_program_error_code(err) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/solana/ruby/kit/programs.rb', line 28 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
18 19 20 21 22 23 |
# File 'lib/solana/ruby/kit/programs.rb', line 18 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 |