MArk deprecated function signatures (#1487)
This commit is contained in:
@@ -7,6 +7,7 @@ Changes:
|
||||
- Optimize `u8aToHex` with direct (non-hex) conversion
|
||||
- Change all occurences of `.substr(...)` to `.substring(...)`
|
||||
- Sync with upstream Substrate ss58 registry
|
||||
- Mark deprecated function signatures (no removals)
|
||||
|
||||
|
||||
## 9.1.1 Apr 30, 2022
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"@noble/secp256k1": "1.5.5",
|
||||
"@polkadot/networks": "9.1.2-9",
|
||||
"@polkadot/util": "9.1.2-9",
|
||||
"@polkadot/wasm-crypto": "^6.0.2-14",
|
||||
"@polkadot/wasm-crypto": "^6.0.2-15",
|
||||
"@polkadot/x-bigint": "9.1.2-9",
|
||||
"@polkadot/x-randomvalues": "9.1.2-9",
|
||||
"@scure/base": "1.0.0",
|
||||
|
||||
@@ -42,7 +42,9 @@ function createValue (valueBn: BN, byteLength: number, { isLe, isNegative }: Num
|
||||
* ```
|
||||
*/
|
||||
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, options?: NumberOptions): Uint8Array;
|
||||
/** @deprecated Use bnToU8a(value?: ExtToBn | BN | bigint | number | null, options?: NumberOptions) */
|
||||
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, bitLength?: number, isLe?: boolean): Uint8Array;
|
||||
/** @deprecated Use bnToU8a(value?: ExtToBn | BN | bigint | number | null, options?: NumberOptions) */
|
||||
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | bigint | number | null, arg1: number | NumberOptions = DEFAULT_OPTS, arg2?: boolean): Uint8Array {
|
||||
const options: NumberOptions = objectSpread(
|
||||
{ bitLength: -1, isLe: true, isNegative: false },
|
||||
|
||||
@@ -44,6 +44,10 @@ interface Options {
|
||||
}
|
||||
|
||||
interface BalanceFormatter {
|
||||
<ExtToBn extends ToBn> (input?: number | string | BN | bigint | ExtToBn, options?: Options): string;
|
||||
/** @deprecated Use balanceFormat(input?: number | string | BN | bigint | ExtToBn, options?: Options) */
|
||||
<ExtToBn extends ToBn> (input?: number | string | BN | bigint | ExtToBn, options?: boolean, decimals?: number): string;
|
||||
/** @deprecated Use balanceFormat(input?: number | string | BN | bigint | ExtToBn, options?: Options) */
|
||||
<ExtToBn extends ToBn> (input?: number | string | BN | bigint | ExtToBn, options?: Options, decimals?: number): string;
|
||||
calcSi (text: string, decimals?: number): SiDef;
|
||||
findSi (type: string): SiDef;
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('hexToBn', (): void => {
|
||||
).toBe(256);
|
||||
});
|
||||
|
||||
it('handles backwards compatibility', (): void => {
|
||||
it('handles legacy compatibility', (): void => {
|
||||
expect(
|
||||
hexToBn('0x0001000000000000', false).eq(
|
||||
hexToBn('0x0001000000000000', { isLe: false })
|
||||
|
||||
@@ -26,7 +26,11 @@ import { hexStripPrefix } from './stripPrefix';
|
||||
* hexToBn('0x123480001f'); // => BN(0x123480001f)
|
||||
* ```
|
||||
*/
|
||||
export function hexToBn (value?: string | null, options: ToBnOptions | boolean = {}): BN {
|
||||
function hexToBn (value?: string | null, options?: ToBnOptions): BN;
|
||||
/** @deprecated Use hexToBn (value?: string | null, options?: ToBnOptions) */
|
||||
function hexToBn (value?: string | null, options?: boolean): BN;
|
||||
/** @deprecated Use hexToBn (value?: string | null, options?: ToBnOptions) */
|
||||
function hexToBn (value?: string | null, options: ToBnOptions | boolean = {}): BN {
|
||||
if (!value || value === '0x') {
|
||||
return new BN(0);
|
||||
}
|
||||
@@ -47,3 +51,5 @@ export function hexToBn (value?: string | null, options: ToBnOptions | boolean =
|
||||
? bn.fromTwos(stripped.length * 4)
|
||||
: bn;
|
||||
}
|
||||
|
||||
export { hexToBn };
|
||||
|
||||
@@ -5,6 +5,21 @@ import { performance } from '../test/performance';
|
||||
import { u8aToBn } from '.';
|
||||
|
||||
describe('u8aToBn', (): void => {
|
||||
it('supports legacy compatibility', (): void => {
|
||||
expect(
|
||||
u8aToBn(
|
||||
new Uint8Array([0x12, 0x34]),
|
||||
true
|
||||
).toString(16)
|
||||
).toBe('3412');
|
||||
expect(
|
||||
u8aToBn(
|
||||
new Uint8Array([0x12, 0x34]),
|
||||
false
|
||||
).toString(16)
|
||||
).toBe('1234');
|
||||
});
|
||||
|
||||
it('converts little-endian by default', (): void => {
|
||||
expect(
|
||||
u8aToBn(
|
||||
@@ -12,6 +27,7 @@ describe('u8aToBn', (): void => {
|
||||
).toString(16)
|
||||
).toBe('3412');
|
||||
});
|
||||
|
||||
it('converts values (big-endian)', (): void => {
|
||||
expect(
|
||||
u8aToBn(
|
||||
|
||||
@@ -25,7 +25,11 @@ import { objectSpread } from '../object/spread';
|
||||
* u8aToHex(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0xf])); // 0x68656c0f
|
||||
* ```
|
||||
*/
|
||||
export function u8aToBn (value: Uint8Array, options: ToBnOptions | boolean = {}): BN {
|
||||
function u8aToBn (value: Uint8Array, options?: ToBnOptions): BN;
|
||||
/** @deprecated Use u8aToBn(value: Uint8Array, options?: ToBnOptions) */
|
||||
function u8aToBn (value: Uint8Array, options?: boolean): BN;
|
||||
/** @deprecated Use hexToBn (value?: string | null, options?: ToBnOptions) */
|
||||
function u8aToBn (value: Uint8Array, options: ToBnOptions | boolean = {}): BN {
|
||||
// NOTE: This is the same process as followed in the hexToBn conversion
|
||||
// For Uint8Array, default to LE
|
||||
const { isLe, isNegative } = objectSpread<ToBnOptions>(
|
||||
@@ -40,3 +44,5 @@ export function u8aToBn (value: Uint8Array, options: ToBnOptions | boolean = {})
|
||||
? bn.fromTwos(value.length * 8)
|
||||
: bn;
|
||||
}
|
||||
|
||||
export { u8aToBn };
|
||||
|
||||
@@ -2182,7 +2182,7 @@ __metadata:
|
||||
"@noble/secp256k1": 1.5.5
|
||||
"@polkadot/networks": 9.1.2-9
|
||||
"@polkadot/util": 9.1.2-9
|
||||
"@polkadot/wasm-crypto": ^6.0.2-14
|
||||
"@polkadot/wasm-crypto": ^6.0.2-15
|
||||
"@polkadot/x-bigint": 9.1.2-9
|
||||
"@polkadot/x-randomvalues": 9.1.2-9
|
||||
"@scure/base": 1.0.0
|
||||
@@ -2210,79 +2210,79 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/wasm-bridge@npm:6.0.2-14":
|
||||
version: 6.0.2-14
|
||||
resolution: "@polkadot/wasm-bridge@npm:6.0.2-14"
|
||||
"@polkadot/wasm-bridge@npm:6.0.2-15":
|
||||
version: 6.0.2-15
|
||||
resolution: "@polkadot/wasm-bridge@npm:6.0.2-15"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.17.9
|
||||
peerDependencies:
|
||||
"@polkadot/util": "*"
|
||||
"@polkadot/x-randomvalues": "*"
|
||||
checksum: 035c9179f712b60661ff83691f641284e6801efafceb3ece62c7aaa3043870be3c18b3459819d10b98e9690e4140af924108db521ec2019f9aa0f28c81c1d0b8
|
||||
checksum: 02e1109ffb290276ea0ea3ed2ad1a74296d92efe512c29fba59b619d2232adc0aa809a587c4a5fc516f877ce9df70e143f7ce161fb2c5aff9bbb38cad4a10bf6
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/wasm-crypto-asmjs@npm:6.0.2-14":
|
||||
version: 6.0.2-14
|
||||
resolution: "@polkadot/wasm-crypto-asmjs@npm:6.0.2-14"
|
||||
"@polkadot/wasm-crypto-asmjs@npm:6.0.2-15":
|
||||
version: 6.0.2-15
|
||||
resolution: "@polkadot/wasm-crypto-asmjs@npm:6.0.2-15"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.17.9
|
||||
peerDependencies:
|
||||
"@polkadot/util": "*"
|
||||
checksum: 7d4161cdd8f28d3b25a50c26428d9b59d03b85c1170620913ec66932543cf3fbaa44b2f0971dece824a164a9566e634689a52ef551a6de398007f6c716ff6cec
|
||||
checksum: 17f2ba1e6c3c658ca2ca9753033b9c038a0b624dd02b98267625570d88ad07708b01fdcc0456ae31d1869f1d65389b6df1a74f737f4e7c54a11cce76249de30f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/wasm-crypto-init@npm:6.0.2-14":
|
||||
version: 6.0.2-14
|
||||
resolution: "@polkadot/wasm-crypto-init@npm:6.0.2-14"
|
||||
"@polkadot/wasm-crypto-init@npm:6.0.2-15":
|
||||
version: 6.0.2-15
|
||||
resolution: "@polkadot/wasm-crypto-init@npm:6.0.2-15"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.17.9
|
||||
"@polkadot/wasm-bridge": 6.0.2-14
|
||||
"@polkadot/wasm-crypto-asmjs": 6.0.2-14
|
||||
"@polkadot/wasm-crypto-wasm": 6.0.2-14
|
||||
"@polkadot/wasm-bridge": 6.0.2-15
|
||||
"@polkadot/wasm-crypto-asmjs": 6.0.2-15
|
||||
"@polkadot/wasm-crypto-wasm": 6.0.2-15
|
||||
peerDependencies:
|
||||
"@polkadot/util": "*"
|
||||
checksum: 5dde2551872692ecf74067f076be54b2e69fcf2945dfa6af2c1fe528a6ddd06d6a26e1a22d119a44639690f4df4373fa1a2346c3de21e37a3b8d842145c80280
|
||||
checksum: d29af508ef736ac3a54a7818bde62018b4ec98c6ef291a8554f8aae1b1796f2bb71e9355bf784ef18faf2d017a104a1643b23be1c45ba4b5e3642d6c6e1632cd
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/wasm-crypto-wasm@npm:6.0.2-14":
|
||||
version: 6.0.2-14
|
||||
resolution: "@polkadot/wasm-crypto-wasm@npm:6.0.2-14"
|
||||
"@polkadot/wasm-crypto-wasm@npm:6.0.2-15":
|
||||
version: 6.0.2-15
|
||||
resolution: "@polkadot/wasm-crypto-wasm@npm:6.0.2-15"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.17.9
|
||||
"@polkadot/wasm-util": 6.0.2-14
|
||||
"@polkadot/wasm-util": 6.0.2-15
|
||||
peerDependencies:
|
||||
"@polkadot/util": "*"
|
||||
checksum: bc90cb8cfcfbf28a6f0a57b77bbaab81925b352e7f8f348111a11e3c780aebaf18dfd3848c0cff69dc0ca6b171dcf52fb81f43a2b280db306ac8f43f020eb673
|
||||
checksum: cc1a388b4b1c7707196485c48f2038edba4cd1bf85b827c483780f0392c25f73c1e914a4191e816d98f374149a7e5c47260b5781b8f105a6c7234ac6133d0ac7
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/wasm-crypto@npm:^6.0.2-14":
|
||||
version: 6.0.2-14
|
||||
resolution: "@polkadot/wasm-crypto@npm:6.0.2-14"
|
||||
"@polkadot/wasm-crypto@npm:^6.0.2-15":
|
||||
version: 6.0.2-15
|
||||
resolution: "@polkadot/wasm-crypto@npm:6.0.2-15"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.17.9
|
||||
"@polkadot/wasm-bridge": 6.0.2-14
|
||||
"@polkadot/wasm-crypto-asmjs": 6.0.2-14
|
||||
"@polkadot/wasm-crypto-init": 6.0.2-14
|
||||
"@polkadot/wasm-crypto-wasm": 6.0.2-14
|
||||
"@polkadot/wasm-util": 6.0.2-14
|
||||
"@polkadot/wasm-bridge": 6.0.2-15
|
||||
"@polkadot/wasm-crypto-asmjs": 6.0.2-15
|
||||
"@polkadot/wasm-crypto-init": 6.0.2-15
|
||||
"@polkadot/wasm-crypto-wasm": 6.0.2-15
|
||||
"@polkadot/wasm-util": 6.0.2-15
|
||||
peerDependencies:
|
||||
"@polkadot/util": "*"
|
||||
checksum: f97a03acf5368bceaccb4cdb3395a08e200958d15803602c4b13f023d3876a2b553aa97262a2d15d83128f7d4dfa3f4bbe11af1b7cef2e7358a68f480e335a6d
|
||||
checksum: e1e137fc0d943e1a545a71abf030b6aba1a8c7bf1ba27f9f0c75d3a861b534b582149a34724cbc54592a574afafcb2f05a9d1f62e1d79812970e000d645a4e68
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@polkadot/wasm-util@npm:6.0.2-14":
|
||||
version: 6.0.2-14
|
||||
resolution: "@polkadot/wasm-util@npm:6.0.2-14"
|
||||
"@polkadot/wasm-util@npm:6.0.2-15":
|
||||
version: 6.0.2-15
|
||||
resolution: "@polkadot/wasm-util@npm:6.0.2-15"
|
||||
dependencies:
|
||||
"@babel/runtime": ^7.17.9
|
||||
peerDependencies:
|
||||
"@polkadot/util": "*"
|
||||
checksum: cf7f0dad878bf787d022379a8039b3cc44ce61002c1138dbcc97aeaebde269d618ce9b55c8f6d521058a58e3b89aaab4254d7f02e9dea6f6b41956035a594dbc
|
||||
checksum: 0e9225f7382fea3b4163edec941cd11da5de079db4a50209851c7d0af99f6e01d123083b37e9dc5bbc1cb0d2370d38898b71a8678be868d28bb8da22366f4ce2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user