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
+3
View File
@@ -0,0 +1,3 @@
# 0.34.1
- Changed the send signature (for future expansion of eg. events) to return `result: { status: ExtrinsicStatus }` instead of `status: ExtrinsicStatus`. For most cases where only status `toString` checks are used, i.e. `status.toString() === 'Finalised'` this should not be a breaking change. Deep inspection of the status object however will need to adapt.
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "0.33.26"
"version": "0.34.0"
}
+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"
}
}
+15 -15
View File
@@ -1369,14 +1369,14 @@
typedoc-plugin-no-inherit "^1.0.2"
typescript "^3.2.2"
"@polkadot/keyring@^0.33.17":
version "0.33.17"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.33.17.tgz#8562d782ca0cba837335d5c0788395da13375541"
integrity sha512-FFyiPLwXmHrB4wHHWYKrZpP+QphL09j/HPjwksrI8WgrGkoYR5worNjL8qyDOdqdoKkaR1wWFSRP08bA3zbKPA==
"@polkadot/keyring@^0.33.18":
version "0.33.18"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.33.18.tgz#8fd0a4b6fc23d568ec5799ab333993aa4acf38ce"
integrity sha512-p4LtenOPSH3CuwgKuu6pql4b+WiRSDXaYg0Y9+PznQtAlRwGFqGm7KSyVs0ak7EBNBq6DvRLp3E1AEcDpc3dWg==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/util" "^0.33.17"
"@polkadot/util-crypto" "^0.33.17"
"@polkadot/util" "^0.33.18"
"@polkadot/util-crypto" "^0.33.18"
"@types/bs58" "^3.0.30"
bs58 "^4.0.1"
@@ -1385,13 +1385,13 @@
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.43.tgz#e59d86cf6bed833010315c5b301bfea6c05fd4a8"
integrity sha512-B7mSH+yrc7PBHMWUfpTFAK0OLgOesWlzkhse0/O8Itu2Rf6YrixEnhUYKEDp7mDO3h2SlBwn6BfVkvY4qvtwgg==
"@polkadot/util-crypto@^0.33.17":
version "0.33.17"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.33.17.tgz#c3b118bb763e45bafc71897cb2f8aacfdce6b7c7"
integrity sha512-jSGmtJjMuXYPrTcaxdnspKwGqFvRZ/9X5TzdPdKl/YW1uTKE/0Uox8WRHEtTZ6R1fmNI6Yb9hptMnV4KcdWiOw==
"@polkadot/util-crypto@^0.33.18":
version "0.33.18"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.33.18.tgz#7fb937794c4130b67a847784578a5def1fce61c2"
integrity sha512-gr/xi3Jl3rX0CXyzfFCIJ02r+s+tKxrP/CiZ80boHeSEvSH9LoFvkrVaHjBaejD3ouAVXLbr2uFq9SdLACY0gg==
dependencies:
"@babel/runtime" "^7.2.0"
"@polkadot/util" "^0.33.17"
"@polkadot/util" "^0.33.18"
"@types/bip39" "^2.4.1"
bip39 "^2.5.0"
blakejs "^1.1.0"
@@ -1399,10 +1399,10 @@
tweetnacl "^1.0.0"
xxhashjs "^0.2.2"
"@polkadot/util@^0.33.17":
version "0.33.17"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.33.17.tgz#c7fd79016fdd7b5f71cc7eed990a0c8edca25802"
integrity sha512-eQHt6YrVa578/fXEkrsw5bePGEZPHK4uQ6MYrsBZ7ajgE5iBJOXiMhgh3uopLzG+OtxEWfzk3Oj28/YzRpLdVA==
"@polkadot/util@^0.33.18":
version "0.33.18"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.33.18.tgz#2d0fa95d72de462f389516b5b0c61824099bbff7"
integrity sha512-bvC7/ucrY8Ws2ckRhU0cvI0TNylmcFEEaw97p96w/sHQcMuQH+yBu1VLyUnxIvyV1nX0lrmSqR+s4a9I6R1mMA==
dependencies:
"@babel/runtime" "^7.2.0"
"@types/bn.js" "^4.11.3"