@exodus/bigint 3.0.0 → 4.0.0
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/CHANGELOG.md +68 -0
- package/LICENSE +7 -0
- package/README.md +4 -1
- package/package.json +13 -11
- package/src/bn.js +0 -158
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [4.0.0](https://github.com/ExodusMovement/hydra/compare/@exodus/bigint@3.0.1...@exodus/bigint@4.0.0) (2025-10-21)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
- remove /bn.js export (#14160)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- feat!: remove /bn.js export (#14160)
|
|
15
|
+
|
|
16
|
+
## [3.0.1](https://github.com/ExodusMovement/hydra/compare/@exodus/bigint@3.0.0...@exodus/bigint@3.0.1) (2024-11-01)
|
|
17
|
+
|
|
18
|
+
Re-licensed under MIT license.
|
|
19
|
+
|
|
20
|
+
### Reverts
|
|
21
|
+
|
|
22
|
+
- Revert "chore: disable lint/test for imported packages temporarily" ([b826a4a](https://github.com/ExodusMovement/hydra/commit/b826a4a49ddd77048958986a59b1eadf7430cc7e))
|
|
23
|
+
|
|
24
|
+
## [3.0.0](https://github.com/ExodusMovement/exodus-core/compare/@exodus/bigint@2.0.2...@exodus/bigint@3.0.0) (2024-07-06)
|
|
25
|
+
|
|
26
|
+
### ⚠ BREAKING CHANGES
|
|
27
|
+
|
|
28
|
+
- make bigint always native, switch it ESM (#1232)
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
- make bigint always native, switch it ESM ([#1232](https://github.com/ExodusMovement/exodus-core/issues/1232)) ([ffbeb9d](https://github.com/ExodusMovement/exodus-core/commit/ffbeb9d73dcb89d34667d6d7f8db14139dbb7b12))
|
|
33
|
+
|
|
34
|
+
## [2.0.2](https://github.com/ExodusMovement/exodus-core/compare/@exodus/bigint@2.0.1...@exodus/bigint@2.0.2) (2024-07-05)
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
- bigint is a CJS module ([#1218](https://github.com/ExodusMovement/exodus-core/issues/1218)) ([e482cf4](https://github.com/ExodusMovement/exodus-core/commit/e482cf44eff24f90919465de178bda94a6fc3f91))
|
|
39
|
+
|
|
40
|
+
## [2.0.1](https://github.com/ExodusMovement/exodus-core/compare/@exodus/bigint@2.0.0...@exodus/bigint@2.0.1) (2024-04-01)
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
- don't use reserved property 'name' ([#1135](https://github.com/ExodusMovement/exodus-core/issues/1135)) ([0c2e549](https://github.com/ExodusMovement/exodus-core/commit/0c2e54936e322c0f5eeeae4794b0d89be6896408))
|
|
45
|
+
|
|
46
|
+
# [2.0.0](https://github.com/ExodusMovement/exodus-core/compare/@exodus/bigint@1.1.1...@exodus/bigint@2.0.0) (2024-03-20)
|
|
47
|
+
|
|
48
|
+
### ⚠ BREAKING CHANGES
|
|
49
|
+
|
|
50
|
+
- remove ZERO and TEN BigIntWrapper constants ([#1111](https://github.com/ExodusMovement/exodus-core/issues/1111)) ([b6c8486a](https://github.com/ExodusMovement/exodus-core/commit/b6c8486acd388d7fac0139e062f9c9009fe76785))
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
- bigIntWrapper.isBigIntWrapper ([#1112](https://github.com/ExodusMovement/exodus-core/issues/1112)) ([11be301](https://github.com/ExodusMovement/exodus-core/commit/11be301a62c12b001cdbd027d14aa5f41fdcf885))
|
|
55
|
+
|
|
56
|
+
## [1.1.1](https://github.com/ExodusMovement/exodus-core/compare/@exodus/bigint@1.1.0...@exodus/bigint@1.1.1) (2024-03-08)
|
|
57
|
+
|
|
58
|
+
### Bug Fixes
|
|
59
|
+
|
|
60
|
+
- BigInt wrappers .ZERO, .TEN ([#1106](https://github.com/ExodusMovement/exodus-core/issues/1106)) ([c009d61](https://github.com/ExodusMovement/exodus-core/commit/c009d610c5f9648a6e3e1e7b4f0d5bc6a93936ea))
|
|
61
|
+
|
|
62
|
+
# [1.1.0](https://github.com/ExodusMovement/exodus-core/compare/@exodus/bigint@1.0.0...@exodus/bigint@1.1.0) (2024-02-08)
|
|
63
|
+
|
|
64
|
+
- refactor: no BigInt literals, to make uglify happy ([#1048](https://github.com/ExodusMovement/exodus-core/issues/1048)) ([aa162a2](https://github.com/ExodusMovement/exodus-core/commit/aa162a23b7f55cfcf3c9db3a1321742f39d1e9ec))
|
|
65
|
+
|
|
66
|
+
# 1.0.0 (2023-10-31)
|
|
67
|
+
|
|
68
|
+
Initial release
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2024 Exodus Movement, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# @exodus/bigint
|
|
2
2
|
|
|
3
|
-
Immutable API wrapper for
|
|
3
|
+
Immutable API wrapper for BigInt numbers.
|
|
4
|
+
|
|
5
|
+
> ⚠️ Warning:
|
|
6
|
+
> These days you should probably just use BigInt directly.
|
|
4
7
|
|
|
5
8
|
## Usage
|
|
6
9
|
|
package/package.json
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/bigint",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "bigint
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "bigint wrapper for native BigInt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": "Exodus Movement, Inc.",
|
|
8
|
-
"license": "
|
|
9
|
-
"homepage": "https://github.com/ExodusMovement/
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://github.com/ExodusMovement/hydra/tree/master/libraries/bigint",
|
|
10
10
|
"files": [
|
|
11
11
|
"src",
|
|
12
12
|
"!**/__tests__",
|
|
13
|
+
"CHANGELOG.md",
|
|
13
14
|
"README.md"
|
|
14
15
|
],
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"bn.js": "^4.11.0",
|
|
17
|
-
"lodash": "^4.17.11",
|
|
18
17
|
"minimalistic-assert": "^1.0.1"
|
|
19
18
|
},
|
|
20
19
|
"scripts": {
|
|
21
|
-
"test": "run -T jest",
|
|
22
|
-
"lint": "run -T eslint .
|
|
20
|
+
"test": "run -T exodus-test --jest",
|
|
21
|
+
"lint": "run -T eslint .",
|
|
23
22
|
"lint:fix": "yarn lint --fix"
|
|
24
23
|
},
|
|
25
24
|
"repository": {
|
|
26
25
|
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/ExodusMovement/
|
|
26
|
+
"url": "git+https://github.com/ExodusMovement/hydra.git"
|
|
28
27
|
},
|
|
29
28
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/ExodusMovement/
|
|
29
|
+
"url": "https://github.com/ExodusMovement/hydra/issues?q=is%3Aissue+is%3Aopen+label%3Abigint"
|
|
31
30
|
},
|
|
32
|
-
"
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"provenance": false
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "dd404f90b5ed03b47027726a301f7dcca5887ef7"
|
|
33
35
|
}
|
package/src/bn.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import assert from 'minimalistic-assert'
|
|
2
|
-
import BN from 'bn.js'
|
|
3
|
-
|
|
4
|
-
// TODO: calculator delegator should wrap/unwrap all BN instances
|
|
5
|
-
// so that callers never gett a raw BN instance back
|
|
6
|
-
|
|
7
|
-
const FACTORY_SYMBOL = Symbol('bn-wrapper')
|
|
8
|
-
|
|
9
|
-
const unwrap = (value) => (value instanceof Wrapper ? value.unwrap() : value)
|
|
10
|
-
|
|
11
|
-
const BI_ZERO = new BN(0)
|
|
12
|
-
|
|
13
|
-
export default class Wrapper {
|
|
14
|
-
static wrapperName = 'bn.js'
|
|
15
|
-
static isUnderlyingInstance(a) {
|
|
16
|
-
return BN.isBN(a)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static wrap(value, base = 10) {
|
|
20
|
-
if (!BN.isBN(value)) {
|
|
21
|
-
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
22
|
-
throw new TypeError(`Unsupported type: ${typeof value}`)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (base !== 10 && base !== 16) throw new TypeError(`Unsupported base: ${base}`)
|
|
26
|
-
|
|
27
|
-
value = new BN(value, base)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return new Wrapper(FACTORY_SYMBOL, value)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
__value__
|
|
34
|
-
|
|
35
|
-
constructor(factorySymbol, value) {
|
|
36
|
-
if (factorySymbol !== FACTORY_SYMBOL) throw new Error('use wrap() instead')
|
|
37
|
-
|
|
38
|
-
this.__value__ = value
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
unwrap() {
|
|
42
|
-
return this.__value__
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
add(value) {
|
|
46
|
-
return Wrapper.wrap(this.__value__.add(unwrap(value)))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
mutateAdd(value) {
|
|
50
|
-
this.__value__.iadd(unwrap(value))
|
|
51
|
-
return this
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
sub(value) {
|
|
55
|
-
return Wrapper.wrap(this.__value__.sub(unwrap(value)))
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
mutateSub(value) {
|
|
59
|
-
this.__value__.isub(unwrap(value))
|
|
60
|
-
return this
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
mul(value) {
|
|
64
|
-
return Wrapper.wrap(this.__value__.mul(unwrap(value)))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
mutateMul(value) {
|
|
68
|
-
this.__value__.imul(unwrap(value))
|
|
69
|
-
return this
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
div(value) {
|
|
73
|
-
return Wrapper.wrap(this.__value__.div(unwrap(value)))
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
mutateDiv(value) {
|
|
77
|
-
this.__value__.idivn(unwrap(value))
|
|
78
|
-
return this
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
mod(value) {
|
|
82
|
-
return Wrapper.wrap(this.__value__.mod(unwrap(value)))
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
pow(value) {
|
|
86
|
-
return Wrapper.wrap(this.__value__.pow(unwrap(value)))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
negate() {
|
|
90
|
-
return Wrapper.wrap(this.__value__.neg())
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
mutateNegate() {
|
|
94
|
-
return Wrapper.wrap(this.__value__.ineg())
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
abs() {
|
|
98
|
-
return this.isNegative() ? Wrapper.wrap(this.__value__.abs()) : this
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
mutateAbs() {
|
|
102
|
-
this.__value__.iabs()
|
|
103
|
-
return this
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
gte(value) {
|
|
107
|
-
return this.__value__.gte(unwrap(value))
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
gt(value) {
|
|
111
|
-
return this.__value__.gt(unwrap(value))
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
lte(value) {
|
|
115
|
-
return this.__value__.lte(unwrap(value))
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
lt(value) {
|
|
119
|
-
return this.__value__.lt(unwrap(value))
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
eq(value) {
|
|
123
|
-
return this.__value__.eq(unwrap(value))
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
isZero() {
|
|
127
|
-
return this.__value__.isZero()
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
isNegative() {
|
|
131
|
-
return this.__value__.isNeg()
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
isPositive() {
|
|
135
|
-
return this.__value__.gt(BI_ZERO)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
toNumber() {
|
|
139
|
-
return this.__value__.toNumber()
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
toString(base) {
|
|
143
|
-
assert(typeof base === 'number', 'expected number "base"')
|
|
144
|
-
return this.__value__.toString(base)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
toBaseBufferLE(length) {
|
|
148
|
-
return this.__value__.toBuffer('le', length)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
toBaseBufferBE(length) {
|
|
152
|
-
return this.__value__.toBuffer('be', length)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
isBigIntWrapper() {
|
|
156
|
-
return true
|
|
157
|
-
}
|
|
158
|
-
}
|