Skip to content

Commit

Permalink
Merge 947717c into f77d750
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Oct 5, 2018
2 parents f77d750 + 947717c commit 0d20e23
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test": "jest --coverage"
},
"devDependencies": {
"@polkadot/dev": "^0.20.21",
"@polkadot/dev": "^0.20.24",
"@polkadot/ts": "^0.1.30"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/type-extrinsics/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FunctionMetadata } from '@polkadot/types/Metadata';

export interface ExtrinsicFunction {
(...args: any[]): UncheckedMortalExtrinsic,
callId: Uint8Array,
meta: FunctionMetadata,
method: string;
section: string;
Expand Down
8 changes: 3 additions & 5 deletions packages/type-extrinsics/src/utils/createUnchecked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function createDescriptor (
index: number,
meta: FunctionMetadata
): ExtrinsicFunction {
const callId = new Uint8Array([index, meta.id.toNumber()]);
let extrinsicFn: any;

// If the extrinsic function has an argument of type `Origin`, we ignore it
Expand All @@ -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(callId, meta, args);

return new UncheckedMortalExtrinsic(call);
};

extrinsicFn.callId = callId;
extrinsicFn.meta = meta;
extrinsicFn.method = method;
extrinsicFn.section = section;
Expand Down
13 changes: 13 additions & 0 deletions packages/types/src/UncheckedMortalExtrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -55,6 +56,18 @@ export default class UncheckedMortalExtrinsic extends Extrinsic {
return this._signature;
}

get meta (): FunctionMetadata {
return this._call.meta;
}

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);

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1170,9 +1170,9 @@
version "1.1.0"
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.0.tgz#50c1e2260ac0ed9439a181de3725a0168d59c48a"

"@polkadot/dev@^0.20.21":
version "0.20.21"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.20.21.tgz#81d707d5aeb4b32e22fea1e1653ab238c77eefeb"
"@polkadot/dev@^0.20.24":
version "0.20.24"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.20.24.tgz#e88af950aa4e0e1a549d0a4860b2b3f8d63ce723"
dependencies:
"@babel/cli" "^7.0.0"
"@babel/core" "^7.0.0"
Expand Down

0 comments on commit 0d20e23

Please sign in to comment.