tempo.ts 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/README.md +33 -2
  2. package/dist/chains.d.ts +509 -115
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/chains.js +18 -9
  5. package/dist/chains.js.map +1 -1
  6. package/dist/ox/Order.d.ts +92 -0
  7. package/dist/ox/Order.d.ts.map +1 -0
  8. package/dist/ox/Order.js +88 -0
  9. package/dist/ox/Order.js.map +1 -0
  10. package/dist/ox/OrdersFilters.d.ts +72 -0
  11. package/dist/ox/OrdersFilters.d.ts.map +1 -0
  12. package/dist/ox/OrdersFilters.js +100 -0
  13. package/dist/ox/OrdersFilters.js.map +1 -0
  14. package/dist/ox/Pagination.d.ts +128 -0
  15. package/dist/ox/Pagination.d.ts.map +1 -0
  16. package/dist/ox/Pagination.js +78 -0
  17. package/dist/ox/Pagination.js.map +1 -0
  18. package/dist/ox/PoolId.d.ts +18 -0
  19. package/dist/ox/PoolId.d.ts.map +1 -0
  20. package/dist/ox/PoolId.js +13 -0
  21. package/dist/ox/PoolId.js.map +1 -0
  22. package/dist/ox/RpcSchema.d.ts +32 -0
  23. package/dist/ox/RpcSchema.d.ts.map +1 -0
  24. package/dist/ox/RpcSchema.js +2 -0
  25. package/dist/ox/RpcSchema.js.map +1 -0
  26. package/dist/ox/SignatureEnvelope.d.ts +1 -1
  27. package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
  28. package/dist/ox/SignatureEnvelope.js.map +1 -1
  29. package/dist/{viem → ox}/Tick.d.ts +4 -0
  30. package/dist/ox/Tick.d.ts.map +1 -0
  31. package/dist/ox/Tick.js.map +1 -0
  32. package/dist/ox/Transaction.d.ts.map +1 -1
  33. package/dist/ox/Transaction.js +2 -1
  34. package/dist/ox/Transaction.js.map +1 -1
  35. package/dist/ox/TransactionEnvelopeAA.d.ts +6 -6
  36. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
  37. package/dist/ox/TransactionEnvelopeAA.js +4 -2
  38. package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
  39. package/dist/ox/TransactionRequest.d.ts +4 -0
  40. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  41. package/dist/ox/TransactionRequest.js.map +1 -1
  42. package/dist/ox/index.d.ts +6 -0
  43. package/dist/ox/index.d.ts.map +1 -1
  44. package/dist/ox/index.js +6 -0
  45. package/dist/ox/index.js.map +1 -1
  46. package/dist/prool/Instance.d.ts.map +1 -1
  47. package/dist/prool/Instance.js +20 -4
  48. package/dist/prool/Instance.js.map +1 -1
  49. package/dist/viem/Abis.d.ts +1469 -1082
  50. package/dist/viem/Abis.d.ts.map +1 -1
  51. package/dist/viem/Abis.js +932 -671
  52. package/dist/viem/Abis.js.map +1 -1
  53. package/dist/viem/Account.d.ts +150 -0
  54. package/dist/viem/Account.d.ts.map +1 -0
  55. package/dist/viem/Account.js +221 -0
  56. package/dist/viem/Account.js.map +1 -0
  57. package/dist/viem/Actions/amm.d.ts +80 -118
  58. package/dist/viem/Actions/amm.d.ts.map +1 -1
  59. package/dist/viem/Actions/amm.js +47 -116
  60. package/dist/viem/Actions/amm.js.map +1 -1
  61. package/dist/viem/Actions/dex.d.ts +889 -633
  62. package/dist/viem/Actions/dex.d.ts.map +1 -1
  63. package/dist/viem/Actions/dex.js +99 -0
  64. package/dist/viem/Actions/dex.js.map +1 -1
  65. package/dist/viem/Actions/fee.d.ts +3 -17
  66. package/dist/viem/Actions/fee.d.ts.map +1 -1
  67. package/dist/viem/Actions/fee.js.map +1 -1
  68. package/dist/viem/Actions/index.d.ts +1 -0
  69. package/dist/viem/Actions/index.d.ts.map +1 -1
  70. package/dist/viem/Actions/index.js +1 -0
  71. package/dist/viem/Actions/index.js.map +1 -1
  72. package/dist/viem/Actions/reward.d.ts +3236 -0
  73. package/dist/viem/Actions/reward.d.ts.map +1 -0
  74. package/dist/viem/Actions/reward.js +725 -0
  75. package/dist/viem/Actions/reward.js.map +1 -0
  76. package/dist/viem/Actions/token.d.ts +4295 -2646
  77. package/dist/viem/Actions/token.d.ts.map +1 -1
  78. package/dist/viem/Actions/token.js +214 -335
  79. package/dist/viem/Actions/token.js.map +1 -1
  80. package/dist/viem/Addresses.d.ts +1 -2
  81. package/dist/viem/Addresses.d.ts.map +1 -1
  82. package/dist/viem/Addresses.js +1 -2
  83. package/dist/viem/Addresses.js.map +1 -1
  84. package/dist/viem/Chain.d.ts +38 -12
  85. package/dist/viem/Chain.d.ts.map +1 -1
  86. package/dist/viem/Chain.js +27 -18
  87. package/dist/viem/Chain.js.map +1 -1
  88. package/dist/viem/Decorator.d.ts +959 -405
  89. package/dist/viem/Decorator.d.ts.map +1 -1
  90. package/dist/viem/Decorator.js +13 -5
  91. package/dist/viem/Decorator.js.map +1 -1
  92. package/dist/viem/Formatters.d.ts +8 -1
  93. package/dist/viem/Formatters.d.ts.map +1 -1
  94. package/dist/viem/Formatters.js +17 -0
  95. package/dist/viem/Formatters.js.map +1 -1
  96. package/dist/viem/P256.d.ts +2 -0
  97. package/dist/viem/P256.d.ts.map +1 -0
  98. package/dist/viem/P256.js +2 -0
  99. package/dist/viem/P256.js.map +1 -0
  100. package/dist/viem/Secp256k1.d.ts +2 -0
  101. package/dist/viem/Secp256k1.d.ts.map +1 -0
  102. package/dist/viem/Secp256k1.js +2 -0
  103. package/dist/viem/Secp256k1.js.map +1 -0
  104. package/dist/viem/TokenIds.d.ts +1 -2
  105. package/dist/viem/TokenIds.d.ts.map +1 -1
  106. package/dist/viem/TokenIds.js +1 -2
  107. package/dist/viem/TokenIds.js.map +1 -1
  108. package/dist/viem/Transaction.d.ts +1 -1
  109. package/dist/viem/Transaction.d.ts.map +1 -1
  110. package/dist/viem/Transaction.js +46 -5
  111. package/dist/viem/Transaction.js.map +1 -1
  112. package/dist/viem/WebAuthnP256.d.ts +79 -0
  113. package/dist/viem/WebAuthnP256.d.ts.map +1 -0
  114. package/dist/viem/WebAuthnP256.js +95 -0
  115. package/dist/viem/WebAuthnP256.js.map +1 -0
  116. package/dist/viem/WebCryptoP256.d.ts +2 -0
  117. package/dist/viem/WebCryptoP256.d.ts.map +1 -0
  118. package/dist/viem/WebCryptoP256.js +2 -0
  119. package/dist/viem/WebCryptoP256.js.map +1 -0
  120. package/dist/viem/index.d.ts +6 -3
  121. package/dist/viem/index.d.ts.map +1 -1
  122. package/dist/viem/index.js +6 -3
  123. package/dist/viem/index.js.map +1 -1
  124. package/dist/viem/internal/account.d.ts +24 -0
  125. package/dist/viem/internal/account.d.ts.map +1 -0
  126. package/dist/viem/internal/account.js +68 -0
  127. package/dist/viem/internal/account.js.map +1 -0
  128. package/dist/viem/internal/types.d.ts +10 -0
  129. package/dist/viem/internal/types.d.ts.map +1 -1
  130. package/dist/wagmi/Actions/amm.d.ts +428 -0
  131. package/dist/wagmi/Actions/amm.d.ts.map +1 -0
  132. package/dist/wagmi/Actions/amm.js +472 -0
  133. package/dist/wagmi/Actions/amm.js.map +1 -0
  134. package/dist/wagmi/Actions/dex.d.ts +908 -0
  135. package/dist/wagmi/Actions/dex.d.ts.map +1 -0
  136. package/dist/wagmi/Actions/dex.js +1023 -0
  137. package/dist/wagmi/Actions/dex.js.map +1 -0
  138. package/dist/wagmi/Actions/fee.d.ts +111 -0
  139. package/dist/wagmi/Actions/fee.d.ts.map +1 -0
  140. package/dist/wagmi/Actions/fee.js +126 -0
  141. package/dist/wagmi/Actions/fee.js.map +1 -0
  142. package/dist/wagmi/Actions/index.d.ts +6 -0
  143. package/dist/wagmi/Actions/index.d.ts.map +1 -0
  144. package/dist/wagmi/Actions/index.js +6 -0
  145. package/dist/wagmi/Actions/index.js.map +1 -0
  146. package/dist/wagmi/Actions/reward.d.ts +348 -0
  147. package/dist/wagmi/Actions/reward.d.ts.map +1 -0
  148. package/dist/wagmi/Actions/reward.js +388 -0
  149. package/dist/wagmi/Actions/reward.js.map +1 -0
  150. package/dist/wagmi/Actions/token.d.ts +1546 -0
  151. package/dist/wagmi/Actions/token.d.ts.map +1 -0
  152. package/dist/wagmi/Actions/token.js +1712 -0
  153. package/dist/wagmi/Actions/token.js.map +1 -0
  154. package/dist/wagmi/Connector.d.ts +73 -0
  155. package/dist/wagmi/Connector.d.ts.map +1 -0
  156. package/dist/wagmi/Connector.js +249 -0
  157. package/dist/wagmi/Connector.js.map +1 -0
  158. package/dist/wagmi/Hooks/amm.d.ts +421 -0
  159. package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
  160. package/dist/wagmi/Hooks/amm.js +504 -0
  161. package/dist/wagmi/Hooks/amm.js.map +1 -0
  162. package/dist/wagmi/Hooks/dex.d.ts +816 -0
  163. package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
  164. package/dist/wagmi/Hooks/dex.js +973 -0
  165. package/dist/wagmi/Hooks/dex.js.map +1 -0
  166. package/dist/wagmi/Hooks/fee.d.ts +97 -0
  167. package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
  168. package/dist/wagmi/Hooks/fee.js +109 -0
  169. package/dist/wagmi/Hooks/fee.js.map +1 -0
  170. package/dist/wagmi/Hooks/index.d.ts +6 -0
  171. package/dist/wagmi/Hooks/index.d.ts.map +1 -0
  172. package/dist/wagmi/Hooks/index.js +6 -0
  173. package/dist/wagmi/Hooks/index.js.map +1 -0
  174. package/dist/wagmi/Hooks/reward.d.ts +307 -0
  175. package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
  176. package/dist/wagmi/Hooks/reward.js +349 -0
  177. package/dist/wagmi/Hooks/reward.js.map +1 -0
  178. package/dist/wagmi/Hooks/token.d.ts +1388 -0
  179. package/dist/wagmi/Hooks/token.d.ts.map +1 -0
  180. package/dist/wagmi/Hooks/token.js +1657 -0
  181. package/dist/wagmi/Hooks/token.js.map +1 -0
  182. package/dist/wagmi/index.d.ts +4 -0
  183. package/dist/wagmi/index.d.ts.map +1 -0
  184. package/dist/wagmi/index.js +4 -0
  185. package/dist/wagmi/index.js.map +1 -0
  186. package/package.json +54 -10
  187. package/src/chains.ts +19 -9
  188. package/src/ox/Order.test.ts +78 -0
  189. package/src/ox/Order.ts +125 -0
  190. package/src/ox/OrdersFilters.test.ts +182 -0
  191. package/src/ox/OrdersFilters.ts +125 -0
  192. package/src/ox/Pagination.test.ts +162 -0
  193. package/src/ox/Pagination.ts +164 -0
  194. package/src/ox/PoolId.test.ts +33 -0
  195. package/src/ox/PoolId.ts +27 -0
  196. package/src/ox/RpcSchema.ts +35 -0
  197. package/src/ox/SignatureEnvelope.ts +3 -1
  198. package/src/{viem → ox}/Tick.test.ts +1 -1
  199. package/src/{viem → ox}/Tick.ts +5 -0
  200. package/src/ox/Transaction.test.ts +1 -1
  201. package/src/ox/Transaction.ts +2 -1
  202. package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
  203. package/src/ox/TransactionEnvelopeAA.ts +9 -7
  204. package/src/ox/TransactionRequest.ts +4 -0
  205. package/src/ox/index.ts +6 -0
  206. package/src/prool/Instance.ts +51 -37
  207. package/src/prool/internal/chain.json +104 -52
  208. package/src/tsconfig.json +9 -0
  209. package/src/viem/Abis.ts +972 -710
  210. package/src/viem/Account.ts +279 -0
  211. package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
  212. package/src/viem/Actions/amm.test.ts +98 -169
  213. package/src/viem/Actions/amm.ts +68 -155
  214. package/src/viem/Actions/dex.test.ts +563 -484
  215. package/src/viem/Actions/dex.ts +173 -0
  216. package/src/viem/Actions/fee.test.ts +23 -34
  217. package/src/viem/Actions/fee.ts +7 -0
  218. package/src/viem/Actions/index.ts +1 -0
  219. package/src/viem/Actions/policy.test.ts +19 -33
  220. package/src/viem/Actions/reward.test.ts +457 -0
  221. package/src/viem/Actions/reward.ts +999 -0
  222. package/src/viem/Actions/token.test.ts +453 -287
  223. package/src/viem/Actions/token.ts +452 -540
  224. package/src/viem/Addresses.ts +1 -2
  225. package/src/viem/Chain.ts +70 -20
  226. package/src/viem/Decorator.test.ts +2 -1
  227. package/src/viem/Decorator.ts +996 -421
  228. package/src/viem/Formatters.ts +31 -5
  229. package/src/viem/P256.ts +1 -0
  230. package/src/viem/Secp256k1.ts +1 -0
  231. package/src/viem/TokenIds.ts +1 -2
  232. package/src/viem/Transaction.ts +53 -7
  233. package/src/viem/WebAuthnP256.ts +140 -0
  234. package/src/viem/WebCryptoP256.ts +1 -0
  235. package/src/viem/e2e.test.ts +1126 -297
  236. package/src/viem/index.ts +6 -3
  237. package/src/viem/internal/account.ts +107 -0
  238. package/src/viem/internal/types.ts +9 -0
  239. package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
  240. package/src/wagmi/Actions/amm.test.ts +198 -0
  241. package/src/wagmi/Actions/amm.ts +691 -0
  242. package/src/wagmi/Actions/dex.test.ts +1507 -0
  243. package/src/wagmi/Actions/dex.ts +1640 -0
  244. package/src/wagmi/Actions/fee.test.ts +63 -0
  245. package/src/wagmi/Actions/fee.ts +208 -0
  246. package/src/wagmi/Actions/index.ts +5 -0
  247. package/src/wagmi/Actions/reward.test.ts +210 -0
  248. package/src/wagmi/Actions/reward.ts +632 -0
  249. package/src/wagmi/Actions/token.test.ts +1308 -0
  250. package/src/wagmi/Actions/token.ts +2613 -0
  251. package/src/wagmi/Connector.test.ts +53 -0
  252. package/src/wagmi/Connector.ts +367 -0
  253. package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
  254. package/src/wagmi/Hooks/amm.test.ts +424 -0
  255. package/src/wagmi/Hooks/amm.ts +806 -0
  256. package/src/wagmi/Hooks/dex.test.ts +1017 -0
  257. package/src/wagmi/Hooks/dex.ts +1685 -0
  258. package/src/wagmi/Hooks/fee.test.ts +166 -0
  259. package/src/wagmi/Hooks/fee.ts +206 -0
  260. package/src/wagmi/Hooks/index.ts +5 -0
  261. package/src/wagmi/Hooks/reward.test.ts +219 -0
  262. package/src/wagmi/Hooks/reward.ts +672 -0
  263. package/src/wagmi/Hooks/token.test.ts +1670 -0
  264. package/src/wagmi/Hooks/token.ts +2906 -0
  265. package/src/wagmi/index.ts +3 -0
  266. package/src/wagmi/internal/types.ts +16 -0
  267. package/dist/viem/Client.d.ts +0 -27
  268. package/dist/viem/Client.d.ts.map +0 -1
  269. package/dist/viem/Client.js +0 -28
  270. package/dist/viem/Client.js.map +0 -1
  271. package/dist/viem/Tick.d.ts.map +0 -1
  272. package/dist/viem/Tick.js.map +0 -1
  273. package/src/viem/Client.bench-d.ts +0 -8
  274. package/src/viem/Client.test.ts +0 -178
  275. package/src/viem/Client.ts +0 -91
  276. /package/dist/{viem → ox}/Tick.js +0 -0
@@ -1,5 +1,4 @@
1
1
  import * as Hex from 'ox/Hex';
2
- import * as Signature from 'ox/Signature';
3
2
  import { encodeFunctionData, parseEventLogs, } from 'viem';
4
3
  import { parseAccount } from 'viem/accounts';
5
4
  import { multicall, readContract, sendTransaction, sendTransactionSync, watchContractEvent, writeContract, writeContractSync, } from 'viem/actions';
@@ -35,7 +34,7 @@ import { defineCall } from '../internal/utils.js';
35
34
  * @returns The transaction hash.
36
35
  */
37
36
  export async function approve(client, parameters) {
38
- const { token = Addresses.defaultFeeToken, ...rest } = parameters;
37
+ const { token, ...rest } = parameters;
39
38
  return approve.inner(writeContract, client, parameters, { ...rest, token });
40
39
  }
41
40
  (function (approve) {
@@ -82,7 +81,7 @@ export async function approve(client, parameters) {
82
81
  * @returns The call.
83
82
  */
84
83
  function call(args) {
85
- const { spender, amount, token = Addresses.defaultFeeToken } = args;
84
+ const { spender, amount, token } = args;
86
85
  return defineCall({
87
86
  address: TokenId.toAddress(token),
88
87
  abi: Abis.tip20,
@@ -130,11 +129,8 @@ export async function approve(client, parameters) {
130
129
  * @returns The transaction receipt and event data.
131
130
  */
132
131
  export async function approveSync(client, parameters) {
133
- const { throwOnReceiptRevert = true, token = Addresses.defaultFeeToken, ...rest } = parameters;
134
- const receipt = await approve.inner(writeContractSync, client, { ...parameters, throwOnReceiptRevert }, {
135
- ...rest,
136
- token,
137
- });
132
+ const { throwOnReceiptRevert = true, ...rest } = parameters;
133
+ const receipt = await approve.inner(writeContractSync, client, { ...parameters, throwOnReceiptRevert }, rest);
138
134
  const { args } = approve.extractEvent(receipt.logs);
139
135
  return {
140
136
  ...args,
@@ -647,7 +643,7 @@ export async function create(client, parameters) {
647
643
  * @returns The call.
648
644
  */
649
645
  function call(args) {
650
- const { name, symbol, currency, quoteToken = Addresses.defaultQuoteToken, admin, } = args;
646
+ const { name, symbol, currency, quoteToken = Addresses.linkingUsd, admin, } = args;
651
647
  return defineCall({
652
648
  address: Addresses.tip20Factory,
653
649
  abi: Abis.tip20Factory,
@@ -714,137 +710,6 @@ export async function createSync(client, parameters) {
714
710
  receipt,
715
711
  };
716
712
  }
717
- /**
718
- * Finalizes the quote token update for a TIP20 token.
719
- *
720
- * @example
721
- * ```ts
722
- * import { createClient, http } from 'viem'
723
- * import { tempo } from 'tempo.ts/chains'
724
- * import * as actions from 'tempo.ts/viem/actions'
725
- * import { privateKeyToAccount } from 'viem/accounts'
726
- *
727
- * const client = createClient({
728
- * account: privateKeyToAccount('0x...'),
729
- * chain: tempo,
730
- * transport: http(),
731
- * })
732
- *
733
- * const result = await actions.token.finalizeUpdateQuoteToken(client, {
734
- * token: '0x...',
735
- * })
736
- * ```
737
- *
738
- * @param client - Client.
739
- * @param parameters - Parameters.
740
- * @returns The transaction hash.
741
- */
742
- export async function finalizeUpdateQuoteToken(client, parameters) {
743
- return finalizeUpdateQuoteToken.inner(writeContract, client, parameters);
744
- }
745
- (function (finalizeUpdateQuoteToken) {
746
- /** @internal */
747
- async function inner(action, client, parameters) {
748
- const { token, ...rest } = parameters;
749
- const call = finalizeUpdateQuoteToken.call({ token });
750
- return (await action(client, {
751
- ...rest,
752
- ...call,
753
- }));
754
- }
755
- finalizeUpdateQuoteToken.inner = inner;
756
- /**
757
- * Defines a call to the `finalizeQuoteTokenUpdate` function.
758
- *
759
- * Can be passed as a parameter to:
760
- * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
761
- * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
762
- * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
763
- *
764
- * @example
765
- * ```ts
766
- * import { createClient, http, walletActions } from 'viem'
767
- * import { tempo } from 'tempo.ts/chains'
768
- * import * as actions from 'tempo.ts/viem/actions'
769
- *
770
- * const client = createClient({
771
- * chain: tempo,
772
- * transport: http(),
773
- * }).extend(walletActions)
774
- *
775
- * const { result } = await client.sendCalls({
776
- * calls: [
777
- * actions.token.finalizeUpdateQuoteToken.call({
778
- * token: '0x20c0...babe',
779
- * }),
780
- * ]
781
- * })
782
- * ```
783
- *
784
- * @param args - Arguments.
785
- * @returns The call.
786
- */
787
- function call(args) {
788
- const { token } = args;
789
- return defineCall({
790
- address: TokenId.toAddress(token),
791
- abi: Abis.tip20,
792
- functionName: 'finalizeQuoteTokenUpdate',
793
- args: [],
794
- });
795
- }
796
- finalizeUpdateQuoteToken.call = call;
797
- /**
798
- * Extracts the event from the logs.
799
- *
800
- * @param logs - Logs.
801
- * @returns The event.
802
- */
803
- function extractEvent(logs) {
804
- const [log] = parseEventLogs({
805
- abi: Abis.tip20,
806
- logs,
807
- eventName: 'QuoteTokenUpdateFinalized',
808
- });
809
- if (!log)
810
- throw new Error('`QuoteTokenUpdateFinalized` event not found.');
811
- return log;
812
- }
813
- finalizeUpdateQuoteToken.extractEvent = extractEvent;
814
- })(finalizeUpdateQuoteToken || (finalizeUpdateQuoteToken = {}));
815
- /**
816
- * Finalizes the quote token update for a TIP20 token.
817
- *
818
- * @example
819
- * ```ts
820
- * import { createClient, http } from 'viem'
821
- * import { tempo } from 'tempo.ts/chains'
822
- * import * as actions from 'tempo.ts/viem/actions'
823
- * import { privateKeyToAccount } from 'viem/accounts'
824
- *
825
- * const client = createClient({
826
- * account: privateKeyToAccount('0x...'),
827
- * chain: tempo,
828
- * transport: http(),
829
- * })
830
- *
831
- * const result = await actions.token.finalizeUpdateQuoteTokenSync(client, {
832
- * token: '0x...',
833
- * })
834
- * ```
835
- *
836
- * @param client - Client.
837
- * @param parameters - Parameters.
838
- * @returns The transaction receipt and event data.
839
- */
840
- export async function finalizeUpdateQuoteTokenSync(client, parameters) {
841
- const receipt = await finalizeUpdateQuoteToken.inner(writeContractSync, client, parameters);
842
- const { args } = finalizeUpdateQuoteToken.extractEvent(receipt.logs);
843
- return {
844
- ...args,
845
- receipt,
846
- };
847
- }
848
713
  /**
849
714
  * Gets TIP20 token allowance.
850
715
  *
@@ -888,7 +753,7 @@ export async function getAllowance(client, parameters) {
888
753
  * @returns The call.
889
754
  */
890
755
  function call(args) {
891
- const { account, spender, token = Addresses.defaultFeeToken } = args;
756
+ const { account, spender, token } = args;
892
757
  return defineCall({
893
758
  address: TokenId.toAddress(token),
894
759
  abi: Abis.tip20,
@@ -923,8 +788,8 @@ export async function getAllowance(client, parameters) {
923
788
  * @param parameters - Parameters.
924
789
  * @returns The token balance.
925
790
  */
926
- export async function getBalance(client, ...parameters) {
927
- const { account = client.account, ...rest } = parameters[0] ?? {};
791
+ export async function getBalance(client, parameters) {
792
+ const { account = client.account, ...rest } = parameters;
928
793
  const address = account ? parseAccount(account).address : undefined;
929
794
  if (!address)
930
795
  throw new Error('account is required.');
@@ -941,7 +806,7 @@ export async function getBalance(client, ...parameters) {
941
806
  * @returns The call.
942
807
  */
943
808
  function call(args) {
944
- const { account, token = Addresses.defaultFeeToken } = args;
809
+ const { account, token } = args;
945
810
  return defineCall({
946
811
  address: TokenId.toAddress(token),
947
812
  abi: Abis.tip20,
@@ -976,11 +841,11 @@ export async function getBalance(client, ...parameters) {
976
841
  * @param parameters - Parameters.
977
842
  * @returns The token metadata.
978
843
  */
979
- export async function getMetadata(client, parameters = {}) {
980
- const { token = Addresses.defaultFeeToken, ...rest } = parameters;
844
+ export async function getMetadata(client, parameters) {
845
+ const { token, ...rest } = parameters;
981
846
  const address = TokenId.toAddress(token);
982
847
  const abi = Abis.tip20;
983
- if (TokenId.from(token) === TokenId.fromAddress(Addresses.defaultQuoteToken))
848
+ if (TokenId.from(token) === TokenId.fromAddress(Addresses.linkingUsd))
984
849
  return multicall(client, {
985
850
  ...rest,
986
851
  contracts: [
@@ -1082,6 +947,54 @@ export async function getMetadata(client, parameters = {}) {
1082
947
  transferPolicyId,
1083
948
  }));
1084
949
  }
950
+ /**
951
+ * Gets the admin role for a specific role in a TIP20 token.
952
+ *
953
+ * @example
954
+ * ```ts
955
+ * import { createClient, http } from 'viem'
956
+ * import { tempo } from 'tempo.ts/chains'
957
+ * import * as actions from 'tempo.ts/viem/actions'
958
+ *
959
+ * const client = createClient({
960
+ * chain: tempo,
961
+ * transport: http(),
962
+ * })
963
+ *
964
+ * const adminRole = await actions.token.getRoleAdmin(client, {
965
+ * role: 'minter',
966
+ * token: '0x...',
967
+ * })
968
+ * ```
969
+ *
970
+ * @param client - Client.
971
+ * @param parameters - Parameters.
972
+ * @returns The admin role hash.
973
+ */
974
+ export async function getRoleAdmin(client, parameters) {
975
+ return readContract(client, {
976
+ ...parameters,
977
+ ...getRoleAdmin.call(parameters),
978
+ });
979
+ }
980
+ (function (getRoleAdmin) {
981
+ /**
982
+ * Defines a call to the `getRoleAdmin` function.
983
+ *
984
+ * @param args - Arguments.
985
+ * @returns The call.
986
+ */
987
+ function call(args) {
988
+ const { role, token } = args;
989
+ return defineCall({
990
+ address: TokenId.toAddress(token),
991
+ abi: Abis.tip20,
992
+ functionName: 'getRoleAdmin',
993
+ args: [TokenRole.serialize(role)],
994
+ });
995
+ }
996
+ getRoleAdmin.call = call;
997
+ })(getRoleAdmin || (getRoleAdmin = {}));
1085
998
  /**
1086
999
  * Checks if an account has a specific role for a TIP20 token.
1087
1000
  *
@@ -1565,171 +1478,6 @@ export async function pauseSync(client, parameters) {
1565
1478
  receipt,
1566
1479
  };
1567
1480
  }
1568
- /**
1569
- * Approves a spender using a signed permit.
1570
- *
1571
- * @example
1572
- * ```ts
1573
- * import { createClient, http } from 'viem'
1574
- * import { tempo } from 'tempo.ts/chains'
1575
- * import * as actions from 'tempo.ts/viem/actions'
1576
- * import { privateKeyToAccount } from 'viem/accounts'
1577
- *
1578
- * const client = createClient({
1579
- * account: privateKeyToAccount('0x...'),
1580
- * chain: tempo,
1581
- * transport: http(),
1582
- * })
1583
- *
1584
- * const result = await actions.token.permit(client, {
1585
- * owner: '0x...',
1586
- * spender: '0x...',
1587
- * value: 100n,
1588
- * deadline: 1234567890n,
1589
- * signature: { r: 0n, s: 0n, yParity: 0 },
1590
- * })
1591
- * ```
1592
- *
1593
- * @param client - Client.
1594
- * @param parameters - Parameters.
1595
- * @returns The transaction hash.
1596
- */
1597
- export async function permit(client, parameters) {
1598
- return permit.inner(writeContract, client, parameters);
1599
- }
1600
- (function (permit) {
1601
- /** @internal */
1602
- async function inner(action, client, parameters) {
1603
- const { owner, spender, value, deadline, signature, token, ...rest } = parameters;
1604
- const call = permit.call({
1605
- owner,
1606
- spender,
1607
- value,
1608
- deadline,
1609
- signature,
1610
- token,
1611
- });
1612
- return (await action(client, {
1613
- ...rest,
1614
- ...call,
1615
- }));
1616
- }
1617
- permit.inner = inner;
1618
- /**
1619
- * Defines a call to the `permit` function.
1620
- *
1621
- * Can be passed as a parameter to:
1622
- * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
1623
- * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
1624
- * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
1625
- *
1626
- * @example
1627
- * ```ts
1628
- * import { createClient, http, walletActions } from 'viem'
1629
- * import { tempo } from 'tempo.ts/chains'
1630
- * import * as actions from 'tempo.ts/viem/actions'
1631
- *
1632
- * const client = createClient({
1633
- * chain: tempo,
1634
- * transport: http(),
1635
- * }).extend(walletActions)
1636
- *
1637
- * const { result } = await client.sendCalls({
1638
- * calls: [
1639
- * actions.token.permit.call({
1640
- * owner: '0x20c0...beef',
1641
- * spender: '0x20c0...babe',
1642
- * value: 100n,
1643
- * deadline: 1234567890n,
1644
- * signature: { r: 0n, s: 0n, yParity: 0 },
1645
- * token: '0x20c0...cafe',
1646
- * }),
1647
- * ]
1648
- * })
1649
- * ```
1650
- *
1651
- * @param args - Arguments.
1652
- * @returns The call.
1653
- */
1654
- function call(args) {
1655
- const { owner, spender, value, deadline, signature, token = Addresses.defaultFeeToken, } = args;
1656
- const { r, s, yParity } = Signature.from(signature);
1657
- const v = Signature.yParityToV(yParity);
1658
- return defineCall({
1659
- address: TokenId.toAddress(token),
1660
- abi: Abis.tip20,
1661
- functionName: 'permit',
1662
- args: [
1663
- owner,
1664
- spender,
1665
- value,
1666
- deadline,
1667
- v,
1668
- Hex.trimLeft(Hex.fromNumber(r)),
1669
- Hex.trimLeft(Hex.fromNumber(s)),
1670
- ],
1671
- });
1672
- }
1673
- permit.call = call;
1674
- /**
1675
- * Extracts the event from the logs.
1676
- *
1677
- * @param logs - Logs.
1678
- * @returns The event.
1679
- */
1680
- function extractEvent(logs) {
1681
- const [log] = parseEventLogs({
1682
- abi: Abis.tip20,
1683
- logs,
1684
- eventName: 'Approval',
1685
- });
1686
- if (!log)
1687
- throw new Error('`Approval` event not found.');
1688
- return log;
1689
- }
1690
- permit.extractEvent = extractEvent;
1691
- })(permit || (permit = {}));
1692
- /**
1693
- * Approves a spender using a signed permit.
1694
- *
1695
- * @example
1696
- * ```ts
1697
- * import { createClient, http } from 'viem'
1698
- * import { tempo } from 'tempo.ts/chains'
1699
- * import * as actions from 'tempo.ts/viem/actions'
1700
- * import { privateKeyToAccount } from 'viem/accounts'
1701
- *
1702
- * const client = createClient({
1703
- * account: privateKeyToAccount('0x...'),
1704
- * chain: tempo,
1705
- * transport: http(),
1706
- * })
1707
- *
1708
- * const result = await actions.token.permitSync(client, {
1709
- * owner: '0x...',
1710
- * spender: '0x...',
1711
- * value: 100n,
1712
- * deadline: 1234567890n,
1713
- * signature: { r: 0n, s: 0n, yParity: 0 },
1714
- * })
1715
- * ```
1716
- *
1717
- * @param client - Client.
1718
- * @param parameters - Parameters.
1719
- * @returns The transaction receipt and event data.
1720
- */
1721
- export async function permitSync(client, parameters) {
1722
- const { throwOnReceiptRevert = true, ...rest } = parameters;
1723
- const receipt = await permit.inner(writeContractSync, client, {
1724
- ...rest,
1725
- throwOnReceiptRevert,
1726
- });
1727
- const { args } = permit.extractEvent(receipt.logs);
1728
- return {
1729
- ...args,
1730
- receipt,
1731
- };
1732
- }
1733
1481
  /**
1734
1482
  * Renounces a role for a TIP20 token.
1735
1483
  *
@@ -2376,7 +2124,7 @@ export async function transfer(client, parameters) {
2376
2124
  * @returns The call.
2377
2125
  */
2378
2126
  function call(args) {
2379
- const { amount, from, memo, token = Addresses.defaultFeeToken, to } = args;
2127
+ const { amount, from, memo, token, to } = args;
2380
2128
  const callArgs = (() => {
2381
2129
  if (memo && from)
2382
2130
  return {
@@ -2612,7 +2360,7 @@ export async function unpauseSync(client, parameters) {
2612
2360
  * transport: http(),
2613
2361
  * })
2614
2362
  *
2615
- * const result = await actions.token.updateQuoteToken(client, {
2363
+ * const result = await actions.token.prepareUpdateQuoteToken(client, {
2616
2364
  * token: '0x...',
2617
2365
  * quoteToken: '0x...',
2618
2366
  * })
@@ -2622,14 +2370,147 @@ export async function unpauseSync(client, parameters) {
2622
2370
  * @param parameters - Parameters.
2623
2371
  * @returns The transaction hash.
2624
2372
  */
2373
+ export async function prepareUpdateQuoteToken(client, parameters) {
2374
+ return prepareUpdateQuoteToken.inner(writeContract, client, parameters);
2375
+ }
2376
+ (function (prepareUpdateQuoteToken) {
2377
+ /** @internal */
2378
+ async function inner(action, client, parameters) {
2379
+ const { quoteToken, token, ...rest } = parameters;
2380
+ const call = prepareUpdateQuoteToken.call({ quoteToken, token });
2381
+ return (await action(client, {
2382
+ ...rest,
2383
+ ...call,
2384
+ }));
2385
+ }
2386
+ prepareUpdateQuoteToken.inner = inner;
2387
+ /**
2388
+ * Defines a call to the `prepareUpdateQuoteToken` function.
2389
+ *
2390
+ * Can be passed as a parameter to:
2391
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
2392
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
2393
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
2394
+ *
2395
+ * @example
2396
+ * ```ts
2397
+ * import { createClient, http, walletActions } from 'viem'
2398
+ * import { tempo } from 'tempo.ts/chains'
2399
+ * import * as actions from 'tempo.ts/viem/actions'
2400
+ *
2401
+ * const client = createClient({
2402
+ * chain: tempo,
2403
+ * transport: http(),
2404
+ * }).extend(walletActions)
2405
+ *
2406
+ * const { result } = await client.sendCalls({
2407
+ * calls: [
2408
+ * actions.token.prepareUpdateQuoteToken.call({
2409
+ * token: '0x20c0...babe',
2410
+ * quoteToken: '0x20c0...cafe',
2411
+ * }),
2412
+ * ]
2413
+ * })
2414
+ * ```
2415
+ *
2416
+ * @param args - Arguments.
2417
+ * @returns The call.
2418
+ */
2419
+ function call(args) {
2420
+ const { token, quoteToken } = args;
2421
+ return defineCall({
2422
+ address: TokenId.toAddress(token),
2423
+ abi: Abis.tip20,
2424
+ functionName: 'setNextQuoteToken',
2425
+ args: [TokenId.toAddress(quoteToken)],
2426
+ });
2427
+ }
2428
+ prepareUpdateQuoteToken.call = call;
2429
+ /**
2430
+ * Extracts the event from the logs.
2431
+ *
2432
+ * @param logs - Logs.
2433
+ * @returns The event.
2434
+ */
2435
+ function extractEvent(logs) {
2436
+ const [log] = parseEventLogs({
2437
+ abi: Abis.tip20,
2438
+ logs,
2439
+ eventName: 'NextQuoteTokenSet',
2440
+ });
2441
+ if (!log)
2442
+ throw new Error('`NextQuoteTokenSet` event not found.');
2443
+ return log;
2444
+ }
2445
+ prepareUpdateQuoteToken.extractEvent = extractEvent;
2446
+ })(prepareUpdateQuoteToken || (prepareUpdateQuoteToken = {}));
2447
+ /**
2448
+ * Updates the quote token for a TIP20 token.
2449
+ *
2450
+ * @example
2451
+ * ```ts
2452
+ * import { createClient, http } from 'viem'
2453
+ * import { tempo } from 'tempo.ts/chains'
2454
+ * import * as actions from 'tempo.ts/viem/actions'
2455
+ * import { privateKeyToAccount } from 'viem/accounts'
2456
+ *
2457
+ * const client = createClient({
2458
+ * account: privateKeyToAccount('0x...'),
2459
+ * chain: tempo,
2460
+ * transport: http(),
2461
+ * })
2462
+ *
2463
+ * const result = await actions.token.prepareUpdateQuoteTokenSync(client, {
2464
+ * token: '0x...',
2465
+ * quoteToken: '0x...',
2466
+ * })
2467
+ * ```
2468
+ *
2469
+ * @param client - Client.
2470
+ * @param parameters - Parameters.
2471
+ * @returns The transaction receipt and event data.
2472
+ */
2473
+ export async function prepareUpdateQuoteTokenSync(client, parameters) {
2474
+ const receipt = await prepareUpdateQuoteToken.inner(writeContractSync, client, parameters);
2475
+ const { args } = prepareUpdateQuoteToken.extractEvent(receipt.logs);
2476
+ return {
2477
+ ...args,
2478
+ receipt,
2479
+ };
2480
+ }
2481
+ /**
2482
+ * Updates the quote token for a TIP20 token.
2483
+ *
2484
+ * @example
2485
+ * ```ts
2486
+ * import { createClient, http } from 'viem'
2487
+ * import { tempo } from 'tempo.ts/chains'
2488
+ * import * as actions from 'tempo.ts/viem/actions'
2489
+ * import { privateKeyToAccount } from 'viem/accounts'
2490
+ *
2491
+ * const client = createClient({
2492
+ * account: privateKeyToAccount('0x...'),
2493
+ * chain: tempo,
2494
+ * transport: http(),
2495
+ * })
2496
+ *
2497
+ * const result = await actions.token.updateQuoteToken(client, {
2498
+ * token: '0x...',
2499
+ * })
2500
+ * ```
2501
+ *
2502
+ * @param client - Client.
2503
+ * @param parameters - Parameters.
2504
+ * @returns The transaction hash.
2505
+ */
2625
2506
  export async function updateQuoteToken(client, parameters) {
2626
2507
  return updateQuoteToken.inner(writeContract, client, parameters);
2627
2508
  }
2628
2509
  (function (updateQuoteToken) {
2629
2510
  /** @internal */
2630
2511
  async function inner(action, client, parameters) {
2631
- const { quoteToken, token, ...rest } = parameters;
2632
- const call = updateQuoteToken.call({ quoteToken, token });
2512
+ const { token, ...rest } = parameters;
2513
+ const call = updateQuoteToken.call({ token });
2633
2514
  return (await action(client, {
2634
2515
  ...rest,
2635
2516
  ...call,
@@ -2659,7 +2540,6 @@ export async function updateQuoteToken(client, parameters) {
2659
2540
  * calls: [
2660
2541
  * actions.token.updateQuoteToken.call({
2661
2542
  * token: '0x20c0...babe',
2662
- * quoteToken: '0x20c0...cafe',
2663
2543
  * }),
2664
2544
  * ]
2665
2545
  * })
@@ -2669,12 +2549,12 @@ export async function updateQuoteToken(client, parameters) {
2669
2549
  * @returns The call.
2670
2550
  */
2671
2551
  function call(args) {
2672
- const { token, quoteToken } = args;
2552
+ const { token } = args;
2673
2553
  return defineCall({
2674
2554
  address: TokenId.toAddress(token),
2675
2555
  abi: Abis.tip20,
2676
- functionName: 'updateQuoteToken',
2677
- args: [TokenId.toAddress(quoteToken)],
2556
+ functionName: 'completeQuoteTokenUpdate',
2557
+ args: [],
2678
2558
  });
2679
2559
  }
2680
2560
  updateQuoteToken.call = call;
@@ -2688,10 +2568,10 @@ export async function updateQuoteToken(client, parameters) {
2688
2568
  const [log] = parseEventLogs({
2689
2569
  abi: Abis.tip20,
2690
2570
  logs,
2691
- eventName: 'UpdateQuoteToken',
2571
+ eventName: 'QuoteTokenUpdate',
2692
2572
  });
2693
2573
  if (!log)
2694
- throw new Error('`UpdateQuoteToken` event not found.');
2574
+ throw new Error('`QuoteTokenUpdateCompleted` event not found.');
2695
2575
  return log;
2696
2576
  }
2697
2577
  updateQuoteToken.extractEvent = extractEvent;
@@ -2714,7 +2594,6 @@ export async function updateQuoteToken(client, parameters) {
2714
2594
  *
2715
2595
  * const result = await actions.token.updateQuoteTokenSync(client, {
2716
2596
  * token: '0x...',
2717
- * quoteToken: '0x...',
2718
2597
  * })
2719
2598
  * ```
2720
2599
  *
@@ -2756,7 +2635,7 @@ export async function updateQuoteTokenSync(client, parameters) {
2756
2635
  * @returns A function to unsubscribe from the event.
2757
2636
  */
2758
2637
  export function watchApprove(client, parameters) {
2759
- const { onApproval, token = Addresses.defaultFeeToken, ...rest } = parameters;
2638
+ const { onApproval, token, ...rest } = parameters;
2760
2639
  return watchContractEvent(client, {
2761
2640
  ...rest,
2762
2641
  address: TokenId.toAddress(token),
@@ -2795,7 +2674,7 @@ export function watchApprove(client, parameters) {
2795
2674
  * @returns A function to unsubscribe from the event.
2796
2675
  */
2797
2676
  export function watchBurn(client, parameters) {
2798
- const { onBurn, token = Addresses.defaultFeeToken, ...rest } = parameters;
2677
+ const { onBurn, token, ...rest } = parameters;
2799
2678
  return watchContractEvent(client, {
2800
2679
  ...rest,
2801
2680
  address: TokenId.toAddress(token),
@@ -2873,7 +2752,7 @@ export function watchCreate(client, parameters) {
2873
2752
  * @returns A function to unsubscribe from the event.
2874
2753
  */
2875
2754
  export function watchMint(client, parameters) {
2876
- const { onMint, token = Addresses.defaultFeeToken, ...rest } = parameters;
2755
+ const { onMint, token, ...rest } = parameters;
2877
2756
  return watchContractEvent(client, {
2878
2757
  ...rest,
2879
2758
  address: TokenId.toAddress(token),
@@ -2912,7 +2791,7 @@ export function watchMint(client, parameters) {
2912
2791
  * @returns A function to unsubscribe from the event.
2913
2792
  */
2914
2793
  export function watchAdminRole(client, parameters) {
2915
- const { onRoleAdminUpdated, token = Addresses.defaultFeeToken, ...rest } = parameters;
2794
+ const { onRoleAdminUpdated, token, ...rest } = parameters;
2916
2795
  return watchContractEvent(client, {
2917
2796
  ...rest,
2918
2797
  address: TokenId.toAddress(token),
@@ -2951,7 +2830,7 @@ export function watchAdminRole(client, parameters) {
2951
2830
  * @returns A function to unsubscribe from the event.
2952
2831
  */
2953
2832
  export function watchRole(client, parameters) {
2954
- const { onRoleUpdated, token = Addresses.defaultFeeToken, ...rest } = parameters;
2833
+ const { onRoleUpdated, token, ...rest } = parameters;
2955
2834
  return watchContractEvent(client, {
2956
2835
  ...rest,
2957
2836
  address: TokenId.toAddress(token),
@@ -2993,7 +2872,7 @@ export function watchRole(client, parameters) {
2993
2872
  * @returns A function to unsubscribe from the event.
2994
2873
  */
2995
2874
  export function watchTransfer(client, parameters) {
2996
- const { onTransfer, token = Addresses.defaultFeeToken, ...rest } = parameters;
2875
+ const { onTransfer, token, ...rest } = parameters;
2997
2876
  return watchContractEvent(client, {
2998
2877
  ...rest,
2999
2878
  address: TokenId.toAddress(token),
@@ -3022,8 +2901,8 @@ export function watchTransfer(client, parameters) {
3022
2901
  *
3023
2902
  * const unwatch = actions.token.watchUpdateQuoteToken(client, {
3024
2903
  * onUpdateQuoteToken: (args, log) => {
3025
- * if (args.finalized)
3026
- * console.log('quote token update finalized:', args.newQuoteToken)
2904
+ * if (args.completed)
2905
+ * console.log('quote token update completed:', args.newQuoteToken)
3027
2906
  * else
3028
2907
  * console.log('quote token update proposed:', args.newQuoteToken)
3029
2908
  * },
@@ -3035,7 +2914,7 @@ export function watchTransfer(client, parameters) {
3035
2914
  * @returns A function to unsubscribe from the event.
3036
2915
  */
3037
2916
  export function watchUpdateQuoteToken(client, parameters) {
3038
- const { onUpdateQuoteToken, token = Addresses.defaultFeeToken, ...rest } = parameters;
2917
+ const { onUpdateQuoteToken, token, ...rest } = parameters;
3039
2918
  const address = TokenId.toAddress(token);
3040
2919
  return watchContractEvent(client, {
3041
2920
  ...rest,
@@ -3043,12 +2922,12 @@ export function watchUpdateQuoteToken(client, parameters) {
3043
2922
  abi: Abis.tip20,
3044
2923
  onLogs: (logs) => {
3045
2924
  for (const log of logs) {
3046
- if (log.eventName !== 'UpdateQuoteToken' &&
3047
- log.eventName !== 'QuoteTokenUpdateFinalized')
2925
+ if (log.eventName !== 'NextQuoteTokenSet' &&
2926
+ log.eventName !== 'QuoteTokenUpdate')
3048
2927
  continue;
3049
2928
  onUpdateQuoteToken({
3050
2929
  ...log.args,
3051
- finalized: log.eventName === 'QuoteTokenUpdateFinalized',
2930
+ completed: log.eventName === 'QuoteTokenUpdate',
3052
2931
  }, log);
3053
2932
  }
3054
2933
  },