Skip to content

Commit 1684ee1

Browse files
authored
Merge pull request #24 from polkawallet-io/develop
release 0.4.7
2 parents 4335c5c + cddb527 commit 1684ee1

File tree

9 files changed

+409
-333
lines changed

9 files changed

+409
-333
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [0.4.7] - 20220606
2+
3+
* bump polkadot-js/api v8.5.1
4+
* update tx error message parsing
5+
16
## [0.4.6] - 20220526
27

38
* add dapp auth

example/pubspec.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ packages:
192192
name: mobx
193193
url: "https://pub.dartlang.org"
194194
source: hosted
195-
version: "2.0.5"
195+
version: "2.0.7"
196196
path:
197197
dependency: transitive
198198
description:
@@ -262,7 +262,7 @@ packages:
262262
path: ".."
263263
relative: true
264264
source: path
265-
version: "0.4.2"
265+
version: "0.4.6"
266266
process:
267267
dependency: transitive
268268
description:
@@ -365,7 +365,7 @@ packages:
365365
name: webview_flutter
366366
url: "https://pub.dartlang.org"
367367
source: hosted
368-
version: "3.0.0"
368+
version: "3.0.4"
369369
webview_flutter_android:
370370
dependency: transitive
371371
description:

js_api/dist/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js_api/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@polkawallet/js-api",
3-
"version": "0.4.2",
3+
"version": "0.4.6",
44
"main": "index.js",
55
"license": "Apache-2.0",
66
"keywords": [
@@ -24,13 +24,13 @@
2424
"build-dev": "webpack --mode development"
2525
},
2626
"resolutions": {
27-
"@polkadot/api": "^8.1.1",
27+
"@polkadot/api": "^8.5.1",
2828
"bn.js": "4.12.0"
2929
},
3030
"dependencies": {
31-
"@polkadot/api": "^8.1.1",
32-
"@polkadot/extension-dapp": "^0.43.1",
33-
"@polkadot/ui-shared": "^2.0.1",
31+
"@polkadot/api": "^8.5.1",
32+
"@polkadot/extension-dapp": "^0.43.2",
33+
"@polkadot/ui-shared": "^2.2.1",
3434
"@walletconnect/client": "2.0.0-alpha.26",
3535
"bn.js": "^5.1.2",
3636
"oo7-substrate": "^0.8.0",

js_api/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ async function connect(nodes: string[]) {
4343
});
4444
if (!(<any>window).api) {
4545
(<any>window).api = res;
46-
const url = nodes[(<any>res)._options.provider.__private_29_endpointIndex];
46+
const url = nodes[(<any>res)._options.provider.__private_23_endpointIndex];
4747
send("log", `${url} wss connected success`);
4848
resolve(url);
4949
} else {
5050
res.disconnect();
51-
const url = nodes[(<any>res)._options.provider.__private_29_endpointIndex];
51+
const url = nodes[(<any>res)._options.provider.__private_23_endpointIndex];
5252
send("log", `${url} wss success and disconnected`);
5353
resolve(url);
5454
}

js_api/src/service/keyring.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,29 +187,18 @@ function _extractEvents(api: ApiPromise, result: SubmittableResult) {
187187
}
188188

189189
let success = false;
190-
let error: DispatchError["type"] = "";
190+
let error: string;
191191
result.events
192192
.filter((event) => !!event.event)
193193
.map(({ event: { data, method, section } }) => {
194194
if (section === "system" && method === "ExtrinsicFailed") {
195195
const [dispatchError] = (data as unknown) as ITuple<[DispatchError]>;
196-
let message = dispatchError.type;
196+
error = _getDispatchError(dispatchError);
197197

198-
if (dispatchError.isModule) {
199-
try {
200-
const mod = dispatchError.asModule;
201-
const err = api.registry.findMetaError(new Uint8Array([mod.index.toNumber(), mod.error.toNumber()]));
202-
203-
message = `${err.section}.${err.name}`;
204-
} catch (error) {
205-
// swallow error
206-
}
207-
}
208198
(<any>window).send("txUpdateEvent", {
209199
title: `${section}.${method}`,
210-
message,
200+
message: error,
211201
});
212-
error = message;
213202
} else {
214203
(<any>window).send("txUpdateEvent", {
215204
title: `${section}.${method}`,
@@ -223,6 +212,25 @@ function _extractEvents(api: ApiPromise, result: SubmittableResult) {
223212
return { success, error };
224213
}
225214

215+
export function _getDispatchError(dispatchError: DispatchError): string {
216+
let message: string = dispatchError.type;
217+
218+
if (dispatchError.isModule) {
219+
try {
220+
const mod = dispatchError.asModule;
221+
const error = dispatchError.registry.findMetaError(mod);
222+
223+
message = `${error.section}.${error.name}`;
224+
} catch (error) {
225+
// swallow
226+
}
227+
} else if (dispatchError.isToken) {
228+
message = `${dispatchError.type}.${dispatchError.asToken.type}`;
229+
}
230+
231+
return message;
232+
}
233+
226234
/**
227235
* sign and send extrinsic to network and wait for result.
228236
*/

0 commit comments

Comments
 (0)