Skip to content

Commit

Permalink
Merge pull request #250 from Virus-Axel/bugfix/ata_token_pid
Browse files Browse the repository at this point in the history
Fix token program parameter in ata builder
  • Loading branch information
Virus-Axel authored Jul 30, 2024
2 parents 93939ad + c3bd624 commit a473ae3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/anchor_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace godot{
class AnchorProgram : public Node{
GDCLASS(AnchorProgram, Node)
private:
Variant idl;
Dictionary idl;
String pid;
String url_override = "";
String pending_account_name = "";
Expand Down
2 changes: 1 addition & 1 deletion instructions/src/associated_token_account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Variant AssociatedTokenAccountProgram::create_associated_token_account(const Var
result->append_meta(AccountMeta(wallet_address, false, false));
result->append_meta(AccountMeta(mint_address, false, false));
result->append_meta(AccountMeta(SystemProgram::get_pid(), false, false));
result->append_meta(AccountMeta(TokenProgram::get_pid(), false, false));
result->append_meta(AccountMeta(token_program_id, false, false));

return result;
}
Expand Down
11 changes: 3 additions & 8 deletions src/anchor_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ Dictionary AnchorProgram::option(const Variant &val){
}

Variant AnchorProgram::build_instruction(String name, Array accounts, Variant arguments){
ERR_FAIL_COND_V_EDMSG(idl.is_empty(), nullptr, "IDL is empty, try loading from PID or JSON file.");
Instruction *result = memnew(Instruction);

PackedByteArray data = discriminator_by_name(name.to_snake_case());
Expand All @@ -852,15 +853,9 @@ Variant AnchorProgram::build_instruction(String name, Array accounts, Variant ar
result->set_data(data);

const Dictionary instruction_info = find_idl_instruction(name);
if(instruction_info.is_empty()){
internal::gdextension_interface_print_warning((String("IDL does not contain an instruction named ") + name + ".").ascii(), "build_instruction", __FILE__, __LINE__, true);
return nullptr;
}

if(((Array)instruction_info["accounts"]).size() != accounts.size()){
internal::gdextension_interface_print_warning("Unexpected amount or accounts", "build_instruction", __FILE__, __LINE__, true);
return nullptr;
}
ERR_FAIL_COND_V_EDMSG(instruction_info.is_empty(), nullptr, (String("IDL does not contain an instruction named ") + name + ".").ascii());
ERR_FAIL_COND_V_EDMSG(((Array)instruction_info["accounts"]).size() != accounts.size(), nullptr, "Unexpected amount or accounts");

Array ref_accounts = instruction_info["accounts"];

Expand Down

0 comments on commit a473ae3

Please sign in to comment.