Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

Commit

Permalink
Fix/12 and references (#15)
Browse files Browse the repository at this point in the history
* Try fix #12

* Update to latest plug tag

* Update to polkadot api 1.8.1 compatability

Co-authored-by: Jordan Beauchamp <[email protected]>
  • Loading branch information
hoani and jordy25519 authored Jun 22, 2020
1 parent 0227a5e commit af77c11
Show file tree
Hide file tree
Showing 17 changed files with 203 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
docker:
- image: circleci/node:10.13.0
# Run Plug node
- image: plugnet/plugblockchain:1.0.0-rc2
- image: plugnet/plugblockchain:1.0.0-rc3.1
entrypoint: /usr/local/bin/plug
command:
- --dev
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ async function main() {

}
```

## Build
To build the package for distribution run:
```
tsc
```

2 changes: 1 addition & 1 deletion dist/Extrinsic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ It has had its payload and signature type changed to use Plug versions.
**/
import { Address, Call } from '@polkadot/types/interfaces/runtime';
import { ExtrinsicPayloadValue, IExtrinsicImpl, IKeyringPair, Registry, SignatureOptions } from '@polkadot/types/types';
import { ExtrinsicOptions } from '@polkadot/types/primitive/Extrinsic/types';
import { ExtrinsicOptions } from '@polkadot/types/extrinsic/types';
import Struct from '@polkadot/types/codec/Struct';
import PlugExtrinsicSignatureV1 from './ExtrinsicSignature';
export declare const TRANSACTION_VERSION = 4;
Expand Down
3 changes: 2 additions & 1 deletion dist/Extrinsic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRANSACTION_VERSION = void 0;
const util_1 = require("@polkadot/util");
const create_1 = require("@polkadot/types/codec/create");
const create_1 = require("@polkadot/types/create");
const Struct_1 = require("@polkadot/types/codec/Struct");
const ExtrinsicSignature_1 = require("./ExtrinsicSignature");
exports.TRANSACTION_VERSION = 4;
Expand Down
3 changes: 2 additions & 1 deletion dist/ExtrinsicPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.PayloadV1 = exports.SignedExtraV1 = exports.BasePayloadV1 = void 0;
const Struct_1 = require("@polkadot/types/codec/Struct");
const util_1 = require("@polkadot/types/primitive/Extrinsic/util");
const util_1 = require("@polkadot/types/extrinsic/util");
// The base fields in a Plug V1 extrinsic payload
exports.BasePayloadV1 = {
method: 'Bytes',
Expand Down
6 changes: 3 additions & 3 deletions dist/ExtrinsicSignature.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Compact from '@polkadot/types/codec/Compact';
import Option from '@polkadot/types/codec/Option';
import Struct from '@polkadot/types/codec/Struct';
import { Address, Balance, Call, EcdsaSignature, Ed25519Signature, ExtrinsicEra, Index, MultiSignature, Sr25519Signature } from '@polkadot/types/interfaces';
import { ExtrinsicSignatureOptions } from '@polkadot/types/primitive/Extrinsic/types';
import { AnyNumber, AnyU8a, IExtrinsicEra, IExtrinsicSignature, IKeyringPair, Registry, RuntimeVersionInterface } from '@polkadot/types/types';
import { ExtrinsicSignatureOptions } from '@polkadot/types/extrinsic/types';
import { AnyNumber, AnyU8a, IExtrinsicEra, IExtrinsicSignature, IKeyringPair, Registry, IRuntimeVersion } from '@polkadot/types/types';
import Doughnut from './Doughnut';
import PlugExtrinsicPayloadV1, { PlugExtrinsicPayloadValue } from './ExtrinsicPayload';
export interface SignatureOptions {
Expand All @@ -12,7 +12,7 @@ export interface SignatureOptions {
doughnut?: Option<Doughnut>;
genesisHash: AnyU8a;
nonce: AnyNumber;
runtimeVersion: RuntimeVersionInterface;
runtimeVersion: IRuntimeVersion;
tip?: AnyNumber;
}
/**
Expand Down
4 changes: 2 additions & 2 deletions dist/ExtrinsicSignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
const create_1 = require("@polkadot/types/codec/create");
const create_1 = require("@polkadot/types/create");
const Struct_1 = require("@polkadot/types/codec/Struct");
const constants_1 = require("@polkadot/types/primitive/Extrinsic/constants");
const constants_1 = require("@polkadot/types/extrinsic/constants");
const ExtrinsicPayload_1 = require("./ExtrinsicPayload");
const util_1 = require("@polkadot/util");
/**
Expand Down
8 changes: 4 additions & 4 deletions dist/InterfaceTypes.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Option from '@polkadot/types/codec/Option';
import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry';
import { InterfaceTypes } from '@polkadot/types/types/registry';
import Doughnut from './Doughnut';
declare module '@polkadot/types/interfaceRegistry' {
interface InterfaceRegistry {
declare module '@polkadot/types/types/registry' {
interface InterfaceTypes {
Doughnut: Doughnut;
'Option<Doughnut>': Option<Doughnut>;
}
}
export declare type PlugInterfaceTypes = keyof InterfaceRegistry;
export declare type PlugInterfaceTypes = keyof InterfaceTypes;
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ declare const PlugRuntimeTypes: {
Doughnut: typeof Doughnut;
ExtrinsicV4: typeof PlugExtrinsicV1;
RewardBalance: string;
Address: string;
};
export default PlugRuntimeTypes;
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ const PlugRuntimeTypes = {
ExtrinsicV4: Extrinsic_1.default,
// The staking reward currency type
RewardBalance: 'Balance',
// The chain address type is the AccountId type
Address: 'AccountId',
};
exports.default = PlugRuntimeTypes;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"dependencies": {
"@polkadot/types": "^1.1.1",
"@polkadot/types": "1.8.1",
"@polkadot/util": "^2.3.1",
"f": "^1.4.0"
},
"devDependencies": {
"@polkadot/api": "^1.1.1",
"@polkadot/api": "1.8.1",
"@polkadot/util-crypto": "^2.3.1",
"@types/bn.js": "^4.11.6",
"@types/jest": "^25.1.2",
Expand Down
4 changes: 2 additions & 2 deletions types/Extrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ It has had its payload and signature type changed to use Plug versions.
**/
import { Address, Call } from '@polkadot/types/interfaces/runtime';
import { ExtrinsicPayloadValue, IExtrinsicImpl, IKeyringPair, Registry, SignatureOptions } from '@polkadot/types/types';
import { ExtrinsicOptions } from '@polkadot/types/primitive/Extrinsic/types';
import { ExtrinsicOptions } from '@polkadot/types/extrinsic/types';

import { isU8a } from '@polkadot/util';

import { ClassOf, createType } from '@polkadot/types/codec/create';
import { ClassOf, createType } from '@polkadot/types/create';
import Struct from '@polkadot/types/codec/Struct';
import PlugExtrinsicSignatureV1 from './ExtrinsicSignature';

Expand Down
2 changes: 1 addition & 1 deletion types/ExtrinsicPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Option from '@polkadot/types/codec/Option';
import Struct from '@polkadot/types/codec/Struct';
import { Balance, ExtrinsicEra, Hash, Index } from '@polkadot/types/interfaces';
import Bytes from '@polkadot/types/primitive/Bytes';
import { sign } from '@polkadot/types/primitive/Extrinsic/util';
import { sign } from '@polkadot/types/extrinsic/util';
import u32 from '@polkadot/types/primitive/U32';
import { AnyNumber, AnyU8a, IExtrinsicEra, IKeyringPair, IMethod, Registry } from '@polkadot/types/types';

Expand Down
10 changes: 5 additions & 5 deletions types/ExtrinsicSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.

import Compact from '@polkadot/types/codec/Compact';
import { createType } from '@polkadot/types/codec/create';
import { createType } from '@polkadot/types/create';
import Option from '@polkadot/types/codec/Option';
import Struct from '@polkadot/types/codec/Struct';
import {
Expand All @@ -17,8 +17,8 @@ import {
MultiSignature,
Sr25519Signature,
} from '@polkadot/types/interfaces';
import { EMPTY_U8A, IMMORTAL_ERA } from '@polkadot/types/primitive/Extrinsic/constants';
import { ExtrinsicSignatureOptions } from '@polkadot/types/primitive/Extrinsic/types';
import { EMPTY_U8A, IMMORTAL_ERA } from '@polkadot/types/extrinsic/constants';
import { ExtrinsicSignatureOptions } from '@polkadot/types/extrinsic/types';

import {
AnyNumber,
Expand All @@ -27,7 +27,7 @@ import {
IExtrinsicSignature,
IKeyringPair,
Registry,
RuntimeVersionInterface,
IRuntimeVersion,
} from '@polkadot/types/types';

import Doughnut from './Doughnut';
Expand All @@ -40,7 +40,7 @@ export interface SignatureOptions {
doughnut?: Option<Doughnut>;
genesisHash: AnyU8a;
nonce: AnyNumber;
runtimeVersion: RuntimeVersionInterface;
runtimeVersion: IRuntimeVersion;
tip?: AnyNumber;
}

Expand Down
8 changes: 4 additions & 4 deletions types/InterfaceTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
// limitations under the License.

import Option from '@polkadot/types/codec/Option';
import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry';
import { InterfaceTypes } from '@polkadot/types/types/registry';
import Doughnut from './Doughnut';

// Merge the [[InterfaceRegistry]] definition from `@polkadot/types/interfaceRegistry` with plug types
declare module '@polkadot/types/interfaceRegistry' {
interface InterfaceRegistry {
declare module '@polkadot/types/types/registry' {
interface InterfaceTypes {
// Add types that only Plug knows about.
// TS will merge them into the polkadot provided [[InterfaceRegistry]]
Doughnut: Doughnut;
'Option<Doughnut>': Option<Doughnut>;
}
}

export type PlugInterfaceTypes = keyof InterfaceRegistry;
export type PlugInterfaceTypes = keyof InterfaceTypes;
2 changes: 2 additions & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const PlugRuntimeTypes = {
ExtrinsicV4: PlugExtrinsicV1,
// The staking reward currency type
RewardBalance: 'Balance',
// The chain address type is the AccountId type
Address: 'AccountId',
};

export default PlugRuntimeTypes;
Loading

0 comments on commit af77c11

Please sign in to comment.