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
@@ -0,0 +1,63 @@
1
+ import { connect } from '@wagmi/core'
2
+ import { describe, expect, test } from 'vitest'
3
+ import { accounts } from '../../../test/viem/config.js'
4
+ import { config, queryClient } from '../../../test/wagmi/config.js'
5
+ import { getUserToken, setUserToken, setUserTokenSync } from './fee.js'
6
+
7
+ const account = accounts[0]
8
+
9
+ describe('getUserToken', () => {
10
+ test('default', async () => {
11
+ const result = await getUserToken(config, {
12
+ account,
13
+ })
14
+ expect(result).toMatchInlineSnapshot(`
15
+ {
16
+ "address": "0x20C0000000000000000000000000000000000001",
17
+ "id": 1n,
18
+ }
19
+ `)
20
+ })
21
+
22
+ describe('queryOptions', () => {
23
+ test('default', async () => {
24
+ const options = getUserToken.queryOptions(config, {
25
+ account,
26
+ })
27
+ expect(await queryClient.fetchQuery(options)).toMatchInlineSnapshot(
28
+ `
29
+ {
30
+ "address": "0x20C0000000000000000000000000000000000001",
31
+ "id": 1n,
32
+ }
33
+ `,
34
+ )
35
+ })
36
+ })
37
+ })
38
+
39
+ describe.skip('setUserToken', () => {
40
+ test('default', async () => {
41
+ await connect(config, {
42
+ connector: config.connectors[0]!,
43
+ })
44
+ const hash = await setUserToken(config, {
45
+ account,
46
+ token: '0x20C0000000000000000000000000000000000001',
47
+ })
48
+ expect(hash).toBeDefined()
49
+ })
50
+ })
51
+
52
+ describe.skip('setUserTokenSync', () => {
53
+ test('default', async () => {
54
+ await connect(config, {
55
+ connector: config.connectors[0]!,
56
+ })
57
+ const result = await setUserTokenSync(config, {
58
+ account,
59
+ token: '0x20C0000000000000000000000000000000000001',
60
+ })
61
+ expect(result).toBeDefined()
62
+ })
63
+ })
@@ -0,0 +1,208 @@
1
+ import type * as Query from '@tanstack/query-core'
2
+ import { type Config, getConnectorClient } from '@wagmi/core'
3
+ import type { ChainIdParameter, ConnectorParameter } from '@wagmi/core/internal'
4
+ import type { Account } from 'viem'
5
+ import type { PartialBy, RequiredBy } from '../../internal/types.js'
6
+ import * as viem_Actions from '../../viem/Actions/fee.js'
7
+
8
+ /**
9
+ * Gets the user's default fee token.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { createConfig, http } from '@wagmi/core'
14
+ * import { tempo } from 'tempo.ts/chains'
15
+ * import { Actions } from 'tempo.ts/wagmi'
16
+ *
17
+ * const config = createConfig({
18
+ * chains: [tempo],
19
+ * transports: {
20
+ * [tempo.id]: http(),
21
+ * },
22
+ * })
23
+ *
24
+ * const hash = await Actions.fee.getUserToken(config, {
25
+ * account: '0x20c...0055',
26
+ * })
27
+ * ```
28
+ *
29
+ * @param config - Config.
30
+ * @param parameters - Parameters.
31
+ * @returns Transaction hash.
32
+ */
33
+ export function getUserToken<config extends Config>(
34
+ config: config,
35
+ parameters: getUserToken.Parameters<config>,
36
+ ): Promise<getUserToken.ReturnValue> {
37
+ const { chainId, ...rest } = parameters
38
+ const client = config.getClient({ chainId })
39
+ return viem_Actions.getUserToken(client, rest)
40
+ }
41
+
42
+ export namespace getUserToken {
43
+ export type Parameters<config extends Config> = ChainIdParameter<config> &
44
+ viem_Actions.getUserToken.Parameters
45
+
46
+ export type ReturnValue = viem_Actions.getUserToken.ReturnValue
47
+
48
+ export function queryKey<config extends Config>(
49
+ parameters: PartialBy<Parameters<config>, 'account'>,
50
+ ) {
51
+ return ['getUserToken', parameters] as const
52
+ }
53
+
54
+ export type QueryKey<config extends Config> = ReturnType<
55
+ typeof queryKey<config>
56
+ >
57
+
58
+ export function queryOptions<config extends Config, selectData = ReturnValue>(
59
+ config: Config,
60
+ parameters: queryOptions.Parameters<config, selectData>,
61
+ ): queryOptions.ReturnValue<config, selectData> {
62
+ const { query, ...rest } = parameters
63
+ return {
64
+ ...query,
65
+ queryKey: queryKey(rest),
66
+ async queryFn({ queryKey }) {
67
+ const [, { account, ...parameters }] = queryKey
68
+ if (!account) throw new Error('account is required.')
69
+ return await getUserToken(config, { account, ...parameters })
70
+ },
71
+ }
72
+ }
73
+
74
+ export declare namespace queryOptions {
75
+ export type Parameters<
76
+ config extends Config,
77
+ selectData = getUserToken.ReturnValue,
78
+ > = PartialBy<getUserToken.Parameters<config>, 'account'> & {
79
+ query?:
80
+ | Omit<ReturnValue<config, selectData>, 'queryKey' | 'queryFn'>
81
+ | undefined
82
+ }
83
+
84
+ export type ReturnValue<
85
+ config extends Config,
86
+ selectData = getUserToken.ReturnValue,
87
+ > = RequiredBy<
88
+ Query.QueryOptions<
89
+ getUserToken.ReturnValue,
90
+ Query.DefaultError,
91
+ selectData,
92
+ getUserToken.QueryKey<config>
93
+ >,
94
+ 'queryKey' | 'queryFn'
95
+ >
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Sets the user's default fee token.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import { createConfig, http } from '@wagmi/core'
105
+ * import { tempo } from 'tempo.ts/chains'
106
+ * import { Actions } from 'tempo.ts/wagmi'
107
+ *
108
+ * const config = createConfig({
109
+ * chains: [tempo],
110
+ * transports: {
111
+ * [tempo.id]: http(),
112
+ * },
113
+ * })
114
+ *
115
+ * const result = await Actions.fee.setUserToken(config, {
116
+ * token: '0x20c...0055',
117
+ * })
118
+ * ```
119
+ *
120
+ * @param config - Config.
121
+ * @param parameters - Parameters.
122
+ * @returns The transaction receipt and event data.
123
+ */
124
+ export async function setUserToken<config extends Config>(
125
+ config: config,
126
+ parameters: setUserToken.Parameters<config>,
127
+ ): Promise<viem_Actions.setUserToken.ReturnValue> {
128
+ const { account, chainId, connector } = parameters
129
+
130
+ const client = await getConnectorClient(config, {
131
+ account,
132
+ assertChainId: false,
133
+ chainId,
134
+ connector,
135
+ })
136
+
137
+ return viem_Actions.setUserToken(
138
+ client,
139
+ parameters as viem_Actions.setUserToken.Parameters,
140
+ )
141
+ }
142
+
143
+ export declare namespace setUserToken {
144
+ export type Parameters<config extends Config> = ChainIdParameter<config> &
145
+ ConnectorParameter &
146
+ Omit<viem_Actions.setUserToken.Parameters<undefined, Account>, 'chain'>
147
+
148
+ export type ReturnValue = viem_Actions.setUserToken.ReturnValue
149
+
150
+ export type ErrorType = viem_Actions.setUserToken.ErrorType
151
+ }
152
+
153
+ /**
154
+ * Sets the user's default fee token.
155
+ *
156
+ * Note: This is a synchronous action that waits for the transaction to
157
+ * be included on a block before returning a response.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * import { createConfig, http } from '@wagmi/core'
162
+ * import { tempo } from 'tempo.ts/chains'
163
+ * import { Actions } from 'tempo.ts/wagmi'
164
+ *
165
+ * const config = createConfig({
166
+ * chains: [tempo],
167
+ * transports: {
168
+ * [tempo.id]: http(),
169
+ * },
170
+ * })
171
+ *
172
+ * const result = await Actions.fee.setUserTokenSync(config, {
173
+ * token: '0x20c...0055',
174
+ * })
175
+ * ```
176
+ *
177
+ * @param config - Config.
178
+ * @param parameters - Parameters.
179
+ * @returns The transaction receipt and event data.
180
+ */
181
+ export async function setUserTokenSync<config extends Config>(
182
+ config: config,
183
+ parameters: setUserTokenSync.Parameters<config>,
184
+ ): Promise<viem_Actions.setUserTokenSync.ReturnValue> {
185
+ const { account, chainId, connector } = parameters
186
+
187
+ const client = await getConnectorClient(config, {
188
+ account,
189
+ assertChainId: false,
190
+ chainId,
191
+ connector,
192
+ })
193
+
194
+ return viem_Actions.setUserTokenSync(
195
+ client,
196
+ parameters as viem_Actions.setUserTokenSync.Parameters,
197
+ )
198
+ }
199
+
200
+ export declare namespace setUserTokenSync {
201
+ export type Parameters<config extends Config> = ChainIdParameter<config> &
202
+ ConnectorParameter &
203
+ Omit<viem_Actions.setUserTokenSync.Parameters<undefined, Account>, 'chain'>
204
+
205
+ export type ReturnValue = viem_Actions.setUserTokenSync.ReturnValue
206
+
207
+ export type ErrorType = viem_Actions.setUserTokenSync.ErrorType
208
+ }
@@ -0,0 +1,5 @@
1
+ export * as amm from './amm.js'
2
+ export * as dex from './dex.js'
3
+ export * as fee from './fee.js'
4
+ export * as reward from './reward.js'
5
+ export * as token from './token.js'
@@ -0,0 +1,210 @@
1
+ import { getAccount } from '@wagmi/core'
2
+ import { parseUnits } from 'viem'
3
+ import { describe, expect, test } from 'vitest'
4
+ import { config, queryClient, setupToken } from '../../../test/wagmi/config.js'
5
+ import * as actions from './reward.js'
6
+ import * as tokenActions from './token.js'
7
+
8
+ describe('cancelSync', () => {
9
+ test('default', async () => {
10
+ const { token } = await setupToken()
11
+
12
+ // Start a reward stream
13
+ const rewardAmount = parseUnits('100', 6)
14
+ const { id: streamId } = await actions.startSync(config, {
15
+ amount: rewardAmount,
16
+ seconds: 3600,
17
+ token,
18
+ })
19
+
20
+ // Cancel the reward
21
+ const { receipt, refund, ...result } = await actions.cancelSync(config, {
22
+ id: streamId,
23
+ token,
24
+ })
25
+
26
+ expect(refund).toBeGreaterThan(0n)
27
+ expect(receipt).toBeDefined()
28
+ expect(result.funder).toBeDefined()
29
+ expect(result.id).toBe(streamId)
30
+ })
31
+ })
32
+
33
+ // TODO: unskip
34
+ describe.skip('claimSync', () => {
35
+ test('default', async () => {
36
+ const { token } = await setupToken()
37
+
38
+ const account = getAccount(config)
39
+
40
+ const balanceBefore = await tokenActions.getBalance(config, {
41
+ account: account.address!,
42
+ token,
43
+ })
44
+
45
+ // Opt in to rewards
46
+ await actions.setRecipientSync(config, {
47
+ recipient: account.address!,
48
+ token,
49
+ })
50
+
51
+ // Mint reward tokens
52
+ const rewardAmount = parseUnits('100', 6)
53
+ await tokenActions.mintSync(config, {
54
+ amount: rewardAmount,
55
+ to: account.address!,
56
+ token,
57
+ })
58
+
59
+ // Start immediate reward
60
+ await actions.startSync(config, {
61
+ amount: rewardAmount,
62
+ seconds: 0,
63
+ token,
64
+ })
65
+
66
+ // Trigger reward accrual by transferring
67
+ await tokenActions.transferSync(config, {
68
+ amount: 1n,
69
+ to: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
70
+ token,
71
+ })
72
+
73
+ // Claim rewards
74
+ const { receipt } = await actions.claimSync(config, {
75
+ token,
76
+ })
77
+
78
+ expect(receipt).toBeDefined()
79
+
80
+ const balanceAfter = await tokenActions.getBalance(config, {
81
+ account: account.address!,
82
+ token,
83
+ })
84
+
85
+ // Balance should have increased due to claimed rewards
86
+ expect(balanceAfter).toBeGreaterThan(
87
+ balanceBefore + rewardAmount - parseUnits('1', 6),
88
+ )
89
+ })
90
+ })
91
+
92
+ describe('getStream', () => {
93
+ test('default', async () => {
94
+ const { token } = await setupToken()
95
+
96
+ // Start a reward stream
97
+ const rewardAmount = parseUnits('100', 6)
98
+ const { id: streamId } = await actions.startSync(config, {
99
+ amount: rewardAmount,
100
+ seconds: 10,
101
+ token,
102
+ })
103
+
104
+ // Get the stream
105
+ const stream = await actions.getStream(config, {
106
+ id: streamId,
107
+ token,
108
+ })
109
+
110
+ expect(stream.funder).toBeDefined()
111
+ expect(stream.amountTotal).toBe(rewardAmount)
112
+ expect(stream.endTime).toBeGreaterThan(stream.startTime)
113
+ expect(stream.ratePerSecondScaled).toBeGreaterThan(0n)
114
+ })
115
+
116
+ describe('queryOptions', () => {
117
+ test('default', async () => {
118
+ const { token } = await setupToken()
119
+
120
+ // Start a reward stream
121
+ const rewardAmount = parseUnits('100', 6)
122
+ const { id: streamId } = await actions.startSync(config, {
123
+ amount: rewardAmount,
124
+ seconds: 10,
125
+ token,
126
+ })
127
+
128
+ const options = actions.getStream.queryOptions(config, {
129
+ id: streamId,
130
+ token,
131
+ })
132
+
133
+ const stream = await queryClient.fetchQuery(options)
134
+
135
+ expect(stream.funder).toBeDefined()
136
+ expect(stream.amountTotal).toBe(rewardAmount)
137
+ })
138
+ })
139
+ })
140
+
141
+ describe('getTotalPerSecond', () => {
142
+ test('default', async () => {
143
+ const { token } = await setupToken()
144
+
145
+ const rate = await actions.getTotalPerSecond(config, {
146
+ token,
147
+ })
148
+
149
+ expect(rate).toBe(0n)
150
+ })
151
+
152
+ describe('queryOptions', () => {
153
+ test('default', async () => {
154
+ const { token } = await setupToken()
155
+
156
+ const options = actions.getTotalPerSecond.queryOptions(config, {
157
+ token,
158
+ })
159
+
160
+ const rate = await queryClient.fetchQuery(options)
161
+
162
+ expect(rate).toBe(0n)
163
+ })
164
+ })
165
+ })
166
+
167
+ describe('setRecipientSync', () => {
168
+ test('default', async () => {
169
+ const { token } = await setupToken()
170
+
171
+ const account = getAccount(config)
172
+
173
+ // Set reward recipient
174
+ const { holder, receipt, recipient } = await actions.setRecipientSync(
175
+ config,
176
+ {
177
+ recipient: account.address!,
178
+ token,
179
+ },
180
+ )
181
+
182
+ expect(receipt).toBeDefined()
183
+ expect(holder).toBe(account.address)
184
+ expect(recipient).toBe(account.address)
185
+ })
186
+ })
187
+
188
+ describe('startSync', () => {
189
+ test('default', async () => {
190
+ const { token } = await setupToken()
191
+
192
+ const account = getAccount(config)
193
+
194
+ // Start a reward stream
195
+ const rewardAmount = parseUnits('100', 6)
196
+ const duration = 10
197
+ const { amount, durationSeconds, funder, id, receipt } =
198
+ await actions.startSync(config, {
199
+ amount: rewardAmount,
200
+ seconds: duration,
201
+ token,
202
+ })
203
+
204
+ expect(receipt).toBeDefined()
205
+ expect(funder).toBe(account.address)
206
+ expect(id).toBeGreaterThan(0n)
207
+ expect(amount).toBe(rewardAmount)
208
+ expect(durationSeconds).toBe(duration)
209
+ })
210
+ })