@geeqdev/geeq-sdk 0.1.0 → 0.2.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 (392) hide show
  1. package/.idea/geeq_sdk.iml +12 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/vcs.xml +6 -0
  4. package/.nvmrc +1 -0
  5. package/CONTRIBUTING.md +20 -0
  6. package/dist/src/address/record-type.d.ts +10 -0
  7. package/dist/src/address/record-type.js +59 -0
  8. package/dist/src/address/record-type.js.map +1 -0
  9. package/dist/src/address/wallet-address.d.ts +34 -0
  10. package/dist/src/address/wallet-address.js +90 -0
  11. package/dist/src/address/wallet-address.js.map +1 -0
  12. package/dist/src/amount.d.ts +43 -0
  13. package/dist/src/amount.js +105 -0
  14. package/dist/src/amount.js.map +1 -0
  15. package/dist/src/assert.d.ts +12 -0
  16. package/dist/src/assert.js +24 -0
  17. package/dist/src/assert.js.map +1 -0
  18. package/dist/src/capnp/adminNetTx.capnp.d.ts +75 -0
  19. package/dist/src/capnp/adminNetTx.capnp.js +66 -0
  20. package/dist/src/capnp/adminNetTx.capnp.js.map +1 -0
  21. package/dist/src/capnp/appLayBlock.capnp.d.ts +26 -0
  22. package/dist/src/capnp/appLayBlock.capnp.js +24 -0
  23. package/dist/src/capnp/appLayBlock.capnp.js.map +1 -0
  24. package/dist/src/capnp/appLayLedger.capnp.d.ts +34 -0
  25. package/dist/src/capnp/appLayLedger.capnp.js +32 -0
  26. package/dist/src/capnp/appLayLedger.capnp.js.map +1 -0
  27. package/dist/src/capnp/appLayRec.capnp.d.ts +129 -0
  28. package/dist/src/capnp/appLayRec.capnp.js +156 -0
  29. package/dist/src/capnp/appLayRec.capnp.js.map +1 -0
  30. package/dist/src/capnp/chainStateView.capnp.d.ts +50 -0
  31. package/dist/src/capnp/chainStateView.capnp.js +48 -0
  32. package/dist/src/capnp/chainStateView.capnp.js.map +1 -0
  33. package/dist/src/capnp/coinAcctRec.capnp.d.ts +178 -0
  34. package/dist/src/capnp/coinAcctRec.capnp.js +189 -0
  35. package/dist/src/capnp/coinAcctRec.capnp.js.map +1 -0
  36. package/dist/src/capnp/genesisBlock.capnp.d.ts +61 -0
  37. package/dist/src/capnp/genesisBlock.capnp.js +55 -0
  38. package/dist/src/capnp/genesisBlock.capnp.js.map +1 -0
  39. package/dist/src/capnp/hubContentStmt.capnp.d.ts +63 -0
  40. package/dist/src/capnp/hubContentStmt.capnp.js +57 -0
  41. package/dist/src/capnp/hubContentStmt.capnp.js.map +1 -0
  42. package/dist/src/capnp/misc.capnp.d.ts +20 -0
  43. package/dist/src/capnp/misc.capnp.js +18 -0
  44. package/dist/src/capnp/misc.capnp.js.map +1 -0
  45. package/dist/src/capnp/netActorRec.capnp.d.ts +65 -0
  46. package/dist/src/capnp/netActorRec.capnp.js +65 -0
  47. package/dist/src/capnp/netActorRec.capnp.js.map +1 -0
  48. package/dist/src/capnp/nodeContentStmt.capnp.d.ts +67 -0
  49. package/dist/src/capnp/nodeContentStmt.capnp.js +61 -0
  50. package/dist/src/capnp/nodeContentStmt.capnp.js.map +1 -0
  51. package/dist/src/capnp/nodePayloadList.capnp.d.ts +28 -0
  52. package/dist/src/capnp/nodePayloadList.capnp.js +26 -0
  53. package/dist/src/capnp/nodePayloadList.capnp.js.map +1 -0
  54. package/dist/src/capnp/nodeTxList.capnp.d.ts +36 -0
  55. package/dist/src/capnp/nodeTxList.capnp.js +34 -0
  56. package/dist/src/capnp/nodeTxList.capnp.js.map +1 -0
  57. package/dist/src/capnp/paramAcctRec.capnp.d.ts +338 -0
  58. package/dist/src/capnp/paramAcctRec.capnp.js +669 -0
  59. package/dist/src/capnp/paramAcctRec.capnp.js.map +1 -0
  60. package/dist/src/capnp/payload.capnp.d.ts +237 -0
  61. package/dist/src/capnp/payload.capnp.js +260 -0
  62. package/dist/src/capnp/payload.capnp.js.map +1 -0
  63. package/dist/src/capnp/proxyAcctRec.capnp.d.ts +223 -0
  64. package/dist/src/capnp/proxyAcctRec.capnp.js +255 -0
  65. package/dist/src/capnp/proxyAcctRec.capnp.js.map +1 -0
  66. package/dist/src/capnp/relayContentStmt.capnp.d.ts +82 -0
  67. package/dist/src/capnp/relayContentStmt.capnp.js +85 -0
  68. package/dist/src/capnp/relayContentStmt.capnp.js.map +1 -0
  69. package/dist/src/capnp/sysAcctRec.capnp.d.ts +48 -0
  70. package/dist/src/capnp/sysAcctRec.capnp.js +46 -0
  71. package/dist/src/capnp/sysAcctRec.capnp.js.map +1 -0
  72. package/dist/src/capnp/userAppTx.capnp.d.ts +230 -0
  73. package/dist/src/capnp/userAppTx.capnp.js +270 -0
  74. package/dist/src/capnp/userAppTx.capnp.js.map +1 -0
  75. package/dist/src/capnp/userValTx.capnp.d.ts +1575 -0
  76. package/dist/src/capnp/userValTx.capnp.js +2004 -0
  77. package/dist/src/capnp/userValTx.capnp.js.map +1 -0
  78. package/dist/src/capnp/valLayBlock.capnp.d.ts +88 -0
  79. package/dist/src/capnp/valLayBlock.capnp.js +86 -0
  80. package/dist/src/capnp/valLayBlock.capnp.js.map +1 -0
  81. package/dist/src/capnp/valLayLedger.capnp.d.ts +85 -0
  82. package/dist/src/capnp/valLayLedger.capnp.js +75 -0
  83. package/dist/src/capnp/valLayLedger.capnp.js.map +1 -0
  84. package/dist/src/chain/geeq-chain.d.ts +474 -0
  85. package/dist/src/chain/geeq-chain.js +721 -0
  86. package/dist/src/chain/geeq-chain.js.map +1 -0
  87. package/dist/src/chain/geeq-node.d.ts +57 -0
  88. package/dist/src/chain/geeq-node.js +62 -0
  89. package/dist/src/chain/geeq-node.js.map +1 -0
  90. package/dist/src/chain/nonce-guard.d.ts +42 -0
  91. package/dist/src/chain/nonce-guard.js +68 -0
  92. package/dist/src/chain/nonce-guard.js.map +1 -0
  93. package/dist/src/chain/select.d.ts +40 -0
  94. package/dist/src/chain/select.js +114 -0
  95. package/dist/src/chain/select.js.map +1 -0
  96. package/dist/src/crypto/account-id.d.ts +35 -0
  97. package/dist/src/crypto/account-id.js +58 -0
  98. package/dist/src/crypto/account-id.js.map +1 -0
  99. package/dist/src/crypto/keypair.d.ts +24 -0
  100. package/dist/src/crypto/keypair.js +158 -0
  101. package/dist/src/crypto/keypair.js.map +1 -0
  102. package/dist/src/crypto/mnemonic.d.ts +34 -0
  103. package/dist/src/crypto/mnemonic.js +57 -0
  104. package/dist/src/crypto/mnemonic.js.map +1 -0
  105. package/dist/src/encoding/base64.d.ts +8 -0
  106. package/dist/src/encoding/base64.js +53 -0
  107. package/dist/src/encoding/base64.js.map +1 -0
  108. package/dist/src/encoding/hex.d.ts +2 -0
  109. package/dist/src/encoding/hex.js +35 -0
  110. package/dist/src/encoding/hex.js.map +1 -0
  111. package/dist/src/errors.d.ts +83 -0
  112. package/dist/src/errors.js +49 -0
  113. package/dist/src/errors.js.map +1 -0
  114. package/dist/src/index.d.ts +59 -0
  115. package/dist/src/index.js +53 -0
  116. package/dist/src/index.js.map +1 -0
  117. package/dist/src/ledger/coin-accounts.d.ts +42 -0
  118. package/dist/src/ledger/coin-accounts.js +37 -0
  119. package/dist/src/ledger/coin-accounts.js.map +1 -0
  120. package/dist/src/ledger/decode.d.ts +18 -0
  121. package/dist/src/ledger/decode.js +113 -0
  122. package/dist/src/ledger/decode.js.map +1 -0
  123. package/dist/src/ledger/geeq-ledger.d.ts +99 -0
  124. package/dist/src/ledger/geeq-ledger.js +125 -0
  125. package/dist/src/ledger/geeq-ledger.js.map +1 -0
  126. package/dist/src/ledger/net-actors.d.ts +65 -0
  127. package/dist/src/ledger/net-actors.js +53 -0
  128. package/dist/src/ledger/net-actors.js.map +1 -0
  129. package/dist/src/ledger/nft-records.d.ts +13 -0
  130. package/dist/src/ledger/nft-records.js +41 -0
  131. package/dist/src/ledger/nft-records.js.map +1 -0
  132. package/dist/src/ledger/params.d.ts +34 -0
  133. package/dist/src/ledger/params.js +71 -0
  134. package/dist/src/ledger/params.js.map +1 -0
  135. package/dist/src/ledger/proxy-accounts.d.ts +26 -0
  136. package/dist/src/ledger/proxy-accounts.js +27 -0
  137. package/dist/src/ledger/proxy-accounts.js.map +1 -0
  138. package/dist/src/net/discovery.d.ts +62 -0
  139. package/dist/src/net/discovery.js +136 -0
  140. package/dist/src/net/discovery.js.map +1 -0
  141. package/dist/src/net/explorer.d.ts +57 -0
  142. package/dist/src/net/explorer.js +64 -0
  143. package/dist/src/net/explorer.js.map +1 -0
  144. package/dist/src/net/read-ledger.d.ts +7 -0
  145. package/dist/src/net/read-ledger.js +39 -0
  146. package/dist/src/net/read-ledger.js.map +1 -0
  147. package/dist/src/net/routes.d.ts +49 -0
  148. package/dist/src/net/routes.js +70 -0
  149. package/dist/src/net/routes.js.map +1 -0
  150. package/dist/src/net/transport.d.ts +55 -0
  151. package/dist/src/net/transport.js +168 -0
  152. package/dist/src/net/transport.js.map +1 -0
  153. package/dist/src/net/websocket.d.ts +49 -0
  154. package/dist/src/net/websocket.js +54 -0
  155. package/dist/src/net/websocket.js.map +1 -0
  156. package/dist/src/runtime/bindings.d.ts +9 -0
  157. package/dist/src/runtime/bindings.js +27 -0
  158. package/dist/src/runtime/bindings.js.map +1 -0
  159. package/dist/src/runtime/init.d.ts +13 -0
  160. package/dist/src/runtime/init.js +40 -0
  161. package/dist/src/runtime/init.js.map +1 -0
  162. package/dist/src/runtime/wasm-loader.browser.d.ts +14 -0
  163. package/dist/src/runtime/wasm-loader.browser.js +20 -0
  164. package/dist/src/runtime/wasm-loader.browser.js.map +1 -0
  165. package/dist/src/runtime/wasm-loader.node.d.ts +7 -0
  166. package/dist/src/runtime/wasm-loader.node.js +14 -0
  167. package/dist/src/runtime/wasm-loader.node.js.map +1 -0
  168. package/dist/src/socket/geeq-socket.d.ts +232 -0
  169. package/dist/src/socket/geeq-socket.js +634 -0
  170. package/dist/src/socket/geeq-socket.js.map +1 -0
  171. package/dist/src/socket/tracked-tx.d.ts +148 -0
  172. package/dist/src/socket/tracked-tx.js +212 -0
  173. package/dist/src/socket/tracked-tx.js.map +1 -0
  174. package/dist/src/socket/tx-status.d.ts +69 -0
  175. package/dist/src/socket/tx-status.js +72 -0
  176. package/dist/src/socket/tx-status.js.map +1 -0
  177. package/dist/src/tx/attestation.d.ts +60 -0
  178. package/dist/src/tx/attestation.js +163 -0
  179. package/dist/src/tx/attestation.js.map +1 -0
  180. package/dist/src/tx/content.d.ts +27 -0
  181. package/dist/src/tx/content.js +62 -0
  182. package/dist/src/tx/content.js.map +1 -0
  183. package/dist/src/tx/encode.d.ts +60 -0
  184. package/dist/src/tx/encode.js +82 -0
  185. package/dist/src/tx/encode.js.map +1 -0
  186. package/dist/src/tx/expiry.d.ts +11 -0
  187. package/dist/src/tx/expiry.js +12 -0
  188. package/dist/src/tx/expiry.js.map +1 -0
  189. package/dist/src/tx/fee.d.ts +16 -0
  190. package/dist/src/tx/fee.js +29 -0
  191. package/dist/src/tx/fee.js.map +1 -0
  192. package/dist/src/tx/metadata.d.ts +39 -0
  193. package/dist/src/tx/metadata.js +66 -0
  194. package/dist/src/tx/metadata.js.map +1 -0
  195. package/dist/src/tx/nft.d.ts +16 -0
  196. package/dist/src/tx/nft.js +98 -0
  197. package/dist/src/tx/nft.js.map +1 -0
  198. package/dist/src/tx/proxy.d.ts +37 -0
  199. package/dist/src/tx/proxy.js +134 -0
  200. package/dist/src/tx/proxy.js.map +1 -0
  201. package/dist/src/tx/transfer.d.ts +31 -0
  202. package/dist/src/tx/transfer.js +123 -0
  203. package/dist/src/tx/transfer.js.map +1 -0
  204. package/dist/src/types.d.ts +448 -0
  205. package/dist/src/types.js +2 -0
  206. package/dist/src/types.js.map +1 -0
  207. package/dist/tests/account-id.test.d.ts +1 -0
  208. package/dist/tests/account-id.test.js +27 -0
  209. package/dist/tests/account-id.test.js.map +1 -0
  210. package/dist/tests/amount.test.d.ts +1 -0
  211. package/dist/tests/amount.test.js +113 -0
  212. package/dist/tests/amount.test.js.map +1 -0
  213. package/dist/tests/attestation.test.d.ts +1 -0
  214. package/dist/tests/attestation.test.js +182 -0
  215. package/dist/tests/attestation.test.js.map +1 -0
  216. package/dist/tests/chain.test.d.ts +1 -0
  217. package/dist/tests/chain.test.js +647 -0
  218. package/dist/tests/chain.test.js.map +1 -0
  219. package/dist/tests/content.test.d.ts +1 -0
  220. package/dist/tests/content.test.js +90 -0
  221. package/dist/tests/content.test.js.map +1 -0
  222. package/dist/tests/documented-api.test.d.ts +1 -0
  223. package/dist/tests/documented-api.test.js +229 -0
  224. package/dist/tests/documented-api.test.js.map +1 -0
  225. package/dist/tests/explorer.test.d.ts +1 -0
  226. package/dist/tests/explorer.test.js +95 -0
  227. package/dist/tests/explorer.test.js.map +1 -0
  228. package/dist/tests/fee.test.d.ts +1 -0
  229. package/dist/tests/fee.test.js +179 -0
  230. package/dist/tests/fee.test.js.map +1 -0
  231. package/dist/tests/fixtures/build-vll.d.ts +71 -0
  232. package/dist/tests/fixtures/build-vll.js +141 -0
  233. package/dist/tests/fixtures/build-vll.js.map +1 -0
  234. package/dist/tests/fixtures/fake-socket.d.ts +44 -0
  235. package/dist/tests/fixtures/fake-socket.js +93 -0
  236. package/dist/tests/fixtures/fake-socket.js.map +1 -0
  237. package/dist/tests/fixtures/fake-transport.d.ts +24 -0
  238. package/dist/tests/fixtures/fake-transport.js +30 -0
  239. package/dist/tests/fixtures/fake-transport.js.map +1 -0
  240. package/dist/tests/keypair.test.d.ts +1 -0
  241. package/dist/tests/keypair.test.js +163 -0
  242. package/dist/tests/keypair.test.js.map +1 -0
  243. package/dist/tests/ledger.test.d.ts +1 -0
  244. package/dist/tests/ledger.test.js +234 -0
  245. package/dist/tests/ledger.test.js.map +1 -0
  246. package/dist/tests/mnemonic.test.d.ts +1 -0
  247. package/dist/tests/mnemonic.test.js +97 -0
  248. package/dist/tests/mnemonic.test.js.map +1 -0
  249. package/dist/tests/nft-transfer.test.d.ts +1 -0
  250. package/dist/tests/nft-transfer.test.js +170 -0
  251. package/dist/tests/nft-transfer.test.js.map +1 -0
  252. package/dist/tests/nft.test.d.ts +1 -0
  253. package/dist/tests/nft.test.js +180 -0
  254. package/dist/tests/nft.test.js.map +1 -0
  255. package/dist/tests/offline.test.d.ts +1 -0
  256. package/dist/tests/offline.test.js +95 -0
  257. package/dist/tests/offline.test.js.map +1 -0
  258. package/dist/tests/proxy.test.d.ts +1 -0
  259. package/dist/tests/proxy.test.js +183 -0
  260. package/dist/tests/proxy.test.js.map +1 -0
  261. package/dist/tests/select.test.d.ts +1 -0
  262. package/dist/tests/select.test.js +200 -0
  263. package/dist/tests/select.test.js.map +1 -0
  264. package/dist/tests/socket.test.d.ts +1 -0
  265. package/dist/tests/socket.test.js +607 -0
  266. package/dist/tests/socket.test.js.map +1 -0
  267. package/dist/tests/transfer.test.d.ts +1 -0
  268. package/dist/tests/transfer.test.js +225 -0
  269. package/dist/tests/transfer.test.js.map +1 -0
  270. package/dist/tests/wallet-address.test.d.ts +1 -0
  271. package/dist/tests/wallet-address.test.js +101 -0
  272. package/dist/tests/wallet-address.test.js.map +1 -0
  273. package/dist/tests/wasm-loader.jest.d.ts +13 -0
  274. package/dist/tests/wasm-loader.jest.js +15 -0
  275. package/dist/tests/wasm-loader.jest.js.map +1 -0
  276. package/example/.env.example +4 -0
  277. package/example/README.md +304 -0
  278. package/example/USAGE.md +74 -0
  279. package/example/index.html +12 -0
  280. package/example/package-lock.json +1557 -0
  281. package/example/package.json +25 -0
  282. package/example/scripts/browser-check.mjs +1421 -0
  283. package/example/scripts/match-derivation.mjs +65 -0
  284. package/example/src/App.vue +138 -0
  285. package/example/src/components/AuthorityPanel.vue +277 -0
  286. package/example/src/components/ChainPanel.vue +267 -0
  287. package/example/src/components/ChainState.vue +59 -0
  288. package/example/src/components/CopyButton.vue +25 -0
  289. package/example/src/components/CreateAssetPanel.vue +313 -0
  290. package/example/src/components/DigitalAssetsPanel.vue +68 -0
  291. package/example/src/components/EvidencePanel.vue +396 -0
  292. package/example/src/components/ExplorerPanel.vue +119 -0
  293. package/example/src/components/KeypairPanel.vue +182 -0
  294. package/example/src/components/PhrasePanel.vue +105 -0
  295. package/example/src/components/SocketWarning.vue +18 -0
  296. package/example/src/components/StepGate.vue +24 -0
  297. package/example/src/components/TransferPanel.vue +416 -0
  298. package/example/src/components/TxDeadline.vue +19 -0
  299. package/example/src/components/TxFee.vue +31 -0
  300. package/example/src/components/TxStatus.vue +105 -0
  301. package/example/src/composables/useSocketConnection.ts +80 -0
  302. package/example/src/env.d.ts +12 -0
  303. package/example/src/main.ts +5 -0
  304. package/example/src/pennies.ts +7 -0
  305. package/example/src/style.css +149 -0
  306. package/example/tsconfig.json +19 -0
  307. package/example/vite.config.ts +26 -0
  308. package/jest.config.js +18 -0
  309. package/package.json +2 -6
  310. package/scripts/copy-wasm.mjs +21 -0
  311. package/scripts/smoke.mjs +382 -0
  312. package/src/address/record-type.ts +77 -0
  313. package/src/address/wallet-address.ts +105 -0
  314. package/src/amount.ts +143 -0
  315. package/src/assert.ts +30 -0
  316. package/src/capnp/README.md +15 -0
  317. package/src/capnp/adminNetTx.capnp.ts +66 -0
  318. package/src/capnp/appLayBlock.capnp.ts +26 -0
  319. package/src/capnp/appLayLedger.capnp.ts +35 -0
  320. package/src/capnp/appLayRec.capnp.ts +159 -0
  321. package/src/capnp/chainStateView.capnp.ts +49 -0
  322. package/src/capnp/coinAcctRec.capnp.ts +193 -0
  323. package/src/capnp/genesisBlock.capnp.ts +56 -0
  324. package/src/capnp/hubContentStmt.capnp.ts +59 -0
  325. package/src/capnp/misc.capnp.ts +19 -0
  326. package/src/capnp/netActorRec.capnp.ts +64 -0
  327. package/src/capnp/nodeContentStmt.capnp.ts +62 -0
  328. package/src/capnp/nodePayloadList.capnp.ts +28 -0
  329. package/src/capnp/nodeTxList.capnp.ts +37 -0
  330. package/src/capnp/paramAcctRec.capnp.ts +669 -0
  331. package/src/capnp/payload.capnp.ts +261 -0
  332. package/src/capnp/proxyAcctRec.capnp.ts +259 -0
  333. package/src/capnp/relayContentStmt.capnp.ts +85 -0
  334. package/src/capnp/sysAcctRec.capnp.ts +47 -0
  335. package/src/capnp/userAppTx.capnp.ts +269 -0
  336. package/src/capnp/userValTx.capnp.ts +1999 -0
  337. package/src/capnp/valLayBlock.capnp.ts +93 -0
  338. package/src/capnp/valLayLedger.capnp.ts +80 -0
  339. package/src/chain/geeq-chain.ts +1094 -0
  340. package/src/chain/geeq-node.ts +105 -0
  341. package/src/chain/nonce-guard.ts +73 -0
  342. package/src/chain/select.ts +149 -0
  343. package/src/crypto/account-id.ts +83 -0
  344. package/src/crypto/keypair.ts +221 -0
  345. package/src/crypto/mnemonic.ts +69 -0
  346. package/src/encoding/base64.ts +58 -0
  347. package/src/encoding/hex.ts +42 -0
  348. package/src/errors.ts +122 -0
  349. package/src/index.ts +195 -0
  350. package/src/ledger/coin-accounts.ts +73 -0
  351. package/src/ledger/decode.ts +147 -0
  352. package/src/ledger/geeq-ledger.ts +184 -0
  353. package/src/ledger/net-actors.ts +129 -0
  354. package/src/ledger/nft-records.ts +49 -0
  355. package/src/ledger/params.ts +82 -0
  356. package/src/ledger/proxy-accounts.ts +51 -0
  357. package/src/net/discovery.ts +231 -0
  358. package/src/net/explorer.ts +123 -0
  359. package/src/net/read-ledger.ts +58 -0
  360. package/src/net/routes.ts +79 -0
  361. package/src/net/transport.ts +221 -0
  362. package/src/net/websocket.ts +94 -0
  363. package/src/runtime/bindings.ts +38 -0
  364. package/src/runtime/init.ts +49 -0
  365. package/src/runtime/wasm-loader.browser.ts +22 -0
  366. package/src/runtime/wasm-loader.node.ts +16 -0
  367. package/src/socket/geeq-socket.ts +827 -0
  368. package/src/socket/tracked-tx.ts +319 -0
  369. package/src/socket/tx-status.ts +131 -0
  370. package/src/tx/attestation.ts +222 -0
  371. package/src/tx/content.ts +82 -0
  372. package/src/tx/encode.ts +107 -0
  373. package/src/tx/expiry.ts +11 -0
  374. package/src/tx/fee.ts +31 -0
  375. package/src/tx/metadata.ts +100 -0
  376. package/src/tx/nft.ts +108 -0
  377. package/src/tx/proxy.ts +156 -0
  378. package/src/tx/transfer.ts +162 -0
  379. package/src/types.ts +503 -0
  380. package/src/wasm/README.md +22 -0
  381. package/src/wasm/browser/geeq_core.d.ts +1224 -0
  382. package/src/wasm/browser/geeq_core.js +6014 -0
  383. package/src/wasm/browser/geeq_core_bg.wasm +0 -0
  384. package/src/wasm/browser/geeq_core_bg.wasm.d.ts +447 -0
  385. package/src/wasm/nodejs/geeq_core.d.ts +753 -0
  386. package/src/wasm/nodejs/geeq_core.js +6016 -0
  387. package/src/wasm/nodejs/geeq_core_bg.wasm +0 -0
  388. package/src/wasm/nodejs/geeq_core_bg.wasm.d.ts +447 -0
  389. package/src/wasm/nodejs/package.json +3 -0
  390. package/tsconfig.build.json +8 -0
  391. package/tsconfig.json +21 -0
  392. package/tsup.config.ts +60 -0
@@ -0,0 +1,42 @@
1
+ import type { CoinAcctRec } from '../capnp/coinAcctRec.capnp';
2
+ /** Which coin record subtype an account is. Only `'asset'` may sign an attestation. */
3
+ export type GeeqCoinRecordKind = 'asset' | 'hl' | 'micro' | 'unknown';
4
+ /** One coin account record, as plain values. */
5
+ export interface GeeqCoinAccount {
6
+ readonly accountId: Uint8Array;
7
+ readonly kind: GeeqCoinRecordKind;
8
+ /**
9
+ * `undefined` for a hash-lock record, which carries no nonce field at all, and for a
10
+ * record whose subtype could not be read.
11
+ */
12
+ readonly nonce: number | undefined;
13
+ /** Balance in pennies. Use `formatGeeq` to show it. */
14
+ readonly balance: bigint;
15
+ /** The NFTs it holds, in the order its record lists them. Read for coin-asset records only. */
16
+ readonly nfts: readonly GeeqHeldNft[];
17
+ }
18
+ /** One NFT an account holds, as its record lists it. */
19
+ export interface GeeqHeldNft {
20
+ /** The NFT's 32-byte id. */
21
+ readonly id: Uint8Array;
22
+ /** A counterparty NFT moves only with a counterparty transaction, never a plain transfer. */
23
+ readonly counterparty: boolean;
24
+ }
25
+ /** What we keep per account. The id is the map key, so it is not repeated here. */
26
+ export interface CoinAccountFacts {
27
+ readonly kind: GeeqCoinRecordKind;
28
+ readonly nonce: number | undefined;
29
+ readonly balance: bigint;
30
+ readonly nfts: readonly GeeqHeldNft[];
31
+ }
32
+ /**
33
+ * Read a coin account's subtype and nonce without tripping the union's zero value.
34
+ *
35
+ * `getAsset()` throws on a record of another subtype, and — worse — `ASSET` is the
36
+ * union's zero value, so a record whose tag is unset and whose pointer is null passes
37
+ * capnp-ts's `testWhich`. `getStruct` then calls `initStruct`, MUTATING the decoded
38
+ * message and handing back a zeroed struct whose `getNonce()` is `0`. A silent nonce of
39
+ * zero is the worst possible failure here, so every arm is guarded by both `isX()` and
40
+ * `hasX()` and an unreadable record reports `'unknown'` instead of a number.
41
+ */
42
+ export declare function readCoinAccount(record: CoinAcctRec): CoinAccountFacts;
@@ -0,0 +1,37 @@
1
+ import { uint64ToPennies } from '../amount';
2
+ /**
3
+ * Read a coin account's subtype and nonce without tripping the union's zero value.
4
+ *
5
+ * `getAsset()` throws on a record of another subtype, and — worse — `ASSET` is the
6
+ * union's zero value, so a record whose tag is unset and whose pointer is null passes
7
+ * capnp-ts's `testWhich`. `getStruct` then calls `initStruct`, MUTATING the decoded
8
+ * message and handing back a zeroed struct whose `getNonce()` is `0`. A silent nonce of
9
+ * zero is the worst possible failure here, so every arm is guarded by both `isX()` and
10
+ * `hasX()` and an unreadable record reports `'unknown'` instead of a number.
11
+ */
12
+ export function readCoinAccount(record) {
13
+ const recType = record.getRecType();
14
+ // The balance lives on the outer record, so every subtype has one.
15
+ const balance = uint64ToPennies(record.getAmtCoin());
16
+ if (recType.isAsset()) {
17
+ if (!recType.hasAsset())
18
+ return { kind: 'unknown', nonce: undefined, balance, nfts: [] };
19
+ const asset = recType.getAsset();
20
+ const nfts = asset.getNftAssetSubgroups().toArray().map((nft) => ({
21
+ id: new Uint8Array(nft.getAcctNumApp().toArrayBuffer()),
22
+ counterparty: nft.getFlagCounterpartyNft(),
23
+ }));
24
+ return { kind: 'asset', nonce: asset.getNonce(), balance, nfts };
25
+ }
26
+ if (recType.isHl()) {
27
+ // Hash-lock records have no nonce field in the schema at all.
28
+ return { kind: 'hl', nonce: undefined, balance, nfts: [] };
29
+ }
30
+ if (recType.isMicro()) {
31
+ return recType.hasMicro()
32
+ ? { kind: 'micro', nonce: recType.getMicro().getNonce(), balance, nfts: [] }
33
+ : { kind: 'unknown', nonce: undefined, balance, nfts: [] };
34
+ }
35
+ return { kind: 'unknown', nonce: undefined, balance, nfts: [] };
36
+ }
37
+ //# sourceMappingURL=coin-accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coin-accounts.js","sourceRoot":"","sources":["../../../src/ledger/coin-accounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAoC3C;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,MAAmB;IACjD,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;IACnC,mEAAmE;IACnE,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;IAEpD,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;QACxF,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAA;QAChC,MAAM,IAAI,GAAG,KAAK,CAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAChE,EAAE,EAAE,IAAI,UAAU,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,aAAa,EAAE,CAAC;YACvD,YAAY,EAAE,GAAG,CAAC,sBAAsB,EAAE;SAC3C,CAAC,CAAC,CAAA;QACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAClE,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACnB,8DAA8D;QAC9D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;IAC5D,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtB,OAAO,OAAO,CAAC,QAAQ,EAAE;YACvB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YAC5E,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;IAC9D,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;AACjE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { GeeqLedger } from './geeq-ledger';
2
+ export interface DecodeLedgerOptions {
3
+ /** The node this came from, carried through onto the snapshot. */
4
+ readonly nodeUrl?: string | undefined;
5
+ /** Overrides the read timestamp. For deterministic tests. */
6
+ readonly readAt?: number | undefined;
7
+ }
8
+ /**
9
+ * Decode a validation layer ledger.
10
+ *
11
+ * `source` is what a node's `result` field holds: base64, or the bytes behind it. The
12
+ * message is Cap'n Proto **packed**, which is what the node writes with
13
+ * `toPackedArrayBuffer()` — not the flattened form used for signing.
14
+ *
15
+ * Everything is read in this one pass and the message is then dropped, so the caller
16
+ * gets plain values with no traversal budget attached. See {@link GeeqLedger}.
17
+ */
18
+ export declare function decodeValidationLedger(source: Uint8Array | ArrayBuffer | string, options?: DecodeLedgerOptions): GeeqLedger;
@@ -0,0 +1,113 @@
1
+ import { Message } from 'capnp-ts';
2
+ import { ValLayLedger as CapnpValLayLedger } from '../capnp/valLayLedger.capnp';
3
+ import { MAX_UINT32 } from '../assert';
4
+ import { fromBase64, toBase64 } from '../encoding/base64';
5
+ import { GeeqError, ledgerUnreadable } from '../errors';
6
+ import { readCoinAccount } from './coin-accounts';
7
+ import { GeeqLedger } from './geeq-ledger';
8
+ import { isProcessing, toNodeRole, toNodeStatus } from './net-actors';
9
+ import { readGeeqNorm, readMetadataLimits, readMinimumTransfer } from './params';
10
+ import { readProxyAccount } from './proxy-accounts';
11
+ /**
12
+ * Decode a validation layer ledger.
13
+ *
14
+ * `source` is what a node's `result` field holds: base64, or the bytes behind it. The
15
+ * message is Cap'n Proto **packed**, which is what the node writes with
16
+ * `toPackedArrayBuffer()` — not the flattened form used for signing.
17
+ *
18
+ * Everything is read in this one pass and the message is then dropped, so the caller
19
+ * gets plain values with no traversal budget attached. See {@link GeeqLedger}.
20
+ */
21
+ export function decodeValidationLedger(source, options = {}) {
22
+ const bytes = typeof source === 'string'
23
+ ? fromBase64(source, 'The ledger')
24
+ : source instanceof ArrayBuffer
25
+ ? new Uint8Array(source)
26
+ : source;
27
+ if (bytes.length === 0) {
28
+ throw ledgerUnreadable('The ledger is empty. A node reports this before it has committed its first ' +
29
+ 'block and while it is resyncing — wait and retry, or read from another node ' +
30
+ 'on the same chain.');
31
+ }
32
+ let ledger;
33
+ try {
34
+ ledger = new Message(bytes, true).getRoot(CapnpValLayLedger);
35
+ }
36
+ catch (cause) {
37
+ throw ledgerUnreadable(`Could not decode ${bytes.length} bytes as a packed Cap'n Proto ValLayLedger. ` +
38
+ 'The node is probably running a schema version this SDK does not know — ' +
39
+ 'upgrade @geeqdev/geeq-sdk, or read the chain state yourself.', cause);
40
+ }
41
+ try {
42
+ const chainNumber = ledger.getChainNum();
43
+ const blockNumber = ledger.getBlockNum();
44
+ if (blockNumber >= MAX_UINT32) {
45
+ // Every transaction targets blockNumber + 1, which would overflow the uint32 the
46
+ // protocol encodes it in. Refuse rather than silently wrap to zero.
47
+ throw ledgerUnreadable(`The ledger reports block ${blockNumber}, the maximum a uint32 can hold, so no ` +
48
+ 'transaction can target the next block. The ledger is almost certainly corrupt.');
49
+ }
50
+ const nodes = ledger
51
+ .getNetActorList()
52
+ .getNetActorRecs()
53
+ .toArray()
54
+ .map((record) => {
55
+ const role = toNodeRole(record.getNetActorType());
56
+ const status = toNodeStatus(record.getRecStatus());
57
+ const retiresAtBlock = record.getBlockNumRemove();
58
+ return Object.freeze({
59
+ nodeNumber: record.getNodeNumSelf(),
60
+ host: record.getIpAddr(),
61
+ port: record.getPortNum(),
62
+ role,
63
+ status,
64
+ processing: isProcessing(role, status),
65
+ retiresAtBlock,
66
+ // The node's own guard compares its blockNumRemove against its current block
67
+ // plus two, and the ledger's block is that current block.
68
+ retiring: retiresAtBlock < blockNumber + 2,
69
+ });
70
+ });
71
+ const params = ledger.getParamAcctList().getParamAcctRecs().toArray();
72
+ // A plausibility gate. Packed capnp can "succeed" on garbage and yield a message of
73
+ // zeros, which would otherwise surface much later as chain 0, block 0 and a missing
74
+ // account. A real ledger always carries net actors and parameters.
75
+ if (nodes.length === 0 || params.length === 0) {
76
+ throw ledgerUnreadable(`The ledger decoded but does not look like one: chain ${chainNumber}, block ` +
77
+ `${blockNumber}, ${nodes.length} net actor records, ${params.length} parameter ` +
78
+ 'records. A real ledger always has at least one of each, so this URL is ' +
79
+ 'probably not a Geeq node.');
80
+ }
81
+ const accounts = new Map();
82
+ const coinAccounts = ledger.getCoinAcctRecs();
83
+ for (let index = 0; index < coinAccounts.getLength(); index += 1) {
84
+ const record = coinAccounts.get(index);
85
+ const accountId = new Uint8Array(record.getAcctNumVal().toArrayBuffer());
86
+ accounts.set(toBase64(accountId), readCoinAccount(record));
87
+ }
88
+ const proxies = new Map();
89
+ for (const record of ledger.getProxyAcctRecs().toArray()) {
90
+ const accountId = new Uint8Array(record.getAcctNumVal().toArrayBuffer());
91
+ proxies.set(toBase64(accountId), readProxyAccount(record));
92
+ }
93
+ return new GeeqLedger({
94
+ chainNumber,
95
+ blockNumber,
96
+ nodes,
97
+ metadataLimits: readMetadataLimits(params),
98
+ minimumTransfer: readMinimumTransfer(params),
99
+ geeqNorm: readGeeqNorm(params),
100
+ accounts,
101
+ proxies,
102
+ readAt: options.readAt ?? Date.now(),
103
+ nodeUrl: options.nodeUrl,
104
+ });
105
+ }
106
+ catch (cause) {
107
+ if (cause instanceof GeeqError)
108
+ throw cause;
109
+ throw ledgerUnreadable('The ledger decoded but its contents could not be read. The node is probably ' +
110
+ 'running a schema version this SDK does not know.', cause);
111
+ }
112
+ }
113
+ //# sourceMappingURL=decode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode.js","sourceRoot":"","sources":["../../../src/ledger/decode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AASnD;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAyC,EACzC,UAA+B,EAAE;IAEjC,MAAM,KAAK,GACT,OAAO,MAAM,KAAK,QAAQ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EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;QAC5D,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAA6B,CAAA;QACpD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;YACzD,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,aAAa,EAAE,CAAC,CAAA;YACxE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;QAC5D,CAAC;QAED,OAAO,IAAI,UAAU,CAAC;YACpB,WAAW;YACX,WAAW;YACX,KAAK;YACL,cAAc,EAAE,kBAAkB,CAAC,MAAM,CAAC;YAC1C,eAAe,EAAE,mBAAmB,CAAC,MAAM,CAAC;YAC5C,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC;YAC9B,QAAQ;YACR,OAAO;YACP,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE;YACpC,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,SAAS;YAAE,MAAM,KAAK,CAAA;QAC3C,MAAM,gBAAgB,CACpB,8EAA8E;YAC5E,kDAAkD,EACpD,KAAK,CACN,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,99 @@
1
+ import type { AccountRef } from '../crypto/account-id';
2
+ import type { GeeqMetadataLimits } from '../types';
3
+ import type { CoinAccountFacts, GeeqCoinAccount } from './coin-accounts';
4
+ import type { GeeqLedgerNode } from './net-actors';
5
+ import type { GeeqProxyAccount, ProxyAccountFacts } from './proxy-accounts';
6
+ /** @internal — built by {@link decodeValidationLedger}, never by hand. */
7
+ export interface GeeqLedgerInit {
8
+ readonly chainNumber: number;
9
+ readonly blockNumber: number;
10
+ readonly nodes: readonly GeeqLedgerNode[];
11
+ readonly metadataLimits: GeeqMetadataLimits | undefined;
12
+ readonly minimumTransfer: bigint | undefined;
13
+ readonly geeqNorm: bigint | undefined;
14
+ readonly accounts: ReadonlyMap<string, CoinAccountFacts>;
15
+ readonly proxies: ReadonlyMap<string, ProxyAccountFacts>;
16
+ readonly readAt: number;
17
+ readonly nodeUrl: string | undefined;
18
+ }
19
+ /**
20
+ * One validation layer ledger, decoded into plain values.
21
+ *
22
+ * This is a snapshot, not a view: the Cap'n Proto `Message` it came from is released
23
+ * the moment decoding finishes. That is deliberate and load-bearing. capnp-ts counts a
24
+ * traversal budget per `Message` and never resets it, so a retained handle rescanned on
25
+ * every transaction eventually throws `PTR_TRAVERSAL_LIMIT_EXCEEDED`; and reading a
26
+ * malformed union arm mutates the message in place. Neither can happen to a snapshot.
27
+ *
28
+ * It holds no WebAssembly handle, so unlike a keypair it needs no `dispose()`.
29
+ */
30
+ export declare class GeeqLedger {
31
+ /** The ledger's own chain number. A transaction must name exactly this. */
32
+ readonly chainNumber: number;
33
+ /** N — the last block committed to this ledger. */
34
+ readonly blockNumber: number;
35
+ /** N + 1 — the block a transaction built now should ask for. */
36
+ readonly targetBlockNumber: number;
37
+ /** Every net actor, in ledger order. */
38
+ readonly nodes: readonly GeeqLedgerNode[];
39
+ /** Undefined when this chain publishes no metadata parameters. */
40
+ readonly metadataLimits: GeeqMetadataLimits | undefined;
41
+ /**
42
+ * The smallest transfer this chain accepts, in pennies.
43
+ *
44
+ * Undefined when the chain does not publish the parameters it is derived from.
45
+ */
46
+ readonly minimumTransfer: bigint | undefined;
47
+ /**
48
+ * The chain's `geeqNorm` parameter, which the minimum transfer and every fee are
49
+ * multiples of. Undefined when the chain does not publish it.
50
+ */
51
+ readonly geeqNorm: bigint | undefined;
52
+ /** `Date.now()` when this was read, so callers can judge staleness. */
53
+ readonly readAt: number;
54
+ /** The node it was read from, when it came from one. */
55
+ readonly nodeUrl: string | undefined;
56
+ private readonly accounts;
57
+ private readonly proxies;
58
+ /** @internal */
59
+ constructor(init: GeeqLedgerInit);
60
+ /** The nodes that will actually accept a transaction. */
61
+ get processingNodes(): readonly GeeqLedgerNode[];
62
+ /**
63
+ * Find a net actor record.
64
+ *
65
+ * By `host` this matches the bare IP and nothing else — every first-party client does
66
+ * the same, because a record's `port` is the node's internal listen port while clients
67
+ * connect through a proxy on another one. Matching on both finds nothing.
68
+ */
69
+ findNode(match: {
70
+ readonly host: string;
71
+ } | {
72
+ readonly nodeNumber: number;
73
+ }): GeeqLedgerNode | undefined;
74
+ /** Every net actor record at one host. More than one is possible, and ambiguous. */
75
+ findNodes(host: string): readonly GeeqLedgerNode[];
76
+ /**
77
+ * The signing account's coin record, or `undefined` when this chain has none for it.
78
+ *
79
+ * Absence is the ordinary state of a freshly generated keypair: an account appears in
80
+ * the ledger only once it has been funded.
81
+ */
82
+ findCoinAccount(account: AccountRef): GeeqCoinAccount | undefined;
83
+ /** A proxy record, or `undefined` when this chain has none with that id. */
84
+ findProxyAccount(account: AccountRef): GeeqProxyAccount | undefined;
85
+ /**
86
+ * Every NFT mint proxy an account administers — the ones it can mint through.
87
+ *
88
+ * Found by the admin each record names, so it needs nothing remembered from when they
89
+ * were created.
90
+ */
91
+ findProxyAccounts(match: {
92
+ readonly admin: AccountRef;
93
+ }): readonly GeeqProxyAccount[];
94
+ /** How many coin accounts this ledger carries. Mostly useful for diagnostics. */
95
+ get coinAccountCount(): number;
96
+ /** Summary only — the account table is far too large to serialise. */
97
+ toJSON(): Record<string, unknown>;
98
+ toString(): string;
99
+ }
@@ -0,0 +1,125 @@
1
+ import { resolveAccountId } from '../crypto/account-id';
2
+ import { fromBase64, toBase64 } from '../encoding/base64';
3
+ /**
4
+ * One validation layer ledger, decoded into plain values.
5
+ *
6
+ * This is a snapshot, not a view: the Cap'n Proto `Message` it came from is released
7
+ * the moment decoding finishes. That is deliberate and load-bearing. capnp-ts counts a
8
+ * traversal budget per `Message` and never resets it, so a retained handle rescanned on
9
+ * every transaction eventually throws `PTR_TRAVERSAL_LIMIT_EXCEEDED`; and reading a
10
+ * malformed union arm mutates the message in place. Neither can happen to a snapshot.
11
+ *
12
+ * It holds no WebAssembly handle, so unlike a keypair it needs no `dispose()`.
13
+ */
14
+ export class GeeqLedger {
15
+ /** @internal */
16
+ constructor(init) {
17
+ this.chainNumber = init.chainNumber;
18
+ this.blockNumber = init.blockNumber;
19
+ this.targetBlockNumber = init.blockNumber + 1;
20
+ this.nodes = Object.freeze([...init.nodes]);
21
+ this.metadataLimits = init.metadataLimits;
22
+ this.minimumTransfer = init.minimumTransfer;
23
+ this.geeqNorm = init.geeqNorm;
24
+ this.readAt = init.readAt;
25
+ this.nodeUrl = init.nodeUrl;
26
+ Object.defineProperty(this, 'accounts', {
27
+ value: init.accounts,
28
+ enumerable: false,
29
+ writable: false,
30
+ });
31
+ Object.defineProperty(this, 'proxies', {
32
+ value: init.proxies,
33
+ enumerable: false,
34
+ writable: false,
35
+ });
36
+ }
37
+ /** The nodes that will actually accept a transaction. */
38
+ get processingNodes() {
39
+ return this.nodes.filter((node) => node.processing);
40
+ }
41
+ /**
42
+ * Find a net actor record.
43
+ *
44
+ * By `host` this matches the bare IP and nothing else — every first-party client does
45
+ * the same, because a record's `port` is the node's internal listen port while clients
46
+ * connect through a proxy on another one. Matching on both finds nothing.
47
+ */
48
+ findNode(match) {
49
+ if ('nodeNumber' in match) {
50
+ return this.nodes.find((node) => node.nodeNumber === match.nodeNumber);
51
+ }
52
+ return this.nodes.find((node) => node.host === match.host);
53
+ }
54
+ /** Every net actor record at one host. More than one is possible, and ambiguous. */
55
+ findNodes(host) {
56
+ return this.nodes.filter((node) => node.host === host);
57
+ }
58
+ /**
59
+ * The signing account's coin record, or `undefined` when this chain has none for it.
60
+ *
61
+ * Absence is the ordinary state of a freshly generated keypair: an account appears in
62
+ * the ledger only once it has been funded.
63
+ */
64
+ findCoinAccount(account) {
65
+ const accountId = resolveAccountId(account);
66
+ const facts = this.accounts.get(toBase64(accountId));
67
+ if (facts === undefined)
68
+ return undefined;
69
+ return Object.freeze({
70
+ accountId,
71
+ kind: facts.kind,
72
+ nonce: facts.nonce,
73
+ balance: facts.balance,
74
+ nfts: facts.nfts,
75
+ });
76
+ }
77
+ /** A proxy record, or `undefined` when this chain has none with that id. */
78
+ findProxyAccount(account) {
79
+ const accountId = resolveAccountId(account);
80
+ const facts = this.proxies.get(toBase64(accountId));
81
+ if (facts === undefined)
82
+ return undefined;
83
+ return Object.freeze({ accountId, ...facts });
84
+ }
85
+ /**
86
+ * Every NFT mint proxy an account administers — the ones it can mint through.
87
+ *
88
+ * Found by the admin each record names, so it needs nothing remembered from when they
89
+ * were created.
90
+ */
91
+ findProxyAccounts(match) {
92
+ const admin = toBase64(resolveAccountId(match.admin));
93
+ const found = [];
94
+ for (const [key, facts] of this.proxies) {
95
+ if (facts.admin !== undefined && toBase64(facts.admin) === admin) {
96
+ found.push(Object.freeze({ accountId: fromBase64(key), ...facts }));
97
+ }
98
+ }
99
+ return found;
100
+ }
101
+ /** How many coin accounts this ledger carries. Mostly useful for diagnostics. */
102
+ get coinAccountCount() {
103
+ return this.accounts.size;
104
+ }
105
+ /** Summary only — the account table is far too large to serialise. */
106
+ toJSON() {
107
+ return {
108
+ chainNumber: this.chainNumber,
109
+ blockNumber: this.blockNumber,
110
+ targetBlockNumber: this.targetBlockNumber,
111
+ nodes: this.nodes,
112
+ metadataLimits: this.metadataLimits,
113
+ minimumTransfer: this.minimumTransfer?.toString(),
114
+ geeqNorm: this.geeqNorm?.toString(),
115
+ coinAccountCount: this.coinAccountCount,
116
+ proxyAccountCount: this.proxies.size,
117
+ readAt: this.readAt,
118
+ nodeUrl: this.nodeUrl,
119
+ };
120
+ }
121
+ toString() {
122
+ return `GeeqLedger(chain ${this.chainNumber}, block ${this.blockNumber}, ${this.nodes.length} nodes)`;
123
+ }
124
+ }
125
+ //# sourceMappingURL=geeq-ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3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AC,gBAAgB;YACvC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACpC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,oBAAoB,IAAI,CAAC,WAAW,WAAW,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,SAAS,CAAA;IACvG,CAAC;CACF"}
@@ -0,0 +1,65 @@
1
+ /** What kind of actor a net actor record describes. */
2
+ export type GeeqNodeRole = 'anchor-node' | 'anon-node' | 'cert-node' | 'cert-authority' | 'chain-admin' | 'relay' | 'treasury-agent' | 'unknown';
3
+ /** What that actor is currently doing. */
4
+ export type GeeqNodeStatus = 'chain-admin' | 'hub' | 'leaving' | 'listening' | 'node' | 'ready' | 'relay' | 'suspended' | 'unknown';
5
+ /**
6
+ * Unknown values map to `'unknown'` rather than throwing.
7
+ *
8
+ * This deliberately differs from `fromWasmRecordType`, which throws: a bad record type
9
+ * means a corrupt address, but a new actor kind on a newer chain must not make an
10
+ * otherwise-valid ledger undecodable. An `'unknown'` actor is never `processing`, so
11
+ * the safe outcome is the default.
12
+ */
13
+ export declare function toNodeRole(value: number): GeeqNodeRole;
14
+ export declare function toNodeStatus(value: number): GeeqNodeStatus;
15
+ /**
16
+ * Whether this actor will accept a transaction.
17
+ *
18
+ * Mirrors `isActive()` in the node itself
19
+ * (geeq_node_core/src/wrappers/network-actor-record/index.ts). Anything else answers
20
+ * HTTP 400 `'not processing'`, or — for a relay — registers no handler at all.
21
+ */
22
+ export declare function isProcessing(role: GeeqNodeRole, status: GeeqNodeStatus): boolean;
23
+ /** One net actor record, as plain values. */
24
+ export interface GeeqLedgerNode {
25
+ /** `nodeNumSelf` — what a transaction must name, checked with strict equality. */
26
+ readonly nodeNumber: number;
27
+ /** The bare IP the ledger records. Nodes are matched on this and nothing else. */
28
+ readonly host: string;
29
+ /**
30
+ * The port recorded against this node in the ledger.
31
+ *
32
+ * **Not the port you connect to.** Clients always reach a node on 2082, where TLS is
33
+ * terminated; every first-party client ignores this field and rebuilds the URL from
34
+ * its own configuration. Exposed for diagnostics, and used only to break a tie when
35
+ * one address carries several records.
36
+ */
37
+ readonly port: number;
38
+ readonly role: GeeqNodeRole;
39
+ readonly status: GeeqNodeStatus;
40
+ /**
41
+ * True when the protocol permits this node to accept transactions.
42
+ *
43
+ * **Not a liveness signal.** Nothing in the protocol evicts a crashed node from the
44
+ * net actor list, and `blockNumLiveness` is rewritten for every actor on every commit
45
+ * rather than per node, so it carries no health information at all. A node that died
46
+ * an hour ago still reads as processing here. The only way to learn a node is up is
47
+ * to talk to it.
48
+ */
49
+ readonly processing: boolean;
50
+ /**
51
+ * `blockNumRemove` — the block at which this node's turn in the active set ends.
52
+ *
53
+ * Reset 100–355 blocks ahead each time the node is promoted, so it is a rotation
54
+ * deadline rather than a departure flag.
55
+ */
56
+ readonly retiresAtBlock: number;
57
+ /**
58
+ * True when this node is inside its own shutdown window and will refuse work.
59
+ *
60
+ * The node's submit handler answers HTTP 503 `'Block chain is stopped'` once its
61
+ * `blockNumRemove` is less than its current block plus two, so this is knowable from
62
+ * the ledger before a transaction is ever built.
63
+ */
64
+ readonly retiring: boolean;
65
+ }
@@ -0,0 +1,53 @@
1
+ import { NetActorStatus as CapnpNetActorStatus, NetActorType as CapnpNetActorType, } from '../capnp/netActorRec.capnp';
2
+ const ROLES = Object.freeze({
3
+ [CapnpNetActorType.NET_ACTOR_TYPE_ANCHOR_NODE]: 'anchor-node',
4
+ [CapnpNetActorType.NET_ACTOR_TYPE_ANON_NODE]: 'anon-node',
5
+ [CapnpNetActorType.NET_ACTOR_TYPE_CERT_NODE]: 'cert-node',
6
+ [CapnpNetActorType.NET_ACTOR_TYPE_CERT_AUTH]: 'cert-authority',
7
+ [CapnpNetActorType.NET_ACTOR_TYPE_CHAIN_ADMIN]: 'chain-admin',
8
+ [CapnpNetActorType.NET_ACTOR_TYPE_RELAY]: 'relay',
9
+ [CapnpNetActorType.NET_ACTOR_TYPE_TREASURY_AGENT]: 'treasury-agent',
10
+ });
11
+ const STATUSES = Object.freeze({
12
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_CHAIN_ADMIN]: 'chain-admin',
13
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_HUB]: 'hub',
14
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_LEAVING]: 'leaving',
15
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_LISTENING]: 'listening',
16
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_NODE]: 'node',
17
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_READY]: 'ready',
18
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_RELAY]: 'relay',
19
+ [CapnpNetActorStatus.NET_ACTOR_STATUS_SUSPENDED]: 'suspended',
20
+ });
21
+ /**
22
+ * Unknown values map to `'unknown'` rather than throwing.
23
+ *
24
+ * This deliberately differs from `fromWasmRecordType`, which throws: a bad record type
25
+ * means a corrupt address, but a new actor kind on a newer chain must not make an
26
+ * otherwise-valid ledger undecodable. An `'unknown'` actor is never `processing`, so
27
+ * the safe outcome is the default.
28
+ */
29
+ export function toNodeRole(value) {
30
+ return ROLES[value] ?? 'unknown';
31
+ }
32
+ export function toNodeStatus(value) {
33
+ return STATUSES[value] ?? 'unknown';
34
+ }
35
+ /** Roles that run the transaction handler at all. */
36
+ const PROCESSING_ROLES = new Set([
37
+ 'anon-node',
38
+ 'anchor-node',
39
+ 'cert-node',
40
+ ]);
41
+ /** Statuses in which such a role actually accepts transactions. */
42
+ const PROCESSING_STATUSES = new Set(['node', 'hub']);
43
+ /**
44
+ * Whether this actor will accept a transaction.
45
+ *
46
+ * Mirrors `isActive()` in the node itself
47
+ * (geeq_node_core/src/wrappers/network-actor-record/index.ts). Anything else answers
48
+ * HTTP 400 `'not processing'`, or — for a relay — registers no handler at all.
49
+ */
50
+ export function isProcessing(role, status) {
51
+ return PROCESSING_ROLES.has(role) && PROCESSING_STATUSES.has(status);
52
+ }
53
+ //# sourceMappingURL=net-actors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"net-actors.js","sourceRoot":"","sources":["../../../src/ledger/net-actors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,mBAAmB,EACrC,YAAY,IAAI,iBAAiB,GAClC,MAAM,4BAA4B,CAAA;AAyBnC,MAAM,KAAK,GAA2C,MAAM,CAAC,MAAM,CAAC;IAClE,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,EAAE,aAAa;IAC7D,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,EAAE,WAAW;IACzD,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,EAAE,WAAW;IACzD,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,EAAE,gBAAgB;IAC9D,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,EAAE,aAAa;IAC7D,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,EAAE,OAAO;IACjD,CAAC,iBAAiB,CAAC,6BAA6B,CAAC,EAAE,gBAAgB;CACpE,CAAC,CAAA;AAEF,MAAM,QAAQ,GAA6C,MAAM,CAAC,MAAM,CAAC;IACvE,CAAC,mBAAmB,CAAC,4BAA4B,CAAC,EAAE,aAAa;IACjE,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,EAAE,KAAK;IACjD,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,EAAE,SAAS;IACzD,CAAC,mBAAmB,CAAC,0BAA0B,CAAC,EAAE,WAAW;IAC7D,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,EAAE,MAAM;IACnD,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,EAAE,OAAO;IACrD,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,EAAE,OAAO;IACrD,CAAC,mBAAmB,CAAC,0BAA0B,CAAC,EAAE,WAAW;CAC9D,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,SAAS,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,SAAS,CAAA;AACrC,CAAC;AAED,qDAAqD;AACrD,MAAM,gBAAgB,GAA8B,IAAI,GAAG,CAAe;IACxE,WAAW;IACX,aAAa;IACb,WAAW;CACZ,CAAC,CAAA;AAEF,mEAAmE;AACnE,MAAM,mBAAmB,GAAgC,IAAI,GAAG,CAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA;AAEjG;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAkB,EAAE,MAAsB;IACrE,OAAO,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACtE,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** What the application layer ledger says one NFT stands for. */
2
+ export interface NftRecordFacts {
3
+ readonly attestHash: Uint8Array;
4
+ readonly metadata: readonly string[];
5
+ }
6
+ /**
7
+ * The NFT records in an application layer ledger, keyed by the NFT's base64 id.
8
+ *
9
+ * `source` is what a node's `result` holds for `type=all`: base64 packed Cap'n Proto, the
10
+ * same form as the validation layer ledger. Other application records are skipped. As
11
+ * with that ledger, the message is dropped once read.
12
+ */
13
+ export declare function decodeNftRecords(source: string): Map<string, NftRecordFacts>;
@@ -0,0 +1,41 @@
1
+ import { Message } from 'capnp-ts';
2
+ import { AppLayLedger as CapnpAppLayLedger } from '../capnp/appLayLedger.capnp';
3
+ import { fromBase64, toBase64 } from '../encoding/base64';
4
+ import { ledgerUnreadable } from '../errors';
5
+ /**
6
+ * The NFT records in an application layer ledger, keyed by the NFT's base64 id.
7
+ *
8
+ * `source` is what a node's `result` holds for `type=all`: base64 packed Cap'n Proto, the
9
+ * same form as the validation layer ledger. Other application records are skipped. As
10
+ * with that ledger, the message is dropped once read.
11
+ */
12
+ export function decodeNftRecords(source) {
13
+ const bytes = fromBase64(source, 'The application layer ledger');
14
+ const records = new Map();
15
+ const decoder = new TextDecoder();
16
+ try {
17
+ const ledger = new Message(bytes, true).getRoot(CapnpAppLayLedger);
18
+ for (const record of ledger.getAppLayRecs().toArray()) {
19
+ // `counterparty` is the union's zero value, so the arm is checked before it is read.
20
+ const recType = record.getRecType();
21
+ if (!recType.isNft() || !recType.hasNft())
22
+ continue;
23
+ const data = recType.getNft().getAttestationSubgroup().getData();
24
+ const metadata = data
25
+ .getMetadata()
26
+ .toArray()
27
+ .sort((a, b) => a.getPosition() - b.getPosition())
28
+ .map((entry) => decoder.decode(new Uint8Array(entry.getItem().toArrayBuffer())));
29
+ records.set(toBase64(new Uint8Array(record.getAcctNumApp().toArrayBuffer())), {
30
+ attestHash: new Uint8Array(data.getAttestHash().toArrayBuffer()),
31
+ metadata,
32
+ });
33
+ }
34
+ }
35
+ catch (cause) {
36
+ throw ledgerUnreadable('The application layer ledger could not be read. The node is probably running a ' +
37
+ 'schema version this SDK does not know.', cause);
38
+ }
39
+ return records;
40
+ }
41
+ //# sourceMappingURL=nft-records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nft-records.js","sourceRoot":"","sources":["../../../src/ledger/nft-records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAQ5C;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAA;IAChE,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CA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