api: Error: createType(Text):: Text:: Decoded input doesn't match input
Hi, I call my smart contract functions and they return correctly but when I call one specific function in polkadot.js, this error happens:
Error: createType(Text):: Text:: Decoded input doesn't match input, received 0x2070726f7669646572 (9 bytes), created 0x242070726f7669646572 (10 bytes)
at createTypeUnsafe (node_modules/@polkadot/types/create/createType.cjs:58:11)
at formatData (node_modules/@polkadot/api-contract/util.cjs:20:39)
at MapSubscriber.project (node_modules/@polkadot/api-contract/base/Contract.cjs:162:81)
at MapSubscriber._next (node_modules/rxjs/internal/operators/map.js:49:35)
at MapSubscriber.Subscriber.next (node_modules/rxjs/internal/Subscriber.js:66:18)
at RefCountSubscriber.Subscriber._next (node_modules/rxjs/internal/Subscriber.js:89:26)
at RefCountSubscriber.Subscriber.next (node_modules/rxjs/internal/Subscriber.js:66:18)
at ReplaySubject.Subject.next (node_modules/rxjs/internal/Subject.js:60:25)
at ReplaySubject.nextInfiniteTimeWindow (node_modules/rxjs/internal/ReplaySubject.js:50:31)
at ConnectableSubscriber.Subscriber._next (node_modules/rxjs/internal/Subscriber.js:89:26)
at ConnectableSubscriber.Subscriber.next (node_modules/rxjs/internal/Subscriber.js:66:18)
at /Users/project/node_modules/@polkadot/rpc-core/index.cjs:262:20
at processTicksAndRejections (internal/process/task_queues.js:93:5)
The function in ink! contract
pub fn get_username(&self) -> String {
let caller: AccountId = self.env().caller();
match self.address_to_username.get(&caller) {
Some(username) => username.clone(),
None => panic!("this address has not a valid associated username!"),
}
}
I use these versions:
"@polkadot/api": "^4.9.2",
"@polkadot/api-contract": "^4.9.2",
Thanks for helping:)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- problem in polkadot.js decode https://github.com/polkadot-js/api/issues/3515 — committed to oxydev/SubsCrypt-npm-library by SaberDoTcodeR 3 years ago
- getUsername is working now https://github.com/polkadot-js/api/issues/3515 is solved — committed to oxydev/SubsCrypt-npm-library by SaberDoTcodeR 3 years ago
@jacogr Thanks a lot. it’s fixed.
@azhu003 Your issue have got nothing to do with the decoding of
Text
fields and it out of scope for this as logged. Rather your contract pallet version is different from the one the API supports - it only tracks latest Substrate master for contracts since it evolves constantly.@SaberDoTcodeR Could you please verify if it is still an issue in 4.11.2?
This is the contract file.
Since you tried the betas… can you give
4.9.3-17
a go since it includes the linked PR?(There was a case that was missed, it has been added alongside the missing tests for these checks…)