tempo.ts 0.7.5 → 0.8.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.
- package/CHANGELOG.md +32 -0
- package/dist/chains.d.ts +6 -20
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +14 -15
- package/dist/chains.js.map +1 -1
- package/dist/ox/KeyAuthorization.d.ts +356 -0
- package/dist/ox/KeyAuthorization.d.ts.map +1 -0
- package/dist/ox/KeyAuthorization.js +360 -0
- package/dist/ox/KeyAuthorization.js.map +1 -0
- package/dist/ox/SignatureEnvelope.d.ts +21 -6
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
- package/dist/ox/SignatureEnvelope.js +43 -3
- package/dist/ox/SignatureEnvelope.js.map +1 -1
- package/dist/ox/Transaction.d.ts +5 -1
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +5 -0
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +9 -0
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.js +17 -4
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
- package/dist/ox/TransactionRequest.d.ts +7 -1
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js +12 -0
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +1 -0
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +1 -0
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.js +1 -1
- package/dist/prool/Instance.js.map +1 -1
- package/{src/prool/internal → dist/prool}/chain.json +4 -2
- package/dist/viem/Abis.d.ts +319 -6
- package/dist/viem/Abis.d.ts.map +1 -1
- package/dist/viem/Abis.js +199 -7
- package/dist/viem/Abis.js.map +1 -1
- package/dist/viem/Account.d.ts +103 -14
- package/dist/viem/Account.d.ts.map +1 -1
- package/dist/viem/Account.js +177 -23
- package/dist/viem/Account.js.map +1 -1
- package/dist/viem/Actions/account.d.ts.map +1 -1
- package/dist/viem/Actions/account.js +4 -5
- package/dist/viem/Actions/account.js.map +1 -1
- package/dist/viem/Actions/amm.d.ts +84 -32
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +12 -32
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/dex.d.ts +156 -4
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/fee.d.ts +4 -0
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/reward.d.ts +78 -0
- package/dist/viem/Actions/reward.d.ts.map +1 -1
- package/dist/viem/Actions/token.d.ts +585 -0
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +2 -2
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Addresses.d.ts +1 -1
- package/dist/viem/Addresses.d.ts.map +1 -1
- package/dist/viem/Addresses.js +1 -1
- package/dist/viem/Addresses.js.map +1 -1
- package/dist/viem/Chain.d.ts +35 -0
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +37 -0
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +193 -16
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +7 -0
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +8 -7
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Storage.d.ts +1 -0
- package/dist/viem/Storage.d.ts.map +1 -1
- package/dist/viem/Storage.js +21 -0
- package/dist/viem/Storage.js.map +1 -1
- package/dist/viem/TokenIds.d.ts +1 -1
- package/dist/viem/TokenIds.d.ts.map +1 -1
- package/dist/viem/TokenIds.js +1 -1
- package/dist/viem/TokenIds.js.map +1 -1
- package/dist/viem/Transaction.d.ts +9 -1
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +2 -1
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/WebAuthnP256.d.ts +4 -1
- package/dist/viem/WebAuthnP256.d.ts.map +1 -1
- package/dist/viem/WebAuthnP256.js +3 -1
- package/dist/viem/WebAuthnP256.js.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +6 -16
- package/dist/wagmi/Actions/amm.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.js +6 -16
- package/dist/wagmi/Actions/amm.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +25 -8
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +120 -27
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/amm.d.ts +6 -16
- package/dist/wagmi/Hooks/amm.d.ts.map +1 -1
- package/dist/wagmi/Hooks/amm.js +6 -16
- package/dist/wagmi/Hooks/amm.js.map +1 -1
- package/package.json +3 -2
- package/src/chains.ts +14 -15
- package/src/ox/KeyAuthorization.test.ts +1332 -0
- package/src/ox/KeyAuthorization.ts +542 -0
- package/src/ox/SignatureEnvelope.test.ts +624 -0
- package/src/ox/SignatureEnvelope.ts +89 -9
- package/src/ox/Transaction.test.ts +214 -0
- package/src/ox/Transaction.ts +13 -1
- package/src/ox/TransactionEnvelopeAA.test.ts +164 -4
- package/src/ox/TransactionEnvelopeAA.ts +36 -3
- package/src/ox/TransactionRequest.ts +22 -1
- package/src/ox/e2e.test.ts +612 -5
- package/src/ox/index.ts +1 -0
- package/src/prool/Instance.ts +1 -1
- package/src/prool/chain.json +238 -0
- package/src/server/Handler.test.ts +20 -36
- package/src/viem/Abis.ts +200 -7
- package/src/viem/Account.test.ts +444 -0
- package/src/viem/Account.ts +355 -42
- package/src/viem/Actions/account.ts +3 -5
- package/src/viem/Actions/amm.test.ts +220 -1
- package/src/viem/Actions/amm.ts +12 -32
- package/src/viem/Actions/token.test.ts +8 -8
- package/src/viem/Actions/token.ts +2 -2
- package/src/viem/Addresses.ts +1 -1
- package/src/viem/Chain.test.ts +168 -0
- package/src/viem/Chain.ts +37 -1
- package/src/viem/Decorator.ts +214 -16
- package/src/viem/Formatters.ts +8 -7
- package/src/viem/Storage.ts +22 -0
- package/src/viem/TokenIds.ts +1 -1
- package/src/viem/Transaction.ts +14 -2
- package/src/viem/WebAuthnP256.ts +8 -2
- package/src/viem/e2e.test.ts +299 -96
- package/src/wagmi/Actions/amm.test.ts +93 -2
- package/src/wagmi/Actions/amm.ts +6 -16
- package/src/wagmi/Connector.test.ts +1 -1
- package/src/wagmi/Connector.ts +184 -54
- package/src/wagmi/Hooks/amm.test.ts +335 -0
- package/src/wagmi/Hooks/amm.ts +6 -16
- package/src/wagmi/Hooks/fee.test.ts +10 -4
- package/src/wagmi/Hooks/token.test.ts +0 -488
- package/dist/viem/internal/account.d.ts +0 -21
- package/dist/viem/internal/account.d.ts.map +0 -1
- package/dist/viem/internal/account.js +0 -61
- package/dist/viem/internal/account.js.map +0 -1
- package/src/viem/internal/account.ts +0 -89
package/src/viem/Decorator.ts
CHANGED
|
@@ -100,6 +100,66 @@ export type Decorator<
|
|
|
100
100
|
getLiquidityBalance: (
|
|
101
101
|
parameters: ammActions.getLiquidityBalance.Parameters,
|
|
102
102
|
) => Promise<ammActions.getLiquidityBalance.ReturnValue>
|
|
103
|
+
/**
|
|
104
|
+
* Removes liquidity from a pool.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { createClient, http } from 'viem'
|
|
109
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
110
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
111
|
+
* import { tempoActions } from 'tempo.ts/viem'
|
|
112
|
+
*
|
|
113
|
+
* const client = createClient({
|
|
114
|
+
* account: privateKeyToAccount('0x...'),
|
|
115
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
116
|
+
* transport: http(),
|
|
117
|
+
* }).extend(tempoActions())
|
|
118
|
+
*
|
|
119
|
+
* const hash = await client.amm.burn({
|
|
120
|
+
* userToken: '0x...',
|
|
121
|
+
* validatorToken: '0x...',
|
|
122
|
+
* liquidity: 50n,
|
|
123
|
+
* to: '0x...',
|
|
124
|
+
* })
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @param parameters - Parameters.
|
|
128
|
+
* @returns The transaction hash.
|
|
129
|
+
*/
|
|
130
|
+
burn: (
|
|
131
|
+
parameters: ammActions.burn.Parameters<chain, account>,
|
|
132
|
+
) => Promise<ammActions.burn.ReturnValue>
|
|
133
|
+
/**
|
|
134
|
+
* Removes liquidity from a pool and waits for confirmation.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* import { createClient, http } from 'viem'
|
|
139
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
140
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
141
|
+
* import { tempoActions } from 'tempo.ts/viem'
|
|
142
|
+
*
|
|
143
|
+
* const client = createClient({
|
|
144
|
+
* account: privateKeyToAccount('0x...'),
|
|
145
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
146
|
+
* transport: http(),
|
|
147
|
+
* }).extend(tempoActions())
|
|
148
|
+
*
|
|
149
|
+
* const { receipt, ...result } = await client.amm.burnSync({
|
|
150
|
+
* userToken: '0x...',
|
|
151
|
+
* validatorToken: '0x...',
|
|
152
|
+
* liquidity: 50n,
|
|
153
|
+
* to: '0x...',
|
|
154
|
+
* })
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @param parameters - Parameters.
|
|
158
|
+
* @returns The transaction receipt and event data.
|
|
159
|
+
*/
|
|
160
|
+
burnSync: (
|
|
161
|
+
parameters: ammActions.burnSync.Parameters<chain, account>,
|
|
162
|
+
) => Promise<ammActions.burnSync.ReturnValue>
|
|
103
163
|
/**
|
|
104
164
|
* Adds liquidity to a pool.
|
|
105
165
|
*
|
|
@@ -117,14 +177,9 @@ export type Decorator<
|
|
|
117
177
|
* }).extend(tempoActions())
|
|
118
178
|
*
|
|
119
179
|
* const hash = await client.amm.mint({
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* },
|
|
124
|
-
* validatorToken: {
|
|
125
|
-
* address: '0x...',
|
|
126
|
-
* amount: 100n,
|
|
127
|
-
* },
|
|
180
|
+
* userTokenAddress: '0x...',
|
|
181
|
+
* validatorTokenAddress: '0x...',
|
|
182
|
+
* validatorTokenAmount: 100n,
|
|
128
183
|
* to: '0x...',
|
|
129
184
|
* })
|
|
130
185
|
* ```
|
|
@@ -152,14 +207,9 @@ export type Decorator<
|
|
|
152
207
|
* }).extend(tempoActions())
|
|
153
208
|
*
|
|
154
209
|
* const result = await client.amm.mintSync({
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* },
|
|
159
|
-
* validatorToken: {
|
|
160
|
-
* address: '0x...',
|
|
161
|
-
* amount: 100n,
|
|
162
|
-
* },
|
|
210
|
+
* userTokenAddress: '0x...',
|
|
211
|
+
* validatorTokenAddress: '0x...',
|
|
212
|
+
* validatorTokenAmount: 100n,
|
|
163
213
|
* to: '0x...',
|
|
164
214
|
* })
|
|
165
215
|
* ```
|
|
@@ -170,6 +220,116 @@ export type Decorator<
|
|
|
170
220
|
mintSync: (
|
|
171
221
|
parameters: ammActions.mintSync.Parameters<chain, account>,
|
|
172
222
|
) => Promise<ammActions.mintSync.ReturnValue>
|
|
223
|
+
/**
|
|
224
|
+
* Swaps tokens during a rebalance operation.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* import { createClient, http } from 'viem'
|
|
229
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
230
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
231
|
+
* import { tempoActions } from 'tempo.ts/viem'
|
|
232
|
+
*
|
|
233
|
+
* const client = createClient({
|
|
234
|
+
* account: privateKeyToAccount('0x...'),
|
|
235
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
236
|
+
* transport: http(),
|
|
237
|
+
* }).extend(tempoActions())
|
|
238
|
+
*
|
|
239
|
+
* const hash = await client.amm.rebalanceSwap({
|
|
240
|
+
* userToken: '0x...',
|
|
241
|
+
* validatorToken: '0x...',
|
|
242
|
+
* amountOut: 100n,
|
|
243
|
+
* to: '0x...',
|
|
244
|
+
* })
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* @param parameters - Parameters.
|
|
248
|
+
* @returns The transaction hash.
|
|
249
|
+
*/
|
|
250
|
+
rebalanceSwap: (
|
|
251
|
+
parameters: ammActions.rebalanceSwap.Parameters<chain, account>,
|
|
252
|
+
) => Promise<ammActions.rebalanceSwap.ReturnValue>
|
|
253
|
+
/**
|
|
254
|
+
* Swaps tokens during a rebalance operation and waits for confirmation.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* import { createClient, http } from 'viem'
|
|
259
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
260
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
261
|
+
* import { tempoActions } from 'tempo.ts/viem'
|
|
262
|
+
*
|
|
263
|
+
* const client = createClient({
|
|
264
|
+
* account: privateKeyToAccount('0x...'),
|
|
265
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
266
|
+
* transport: http(),
|
|
267
|
+
* }).extend(tempoActions())
|
|
268
|
+
*
|
|
269
|
+
* const { receipt, ...result } = await client.amm.rebalanceSwapSync({
|
|
270
|
+
* userToken: '0x...',
|
|
271
|
+
* validatorToken: '0x...',
|
|
272
|
+
* amountOut: 100n,
|
|
273
|
+
* to: '0x...',
|
|
274
|
+
* })
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* @param parameters - Parameters.
|
|
278
|
+
* @returns The transaction receipt and event data.
|
|
279
|
+
*/
|
|
280
|
+
rebalanceSwapSync: (
|
|
281
|
+
parameters: ammActions.rebalanceSwapSync.Parameters<chain, account>,
|
|
282
|
+
) => Promise<ammActions.rebalanceSwapSync.ReturnValue>
|
|
283
|
+
/**
|
|
284
|
+
* Watches for burn (liquidity removal) events.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
* import { createClient, http } from 'viem'
|
|
289
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
290
|
+
* import { tempoActions } from 'tempo.ts/viem'
|
|
291
|
+
*
|
|
292
|
+
* const client = createClient({
|
|
293
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
294
|
+
* transport: http(),
|
|
295
|
+
* }).extend(tempoActions())
|
|
296
|
+
*
|
|
297
|
+
* const unwatch = client.amm.watchBurn({
|
|
298
|
+
* onBurn: (args, log) => {
|
|
299
|
+
* console.log('Liquidity removed:', args)
|
|
300
|
+
* },
|
|
301
|
+
* })
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
* @param parameters - Parameters.
|
|
305
|
+
* @returns A function to unsubscribe from the event.
|
|
306
|
+
*/
|
|
307
|
+
watchBurn: (parameters: ammActions.watchBurn.Parameters) => () => void
|
|
308
|
+
/**
|
|
309
|
+
* Watches for fee swap events.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* import { createClient, http } from 'viem'
|
|
314
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
315
|
+
* import { tempoActions } from 'tempo.ts/viem'
|
|
316
|
+
*
|
|
317
|
+
* const client = createClient({
|
|
318
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
319
|
+
* transport: http(),
|
|
320
|
+
* }).extend(tempoActions())
|
|
321
|
+
*
|
|
322
|
+
* const unwatch = client.amm.watchFeeSwap({
|
|
323
|
+
* onFeeSwap: (args, log) => {
|
|
324
|
+
* console.log('Fee swap:', args)
|
|
325
|
+
* },
|
|
326
|
+
* })
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @param parameters - Parameters.
|
|
330
|
+
* @returns A function to unsubscribe from the event.
|
|
331
|
+
*/
|
|
332
|
+
watchFeeSwap: (parameters: ammActions.watchFeeSwap.Parameters) => () => void
|
|
173
333
|
/**
|
|
174
334
|
* Watches for liquidity mint events.
|
|
175
335
|
*
|
|
@@ -195,6 +355,33 @@ export type Decorator<
|
|
|
195
355
|
* @returns A function to unsubscribe from the event.
|
|
196
356
|
*/
|
|
197
357
|
watchMint: (parameters: ammActions.watchMint.Parameters) => () => void
|
|
358
|
+
/**
|
|
359
|
+
* Watches for rebalance swap events.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* import { createClient, http } from 'viem'
|
|
364
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
365
|
+
* import { tempoActions } from 'tempo.ts/viem'
|
|
366
|
+
*
|
|
367
|
+
* const client = createClient({
|
|
368
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
369
|
+
* transport: http(),
|
|
370
|
+
* }).extend(tempoActions())
|
|
371
|
+
*
|
|
372
|
+
* const unwatch = client.amm.watchRebalanceSwap({
|
|
373
|
+
* onRebalanceSwap: (args, log) => {
|
|
374
|
+
* console.log('Rebalance swap:', args)
|
|
375
|
+
* },
|
|
376
|
+
* })
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
* @param parameters - Parameters.
|
|
380
|
+
* @returns A function to unsubscribe from the event.
|
|
381
|
+
*/
|
|
382
|
+
watchRebalanceSwap: (
|
|
383
|
+
parameters: ammActions.watchRebalanceSwap.Parameters,
|
|
384
|
+
) => () => void
|
|
198
385
|
}
|
|
199
386
|
dex: {
|
|
200
387
|
/**
|
|
@@ -2706,9 +2893,20 @@ export function decorator() {
|
|
|
2706
2893
|
getPool: (parameters) => ammActions.getPool(client, parameters),
|
|
2707
2894
|
getLiquidityBalance: (parameters) =>
|
|
2708
2895
|
ammActions.getLiquidityBalance(client, parameters),
|
|
2896
|
+
burn: (parameters) => ammActions.burn(client, parameters),
|
|
2897
|
+
burnSync: (parameters) => ammActions.burnSync(client, parameters),
|
|
2709
2898
|
mint: (parameters) => ammActions.mint(client, parameters),
|
|
2710
2899
|
mintSync: (parameters) => ammActions.mintSync(client, parameters),
|
|
2900
|
+
rebalanceSwap: (parameters) =>
|
|
2901
|
+
ammActions.rebalanceSwap(client, parameters),
|
|
2902
|
+
rebalanceSwapSync: (parameters) =>
|
|
2903
|
+
ammActions.rebalanceSwapSync(client, parameters),
|
|
2904
|
+
watchBurn: (parameters) => ammActions.watchBurn(client, parameters),
|
|
2905
|
+
watchFeeSwap: (parameters) =>
|
|
2906
|
+
ammActions.watchFeeSwap(client, parameters),
|
|
2711
2907
|
watchMint: (parameters) => ammActions.watchMint(client, parameters),
|
|
2908
|
+
watchRebalanceSwap: (parameters) =>
|
|
2909
|
+
ammActions.watchRebalanceSwap(client, parameters),
|
|
2712
2910
|
},
|
|
2713
2911
|
dex: {
|
|
2714
2912
|
buy: (parameters) => dexActions.buy(client, parameters),
|
package/src/viem/Formatters.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { parseAccount } from 'viem/accounts'
|
|
|
12
12
|
import type { UnionOmit } from '../internal/types.js'
|
|
13
13
|
import * as ox_Transaction from '../ox/Transaction.js'
|
|
14
14
|
import * as ox_TransactionRequest from '../ox/TransactionRequest.js'
|
|
15
|
+
import type { Account } from './Account.js'
|
|
15
16
|
import type { GetFeeTokenParameter } from './internal/types.js'
|
|
16
17
|
import {
|
|
17
18
|
isTempo,
|
|
@@ -77,6 +78,7 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
|
77
78
|
action?: string | undefined,
|
|
78
79
|
): TransactionRequestRpc {
|
|
79
80
|
const request = r as Request<chain>
|
|
81
|
+
const account = request.account as Account | undefined
|
|
80
82
|
|
|
81
83
|
// Convert EIP-1559 transactions to AA transactions.
|
|
82
84
|
if (request.type === 'eip1559') (request as any).type = 'aa'
|
|
@@ -91,7 +93,7 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
|
91
93
|
if (action)
|
|
92
94
|
request.calls = request.calls ?? [
|
|
93
95
|
{
|
|
94
|
-
to: r.to ||
|
|
96
|
+
to: r.to || '0x0000000000000000000000000000000000000000',
|
|
95
97
|
value: r.value,
|
|
96
98
|
data: r.data,
|
|
97
99
|
},
|
|
@@ -106,11 +108,10 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
|
106
108
|
s: BigInt(auth.s!),
|
|
107
109
|
yParity: Number(auth.yParity),
|
|
108
110
|
})),
|
|
109
|
-
nonce: request.nonce ? BigInt(request.nonce) : undefined,
|
|
110
111
|
type: 'aa',
|
|
111
112
|
} as never)
|
|
112
113
|
|
|
113
|
-
if (action === 'estimateGas'
|
|
114
|
+
if (action === 'estimateGas') {
|
|
114
115
|
rpc.maxFeePerGas = undefined
|
|
115
116
|
rpc.maxPriorityFeePerGas = undefined
|
|
116
117
|
}
|
|
@@ -140,12 +141,12 @@ export function formatTransactionRequest<chain extends Chain | undefined>(
|
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
const [keyType, keyData] = (() => {
|
|
143
|
-
|
|
144
|
-
if (
|
|
144
|
+
const type = account?.keyType || account?.source
|
|
145
|
+
if (!type) return [undefined, undefined]
|
|
146
|
+
if (type === 'webAuthn')
|
|
145
147
|
// TODO: derive correct bytes size of key data based on webauthn create metadata.
|
|
146
148
|
return ['webAuthn', `0x${'ff'.repeat(1400)}`]
|
|
147
|
-
if (['p256', 'secp256k1'].includes(
|
|
148
|
-
return [r.account.source, undefined]
|
|
149
|
+
if (['p256', 'secp256k1'].includes(type)) return [type, undefined]
|
|
149
150
|
return [undefined, undefined]
|
|
150
151
|
})()
|
|
151
152
|
|
package/src/viem/Storage.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { createStore, del, get, set } from 'idb-keyval'
|
|
1
2
|
import * as Json from 'ox/Json'
|
|
2
3
|
|
|
3
4
|
import type { MaybePromise } from '../internal/types.js'
|
|
5
|
+
import { normalizeValue } from './internal/utils.js'
|
|
4
6
|
|
|
5
7
|
export type Storage<
|
|
6
8
|
schema extends Record<string, unknown> = Record<string, unknown>,
|
|
@@ -33,6 +35,26 @@ export namespace from {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
export function idb<schema extends Record<string, unknown>>() {
|
|
39
|
+
const store =
|
|
40
|
+
typeof indexedDB !== 'undefined'
|
|
41
|
+
? createStore('tempo.ts', 'store')
|
|
42
|
+
: undefined
|
|
43
|
+
return from<schema>({
|
|
44
|
+
async getItem(name) {
|
|
45
|
+
const value = await get(name, store)
|
|
46
|
+
if (value === null) return null
|
|
47
|
+
return value
|
|
48
|
+
},
|
|
49
|
+
async removeItem(name) {
|
|
50
|
+
await del(name, store)
|
|
51
|
+
},
|
|
52
|
+
async setItem(name, value) {
|
|
53
|
+
await set(name, normalizeValue(value), store)
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
export function localStorage<schema extends Record<string, unknown>>(
|
|
37
59
|
options: localStorage.Options = {},
|
|
38
60
|
) {
|
package/src/viem/TokenIds.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const pathUsd = 0n
|
package/src/viem/Transaction.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
type TransactionType as viem_TransactionType,
|
|
30
30
|
} from 'viem'
|
|
31
31
|
import type { ExactPartial, OneOf, PartialBy } from '../internal/types.js'
|
|
32
|
+
import type * as KeyAuthorization from '../ox/KeyAuthorization.js'
|
|
32
33
|
import * as SignatureEnvelope from '../ox/SignatureEnvelope.js'
|
|
33
34
|
import * as TxAA from '../ox/TransactionEnvelopeAA.js'
|
|
34
35
|
import type * as ox_TransactionReceipt from '../ox/TransactionReceipt.js'
|
|
@@ -43,7 +44,11 @@ export type Transaction<
|
|
|
43
44
|
>
|
|
44
45
|
export type TransactionRpc<pending extends boolean = false> = OneOf<
|
|
45
46
|
| viem_RpcTransaction<pending>
|
|
46
|
-
| (Omit<
|
|
47
|
+
| (Omit<
|
|
48
|
+
TransactionAA<Hex.Hex, Hex.Hex, pending, '0x76'>,
|
|
49
|
+
'keyAuthorization' | 'signature'
|
|
50
|
+
> & {
|
|
51
|
+
keyAuthorization?: KeyAuthorization.Rpc | null | undefined
|
|
47
52
|
signature: SignatureEnvelope.SignatureEnvelopeRpc
|
|
48
53
|
})
|
|
49
54
|
>
|
|
@@ -66,6 +71,7 @@ export type TransactionAA<
|
|
|
66
71
|
chainId: index
|
|
67
72
|
feeToken?: Address | undefined
|
|
68
73
|
feePayerSignature?: viem_Signature | undefined
|
|
74
|
+
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | null | undefined
|
|
69
75
|
nonceKey?: quantity | undefined
|
|
70
76
|
signature: SignatureEnvelope.SignatureEnvelope
|
|
71
77
|
type: type
|
|
@@ -109,9 +115,13 @@ export type TransactionRequestAA<
|
|
|
109
115
|
ExactPartial<FeeValuesEIP1559<quantity>> & {
|
|
110
116
|
accessList?: AccessList | undefined
|
|
111
117
|
authorizationList?: AuthorizationList<index, boolean> | undefined
|
|
118
|
+
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
|
|
112
119
|
calls?: readonly TxAA.Call<quantity>[] | undefined
|
|
113
120
|
feePayer?: Account | true | undefined
|
|
114
121
|
feeToken?: Address | bigint | undefined
|
|
122
|
+
nonceKey?: 'random' | quantity | undefined
|
|
123
|
+
validBefore?: index | undefined
|
|
124
|
+
validAfter?: index | undefined
|
|
115
125
|
}
|
|
116
126
|
|
|
117
127
|
export type TransactionSerializable = OneOf<
|
|
@@ -129,6 +139,7 @@ export type TransactionSerializableAA<
|
|
|
129
139
|
chainId: number
|
|
130
140
|
feeToken?: Address | bigint | undefined
|
|
131
141
|
feePayerSignature?: viem_Signature | null | undefined
|
|
142
|
+
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
|
|
132
143
|
nonceKey?: quantity | undefined
|
|
133
144
|
signature?: SignatureEnvelope.SignatureEnvelope<quantity, index> | undefined
|
|
134
145
|
validBefore?: index | undefined
|
|
@@ -151,6 +162,7 @@ export function getType(
|
|
|
151
162
|
typeof transaction.calls !== 'undefined' ||
|
|
152
163
|
typeof transaction.feePayer !== 'undefined' ||
|
|
153
164
|
typeof transaction.feeToken !== 'undefined' ||
|
|
165
|
+
typeof transaction.nonceKey !== 'undefined' ||
|
|
154
166
|
typeof transaction.signature !== 'undefined' ||
|
|
155
167
|
typeof transaction.validBefore !== 'undefined' ||
|
|
156
168
|
typeof transaction.validAfter !== 'undefined'
|
|
@@ -303,7 +315,7 @@ async function serializeAA(
|
|
|
303
315
|
? rest.calls
|
|
304
316
|
: [
|
|
305
317
|
{
|
|
306
|
-
to: rest.to ||
|
|
318
|
+
to: rest.to || '0x0000000000000000000000000000000000000000',
|
|
307
319
|
value: rest.value,
|
|
308
320
|
data: rest.data,
|
|
309
321
|
},
|
package/src/viem/WebAuthnP256.ts
CHANGED
|
@@ -117,15 +117,17 @@ export declare namespace createCredential {
|
|
|
117
117
|
export async function getCredential(
|
|
118
118
|
parameters: getCredential.Parameters,
|
|
119
119
|
): Promise<getCredential.ReturnValue> {
|
|
120
|
-
const { raw } = await WebAuthnP256.sign({
|
|
120
|
+
const { metadata, raw, signature } = await WebAuthnP256.sign({
|
|
121
121
|
...parameters,
|
|
122
122
|
challenge: parameters.hash ?? '0x',
|
|
123
123
|
})
|
|
124
124
|
const publicKey = await parameters.getPublicKey(raw)
|
|
125
125
|
return {
|
|
126
126
|
id: raw.id,
|
|
127
|
+
metadata,
|
|
127
128
|
publicKey,
|
|
128
129
|
raw,
|
|
130
|
+
signature,
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
|
|
@@ -136,5 +138,9 @@ export declare namespace getCredential {
|
|
|
136
138
|
credential: WebAuthnP256.P256Credential['raw'],
|
|
137
139
|
) => Promise<Hex.Hex>
|
|
138
140
|
}
|
|
139
|
-
|
|
141
|
+
|
|
142
|
+
export type ReturnValue = WebAuthnP256.sign.ReturnType & {
|
|
143
|
+
id: string
|
|
144
|
+
publicKey: Hex.Hex
|
|
145
|
+
}
|
|
140
146
|
}
|