@alephium/web3 0.9.0-rc.0 → 0.9.0-rc.1

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.
Files changed (73) hide show
  1. package/dist/alephium-web3.min.js +3 -0
  2. package/dist/alephium-web3.min.js.LICENSE.txt +12 -0
  3. package/dist/alephium-web3.min.js.map +1 -0
  4. package/dist/scripts/check-versions.d.ts +1 -0
  5. package/dist/scripts/check-versions.js +39 -0
  6. package/dist/scripts/header.d.ts +0 -0
  7. package/dist/scripts/header.js +18 -0
  8. package/dist/src/api/api-alephium.d.ts +1717 -0
  9. package/dist/src/api/api-alephium.js +1284 -0
  10. package/dist/src/api/api-explorer.d.ts +923 -0
  11. package/dist/src/api/api-explorer.js +711 -0
  12. package/dist/src/api/explorer-provider.d.ts +20 -0
  13. package/dist/src/api/explorer-provider.js +69 -0
  14. package/dist/src/api/index.d.ts +6 -0
  15. package/dist/src/api/index.js +52 -0
  16. package/dist/src/api/node-provider.d.ts +38 -0
  17. package/dist/src/api/node-provider.js +99 -0
  18. package/dist/src/api/types.d.ts +38 -0
  19. package/dist/src/api/types.js +259 -0
  20. package/dist/src/api/utils.d.ts +12 -0
  21. package/dist/src/api/utils.js +59 -0
  22. package/dist/src/constants.d.ts +6 -0
  23. package/dist/src/constants.js +26 -0
  24. package/dist/src/contract/contract.d.ts +297 -0
  25. package/dist/src/contract/contract.js +1097 -0
  26. package/dist/src/contract/events.d.ts +11 -0
  27. package/dist/src/contract/events.js +65 -0
  28. package/dist/src/contract/index.d.ts +3 -0
  29. package/dist/src/contract/index.js +36 -0
  30. package/dist/src/contract/ralph.d.ts +13 -0
  31. package/dist/src/contract/ralph.js +397 -0
  32. package/dist/src/global.d.ts +7 -0
  33. package/dist/src/global.js +54 -0
  34. package/dist/src/index.d.ts +9 -0
  35. package/dist/src/index.js +58 -0
  36. package/dist/src/signer/index.d.ts +3 -0
  37. package/dist/src/signer/index.js +36 -0
  38. package/dist/src/signer/signer.d.ts +60 -0
  39. package/dist/src/signer/signer.js +236 -0
  40. package/dist/src/signer/tx-builder.d.ts +12 -0
  41. package/dist/src/signer/tx-builder.js +96 -0
  42. package/dist/src/signer/types.d.ts +115 -0
  43. package/dist/src/signer/types.js +30 -0
  44. package/dist/src/token/index.d.ts +1 -0
  45. package/dist/src/token/index.js +34 -0
  46. package/dist/src/token/nft.d.ts +10 -0
  47. package/dist/src/token/nft.js +19 -0
  48. package/dist/src/transaction/index.d.ts +2 -0
  49. package/dist/src/transaction/index.js +35 -0
  50. package/dist/src/transaction/sign-verify.d.ts +3 -0
  51. package/dist/src/transaction/sign-verify.js +52 -0
  52. package/dist/src/transaction/status.d.ts +11 -0
  53. package/dist/src/transaction/status.js +49 -0
  54. package/dist/src/utils/address.d.ts +1 -0
  55. package/dist/src/utils/address.js +42 -0
  56. package/dist/src/utils/bs58.d.ts +5 -0
  57. package/dist/src/utils/bs58.js +40 -0
  58. package/dist/src/utils/djb2.d.ts +1 -0
  59. package/dist/src/utils/djb2.js +27 -0
  60. package/dist/src/utils/index.d.ts +7 -0
  61. package/dist/src/utils/index.js +40 -0
  62. package/dist/src/utils/number.d.ts +18 -0
  63. package/dist/src/utils/number.fixture.d.ts +12 -0
  64. package/dist/src/utils/number.fixture.js +189 -0
  65. package/dist/src/utils/number.js +149 -0
  66. package/dist/src/utils/sign.d.ts +3 -0
  67. package/dist/src/utils/sign.js +89 -0
  68. package/dist/src/utils/subscription.d.ts +21 -0
  69. package/dist/src/utils/subscription.js +51 -0
  70. package/dist/src/utils/utils.d.ts +40 -0
  71. package/dist/src/utils/utils.js +244 -0
  72. package/package.json +1 -1
  73. package/LICENSE +0 -165
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }) : (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ o[k2] = m[k];
29
+ }));
30
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
31
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ __exportStar(require("./status"), exports);
35
+ __exportStar(require("./sign-verify"), exports);
@@ -0,0 +1,3 @@
1
+ import { KeyType } from '../signer';
2
+ export declare function transactionSign(txId: string, privateKey: string, keyType?: KeyType): string;
3
+ export declare function transactionVerifySignature(txId: string, publicKey: string, signature: string, keyType?: KeyType): boolean;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }) : (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ o[k2] = m[k];
29
+ }));
30
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
31
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
32
+ }) : function(o, v) {
33
+ o["default"] = v;
34
+ });
35
+ var __importStar = (this && this.__importStar) || function (mod) {
36
+ if (mod && mod.__esModule) return mod;
37
+ var result = {};
38
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
+ __setModuleDefault(result, mod);
40
+ return result;
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.transactionVerifySignature = exports.transactionSign = void 0;
44
+ const utils = __importStar(require("../utils"));
45
+ function transactionSign(txId, privateKey, keyType) {
46
+ return utils.sign(txId, privateKey, keyType);
47
+ }
48
+ exports.transactionSign = transactionSign;
49
+ function transactionVerifySignature(txId, publicKey, signature, keyType) {
50
+ return utils.verifySignature(txId, publicKey, signature, keyType);
51
+ }
52
+ exports.transactionVerifySignature = transactionVerifySignature;
@@ -0,0 +1,11 @@
1
+ import { node } from '../api';
2
+ import { Subscription, SubscribeOptions } from '../utils';
3
+ export type TxStatus = node.TxStatus;
4
+ export declare class TxStatusSubscription extends Subscription<TxStatus> {
5
+ readonly txId: string;
6
+ readonly fromGroup?: number;
7
+ readonly toGroup?: number;
8
+ constructor(options: SubscribeOptions<TxStatus>, txId: string, fromGroup?: number, toGroup?: number);
9
+ polling(): Promise<void>;
10
+ }
11
+ export declare function subscribeToTxStatus(options: SubscribeOptions<TxStatus>, txId: string, fromGroup?: number, toGroup?: number): TxStatusSubscription;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.subscribeToTxStatus = exports.TxStatusSubscription = void 0;
21
+ const __1 = require("..");
22
+ const utils_1 = require("../utils");
23
+ class TxStatusSubscription extends utils_1.Subscription {
24
+ constructor(options, txId, fromGroup, toGroup) {
25
+ super(options);
26
+ this.txId = txId;
27
+ this.fromGroup = fromGroup;
28
+ this.toGroup = toGroup;
29
+ this.startPolling();
30
+ }
31
+ async polling() {
32
+ try {
33
+ const txStatus = await __1.web3.getCurrentNodeProvider().transactions.getTransactionsStatus({
34
+ txId: this.txId,
35
+ fromGroup: this.fromGroup,
36
+ toGroup: this.toGroup
37
+ });
38
+ await this.messageCallback(txStatus);
39
+ }
40
+ catch (err) {
41
+ await this.errorCallback(err, this);
42
+ }
43
+ }
44
+ }
45
+ exports.TxStatusSubscription = TxStatusSubscription;
46
+ function subscribeToTxStatus(options, txId, fromGroup, toGroup) {
47
+ return new TxStatusSubscription(options, txId, fromGroup, toGroup);
48
+ }
49
+ exports.subscribeToTxStatus = subscribeToTxStatus;
@@ -0,0 +1 @@
1
+ export declare function addressToGroup(address: string, totalNumberOfGroups: number): number;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.addressToGroup = void 0;
24
+ const bs58_1 = __importDefault(require("./bs58"));
25
+ const djb2_1 = __importDefault(require("./djb2"));
26
+ function addressToGroup(address, totalNumberOfGroups) {
27
+ const bytes = bs58_1.default.decode(address).slice(1);
28
+ const value = (0, djb2_1.default)(bytes) | 1;
29
+ const hash = toPosInt(xorByte(value));
30
+ const group = hash % totalNumberOfGroups;
31
+ return group;
32
+ }
33
+ exports.addressToGroup = addressToGroup;
34
+ function xorByte(value) {
35
+ const byte0 = value >> 24;
36
+ const byte1 = value >> 16;
37
+ const byte2 = value >> 8;
38
+ return byte0 ^ byte1 ^ byte2 ^ value;
39
+ }
40
+ function toPosInt(byte) {
41
+ return byte & 0xff;
42
+ }
@@ -0,0 +1,5 @@
1
+ /** This source is under MIT License and come originally from https://github.com/cryptocoinjs/bs58 **/
2
+ import basex from 'base-x';
3
+ export declare const bs58: basex.BaseConverter;
4
+ export declare function isBase58(s: string): boolean;
5
+ export default bs58;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.isBase58 = exports.bs58 = void 0;
24
+ /** This source is under MIT License and come originally from https://github.com/cryptocoinjs/bs58 **/
25
+ const base_x_1 = __importDefault(require("base-x"));
26
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
27
+ exports.bs58 = (0, base_x_1.default)(ALPHABET);
28
+ function isBase58(s) {
29
+ if (s === '' || s.trim() === '') {
30
+ return false;
31
+ }
32
+ try {
33
+ return exports.bs58.encode(exports.bs58.decode(s)) === s;
34
+ }
35
+ catch (err) {
36
+ return false;
37
+ }
38
+ }
39
+ exports.isBase58 = isBase58;
40
+ exports.default = exports.bs58;
@@ -0,0 +1 @@
1
+ export default function djb2(bytes: Uint8Array): number;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ function djb2(bytes) {
21
+ let hash = 5381;
22
+ for (let i = 0; i < bytes.length; i++) {
23
+ hash = (hash << 5) + hash + (bytes[`${i}`] & 0xff);
24
+ }
25
+ return hash;
26
+ }
27
+ exports.default = djb2;
@@ -0,0 +1,7 @@
1
+ export * from './address';
2
+ export * from './bs58';
3
+ export * from './djb2';
4
+ export * from './utils';
5
+ export * from './subscription';
6
+ export * from './sign';
7
+ export * from './number';
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
+ desc = { enumerable: true, get: function() { return m[k]; } };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }) : (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ o[k2] = m[k];
29
+ }));
30
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
31
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ __exportStar(require("./address"), exports);
35
+ __exportStar(require("./bs58"), exports);
36
+ __exportStar(require("./djb2"), exports);
37
+ __exportStar(require("./utils"), exports);
38
+ __exportStar(require("./subscription"), exports);
39
+ __exportStar(require("./sign"), exports);
40
+ __exportStar(require("./number"), exports);
@@ -0,0 +1,18 @@
1
+ import { Number256 } from '..';
2
+ export declare const isNumeric: (numToCheck: any) => boolean;
3
+ export interface IPrettifyNumberConfig {
4
+ minDecimalPlaces: number;
5
+ maxDecimalPlaces: number;
6
+ /** significant digits to show in decimals while respecting decimal places */
7
+ minDecimalSignificantDigits: number;
8
+ /** special case for zero, e.g. we may want to display $0.00 or 0.0 ALPH */
9
+ decimalPlacesWhenZero: number;
10
+ }
11
+ export declare const prettifyNumberConfig: Record<string, IPrettifyNumberConfig>;
12
+ export declare function prettifyAttoAlphAmount(amount: Number256): string | undefined;
13
+ export declare function prettifyTokenAmount(amount: Number256, decimals: number): string | undefined;
14
+ export declare function prettifyExactAmount(amount: Number256, decimals: number): string | undefined;
15
+ export declare function prettifyNumber(amount: Number256, decimals: number, config: IPrettifyNumberConfig): string | undefined;
16
+ export declare function convertAmountWithDecimals(amount: string | number, decimals: number): bigint | undefined;
17
+ export declare function convertAlphAmountWithDecimals(amount: string | number): bigint | undefined;
18
+ export declare function number256ToBigint(number: Number256): bigint;
@@ -0,0 +1,12 @@
1
+ export declare const tests: {
2
+ raw: bigint;
3
+ decimal: number;
4
+ exact: string;
5
+ alphFormat: string;
6
+ tokenFormat: string;
7
+ }[];
8
+ export declare const tests1: {
9
+ raw: string;
10
+ decimals: number;
11
+ amount: bigint;
12
+ }[];
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tests1 = exports.tests = void 0;
4
+ /*
5
+ Copyright 2018 - 2022 The Alephium Authors
6
+ This file is part of the alephium project.
7
+
8
+ The library is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU Lesser General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ The library is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General Public License
19
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ exports.tests = [
22
+ {
23
+ raw: 123456n,
24
+ decimal: 5,
25
+ exact: '1.23456',
26
+ alphFormat: '1.23',
27
+ tokenFormat: '1.2346'
28
+ },
29
+ {
30
+ raw: 12345612n,
31
+ decimal: 2,
32
+ exact: '123,456.12',
33
+ alphFormat: '123,456.12',
34
+ tokenFormat: '123,456.12'
35
+ },
36
+ {
37
+ raw: 123456123456n,
38
+ decimal: 6,
39
+ exact: '123,456.123456',
40
+ alphFormat: '123,456.12',
41
+ tokenFormat: '123,456.1235'
42
+ },
43
+ {
44
+ raw: 12n,
45
+ decimal: 2,
46
+ exact: '0.12',
47
+ alphFormat: '0.12',
48
+ tokenFormat: '0.12'
49
+ },
50
+ {
51
+ raw: 123456n,
52
+ decimal: 6,
53
+ exact: '0.123456',
54
+ alphFormat: '0.12',
55
+ tokenFormat: '0.1235'
56
+ },
57
+ {
58
+ raw: 123456n,
59
+ decimal: 7,
60
+ exact: '0.0123456',
61
+ alphFormat: '0.012',
62
+ tokenFormat: '0.0123'
63
+ },
64
+ {
65
+ raw: 123456n,
66
+ decimal: 8,
67
+ exact: '0.00123456',
68
+ alphFormat: '0.0012',
69
+ tokenFormat: '0.0012'
70
+ },
71
+ {
72
+ raw: 123456n,
73
+ decimal: 9,
74
+ exact: '0.000123456',
75
+ alphFormat: '0.00012',
76
+ tokenFormat: '0.00012'
77
+ },
78
+ {
79
+ raw: 123456n,
80
+ decimal: 11,
81
+ exact: '0.00000123456',
82
+ alphFormat: '0.0000012',
83
+ tokenFormat: '0.0000012'
84
+ },
85
+ {
86
+ raw: -123456n,
87
+ decimal: 11,
88
+ exact: '-0.00000123456',
89
+ alphFormat: '-0.0000012',
90
+ tokenFormat: '-0.0000012'
91
+ },
92
+ {
93
+ raw: 8923088n,
94
+ decimal: 10,
95
+ exact: '0.0008923088',
96
+ alphFormat: '0.00089',
97
+ tokenFormat: '0.00089'
98
+ },
99
+ {
100
+ raw: 885n,
101
+ decimal: 6,
102
+ exact: '0.000885',
103
+ alphFormat: '0.00089',
104
+ tokenFormat: '0.00089'
105
+ },
106
+ {
107
+ raw: 100000000000n,
108
+ decimal: 18,
109
+ exact: '0.0000001',
110
+ alphFormat: '0.0000001',
111
+ tokenFormat: '0.0000001'
112
+ },
113
+ {
114
+ raw: 1504000000000000000n,
115
+ decimal: 18,
116
+ exact: '1.504',
117
+ alphFormat: '1.50',
118
+ tokenFormat: '1.504'
119
+ },
120
+ {
121
+ raw: 1505000000000000000n,
122
+ decimal: 18,
123
+ exact: '1.505',
124
+ alphFormat: '1.51',
125
+ tokenFormat: '1.505'
126
+ },
127
+ {
128
+ raw: 1500050000000000000n,
129
+ decimal: 18,
130
+ exact: '1.50005',
131
+ alphFormat: '1.50',
132
+ tokenFormat: '1.5001'
133
+ },
134
+ {
135
+ raw: 100n,
136
+ decimal: 0,
137
+ exact: '100',
138
+ alphFormat: '100.00',
139
+ tokenFormat: '100.0'
140
+ },
141
+ {
142
+ raw: 123456789n,
143
+ decimal: 0,
144
+ exact: '123,456,789',
145
+ alphFormat: '123,456,789.00',
146
+ tokenFormat: '123,456,789.0'
147
+ },
148
+ {
149
+ raw: -123456789n,
150
+ decimal: 0,
151
+ exact: '-123,456,789',
152
+ alphFormat: '-123,456,789.00',
153
+ tokenFormat: '-123,456,789.0'
154
+ },
155
+ {
156
+ raw: 0n,
157
+ decimal: 0,
158
+ exact: '0',
159
+ alphFormat: '0.00',
160
+ tokenFormat: '0.0'
161
+ }
162
+ ];
163
+ exports.tests1 = [
164
+ {
165
+ raw: '0',
166
+ decimals: 18,
167
+ amount: 0n
168
+ },
169
+ {
170
+ raw: '1.23',
171
+ decimals: 2,
172
+ amount: 123n
173
+ },
174
+ {
175
+ raw: '1',
176
+ decimals: 5,
177
+ amount: 100000n
178
+ },
179
+ {
180
+ raw: '1',
181
+ decimals: 18,
182
+ amount: 1000000000000000000n
183
+ },
184
+ {
185
+ raw: '1.23456789',
186
+ decimals: 18,
187
+ amount: 1234567890000000000n
188
+ }
189
+ ];