Move Extrinsic/Method to generic (#1205)
* Move Extrinsic/Method to generic * Strip Generic* primitives * Move Origin & Method, pass lint/tests
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { FunctionMetadata } from '@polkadot/types/Metadata/v6/Calls';
|
||||
import { MethodFunction } from '@polkadot/types/primitive/Method';
|
||||
import { Method } from '@polkadot/types';
|
||||
import { Method } from '@polkadot/types/interfaces';
|
||||
|
||||
import { FunctionMetadata } from '@polkadot/types/Metadata/v7/Calls';
|
||||
import { MethodFunction } from '@polkadot/types/primitive/Generic/Method';
|
||||
import { ClassOf } from '@polkadot/types';
|
||||
import { assert, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
@@ -31,7 +33,7 @@ export default function createDescriptor (
|
||||
`Extrinsic ${section}.${funcName} expects ${expectedArgs.length.valueOf()} arguments, got ${args.length}.`
|
||||
);
|
||||
|
||||
return new Method({
|
||||
return new (ClassOf('Method'))({
|
||||
args,
|
||||
callIndex
|
||||
}, callMetadata);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import { Extrinsic, Metadata } from '@polkadot/types';
|
||||
import { createType, Metadata } from '@polkadot/types';
|
||||
import json from '@polkadot/types/Metadata/v7/static';
|
||||
|
||||
import fromMetadata from '.';
|
||||
@@ -24,7 +24,7 @@ describe('fromMetadata', (): void => {
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
expect(
|
||||
new Extrinsic(newExtrinsics.timestamp.set([10101])).toU8a()
|
||||
createType('Extrinsic', newExtrinsics.timestamp.set([10101])).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
// length (encoded)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ModuleMetadata } from '@polkadot/types/Metadata/v7/Metadata';
|
||||
import { Methods, ModulesWithMethods } from '@polkadot/types/primitive/Method';
|
||||
import { Methods, ModulesWithMethods } from '@polkadot/types/primitive/Generic/Method';
|
||||
import Metadata from '@polkadot/types/Metadata';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import '@polkadot/types/injector';
|
||||
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import { Extrinsic } from '@polkadot/types';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
import extrinsics from './static';
|
||||
|
||||
@@ -14,7 +14,7 @@ const keyring = testingPairs({ type: 'ed25519' }, false);
|
||||
describe('extrinsics', (): void => {
|
||||
it('encodes an actual transfer (actual data)', (): void => {
|
||||
expect(
|
||||
new Extrinsic(
|
||||
createType('Extrinsic',
|
||||
extrinsics.balances.transfer(keyring.bob.publicKey, 6969)
|
||||
).sign(keyring.alice, {
|
||||
blockHash: '0xec7afaf1cca720ce88c1d1b689d81f0583cc15a97d621cf046dd9abf605ef22f',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ModulesWithMethods } from '@polkadot/types/primitive/Method';
|
||||
import { ModulesWithMethods } from '@polkadot/types/primitive/Generic/Method';
|
||||
|
||||
const extrinsics: ModulesWithMethods = {};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import metadataRpc from '@polkadot/types/Metadata/static';
|
||||
import { ModulesWithMethods } from '@polkadot/types/primitive/Method';
|
||||
import { ModulesWithMethods } from '@polkadot/types/primitive/Generic/Method';
|
||||
|
||||
import fromMetadata from './fromMetadata';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user