@hyperlane-xyz/utils 3.9.0 → 3.10.1-beta0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/addresses.d.ts +42 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +292 -0
- package/dist/addresses.js.map +1 -0
- package/dist/addresses.test.d.ts +2 -0
- package/dist/addresses.test.d.ts.map +1 -0
- package/dist/addresses.test.js +44 -0
- package/dist/addresses.test.js.map +1 -0
- package/dist/amount.d.ts +45 -0
- package/dist/amount.d.ts.map +1 -0
- package/dist/amount.js +114 -0
- package/dist/amount.js.map +1 -0
- package/dist/amount.test.d.ts +2 -0
- package/dist/amount.test.d.ts.map +1 -0
- package/dist/amount.test.js +46 -0
- package/dist/amount.test.js.map +1 -0
- package/dist/arrays.d.ts +8 -0
- package/dist/arrays.d.ts.map +1 -0
- package/dist/arrays.js +11 -0
- package/dist/arrays.js.map +1 -0
- package/dist/async.d.ts +56 -0
- package/dist/async.d.ts.map +1 -0
- package/dist/async.js +110 -0
- package/dist/async.js.map +1 -0
- package/dist/base58.d.ts +5 -0
- package/dist/base58.d.ts.map +1 -0
- package/dist/base58.js +15 -0
- package/dist/base58.js.map +1 -0
- package/dist/base64.d.ts +3 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/base64.js +25 -0
- package/dist/base64.js.map +1 -0
- package/dist/big-numbers.d.ts +50 -0
- package/dist/big-numbers.d.ts.map +1 -0
- package/dist/big-numbers.js +80 -0
- package/dist/big-numbers.js.map +1 -0
- package/dist/big-numbers.test.d.ts +2 -0
- package/dist/big-numbers.test.d.ts.map +1 -0
- package/dist/big-numbers.test.js +96 -0
- package/dist/big-numbers.test.js.map +1 -0
- package/dist/calldata.d.ts +3 -0
- package/dist/calldata.d.ts.map +1 -0
- package/dist/calldata.js +4 -0
- package/dist/calldata.js.map +1 -0
- package/dist/checkpoints.d.ts +5 -0
- package/dist/checkpoints.d.ts.map +1 -0
- package/dist/checkpoints.js +24 -0
- package/dist/checkpoints.js.map +1 -0
- package/dist/domains.d.ts +2 -0
- package/dist/domains.d.ts.map +1 -0
- package/dist/domains.js +6 -0
- package/dist/domains.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +11 -0
- package/dist/env.js.map +1 -0
- package/dist/ids.d.ts +20 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +42 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +23 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -142
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +21 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +91 -0
- package/dist/logging.js.map +1 -0
- package/dist/math.d.ts +5 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/math.js +18 -0
- package/dist/math.js.map +1 -0
- package/dist/messages.d.ts +21 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +52 -0
- package/dist/messages.js.map +1 -0
- package/dist/multisig.d.ts +4 -0
- package/dist/multisig.d.ts.map +1 -0
- package/dist/multisig.js +53 -0
- package/dist/multisig.js.map +1 -0
- package/dist/objects.d.ts +19 -0
- package/dist/objects.d.ts.map +1 -0
- package/dist/objects.js +95 -0
- package/dist/objects.js.map +1 -0
- package/dist/sets.d.ts +4 -0
- package/dist/sets.d.ts.map +1 -0
- package/dist/sets.js +24 -0
- package/dist/sets.js.map +1 -0
- package/dist/src/base64.js +2 -2
- package/dist/src/base64.js.map +1 -1
- package/dist/src/env.d.ts +1 -1
- package/dist/src/env.d.ts.map +1 -1
- package/dist/src/env.js +2 -2
- package/dist/src/env.js.map +1 -1
- package/dist/src/logging.d.ts +19 -5
- package/dist/src/logging.d.ts.map +1 -1
- package/dist/src/logging.js +79 -34
- package/dist/src/logging.js.map +1 -1
- package/dist/strings.d.ts +7 -0
- package/dist/strings.d.ts.map +1 -0
- package/dist/strings.js +43 -0
- package/dist/strings.js.map +1 -0
- package/dist/typeof.d.ts +3 -0
- package/dist/typeof.d.ts.map +1 -0
- package/dist/typeof.js +7 -0
- package/dist/typeof.js.map +1 -0
- package/dist/types.d.ts +88 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +6 -0
- package/dist/validation.js.map +1 -0
- package/dist/validator.d.ts +17 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +43 -0
- package/dist/validator.js.map +1 -0
- package/package.json +14 -8
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { eqAmountApproximate, fromWei, fromWeiRounded, toWei, } from './amount.js';
|
|
3
|
+
describe('fromWei', () => {
|
|
4
|
+
it('parses and converts correctly', () => {
|
|
5
|
+
expect(fromWei(1, 0)).to.equal('1');
|
|
6
|
+
expect(fromWei('1000000', 6)).to.equal('1');
|
|
7
|
+
expect(fromWei('1000000000000000000')).to.equal('1');
|
|
8
|
+
expect(fromWei('1000000000000000000.1234')).to.equal('1');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe('fromWeiRounded', () => {
|
|
12
|
+
it('parses and converts correctly', () => {
|
|
13
|
+
expect(fromWeiRounded(1, 0)).to.equal('1.0000');
|
|
14
|
+
expect(fromWeiRounded('1000000', 6)).to.equal('1.0000');
|
|
15
|
+
expect(fromWeiRounded('1000000000000000000')).to.equal('1.0000');
|
|
16
|
+
expect(fromWeiRounded('1000000000000000000.1234')).to.equal('1.0000');
|
|
17
|
+
});
|
|
18
|
+
it('rounds correctly', () => {
|
|
19
|
+
expect(fromWeiRounded(1234567890, 6, 2)).to.equal('1234.56');
|
|
20
|
+
expect(fromWeiRounded('1234567890', 6, 4)).to.equal('1234.5678');
|
|
21
|
+
expect(fromWeiRounded('10000000000000000000')).to.equal('10.0000');
|
|
22
|
+
expect(fromWeiRounded('10000000000000000000', 18, 0)).to.equal('10');
|
|
23
|
+
});
|
|
24
|
+
it('can drop decimals for large numbers', () => {
|
|
25
|
+
expect(fromWeiRounded('10001000000000000000000')).to.equal('10001.00');
|
|
26
|
+
expect(fromWeiRounded('10001000000000000000', 15, 4)).to.equal('10001.0000');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('toWei', () => {
|
|
30
|
+
it('parses and converts correctly', () => {
|
|
31
|
+
expect(toWei(1, 0)).to.equal('1');
|
|
32
|
+
expect(toWei('1', 6)).to.equal('1000000');
|
|
33
|
+
expect(toWei('123.456')).to.equal('123456000000000000000');
|
|
34
|
+
expect(toWei('1.00000000000000000001')).to.equal('1000000000000000000');
|
|
35
|
+
expect(toWei('1.00000000000000000001', 6)).to.equal('1000000');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('eqAmountApproximate', () => {
|
|
39
|
+
it('compares correctly', () => {
|
|
40
|
+
expect(eqAmountApproximate(1, 1.001, 0.001)).to.be.true;
|
|
41
|
+
expect(eqAmountApproximate(9, 9.001, 0.01)).to.be.true;
|
|
42
|
+
expect(eqAmountApproximate('9876543210', '9876543210', '1')).to.be.true;
|
|
43
|
+
expect(eqAmountApproximate('9876543210', '9876543212', '1')).to.be.false;
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=amount.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.test.js","sourceRoot":"","sources":["../src/amount.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EACL,mBAAmB,EACnB,OAAO,EACP,cAAc,EACd,KAAK,GACN,MAAM,aAAa,CAAC;AAErB,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,OAAO,CAAC,C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,CAAC,CAAC;AAEH,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC5B,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACxD,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACvD,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QACxE,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/arrays.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Sliceable {
|
|
2
|
+
length: number;
|
|
3
|
+
slice: (i: number, j: number) => any;
|
|
4
|
+
}
|
|
5
|
+
export declare function chunk<T extends Sliceable>(str: T, size: number): T[];
|
|
6
|
+
export declare function exclude<T>(item: T, list: T[]): T[];
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=arrays.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrays.d.ts","sourceRoot":"","sources":["../src/arrays.ts"],"names":[],"mappings":"AAAA,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;CACtC;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,OAM9D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAE5C"}
|
package/dist/arrays.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function chunk(str, size) {
|
|
2
|
+
const R = [];
|
|
3
|
+
for (let i = 0; i < str.length; i += size) {
|
|
4
|
+
R.push(str.slice(i, i + size));
|
|
5
|
+
}
|
|
6
|
+
return R;
|
|
7
|
+
}
|
|
8
|
+
export function exclude(item, list) {
|
|
9
|
+
return list.filter((i) => i !== item);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=arrays.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrays.js","sourceRoot":"","sources":["../src/arrays.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,KAAK,CAAsB,GAAM,EAAE,IAAY;IAC7D,MAAM,CAAC,GAAa,EAAE,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,OAAO,CAAI,IAAO,EAAE,IAAS;IAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/async.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a promise that resolves in ms milliseconds.
|
|
3
|
+
* @param ms Time to wait
|
|
4
|
+
*/
|
|
5
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Wait up to a given amount of time, and throw an error if the promise does not resolve in time.
|
|
8
|
+
* @param promise The promise to timeout on.
|
|
9
|
+
* @param timeoutMs How long to wait for the promise in milliseconds.
|
|
10
|
+
* @param message The error message if a timeout occurs.
|
|
11
|
+
*/
|
|
12
|
+
export declare function timeout<T>(promise: Promise<T>, timeoutMs?: number, message?: string): Promise<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Run a callback with a timeout.
|
|
15
|
+
* @param timeoutMs How long to wait for the promise in milliseconds.
|
|
16
|
+
* @param callback The callback to run.
|
|
17
|
+
* @returns callback return value
|
|
18
|
+
*/
|
|
19
|
+
export declare function runWithTimeout<T>(timeoutMs: number, callback: () => Promise<T>): Promise<T | void>;
|
|
20
|
+
/**
|
|
21
|
+
* Retries an async function if it raises an exception,
|
|
22
|
+
* using exponential backoff.
|
|
23
|
+
* @param runner callback to run
|
|
24
|
+
* @param attempts max number of attempts
|
|
25
|
+
* @param baseRetryMs base delay between attempts
|
|
26
|
+
* @returns runner return value
|
|
27
|
+
*/
|
|
28
|
+
export declare function retryAsync<T>(runner: () => T, attempts?: number, baseRetryMs?: number): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Run a callback with a timeout, and retry if the callback throws an error.
|
|
31
|
+
* @param runner callback to run
|
|
32
|
+
* @param delayMs base delay between attempts
|
|
33
|
+
* @param maxAttempts maximum number of attempts
|
|
34
|
+
* @returns runner return value
|
|
35
|
+
*/
|
|
36
|
+
export declare function pollAsync<T>(runner: () => Promise<T>, delayMs?: number, maxAttempts?: number | undefined): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* An enhanced Promise.race that returns
|
|
39
|
+
* objects with the promise itself and index
|
|
40
|
+
* instead of just the resolved value.
|
|
41
|
+
*/
|
|
42
|
+
export declare function raceWithContext<T>(promises: Array<Promise<T>>): Promise<{
|
|
43
|
+
resolved: T;
|
|
44
|
+
promise: Promise<T>;
|
|
45
|
+
index: number;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Map an async function over a list xs with a given concurrency level
|
|
49
|
+
* Forked from https://github.com/celo-org/developer-tooling/blob/0c61e7e02c741fe10ecd1d733a33692d324cdc82/packages/sdk/base/src/async.ts#L128
|
|
50
|
+
*
|
|
51
|
+
* @param concurrency number of `mapFn` concurrent executions
|
|
52
|
+
* @param xs list of value
|
|
53
|
+
* @param mapFn mapping function
|
|
54
|
+
*/
|
|
55
|
+
export declare function concurrentMap<A, B>(concurrency: number, xs: A[], mapFn: (val: A, idx: number) => Promise<B>): Promise<B[]>;
|
|
56
|
+
//# sourceMappingURL=async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../src/async.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,SAAoB,GAC1B,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAanB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,MAAM,EAAE,MAAM,CAAC,EACf,QAAQ,SAAI,EACZ,WAAW,SAAK,cAajB;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACxB,OAAO,SAAM,EACb,WAAW,GAAE,MAAM,GAAG,SAAqB,cAe5C;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAK9D;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,CAAC,EAAE,CAAC,EACtC,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,CAAC,EAAE,EACP,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,CAAC,EAAE,CAAC,CAWd"}
|
package/dist/async.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a promise that resolves in ms milliseconds.
|
|
3
|
+
* @param ms Time to wait
|
|
4
|
+
*/
|
|
5
|
+
export function sleep(ms) {
|
|
6
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Wait up to a given amount of time, and throw an error if the promise does not resolve in time.
|
|
10
|
+
* @param promise The promise to timeout on.
|
|
11
|
+
* @param timeoutMs How long to wait for the promise in milliseconds.
|
|
12
|
+
* @param message The error message if a timeout occurs.
|
|
13
|
+
*/
|
|
14
|
+
export function timeout(promise, timeoutMs, message = 'Timeout reached') {
|
|
15
|
+
if (!timeoutMs || timeoutMs <= 0)
|
|
16
|
+
return promise;
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
reject(new Error(message));
|
|
20
|
+
}, timeoutMs);
|
|
21
|
+
promise.then(resolve).catch(reject);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run a callback with a timeout.
|
|
26
|
+
* @param timeoutMs How long to wait for the promise in milliseconds.
|
|
27
|
+
* @param callback The callback to run.
|
|
28
|
+
* @returns callback return value
|
|
29
|
+
*/
|
|
30
|
+
export async function runWithTimeout(timeoutMs, callback) {
|
|
31
|
+
let timeout;
|
|
32
|
+
const timeoutProm = new Promise((_, reject) => (timeout = setTimeout(() => reject(new Error(`Timed out in ${timeoutMs}ms.`)), timeoutMs)));
|
|
33
|
+
const ret = await Promise.race([callback(), timeoutProm]);
|
|
34
|
+
// @ts-ignore timeout gets set immediately by the promise constructor
|
|
35
|
+
clearTimeout(timeout);
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Retries an async function if it raises an exception,
|
|
40
|
+
* using exponential backoff.
|
|
41
|
+
* @param runner callback to run
|
|
42
|
+
* @param attempts max number of attempts
|
|
43
|
+
* @param baseRetryMs base delay between attempts
|
|
44
|
+
* @returns runner return value
|
|
45
|
+
*/
|
|
46
|
+
export async function retryAsync(runner, attempts = 5, baseRetryMs = 50) {
|
|
47
|
+
let saveError;
|
|
48
|
+
for (let i = 0; i < attempts; i++) {
|
|
49
|
+
try {
|
|
50
|
+
const result = await runner();
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
saveError = error;
|
|
55
|
+
await sleep(baseRetryMs * 2 ** i);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
throw saveError;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Run a callback with a timeout, and retry if the callback throws an error.
|
|
62
|
+
* @param runner callback to run
|
|
63
|
+
* @param delayMs base delay between attempts
|
|
64
|
+
* @param maxAttempts maximum number of attempts
|
|
65
|
+
* @returns runner return value
|
|
66
|
+
*/
|
|
67
|
+
export async function pollAsync(runner, delayMs = 500, maxAttempts = undefined) {
|
|
68
|
+
let attempts = 0;
|
|
69
|
+
let saveError;
|
|
70
|
+
while (!maxAttempts || attempts < maxAttempts) {
|
|
71
|
+
try {
|
|
72
|
+
const ret = await runner();
|
|
73
|
+
return ret;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
saveError = error;
|
|
77
|
+
attempts += 1;
|
|
78
|
+
await sleep(delayMs);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
throw saveError;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* An enhanced Promise.race that returns
|
|
85
|
+
* objects with the promise itself and index
|
|
86
|
+
* instead of just the resolved value.
|
|
87
|
+
*/
|
|
88
|
+
export async function raceWithContext(promises) {
|
|
89
|
+
const promisesWithContext = promises.map((p, i) => p.then((resolved) => ({ resolved, promise: p, index: i })));
|
|
90
|
+
return Promise.race(promisesWithContext);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Map an async function over a list xs with a given concurrency level
|
|
94
|
+
* Forked from https://github.com/celo-org/developer-tooling/blob/0c61e7e02c741fe10ecd1d733a33692d324cdc82/packages/sdk/base/src/async.ts#L128
|
|
95
|
+
*
|
|
96
|
+
* @param concurrency number of `mapFn` concurrent executions
|
|
97
|
+
* @param xs list of value
|
|
98
|
+
* @param mapFn mapping function
|
|
99
|
+
*/
|
|
100
|
+
export async function concurrentMap(concurrency, xs, mapFn) {
|
|
101
|
+
let res = [];
|
|
102
|
+
for (let i = 0; i < xs.length; i += concurrency) {
|
|
103
|
+
const remaining = xs.length - i;
|
|
104
|
+
const sliceSize = Math.min(remaining, concurrency);
|
|
105
|
+
const slice = xs.slice(i, i + sliceSize);
|
|
106
|
+
res = res.concat(await Promise.all(slice.map((elem, index) => mapFn(elem, i + index))));
|
|
107
|
+
}
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../src/async.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CA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3C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,WAAmB,EACnB,EAAO,EACP,KAA0C;IAE1C,IAAI,GAAG,GAAQ,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC;QAChD,MAAM,SAAS,GAAG,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC;QACzC,GAAG,GAAG,GAAG,CAAC,MAAM,CACd,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/base58.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
export declare function base58ToBuffer(value: string): Buffer;
|
|
3
|
+
export declare function bufferToBase58(value: Buffer): string;
|
|
4
|
+
export declare function hexOrBase58ToHex(value: string): string;
|
|
5
|
+
//# sourceMappingURL=base58.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../src/base58.ts"],"names":[],"mappings":";AAEA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAID,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,UAI7C"}
|
package/dist/base58.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { utils } from 'ethers';
|
|
2
|
+
export function base58ToBuffer(value) {
|
|
3
|
+
return Buffer.from(utils.base58.decode(value));
|
|
4
|
+
}
|
|
5
|
+
export function bufferToBase58(value) {
|
|
6
|
+
return utils.base58.encode(value);
|
|
7
|
+
}
|
|
8
|
+
// If the value is already hex (checked by 0x prefix), return it as is.
|
|
9
|
+
// Otherwise, treat it as base58 and convert it to hex.
|
|
10
|
+
export function hexOrBase58ToHex(value) {
|
|
11
|
+
if (value.startsWith('0x'))
|
|
12
|
+
return value;
|
|
13
|
+
return utils.hexlify(base58ToBuffer(value));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=base58.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base58.js","sourceRoot":"","sources":["../src/base58.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,uEAAuE;AACvE,uDAAuD;AACvD,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAEzC,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
package/dist/base64.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../src/base64.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAQtD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CASpE"}
|
package/dist/base64.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { rootLogger } from './logging.js';
|
|
2
|
+
export function toBase64(data) {
|
|
3
|
+
try {
|
|
4
|
+
if (!data)
|
|
5
|
+
throw new Error('No data to encode');
|
|
6
|
+
return btoa(JSON.stringify(data));
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
rootLogger.error('Unable to serialize + encode data to base64', data);
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function fromBase64(data) {
|
|
14
|
+
try {
|
|
15
|
+
if (!data)
|
|
16
|
+
throw new Error('No data to decode');
|
|
17
|
+
const msg = Array.isArray(data) ? data[0] : data;
|
|
18
|
+
return JSON.parse(atob(msg));
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
rootLogger.error('Unable to decode + deserialize data from base64', data);
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../src/base64.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,UAAU,QAAQ,CAAC,IAAS;IAChC,IAAI,CAAC;QACH,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,CAAC,6CAA6C,EAAE,IAAI,CAAC,CAAC;QACtE,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,IAAuB;IACnD,IAAI,CAAC;QACH,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,UAAU,CAAC,KAAK,CAAC,iDAAiD,EAAE,IAAI,CAAC,CAAC;QAC1E,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BigNumber } from 'bignumber.js';
|
|
2
|
+
import { FixedNumber } from 'ethers';
|
|
3
|
+
/**
|
|
4
|
+
* Check if a value is bigNumberish (e.g. valid numbers, bigNumber).
|
|
5
|
+
* @param value The value to check.
|
|
6
|
+
* @returns true/false.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isBigNumberish(value: BigNumber.Value | undefined | null): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Check if a value (e.g. hex string or number) is zeroish (0, 0x0, 0x00, etc.).
|
|
11
|
+
* @param value The value to check.
|
|
12
|
+
* @returns true/false.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isZeroish(value: BigNumber.Value): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a BigNumber to a FixedNumber of the format fixed128x18.
|
|
17
|
+
* @param big The BigNumber to convert.
|
|
18
|
+
* @returns A FixedNumber representation of a BigNumber.
|
|
19
|
+
*/
|
|
20
|
+
export declare function bigToFixed(big: BigNumber.Value): FixedNumber;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a FixedNumber (of any format) to a BigNumber.
|
|
23
|
+
* @param fixed The FixedNumber to convert.
|
|
24
|
+
* @param ceil If true, the ceiling of fixed is used. Otherwise, the floor is used.
|
|
25
|
+
* @returns A BigNumber representation of a FixedNumber.
|
|
26
|
+
*/
|
|
27
|
+
export declare function fixedToBig(fixed: FixedNumber, ceil?: boolean): BigNumber;
|
|
28
|
+
/**
|
|
29
|
+
* Multiplies a BigNumber by a FixedNumber, returning the BigNumber product.
|
|
30
|
+
* @param big The BigNumber to multiply.
|
|
31
|
+
* @param fixed The FixedNumber to multiply.
|
|
32
|
+
* @param ceil If true, the ceiling of the product is used. Otherwise, the floor is used.
|
|
33
|
+
* @returns The BigNumber product in string type.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mulBigAndFixed(big: BigNumber.Value, fixed: FixedNumber, ceil?: boolean): string;
|
|
36
|
+
/**
|
|
37
|
+
* Return the smaller in the given two BigNumbers.
|
|
38
|
+
* @param bn1 The BigNumber to compare.
|
|
39
|
+
* @param bn2 The BigNumber to compare.
|
|
40
|
+
* @returns The smaller BigNumber in string type.
|
|
41
|
+
*/
|
|
42
|
+
export declare function BigNumberMin(bn1: BigNumber.Value, bn2: BigNumber.Value): string;
|
|
43
|
+
/**
|
|
44
|
+
* Return the bigger in the given two BigNumbers.
|
|
45
|
+
* @param bn1 The BigNumber to compare.
|
|
46
|
+
* @param bn2 The BigNumber to compare.
|
|
47
|
+
* @returns The bigger BigNumber in string type.
|
|
48
|
+
*/
|
|
49
|
+
export declare function BigNumberMax(bn1: BigNumber.Value, bn2: BigNumber.Value): string;
|
|
50
|
+
//# sourceMappingURL=big-numbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"big-numbers.d.ts","sourceRoot":"","sources":["../src/big-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAKrC;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,CAAC,KAAK,GAAG,SAAS,GAAG,IAAI,GACxC,OAAO,CAOT;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,GAAG,OAAO,CAMzD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,GAAG,WAAW,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,UAAQ,GAAG,SAAS,CAGtE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,SAAS,CAAC,KAAK,EACpB,KAAK,EAAE,WAAW,EAClB,IAAI,UAAQ,GACX,MAAM,CAIR;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,SAAS,CAAC,KAAK,EACpB,GAAG,EAAE,SAAS,CAAC,KAAK,GACnB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,SAAS,CAAC,KAAK,EACpB,GAAG,EAAE,SAAS,CAAC,KAAK,GACnB,MAAM,CAER"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BigNumber } from 'bignumber.js';
|
|
2
|
+
import { FixedNumber } from 'ethers';
|
|
3
|
+
// Use toString(10) on bignumber.js to prevent ethers.js bigNumber error
|
|
4
|
+
// when parsing exponential string over e21
|
|
5
|
+
/**
|
|
6
|
+
* Check if a value is bigNumberish (e.g. valid numbers, bigNumber).
|
|
7
|
+
* @param value The value to check.
|
|
8
|
+
* @returns true/false.
|
|
9
|
+
*/
|
|
10
|
+
export function isBigNumberish(value) {
|
|
11
|
+
try {
|
|
12
|
+
const val = BigNumber(value);
|
|
13
|
+
return !val.isNaN() && val.isFinite() && BigNumber.isBigNumber(val);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if a value (e.g. hex string or number) is zeroish (0, 0x0, 0x00, etc.).
|
|
21
|
+
* @param value The value to check.
|
|
22
|
+
* @returns true/false.
|
|
23
|
+
*/
|
|
24
|
+
export function isZeroish(value) {
|
|
25
|
+
try {
|
|
26
|
+
return BigNumber(value).isZero();
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Converts a BigNumber to a FixedNumber of the format fixed128x18.
|
|
34
|
+
* @param big The BigNumber to convert.
|
|
35
|
+
* @returns A FixedNumber representation of a BigNumber.
|
|
36
|
+
*/
|
|
37
|
+
export function bigToFixed(big) {
|
|
38
|
+
return FixedNumber.from(big.toString(10));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Converts a FixedNumber (of any format) to a BigNumber.
|
|
42
|
+
* @param fixed The FixedNumber to convert.
|
|
43
|
+
* @param ceil If true, the ceiling of fixed is used. Otherwise, the floor is used.
|
|
44
|
+
* @returns A BigNumber representation of a FixedNumber.
|
|
45
|
+
*/
|
|
46
|
+
export function fixedToBig(fixed, ceil = false) {
|
|
47
|
+
const fixedAsInteger = ceil ? fixed.ceiling() : fixed.floor();
|
|
48
|
+
return BigNumber(fixedAsInteger.toFormat('fixed256x0').toString());
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Multiplies a BigNumber by a FixedNumber, returning the BigNumber product.
|
|
52
|
+
* @param big The BigNumber to multiply.
|
|
53
|
+
* @param fixed The FixedNumber to multiply.
|
|
54
|
+
* @param ceil If true, the ceiling of the product is used. Otherwise, the floor is used.
|
|
55
|
+
* @returns The BigNumber product in string type.
|
|
56
|
+
*/
|
|
57
|
+
export function mulBigAndFixed(big, fixed, ceil = false) {
|
|
58
|
+
// Converts big to a FixedNumber, multiplies it by fixed, and converts the product back
|
|
59
|
+
// to a BigNumber.
|
|
60
|
+
return fixedToBig(fixed.mulUnsafe(bigToFixed(big)), ceil).toString(10);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Return the smaller in the given two BigNumbers.
|
|
64
|
+
* @param bn1 The BigNumber to compare.
|
|
65
|
+
* @param bn2 The BigNumber to compare.
|
|
66
|
+
* @returns The smaller BigNumber in string type.
|
|
67
|
+
*/
|
|
68
|
+
export function BigNumberMin(bn1, bn2) {
|
|
69
|
+
return BigNumber(bn1).gte(bn2) ? bn2.toString(10) : bn1.toString(10);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Return the bigger in the given two BigNumbers.
|
|
73
|
+
* @param bn1 The BigNumber to compare.
|
|
74
|
+
* @param bn2 The BigNumber to compare.
|
|
75
|
+
* @returns The bigger BigNumber in string type.
|
|
76
|
+
*/
|
|
77
|
+
export function BigNumberMax(bn1, bn2) {
|
|
78
|
+
return BigNumber(bn1).lte(bn2) ? bn2.toString(10) : bn1.toString(10);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=big-numbers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"big-numbers.js","sourceRoot":"","sources":["../src/big-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,wEAAwE;AACxE,2CAA2C;AAE3C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAyC;IAEzC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,SAAS,CAAC,KAAM,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,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AAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,GAAoB,EACpB,GAAoB;IAEpB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"big-numbers.test.d.ts","sourceRoot":"","sources":["../src/big-numbers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { BigNumber } from 'bignumber.js';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { FixedNumber } from 'ethers';
|
|
4
|
+
import { BigNumberMax, BigNumberMin, bigToFixed, fixedToBig, isBigNumberish, isZeroish, mulBigAndFixed, } from './big-numbers.js';
|
|
5
|
+
describe('isBigNumberish', () => {
|
|
6
|
+
const testCases = [
|
|
7
|
+
{ expect: false, context: 'invalid number', case: 'invalidNumber' },
|
|
8
|
+
{ expect: false, context: 'NaN', case: NaN },
|
|
9
|
+
{ expect: false, context: 'undefined', case: undefined },
|
|
10
|
+
{ expect: false, context: 'null', case: null },
|
|
11
|
+
{ expect: true, context: 'decimal', case: 123.123 },
|
|
12
|
+
{ expect: true, context: 'integer', case: 300000 },
|
|
13
|
+
{ expect: true, context: 'hex 0', case: 0x00 },
|
|
14
|
+
{ expect: true, context: 'hex 0', case: 0x000 },
|
|
15
|
+
{
|
|
16
|
+
expect: true,
|
|
17
|
+
context: 'address 0',
|
|
18
|
+
case: 0x0000000000000000000000000000000000000000,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
testCases.forEach((tc) => {
|
|
22
|
+
it(`returns ${tc.expect} for ${tc.case}`, () => {
|
|
23
|
+
expect(isBigNumberish(tc.case)).to.equal(tc.expect);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('isZeroish', () => {
|
|
28
|
+
const testCases = [
|
|
29
|
+
{ expect: false, context: 'invalid number', case: 'invalidNumber' },
|
|
30
|
+
{ expect: false, context: 'NaN', case: NaN },
|
|
31
|
+
{ expect: false, context: 'undefined', case: undefined },
|
|
32
|
+
{ expect: false, context: 'null', case: null },
|
|
33
|
+
{ expect: false, context: 'non 0 decimal', case: 123.123 },
|
|
34
|
+
{ expect: false, context: 'non 0 integer', case: 123 },
|
|
35
|
+
{ expect: true, context: 'hex 0', case: 0x00 },
|
|
36
|
+
{ expect: true, context: 'hex 0', case: 0x000 },
|
|
37
|
+
{
|
|
38
|
+
expect: true,
|
|
39
|
+
context: 'address 0',
|
|
40
|
+
case: 0x0000000000000000000000000000000000000000,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
testCases.forEach((tc) => {
|
|
44
|
+
it(`returns ${tc.expect} for ${tc.case}`, () => {
|
|
45
|
+
expect(isZeroish(tc.case)).to.equal(tc.expect);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe('bigToFixed', () => {
|
|
50
|
+
it('converts a BigNumber to a FixedNumber', () => {
|
|
51
|
+
const big = BigNumber('7.5e-10');
|
|
52
|
+
const fixed = bigToFixed(big);
|
|
53
|
+
expect(fixed.toUnsafeFloat()).to.equal(7.5e-10);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('fixedToBig', () => {
|
|
57
|
+
it('converts a FixedNumber to a floored BigNumber', () => {
|
|
58
|
+
const fixed = FixedNumber.from('12.34');
|
|
59
|
+
const big = fixedToBig(fixed);
|
|
60
|
+
expect(big.toNumber()).to.equal(12);
|
|
61
|
+
});
|
|
62
|
+
it('converts a FixedNumber to a ceilinged BigNumber', () => {
|
|
63
|
+
const fixed = FixedNumber.from('12.34');
|
|
64
|
+
const big = fixedToBig(fixed, true);
|
|
65
|
+
expect(big.toNumber()).to.equal(13);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('mulBigAndFixed', () => {
|
|
69
|
+
it('gets the floored product of a BigNumber and FixedNumber', () => {
|
|
70
|
+
const big = BigNumber('1000');
|
|
71
|
+
const fixed = FixedNumber.from('1.2345');
|
|
72
|
+
const product = mulBigAndFixed(big, fixed);
|
|
73
|
+
expect(product).to.equal((1234).toString());
|
|
74
|
+
});
|
|
75
|
+
it('gets the ceilinged product of a BigNumber and FixedNumber', () => {
|
|
76
|
+
const big = BigNumber('1000');
|
|
77
|
+
const fixed = FixedNumber.from('1.2345');
|
|
78
|
+
const product = mulBigAndFixed(big, fixed, true);
|
|
79
|
+
expect(product).to.equal((1235).toString());
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('BigNumberMin', () => {
|
|
83
|
+
it('gets the min between the two BigNumber', () => {
|
|
84
|
+
const big = BigNumber('1000');
|
|
85
|
+
const bigger = BigNumber('10000');
|
|
86
|
+
expect(BigNumberMin(big, bigger)).to.equal(big.toString());
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe('BigNumberMax', () => {
|
|
90
|
+
it('gets the max between the two BigNumber', () => {
|
|
91
|
+
const big = BigNumber('1000');
|
|
92
|
+
const bigger = BigNumber('10000');
|
|
93
|
+
expect(BigNumberMax(big, bigger)).to.equal(bigger.toString());
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=big-numbers.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"big-numbers.test.js","sourceRoot":"","sources":["../src/big-numbers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,cAAc,EACd,SAAS,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AAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calldata.d.ts","sourceRoot":"","sources":["../src/calldata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,wBAAgB,cAAc,CAC5B,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,CAAC,EAC1D,mBAAmB,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAKxE"}
|
package/dist/calldata.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calldata.js","sourceRoot":"","sources":["../src/calldata.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAG5B,mBAAsB,EAAE,YAAkB,EAAE,YAAkB;IAC9D,OAAO,mBAAmB,CAAC,SAAS,CAAC,kBAAkB,CACrD,YAAY,EACZ,YAAY,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Checkpoint, S3Checkpoint, S3CheckpointWithId } from './types.js';
|
|
2
|
+
export declare function isS3Checkpoint(obj: any): obj is S3Checkpoint;
|
|
3
|
+
export declare function isS3CheckpointWithId(obj: any): obj is S3CheckpointWithId;
|
|
4
|
+
export declare function isCheckpoint(obj: any): obj is Checkpoint;
|
|
5
|
+
//# sourceMappingURL=checkpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoints.d.ts","sourceRoot":"","sources":["../src/checkpoints.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAEnB,MAAM,YAAY,CAAC;AAUpB,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,YAAY,CAE5D;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,kBAAkB,CAMxE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,UAAU,CAMxD"}
|