@gnolang/tm2-js-client 1.3.2 → 2.0.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 (312) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs +12 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs +12 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.cjs +14 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.mjs +14 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.cjs +9 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.mjs +9 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.cjs +16 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.mjs +11 -0
  10. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  11. package/dist/index.cjs +92 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.cts +23 -0
  14. package/dist/index.d.cts.map +1 -0
  15. package/dist/index.d.mts +23 -0
  16. package/dist/index.d.mts.map +1 -0
  17. package/dist/index.mjs +22 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/proto/google/protobuf/any.cjs +84 -0
  20. package/dist/proto/google/protobuf/any.cjs.map +1 -0
  21. package/dist/proto/google/protobuf/any.d.cts +141 -0
  22. package/dist/proto/google/protobuf/any.d.cts.map +1 -0
  23. package/dist/proto/google/protobuf/any.d.mts +141 -0
  24. package/dist/proto/google/protobuf/any.d.mts.map +1 -0
  25. package/dist/proto/google/protobuf/any.mjs +83 -0
  26. package/dist/proto/google/protobuf/any.mjs.map +1 -0
  27. package/dist/proto/index.cjs +2 -0
  28. package/dist/proto/index.d.cts +2 -0
  29. package/dist/proto/index.d.mts +2 -0
  30. package/dist/proto/index.mjs +3 -0
  31. package/dist/proto/tm2/abci.cjs +182 -0
  32. package/dist/proto/tm2/abci.cjs.map +1 -0
  33. package/dist/proto/tm2/abci.d.cts +33 -0
  34. package/dist/proto/tm2/abci.d.cts.map +1 -0
  35. package/dist/proto/tm2/abci.d.mts +33 -0
  36. package/dist/proto/tm2/abci.d.mts.map +1 -0
  37. package/dist/proto/tm2/abci.mjs +181 -0
  38. package/dist/proto/tm2/abci.mjs.map +1 -0
  39. package/dist/proto/tm2/tx.cjs +263 -0
  40. package/dist/proto/tm2/tx.cjs.map +1 -0
  41. package/dist/proto/tm2/tx.d.cts +49 -0
  42. package/dist/proto/tm2/tx.d.cts.map +1 -0
  43. package/dist/proto/tm2/tx.d.mts +49 -0
  44. package/dist/proto/tm2/tx.d.mts.map +1 -0
  45. package/dist/proto/tm2/tx.mjs +258 -0
  46. package/dist/proto/tm2/tx.mjs.map +1 -0
  47. package/dist/provider/endpoints.cjs +43 -0
  48. package/dist/provider/endpoints.cjs.map +1 -0
  49. package/dist/provider/endpoints.d.cts +33 -0
  50. package/dist/provider/endpoints.d.cts.map +1 -0
  51. package/dist/provider/endpoints.d.mts +33 -0
  52. package/dist/provider/endpoints.d.mts.map +1 -0
  53. package/dist/provider/endpoints.mjs +39 -0
  54. package/dist/provider/endpoints.mjs.map +1 -0
  55. package/dist/provider/errors/errors.cjs +122 -0
  56. package/dist/provider/errors/errors.cjs.map +1 -0
  57. package/dist/provider/errors/errors.d.cts +62 -0
  58. package/dist/provider/errors/errors.d.cts.map +1 -0
  59. package/dist/provider/errors/errors.d.mts +62 -0
  60. package/dist/provider/errors/errors.d.mts.map +1 -0
  61. package/dist/provider/errors/errors.mjs +104 -0
  62. package/dist/provider/errors/errors.mjs.map +1 -0
  63. package/dist/provider/errors/messages.cjs +40 -0
  64. package/dist/provider/errors/messages.cjs.map +1 -0
  65. package/dist/provider/errors/messages.mjs +23 -0
  66. package/dist/provider/errors/messages.mjs.map +1 -0
  67. package/dist/provider/index.cjs +12 -0
  68. package/dist/provider/index.d.cts +11 -0
  69. package/dist/provider/index.d.mts +11 -0
  70. package/dist/provider/index.mjs +13 -0
  71. package/dist/provider/jsonrpc/index.cjs +1 -0
  72. package/dist/provider/jsonrpc/index.d.cts +1 -0
  73. package/dist/provider/jsonrpc/index.d.mts +1 -0
  74. package/dist/provider/jsonrpc/index.mjs +2 -0
  75. package/dist/provider/jsonrpc/jsonrpc.cjs +20 -0
  76. package/dist/provider/jsonrpc/jsonrpc.cjs.map +1 -0
  77. package/dist/provider/jsonrpc/jsonrpc.d.cts +16 -0
  78. package/dist/provider/jsonrpc/jsonrpc.d.cts.map +1 -0
  79. package/dist/provider/jsonrpc/jsonrpc.d.mts +16 -0
  80. package/dist/provider/jsonrpc/jsonrpc.d.mts.map +1 -0
  81. package/dist/provider/jsonrpc/jsonrpc.mjs +19 -0
  82. package/dist/provider/jsonrpc/jsonrpc.mjs.map +1 -0
  83. package/dist/provider/provider.cjs +130 -0
  84. package/dist/provider/provider.cjs.map +1 -0
  85. package/dist/provider/provider.d.cts +130 -0
  86. package/dist/provider/provider.d.cts.map +1 -0
  87. package/dist/provider/provider.d.mts +130 -0
  88. package/dist/provider/provider.d.mts.map +1 -0
  89. package/dist/provider/provider.mjs +130 -0
  90. package/dist/provider/provider.mjs.map +1 -0
  91. package/dist/provider/types/abci.cjs +6 -0
  92. package/dist/provider/types/abci.cjs.map +1 -0
  93. package/dist/provider/types/abci.d.cts +42 -0
  94. package/dist/provider/types/abci.d.cts.map +1 -0
  95. package/dist/provider/types/abci.d.mts +42 -0
  96. package/dist/provider/types/abci.d.mts.map +1 -0
  97. package/dist/provider/types/abci.mjs +6 -0
  98. package/dist/provider/types/abci.mjs.map +1 -0
  99. package/dist/provider/types/common.d.cts +186 -0
  100. package/dist/provider/types/common.d.cts.map +1 -0
  101. package/dist/provider/types/common.d.mts +186 -0
  102. package/dist/provider/types/common.d.mts.map +1 -0
  103. package/dist/provider/types/jsonrpc.d.cts +30 -0
  104. package/dist/provider/types/jsonrpc.d.cts.map +1 -0
  105. package/dist/provider/types/jsonrpc.d.mts +30 -0
  106. package/dist/provider/types/jsonrpc.d.mts.map +1 -0
  107. package/dist/provider/utility/adapters.cjs +241 -0
  108. package/dist/provider/utility/adapters.cjs.map +1 -0
  109. package/dist/provider/utility/adapters.d.cts +19 -0
  110. package/dist/provider/utility/adapters.d.cts.map +1 -0
  111. package/dist/provider/utility/adapters.d.mts +19 -0
  112. package/dist/provider/utility/adapters.d.mts.map +1 -0
  113. package/dist/provider/utility/adapters.mjs +231 -0
  114. package/dist/provider/utility/adapters.mjs.map +1 -0
  115. package/dist/provider/utility/errors.utility.cjs +38 -0
  116. package/dist/provider/utility/errors.utility.cjs.map +1 -0
  117. package/dist/provider/utility/errors.utility.mjs +38 -0
  118. package/dist/provider/utility/errors.utility.mjs.map +1 -0
  119. package/dist/provider/utility/index.cjs +3 -0
  120. package/dist/provider/utility/index.d.cts +3 -0
  121. package/dist/provider/utility/index.d.mts +3 -0
  122. package/dist/provider/utility/index.mjs +4 -0
  123. package/dist/provider/utility/provider.utility.cjs +122 -0
  124. package/dist/provider/utility/provider.utility.cjs.map +1 -0
  125. package/{bin/provider/utility/provider.utility.d.ts → dist/provider/utility/provider.utility.d.cts} +15 -10
  126. package/dist/provider/utility/provider.utility.d.cts.map +1 -0
  127. package/dist/provider/utility/provider.utility.d.mts +45 -0
  128. package/dist/provider/utility/provider.utility.d.mts.map +1 -0
  129. package/dist/provider/utility/provider.utility.mjs +116 -0
  130. package/dist/provider/utility/provider.utility.mjs.map +1 -0
  131. package/dist/provider/utility/requests.utility.cjs +75 -0
  132. package/dist/provider/utility/requests.utility.cjs.map +1 -0
  133. package/dist/provider/utility/requests.utility.d.cts +40 -0
  134. package/dist/provider/utility/requests.utility.d.cts.map +1 -0
  135. package/dist/provider/utility/requests.utility.d.mts +40 -0
  136. package/dist/provider/utility/requests.utility.d.mts.map +1 -0
  137. package/dist/provider/utility/requests.utility.mjs +68 -0
  138. package/dist/provider/utility/requests.utility.mjs.map +1 -0
  139. package/dist/provider/websocket/index.cjs +1 -0
  140. package/dist/provider/websocket/index.d.cts +1 -0
  141. package/dist/provider/websocket/index.d.mts +1 -0
  142. package/dist/provider/websocket/index.mjs +2 -0
  143. package/dist/provider/websocket/ws.cjs +27 -0
  144. package/dist/provider/websocket/ws.cjs.map +1 -0
  145. package/dist/provider/websocket/ws.d.cts +21 -0
  146. package/dist/provider/websocket/ws.d.cts.map +1 -0
  147. package/dist/provider/websocket/ws.d.mts +21 -0
  148. package/dist/provider/websocket/ws.d.mts.map +1 -0
  149. package/dist/provider/websocket/ws.mjs +26 -0
  150. package/dist/provider/websocket/ws.mjs.map +1 -0
  151. package/dist/services/index.cjs +1 -0
  152. package/dist/services/index.d.cts +2 -0
  153. package/dist/services/index.d.mts +2 -0
  154. package/dist/services/index.mjs +2 -0
  155. package/dist/services/rest/restService.cjs +16 -0
  156. package/dist/services/rest/restService.cjs.map +1 -0
  157. package/dist/services/rest/restService.d.cts +9 -0
  158. package/dist/services/rest/restService.d.cts.map +1 -0
  159. package/dist/services/rest/restService.d.mts +9 -0
  160. package/dist/services/rest/restService.d.mts.map +1 -0
  161. package/dist/services/rest/restService.mjs +14 -0
  162. package/dist/services/rest/restService.mjs.map +1 -0
  163. package/dist/services/rest/restService.types.d.cts +11 -0
  164. package/dist/services/rest/restService.types.d.cts.map +1 -0
  165. package/dist/services/rest/restService.types.d.mts +11 -0
  166. package/dist/services/rest/restService.types.d.mts.map +1 -0
  167. package/dist/wallet/index.cjs +8 -0
  168. package/dist/wallet/index.d.cts +7 -0
  169. package/dist/wallet/index.d.mts +7 -0
  170. package/dist/wallet/index.mjs +9 -0
  171. package/dist/wallet/key/index.cjs +1 -0
  172. package/dist/wallet/key/index.mjs +2 -0
  173. package/dist/wallet/key/key.cjs +46 -0
  174. package/dist/wallet/key/key.cjs.map +1 -0
  175. package/dist/wallet/key/key.d.cts +26 -0
  176. package/dist/wallet/key/key.d.cts.map +1 -0
  177. package/dist/wallet/key/key.d.mts +26 -0
  178. package/dist/wallet/key/key.d.mts.map +1 -0
  179. package/dist/wallet/key/key.mjs +45 -0
  180. package/dist/wallet/key/key.mjs.map +1 -0
  181. package/dist/wallet/ledger/index.cjs +1 -0
  182. package/dist/wallet/ledger/index.d.cts +1 -0
  183. package/dist/wallet/ledger/index.d.mts +1 -0
  184. package/dist/wallet/ledger/index.mjs +2 -0
  185. package/dist/wallet/ledger/ledger.cjs +49 -0
  186. package/dist/wallet/ledger/ledger.cjs.map +1 -0
  187. package/dist/wallet/ledger/ledger.d.cts +27 -0
  188. package/dist/wallet/ledger/ledger.d.cts.map +1 -0
  189. package/dist/wallet/ledger/ledger.d.mts +27 -0
  190. package/dist/wallet/ledger/ledger.d.mts.map +1 -0
  191. package/dist/wallet/ledger/ledger.mjs +48 -0
  192. package/dist/wallet/ledger/ledger.mjs.map +1 -0
  193. package/dist/wallet/signer.d.cts +33 -0
  194. package/dist/wallet/signer.d.cts.map +1 -0
  195. package/dist/wallet/signer.d.mts +33 -0
  196. package/dist/wallet/signer.d.mts.map +1 -0
  197. package/dist/wallet/types/sign.cjs +6 -0
  198. package/dist/wallet/types/sign.cjs.map +1 -0
  199. package/dist/wallet/types/sign.d.cts +20 -0
  200. package/dist/wallet/types/sign.d.cts.map +1 -0
  201. package/dist/wallet/types/sign.d.mts +20 -0
  202. package/dist/wallet/types/sign.d.mts.map +1 -0
  203. package/dist/wallet/types/sign.mjs +6 -0
  204. package/dist/wallet/types/sign.mjs.map +1 -0
  205. package/dist/wallet/types/wallet.d.cts +9 -0
  206. package/dist/wallet/types/wallet.d.cts.map +1 -0
  207. package/dist/wallet/types/wallet.d.mts +9 -0
  208. package/dist/wallet/types/wallet.d.mts.map +1 -0
  209. package/dist/wallet/utility/index.cjs +1 -0
  210. package/dist/wallet/utility/index.d.cts +1 -0
  211. package/dist/wallet/utility/index.d.mts +1 -0
  212. package/dist/wallet/utility/index.mjs +2 -0
  213. package/dist/wallet/utility/utility.cjs +83 -0
  214. package/dist/wallet/utility/utility.cjs.map +1 -0
  215. package/dist/wallet/utility/utility.d.cts +42 -0
  216. package/dist/wallet/utility/utility.d.cts.map +1 -0
  217. package/dist/wallet/utility/utility.d.mts +42 -0
  218. package/dist/wallet/utility/utility.d.mts.map +1 -0
  219. package/dist/wallet/utility/utility.mjs +75 -0
  220. package/dist/wallet/utility/utility.mjs.map +1 -0
  221. package/dist/wallet/wallet.cjs +223 -0
  222. package/dist/wallet/wallet.cjs.map +1 -0
  223. package/dist/wallet/wallet.d.cts +113 -0
  224. package/dist/wallet/wallet.d.cts.map +1 -0
  225. package/dist/wallet/wallet.d.mts +113 -0
  226. package/dist/wallet/wallet.d.mts.map +1 -0
  227. package/dist/wallet/wallet.mjs +222 -0
  228. package/dist/wallet/wallet.mjs.map +1 -0
  229. package/package.json +57 -38
  230. package/bin/index.d.ts +0 -4
  231. package/bin/index.js +0 -20
  232. package/bin/proto/google/protobuf/any.d.ts +0 -145
  233. package/bin/proto/google/protobuf/any.js +0 -113
  234. package/bin/proto/index.d.ts +0 -2
  235. package/bin/proto/index.js +0 -20
  236. package/bin/proto/tm2/abci.d.ts +0 -37
  237. package/bin/proto/tm2/abci.js +0 -277
  238. package/bin/proto/tm2/tx.d.ts +0 -52
  239. package/bin/proto/tm2/tx.js +0 -360
  240. package/bin/provider/endpoints.d.ts +0 -29
  241. package/bin/provider/endpoints.js +0 -37
  242. package/bin/provider/errors/errors.d.ts +0 -59
  243. package/bin/provider/errors/errors.js +0 -173
  244. package/bin/provider/errors/index.d.ts +0 -1
  245. package/bin/provider/errors/index.js +0 -17
  246. package/bin/provider/errors/messages.d.ts +0 -19
  247. package/bin/provider/errors/messages.js +0 -41
  248. package/bin/provider/index.d.ts +0 -7
  249. package/bin/provider/index.js +0 -23
  250. package/bin/provider/jsonrpc/index.d.ts +0 -1
  251. package/bin/provider/jsonrpc/index.js +0 -17
  252. package/bin/provider/jsonrpc/jsonrpc.d.ts +0 -31
  253. package/bin/provider/jsonrpc/jsonrpc.js +0 -327
  254. package/bin/provider/jsonrpc/jsonrpc.test.d.ts +0 -1
  255. package/bin/provider/jsonrpc/jsonrpc.test.js +0 -488
  256. package/bin/provider/provider.d.ts +0 -98
  257. package/bin/provider/provider.js +0 -2
  258. package/bin/provider/types/abci.d.ts +0 -39
  259. package/bin/provider/types/abci.js +0 -4
  260. package/bin/provider/types/common.d.ts +0 -184
  261. package/bin/provider/types/common.js +0 -3
  262. package/bin/provider/types/index.d.ts +0 -3
  263. package/bin/provider/types/index.js +0 -19
  264. package/bin/provider/types/jsonrpc.d.ts +0 -26
  265. package/bin/provider/types/jsonrpc.js +0 -2
  266. package/bin/provider/utility/errors.utility.d.ts +0 -11
  267. package/bin/provider/utility/errors.utility.js +0 -56
  268. package/bin/provider/utility/index.d.ts +0 -2
  269. package/bin/provider/utility/index.js +0 -18
  270. package/bin/provider/utility/provider.utility.js +0 -244
  271. package/bin/provider/utility/requests.utility.d.ts +0 -35
  272. package/bin/provider/utility/requests.utility.js +0 -80
  273. package/bin/provider/websocket/index.d.ts +0 -1
  274. package/bin/provider/websocket/index.js +0 -17
  275. package/bin/provider/websocket/ws.d.ts +0 -58
  276. package/bin/provider/websocket/ws.js +0 -415
  277. package/bin/provider/websocket/ws.test.d.ts +0 -1
  278. package/bin/provider/websocket/ws.test.js +0 -648
  279. package/bin/services/index.d.ts +0 -2
  280. package/bin/services/index.js +0 -18
  281. package/bin/services/rest/restService.d.ts +0 -4
  282. package/bin/services/rest/restService.js +0 -72
  283. package/bin/services/rest/restService.types.d.ts +0 -6
  284. package/bin/services/rest/restService.types.js +0 -2
  285. package/bin/wallet/index.d.ts +0 -6
  286. package/bin/wallet/index.js +0 -22
  287. package/bin/wallet/key/index.d.ts +0 -1
  288. package/bin/wallet/key/index.js +0 -17
  289. package/bin/wallet/key/key.d.ts +0 -21
  290. package/bin/wallet/key/key.js +0 -102
  291. package/bin/wallet/key/key.test.d.ts +0 -1
  292. package/bin/wallet/key/key.test.js +0 -121
  293. package/bin/wallet/ledger/index.d.ts +0 -1
  294. package/bin/wallet/ledger/index.js +0 -17
  295. package/bin/wallet/ledger/ledger.d.ts +0 -22
  296. package/bin/wallet/ledger/ledger.js +0 -109
  297. package/bin/wallet/signer.d.ts +0 -29
  298. package/bin/wallet/signer.js +0 -2
  299. package/bin/wallet/types/index.d.ts +0 -2
  300. package/bin/wallet/types/index.js +0 -18
  301. package/bin/wallet/types/sign.d.ts +0 -16
  302. package/bin/wallet/types/sign.js +0 -4
  303. package/bin/wallet/types/wallet.d.ts +0 -5
  304. package/bin/wallet/types/wallet.js +0 -2
  305. package/bin/wallet/utility/index.d.ts +0 -1
  306. package/bin/wallet/utility/index.js +0 -17
  307. package/bin/wallet/utility/utility.d.ts +0 -36
  308. package/bin/wallet/utility/utility.js +0 -117
  309. package/bin/wallet/wallet.d.ts +0 -102
  310. package/bin/wallet/wallet.js +0 -354
  311. package/bin/wallet/wallet.test.d.ts +0 -1
  312. package/bin/wallet/wallet.test.js +0 -352
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.cjs","names":["uint8ArrayToBase64","Tx","extractSimulateFromResponse","adaptAbciQueryResponse","constructRequestError","extractBalanceFromResponse","adaptBlockResponse","adaptBlockResultsResponse","adaptConsensusParamsResponse","adaptNetInfoResponse","extractSequenceFromResponse","extractAccountNumberFromResponse","extractAccountFromResponse","adaptStatusResponse","adaptTxResponse","TransactionEndpoint","adaptBroadcastTxSyncResponse","ABCIErrorKey","adaptBroadcastTxCommitResponse","waitForTransaction"],"sources":["../../src/provider/provider.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n Tx,\n} from \"../proto/index.js\";\nimport {\n TransactionEndpoint,\n} from \"./endpoints.js\";\nimport {\n ABCIAccount,\n ABCIErrorKey,\n ABCIResponse,\n BlockInfo,\n BlockResult,\n BroadcastAsGeneric,\n BroadcastTransactionMap,\n BroadcastTxCommitResult,\n BroadcastTxSyncResult,\n ConsensusParams,\n NetworkInfo,\n Status,\n TxResult,\n} from \"./types/index.js\";\nimport {\n constructRequestError,\n} from \"./utility/errors.utility.js\";\nimport {\n adaptAbciQueryResponse,\n adaptBlockResponse,\n adaptBlockResultsResponse,\n adaptBroadcastTxCommitResponse,\n adaptBroadcastTxSyncResponse,\n adaptConsensusParamsResponse,\n adaptNetInfoResponse,\n adaptStatusResponse,\n adaptTxResponse,\n extractAccountFromResponse,\n extractAccountNumberFromResponse,\n extractBalanceFromResponse,\n extractSequenceFromResponse,\n extractSimulateFromResponse,\n uint8ArrayToBase64,\n waitForTransaction,\n} from \"./utility/index.js\";\n\n/**\n * Read-only abstraction for accessing blockchain data\n */\nexport interface Provider {\n // Account-specific methods //\n\n /**\n * Fetches the denomination balance of the account\n * @param {string} address the bech32 address of the account\n * @param {string} [denomination=ugnot] the balance denomination\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getBalance(\n address: string,\n denomination?: string,\n height?: number\n ): Promise<number>\n\n /**\n * Fetches the account sequence\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used.\n * @deprecated use {@link getAccount} instead\n */\n getAccountSequence(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account number. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n * @deprecated use {@link getAccount} instead\n */\n getAccountNumber(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getAccount(address: string, height?: number): Promise<ABCIAccount>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlock(height: number): Promise<BlockInfo>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlockResult(height: number): Promise<BlockResult>\n\n /**\n * Fetches the latest block number from the chain\n */\n getBlockNumber(): Promise<number>\n\n // Network-specific methods //\n\n /**\n * Fetches the network information\n */\n getNetwork(): Promise<NetworkInfo>\n\n /**\n * Fetches the consensus params for the specific block height\n * @param {number} height the height for querying\n */\n getConsensusParams(height: number): Promise<ConsensusParams>\n\n /**\n * Fetches the current node status\n */\n getStatus(): Promise<Status>\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice(): Promise<number>\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas(tx: Tx): Promise<bigint>\n\n // Transaction specific methods //\n\n /**\n * Sends the transaction to the node. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction broadcast result.\n * @param {string} tx the base64-encoded signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K\n ): Promise<BroadcastAsGeneric<K>[\"result\"]>\n\n /**\n * Waits for the transaction to be committed on the chain.\n * NOTE: This method will not take in the fromHeight parameter once\n * proper transaction indexing is added - the implementation should\n * simply try to fetch the transaction first to see if it's included in a block\n * before starting to wait for it; Until then, this method should be used\n * in the sequence:\n * get latest block -> send transaction -> waitForTransaction(block before send)\n * @param {string} hash The transaction hash\n * @param {number} [fromHeight=latest] The block height used to begin the search\n * @param {number} [timeout=15000] Optional wait timeout in MS\n */\n waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number\n ): Promise<Tx>\n}\n\n/**\n * Base provider implementation backed by a Tm2Client.\n * Subclasses only need to provide a static `create()` factory.\n */\nexport abstract class BaseTm2Provider implements Provider {\n protected readonly client: Tm2Client;\n\n protected constructor(client: Tm2Client) {\n this.client = client;\n }\n\n async estimateGas(tx: Tx): Promise<bigint> {\n const encodedTx = uint8ArrayToBase64(Tx.encode(tx).finish());\n const rpcResponse = await this.client.abciQuery({\n path: \".app/simulate\",\n data: new TextEncoder().encode(encodedTx),\n height: 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n const simulateResult = extractSimulateFromResponse(abciResponse);\n\n const resultErrorKey = simulateResult.response_base?.error?.type_url;\n if (resultErrorKey) {\n throw constructRequestError(resultErrorKey);\n }\n\n return simulateResult.gas_used;\n }\n\n async getBalance(\n address: string,\n denomination?: string,\n height?: number,\n ): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `bank/balances/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n\n return extractBalanceFromResponse(\n abciResponse.response.ResponseBase.Data,\n denomination ? denomination : \"ugnot\",\n );\n }\n\n async getBlock(height: number): Promise<BlockInfo> {\n const rpcResponse = await this.client.block(height);\n return adaptBlockResponse(rpcResponse);\n }\n\n async getBlockResult(height: number): Promise<BlockResult> {\n const rpcResponse = await this.client.blockResults(height);\n return adaptBlockResultsResponse(rpcResponse);\n }\n\n async getBlockNumber(): Promise<number> {\n const status = await this.getStatus();\n return parseInt(status.sync_info.latest_block_height);\n }\n\n async getConsensusParams(height: number): Promise<ConsensusParams> {\n const rpcResponse = await this.client.consensusParams(height);\n return adaptConsensusParamsResponse(rpcResponse);\n }\n\n getGasPrice(): Promise<number> {\n return Promise.reject(\"not supported\");\n }\n\n async getNetwork(): Promise<NetworkInfo> {\n const rpcResponse = await this.client.netInfo();\n return adaptNetInfoResponse(rpcResponse);\n }\n\n async getAccountSequence(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractSequenceFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getAccountNumber(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountNumberFromResponse(\n abciResponse.response.ResponseBase.Data,\n );\n }\n\n async getAccount(address: string, height?: number): Promise<ABCIAccount> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getStatus(): Promise<Status> {\n const rpcResponse = await this.client.status();\n return adaptStatusResponse(rpcResponse);\n }\n\n async getTransaction(hash: string): Promise<TxResult> {\n const hashBytes = Uint8Array.from(\n (hash.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)),\n );\n const rpcResponse = await this.client.tx({\n hash: hashBytes,\n });\n return adaptTxResponse(rpcResponse);\n }\n\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n const txBytes = Uint8Array.from(Buffer.from(tx, \"base64\"));\n\n switch (endpoint) {\n case TransactionEndpoint.BROADCAST_TX_COMMIT:\n return this.broadcastTxCommit(txBytes);\n case TransactionEndpoint.BROADCAST_TX_SYNC:\n default:\n return this.broadcastTxSync(txBytes);\n }\n }\n\n private async broadcastTxSync(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxSyncResult> {\n const rpcResponse = await this.client.broadcastTxSync({\n tx: txBytes,\n });\n const response = adaptBroadcastTxSyncResponse(rpcResponse);\n\n if (response.error) {\n const errType: string = response.error[ABCIErrorKey];\n const log: string = response.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n private async broadcastTxCommit(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxCommitResult> {\n const rpcResponse = await this.client.broadcastTxCommit({\n tx: txBytes,\n });\n const response = adaptBroadcastTxCommitResponse(rpcResponse);\n\n const {\n check_tx, deliver_tx,\n } = response;\n\n if (check_tx.ResponseBase.Error) {\n const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = check_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n if (deliver_tx.ResponseBase.Error) {\n const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = deliver_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n async waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number,\n ): Promise<Tx> {\n return waitForTransaction(this, hash, fromHeight, timeout);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkLA,IAAsB,kBAAtB,MAA0D;CAGxD,YAAsB,QAAmB;+CAFtB,UAAA,KAAA,EAAkB;AAGnC,OAAK,SAAS;;CAGhB,MAAM,YAAY,IAAyB;EACzC,MAAM,YAAYA,yBAAAA,mBAAmBC,WAAAA,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC;EAS5D,MAAM,iBAAiBC,yBAAAA,4BADYC,iBAAAA,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM;GACN,MAAM,IAAI,aAAa,CAAC,OAAO,UAAU;GACzC,QAAQ;GACR,OAAO;GACR,CAAC,CAEoE,CACN;EAEhE,MAAM,iBAAiB,eAAe,eAAe,OAAO;AAC5D,MAAI,eACF,OAAMC,uBAAAA,sBAAsB,eAAe;AAG7C,SAAO,eAAe;;CAGxB,MAAM,WACJ,SACA,cACA,QACiB;AAUjB,SAAOC,yBAAAA,2BAF4BF,iBAAAA,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM,iBAAiB;GACvB,MAAM,IAAI,YAAY;GACtB,QAAQ,SAAS,SAAS;GAC1B,OAAO;GACR,CAAC,CAEoE,CAGvD,SAAS,aAAa,MACnC,eAAe,eAAe,QAC/B;;CAGH,MAAM,SAAS,QAAoC;AAE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AGT,MAAM,mBACJ,MACA,YACA,SACa;AACb,SAAOe,yBAAAA,mBAAmB,MAAM,MAAM,YAAY,QAAQ"}
@@ -0,0 +1,130 @@
1
+ import { Tx } from "../proto/tm2/tx.cjs";
2
+ import { ABCIAccount } from "./types/abci.cjs";
3
+ import { BlockInfo, BlockResult, BroadcastAsGeneric, BroadcastTransactionMap, ConsensusParams, NetworkInfo, Status, TxResult } from "./types/common.cjs";
4
+ import { Tm2Client } from "@gnolang/tm2-rpc";
5
+
6
+ //#region src/provider/provider.d.ts
7
+ /**
8
+ * Read-only abstraction for accessing blockchain data
9
+ */
10
+ interface Provider {
11
+ /**
12
+ * Fetches the denomination balance of the account
13
+ * @param {string} address the bech32 address of the account
14
+ * @param {string} [denomination=ugnot] the balance denomination
15
+ * @param {number} [height=0] the height for querying.
16
+ * If omitted, the latest height is used
17
+ */
18
+ getBalance(address: string, denomination?: string, height?: number): Promise<number>;
19
+ /**
20
+ * Fetches the account sequence
21
+ * @param {string} address the bech32 address of the account
22
+ * @param {number} [height=0] the height for querying.
23
+ * If omitted, the latest height is used.
24
+ * @deprecated use {@link getAccount} instead
25
+ */
26
+ getAccountSequence(address: string, height?: number): Promise<number>;
27
+ /**
28
+ * Fetches the account number. Errors out if the account
29
+ * is not initialized
30
+ * @param {string} address the bech32 address of the account
31
+ * @param {number} [height=0] the height for querying.
32
+ * If omitted, the latest height is used
33
+ * @deprecated use {@link getAccount} instead
34
+ */
35
+ getAccountNumber(address: string, height?: number): Promise<number>;
36
+ /**
37
+ * Fetches the account. Errors out if the account
38
+ * is not initialized
39
+ * @param {string} address the bech32 address of the account
40
+ * @param {number} [height=0] the height for querying.
41
+ * If omitted, the latest height is used
42
+ */
43
+ getAccount(address: string, height?: number): Promise<ABCIAccount>;
44
+ /**
45
+ * Fetches the block at the specific height, if any
46
+ * @param {number} height the height for querying
47
+ */
48
+ getBlock(height: number): Promise<BlockInfo>;
49
+ /**
50
+ * Fetches the block at the specific height, if any
51
+ * @param {number} height the height for querying
52
+ */
53
+ getBlockResult(height: number): Promise<BlockResult>;
54
+ /**
55
+ * Fetches the latest block number from the chain
56
+ */
57
+ getBlockNumber(): Promise<number>;
58
+ /**
59
+ * Fetches the network information
60
+ */
61
+ getNetwork(): Promise<NetworkInfo>;
62
+ /**
63
+ * Fetches the consensus params for the specific block height
64
+ * @param {number} height the height for querying
65
+ */
66
+ getConsensusParams(height: number): Promise<ConsensusParams>;
67
+ /**
68
+ * Fetches the current node status
69
+ */
70
+ getStatus(): Promise<Status>;
71
+ /**
72
+ * Fetches the current (recommended) average gas price
73
+ */
74
+ getGasPrice(): Promise<number>;
75
+ /**
76
+ * Estimates the gas limit for the transaction
77
+ * @param {Tx} tx the transaction that needs estimating
78
+ */
79
+ estimateGas(tx: Tx): Promise<bigint>;
80
+ /**
81
+ * Sends the transaction to the node. If the type of endpoint
82
+ * is a broadcast commit, waits for the transaction to be committed to the chain.
83
+ * The transaction needs to be signed beforehand.
84
+ * Returns the transaction broadcast result.
85
+ * @param {string} tx the base64-encoded signed transaction
86
+ * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)
87
+ */
88
+ sendTransaction<K extends keyof BroadcastTransactionMap>(tx: string, endpoint: K): Promise<BroadcastAsGeneric<K>["result"]>;
89
+ /**
90
+ * Waits for the transaction to be committed on the chain.
91
+ * NOTE: This method will not take in the fromHeight parameter once
92
+ * proper transaction indexing is added - the implementation should
93
+ * simply try to fetch the transaction first to see if it's included in a block
94
+ * before starting to wait for it; Until then, this method should be used
95
+ * in the sequence:
96
+ * get latest block -> send transaction -> waitForTransaction(block before send)
97
+ * @param {string} hash The transaction hash
98
+ * @param {number} [fromHeight=latest] The block height used to begin the search
99
+ * @param {number} [timeout=15000] Optional wait timeout in MS
100
+ */
101
+ waitForTransaction(hash: string, fromHeight?: number, timeout?: number): Promise<Tx>;
102
+ }
103
+ /**
104
+ * Base provider implementation backed by a Tm2Client.
105
+ * Subclasses only need to provide a static `create()` factory.
106
+ */
107
+ declare abstract class BaseTm2Provider implements Provider {
108
+ protected readonly client: Tm2Client;
109
+ protected constructor(client: Tm2Client);
110
+ estimateGas(tx: Tx): Promise<bigint>;
111
+ getBalance(address: string, denomination?: string, height?: number): Promise<number>;
112
+ getBlock(height: number): Promise<BlockInfo>;
113
+ getBlockResult(height: number): Promise<BlockResult>;
114
+ getBlockNumber(): Promise<number>;
115
+ getConsensusParams(height: number): Promise<ConsensusParams>;
116
+ getGasPrice(): Promise<number>;
117
+ getNetwork(): Promise<NetworkInfo>;
118
+ getAccountSequence(address: string, height?: number): Promise<number>;
119
+ getAccountNumber(address: string, height?: number): Promise<number>;
120
+ getAccount(address: string, height?: number): Promise<ABCIAccount>;
121
+ getStatus(): Promise<Status>;
122
+ getTransaction(hash: string): Promise<TxResult>;
123
+ sendTransaction<K extends keyof BroadcastTransactionMap>(tx: string, endpoint: K): Promise<BroadcastTransactionMap[K]["result"]>;
124
+ private broadcastTxSync;
125
+ private broadcastTxCommit;
126
+ waitForTransaction(hash: string, fromHeight?: number, timeout?: number): Promise<Tx>;
127
+ }
128
+ //#endregion
129
+ export { BaseTm2Provider, Provider };
130
+ //# sourceMappingURL=provider.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.cts","names":[],"sources":["../../src/provider/provider.ts"],"mappings":";;;;;;;;;UAkDiB,QAAA;EAAA;;;;;;;EAUf,UAAA,CACE,OAAA,UACA,YAAA,WACA,MAAA,YACC,OAAA;EAkC+B;;;;;;;EAzBlC,kBAAA,CAAmB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAiDlB;;;;;;;;EAvCpC,gBAAA,CAAiB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAsEzC;;;;;;;EA7DX,UAAA,CAAW,OAAA,UAAiB,MAAA,YAAkB,OAAA,CAAQ,WAAA;EA9BpD;;;;EAoCF,QAAA,CAAS,MAAA,WAAiB,OAAA,CAAQ,SAAA;EAzBE;;;;EA+BpC,cAAA,CAAe,MAAA,WAAiB,OAAA,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MAAA;EAKrB,cAAA,CAAe,IAAA,WAAe,OAAA,CAAQ,QAAA;EAUtC,eAAA,iBAAgC,uBAAA,CAAA,CACpC,EAAA,UACA,QAAA,EAAU,CAAA,GACT,OAAA,CAAQ,uBAAA,CAAwB,CAAA;EAAA,QAYrB,eAAA;EAAA,QAkBA,iBAAA;EA6BR,kBAAA,CACJ,IAAA,UACA,UAAA,WACA,OAAA,YACC,OAAA,CAAQ,EAAA;AAAA"}
@@ -0,0 +1,130 @@
1
+ import { Tx } from "../proto/tm2/tx.mjs";
2
+ import { ABCIAccount } from "./types/abci.mjs";
3
+ import { BlockInfo, BlockResult, BroadcastAsGeneric, BroadcastTransactionMap, ConsensusParams, NetworkInfo, Status, TxResult } from "./types/common.mjs";
4
+ import { Tm2Client } from "@gnolang/tm2-rpc";
5
+
6
+ //#region src/provider/provider.d.ts
7
+ /**
8
+ * Read-only abstraction for accessing blockchain data
9
+ */
10
+ interface Provider {
11
+ /**
12
+ * Fetches the denomination balance of the account
13
+ * @param {string} address the bech32 address of the account
14
+ * @param {string} [denomination=ugnot] the balance denomination
15
+ * @param {number} [height=0] the height for querying.
16
+ * If omitted, the latest height is used
17
+ */
18
+ getBalance(address: string, denomination?: string, height?: number): Promise<number>;
19
+ /**
20
+ * Fetches the account sequence
21
+ * @param {string} address the bech32 address of the account
22
+ * @param {number} [height=0] the height for querying.
23
+ * If omitted, the latest height is used.
24
+ * @deprecated use {@link getAccount} instead
25
+ */
26
+ getAccountSequence(address: string, height?: number): Promise<number>;
27
+ /**
28
+ * Fetches the account number. Errors out if the account
29
+ * is not initialized
30
+ * @param {string} address the bech32 address of the account
31
+ * @param {number} [height=0] the height for querying.
32
+ * If omitted, the latest height is used
33
+ * @deprecated use {@link getAccount} instead
34
+ */
35
+ getAccountNumber(address: string, height?: number): Promise<number>;
36
+ /**
37
+ * Fetches the account. Errors out if the account
38
+ * is not initialized
39
+ * @param {string} address the bech32 address of the account
40
+ * @param {number} [height=0] the height for querying.
41
+ * If omitted, the latest height is used
42
+ */
43
+ getAccount(address: string, height?: number): Promise<ABCIAccount>;
44
+ /**
45
+ * Fetches the block at the specific height, if any
46
+ * @param {number} height the height for querying
47
+ */
48
+ getBlock(height: number): Promise<BlockInfo>;
49
+ /**
50
+ * Fetches the block at the specific height, if any
51
+ * @param {number} height the height for querying
52
+ */
53
+ getBlockResult(height: number): Promise<BlockResult>;
54
+ /**
55
+ * Fetches the latest block number from the chain
56
+ */
57
+ getBlockNumber(): Promise<number>;
58
+ /**
59
+ * Fetches the network information
60
+ */
61
+ getNetwork(): Promise<NetworkInfo>;
62
+ /**
63
+ * Fetches the consensus params for the specific block height
64
+ * @param {number} height the height for querying
65
+ */
66
+ getConsensusParams(height: number): Promise<ConsensusParams>;
67
+ /**
68
+ * Fetches the current node status
69
+ */
70
+ getStatus(): Promise<Status>;
71
+ /**
72
+ * Fetches the current (recommended) average gas price
73
+ */
74
+ getGasPrice(): Promise<number>;
75
+ /**
76
+ * Estimates the gas limit for the transaction
77
+ * @param {Tx} tx the transaction that needs estimating
78
+ */
79
+ estimateGas(tx: Tx): Promise<bigint>;
80
+ /**
81
+ * Sends the transaction to the node. If the type of endpoint
82
+ * is a broadcast commit, waits for the transaction to be committed to the chain.
83
+ * The transaction needs to be signed beforehand.
84
+ * Returns the transaction broadcast result.
85
+ * @param {string} tx the base64-encoded signed transaction
86
+ * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)
87
+ */
88
+ sendTransaction<K extends keyof BroadcastTransactionMap>(tx: string, endpoint: K): Promise<BroadcastAsGeneric<K>["result"]>;
89
+ /**
90
+ * Waits for the transaction to be committed on the chain.
91
+ * NOTE: This method will not take in the fromHeight parameter once
92
+ * proper transaction indexing is added - the implementation should
93
+ * simply try to fetch the transaction first to see if it's included in a block
94
+ * before starting to wait for it; Until then, this method should be used
95
+ * in the sequence:
96
+ * get latest block -> send transaction -> waitForTransaction(block before send)
97
+ * @param {string} hash The transaction hash
98
+ * @param {number} [fromHeight=latest] The block height used to begin the search
99
+ * @param {number} [timeout=15000] Optional wait timeout in MS
100
+ */
101
+ waitForTransaction(hash: string, fromHeight?: number, timeout?: number): Promise<Tx>;
102
+ }
103
+ /**
104
+ * Base provider implementation backed by a Tm2Client.
105
+ * Subclasses only need to provide a static `create()` factory.
106
+ */
107
+ declare abstract class BaseTm2Provider implements Provider {
108
+ protected readonly client: Tm2Client;
109
+ protected constructor(client: Tm2Client);
110
+ estimateGas(tx: Tx): Promise<bigint>;
111
+ getBalance(address: string, denomination?: string, height?: number): Promise<number>;
112
+ getBlock(height: number): Promise<BlockInfo>;
113
+ getBlockResult(height: number): Promise<BlockResult>;
114
+ getBlockNumber(): Promise<number>;
115
+ getConsensusParams(height: number): Promise<ConsensusParams>;
116
+ getGasPrice(): Promise<number>;
117
+ getNetwork(): Promise<NetworkInfo>;
118
+ getAccountSequence(address: string, height?: number): Promise<number>;
119
+ getAccountNumber(address: string, height?: number): Promise<number>;
120
+ getAccount(address: string, height?: number): Promise<ABCIAccount>;
121
+ getStatus(): Promise<Status>;
122
+ getTransaction(hash: string): Promise<TxResult>;
123
+ sendTransaction<K extends keyof BroadcastTransactionMap>(tx: string, endpoint: K): Promise<BroadcastTransactionMap[K]["result"]>;
124
+ private broadcastTxSync;
125
+ private broadcastTxCommit;
126
+ waitForTransaction(hash: string, fromHeight?: number, timeout?: number): Promise<Tx>;
127
+ }
128
+ //#endregion
129
+ export { BaseTm2Provider, Provider };
130
+ //# sourceMappingURL=provider.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.mts","names":[],"sources":["../../src/provider/provider.ts"],"mappings":";;;;;;;;;UAkDiB,QAAA;EAAA;;;;;;;EAUf,UAAA,CACE,OAAA,UACA,YAAA,WACA,MAAA,YACC,OAAA;EAkC+B;;;;;;;EAzBlC,kBAAA,CAAmB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAiDlB;;;;;;;;EAvCpC,gBAAA,CAAiB,OAAA,UAAiB,MAAA,YAAkB,OAAA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AAmB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAYtD,gBAAA,CAAiB,OAAA,UAAiB,MAAA,YAAkB,OAAA;EAcpD,UAAA,CAAW,OAAA,UAAiB,MAAA,YAAkB,OAAA,CAAQ,WAAA;EAYtD,SAAA,CAAA,GAAa,OAAA,CAAQ,MAAA;EAKrB,cAAA,CAAe,IAAA,WAAe,OAAA,CAAQ,QAAA;EAUtC,eAAA,iBAAgC,uBAAA,CAAA,CACpC,EAAA,UACA,QAAA,EAAU,CAAA,GACT,OAAA,CAAQ,uBAAA,CAAwB,CAAA;EAAA,QAYrB,eAAA;EAAA,QAkBA,iBAAA;EA6BR,kBAAA,CACJ,IAAA,UACA,UAAA,WACA,OAAA,YACC,OAAA,CAAQ,EAAA;AAAA"}
@@ -0,0 +1,130 @@
1
+ import { Tx } from "../proto/tm2/tx.mjs";
2
+ import "../proto/index.mjs";
3
+ import { TransactionEndpoint } from "./endpoints.mjs";
4
+ import { _defineProperty } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.mjs";
5
+ import { ABCIErrorKey } from "./types/abci.mjs";
6
+ import { constructRequestError } from "./utility/errors.utility.mjs";
7
+ import { adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse } from "./utility/adapters.mjs";
8
+ import { uint8ArrayToBase64 } from "./utility/requests.utility.mjs";
9
+ import { extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, waitForTransaction } from "./utility/provider.utility.mjs";
10
+ import "./utility/index.mjs";
11
+ //#region src/provider/provider.ts
12
+ /**
13
+ * Base provider implementation backed by a Tm2Client.
14
+ * Subclasses only need to provide a static `create()` factory.
15
+ */
16
+ var BaseTm2Provider = class {
17
+ constructor(client) {
18
+ _defineProperty(this, "client", void 0);
19
+ this.client = client;
20
+ }
21
+ async estimateGas(tx) {
22
+ const encodedTx = uint8ArrayToBase64(Tx.encode(tx).finish());
23
+ const simulateResult = extractSimulateFromResponse(adaptAbciQueryResponse(await this.client.abciQuery({
24
+ path: ".app/simulate",
25
+ data: new TextEncoder().encode(encodedTx),
26
+ height: 0,
27
+ prove: false
28
+ })));
29
+ const resultErrorKey = simulateResult.response_base?.error?.type_url;
30
+ if (resultErrorKey) throw constructRequestError(resultErrorKey);
31
+ return simulateResult.gas_used;
32
+ }
33
+ async getBalance(address, denomination, height) {
34
+ return extractBalanceFromResponse(adaptAbciQueryResponse(await this.client.abciQuery({
35
+ path: `bank/balances/${address}`,
36
+ data: new Uint8Array(),
37
+ height: height ? height : 0,
38
+ prove: false
39
+ })).response.ResponseBase.Data, denomination ? denomination : "ugnot");
40
+ }
41
+ async getBlock(height) {
42
+ return adaptBlockResponse(await this.client.block(height));
43
+ }
44
+ async getBlockResult(height) {
45
+ return adaptBlockResultsResponse(await this.client.blockResults(height));
46
+ }
47
+ async getBlockNumber() {
48
+ const status = await this.getStatus();
49
+ return parseInt(status.sync_info.latest_block_height);
50
+ }
51
+ async getConsensusParams(height) {
52
+ return adaptConsensusParamsResponse(await this.client.consensusParams(height));
53
+ }
54
+ getGasPrice() {
55
+ return Promise.reject("not supported");
56
+ }
57
+ async getNetwork() {
58
+ return adaptNetInfoResponse(await this.client.netInfo());
59
+ }
60
+ async getAccountSequence(address, height) {
61
+ return extractSequenceFromResponse(adaptAbciQueryResponse(await this.client.abciQuery({
62
+ path: `auth/accounts/${address}`,
63
+ data: new Uint8Array(),
64
+ height: height ? height : 0,
65
+ prove: false
66
+ })).response.ResponseBase.Data);
67
+ }
68
+ async getAccountNumber(address, height) {
69
+ return extractAccountNumberFromResponse(adaptAbciQueryResponse(await this.client.abciQuery({
70
+ path: `auth/accounts/${address}`,
71
+ data: new Uint8Array(),
72
+ height: height ? height : 0,
73
+ prove: false
74
+ })).response.ResponseBase.Data);
75
+ }
76
+ async getAccount(address, height) {
77
+ return extractAccountFromResponse(adaptAbciQueryResponse(await this.client.abciQuery({
78
+ path: `auth/accounts/${address}`,
79
+ data: new Uint8Array(),
80
+ height: height ? height : 0,
81
+ prove: false
82
+ })).response.ResponseBase.Data);
83
+ }
84
+ async getStatus() {
85
+ return adaptStatusResponse(await this.client.status());
86
+ }
87
+ async getTransaction(hash) {
88
+ const hashBytes = Uint8Array.from((hash.match(/.{1,2}/g) ?? []).map((byte) => parseInt(byte, 16)));
89
+ return adaptTxResponse(await this.client.tx({ hash: hashBytes }));
90
+ }
91
+ async sendTransaction(tx, endpoint) {
92
+ const txBytes = Uint8Array.from(Buffer.from(tx, "base64"));
93
+ switch (endpoint) {
94
+ case TransactionEndpoint.BROADCAST_TX_COMMIT: return this.broadcastTxCommit(txBytes);
95
+ case TransactionEndpoint.BROADCAST_TX_SYNC:
96
+ default: return this.broadcastTxSync(txBytes);
97
+ }
98
+ }
99
+ async broadcastTxSync(txBytes) {
100
+ const response = adaptBroadcastTxSyncResponse(await this.client.broadcastTxSync({ tx: txBytes }));
101
+ if (response.error) {
102
+ const errType = response.error[ABCIErrorKey];
103
+ const log = response.Log;
104
+ throw constructRequestError(errType, log);
105
+ }
106
+ return response;
107
+ }
108
+ async broadcastTxCommit(txBytes) {
109
+ const response = adaptBroadcastTxCommitResponse(await this.client.broadcastTxCommit({ tx: txBytes }));
110
+ const { check_tx, deliver_tx } = response;
111
+ if (check_tx.ResponseBase.Error) {
112
+ const errType = check_tx.ResponseBase.Error[ABCIErrorKey];
113
+ const log = check_tx.ResponseBase.Log;
114
+ throw constructRequestError(errType, log);
115
+ }
116
+ if (deliver_tx.ResponseBase.Error) {
117
+ const errType = deliver_tx.ResponseBase.Error[ABCIErrorKey];
118
+ const log = deliver_tx.ResponseBase.Log;
119
+ throw constructRequestError(errType, log);
120
+ }
121
+ return response;
122
+ }
123
+ async waitForTransaction(hash, fromHeight, timeout) {
124
+ return waitForTransaction(this, hash, fromHeight, timeout);
125
+ }
126
+ };
127
+ //#endregion
128
+ export { BaseTm2Provider };
129
+
130
+ //# sourceMappingURL=provider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.mjs","names":[],"sources":["../../src/provider/provider.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n Tx,\n} from \"../proto/index.js\";\nimport {\n TransactionEndpoint,\n} from \"./endpoints.js\";\nimport {\n ABCIAccount,\n ABCIErrorKey,\n ABCIResponse,\n BlockInfo,\n BlockResult,\n BroadcastAsGeneric,\n BroadcastTransactionMap,\n BroadcastTxCommitResult,\n BroadcastTxSyncResult,\n ConsensusParams,\n NetworkInfo,\n Status,\n TxResult,\n} from \"./types/index.js\";\nimport {\n constructRequestError,\n} from \"./utility/errors.utility.js\";\nimport {\n adaptAbciQueryResponse,\n adaptBlockResponse,\n adaptBlockResultsResponse,\n adaptBroadcastTxCommitResponse,\n adaptBroadcastTxSyncResponse,\n adaptConsensusParamsResponse,\n adaptNetInfoResponse,\n adaptStatusResponse,\n adaptTxResponse,\n extractAccountFromResponse,\n extractAccountNumberFromResponse,\n extractBalanceFromResponse,\n extractSequenceFromResponse,\n extractSimulateFromResponse,\n uint8ArrayToBase64,\n waitForTransaction,\n} from \"./utility/index.js\";\n\n/**\n * Read-only abstraction for accessing blockchain data\n */\nexport interface Provider {\n // Account-specific methods //\n\n /**\n * Fetches the denomination balance of the account\n * @param {string} address the bech32 address of the account\n * @param {string} [denomination=ugnot] the balance denomination\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getBalance(\n address: string,\n denomination?: string,\n height?: number\n ): Promise<number>\n\n /**\n * Fetches the account sequence\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used.\n * @deprecated use {@link getAccount} instead\n */\n getAccountSequence(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account number. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n * @deprecated use {@link getAccount} instead\n */\n getAccountNumber(address: string, height?: number): Promise<number>\n\n /**\n * Fetches the account. Errors out if the account\n * is not initialized\n * @param {string} address the bech32 address of the account\n * @param {number} [height=0] the height for querying.\n * If omitted, the latest height is used\n */\n getAccount(address: string, height?: number): Promise<ABCIAccount>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlock(height: number): Promise<BlockInfo>\n\n /**\n * Fetches the block at the specific height, if any\n * @param {number} height the height for querying\n */\n getBlockResult(height: number): Promise<BlockResult>\n\n /**\n * Fetches the latest block number from the chain\n */\n getBlockNumber(): Promise<number>\n\n // Network-specific methods //\n\n /**\n * Fetches the network information\n */\n getNetwork(): Promise<NetworkInfo>\n\n /**\n * Fetches the consensus params for the specific block height\n * @param {number} height the height for querying\n */\n getConsensusParams(height: number): Promise<ConsensusParams>\n\n /**\n * Fetches the current node status\n */\n getStatus(): Promise<Status>\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice(): Promise<number>\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas(tx: Tx): Promise<bigint>\n\n // Transaction specific methods //\n\n /**\n * Sends the transaction to the node. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction broadcast result.\n * @param {string} tx the base64-encoded signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K\n ): Promise<BroadcastAsGeneric<K>[\"result\"]>\n\n /**\n * Waits for the transaction to be committed on the chain.\n * NOTE: This method will not take in the fromHeight parameter once\n * proper transaction indexing is added - the implementation should\n * simply try to fetch the transaction first to see if it's included in a block\n * before starting to wait for it; Until then, this method should be used\n * in the sequence:\n * get latest block -> send transaction -> waitForTransaction(block before send)\n * @param {string} hash The transaction hash\n * @param {number} [fromHeight=latest] The block height used to begin the search\n * @param {number} [timeout=15000] Optional wait timeout in MS\n */\n waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number\n ): Promise<Tx>\n}\n\n/**\n * Base provider implementation backed by a Tm2Client.\n * Subclasses only need to provide a static `create()` factory.\n */\nexport abstract class BaseTm2Provider implements Provider {\n protected readonly client: Tm2Client;\n\n protected constructor(client: Tm2Client) {\n this.client = client;\n }\n\n async estimateGas(tx: Tx): Promise<bigint> {\n const encodedTx = uint8ArrayToBase64(Tx.encode(tx).finish());\n const rpcResponse = await this.client.abciQuery({\n path: \".app/simulate\",\n data: new TextEncoder().encode(encodedTx),\n height: 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n const simulateResult = extractSimulateFromResponse(abciResponse);\n\n const resultErrorKey = simulateResult.response_base?.error?.type_url;\n if (resultErrorKey) {\n throw constructRequestError(resultErrorKey);\n }\n\n return simulateResult.gas_used;\n }\n\n async getBalance(\n address: string,\n denomination?: string,\n height?: number,\n ): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `bank/balances/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n\n return extractBalanceFromResponse(\n abciResponse.response.ResponseBase.Data,\n denomination ? denomination : \"ugnot\",\n );\n }\n\n async getBlock(height: number): Promise<BlockInfo> {\n const rpcResponse = await this.client.block(height);\n return adaptBlockResponse(rpcResponse);\n }\n\n async getBlockResult(height: number): Promise<BlockResult> {\n const rpcResponse = await this.client.blockResults(height);\n return adaptBlockResultsResponse(rpcResponse);\n }\n\n async getBlockNumber(): Promise<number> {\n const status = await this.getStatus();\n return parseInt(status.sync_info.latest_block_height);\n }\n\n async getConsensusParams(height: number): Promise<ConsensusParams> {\n const rpcResponse = await this.client.consensusParams(height);\n return adaptConsensusParamsResponse(rpcResponse);\n }\n\n getGasPrice(): Promise<number> {\n return Promise.reject(\"not supported\");\n }\n\n async getNetwork(): Promise<NetworkInfo> {\n const rpcResponse = await this.client.netInfo();\n return adaptNetInfoResponse(rpcResponse);\n }\n\n async getAccountSequence(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractSequenceFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getAccountNumber(address: string, height?: number): Promise<number> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountNumberFromResponse(\n abciResponse.response.ResponseBase.Data,\n );\n }\n\n async getAccount(address: string, height?: number): Promise<ABCIAccount> {\n const rpcResponse = await this.client.abciQuery({\n path: `auth/accounts/${address}`,\n data: new Uint8Array(),\n height: height ? height : 0,\n prove: false,\n });\n\n const abciResponse: ABCIResponse = adaptAbciQueryResponse(rpcResponse);\n return extractAccountFromResponse(abciResponse.response.ResponseBase.Data);\n }\n\n async getStatus(): Promise<Status> {\n const rpcResponse = await this.client.status();\n return adaptStatusResponse(rpcResponse);\n }\n\n async getTransaction(hash: string): Promise<TxResult> {\n const hashBytes = Uint8Array.from(\n (hash.match(/.{1,2}/g) ?? []).map(byte => parseInt(byte, 16)),\n );\n const rpcResponse = await this.client.tx({\n hash: hashBytes,\n });\n return adaptTxResponse(rpcResponse);\n }\n\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: string,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n const txBytes = Uint8Array.from(Buffer.from(tx, \"base64\"));\n\n switch (endpoint) {\n case TransactionEndpoint.BROADCAST_TX_COMMIT:\n return this.broadcastTxCommit(txBytes);\n case TransactionEndpoint.BROADCAST_TX_SYNC:\n default:\n return this.broadcastTxSync(txBytes);\n }\n }\n\n private async broadcastTxSync(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxSyncResult> {\n const rpcResponse = await this.client.broadcastTxSync({\n tx: txBytes,\n });\n const response = adaptBroadcastTxSyncResponse(rpcResponse);\n\n if (response.error) {\n const errType: string = response.error[ABCIErrorKey];\n const log: string = response.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n private async broadcastTxCommit(\n txBytes: Uint8Array,\n ): Promise<BroadcastTxCommitResult> {\n const rpcResponse = await this.client.broadcastTxCommit({\n tx: txBytes,\n });\n const response = adaptBroadcastTxCommitResponse(rpcResponse);\n\n const {\n check_tx, deliver_tx,\n } = response;\n\n if (check_tx.ResponseBase.Error) {\n const errType: string = check_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = check_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n if (deliver_tx.ResponseBase.Error) {\n const errType: string = deliver_tx.ResponseBase.Error[ABCIErrorKey];\n const log: string = deliver_tx.ResponseBase.Log;\n\n throw constructRequestError(errType, log);\n }\n\n return response;\n }\n\n async waitForTransaction(\n hash: string,\n fromHeight?: number,\n timeout?: number,\n ): Promise<Tx> {\n return waitForTransaction(this, hash, fromHeight, timeout);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkLA,IAAsB,kBAAtB,MAA0D;CAGxD,YAAsB,QAAmB;wBAFtB,UAAA,KAAA,EAAkB;AAGnC,OAAK,SAAS;;CAGhB,MAAM,YAAY,IAAyB;EACzC,MAAM,YAAY,mBAAmB,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC;EAS5D,MAAM,iBAAiB,4BADY,uBAPf,MAAM,KAAK,OAAO,UAAU;GAC9C,MAAM;GACN,MAAM,IAAI,aAAa,CAAC,OAAO,UAAU;GACzC,QAAQ;GACR,OAAO;GACR,CAAC,CAEoE,CACN;EAEhE,MAAM,iBAAiB,eAAe,eAAe,OAAO;AAC5D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M,UAAkB,WAAW,aAAa,MAAM;GACtD,MAAM,MAAc,WAAW,aAAa;AAE5C,SAAM,sBAAsB,SAAS,IAAI;;AAG3C,SAAO;;CAGT,MAAM,mBACJ,MACA,YACA,SACa;AACb,SAAO,mBAAmB,MAAM,MAAM,YAAY,QAAQ"}
@@ -0,0 +1,6 @@
1
+ //#region src/provider/types/abci.ts
2
+ const ABCIErrorKey = "@type";
3
+ //#endregion
4
+ exports.ABCIErrorKey = ABCIErrorKey;
5
+
6
+ //# sourceMappingURL=abci.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abci.cjs","names":[],"sources":["../../../src/provider/types/abci.ts"],"sourcesContent":["export interface ABCIResponse {\n response: {\n ResponseBase: ABCIResponseBase\n Key: string | null\n Value: string | null\n Proof: MerkleProof | null\n Height: string\n }\n}\n\nexport interface ABCIResponseBase {\n Error: {\n // ABCIErrorKey\n [key: string]: string\n } | null\n Data: string | null\n Events: string | null\n Log: string\n Info: string\n}\n\ninterface MerkleProof {\n ops: {\n type: string\n key: string | null\n data: string | null\n }[]\n}\n\nexport interface ABCIAccount {\n BaseAccount: {\n // the associated account address\n address: string\n // the balance list\n coins: string\n // the public key info\n public_key: {\n // type of public key\n \"@type\": string\n // public key value\n value: string\n } | null\n // the account number (state-dependent) (decimal)\n account_number: string\n // the account sequence / nonce (decimal)\n sequence: string\n }\n}\n\nexport const ABCIErrorKey = \"@type\";\n"],"mappings":";AAiDA,MAAa,eAAe"}
@@ -0,0 +1,42 @@
1
+ //#region src/provider/types/abci.d.ts
2
+ interface ABCIResponse {
3
+ response: {
4
+ ResponseBase: ABCIResponseBase;
5
+ Key: string | null;
6
+ Value: string | null;
7
+ Proof: MerkleProof | null;
8
+ Height: string;
9
+ };
10
+ }
11
+ interface ABCIResponseBase {
12
+ Error: {
13
+ [key: string]: string;
14
+ } | null;
15
+ Data: string | null;
16
+ Events: string | null;
17
+ Log: string;
18
+ Info: string;
19
+ }
20
+ interface MerkleProof {
21
+ ops: {
22
+ type: string;
23
+ key: string | null;
24
+ data: string | null;
25
+ }[];
26
+ }
27
+ interface ABCIAccount {
28
+ BaseAccount: {
29
+ address: string;
30
+ coins: string;
31
+ public_key: {
32
+ "@type": string;
33
+ value: string;
34
+ } | null;
35
+ account_number: string;
36
+ sequence: string;
37
+ };
38
+ }
39
+ declare const ABCIErrorKey = "@type";
40
+ //#endregion
41
+ export { ABCIAccount, ABCIErrorKey, ABCIResponse, ABCIResponseBase };
42
+ //# sourceMappingURL=abci.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abci.d.cts","names":[],"sources":["../../../src/provider/types/abci.ts"],"mappings":";UAAiB,YAAA;EACf,QAAA;IACE,YAAA,EAAc,gBAAA;IACd,GAAA;IACA,KAAA;IACA,KAAA,EAAO,WAAA;IACP,MAAA;EAAA;AAAA;AAAA,UAIa,gBAAA;EACf,KAAA;IAAA,CAEG,GAAA;EAAA;EAEH,IAAA;EACA,MAAA;EACA,GAAA;EACA,IAAA;AAAA;AAAA,UAGQ,WAAA;EACR,GAAA;IACE,IAAA;IACA,GAAA;IACA,IAAA;EAAA;AAAA;AAAA,UAIa,WAAA;EACf,WAAA;IAEE,OAAA;IAEA,KAAA;IAEA,UAAA;MAEE,OAAA;MAEA,KAAA;IAAA;IAGF,cAAA;IAEA,QAAA;EAAA;AAAA;AAAA,cAIS,YAAA"}
@@ -0,0 +1,42 @@
1
+ //#region src/provider/types/abci.d.ts
2
+ interface ABCIResponse {
3
+ response: {
4
+ ResponseBase: ABCIResponseBase;
5
+ Key: string | null;
6
+ Value: string | null;
7
+ Proof: MerkleProof | null;
8
+ Height: string;
9
+ };
10
+ }
11
+ interface ABCIResponseBase {
12
+ Error: {
13
+ [key: string]: string;
14
+ } | null;
15
+ Data: string | null;
16
+ Events: string | null;
17
+ Log: string;
18
+ Info: string;
19
+ }
20
+ interface MerkleProof {
21
+ ops: {
22
+ type: string;
23
+ key: string | null;
24
+ data: string | null;
25
+ }[];
26
+ }
27
+ interface ABCIAccount {
28
+ BaseAccount: {
29
+ address: string;
30
+ coins: string;
31
+ public_key: {
32
+ "@type": string;
33
+ value: string;
34
+ } | null;
35
+ account_number: string;
36
+ sequence: string;
37
+ };
38
+ }
39
+ declare const ABCIErrorKey = "@type";
40
+ //#endregion
41
+ export { ABCIAccount, ABCIErrorKey, ABCIResponse, ABCIResponseBase };
42
+ //# sourceMappingURL=abci.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abci.d.mts","names":[],"sources":["../../../src/provider/types/abci.ts"],"mappings":";UAAiB,YAAA;EACf,QAAA;IACE,YAAA,EAAc,gBAAA;IACd,GAAA;IACA,KAAA;IACA,KAAA,EAAO,WAAA;IACP,MAAA;EAAA;AAAA;AAAA,UAIa,gBAAA;EACf,KAAA;IAAA,CAEG,GAAA;EAAA;EAEH,IAAA;EACA,MAAA;EACA,GAAA;EACA,IAAA;AAAA;AAAA,UAGQ,WAAA;EACR,GAAA;IACE,IAAA;IACA,GAAA;IACA,IAAA;EAAA;AAAA;AAAA,UAIa,WAAA;EACf,WAAA;IAEE,OAAA;IAEA,KAAA;IAEA,UAAA;MAEE,OAAA;MAEA,KAAA;IAAA;IAGF,cAAA;IAEA,QAAA;EAAA;AAAA;AAAA,cAIS,YAAA"}
@@ -0,0 +1,6 @@
1
+ //#region src/provider/types/abci.ts
2
+ const ABCIErrorKey = "@type";
3
+ //#endregion
4
+ export { ABCIErrorKey };
5
+
6
+ //# sourceMappingURL=abci.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abci.mjs","names":[],"sources":["../../../src/provider/types/abci.ts"],"sourcesContent":["export interface ABCIResponse {\n response: {\n ResponseBase: ABCIResponseBase\n Key: string | null\n Value: string | null\n Proof: MerkleProof | null\n Height: string\n }\n}\n\nexport interface ABCIResponseBase {\n Error: {\n // ABCIErrorKey\n [key: string]: string\n } | null\n Data: string | null\n Events: string | null\n Log: string\n Info: string\n}\n\ninterface MerkleProof {\n ops: {\n type: string\n key: string | null\n data: string | null\n }[]\n}\n\nexport interface ABCIAccount {\n BaseAccount: {\n // the associated account address\n address: string\n // the balance list\n coins: string\n // the public key info\n public_key: {\n // type of public key\n \"@type\": string\n // public key value\n value: string\n } | null\n // the account number (state-dependent) (decimal)\n account_number: string\n // the account sequence / nonce (decimal)\n sequence: string\n }\n}\n\nexport const ABCIErrorKey = \"@type\";\n"],"mappings":";AAiDA,MAAa,eAAe"}