stellar / stellar-cli

CLI for Soroban contracts.
65 stars 55 forks source link

`TypeError: accountId not set` when trying to `signAuthEntries` #1485

Open kalepail opened 1 month ago

kalepail commented 1 month ago

What version are you using?

CLI

% stellar --version
stellar 21.2.0 (41a1e0dd0e3e8e34f94b4e78fc7f71d7f15420c7)
soroban-env 21.2.0 (8809852dcf8489f99407a5ceac12625ee3d14693)
soroban-env interface version 90194313216
stellar-xdr 21.2.0 (9bea881f2057e412fdbb98875841626bf77b4b88)
xdr curr (70180d5e8d9caee9e8645ed8a38c36a8cf403cd9)

TS bindings and base js-sdk library are both using:

"@stellar/stellar-sdk": "12.2.0"

What did you do?

Attempting to sign auth entries using the signAuthEntries method of the TS bindings.

What did you expect to see?

No errors.

What did you see instead?

1725 |     this._arm = arm;
1726 |     this._armType = arm === _void__WEBPACK_IMPORTED_MODULE_0__.Void ? _void__WEBPACK_IMPORTED_MODULE_0__.Void : this.constructor._arms[arm];
1727 |     this._value = value;
1728 |   }
1729 |   get(armName = this._arm) {
1730 |     if (this._arm !== _void__WEBPACK_IMPORTED_MODULE_0__.Void && this._arm !== armName) throw new TypeError(`${armName} not set`);
                                                                                                     ^
TypeError: accountId not set
      at get (/Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/js-xdr/lib/xdr.js:1730:95)
      at /Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:248:59
      at map (:1:21)
      at /Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:247:31
      at _callee6$ (/Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:280:40)
      at tryCatch (/Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:33:911)
      at /Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:33:2859
      at /Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:33:1545
      at asyncGeneratorStep (/Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:40:66)
      at _next (/Users/tylervanderhoeven/Desktop/check-auth-puzzle/bun_tests/puzzle-sdk/node_modules/@stellar/stellar-sdk/lib/contract/assembled_transaction.js:41:163)

Bun v1.1.8 (macOS arm64)

Here's a Bun JS TS file for the error.

import { SorobanRpc, Networks, Keypair, xdr, hash, Address, Operation } from '@stellar/stellar-sdk'
import { basicNodeSigner, DEFAULT_TIMEOUT } from '@stellar/stellar-sdk/contract';
import { Client, networks } from 'puzzle-sdk'

const keypair = Keypair.fromSecret('SDNS3C4YQ5BDBXBZ56MEB754VLY352VSWGJZNW3W5CIUXEI3MEBTWKFT'); // GDT3KJMJIQWDOZWERC3K5SSGQGYALT2VSUAQP2YEGDK7YDPSQWUCIHYZ
const publicKey = keypair.publicKey()

const nativeSAC = 'CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC'
const contractId = 'CDLOZN6IK55ANUCMERGWIDBITVKSJE452B6VN37ZMRJGBGELSWXSUANG'

const rpcUrl = 'https://soroban-testnet.stellar.org'
const rpc = new SorobanRpc.Server(rpcUrl)

const networkPassphrase = Networks.TESTNET

const contract = new Client({
    ...networks.testnet,
    ...basicNodeSigner(keypair, networkPassphrase),
    networkPassphrase,
    contractId,
    publicKey,
    rpcUrl,
})

const { built, simulationData, ...rest } = await contract.call({
    sac: nativeSAC
})

rest.signAuthEntries()

console.log(built?.toXDR());
leighmcculloch commented 1 month ago

cc @Shaptic @chadoh

chadoh commented 1 month ago

@kalepail do you have a test repository I can clone to experience this error? I'll try to reproduce with my own signAuthEntries use-case but it would help to see the original.