Build error when using `Mapping<K,V,H>` where `V` has no default constructor.
- Dominant language
- TypeScript
- Stars
- 31
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
Error when build contracts when using `Mapping` type where type `V` take more than one required constructor arguments.
### Example contract
Using `Uint8Array` for mapping value, it takes length as mandatory constructor argument.
```ts
import {
AccountId, HashKeccak256, Mapping
} from "ask-lang";
@spreadLayout()
class Data {
map: Mapping = new Mapping();
}
@contract()
export class Contract {
data: Data;
constructor() {
this.data = new Data();
}
@constructor()
default(): void {}
@message()
get(account: AccountId): Uint8Array {
// return new Uint8Array(0);
return this.data.map.get(account); // works if this line is commemted out.
}
}
```
### Error
```console
$ ASK_CONFIG=./askconfig.json asc --config asconfig.json serialize.ts
ERROR TS2554: Expected 1 arguments, but got 0.
return instantiate();
~~~~~~~~~~~~~~~~
in ~lib/as-serde-scale/misc.ts(21,20)
FAILURE 1 compile error(s)
error Command failed with exit code 1.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the contract build with the Mapping example and inspect lib/as-serde-scale/misc.ts at the instantiate() call reported in the error. Trace how Mapping values are deserialized, then verify that the example compiles without requiring a default constructor for Uint8Array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, wasm
- Domain
- blockchain
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100