junobuild / juno-js

JavaScript libraries for interfacing with Juno
MIT License
14 stars 1 forks source link

listAssets candid decoded arguments error #170

Closed ByronBecker closed 1 month ago

ByronBecker commented 1 month ago

When importing listAssets from @junobuild/core and using it in a NodeJS context, like this:

  await listAssets({
    collection: "user-profile-avatar",
    satellite: {
      identity: anonymous,
      satelliteId: "njz5m-nyaaa-aaaal-ajola-cai",
      fetch,
    },
  });

I receive the following error:

Pr [Error]: Call failed:
  Canister: <my_canister_id>
  Method: list_assets (query)
  "Status": "rejected"
  "Code": "CanisterError"
  "Message": "IC0503: Error from Canister <my_canister_id>: Canister called `ic0.trap` with message: failed to decode call arguments: Custom(Fail to decode argument 0 from table0 to text\n\nCaused by:\n    Subtyping error: text).\nConsider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly"
    at 

    ...

    index.mjs:30:18) {
  canisterId: Cr {
    _arr: Uint8Array(10) [
       0,  0,   0, 0, 1,
      96, 75, 150, 1, 1
    ],
    _isPrincipal: true
  },
  methodName: 'list_assets',
  type: 'query',
  props: {
    Status: 'rejected',
    Code: 'CanisterError',
    Message: 'IC0503: Error from Canister <my_canister_id>: Canister called `ic0.trap` with message: failed to decode call arguments: Custom(Fail to decode argument 0 from table0 to text\n' +
      '\n' +
      'Caused by:\n' +
      '    Subtyping error: text).\n' +
      'Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly'
  },
  result: {
    status: 'rejected',
    error_code: 'IC0503',
    reject_code: 5,
    reject_message: 'IC0503: Error from Canister <my_canister_id>: Canister called `ic0.trap` with message: failed to decode call arguments: Custom(Fail to decode argument 0 from table0 to text\n' +
      '\n' +
      'Caused by:\n' +
      '    Subtyping error: text).\n' +
      'Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly',
    signatures: [
      {
        timestamp: L { s: 1, e: 18, c: [ 17215, 26329805564931 ] },
        signature: Uint8Array(64) [
          147,  47,  88,   0,  83, 149,  78, 202, 195,   4,  96,
          164, 255, 227,  59, 112, 171,   0,  14,  44, 118, 246,
          170,  26,  26,  66, 100, 118, 115,   7,  67, 199,  87,
           87,  76,  52, 157, 239, 206,  23, 232,  10,   5, 160,
          173, 210, 206,  69, 200, 201, 114, 116,  22,  71, 103,
          247, 140, 122,   6,  35, 238, 177, 182,   9
        ],
        identity: Uint8Array(29) [
          235, 158,  15, 112, 233, 184, 191, 31,
           49, 179,  85,  43,  63, 184, 186, 80,
           52,  62, 230, 183,  45, 201,  27, 87,
          141, 100,   6,  88,   2
        ]
      }
    ]
  }
}
peterpeterparker commented 1 month ago

Not sure what's happening, your identity is correct?

With the sample I got no issue: https://github.com/junobuild/examples/blob/main/node/basic/assets.mjs

What's the version of your Satellite? What version of the library are you using?

peterpeterparker commented 1 month ago

Maybe it's because you used the snippet which was outdated. If you update is as I just did it should work out.