Skip to content

Make options for .signAsync optional #2012

@xlc

Description

@xlc

Goal:

Update signAsync to make the second argument optional, and default to {}

Background:

Currently this code will crash:

const signed = await api.system.remark().signAsync(pair, options); when options is undefined, it gives this error

(node:78914) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'nonce' of undefined
    at Submittable.value (/Users/xiliangchen/projects/playground/node_modules/@polkadot/api/submittable/createClass.js:59:42)
    at Submittable.value (/Users/xiliangchen/projects/playground/node_modules/@polkadot/api/submittable/createClass.js:129:99)
    at /Users/xiliangchen/projects/playground/node_modules/@polkadot/api/submittable/createClass.js:251:110
    at /Users/xiliangchen/projects/playground/node_modules/@polkadot/api/promise/Api.js:78:14
    at Submittable.signAsync (/Users/xiliangchen/projects/playground/node_modules/@polkadot/api/submittable/createClass.js:251:170)
    at /Users/xiliangchen/projects/playground/index.ts:28:33
    at step (/Users/xiliangchen/projects/playground/index.ts:33:23)
    at Object.next (/Users/xiliangchen/projects/playground/index.ts:14:53)
    at /Users/xiliangchen/projects/playground/index.ts:8:71
    at new Promise (<anonymous>)

Actions:

Make second argument optional

public signAsync (account: AddressOrPair, optionsOrNonce: Partial<SignerOptions>): SubmittableThis<ApiType, this> {

Update interface

signAsync(account: AddressOrPair, _options: Partial<SignatureOptions>): SubmittableThis<ApiType, this>;

Provide appropriate unit tests.


@jacogr please tag this if you are happy about this.

Tags:
bounty-awaiting-approval
bounty-XS

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugTracks issues causing errors or unintended behavior, critical to fix for reliability.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions