@aeternity/aepp-sdk 14.0.0 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +11 -19
  3. package/dist/aepp-sdk.browser-script.cjs +1 -1
  4. package/dist/aepp-sdk.browser-script.cjs.LICENSE.txt +2 -0
  5. package/dist/aepp-sdk.browser-script.cjs.map +1 -1
  6. package/dist/aepp-sdk.browser.cjs +1 -1
  7. package/dist/aepp-sdk.browser.cjs.map +1 -1
  8. package/dist/aepp-sdk.cjs +11678 -6969
  9. package/dist/aepp-sdk.cjs.map +1 -1
  10. package/es/AeSdkBase.d.ts +10 -1
  11. package/es/AeSdkBase.js +12 -2
  12. package/es/AeSdkBase.js.map +1 -1
  13. package/es/AeSdkMethods.d.ts +1 -1
  14. package/es/AeSdkMethods.js.map +1 -1
  15. package/es/AeSdkWallet.js +1 -1
  16. package/es/AeSdkWallet.js.map +1 -1
  17. package/es/Middleware.d.ts +5 -1
  18. package/es/Middleware.js +7 -2
  19. package/es/Middleware.js.map +1 -1
  20. package/es/MiddlewareSubscriber.d.ts +3 -0
  21. package/es/MiddlewareSubscriber.js +4 -0
  22. package/es/MiddlewareSubscriber.js.map +1 -1
  23. package/es/Node.d.ts +6 -1
  24. package/es/Node.js +28 -4
  25. package/es/Node.js.map +1 -1
  26. package/es/account/Base.d.ts +12 -0
  27. package/es/account/Base.js +1 -0
  28. package/es/account/Base.js.map +1 -1
  29. package/es/account/BaseFactory.d.ts +1 -0
  30. package/es/account/BaseFactory.js +1 -0
  31. package/es/account/BaseFactory.js.map +1 -1
  32. package/es/account/Generalized.d.ts +5 -0
  33. package/es/account/Generalized.js +9 -0
  34. package/es/account/Generalized.js.map +1 -1
  35. package/es/account/Ledger.d.ts +5 -0
  36. package/es/account/Ledger.js +9 -0
  37. package/es/account/Ledger.js.map +1 -1
  38. package/es/account/LedgerFactory.d.ts +2 -0
  39. package/es/account/LedgerFactory.js +10 -4
  40. package/es/account/LedgerFactory.js.map +1 -1
  41. package/es/account/Memory.d.ts +5 -0
  42. package/es/account/Memory.js +14 -5
  43. package/es/account/Memory.js.map +1 -1
  44. package/es/account/Metamask.d.ts +8 -0
  45. package/es/account/Metamask.js +13 -0
  46. package/es/account/Metamask.js.map +1 -1
  47. package/es/account/MetamaskFactory.d.ts +20 -2
  48. package/es/account/MetamaskFactory.js +93 -39
  49. package/es/account/MetamaskFactory.js.map +1 -1
  50. package/es/account/MnemonicFactory.d.ts +12 -2
  51. package/es/account/MnemonicFactory.js +48 -24
  52. package/es/account/MnemonicFactory.js.map +1 -1
  53. package/es/account/Rpc.d.ts +5 -0
  54. package/es/account/Rpc.js +8 -0
  55. package/es/account/Rpc.js.map +1 -1
  56. package/es/aens.d.ts +25 -5
  57. package/es/aens.js +52 -18
  58. package/es/aens.js.map +1 -1
  59. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -1
  60. package/es/aepp-wallet-communication/connection/BrowserRuntime.js.map +1 -1
  61. package/es/apis/middleware/middleware.d.ts +99 -9
  62. package/es/apis/middleware/middleware.js +560 -91
  63. package/es/apis/middleware/middleware.js.map +1 -1
  64. package/es/apis/middleware/models/index.d.ts +1267 -1582
  65. package/es/apis/middleware/models/index.js +1 -1363
  66. package/es/apis/middleware/models/index.js.map +1 -1
  67. package/es/apis/middleware/models/mappers.d.ts +126 -56
  68. package/es/apis/middleware/models/mappers.js +6250 -2989
  69. package/es/apis/middleware/models/mappers.js.map +1 -1
  70. package/es/apis/middleware/models/parameters.d.ts +54 -33
  71. package/es/apis/middleware/models/parameters.js +389 -134
  72. package/es/apis/middleware/models/parameters.js.map +1 -1
  73. package/es/apis/node/models/index.d.ts +60 -15
  74. package/es/apis/node/models/index.js.map +1 -1
  75. package/es/apis/node/models/mappers.d.ts +3 -0
  76. package/es/apis/node/models/mappers.js +130 -2
  77. package/es/apis/node/models/mappers.js.map +1 -1
  78. package/es/apis/node/node.d.ts +13 -1
  79. package/es/apis/node/node.js +54 -0
  80. package/es/apis/node/node.js.map +1 -1
  81. package/es/chain.d.ts +19 -6
  82. package/es/chain.js +30 -24
  83. package/es/chain.js.map +1 -1
  84. package/es/channel/Contract.d.ts +6 -3
  85. package/es/channel/Contract.js +5 -2
  86. package/es/channel/Contract.js.map +1 -1
  87. package/es/channel/Spend.d.ts +1 -1
  88. package/es/channel/Spend.js.map +1 -1
  89. package/es/channel/handlers.js +1 -2
  90. package/es/channel/handlers.js.map +1 -1
  91. package/es/channel/internal.d.ts +1 -1
  92. package/es/channel/internal.js +2 -2
  93. package/es/channel/internal.js.map +1 -1
  94. package/es/contract/Contract.d.ts +13 -2
  95. package/es/contract/Contract.js +22 -12
  96. package/es/contract/Contract.js.map +1 -1
  97. package/es/contract/compiler/Base.d.ts +1 -0
  98. package/es/contract/compiler/Base.js +1 -0
  99. package/es/contract/compiler/Base.js.map +1 -1
  100. package/es/contract/compiler/Cli.d.ts +2 -1
  101. package/es/contract/compiler/Cli.js +11 -9
  102. package/es/contract/compiler/Cli.js.map +1 -1
  103. package/es/contract/compiler/Http.d.ts +2 -1
  104. package/es/contract/compiler/Http.js +3 -2
  105. package/es/contract/compiler/Http.js.map +1 -1
  106. package/es/contract/compiler/getFileSystem.d.ts +1 -0
  107. package/es/contract/compiler/getFileSystem.js +1 -0
  108. package/es/contract/compiler/getFileSystem.js.map +1 -1
  109. package/es/contract/ga.d.ts +3 -3
  110. package/es/contract/ga.js +3 -3
  111. package/es/contract/ga.js.map +1 -1
  112. package/es/index-browser.d.ts +32 -2
  113. package/es/index-browser.js +32 -2
  114. package/es/index-browser.js.map +1 -1
  115. package/es/oracle/Oracle.d.ts +10 -1
  116. package/es/oracle/Oracle.js +16 -6
  117. package/es/oracle/Oracle.js.map +1 -1
  118. package/es/oracle/OracleBase.d.ts +15 -2
  119. package/es/oracle/OracleBase.js +23 -1
  120. package/es/oracle/OracleBase.js.map +1 -1
  121. package/es/oracle/OracleClient.d.ts +3 -0
  122. package/es/oracle/OracleClient.js +6 -1
  123. package/es/oracle/OracleClient.js.map +1 -1
  124. package/es/spend.js +1 -1
  125. package/es/spend.js.map +1 -1
  126. package/es/tx/builder/common.js +6 -3
  127. package/es/tx/builder/common.js.map +1 -1
  128. package/es/tx/builder/constants.d.ts +53 -3
  129. package/es/tx/builder/constants.js +62 -12
  130. package/es/tx/builder/constants.js.map +1 -1
  131. package/es/tx/builder/delegation/schema.js +15 -0
  132. package/es/tx/builder/delegation/schema.js.map +1 -1
  133. package/es/tx/builder/entry/constants.d.ts +4 -1
  134. package/es/tx/builder/entry/constants.js +10 -1
  135. package/es/tx/builder/entry/constants.js.map +1 -1
  136. package/es/tx/builder/entry/index.js +1 -2
  137. package/es/tx/builder/entry/index.js.map +1 -1
  138. package/es/tx/builder/field-types/ct-version.js +1 -2
  139. package/es/tx/builder/field-types/ct-version.js.map +1 -1
  140. package/es/tx/builder/field-types/fee.d.ts +1 -1
  141. package/es/tx/builder/field-types/fee.js +4 -4
  142. package/es/tx/builder/field-types/fee.js.map +1 -1
  143. package/es/tx/builder/field-types/gas-price.d.ts +3 -0
  144. package/es/tx/builder/field-types/gas-price.js +1 -1
  145. package/es/tx/builder/field-types/gas-price.js.map +1 -1
  146. package/es/tx/builder/field-types/name-fee.js +1 -1
  147. package/es/tx/builder/field-types/name-fee.js.map +1 -1
  148. package/es/tx/builder/field-types/name-id.js +2 -2
  149. package/es/tx/builder/field-types/name-id.js.map +1 -1
  150. package/es/tx/builder/field-types/nonce.d.ts +1 -1
  151. package/es/tx/builder/field-types/nonce.js.map +1 -1
  152. package/es/tx/builder/field-types/pointers.js +3 -3
  153. package/es/tx/builder/field-types/pointers.js.map +1 -1
  154. package/es/tx/builder/field-types/ttl.js +1 -2
  155. package/es/tx/builder/field-types/ttl.js.map +1 -1
  156. package/es/tx/builder/helpers.d.ts +18 -12
  157. package/es/tx/builder/helpers.js +25 -17
  158. package/es/tx/builder/helpers.js.map +1 -1
  159. package/es/tx/builder/schema.d.ts +27 -24
  160. package/es/tx/builder/schema.generated.d.ts +12 -12
  161. package/es/tx/builder/schema.generated.js.map +1 -1
  162. package/es/tx/builder/schema.js +5 -3
  163. package/es/tx/builder/schema.js.map +1 -1
  164. package/es/tx/execution-cost.d.ts +3 -0
  165. package/es/tx/execution-cost.js +7 -4
  166. package/es/tx/execution-cost.js.map +1 -1
  167. package/es/tx/transaction-signer.d.ts +1 -0
  168. package/es/tx/transaction-signer.js +1 -0
  169. package/es/tx/transaction-signer.js.map +1 -1
  170. package/es/tx/validator.js +4 -3
  171. package/es/tx/validator.js.map +1 -1
  172. package/es/utils/MiddlewarePage.d.ts +4 -3
  173. package/es/utils/MiddlewarePage.js.map +1 -1
  174. package/es/utils/amount-formatter.d.ts +15 -1
  175. package/es/utils/amount-formatter.js +17 -1
  176. package/es/utils/amount-formatter.js.map +1 -1
  177. package/es/utils/autorest.d.ts +1 -1
  178. package/es/utils/autorest.js +10 -4
  179. package/es/utils/autorest.js.map +1 -1
  180. package/es/utils/bignumber.d.ts +1 -1
  181. package/es/utils/bignumber.js +1 -1
  182. package/es/utils/bignumber.js.map +1 -1
  183. package/es/utils/bytes.d.ts +3 -1
  184. package/es/utils/bytes.js +3 -1
  185. package/es/utils/bytes.js.map +1 -1
  186. package/es/utils/crypto.d.ts +48 -15
  187. package/es/utils/crypto.js +80 -29
  188. package/es/utils/crypto.js.map +1 -1
  189. package/es/utils/encoder-types.d.ts +1 -1
  190. package/es/utils/encoder-types.js +1 -1
  191. package/es/utils/encoder-types.js.map +1 -1
  192. package/es/utils/encoder.d.ts +2 -0
  193. package/es/utils/encoder.js +2 -0
  194. package/es/utils/encoder.js.map +1 -1
  195. package/es/utils/errors.d.ts +2 -2
  196. package/es/utils/errors.js +2 -2
  197. package/es/utils/errors.js.map +1 -1
  198. package/es/utils/json-big.js +1 -1
  199. package/es/utils/json-big.js.map +1 -1
  200. package/es/utils/jwt.js +3 -3
  201. package/es/utils/jwt.js.map +1 -1
  202. package/es/utils/typed-data.d.ts +5 -0
  203. package/es/utils/typed-data.js +6 -0
  204. package/es/utils/typed-data.js.map +1 -1
  205. package/package.json +50 -51
@@ -1,4 +1,4 @@
1
- import { BigNumber } from 'bignumber.js';
1
+ import BigNumber from 'bignumber.js';
2
2
  import coinAmount from './coin-amount.js';
3
3
  import { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js';
4
4
  import { MIN_GAS_PRICE } from '../constants.js';
@@ -1 +1 @@
1
- {"version":3,"file":"gas-price.js","names":["BigNumber","coinAmount","ArgumentError","IllegalArgumentError","MIN_GAS_PRICE","formatAmount","gasPriceCache","WeakMap","getCachedIncreasedGasPrice","node","cache","get","time","Date","now","gasPrice","minGasPrice","utilization","getRecentGasPrices","BigInt","toString","times","integerValue","toFixed","maxSafeGasPrice","console","warn","set","prepare","value","params","onNode","denomination","undefined","targetDenomination","serializeAettos"],"sources":["../../../../src/tx/builder/field-types/gas-price.ts"],"sourcesContent":["import { BigNumber } from 'bignumber.js';\nimport coinAmount from './coin-amount.js';\nimport { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js';\nimport { Int, MIN_GAS_PRICE } from '../constants.js';\nimport Node from '../../../Node.js';\nimport { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter.js';\n\nconst gasPriceCache: WeakMap<Node, { time: number; gasPrice: bigint }> = new WeakMap();\n\nexport async function getCachedIncreasedGasPrice(node: Node): Promise<bigint> {\n const cache = gasPriceCache.get(node);\n if (cache != null && cache.time > Date.now() - 20 * 1000) {\n return cache.gasPrice;\n }\n\n const { minGasPrice, utilization } = (await node.getRecentGasPrices())[0];\n let gasPrice =\n utilization < 70\n ? 0n\n : BigInt(new BigNumber(minGasPrice.toString()).times(1.01).integerValue().toFixed());\n\n const maxSafeGasPrice = BigInt(MIN_GAS_PRICE) * 100000n; // max microblock fee is 600ae or 35usd\n if (gasPrice > maxSafeGasPrice) {\n console.warn(\n `Estimated gas price ${gasPrice} exceeds the maximum safe value for unknown reason.` +\n ` It will be limited to ${maxSafeGasPrice}.` +\n ' To overcome this restriction provide `gasPrice`/`fee` in options.',\n );\n gasPrice = maxSafeGasPrice;\n }\n\n gasPriceCache.set(node, { gasPrice, time: Date.now() });\n return gasPrice;\n}\n\n// TODO: use withFormatting after using a single type for coins representation\nexport default {\n ...coinAmount,\n\n async prepare(\n value: Int | undefined,\n params: {},\n {\n onNode,\n denomination,\n }: {\n onNode?: Node;\n denomination?: AE_AMOUNT_FORMATS;\n },\n ): Promise<Int | undefined> {\n if (value != null) return value;\n if (onNode == null) {\n throw new ArgumentError('onNode', 'provided (or provide `gasPrice` instead)', onNode);\n }\n const gasPrice = await getCachedIncreasedGasPrice(onNode);\n if (gasPrice === 0n) return undefined;\n return formatAmount(gasPrice, { targetDenomination: denomination });\n },\n\n serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {\n if (+value < MIN_GAS_PRICE) {\n throw new IllegalArgumentError(\n `Gas price ${value.toString()} must be bigger than ${MIN_GAS_PRICE}`,\n );\n }\n return value;\n },\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,SAASC,aAAa,EAAEC,oBAAoB,QAAQ,0BAA0B;AAC9E,SAAcC,aAAa,QAAQ,iBAAiB;AAEpD,SAA4BC,YAAY,QAAQ,oCAAoC;AAEpF,MAAMC,aAAgE,GAAG,IAAIC,OAAO,CAAC,CAAC;AAEtF,OAAO,eAAeC,0BAA0BA,CAACC,IAAU,EAAmB;EAC5E,MAAMC,KAAK,GAAGJ,aAAa,CAACK,GAAG,CAACF,IAAI,CAAC;EACrC,IAAIC,KAAK,IAAI,IAAI,IAAIA,KAAK,CAACE,IAAI,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE;IACxD,OAAOJ,KAAK,CAACK,QAAQ;EACvB;EAEA,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAG,CAAC,MA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AQ,CAAC,CAAC,EAAU;IAC5E,IAAI,CAACS,KAAK,GAAGzB,aAAa,EAAE;MAC1B,MAAM,IAAID,oBAAoB,CAC5B,aAAa0B,KAAK,CAACT,QAAQ,CAAC,CAAC,wBAAwBhB,aAAa,EACpE,CAAC;IACH;IACA,OAAOyB,KAAK;EACd;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"gas-price.js","names":["BigNumber","coinAmount","ArgumentError","IllegalArgumentError","MIN_GAS_PRICE","formatAmount","gasPriceCache","WeakMap","getCachedIncreasedGasPrice","node","cache","get","time","Date","now","gasPrice","minGasPrice","utilization","getRecentGasPrices","BigInt","toString","times","integerValue","toFixed","maxSafeGasPrice","console","warn","set","prepare","value","params","onNode","denomination","undefined","targetDenomination","serializeAettos"],"sources":["../../../../src/tx/builder/field-types/gas-price.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport coinAmount from './coin-amount.js';\nimport { ArgumentError, IllegalArgumentError } from '../../../utils/errors.js';\nimport { Int, MIN_GAS_PRICE } from '../constants.js';\nimport Node from '../../../Node.js';\nimport { AE_AMOUNT_FORMATS, formatAmount } from '../../../utils/amount-formatter.js';\n\nconst gasPriceCache: WeakMap<Node, { time: number; gasPrice: bigint }> = new WeakMap();\n\nexport async function getCachedIncreasedGasPrice(node: Node): Promise<bigint> {\n const cache = gasPriceCache.get(node);\n if (cache != null && cache.time > Date.now() - 20 * 1000) {\n return cache.gasPrice;\n }\n\n const { minGasPrice, utilization } = (await node.getRecentGasPrices())[0];\n let gasPrice =\n utilization < 70\n ? 0n\n : BigInt(new BigNumber(minGasPrice.toString()).times(1.01).integerValue().toFixed());\n\n const maxSafeGasPrice = BigInt(MIN_GAS_PRICE) * 100000n; // max microblock fee is 600ae or 35usd\n if (gasPrice > maxSafeGasPrice) {\n console.warn(\n `Estimated gas price ${gasPrice} exceeds the maximum safe value for unknown reason.` +\n ` It will be limited to ${maxSafeGasPrice}.` +\n ' To overcome this restriction provide `gasPrice`/`fee` in options.',\n );\n gasPrice = maxSafeGasPrice;\n }\n\n gasPriceCache.set(node, { gasPrice, time: Date.now() });\n return gasPrice;\n}\n\n// TODO: use withFormatting after using a single type for coins representation\nexport default {\n ...coinAmount,\n\n async prepare(\n value: Int | undefined,\n params: {},\n {\n onNode,\n denomination,\n }: {\n onNode?: Node;\n /**\n * @deprecated no replacement implemented yet\n */\n denomination?: AE_AMOUNT_FORMATS;\n },\n ): Promise<Int | undefined> {\n if (value != null) return value;\n if (onNode == null) {\n throw new ArgumentError('onNode', 'provided (or provide `gasPrice` instead)', onNode);\n }\n const gasPrice = await getCachedIncreasedGasPrice(onNode);\n if (gasPrice === 0n) return undefined;\n return formatAmount(gasPrice, { targetDenomination: denomination });\n },\n\n serializeAettos(value: string | undefined = MIN_GAS_PRICE.toString()): string {\n if (+value < MIN_GAS_PRICE) {\n throw new IllegalArgumentError(\n `Gas price ${value.toString()} must be bigger than ${MIN_GAS_PRICE}`,\n );\n }\n return value;\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,OAAOC,UAAU,MAAM,kBAAkB;AACzC,SAASC,aAAa,EAAEC,oBAAoB,QAAQ,0BAA0B;AAC9E,SAAcC,aAAa,QAAQ,iBAAiB;AAEpD,SAA4BC,YAAY,QAAQ,oCAAoC;AAEpF,MAAMC,aAAgE,GAAG,IAAIC,OAAO,CAAC,CAAC;AAEtF,OAAO,eAAeC,0BAA0BA,CAACC,IAAU,EAAmB;EAC5E,MAAMC,KAAK,GAAGJ,aAAa,CAACK,GAAG,CAACF,IAAI,CAAC;EACrC,IAAIC,KAAK,IAAI,IAAI,IAAIA,KAAK,CAACE,IAAI,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE;IACxD,OAAOJ,KAAK,CAACK,QAAQ;EACvB;EAEA,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAG,CAAC,MAAMR,IAAI,CAACS,kBAAkB,CAAC,CAAC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CAACS,KAAK,GAAGzB,aAAa,EAAE;MAC1B,MAAM,IAAID,oBAAoB,CAC5B,aAAa0B,KAAK,CAACT,QAAQ,CAAC,CAAC,wBAAwBhB,aAAa,EACpE,CAAC;IACH;IACA,OAAOyB,KAAK;EACd;AACF,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { BigNumber } from 'bignumber.js';
1
+ import BigNumber from 'bignumber.js';
2
2
  import { getMinimumNameFee } from '../helpers.js';
3
3
  import { InsufficientNameFeeError } from '../../../utils/errors.js';
4
4
  import coinAmount from './coin-amount.js';
@@ -1 +1 @@
1
- {"version":3,"file":"name-fee.js","names":["BigNumber","getMinimumNameFee","InsufficientNameFeeError","coinAmount","serializeAettos","_value","txFields","minNameFee","name","value","gt","toFixed","serialize","parameters","call"],"sources":["../../../../src/tx/builder/field-types/name-fee.ts"],"sourcesContent":["import { BigNumber } from 'bignumber.js';\nimport { getMinimumNameFee } from '../helpers.js';\nimport { InsufficientNameFeeError } from '../../../utils/errors.js';\nimport coinAmount from './coin-amount.js';\nimport { AensName, Int } from '../constants.js';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(_value: string | undefined, txFields: { name: AensName }): string {\n const minNameFee = getMinimumNameFee(txFields.name);\n const value = new BigNumber(_value ?? minNameFee);\n if (minNameFee.gt(value)) throw new InsufficientNameFeeError(value, minNameFee);\n return value.toFixed();\n },\n\n /**\n * @param value - AENS name fee\n * @param txFields - Transaction fields\n * @param txFields.name - AENS Name in transaction\n */\n serialize(\n value: Int | undefined,\n txFields: { name: AensName } & Parameters<(typeof coinAmount)['serialize']>[1],\n parameters: Parameters<(typeof coinAmount)['serialize']>[2],\n ): Buffer {\n return coinAmount.serialize.call(this, value, txFields, parameters);\n },\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,wBAAwB,QAAQ,0BAA0B;AACnE,OAAOC,UAAU,MAAM,kBAAkB;AAGzC,eAAe;EACb,GAAGA,UAAU;EAEbC,eAAeA,CAACC,MAA0B,EAAEC,QAA4B,EAAU;IAChF,MAAMC,UAAU,GAAGN,iBAAiB,CAACK,QAAQ,CAACE,IAAI,CAAC;IACnD,MAAMC,KAAK,GAAG,IAAIT,SAAS,CAACK,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIE,UAAU,CAAC;IACjD,IAAIA,UAAU,CAACG,EAAE,CAACD,KAAK,CAAC,EAAE,MAAM,IAAIP,wBAAwB,CAACO,KAAK,EAAEF,UAAU,CAAC;IAC/E,OAAOE,KAAK,CAACE,OAAO,CAAC,CAAC;EACxB,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,SAASA,CACPH,KAAsB,EACtBH,QAA8E,EAC9EO,UAA2D,EACnD;IACR,OAAOV,UAAU,CAACS,SAAS,CAACE,IAAI,CAAC,IAAI,EAAEL,KAAK,EAAEH,QAAQ,EAAEO,UAAU,CAAC;EACrE;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"name-fee.js","names":["BigNumber","getMinimumNameFee","InsufficientNameFeeError","coinAmount","serializeAettos","_value","txFields","minNameFee","name","value","gt","toFixed","serialize","parameters","call"],"sources":["../../../../src/tx/builder/field-types/name-fee.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { getMinimumNameFee } from '../helpers.js';\nimport { InsufficientNameFeeError } from '../../../utils/errors.js';\nimport coinAmount from './coin-amount.js';\nimport { AensName, Int } from '../constants.js';\n\nexport default {\n ...coinAmount,\n\n serializeAettos(_value: string | undefined, txFields: { name: AensName }): string {\n const minNameFee = getMinimumNameFee(txFields.name);\n const value = new BigNumber(_value ?? minNameFee);\n if (minNameFee.gt(value)) throw new InsufficientNameFeeError(value, minNameFee);\n return value.toFixed();\n },\n\n /**\n * @param value - AENS name fee\n * @param txFields - Transaction fields\n * @param txFields.name - AENS Name in transaction\n */\n serialize(\n value: Int | undefined,\n txFields: { name: AensName } & Parameters<(typeof coinAmount)['serialize']>[1],\n parameters: Parameters<(typeof coinAmount)['serialize']>[2],\n ): Buffer {\n return coinAmount.serialize.call(this, value, txFields, parameters);\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,wBAAwB,QAAQ,0BAA0B;AACnE,OAAOC,UAAU,MAAM,kBAAkB;AAGzC,eAAe;EACb,GAAGA,UAAU;EAEbC,eAAeA,CAACC,MAA0B,EAAEC,QAA4B,EAAU;IAChF,MAAMC,UAAU,GAAGN,iBAAiB,CAACK,QAAQ,CAACE,IAAI,CAAC;IACnD,MAAMC,KAAK,GAAG,IAAIT,SAAS,CAACK,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIE,UAAU,CAAC;IACjD,IAAIA,UAAU,CAACG,EAAE,CAACD,KAAK,CAAC,EAAE,MAAM,IAAIP,wBAAwB,CAACO,KAAK,EAAEF,UAAU,CAAC;IAC/E,OAAOE,KAAK,CAACE,OAAO,CAAC,CAAC;EACxB,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,SAASA,CACPH,KAAsB,EACtBH,QAA8E,EAC9EO,UAA2D,EACnD;IACR,OAAOV,UAAU,CAACS,SAAS,CAACE,IAAI,CAAC,IAAI,EAAEL,KAAK,EAAEH,QAAQ,EAAEO,UAAU,CAAC;EACrE;AACF,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { produceNameId, isNameValid } from '../helpers.js';
1
+ import { produceNameId, isName } from '../helpers.js';
2
2
  import address from './address.js';
3
3
  import { Encoding } from '../../../utils/encoder.js';
4
4
  const addressName = address(Encoding.Name);
@@ -8,7 +8,7 @@ export default {
8
8
  * @param value - AENS name ID
9
9
  */
10
10
  serialize(value) {
11
- return addressName.serialize(isNameValid(value) ? produceNameId(value) : value);
11
+ return addressName.serialize(isName(value) ? produceNameId(value) : value);
12
12
  }
13
13
  };
14
14
  //# sourceMappingURL=name-id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"name-id.js","names":["produceNameId","isNameValid","address","Encoding","addressName","Name","serialize","value"],"sources":["../../../../src/tx/builder/field-types/name-id.ts"],"sourcesContent":["import { AensName } from '../constants.js';\nimport { produceNameId, isNameValid } from '../helpers.js';\nimport address from './address.js';\nimport { Encoded, Encoding } from '../../../utils/encoder.js';\n\nconst addressName = address(Encoding.Name);\n\nexport default {\n ...addressName,\n\n /**\n * @param value - AENS name ID\n */\n serialize(value: AensName | Encoded.Name): Buffer {\n return addressName.serialize(isNameValid(value) ? produceNameId(value) : value);\n },\n};\n"],"mappings":"AACA,SAASA,aAAa,EAAEC,WAAW,QAAQ,eAAe;AAC1D,OAAOC,OAAO,MAAM,cAAc;AAClC,SAAkBC,QAAQ,QAAQ,2BAA2B;AAE7D,MAAMC,WAAW,GAAGF,OAAO,CAACC,QAAQ,CAACE,IAAI,CAAC;AAE1C,eAAe;EACb,GAAGD,WAAW;EAEd;AACF;AACA;EACEE,SAASA,CAACC,KAA8B,EAAU;IAChD,OAAOH,WAAW,CAACE,SAAS,CAACL,WAAW,CAACM,KAAK,CAAC,GAAGP,aAAa,CAACO,KAAK,CAAC,GAAGA,KAAK,CAAC;EACjF;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"name-id.js","names":["produceNameId","isName","address","Encoding","addressName","Name","serialize","value"],"sources":["../../../../src/tx/builder/field-types/name-id.ts"],"sourcesContent":["import { AensName } from '../constants.js';\nimport { produceNameId, isName } from '../helpers.js';\nimport address from './address.js';\nimport { Encoded, Encoding } from '../../../utils/encoder.js';\n\nconst addressName = address(Encoding.Name);\n\nexport default {\n ...addressName,\n\n /**\n * @param value - AENS name ID\n */\n serialize(value: AensName | Encoded.Name): Buffer {\n return addressName.serialize(isName(value) ? produceNameId(value) : value);\n },\n};\n"],"mappings":"AACA,SAASA,aAAa,EAAEC,MAAM,QAAQ,eAAe;AACrD,OAAOC,OAAO,MAAM,cAAc;AAClC,SAAkBC,QAAQ,QAAQ,2BAA2B;AAE7D,MAAMC,WAAW,GAAGF,OAAO,CAACC,QAAQ,CAACE,IAAI,CAAC;AAE1C,eAAe;EACb,GAAGD,WAAW;EAEd;AACF;AACA;EACEE,SAASA,CAACC,KAA8B,EAAU;IAChD,OAAOH,WAAW,CAACE,SAAS,CAACL,MAAM,CAACM,KAAK,CAAC,GAAGP,aAAa,CAACO,KAAK,CAAC,GAAGA,KAAK,CAAC;EAC5E;AACF,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import Node from '../../../Node.js';
2
- import { NextNonceStrategy } from '../../../apis/node/index.js';
2
+ import { Enum1 as NextNonceStrategy } from '../../../apis/node/index.js';
3
3
  import { Tag } from '../constants.js';
4
4
  export default function genNonceField<SenderKey extends string>(senderKey: SenderKey): {
5
5
  serialize: (value: number, params: {
@@ -1 +1 @@
1
- {"version":3,"file":"nonce.js","names":["isAccountNotFoundError","shortUInt","ArgumentError","Tag","genNonceField","senderKey","serialize","value","tag","GaAttachTx","prepare","params","options","onNode","strategy","senderId","requirement","getAccountNextNonce","replace","catch","error","nextNonce"],"sources":["../../../../src/tx/builder/field-types/nonce.ts"],"sourcesContent":["import { isAccountNotFoundError } from '../../../utils/other.js';\nimport shortUInt from './short-u-int.js';\nimport Node from '../../../Node.js';\nimport { ArgumentError } from '../../../utils/errors.js';\nimport { NextNonceStrategy } from '../../../apis/node/index.js';\nimport { Tag } from '../constants.js';\n\nexport default function genNonceField<SenderKey extends string>(\n senderKey: SenderKey,\n): {\n serialize: (value: number, params: { tag: Tag }) => Buffer;\n // TODO: (value: number) => Promise<number> | (value: undefined, ...) => Promise<number>\n prepare: (\n value: number | undefined,\n params: {},\n // TODO: replace `string` with AddressEncodings\n options: { [key in SenderKey]: string } & {\n strategy?: NextNonceStrategy;\n onNode?: Node;\n _isInternalBuild?: boolean;\n },\n ) => Promise<number>;\n deserialize: (value: Buffer) => number;\n senderKey: string;\n} {\n return {\n ...shortUInt,\n\n serialize(value: number, { tag }): Buffer {\n if (Tag.GaAttachTx === tag && value !== 1) {\n throw new ArgumentError('nonce', 'equal 1 if GaAttachTx', value);\n }\n return shortUInt.serialize(value);\n },\n\n async prepare(value, params, options) {\n if (value != null) return value;\n // TODO: uncomment the below line\n // if (options._isInternalBuild === true) return 0;\n const { onNode, strategy } = options;\n const senderId = options[senderKey];\n const requirement = 'provided (or provide `nonce` instead)';\n if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);\n if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);\n return (\n await onNode\n .getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), { strategy })\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { nextNonce: 1 };\n })\n ).nextNonce;\n },\n\n senderKey,\n };\n}\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,yBAAyB;AAChE,OAAOC,SAAS,MAAM,kBAAkB;AAExC,SAASC,aAAa,QAAQ,0BAA0B;AAExD,SAASC,GAAG,QAAQ,iBAAiB;AAErC,eAAe,SAASC,aAAaA,CACnCC,SAAoB,EAgBpB;EACA,OAAO;IACL,GAAGJ,SAAS;IAEZK,SAASA,CAACC,KAAa,EAAE;MAAEC;IAAI,CAAC,EAAU;MACxC,IAAIL,GAAG,CAACM,UAAU,KAAKD,GAAG,IAAID,KAAK,KAAK,CAAC,EAAE;QACzC,MAAM,IAAIL,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAEK,KAAK,CAAC;MAClE;MACA,OAAON,SAAS,CAACK,SAAS,CAACC,KAAK,CAAC;IACnC,CAAC;IAED,MAAMG,OAAOA,CAACH,KAAK,EAAEI,MAAM,EAAEC,OAAO,EAAE;MACpC,IAAIL,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;MAC/B;MACA;MACA,MAAM;QAAEM,MAAM;QAAEC;MAAS,CAAC,GAAGF,OAAO;MACpC,MAAMG,QAAQ,GAAGH,OAAO,CAACP,SAAS,CAAC;MACnC,MAAMW,WAAW,GAAG,uCAAuC;MAC3D,IAAIH,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIX,aAAa,CAAC,QAAQ,EAAEc,WAAW,EAAEH,MAAM,CAAC;MAC1E,IAAIE,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIb,aAAa,CAAC,UAAU,EAAEc,WAAW,EAAED,QAAQ,CAAC;MAChF,OAAO,CACL,MAAMF,MAAM,CACTI,mBAAmB,CAACF,QAAQ,CAACG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QAAEJ;MAAS,CAAC,CAAC,CAClEK,KAAK,CAAEC,KAAK,IAAK;QAChB,IAAI,CAACpB,sBAAsB,CAACoB,KAAK,CAAC,EAAE,MAAMA,KAAK;QAC/C,OAAO;UAAEC,SAAS,EAAE;QAAE,CAAC;MACzB,CAAC,CAAC,EACJA,SAAS;IACb,CAAC;IAEDhB;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"nonce.js","names":["isAccountNotFoundError","shortUInt","ArgumentError","Tag","genNonceField","senderKey","serialize","value","tag","GaAttachTx","prepare","params","options","onNode","strategy","senderId","requirement","getAccountNextNonce","replace","catch","error","nextNonce"],"sources":["../../../../src/tx/builder/field-types/nonce.ts"],"sourcesContent":["import { isAccountNotFoundError } from '../../../utils/other.js';\nimport shortUInt from './short-u-int.js';\nimport Node from '../../../Node.js';\nimport { ArgumentError } from '../../../utils/errors.js';\nimport { Enum1 as NextNonceStrategy } from '../../../apis/node/index.js';\nimport { Tag } from '../constants.js';\n\nexport default function genNonceField<SenderKey extends string>(\n senderKey: SenderKey,\n): {\n serialize: (value: number, params: { tag: Tag }) => Buffer;\n // TODO: (value: number) => Promise<number> | (value: undefined, ...) => Promise<number>\n prepare: (\n value: number | undefined,\n params: {},\n // TODO: replace `string` with AddressEncodings\n options: { [key in SenderKey]: string } & {\n strategy?: NextNonceStrategy;\n onNode?: Node;\n _isInternalBuild?: boolean;\n },\n ) => Promise<number>;\n deserialize: (value: Buffer) => number;\n senderKey: string;\n} {\n return {\n ...shortUInt,\n\n serialize(value: number, { tag }): Buffer {\n if (Tag.GaAttachTx === tag && value !== 1) {\n throw new ArgumentError('nonce', 'equal 1 if GaAttachTx', value);\n }\n return shortUInt.serialize(value);\n },\n\n async prepare(value, params, options) {\n if (value != null) return value;\n // TODO: uncomment the below line\n // if (options._isInternalBuild === true) return 0;\n const { onNode, strategy } = options;\n const senderId = options[senderKey];\n const requirement = 'provided (or provide `nonce` instead)';\n if (onNode == null) throw new ArgumentError('onNode', requirement, onNode);\n if (senderId == null) throw new ArgumentError('senderId', requirement, senderId);\n return (\n await onNode\n .getAccountNextNonce(senderId.replace(/^ok_/, 'ak_'), { strategy })\n .catch((error) => {\n if (!isAccountNotFoundError(error)) throw error;\n return { nextNonce: 1 };\n })\n ).nextNonce;\n },\n\n senderKey,\n };\n}\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAQ,yBAAyB;AAChE,OAAOC,SAAS,MAAM,kBAAkB;AAExC,SAASC,aAAa,QAAQ,0BAA0B;AAExD,SAASC,GAAG,QAAQ,iBAAiB;AAErC,eAAe,SAASC,aAAaA,CACnCC,SAAoB,EAgBpB;EACA,OAAO;IACL,GAAGJ,SAAS;IAEZK,SAASA,CAACC,KAAa,EAAE;MAAEC;IAAI,CAAC,EAAU;MACxC,IAAIL,GAAG,CAACM,UAAU,KAAKD,GAAG,IAAID,KAAK,KAAK,CAAC,EAAE;QACzC,MAAM,IAAIL,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAEK,KAAK,CAAC;MAClE;MACA,OAAON,SAAS,CAACK,SAAS,CAACC,KAAK,CAAC;IACnC,CAAC;IAED,MAAMG,OAAOA,CAACH,KAAK,EAAEI,MAAM,EAAEC,OAAO,EAAE;MACpC,IAAIL,KAAK,IAAI,IAAI,EAAE,OAAOA,KAAK;MAC/B;MACA;MACA,MAAM;QAAEM,MAAM;QAAEC;MAAS,CAAC,GAAGF,OAAO;MACpC,MAAMG,QAAQ,GAAGH,OAAO,CAACP,SAAS,CAAC;MACnC,MAAMW,WAAW,GAAG,uCAAuC;MAC3D,IAAIH,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIX,aAAa,CAAC,QAAQ,EAAEc,WAAW,EAAEH,MAAM,CAAC;MAC1E,IAAIE,QAAQ,IAAI,IAAI,EAAE,MAAM,IAAIb,aAAa,CAAC,UAAU,EAAEc,WAAW,EAAED,QAAQ,CAAC;MAChF,OAAO,CACL,MAAMF,MAAM,CACTI,mBAAmB,CAACF,QAAQ,CAACG,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QAAEJ;MAAS,CAAC,CAAC,CAClEK,KAAK,CAAEC,KAAK,IAAK;QAChB,IAAI,CAACpB,sBAAsB,CAACoB,KAAK,CAAC,EAAE,MAAMA,KAAK;QAC/C,OAAO;UAAEC,SAAS,EAAE;QAAE,CAAC;MACzB,CAAC,CAAC,EACJA,SAAS;IACb,CAAC;IAEDhB;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Buffer as _Buffer } from "buffer";
2
2
  import { toBytes } from '../../../utils/bytes.js';
3
3
  import { Encoding, decode, encode } from '../../../utils/encoder.js';
4
- import { isAddressValid } from '../../../utils/crypto.js';
4
+ import { isEncoded } from '../../../utils/crypto.js';
5
5
  import { IllegalArgumentError, DecodeError, ArgumentError } from '../../../utils/errors.js';
6
6
  import address, { idTagToEncoding } from './address.js';
7
7
  const ID_TAG = _Buffer.from([1]);
@@ -27,10 +27,10 @@ export default allowRaw => ({
27
27
  id
28
28
  }) => {
29
29
  let payload;
30
- if (isAddressValid(id, ...idTagToEncoding)) {
30
+ if (isEncoded(id, ...idTagToEncoding)) {
31
31
  payload = [...(allowRaw ? [ID_TAG] : []), addressAny.serialize(id)];
32
32
  }
33
- if (isAddressValid(id, Encoding.Bytearray)) {
33
+ if (isEncoded(id, Encoding.Bytearray)) {
34
34
  const data = decode(id);
35
35
  if (data.length > DATA_LENGTH_MAX) {
36
36
  throw new ArgumentError('Raw pointer', `shorter than ${DATA_LENGTH_MAX + 1} bytes`, `${data.length} bytes`);
@@ -1 +1 @@
1
- {"version":3,"file":"pointers.js","names":["toBytes","Encoding","decode","encode","isAddressValid","IllegalArgumentError","DecodeError","ArgumentError","address","idTagToEncoding","ID_TAG","_Buffer","from","DATA_TAG","DATA_LENGTH_MAX","addressAny","allowRaw","serialize","pointers","length","map","key","id","payload","Bytearray","data","concat","deserialize","bKey","bId","toString","tag","subarray","equals"],"sources":["../../../../src/tx/builder/field-types/pointers.ts"],"sourcesContent":["import { NamePointer as NamePointerString } from '../../../apis/node/index.js';\nimport { toBytes } from '../../../utils/bytes.js';\nimport { Encoded, Encoding, decode, encode } from '../../../utils/encoder.js';\nimport { isAddressValid } from '../../../utils/crypto.js';\nimport { IllegalArgumentError, DecodeError, ArgumentError } from '../../../utils/errors.js';\nimport address, { AddressEncodings, idTagToEncoding } from './address.js';\n\nconst ID_TAG = Buffer.from([1]);\nconst DATA_TAG = Buffer.from([2]);\nconst DATA_LENGTH_MAX = 1024;\nconst addressAny = address(...idTagToEncoding);\n\n// TODO: remove after fixing node types\ntype NamePointer = NamePointerString & {\n id: Encoded.Generic<AddressEncodings>;\n};\ntype NamePointerRaw = NamePointerString & {\n id: Encoded.Generic<AddressEncodings | Encoding.Bytearray>;\n};\n\nexport default <AllowRaw extends boolean>(\n allowRaw: AllowRaw,\n): {\n serialize: (pointers: Array<AllowRaw extends true ? NamePointerRaw : NamePointer>) => Buffer[][];\n deserialize: (\n pointers: Array<[key: Buffer, id: Buffer]>,\n ) => Array<AllowRaw extends true ? NamePointerRaw : NamePointer>;\n} => ({\n /**\n * Helper function to build pointers for name update TX\n * @param pointers - Array of pointers\n * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`\n * @returns Serialized pointers array\n */\n serialize(pointers) {\n if (pointers.length > 32) {\n throw new IllegalArgumentError(\n `Expected 32 pointers or less, got ${pointers.length} instead`,\n );\n }\n return pointers.map(({ key, id }) => {\n let payload;\n if (isAddressValid(id, ...idTagToEncoding)) {\n payload = [...(allowRaw ? [ID_TAG] : []), addressAny.serialize(id)];\n }\n if (isAddressValid(id, Encoding.Bytearray)) {\n const data = decode(id);\n if (data.length > DATA_LENGTH_MAX) {\n throw new ArgumentError(\n 'Raw pointer',\n `shorter than ${DATA_LENGTH_MAX + 1} bytes`,\n `${data.length} bytes`,\n );\n }\n payload = [DATA_TAG, data];\n }\n if (payload == null) throw new DecodeError(`Unknown AENS pointer value: ${id}`);\n return [toBytes(key), Buffer.concat(payload)];\n });\n },\n\n /**\n * Helper function to read pointers from name update TX\n * @param pointers - Array of pointers\n * @returns Deserialize pointer array\n */\n deserialize(pointers) {\n return pointers.map(([bKey, bId]) => {\n if (!allowRaw) return { key: bKey.toString(), id: addressAny.deserialize(bId) };\n const tag = bId.subarray(0, 1);\n const payload = bId.subarray(1);\n let id;\n if (tag.equals(ID_TAG)) id = addressAny.deserialize(payload);\n // TS can't figure out the real type depending on allowRaw\n if (tag.equals(DATA_TAG)) id = encode(payload, Encoding.Bytearray) as Encoded.AccountAddress;\n if (id == null) throw new DecodeError(`Unknown AENS pointer tag: ${tag}`);\n return { key: bKey.toString(), id };\n });\n },\n});\n"],"mappings":";AACA,SAASA,OAAO,QAAQ,yBAAyB;AACjD,SAAkBC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,2BAA2B;AAC7E,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,oBAAoB,EAAEC,WAAW,EAAEC,aAAa,QAAQ,0BAA0B;AAC3F,OAAOC,OAAO,IAAsBC,eAAe,QAAQ,cAAc;AAEzE,MAAMC,MAAM,GAAGC,OAAA,CAAOC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,MAAMC,QAAQ,GAAGF,OAAA,CAAOC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,MAAME,eAAe,GAAG,IAAI;AAC5B,MAAMC,UAAU,GAAGP,OAAO,CAAC,GAAGC,eAAe,CAAC;;AAE9C;;AAQA,eACE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nC,IAAI,CAACb,QAAQ,EAAE,OAAO;QAAEK,GAAG,EAAEO,IAAI,CAACE,QAAQ,CAAC,CAAC;QAAER,EAAE,EAAEP,UAAU,CAACY,WAAW,CAACE,GAAG;MAAE,CAAC;MAC/E,MAAME,GAAG,GAAGF,GAAG,CAACG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;MAC9B,MAAMT,OAAO,GAAGM,GAAG,CAACG,QAAQ,CAAC,CAAC,CAAC;MAC/B,IAAIV,EAAE;MACN,IAAIS,GAAG,CAACE,MAAM,CAACvB,MAAM,CAAC,EAAEY,EAAE,GAAGP,UAAU,CAACY,WAAW,CAACJ,OAAO,CAAC;MAC5D;MACA,IAAIQ,GAAG,CAACE,MAAM,CAACpB,QAAQ,CAAC,EAAES,EAAE,GAAGnB,MAAM,CAACoB,OAAO,EAAEtB,QAAQ,CAACuB,SAAS,CAA2B;MAC5F,IAAIF,EAAE,IAAI,IAAI,EAAE,MAAM,IAAIhB,WAAW,CAAC,6BAA6ByB,GAAG,EAAE,CAAC;MACzE,OAAO;QAAEV,GAAG,EAAEO,IAAI,CAACE,QAAQ,CAAC,CAAC;QAAER;MAAG,CAAC;IACrC,CAAC,CAAC;EACJ;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"pointers.js","names":["toBytes","Encoding","decode","encode","isEncoded","IllegalArgumentError","DecodeError","ArgumentError","address","idTagToEncoding","ID_TAG","_Buffer","from","DATA_TAG","DATA_LENGTH_MAX","addressAny","allowRaw","serialize","pointers","length","map","key","id","payload","Bytearray","data","concat","deserialize","bKey","bId","toString","tag","subarray","equals"],"sources":["../../../../src/tx/builder/field-types/pointers.ts"],"sourcesContent":["import { NamePointer as NamePointerString } from '../../../apis/node/index.js';\nimport { toBytes } from '../../../utils/bytes.js';\nimport { Encoded, Encoding, decode, encode } from '../../../utils/encoder.js';\nimport { isEncoded } from '../../../utils/crypto.js';\nimport { IllegalArgumentError, DecodeError, ArgumentError } from '../../../utils/errors.js';\nimport address, { AddressEncodings, idTagToEncoding } from './address.js';\n\nconst ID_TAG = Buffer.from([1]);\nconst DATA_TAG = Buffer.from([2]);\nconst DATA_LENGTH_MAX = 1024;\nconst addressAny = address(...idTagToEncoding);\n\n// TODO: remove after fixing node types\ntype NamePointer = NamePointerString & {\n id: Encoded.Generic<AddressEncodings>;\n};\ntype NamePointerRaw = NamePointerString & {\n id: Encoded.Generic<AddressEncodings | Encoding.Bytearray>;\n};\n\nexport default <AllowRaw extends boolean>(\n allowRaw: AllowRaw,\n): {\n serialize: (pointers: Array<AllowRaw extends true ? NamePointerRaw : NamePointer>) => Buffer[][];\n deserialize: (\n pointers: Array<[key: Buffer, id: Buffer]>,\n ) => Array<AllowRaw extends true ? NamePointerRaw : NamePointer>;\n} => ({\n /**\n * Helper function to build pointers for name update TX\n * @param pointers - Array of pointers\n * `([ { key: 'account_pubkey', id: 'ak_32klj5j23k23j5423l434l2j3423'} ])`\n * @returns Serialized pointers array\n */\n serialize(pointers) {\n if (pointers.length > 32) {\n throw new IllegalArgumentError(\n `Expected 32 pointers or less, got ${pointers.length} instead`,\n );\n }\n return pointers.map(({ key, id }) => {\n let payload;\n if (isEncoded(id, ...idTagToEncoding)) {\n payload = [...(allowRaw ? [ID_TAG] : []), addressAny.serialize(id)];\n }\n if (isEncoded(id, Encoding.Bytearray)) {\n const data = decode(id);\n if (data.length > DATA_LENGTH_MAX) {\n throw new ArgumentError(\n 'Raw pointer',\n `shorter than ${DATA_LENGTH_MAX + 1} bytes`,\n `${data.length} bytes`,\n );\n }\n payload = [DATA_TAG, data];\n }\n if (payload == null) throw new DecodeError(`Unknown AENS pointer value: ${id}`);\n return [toBytes(key), Buffer.concat(payload)];\n });\n },\n\n /**\n * Helper function to read pointers from name update TX\n * @param pointers - Array of pointers\n * @returns Deserialize pointer array\n */\n deserialize(pointers) {\n return pointers.map(([bKey, bId]) => {\n if (!allowRaw) return { key: bKey.toString(), id: addressAny.deserialize(bId) };\n const tag = bId.subarray(0, 1);\n const payload = bId.subarray(1);\n let id;\n if (tag.equals(ID_TAG)) id = addressAny.deserialize(payload);\n // TS can't figure out the real type depending on allowRaw\n if (tag.equals(DATA_TAG)) id = encode(payload, Encoding.Bytearray) as Encoded.AccountAddress;\n if (id == null) throw new DecodeError(`Unknown AENS pointer tag: ${tag}`);\n return { key: bKey.toString(), id };\n });\n },\n});\n"],"mappings":";AACA,SAASA,OAAO,QAAQ,yBAAyB;AACjD,SAAkBC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,2BAA2B;AAC7E,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,oBAAoB,EAAEC,WAAW,EAAEC,aAAa,QAAQ,0BAA0B;AAC3F,OAAOC,OAAO,IAAsBC,eAAe,QAAQ,cAAc;AAEzE,MAAMC,MAAM,GAAGC,OAAA,CAAOC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/B,MAAMC,QAAQ,GAAGF,OAAA,CAAOC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,MAAME,eAAe,GAAG,IAAI;AAC5B,MAAMC,UAAU,GAAGP,OAAO,CAAC,GAAGC,eAAe,CAAC;;AAE9C;;AAQA,eACEO,QAAkB,KAMd;EACJ;AACF;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACC,QAAQ,EAAE;IAClB,IAAIA,QAAQ,CAACC,MAAM,GAAG,EAAE,EAAE;MACxB,MAAM,IAAId,oBAAoB,CAC5B,qCAAqCa,QAAQ,CAACC,MAAM,UACtD,CAAC;IACH;IACA,OAAOD,QAAQ,CAACE,GAAG,CAAC,CAAC;MAAEC,GAAG;MAAEC;IAAG,CAAC,KAAK;MACnC,IAAIC,OAAO;MACX,IAAInB,SAAS,CAACkB,EAAE,EAAE,GAAGb,eAAe,CAAC,EAAE;QACrCc,OAAO,GAAG,CAAC,IAAIP,QAAQ,GAAG,CAACN,MAAM,CAAC,GAAG,EAAE,CAAC,EAAEK,UAAU,CAACE,SAAS,CAACK,EAAE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nB,MAAM,CAACoB,OAAO,EAAEtB,QAAQ,CAACuB,SAAS,CAA2B;MAC5F,IAAIF,EAAE,IAAI,IAAI,EAAE,MAAM,IAAIhB,WAAW,CAAC,6BAA6ByB,GAAG,EAAE,CAAC;MACzE,OAAO;QAAEV,GAAG,EAAEO,IAAI,CAACE,QAAQ,CAAC,CAAC;QAAER;MAAG,CAAC;IACrC,CAAC,CAAC;EACJ;AACF,CAAC,CAAC","ignoreList":[]}
@@ -19,9 +19,8 @@ export default {
19
19
  ...options
20
20
  }) {
21
21
  if (absoluteTtl !== true && value !== 0 && (value != null || _isInternalBuild === true)) {
22
- var _value;
23
22
  if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);
24
- value = ((_value = value) !== null && _value !== void 0 ? _value : 3) + (await getHeight({
23
+ value = (value !== null && value !== void 0 ? value : 3) + (await getHeight({
25
24
  ...options,
26
25
  onNode,
27
26
  cached: true
@@ -1 +1 @@
1
- {"version":3,"file":"ttl.js","names":["shortUInt","ArgumentError","getHeight","serialize","value","prepare","params","onNode","absoluteTtl","_isInternalBuild","options","_value","cached"],"sources":["../../../../src/tx/builder/field-types/ttl.ts"],"sourcesContent":["import shortUInt from './short-u-int.js';\nimport Node from '../../../Node.js';\nimport { ArgumentError } from '../../../utils/errors.js';\nimport { _getPollInterval, getHeight } from '../../../chain.js';\n\n/**\n * Time to leave\n */\nexport default {\n ...shortUInt,\n\n serialize(value: number | undefined): Buffer {\n return shortUInt.serialize(value ?? 0);\n },\n\n async prepare(\n value: number | undefined,\n params: {},\n // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }\n {\n onNode,\n absoluteTtl,\n _isInternalBuild,\n ...options\n }: {\n onNode?: Node;\n absoluteTtl?: boolean;\n _isInternalBuild?: boolean;\n } & Omit<Parameters<typeof _getPollInterval>[1], 'onNode'>,\n ) {\n if (absoluteTtl !== true && value !== 0 && (value != null || _isInternalBuild === true)) {\n if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);\n value = (value ?? 3) + (await getHeight({ ...options, onNode, cached: true }));\n }\n return value;\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,kBAAkB;AAExC,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAA2BC,SAAS,QAAQ,mBAAmB;;AAE/D;AACA;AACA;AACA,eAAe;EACb,GAAGF,SAAS;EAEZG,SAASA,CAACC,KAAyB,EAAU;IAC3C,OAAOJ,SAAS,CAACG,SAAS,CAACC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC;EACxC,CAAC;EAED,MAAMC,OAAOA,CACXD,KAAyB,EACzBE,MAAU;EACV;EACA;IACEC,MAAM;IACNC,WAAW;IACXC,gBAAgB;IAChB,GAAGC;EAKoD,CAAC,EAC1D;IACA,IAAIF,WAAW,KAAK,IAAI,IAAIJ,KAAK,KAAK,CAAC,KAAKA,KAAK,IAAI,IAAI,IAAIK,gBAAgB,KAAK,IAAI,CAAC,EAAE;MAAA,IAAAE,MAAA;MACvF,IAAIJ,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIN,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAEM,MAAM,CAAC;MACzEH,KAAK,GAAG,EAAAO,MAAA,GAACP,KAAK,cAAAO,MAAA,cAAAA,MAAA,GAAI,CAAC,KAAK,MAAMT,SAAS,CAAC;QAAE,GAAGQ,OAAO;QAAEH,MAAM;QAAEK,MAAM,EAAE;MAAK,CAAC,CAAC,CAAC;IAChF;IACA,OAAOR,KAAK;EACd;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ttl.js","names":["shortUInt","ArgumentError","getHeight","serialize","value","prepare","params","onNode","absoluteTtl","_isInternalBuild","options","cached"],"sources":["../../../../src/tx/builder/field-types/ttl.ts"],"sourcesContent":["import shortUInt from './short-u-int.js';\nimport Node from '../../../Node.js';\nimport { ArgumentError } from '../../../utils/errors.js';\nimport { _getPollInterval, getHeight } from '../../../chain.js';\n\n/**\n * Time to leave\n */\nexport default {\n ...shortUInt,\n\n serialize(value: number | undefined): Buffer {\n return shortUInt.serialize(value ?? 0);\n },\n\n async prepare(\n value: number | undefined,\n params: {},\n // TODO: { absoluteTtl: true } | { absoluteTtl: false, onNode: Node }\n {\n onNode,\n absoluteTtl,\n _isInternalBuild,\n ...options\n }: {\n onNode?: Node;\n absoluteTtl?: boolean;\n _isInternalBuild?: boolean;\n } & Omit<Parameters<typeof _getPollInterval>[1], 'onNode'>,\n ) {\n if (absoluteTtl !== true && value !== 0 && (value != null || _isInternalBuild === true)) {\n if (onNode == null) throw new ArgumentError('onNode', 'provided', onNode);\n value = (value ?? 3) + (await getHeight({ ...options, onNode, cached: true }));\n }\n return value;\n },\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,kBAAkB;AAExC,SAASC,aAAa,QAAQ,0BAA0B;AACxD,SAA2BC,SAAS,QAAQ,mBAAmB;;AAE/D;AACA;AACA;AACA,eAAe;EACb,GAAGF,SAAS;EAEZG,SAASA,CAACC,KAAyB,EAAU;IAC3C,OAAOJ,SAAS,CAACG,SAAS,CAACC,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,CAAC;EACxC,CAAC;EAED,MAAMC,OAAOA,CACXD,KAAyB,EACzBE,MAAU;EACV;EACA;IACEC,MAAM;IACNC,WAAW;IACXC,gBAAgB;IAChB,GAAGC;EAKoD,CAAC,EAC1D;IACA,IAAIF,WAAW,KAAK,IAAI,IAAIJ,KAAK,KAAK,CAAC,KAAKA,KAAK,IAAI,IAAI,IAAIK,gBAAgB,KAAK,IAAI,CAAC,EAAE;MACvF,IAAIF,MAAM,IAAI,IAAI,EAAE,MAAM,IAAIN,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAEM,MAAM,CAAC;MACzEH,KAAK,GAAG,CAACA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,CAAC,KAAK,MAAMF,SAAS,CAAC;QAAE,GAAGQ,OAAO;QAAEH,MAAM;QAAEI,MAAM,EAAE;MAAK,CAAC,CAAC,CAAC;IAChF;IACA,OAAOP,KAAK;EACd;AACF,CAAC","ignoreList":[]}
@@ -1,17 +1,17 @@
1
- import { BigNumber } from 'bignumber.js';
1
+ import BigNumber from 'bignumber.js';
2
2
  import { Encoded } from '../../utils/encoder.js';
3
3
  import { AensName } from './constants.js';
4
4
  /**
5
5
  * JavaScript-based Transaction builder helper function's
6
6
  */
7
7
  /**
8
- * Build a contract public key
8
+ * Build a contract address
9
9
  * @category contract
10
- * @param ownerId - The public key of the owner account
11
- * @param nonce - the nonce of the transaction
12
- * @returns Contract public key
10
+ * @param owner - Address of contract owner
11
+ * @param nonce - Nonce of ContractCreateTx or state channel round when contract was created
12
+ * @returns Contract address
13
13
  */
14
- export declare function buildContractId(ownerId: Encoded.AccountAddress, nonce: number | BigNumber): Encoded.ContractAddress;
14
+ export declare function buildContractId(owner: Encoded.AccountAddress, nonce: number | BigNumber): Encoded.ContractAddress;
15
15
  /**
16
16
  * Build a oracle query id
17
17
  * @category oracle
@@ -40,11 +40,12 @@ export declare function produceNameId(name: AensName): Encoded.Name;
40
40
  export declare function commitmentHash(name: AensName, salt?: number): Encoded.Commitment;
41
41
  /**
42
42
  * Utility function to convert bytes to int
43
- * @category transaction builder
44
- * @param buf - Value
43
+ * @category utils
44
+ * @param buffer - Value
45
45
  * @returns Buffer Buffer from number(BigEndian)
46
+ * @deprecated use `BigInt('0x' + <buffer>.toString('hex')).toString()` instead
46
47
  */
47
- export declare function readInt(buf?: Buffer): string;
48
+ export declare function readInt(buffer?: Uint8Array): string;
48
49
  /**
49
50
  * Ensure that name is valid AENS name, would throw an exception otherwise
50
51
  * @category AENS
@@ -56,7 +57,7 @@ export declare function ensureName(maybeName: string): asserts maybeName is Aens
56
57
  * @category AENS
57
58
  * @param maybeName - AENS name
58
59
  */
59
- export declare function isNameValid(maybeName: string): maybeName is AensName;
60
+ export declare function isName(maybeName: string): maybeName is AensName;
60
61
  declare const encodingToPointerKey: readonly [readonly [Encoded.Encoding.AccountAddress, "account_pubkey"], readonly [Encoded.Encoding.OracleAddress, "oracle_pubkey"], readonly [Encoded.Encoding.ContractAddress, "contract_pubkey"], readonly [Encoded.Encoding.Channel, "channel"]];
61
62
  /**
62
63
  * @category AENS
@@ -85,11 +86,16 @@ export declare function computeBidFee(name: AensName, { startFee, increment, }?:
85
86
  increment?: number;
86
87
  }): BigNumber;
87
88
  /**
88
- * Compute auction end height
89
+ * Compute approximate auction end height.
90
+ *
91
+ * From Ceres, each time a new (successful!) bid is made for a name the auction is extended for up
92
+ * to 120 key-blocks/generations. I.e. after the bid there is always at least 120 generations to
93
+ * make a higher bid.
94
+ *
89
95
  * @category AENS
90
96
  * @param name - Name to compute auction end for
91
97
  * @param claimHeight - Auction starting height
92
- * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}
98
+ * @see {@link https://github.com/aeternity/protocol/blob/cfb19ce/AENS.md#from-ceres-protocol-upgrade}
93
99
  * @returns Auction end height
94
100
  */
95
101
  export declare function computeAuctionEndBlock(name: AensName, claimHeight: number): number;
@@ -1,10 +1,10 @@
1
1
  import { Buffer as _Buffer } from "buffer";
2
- import { BigNumber } from 'bignumber.js';
2
+ import BigNumber from 'bignumber.js';
3
3
  import { genSalt, hash } from '../../utils/crypto.js';
4
4
  import { decode, encode, Encoding } from '../../utils/encoder.js';
5
5
  import { toBytes } from '../../utils/bytes.js';
6
6
  import { concatBuffers } from '../../utils/other.js';
7
- import { NAME_BID_RANGES, NAME_BID_TIMEOUT_BLOCKS, NAME_FEE_BID_INCREMENT, NAME_MAX_LENGTH_FEE } from './constants.js';
7
+ import { NAME_BID_RANGES, NAME_FEE_BID_INCREMENT, NAME_MAX_LENGTH_FEE } from './constants.js';
8
8
  import { ceil } from '../../utils/bignumber.js';
9
9
  import { ArgumentError, IllegalBidFeeError } from '../../utils/errors.js';
10
10
 
@@ -13,18 +13,19 @@ import { ArgumentError, IllegalBidFeeError } from '../../utils/errors.js';
13
13
  */
14
14
 
15
15
  /**
16
- * Build a contract public key
16
+ * Build a contract address
17
17
  * @category contract
18
- * @param ownerId - The public key of the owner account
19
- * @param nonce - the nonce of the transaction
20
- * @returns Contract public key
18
+ * @param owner - Address of contract owner
19
+ * @param nonce - Nonce of ContractCreateTx or state channel round when contract was created
20
+ * @returns Contract address
21
21
  */
22
- export function buildContractId(ownerId, nonce) {
23
- const ownerIdAndNonce = _Buffer.from([...decode(ownerId), ...toBytes(nonce)]);
22
+ export function buildContractId(owner, nonce) {
23
+ const ownerIdAndNonce = _Buffer.from([...decode(owner), ...toBytes(nonce)]);
24
24
  const b2bHash = hash(ownerIdAndNonce);
25
25
  return encode(b2bHash, Encoding.ContractAddress);
26
26
  }
27
27
 
28
+ // TODO: add `build` prefix the same as others
28
29
  /**
29
30
  * Build a oracle query id
30
31
  * @category oracle
@@ -82,6 +83,7 @@ export function nameToPunycode(maybeName) {
82
83
  return punycode;
83
84
  }
84
85
 
86
+ // TODO: replace `produce` with `build` the same as others
85
87
  /**
86
88
  * Encode an AENS name
87
89
  * @category AENS
@@ -92,6 +94,7 @@ export function produceNameId(name) {
92
94
  return encode(hash(nameToPunycode(name)), Encoding.Name);
93
95
  }
94
96
 
97
+ // TODO: add `build` the same as others
95
98
  /**
96
99
  * Generate the commitment hash by hashing the salt and
97
100
  * name, base 58 encoding the result and prepending 'cm_'
@@ -106,12 +109,13 @@ export function commitmentHash(name, salt = genSalt()) {
106
109
 
107
110
  /**
108
111
  * Utility function to convert bytes to int
109
- * @category transaction builder
110
- * @param buf - Value
112
+ * @category utils
113
+ * @param buffer - Value
111
114
  * @returns Buffer Buffer from number(BigEndian)
115
+ * @deprecated use `BigInt('0x' + <buffer>.toString('hex')).toString()` instead
112
116
  */
113
- export function readInt(buf = _Buffer.from([])) {
114
- return new BigNumber(_Buffer.from(buf).toString('hex'), 16).toString(10);
117
+ export function readInt(buffer = _Buffer.from([])) {
118
+ return BigInt('0x' + _Buffer.from(buffer).toString('hex')).toString();
115
119
  }
116
120
 
117
121
  /**
@@ -128,8 +132,7 @@ export function ensureName(maybeName) {
128
132
  * @category AENS
129
133
  * @param maybeName - AENS name
130
134
  */
131
- // TODO: consider renaming to isName
132
- export function isNameValid(maybeName) {
135
+ export function isName(maybeName) {
133
136
  try {
134
137
  ensureName(maybeName);
135
138
  return true;
@@ -183,17 +186,22 @@ export function computeBidFee(name, {
183
186
  }
184
187
 
185
188
  /**
186
- * Compute auction end height
189
+ * Compute approximate auction end height.
190
+ *
191
+ * From Ceres, each time a new (successful!) bid is made for a name the auction is extended for up
192
+ * to 120 key-blocks/generations. I.e. after the bid there is always at least 120 generations to
193
+ * make a higher bid.
194
+ *
187
195
  * @category AENS
188
196
  * @param name - Name to compute auction end for
189
197
  * @param claimHeight - Auction starting height
190
- * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}
198
+ * @see {@link https://github.com/aeternity/protocol/blob/cfb19ce/AENS.md#from-ceres-protocol-upgrade}
191
199
  * @returns Auction end height
192
200
  */
193
201
  export function computeAuctionEndBlock(name, claimHeight) {
194
202
  var _ref, _ref2, _ref3;
195
203
  const length = nameToPunycode(name).length - AENS_SUFFIX.length;
196
- const h = (_ref = (_ref2 = (_ref3 = length <= 4 ? 62 * NAME_BID_TIMEOUT_BLOCKS : null) !== null && _ref3 !== void 0 ? _ref3 : length <= 8 ? 31 * NAME_BID_TIMEOUT_BLOCKS : null) !== null && _ref2 !== void 0 ? _ref2 : length <= 12 ? NAME_BID_TIMEOUT_BLOCKS : null) !== null && _ref !== void 0 ? _ref : 0;
204
+ const h = (_ref = (_ref2 = (_ref3 = length <= 4 ? 2400 : null) !== null && _ref3 !== void 0 ? _ref3 : length <= 8 ? 960 : null) !== null && _ref2 !== void 0 ? _ref2 : length <= 12 ? 480 : null) !== null && _ref !== void 0 ? _ref : 0;
197
205
  return h + claimHeight;
198
206
  }
199
207
 
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["BigNumber","genSalt","hash","decode","encode","Encoding","toBytes","concatBuffers","NAME_BID_RANGES","NAME_BID_TIMEOUT_BLOCKS","NAME_FEE_BID_INCREMENT","NAME_MAX_LENGTH_FEE","ceil","ArgumentError","IllegalBidFeeError","buildContractId","ownerId","nonce","ownerIdAndNonce","_Buffer","from","b2bHash","ContractAddress","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","alloc","length","OracleQueryId","AENS_SUFFIX","nameToPunycode","maybeName","name","suffix","other","split","slice","test","at","punycode","u","URL","username","password","port","search","pathname","host","error","TypeError","message","includes","produceNameId","Name","commitmentHash","salt","toString","padStart","Commitment","readInt","buf","ensureName","isNameValid","encodingToPointerKey","AccountAddress","OracleAddress","Channel","getDefaultPointerKey","identifier","encoding","substring","result","find","e","map","join","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","_ref","_ref2","_ref3","h","isAuctionName"],"sources":["../../../src/tx/builder/helpers.ts"],"sourcesContent":["import { BigNumber } from 'bignumber.js';\nimport { genSalt, hash } from '../../utils/crypto.js';\nimport { decode, encode, Encoded, Encoding } from '../../utils/encoder.js';\nimport { toBytes } from '../../utils/bytes.js';\nimport { concatBuffers } from '../../utils/other.js';\nimport {\n AensName,\n NAME_BID_RANGES,\n NAME_BID_TIMEOUT_BLOCKS,\n NAME_FEE_BID_INCREMENT,\n NAME_MAX_LENGTH_FEE,\n} from './constants.js';\nimport { ceil } from '../../utils/bignumber.js';\nimport { ArgumentError, IllegalBidFeeError } from '../../utils/errors.js';\n\n/**\n * JavaScript-based Transaction builder helper function's\n */\n\n/**\n * Build a contract public key\n * @category contract\n * @param ownerId - The public key of the owner account\n * @param nonce - the nonce of the transaction\n * @returns Contract public key\n */\nexport function buildContractId(\n ownerId: Encoded.AccountAddress,\n nonce: number | BigNumber,\n): Encoded.ContractAddress {\n const ownerIdAndNonce = Buffer.from([...decode(ownerId), ...toBytes(nonce)]);\n const b2bHash = hash(ownerIdAndNonce);\n return encode(b2bHash, Encoding.ContractAddress);\n}\n\n/**\n * Build a oracle query id\n * @category oracle\n * @param senderId - The public key of the sender account\n * @param nonce - the nonce of the transaction\n * @param oracleId - The oracle public key\n * @returns Contract public key\n */\nexport function oracleQueryId(\n senderId: Encoded.AccountAddress,\n nonce: number | BigNumber | string,\n oracleId: Encoded.OracleAddress,\n): Encoded.OracleQueryId {\n function _int32(val: number | string | BigNumber): Buffer {\n const nonceBE = toBytes(val, true);\n return concatBuffers([Buffer.alloc(32 - nonceBE.length), nonceBE]);\n }\n\n const b2bHash = hash(Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]));\n return encode(b2bHash, Encoding.OracleQueryId);\n}\n\nconst AENS_SUFFIX = '.chain';\n\nexport function nameToPunycode(maybeName: string): AensName {\n const [name, suffix, ...other] = maybeName.split('.');\n if (other.length !== 0) throw new ArgumentError('aens name', 'including only one dot', maybeName);\n if (suffix !== AENS_SUFFIX.slice(1)) {\n throw new ArgumentError('aens name', `suffixed with ${AENS_SUFFIX}`, maybeName);\n }\n if (/\\p{Emoji_Presentation}/u.test(name)) {\n throw new ArgumentError('aens name', 'not containing emoji', maybeName);\n }\n if (name[2] === '-' && name[3] === '-') {\n throw new ArgumentError(\n 'aens name',\n 'without \"-\" char in both the third and fourth positions',\n maybeName,\n );\n }\n if (name[0] === '-') {\n throw new ArgumentError('aens name', 'starting with no \"-\" char', maybeName);\n }\n if (name.at(-1) === '-') {\n throw new ArgumentError('aens name', 'ending with no \"-\" char', maybeName);\n }\n let punycode;\n try {\n const u = new URL(`http://${name}.${suffix}`);\n if (u.username + u.password + u.port + u.search + u.hash !== '' || u.pathname !== '/') {\n throw new ArgumentError('aens name', 'valid', maybeName);\n }\n punycode = u.host;\n } catch (error) {\n if (error instanceof TypeError && error.message.includes('Invalid URL')) {\n throw new ArgumentError('aens name', 'valid', maybeName);\n }\n throw error;\n }\n if (!/^[a-z0-9.-]+$/i.test(punycode)) {\n throw new ArgumentError('aens name', 'without illegal chars', maybeName);\n }\n if (punycode.length > 63 + AENS_SUFFIX.length) {\n throw new ArgumentError('aens name', 'not too long', maybeName);\n }\n return punycode as AensName;\n}\n\n/**\n * Encode an AENS name\n * @category AENS\n * @param name - Name to encode\n * @returns `nm_` prefixed encoded AENS name\n */\nexport function produceNameId(name: AensName): Encoded.Name {\n return encode(hash(nameToPunycode(name)), Encoding.Name);\n}\n\n/**\n * Generate the commitment hash by hashing the salt and\n * name, base 58 encoding the result and prepending 'cm_'\n * @category transaction builder\n * @param name - Name to be registered\n * @param salt - Random number\n * @returns Commitment hash\n */\nexport function commitmentHash(name: AensName, salt: number = genSalt()): Encoded.Commitment {\n return encode(\n hash(\n concatBuffers([\n Buffer.from(nameToPunycode(name)),\n Buffer.from(salt.toString(16).padStart(64, '0'), 'hex'),\n ]),\n ),\n Encoding.Commitment,\n );\n}\n\n/**\n * Utility function to convert bytes to int\n * @category transaction builder\n * @param buf - Value\n * @returns Buffer Buffer from number(BigEndian)\n */\nexport function readInt(buf: Buffer = Buffer.from([])): string {\n return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10);\n}\n\n/**\n * Ensure that name is valid AENS name, would throw an exception otherwise\n * @category AENS\n * @param maybeName - AENS name\n */\nexport function ensureName(maybeName: string): asserts maybeName is AensName {\n nameToPunycode(maybeName);\n}\n\n/**\n * Is AENS name valid\n * @category AENS\n * @param maybeName - AENS name\n */\n// TODO: consider renaming to isName\nexport function isNameValid(maybeName: string): maybeName is AensName {\n try {\n ensureName(maybeName);\n return true;\n } catch (error) {\n return false;\n }\n}\n\nconst encodingToPointerKey = [\n [Encoding.AccountAddress, 'account_pubkey'],\n [Encoding.OracleAddress, 'oracle_pubkey'],\n [Encoding.ContractAddress, 'contract_pubkey'],\n [Encoding.Channel, 'channel'],\n] as const;\n\n/**\n * @category AENS\n * @param identifier - account/oracle/contract address, or channel\n * @returns default AENS pointer key\n */\nexport function getDefaultPointerKey(\n identifier: Encoded.Generic<(typeof encodingToPointerKey)[number][0]>,\n): (typeof encodingToPointerKey)[number][1] {\n decode(identifier);\n const encoding = identifier.substring(0, 2);\n const result = encodingToPointerKey.find(([e]) => e === encoding)?.[1];\n if (result != null) return result;\n throw new ArgumentError(\n 'identifier',\n `prefixed with one of ${encodingToPointerKey.map(([e]) => `${e}_`).join(', ')}`,\n identifier,\n );\n}\n\n/**\n * Get the minimum AENS name fee\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @returns the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee(name: AensName): BigNumber {\n const nameLength = nameToPunycode(name).length - AENS_SUFFIX.length;\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];\n}\n\n/**\n * Compute bid fee for AENS auction\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @param options - Options\n * @param options.startFee - Auction start fee\n * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)\n * @returns Bid fee\n */\nexport function computeBidFee(\n name: AensName,\n {\n startFee,\n increment = NAME_FEE_BID_INCREMENT,\n }: { startFee?: number | string | BigNumber; increment?: number } = {},\n): BigNumber {\n if (!(Number(increment) === increment && increment % 1 !== 0))\n throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);\n if (increment < NAME_FEE_BID_INCREMENT)\n throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);\n // FIXME: increment should be used somehow here\n return ceil(\n new BigNumber(startFee ?? getMinimumNameFee(name)).times(\n new BigNumber(NAME_FEE_BID_INCREMENT).plus(1),\n ),\n );\n}\n\n/**\n * Compute auction end height\n * @category AENS\n * @param name - Name to compute auction end for\n * @param claimHeight - Auction starting height\n * @see {@link https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273}\n * @returns Auction end height\n */\nexport function computeAuctionEndBlock(name: AensName, claimHeight: number): number {\n const length = nameToPunycode(name).length - AENS_SUFFIX.length;\n const h =\n (length <= 4 ? 62 * NAME_BID_TIMEOUT_BLOCKS : null) ??\n (length <= 8 ? 31 * NAME_BID_TIMEOUT_BLOCKS : null) ??\n (length <= 12 ? NAME_BID_TIMEOUT_BLOCKS : null) ??\n 0;\n return h + claimHeight;\n}\n\n/**\n * Is name accept going to auction\n * @category AENS\n */\nexport function isAuctionName(name: AensName): boolean {\n return nameToPunycode(name).length < 13 + AENS_SUFFIX.length;\n}\n"],"mappings":";AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,OAAO,EAAEC,IAAI,QAAQ,uBAAuB;AACrD,SAASC,MAAM,EAAEC,MAAM,EAAWC,QAAQ,QAAQ,wBAAwB;AAC1E,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAEEC,eAAe,EACfC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB,QACd,gBAAgB;AACvB,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,uBAAuB;;AAEzE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,OAA+B,EAC/BC,KAAyB,EACA;EACzB,MAAMC,eAAe,GAAGC,OAAA,CAAOC,IAAI,CAAC,CAAC,GAAGjB,MAAM,CAACa,OAAO,CAAC,EAAE,GAAGV,OAAO,CAACW,KAAK,CAAC,CAAC,CAAC;EAC5E,MAAMI,OAAO,GAAGnB,IAAI,CAACgB,eAAe,CAAC;EACrC,OAAOd,MAAM,CAACiB,OAAO,EAAEhB,QAAQ,CAACiB,eAAe,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,QAAgC,EAChCP,KAAkC,EAClCQ,QAA+B,EACR;EACvB,SAASC,MAAMA,CAACC,GAAgC,EAAU;IACxD,MAAMC,OAAO,GAAGt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AAI,CAAC,CAACL,MAAM,GAAG,EAAE,GAAGE,WAAW,CAACF,MAAM;AAC9D","ignoreList":[]}
1
+ {"version":3,"file":"helpers.js","names":["BigNumber","genSalt","hash","decode","encode","Encoding","toBytes","concatBuffers","NAME_BID_RANGES","NAME_FEE_BID_INCREMENT","NAME_MAX_LENGTH_FEE","ceil","ArgumentError","IllegalBidFeeError","buildContractId","owner","nonce","ownerIdAndNonce","_Buffer","from","b2bHash","ContractAddress","oracleQueryId","senderId","oracleId","_int32","val","nonceBE","alloc","length","OracleQueryId","AENS_SUFFIX","nameToPunycode","maybeName","name","suffix","other","split","slice","test","at","punycode","u","URL","username","password","port","search","pathname","host","error","TypeError","message","includes","produceNameId","Name","commitmentHash","salt","toString","padStart","Commitment","readInt","buffer","BigInt","ensureName","isName","encodingToPointerKey","AccountAddress","OracleAddress","Channel","getDefaultPointerKey","identifier","encoding","substring","result","find","e","map","join","getMinimumNameFee","nameLength","Math","min","computeBidFee","startFee","increment","Number","times","plus","computeAuctionEndBlock","claimHeight","_ref","_ref2","_ref3","h","isAuctionName"],"sources":["../../../src/tx/builder/helpers.ts"],"sourcesContent":["import BigNumber from 'bignumber.js';\nimport { genSalt, hash } from '../../utils/crypto.js';\nimport { decode, encode, Encoded, Encoding } from '../../utils/encoder.js';\nimport { toBytes } from '../../utils/bytes.js';\nimport { concatBuffers } from '../../utils/other.js';\nimport {\n AensName,\n NAME_BID_RANGES,\n NAME_FEE_BID_INCREMENT,\n NAME_MAX_LENGTH_FEE,\n} from './constants.js';\nimport { ceil } from '../../utils/bignumber.js';\nimport { ArgumentError, IllegalBidFeeError } from '../../utils/errors.js';\n\n/**\n * JavaScript-based Transaction builder helper function's\n */\n\n/**\n * Build a contract address\n * @category contract\n * @param owner - Address of contract owner\n * @param nonce - Nonce of ContractCreateTx or state channel round when contract was created\n * @returns Contract address\n */\nexport function buildContractId(\n owner: Encoded.AccountAddress,\n nonce: number | BigNumber,\n): Encoded.ContractAddress {\n const ownerIdAndNonce = Buffer.from([...decode(owner), ...toBytes(nonce)]);\n const b2bHash = hash(ownerIdAndNonce);\n return encode(b2bHash, Encoding.ContractAddress);\n}\n\n// TODO: add `build` prefix the same as others\n/**\n * Build a oracle query id\n * @category oracle\n * @param senderId - The public key of the sender account\n * @param nonce - the nonce of the transaction\n * @param oracleId - The oracle public key\n * @returns Contract public key\n */\nexport function oracleQueryId(\n senderId: Encoded.AccountAddress,\n nonce: number | BigNumber | string,\n oracleId: Encoded.OracleAddress,\n): Encoded.OracleQueryId {\n function _int32(val: number | string | BigNumber): Buffer {\n const nonceBE = toBytes(val, true);\n return concatBuffers([Buffer.alloc(32 - nonceBE.length), nonceBE]);\n }\n\n const b2bHash = hash(Buffer.from([...decode(senderId), ..._int32(nonce), ...decode(oracleId)]));\n return encode(b2bHash, Encoding.OracleQueryId);\n}\n\nconst AENS_SUFFIX = '.chain';\n\nexport function nameToPunycode(maybeName: string): AensName {\n const [name, suffix, ...other] = maybeName.split('.');\n if (other.length !== 0) throw new ArgumentError('aens name', 'including only one dot', maybeName);\n if (suffix !== AENS_SUFFIX.slice(1)) {\n throw new ArgumentError('aens name', `suffixed with ${AENS_SUFFIX}`, maybeName);\n }\n if (/\\p{Emoji_Presentation}/u.test(name)) {\n throw new ArgumentError('aens name', 'not containing emoji', maybeName);\n }\n if (name[2] === '-' && name[3] === '-') {\n throw new ArgumentError(\n 'aens name',\n 'without \"-\" char in both the third and fourth positions',\n maybeName,\n );\n }\n if (name[0] === '-') {\n throw new ArgumentError('aens name', 'starting with no \"-\" char', maybeName);\n }\n if (name.at(-1) === '-') {\n throw new ArgumentError('aens name', 'ending with no \"-\" char', maybeName);\n }\n let punycode;\n try {\n const u = new URL(`http://${name}.${suffix}`);\n if (u.username + u.password + u.port + u.search + u.hash !== '' || u.pathname !== '/') {\n throw new ArgumentError('aens name', 'valid', maybeName);\n }\n punycode = u.host;\n } catch (error) {\n if (error instanceof TypeError && error.message.includes('Invalid URL')) {\n throw new ArgumentError('aens name', 'valid', maybeName);\n }\n throw error;\n }\n if (!/^[a-z0-9.-]+$/i.test(punycode)) {\n throw new ArgumentError('aens name', 'without illegal chars', maybeName);\n }\n if (punycode.length > 63 + AENS_SUFFIX.length) {\n throw new ArgumentError('aens name', 'not too long', maybeName);\n }\n return punycode as AensName;\n}\n\n// TODO: replace `produce` with `build` the same as others\n/**\n * Encode an AENS name\n * @category AENS\n * @param name - Name to encode\n * @returns `nm_` prefixed encoded AENS name\n */\nexport function produceNameId(name: AensName): Encoded.Name {\n return encode(hash(nameToPunycode(name)), Encoding.Name);\n}\n\n// TODO: add `build` the same as others\n/**\n * Generate the commitment hash by hashing the salt and\n * name, base 58 encoding the result and prepending 'cm_'\n * @category transaction builder\n * @param name - Name to be registered\n * @param salt - Random number\n * @returns Commitment hash\n */\nexport function commitmentHash(name: AensName, salt: number = genSalt()): Encoded.Commitment {\n return encode(\n hash(\n concatBuffers([\n Buffer.from(nameToPunycode(name)),\n Buffer.from(salt.toString(16).padStart(64, '0'), 'hex'),\n ]),\n ),\n Encoding.Commitment,\n );\n}\n\n/**\n * Utility function to convert bytes to int\n * @category utils\n * @param buffer - Value\n * @returns Buffer Buffer from number(BigEndian)\n * @deprecated use `BigInt('0x' + <buffer>.toString('hex')).toString()` instead\n */\nexport function readInt(buffer: Uint8Array = Buffer.from([])): string {\n return BigInt('0x' + Buffer.from(buffer).toString('hex')).toString();\n}\n\n/**\n * Ensure that name is valid AENS name, would throw an exception otherwise\n * @category AENS\n * @param maybeName - AENS name\n */\nexport function ensureName(maybeName: string): asserts maybeName is AensName {\n nameToPunycode(maybeName);\n}\n\n/**\n * Is AENS name valid\n * @category AENS\n * @param maybeName - AENS name\n */\nexport function isName(maybeName: string): maybeName is AensName {\n try {\n ensureName(maybeName);\n return true;\n } catch (error) {\n return false;\n }\n}\n\nconst encodingToPointerKey = [\n [Encoding.AccountAddress, 'account_pubkey'],\n [Encoding.OracleAddress, 'oracle_pubkey'],\n [Encoding.ContractAddress, 'contract_pubkey'],\n [Encoding.Channel, 'channel'],\n] as const;\n\n/**\n * @category AENS\n * @param identifier - account/oracle/contract address, or channel\n * @returns default AENS pointer key\n */\nexport function getDefaultPointerKey(\n identifier: Encoded.Generic<(typeof encodingToPointerKey)[number][0]>,\n): (typeof encodingToPointerKey)[number][1] {\n decode(identifier);\n const encoding = identifier.substring(0, 2);\n const result = encodingToPointerKey.find(([e]) => e === encoding)?.[1];\n if (result != null) return result;\n throw new ArgumentError(\n 'identifier',\n `prefixed with one of ${encodingToPointerKey.map(([e]) => `${e}_`).join(', ')}`,\n identifier,\n );\n}\n\n/**\n * Get the minimum AENS name fee\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @returns the minimum fee for the AENS name auction\n */\nexport function getMinimumNameFee(name: AensName): BigNumber {\n const nameLength = nameToPunycode(name).length - AENS_SUFFIX.length;\n return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)];\n}\n\n/**\n * Compute bid fee for AENS auction\n * @category AENS\n * @param name - the AENS name to get the fee for\n * @param options - Options\n * @param options.startFee - Auction start fee\n * @param options.increment - Bid multiplier(In percentage, must be between 0 and 1)\n * @returns Bid fee\n */\nexport function computeBidFee(\n name: AensName,\n {\n startFee,\n increment = NAME_FEE_BID_INCREMENT,\n }: { startFee?: number | string | BigNumber; increment?: number } = {},\n): BigNumber {\n if (!(Number(increment) === increment && increment % 1 !== 0))\n throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`);\n if (increment < NAME_FEE_BID_INCREMENT)\n throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`);\n // FIXME: increment should be used somehow here\n return ceil(\n new BigNumber(startFee ?? getMinimumNameFee(name)).times(\n new BigNumber(NAME_FEE_BID_INCREMENT).plus(1),\n ),\n );\n}\n\n/**\n * Compute approximate auction end height.\n *\n * From Ceres, each time a new (successful!) bid is made for a name the auction is extended for up\n * to 120 key-blocks/generations. I.e. after the bid there is always at least 120 generations to\n * make a higher bid.\n *\n * @category AENS\n * @param name - Name to compute auction end for\n * @param claimHeight - Auction starting height\n * @see {@link https://github.com/aeternity/protocol/blob/cfb19ce/AENS.md#from-ceres-protocol-upgrade}\n * @returns Auction end height\n */\nexport function computeAuctionEndBlock(name: AensName, claimHeight: number): number {\n const length = nameToPunycode(name).length - AENS_SUFFIX.length;\n const h =\n (length <= 4 ? 2400 : null) ?? (length <= 8 ? 960 : null) ?? (length <= 12 ? 480 : null) ?? 0;\n return h + claimHeight;\n}\n\n/**\n * Is name accept going to auction\n * @category AENS\n */\nexport function isAuctionName(name: AensName): boolean {\n return nameToPunycode(name).length < 13 + AENS_SUFFIX.length;\n}\n"],"mappings":";AAAA,OAAOA,SAAS,MAAM,cAAc;AACpC,SAASC,OAAO,EAAEC,IAAI,QAAQ,uBAAuB;AACrD,SAASC,MAAM,EAAEC,MAAM,EAAWC,QAAQ,QAAQ,wBAAwB;AAC1E,SAASC,OAAO,QAAQ,sBAAsB;AAC9C,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAEEC,eAAe,EACfC,sBAAsB,EACtBC,mBAAmB,QACd,gBAAgB;AACvB,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,aAAa,EAAEC,kBAAkB,QAAQ,uBAAuB;;AAEzE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,KAA6B,EAC7BC,KAAyB,EACA;EACzB,MAAMC,eAAe,GAAGC,OAAA,CAAOC,IAAI,CAAC,CAAC,GAAGhB,MAAM,CAACY,KAAK,CAAC,EAAE,GAAGT,OAAO,CAACU,KAAK,CAAC,CAAC,CAAC;EAC1E,MAAMI,OAAO,GAAGlB,IAAI,CAACe,eAAe,CAAC;EACrC,OAAOb,MAAM,CAACgB,OAAO,EAAEf,QAAQ,CAACgB,eAAe,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,QA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