Adjust raw toAscii output (#4097)
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/api": "6.4.3-8",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"@polkadot/util": "^7.5.1",
|
||||
"@polkadot/util": "^7.6.1",
|
||||
"rxjs": "^7.4.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
"@polkadot/api": "6.4.3-8",
|
||||
"@polkadot/rpc-core": "6.4.3-8",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"@polkadot/util": "^7.5.1",
|
||||
"@polkadot/util-crypto": "^7.5.1",
|
||||
"@polkadot/util": "^7.6.1",
|
||||
"@polkadot/util-crypto": "^7.6.1",
|
||||
"rxjs": "^7.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.5.1",
|
||||
"@polkadot/keyring": "^7.6.1",
|
||||
"@polkadot/rpc-provider": "6.4.3-8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/api-derive": "6.4.3-8",
|
||||
"@polkadot/keyring": "^7.5.1",
|
||||
"@polkadot/keyring": "^7.6.1",
|
||||
"@polkadot/rpc-core": "6.4.3-8",
|
||||
"@polkadot/rpc-provider": "6.4.3-8",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"@polkadot/types-known": "6.4.3-8",
|
||||
"@polkadot/util": "^7.5.1",
|
||||
"@polkadot/util-crypto": "^7.5.1",
|
||||
"@polkadot/util": "^7.6.1",
|
||||
"@polkadot/util-crypto": "^7.6.1",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^7.4.0"
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/rpc-provider": "6.4.3-8",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"@polkadot/util": "^7.5.1",
|
||||
"@polkadot/util": "^7.6.1",
|
||||
"rxjs": "^7.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.5.1"
|
||||
"@polkadot/keyring": "^7.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"@polkadot/util": "^7.5.1",
|
||||
"@polkadot/util-crypto": "^7.5.1",
|
||||
"@polkadot/x-fetch": "^7.5.1",
|
||||
"@polkadot/x-global": "^7.5.1",
|
||||
"@polkadot/x-ws": "^7.5.1",
|
||||
"@polkadot/util": "^7.6.1",
|
||||
"@polkadot/util-crypto": "^7.6.1",
|
||||
"@polkadot/x-fetch": "^7.6.1",
|
||||
"@polkadot/x-global": "^7.6.1",
|
||||
"@polkadot/x-ws": "^7.6.1",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.5.1",
|
||||
"@polkadot/keyring": "^7.6.1",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"mock-socket": "^9.0.6",
|
||||
"nock": "^13.1.4"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"@polkadot/rpc-provider": "6.4.3-8",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"@polkadot/types-support": "6.4.3-8",
|
||||
"@polkadot/util": "^7.5.1",
|
||||
"@polkadot/util": "^7.6.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.2.1"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/networks": "^7.5.1",
|
||||
"@polkadot/networks": "^7.6.1",
|
||||
"@polkadot/types": "6.4.3-8",
|
||||
"@polkadot/util": "^7.5.1"
|
||||
"@polkadot/util": "^7.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-support#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/util": "^7.5.1"
|
||||
"@polkadot/util": "^7.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/util": "^7.5.1",
|
||||
"@polkadot/util-crypto": "^7.5.1",
|
||||
"@polkadot/util": "^7.6.1",
|
||||
"@polkadot/util-crypto": "^7.6.1",
|
||||
"rxjs": "^7.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.5.1",
|
||||
"@polkadot/keyring": "^7.6.1",
|
||||
"@polkadot/types-support": "6.4.3-8",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.12.0"
|
||||
|
||||
@@ -51,7 +51,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
* @description Returns true if the type wraps an empty/default all-0 value
|
||||
*/
|
||||
public get isEmpty (): boolean {
|
||||
return !this.length || isUndefined(this.find((value) => !!value));
|
||||
return !this.length || isUndefined(this.find((b) => !!b));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
public eq (other?: unknown): boolean {
|
||||
if (other instanceof Uint8Array) {
|
||||
return (this.length === other.length) &&
|
||||
!this.some((value, index) => value !== other[index]);
|
||||
!this.some((b, index) => b !== other[index]);
|
||||
}
|
||||
|
||||
return this.eq(u8aToU8a(other as string));
|
||||
@@ -119,9 +119,16 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (): AnyJson {
|
||||
return this.isAscii
|
||||
? this.toUtf8()
|
||||
: this.toJSON();
|
||||
if (this.isAscii) {
|
||||
const text = this.toUtf8();
|
||||
|
||||
// ensure we didn't end up with multibyte codepoints
|
||||
if (isAscii(text)) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
return this.toJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user