Skip to content

Add Signer to Api #660

@ianhe8x

Description

@ianhe8x

As a dapp, it doesn't always have access to key pair. Key pairs could be managed in a browser extension or hardware wallet. So I propose to introduce signer to api and let it do the signing. This will allow our browser extension to work with the api by exposing a signer into browser's global.

export interface Signer {
  sign(extrinsic: Extrinsic, opt: {from: string} & SignatureOptions): Promise<void>;
}

signAndSend is the place to use the signer. I prefer to changing the signature to below which looks more neat

  signAndSend (options: SignAndSendOptions)
  signAndSend (options: SignAndSendOptions, statusCb: StatusCb)
  signAndSend (options: SignAndSendOptions, statusCb?: StatusCb)

interface SignAndSendOptions extends Partial<SignatureOptions> {
  from: string | KeyringPair
}

though to keep backward compatible, it could also be like:

signAndSend (account: KeyringPair | string, _options?: Partial<SignatureOptionsPartial> | StatusCb, statusCb?: StatusCb)

I would like to hear from you if it's the right direction before submitting my PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions