ripple-binary-codec 0.2.7 → 1.0.0-mpt-beta

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 (364) hide show
  1. package/README.md +104 -2
  2. package/dist/binary.d.ts +90 -0
  3. package/dist/binary.js +128 -0
  4. package/dist/binary.js.map +1 -0
  5. package/dist/coretypes.d.ts +9 -0
  6. package/dist/coretypes.js +48 -0
  7. package/dist/coretypes.js.map +1 -0
  8. package/dist/enums/bytes.d.ts +25 -0
  9. package/dist/enums/bytes.js +63 -0
  10. package/dist/enums/bytes.js.map +1 -0
  11. package/dist/enums/constants.d.ts +4 -0
  12. package/dist/enums/constants.js +8 -0
  13. package/dist/enums/constants.js.map +1 -0
  14. package/dist/enums/definitions.json +2956 -0
  15. package/dist/enums/field.d.ts +28 -0
  16. package/dist/enums/field.js +58 -0
  17. package/dist/enums/field.js.map +1 -0
  18. package/dist/enums/index.d.ts +12 -0
  19. package/dist/enums/index.js +31 -0
  20. package/dist/enums/index.js.map +1 -0
  21. package/{distrib/npm → dist/enums/src}/enums/definitions.json +1709 -438
  22. package/dist/enums/utils-renumber.d.ts +101 -0
  23. package/dist/enums/utils-renumber.js +127 -0
  24. package/dist/enums/utils-renumber.js.map +1 -0
  25. package/dist/enums/xrpl-definitions-base.d.ts +44 -0
  26. package/dist/enums/xrpl-definitions-base.js +59 -0
  27. package/dist/enums/xrpl-definitions-base.js.map +1 -0
  28. package/dist/enums/xrpl-definitions.d.ts +21 -0
  29. package/dist/enums/xrpl-definitions.js +29 -0
  30. package/dist/enums/xrpl-definitions.js.map +1 -0
  31. package/dist/hash-prefixes.d.ts +5 -0
  32. package/dist/hash-prefixes.js +41 -0
  33. package/dist/hash-prefixes.js.map +1 -0
  34. package/dist/hashes.d.ts +50 -0
  35. package/dist/hashes.js +76 -0
  36. package/dist/hashes.js.map +1 -0
  37. package/dist/index.d.ts +64 -0
  38. package/dist/index.js +123 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/ledger-hashes.d.ts +48 -0
  41. package/dist/ledger-hashes.js +141 -0
  42. package/dist/ledger-hashes.js.map +1 -0
  43. package/dist/quality.d.ts +21 -0
  44. package/dist/quality.js +42 -0
  45. package/dist/quality.js.map +1 -0
  46. package/dist/serdes/binary-parser.d.ts +100 -0
  47. package/dist/serdes/binary-parser.js +194 -0
  48. package/dist/serdes/binary-parser.js.map +1 -0
  49. package/dist/serdes/binary-serializer.d.ts +81 -0
  50. package/dist/serdes/binary-serializer.js +149 -0
  51. package/dist/serdes/binary-serializer.js.map +1 -0
  52. package/dist/shamap.d.ts +102 -0
  53. package/dist/shamap.js +172 -0
  54. package/dist/shamap.js.map +1 -0
  55. package/dist/src/binary.d.ts +90 -0
  56. package/dist/src/binary.js +128 -0
  57. package/dist/src/binary.js.map +1 -0
  58. package/dist/src/coretypes.d.ts +9 -0
  59. package/dist/src/coretypes.js +48 -0
  60. package/dist/src/coretypes.js.map +1 -0
  61. package/dist/src/enums/bytes.d.ts +25 -0
  62. package/dist/src/enums/bytes.js +63 -0
  63. package/dist/src/enums/bytes.js.map +1 -0
  64. package/dist/src/enums/constants.d.ts +4 -0
  65. package/dist/src/enums/constants.js +8 -0
  66. package/dist/src/enums/constants.js.map +1 -0
  67. package/dist/src/enums/definitions.json +2956 -0
  68. package/dist/src/enums/field.d.ts +28 -0
  69. package/dist/src/enums/field.js +58 -0
  70. package/dist/src/enums/field.js.map +1 -0
  71. package/dist/src/enums/index.d.ts +12 -0
  72. package/dist/src/enums/index.js +31 -0
  73. package/dist/src/enums/index.js.map +1 -0
  74. package/dist/src/enums/utils-renumber.d.ts +101 -0
  75. package/dist/src/enums/utils-renumber.js +127 -0
  76. package/dist/src/enums/utils-renumber.js.map +1 -0
  77. package/dist/src/enums/xrpl-definitions-base.d.ts +44 -0
  78. package/dist/src/enums/xrpl-definitions-base.js +59 -0
  79. package/dist/src/enums/xrpl-definitions-base.js.map +1 -0
  80. package/dist/src/enums/xrpl-definitions.d.ts +21 -0
  81. package/dist/src/enums/xrpl-definitions.js +29 -0
  82. package/dist/src/enums/xrpl-definitions.js.map +1 -0
  83. package/dist/src/hash-prefixes.d.ts +5 -0
  84. package/dist/src/hash-prefixes.js +41 -0
  85. package/dist/src/hash-prefixes.js.map +1 -0
  86. package/dist/src/hashes.d.ts +50 -0
  87. package/dist/src/hashes.js +76 -0
  88. package/dist/src/hashes.js.map +1 -0
  89. package/dist/src/index.d.ts +64 -0
  90. package/dist/src/index.js +123 -0
  91. package/dist/src/index.js.map +1 -0
  92. package/dist/src/ledger-hashes.d.ts +48 -0
  93. package/dist/src/ledger-hashes.js +141 -0
  94. package/dist/src/ledger-hashes.js.map +1 -0
  95. package/dist/src/quality.d.ts +21 -0
  96. package/dist/src/quality.js +42 -0
  97. package/dist/src/quality.js.map +1 -0
  98. package/dist/src/serdes/binary-parser.d.ts +100 -0
  99. package/dist/src/serdes/binary-parser.js +194 -0
  100. package/dist/src/serdes/binary-parser.js.map +1 -0
  101. package/dist/src/serdes/binary-serializer.d.ts +81 -0
  102. package/dist/src/serdes/binary-serializer.js +149 -0
  103. package/dist/src/serdes/binary-serializer.js.map +1 -0
  104. package/dist/src/shamap.d.ts +102 -0
  105. package/dist/src/shamap.js +172 -0
  106. package/dist/src/shamap.js.map +1 -0
  107. package/dist/src/types/account-id.d.ts +35 -0
  108. package/dist/src/types/account-id.js +69 -0
  109. package/dist/src/types/account-id.js.map +1 -0
  110. package/dist/src/types/amount.d.ts +91 -0
  111. package/dist/src/types/amount.js +289 -0
  112. package/dist/src/types/amount.js.map +1 -0
  113. package/dist/src/types/blob.d.ts +24 -0
  114. package/dist/src/types/blob.js +40 -0
  115. package/dist/src/types/blob.js.map +1 -0
  116. package/dist/src/types/currency.d.ts +28 -0
  117. package/dist/src/types/currency.js +127 -0
  118. package/dist/src/types/currency.js.map +1 -0
  119. package/dist/src/types/hash-128.d.ts +16 -0
  120. package/dist/src/types/hash-128.js +32 -0
  121. package/dist/src/types/hash-128.js.map +1 -0
  122. package/dist/src/types/hash-160.d.ts +10 -0
  123. package/dist/src/types/hash-160.js +19 -0
  124. package/dist/src/types/hash-160.js.map +1 -0
  125. package/dist/src/types/hash-192.d.ts +10 -0
  126. package/dist/src/types/hash-192.js +19 -0
  127. package/dist/src/types/hash-192.js.map +1 -0
  128. package/dist/src/types/hash-256.d.ts +10 -0
  129. package/dist/src/types/hash-256.js +16 -0
  130. package/dist/src/types/hash-256.js.map +1 -0
  131. package/dist/src/types/hash.d.ts +40 -0
  132. package/dist/src/types/hash.js +73 -0
  133. package/dist/src/types/hash.js.map +1 -0
  134. package/dist/src/types/index.d.ts +19 -0
  135. package/dist/src/types/index.js +64 -0
  136. package/dist/src/types/index.js.map +1 -0
  137. package/dist/src/types/issue.d.ts +38 -0
  138. package/dist/src/types/issue.js +81 -0
  139. package/dist/src/types/issue.js.map +1 -0
  140. package/dist/src/types/path-set.d.ts +36 -0
  141. package/dist/src/types/path-set.js +233 -0
  142. package/dist/src/types/path-set.js.map +1 -0
  143. package/dist/src/types/serialized-type.d.ts +70 -0
  144. package/dist/src/types/serialized-type.js +105 -0
  145. package/dist/src/types/serialized-type.js.map +1 -0
  146. package/dist/src/types/st-array.d.ts +31 -0
  147. package/dist/src/types/st-array.js +83 -0
  148. package/dist/src/types/st-array.js.map +1 -0
  149. package/dist/src/types/st-object.d.ts +32 -0
  150. package/dist/src/types/st-object.js +155 -0
  151. package/dist/src/types/st-object.js.map +1 -0
  152. package/dist/src/types/uint-16.d.ts +24 -0
  153. package/dist/src/types/uint-16.js +45 -0
  154. package/dist/src/types/uint-16.js.map +1 -0
  155. package/dist/src/types/uint-32.d.ts +24 -0
  156. package/dist/src/types/uint-32.js +50 -0
  157. package/dist/src/types/uint-32.js.map +1 -0
  158. package/dist/src/types/uint-64.d.ts +37 -0
  159. package/dist/src/types/uint-64.js +86 -0
  160. package/dist/src/types/uint-64.js.map +1 -0
  161. package/dist/src/types/uint-8.d.ts +24 -0
  162. package/dist/src/types/uint-8.js +46 -0
  163. package/dist/src/types/uint-8.js.map +1 -0
  164. package/dist/src/types/uint.d.ts +29 -0
  165. package/dist/src/types/uint.js +47 -0
  166. package/dist/src/types/uint.js.map +1 -0
  167. package/dist/src/types/vector-256.d.ts +30 -0
  168. package/dist/src/types/vector-256.js +73 -0
  169. package/dist/src/types/vector-256.js.map +1 -0
  170. package/dist/src/types/xchain-bridge.d.ts +44 -0
  171. package/dist/src/types/xchain-bridge.js +102 -0
  172. package/dist/src/types/xchain-bridge.js.map +1 -0
  173. package/dist/src/utils.d.ts +47 -0
  174. package/dist/src/utils.js +137 -0
  175. package/dist/src/utils.js.map +1 -0
  176. package/dist/tsconfig.tsbuildinfo +1 -0
  177. package/dist/types/account-id.d.ts +35 -0
  178. package/dist/types/account-id.js +69 -0
  179. package/dist/types/account-id.js.map +1 -0
  180. package/dist/types/amount.d.ts +91 -0
  181. package/dist/types/amount.js +289 -0
  182. package/dist/types/amount.js.map +1 -0
  183. package/dist/types/blob.d.ts +24 -0
  184. package/dist/types/blob.js +40 -0
  185. package/dist/types/blob.js.map +1 -0
  186. package/dist/types/currency.d.ts +28 -0
  187. package/dist/types/currency.js +127 -0
  188. package/dist/types/currency.js.map +1 -0
  189. package/dist/types/hash-128.d.ts +16 -0
  190. package/dist/types/hash-128.js +32 -0
  191. package/dist/types/hash-128.js.map +1 -0
  192. package/dist/types/hash-160.d.ts +10 -0
  193. package/dist/types/hash-160.js +19 -0
  194. package/dist/types/hash-160.js.map +1 -0
  195. package/dist/types/hash-192.d.ts +10 -0
  196. package/dist/types/hash-192.js +19 -0
  197. package/dist/types/hash-192.js.map +1 -0
  198. package/dist/types/hash-256.d.ts +10 -0
  199. package/dist/types/hash-256.js +16 -0
  200. package/dist/types/hash-256.js.map +1 -0
  201. package/dist/types/hash.d.ts +40 -0
  202. package/dist/types/hash.js +73 -0
  203. package/dist/types/hash.js.map +1 -0
  204. package/dist/types/index.d.ts +19 -0
  205. package/dist/types/index.js +64 -0
  206. package/dist/types/index.js.map +1 -0
  207. package/dist/types/issue.d.ts +38 -0
  208. package/dist/types/issue.js +81 -0
  209. package/dist/types/issue.js.map +1 -0
  210. package/dist/types/path-set.d.ts +36 -0
  211. package/dist/types/path-set.js +233 -0
  212. package/dist/types/path-set.js.map +1 -0
  213. package/dist/types/serialized-type.d.ts +70 -0
  214. package/dist/types/serialized-type.js +105 -0
  215. package/dist/types/serialized-type.js.map +1 -0
  216. package/dist/types/st-array.d.ts +31 -0
  217. package/dist/types/st-array.js +83 -0
  218. package/dist/types/st-array.js.map +1 -0
  219. package/dist/types/st-object.d.ts +32 -0
  220. package/dist/types/st-object.js +155 -0
  221. package/dist/types/st-object.js.map +1 -0
  222. package/dist/types/uint-16.d.ts +24 -0
  223. package/dist/types/uint-16.js +45 -0
  224. package/dist/types/uint-16.js.map +1 -0
  225. package/dist/types/uint-32.d.ts +24 -0
  226. package/dist/types/uint-32.js +50 -0
  227. package/dist/types/uint-32.js.map +1 -0
  228. package/dist/types/uint-64.d.ts +37 -0
  229. package/dist/types/uint-64.js +86 -0
  230. package/dist/types/uint-64.js.map +1 -0
  231. package/dist/types/uint-8.d.ts +24 -0
  232. package/dist/types/uint-8.js +46 -0
  233. package/dist/types/uint-8.js.map +1 -0
  234. package/dist/types/uint.d.ts +29 -0
  235. package/dist/types/uint.js +47 -0
  236. package/dist/types/uint.js.map +1 -0
  237. package/dist/types/vector-256.d.ts +30 -0
  238. package/dist/types/vector-256.js +73 -0
  239. package/dist/types/vector-256.js.map +1 -0
  240. package/dist/types/xchain-bridge.d.ts +44 -0
  241. package/dist/types/xchain-bridge.js +102 -0
  242. package/dist/types/xchain-bridge.js.map +1 -0
  243. package/dist/utils.d.ts +47 -0
  244. package/dist/utils.js +137 -0
  245. package/dist/utils.js.map +1 -0
  246. package/package.json +28 -33
  247. package/src/README.md +5 -0
  248. package/src/binary.ts +194 -0
  249. package/src/coretypes.ts +31 -0
  250. package/src/enums/README.md +144 -0
  251. package/src/enums/bytes.ts +74 -0
  252. package/src/enums/constants.ts +4 -0
  253. package/src/enums/definitions.json +2961 -0
  254. package/src/enums/field.ts +84 -0
  255. package/src/enums/index.ts +34 -0
  256. package/src/enums/utils-renumber.ts +134 -0
  257. package/src/enums/xrpl-definitions-base.ts +111 -0
  258. package/src/enums/xrpl-definitions.ts +32 -0
  259. package/src/hash-prefixes.ts +40 -0
  260. package/src/hashes.ts +75 -0
  261. package/src/index.ts +153 -0
  262. package/src/ledger-hashes.ts +191 -0
  263. package/src/quality.ts +38 -0
  264. package/src/serdes/binary-parser.ts +224 -0
  265. package/src/serdes/binary-serializer.ts +166 -0
  266. package/src/shamap.ts +186 -0
  267. package/src/types/account-id.ts +86 -0
  268. package/src/types/amount.ts +362 -0
  269. package/src/types/blob.ts +43 -0
  270. package/src/types/currency.ts +140 -0
  271. package/src/types/hash-128.ts +33 -0
  272. package/src/types/hash-160.ts +19 -0
  273. package/src/types/hash-192.ts +19 -0
  274. package/src/types/hash-256.ts +15 -0
  275. package/src/types/hash.ts +83 -0
  276. package/src/types/index.ts +66 -0
  277. package/src/types/issue.ts +96 -0
  278. package/src/types/path-set.ts +290 -0
  279. package/src/types/serialized-type.ts +122 -0
  280. package/src/types/st-array.ts +107 -0
  281. package/src/types/st-object.ts +192 -0
  282. package/src/types/uint-16.ts +53 -0
  283. package/src/types/uint-32.ts +59 -0
  284. package/src/types/uint-64.ts +104 -0
  285. package/src/types/uint-8.ts +52 -0
  286. package/src/types/uint.ts +60 -0
  287. package/src/types/vector-256.ts +79 -0
  288. package/src/types/xchain-bridge.ts +128 -0
  289. package/src/utils.ts +152 -0
  290. package/HISTORY.md +0 -66
  291. package/distrib/npm/binary.js +0 -68
  292. package/distrib/npm/coretypes.js +0 -22
  293. package/distrib/npm/enums/index.js +0 -125
  294. package/distrib/npm/enums/utils-renumber.js +0 -134
  295. package/distrib/npm/hash-prefixes.js +0 -30
  296. package/distrib/npm/hashes.js +0 -42
  297. package/distrib/npm/index.js +0 -72
  298. package/distrib/npm/ledger-hashes.js +0 -71
  299. package/distrib/npm/quality.js +0 -20
  300. package/distrib/npm/serdes/binary-parser.js +0 -98
  301. package/distrib/npm/serdes/binary-serializer.js +0 -106
  302. package/distrib/npm/shamap.js +0 -107
  303. package/distrib/npm/types/account-id.js +0 -41
  304. package/distrib/npm/types/amount.js +0 -215
  305. package/distrib/npm/types/blob.js +0 -28
  306. package/distrib/npm/types/currency.js +0 -91
  307. package/distrib/npm/types/hash-128.js +0 -10
  308. package/distrib/npm/types/hash-160.js +0 -10
  309. package/distrib/npm/types/hash-256.js +0 -15
  310. package/distrib/npm/types/hash.js +0 -45
  311. package/distrib/npm/types/index.js +0 -45
  312. package/distrib/npm/types/path-set.js +0 -112
  313. package/distrib/npm/types/serialized-type.js +0 -63
  314. package/distrib/npm/types/st-array.js +0 -37
  315. package/distrib/npm/types/st-object.js +0 -65
  316. package/distrib/npm/types/uint-16.js +0 -10
  317. package/distrib/npm/types/uint-32.js +0 -10
  318. package/distrib/npm/types/uint-64.js +0 -49
  319. package/distrib/npm/types/uint-8.js +0 -10
  320. package/distrib/npm/types/uint.js +0 -60
  321. package/distrib/npm/types/vector-256.js +0 -31
  322. package/distrib/npm/utils/bytes-utils.js +0 -112
  323. package/distrib/npm/utils/make-class.js +0 -83
  324. package/test/amount-test.js +0 -43
  325. package/test/binary-json-test.js +0 -43
  326. package/test/binary-parser-test.js +0 -341
  327. package/test/binary-serializer-test.js +0 -194
  328. package/test/bytes-utils-test.js +0 -72
  329. package/test/fixtures/account-tx-transactions.db +0 -0
  330. package/test/fixtures/codec-fixtures.json +0 -4466
  331. package/test/fixtures/data-driven-tests.json +0 -3721
  332. package/test/fixtures/delivermin-tx-binary.json +0 -1
  333. package/test/fixtures/delivermin-tx.json +0 -98
  334. package/test/fixtures/deposit-preauth-tx-binary.json +0 -1
  335. package/test/fixtures/deposit-preauth-tx-meta-binary.json +0 -1
  336. package/test/fixtures/deposit-preauth-tx.json +0 -58
  337. package/test/fixtures/escrow-cancel-binary.json +0 -1
  338. package/test/fixtures/escrow-cancel-tx.json +0 -6
  339. package/test/fixtures/escrow-create-binary.json +0 -1
  340. package/test/fixtures/escrow-create-tx.json +0 -10
  341. package/test/fixtures/escrow-finish-binary.json +0 -1
  342. package/test/fixtures/escrow-finish-meta-binary.json +0 -1
  343. package/test/fixtures/escrow-finish-tx.json +0 -95
  344. package/test/fixtures/ledger-full-38129.json +0 -1
  345. package/test/fixtures/ledger-full-40000.json +0 -1
  346. package/test/fixtures/payment-channel-claim-binary.json +0 -1
  347. package/test/fixtures/payment-channel-claim-tx.json +0 -8
  348. package/test/fixtures/payment-channel-create-binary.json +0 -1
  349. package/test/fixtures/payment-channel-create-tx.json +0 -11
  350. package/test/fixtures/payment-channel-fund-binary.json +0 -1
  351. package/test/fixtures/payment-channel-fund-tx.json +0 -7
  352. package/test/fixtures/signerlistset-tx-binary.json +0 -1
  353. package/test/fixtures/signerlistset-tx-meta-binary.json +0 -1
  354. package/test/fixtures/signerlistset-tx.json +0 -94
  355. package/test/hash-test.js +0 -58
  356. package/test/ledger-test.js +0 -26
  357. package/test/mocha.opts +0 -1
  358. package/test/quality-test.js +0 -16
  359. package/test/shamap-test.js +0 -88
  360. package/test/signing-data-encoding-test.js +0 -120
  361. package/test/tx-encode-decode-test.js +0 -124
  362. package/test/types-test.js +0 -38
  363. package/test/uint-test.js +0 -38
  364. package/test/utils.js +0 -93
@@ -1,10 +0,0 @@
1
- 'use strict';var makeClass = require('../utils/make-class');var _require =
2
- require('./hash'),Hash = _require.Hash;
3
-
4
- var Hash160 = makeClass({
5
- inherits: Hash,
6
- statics: { width: 20 } });
7
-
8
-
9
- module.exports = {
10
- Hash160: Hash160 };
@@ -1,15 +0,0 @@
1
- 'use strict';var makeClass = require('../utils/make-class');var _require =
2
- require('./hash'),Hash = _require.Hash;
3
-
4
- var Hash256 = makeClass({
5
- inherits: Hash,
6
- statics: {
7
- width: 32,
8
- init: function init() {
9
- this.ZERO_256 = new this(new Uint8Array(this.width));
10
- } } });
11
-
12
-
13
-
14
- module.exports = {
15
- Hash256: Hash256 };
@@ -1,45 +0,0 @@
1
- 'use strict';var assert = require('assert');
2
- var makeClass = require('../utils/make-class');var _require =
3
- require('./serialized-type'),Comparable = _require.Comparable,SerializedType = _require.SerializedType;var _require2 =
4
- require('../utils/bytes-utils'),compareBytes = _require2.compareBytes,parseBytes = _require2.parseBytes;
5
-
6
- var Hash = makeClass({
7
- Hash: function Hash(bytes) {
8
- var width = this.constructor.width;
9
- this._bytes = bytes ? parseBytes(bytes, Uint8Array) :
10
- new Uint8Array(width);
11
- assert.equal(this._bytes.length, width);
12
- },
13
- mixins: [Comparable, SerializedType],
14
- statics: {
15
- width: NaN,
16
- from: function from(value) {
17
- if (value instanceof this) {
18
- return value;
19
- }
20
- return new this(parseBytes(value));
21
- },
22
- fromParser: function fromParser(parser, hint) {
23
- return new this(parser.read(hint || this.width));
24
- } },
25
-
26
- compareTo: function compareTo(other) {
27
- return compareBytes(this._bytes, this.constructor.from(other)._bytes);
28
- },
29
- toString: function toString() {
30
- return this.toHex();
31
- },
32
- nibblet: function nibblet(depth) {
33
- var byte_ix = depth > 0 ? depth / 2 | 0 : 0;
34
- var b = this._bytes[byte_ix];
35
- if (depth % 2 === 0) {
36
- b = (b & 0xF0) >>> 4;
37
- } else {
38
- b = b & 0x0F;
39
- }
40
- return b;
41
- } });
42
-
43
-
44
- module.exports = {
45
- Hash: Hash };
@@ -1,45 +0,0 @@
1
- 'use strict';var enums = require('../enums');var
2
- Field = enums.Field;var _require =
3
- require('./account-id'),AccountID = _require.AccountID;var _require2 =
4
- require('./amount'),Amount = _require2.Amount;var _require3 =
5
- require('./blob'),Blob = _require3.Blob;var _require4 =
6
- require('./currency'),Currency = _require4.Currency;var _require5 =
7
- require('./hash-128'),Hash128 = _require5.Hash128;var _require6 =
8
- require('./hash-160'),Hash160 = _require6.Hash160;var _require7 =
9
- require('./hash-256'),Hash256 = _require7.Hash256;var _require8 =
10
- require('./path-set'),PathSet = _require8.PathSet;var _require9 =
11
- require('./st-array'),STArray = _require9.STArray;var _require10 =
12
- require('./st-object'),STObject = _require10.STObject;var _require11 =
13
- require('./uint-16'),UInt16 = _require11.UInt16;var _require12 =
14
- require('./uint-32'),UInt32 = _require12.UInt32;var _require13 =
15
- require('./uint-64'),UInt64 = _require13.UInt64;var _require14 =
16
- require('./uint-8'),UInt8 = _require14.UInt8;var _require15 =
17
- require('./vector-256'),Vector256 = _require15.Vector256;
18
-
19
- var coreTypes = {
20
- AccountID: AccountID,
21
- Amount: Amount,
22
- Blob: Blob,
23
- Currency: Currency,
24
- Hash128: Hash128,
25
- Hash160: Hash160,
26
- Hash256: Hash256,
27
- PathSet: PathSet,
28
- STArray: STArray,
29
- STObject: STObject,
30
- UInt8: UInt8,
31
- UInt16: UInt16,
32
- UInt32: UInt32,
33
- UInt64: UInt64,
34
- Vector256: Vector256 };
35
-
36
-
37
- Field.values.forEach(function (field) {
38
- field.associatedType = coreTypes[field.type];
39
- });
40
-
41
- Field.TransactionType.associatedType = enums.TransactionType;
42
- Field.TransactionResult.associatedType = enums.TransactionResult;
43
- Field.LedgerEntryType.associatedType = enums.LedgerEntryType;
44
-
45
- module.exports = coreTypes;
@@ -1,112 +0,0 @@
1
- 'use strict'; /* eslint-disable no-unused-expressions */
2
-
3
- var makeClass = require('../utils/make-class');var _require =
4
- require('./serialized-type'),SerializedType = _require.SerializedType,ensureArrayLikeIs = _require.ensureArrayLikeIs;var _require2 =
5
- require('./currency'),Currency = _require2.Currency;var _require3 =
6
- require('./account-id'),AccountID = _require3.AccountID;
7
-
8
- var PATHSET_END_BYTE = 0x00;
9
- var PATH_SEPARATOR_BYTE = 0xFF;
10
- var TYPE_ACCOUNT = 0x01;
11
- var TYPE_CURRENCY = 0x10;
12
- var TYPE_ISSUER = 0x20;
13
-
14
- var Hop = makeClass({
15
- statics: {
16
- from: function from(value) {
17
- if (value instanceof this) {
18
- return value;
19
- }
20
- var hop = new Hop();
21
- value.issuer && (hop.issuer = AccountID.from(value.issuer));
22
- value.account && (hop.account = AccountID.from(value.account));
23
- value.currency && (hop.currency = Currency.from(value.currency));
24
- return hop;
25
- },
26
- parse: function parse(parser, type) {
27
- var hop = new Hop();
28
- type & TYPE_ACCOUNT && (hop.account = AccountID.fromParser(parser));
29
- type & TYPE_CURRENCY && (hop.currency = Currency.fromParser(parser));
30
- type & TYPE_ISSUER && (hop.issuer = AccountID.fromParser(parser));
31
- return hop;
32
- } },
33
-
34
- toJSON: function toJSON() {
35
- var type = this.type();
36
- var ret = {};
37
- type & TYPE_ACCOUNT && (ret.account = this.account.toJSON());
38
- type & TYPE_ISSUER && (ret.issuer = this.issuer.toJSON());
39
- type & TYPE_CURRENCY && (ret.currency = this.currency.toJSON());
40
- return ret;
41
- },
42
- type: function type() {
43
- var type = 0;
44
- this.issuer && (type += TYPE_ISSUER);
45
- this.account && (type += TYPE_ACCOUNT);
46
- this.currency && (type += TYPE_CURRENCY);
47
- return type;
48
- } });
49
-
50
-
51
- var Path = makeClass({
52
- inherits: Array,
53
- statics: {
54
- from: function from(value) {
55
- return ensureArrayLikeIs(Path, value).withChildren(Hop);
56
- } },
57
-
58
- toJSON: function toJSON() {
59
- return this.map(function (k) {return k.toJSON();});
60
- } });
61
-
62
-
63
- var PathSet = makeClass({
64
- mixins: SerializedType,
65
- inherits: Array,
66
- statics: {
67
- from: function from(value) {
68
- return ensureArrayLikeIs(PathSet, value).withChildren(Path);
69
- },
70
- fromParser: function fromParser(parser) {
71
- var pathSet = new this();
72
- var path = void 0;
73
- while (!parser.end()) {
74
- var type = parser.readUInt8();
75
- if (type === PATHSET_END_BYTE) {
76
- break;
77
- }
78
- if (type === PATH_SEPARATOR_BYTE) {
79
- path = null;
80
- continue;
81
- }
82
- if (!path) {
83
- path = new Path();
84
- pathSet.push(path);
85
- }
86
- path.push(Hop.parse(parser, type));
87
- }
88
- return pathSet;
89
- } },
90
-
91
- toJSON: function toJSON() {
92
- return this.map(function (k) {return k.toJSON();});
93
- },
94
- toBytesSink: function toBytesSink(sink) {
95
- var n = 0;
96
- this.forEach(function (path) {
97
- if (n++ !== 0) {
98
- sink.put([PATH_SEPARATOR_BYTE]);
99
- }
100
- path.forEach(function (hop) {
101
- sink.put([hop.type()]);
102
- hop.account && hop.account.toBytesSink(sink);
103
- hop.currency && hop.currency.toBytesSink(sink);
104
- hop.issuer && hop.issuer.toBytesSink(sink);
105
- });
106
- });
107
- sink.put([PATHSET_END_BYTE]);
108
- } });
109
-
110
-
111
- module.exports = {
112
- PathSet: PathSet };
@@ -1,63 +0,0 @@
1
- 'use strict';var _require = require('../utils/bytes-utils'),bytesToHex = _require.bytesToHex,slice = _require.slice;var _require2 =
2
- require('../serdes/binary-serializer'),BytesList = _require2.BytesList;
3
-
4
- var Comparable = {
5
- lt: function lt(other) {
6
- return this.compareTo(other) < 0;
7
- },
8
- eq: function eq(other) {
9
- return this.compareTo(other) === 0;
10
- },
11
- gt: function gt(other) {
12
- return this.compareTo(other) > 0;
13
- },
14
- gte: function gte(other) {
15
- return this.compareTo(other) > -1;
16
- },
17
- lte: function lte(other) {
18
- return this.compareTo(other) < 1;
19
- } };
20
-
21
-
22
- var SerializedType = {
23
- toBytesSink: function toBytesSink(sink) {
24
- sink.put(this._bytes);
25
- },
26
- toHex: function toHex() {
27
- return bytesToHex(this.toBytes());
28
- },
29
- toBytes: function toBytes() {
30
- if (this._bytes) {
31
- return slice(this._bytes);
32
- }
33
- var bl = new BytesList();
34
- this.toBytesSink(bl);
35
- return bl.toBytes();
36
- },
37
- toJSON: function toJSON() {
38
- return this.toHex();
39
- },
40
- toString: function toString() {
41
- return this.toHex();
42
- } };
43
-
44
-
45
- function ensureArrayLikeIs(Type, arrayLike) {
46
- return {
47
- withChildren: function withChildren(Child) {
48
- if (arrayLike instanceof Type) {
49
- return arrayLike;
50
- }
51
- var obj = new Type();
52
- for (var i = 0; i < arrayLike.length; i++) {
53
- obj.push(Child.from(arrayLike[i]));
54
- }
55
- return obj;
56
- } };
57
-
58
- }
59
-
60
- module.exports = {
61
- ensureArrayLikeIs: ensureArrayLikeIs,
62
- SerializedType: SerializedType,
63
- Comparable: Comparable };
@@ -1,37 +0,0 @@
1
- 'use strict';var makeClass = require('../utils/make-class');var _require =
2
- require('./serialized-type'),ensureArrayLikeIs = _require.ensureArrayLikeIs,SerializedType = _require.SerializedType;var _require2 =
3
- require('../enums'),Field = _require2.Field;var _require3 =
4
- require('./st-object'),STObject = _require3.STObject;var
5
- ArrayEndMarker = Field.ArrayEndMarker;
6
-
7
- var STArray = makeClass({
8
- mixins: SerializedType,
9
- inherits: Array,
10
- statics: {
11
- fromParser: function fromParser(parser) {
12
- var array = new STArray();
13
- while (!parser.end()) {
14
- var field = parser.readField();
15
- if (field === ArrayEndMarker) {
16
- break;
17
- }
18
- var outer = new STObject();
19
- outer[field] = parser.readFieldValue(field);
20
- array.push(outer);
21
- }
22
- return array;
23
- },
24
- from: function from(value) {
25
- return ensureArrayLikeIs(STArray, value).withChildren(STObject);
26
- } },
27
-
28
- toJSON: function toJSON() {
29
- return this.map(function (v) {return v.toJSON();});
30
- },
31
- toBytesSink: function toBytesSink(sink) {
32
- this.forEach(function (so) {return so.toBytesSink(sink);});
33
- } });
34
-
35
-
36
- module.exports = {
37
- STArray: STArray };
@@ -1,65 +0,0 @@
1
- 'use strict';var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {return typeof obj;} : function (obj) {return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;};var _ = require('lodash');
2
- var makeClass = require('../utils/make-class');var _require =
3
- require('../enums'),Field = _require.Field;var _require2 =
4
- require('../serdes/binary-serializer'),BinarySerializer = _require2.BinarySerializer;var
5
- ObjectEndMarker = Field.ObjectEndMarker;var _require3 =
6
- require('./serialized-type'),SerializedType = _require3.SerializedType;
7
-
8
- var STObject = makeClass({
9
- mixins: SerializedType,
10
- statics: {
11
- fromParser: function fromParser(parser, hint) {
12
- var end = typeof hint === 'number' ? parser.pos() + hint : null;
13
- var so = new this();
14
- while (!parser.end(end)) {
15
- var field = parser.readField();
16
- if (field === ObjectEndMarker) {
17
- break;
18
- }
19
- so[field] = parser.readFieldValue(field);
20
- }
21
- return so;
22
- },
23
- from: function from(value) {
24
- if (value instanceof this) {
25
- return value;
26
- }
27
- if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
28
- return _.transform(value, function (so, val, key) {
29
- var field = Field[key];
30
- if (field) {
31
- so[field] = field.associatedType.from(val);
32
- } else {
33
- so[key] = val;
34
- }
35
- }, new this());
36
- }
37
- throw new Error(value + ' is unsupported');
38
- } },
39
-
40
- fieldKeys: function fieldKeys() {
41
- return Object.keys(this).map(function (k) {return Field[k];}).filter(Boolean);
42
- },
43
- toJSON: function toJSON() {
44
- // Otherwise seemingly result will have same prototype as `this`
45
- var accumulator = {}; // of only `own` properties
46
- return _.transform(this, function (result, value, key) {
47
- result[key] = value && value.toJSON ? value.toJSON() : value;
48
- }, accumulator);
49
- },
50
- toBytesSink: function toBytesSink(sink) {var _this = this;var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {return true;};
51
- var serializer = new BinarySerializer(sink);
52
- var fields = this.fieldKeys();
53
- var sorted = _.sortBy(fields, 'ordinal');
54
- sorted.filter(filter).forEach(function (field) {
55
- var value = _this[field];
56
- if (!field.isSerialized) {
57
- return;
58
- }
59
- serializer.writeFieldAndValue(field, value);
60
- });
61
- } });
62
-
63
-
64
- module.exports = {
65
- STObject: STObject };
@@ -1,10 +0,0 @@
1
- 'use strict';var makeClass = require('../utils/make-class');var _require =
2
- require('./uint'),UInt = _require.UInt;
3
-
4
- var UInt16 = makeClass({
5
- inherits: UInt,
6
- statics: { width: 2 } });
7
-
8
-
9
- module.exports = {
10
- UInt16: UInt16 };
@@ -1,10 +0,0 @@
1
- 'use strict';var makeClass = require('../utils/make-class');var _require =
2
- require('./uint'),UInt = _require.UInt;
3
-
4
- var UInt32 = makeClass({
5
- inherits: UInt,
6
- statics: { width: 4 } });
7
-
8
-
9
- module.exports = {
10
- UInt32: UInt32 };
@@ -1,49 +0,0 @@
1
- 'use strict';var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {return typeof obj;} : function (obj) {return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;};var assert = require('assert');
2
- var BN = require('bn.js');
3
- var makeClass = require('../utils/make-class');var _require =
4
-
5
- require('../utils/bytes-utils'),bytesToHex = _require.bytesToHex,parseBytes = _require.parseBytes,serializeUIntN = _require.serializeUIntN;var _require2 =
6
- require('./uint'),UInt = _require2.UInt;
7
-
8
- var HEX_REGEX = /^[A-F0-9]{16}$/;
9
-
10
- var UInt64 = makeClass({
11
- inherits: UInt,
12
- statics: { width: 8 },
13
- UInt64: function UInt64() {var arg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
14
- var argType = typeof arg === 'undefined' ? 'undefined' : _typeof(arg);
15
- if (argType === 'number') {
16
- assert(arg >= 0);
17
- this._bytes = new Uint8Array(8);
18
- this._bytes.set(serializeUIntN(arg, 4), 4);
19
- } else if (arg instanceof BN) {
20
- this._bytes = parseBytes(arg.toArray('be', 8), Uint8Array);
21
- this._toBN = arg;
22
- } else {
23
- if (argType === 'string') {
24
- if (!HEX_REGEX.test(arg)) {
25
- throw new Error(arg + ' is not a valid UInt64 hex string');
26
- }
27
- }
28
- this._bytes = parseBytes(arg, Uint8Array);
29
- }
30
- assert(this._bytes.length === 8);
31
- },
32
- toJSON: function toJSON() {
33
- return bytesToHex(this._bytes);
34
- },
35
- valueOf: function valueOf() {
36
- return this.toBN();
37
- },
38
- cached: {
39
- toBN: function toBN() {
40
- return new BN(this._bytes);
41
- } },
42
-
43
- toBytes: function toBytes() {
44
- return this._bytes;
45
- } });
46
-
47
-
48
- module.exports = {
49
- UInt64: UInt64 };
@@ -1,10 +0,0 @@
1
- 'use strict';var makeClass = require('../utils/make-class');var _require =
2
- require('./uint'),UInt = _require.UInt;
3
-
4
- var UInt8 = makeClass({
5
- inherits: UInt,
6
- statics: { width: 1 } });
7
-
8
-
9
- module.exports = {
10
- UInt8: UInt8 };
@@ -1,60 +0,0 @@
1
- 'use strict';var assert = require('assert');
2
- var BN = require('bn.js');
3
- var makeClass = require('../utils/make-class');var _require =
4
- require('./serialized-type'),Comparable = _require.Comparable,SerializedType = _require.SerializedType;var _require2 =
5
- require('../utils/bytes-utils'),serializeUIntN = _require2.serializeUIntN;
6
- var MAX_VALUES = [0, 255, 65535, 16777215, 4294967295];
7
-
8
- function signum(a, b) {
9
- return a < b ? -1 : a === b ? 0 : 1;
10
- }
11
-
12
- var UInt = makeClass({
13
- mixins: [Comparable, SerializedType],
14
- UInt: function UInt() {var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
15
- var max = MAX_VALUES[this.constructor.width];
16
- if (val < 0 || !(val <= max)) {
17
- throw new Error(val + ' not in range 0 <= $val <= ' + max);
18
- }
19
- this.val = val;
20
- },
21
- statics: {
22
- width: 0,
23
- fromParser: function fromParser(parser) {
24
- var val = this.width > 4 ? parser.read(this.width) :
25
- parser.readUIntN(this.width);
26
- return new this(val);
27
- },
28
- from: function from(val) {
29
- return val instanceof this ? val : new this(val);
30
- } },
31
-
32
- toJSON: function toJSON() {
33
- return this.val;
34
- },
35
- valueOf: function valueOf() {
36
- return this.val;
37
- },
38
- compareTo: function compareTo(other) {
39
- var thisValue = this.valueOf();
40
- var otherValue = other.valueOf();
41
- if (thisValue instanceof BN) {
42
- return otherValue instanceof BN ?
43
- thisValue.cmp(otherValue) :
44
- thisValue.cmpn(otherValue);
45
- } else if (otherValue instanceof BN) {
46
- return -other.compareTo(this);
47
- }
48
- assert(typeof otherValue === 'number');
49
- return signum(thisValue, otherValue);
50
- },
51
- toBytesSink: function toBytesSink(sink) {
52
- sink.put(this.toBytes());
53
- },
54
- toBytes: function toBytes() {
55
- return serializeUIntN(this.val, this.constructor.width);
56
- } });
57
-
58
-
59
- module.exports = {
60
- UInt: UInt };
@@ -1,31 +0,0 @@
1
- 'use strict';var makeClass = require('../utils/make-class');var _require =
2
- require('./hash-256'),Hash256 = _require.Hash256;var _require2 =
3
- require('./serialized-type'),ensureArrayLikeIs = _require2.ensureArrayLikeIs,SerializedType = _require2.SerializedType;
4
-
5
- var Vector256 = makeClass({
6
- mixins: SerializedType,
7
- inherits: Array,
8
- statics: {
9
- fromParser: function fromParser(parser, hint) {
10
- var vector256 = new this();
11
- var bytes = hint !== null ? hint : parser.size() - parser.pos();
12
- var hashes = bytes / 32;
13
- for (var i = 0; i < hashes; i++) {
14
- vector256.push(Hash256.fromParser(parser));
15
- }
16
- return vector256;
17
- },
18
- from: function from(value) {
19
- return ensureArrayLikeIs(Vector256, value).withChildren(Hash256);
20
- } },
21
-
22
- toBytesSink: function toBytesSink(sink) {
23
- this.forEach(function (h) {return h.toBytesSink(sink);});
24
- },
25
- toJSON: function toJSON() {
26
- return this.map(function (hash) {return hash.toJSON();});
27
- } });
28
-
29
-
30
- module.exports = {
31
- Vector256: Vector256 };
@@ -1,112 +0,0 @@
1
- 'use strict';var assert = require('assert');
2
-
3
- function signum(a, b) {
4
- return a < b ? -1 : a === b ? 0 : 1;
5
- }
6
-
7
- var hexLookup = function () {
8
- var res = {};
9
- var reverse = res.reverse = new Array(256);
10
- for (var i = 0; i < 16; i++) {
11
- var char = i.toString(16).toUpperCase();
12
- res[char] = i;
13
-
14
- for (var j = 0; j < 16; j++) {
15
- var char2 = j.toString(16).toUpperCase();
16
- var byte = (i << 4) + j;
17
- var byteHex = char + char2;
18
- res[byteHex] = byte;
19
- reverse[byte] = byteHex;
20
- }
21
- }
22
- return res;
23
- }();
24
-
25
- var reverseHexLookup = hexLookup.reverse;
26
-
27
- function bytesToHex(sequence) {
28
- var buf = Array(sequence.length);
29
- for (var i = sequence.length - 1; i >= 0; i--) {
30
- buf[i] = reverseHexLookup[sequence[i]];
31
- }
32
- return buf.join('');
33
- }
34
-
35
- function byteForHex(hex) {
36
- var byte = hexLookup[hex];
37
- if (byte === undefined) {
38
- throw new Error('`' + hex + '` is not a valid hex representation of a byte');
39
- }
40
- return byte;
41
- }
42
-
43
- function parseBytes(val) {var Output = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Array;
44
- if (!val || val.length === undefined) {
45
- throw new Error(val + ' is not a sequence');
46
- }
47
-
48
- if (typeof val === 'string') {
49
- var start = val.length % 2;
50
- var _res = new Output((val.length + start) / 2);
51
- for (var i = val.length, to = _res.length - 1; to >= start; i -= 2, to--) {
52
- _res[to] = byteForHex(val.slice(i - 2, i));
53
- }
54
- if (start === 1) {
55
- _res[0] = byteForHex(val[0]);
56
- }
57
- return _res;
58
- } else if (val instanceof Output) {
59
- return val;
60
- } else if (Output === Uint8Array) {
61
- return new Output(val);
62
- }
63
- var res = new Output(val.length);
64
- for (var _i = val.length - 1; _i >= 0; _i--) {
65
- res[_i] = val[_i];
66
- }
67
- return res;
68
- }
69
-
70
- function serializeUIntN(val, width) {
71
- var newBytes = new Uint8Array(width);
72
- var lastIx = width - 1;
73
- for (var i = 0; i < width; i++) {
74
- newBytes[lastIx - i] = val >>> i * 8 & 0xff;
75
- }
76
- return newBytes;
77
- }
78
-
79
- function compareBytes(a, b) {
80
- assert(a.length === b.length);
81
- for (var i = 0; i < a.length; i++) {
82
- var cmp = signum(a[i], b[i]);
83
- if (cmp !== 0) {
84
- return cmp;
85
- }
86
- }
87
- return 0;
88
- }
89
-
90
- function slice(val) {var startIx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;var endIx = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : val.length;var Output = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : val.constructor;
91
- /* eslint-disable no-param-reassign*/
92
- if (startIx < 0) {
93
- startIx += val.length;
94
- }
95
- if (endIx < 0) {
96
- endIx += val.length;
97
- }
98
- /* eslint-enable no-param-reassign*/
99
- var len = endIx - startIx;
100
- var res = new Output(len);
101
- for (var i = endIx - 1; i >= startIx; i--) {
102
- res[i - startIx] = val[i];
103
- }
104
- return res;
105
- }
106
-
107
- module.exports = {
108
- parseBytes: parseBytes,
109
- bytesToHex: bytesToHex,
110
- slice: slice,
111
- compareBytes: compareBytes,
112
- serializeUIntN: serializeUIntN };