Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with transaction signing on testnet 22 with stellar SDK 13.0.0 #1113

Open
VarNotUsed opened this issue Nov 28, 2024 · 3 comments
Open
Labels

Comments

@VarNotUsed
Copy link

VarNotUsed commented Nov 28, 2024

I get TypeError: Cannot read properties of undefined (reading 'switch') when trying to sign a transaction with my generated bindings. I appended the decoded xdr. Tested it in Labratory, looks fine. Before the update this exact contract call was working fine.

Seems to be the credentials() which returns undefined

I've tested with different node versions, generated the bindings with 22 and 22.1, the problem remains

What version are you on?
@stellar/freighter-api": "3.0.0",
@stellar/stellar-sdk": "13.0.0",

const CollectionDeployerContract =
    new PhoenixNFTCollectionDeployerContract.Client({
      publicKey: storePersist.wallet.address!,
      contractId: constants.COLLECTION_DEPLOYER_ADDRESS,
      networkPassphrase: constants.NETWORK_PASSPHRASE,
      rpcUrl: constants.RPC_URL,
      // @ts-ignore
      signTransaction: async (tx: string) =>
        storePersist.wallet.walletType === "wallet-connect"
          ? signer.signTransaction(tx)
          : // @ts-ignore
            signer.sign(tx),
    });

   const tx = await CollectionDeployerContract.deploy_new_collection(
        {
          salt,
          admin: storePersist.wallet.address!,
          name,
          symbol,
        }
      );
  const res = await tx?.signAndSend();


async signTransaction(
    tx: XDR_BASE64,
    opts?: {
      network?: string;
      networkPassphrase?: string;
      accountToSign?: string;
    }
  ): Promise<XDR_BASE64> {
    const res = await signTransaction(tx);

    return res.error ? "" : res.signedTxXdr;
  }
{
  "tx": {
    "tx": {
      "source_account": "GBZWEHOLTS4UVSIZLCSBQNX2DFBDB5KU3E4DJX5MDKW3QQ4WZNNDTRU2",
      "fee": 9660307,
      "seq_num": 4460448090947585,
      "cond": {
        "time": {
          "min_time": 0,
          "max_time": 1732636525
        }
      },
      "memo": "none",
      "operations": [
        {
          "source_account": null,
          "body": {
            "invoke_host_function": {
              "host_function": {
                "invoke_contract": {
                  "contract_address": "CABR5MU6AGG2KSJ6EWVWRJJ6UYEQIC6LZXBBDPDOGTBGYQVDAMZNWSID",
                  "function_name": "deploy_new_collection",
                  "args": [
                    {
                      "bytes": "3cf9479c2ba0bae2ea9dabc41d8a5b577ab68aafeeb90060dbe2bb932c38d255"
                    },
                    {
                      "address": "GBZWEHOLTS4UVSIZLCSBQNX2DFBDB5KU3E4DJX5MDKW3QQ4WZNNDTRU2"
                    },
                    {
                      "string": "foo"
                    },
                    {
                      "string": "bar"
                    }
                  ]
                }
              },
              "auth": [
                {
                  "credentials": "source_account",
                  "root_invocation": {
                    "function": {
                      "contract_fn": {
                        "contract_address": "CABR5MU6AGG2KSJ6EWVWRJJ6UYEQIC6LZXBBDPDOGTBGYQVDAMZNWSID",
                        "function_name": "deploy_new_collection",
                        "args": [
                          {
                            "bytes": "3cf9479c2ba0bae2ea9dabc41d8a5b577ab68aafeeb90060dbe2bb932c38d255"
                          },
                          {
                            "address": "GBZWEHOLTS4UVSIZLCSBQNX2DFBDB5KU3E4DJX5MDKW3QQ4WZNNDTRU2"
                          },
                          {
                            "string": "foo"
                          },
                          {
                            "string": "bar"
                          }
                        ]
                      }
                    },
                    "sub_invocations": [
                      {
                        "function": {
                          "create_contract_v2_host_fn": {
                            "contract_id_preimage": {
                              "address": {
                                "address": "GBZWEHOLTS4UVSIZLCSBQNX2DFBDB5KU3E4DJX5MDKW3QQ4WZNNDTRU2",
                                "salt": "3cf9479c2ba0bae2ea9dabc41d8a5b577ab68aafeeb90060dbe2bb932c38d255"
                              }
                            },
                            "executable": {
                              "wasm": "d1ee3cb7eb78015e40e07c37d05b7f859692cf6484645ef84398d87755364dba"
                            },
                            "constructor_args": []
                          }
                        },
                        "sub_invocations": []
                      }
                    ]
                  }
                }
              ]
            }
          }
        }
      ],
      "ext": {
        "v1": {
          "ext": "v0",
          "resources": {
            "footprint": {
              "read_only": [
                {
                  "contract_data": {
                    "contract": "CABR5MU6AGG2KSJ6EWVWRJJ6UYEQIC6LZXBBDPDOGTBGYQVDAMZNWSID",
                    "key": "ledger_key_contract_instance",
                    "durability": "persistent"
                  }
                },
                {
                  "contract_code": {
                    "hash": "9b82c518b594d5c0dc0b561e26e97d602025bfc373debe1171524b2342fe5777"
                  }
                },
                {
                  "contract_code": {
                    "hash": "d1ee3cb7eb78015e40e07c37d05b7f859692cf6484645ef84398d87755364dba"
                  }
                }
              ],
              "read_write": [
                {
                  "contract_data": {
                    "contract": "CABR5MU6AGG2KSJ6EWVWRJJ6UYEQIC6LZXBBDPDOGTBGYQVDAMZNWSID",
                    "key": {
                      "vec": [
                        {
                          "symbol": "AllCollections"
                        }
                      ]
                    },
                    "durability": "persistent"
                  }
                },
                {
                  "contract_data": {
                    "contract": "CABR5MU6AGG2KSJ6EWVWRJJ6UYEQIC6LZXBBDPDOGTBGYQVDAMZNWSID",
                    "key": {
                      "vec": [
                        {
                          "symbol": "Creator"
                        },
                        {
                          "address": "GBZWEHOLTS4UVSIZLCSBQNX2DFBDB5KU3E4DJX5MDKW3QQ4WZNNDTRU2"
                        }
                      ]
                    },
                    "durability": "persistent"
                  }
                },
                {
                  "contract_data": {
                    "contract": "CD3N7J5U45W5EFE5UC6LJ4IVESVTRFVLTMCTTQ5YDUFBBJKSTQGYEFRZ",
                    "key": {
                      "vec": [
                        {
                          "symbol": "Admin"
                        }
                      ]
                    },
                    "durability": "persistent"
                  }
                },
                {
                  "contract_data": {
                    "contract": "CD3N7J5U45W5EFE5UC6LJ4IVESVTRFVLTMCTTQ5YDUFBBJKSTQGYEFRZ",
                    "key": {
                      "vec": [
                        {
                          "symbol": "Config"
                        }
                      ]
                    },
                    "durability": "persistent"
                  }
                },
                {
                  "contract_data": {
                    "contract": "CD3N7J5U45W5EFE5UC6LJ4IVESVTRFVLTMCTTQ5YDUFBBJKSTQGYEFRZ",
                    "key": {
                      "vec": [
                        {
                          "symbol": "IsInitialized"
                        }
                      ]
                    },
                    "durability": "persistent"
                  }
                },
                {
                  "contract_data": {
                    "contract": "CD3N7J5U45W5EFE5UC6LJ4IVESVTRFVLTMCTTQ5YDUFBBJKSTQGYEFRZ",
                    "key": "ledger_key_contract_instance",
                    "durability": "persistent"
                  }
                }
              ]
            },
            "instructions": 4615434,
            "read_bytes": 15416,
            "write_bytes": 856
          },
          "resource_fee": 9660207
        }
      }
    },
    "signatures": [
      {
        "hint": "96cb5a39",
        "signature": "b29142e2dd6ae63cd8ff42985cef7d15f5462443cb9b44d443de194f7a1f671de760c2f944a88b51d46d393616ee885ef11a1f4167f24922448fa986e8df5306"
      }
    ]
  }
}
@VarNotUsed VarNotUsed added the bug label Nov 28, 2024
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Nov 28, 2024
@tupui
Copy link

tupui commented Dec 8, 2024

I think I have the same, I posted a question here https://discord.com/channels/897514728459468821/1315433251044724766/1315433251044724766

Did you resolve it @VarNotUsed?

@leighmcculloch
Copy link
Member

leighmcculloch commented Dec 9, 2024

Possibly also related this other thread from 1-2 weeks ago:
https://discord.com/channels/897514728459468821/1311042271160045598

@janewang janewang moved this from Backlog (Not Ready) to Backlog (Ready for Design) in DevX Dec 9, 2024
@janewang janewang moved this from Backlog (Ready for Design) to Todo (Ready for Dev) in DevX Dec 9, 2024
@Shaptic
Copy link
Contributor

Shaptic commented Dec 9, 2024

Reposting what I posted in Discord:

Please read the breaking changes in the v13.0.0 release notes. This is one relevant piece:

The ClientOptions.signTransaction type has been updated to reflect the latest SEP-43 protocol, which matches the latest major version of Freighter and other wallets. It now accepts address, submit, and submitUrl options, and it returns a promise containing the signedTxXdr and the signerAddress. It now also returns an Error type if an error occurs during signing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo (Ready for Dev)
Development

No branches or pull requests

4 participants