ripple-binary-codec 1.5.0-beta.2 → 1.5.0-beta.4

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 (120) hide show
  1. package/dist/binary.d.ts +23 -7
  2. package/dist/binary.js +54 -33
  3. package/dist/binary.js.map +1 -1
  4. package/dist/coretypes.d.ts +2 -2
  5. package/dist/coretypes.js +33 -9
  6. package/dist/coretypes.js.map +1 -1
  7. package/dist/enums/bytes.d.ts +26 -0
  8. package/dist/enums/bytes.js +64 -0
  9. package/dist/enums/bytes.js.map +1 -0
  10. package/dist/enums/constants.d.ts +4 -0
  11. package/dist/enums/constants.js +8 -0
  12. package/dist/enums/constants.js.map +1 -0
  13. package/dist/enums/definitions.json +108 -138
  14. package/dist/enums/field.d.ts +29 -0
  15. package/dist/enums/field.js +59 -0
  16. package/dist/enums/field.js.map +1 -0
  17. package/dist/enums/index.d.ts +12 -48
  18. package/dist/enums/index.js +42 -124
  19. package/dist/enums/index.js.map +1 -1
  20. package/dist/enums/src/enums/definitions.json +108 -138
  21. package/dist/enums/utils-renumber.js +14 -14
  22. package/dist/enums/utils-renumber.js.map +1 -1
  23. package/dist/enums/xrpl-definitions-base.d.ts +44 -0
  24. package/dist/enums/xrpl-definitions-base.js +59 -0
  25. package/dist/enums/xrpl-definitions-base.js.map +1 -0
  26. package/dist/enums/xrpl-definitions.d.ts +21 -0
  27. package/dist/enums/xrpl-definitions.js +29 -0
  28. package/dist/enums/xrpl-definitions.js.map +1 -0
  29. package/dist/hash-prefixes.js +3 -3
  30. package/dist/hash-prefixes.js.map +1 -1
  31. package/dist/hashes.js +21 -43
  32. package/dist/hashes.js.map +1 -1
  33. package/dist/index.d.ts +14 -16
  34. package/dist/index.js +62 -24
  35. package/dist/index.js.map +1 -1
  36. package/dist/ledger-hashes.d.ts +5 -2
  37. package/dist/ledger-hashes.js +54 -29
  38. package/dist/ledger-hashes.js.map +1 -1
  39. package/dist/quality.js +18 -21
  40. package/dist/quality.js.map +1 -1
  41. package/dist/serdes/binary-parser.d.ts +6 -3
  42. package/dist/serdes/binary-parser.js +82 -57
  43. package/dist/serdes/binary-parser.js.map +1 -1
  44. package/dist/serdes/binary-serializer.d.ts +1 -1
  45. package/dist/serdes/binary-serializer.js +59 -40
  46. package/dist/serdes/binary-serializer.js.map +1 -1
  47. package/dist/shamap.js +72 -98
  48. package/dist/shamap.js.map +1 -1
  49. package/dist/types/account-id.js +18 -35
  50. package/dist/types/account-id.js.map +1 -1
  51. package/dist/types/amount.js +71 -88
  52. package/dist/types/amount.js.map +1 -1
  53. package/dist/types/blob.js +10 -27
  54. package/dist/types/blob.js.map +1 -1
  55. package/dist/types/currency.js +26 -44
  56. package/dist/types/currency.js.map +1 -1
  57. package/dist/types/hash-128.d.ts +6 -0
  58. package/dist/types/hash-128.js +23 -25
  59. package/dist/types/hash-128.js.map +1 -1
  60. package/dist/types/hash-160.js +8 -25
  61. package/dist/types/hash-160.js.map +1 -1
  62. package/dist/types/hash-256.js +8 -25
  63. package/dist/types/hash-256.js.map +1 -1
  64. package/dist/types/hash.js +20 -38
  65. package/dist/types/hash.js.map +1 -1
  66. package/dist/types/index.d.ts +3 -24
  67. package/dist/types/index.js +39 -28
  68. package/dist/types/index.js.map +1 -1
  69. package/dist/types/issue.js +24 -41
  70. package/dist/types/issue.js.map +1 -1
  71. package/dist/types/path-set.js +57 -87
  72. package/dist/types/path-set.js.map +1 -1
  73. package/dist/types/serialized-type.d.ts +3 -3
  74. package/dist/types/serialized-type.js +35 -56
  75. package/dist/types/serialized-type.js.map +1 -1
  76. package/dist/types/st-array.js +26 -46
  77. package/dist/types/st-array.js.map +1 -1
  78. package/dist/types/st-object.d.ts +6 -3
  79. package/dist/types/st-object.js +52 -74
  80. package/dist/types/st-object.js.map +1 -1
  81. package/dist/types/uint-16.js +15 -32
  82. package/dist/types/uint-16.js.map +1 -1
  83. package/dist/types/uint-32.js +16 -33
  84. package/dist/types/uint-32.js.map +1 -1
  85. package/dist/types/uint-64.d.ts +1 -1
  86. package/dist/types/uint-64.js +30 -47
  87. package/dist/types/uint-64.js.map +1 -1
  88. package/dist/types/uint-8.js +15 -32
  89. package/dist/types/uint-8.js.map +1 -1
  90. package/dist/types/uint.d.ts +1 -1
  91. package/dist/types/uint.js +10 -27
  92. package/dist/types/uint.js.map +1 -1
  93. package/dist/types/vector-256.js +23 -40
  94. package/dist/types/vector-256.js.map +1 -1
  95. package/dist/types/xchain-bridge.js +44 -61
  96. package/dist/types/xchain-bridge.js.map +1 -1
  97. package/package.json +7 -7
  98. package/test/amount.test.js +1 -1
  99. package/test/binary-json.test.js +1 -1
  100. package/test/binary-parser.test.js +4 -4
  101. package/test/binary-serializer.test.js +3 -3
  102. package/test/definitions.test.js +100 -0
  103. package/test/fixtures/codec-fixtures.json +136 -196
  104. package/test/hash.test.js +28 -2
  105. package/test/ledger.test.js +1 -1
  106. package/test/lower-case-hex.test.js +1 -1
  107. package/test/pseudo-transaction.test.js +1 -1
  108. package/test/quality.test.js +1 -1
  109. package/test/shamap.test.js +3 -3
  110. package/test/signing-data-encoding.test.js +128 -3
  111. package/test/tx-encode-decode.test.js +1 -1
  112. package/test/types.test.js +2 -2
  113. package/test/uint.test.js +2 -2
  114. package/test/x-address.test.js +1 -1
  115. package/dist/types/issued-currency.d.ts +0 -46
  116. package/dist/types/issued-currency.js +0 -108
  117. package/dist/types/issued-currency.js.map +0 -1
  118. package/dist/types/xchain-attestation-batch.d.ts +0 -44
  119. package/dist/types/xchain-attestation-batch.js +0 -107
  120. package/dist/types/xchain-attestation-batch.js.map +0 -1
@@ -23,7 +23,6 @@
23
23
  "UInt512": 23,
24
24
  "Issue": 24,
25
25
  "XChainBridge": 25,
26
- "XChainAttestationBatch": 26,
27
26
  "Transaction": 10001,
28
27
  "LedgerEntry": 10002,
29
28
  "Validation": 10003,
@@ -298,6 +297,16 @@
298
297
  "type": "UInt16"
299
298
  }
300
299
  ],
300
+ [
301
+ "DiscountedFee",
302
+ {
303
+ "nth": 6,
304
+ "isVLEncoded": false,
305
+ "isSerialized": true,
306
+ "isSigningField": true,
307
+ "type": "UInt16"
308
+ }
309
+ ],
301
310
  [
302
311
  "Version",
303
312
  {
@@ -348,6 +357,16 @@
348
357
  "type": "UInt16"
349
358
  }
350
359
  ],
360
+ [
361
+ "NetworkID",
362
+ {
363
+ "nth": 1,
364
+ "isVLEncoded": false,
365
+ "isSerialized": true,
366
+ "isSigningField": true,
367
+ "type": "UInt32"
368
+ }
369
+ ],
351
370
  [
352
371
  "Flags",
353
372
  {
@@ -789,7 +808,7 @@
789
808
  }
790
809
  ],
791
810
  [
792
- "VoteWeight",
811
+ "LockCount",
793
812
  {
794
813
  "nth": 47,
795
814
  "isVLEncoded": false,
@@ -799,7 +818,7 @@
799
818
  }
800
819
  ],
801
820
  [
802
- "DiscountedFee",
821
+ "VoteWeight",
803
822
  {
804
823
  "nth": 48,
805
824
  "isVLEncoded": false,
@@ -808,6 +827,16 @@
808
827
  "type": "UInt32"
809
828
  }
810
829
  ],
830
+ [
831
+ "FirstNFTokenSequence",
832
+ {
833
+ "nth": 50,
834
+ "isVLEncoded": false,
835
+ "isSerialized": true,
836
+ "isSigningField": true,
837
+ "type": "UInt32"
838
+ }
839
+ ],
811
840
  [
812
841
  "IndexNext",
813
842
  {
@@ -1539,9 +1568,9 @@
1539
1568
  }
1540
1569
  ],
1541
1570
  [
1542
- "LPTokenOut",
1571
+ "LockedBalance",
1543
1572
  {
1544
- "nth": 20,
1573
+ "nth": 21,
1545
1574
  "isVLEncoded": false,
1546
1575
  "isSerialized": true,
1547
1576
  "isSigningField": true,
@@ -1549,9 +1578,9 @@
1549
1578
  }
1550
1579
  ],
1551
1580
  [
1552
- "LPTokenIn",
1581
+ "BaseFeeDrops",
1553
1582
  {
1554
- "nth": 21,
1583
+ "nth": 22,
1555
1584
  "isVLEncoded": false,
1556
1585
  "isSerialized": true,
1557
1586
  "isSigningField": true,
@@ -1559,9 +1588,9 @@
1559
1588
  }
1560
1589
  ],
1561
1590
  [
1562
- "EPrice",
1591
+ "ReserveBaseDrops",
1563
1592
  {
1564
- "nth": 22,
1593
+ "nth": 23,
1565
1594
  "isVLEncoded": false,
1566
1595
  "isSerialized": true,
1567
1596
  "isSigningField": true,
@@ -1569,9 +1598,9 @@
1569
1598
  }
1570
1599
  ],
1571
1600
  [
1572
- "Price",
1601
+ "ReserveIncrementDrops",
1573
1602
  {
1574
- "nth": 23,
1603
+ "nth": 24,
1575
1604
  "isVLEncoded": false,
1576
1605
  "isSerialized": true,
1577
1606
  "isSigningField": true,
@@ -1579,9 +1608,9 @@
1579
1608
  }
1580
1609
  ],
1581
1610
  [
1582
- "LPTokenBalance",
1611
+ "LPTokenOut",
1583
1612
  {
1584
- "nth": 24,
1613
+ "nth": 25,
1585
1614
  "isVLEncoded": false,
1586
1615
  "isSerialized": true,
1587
1616
  "isSigningField": true,
@@ -1589,7 +1618,27 @@
1589
1618
  }
1590
1619
  ],
1591
1620
  [
1592
- "XChainFee",
1621
+ "LPTokenIn",
1622
+ {
1623
+ "nth": 26,
1624
+ "isVLEncoded": false,
1625
+ "isSerialized": true,
1626
+ "isSigningField": true,
1627
+ "type": "Amount"
1628
+ }
1629
+ ],
1630
+ [
1631
+ "EPrice",
1632
+ {
1633
+ "nth": 27,
1634
+ "isVLEncoded": false,
1635
+ "isSerialized": true,
1636
+ "isSigningField": true,
1637
+ "type": "Amount"
1638
+ }
1639
+ ],
1640
+ [
1641
+ "Price",
1593
1642
  {
1594
1643
  "nth": 28,
1595
1644
  "isVLEncoded": false,
@@ -1618,6 +1667,16 @@
1618
1667
  "type": "Amount"
1619
1668
  }
1620
1669
  ],
1670
+ [
1671
+ "LPTokenBalance",
1672
+ {
1673
+ "nth": 31,
1674
+ "isVLEncoded": false,
1675
+ "isSerialized": true,
1676
+ "isSigningField": true,
1677
+ "type": "Amount"
1678
+ }
1679
+ ],
1621
1680
  [
1622
1681
  "PublicKey",
1623
1682
  {
@@ -1948,16 +2007,6 @@
1948
2007
  "type": "AccountID"
1949
2008
  }
1950
2009
  ],
1951
- [
1952
- "AMMAccount",
1953
- {
1954
- "nth": 11,
1955
- "isVLEncoded": true,
1956
- "isSerialized": true,
1957
- "isSigningField": true,
1958
- "type": "AccountID"
1959
- }
1960
- ],
1961
2010
  [
1962
2011
  "HookAccount",
1963
2012
  {
@@ -1968,16 +2017,6 @@
1968
2017
  "type": "AccountID"
1969
2018
  }
1970
2019
  ],
1971
- [
1972
- "ThisChainAccount",
1973
- {
1974
- "nth": 17,
1975
- "isVLEncoded": true,
1976
- "isSerialized": true,
1977
- "isSigningField": true,
1978
- "type": "AccountID"
1979
- }
1980
- ],
1981
2020
  [
1982
2021
  "OtherChainSource",
1983
2022
  {
@@ -2099,9 +2138,9 @@
2099
2138
  }
2100
2139
  ],
2101
2140
  [
2102
- "Asset",
2141
+ "IssuingChainIssue",
2103
2142
  {
2104
- "nth": 3,
2143
+ "nth": 2,
2105
2144
  "isVLEncoded": false,
2106
2145
  "isSerialized": true,
2107
2146
  "isSigningField": true,
@@ -2109,9 +2148,9 @@
2109
2148
  }
2110
2149
  ],
2111
2150
  [
2112
- "IssuingChainIssue",
2151
+ "Asset",
2113
2152
  {
2114
- "nth": 2,
2153
+ "nth": 3,
2115
2154
  "isVLEncoded": false,
2116
2155
  "isSerialized": true,
2117
2156
  "isSigningField": true,
@@ -2138,16 +2177,6 @@
2138
2177
  "type": "XChainBridge"
2139
2178
  }
2140
2179
  ],
2141
- [
2142
- "XChainAttestationBatch",
2143
- {
2144
- "nth": 1,
2145
- "isVLEncoded": false,
2146
- "isSerialized": true,
2147
- "isSigningField": true,
2148
- "type": "XChainAttestationBatch"
2149
- }
2150
- ],
2151
2180
  [
2152
2181
  "TransactionMetaData",
2153
2182
  {
@@ -2371,7 +2400,7 @@
2371
2400
  [
2372
2401
  "AuctionSlot",
2373
2402
  {
2374
- "nth": 27,
2403
+ "nth": 26,
2375
2404
  "isVLEncoded": false,
2376
2405
  "isSerialized": true,
2377
2406
  "isSigningField": true,
@@ -2381,37 +2410,7 @@
2381
2410
  [
2382
2411
  "AuthAccount",
2383
2412
  {
2384
- "nth": 28,
2385
- "isVLEncoded": false,
2386
- "isSerialized": true,
2387
- "isSigningField": true,
2388
- "type": "STObject"
2389
- }
2390
- ],
2391
- [
2392
- "AMMToken",
2393
- {
2394
- "nth": 29,
2395
- "isVLEncoded": false,
2396
- "isSerialized": true,
2397
- "isSigningField": true,
2398
- "type": "STObject"
2399
- }
2400
- ],
2401
- [
2402
- "Token1",
2403
- {
2404
- "nth": 30,
2405
- "isVLEncoded": false,
2406
- "isSerialized": true,
2407
- "isSigningField": true,
2408
- "type": "STObject"
2409
- }
2410
- ],
2411
- [
2412
- "Token2",
2413
- {
2414
- "nth": 31,
2413
+ "nth": 27,
2415
2414
  "isVLEncoded": false,
2416
2415
  "isSerialized": true,
2417
2416
  "isSigningField": true,
@@ -2438,20 +2437,10 @@
2438
2437
  "type": "STObject"
2439
2438
  }
2440
2439
  ],
2441
- [
2442
- "XChainAttestationBatchElement",
2443
- {
2444
- "nth": 34,
2445
- "isVLEncoded": false,
2446
- "isSerialized": true,
2447
- "isSigningField": true,
2448
- "type": "STObject"
2449
- }
2450
- ],
2451
2440
  [
2452
2441
  "XChainClaimAttestationBatchElement",
2453
2442
  {
2454
- "nth": 35,
2443
+ "nth": 34,
2455
2444
  "isVLEncoded": false,
2456
2445
  "isSerialized": true,
2457
2446
  "isSigningField": true,
@@ -2461,17 +2450,7 @@
2461
2450
  [
2462
2451
  "XChainCreateAccountAttestationBatchElement",
2463
2452
  {
2464
- "nth": 36,
2465
- "isVLEncoded": false,
2466
- "isSerialized": true,
2467
- "isSigningField": true,
2468
- "type": "STObject"
2469
- }
2470
- ],
2471
- [
2472
- "XChainAttestationBatchInner",
2473
- {
2474
- "nth": 37,
2453
+ "nth": 35,
2475
2454
  "isVLEncoded": false,
2476
2455
  "isSerialized": true,
2477
2456
  "isSigningField": true,
@@ -2571,7 +2550,7 @@
2571
2550
  [
2572
2551
  "VoteSlots",
2573
2552
  {
2574
- "nth": 14,
2553
+ "nth": 12,
2575
2554
  "isVLEncoded": false,
2576
2555
  "isSerialized": true,
2577
2556
  "isSigningField": true,
@@ -2628,20 +2607,10 @@
2628
2607
  "type": "STArray"
2629
2608
  }
2630
2609
  ],
2631
- [
2632
- "XChainProofSigs",
2633
- {
2634
- "nth": 21,
2635
- "isVLEncoded": false,
2636
- "isSerialized": true,
2637
- "isSigningField": true,
2638
- "type": "STArray"
2639
- }
2640
- ],
2641
2610
  [
2642
2611
  "XChainClaimAttestationBatch",
2643
2612
  {
2644
- "nth": 22,
2613
+ "nth": 21,
2645
2614
  "isVLEncoded": false,
2646
2615
  "isSerialized": true,
2647
2616
  "isSigningField": true,
@@ -2651,7 +2620,7 @@
2651
2620
  [
2652
2621
  "XChainCreateAccountAttestationBatch",
2653
2622
  {
2654
- "nth": 23,
2623
+ "nth": 22,
2655
2624
  "isVLEncoded": false,
2656
2625
  "isSerialized": true,
2657
2626
  "isSigningField": true,
@@ -2661,7 +2630,7 @@
2661
2630
  [
2662
2631
  "XChainClaimAttestations",
2663
2632
  {
2664
- "nth": 24,
2633
+ "nth": 23,
2665
2634
  "isVLEncoded": false,
2666
2635
  "isSerialized": true,
2667
2636
  "isSigningField": true,
@@ -2671,7 +2640,7 @@
2671
2640
  [
2672
2641
  "XChainCreateAccountAttestations",
2673
2642
  {
2674
- "nth": 25,
2643
+ "nth": 24,
2675
2644
  "isVLEncoded": false,
2676
2645
  "isSerialized": true,
2677
2646
  "isSigningField": true,
@@ -2681,7 +2650,7 @@
2681
2650
  [
2682
2651
  "AuthAccounts",
2683
2652
  {
2684
- "nth": 26,
2653
+ "nth": 25,
2685
2654
  "isVLEncoded": false,
2686
2655
  "isSerialized": true,
2687
2656
  "isSigningField": true,
@@ -2703,6 +2672,9 @@
2703
2672
  "telCAN_NOT_QUEUE_BLOCKED": -389,
2704
2673
  "telCAN_NOT_QUEUE_FEE": -388,
2705
2674
  "telCAN_NOT_QUEUE_FULL": -387,
2675
+ "telWRONG_NETWORK": -386,
2676
+ "telREQUIRES_NETWORK_ID": -385,
2677
+ "telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384,
2706
2678
  "temMALFORMED": -299,
2707
2679
  "temBAD_AMOUNT": -298,
2708
2680
  "temBAD_CURRENCY": -297,
@@ -2741,8 +2713,7 @@
2741
2713
  "temUNKNOWN": -264,
2742
2714
  "temSEQ_AND_TICKET": -263,
2743
2715
  "temBAD_NFTOKEN_TRANSFER_FEE": -262,
2744
- "temBAD_AMM_OPTIONS": -261,
2745
- "temBAD_AMM_TOKENS": -260,
2716
+ "temBAD_AMM_TOKENS": -261,
2746
2717
  "temEQUAL_DOOR_ACCOUNTS": -259,
2747
2718
  "temBAD_XCHAIN_PROOF": -258,
2748
2719
  "temSIDECHAIN_BAD_ISSUES": -257,
@@ -2833,28 +2804,26 @@
2833
2804
  "tecINSUFFICIENT_PAYMENT": 161,
2834
2805
  "tecUNFUNDED_AMM": 162,
2835
2806
  "tecAMM_BALANCE": 163,
2836
- "tecAMM_FAILED_DEPOSIT": 164,
2837
- "tecAMM_FAILED_WITHDRAW": 165,
2838
- "tecAMM_INVALID_TOKENS": 166,
2839
- "tecAMM_EXISTS": 167,
2840
- "tecAMM_FAILED_BID": 168,
2841
- "tecAMM_FAILED_VOTE": 169,
2807
+ "tecAMM_FAILED": 164,
2808
+ "tecAMM_INVALID_TOKENS": 165,
2842
2809
  "tecBAD_XCHAIN_TRANSFER_ISSUE": 171,
2843
2810
  "tecXCHAIN_NO_CLAIM_ID": 172,
2844
2811
  "tecXCHAIN_BAD_CLAIM_ID": 173,
2845
2812
  "tecXCHAIN_CLAIM_NO_QUORUM": 174,
2846
2813
  "tecXCHAIN_PROOF_UNKNOWN_KEY": 175,
2847
2814
  "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 176,
2848
- "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 177,
2849
- "tecXCHAIN_WRONG_CHAIN": 178,
2850
- "tecXCHAIN_REWARD_MISMATCH": 179,
2851
- "tecXCHAIN_NO_SIGNERS_LIST": 180,
2852
- "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 181,
2853
- "tecXCHAIN_INSUFF_CREATE_AMOUNT": 182,
2854
- "tecXCHAIN_ACCOUNT_CREATE_PAST": 183,
2855
- "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 184,
2856
- "tecXCHAIN_PAYMENT_FAILED": 185,
2857
- "tecXCHAIN_SELF_COMMIT": 186
2815
+ "tecXCHAIN_WRONG_CHAIN": 177,
2816
+ "tecXCHAIN_REWARD_MISMATCH": 178,
2817
+ "tecXCHAIN_NO_SIGNERS_LIST": 179,
2818
+ "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 180,
2819
+ "tecXCHAIN_INSUFF_CREATE_AMOUNT": 181,
2820
+ "tecXCHAIN_ACCOUNT_CREATE_PAST": 182,
2821
+ "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 183,
2822
+ "tecXCHAIN_PAYMENT_FAILED": 184,
2823
+ "tecXCHAIN_SELF_COMMIT": 185,
2824
+ "tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 186,
2825
+ "tecREQUIRES_FLAG": 187,
2826
+ "tecPRECISION_LOSS": 188
2858
2827
  },
2859
2828
  "TRANSACTION_TYPES": {
2860
2829
  "Invalid": -1,
@@ -2896,8 +2865,9 @@
2896
2865
  "XChainCommit": 42,
2897
2866
  "XChainClaim": 43,
2898
2867
  "XChainAccountCreateCommit": 44,
2899
- "XChainAddAttestation": 45,
2900
- "XChainModifyBridge": 46,
2868
+ "XChainAddClaimAttestation": 45,
2869
+ "XChainAddAccountCreateAttestation": 46,
2870
+ "XChainModifyBridge": 47,
2901
2871
  "EnableAmendment": 100,
2902
2872
  "SetFee": 101,
2903
2873
  "UNLModify": 102
@@ -0,0 +1,29 @@
1
+ import { Bytes } from './bytes';
2
+ import { SerializedType } from '../types/serialized-type';
3
+ import { Buffer } from 'buffer/';
4
+ /**
5
+ * Encoding information for a rippled field, often used in transactions.
6
+ * See the enums [README.md](https://github.com/XRPLF/xrpl.js/tree/main/packages/ripple-binary-codec/src/enums) for more details on what each means.
7
+ */
8
+ export interface FieldInfo {
9
+ nth: number;
10
+ isVLEncoded: boolean;
11
+ isSerialized: boolean;
12
+ isSigningField: boolean;
13
+ type: string;
14
+ }
15
+ export interface FieldInstance {
16
+ readonly nth: number;
17
+ readonly isVariableLengthEncoded: boolean;
18
+ readonly isSerialized: boolean;
19
+ readonly isSigningField: boolean;
20
+ readonly type: Bytes;
21
+ readonly ordinal: number;
22
+ readonly name: string;
23
+ readonly header: Buffer;
24
+ readonly associatedType: typeof SerializedType;
25
+ }
26
+ export declare class FieldLookup {
27
+ constructor(fields: Array<[string, FieldInfo]>, types: Record<string, number>);
28
+ fromString(value: string): FieldInstance;
29
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldLookup = void 0;
4
+ const bytes_1 = require("./bytes");
5
+ const serialized_type_1 = require("../types/serialized-type");
6
+ const constants_1 = require("./constants");
7
+ const buffer_1 = require("buffer/");
8
+ /*
9
+ * @brief: Serialize a field based on type_code and Field.nth
10
+ */
11
+ function fieldHeader(type, nth) {
12
+ const header = [];
13
+ if (type < 16) {
14
+ if (nth < 16) {
15
+ header.push((type << 4) | nth);
16
+ }
17
+ else {
18
+ header.push(type << 4, nth);
19
+ }
20
+ }
21
+ else if (nth < 16) {
22
+ header.push(nth, type);
23
+ }
24
+ else {
25
+ header.push(0, type, nth);
26
+ }
27
+ return buffer_1.Buffer.from(header);
28
+ }
29
+ function buildField([name, info], typeOrdinal) {
30
+ const field = fieldHeader(typeOrdinal, info.nth);
31
+ return {
32
+ name: name,
33
+ nth: info.nth,
34
+ isVariableLengthEncoded: info.isVLEncoded,
35
+ isSerialized: info.isSerialized,
36
+ isSigningField: info.isSigningField,
37
+ ordinal: (typeOrdinal << 16) | info.nth,
38
+ type: new bytes_1.Bytes(info.type, typeOrdinal, constants_1.TYPE_WIDTH),
39
+ header: field,
40
+ associatedType: serialized_type_1.SerializedType, // For later assignment in ./types/index.js or Definitions.updateAll(...)
41
+ };
42
+ }
43
+ /*
44
+ * @brief: The collection of all fields as defined in definitions.json
45
+ */
46
+ class FieldLookup {
47
+ constructor(fields, types) {
48
+ fields.forEach(([name, field_info]) => {
49
+ const typeOrdinal = types[field_info.type];
50
+ this[name] = buildField([name, field_info], typeOrdinal);
51
+ this[this[name].ordinal.toString()] = this[name];
52
+ });
53
+ }
54
+ fromString(value) {
55
+ return this[value];
56
+ }
57
+ }
58
+ exports.FieldLookup = FieldLookup;
59
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/enums/field.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAC/B,8DAAyD;AACzD,2CAAwC;AACxC,oCAAgC;AA0BhC;;GAEG;AACH,SAAS,WAAW,CAAC,IAAY,EAAE,GAAW;IAC5C,MAAM,MAAM,GAAkB,EAAE,CAAA;IAChC,IAAI,IAAI,GAAG,EAAE,EAAE;QACb,IAAI,GAAG,GAAG,EAAE,EAAE;YACZ,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;SAC/B;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;SAC5B;KACF;SAAM,IAAI,GAAG,GAAG,EAAE,EAAE;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;KACvB;SAAM;QACL,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;KAC1B;IACD,OAAO,eAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC;AAED,SAAS,UAAU,CACjB,CAAC,IAAI,EAAE,IAAI,CAAsB,EACjC,WAAmB;IAEnB,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAChD,OAAO;QACL,IAAI,EAAE,IAAI;QACV,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,uBAAuB,EAAE,IAAI,CAAC,WAAW;QACzC,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,OAAO,EAAE,CAAC,WAAW,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG;QACvC,IAAI,EAAE,IAAI,aAAK,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,sBAAU,CAAC;QACnD,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,gCAAc,EAAE,yEAAyE;KAC1G,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAa,WAAW;IACtB,YACE,MAAkC,EAClC,KAA6B;QAE7B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE;YACpC,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YAC1C,IAAI,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,WAAW,CAAC,CAAA;YACxD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAkB,CAAA;IACrC,CAAC;CACF;AAfD,kCAeC"}
@@ -1,48 +1,12 @@
1
- import { SerializedType } from '../types/serialized-type';
2
- import { Buffer } from 'buffer/';
3
- import { BytesList } from '../binary';
4
- export declare const TRANSACTION_TYPES: string[];
5
- export declare class Bytes {
6
- readonly name: string;
7
- readonly ordinal: number;
8
- readonly ordinalWidth: number;
9
- readonly bytes: Buffer;
10
- constructor(name: string, ordinal: number, ordinalWidth: number);
11
- toJSON(): string;
12
- toBytesSink(sink: BytesList): void;
13
- toBytes(): Uint8Array;
14
- }
15
- declare class BytesLookup {
16
- readonly ordinalWidth: number;
17
- constructor(types: Record<string, number>, ordinalWidth: number);
18
- from(value: Bytes | string): Bytes;
19
- fromParser(parser: any): Bytes;
20
- }
21
- interface FieldInfo {
22
- nth: number;
23
- isVLEncoded: boolean;
24
- isSerialized: boolean;
25
- isSigningField: boolean;
26
- type: string;
27
- }
28
- interface FieldInstance {
29
- readonly nth: number;
30
- readonly isVariableLengthEncoded: boolean;
31
- readonly isSerialized: boolean;
32
- readonly isSigningField: boolean;
33
- readonly type: Bytes;
34
- readonly ordinal: number;
35
- readonly name: string;
36
- readonly header: Buffer;
37
- readonly associatedType: typeof SerializedType;
38
- }
39
- declare class FieldLookup {
40
- constructor(fields: Array<[string, FieldInfo]>);
41
- fromString(value: string): FieldInstance;
42
- }
43
- declare const Type: BytesLookup;
44
- declare const LedgerEntryType: BytesLookup;
45
- declare const TransactionType: BytesLookup;
46
- declare const TransactionResult: BytesLookup;
47
- declare const Field: FieldLookup;
48
- export { Field, FieldInstance, Type, LedgerEntryType, TransactionResult, TransactionType, };
1
+ import { XrplDefinitionsBase, FieldInstance, Bytes } from './xrpl-definitions-base';
2
+ /**
3
+ * By default, coreTypes from the `types` folder is where known type definitions are initialized to avoid import cycles.
4
+ */
5
+ declare const DEFAULT_DEFINITIONS: XrplDefinitionsBase;
6
+ declare const Type: import("./bytes").BytesLookup;
7
+ declare const LedgerEntryType: import("./bytes").BytesLookup;
8
+ declare const TransactionType: import("./bytes").BytesLookup;
9
+ declare const TransactionResult: import("./bytes").BytesLookup;
10
+ declare const Field: import("./field").FieldLookup;
11
+ declare const TRANSACTION_TYPES: string[];
12
+ export { Bytes, XrplDefinitionsBase, DEFAULT_DEFINITIONS, Field, FieldInstance, Type, LedgerEntryType, TransactionResult, TransactionType, TRANSACTION_TYPES, };