Return { status: ExtrinsicStatus } from tx send subscription (#486)

* Return { status: ExtrinsicStatus } from tx send subscription

* Added changelog

* Fix typo

* Bump version

* Bump deps
This commit is contained in:
Jaco Greeff
2018-12-18 11:13:32 +01:00
committed by GitHub
parent 419de9407b
commit 5fa087e7c0
14 changed files with 83 additions and 55 deletions
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-observable",
"version": "0.33.26",
"version": "0.34.0",
"description": "An Observable wrapper around the Polkadot JS API",
"main": "index.js",
"keywords": [
@@ -30,10 +30,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-rx#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/extrinsics": "^0.33.26",
"@polkadot/rpc-core": "^0.33.26",
"@polkadot/rpc-provider": "^0.33.26",
"@polkadot/storage": "^0.33.26",
"@polkadot/extrinsics": "^0.34.0",
"@polkadot/rpc-core": "^0.34.0",
"@polkadot/rpc-provider": "^0.34.0",
"@polkadot/storage": "^0.34.0",
"@types/rx": "^4.1.1",
"rxjs": "^6.3.3"
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "0.33.26",
"version": "0.34.0",
"description": "An RxJS wrapper around the Polkadot JS RPC",
"main": "index.js",
"keywords": [
@@ -30,10 +30,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/extrinsics": "^0.33.26",
"@polkadot/rpc-provider": "^0.33.26",
"@polkadot/rpc-rx": "^0.33.26",
"@polkadot/storage": "^0.33.26",
"@polkadot/extrinsics": "^0.34.0",
"@polkadot/rpc-provider": "^0.34.0",
"@polkadot/rpc-rx": "^0.34.0",
"@polkadot/storage": "^0.34.0",
"@types/rx": "^4.1.1",
"core-js": "^2.5.7",
"rxjs": "^6.3.3"
@@ -8,6 +8,12 @@ import { ApiPromiseInterface } from './types';
import { Extrinsic, ExtrinsicStatus, Hash } from '@polkadot/types/index';
type SendResult = {
status: ExtrinsicStatus,
// toString for backwards compat, i.e. result.toString() === 'finalised'
toString (): string
};
export default class SubmittableExtrinsic extends Extrinsic {
private _api: ApiPromiseInterface;
@@ -17,12 +23,17 @@ export default class SubmittableExtrinsic extends Extrinsic {
this._api = api;
}
send (statusCb?: (status: ExtrinsicStatus) => any): Promise<Hash> {
send (statusCb?: (result: SendResult) => any): Promise<Hash> {
if (!statusCb || !this._api.hasSubscriptions) {
return this._api.rpc.author.submitExtrinsic(this);
}
return this._api.rpc.author.submitAndWatchExtrinsic(this, statusCb);
return this._api.rpc.author.submitAndWatchExtrinsic(this, (status: ExtrinsicStatus) =>
statusCb({
status,
toString: status.toString
})
);
}
sign (signerPair: KeyringPair, nonce: AnyNumber, blockHash?: AnyU8a): SubmittableExtrinsic {
+16 -2
View File
@@ -7,8 +7,15 @@ import { AnyNumber, AnyU8a } from '@polkadot/types/types';
import { ApiRxInterface } from './types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Extrinsic, ExtrinsicStatus } from '@polkadot/types/index';
type SendResult = {
status: ExtrinsicStatus,
// toString for backwards compat, i.e. result.toString() === 'finalised'
toString (): string
};
export default class SubmittableExtrinsic extends Extrinsic {
private _api: ApiRxInterface;
@@ -18,8 +25,15 @@ export default class SubmittableExtrinsic extends Extrinsic {
this._api = api;
}
send (): Observable<ExtrinsicStatus> {
return this._api.rpc.author.submitAndWatchExtrinsic(this);
send (): Observable<SendResult> {
return this._api.rpc.author
.submitAndWatchExtrinsic(this)
.pipe(
map((status: ExtrinsicStatus) => ({
status,
toString: status.toString
}))
);
}
sign (signerPair: KeyringPair, nonce: AnyNumber, blockHash?: AnyU8a): SubmittableExtrinsic {
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "0.33.26",
"version": "0.34.0",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -30,9 +30,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/jsonrpc": "^0.33.26",
"@polkadot/rpc-provider": "^0.33.26",
"@polkadot/types": "^0.33.26",
"@polkadot/util": "^0.33.17"
"@polkadot/jsonrpc": "^0.34.0",
"@polkadot/rpc-provider": "^0.34.0",
"@polkadot/types": "^0.34.0",
"@polkadot/util": "^0.33.18"
}
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "0.33.26",
"version": "0.34.0",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
@@ -30,10 +30,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.33.17",
"@polkadot/storage": "^0.33.26",
"@polkadot/util": "^0.33.17",
"@polkadot/util-crypto": "^0.33.17",
"@polkadot/keyring": "^0.33.18",
"@polkadot/storage": "^0.34.0",
"@polkadot/util": "^0.33.18",
"@polkadot/util-crypto": "^0.33.18",
"@types/nock": "^9.3.0",
"eventemitter3": "^3.1.0",
"isomorphic-fetch": "^2.2.1",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-rx",
"version": "0.33.26",
"version": "0.34.0",
"description": "An RxJs wrapper around the Polkadot JS API",
"main": "index.js",
"keywords": [
@@ -30,8 +30,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-rx#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/rpc-core": "^0.33.26",
"@polkadot/rpc-provider": "^0.33.26",
"@polkadot/rpc-core": "^0.34.0",
"@polkadot/rpc-provider": "^0.34.0",
"@types/rx": "^4.1.1",
"rxjs": "^6.3.3"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/extrinsics",
"version": "0.33.26",
"version": "0.34.0",
"main": "index.js",
"repository": "https://github.com/polkadot-js/api.git",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -11,7 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/types": "^0.33.26",
"@polkadot/util": "^0.33.17"
"@polkadot/types": "^0.34.0",
"@polkadot/util": "^0.33.18"
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/jsonrpc",
"version": "0.33.26",
"version": "0.34.0",
"description": "Method definitions for the Polkadot RPC layer",
"main": "index.js",
"engines": {
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/storage",
"version": "0.33.26",
"version": "0.34.0",
"description": "Generic wrapper wrapper around state storage",
"main": "index.js",
"engines": {
@@ -30,9 +30,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.33.17",
"@polkadot/types": "^0.33.26",
"@polkadot/util": "^0.33.17",
"@polkadot/util-crypto": "^0.33.17"
"@polkadot/keyring": "^0.33.18",
"@polkadot/types": "^0.34.0",
"@polkadot/util": "^0.33.18",
"@polkadot/util-crypto": "^0.33.18"
}
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "0.33.26",
"version": "0.34.0",
"description": "Implementation of the Parity codec",
"main": "index.js",
"keywords": [
@@ -30,7 +30,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.33.17",
"@polkadot/util": "^0.33.17"
"@polkadot/keyring": "^0.33.18",
"@polkadot/util": "^0.33.18"
}
}