@transia/ripple-binary-codec 1.4.4-alpha.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.
Files changed (164) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +107 -0
  3. package/dist/binary.d.ts +91 -0
  4. package/dist/binary.js +128 -0
  5. package/dist/binary.js.map +1 -0
  6. package/dist/coretypes.d.ts +9 -0
  7. package/dist/coretypes.js +48 -0
  8. package/dist/coretypes.js.map +1 -0
  9. package/dist/enums/bytes.d.ts +26 -0
  10. package/dist/enums/bytes.js +64 -0
  11. package/dist/enums/bytes.js.map +1 -0
  12. package/dist/enums/constants.d.ts +4 -0
  13. package/dist/enums/constants.js +8 -0
  14. package/dist/enums/constants.js.map +1 -0
  15. package/dist/enums/definitions.json +2476 -0
  16. package/dist/enums/field.d.ts +29 -0
  17. package/dist/enums/field.js +59 -0
  18. package/dist/enums/field.js.map +1 -0
  19. package/dist/enums/index.d.ts +13 -0
  20. package/dist/enums/index.js +53 -0
  21. package/dist/enums/index.js.map +1 -0
  22. package/dist/enums/src/enums/definitions.json +2481 -0
  23. package/dist/enums/utils-renumber.d.ts +101 -0
  24. package/dist/enums/utils-renumber.js +127 -0
  25. package/dist/enums/utils-renumber.js.map +1 -0
  26. package/dist/enums/xrpl-definitions-base.d.ts +45 -0
  27. package/dist/enums/xrpl-definitions-base.js +63 -0
  28. package/dist/enums/xrpl-definitions-base.js.map +1 -0
  29. package/dist/enums/xrpl-definitions.d.ts +21 -0
  30. package/dist/enums/xrpl-definitions.js +29 -0
  31. package/dist/enums/xrpl-definitions.js.map +1 -0
  32. package/dist/hash-prefixes.d.ts +6 -0
  33. package/dist/hash-prefixes.js +41 -0
  34. package/dist/hash-prefixes.js.map +1 -0
  35. package/dist/hashes.d.ts +51 -0
  36. package/dist/hashes.js +77 -0
  37. package/dist/hashes.js.map +1 -0
  38. package/dist/index.d.ts +64 -0
  39. package/dist/index.js +139 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/ledger-hashes.d.ts +49 -0
  42. package/dist/ledger-hashes.js +160 -0
  43. package/dist/ledger-hashes.js.map +1 -0
  44. package/dist/quality.d.ts +22 -0
  45. package/dist/quality.js +40 -0
  46. package/dist/quality.js.map +1 -0
  47. package/dist/serdes/binary-parser.d.ts +101 -0
  48. package/dist/serdes/binary-parser.js +210 -0
  49. package/dist/serdes/binary-parser.js.map +1 -0
  50. package/dist/serdes/binary-serializer.d.ts +82 -0
  51. package/dist/serdes/binary-serializer.js +172 -0
  52. package/dist/serdes/binary-serializer.js.map +1 -0
  53. package/dist/shamap.d.ts +103 -0
  54. package/dist/shamap.js +172 -0
  55. package/dist/shamap.js.map +1 -0
  56. package/dist/types/account-id.d.ts +36 -0
  57. package/dist/types/account-id.js +71 -0
  58. package/dist/types/account-id.js.map +1 -0
  59. package/dist/types/amount.d.ts +68 -0
  60. package/dist/types/amount.js +207 -0
  61. package/dist/types/amount.js.map +1 -0
  62. package/dist/types/blob.d.ts +25 -0
  63. package/dist/types/blob.js +40 -0
  64. package/dist/types/blob.js.map +1 -0
  65. package/dist/types/currency.d.ts +29 -0
  66. package/dist/types/currency.js +127 -0
  67. package/dist/types/currency.js.map +1 -0
  68. package/dist/types/hash-128.d.ts +17 -0
  69. package/dist/types/hash-128.js +32 -0
  70. package/dist/types/hash-128.js.map +1 -0
  71. package/dist/types/hash-160.d.ts +11 -0
  72. package/dist/types/hash-160.js +20 -0
  73. package/dist/types/hash-160.js.map +1 -0
  74. package/dist/types/hash-256.d.ts +11 -0
  75. package/dist/types/hash-256.js +17 -0
  76. package/dist/types/hash-256.js.map +1 -0
  77. package/dist/types/hash.d.ts +41 -0
  78. package/dist/types/hash.js +72 -0
  79. package/dist/types/hash.js.map +1 -0
  80. package/dist/types/index.d.ts +18 -0
  81. package/dist/types/index.js +57 -0
  82. package/dist/types/index.js.map +1 -0
  83. package/dist/types/issue.d.ts +39 -0
  84. package/dist/types/issue.js +81 -0
  85. package/dist/types/issue.js.map +1 -0
  86. package/dist/types/path-set.d.ts +36 -0
  87. package/dist/types/path-set.js +233 -0
  88. package/dist/types/path-set.js.map +1 -0
  89. package/dist/types/serialized-type.d.ts +63 -0
  90. package/dist/types/serialized-type.js +97 -0
  91. package/dist/types/serialized-type.js.map +1 -0
  92. package/dist/types/st-array.d.ts +28 -0
  93. package/dist/types/st-array.js +80 -0
  94. package/dist/types/st-array.js.map +1 -0
  95. package/dist/types/st-object.d.ts +32 -0
  96. package/dist/types/st-object.js +149 -0
  97. package/dist/types/st-object.js.map +1 -0
  98. package/dist/types/uint-16.d.ts +25 -0
  99. package/dist/types/uint-16.js +44 -0
  100. package/dist/types/uint-16.js.map +1 -0
  101. package/dist/types/uint-32.d.ts +25 -0
  102. package/dist/types/uint-32.js +49 -0
  103. package/dist/types/uint-32.js.map +1 -0
  104. package/dist/types/uint-64.d.ts +39 -0
  105. package/dist/types/uint-64.js +87 -0
  106. package/dist/types/uint-64.js.map +1 -0
  107. package/dist/types/uint-8.d.ts +25 -0
  108. package/dist/types/uint-8.js +44 -0
  109. package/dist/types/uint-8.js.map +1 -0
  110. package/dist/types/uint.d.ts +30 -0
  111. package/dist/types/uint.js +42 -0
  112. package/dist/types/uint.js.map +1 -0
  113. package/dist/types/vector-256.d.ts +31 -0
  114. package/dist/types/vector-256.js +75 -0
  115. package/dist/types/vector-256.js.map +1 -0
  116. package/package.json +47 -0
  117. package/test/amount.test.js +43 -0
  118. package/test/binary-json.test.js +45 -0
  119. package/test/binary-parser.test.js +396 -0
  120. package/test/binary-serializer.test.js +289 -0
  121. package/test/definitions.test.js +100 -0
  122. package/test/fixtures/account-tx-transactions.db +0 -0
  123. package/test/fixtures/codec-fixtures.json +4466 -0
  124. package/test/fixtures/data-driven-tests.json +2919 -0
  125. package/test/fixtures/delivermin-tx-binary.json +1 -0
  126. package/test/fixtures/delivermin-tx.json +98 -0
  127. package/test/fixtures/deposit-preauth-tx-binary.json +1 -0
  128. package/test/fixtures/deposit-preauth-tx-meta-binary.json +1 -0
  129. package/test/fixtures/deposit-preauth-tx.json +58 -0
  130. package/test/fixtures/escrow-cancel-binary.json +1 -0
  131. package/test/fixtures/escrow-cancel-tx.json +6 -0
  132. package/test/fixtures/escrow-create-binary.json +1 -0
  133. package/test/fixtures/escrow-create-tx.json +10 -0
  134. package/test/fixtures/escrow-finish-binary.json +1 -0
  135. package/test/fixtures/escrow-finish-meta-binary.json +1 -0
  136. package/test/fixtures/escrow-finish-tx.json +95 -0
  137. package/test/fixtures/ledger-full-38129.json +1 -0
  138. package/test/fixtures/ledger-full-40000.json +1 -0
  139. package/test/fixtures/negative-unl.json +12 -0
  140. package/test/fixtures/nf-token.json +547 -0
  141. package/test/fixtures/payment-channel-claim-binary.json +1 -0
  142. package/test/fixtures/payment-channel-claim-tx.json +8 -0
  143. package/test/fixtures/payment-channel-create-binary.json +1 -0
  144. package/test/fixtures/payment-channel-create-tx.json +11 -0
  145. package/test/fixtures/payment-channel-fund-binary.json +1 -0
  146. package/test/fixtures/payment-channel-fund-tx.json +7 -0
  147. package/test/fixtures/signerlistset-tx-binary.json +1 -0
  148. package/test/fixtures/signerlistset-tx-meta-binary.json +1 -0
  149. package/test/fixtures/signerlistset-tx.json +94 -0
  150. package/test/fixtures/ticket-create-binary.json +1 -0
  151. package/test/fixtures/ticket-create-tx.json +7 -0
  152. package/test/fixtures/x-codec-fixtures.json +188 -0
  153. package/test/hash.test.js +135 -0
  154. package/test/ledger.test.js +29 -0
  155. package/test/lower-case-hex.test.js +46 -0
  156. package/test/pseudo-transaction.test.js +38 -0
  157. package/test/quality.test.js +15 -0
  158. package/test/shamap.test.js +89 -0
  159. package/test/signing-data-encoding.test.js +242 -0
  160. package/test/tx-encode-decode.test.js +119 -0
  161. package/test/types.test.js +34 -0
  162. package/test/uint.test.js +148 -0
  163. package/test/utils.js +30 -0
  164. package/test/x-address.test.js +181 -0
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Quick script to re-number values
3
+ */
4
+ declare const input: {
5
+ temBAD_SEND_XRP_PATHS: number;
6
+ temBAD_SEQUENCE: number;
7
+ temBAD_SIGNATURE: number;
8
+ temBAD_SRC_ACCOUNT: number;
9
+ temBAD_TRANSFER_RATE: number;
10
+ temDST_IS_SRC: number;
11
+ temDST_NEEDED: number;
12
+ temINVALID: number;
13
+ temINVALID_FLAG: number;
14
+ temREDUNDANT: number;
15
+ temRIPPLE_EMPTY: number;
16
+ temDISABLED: number;
17
+ temBAD_SIGNER: number;
18
+ temBAD_QUORUM: number;
19
+ temBAD_WEIGHT: number;
20
+ temBAD_TICK_SIZE: number;
21
+ temINVALID_ACCOUNT_ID: number;
22
+ temCANNOT_PREAUTH_SELF: number;
23
+ temUNCERTAIN: number;
24
+ temUNKNOWN: number;
25
+ tefFAILURE: number;
26
+ tefALREADY: number;
27
+ tefBAD_ADD_AUTH: number;
28
+ tefBAD_AUTH: number;
29
+ tefBAD_LEDGER: number;
30
+ tefCREATED: number;
31
+ tefEXCEPTION: number;
32
+ tefINTERNAL: number;
33
+ tefNO_AUTH_REQUIRED: number;
34
+ tefPAST_SEQ: number;
35
+ tefWRONG_PRIOR: number;
36
+ tefMASTER_DISABLED: number;
37
+ tefMAX_LEDGER: number;
38
+ tefBAD_SIGNATURE: number;
39
+ tefBAD_QUORUM: number;
40
+ tefNOT_MULTI_SIGNING: number;
41
+ tefBAD_AUTH_MASTER: number;
42
+ tefINVARIANT_FAILED: number;
43
+ tefTOO_BIG: number;
44
+ terRETRY: number;
45
+ terFUNDS_SPENT: number;
46
+ terINSUF_FEE_B: number;
47
+ terNO_ACCOUNT: number;
48
+ terNO_AUTH: number;
49
+ terNO_LINE: number;
50
+ terOWNERS: number;
51
+ terPRE_SEQ: number;
52
+ terLAST: number;
53
+ terNO_RIPPLE: number;
54
+ terQUEUED: number;
55
+ tesSUCCESS: number;
56
+ tecCLAIM: number;
57
+ tecPATH_PARTIAL: number;
58
+ tecUNFUNDED_ADD: number;
59
+ tecUNFUNDED_OFFER: number;
60
+ tecUNFUNDED_PAYMENT: number;
61
+ tecFAILED_PROCESSING: number;
62
+ tecDIR_FULL: number;
63
+ tecINSUF_RESERVE_LINE: number;
64
+ tecINSUF_RESERVE_OFFER: number;
65
+ tecNO_DST: number;
66
+ tecNO_DST_INSUF_XRP: number;
67
+ tecNO_LINE_INSUF_RESERVE: number;
68
+ tecNO_LINE_REDUNDANT: number;
69
+ tecPATH_DRY: number;
70
+ tecUNFUNDED: number;
71
+ tecNO_ALTERNATIVE_KEY: number;
72
+ tecNO_REGULAR_KEY: number;
73
+ tecOWNERS: number;
74
+ tecNO_ISSUER: number;
75
+ tecNO_AUTH: number;
76
+ tecNO_LINE: number;
77
+ tecINSUFF_FEE: number;
78
+ tecFROZEN: number;
79
+ tecNO_TARGET: number;
80
+ tecNO_PERMISSION: number;
81
+ tecNO_ENTRY: number;
82
+ tecINSUFFICIENT_RESERVE: number;
83
+ tecNEED_MASTER_KEY: number;
84
+ tecDST_TAG_NEEDED: number;
85
+ tecINTERNAL: number;
86
+ tecOVERSIZE: number;
87
+ tecCRYPTOCONDITION_ERROR: number;
88
+ tecINVARIANT_FAILED: number;
89
+ tecEXPIRED: number;
90
+ tecDUPLICATE: number;
91
+ tecKILLED: number;
92
+ tecHAS_OBLIGATIONS: number;
93
+ tecTOO_SOON: number;
94
+ };
95
+ declare let startingFromTemBADSENDXRPPATHS: number;
96
+ declare let startingFromTefFAILURE: number;
97
+ declare let startingFromTerRETRY: number;
98
+ declare const tesSUCCESS = 0;
99
+ declare let startingFromTecCLAIM: number;
100
+ declare const startingFromTecDIRFULL = 121;
101
+ declare let previousKey: string;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ /**
3
+ * Quick script to re-number values
4
+ */
5
+ const input = {
6
+ temBAD_SEND_XRP_PATHS: -283,
7
+ temBAD_SEQUENCE: -282,
8
+ temBAD_SIGNATURE: -281,
9
+ temBAD_SRC_ACCOUNT: -280,
10
+ temBAD_TRANSFER_RATE: -279,
11
+ temDST_IS_SRC: -278,
12
+ temDST_NEEDED: -277,
13
+ temINVALID: -276,
14
+ temINVALID_FLAG: -275,
15
+ temREDUNDANT: -274,
16
+ temRIPPLE_EMPTY: -273,
17
+ temDISABLED: -272,
18
+ temBAD_SIGNER: -271,
19
+ temBAD_QUORUM: -270,
20
+ temBAD_WEIGHT: -269,
21
+ temBAD_TICK_SIZE: -268,
22
+ temINVALID_ACCOUNT_ID: -267,
23
+ temCANNOT_PREAUTH_SELF: -266,
24
+ temUNCERTAIN: -265,
25
+ temUNKNOWN: -264,
26
+ tefFAILURE: -199,
27
+ tefALREADY: -198,
28
+ tefBAD_ADD_AUTH: -197,
29
+ tefBAD_AUTH: -196,
30
+ tefBAD_LEDGER: -195,
31
+ tefCREATED: -194,
32
+ tefEXCEPTION: -193,
33
+ tefINTERNAL: -192,
34
+ tefNO_AUTH_REQUIRED: -191,
35
+ tefPAST_SEQ: -190,
36
+ tefWRONG_PRIOR: -189,
37
+ tefMASTER_DISABLED: -188,
38
+ tefMAX_LEDGER: -187,
39
+ tefBAD_SIGNATURE: -186,
40
+ tefBAD_QUORUM: -185,
41
+ tefNOT_MULTI_SIGNING: -184,
42
+ tefBAD_AUTH_MASTER: -183,
43
+ tefINVARIANT_FAILED: -182,
44
+ tefTOO_BIG: -181,
45
+ terRETRY: -99,
46
+ terFUNDS_SPENT: -98,
47
+ terINSUF_FEE_B: -97,
48
+ terNO_ACCOUNT: -96,
49
+ terNO_AUTH: -95,
50
+ terNO_LINE: -94,
51
+ terOWNERS: -93,
52
+ terPRE_SEQ: -92,
53
+ terLAST: -91,
54
+ terNO_RIPPLE: -90,
55
+ terQUEUED: -89,
56
+ tesSUCCESS: 0,
57
+ tecCLAIM: 100,
58
+ tecPATH_PARTIAL: 101,
59
+ tecUNFUNDED_ADD: 102,
60
+ tecUNFUNDED_OFFER: 103,
61
+ tecUNFUNDED_PAYMENT: 104,
62
+ tecFAILED_PROCESSING: 105,
63
+ tecDIR_FULL: 121,
64
+ tecINSUF_RESERVE_LINE: 122,
65
+ tecINSUF_RESERVE_OFFER: 123,
66
+ tecNO_DST: 124,
67
+ tecNO_DST_INSUF_XRP: 125,
68
+ tecNO_LINE_INSUF_RESERVE: 126,
69
+ tecNO_LINE_REDUNDANT: 127,
70
+ tecPATH_DRY: 128,
71
+ tecUNFUNDED: 129,
72
+ tecNO_ALTERNATIVE_KEY: 130,
73
+ tecNO_REGULAR_KEY: 131,
74
+ tecOWNERS: 132,
75
+ tecNO_ISSUER: 133,
76
+ tecNO_AUTH: 134,
77
+ tecNO_LINE: 135,
78
+ tecINSUFF_FEE: 136,
79
+ tecFROZEN: 137,
80
+ tecNO_TARGET: 138,
81
+ tecNO_PERMISSION: 139,
82
+ tecNO_ENTRY: 140,
83
+ tecINSUFFICIENT_RESERVE: 141,
84
+ tecNEED_MASTER_KEY: 142,
85
+ tecDST_TAG_NEEDED: 143,
86
+ tecINTERNAL: 144,
87
+ tecOVERSIZE: 145,
88
+ tecCRYPTOCONDITION_ERROR: 146,
89
+ tecINVARIANT_FAILED: 147,
90
+ tecEXPIRED: 148,
91
+ tecDUPLICATE: 149,
92
+ tecKILLED: 150,
93
+ tecHAS_OBLIGATIONS: 151,
94
+ tecTOO_SOON: 152,
95
+ };
96
+ let startingFromTemBADSENDXRPPATHS = -284;
97
+ let startingFromTefFAILURE = -199;
98
+ let startingFromTerRETRY = -99;
99
+ const tesSUCCESS = 0;
100
+ let startingFromTecCLAIM = 100;
101
+ const startingFromTecDIRFULL = 121;
102
+ let previousKey = 'tem';
103
+ Object.keys(input).forEach((key) => {
104
+ if (key.substring(0, 3) !== previousKey.substring(0, 3)) {
105
+ console.log();
106
+ previousKey = key;
107
+ }
108
+ if (key.substring(0, 3) === 'tem') {
109
+ console.log(` "${key}": ${startingFromTemBADSENDXRPPATHS++},`);
110
+ }
111
+ else if (key.substring(0, 3) === 'tef') {
112
+ console.log(` "${key}": ${startingFromTefFAILURE++},`);
113
+ }
114
+ else if (key.substring(0, 3) === 'ter') {
115
+ console.log(` "${key}": ${startingFromTerRETRY++},`);
116
+ }
117
+ else if (key.substring(0, 3) === 'tes') {
118
+ console.log(` "${key}": ${tesSUCCESS},`);
119
+ }
120
+ else if (key.substring(0, 3) === 'tec') {
121
+ if (key === 'tecDIR_FULL') {
122
+ startingFromTecCLAIM = startingFromTecDIRFULL;
123
+ }
124
+ console.log(` "${key}": ${startingFromTecCLAIM++},`);
125
+ }
126
+ });
127
+ //# sourceMappingURL=utils-renumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-renumber.js","sourceRoot":"","sources":["../../src/enums/utils-renumber.ts"],"names":[],"mappings":";AAAA;;GAEG;AAEH,MAAM,KAAK,GAAG;IACZ,qBAAqB,EAAE,CAAC,GAAG;IAC3B,eAAe,EAAE,CAAC,GAAG;IACrB,gBAAgB,EAAE,CAAC,GAAG;IACtB,kBAAkB,EAAE,CAAC,GAAG;IACxB,oBAAoB,EAAE,CAAC,GAAG;IAC1B,aAAa,EAAE,CAAC,GAAG;IACnB,aAAa,EAAE,CAAC,GAAG;IACnB,UAAU,EAAE,CAAC,GAAG;IAChB,eAAe,EAAE,CAAC,GAAG;IACrB,YAAY,EAAE,CAAC,GAAG;IAClB,eAAe,EAAE,CAAC,GAAG;IACrB,WAAW,EAAE,CAAC,GAAG;IACjB,aAAa,EAAE,CAAC,GAAG;IACnB,aAAa,EAAE,CAAC,GAAG;IACnB,aAAa,EAAE,CAAC,GAAG;IACnB,gBAAgB,EAAE,CAAC,GAAG;IACtB,qBAAqB,EAAE,CAAC,GAAG;IAC3B,sBAAsB,EAAE,CAAC,GAAG;IAE5B,YAAY,EAAE,CAAC,GAAG;IAClB,UAAU,EAAE,CAAC,GAAG;IAEhB,UAAU,EAAE,CAAC,GAAG;IAChB,UAAU,EAAE,CAAC,GAAG;IAChB,eAAe,EAAE,CAAC,GAAG;IACrB,WAAW,EAAE,CAAC,GAAG;IACjB,aAAa,EAAE,CAAC,GAAG;IACnB,UAAU,EAAE,CAAC,GAAG;IAChB,YAAY,EA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AS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,sBAAsB,EAAE,GAAG,CAAC,CAAA;KAC1D;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,oBAAoB,EAAE,GAAG,CAAC,CAAA;KACxD;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,UAAU,GAAG,CAAC,CAAA;KAC5C;SAAM,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,EAAE;QACxC,IAAI,GAAG,KAAK,aAAa,EAAE;YACzB,oBAAoB,GAAG,sBAAsB,CAAA;SAC9C;QACD,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,oBAAoB,EAAE,GAAG,CAAC,CAAA;KACxD;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ import { SerializedType } from '../types/serialized-type';
2
+ import { Bytes, BytesLookup } from './bytes';
3
+ import { FieldInfo, FieldLookup, FieldInstance } from './field';
4
+ interface DefinitionsData {
5
+ TYPES: Record<string, number>;
6
+ LEDGER_ENTRY_TYPES: Record<string, number>;
7
+ FIELDS: (string | FieldInfo)[][];
8
+ TRANSACTION_RESULTS: Record<string, number>;
9
+ TRANSACTION_TYPES: Record<string, number>;
10
+ }
11
+ /**
12
+ * Stores the various types and fields for rippled to be used to encode/decode information later on.
13
+ * XrplDefinitions should be instantiated instead of this class.
14
+ */
15
+ declare class XrplDefinitionsBase {
16
+ field: FieldLookup;
17
+ ledgerEntryType: BytesLookup;
18
+ type: BytesLookup;
19
+ transactionResult: BytesLookup;
20
+ transactionType: BytesLookup;
21
+ transactionNames: string[];
22
+ transactionMap: Record<string, number>;
23
+ dataTypes: Record<string, typeof SerializedType>;
24
+ /**
25
+ * Present rippled types in a typed and updatable format.
26
+ * For an example of the input format see `definitions.json`
27
+ * To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
28
+ *
29
+ * See the definitions.test.js file for examples of how to create your own updated definitions.json.
30
+ *
31
+ * @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
32
+ * @param types - A list of type objects with the same name as the fields defined.
33
+ * You can use the coreTypes object if you are not adding new types.
34
+ */
35
+ constructor(enums: DefinitionsData, types: Record<string, typeof SerializedType>);
36
+ /**
37
+ * Associates each Field to a corresponding class that TypeScript can recognize.
38
+ *
39
+ * @param types a list of type objects with the same name as the fields defined.
40
+ * Defaults to xrpl.js's core type definitions.
41
+ */
42
+ associateTypes(types: Record<string, typeof SerializedType>): void;
43
+ getAssociatedTypes(): Record<string, typeof SerializedType>;
44
+ }
45
+ export { DefinitionsData, XrplDefinitionsBase, FieldLookup, FieldInfo, FieldInstance, Bytes, BytesLookup, };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BytesLookup = exports.Bytes = exports.FieldLookup = exports.XrplDefinitionsBase = void 0;
4
+ const bytes_1 = require("./bytes");
5
+ Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return bytes_1.Bytes; } });
6
+ Object.defineProperty(exports, "BytesLookup", { enumerable: true, get: function () { return bytes_1.BytesLookup; } });
7
+ const field_1 = require("./field");
8
+ Object.defineProperty(exports, "FieldLookup", { enumerable: true, get: function () { return field_1.FieldLookup; } });
9
+ const constants_1 = require("./constants");
10
+ /**
11
+ * Stores the various types and fields for rippled to be used to encode/decode information later on.
12
+ * XrplDefinitions should be instantiated instead of this class.
13
+ */
14
+ class XrplDefinitionsBase {
15
+ /**
16
+ * Present rippled types in a typed and updatable format.
17
+ * For an example of the input format see `definitions.json`
18
+ * To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
19
+ *
20
+ * See the definitions.test.js file for examples of how to create your own updated definitions.json.
21
+ *
22
+ * @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
23
+ * @param types - A list of type objects with the same name as the fields defined.
24
+ * You can use the coreTypes object if you are not adding new types.
25
+ */
26
+ constructor(enums, types) {
27
+ this.type = new bytes_1.BytesLookup(enums.TYPES, constants_1.TYPE_WIDTH);
28
+ this.ledgerEntryType = new bytes_1.BytesLookup(enums.LEDGER_ENTRY_TYPES, constants_1.LEDGER_ENTRY_WIDTH);
29
+ this.transactionType = new bytes_1.BytesLookup(enums.TRANSACTION_TYPES, constants_1.TRANSACTION_TYPE_WIDTH);
30
+ this.transactionResult = new bytes_1.BytesLookup(enums.TRANSACTION_RESULTS, constants_1.TRANSACTION_RESULT_WIDTH);
31
+ this.field = new field_1.FieldLookup(enums.FIELDS, enums.TYPES);
32
+ this.transactionNames = Object.entries(enums.TRANSACTION_TYPES)
33
+ .filter(([_key, value]) => value >= 0)
34
+ .map(([key, _value]) => key);
35
+ const ignoreList = ['EnableAmendment', 'SetFee', 'UNLModify', 'EmitFailure'];
36
+ this.transactionMap = Object.assign({}, ...Object.entries(enums.TRANSACTION_TYPES)
37
+ .filter(([_key, _value]) => _value >= 0 || ignoreList.includes(_key))
38
+ .map(([key, value]) => ({ [key]: value })));
39
+ this.dataTypes = {}; // Filled in via associateTypes
40
+ this.associateTypes(types);
41
+ }
42
+ /**
43
+ * Associates each Field to a corresponding class that TypeScript can recognize.
44
+ *
45
+ * @param types a list of type objects with the same name as the fields defined.
46
+ * Defaults to xrpl.js's core type definitions.
47
+ */
48
+ associateTypes(types) {
49
+ // Overwrite any existing type definitions with the given types
50
+ this.dataTypes = Object.assign({}, this.dataTypes, types);
51
+ Object.values(this.field).forEach((field) => {
52
+ field.associatedType = this.dataTypes[field.type.name];
53
+ });
54
+ this.field['TransactionType'].associatedType = this.transactionType;
55
+ this.field['TransactionResult'].associatedType = this.transactionResult;
56
+ this.field['LedgerEntryType'].associatedType = this.ledgerEntryType;
57
+ }
58
+ getAssociatedTypes() {
59
+ return this.dataTypes;
60
+ }
61
+ }
62
+ exports.XrplDefinitionsBase = XrplDefinitionsBase;
63
+ //# sourceMappingURL=xrpl-definitions-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrpl-definitions-base.js","sourceRoot":"","sources":["../../src/enums/xrpl-definitions-base.ts"],"names":[],"mappings":";;;AACA,mCAA4C;AAuH1C,sFAvHO,aAAK,OAuHP;AACL,4FAxHc,mBAAW,OAwHd;AAvHb,mCAA+D;AAmH7D,4FAnHkB,mBAAW,OAmHlB;AAlHb,2CAKoB;AAUpB;;;GAGG;AACH,MAAM,mBAAmB;IAkBvB;;;;;;;;;;OAUG;IACH,YACE,KAAsB,EACtB,KAA4C;QAE5C,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAW,CAAC,KAAK,CAAC,KAAK,EAAE,sBAAU,CAAC,CAAA;QACpD,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAW,CACpC,KAAK,CAAC,kBAAkB,EACxB,8BAAkB,CACnB,CAAA;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,mBAAW,CACpC,KAAK,CAAC,iBAAiB,EACvB,kCAAsB,CACvB,CAAA;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,mBAAW,CACtC,KAAK,CAAC,mBAAmB,EACzB,oCAAwB,CACzB,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAW,CAC1B,KAAK,CAAC,MAAoC,EAC1C,KAAK,CAAC,KAAK,CACZ,CAAA;QAED,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;aAC5D,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;aACrC,GAAG,CAAC,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BAAiB,CAAA;QACvE,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAAA;IACrE,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF;AAIC,kDAAmB"}
@@ -0,0 +1,21 @@
1
+ import { type DefinitionsData, XrplDefinitionsBase } from './xrpl-definitions-base';
2
+ import { SerializedType } from '../types/serialized-type';
3
+ /**
4
+ * Stores the various types and fields for rippled to be used to encode/decode information later on.
5
+ * Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
6
+ * ledger data.
7
+ */
8
+ export declare class XrplDefinitions extends XrplDefinitionsBase {
9
+ /**
10
+ * Present rippled types in a typed and updatable format.
11
+ * For an example of the input format see `definitions.json`
12
+ * To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
13
+ *
14
+ * See the definitions.test.js file for examples of how to create your own updated definitions.json.
15
+ *
16
+ * @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
17
+ * @param additionalTypes - A list of SerializedType objects with the same name as the fields defined.
18
+ * These types will be included in addition to the coreTypes used on mainnet.
19
+ */
20
+ constructor(enums: DefinitionsData, additionalTypes?: Record<string, typeof SerializedType>);
21
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XrplDefinitions = void 0;
4
+ const xrpl_definitions_base_1 = require("./xrpl-definitions-base");
5
+ const types_1 = require("../types");
6
+ /**
7
+ * Stores the various types and fields for rippled to be used to encode/decode information later on.
8
+ * Should be used instead of XrplDefinitionsBase since this defines default `types` for serializing/deserializing
9
+ * ledger data.
10
+ */
11
+ class XrplDefinitions extends xrpl_definitions_base_1.XrplDefinitionsBase {
12
+ /**
13
+ * Present rippled types in a typed and updatable format.
14
+ * For an example of the input format see `definitions.json`
15
+ * To generate a new definitions file from rippled source code, use this tool: https://github.com/RichardAH/xrpl-codec-gen
16
+ *
17
+ * See the definitions.test.js file for examples of how to create your own updated definitions.json.
18
+ *
19
+ * @param enums - A json encoding of the core types, transaction types, transaction results, transaction names, and fields.
20
+ * @param additionalTypes - A list of SerializedType objects with the same name as the fields defined.
21
+ * These types will be included in addition to the coreTypes used on mainnet.
22
+ */
23
+ constructor(enums, additionalTypes) {
24
+ const types = Object.assign({}, types_1.coreTypes, additionalTypes);
25
+ super(enums, types);
26
+ }
27
+ }
28
+ exports.XrplDefinitions = XrplDefinitions;
29
+ //# sourceMappingURL=xrpl-definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrpl-definitions.js","sourceRoot":"","sources":["../../src/enums/xrpl-definitions.ts"],"names":[],"mappings":";;;AAAA,mEAGgC;AAChC,oCAAoC;AAGpC;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,2CAAmB;IACtD;;;;;;;;;;OAUG;IACH,YACE,KAAsB,EACtB,eAAuD;QAEvD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,iBAAS,EAAE,eAAe,CAAC,CAAA;QAC3D,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACrB,CAAC;CACF;AAnBD,0CAmBC"}
@@ -0,0 +1,6 @@
1
+ import { Buffer } from 'buffer/';
2
+ /**
3
+ * Maps HashPrefix names to their byte representation
4
+ */
5
+ declare const HashPrefix: Record<string, Buffer>;
6
+ export { HashPrefix };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HashPrefix = void 0;
4
+ const buffer_1 = require("buffer/");
5
+ /**
6
+ * Write a 32 bit integer to a Buffer
7
+ *
8
+ * @param uint32 32 bit integer to write to buffer
9
+ * @returns a buffer with the bytes representation of uint32
10
+ */
11
+ function bytes(uint32) {
12
+ const result = buffer_1.Buffer.alloc(4);
13
+ result.writeUInt32BE(uint32, 0);
14
+ return result;
15
+ }
16
+ /**
17
+ * Maps HashPrefix names to their byte representation
18
+ */
19
+ const HashPrefix = {
20
+ transactionID: bytes(0x54584e00),
21
+ // transaction plus metadata
22
+ transaction: bytes(0x534e4400),
23
+ // account state
24
+ accountStateEntry: bytes(0x4d4c4e00),
25
+ // inner node in tree
26
+ innerNode: bytes(0x4d494e00),
27
+ // ledger master data for signing
28
+ ledgerHeader: bytes(0x4c575200),
29
+ // inner transaction to sign
30
+ transactionSig: bytes(0x53545800),
31
+ // inner transaction to sign
32
+ transactionMultiSig: bytes(0x534d5400),
33
+ // validation for signing
34
+ validation: bytes(0x56414c00),
35
+ // proposal for signing
36
+ proposal: bytes(0x50525000),
37
+ // payment channel claim
38
+ paymentChannelClaim: bytes(0x434c4d00),
39
+ };
40
+ exports.HashPrefix = HashPrefix;
41
+ //# sourceMappingURL=hash-prefixes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-prefixes.js","sourceRoot":"","sources":["../src/hash-prefixes.ts"],"names":[],"mappings":";;;AAAA,oCAAgC;AAEhC;;;;;GAKG;AACH,SAAS,KAAK,CAAC,MAAc;IAC3B,MAAM,MAAM,GAAG,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC9B,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC/B,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAA2B;IACzC,aAAa,EAAE,KAAK,CAAC,UAAU,CAAC;IAChC,4BAA4B;IAC5B,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC;IAC9B,gBAAgB;IAChB,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC;IACpC,qBAAqB;IACrB,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC;IAC5B,iCAAiC;IACjC,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC;IAC/B,4BAA4B;IAC5B,cAAc,EAAE,KAAK,CAAC,UAAU,CAAC;IACjC,4BAA4B;IAC5B,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC;IACtC,yBAAyB;IACzB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC;IAC7B,uBAAuB;IACvB,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC;IAC3B,wBAAwB;IACxB,mBAAmB,EAAE,KAAK,CAAC,UAAU,CAAC;CACvC,CAAA;AAEQ,gCAAU"}
@@ -0,0 +1,51 @@
1
+ import { Hash256 } from './types/hash-256';
2
+ import { BytesList } from './serdes/binary-serializer';
3
+ import { Buffer } from 'buffer/';
4
+ /**
5
+ * Class for hashing with SHA512
6
+ * @extends BytesList So SerializedTypes can write bytes to a Sha512Half
7
+ */
8
+ declare class Sha512Half extends BytesList {
9
+ private hash;
10
+ /**
11
+ * Construct a new Sha512Hash and write bytes this.hash
12
+ *
13
+ * @param bytes bytes to write to this.hash
14
+ * @returns the new Sha512Hash object
15
+ */
16
+ static put(bytes: Buffer): Sha512Half;
17
+ /**
18
+ * Write bytes to an existing Sha512Hash
19
+ *
20
+ * @param bytes bytes to write to object
21
+ * @returns the Sha512 object
22
+ */
23
+ put(bytes: Buffer): Sha512Half;
24
+ /**
25
+ * Compute SHA512 hash and slice in half
26
+ *
27
+ * @returns half of a SHA512 hash
28
+ */
29
+ finish256(): Buffer;
30
+ /**
31
+ * Constructs a Hash256 from the Sha512Half object
32
+ *
33
+ * @returns a Hash256 object
34
+ */
35
+ finish(): Hash256;
36
+ }
37
+ /**
38
+ * compute SHA512 hash of a list of bytes
39
+ *
40
+ * @param args zero or more arguments to hash
41
+ * @returns the sha512half hash of the arguments.
42
+ */
43
+ declare function sha512Half(...args: Buffer[]): Buffer;
44
+ /**
45
+ * Construct a transactionID from a Serialized Transaction
46
+ *
47
+ * @param serialized bytes to hash
48
+ * @returns a Hash256 object
49
+ */
50
+ declare function transactionID(serialized: Buffer): Hash256;
51
+ export { Sha512Half, sha512Half, transactionID };
package/dist/hashes.js ADDED
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transactionID = exports.sha512Half = exports.Sha512Half = void 0;
4
+ const hash_prefixes_1 = require("./hash-prefixes");
5
+ const createHash = require("create-hash");
6
+ const hash_256_1 = require("./types/hash-256");
7
+ const binary_serializer_1 = require("./serdes/binary-serializer");
8
+ const buffer_1 = require("buffer/");
9
+ /**
10
+ * Class for hashing with SHA512
11
+ * @extends BytesList So SerializedTypes can write bytes to a Sha512Half
12
+ */
13
+ class Sha512Half extends binary_serializer_1.BytesList {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.hash = createHash('sha512');
17
+ }
18
+ /**
19
+ * Construct a new Sha512Hash and write bytes this.hash
20
+ *
21
+ * @param bytes bytes to write to this.hash
22
+ * @returns the new Sha512Hash object
23
+ */
24
+ static put(bytes) {
25
+ return new Sha512Half().put(bytes);
26
+ }
27
+ /**
28
+ * Write bytes to an existing Sha512Hash
29
+ *
30
+ * @param bytes bytes to write to object
31
+ * @returns the Sha512 object
32
+ */
33
+ put(bytes) {
34
+ this.hash.update(bytes);
35
+ return this;
36
+ }
37
+ /**
38
+ * Compute SHA512 hash and slice in half
39
+ *
40
+ * @returns half of a SHA512 hash
41
+ */
42
+ finish256() {
43
+ return buffer_1.Buffer.from(this.hash.digest().slice(0, 32));
44
+ }
45
+ /**
46
+ * Constructs a Hash256 from the Sha512Half object
47
+ *
48
+ * @returns a Hash256 object
49
+ */
50
+ finish() {
51
+ return new hash_256_1.Hash256(this.finish256());
52
+ }
53
+ }
54
+ exports.Sha512Half = Sha512Half;
55
+ /**
56
+ * compute SHA512 hash of a list of bytes
57
+ *
58
+ * @param args zero or more arguments to hash
59
+ * @returns the sha512half hash of the arguments.
60
+ */
61
+ function sha512Half(...args) {
62
+ const hash = new Sha512Half();
63
+ args.forEach((a) => hash.put(a));
64
+ return hash.finish256();
65
+ }
66
+ exports.sha512Half = sha512Half;
67
+ /**
68
+ * Construct a transactionID from a Serialized Transaction
69
+ *
70
+ * @param serialized bytes to hash
71
+ * @returns a Hash256 object
72
+ */
73
+ function transactionID(serialized) {
74
+ return new hash_256_1.Hash256(sha512Half(hash_prefixes_1.HashPrefix.transactionID, serialized));
75
+ }
76
+ exports.transactionID = transactionID;
77
+ //# sourceMappingURL=hashes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashes.js","sourceRoot":"","sources":["../src/hashes.ts"],"names":[],"mappings":";;;AAAA,mDAA4C;AAC5C,0CAA0C;AAC1C,+CAA0C;AAC1C,kEAAsD;AACtD,oCAAgC;AAEhC;;;GAGG;AACH,MAAM,UAAW,SAAQ,6BAAS;IAAlC;;QACU,SAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IAwCrC,CAAC;IAtCC;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,UAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,KAAa;QACf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;OAIG;IACH,SAAS;QACP,OAAO,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IACrD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAI,kBAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;IACtC,CAAC;CACF;AAwBQ,gCAAU;AAtBnB;;;;;GAKG;AACH,SAAS,UAAU,CAAC,GAAG,IAAc;IACnC,MAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAA;IAC7B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAChC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAA;AACzB,CAAC;AAYoB,gCAAU;AAV/B;;;;;GAKG;AACH,SAAS,aAAa,CAAC,UAAkB;IACvC,OAAO,IAAI,kBAAO,CAAC,UAAU,CAAC,0BAAU,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAA;AACtE,CAAC;AAEgC,sCAAa"}
@@ -0,0 +1,64 @@
1
+ import { decodeLedgerData } from './ledger-hashes';
2
+ import { JsonObject } from './types/serialized-type';
3
+ import { XrplDefinitionsBase, TRANSACTION_TYPES, TRANSACTION_TYPE_MAP, DEFAULT_DEFINITIONS } from './enums';
4
+ import { XrplDefinitions } from './enums/xrpl-definitions';
5
+ import { coreTypes } from './types';
6
+ /**
7
+ * Decode a transaction
8
+ *
9
+ * @param binary hex-string of the encoded transaction
10
+ * @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
11
+ * @returns the JSON representation of the transaction
12
+ */
13
+ declare function decode(binary: string, definitions?: XrplDefinitionsBase): JsonObject;
14
+ /**
15
+ * Encode a transaction
16
+ *
17
+ * @param json The JSON representation of a transaction
18
+ * @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
19
+ *
20
+ * @returns A hex-string of the encoded transaction
21
+ */
22
+ declare function encode(json: object, definitions?: XrplDefinitionsBase): string;
23
+ /**
24
+ * Encode a transaction and prepare for signing
25
+ *
26
+ * @param json JSON object representing the transaction
27
+ * @param signer string representing the account to sign the transaction with
28
+ * @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
29
+ * @returns a hex string of the encoded transaction
30
+ */
31
+ declare function encodeForSigning(json: object, definitions?: XrplDefinitionsBase): string;
32
+ /**
33
+ * Encode a transaction and prepare for signing with a claim
34
+ *
35
+ * @param json JSON object representing the transaction
36
+ * @param signer string representing the account to sign the transaction with
37
+ * @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
38
+ * @returns a hex string of the encoded transaction
39
+ */
40
+ declare function encodeForSigningClaim(json: object): string;
41
+ /**
42
+ * Encode a transaction and prepare for multi-signing
43
+ *
44
+ * @param json JSON object representing the transaction
45
+ * @param signer string representing the account to sign the transaction with
46
+ * @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
47
+ * @returns a hex string of the encoded transaction
48
+ */
49
+ declare function encodeForMultisigning(json: object, signer: string, definitions?: XrplDefinitionsBase): string;
50
+ /**
51
+ * Encode a quality value
52
+ *
53
+ * @param value string representation of a number
54
+ * @returns a hex-string representing the quality
55
+ */
56
+ declare function encodeQuality(value: string): string;
57
+ /**
58
+ * Decode a quality value
59
+ *
60
+ * @param value hex-string of a quality
61
+ * @returns a string representing the quality
62
+ */
63
+ declare function decodeQuality(value: string): string;
64
+ export { decode, encode, encodeForSigning, encodeForSigningClaim, encodeForMultisigning, encodeQuality, decodeQuality, decodeLedgerData, TRANSACTION_TYPES, TRANSACTION_TYPE_MAP, XrplDefinitions, XrplDefinitionsBase, DEFAULT_DEFINITIONS, coreTypes, };