@polkadot/api/types#SignerResult TypeScript Examples
The following examples show how to use
@polkadot/api/types#SignerResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: snap.ts From metamask-snap-polkadot with Apache License 2.0 | 6 votes |
public signer: InjectedSigner = {
signPayload: async (payload: SignerPayloadJSON): Promise<SignerResult> => {
const signature = await signPayloadJSON.bind(this)(payload);
const id = this.requestCounter;
this.requestCounter += 1;
return {id, signature};
},
signRaw: async (raw: SignerPayloadRaw): Promise<SignerResult> => {
const signature = await signPayloadRaw.bind(this)(raw);
const id = this.requestCounter;
this.requestCounter += 1;
return {id, signature};
},
update: () => null
};
Example #2
Source File: ApiSigner.ts From crust-apps with Apache License 2.0 | 6 votes |
public async signPayload (payload: SignerPayloadJSON): Promise<SignerResult> {
return new Promise((resolve, reject): void => {
this.#queuePayload(this.#registry, payload, (id: number, result: SignerResult | null): void => {
if (result) {
resolve(result);
} else {
reject(new Error('Unable to sign'));
}
});
});
}
Example #3
Source File: QrSigner.ts From crust-apps with Apache License 2.0 | 6 votes |
public async signPayload (payload: SignerPayloadJSON): Promise<SignerResult> {
return new Promise((resolve, reject): void => {
// limit size of the transaction
const isQrHashed = (payload.method.length > 5000);
const wrapper = this.#registry.createType('ExtrinsicPayload', payload, { version: payload.version });
const qrPayload = isQrHashed
? blake2AsU8a(wrapper.toU8a(true))
: wrapper.toU8a();
this.#setState({
isQrHashed,
qrAddress: payload.address,
qrPayload,
qrReject: reject,
qrResolve: resolve
});
});
}
Example #4
Source File: SingleAccountSigner.ts From interbtc-api with Apache License 2.0 | 6 votes |
public async signPayload (payload: SignerPayloadJSON): Promise<SignerResult> {
if (payload.address !== this.#keyringPair.address) {
throw new Error("does not have the keyringPair");
}
return new Promise((resolve): void => {
setTimeout((): void => {
const signed = this.#registry.createType("ExtrinsicPayload", payload, { version: payload.version }).sign(this.#keyringPair);
resolve({
id: ++id,
...signed
});
}, this.#signDelay);
});
}
Example #5
Source File: SingleAccountSigner.ts From interbtc-api with Apache License 2.0 | 6 votes |
public async signRaw ({ address, data }: SignerPayloadRaw): Promise<SignerResult> {
if (address !== this.#keyringPair.address) {
throw new Error("does not have the keyringPair");
}
return new Promise((resolve): void => {
setTimeout((): void => {
const signature = u8aToHex(this.#keyringPair.sign(hexToU8a(data)));
resolve({
id: ++id,
signature
});
}, this.#signDelay);
});
}
Example #6
Source File: AccountSigner.ts From subscan-multisig-react with Apache License 2.0 | 6 votes |
public async signPayload(payload: SignerPayloadJSON): Promise<SignerResult> {
return new Promise((resolve): void => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const signed = this.#registry
.createType('ExtrinsicPayload', payload, { version: payload.version })
.sign(this.#keyringPair);
lockAccount(this.#keyringPair);
resolve({ id: ++id, ...signed });
});
}
Example #7
Source File: ApiSigner.ts From subscan-multisig-react with Apache License 2.0 | 6 votes |
public async signPayload(payload: SignerPayloadJSON): Promise<SignerResult> {
return new Promise((resolve, reject): void => {
this.#queuePayload(this.#registry, payload, (id: number, result: SignerResult | null): void => {
if (result) {
resolve(result);
} else {
reject(new Error('Unable to sign'));
}
});
});
}
Example #8
Source File: QrSigner.ts From subscan-multisig-react with Apache License 2.0 | 6 votes |
public async signPayload(payload: SignerPayloadJSON): Promise<SignerResult> {
return new Promise((resolve, reject): void => {
// limit size of the transaction
// eslint-disable-next-line no-magic-numbers
const isQrHashed = payload.method.length > 5000;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const wrapper = this.#registry.createType('ExtrinsicPayload', payload, { version: payload.version });
const qrPayload = isQrHashed ? blake2AsU8a(wrapper.toU8a(true)) : wrapper.toU8a();
this.#setState({
isQrHashed,
qrAddress: payload.address,
qrPayload,
qrReject: reject,
qrResolve: resolve,
});
});
}
Example #9
Source File: AccountSigner.ts From crust-apps with Apache License 2.0 | 5 votes |
public async signPayload (payload: SignerPayloadJSON): Promise<SignerResult> {
return new Promise((resolve): void => {
const signed = this.#registry.createType('ExtrinsicPayload', payload, { version: payload.version }).sign(this.#keyringPair);
lockAccount(this.#keyringPair);
resolve({ id: ++id, ...signed });
});
}
Example #10
Source File: LedgerSigner.ts From crust-apps with Apache License 2.0 | 5 votes |
public async signPayload (payload: SignerPayloadJSON): Promise<SignerResult> {
const raw = this.#registry.createType('ExtrinsicPayload', payload, { version: payload.version });
const { signature } = await this.#getLedger().sign(raw.toU8a(true), this.#accountOffset, this.#addressOffset);
return { id: ++id, signature };
}
Example #11
Source File: LedgerSigner.ts From subscan-multisig-react with Apache License 2.0 | 5 votes |
public async signPayload(payload: SignerPayloadJSON): Promise<SignerResult> {
const raw = this.registry.createType('ExtrinsicPayload', payload, { version: payload.version });
const { signature } = await this.getLedger().sign(raw.toU8a(true), this.accountOffset, this.addressOffset);
return { id: ++id, signature };
}