Vector of BytesN<4> is having trouble

Open
#1,184 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust, typescript
Domain
api

Research direction

Reproduce the contract.mint call using the shown Vec<BytesN<4>> canvas, then inspect node_modules/@stellar/stellar-sdk/lib/contract_spec.js at scValToNative and dist/esm/assembled-tx.js where result conversion is invoked. Done means the call no longer raises the reported type error for this vector result.

Written by the indexing model from the issue text.

Description

bug

Soroban version

% soroban --version
soroban 20.2.0 (v20.0.0-rc3-125-g07dcd3c78a15f3ad0db023c3242e154443eb106a)
soroban-env 20.1.0 (36d33cb6c986c9a8a9200b7eb04cf02e2c3f0ef4)
soroban-env interface version 85899345920
stellar-xdr 20.0.2 (a928e82943e4e93c887555fdec3b1e139ad810d2)
xdr curr (bb54e505f814386a3f45172e0b7e95b7badbe969)

Relevant rust contract code (see the canvas arg)

pub fn mint(
    env: Env,
    canvas: Vec<BytesN<4>>,
    owner: Address,
    author: String,
) -> Option<Vec<BytesN<4>>> { }

The generated TS binding interface for the above contract function

const { result } = await contract.mint({
    canvas: [
        Buffer.from([226, 148, 140, 0]),
        Buffer.from([226, 148, 172, 0]),
        Buffer.from([226, 148, 172, 0]),
        Buffer.from([226, 148, 172, 0]),
        Buffer.from([226, 148, 144, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 150, 128, 0]),
        Buffer.from([226, 150, 132, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 150, 136, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 150, 128, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 150, 132, 0]),
        Buffer.from([226, 150, 128, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 148, 130, 0]),
        Buffer.from([226, 148, 180, 0]),
        Buffer.from([226, 148, 180, 0]),
        Buffer.from([226, 148, 180, 0]),
        Buffer.from([226, 148, 180, 0]),
        Buffer.from([226, 148, 180, 0]),
    ],
    owner: 'GAKZAQ5AIODB635TLYSAV7NM3TV4LCHMOBHLNY7LEHO3LWDHLK4UG6QK',
    author: 'kalepail'
})

The resulting error when running the above code

413 |               var valTypes = tuple.valueTypes();
414 |               return ((_scv$vec2 = scv.vec()) !== null && _scv$vec2 !== void 0 ? _scv$vec2 : []).map(function (elm, i) {
415 |                 return _this5.scValToNative(elm, valTypes[i]);
416 |               });
417 |             }
418 |             throw new TypeError("Type ".concat(typeDef, " was not vec, but ").concat(scv, " is"));
                        ^
TypeError: Type [object Object] was not vec, but [object Object] is
      at scValToNative (/Users/tylervanderhoeven/Desktop/kalewalk/kalewalk-sdk/node_modules/@stellar/stellar-sdk/lib/contract_spec.js:418:19)
      at funcResToNative (/Users/tylervanderhoeven/Desktop/kalewalk/kalewalk-sdk/node_modules/@stellar/stellar-sdk/lib/contract_spec.js:100:14)
      at result (/Users/tylervanderhoeven/Desktop/kalewalk/kalewalk-sdk/dist/esm/assembled-tx.js:139:20)
      at /Users/tylervanderhoeven/Desktop/kalewalk/index.ts:35:26
Dominant language
Rust
Stars
123
Forks
141
Avg merge
2d 21h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-cli

All issues in stellar/stellar-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.