Expose callIndex on extrinsics (lookups) (#206)
* Expose callId on extrinsics (lookups) * Expose call meta * s/callId/callIndex/
This commit is contained in:
+1
@@ -7,6 +7,7 @@ import { FunctionMetadata } from '@polkadot/types/Metadata';
|
||||
|
||||
export interface ExtrinsicFunction {
|
||||
(...args: any[]): UncheckedMortalExtrinsic,
|
||||
callIndex: Uint8Array,
|
||||
meta: FunctionMetadata,
|
||||
method: string;
|
||||
section: string;
|
||||
|
||||
@@ -19,6 +19,7 @@ export default function createDescriptor (
|
||||
index: number,
|
||||
meta: FunctionMetadata
|
||||
): ExtrinsicFunction {
|
||||
const callIndex = new Uint8Array([index, meta.id.toNumber()]);
|
||||
let extrinsicFn: any;
|
||||
|
||||
// If the extrinsic function has an argument of type `Origin`, we ignore it
|
||||
@@ -32,15 +33,12 @@ export default function createDescriptor (
|
||||
throw new Error(`Extrinsic ${section}.${method} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`);
|
||||
}
|
||||
|
||||
const call = new Call(
|
||||
new Uint8Array([index, meta.id.toNumber()]),
|
||||
meta,
|
||||
args
|
||||
);
|
||||
const call = new Call(callIndex, meta, args);
|
||||
|
||||
return new UncheckedMortalExtrinsic(call);
|
||||
};
|
||||
|
||||
extrinsicFn.callIndex = callIndex;
|
||||
extrinsicFn.meta = meta;
|
||||
extrinsicFn.method = method;
|
||||
extrinsicFn.section = section;
|
||||
|
||||
@@ -11,11 +11,15 @@ export default class CallIndex extends U8aFixed {
|
||||
super(value, 16);
|
||||
}
|
||||
|
||||
get callIndex (): Uint8Array {
|
||||
return this.raw;
|
||||
}
|
||||
|
||||
get methodIndex (): number {
|
||||
return this.raw[1];
|
||||
return this.callIndex[1];
|
||||
}
|
||||
|
||||
get sectionIndex (): number {
|
||||
return this.raw[0];
|
||||
return this.callIndex[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import u8aConcat from '@polkadot/util/u8a/concat';
|
||||
import Address from './Address';
|
||||
import Call from './Call';
|
||||
import Extrinsic from './Extrinsic';
|
||||
import { FunctionMetadata } from './Metadata';
|
||||
import SignaturePayload from './SignaturePayload';
|
||||
import TransactionSignature from './TransactionSignature';
|
||||
|
||||
@@ -55,6 +56,22 @@ export default class UncheckedMortalExtrinsic extends Extrinsic {
|
||||
return this._signature;
|
||||
}
|
||||
|
||||
get meta (): FunctionMetadata {
|
||||
return this._call.meta;
|
||||
}
|
||||
|
||||
get callIndex (): Uint8Array {
|
||||
return this._call.callIndex;
|
||||
}
|
||||
|
||||
get methodIndex (): number {
|
||||
return this._call.methodIndex;
|
||||
}
|
||||
|
||||
get sectionIndex (): number {
|
||||
return this._call.sectionIndex;
|
||||
}
|
||||
|
||||
sign (signerPair: KeyringPair, nonce: AnyNumber, blockHash: AnyU8a): UncheckedMortalExtrinsic {
|
||||
const signature = this.createSignature(this._call, signerPair, nonce, blockHash);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user