tempo.ts 0.11.0 → 0.12.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 (196) hide show
  1. package/CHANGELOG.md +67 -4
  2. package/README.md +3 -34
  3. package/dist/server/Handler.d.ts +14 -14
  4. package/dist/server/Handler.d.ts.map +1 -1
  5. package/dist/server/Handler.js +16 -17
  6. package/dist/server/Handler.js.map +1 -1
  7. package/dist/wagmi/Actions/amm.d.ts +51 -51
  8. package/dist/wagmi/Actions/amm.d.ts.map +1 -1
  9. package/dist/wagmi/Actions/amm.js +37 -37
  10. package/dist/wagmi/Actions/amm.js.map +1 -1
  11. package/dist/wagmi/Actions/dex.d.ts +129 -129
  12. package/dist/wagmi/Actions/dex.d.ts.map +1 -1
  13. package/dist/wagmi/Actions/dex.js +73 -73
  14. package/dist/wagmi/Actions/dex.js.map +1 -1
  15. package/dist/wagmi/Actions/faucet.d.ts +9 -9
  16. package/dist/wagmi/Actions/faucet.d.ts.map +1 -1
  17. package/dist/wagmi/Actions/faucet.js +7 -7
  18. package/dist/wagmi/Actions/faucet.js.map +1 -1
  19. package/dist/wagmi/Actions/fee.d.ts +17 -17
  20. package/dist/wagmi/Actions/fee.d.ts.map +1 -1
  21. package/dist/wagmi/Actions/fee.js +10 -10
  22. package/dist/wagmi/Actions/fee.js.map +1 -1
  23. package/dist/wagmi/Actions/nonce.d.ts +9 -79
  24. package/dist/wagmi/Actions/nonce.d.ts.map +1 -1
  25. package/dist/wagmi/Actions/nonce.js +7 -89
  26. package/dist/wagmi/Actions/nonce.js.map +1 -1
  27. package/dist/wagmi/Actions/policy.d.ts +69 -70
  28. package/dist/wagmi/Actions/policy.d.ts.map +1 -1
  29. package/dist/wagmi/Actions/policy.js +43 -43
  30. package/dist/wagmi/Actions/policy.js.map +1 -1
  31. package/dist/wagmi/Actions/reward.d.ts +51 -51
  32. package/dist/wagmi/Actions/reward.d.ts.map +1 -1
  33. package/dist/wagmi/Actions/reward.js +31 -31
  34. package/dist/wagmi/Actions/reward.js.map +1 -1
  35. package/dist/wagmi/Actions/token.d.ts +238 -238
  36. package/dist/wagmi/Actions/token.d.ts.map +1 -1
  37. package/dist/wagmi/Actions/token.js +136 -136
  38. package/dist/wagmi/Actions/token.js.map +1 -1
  39. package/dist/wagmi/Connector.d.ts +2 -1
  40. package/dist/wagmi/Connector.d.ts.map +1 -1
  41. package/dist/wagmi/Connector.js +83 -22
  42. package/dist/wagmi/Connector.js.map +1 -1
  43. package/dist/wagmi/Hooks/nonce.d.ts +1 -52
  44. package/dist/wagmi/Hooks/nonce.d.ts.map +1 -1
  45. package/dist/wagmi/Hooks/nonce.js +1 -70
  46. package/dist/wagmi/Hooks/nonce.js.map +1 -1
  47. package/dist/wagmi/Hooks/policy.d.ts +0 -1
  48. package/dist/wagmi/Hooks/policy.d.ts.map +1 -1
  49. package/dist/wagmi/Hooks/policy.js.map +1 -1
  50. package/dist/wagmi/KeyManager.d.ts +6 -3
  51. package/dist/wagmi/KeyManager.d.ts.map +1 -1
  52. package/dist/wagmi/KeyManager.js +9 -4
  53. package/dist/wagmi/KeyManager.js.map +1 -1
  54. package/package.json +2 -2
  55. package/src/server/Handler.test.ts +2 -2
  56. package/src/server/Handler.ts +16 -17
  57. package/src/wagmi/Actions/amm.ts +63 -63
  58. package/src/wagmi/Actions/dex.test.ts +1 -1
  59. package/src/wagmi/Actions/dex.ts +153 -153
  60. package/src/wagmi/Actions/faucet.ts +11 -11
  61. package/src/wagmi/Actions/fee.ts +20 -20
  62. package/src/wagmi/Actions/nonce.test.ts +1 -64
  63. package/src/wagmi/Actions/nonce.ts +10 -142
  64. package/src/wagmi/Actions/policy.ts +83 -85
  65. package/src/wagmi/Actions/reward.ts +64 -61
  66. package/src/wagmi/Actions/token.ts +287 -283
  67. package/src/wagmi/Connector.ts +105 -31
  68. package/src/wagmi/Hooks/dex.test.ts +1 -1
  69. package/src/wagmi/Hooks/fee.test.ts +0 -6
  70. package/src/wagmi/Hooks/nonce.test.ts +1 -66
  71. package/src/wagmi/Hooks/nonce.ts +1 -114
  72. package/src/wagmi/Hooks/policy.ts +0 -2
  73. package/src/wagmi/KeyManager.ts +18 -5
  74. package/dist/viem/Abis.d.ts +0 -2649
  75. package/dist/viem/Abis.d.ts.map +0 -1
  76. package/dist/viem/Abis.js +0 -1677
  77. package/dist/viem/Abis.js.map +0 -1
  78. package/dist/viem/Account.d.ts +0 -244
  79. package/dist/viem/Account.d.ts.map +0 -1
  80. package/dist/viem/Account.js +0 -382
  81. package/dist/viem/Account.js.map +0 -1
  82. package/dist/viem/Actions/amm.d.ts +0 -1991
  83. package/dist/viem/Actions/amm.d.ts.map +0 -1
  84. package/dist/viem/Actions/amm.js +0 -814
  85. package/dist/viem/Actions/amm.js.map +0 -1
  86. package/dist/viem/Actions/dex.d.ts +0 -3900
  87. package/dist/viem/Actions/dex.d.ts.map +0 -1
  88. package/dist/viem/Actions/dex.js +0 -1414
  89. package/dist/viem/Actions/dex.js.map +0 -1
  90. package/dist/viem/Actions/faucet.d.ts +0 -69
  91. package/dist/viem/Actions/faucet.d.ts.map +0 -1
  92. package/dist/viem/Actions/faucet.js +0 -73
  93. package/dist/viem/Actions/faucet.js.map +0 -1
  94. package/dist/viem/Actions/fee.d.ts +0 -360
  95. package/dist/viem/Actions/fee.d.ts.map +0 -1
  96. package/dist/viem/Actions/fee.js +0 -237
  97. package/dist/viem/Actions/fee.js.map +0 -1
  98. package/dist/viem/Actions/nonce.d.ts +0 -257
  99. package/dist/viem/Actions/nonce.d.ts.map +0 -1
  100. package/dist/viem/Actions/nonce.js +0 -228
  101. package/dist/viem/Actions/nonce.js.map +0 -1
  102. package/dist/viem/Actions/policy.d.ts +0 -1680
  103. package/dist/viem/Actions/policy.d.ts.map +0 -1
  104. package/dist/viem/Actions/policy.js +0 -875
  105. package/dist/viem/Actions/policy.js.map +0 -1
  106. package/dist/viem/Actions/reward.d.ts +0 -2422
  107. package/dist/viem/Actions/reward.d.ts.map +0 -1
  108. package/dist/viem/Actions/reward.js +0 -651
  109. package/dist/viem/Actions/reward.js.map +0 -1
  110. package/dist/viem/Actions/token.d.ts +0 -16007
  111. package/dist/viem/Actions/token.d.ts.map +0 -1
  112. package/dist/viem/Actions/token.js +0 -2936
  113. package/dist/viem/Actions/token.js.map +0 -1
  114. package/dist/viem/Addresses.d.ts +0 -9
  115. package/dist/viem/Addresses.d.ts.map +0 -1
  116. package/dist/viem/Addresses.js +0 -9
  117. package/dist/viem/Addresses.js.map +0 -1
  118. package/dist/viem/Chain.d.ts +0 -451
  119. package/dist/viem/Chain.d.ts.map +0 -1
  120. package/dist/viem/Chain.js +0 -96
  121. package/dist/viem/Chain.js.map +0 -1
  122. package/dist/viem/Formatters.d.ts +0 -10
  123. package/dist/viem/Formatters.d.ts.map +0 -1
  124. package/dist/viem/Formatters.js +0 -104
  125. package/dist/viem/Formatters.js.map +0 -1
  126. package/dist/viem/Storage.d.ts +0 -24
  127. package/dist/viem/Storage.d.ts.map +0 -1
  128. package/dist/viem/Storage.js +0 -68
  129. package/dist/viem/Storage.js.map +0 -1
  130. package/dist/viem/Transaction.d.ts +0 -76
  131. package/dist/viem/Transaction.d.ts.map +0 -1
  132. package/dist/viem/Transaction.js +0 -176
  133. package/dist/viem/Transaction.js.map +0 -1
  134. package/dist/viem/Transport.d.ts +0 -33
  135. package/dist/viem/Transport.d.ts.map +0 -1
  136. package/dist/viem/Transport.js +0 -138
  137. package/dist/viem/Transport.js.map +0 -1
  138. package/dist/viem/WebAuthnP256.d.ts +0 -82
  139. package/dist/viem/WebAuthnP256.d.ts.map +0 -1
  140. package/dist/viem/WebAuthnP256.js +0 -97
  141. package/dist/viem/WebAuthnP256.js.map +0 -1
  142. package/dist/viem/WebCryptoP256.d.ts +0 -2
  143. package/dist/viem/WebCryptoP256.d.ts.map +0 -1
  144. package/dist/viem/WebCryptoP256.js +0 -2
  145. package/dist/viem/WebCryptoP256.js.map +0 -1
  146. package/dist/viem/internal/types.d.ts +0 -20
  147. package/dist/viem/internal/types.d.ts.map +0 -1
  148. package/dist/viem/internal/types.js +0 -2
  149. package/dist/viem/internal/types.js.map +0 -1
  150. package/dist/viem/internal/utils.d.ts +0 -14
  151. package/dist/viem/internal/utils.d.ts.map +0 -1
  152. package/dist/viem/internal/utils.js +0 -33
  153. package/dist/viem/internal/utils.js.map +0 -1
  154. package/src/chains.ts +0 -54
  155. package/src/viem/Abis.ts +0 -1688
  156. package/src/viem/Account.test.ts +0 -444
  157. package/src/viem/Account.ts +0 -601
  158. package/src/viem/Actions/account.test.ts +0 -414
  159. package/src/viem/Actions/account.ts +0 -106
  160. package/src/viem/Actions/amm.test.ts +0 -381
  161. package/src/viem/Actions/amm.ts +0 -1227
  162. package/src/viem/Actions/dex.test.ts +0 -1549
  163. package/src/viem/Actions/dex.ts +0 -2150
  164. package/src/viem/Actions/faucet.ts +0 -121
  165. package/src/viem/Actions/fee.test.ts +0 -259
  166. package/src/viem/Actions/fee.ts +0 -372
  167. package/src/viem/Actions/index.ts +0 -9
  168. package/src/viem/Actions/nonce.test.ts +0 -206
  169. package/src/viem/Actions/nonce.ts +0 -347
  170. package/src/viem/Actions/policy.test.ts +0 -534
  171. package/src/viem/Actions/policy.ts +0 -1335
  172. package/src/viem/Actions/reward.test.ts +0 -434
  173. package/src/viem/Actions/reward.ts +0 -944
  174. package/src/viem/Actions/token.test.ts +0 -3029
  175. package/src/viem/Actions/token.ts +0 -4458
  176. package/src/viem/Addresses.ts +0 -9
  177. package/src/viem/Chain.bench-d.ts +0 -12
  178. package/src/viem/Chain.test.ts +0 -168
  179. package/src/viem/Chain.ts +0 -157
  180. package/src/viem/Decorator.bench-d.ts +0 -11
  181. package/src/viem/Decorator.test.ts +0 -39
  182. package/src/viem/Decorator.ts +0 -3179
  183. package/src/viem/Formatters.ts +0 -164
  184. package/src/viem/P256.ts +0 -1
  185. package/src/viem/Secp256k1.ts +0 -1
  186. package/src/viem/Storage.ts +0 -110
  187. package/src/viem/TokenIds.ts +0 -1
  188. package/src/viem/Transaction.ts +0 -382
  189. package/src/viem/Transport.ts +0 -191
  190. package/src/viem/WebAuthnP256.ts +0 -146
  191. package/src/viem/WebCryptoP256.ts +0 -1
  192. package/src/viem/e2e.test.ts +0 -1602
  193. package/src/viem/index.ts +0 -30
  194. package/src/viem/internal/types.ts +0 -69
  195. package/src/viem/internal/utils.ts +0 -58
  196. package/src/wagmi/internal/types.ts +0 -16
@@ -1,9 +0,0 @@
1
- export const accountImplementation =
2
- '0x7702c00000000000000000000000000000000000'
3
- export const accountRegistrar = '0x7702ac0000000000000000000000000000000000'
4
- export const feeManager = '0xfeec000000000000000000000000000000000000'
5
- export const nonceManager = '0x4e4F4E4345000000000000000000000000000000'
6
- export const pathUsd = '0x20c0000000000000000000000000000000000000'
7
- export const stablecoinExchange = '0xdec0000000000000000000000000000000000000'
8
- export const tip20Factory = '0x20fc000000000000000000000000000000000000'
9
- export const tip403Registry = '0x403c000000000000000000000000000000000000'
@@ -1,12 +0,0 @@
1
- import { attest } from '@ark/attest'
2
- import { createClient, http } from 'viem'
3
- import { test } from 'vitest'
4
- import { tempo } from '../chains.js'
5
-
6
- test('decorator', () => {
7
- createClient({
8
- chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
9
- transport: http('https://cloudflare-eth.com'),
10
- })
11
- attest.instantiations([62236, 'instantiations'])
12
- })
@@ -1,168 +0,0 @@
1
- import {
2
- getTransaction,
3
- prepareTransactionRequest,
4
- sendTransactionSync,
5
- } from 'viem/actions'
6
- import { describe, expect, test, vi } from 'vitest'
7
- import { chain, client, clientWithAccount } from '../../test/viem/config.js'
8
-
9
- describe('chain.prepareTransactionRequest', () => {
10
- test('behavior: sequential nonce keys for feePayer transactions', async () => {
11
- const requests = await Promise.all([
12
- chain.prepareTransactionRequest({ feePayer: true } as never),
13
- chain.prepareTransactionRequest({ feePayer: true } as never),
14
- chain.prepareTransactionRequest({ feePayer: true } as never),
15
- ])
16
-
17
- expect((requests[0] as any)?.nonceKey).toBe(undefined)
18
- expect((requests[1] as any)?.nonceKey).toBeGreaterThan(0n)
19
- expect((requests[2] as any)?.nonceKey).toBeGreaterThan(0n)
20
- })
21
-
22
- test('behavior: nonce key counter resets after event loop tick', async () => {
23
- const requests1 = await Promise.all([
24
- chain.prepareTransactionRequest({ feePayer: true } as never),
25
- chain.prepareTransactionRequest({ feePayer: true } as never),
26
- ])
27
-
28
- expect((requests1[0] as any)?.nonceKey).toBe(undefined)
29
- expect((requests1[1] as any)?.nonceKey).toBeGreaterThan(0n)
30
-
31
- // Wait for microtask queue to flush
32
- await new Promise((resolve) => queueMicrotask(() => resolve(undefined)))
33
-
34
- const requests2 = await Promise.all([
35
- chain.prepareTransactionRequest({ feePayer: true } as never),
36
- chain.prepareTransactionRequest({ feePayer: true } as never),
37
- ])
38
-
39
- // Counter should have reset
40
- expect((requests2[0] as any)?.nonceKey).toBe(undefined)
41
- expect((requests2[1] as any)?.nonceKey).toBeGreaterThan(0n)
42
- })
43
-
44
- test('behavior: explicit nonceKey overrides counter', async () => {
45
- const requests = await Promise.all([
46
- chain.prepareTransactionRequest({
47
- feePayer: true,
48
- nonceKey: 42n,
49
- } as never),
50
- chain.prepareTransactionRequest({ feePayer: true } as never),
51
- chain.prepareTransactionRequest({
52
- feePayer: true,
53
- nonceKey: 100n,
54
- } as never),
55
- ])
56
-
57
- expect((requests[0] as any)?.nonceKey).toBe(42n)
58
- expect((requests[1] as any)?.nonceKey).toBe(undefined)
59
- expect((requests[2] as any)?.nonceKey).toBe(100n)
60
- })
61
-
62
- test('behavior: default nonceKey when feePayer is not true', async () => {
63
- const request = await chain.prepareTransactionRequest({} as never)
64
- expect((request as any)?.nonceKey).toBe(undefined)
65
- })
66
-
67
- test('behavior: nonce with sequential nonceKey', async () => {
68
- const requests = await Promise.all([
69
- chain.prepareTransactionRequest({ feePayer: true } as never), // nonceKey: 0n
70
- chain.prepareTransactionRequest({ feePayer: true } as never), // nonceKey: 1n
71
- chain.prepareTransactionRequest({ feePayer: true } as never), // nonceKey: 2n
72
- ])
73
-
74
- // Note: 0n is falsy, so first request has nonce undefined
75
- expect((requests[0] as any)?.nonce).toBe(undefined)
76
- expect((requests[0] as any)?.nonceKey).toBe(undefined)
77
-
78
- // nonceKey >= 1n is truthy, so nonce is 0
79
- expect((requests[1] as any)?.nonce).toBe(0)
80
- expect((requests[1] as any)?.nonceKey).toBeGreaterThan(0n)
81
-
82
- expect((requests[2] as any)?.nonce).toBe(0)
83
- expect((requests[2] as any)?.nonceKey).toBeGreaterThan(0n)
84
- })
85
-
86
- test('behavior: explicit nonce is preserved', async () => {
87
- const request = await chain.prepareTransactionRequest({
88
- feePayer: true,
89
- nonce: 123,
90
- } as never)
91
- expect((request as any)?.nonce).toBe(123)
92
- expect((request as any)?.nonceKey).toBe(undefined)
93
- })
94
-
95
- test('behavior: default nonceKey is 0n (falsy)', async () => {
96
- const request = await chain.prepareTransactionRequest({} as never)
97
- expect((request as any)?.nonceKey).toBe(undefined)
98
- expect((request as any)?.nonce).toBe(undefined)
99
- })
100
-
101
- test('behavior: resetScheduled optimization - only one microtask scheduled', async () => {
102
- const queueMicrotaskSpy = vi.spyOn(globalThis, 'queueMicrotask')
103
- const callCountBefore = queueMicrotaskSpy.mock.calls.length
104
-
105
- // Prepare multiple transactions in parallel
106
- await Promise.all([
107
- chain.prepareTransactionRequest({ feePayer: true } as never),
108
- chain.prepareTransactionRequest({ feePayer: true } as never),
109
- chain.prepareTransactionRequest({ feePayer: true } as never),
110
- chain.prepareTransactionRequest({ feePayer: true } as never),
111
- chain.prepareTransactionRequest({ feePayer: true } as never),
112
- ])
113
-
114
- const callCountAfter = queueMicrotaskSpy.mock.calls.length
115
-
116
- // Only one microtask should have been scheduled for the reset
117
- expect(callCountAfter - callCountBefore).toBe(1)
118
-
119
- queueMicrotaskSpy.mockRestore()
120
- })
121
-
122
- describe('e2e', async () => {
123
- test('behavior: prepareTransactionRequest', async () => {
124
- const [request, request2, request3] = await Promise.all([
125
- prepareTransactionRequest(client, {
126
- to: '0x0000000000000000000000000000000000000000',
127
- }),
128
- prepareTransactionRequest(client, {
129
- to: '0x0000000000000000000000000000000000000000',
130
- }),
131
- prepareTransactionRequest(client, {
132
- to: '0x0000000000000000000000000000000000000000',
133
- }),
134
- ])
135
- expect(request.nonceKey).toBe(undefined)
136
- expect(request2.nonceKey).toBeGreaterThan(0n)
137
- expect(request3.nonceKey).toBeGreaterThan(0n)
138
- })
139
-
140
- test('behavior: sendTransaction', async () => {
141
- const receipts = await Promise.all([
142
- sendTransactionSync(clientWithAccount, {
143
- to: '0x0000000000000000000000000000000000000000',
144
- }),
145
- sendTransactionSync(clientWithAccount, {
146
- to: '0x0000000000000000000000000000000000000001',
147
- }),
148
- sendTransactionSync(clientWithAccount, {
149
- to: '0x0000000000000000000000000000000000000002',
150
- }),
151
- ])
152
- const transactions = await Promise.all([
153
- getTransaction(clientWithAccount, {
154
- hash: receipts[0].transactionHash,
155
- }),
156
- getTransaction(clientWithAccount, {
157
- hash: receipts[1].transactionHash,
158
- }),
159
- getTransaction(clientWithAccount, {
160
- hash: receipts[2].transactionHash,
161
- }),
162
- ])
163
- expect(transactions[0].nonceKey).toBe(0n)
164
- expect(transactions[1].nonceKey).toBeGreaterThan(0n)
165
- expect(transactions[2].nonceKey).toBeGreaterThan(0n)
166
- })
167
- })
168
- })
package/src/viem/Chain.ts DELETED
@@ -1,157 +0,0 @@
1
- import * as Hex from 'ox/Hex'
2
- import { TokenId } from 'ox/tempo'
3
- import {
4
- defineTransaction,
5
- defineTransactionReceipt,
6
- defineTransactionRequest,
7
- type SerializeTransactionFn,
8
- type Chain as viem_Chain,
9
- } from 'viem'
10
- import type { IsUndefined } from '../internal/types.js'
11
- import * as Formatters from './Formatters.js'
12
- import * as Transaction from './Transaction.js'
13
-
14
- export type Chain<
15
- feeToken extends TokenId.TokenIdOrAddress | null | undefined =
16
- | TokenId.TokenIdOrAddress
17
- | null
18
- | undefined,
19
- > = viem_Chain &
20
- (IsUndefined<feeToken> extends true
21
- ? {
22
- feeToken?: TokenId.TokenIdOrAddress | null | undefined
23
- }
24
- : {
25
- feeToken: feeToken
26
- })
27
-
28
- function config<const chain extends Chain>(chain: chain) {
29
- const nonceKeyManager = {
30
- counter: 0,
31
- resetScheduled: false,
32
- reset() {
33
- this.counter = 0
34
- this.resetScheduled = false
35
- },
36
- get() {
37
- if (!this.resetScheduled) {
38
- this.resetScheduled = true
39
- queueMicrotask(() => this.reset())
40
- }
41
- const count = this.counter
42
- this.counter++
43
- if (count === 0) return 0n
44
- return Hex.toBigInt(Hex.random(6))
45
- },
46
- }
47
-
48
- return {
49
- blockTime: 1_000,
50
- formatters: {
51
- transaction: defineTransaction({
52
- exclude: ['aaAuthorizationList' as never],
53
- format: Formatters.formatTransaction,
54
- }),
55
- transactionReceipt: defineTransactionReceipt({
56
- format: Formatters.formatTransactionReceipt,
57
- }),
58
- transactionRequest: defineTransactionRequest({
59
- format: (
60
- ...[request, action]: Parameters<
61
- typeof Formatters.formatTransactionRequest<chain>
62
- >
63
- ) =>
64
- Formatters.formatTransactionRequest<chain>(
65
- {
66
- ...request,
67
-
68
- // Note: if we have marked the transaction as intended to be paid
69
- // by a fee payer (feePayer: true), we will not infer the fee token
70
- // as the fee payer will choose their fee token.
71
- ...(request.feePayer !== true &&
72
- (action === 'estimateGas' ||
73
- action === 'fillTransaction' ||
74
- action === 'sendTransaction')
75
- ? {
76
- feeToken: request.feeToken ?? chain.feeToken,
77
- }
78
- : {}),
79
- },
80
- action,
81
- ),
82
- }),
83
- },
84
- async prepareTransactionRequest(r) {
85
- const request = r as Transaction.TransactionRequest
86
- const nonceKey = (() => {
87
- if (typeof request.nonceKey !== 'undefined') return request.nonceKey
88
- const nonceKey = nonceKeyManager.get()
89
- if (nonceKey === 0n) return undefined
90
- return nonceKey
91
- })()
92
-
93
- const nonce = (() => {
94
- if (typeof request.nonce === 'number') return request.nonce
95
- // TODO: remove this line once `eth_fillTransaction` supports nonce keys.
96
- if (nonceKey) return 0
97
- return undefined
98
- })()
99
-
100
- return { ...request, nonce, nonceKey } as unknown as typeof r
101
- },
102
- serializers: {
103
- // TODO: casting to satisfy viem – viem v3 to have more flexible serializer type.
104
- transaction: ((transaction, signature) =>
105
- Transaction.serialize(
106
- {
107
- ...transaction,
108
- // If we have marked the transaction as intended to be paid
109
- // by a fee payer (feePayer: true), we will not infer the fee token
110
- // as the fee payer will choose their fee token.
111
- ...((transaction as { feePayer?: unknown }).feePayer !== true
112
- ? {
113
- feeToken:
114
- (transaction as { feeToken?: unknown }).feeToken ??
115
- chain.feeToken ??
116
- undefined,
117
- }
118
- : {}),
119
- } as never,
120
- signature,
121
- )) as SerializeTransactionFn,
122
- },
123
- ...chain,
124
- } as const satisfies viem_Chain
125
- }
126
-
127
- export function define<const chain extends viem_Chain>(
128
- chain: chain,
129
- ): define.ReturnValue<chain> {
130
- return Object.assign(
131
- (properties = {}) => config({ ...chain, ...properties }),
132
- { id: chain.id },
133
- ) as never
134
- }
135
-
136
- export { TokenId }
137
-
138
- export declare namespace define {
139
- type Properties = {
140
- /**
141
- * Fee token to set for mutable actions.
142
- *
143
- * Pass `null` to opt-in to protocol preferences.
144
- *
145
- * @example '0x20c0000000000000000000000000000000000001'
146
- * @example 1n
147
- * @example null
148
- */
149
- feeToken?: TokenId.TokenIdOrAddress | null | undefined
150
- }
151
-
152
- type ReturnValue<chain extends viem_Chain> = (<
153
- properties extends define.Properties | undefined,
154
- >(
155
- properties?: properties | undefined,
156
- ) => ReturnType<typeof config<chain & properties>>) & { id: chain['id'] }
157
- }
@@ -1,11 +0,0 @@
1
- import { attest } from '@ark/attest'
2
- import { createClient, http } from 'viem'
3
- import { test } from 'vitest'
4
- import { decorator } from './Decorator.js'
5
-
6
- test('decorator', () => {
7
- createClient({
8
- transport: http('https://cloudflare-eth.com'),
9
- }).extend(decorator())
10
- attest.instantiations([40758, 'instantiations'])
11
- })
@@ -1,39 +0,0 @@
1
- import { tempoLocal } from 'tempo.ts/chains'
2
- import { tempoActions } from 'tempo.ts/viem'
3
- import { createClient, http } from 'viem'
4
- import { describe, expect, test } from 'vitest'
5
-
6
- describe('decorator', () => {
7
- const client2 = createClient({
8
- chain: tempoLocal({ feeToken: 1n }),
9
- transport: http(),
10
- }).extend(tempoActions())
11
-
12
- test('default', async () => {
13
- expect(Object.keys(client2)).toMatchInlineSnapshot(`
14
- [
15
- "account",
16
- "batch",
17
- "cacheTime",
18
- "ccipRead",
19
- "chain",
20
- "key",
21
- "name",
22
- "pollingInterval",
23
- "request",
24
- "transport",
25
- "type",
26
- "uid",
27
- "extend",
28
- "verifyHash",
29
- "amm",
30
- "dex",
31
- "faucet",
32
- "fee",
33
- "policy",
34
- "reward",
35
- "token",
36
- ]
37
- `)
38
- })
39
- })