@gnolang/tm2-js-client 2.0.3 → 2.0.5

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 (234) hide show
  1. package/CHANGELOG.md +424 -0
  2. package/CONTRIBUTING.md +83 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.cjs +12 -0
  4. package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.143.0/helpers/esm}/defineProperty.mjs +3 -3
  5. package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.143.0/helpers/esm}/toPrimitive.cjs +4 -4
  6. package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.143.0/helpers/esm}/toPrimitive.mjs +3 -3
  7. package/dist/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.cjs +9 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/toPropertyKey.mjs +9 -0
  9. package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.143.0/helpers/esm}/typeof.cjs +2 -2
  10. package/dist/_virtual/{_@oxc-project_runtime@0.122.0/helpers → _@oxc-project_runtime@0.143.0/helpers/esm}/typeof.mjs +2 -2
  11. package/dist/_virtual/_rolldown/runtime.cjs +1 -1
  12. package/dist/index.cjs +9 -2
  13. package/dist/index.d.cts +8 -1
  14. package/dist/index.d.mts +8 -1
  15. package/dist/index.mjs +3 -1
  16. package/dist/proto/google/protobuf/any.cjs +3 -4
  17. package/dist/proto/google/protobuf/any.cjs.map +1 -1
  18. package/dist/proto/google/protobuf/any.d.cts +3 -4
  19. package/dist/proto/google/protobuf/any.d.cts.map +1 -1
  20. package/dist/proto/google/protobuf/any.d.mts +3 -4
  21. package/dist/proto/google/protobuf/any.d.mts.map +1 -1
  22. package/dist/proto/google/protobuf/any.mjs +3 -3
  23. package/dist/proto/google/protobuf/any.mjs.map +1 -1
  24. package/dist/proto/index.cjs +15 -2
  25. package/dist/proto/index.d.cts +4 -1
  26. package/dist/proto/index.d.mts +4 -1
  27. package/dist/proto/index.mjs +5 -3
  28. package/dist/proto/tm2/abci.cjs +4 -4
  29. package/dist/proto/tm2/abci.cjs.map +1 -1
  30. package/dist/proto/tm2/abci.d.cts +3 -4
  31. package/dist/proto/tm2/abci.d.cts.map +1 -1
  32. package/dist/proto/tm2/abci.d.mts +3 -4
  33. package/dist/proto/tm2/abci.d.mts.map +1 -1
  34. package/dist/proto/tm2/abci.mjs +4 -4
  35. package/dist/proto/tm2/abci.mjs.map +1 -1
  36. package/dist/proto/tm2/multisig.cjs +198 -0
  37. package/dist/proto/tm2/multisig.cjs.map +1 -0
  38. package/dist/proto/tm2/multisig.d.cts +3 -4
  39. package/dist/proto/tm2/multisig.d.cts.map +1 -1
  40. package/dist/proto/tm2/multisig.d.mts +3 -4
  41. package/dist/proto/tm2/multisig.d.mts.map +1 -1
  42. package/dist/proto/tm2/multisig.mjs +196 -0
  43. package/dist/proto/tm2/multisig.mjs.map +1 -0
  44. package/dist/proto/tm2/tx.cjs +6 -7
  45. package/dist/proto/tm2/tx.cjs.map +1 -1
  46. package/dist/proto/tm2/tx.d.cts +2 -3
  47. package/dist/proto/tm2/tx.d.cts.map +1 -1
  48. package/dist/proto/tm2/tx.d.mts +2 -3
  49. package/dist/proto/tm2/tx.d.mts.map +1 -1
  50. package/dist/proto/tm2/tx.mjs +6 -6
  51. package/dist/proto/tm2/tx.mjs.map +1 -1
  52. package/dist/provider/endpoints.cjs.map +1 -1
  53. package/dist/provider/endpoints.d.cts.map +1 -1
  54. package/dist/provider/endpoints.d.mts.map +1 -1
  55. package/dist/provider/endpoints.mjs.map +1 -1
  56. package/dist/provider/errors/errors.cjs +2 -2
  57. package/dist/provider/errors/errors.cjs.map +1 -1
  58. package/dist/provider/errors/errors.d.cts.map +1 -1
  59. package/dist/provider/errors/errors.d.mts.map +1 -1
  60. package/dist/provider/errors/errors.mjs +1 -1
  61. package/dist/provider/errors/errors.mjs.map +1 -1
  62. package/dist/provider/errors/index.cjs +20 -1
  63. package/dist/provider/errors/index.d.cts +2 -1
  64. package/dist/provider/errors/index.d.mts +2 -1
  65. package/dist/provider/errors/index.mjs +2 -2
  66. package/dist/provider/index.cjs +61 -9
  67. package/dist/provider/index.d.cts +7 -1
  68. package/dist/provider/index.d.mts +7 -1
  69. package/dist/provider/index.mjs +10 -10
  70. package/dist/provider/jsonrpc/index.cjs +2 -1
  71. package/dist/provider/jsonrpc/index.d.cts +2 -1
  72. package/dist/provider/jsonrpc/index.d.mts +2 -1
  73. package/dist/provider/jsonrpc/index.mjs +2 -2
  74. package/dist/provider/jsonrpc/jsonrpc.cjs +2 -2
  75. package/dist/provider/jsonrpc/jsonrpc.cjs.map +1 -1
  76. package/dist/provider/jsonrpc/jsonrpc.d.cts +0 -1
  77. package/dist/provider/jsonrpc/jsonrpc.d.cts.map +1 -1
  78. package/dist/provider/jsonrpc/jsonrpc.d.mts +0 -1
  79. package/dist/provider/jsonrpc/jsonrpc.d.mts.map +1 -1
  80. package/dist/provider/jsonrpc/jsonrpc.mjs +2 -1
  81. package/dist/provider/jsonrpc/jsonrpc.mjs.map +1 -1
  82. package/dist/provider/provider.cjs +8 -9
  83. package/dist/provider/provider.cjs.map +1 -1
  84. package/dist/provider/provider.d.cts +2 -1
  85. package/dist/provider/provider.d.cts.map +1 -1
  86. package/dist/provider/provider.d.mts +2 -1
  87. package/dist/provider/provider.d.mts.map +1 -1
  88. package/dist/provider/provider.mjs +43 -26
  89. package/dist/provider/provider.mjs.map +1 -1
  90. package/dist/provider/types/abci.d.cts.map +1 -1
  91. package/dist/provider/types/abci.d.mts.map +1 -1
  92. package/dist/provider/types/common.d.cts +1 -2
  93. package/dist/provider/types/common.d.cts.map +1 -1
  94. package/dist/provider/types/common.d.mts +1 -2
  95. package/dist/provider/types/common.d.mts.map +1 -1
  96. package/dist/provider/types/index.cjs +2 -1
  97. package/dist/provider/types/index.d.cts +2 -1
  98. package/dist/provider/types/index.d.mts +2 -1
  99. package/dist/provider/types/index.mjs +2 -2
  100. package/dist/provider/types/jsonrpc.d.cts.map +1 -1
  101. package/dist/provider/types/jsonrpc.d.mts.map +1 -1
  102. package/dist/provider/utility/adapters.cjs +1 -1
  103. package/dist/provider/utility/adapters.cjs.map +1 -1
  104. package/dist/provider/utility/adapters.d.cts +1 -1
  105. package/dist/provider/utility/adapters.d.cts.map +1 -1
  106. package/dist/provider/utility/adapters.d.mts +1 -1
  107. package/dist/provider/utility/adapters.d.mts.map +1 -1
  108. package/dist/provider/utility/adapters.mjs +1 -1
  109. package/dist/provider/utility/adapters.mjs.map +1 -1
  110. package/dist/provider/utility/errors.utility.cjs.map +1 -1
  111. package/dist/provider/utility/errors.utility.mjs.map +1 -1
  112. package/dist/provider/utility/index.cjs +27 -3
  113. package/dist/provider/utility/index.d.cts +2 -1
  114. package/dist/provider/utility/index.d.mts +2 -1
  115. package/dist/provider/utility/index.mjs +4 -4
  116. package/dist/provider/utility/provider.utility.cjs +4 -5
  117. package/dist/provider/utility/provider.utility.cjs.map +1 -1
  118. package/dist/provider/utility/provider.utility.d.cts +3 -2
  119. package/dist/provider/utility/provider.utility.d.cts.map +1 -1
  120. package/dist/provider/utility/provider.utility.d.mts +3 -2
  121. package/dist/provider/utility/provider.utility.d.mts.map +1 -1
  122. package/dist/provider/utility/provider.utility.mjs +3 -2
  123. package/dist/provider/utility/provider.utility.mjs.map +1 -1
  124. package/dist/provider/utility/requests.utility.cjs +0 -1
  125. package/dist/provider/utility/requests.utility.cjs.map +1 -1
  126. package/dist/provider/utility/requests.utility.d.cts +1 -1
  127. package/dist/provider/utility/requests.utility.d.cts.map +1 -1
  128. package/dist/provider/utility/requests.utility.d.mts +1 -1
  129. package/dist/provider/utility/requests.utility.d.mts.map +1 -1
  130. package/dist/provider/utility/requests.utility.mjs.map +1 -1
  131. package/dist/provider/websocket/index.cjs +2 -1
  132. package/dist/provider/websocket/index.d.cts +2 -1
  133. package/dist/provider/websocket/index.d.mts +2 -1
  134. package/dist/provider/websocket/index.mjs +2 -2
  135. package/dist/provider/websocket/ws.cjs +2 -2
  136. package/dist/provider/websocket/ws.cjs.map +1 -1
  137. package/dist/provider/websocket/ws.d.cts +0 -1
  138. package/dist/provider/websocket/ws.d.cts.map +1 -1
  139. package/dist/provider/websocket/ws.d.mts +0 -1
  140. package/dist/provider/websocket/ws.d.mts.map +1 -1
  141. package/dist/provider/websocket/ws.mjs +2 -1
  142. package/dist/provider/websocket/ws.mjs.map +1 -1
  143. package/dist/services/index.cjs +2 -1
  144. package/dist/services/index.d.cts +2 -1
  145. package/dist/services/index.d.mts +2 -1
  146. package/dist/services/index.mjs +2 -2
  147. package/dist/services/rest/restService.cjs +1 -1
  148. package/dist/services/rest/restService.cjs.map +1 -1
  149. package/dist/services/rest/restService.d.cts +0 -1
  150. package/dist/services/rest/restService.d.cts.map +1 -1
  151. package/dist/services/rest/restService.d.mts +0 -1
  152. package/dist/services/rest/restService.d.mts.map +1 -1
  153. package/dist/services/rest/restService.mjs.map +1 -1
  154. package/dist/services/rest/restService.types.d.cts +1 -1
  155. package/dist/services/rest/restService.types.d.cts.map +1 -1
  156. package/dist/services/rest/restService.types.d.mts +1 -1
  157. package/dist/services/rest/restService.types.d.mts.map +1 -1
  158. package/dist/utility/compact-bit-array.cjs +1 -1
  159. package/dist/utility/compact-bit-array.cjs.map +1 -1
  160. package/dist/utility/compact-bit-array.d.cts +0 -1
  161. package/dist/utility/compact-bit-array.d.cts.map +1 -1
  162. package/dist/utility/compact-bit-array.d.mts +0 -1
  163. package/dist/utility/compact-bit-array.d.mts.map +1 -1
  164. package/dist/utility/compact-bit-array.mjs +1 -1
  165. package/dist/utility/compact-bit-array.mjs.map +1 -1
  166. package/dist/utility/index.cjs +3 -1
  167. package/dist/utility/index.d.cts +2 -1
  168. package/dist/utility/index.d.mts +2 -1
  169. package/dist/utility/index.mjs +2 -2
  170. package/dist/wallet/index.cjs +16 -5
  171. package/dist/wallet/index.d.cts +6 -1
  172. package/dist/wallet/index.d.mts +6 -1
  173. package/dist/wallet/index.mjs +6 -6
  174. package/dist/wallet/key/index.cjs +2 -1
  175. package/dist/wallet/key/index.d.cts +2 -1
  176. package/dist/wallet/key/index.d.mts +2 -1
  177. package/dist/wallet/key/index.mjs +2 -2
  178. package/dist/wallet/key/key.cjs +9 -10
  179. package/dist/wallet/key/key.cjs.map +1 -1
  180. package/dist/wallet/key/key.d.cts +0 -1
  181. package/dist/wallet/key/key.d.cts.map +1 -1
  182. package/dist/wallet/key/key.d.mts +0 -1
  183. package/dist/wallet/key/key.d.mts.map +1 -1
  184. package/dist/wallet/key/key.mjs +1 -1
  185. package/dist/wallet/key/key.mjs.map +1 -1
  186. package/dist/wallet/ledger/index.cjs +2 -1
  187. package/dist/wallet/ledger/index.d.cts +2 -1
  188. package/dist/wallet/ledger/index.d.mts +2 -1
  189. package/dist/wallet/ledger/index.mjs +2 -2
  190. package/dist/wallet/ledger/ledger.cjs +9 -10
  191. package/dist/wallet/ledger/ledger.cjs.map +1 -1
  192. package/dist/wallet/ledger/ledger.d.cts +0 -1
  193. package/dist/wallet/ledger/ledger.d.cts.map +1 -1
  194. package/dist/wallet/ledger/ledger.d.mts +0 -1
  195. package/dist/wallet/ledger/ledger.d.mts.map +1 -1
  196. package/dist/wallet/ledger/ledger.mjs +3 -2
  197. package/dist/wallet/ledger/ledger.mjs.map +1 -1
  198. package/dist/wallet/signer.d.cts.map +1 -1
  199. package/dist/wallet/signer.d.mts.map +1 -1
  200. package/dist/wallet/types/index.cjs +2 -1
  201. package/dist/wallet/types/index.d.cts +2 -1
  202. package/dist/wallet/types/index.d.mts +2 -1
  203. package/dist/wallet/types/index.mjs +2 -2
  204. package/dist/wallet/types/sign.d.cts.map +1 -1
  205. package/dist/wallet/types/sign.d.mts.map +1 -1
  206. package/dist/wallet/types/wallet.d.cts.map +1 -1
  207. package/dist/wallet/types/wallet.d.mts.map +1 -1
  208. package/dist/wallet/utility/index.cjs +8 -1
  209. package/dist/wallet/utility/index.d.cts +2 -1
  210. package/dist/wallet/utility/index.d.mts +2 -1
  211. package/dist/wallet/utility/index.mjs +2 -2
  212. package/dist/wallet/utility/utility.cjs +1 -1
  213. package/dist/wallet/utility/utility.cjs.map +1 -1
  214. package/dist/wallet/utility/utility.d.cts +0 -1
  215. package/dist/wallet/utility/utility.d.cts.map +1 -1
  216. package/dist/wallet/utility/utility.d.mts +0 -1
  217. package/dist/wallet/utility/utility.d.mts.map +1 -1
  218. package/dist/wallet/utility/utility.mjs.map +1 -1
  219. package/dist/wallet/wallet.cjs +16 -17
  220. package/dist/wallet/wallet.cjs.map +1 -1
  221. package/dist/wallet/wallet.d.cts +3 -1
  222. package/dist/wallet/wallet.d.cts.map +1 -1
  223. package/dist/wallet/wallet.d.mts +3 -1
  224. package/dist/wallet/wallet.d.mts.map +1 -1
  225. package/dist/wallet/wallet.mjs +4 -3
  226. package/dist/wallet/wallet.mjs.map +1 -1
  227. package/package.json +38 -36
  228. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.cjs +0 -12
  229. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.cjs +0 -9
  230. package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.mjs +0 -9
  231. package/dist/index.cjs.map +0 -1
  232. package/dist/index.d.cts.map +0 -1
  233. package/dist/index.d.mts.map +0 -1
  234. package/dist/index.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"provider.utility.cjs","names":["parseABCI","constructRequestError","ABCIErrorKey","parseProto","ResponseDeliverTx","base64ToUint8Array","uint8ArrayToBase64","Tx"],"sources":["../../../src/provider/utility/provider.utility.ts"],"sourcesContent":["import {\n sha256,\n} from \"@cosmjs/crypto\";\n\nimport {\n Tx,\n} from \"../../proto/index.js\";\nimport {\n ResponseDeliverTx,\n} from \"../../proto/tm2/abci.js\";\nimport {\n Provider,\n} from \"../provider.js\";\nimport {\n ABCIAccount, ABCIErrorKey, ABCIResponse, BlockInfo,\n} from \"../types/index.js\";\nimport {\n constructRequestError,\n} from \"./errors.utility.js\";\nimport {\n base64ToUint8Array,\n parseABCI,\n parseProto,\n uint8ArrayToBase64,\n} from \"./requests.utility.js\";\n\n/**\n * Extracts the specific balance denomination from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n * @param {string} denomination the required denomination\n */\nexport const extractBalanceFromResponse = (\n abciData: string | null,\n denomination: string,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n // Extract the balances\n const balancesRaw = Buffer.from(abciData, \"base64\")\n .toString()\n .replace(/\"/gi, \"\");\n\n // Find the correct balance denomination\n const balances: string[] = balancesRaw.split(\",\");\n if (balances.length < 1) {\n return 0;\n }\n\n // Find the correct denomination\n const pattern = new RegExp(`^(\\\\d+)${denomination}$`);\n for (const balance of balances) {\n const match = balance.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n\n return 0;\n};\n\n/**\n * Extracts the account sequence from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractSequenceFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.sequence, 10);\n }\n catch (_e) {\n // unused case\n }\n\n // Account not initialized,\n // return default value (0)\n return 0;\n};\n\n/**\n * Extracts the account number from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountNumberFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.account_number, 10);\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the account from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountFromResponse = (\n abciData: string | null,\n): ABCIAccount => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return account;\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the simulate transaction response from the ABCI response value\n * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message\n */\nexport const extractSimulateFromResponse = (\n abciResponse: ABCIResponse | null,\n): ResponseDeliverTx => {\n // Make sure the response is initialized\n if (!abciResponse) {\n throw new Error(\"abci data is not initialized\");\n }\n\n const error = abciResponse.response?.ResponseBase?.Error;\n if (error && error[ABCIErrorKey]) {\n throw constructRequestError(error[ABCIErrorKey]);\n }\n\n const value = abciResponse.response.Value;\n if (!value) {\n throw new Error(\"abci data is not initialized\");\n }\n\n try {\n return parseProto(value, ResponseDeliverTx.decode);\n }\n catch (e) {\n throw new Error(\"unable to parse simulate response\", {\n cause: e,\n });\n }\n};\n\n/**\n * Waits for the transaction to be committed to a block in the chain\n * of the specified provider. This helper does a search for incoming blocks\n * and checks if a transaction\n * @param {Provider} provider the provider instance\n * @param {string} hash the base64-encoded hash of the transaction\n * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain\n * @param {number} [timeout=15000] the timeout in MS for the search\n */\nexport const waitForTransaction = async (\n provider: Provider,\n hash: string,\n fromHeight?: number,\n timeout?: number,\n): Promise<Tx> => {\n // Fetch the starting point\n let currentHeight = fromHeight\n ? fromHeight\n : await provider.getBlockNumber();\n\n return new Promise((resolve, reject) => {\n const exitTimeout = timeout ? timeout : 15000;\n\n const fetchInterval = setInterval(async () => {\n // Fetch the latest block height\n const latestHeight = await provider.getBlockNumber();\n\n if (latestHeight < currentHeight) {\n // No need to parse older blocks\n return;\n }\n\n for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {\n // Fetch the block from the chain\n const block: BlockInfo = await provider.getBlock(blockNum);\n\n // Check if there are any transactions at all in the block\n if (!block.block.data.txs || block.block.data.txs.length == 0) {\n continue;\n }\n\n // Find the transaction among the block transactions\n for (const tx of block.block.data.txs) {\n // Decode the base-64 transaction\n const txRaw = base64ToUint8Array(tx);\n\n // Calculate the transaction hash\n const txHash = sha256(txRaw);\n\n if (uint8ArrayToBase64(txHash) == hash) {\n // Clear the interval\n clearInterval(fetchInterval);\n\n // Decode the transaction from amino\n resolve(Tx.decode(txRaw));\n }\n }\n }\n\n currentHeight = latestHeight + 1;\n }, 1000);\n\n setTimeout(() => {\n // Clear the fetch interval\n clearInterval(fetchInterval);\n\n reject(\"transaction fetch timeout\");\n }, exitTimeout);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAa,8BACX,UACA,iBACW;AAEX,KAAI,CAAC,SACH,QAAO;CAST,MAAM,WALc,OAAO,KAAK,UAAU,SAAS,CAChD,UAAU,CACV,QAAQ,OAAO,GAAG,CAGkB,MAAM,IAAI;AACjD,KAAI,SAAS,SAAS,EACpB,QAAO;CAIT,MAAM,UAAU,IAAI,OAAO,UAAU,aAAa,GAAG;AACrD,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,QAAQ,MAAM,QAAQ;AACpC,MAAI,MACF,QAAO,SAAS,MAAM,IAAI,GAAG;;AAIjC,QAAO;;;;;;AAOT,MAAa,+BACX,aACW;AAEX,KAAI,CAAC,SACH,QAAO;AAGT,KAAI;EAEF,MAAM,UAAuBA,yBAAAA,UAAuB,SAAS;AAE7D,SAAO,SAAS,QAAQ,YAAY,UAAU,GAAG;UAE5C,IAAI;AAMX,QAAO;;;;;;AAOT,MAAa,oCACX,aACW;AAEX,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,KAAI;EAEF,MAAM,UAAuBA,yBAAAA,UAAuB,SAAS;AAE7D,SAAO,SAAS,QAAQ,YAAY,gBAAgB,GAAG;UAElD,GAAG;AACR,QAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,GACR,CAAC;;;;;;;AAQN,MAAa,8BACX,aACgB;AAEhB,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,KAAI;AAIF,SAF6BA,yBAAAA,UAAuB,SAAS;UAIxD,GAAG;AACR,QAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,GACR,CAAC;;;;;;;AAQN,MAAa,+BACX,iBACsB;AAEtB,KAAI,CAAC,aACH,OAAM,IAAI,MAAM,+BAA+B;CAGjD,MAAM,QAAQ,aAAa,UAAU,cAAc;AACnD,KAAI,SAAS,MAAA,SACX,OAAMC,uBAAAA,sBAAsB,MAAMC,aAAAA,cAAc;CAGlD,MAAM,QAAQ,aAAa,SAAS;AACpC,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,+BAA+B;AAGjD,KAAI;AACF,SAAOC,yBAAAA,WAAW,OAAOC,eAAAA,kBAAkB,OAAO;UAE7C,GAAG;AACR,QAAM,IAAI,MAAM,qCAAqC,EACnD,OAAO,GACR,CAAC;;;;;;;;;;;;AAaN,MAAa,qBAAqB,OAChC,UACA,MACA,YACA,YACgB;CAEhB,IAAI,gBAAgB,aAChB,aACA,MAAM,SAAS,gBAAgB;AAEnC,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,cAAc,UAAU,UAAU;EAExC,MAAM,gBAAgB,YAAY,YAAY;GAE5C,MAAM,eAAe,MAAM,SAAS,gBAAgB;AAEpD,OAAI,eAAe,cAEjB;AAGF,QAAK,IAAI,WAAW,eAAe,YAAY,cAAc,YAAY;IAEvE,MAAM,QAAmB,MAAM,SAAS,SAAS,SAAS;AAG1D,QAAI,CAAC,MAAM,MAAM,KAAK,OAAO,MAAM,MAAM,KAAK,IAAI,UAAU,EAC1D;AAIF,SAAK,MAAM,MAAM,MAAM,MAAM,KAAK,KAAK;KAErC,MAAM,QAAQC,yBAAAA,mBAAmB,GAAG;KAGpC,MAAM,UAAA,GAAA,eAAA,QAAgB,MAAM;AAE5B,SAAIC,yBAAAA,mBAAmB,OAAO,IAAI,MAAM;AAEtC,oBAAc,cAAc;AAG5B,cAAQC,WAAAA,GAAG,OAAO,MAAM,CAAC;;;;AAK/B,mBAAgB,eAAe;KAC9B,IAAK;AAER,mBAAiB;AAEf,iBAAc,cAAc;AAE5B,UAAO,4BAA4B;KAClC,YAAY;GACf"}
1
+ {"version":3,"file":"provider.utility.cjs","names":["parseABCI","constructRequestError","ABCIErrorKey","parseProto","ResponseDeliverTx","base64ToUint8Array","sha256","uint8ArrayToBase64","Tx"],"sources":["../../../src/provider/utility/provider.utility.ts"],"sourcesContent":["import {\n sha256,\n} from \"@cosmjs/crypto\";\n\nimport {\n Tx,\n} from \"../../proto/index.js\";\nimport {\n ResponseDeliverTx,\n} from \"../../proto/tm2/abci.js\";\nimport {\n Provider,\n} from \"../provider.js\";\nimport {\n ABCIAccount, ABCIErrorKey, ABCIResponse, BlockInfo,\n} from \"../types/index.js\";\nimport {\n constructRequestError,\n} from \"./errors.utility.js\";\nimport {\n base64ToUint8Array,\n parseABCI,\n parseProto,\n uint8ArrayToBase64,\n} from \"./requests.utility.js\";\n\n/**\n * Extracts the specific balance denomination from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n * @param {string} denomination the required denomination\n */\nexport const extractBalanceFromResponse = (\n abciData: string | null,\n denomination: string,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n // Extract the balances\n const balancesRaw = Buffer.from(abciData, \"base64\")\n .toString()\n .replace(/\"/gi, \"\");\n\n // Find the correct balance denomination\n const balances: string[] = balancesRaw.split(\",\");\n if (balances.length < 1) {\n return 0;\n }\n\n // Find the correct denomination\n const pattern = new RegExp(`^(\\\\d+)${denomination}$`);\n for (const balance of balances) {\n const match = balance.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n\n return 0;\n};\n\n/**\n * Extracts the account sequence from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractSequenceFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.sequence, 10);\n }\n catch (_e) {\n // unused case\n }\n\n // Account not initialized,\n // return default value (0)\n return 0;\n};\n\n/**\n * Extracts the account number from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountNumberFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.account_number, 10);\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the account from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountFromResponse = (\n abciData: string | null,\n): ABCIAccount => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return account;\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the simulate transaction response from the ABCI response value\n * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message\n */\nexport const extractSimulateFromResponse = (\n abciResponse: ABCIResponse | null,\n): ResponseDeliverTx => {\n // Make sure the response is initialized\n if (!abciResponse) {\n throw new Error(\"abci data is not initialized\");\n }\n\n const error = abciResponse.response?.ResponseBase?.Error;\n if (error && error[ABCIErrorKey]) {\n throw constructRequestError(error[ABCIErrorKey]);\n }\n\n const value = abciResponse.response.Value;\n if (!value) {\n throw new Error(\"abci data is not initialized\");\n }\n\n try {\n return parseProto(value, ResponseDeliverTx.decode);\n }\n catch (e) {\n throw new Error(\"unable to parse simulate response\", {\n cause: e,\n });\n }\n};\n\n/**\n * Waits for the transaction to be committed to a block in the chain\n * of the specified provider. This helper does a search for incoming blocks\n * and checks if a transaction\n * @param {Provider} provider the provider instance\n * @param {string} hash the base64-encoded hash of the transaction\n * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain\n * @param {number} [timeout=15000] the timeout in MS for the search\n */\nexport const waitForTransaction = async (\n provider: Provider,\n hash: string,\n fromHeight?: number,\n timeout?: number,\n): Promise<Tx> => {\n // Fetch the starting point\n let currentHeight = fromHeight\n ? fromHeight\n : await provider.getBlockNumber();\n\n return new Promise((resolve, reject) => {\n const exitTimeout = timeout ? timeout : 15000;\n\n const fetchInterval = setInterval(async () => {\n // Fetch the latest block height\n const latestHeight = await provider.getBlockNumber();\n\n if (latestHeight < currentHeight) {\n // No need to parse older blocks\n return;\n }\n\n for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {\n // Fetch the block from the chain\n const block: BlockInfo = await provider.getBlock(blockNum);\n\n // Check if there are any transactions at all in the block\n if (!block.block.data.txs || block.block.data.txs.length == 0) {\n continue;\n }\n\n // Find the transaction among the block transactions\n for (const tx of block.block.data.txs) {\n // Decode the base-64 transaction\n const txRaw = base64ToUint8Array(tx);\n\n // Calculate the transaction hash\n const txHash = sha256(txRaw);\n\n if (uint8ArrayToBase64(txHash) == hash) {\n // Clear the interval\n clearInterval(fetchInterval);\n\n // Decode the transaction from amino\n resolve(Tx.decode(txRaw));\n }\n }\n }\n\n currentHeight = latestHeight + 1;\n }, 1000);\n\n setTimeout(() => {\n // Clear the fetch interval\n clearInterval(fetchInterval);\n\n reject(\"transaction fetch timeout\");\n }, exitTimeout);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAa,8BACX,UACA,iBACW;CAEX,IAAI,CAAC,UACH,OAAO;CAST,MAAM,WALc,OAAO,KAAK,UAAU,QAAQ,CAAC,CAChD,SAAS,CAAC,CACV,QAAQ,OAAO,EAGS,CAAA,CAAY,MAAM,GAAG;CAChD,IAAI,SAAS,SAAS,GACpB,OAAO;CAIT,MAAM,UAAU,IAAI,OAAO,UAAU,aAAa,EAAE;CACpD,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,QAAQ,MAAM,OAAO;EACnC,IAAI,OACF,OAAO,SAAS,MAAM,IAAI,EAAE;CAEhC;CAEA,OAAO;AACT;;;;;AAMA,MAAa,+BACX,aACW;CAEX,IAAI,CAAC,UACH,OAAO;CAGT,IAAI;EAEF,MAAM,UAAuBA,yBAAAA,UAAuB,QAAQ;EAE5D,OAAO,SAAS,QAAQ,YAAY,UAAU,EAAE;CAClD,SACO,IAAI,CAEX;CAIA,OAAO;AACT;;;;;AAMA,MAAa,oCACX,aACW;CAEX,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,4BAA4B;CAG9C,IAAI;EAEF,MAAM,UAAuBA,yBAAAA,UAAuB,QAAQ;EAE5D,OAAO,SAAS,QAAQ,YAAY,gBAAgB,EAAE;CACxD,SACO,GAAG;EACR,MAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,EACT,CAAC;CACH;AACF;;;;;AAMA,MAAa,8BACX,aACgB;CAEhB,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,4BAA4B;CAG9C,IAAI;EAIF,OAF6BA,yBAAAA,UAAuB,QAE7C;CACT,SACO,GAAG;EACR,MAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,EACT,CAAC;CACH;AACF;;;;;AAMA,MAAa,+BACX,iBACsB;CAEtB,IAAI,CAAC,cACH,MAAM,IAAI,MAAM,8BAA8B;CAGhD,MAAM,QAAQ,aAAa,UAAU,cAAc;CACnD,IAAI,SAAS,MAAA,UACX,MAAMC,uBAAAA,sBAAsB,MAAMC,eAAAA,aAAa;CAGjD,MAAM,QAAQ,aAAa,SAAS;CACpC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,8BAA8B;CAGhD,IAAI;EACF,OAAOC,yBAAAA,WAAW,OAAOC,aAAAA,kBAAkB,MAAM;CACnD,SACO,GAAG;EACR,MAAM,IAAI,MAAM,qCAAqC,EACnD,OAAO,EACT,CAAC;CACH;AACF;;;;;;;;;;AAWA,MAAa,qBAAqB,OAChC,UACA,MACA,YACA,YACgB;CAEhB,IAAI,gBAAgB,aAChB,aACA,MAAM,SAAS,eAAe;CAElC,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,cAAc,UAAU,UAAU;EAExC,MAAM,gBAAgB,YAAY,YAAY;GAE5C,MAAM,eAAe,MAAM,SAAS,eAAe;GAEnD,IAAI,eAAe,eAEjB;GAGF,KAAK,IAAI,WAAW,eAAe,YAAY,cAAc,YAAY;IAEvE,MAAM,QAAmB,MAAM,SAAS,SAAS,QAAQ;IAGzD,IAAI,CAAC,MAAM,MAAM,KAAK,OAAO,MAAM,MAAM,KAAK,IAAI,UAAU,GAC1D;IAIF,KAAK,MAAM,MAAM,MAAM,MAAM,KAAK,KAAK;KAErC,MAAM,QAAQC,yBAAAA,mBAAmB,EAAE;KAGnC,MAAM,UAAA,GAASC,eAAAA,OAAAA,CAAO,KAAK;KAE3B,IAAIC,yBAAAA,mBAAmB,MAAM,KAAK,MAAM;MAEtC,cAAc,aAAa;MAG3B,QAAQC,WAAAA,GAAG,OAAO,KAAK,CAAC;KAC1B;IACF;GACF;GAEA,gBAAgB,eAAe;EACjC,GAAG,GAAI;EAEP,iBAAiB;GAEf,cAAc,aAAa;GAE3B,OAAO,2BAA2B;EACpC,GAAG,WAAW;CAChB,CAAC;AACH"}
@@ -1,8 +1,9 @@
1
+ import { ResponseDeliverTx } from "../../proto/tm2/abci.cjs";
1
2
  import { Tx } from "../../proto/tm2/tx.cjs";
3
+ import "../../proto/index.cjs";
2
4
  import { ABCIAccount, ABCIResponse } from "../types/abci.cjs";
5
+ import "../types/index.cjs";
3
6
  import { Provider } from "../provider.cjs";
4
- import { ResponseDeliverTx } from "../../proto/tm2/abci.cjs";
5
-
6
7
  //#region src/provider/utility/provider.utility.d.ts
7
8
  /**
8
9
  * Extracts the specific balance denomination from the ABCI response
@@ -1 +1 @@
1
- {"version":3,"file":"provider.utility.d.cts","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"mappings":";;;;;;;;;;AA+BA;cAAa,0BAAA,GACX,QAAA,iBACA,YAAA;;;;AAkCF;cAAa,2BAAA,GACX,QAAA;;;;AA0BF;cAAa,gCAAA,GACX,QAAA;;;;AAwBF;cAAa,0BAAA,GACX,QAAA,oBACC,WAAA;;;;AAuBH;cAAa,2BAAA,GACX,YAAA,EAAc,YAAA,YACb,iBAAA;;;;;;;;AAmCH;;cAAa,kBAAA,GACX,QAAA,EAAU,QAAA,EACV,IAAA,UACA,UAAA,WACA,OAAA,cACC,OAAA,CAAQ,EAAA"}
1
+ {"version":3,"file":"provider.utility.d.cts","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"mappings":";;;;;;;;;;;;cA+Ba,6BACX,yBACA;;;;;cAkCW,8BACX;;;;;cA0BW,mCACX;;;;;cAwBW,6BACX,4BACC;;;;;cAuBU,8BACX,cAAc,wBACb;;;;;;;;;;cAmCU,qBACX,UAAU,UACV,cACA,qBACA,qBACC,QAAQ"}
@@ -1,8 +1,9 @@
1
+ import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
1
2
  import { Tx } from "../../proto/tm2/tx.mjs";
3
+ import "../../proto/index.mjs";
2
4
  import { ABCIAccount, ABCIResponse } from "../types/abci.mjs";
5
+ import "../types/index.mjs";
3
6
  import { Provider } from "../provider.mjs";
4
- import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
5
-
6
7
  //#region src/provider/utility/provider.utility.d.ts
7
8
  /**
8
9
  * Extracts the specific balance denomination from the ABCI response
@@ -1 +1 @@
1
- {"version":3,"file":"provider.utility.d.mts","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"mappings":";;;;;;;;;;AA+BA;cAAa,0BAAA,GACX,QAAA,iBACA,YAAA;;;;AAkCF;cAAa,2BAAA,GACX,QAAA;;;;AA0BF;cAAa,gCAAA,GACX,QAAA;;;;AAwBF;cAAa,0BAAA,GACX,QAAA,oBACC,WAAA;;;;AAuBH;cAAa,2BAAA,GACX,YAAA,EAAc,YAAA,YACb,iBAAA;;;;;;;;AAmCH;;cAAa,kBAAA,GACX,QAAA,EAAU,QAAA,EACV,IAAA,UACA,UAAA,WACA,OAAA,cACC,OAAA,CAAQ,EAAA"}
1
+ {"version":3,"file":"provider.utility.d.mts","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"mappings":";;;;;;;;;;;;cA+Ba,6BACX,yBACA;;;;;cAkCW,8BACX;;;;;cA0BW,mCACX;;;;;cAwBW,6BACX,4BACC;;;;;cAuBU,8BACX,cAAc,wBACb;;;;;;;;;;cAmCU,qBACX,UAAU,UACV,cACA,qBACA,qBACC,QAAQ"}
@@ -1,9 +1,9 @@
1
+ import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
1
2
  import { Tx } from "../../proto/tm2/tx.mjs";
2
3
  import "../../proto/index.mjs";
3
4
  import { ABCIErrorKey } from "../types/abci.mjs";
4
5
  import "../types/index.mjs";
5
6
  import { constructRequestError } from "./errors.utility.mjs";
6
- import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
7
7
  import { base64ToUint8Array, parseABCI, parseProto, uint8ArrayToBase64 } from "./requests.utility.mjs";
8
8
  import { sha256 } from "@cosmjs/crypto";
9
9
  //#region src/provider/utility/provider.utility.ts
@@ -97,7 +97,8 @@ const waitForTransaction = async (provider, hash, fromHeight, timeout) => {
97
97
  if (!block.block.data.txs || block.block.data.txs.length == 0) continue;
98
98
  for (const tx of block.block.data.txs) {
99
99
  const txRaw = base64ToUint8Array(tx);
100
- if (uint8ArrayToBase64(sha256(txRaw)) == hash) {
100
+ const txHash = sha256(txRaw);
101
+ if (uint8ArrayToBase64(txHash) == hash) {
101
102
  clearInterval(fetchInterval);
102
103
  resolve(Tx.decode(txRaw));
103
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"provider.utility.mjs","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"sourcesContent":["import {\n sha256,\n} from \"@cosmjs/crypto\";\n\nimport {\n Tx,\n} from \"../../proto/index.js\";\nimport {\n ResponseDeliverTx,\n} from \"../../proto/tm2/abci.js\";\nimport {\n Provider,\n} from \"../provider.js\";\nimport {\n ABCIAccount, ABCIErrorKey, ABCIResponse, BlockInfo,\n} from \"../types/index.js\";\nimport {\n constructRequestError,\n} from \"./errors.utility.js\";\nimport {\n base64ToUint8Array,\n parseABCI,\n parseProto,\n uint8ArrayToBase64,\n} from \"./requests.utility.js\";\n\n/**\n * Extracts the specific balance denomination from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n * @param {string} denomination the required denomination\n */\nexport const extractBalanceFromResponse = (\n abciData: string | null,\n denomination: string,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n // Extract the balances\n const balancesRaw = Buffer.from(abciData, \"base64\")\n .toString()\n .replace(/\"/gi, \"\");\n\n // Find the correct balance denomination\n const balances: string[] = balancesRaw.split(\",\");\n if (balances.length < 1) {\n return 0;\n }\n\n // Find the correct denomination\n const pattern = new RegExp(`^(\\\\d+)${denomination}$`);\n for (const balance of balances) {\n const match = balance.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n\n return 0;\n};\n\n/**\n * Extracts the account sequence from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractSequenceFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.sequence, 10);\n }\n catch (_e) {\n // unused case\n }\n\n // Account not initialized,\n // return default value (0)\n return 0;\n};\n\n/**\n * Extracts the account number from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountNumberFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.account_number, 10);\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the account from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountFromResponse = (\n abciData: string | null,\n): ABCIAccount => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return account;\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the simulate transaction response from the ABCI response value\n * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message\n */\nexport const extractSimulateFromResponse = (\n abciResponse: ABCIResponse | null,\n): ResponseDeliverTx => {\n // Make sure the response is initialized\n if (!abciResponse) {\n throw new Error(\"abci data is not initialized\");\n }\n\n const error = abciResponse.response?.ResponseBase?.Error;\n if (error && error[ABCIErrorKey]) {\n throw constructRequestError(error[ABCIErrorKey]);\n }\n\n const value = abciResponse.response.Value;\n if (!value) {\n throw new Error(\"abci data is not initialized\");\n }\n\n try {\n return parseProto(value, ResponseDeliverTx.decode);\n }\n catch (e) {\n throw new Error(\"unable to parse simulate response\", {\n cause: e,\n });\n }\n};\n\n/**\n * Waits for the transaction to be committed to a block in the chain\n * of the specified provider. This helper does a search for incoming blocks\n * and checks if a transaction\n * @param {Provider} provider the provider instance\n * @param {string} hash the base64-encoded hash of the transaction\n * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain\n * @param {number} [timeout=15000] the timeout in MS for the search\n */\nexport const waitForTransaction = async (\n provider: Provider,\n hash: string,\n fromHeight?: number,\n timeout?: number,\n): Promise<Tx> => {\n // Fetch the starting point\n let currentHeight = fromHeight\n ? fromHeight\n : await provider.getBlockNumber();\n\n return new Promise((resolve, reject) => {\n const exitTimeout = timeout ? timeout : 15000;\n\n const fetchInterval = setInterval(async () => {\n // Fetch the latest block height\n const latestHeight = await provider.getBlockNumber();\n\n if (latestHeight < currentHeight) {\n // No need to parse older blocks\n return;\n }\n\n for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {\n // Fetch the block from the chain\n const block: BlockInfo = await provider.getBlock(blockNum);\n\n // Check if there are any transactions at all in the block\n if (!block.block.data.txs || block.block.data.txs.length == 0) {\n continue;\n }\n\n // Find the transaction among the block transactions\n for (const tx of block.block.data.txs) {\n // Decode the base-64 transaction\n const txRaw = base64ToUint8Array(tx);\n\n // Calculate the transaction hash\n const txHash = sha256(txRaw);\n\n if (uint8ArrayToBase64(txHash) == hash) {\n // Clear the interval\n clearInterval(fetchInterval);\n\n // Decode the transaction from amino\n resolve(Tx.decode(txRaw));\n }\n }\n }\n\n currentHeight = latestHeight + 1;\n }, 1000);\n\n setTimeout(() => {\n // Clear the fetch interval\n clearInterval(fetchInterval);\n\n reject(\"transaction fetch timeout\");\n }, exitTimeout);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAa,8BACX,UACA,iBACW;AAEX,KAAI,CAAC,SACH,QAAO;CAST,MAAM,WALc,OAAO,KAAK,UAAU,SAAS,CAChD,UAAU,CACV,QAAQ,OAAO,GAAG,CAGkB,MAAM,IAAI;AACjD,KAAI,SAAS,SAAS,EACpB,QAAO;CAIT,MAAM,UAAU,IAAI,OAAO,UAAU,aAAa,GAAG;AACrD,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,QAAQ,MAAM,QAAQ;AACpC,MAAI,MACF,QAAO,SAAS,MAAM,IAAI,GAAG;;AAIjC,QAAO;;;;;;AAOT,MAAa,+BACX,aACW;AAEX,KAAI,CAAC,SACH,QAAO;AAGT,KAAI;EAEF,MAAM,UAAuB,UAAuB,SAAS;AAE7D,SAAO,SAAS,QAAQ,YAAY,UAAU,GAAG;UAE5C,IAAI;AAMX,QAAO;;;;;;AAOT,MAAa,oCACX,aACW;AAEX,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,KAAI;EAEF,MAAM,UAAuB,UAAuB,SAAS;AAE7D,SAAO,SAAS,QAAQ,YAAY,gBAAgB,GAAG;UAElD,GAAG;AACR,QAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,GACR,CAAC;;;;;;;AAQN,MAAa,8BACX,aACgB;AAEhB,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6BAA6B;AAG/C,KAAI;AAIF,SAF6B,UAAuB,SAAS;UAIxD,GAAG;AACR,QAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,GACR,CAAC;;;;;;;AAQN,MAAa,+BACX,iBACsB;AAEtB,KAAI,CAAC,aACH,OAAM,IAAI,MAAM,+BAA+B;CAGjD,MAAM,QAAQ,aAAa,UAAU,cAAc;AACnD,KAAI,SAAS,MAAA,SACX,OAAM,sBAAsB,MAAM,cAAc;CAGlD,MAAM,QAAQ,aAAa,SAAS;AACpC,KAAI,CAAC,MACH,OAAM,IAAI,MAAM,+BAA+B;AAGjD,KAAI;AACF,SAAO,WAAW,OAAO,kBAAkB,OAAO;UAE7C,GAAG;AACR,QAAM,IAAI,MAAM,qCAAqC,EACnD,OAAO,GACR,CAAC;;;;;;;;;;;;AAaN,MAAa,qBAAqB,OAChC,UACA,MACA,YACA,YACgB;CAEhB,IAAI,gBAAgB,aAChB,aACA,MAAM,SAAS,gBAAgB;AAEnC,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,cAAc,UAAU,UAAU;EAExC,MAAM,gBAAgB,YAAY,YAAY;GAE5C,MAAM,eAAe,MAAM,SAAS,gBAAgB;AAEpD,OAAI,eAAe,cAEjB;AAGF,QAAK,IAAI,WAAW,eAAe,YAAY,cAAc,YAAY;IAEvE,MAAM,QAAmB,MAAM,SAAS,SAAS,SAAS;AAG1D,QAAI,CAAC,MAAM,MAAM,KAAK,OAAO,MAAM,MAAM,KAAK,IAAI,UAAU,EAC1D;AAIF,SAAK,MAAM,MAAM,MAAM,MAAM,KAAK,KAAK;KAErC,MAAM,QAAQ,mBAAmB,GAAG;AAKpC,SAAI,mBAFW,OAAO,MAAM,CAEE,IAAI,MAAM;AAEtC,oBAAc,cAAc;AAG5B,cAAQ,GAAG,OAAO,MAAM,CAAC;;;;AAK/B,mBAAgB,eAAe;KAC9B,IAAK;AAER,mBAAiB;AAEf,iBAAc,cAAc;AAE5B,UAAO,4BAA4B;KAClC,YAAY;GACf"}
1
+ {"version":3,"file":"provider.utility.mjs","names":[],"sources":["../../../src/provider/utility/provider.utility.ts"],"sourcesContent":["import {\n sha256,\n} from \"@cosmjs/crypto\";\n\nimport {\n Tx,\n} from \"../../proto/index.js\";\nimport {\n ResponseDeliverTx,\n} from \"../../proto/tm2/abci.js\";\nimport {\n Provider,\n} from \"../provider.js\";\nimport {\n ABCIAccount, ABCIErrorKey, ABCIResponse, BlockInfo,\n} from \"../types/index.js\";\nimport {\n constructRequestError,\n} from \"./errors.utility.js\";\nimport {\n base64ToUint8Array,\n parseABCI,\n parseProto,\n uint8ArrayToBase64,\n} from \"./requests.utility.js\";\n\n/**\n * Extracts the specific balance denomination from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n * @param {string} denomination the required denomination\n */\nexport const extractBalanceFromResponse = (\n abciData: string | null,\n denomination: string,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n // Extract the balances\n const balancesRaw = Buffer.from(abciData, \"base64\")\n .toString()\n .replace(/\"/gi, \"\");\n\n // Find the correct balance denomination\n const balances: string[] = balancesRaw.split(\",\");\n if (balances.length < 1) {\n return 0;\n }\n\n // Find the correct denomination\n const pattern = new RegExp(`^(\\\\d+)${denomination}$`);\n for (const balance of balances) {\n const match = balance.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n\n return 0;\n};\n\n/**\n * Extracts the account sequence from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractSequenceFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.sequence, 10);\n }\n catch (_e) {\n // unused case\n }\n\n // Account not initialized,\n // return default value (0)\n return 0;\n};\n\n/**\n * Extracts the account number from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountNumberFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.account_number, 10);\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the account from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountFromResponse = (\n abciData: string | null,\n): ABCIAccount => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return account;\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the simulate transaction response from the ABCI response value\n * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message\n */\nexport const extractSimulateFromResponse = (\n abciResponse: ABCIResponse | null,\n): ResponseDeliverTx => {\n // Make sure the response is initialized\n if (!abciResponse) {\n throw new Error(\"abci data is not initialized\");\n }\n\n const error = abciResponse.response?.ResponseBase?.Error;\n if (error && error[ABCIErrorKey]) {\n throw constructRequestError(error[ABCIErrorKey]);\n }\n\n const value = abciResponse.response.Value;\n if (!value) {\n throw new Error(\"abci data is not initialized\");\n }\n\n try {\n return parseProto(value, ResponseDeliverTx.decode);\n }\n catch (e) {\n throw new Error(\"unable to parse simulate response\", {\n cause: e,\n });\n }\n};\n\n/**\n * Waits for the transaction to be committed to a block in the chain\n * of the specified provider. This helper does a search for incoming blocks\n * and checks if a transaction\n * @param {Provider} provider the provider instance\n * @param {string} hash the base64-encoded hash of the transaction\n * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain\n * @param {number} [timeout=15000] the timeout in MS for the search\n */\nexport const waitForTransaction = async (\n provider: Provider,\n hash: string,\n fromHeight?: number,\n timeout?: number,\n): Promise<Tx> => {\n // Fetch the starting point\n let currentHeight = fromHeight\n ? fromHeight\n : await provider.getBlockNumber();\n\n return new Promise((resolve, reject) => {\n const exitTimeout = timeout ? timeout : 15000;\n\n const fetchInterval = setInterval(async () => {\n // Fetch the latest block height\n const latestHeight = await provider.getBlockNumber();\n\n if (latestHeight < currentHeight) {\n // No need to parse older blocks\n return;\n }\n\n for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {\n // Fetch the block from the chain\n const block: BlockInfo = await provider.getBlock(blockNum);\n\n // Check if there are any transactions at all in the block\n if (!block.block.data.txs || block.block.data.txs.length == 0) {\n continue;\n }\n\n // Find the transaction among the block transactions\n for (const tx of block.block.data.txs) {\n // Decode the base-64 transaction\n const txRaw = base64ToUint8Array(tx);\n\n // Calculate the transaction hash\n const txHash = sha256(txRaw);\n\n if (uint8ArrayToBase64(txHash) == hash) {\n // Clear the interval\n clearInterval(fetchInterval);\n\n // Decode the transaction from amino\n resolve(Tx.decode(txRaw));\n }\n }\n }\n\n currentHeight = latestHeight + 1;\n }, 1000);\n\n setTimeout(() => {\n // Clear the fetch interval\n clearInterval(fetchInterval);\n\n reject(\"transaction fetch timeout\");\n }, exitTimeout);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;AA+BA,MAAa,8BACX,UACA,iBACW;CAEX,IAAI,CAAC,UACH,OAAO;CAST,MAAM,WALc,OAAO,KAAK,UAAU,QAAQ,CAAC,CAChD,SAAS,CAAC,CACV,QAAQ,OAAO,EAGS,CAAA,CAAY,MAAM,GAAG;CAChD,IAAI,SAAS,SAAS,GACpB,OAAO;CAIT,MAAM,UAAU,IAAI,OAAO,UAAU,aAAa,EAAE;CACpD,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,QAAQ,MAAM,OAAO;EACnC,IAAI,OACF,OAAO,SAAS,MAAM,IAAI,EAAE;CAEhC;CAEA,OAAO;AACT;;;;;AAMA,MAAa,+BACX,aACW;CAEX,IAAI,CAAC,UACH,OAAO;CAGT,IAAI;EAEF,MAAM,UAAuB,UAAuB,QAAQ;EAE5D,OAAO,SAAS,QAAQ,YAAY,UAAU,EAAE;CAClD,SACO,IAAI,CAEX;CAIA,OAAO;AACT;;;;;AAMA,MAAa,oCACX,aACW;CAEX,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,4BAA4B;CAG9C,IAAI;EAEF,MAAM,UAAuB,UAAuB,QAAQ;EAE5D,OAAO,SAAS,QAAQ,YAAY,gBAAgB,EAAE;CACxD,SACO,GAAG;EACR,MAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,EACT,CAAC;CACH;AACF;;;;;AAMA,MAAa,8BACX,aACgB;CAEhB,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,4BAA4B;CAG9C,IAAI;EAIF,OAF6B,UAAuB,QAE7C;CACT,SACO,GAAG;EACR,MAAM,IAAI,MAAM,8BAA8B,EAC5C,OAAO,EACT,CAAC;CACH;AACF;;;;;AAMA,MAAa,+BACX,iBACsB;CAEtB,IAAI,CAAC,cACH,MAAM,IAAI,MAAM,8BAA8B;CAGhD,MAAM,QAAQ,aAAa,UAAU,cAAc;CACnD,IAAI,SAAS,MAAA,UACX,MAAM,sBAAsB,MAAM,aAAa;CAGjD,MAAM,QAAQ,aAAa,SAAS;CACpC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,8BAA8B;CAGhD,IAAI;EACF,OAAO,WAAW,OAAO,kBAAkB,MAAM;CACnD,SACO,GAAG;EACR,MAAM,IAAI,MAAM,qCAAqC,EACnD,OAAO,EACT,CAAC;CACH;AACF;;;;;;;;;;AAWA,MAAa,qBAAqB,OAChC,UACA,MACA,YACA,YACgB;CAEhB,IAAI,gBAAgB,aAChB,aACA,MAAM,SAAS,eAAe;CAElC,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,cAAc,UAAU,UAAU;EAExC,MAAM,gBAAgB,YAAY,YAAY;GAE5C,MAAM,eAAe,MAAM,SAAS,eAAe;GAEnD,IAAI,eAAe,eAEjB;GAGF,KAAK,IAAI,WAAW,eAAe,YAAY,cAAc,YAAY;IAEvE,MAAM,QAAmB,MAAM,SAAS,SAAS,QAAQ;IAGzD,IAAI,CAAC,MAAM,MAAM,KAAK,OAAO,MAAM,MAAM,KAAK,IAAI,UAAU,GAC1D;IAIF,KAAK,MAAM,MAAM,MAAM,MAAM,KAAK,KAAK;KAErC,MAAM,QAAQ,mBAAmB,EAAE;KAGnC,MAAM,SAAS,OAAO,KAAK;KAE3B,IAAI,mBAAmB,MAAM,KAAK,MAAM;MAEtC,cAAc,aAAa;MAG3B,QAAQ,GAAG,OAAO,KAAK,CAAC;KAC1B;IACF;GACF;GAEA,gBAAgB,eAAe;EACjC,GAAG,GAAI;EAEP,iBAAiB;GAEf,cAAc,aAAa;GAE3B,OAAO,2BAA2B;EACpC,GAAG,WAAW;CAChB,CAAC;AACH"}
@@ -1,4 +1,3 @@
1
- require("../../_virtual/_rolldown/runtime.cjs");
2
1
  let uuid = require("uuid");
3
2
  //#region src/provider/utility/requests.utility.ts
4
3
  const standardVersion = "2.0";
@@ -1 +1 @@
1
- {"version":3,"file":"requests.utility.cjs","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"sourcesContent":["import {\n BinaryReader,\n} from \"@bufbuild/protobuf/wire\";\nimport {\n v4 as uuidv4,\n} from \"uuid\";\n\nimport {\n RPCError, RPCRequest, RPCResponse,\n} from \"../types/index.js\";\n\n// The version of the supported JSON-RPC protocol\nconst standardVersion = \"2.0\";\n\n/**\n * Creates a new JSON-RPC 2.0 request\n * @param {string} method the requested method\n * @param {unknown[]} [params] the requested params, if any\n */\nexport const newRequest = (method: string, params?: unknown[]): RPCRequest => {\n return {\n // the ID of the request is not that relevant for this helper method;\n // for finer ID control, instantiate the request object directly\n id: uuidv4(),\n jsonrpc: standardVersion,\n method: method,\n params: params,\n };\n};\n\n/**\n * Creates a new JSON-RPC 2.0 response\n * @param {Result} result the response result, if any\n * @param {RPCError} error the response error, if any\n */\nexport const newResponse = <Result>(\n result?: Result,\n error?: RPCError,\n): RPCResponse<Result> => {\n return {\n id: uuidv4(),\n jsonrpc: standardVersion,\n result: result,\n error: error,\n };\n};\n\n/**\n * Parses the base64 encoded ABCI JSON into a concrete type\n * @param {string} data the base64-encoded JSON\n */\nexport const parseABCI = <Result>(data: string): Result => {\n const jsonData: string = Buffer.from(data, \"base64\").toString();\n const parsedData: Result | null = JSON.parse(jsonData);\n\n if (!parsedData) {\n throw new Error(\"unable to parse JSON response\");\n }\n\n return parsedData;\n};\n\nexport const parseProto = <T>(\n data: string,\n decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T,\n) => {\n const protoData = decodeFn(Buffer.from(data, \"base64\"));\n\n return protoData;\n};\n\n/**\n * Converts a string into base64 representation\n * @param {string} str the raw string\n */\nexport const stringToBase64 = (str: string): string => {\n const buffer = Buffer.from(str, \"utf-8\");\n\n return buffer.toString(\"base64\");\n};\n\n/**\n * Converts a base64 string into a Uint8Array representation\n * @param {string} str the base64-encoded string\n */\nexport const base64ToUint8Array = (str: string): Uint8Array => {\n const buffer = Buffer.from(str, \"base64\");\n\n return new Uint8Array(buffer);\n};\n\n/**\n * Converts a Uint8Array into base64 representation\n * @param {Uint8Array} data the Uint8Array to be encoded\n */\nexport const uint8ArrayToBase64 = (data: Uint8Array): string => {\n return Buffer.from(data).toString(\"base64\");\n};\n"],"mappings":";;;AAYA,MAAM,kBAAkB;;;;;;AAOxB,MAAa,cAAc,QAAgB,WAAmC;AAC5E,QAAO;EAGL,KAAA,GAAA,KAAA,KAAY;EACZ,SAAS;EACD;EACA;EACT;;;;;;;AAQH,MAAa,eACX,QACA,UACwB;AACxB,QAAO;EACL,KAAA,GAAA,KAAA,KAAY;EACZ,SAAS;EACD;EACD;EACR;;;;;;AAOH,MAAa,aAAqB,SAAyB;CACzD,MAAM,WAAmB,OAAO,KAAK,MAAM,SAAS,CAAC,UAAU;CAC/D,MAAM,aAA4B,KAAK,MAAM,SAAS;AAEtD,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,gCAAgC;AAGlD,QAAO;;AAGT,MAAa,cACX,MACA,aACG;AAGH,QAFkB,SAAS,OAAO,KAAK,MAAM,SAAS,CAAC;;;;;;AASzD,MAAa,kBAAkB,QAAwB;AAGrD,QAFe,OAAO,KAAK,KAAK,QAAQ,CAE1B,SAAS,SAAS;;;;;;AAOlC,MAAa,sBAAsB,QAA4B;CAC7D,MAAM,SAAS,OAAO,KAAK,KAAK,SAAS;AAEzC,QAAO,IAAI,WAAW,OAAO;;;;;;AAO/B,MAAa,sBAAsB,SAA6B;AAC9D,QAAO,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS"}
1
+ {"version":3,"file":"requests.utility.cjs","names":["uuidv4"],"sources":["../../../src/provider/utility/requests.utility.ts"],"sourcesContent":["import {\n BinaryReader,\n} from \"@bufbuild/protobuf/wire\";\nimport {\n v4 as uuidv4,\n} from \"uuid\";\n\nimport {\n RPCError, RPCRequest, RPCResponse,\n} from \"../types/index.js\";\n\n// The version of the supported JSON-RPC protocol\nconst standardVersion = \"2.0\";\n\n/**\n * Creates a new JSON-RPC 2.0 request\n * @param {string} method the requested method\n * @param {unknown[]} [params] the requested params, if any\n */\nexport const newRequest = (method: string, params?: unknown[]): RPCRequest => {\n return {\n // the ID of the request is not that relevant for this helper method;\n // for finer ID control, instantiate the request object directly\n id: uuidv4(),\n jsonrpc: standardVersion,\n method: method,\n params: params,\n };\n};\n\n/**\n * Creates a new JSON-RPC 2.0 response\n * @param {Result} result the response result, if any\n * @param {RPCError} error the response error, if any\n */\nexport const newResponse = <Result>(\n result?: Result,\n error?: RPCError,\n): RPCResponse<Result> => {\n return {\n id: uuidv4(),\n jsonrpc: standardVersion,\n result: result,\n error: error,\n };\n};\n\n/**\n * Parses the base64 encoded ABCI JSON into a concrete type\n * @param {string} data the base64-encoded JSON\n */\nexport const parseABCI = <Result>(data: string): Result => {\n const jsonData: string = Buffer.from(data, \"base64\").toString();\n const parsedData: Result | null = JSON.parse(jsonData);\n\n if (!parsedData) {\n throw new Error(\"unable to parse JSON response\");\n }\n\n return parsedData;\n};\n\nexport const parseProto = <T>(\n data: string,\n decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T,\n) => {\n const protoData = decodeFn(Buffer.from(data, \"base64\"));\n\n return protoData;\n};\n\n/**\n * Converts a string into base64 representation\n * @param {string} str the raw string\n */\nexport const stringToBase64 = (str: string): string => {\n const buffer = Buffer.from(str, \"utf-8\");\n\n return buffer.toString(\"base64\");\n};\n\n/**\n * Converts a base64 string into a Uint8Array representation\n * @param {string} str the base64-encoded string\n */\nexport const base64ToUint8Array = (str: string): Uint8Array => {\n const buffer = Buffer.from(str, \"base64\");\n\n return new Uint8Array(buffer);\n};\n\n/**\n * Converts a Uint8Array into base64 representation\n * @param {Uint8Array} data the Uint8Array to be encoded\n */\nexport const uint8ArrayToBase64 = (data: Uint8Array): string => {\n return Buffer.from(data).toString(\"base64\");\n};\n"],"mappings":";;AAYA,MAAM,kBAAkB;;;;;;AAOxB,MAAa,cAAc,QAAgB,WAAmC;CAC5E,OAAO;EAGL,KAAA,GAAIA,KAAAA,GAAAA,CAAO;EACX,SAAS;EACD;EACA;CACV;AACF;;;;;;AAOA,MAAa,eACX,QACA,UACwB;CACxB,OAAO;EACL,KAAA,GAAIA,KAAAA,GAAAA,CAAO;EACX,SAAS;EACD;EACD;CACT;AACF;;;;;AAMA,MAAa,aAAqB,SAAyB;CACzD,MAAM,WAAmB,OAAO,KAAK,MAAM,QAAQ,CAAC,CAAC,SAAS;CAC9D,MAAM,aAA4B,KAAK,MAAM,QAAQ;CAErD,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,+BAA+B;CAGjD,OAAO;AACT;AAEA,MAAa,cACX,MACA,aACG;CAGH,OAFkB,SAAS,OAAO,KAAK,MAAM,QAAQ,CAE9C;AACT;;;;;AAMA,MAAa,kBAAkB,QAAwB;CAGrD,OAFe,OAAO,KAAK,KAAK,OAEzB,CAAA,CAAO,SAAS,QAAQ;AACjC;;;;;AAMA,MAAa,sBAAsB,QAA4B;CAC7D,MAAM,SAAS,OAAO,KAAK,KAAK,QAAQ;CAExC,OAAO,IAAI,WAAW,MAAM;AAC9B;;;;;AAMA,MAAa,sBAAsB,SAA6B;CAC9D,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,SAAS,QAAQ;AAC5C"}
@@ -1,6 +1,6 @@
1
1
  import { RPCError, RPCRequest, RPCResponse } from "../types/jsonrpc.cjs";
2
+ import "../types/index.cjs";
2
3
  import { BinaryReader } from "@bufbuild/protobuf/wire";
3
-
4
4
  //#region src/provider/utility/requests.utility.d.ts
5
5
  /**
6
6
  * Creates a new JSON-RPC 2.0 request
@@ -1 +1 @@
1
- {"version":3,"file":"requests.utility.d.cts","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"mappings":";;;;;;;AAmBA;;cAAa,UAAA,GAAc,MAAA,UAAgB,MAAA,iBAAqB,UAAA;;;;;;cAgBnD,WAAA,WACX,MAAA,GAAS,MAAA,EACT,KAAA,GAAQ,QAAA,KACP,WAAA,CAAY,MAAA;AAHf;;;;AAAA,cAgBa,SAAA,WAAqB,IAAA,aAAe,MAAA;AAAA,cAWpC,UAAA,MACX,IAAA,UACA,QAAA,GAAW,KAAA,EAAO,YAAA,GAAe,UAAA,EAAY,MAAA,cAAoB,CAAA,KAAC,CAAA;;;;;cAWvD,cAAA,GAAkB,GAAA;;;;;cAUlB,kBAAA,GAAsB,GAAA,aAAc,UAAA;;;AAlCjD;;cA4Ca,kBAAA,GAAsB,IAAA,EAAM,UAAA"}
1
+ {"version":3,"file":"requests.utility.d.cts","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"mappings":";;;;;;;;;cAmBa,aAAc,gBAAgB,uBAAqB;;;;;;cAgBnD,cAAe,QAC1B,SAAS,QACT,QAAQ,aACP,YAAY;;;;;cAaF,YAAa,QAAQ,iBAAe;cAWpC,aAAc,GACzB,cACA,WAAW,OAAO,eAAe,YAAY,oBAAoB,MAAC;;;;;cAWvD,iBAAkB;;;;;cAUlB,qBAAsB,gBAAc;;;;;cAUpC,qBAAsB,MAAM"}
@@ -1,6 +1,6 @@
1
1
  import { RPCError, RPCRequest, RPCResponse } from "../types/jsonrpc.mjs";
2
+ import "../types/index.mjs";
2
3
  import { BinaryReader } from "@bufbuild/protobuf/wire";
3
-
4
4
  //#region src/provider/utility/requests.utility.d.ts
5
5
  /**
6
6
  * Creates a new JSON-RPC 2.0 request
@@ -1 +1 @@
1
- {"version":3,"file":"requests.utility.d.mts","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"mappings":";;;;;;;AAmBA;;cAAa,UAAA,GAAc,MAAA,UAAgB,MAAA,iBAAqB,UAAA;;;;;;cAgBnD,WAAA,WACX,MAAA,GAAS,MAAA,EACT,KAAA,GAAQ,QAAA,KACP,WAAA,CAAY,MAAA;AAHf;;;;AAAA,cAgBa,SAAA,WAAqB,IAAA,aAAe,MAAA;AAAA,cAWpC,UAAA,MACX,IAAA,UACA,QAAA,GAAW,KAAA,EAAO,YAAA,GAAe,UAAA,EAAY,MAAA,cAAoB,CAAA,KAAC,CAAA;;;;;cAWvD,cAAA,GAAkB,GAAA;;;;;cAUlB,kBAAA,GAAsB,GAAA,aAAc,UAAA;;;AAlCjD;;cA4Ca,kBAAA,GAAsB,IAAA,EAAM,UAAA"}
1
+ {"version":3,"file":"requests.utility.d.mts","names":[],"sources":["../../../src/provider/utility/requests.utility.ts"],"mappings":";;;;;;;;;cAmBa,aAAc,gBAAgB,uBAAqB;;;;;;cAgBnD,cAAe,QAC1B,SAAS,QACT,QAAQ,aACP,YAAY;;;;;cAaF,YAAa,QAAQ,iBAAe;cAWpC,aAAc,GACzB,cACA,WAAW,OAAO,eAAe,YAAY,oBAAoB,MAAC;;;;;cAWvD,iBAAkB;;;;;cAUlB,qBAAsB,gBAAc;;;;;cAUpC,qBAAsB,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"requests.utility.mjs","names":["uuidv4"],"sources":["../../../src/provider/utility/requests.utility.ts"],"sourcesContent":["import {\n BinaryReader,\n} from \"@bufbuild/protobuf/wire\";\nimport {\n v4 as uuidv4,\n} from \"uuid\";\n\nimport {\n RPCError, RPCRequest, RPCResponse,\n} from \"../types/index.js\";\n\n// The version of the supported JSON-RPC protocol\nconst standardVersion = \"2.0\";\n\n/**\n * Creates a new JSON-RPC 2.0 request\n * @param {string} method the requested method\n * @param {unknown[]} [params] the requested params, if any\n */\nexport const newRequest = (method: string, params?: unknown[]): RPCRequest => {\n return {\n // the ID of the request is not that relevant for this helper method;\n // for finer ID control, instantiate the request object directly\n id: uuidv4(),\n jsonrpc: standardVersion,\n method: method,\n params: params,\n };\n};\n\n/**\n * Creates a new JSON-RPC 2.0 response\n * @param {Result} result the response result, if any\n * @param {RPCError} error the response error, if any\n */\nexport const newResponse = <Result>(\n result?: Result,\n error?: RPCError,\n): RPCResponse<Result> => {\n return {\n id: uuidv4(),\n jsonrpc: standardVersion,\n result: result,\n error: error,\n };\n};\n\n/**\n * Parses the base64 encoded ABCI JSON into a concrete type\n * @param {string} data the base64-encoded JSON\n */\nexport const parseABCI = <Result>(data: string): Result => {\n const jsonData: string = Buffer.from(data, \"base64\").toString();\n const parsedData: Result | null = JSON.parse(jsonData);\n\n if (!parsedData) {\n throw new Error(\"unable to parse JSON response\");\n }\n\n return parsedData;\n};\n\nexport const parseProto = <T>(\n data: string,\n decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T,\n) => {\n const protoData = decodeFn(Buffer.from(data, \"base64\"));\n\n return protoData;\n};\n\n/**\n * Converts a string into base64 representation\n * @param {string} str the raw string\n */\nexport const stringToBase64 = (str: string): string => {\n const buffer = Buffer.from(str, \"utf-8\");\n\n return buffer.toString(\"base64\");\n};\n\n/**\n * Converts a base64 string into a Uint8Array representation\n * @param {string} str the base64-encoded string\n */\nexport const base64ToUint8Array = (str: string): Uint8Array => {\n const buffer = Buffer.from(str, \"base64\");\n\n return new Uint8Array(buffer);\n};\n\n/**\n * Converts a Uint8Array into base64 representation\n * @param {Uint8Array} data the Uint8Array to be encoded\n */\nexport const uint8ArrayToBase64 = (data: Uint8Array): string => {\n return Buffer.from(data).toString(\"base64\");\n};\n"],"mappings":";;AAYA,MAAM,kBAAkB;;;;;;AAOxB,MAAa,cAAc,QAAgB,WAAmC;AAC5E,QAAO;EAGL,IAAIA,IAAQ;EACZ,SAAS;EACD;EACA;EACT;;;;;;;AAQH,MAAa,eACX,QACA,UACwB;AACxB,QAAO;EACL,IAAIA,IAAQ;EACZ,SAAS;EACD;EACD;EACR;;;;;;AAOH,MAAa,aAAqB,SAAyB;CACzD,MAAM,WAAmB,OAAO,KAAK,MAAM,SAAS,CAAC,UAAU;CAC/D,MAAM,aAA4B,KAAK,MAAM,SAAS;AAEtD,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,gCAAgC;AAGlD,QAAO;;AAGT,MAAa,cACX,MACA,aACG;AAGH,QAFkB,SAAS,OAAO,KAAK,MAAM,SAAS,CAAC;;;;;;AASzD,MAAa,kBAAkB,QAAwB;AAGrD,QAFe,OAAO,KAAK,KAAK,QAAQ,CAE1B,SAAS,SAAS;;;;;;AAOlC,MAAa,sBAAsB,QAA4B;CAC7D,MAAM,SAAS,OAAO,KAAK,KAAK,SAAS;AAEzC,QAAO,IAAI,WAAW,OAAO;;;;;;AAO/B,MAAa,sBAAsB,SAA6B;AAC9D,QAAO,OAAO,KAAK,KAAK,CAAC,SAAS,SAAS"}
1
+ {"version":3,"file":"requests.utility.mjs","names":["uuidv4"],"sources":["../../../src/provider/utility/requests.utility.ts"],"sourcesContent":["import {\n BinaryReader,\n} from \"@bufbuild/protobuf/wire\";\nimport {\n v4 as uuidv4,\n} from \"uuid\";\n\nimport {\n RPCError, RPCRequest, RPCResponse,\n} from \"../types/index.js\";\n\n// The version of the supported JSON-RPC protocol\nconst standardVersion = \"2.0\";\n\n/**\n * Creates a new JSON-RPC 2.0 request\n * @param {string} method the requested method\n * @param {unknown[]} [params] the requested params, if any\n */\nexport const newRequest = (method: string, params?: unknown[]): RPCRequest => {\n return {\n // the ID of the request is not that relevant for this helper method;\n // for finer ID control, instantiate the request object directly\n id: uuidv4(),\n jsonrpc: standardVersion,\n method: method,\n params: params,\n };\n};\n\n/**\n * Creates a new JSON-RPC 2.0 response\n * @param {Result} result the response result, if any\n * @param {RPCError} error the response error, if any\n */\nexport const newResponse = <Result>(\n result?: Result,\n error?: RPCError,\n): RPCResponse<Result> => {\n return {\n id: uuidv4(),\n jsonrpc: standardVersion,\n result: result,\n error: error,\n };\n};\n\n/**\n * Parses the base64 encoded ABCI JSON into a concrete type\n * @param {string} data the base64-encoded JSON\n */\nexport const parseABCI = <Result>(data: string): Result => {\n const jsonData: string = Buffer.from(data, \"base64\").toString();\n const parsedData: Result | null = JSON.parse(jsonData);\n\n if (!parsedData) {\n throw new Error(\"unable to parse JSON response\");\n }\n\n return parsedData;\n};\n\nexport const parseProto = <T>(\n data: string,\n decodeFn: (input: BinaryReader | Uint8Array, length?: number) => T,\n) => {\n const protoData = decodeFn(Buffer.from(data, \"base64\"));\n\n return protoData;\n};\n\n/**\n * Converts a string into base64 representation\n * @param {string} str the raw string\n */\nexport const stringToBase64 = (str: string): string => {\n const buffer = Buffer.from(str, \"utf-8\");\n\n return buffer.toString(\"base64\");\n};\n\n/**\n * Converts a base64 string into a Uint8Array representation\n * @param {string} str the base64-encoded string\n */\nexport const base64ToUint8Array = (str: string): Uint8Array => {\n const buffer = Buffer.from(str, \"base64\");\n\n return new Uint8Array(buffer);\n};\n\n/**\n * Converts a Uint8Array into base64 representation\n * @param {Uint8Array} data the Uint8Array to be encoded\n */\nexport const uint8ArrayToBase64 = (data: Uint8Array): string => {\n return Buffer.from(data).toString(\"base64\");\n};\n"],"mappings":";;AAYA,MAAM,kBAAkB;;;;;;AAOxB,MAAa,cAAc,QAAgB,WAAmC;CAC5E,OAAO;EAGL,IAAIA,GAAO;EACX,SAAS;EACD;EACA;CACV;AACF;;;;;;AAOA,MAAa,eACX,QACA,UACwB;CACxB,OAAO;EACL,IAAIA,GAAO;EACX,SAAS;EACD;EACD;CACT;AACF;;;;;AAMA,MAAa,aAAqB,SAAyB;CACzD,MAAM,WAAmB,OAAO,KAAK,MAAM,QAAQ,CAAC,CAAC,SAAS;CAC9D,MAAM,aAA4B,KAAK,MAAM,QAAQ;CAErD,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,+BAA+B;CAGjD,OAAO;AACT;AAEA,MAAa,cACX,MACA,aACG;CAGH,OAFkB,SAAS,OAAO,KAAK,MAAM,QAAQ,CAE9C;AACT;;;;;AAMA,MAAa,kBAAkB,QAAwB;CAGrD,OAFe,OAAO,KAAK,KAAK,OAEzB,CAAA,CAAO,SAAS,QAAQ;AACjC;;;;;AAMA,MAAa,sBAAsB,QAA4B;CAC7D,MAAM,SAAS,OAAO,KAAK,KAAK,QAAQ;CAExC,OAAO,IAAI,WAAW,MAAM;AAC9B;;;;;AAMA,MAAa,sBAAsB,SAA6B;CAC9D,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,SAAS,QAAQ;AAC5C"}
@@ -1 +1,2 @@
1
- require("./ws.cjs");
1
+ const require_ws = require("./ws.cjs");
2
+ exports.WSProvider = require_ws.WSProvider;
@@ -1 +1,2 @@
1
- import { WSProvider } from "./ws.cjs";
1
+ import { WSProvider } from "./ws.cjs";
2
+ export { WSProvider };
@@ -1 +1,2 @@
1
- import { WSProvider } from "./ws.mjs";
1
+ import { WSProvider } from "./ws.mjs";
2
+ export { WSProvider };
@@ -1,2 +1,2 @@
1
- import "./ws.mjs";
2
- export {};
1
+ import { WSProvider } from "./ws.mjs";
2
+ export { WSProvider };
@@ -1,4 +1,3 @@
1
- require("../../_virtual/_rolldown/runtime.cjs");
2
1
  const require_provider = require("../provider.cjs");
3
2
  let _gnolang_tm2_rpc = require("@gnolang/tm2-rpc");
4
3
  //#region src/provider/websocket/ws.ts
@@ -11,7 +10,8 @@ var WSProvider = class WSProvider extends require_provider.BaseTm2Provider {
11
10
  * @param {string} baseURL the WS URL of the node
12
11
  */
13
12
  static async create(baseURL) {
14
- return new WSProvider(await _gnolang_tm2_rpc.Tm2Client.connect(baseURL));
13
+ const client = await _gnolang_tm2_rpc.Tm2Client.connect(baseURL);
14
+ return new WSProvider(client);
15
15
  }
16
16
  /**
17
17
  * Closes the WS connection. Required when done working
@@ -1 +1 @@
1
- {"version":3,"file":"ws.cjs","names":["BaseTm2Provider","Tm2Client"],"sources":["../../../src/provider/websocket/ws.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n BaseTm2Provider,\n} from \"../provider.js\";\n\n/**\n * Provider based on WS JSON-RPC requests\n */\nexport class WSProvider extends BaseTm2Provider {\n /**\n * Creates a new instance of the {@link WSProvider}\n * @param {string} baseURL the WS URL of the node\n */\n static async create(baseURL: string): Promise<WSProvider> {\n const client = await Tm2Client.connect(baseURL);\n return new WSProvider(client);\n }\n\n /**\n * Closes the WS connection. Required when done working\n * with the WS provider\n */\n closeConnection() {\n this.client.disconnect();\n }\n}\n"],"mappings":";;;;;;;AAWA,IAAa,aAAb,MAAa,mBAAmBA,iBAAAA,gBAAgB;;;;;CAK9C,aAAa,OAAO,SAAsC;AAExD,SAAO,IAAI,WADI,MAAMC,iBAAAA,UAAU,QAAQ,QAAQ,CAClB;;;;;;CAO/B,kBAAkB;AAChB,OAAK,OAAO,YAAY"}
1
+ {"version":3,"file":"ws.cjs","names":["BaseTm2Provider","Tm2Client"],"sources":["../../../src/provider/websocket/ws.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n BaseTm2Provider,\n} from \"../provider.js\";\n\n/**\n * Provider based on WS JSON-RPC requests\n */\nexport class WSProvider extends BaseTm2Provider {\n /**\n * Creates a new instance of the {@link WSProvider}\n * @param {string} baseURL the WS URL of the node\n */\n static async create(baseURL: string): Promise<WSProvider> {\n const client = await Tm2Client.connect(baseURL);\n return new WSProvider(client);\n }\n\n /**\n * Closes the WS connection. Required when done working\n * with the WS provider\n */\n closeConnection() {\n this.client.disconnect();\n }\n}\n"],"mappings":";;;;;;AAWA,IAAa,aAAb,MAAa,mBAAmBA,iBAAAA,gBAAgB;;;;;CAK9C,aAAa,OAAO,SAAsC;EACxD,MAAM,SAAS,MAAMC,iBAAAA,UAAU,QAAQ,OAAO;EAC9C,OAAO,IAAI,WAAW,MAAM;CAC9B;;;;;CAMA,kBAAkB;EAChB,KAAK,OAAO,WAAW;CACzB;AACF"}
@@ -1,5 +1,4 @@
1
1
  import { BaseTm2Provider } from "../provider.cjs";
2
-
3
2
  //#region src/provider/websocket/ws.d.ts
4
3
  /**
5
4
  * Provider based on WS JSON-RPC requests
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.cts","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"mappings":";;;;;AAWA;cAAa,UAAA,SAAmB,eAAA;;;;;SAKjB,MAAA,CAAO,OAAA,WAAkB,OAAA,CAAQ,UAAA;EALD;;;;EAc7C,eAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"ws.d.cts","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"mappings":";;;;;cAWa,mBAAmB;;;;;SAKjB,OAAO,kBAAkB,QAAQ;;;;;EAS9C"}
@@ -1,5 +1,4 @@
1
1
  import { BaseTm2Provider } from "../provider.mjs";
2
-
3
2
  //#region src/provider/websocket/ws.d.ts
4
3
  /**
5
4
  * Provider based on WS JSON-RPC requests
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.mts","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"mappings":";;;;;AAWA;cAAa,UAAA,SAAmB,eAAA;;;;;SAKjB,MAAA,CAAO,OAAA,WAAkB,OAAA,CAAQ,UAAA;EALD;;;;EAc7C,eAAA,CAAA;AAAA"}
1
+ {"version":3,"file":"ws.d.mts","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"mappings":";;;;;cAWa,mBAAmB;;;;;SAKjB,OAAO,kBAAkB,QAAQ;;;;;EAS9C"}
@@ -10,7 +10,8 @@ var WSProvider = class WSProvider extends BaseTm2Provider {
10
10
  * @param {string} baseURL the WS URL of the node
11
11
  */
12
12
  static async create(baseURL) {
13
- return new WSProvider(await Tm2Client.connect(baseURL));
13
+ const client = await Tm2Client.connect(baseURL);
14
+ return new WSProvider(client);
14
15
  }
15
16
  /**
16
17
  * Closes the WS connection. Required when done working
@@ -1 +1 @@
1
- {"version":3,"file":"ws.mjs","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n BaseTm2Provider,\n} from \"../provider.js\";\n\n/**\n * Provider based on WS JSON-RPC requests\n */\nexport class WSProvider extends BaseTm2Provider {\n /**\n * Creates a new instance of the {@link WSProvider}\n * @param {string} baseURL the WS URL of the node\n */\n static async create(baseURL: string): Promise<WSProvider> {\n const client = await Tm2Client.connect(baseURL);\n return new WSProvider(client);\n }\n\n /**\n * Closes the WS connection. Required when done working\n * with the WS provider\n */\n closeConnection() {\n this.client.disconnect();\n }\n}\n"],"mappings":";;;;;;AAWA,IAAa,aAAb,MAAa,mBAAmB,gBAAgB;;;;;CAK9C,aAAa,OAAO,SAAsC;AAExD,SAAO,IAAI,WADI,MAAM,UAAU,QAAQ,QAAQ,CAClB;;;;;;CAO/B,kBAAkB;AAChB,OAAK,OAAO,YAAY"}
1
+ {"version":3,"file":"ws.mjs","names":[],"sources":["../../../src/provider/websocket/ws.ts"],"sourcesContent":["import {\n Tm2Client,\n} from \"@gnolang/tm2-rpc\";\n\nimport {\n BaseTm2Provider,\n} from \"../provider.js\";\n\n/**\n * Provider based on WS JSON-RPC requests\n */\nexport class WSProvider extends BaseTm2Provider {\n /**\n * Creates a new instance of the {@link WSProvider}\n * @param {string} baseURL the WS URL of the node\n */\n static async create(baseURL: string): Promise<WSProvider> {\n const client = await Tm2Client.connect(baseURL);\n return new WSProvider(client);\n }\n\n /**\n * Closes the WS connection. Required when done working\n * with the WS provider\n */\n closeConnection() {\n this.client.disconnect();\n }\n}\n"],"mappings":";;;;;;AAWA,IAAa,aAAb,MAAa,mBAAmB,gBAAgB;;;;;CAK9C,aAAa,OAAO,SAAsC;EACxD,MAAM,SAAS,MAAM,UAAU,QAAQ,OAAO;EAC9C,OAAO,IAAI,WAAW,MAAM;CAC9B;;;;;CAMA,kBAAkB;EAChB,KAAK,OAAO,WAAW;CACzB;AACF"}
@@ -1,2 +1,3 @@
1
- require("./rest/restService.cjs");
1
+ const require_restService = require("./rest/restService.cjs");
2
2
  require("./rest/restService.types.cjs");
3
+ exports.RestService = require_restService.RestService;
@@ -1,2 +1,3 @@
1
1
  import { RequestParams } from "./rest/restService.types.cjs";
2
- import { RestService } from "./rest/restService.cjs";
2
+ import { RestService } from "./rest/restService.cjs";
3
+ export { RequestParams, RestService };
@@ -1,2 +1,3 @@
1
1
  import { RequestParams } from "./rest/restService.types.mjs";
2
- import { RestService } from "./rest/restService.mjs";
2
+ import { RestService } from "./rest/restService.mjs";
3
+ export { RequestParams, RestService };
@@ -1,3 +1,3 @@
1
- import "./rest/restService.mjs";
1
+ import { RestService } from "./rest/restService.mjs";
2
2
  import "./rest/restService.types.mjs";
3
- export {};
3
+ export { RestService };
@@ -1,6 +1,6 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
2
  let axios = require("axios");
3
- axios = require_runtime.__toESM(axios);
3
+ axios = require_runtime.__toESM(axios, 1);
4
4
  //#region src/services/rest/restService.ts
5
5
  var RestService = class {
6
6
  static async post(baseURL, params) {
@@ -1 +1 @@
1
- {"version":3,"file":"restService.cjs","names":[],"sources":["../../../src/services/rest/restService.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport {\n RPCResponse,\n} from \"../../provider/index.js\";\nimport {\n RequestParams,\n} from \"./restService.types.js\";\n\nexport class RestService {\n static async post<TResult>(\n baseURL: string,\n params: RequestParams,\n ): Promise<TResult> {\n const axiosResponse = await axios.post<RPCResponse<TResult>>(\n baseURL,\n params.request,\n params.config,\n );\n\n const {\n result, error,\n } = axiosResponse.data;\n\n // Check for errors\n if (error) {\n // Error encountered during the POST request\n throw new Error(`${error.message}: ${error.data}`);\n }\n\n // Check for the correct result format\n if (!result) {\n throw new Error(\"invalid result returned\");\n }\n\n return result;\n }\n}\n"],"mappings":";;;;AASA,IAAa,cAAb,MAAyB;CACvB,aAAa,KACX,SACA,QACkB;EAOlB,MAAM,EACJ,QAAQ,WAPY,MAAM,MAAA,QAAM,KAChC,SACA,OAAO,SACP,OAAO,OACR,EAIiB;AAGlB,MAAI,MAEF,OAAM,IAAI,MAAM,GAAG,MAAM,QAAQ,IAAI,MAAM,OAAO;AAIpD,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,0BAA0B;AAG5C,SAAO"}
1
+ {"version":3,"file":"restService.cjs","names":[],"sources":["../../../src/services/rest/restService.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport {\n RPCResponse,\n} from \"../../provider/index.js\";\nimport {\n RequestParams,\n} from \"./restService.types.js\";\n\nexport class RestService {\n static async post<TResult>(\n baseURL: string,\n params: RequestParams,\n ): Promise<TResult> {\n const axiosResponse = await axios.post<RPCResponse<TResult>>(\n baseURL,\n params.request,\n params.config,\n );\n\n const {\n result, error,\n } = axiosResponse.data;\n\n // Check for errors\n if (error) {\n // Error encountered during the POST request\n throw new Error(`${error.message}: ${error.data}`);\n }\n\n // Check for the correct result format\n if (!result) {\n throw new Error(\"invalid result returned\");\n }\n\n return result;\n }\n}\n"],"mappings":";;;;AASA,IAAa,cAAb,MAAyB;CACvB,aAAa,KACX,SACA,QACkB;EAOlB,MAAM,EACJ,QAAQ,WACN,MARwB,MAAA,QAAM,KAChC,SACA,OAAO,SACP,OAAO,MACT,EAII,CAAc;EAGlB,IAAI,OAEF,MAAM,IAAI,MAAM,GAAG,MAAM,QAAQ,IAAI,MAAM,MAAM;EAInD,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,yBAAyB;EAG3C,OAAO;CACT;AACF"}
@@ -1,5 +1,4 @@
1
1
  import { RequestParams } from "./restService.types.cjs";
2
-
3
2
  //#region src/services/rest/restService.d.ts
4
3
  declare class RestService {
5
4
  static post<TResult>(baseURL: string, params: RequestParams): Promise<TResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"restService.d.cts","names":[],"sources":["../../../src/services/rest/restService.ts"],"mappings":";;;cASa,WAAA;EAAA,OACE,IAAA,SAAA,CACX,OAAA,UACA,MAAA,EAAQ,aAAA,GACP,OAAA,CAAQ,OAAA;AAAA"}
1
+ {"version":3,"file":"restService.d.cts","names":[],"sources":["../../../src/services/rest/restService.ts"],"mappings":";;cASa;SACE,KAAK,SAChB,iBACA,QAAQ,gBACP,QAAQ"}
@@ -1,5 +1,4 @@
1
1
  import { RequestParams } from "./restService.types.mjs";
2
-
3
2
  //#region src/services/rest/restService.d.ts
4
3
  declare class RestService {
5
4
  static post<TResult>(baseURL: string, params: RequestParams): Promise<TResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"restService.d.mts","names":[],"sources":["../../../src/services/rest/restService.ts"],"mappings":";;;cASa,WAAA;EAAA,OACE,IAAA,SAAA,CACX,OAAA,UACA,MAAA,EAAQ,aAAA,GACP,OAAA,CAAQ,OAAA;AAAA"}
1
+ {"version":3,"file":"restService.d.mts","names":[],"sources":["../../../src/services/rest/restService.ts"],"mappings":";;cASa;SACE,KAAK,SAChB,iBACA,QAAQ,gBACP,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"restService.mjs","names":[],"sources":["../../../src/services/rest/restService.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport {\n RPCResponse,\n} from \"../../provider/index.js\";\nimport {\n RequestParams,\n} from \"./restService.types.js\";\n\nexport class RestService {\n static async post<TResult>(\n baseURL: string,\n params: RequestParams,\n ): Promise<TResult> {\n const axiosResponse = await axios.post<RPCResponse<TResult>>(\n baseURL,\n params.request,\n params.config,\n );\n\n const {\n result, error,\n } = axiosResponse.data;\n\n // Check for errors\n if (error) {\n // Error encountered during the POST request\n throw new Error(`${error.message}: ${error.data}`);\n }\n\n // Check for the correct result format\n if (!result) {\n throw new Error(\"invalid result returned\");\n }\n\n return result;\n }\n}\n"],"mappings":";;AASA,IAAa,cAAb,MAAyB;CACvB,aAAa,KACX,SACA,QACkB;EAOlB,MAAM,EACJ,QAAQ,WAPY,MAAM,MAAM,KAChC,SACA,OAAO,SACP,OAAO,OACR,EAIiB;AAGlB,MAAI,MAEF,OAAM,IAAI,MAAM,GAAG,MAAM,QAAQ,IAAI,MAAM,OAAO;AAIpD,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,0BAA0B;AAG5C,SAAO"}
1
+ {"version":3,"file":"restService.mjs","names":[],"sources":["../../../src/services/rest/restService.ts"],"sourcesContent":["import axios from \"axios\";\n\nimport {\n RPCResponse,\n} from \"../../provider/index.js\";\nimport {\n RequestParams,\n} from \"./restService.types.js\";\n\nexport class RestService {\n static async post<TResult>(\n baseURL: string,\n params: RequestParams,\n ): Promise<TResult> {\n const axiosResponse = await axios.post<RPCResponse<TResult>>(\n baseURL,\n params.request,\n params.config,\n );\n\n const {\n result, error,\n } = axiosResponse.data;\n\n // Check for errors\n if (error) {\n // Error encountered during the POST request\n throw new Error(`${error.message}: ${error.data}`);\n }\n\n // Check for the correct result format\n if (!result) {\n throw new Error(\"invalid result returned\");\n }\n\n return result;\n }\n}\n"],"mappings":";;AASA,IAAa,cAAb,MAAyB;CACvB,aAAa,KACX,SACA,QACkB;EAOlB,MAAM,EACJ,QAAQ,WACN,MARwB,MAAM,KAChC,SACA,OAAO,SACP,OAAO,MACT,EAII,CAAc;EAGlB,IAAI,OAEF,MAAM,IAAI,MAAM,GAAG,MAAM,QAAQ,IAAI,MAAM,MAAM;EAInD,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,yBAAyB;EAG3C,OAAO;CACT;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { RPCRequest } from "../../provider/types/jsonrpc.cjs";
2
+ import "../../provider/index.cjs";
2
3
  import { AxiosRequestConfig } from "axios";
3
-
4
4
  //#region src/services/rest/restService.types.d.ts
5
5
  interface RequestParams {
6
6
  request: RPCRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"restService.types.d.cts","names":[],"sources":["../../../src/services/rest/restService.types.ts"],"mappings":";;;;UAQiB,aAAA;EACf,OAAA,EAAS,UAAA;EACT,MAAA,GAAS,kBAAA;AAAA"}
1
+ {"version":3,"file":"restService.types.d.cts","names":[],"sources":["../../../src/services/rest/restService.types.ts"],"mappings":";;;;UAQiB;EACf,SAAS;EACT,SAAS"}
@@ -1,6 +1,6 @@
1
1
  import { RPCRequest } from "../../provider/types/jsonrpc.mjs";
2
+ import "../../provider/index.mjs";
2
3
  import { AxiosRequestConfig } from "axios";
3
-
4
4
  //#region src/services/rest/restService.types.d.ts
5
5
  interface RequestParams {
6
6
  request: RPCRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"restService.types.d.mts","names":[],"sources":["../../../src/services/rest/restService.types.ts"],"mappings":";;;;UAQiB,aAAA;EACf,OAAA,EAAS,UAAA;EACT,MAAA,GAAS,kBAAA;AAAA"}
1
+ {"version":3,"file":"restService.types.d.mts","names":[],"sources":["../../../src/services/rest/restService.types.ts"],"mappings":";;;;UAQiB;EACf,SAAS;EACT,SAAS"}
@@ -11,7 +11,7 @@
11
11
  function compactBitArrayFromAmino(amino) {
12
12
  if (amino === null) return {
13
13
  extra_bits_stored: 0,
14
- elems: new Uint8Array(0)
14
+ elems: /* @__PURE__ */ new Uint8Array(0)
15
15
  };
16
16
  const count = amino.length;
17
17
  const extraBits = count % 8;
@@ -1 +1 @@
1
- {"version":3,"file":"compact-bit-array.cjs","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"sourcesContent":["import type {\n CompactBitArray,\n} from \"../proto/tm2/multisig.js\";\n\n/**\n * Converts an amino-encoded compact bit array string to a CompactBitArray.\n * In the amino format, 'x' represents a set bit (1) and '_' represents\n * an unset bit (0). A null input produces an empty CompactBitArray.\n *\n * @example\n * compactBitArrayFromAmino(\"xx___\") // { extra_bits_stored: 5, elems: Uint8Array([0xC0]) }\n * compactBitArrayFromAmino(null) // { extra_bits_stored: 0, elems: Uint8Array([]) }\n */\nexport function compactBitArrayFromAmino(\n amino: string | null,\n): CompactBitArray {\n if (amino === null) {\n return {\n extra_bits_stored: 0,\n elems: new Uint8Array(0),\n };\n }\n\n const count = amino.length;\n const extraBits = count % 8;\n const numBytes = Math.ceil(count / 8);\n const elems = new Uint8Array(numBytes);\n\n for (let i = 0; i < count; i++) {\n if (amino[i] === \"x\") {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n elems[byteIndex] |= 1 << bitIndex;\n }\n }\n\n return {\n extra_bits_stored: extraBits,\n elems,\n };\n}\n\n/**\n * Converts a CompactBitArray to its amino string representation.\n * Set bits (1) become 'x' and unset bits (0) become '_'.\n * Returns null for empty bit arrays (zero length).\n *\n * @example\n * compactBitArrayToAmino({ extra_bits_stored: 5, elems: Uint8Array([0xC0]) }) // \"xx___\"\n * compactBitArrayToAmino({ extra_bits_stored: 0, elems: Uint8Array([]) }) // null\n */\nexport function compactBitArrayToAmino(\n cba: CompactBitArray,\n): string | null {\n if (cba.elems.length === 0) {\n return null;\n }\n\n const fullBytes = cba.extra_bits_stored === 0\n ? cba.elems.length\n : cba.elems.length - 1;\n const totalBits = fullBytes * 8 + cba.extra_bits_stored;\n\n let result = \"\";\n for (let i = 0; i < totalBits; i++) {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n const isSet = (cba.elems[byteIndex] & (1 << bitIndex)) !== 0;\n result += isSet ? \"x\" : \"_\";\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,yBACd,OACiB;AACjB,KAAI,UAAU,KACZ,QAAO;EACL,mBAAmB;EACnB,OAAO,IAAI,WAAW,EAAE;EACzB;CAGH,MAAM,QAAQ,MAAM;CACpB,MAAM,YAAY,QAAQ;CAC1B,MAAM,WAAW,KAAK,KAAK,QAAQ,EAAE;CACrC,MAAM,QAAQ,IAAI,WAAW,SAAS;AAEtC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,IACzB,KAAI,MAAM,OAAO,KAAK;EACpB,MAAM,YAAY,KAAK,MAAM,IAAI,EAAE;EACnC,MAAM,WAAW,IAAK,IAAI;AAC1B,QAAM,cAAc,KAAK;;AAI7B,QAAO;EACL,mBAAmB;EACnB;EACD;;;;;;;;;;;AAYH,SAAgB,uBACd,KACe;AACf,KAAI,IAAI,MAAM,WAAW,EACvB,QAAO;CAMT,MAAM,aAHY,IAAI,sBAAsB,IACxC,IAAI,MAAM,SACV,IAAI,MAAM,SAAS,KACO,IAAI,IAAI;CAEtC,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,KAAK;EAClC,MAAM,YAAY,KAAK,MAAM,IAAI,EAAE;EACnC,MAAM,WAAW,IAAK,IAAI;EAC1B,MAAM,SAAS,IAAI,MAAM,aAAc,KAAK,cAAe;AAC3D,YAAU,QAAQ,MAAM;;AAG1B,QAAO"}
1
+ {"version":3,"file":"compact-bit-array.cjs","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"sourcesContent":["import type {\n CompactBitArray,\n} from \"../proto/tm2/multisig.js\";\n\n/**\n * Converts an amino-encoded compact bit array string to a CompactBitArray.\n * In the amino format, 'x' represents a set bit (1) and '_' represents\n * an unset bit (0). A null input produces an empty CompactBitArray.\n *\n * @example\n * compactBitArrayFromAmino(\"xx___\") // { extra_bits_stored: 5, elems: Uint8Array([0xC0]) }\n * compactBitArrayFromAmino(null) // { extra_bits_stored: 0, elems: Uint8Array([]) }\n */\nexport function compactBitArrayFromAmino(\n amino: string | null,\n): CompactBitArray {\n if (amino === null) {\n return {\n extra_bits_stored: 0,\n elems: new Uint8Array(0),\n };\n }\n\n const count = amino.length;\n const extraBits = count % 8;\n const numBytes = Math.ceil(count / 8);\n const elems = new Uint8Array(numBytes);\n\n for (let i = 0; i < count; i++) {\n if (amino[i] === \"x\") {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n elems[byteIndex] |= 1 << bitIndex;\n }\n }\n\n return {\n extra_bits_stored: extraBits,\n elems,\n };\n}\n\n/**\n * Converts a CompactBitArray to its amino string representation.\n * Set bits (1) become 'x' and unset bits (0) become '_'.\n * Returns null for empty bit arrays (zero length).\n *\n * @example\n * compactBitArrayToAmino({ extra_bits_stored: 5, elems: Uint8Array([0xC0]) }) // \"xx___\"\n * compactBitArrayToAmino({ extra_bits_stored: 0, elems: Uint8Array([]) }) // null\n */\nexport function compactBitArrayToAmino(\n cba: CompactBitArray,\n): string | null {\n if (cba.elems.length === 0) {\n return null;\n }\n\n const fullBytes = cba.extra_bits_stored === 0\n ? cba.elems.length\n : cba.elems.length - 1;\n const totalBits = fullBytes * 8 + cba.extra_bits_stored;\n\n let result = \"\";\n for (let i = 0; i < totalBits; i++) {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n const isSet = (cba.elems[byteIndex] & (1 << bitIndex)) !== 0;\n result += isSet ? \"x\" : \"_\";\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,yBACd,OACiB;CACjB,IAAI,UAAU,MACZ,OAAO;EACL,mBAAmB;EACnB,uBAAO,IAAI,WAAW,CAAC;CACzB;CAGF,MAAM,QAAQ,MAAM;CACpB,MAAM,YAAY,QAAQ;CAC1B,MAAM,WAAW,KAAK,KAAK,QAAQ,CAAC;CACpC,MAAM,QAAQ,IAAI,WAAW,QAAQ;CAErC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KACzB,IAAI,MAAM,OAAO,KAAK;EACpB,MAAM,YAAY,KAAK,MAAM,IAAI,CAAC;EAClC,MAAM,WAAW,IAAK,IAAI;EAC1B,MAAM,cAAc,KAAK;CAC3B;CAGF,OAAO;EACL,mBAAmB;EACnB;CACF;AACF;;;;;;;;;;AAWA,SAAgB,uBACd,KACe;CACf,IAAI,IAAI,MAAM,WAAW,GACvB,OAAO;CAMT,MAAM,aAHY,IAAI,sBAAsB,IACxC,IAAI,MAAM,SACV,IAAI,MAAM,SAAS,KACO,IAAI,IAAI;CAEtC,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,KAAK;EAClC,MAAM,YAAY,KAAK,MAAM,IAAI,CAAC;EAClC,MAAM,WAAW,IAAK,IAAI;EAC1B,MAAM,SAAS,IAAI,MAAM,aAAc,KAAK,cAAe;EAC3D,UAAU,QAAQ,MAAM;CAC1B;CAEA,OAAO;AACT"}
@@ -1,5 +1,4 @@
1
1
  import { CompactBitArray } from "../proto/tm2/multisig.cjs";
2
-
3
2
  //#region src/utility/compact-bit-array.d.ts
4
3
  /**
5
4
  * Converts an amino-encoded compact bit array string to a CompactBitArray.
@@ -1 +1 @@
1
- {"version":3,"file":"compact-bit-array.d.cts","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"mappings":";;;;;AAaA;;;;;AAsCA;;iBAtCgB,wBAAA,CACd,KAAA,kBACC,eAAA;;;;;;;;;;iBAoCa,sBAAA,CACd,GAAA,EAAK,eAAA"}
1
+ {"version":3,"file":"compact-bit-array.d.cts","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"mappings":";;;;;;;;;;;iBAagB,yBACd,uBACC;;;;;;;;;;iBAoCa,uBACd,KAAK"}
@@ -1,5 +1,4 @@
1
1
  import { CompactBitArray } from "../proto/tm2/multisig.mjs";
2
-
3
2
  //#region src/utility/compact-bit-array.d.ts
4
3
  /**
5
4
  * Converts an amino-encoded compact bit array string to a CompactBitArray.
@@ -1 +1 @@
1
- {"version":3,"file":"compact-bit-array.d.mts","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"mappings":";;;;;AAaA;;;;;AAsCA;;iBAtCgB,wBAAA,CACd,KAAA,kBACC,eAAA;;;;;;;;;;iBAoCa,sBAAA,CACd,GAAA,EAAK,eAAA"}
1
+ {"version":3,"file":"compact-bit-array.d.mts","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"mappings":";;;;;;;;;;;iBAagB,yBACd,uBACC;;;;;;;;;;iBAoCa,uBACd,KAAK"}
@@ -11,7 +11,7 @@
11
11
  function compactBitArrayFromAmino(amino) {
12
12
  if (amino === null) return {
13
13
  extra_bits_stored: 0,
14
- elems: new Uint8Array(0)
14
+ elems: /* @__PURE__ */ new Uint8Array(0)
15
15
  };
16
16
  const count = amino.length;
17
17
  const extraBits = count % 8;
@@ -1 +1 @@
1
- {"version":3,"file":"compact-bit-array.mjs","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"sourcesContent":["import type {\n CompactBitArray,\n} from \"../proto/tm2/multisig.js\";\n\n/**\n * Converts an amino-encoded compact bit array string to a CompactBitArray.\n * In the amino format, 'x' represents a set bit (1) and '_' represents\n * an unset bit (0). A null input produces an empty CompactBitArray.\n *\n * @example\n * compactBitArrayFromAmino(\"xx___\") // { extra_bits_stored: 5, elems: Uint8Array([0xC0]) }\n * compactBitArrayFromAmino(null) // { extra_bits_stored: 0, elems: Uint8Array([]) }\n */\nexport function compactBitArrayFromAmino(\n amino: string | null,\n): CompactBitArray {\n if (amino === null) {\n return {\n extra_bits_stored: 0,\n elems: new Uint8Array(0),\n };\n }\n\n const count = amino.length;\n const extraBits = count % 8;\n const numBytes = Math.ceil(count / 8);\n const elems = new Uint8Array(numBytes);\n\n for (let i = 0; i < count; i++) {\n if (amino[i] === \"x\") {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n elems[byteIndex] |= 1 << bitIndex;\n }\n }\n\n return {\n extra_bits_stored: extraBits,\n elems,\n };\n}\n\n/**\n * Converts a CompactBitArray to its amino string representation.\n * Set bits (1) become 'x' and unset bits (0) become '_'.\n * Returns null for empty bit arrays (zero length).\n *\n * @example\n * compactBitArrayToAmino({ extra_bits_stored: 5, elems: Uint8Array([0xC0]) }) // \"xx___\"\n * compactBitArrayToAmino({ extra_bits_stored: 0, elems: Uint8Array([]) }) // null\n */\nexport function compactBitArrayToAmino(\n cba: CompactBitArray,\n): string | null {\n if (cba.elems.length === 0) {\n return null;\n }\n\n const fullBytes = cba.extra_bits_stored === 0\n ? cba.elems.length\n : cba.elems.length - 1;\n const totalBits = fullBytes * 8 + cba.extra_bits_stored;\n\n let result = \"\";\n for (let i = 0; i < totalBits; i++) {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n const isSet = (cba.elems[byteIndex] & (1 << bitIndex)) !== 0;\n result += isSet ? \"x\" : \"_\";\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,yBACd,OACiB;AACjB,KAAI,UAAU,KACZ,QAAO;EACL,mBAAmB;EACnB,OAAO,IAAI,WAAW,EAAE;EACzB;CAGH,MAAM,QAAQ,MAAM;CACpB,MAAM,YAAY,QAAQ;CAC1B,MAAM,WAAW,KAAK,KAAK,QAAQ,EAAE;CACrC,MAAM,QAAQ,IAAI,WAAW,SAAS;AAEtC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,IACzB,KAAI,MAAM,OAAO,KAAK;EACpB,MAAM,YAAY,KAAK,MAAM,IAAI,EAAE;EACnC,MAAM,WAAW,IAAK,IAAI;AAC1B,QAAM,cAAc,KAAK;;AAI7B,QAAO;EACL,mBAAmB;EACnB;EACD;;;;;;;;;;;AAYH,SAAgB,uBACd,KACe;AACf,KAAI,IAAI,MAAM,WAAW,EACvB,QAAO;CAMT,MAAM,aAHY,IAAI,sBAAsB,IACxC,IAAI,MAAM,SACV,IAAI,MAAM,SAAS,KACO,IAAI,IAAI;CAEtC,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,KAAK;EAClC,MAAM,YAAY,KAAK,MAAM,IAAI,EAAE;EACnC,MAAM,WAAW,IAAK,IAAI;EAC1B,MAAM,SAAS,IAAI,MAAM,aAAc,KAAK,cAAe;AAC3D,YAAU,QAAQ,MAAM;;AAG1B,QAAO"}
1
+ {"version":3,"file":"compact-bit-array.mjs","names":[],"sources":["../../src/utility/compact-bit-array.ts"],"sourcesContent":["import type {\n CompactBitArray,\n} from \"../proto/tm2/multisig.js\";\n\n/**\n * Converts an amino-encoded compact bit array string to a CompactBitArray.\n * In the amino format, 'x' represents a set bit (1) and '_' represents\n * an unset bit (0). A null input produces an empty CompactBitArray.\n *\n * @example\n * compactBitArrayFromAmino(\"xx___\") // { extra_bits_stored: 5, elems: Uint8Array([0xC0]) }\n * compactBitArrayFromAmino(null) // { extra_bits_stored: 0, elems: Uint8Array([]) }\n */\nexport function compactBitArrayFromAmino(\n amino: string | null,\n): CompactBitArray {\n if (amino === null) {\n return {\n extra_bits_stored: 0,\n elems: new Uint8Array(0),\n };\n }\n\n const count = amino.length;\n const extraBits = count % 8;\n const numBytes = Math.ceil(count / 8);\n const elems = new Uint8Array(numBytes);\n\n for (let i = 0; i < count; i++) {\n if (amino[i] === \"x\") {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n elems[byteIndex] |= 1 << bitIndex;\n }\n }\n\n return {\n extra_bits_stored: extraBits,\n elems,\n };\n}\n\n/**\n * Converts a CompactBitArray to its amino string representation.\n * Set bits (1) become 'x' and unset bits (0) become '_'.\n * Returns null for empty bit arrays (zero length).\n *\n * @example\n * compactBitArrayToAmino({ extra_bits_stored: 5, elems: Uint8Array([0xC0]) }) // \"xx___\"\n * compactBitArrayToAmino({ extra_bits_stored: 0, elems: Uint8Array([]) }) // null\n */\nexport function compactBitArrayToAmino(\n cba: CompactBitArray,\n): string | null {\n if (cba.elems.length === 0) {\n return null;\n }\n\n const fullBytes = cba.extra_bits_stored === 0\n ? cba.elems.length\n : cba.elems.length - 1;\n const totalBits = fullBytes * 8 + cba.extra_bits_stored;\n\n let result = \"\";\n for (let i = 0; i < totalBits; i++) {\n const byteIndex = Math.floor(i / 8);\n const bitIndex = 7 - (i % 8);\n const isSet = (cba.elems[byteIndex] & (1 << bitIndex)) !== 0;\n result += isSet ? \"x\" : \"_\";\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;AAaA,SAAgB,yBACd,OACiB;CACjB,IAAI,UAAU,MACZ,OAAO;EACL,mBAAmB;EACnB,uBAAO,IAAI,WAAW,CAAC;CACzB;CAGF,MAAM,QAAQ,MAAM;CACpB,MAAM,YAAY,QAAQ;CAC1B,MAAM,WAAW,KAAK,KAAK,QAAQ,CAAC;CACpC,MAAM,QAAQ,IAAI,WAAW,QAAQ;CAErC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KACzB,IAAI,MAAM,OAAO,KAAK;EACpB,MAAM,YAAY,KAAK,MAAM,IAAI,CAAC;EAClC,MAAM,WAAW,IAAK,IAAI;EAC1B,MAAM,cAAc,KAAK;CAC3B;CAGF,OAAO;EACL,mBAAmB;EACnB;CACF;AACF;;;;;;;;;;AAWA,SAAgB,uBACd,KACe;CACf,IAAI,IAAI,MAAM,WAAW,GACvB,OAAO;CAMT,MAAM,aAHY,IAAI,sBAAsB,IACxC,IAAI,MAAM,SACV,IAAI,MAAM,SAAS,KACO,IAAI,IAAI;CAEtC,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,KAAK;EAClC,MAAM,YAAY,KAAK,MAAM,IAAI,CAAC;EAClC,MAAM,WAAW,IAAK,IAAI;EAC1B,MAAM,SAAS,IAAI,MAAM,aAAc,KAAK,cAAe;EAC3D,UAAU,QAAQ,MAAM;CAC1B;CAEA,OAAO;AACT"}
@@ -1 +1,3 @@
1
- require("./compact-bit-array.cjs");
1
+ const require_compact_bit_array = require("./compact-bit-array.cjs");
2
+ exports.compactBitArrayFromAmino = require_compact_bit_array.compactBitArrayFromAmino;
3
+ exports.compactBitArrayToAmino = require_compact_bit_array.compactBitArrayToAmino;
@@ -1 +1,2 @@
1
- import { compactBitArrayFromAmino, compactBitArrayToAmino } from "./compact-bit-array.cjs";
1
+ import { compactBitArrayFromAmino, compactBitArrayToAmino } from "./compact-bit-array.cjs";
2
+ export { compactBitArrayFromAmino, compactBitArrayToAmino };
@@ -1 +1,2 @@
1
- import { compactBitArrayFromAmino, compactBitArrayToAmino } from "./compact-bit-array.mjs";
1
+ import { compactBitArrayFromAmino, compactBitArrayToAmino } from "./compact-bit-array.mjs";
2
+ export { compactBitArrayFromAmino, compactBitArrayToAmino };
@@ -1,2 +1,2 @@
1
- import "./compact-bit-array.mjs";
2
- export {};
1
+ import { compactBitArrayFromAmino, compactBitArrayToAmino } from "./compact-bit-array.mjs";
2
+ export { compactBitArrayFromAmino, compactBitArrayToAmino };