soroban-cli
soroban-cli copied to clipboard
Vector of BytesN<4> is having trouble
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
@kalepail It's not clear to me what you were attempting to do and what were you expecting. Can you please clarify it? Thanks!
I was attempting to use the ts bindings of a contract to submit an invocation containing a Vec<BytesN<4>> type. When performing that invocation I got the error.