ripple-binary-codec 2.7.0-smartescrow.0 → 2.7.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/dist/enums/definitions.json +0 -75
- package/dist/enums/src/enums/definitions.json +0 -75
- package/dist/src/enums/definitions.json +0 -75
- package/dist/src/types/int-32.d.ts +17 -8
- package/dist/src/types/int-32.js +25 -11
- package/dist/src/types/int-32.js.map +1 -1
- package/dist/src/types/int.d.ts +38 -0
- package/dist/src/types/int.js +57 -0
- package/dist/src/types/int.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/int-32.d.ts +17 -8
- package/dist/types/int-32.js +25 -11
- package/dist/types/int-32.js.map +1 -1
- package/dist/types/int.d.ts +38 -0
- package/dist/types/int.js +57 -0
- package/dist/types/int.js.map +1 -0
- package/package.json +1 -1
- package/src/enums/definitions.json +0 -75
- package/src/types/int-32.ts +27 -12
- package/src/types/int.ts +75 -0
|
@@ -850,56 +850,6 @@
|
|
|
850
850
|
"type": "UInt32"
|
|
851
851
|
}
|
|
852
852
|
],
|
|
853
|
-
[
|
|
854
|
-
"ExtensionComputeLimit",
|
|
855
|
-
{
|
|
856
|
-
"isSerialized": true,
|
|
857
|
-
"isSigningField": true,
|
|
858
|
-
"isVLEncoded": false,
|
|
859
|
-
"nth": 69,
|
|
860
|
-
"type": "UInt32"
|
|
861
|
-
}
|
|
862
|
-
],
|
|
863
|
-
[
|
|
864
|
-
"ExtensionSizeLimit",
|
|
865
|
-
{
|
|
866
|
-
"isSerialized": true,
|
|
867
|
-
"isSigningField": true,
|
|
868
|
-
"isVLEncoded": false,
|
|
869
|
-
"nth": 70,
|
|
870
|
-
"type": "UInt32"
|
|
871
|
-
}
|
|
872
|
-
],
|
|
873
|
-
[
|
|
874
|
-
"GasPrice",
|
|
875
|
-
{
|
|
876
|
-
"isSerialized": true,
|
|
877
|
-
"isSigningField": true,
|
|
878
|
-
"isVLEncoded": false,
|
|
879
|
-
"nth": 71,
|
|
880
|
-
"type": "UInt32"
|
|
881
|
-
}
|
|
882
|
-
],
|
|
883
|
-
[
|
|
884
|
-
"ComputationAllowance",
|
|
885
|
-
{
|
|
886
|
-
"isSerialized": true,
|
|
887
|
-
"isSigningField": true,
|
|
888
|
-
"isVLEncoded": false,
|
|
889
|
-
"nth": 72,
|
|
890
|
-
"type": "UInt32"
|
|
891
|
-
}
|
|
892
|
-
],
|
|
893
|
-
[
|
|
894
|
-
"GasUsed",
|
|
895
|
-
{
|
|
896
|
-
"isSerialized": true,
|
|
897
|
-
"isSigningField": true,
|
|
898
|
-
"isVLEncoded": false,
|
|
899
|
-
"nth": 73,
|
|
900
|
-
"type": "UInt32"
|
|
901
|
-
}
|
|
902
|
-
],
|
|
903
853
|
[
|
|
904
854
|
"IndexNext",
|
|
905
855
|
{
|
|
@@ -2150,16 +2100,6 @@
|
|
|
2150
2100
|
"type": "Blob"
|
|
2151
2101
|
}
|
|
2152
2102
|
],
|
|
2153
|
-
[
|
|
2154
|
-
"FinishFunction",
|
|
2155
|
-
{
|
|
2156
|
-
"isSerialized": true,
|
|
2157
|
-
"isSigningField": true,
|
|
2158
|
-
"isVLEncoded": true,
|
|
2159
|
-
"nth": 32,
|
|
2160
|
-
"type": "Blob"
|
|
2161
|
-
}
|
|
2162
|
-
],
|
|
2163
2103
|
[
|
|
2164
2104
|
"Account",
|
|
2165
2105
|
{
|
|
@@ -2550,16 +2490,6 @@
|
|
|
2550
2490
|
"type": "Int32"
|
|
2551
2491
|
}
|
|
2552
2492
|
],
|
|
2553
|
-
[
|
|
2554
|
-
"WasmReturnCode",
|
|
2555
|
-
{
|
|
2556
|
-
"isSerialized": true,
|
|
2557
|
-
"isSigningField": true,
|
|
2558
|
-
"isVLEncoded": false,
|
|
2559
|
-
"nth": 2,
|
|
2560
|
-
"type": "Int32"
|
|
2561
|
-
}
|
|
2562
|
-
],
|
|
2563
2493
|
[
|
|
2564
2494
|
"TransactionMetaData",
|
|
2565
2495
|
{
|
|
@@ -3601,7 +3531,6 @@
|
|
|
3601
3531
|
"tecUNFUNDED_AMM": 162,
|
|
3602
3532
|
"tecUNFUNDED_OFFER": 103,
|
|
3603
3533
|
"tecUNFUNDED_PAYMENT": 104,
|
|
3604
|
-
"tecWASM_REJECTED": 199,
|
|
3605
3534
|
"tecWRONG_ASSET": 194,
|
|
3606
3535
|
"tecXCHAIN_ACCOUNT_CREATE_PAST": 181,
|
|
3607
3536
|
"tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 182,
|
|
@@ -3639,10 +3568,8 @@
|
|
|
3639
3568
|
"tefNOT_MULTI_SIGNING": -184,
|
|
3640
3569
|
"tefNO_AUTH_REQUIRED": -191,
|
|
3641
3570
|
"tefNO_TICKET": -180,
|
|
3642
|
-
"tefNO_WASM": -177,
|
|
3643
3571
|
"tefPAST_SEQ": -190,
|
|
3644
3572
|
"tefTOO_BIG": -181,
|
|
3645
|
-
"tefWASM_FIELD_NOT_INCLUDED": -176,
|
|
3646
3573
|
"tefWRONG_PRIOR": -189,
|
|
3647
3574
|
"telBAD_DOMAIN": -398,
|
|
3648
3575
|
"telBAD_PATH_COUNT": -397,
|
|
@@ -3688,7 +3615,6 @@
|
|
|
3688
3615
|
"temBAD_TICK_SIZE": -269,
|
|
3689
3616
|
"temBAD_TRANSFER_FEE": -251,
|
|
3690
3617
|
"temBAD_TRANSFER_RATE": -280,
|
|
3691
|
-
"temBAD_WASM": -249,
|
|
3692
3618
|
"temBAD_WEIGHT": -270,
|
|
3693
3619
|
"temCANNOT_PREAUTH_SELF": -267,
|
|
3694
3620
|
"temDISABLED": -273,
|
|
@@ -3704,7 +3630,6 @@
|
|
|
3704
3630
|
"temREDUNDANT": -275,
|
|
3705
3631
|
"temRIPPLE_EMPTY": -274,
|
|
3706
3632
|
"temSEQ_AND_TICKET": -263,
|
|
3707
|
-
"temTEMP_DISABLED": -248,
|
|
3708
3633
|
"temUNCERTAIN": -265,
|
|
3709
3634
|
"temUNKNOWN": -264,
|
|
3710
3635
|
"temXCHAIN_BAD_PROOF": -259,
|
|
@@ -850,56 +850,6 @@
|
|
|
850
850
|
"type": "UInt32"
|
|
851
851
|
}
|
|
852
852
|
],
|
|
853
|
-
[
|
|
854
|
-
"ExtensionComputeLimit",
|
|
855
|
-
{
|
|
856
|
-
"isSerialized": true,
|
|
857
|
-
"isSigningField": true,
|
|
858
|
-
"isVLEncoded": false,
|
|
859
|
-
"nth": 69,
|
|
860
|
-
"type": "UInt32"
|
|
861
|
-
}
|
|
862
|
-
],
|
|
863
|
-
[
|
|
864
|
-
"ExtensionSizeLimit",
|
|
865
|
-
{
|
|
866
|
-
"isSerialized": true,
|
|
867
|
-
"isSigningField": true,
|
|
868
|
-
"isVLEncoded": false,
|
|
869
|
-
"nth": 70,
|
|
870
|
-
"type": "UInt32"
|
|
871
|
-
}
|
|
872
|
-
],
|
|
873
|
-
[
|
|
874
|
-
"GasPrice",
|
|
875
|
-
{
|
|
876
|
-
"isSerialized": true,
|
|
877
|
-
"isSigningField": true,
|
|
878
|
-
"isVLEncoded": false,
|
|
879
|
-
"nth": 71,
|
|
880
|
-
"type": "UInt32"
|
|
881
|
-
}
|
|
882
|
-
],
|
|
883
|
-
[
|
|
884
|
-
"ComputationAllowance",
|
|
885
|
-
{
|
|
886
|
-
"isSerialized": true,
|
|
887
|
-
"isSigningField": true,
|
|
888
|
-
"isVLEncoded": false,
|
|
889
|
-
"nth": 72,
|
|
890
|
-
"type": "UInt32"
|
|
891
|
-
}
|
|
892
|
-
],
|
|
893
|
-
[
|
|
894
|
-
"GasUsed",
|
|
895
|
-
{
|
|
896
|
-
"isSerialized": true,
|
|
897
|
-
"isSigningField": true,
|
|
898
|
-
"isVLEncoded": false,
|
|
899
|
-
"nth": 73,
|
|
900
|
-
"type": "UInt32"
|
|
901
|
-
}
|
|
902
|
-
],
|
|
903
853
|
[
|
|
904
854
|
"IndexNext",
|
|
905
855
|
{
|
|
@@ -2150,16 +2100,6 @@
|
|
|
2150
2100
|
"type": "Blob"
|
|
2151
2101
|
}
|
|
2152
2102
|
],
|
|
2153
|
-
[
|
|
2154
|
-
"FinishFunction",
|
|
2155
|
-
{
|
|
2156
|
-
"isSerialized": true,
|
|
2157
|
-
"isSigningField": true,
|
|
2158
|
-
"isVLEncoded": true,
|
|
2159
|
-
"nth": 32,
|
|
2160
|
-
"type": "Blob"
|
|
2161
|
-
}
|
|
2162
|
-
],
|
|
2163
2103
|
[
|
|
2164
2104
|
"Account",
|
|
2165
2105
|
{
|
|
@@ -2550,16 +2490,6 @@
|
|
|
2550
2490
|
"type": "Int32"
|
|
2551
2491
|
}
|
|
2552
2492
|
],
|
|
2553
|
-
[
|
|
2554
|
-
"WasmReturnCode",
|
|
2555
|
-
{
|
|
2556
|
-
"isSerialized": true,
|
|
2557
|
-
"isSigningField": true,
|
|
2558
|
-
"isVLEncoded": false,
|
|
2559
|
-
"nth": 2,
|
|
2560
|
-
"type": "Int32"
|
|
2561
|
-
}
|
|
2562
|
-
],
|
|
2563
2493
|
[
|
|
2564
2494
|
"TransactionMetaData",
|
|
2565
2495
|
{
|
|
@@ -3601,7 +3531,6 @@
|
|
|
3601
3531
|
"tecUNFUNDED_AMM": 162,
|
|
3602
3532
|
"tecUNFUNDED_OFFER": 103,
|
|
3603
3533
|
"tecUNFUNDED_PAYMENT": 104,
|
|
3604
|
-
"tecWASM_REJECTED": 199,
|
|
3605
3534
|
"tecWRONG_ASSET": 194,
|
|
3606
3535
|
"tecXCHAIN_ACCOUNT_CREATE_PAST": 181,
|
|
3607
3536
|
"tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 182,
|
|
@@ -3640,10 +3569,8 @@
|
|
|
3640
3569
|
"tefNOT_MULTI_SIGNING": -184,
|
|
3641
3570
|
"tefNO_AUTH_REQUIRED": -191,
|
|
3642
3571
|
"tefNO_TICKET": -180,
|
|
3643
|
-
"tefNO_WASM": -177,
|
|
3644
3572
|
"tefPAST_SEQ": -190,
|
|
3645
3573
|
"tefTOO_BIG": -181,
|
|
3646
|
-
"tefWASM_FIELD_NOT_INCLUDED": -176,
|
|
3647
3574
|
"tefWRONG_PRIOR": -189,
|
|
3648
3575
|
|
|
3649
3576
|
"telBAD_DOMAIN": -398,
|
|
@@ -3691,7 +3618,6 @@
|
|
|
3691
3618
|
"temBAD_TICK_SIZE": -269,
|
|
3692
3619
|
"temBAD_TRANSFER_FEE": -251,
|
|
3693
3620
|
"temBAD_TRANSFER_RATE": -280,
|
|
3694
|
-
"temBAD_WASM": -249,
|
|
3695
3621
|
"temBAD_WEIGHT": -270,
|
|
3696
3622
|
"temCANNOT_PREAUTH_SELF": -267,
|
|
3697
3623
|
"temDISABLED": -273,
|
|
@@ -3707,7 +3633,6 @@
|
|
|
3707
3633
|
"temREDUNDANT": -275,
|
|
3708
3634
|
"temRIPPLE_EMPTY": -274,
|
|
3709
3635
|
"temSEQ_AND_TICKET": -263,
|
|
3710
|
-
"temTEMP_DISABLED": -248,
|
|
3711
3636
|
"temUNCERTAIN": -265,
|
|
3712
3637
|
"temUNKNOWN": -264,
|
|
3713
3638
|
"temXCHAIN_BAD_PROOF": -259,
|
|
@@ -850,56 +850,6 @@
|
|
|
850
850
|
"type": "UInt32"
|
|
851
851
|
}
|
|
852
852
|
],
|
|
853
|
-
[
|
|
854
|
-
"ExtensionComputeLimit",
|
|
855
|
-
{
|
|
856
|
-
"isSerialized": true,
|
|
857
|
-
"isSigningField": true,
|
|
858
|
-
"isVLEncoded": false,
|
|
859
|
-
"nth": 69,
|
|
860
|
-
"type": "UInt32"
|
|
861
|
-
}
|
|
862
|
-
],
|
|
863
|
-
[
|
|
864
|
-
"ExtensionSizeLimit",
|
|
865
|
-
{
|
|
866
|
-
"isSerialized": true,
|
|
867
|
-
"isSigningField": true,
|
|
868
|
-
"isVLEncoded": false,
|
|
869
|
-
"nth": 70,
|
|
870
|
-
"type": "UInt32"
|
|
871
|
-
}
|
|
872
|
-
],
|
|
873
|
-
[
|
|
874
|
-
"GasPrice",
|
|
875
|
-
{
|
|
876
|
-
"isSerialized": true,
|
|
877
|
-
"isSigningField": true,
|
|
878
|
-
"isVLEncoded": false,
|
|
879
|
-
"nth": 71,
|
|
880
|
-
"type": "UInt32"
|
|
881
|
-
}
|
|
882
|
-
],
|
|
883
|
-
[
|
|
884
|
-
"ComputationAllowance",
|
|
885
|
-
{
|
|
886
|
-
"isSerialized": true,
|
|
887
|
-
"isSigningField": true,
|
|
888
|
-
"isVLEncoded": false,
|
|
889
|
-
"nth": 72,
|
|
890
|
-
"type": "UInt32"
|
|
891
|
-
}
|
|
892
|
-
],
|
|
893
|
-
[
|
|
894
|
-
"GasUsed",
|
|
895
|
-
{
|
|
896
|
-
"isSerialized": true,
|
|
897
|
-
"isSigningField": true,
|
|
898
|
-
"isVLEncoded": false,
|
|
899
|
-
"nth": 73,
|
|
900
|
-
"type": "UInt32"
|
|
901
|
-
}
|
|
902
|
-
],
|
|
903
853
|
[
|
|
904
854
|
"IndexNext",
|
|
905
855
|
{
|
|
@@ -2150,16 +2100,6 @@
|
|
|
2150
2100
|
"type": "Blob"
|
|
2151
2101
|
}
|
|
2152
2102
|
],
|
|
2153
|
-
[
|
|
2154
|
-
"FinishFunction",
|
|
2155
|
-
{
|
|
2156
|
-
"isSerialized": true,
|
|
2157
|
-
"isSigningField": true,
|
|
2158
|
-
"isVLEncoded": true,
|
|
2159
|
-
"nth": 32,
|
|
2160
|
-
"type": "Blob"
|
|
2161
|
-
}
|
|
2162
|
-
],
|
|
2163
2103
|
[
|
|
2164
2104
|
"Account",
|
|
2165
2105
|
{
|
|
@@ -2550,16 +2490,6 @@
|
|
|
2550
2490
|
"type": "Int32"
|
|
2551
2491
|
}
|
|
2552
2492
|
],
|
|
2553
|
-
[
|
|
2554
|
-
"WasmReturnCode",
|
|
2555
|
-
{
|
|
2556
|
-
"isSerialized": true,
|
|
2557
|
-
"isSigningField": true,
|
|
2558
|
-
"isVLEncoded": false,
|
|
2559
|
-
"nth": 2,
|
|
2560
|
-
"type": "Int32"
|
|
2561
|
-
}
|
|
2562
|
-
],
|
|
2563
2493
|
[
|
|
2564
2494
|
"TransactionMetaData",
|
|
2565
2495
|
{
|
|
@@ -3601,7 +3531,6 @@
|
|
|
3601
3531
|
"tecUNFUNDED_AMM": 162,
|
|
3602
3532
|
"tecUNFUNDED_OFFER": 103,
|
|
3603
3533
|
"tecUNFUNDED_PAYMENT": 104,
|
|
3604
|
-
"tecWASM_REJECTED": 199,
|
|
3605
3534
|
"tecWRONG_ASSET": 194,
|
|
3606
3535
|
"tecXCHAIN_ACCOUNT_CREATE_PAST": 181,
|
|
3607
3536
|
"tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 182,
|
|
@@ -3639,10 +3568,8 @@
|
|
|
3639
3568
|
"tefNOT_MULTI_SIGNING": -184,
|
|
3640
3569
|
"tefNO_AUTH_REQUIRED": -191,
|
|
3641
3570
|
"tefNO_TICKET": -180,
|
|
3642
|
-
"tefNO_WASM": -177,
|
|
3643
3571
|
"tefPAST_SEQ": -190,
|
|
3644
3572
|
"tefTOO_BIG": -181,
|
|
3645
|
-
"tefWASM_FIELD_NOT_INCLUDED": -176,
|
|
3646
3573
|
"tefWRONG_PRIOR": -189,
|
|
3647
3574
|
"telBAD_DOMAIN": -398,
|
|
3648
3575
|
"telBAD_PATH_COUNT": -397,
|
|
@@ -3688,7 +3615,6 @@
|
|
|
3688
3615
|
"temBAD_TICK_SIZE": -269,
|
|
3689
3616
|
"temBAD_TRANSFER_FEE": -251,
|
|
3690
3617
|
"temBAD_TRANSFER_RATE": -280,
|
|
3691
|
-
"temBAD_WASM": -249,
|
|
3692
3618
|
"temBAD_WEIGHT": -270,
|
|
3693
3619
|
"temCANNOT_PREAUTH_SELF": -267,
|
|
3694
3620
|
"temDISABLED": -273,
|
|
@@ -3704,7 +3630,6 @@
|
|
|
3704
3630
|
"temREDUNDANT": -275,
|
|
3705
3631
|
"temRIPPLE_EMPTY": -274,
|
|
3706
3632
|
"temSEQ_AND_TICKET": -263,
|
|
3707
|
-
"temTEMP_DISABLED": -248,
|
|
3708
3633
|
"temUNCERTAIN": -265,
|
|
3709
3634
|
"temUNKNOWN": -264,
|
|
3710
3635
|
"temXCHAIN_BAD_PROOF": -259,
|
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Int } from './int';
|
|
2
2
|
import { BinaryParser } from '../serdes/binary-parser';
|
|
3
3
|
/**
|
|
4
|
-
* Derived Int class for serializing/deserializing 32
|
|
4
|
+
* Derived Int class for serializing/deserializing signed 32-bit integers.
|
|
5
5
|
*/
|
|
6
|
-
declare class Int32 extends
|
|
6
|
+
declare class Int32 extends Int {
|
|
7
7
|
protected static readonly width: number;
|
|
8
8
|
static readonly defaultInt32: Int32;
|
|
9
|
+
static readonly MIN_VALUE: number;
|
|
10
|
+
static readonly MAX_VALUE: number;
|
|
9
11
|
constructor(bytes: Uint8Array);
|
|
10
|
-
static fromParser(parser: BinaryParser): UInt;
|
|
11
12
|
/**
|
|
12
|
-
* Construct
|
|
13
|
+
* Construct an Int32 from a BinaryParser
|
|
13
14
|
*
|
|
14
|
-
* @param
|
|
15
|
+
* @param parser BinaryParser to read Int32 from
|
|
16
|
+
* @returns An Int32 object
|
|
17
|
+
*/
|
|
18
|
+
static fromParser(parser: BinaryParser): Int;
|
|
19
|
+
/**
|
|
20
|
+
* Construct an Int32 object from a number or string
|
|
21
|
+
*
|
|
22
|
+
* @param val Int32 object, number, or string
|
|
23
|
+
* @returns An Int32 object
|
|
15
24
|
*/
|
|
16
25
|
static from<T extends Int32 | number | string>(val: T): Int32;
|
|
17
26
|
/**
|
|
18
|
-
*
|
|
27
|
+
* Get the value of the Int32 object
|
|
19
28
|
*
|
|
20
|
-
* @returns the
|
|
29
|
+
* @returns the signed 32-bit integer represented by this.bytes
|
|
21
30
|
*/
|
|
22
31
|
valueOf(): number;
|
|
23
32
|
}
|
package/dist/src/types/int-32.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Int32 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const int_1 = require("./int");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
/**
|
|
7
|
-
* Derived Int class for serializing/deserializing 32
|
|
7
|
+
* Derived Int class for serializing/deserializing signed 32-bit integers.
|
|
8
8
|
*/
|
|
9
|
-
class Int32 extends
|
|
9
|
+
class Int32 extends int_1.Int {
|
|
10
10
|
constructor(bytes) {
|
|
11
11
|
super(bytes !== null && bytes !== void 0 ? bytes : Int32.defaultInt32.bytes);
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Construct an Int32 from a BinaryParser
|
|
15
|
+
*
|
|
16
|
+
* @param parser BinaryParser to read Int32 from
|
|
17
|
+
* @returns An Int32 object
|
|
18
|
+
*/
|
|
13
19
|
static fromParser(parser) {
|
|
14
20
|
return new Int32(parser.read(Int32.width));
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
|
-
* Construct
|
|
23
|
+
* Construct an Int32 object from a number or string
|
|
18
24
|
*
|
|
19
|
-
* @param val Int32 object or
|
|
25
|
+
* @param val Int32 object, number, or string
|
|
26
|
+
* @returns An Int32 object
|
|
20
27
|
*/
|
|
21
28
|
static from(val) {
|
|
22
29
|
if (val instanceof Int32) {
|
|
@@ -24,27 +31,34 @@ class Int32 extends uint_1.UInt {
|
|
|
24
31
|
}
|
|
25
32
|
const buf = new Uint8Array(Int32.width);
|
|
26
33
|
if (typeof val === 'string') {
|
|
27
|
-
const num = Number
|
|
34
|
+
const num = Number(val);
|
|
35
|
+
if (!Number.isFinite(num) || !Number.isInteger(num)) {
|
|
36
|
+
throw new Error(`Cannot construct Int32 from string: ${val}`);
|
|
37
|
+
}
|
|
38
|
+
Int32.checkIntRange('Int32', num, Int32.MIN_VALUE, Int32.MAX_VALUE);
|
|
28
39
|
(0, utils_1.writeInt32BE)(buf, num, 0);
|
|
29
40
|
return new Int32(buf);
|
|
30
41
|
}
|
|
31
|
-
if (typeof val === 'number') {
|
|
32
|
-
Int32.
|
|
42
|
+
if (typeof val === 'number' && Number.isInteger(val)) {
|
|
43
|
+
Int32.checkIntRange('Int32', val, Int32.MIN_VALUE, Int32.MAX_VALUE);
|
|
33
44
|
(0, utils_1.writeInt32BE)(buf, val, 0);
|
|
34
45
|
return new Int32(buf);
|
|
35
46
|
}
|
|
36
47
|
throw new Error('Cannot construct Int32 from given value');
|
|
37
48
|
}
|
|
38
49
|
/**
|
|
39
|
-
*
|
|
50
|
+
* Get the value of the Int32 object
|
|
40
51
|
*
|
|
41
|
-
* @returns the
|
|
52
|
+
* @returns the signed 32-bit integer represented by this.bytes
|
|
42
53
|
*/
|
|
43
54
|
valueOf() {
|
|
44
55
|
return (0, utils_1.readInt32BE)(this.bytes, 0);
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
exports.Int32 = Int32;
|
|
48
|
-
Int32.width = 32 / 8; // 4
|
|
59
|
+
Int32.width = 32 / 8; // 4 bytes
|
|
49
60
|
Int32.defaultInt32 = new Int32(new Uint8Array(Int32.width));
|
|
61
|
+
// Signed 32-bit integer range
|
|
62
|
+
Int32.MIN_VALUE = -2147483648; // -2^31
|
|
63
|
+
Int32.MAX_VALUE = 2147483647; // 2^31 - 1
|
|
50
64
|
//# sourceMappingURL=int-32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int-32.js","sourceRoot":"","sources":["../../../src/types/int-32.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"int-32.js","sourceRoot":"","sources":["../../../src/types/int-32.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAE3B,oCAAoD;AAEpD;;GAEG;AACH,MAAM,KAAM,SAAQ,SAAG;IAQrB,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,MAAoB;QACpC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAoC,GAAM;QACnD,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,OAAO,GAAG,CAAA;SACX;QAED,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAEvC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;YACvB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;gBACnD,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,EAAE,CAAC,CAAA;aAC9D;YACD,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;YACnE,IAAA,oBAAY,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;SACtB;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YACpD,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;YACnE,IAAA,oBAAY,EAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;YACzB,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;SACtB;QAED,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;IAC5D,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAA,mBAAW,EAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACnC,CAAC;;AAGM,sBAAK;AA/Dc,WAAK,GAAW,EAAE,GAAG,CAAC,CAAA,CAAC,UAAU;AAC3C,kBAAY,GAAU,IAAI,KAAK,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AAE5E,8BAA8B;AACd,eAAS,GAAW,CAAC,UAAU,CAAA,CAAC,QAAQ;AACxC,eAAS,GAAW,UAAU,CAAA,CAAC,WAAW"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Comparable } from './serialized-type';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for serializing and deserializing signed integers.
|
|
4
|
+
*/
|
|
5
|
+
declare abstract class Int extends Comparable<Int | number> {
|
|
6
|
+
protected static width: number;
|
|
7
|
+
constructor(bytes: Uint8Array);
|
|
8
|
+
/**
|
|
9
|
+
* Overload of compareTo for Comparable
|
|
10
|
+
*
|
|
11
|
+
* @param other other Int to compare this to
|
|
12
|
+
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
13
|
+
*/
|
|
14
|
+
compareTo(other: Int | number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Convert an Int object to JSON
|
|
17
|
+
*
|
|
18
|
+
* @returns number or string represented by this.bytes
|
|
19
|
+
*/
|
|
20
|
+
toJSON(): number | string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the value of the Int represented by this.bytes
|
|
23
|
+
*
|
|
24
|
+
* @returns the value
|
|
25
|
+
*/
|
|
26
|
+
abstract valueOf(): number | bigint;
|
|
27
|
+
/**
|
|
28
|
+
* Validate that a number is within the specified signed integer range
|
|
29
|
+
*
|
|
30
|
+
* @param typeName The name of the type (for error messages)
|
|
31
|
+
* @param val The number to validate
|
|
32
|
+
* @param min The minimum allowed value
|
|
33
|
+
* @param max The maximum allowed value
|
|
34
|
+
* @throws Error if the value is out of range
|
|
35
|
+
*/
|
|
36
|
+
static checkIntRange(typeName: string, val: number | bigint, min: number | bigint, max: number | bigint): void;
|
|
37
|
+
}
|
|
38
|
+
export { Int };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Int = void 0;
|
|
4
|
+
const serialized_type_1 = require("./serialized-type");
|
|
5
|
+
/**
|
|
6
|
+
* Compare numbers and bigInts n1 and n2
|
|
7
|
+
*
|
|
8
|
+
* @param n1 First object to compare
|
|
9
|
+
* @param n2 Second object to compare
|
|
10
|
+
* @returns -1, 0, or 1, depending on how the two objects compare
|
|
11
|
+
*/
|
|
12
|
+
function compare(n1, n2) {
|
|
13
|
+
return n1 < n2 ? -1 : n1 == n2 ? 0 : 1;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Base class for serializing and deserializing signed integers.
|
|
17
|
+
*/
|
|
18
|
+
class Int extends serialized_type_1.Comparable {
|
|
19
|
+
constructor(bytes) {
|
|
20
|
+
super(bytes);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Overload of compareTo for Comparable
|
|
24
|
+
*
|
|
25
|
+
* @param other other Int to compare this to
|
|
26
|
+
* @returns -1, 0, or 1 depending on how the objects relate to each other
|
|
27
|
+
*/
|
|
28
|
+
compareTo(other) {
|
|
29
|
+
return compare(this.valueOf(), other.valueOf());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert an Int object to JSON
|
|
33
|
+
*
|
|
34
|
+
* @returns number or string represented by this.bytes
|
|
35
|
+
*/
|
|
36
|
+
toJSON() {
|
|
37
|
+
const val = this.valueOf();
|
|
38
|
+
return typeof val === 'number' ? val : val.toString();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Validate that a number is within the specified signed integer range
|
|
42
|
+
*
|
|
43
|
+
* @param typeName The name of the type (for error messages)
|
|
44
|
+
* @param val The number to validate
|
|
45
|
+
* @param min The minimum allowed value
|
|
46
|
+
* @param max The maximum allowed value
|
|
47
|
+
* @throws Error if the value is out of range
|
|
48
|
+
*/
|
|
49
|
+
// eslint-disable-next-line max-params -- for error clarity in browsers
|
|
50
|
+
static checkIntRange(typeName, val, min, max) {
|
|
51
|
+
if (val < min || val > max) {
|
|
52
|
+
throw new Error(`Invalid ${typeName}: ${val} must be >= ${min} and <= ${max}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.Int = Int;
|
|
57
|
+
//# sourceMappingURL=int.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"int.js","sourceRoot":"","sources":["../../../src/types/int.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,EAAmB,EAAE,EAAmB;IACvD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACxC,CAAC;AAED;;GAEG;AACH,MAAe,GAAI,SAAQ,4BAAwB;IAGjD,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,KAAmB;QAC3B,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAC1B,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IACvD,CAAC;IASD;;;;;;;;OAQG;IACH,uEAAuE;IACvE,MAAM,CAAC,aAAa,CAClB,QAAgB,EAChB,GAAoB,EACpB,GAAoB,EACpB,GAAoB;QAEpB,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,EAAE;YAC1B,MAAM,IAAI,KAAK,CACb,WAAW,QAAQ,KAAK,GAAG,eAAe,GAAG,WAAW,GAAG,EAAE,CAC9D,CAAA;SACF;IACH,CAAC;CACF;AAEQ,kBAAG"}
|