User pair addressRaw for signing (#2504)
* User pair addressRaw for signing * Bump common * Bump common after merge
This commit is contained in:
@@ -28,15 +28,15 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.30.0-beta.5",
|
||||
"@polkadot/util": "^3.3.0-beta.1",
|
||||
"@polkadot/util-crypto": "^3.3.0-beta.1",
|
||||
"@polkadot/util": "^3.3.0-beta.2",
|
||||
"@polkadot/util-crypto": "^3.3.0-beta.2",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.3.0-beta.1",
|
||||
"@polkadot/keyring": "^3.3.0-beta.2",
|
||||
"@types/memoizee": "^0.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,10 @@
|
||||
import { SignOptions } from '@polkadot/keyring/types';
|
||||
import { IKeyringPair, Registry } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
// a helper function for both types of payloads, Raw and metadata-known
|
||||
export function sign (registry: Registry, signerPair: IKeyringPair, u8a: Uint8Array, options?: SignOptions): Uint8Array {
|
||||
const encoded = u8a.length > 256
|
||||
? blake2AsU8a(u8a)
|
||||
? registry.hash(u8a)
|
||||
: u8a;
|
||||
|
||||
return signerPair.sign(encoded, options);
|
||||
|
||||
@@ -140,10 +140,7 @@ export default class ExtrinsicSignatureV1 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? this.registry.hash(account.publicKey)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -136,10 +136,7 @@ export default class ExtrinsicSignatureV2 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? this.registry.hash(account.publicKey)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -46,10 +46,7 @@ export default class ExtrinsicSignatureV3 extends ExtrinsicSignatureV2 {
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? this.registry.hash(account.publicKey)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -141,10 +141,7 @@ export default class ExtrinsicSignatureV4 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? this.registry.hash(account.publicKey)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('MultiSignature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface ICompact<T> extends Codec {
|
||||
|
||||
export interface IKeyringPair {
|
||||
address: string;
|
||||
addressRaw: Uint8Array;
|
||||
publicKey: Uint8Array;
|
||||
sign: (data: Uint8Array, options?: SignOptions) => Uint8Array;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user