Skip to content

Build error when using Mapping<K,V,H> where V has no default constructor. #245

Description

@ashutoshvarma

Problem

Error when build contracts when using Mapping<K,V,H> 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.

import {
    AccountId, HashKeccak256, Mapping
} from "ask-lang";

@spreadLayout()
class Data {
  map: Mapping<AccountId, Uint8Array, HashKeccak256> = 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

$ ASK_CONFIG=./askconfig.json asc --config asconfig.json serialize.ts
ERROR TS2554: Expected 1 arguments, but got 0.

             return instantiate<T>();
                    ~~~~~~~~~~~~~~~~
 in ~lib/as-serde-scale/misc.ts(21,20)

FAILURE 1 compile error(s)
error Command failed with exit code 1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions