Skip to content

Commit

Permalink
1.0 (#1781)
Browse files Browse the repository at this point in the history
* 1.0

* signAsync typing

* Merge master
  • Loading branch information
jacogr authored Jan 30, 2020
1 parent 59e069f commit ca7edf1
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 81 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# 1.0.0-beta-x
# 1.0.1

- **Breaking change** Drop support for Substrate v1 chain in all derives
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators (`@polkadot/types` bin)
- Return unsub functions from provider .on emitters (Thanks to https://github.com/jak-pan)
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators to `@polkadot/types`
- Only decorate derives where relevant parent `api.query.*` is available
- Support `.entries(arg?: any)` lookups on DoubleMaps (in addition to previously supported maps)
- Remove un-deployed support for v11 metadata (this was decided against on Substrate)
Expand All @@ -12,6 +13,7 @@
- Don't map empy tuples, e.. `()` to `Null`, rather keep them empty
- Add lookups to the metadata erros via `findMetaError`
- Update metadata and types for the lastest Substrate & Polkadot versions
- Support metadata V11 as per lastest Substrate
- Remove old known types for Substrate V1

# 0.100.1
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "1.0.0-beta.44"
"version": "1.0.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@babel/core": "^7.8.3",
"@babel/register": "^7.8.3",
"@babel/runtime": "^7.8.3",
"@polkadot/dev": "^0.33.1",
"@polkadot/dev": "^0.33.3",
"@polkadot/ts": "^0.2.1"
}
}
4 changes: 2 additions & 2 deletions packages/api-contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"keywords": [
Expand All @@ -27,6 +27,6 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/types": "^1.0.0-beta.44"
"@polkadot/types": "^1.0.0"
}
}
8 changes: 4 additions & 4 deletions packages/api-derive/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -28,10 +28,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/api": "^1.0.0-beta.44",
"@polkadot/types": "^1.0.0-beta.44"
"@polkadot/api": "^1.0.0",
"@polkadot/types": "^1.0.0"
},
"devDependencies": {
"@polkadot/keyring": "^2.0.0-beta.10"
"@polkadot/keyring": "^2.0.1"
}
}
18 changes: 9 additions & 9 deletions packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -30,15 +30,15 @@
},
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/api-derive": "^1.0.0-beta.44",
"@polkadot/keyring": "^2.0.0-beta.10",
"@polkadot/metadata": "^1.0.0-beta.44",
"@polkadot/rpc-core": "^1.0.0-beta.44",
"@polkadot/rpc-provider": "^1.0.0-beta.44",
"@polkadot/types": "^1.0.0-beta.44",
"@polkadot/util-crypto": "^2.0.0-beta.10"
"@polkadot/api-derive": "^1.0.0",
"@polkadot/keyring": "^2.0.1",
"@polkadot/metadata": "^1.0.0",
"@polkadot/rpc-core": "^1.0.0",
"@polkadot/rpc-provider": "^1.0.0",
"@polkadot/types": "^1.0.0",
"@polkadot/util-crypto": "^2.0.1"
},
"devDependencies": {
"@polkadot/keyring": "^2.0.0-beta.10"
"@polkadot/keyring": "^2.0.1"
}
}
20 changes: 10 additions & 10 deletions packages/api/src/submittable/createClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

import { AccountId, Address, Call, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
import { Address, Call, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo } from '@polkadot/types/interfaces';
import { Callback, Codec, Constructor, IKeyringPair, Registry, SignatureOptions } from '@polkadot/types/types';
import { ApiInterfaceRx, ApiTypes, SignerResult } from '../types';
import { SignerOptions, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultImpl, SubmittableResultResult, SubmittableResultSubscription, SubmittableThis } from './types';
import { AddressOrPair, SignerOptions, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultImpl, SubmittableResultResult, SubmittableResultSubscription, SubmittableThis } from './types';

import { Observable, combineLatest, of } from 'rxjs';
import { first, map, mapTo, mergeMap, switchMap, tap } from 'rxjs/operators';
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
}

// calculate the payment info for this transaction (if signed and submitted)
public paymentInfo (account: IKeyringPair | string | AccountId | Address, options?: Partial<SignerOptions>): SubmittablePaymentResult<ApiType> {
public paymentInfo (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittablePaymentResult<ApiType> {
const [allOptions] = this._makeSignAndSendOptions(options);
const address = isKeyringPair(account) ? account.address : account.toString();

Expand Down Expand Up @@ -82,24 +82,24 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
// signs a transaction, returning `this` to allow chaining. E.g.: `sign(...).send()`
//
// also supports signing through external signers
public signAsync (account: IKeyringPair | string | AccountId | Address, optionsOrNonce: Partial<SignerOptions>): SubmittableThis<ApiType, this> {
public signAsync (account: AddressOrPair, optionsOrNonce: Partial<SignerOptions>): SubmittableThis<ApiType, this> {
return this._decorateMethod(
(): Observable<this> =>
this._signObservable(account, optionsOrNonce).pipe(mapTo(this))
)();
}

// signAndSend with an immediate Hash result
public signAndSend (account: IKeyringPair | string | AccountId | Address, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType>;
public signAndSend (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType>;

// signAndSend with a subscription, i.e. callback provided
public signAndSend (account: IKeyringPair | string | AccountId | Address, statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
public signAndSend (account: AddressOrPair, statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;

// signAndSend with options and a callback
public signAndSend (account: IKeyringPair | string | AccountId | Address, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
public signAndSend (account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;

// signAndSend implementation for all 3 cases above
public signAndSend (account: IKeyringPair | string | AccountId | Address, optionsOrStatus?: Partial<SignerOptions> | Callback<SubmittableResultImpl>, optionalStatusCb?: Callback<SubmittableResultImpl>): SubmittableResultResult<ApiType> | SubmittableResultSubscription<ApiType> {
public signAndSend (account: AddressOrPair, optionsOrStatus?: Partial<SignerOptions> | Callback<SubmittableResultImpl>, optionalStatusCb?: Callback<SubmittableResultImpl>): SubmittableResultResult<ApiType> | SubmittableResultSubscription<ApiType> {
const [options, statusCb] = this._makeSignAndSendOptions(optionsOrStatus, optionalStatusCb);
const isSubscription = this._api.hasSubscriptions && (this._ignoreStatusCb || !!statusCb);

Expand Down Expand Up @@ -144,7 +144,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
return [options, statusCb];
}

private _signObservable (account: IKeyringPair | string | AccountId | Address, optionsOrNonce: Partial<SignerOptions>): Observable<number | undefined> {
private _signObservable (account: AddressOrPair, optionsOrNonce: Partial<SignerOptions>): Observable<number | undefined> {
const address = isKeyringPair(account) ? account.address : account.toString();
const options = this._optionsOrNonce(optionsOrNonce);
let updateId: number | undefined;
Expand All @@ -164,7 +164,7 @@ export default function createClass <ApiType extends ApiTypes> ({ api, apiType,
);
}

private async _signViaSigner (address: | string | AccountId | Address, options: SignatureOptions, header: Header | null): Promise<number> {
private async _signViaSigner (address: Address | string | Uint8Array, options: SignatureOptions, header: Header | null): Promise<number> {
const signer = options.signer || this._api.signer;

assert(signer, 'No signer specified, either via api.setSigner or via sign options');
Expand Down
12 changes: 7 additions & 5 deletions packages/api/src/submittable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,22 @@ export interface SignerOptions {
tip?: AnyNumber;
}

export type AddressOrPair = IKeyringPair | string | AccountId | Address;

export interface SubmittableExtrinsic<ApiType extends ApiTypes> extends IExtrinsic {
paymentInfo (account: IKeyringPair | string | AccountId | Address, options?: Partial<SignerOptions>): SubmittablePaymentResult<ApiType>;
paymentInfo (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittablePaymentResult<ApiType>;

send(): SubmittableResultResult<ApiType>;

send(statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;

sign(account: IKeyringPair, _options: Partial<SignatureOptions>): this;

signAsync(account: IKeyringPair, _options: Partial<SignatureOptions>): SubmittableThis<ApiType, this>;
signAsync(account: AddressOrPair, _options: Partial<SignatureOptions>): SubmittableThis<ApiType, this>;

signAndSend(account: IKeyringPair | string | AccountId | Address, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType>;
signAndSend(account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType>;

signAndSend(account: IKeyringPair | string | AccountId | Address, statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
signAndSend(account: AddressOrPair, statusCb: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;

signAndSend(account: IKeyringPair | string | AccountId | Address, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
signAndSend(account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<SubmittableResultImpl>): SubmittableResultSubscription<ApiType>;
}
10 changes: 5 additions & 5 deletions packages/metadata/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
"publishConfig": {
Expand All @@ -27,11 +27,11 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/types": "^1.0.0-beta.44",
"@polkadot/util": "^2.0.0-beta.10",
"@polkadot/util-crypto": "^2.0.0-beta.10"
"@polkadot/types": "^1.0.0",
"@polkadot/util": "^2.0.1",
"@polkadot/util-crypto": "^2.0.1"
},
"devDependencies": {
"@polkadot/keyring": "^2.0.0-beta.10"
"@polkadot/keyring": "^2.0.1"
}
}
10 changes: 5 additions & 5 deletions packages/rpc-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
Expand All @@ -27,10 +27,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/jsonrpc": "^1.0.0-beta.44",
"@polkadot/rpc-provider": "^1.0.0-beta.44",
"@polkadot/types": "^1.0.0-beta.44",
"@polkadot/util": "^2.0.0-beta.10",
"@polkadot/jsonrpc": "^1.0.0",
"@polkadot/rpc-provider": "^1.0.0",
"@polkadot/types": "^1.0.0",
"@polkadot/util": "^2.0.1",
"rxjs": "^6.5.4"
}
}
10 changes: 5 additions & 5 deletions packages/rpc-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
Expand All @@ -27,15 +27,15 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/metadata": "^1.0.0-beta.44",
"@polkadot/util": "^2.0.0-beta.10",
"@polkadot/util-crypto": "^2.0.0-beta.10",
"@polkadot/metadata": "^1.0.0",
"@polkadot/util": "^2.0.1",
"@polkadot/util-crypto": "^2.0.1",
"eventemitter3": "^4.0.0",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.31"
},
"devDependencies": {
"@polkadot/keyring": "^2.0.0-beta.10",
"@polkadot/keyring": "^2.0.1",
"mock-socket": "^9.0.3",
"nock": "^11.7.2"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/type-jsonrpc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/jsonrpc",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "Method definitions for the Polkadot RPC layer",
"main": "index.js",
"publishConfig": {
Expand Down
10 changes: 5 additions & 5 deletions packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "1.0.0-beta.44",
"version": "1.0.0",
"description": "Implementation of the Parity codec",
"main": "index.js",
"bin": {
Expand Down Expand Up @@ -34,14 +34,14 @@
},
"dependencies": {
"@babel/runtime": "^7.8.3",
"@polkadot/metadata": "^1.0.0-beta.44",
"@polkadot/util": "^2.0.0-beta.10",
"@polkadot/util-crypto": "^2.0.0-beta.10",
"@polkadot/metadata": "^1.0.0",
"@polkadot/util": "^2.0.1",
"@polkadot/util-crypto": "^2.0.1",
"memoizee": "^0.4.14",
"yargs": "^15.1.0"
},
"devDependencies": {
"@polkadot/keyring": "^2.0.0-beta.10",
"@polkadot/keyring": "^2.0.1",
"@types/memoizee": "^0.4.3",
"@types/yargs": "^15.0.2"
}
Expand Down
Loading

0 comments on commit ca7edf1

Please sign in to comment.