Bump deps (#3219)
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
"@babel/runtime": "^7.13.7",
|
||||
"@polkadot/api": "3.10.3-8",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/x-rxjs": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"@polkadot/x-rxjs": "^5.8.1",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
"@polkadot/api": "3.10.3-8",
|
||||
"@polkadot/rpc-core": "3.10.3-8",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/util-crypto": "^5.7.2-6",
|
||||
"@polkadot/x-rxjs": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"@polkadot/util-crypto": "^5.8.1",
|
||||
"@polkadot/x-rxjs": "^5.8.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.7.2-6",
|
||||
"@polkadot/keyring": "^5.8.1",
|
||||
"@polkadot/rpc-provider": "3.10.3-8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.7",
|
||||
"@polkadot/api-derive": "3.10.3-8",
|
||||
"@polkadot/keyring": "^5.7.2-6",
|
||||
"@polkadot/keyring": "^5.8.1",
|
||||
"@polkadot/metadata": "3.10.3-8",
|
||||
"@polkadot/rpc-core": "3.10.3-8",
|
||||
"@polkadot/rpc-provider": "3.10.3-8",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/types-known": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/util-crypto": "^5.7.2-6",
|
||||
"@polkadot/x-rxjs": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"@polkadot/util-crypto": "^5.8.1",
|
||||
"@polkadot/x-rxjs": "^5.8.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
"@babel/runtime": "^7.13.7",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/types-known": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/util-crypto": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"@polkadot/util-crypto": "^5.8.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.7.2-6"
|
||||
"@polkadot/keyring": "^5.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
"@polkadot/metadata": "3.10.3-8",
|
||||
"@polkadot/rpc-provider": "3.10.3-8",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/x-rxjs": "^5.7.2-6"
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"@polkadot/x-rxjs": "^5.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.7.2-6"
|
||||
"@polkadot/keyring": "^5.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.7",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/util-crypto": "^5.7.2-6",
|
||||
"@polkadot/x-fetch": "^5.7.2-6",
|
||||
"@polkadot/x-global": "^5.7.2-6",
|
||||
"@polkadot/x-ws": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"@polkadot/util-crypto": "^5.8.1",
|
||||
"@polkadot/x-fetch": "^5.8.1",
|
||||
"@polkadot/x-global": "^5.8.1",
|
||||
"@polkadot/x-ws": "^5.8.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.7.2-6",
|
||||
"@polkadot/keyring": "^5.8.1",
|
||||
"@polkadot/metadata": "3.10.3-8",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.7"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"@polkadot/metadata": "3.10.3-8",
|
||||
"@polkadot/rpc-provider": "3.10.3-8",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.33",
|
||||
"yargs": "^16.2.0"
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.7",
|
||||
"@polkadot/networks": "^5.7.2-6",
|
||||
"@polkadot/networks": "^5.8.1",
|
||||
"@polkadot/types": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.13.7",
|
||||
"@polkadot/metadata": "3.10.3-8",
|
||||
"@polkadot/util": "^5.7.2-6",
|
||||
"@polkadot/util-crypto": "^5.7.2-6",
|
||||
"@polkadot/x-rxjs": "^5.7.2-6",
|
||||
"@polkadot/util": "^5.8.1",
|
||||
"@polkadot/util-crypto": "^5.8.1",
|
||||
"@polkadot/x-rxjs": "^5.8.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.7.2-6"
|
||||
"@polkadot/keyring": "^5.8.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ abstract class ExtrinsicBase<A extends AnyTuple> extends Base<ExtrinsicVx | Extr
|
||||
* - left as is, to create an inherent
|
||||
*/
|
||||
export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBase<A> implements IExtrinsic<A> {
|
||||
constructor (registry: Registry, value: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call | undefined, { version }: CreateOptions = {}) {
|
||||
constructor (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, { version }: CreateOptions = {}) {
|
||||
super(registry, GenericExtrinsic._decodeExtrinsic(registry, value, version));
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBa
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
private static _decodeExtrinsic (registry: Registry, value: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call | undefined, version: number = DEFAULT_VERSION): ExtrinsicVx | ExtrinsicUnknown {
|
||||
private static _decodeExtrinsic (registry: Registry, value?: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call, version: number = DEFAULT_VERSION): ExtrinsicVx | ExtrinsicUnknown {
|
||||
if (isU8a(value) || Array.isArray(value) || isHex(value)) {
|
||||
return GenericExtrinsic._decodeU8a(registry, u8aToU8a(value), version);
|
||||
} else if (value instanceof registry.createClass('Call')) {
|
||||
|
||||
@@ -36,12 +36,12 @@ const VERSIONS: (keyof InterfaceTypes)[] = [
|
||||
* on the contents included
|
||||
*/
|
||||
export class GenericExtrinsicPayload extends Base<ExtrinsicPayloadVx> {
|
||||
constructor (registry: Registry, value: Partial<ExtrinsicPayloadValue> | Uint8Array | string | undefined, { version }: ExtrinsicPayloadOptions = {}) {
|
||||
constructor (registry: Registry, value?: Partial<ExtrinsicPayloadValue> | Uint8Array | string, { version }: ExtrinsicPayloadOptions = {}) {
|
||||
super(registry, GenericExtrinsicPayload.decodeExtrinsicPayload(registry, value as ExtrinsicPayloadValue, version));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsicPayload (registry: Registry, value: GenericExtrinsicPayload | ExtrinsicPayloadValue | Uint8Array | string | undefined, version: number = DEFAULT_VERSION): ExtrinsicPayloadVx {
|
||||
public static decodeExtrinsicPayload (registry: Registry, value?: GenericExtrinsicPayload | ExtrinsicPayloadValue | Uint8Array | string, version: number = DEFAULT_VERSION): ExtrinsicPayloadVx {
|
||||
if (value instanceof GenericExtrinsicPayload) {
|
||||
return value._raw;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ registry.setMetadata(metadata);
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
describe('ExtrinsicV4', (): void => {
|
||||
it.only('constructs a sane Uint8Array (default)', (): void => {
|
||||
it('constructs a sane Uint8Array (default)', (): void => {
|
||||
expect(
|
||||
new Extrinsic(registry).toU8a()
|
||||
).toEqual(new Uint8Array([
|
||||
@@ -37,7 +37,7 @@ describe('ExtrinsicV4', (): void => {
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'0600' + // balance.transfer
|
||||
'ff' +
|
||||
'00' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
@@ -65,14 +65,14 @@ describe('ExtrinsicV4', (): void => {
|
||||
}).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'ff' +
|
||||
'00' +
|
||||
'd172a74cda4c865912c32ba0a80a57ae69abae410e5ccb59dee84e2f4432db4f' +
|
||||
'00' + // ed25519
|
||||
'b8065808da3d11ddb4167afb156eafb51e8104ba792589bb443653a7fab82b90' +
|
||||
'c6530e838df06bfc8befcbbcfca7e219350cff865439b815b10b8e64ae1e9b01' +
|
||||
'ab31e8dbdbf37398f9a42cfe473e17f6e2e05d8d7a1612513fa73f5f6ad3bfdb' +
|
||||
'adbabd920d033ad48999d9dc6a07e3e7ffb9a503128c94bf4fd97aeb4523f90e' +
|
||||
'000408' + // era. nonce, tip
|
||||
'0600' +
|
||||
'ff' +
|
||||
'00' +
|
||||
'd7568e5f0a7eda67a82691ff379ac4bba4f9c9b859fe779b5d46363b61ad2db9' +
|
||||
'e56c'
|
||||
);
|
||||
|
||||
@@ -58,9 +58,9 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry, undefined).signFake(
|
||||
new ExtrinsicSignature(registry).signFake(
|
||||
registry.createType('Call'),
|
||||
pairs.alice.address,
|
||||
pairs.alice.publicKey,
|
||||
signOptions
|
||||
).toHex()
|
||||
).toEqual(
|
||||
@@ -74,7 +74,7 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
);
|
||||
});
|
||||
|
||||
it('fake signs default', (): void => {
|
||||
it('fake signs default (AccountId address)', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
});
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry, undefined).signFake(
|
||||
new ExtrinsicSignature(registry).signFake(
|
||||
registry.createType('Call'),
|
||||
pairs.alice.address,
|
||||
signOptions
|
||||
@@ -102,4 +102,27 @@ describe('ExtrinsicSignatureV4', (): void => {
|
||||
'00a50100'
|
||||
);
|
||||
});
|
||||
|
||||
it('injects a signature', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
expect(
|
||||
new ExtrinsicSignature(registry).addSignature(
|
||||
pairs.alice.publicKey,
|
||||
new Uint8Array(65).fill(1),
|
||||
new Uint8Array(0)
|
||||
).toHex()
|
||||
).toEqual(
|
||||
'0x' +
|
||||
'00' + // MultiAddress
|
||||
'd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' +
|
||||
'01' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'0101010101010101010101010101010101010101010101010101010101010101' +
|
||||
'000000'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Address, Balance, Call, Index } from '../../interfaces/runtime';
|
||||
import type { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import type { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
import { isU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Compact } from '../../codec/Compact';
|
||||
import { Enum } from '../../codec/Enum';
|
||||
@@ -17,6 +17,10 @@ import { GenericExtrinsicPayloadV4 } from './ExtrinsicPayload';
|
||||
const FAKE_NONE = new Uint8Array();
|
||||
const FAKE_SOME = new Uint8Array([1]);
|
||||
|
||||
function toAddress (registry: Registry, address: Address | Uint8Array | string): Address {
|
||||
return registry.createType('Address', isU8a(address) ? u8aToHex(address) : address);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name GenericExtrinsicSignatureV4
|
||||
* @description
|
||||
@@ -25,7 +29,7 @@ const FAKE_SOME = new Uint8Array([1]);
|
||||
export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSignature {
|
||||
#fakePrefix: Uint8Array;
|
||||
|
||||
constructor (registry: Registry, value: GenericExtrinsicSignatureV4 | Uint8Array | undefined, { isSigned }: ExtrinsicSignatureOptions = {}) {
|
||||
constructor (registry: Registry, value?: GenericExtrinsicSignatureV4 | Uint8Array, { isSigned }: ExtrinsicSignatureOptions = {}) {
|
||||
super(registry, {
|
||||
signer: 'Address',
|
||||
// eslint-disable-next-line sort-keys
|
||||
@@ -39,7 +43,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public static decodeExtrinsicSignature (value: GenericExtrinsicSignatureV4 | Uint8Array | undefined, isSigned = false): GenericExtrinsicSignatureV4 | Uint8Array {
|
||||
public static decodeExtrinsicSignature (value?: GenericExtrinsicSignatureV4 | Uint8Array, isSigned = false): GenericExtrinsicSignatureV4 | Uint8Array {
|
||||
if (!value) {
|
||||
return EMPTY_U8A;
|
||||
} else if (value instanceof GenericExtrinsicSignatureV4) {
|
||||
@@ -125,7 +129,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): IExtrinsicSignature {
|
||||
return this._injectSignature(
|
||||
this.registry.createType('Address', signer),
|
||||
toAddress(this.registry, signer),
|
||||
this.registry.createType('ExtrinsicSignature', signature),
|
||||
new GenericExtrinsicPayloadV4(this.registry, payload)
|
||||
);
|
||||
@@ -151,7 +155,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const signer = toAddress(this.registry, account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('ExtrinsicSignature', payload.sign(account));
|
||||
|
||||
@@ -162,7 +166,7 @@ export class GenericExtrinsicSignatureV4 extends Struct implements IExtrinsicSig
|
||||
* @description Generate a payload and applies a fake signature
|
||||
*/
|
||||
public signFake (method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature {
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = toAddress(this.registry, address);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('ExtrinsicSignature', u8aConcat(this.#fakePrefix, new Uint8Array(64).fill(0x42)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user