tempo.ts 0.6.2 → 0.7.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 +128 -0
- package/README.md +6 -2
- package/dist/ox/Transaction.js +1 -1
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/server/Handler.d.ts +346 -0
- package/dist/server/Handler.d.ts.map +1 -0
- package/dist/server/Handler.js +441 -0
- package/dist/server/Handler.js.map +1 -0
- package/dist/server/Kv.d.ts +16 -0
- package/dist/server/Kv.d.ts.map +1 -0
- package/dist/server/Kv.js +25 -0
- package/dist/server/Kv.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/internal/requestListener.d.ts +124 -0
- package/dist/server/internal/requestListener.d.ts.map +1 -0
- package/dist/server/internal/requestListener.js +174 -0
- package/dist/server/internal/requestListener.js.map +1 -0
- package/dist/viem/Actions/amm.d.ts +51 -1245
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/amm.js +15 -478
- package/dist/viem/Actions/amm.js.map +1 -1
- package/dist/viem/Actions/reward.d.ts +0 -1067
- package/dist/viem/Actions/reward.d.ts.map +1 -1
- package/dist/viem/Actions/reward.js +4 -212
- package/dist/viem/Actions/reward.js.map +1 -1
- package/dist/viem/Decorator.d.ts +0 -263
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +0 -10
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Storage.d.ts +23 -0
- package/dist/viem/Storage.d.ts.map +1 -0
- package/dist/viem/Storage.js +47 -0
- package/dist/viem/Storage.js.map +1 -0
- package/dist/viem/Transport.d.ts +10 -1
- package/dist/viem/Transport.d.ts.map +1 -1
- package/dist/viem/Transport.js +22 -3
- package/dist/viem/Transport.js.map +1 -1
- package/dist/viem/internal/utils.d.ts +6 -0
- package/dist/viem/internal/utils.d.ts.map +1 -1
- package/dist/viem/internal/utils.js +24 -0
- package/dist/viem/internal/utils.js.map +1 -1
- package/dist/wagmi/Actions/amm.d.ts +0 -225
- package/dist/wagmi/Actions/amm.d.ts.map +1 -1
- package/dist/wagmi/Actions/amm.js +0 -248
- package/dist/wagmi/Actions/amm.js.map +1 -1
- package/dist/wagmi/Actions/reward.d.ts +0 -110
- package/dist/wagmi/Actions/reward.d.ts.map +1 -1
- package/dist/wagmi/Actions/reward.js +0 -121
- package/dist/wagmi/Actions/reward.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +6 -17
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +17 -43
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/amm.d.ts +0 -236
- package/dist/wagmi/Hooks/amm.d.ts.map +1 -1
- package/dist/wagmi/Hooks/amm.js +0 -285
- package/dist/wagmi/Hooks/amm.js.map +1 -1
- package/dist/wagmi/Hooks/reward.d.ts +0 -88
- package/dist/wagmi/Hooks/reward.d.ts.map +1 -1
- package/dist/wagmi/Hooks/reward.js +0 -103
- package/dist/wagmi/Hooks/reward.js.map +1 -1
- package/dist/wagmi/KeyManager.d.ts +57 -0
- package/dist/wagmi/KeyManager.d.ts.map +1 -0
- package/dist/wagmi/KeyManager.js +101 -0
- package/dist/wagmi/KeyManager.js.map +1 -0
- package/dist/wagmi/index.d.ts +1 -0
- package/dist/wagmi/index.d.ts.map +1 -1
- package/dist/wagmi/index.js +1 -0
- package/dist/wagmi/index.js.map +1 -1
- package/package.json +8 -2
- package/src/ox/Transaction.ts +1 -1
- package/src/ox/e2e.test.ts +7 -0
- package/src/server/Handler.test.ts +566 -0
- package/src/server/Handler.ts +577 -0
- package/src/server/Kv.ts +40 -0
- package/src/server/index.ts +2 -0
- package/src/server/internal/requestListener.ts +285 -0
- package/src/viem/Actions/amm.test.ts +10 -284
- package/src/viem/Actions/amm.ts +88 -768
- package/src/viem/Actions/reward.test.ts +4 -212
- package/src/viem/Actions/reward.ts +4 -291
- package/src/viem/Decorator.ts +0 -294
- package/src/viem/Storage.ts +88 -0
- package/src/viem/Transport.ts +40 -2
- package/src/viem/e2e.test.ts +106 -3
- package/src/viem/internal/utils.ts +21 -0
- package/src/wagmi/Actions/amm.test.ts +7 -85
- package/src/wagmi/Actions/amm.ts +0 -346
- package/src/wagmi/Actions/reward.test.ts +0 -99
- package/src/wagmi/Actions/reward.ts +0 -203
- package/src/wagmi/Connector.test.ts +4 -1
- package/src/wagmi/Connector.ts +24 -58
- package/src/wagmi/Hooks/amm.test.ts +8 -200
- package/src/wagmi/Hooks/amm.ts +0 -443
- package/src/wagmi/Hooks/reward.test.ts +1 -142
- package/src/wagmi/Hooks/reward.ts +0 -196
- package/src/wagmi/KeyManager.ts +159 -0
- package/src/wagmi/index.ts +1 -0
package/src/wagmi/Actions/amm.ts
CHANGED
|
@@ -192,119 +192,6 @@ export namespace getLiquidityBalance {
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
/**
|
|
196
|
-
* Performs a rebalance swap from validator token to user token.
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* ```ts
|
|
200
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
201
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
202
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
203
|
-
*
|
|
204
|
-
* const config = createConfig({
|
|
205
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
206
|
-
* transports: {
|
|
207
|
-
* [tempo.id]: http(),
|
|
208
|
-
* },
|
|
209
|
-
* })
|
|
210
|
-
*
|
|
211
|
-
* const hash = await Actions.amm.rebalanceSwap(config, {
|
|
212
|
-
* userToken: '0x...',
|
|
213
|
-
* validatorToken: '0x...',
|
|
214
|
-
* amountOut: 100n,
|
|
215
|
-
* to: '0x...',
|
|
216
|
-
* })
|
|
217
|
-
* ```
|
|
218
|
-
*
|
|
219
|
-
* @param config - Config.
|
|
220
|
-
* @param parameters - Parameters.
|
|
221
|
-
* @returns The transaction hash.
|
|
222
|
-
*/
|
|
223
|
-
export async function rebalanceSwap<config extends Config>(
|
|
224
|
-
config: config,
|
|
225
|
-
parameters: rebalanceSwap.Parameters<config>,
|
|
226
|
-
): Promise<viem_Actions.rebalanceSwap.ReturnValue> {
|
|
227
|
-
const { account, chainId, connector } = parameters
|
|
228
|
-
|
|
229
|
-
const client = await getConnectorClient(config, {
|
|
230
|
-
account,
|
|
231
|
-
assertChainId: false,
|
|
232
|
-
chainId,
|
|
233
|
-
connector,
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
return viem_Actions.rebalanceSwap(client, parameters as never)
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export declare namespace rebalanceSwap {
|
|
240
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
241
|
-
ConnectorParameter &
|
|
242
|
-
UnionOmit<
|
|
243
|
-
viem_Actions.rebalanceSwap.Parameters<config['chains'][number], Account>,
|
|
244
|
-
'chain'
|
|
245
|
-
>
|
|
246
|
-
|
|
247
|
-
export type ReturnValue = viem_Actions.rebalanceSwap.ReturnValue
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Performs a rebalance swap from validator token to user token.
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```ts
|
|
255
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
256
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
257
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
258
|
-
*
|
|
259
|
-
* const config = createConfig({
|
|
260
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
261
|
-
* transports: {
|
|
262
|
-
* [tempo.id]: http(),
|
|
263
|
-
* },
|
|
264
|
-
* })
|
|
265
|
-
*
|
|
266
|
-
* const result = await Actions.amm.rebalanceSwapSync(config, {
|
|
267
|
-
* userToken: '0x...',
|
|
268
|
-
* validatorToken: '0x...',
|
|
269
|
-
* amountOut: 100n,
|
|
270
|
-
* to: '0x...',
|
|
271
|
-
* })
|
|
272
|
-
* ```
|
|
273
|
-
*
|
|
274
|
-
* @param config - Config.
|
|
275
|
-
* @param parameters - Parameters.
|
|
276
|
-
* @returns The transaction receipt and event data.
|
|
277
|
-
*/
|
|
278
|
-
export async function rebalanceSwapSync<config extends Config>(
|
|
279
|
-
config: config,
|
|
280
|
-
parameters: rebalanceSwapSync.Parameters<config>,
|
|
281
|
-
): Promise<viem_Actions.rebalanceSwapSync.ReturnValue> {
|
|
282
|
-
const { account, chainId, connector } = parameters
|
|
283
|
-
|
|
284
|
-
const client = await getConnectorClient(config, {
|
|
285
|
-
account,
|
|
286
|
-
assertChainId: false,
|
|
287
|
-
chainId,
|
|
288
|
-
connector,
|
|
289
|
-
})
|
|
290
|
-
|
|
291
|
-
return viem_Actions.rebalanceSwapSync(client, parameters as never)
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export declare namespace rebalanceSwapSync {
|
|
295
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
296
|
-
ConnectorParameter &
|
|
297
|
-
UnionOmit<
|
|
298
|
-
viem_Actions.rebalanceSwapSync.Parameters<
|
|
299
|
-
config['chains'][number],
|
|
300
|
-
Account
|
|
301
|
-
>,
|
|
302
|
-
'chain'
|
|
303
|
-
>
|
|
304
|
-
|
|
305
|
-
export type ReturnValue = viem_Actions.rebalanceSwapSync.ReturnValue
|
|
306
|
-
}
|
|
307
|
-
|
|
308
195
|
/**
|
|
309
196
|
* Adds liquidity to a pool.
|
|
310
197
|
*
|
|
@@ -425,198 +312,6 @@ export declare namespace mintSync {
|
|
|
425
312
|
export type ReturnValue = viem_Actions.mintSync.ReturnValue
|
|
426
313
|
}
|
|
427
314
|
|
|
428
|
-
/**
|
|
429
|
-
* Removes liquidity from a pool.
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
* ```ts
|
|
433
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
434
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
435
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
436
|
-
*
|
|
437
|
-
* const config = createConfig({
|
|
438
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
439
|
-
* transports: {
|
|
440
|
-
* [tempo.id]: http(),
|
|
441
|
-
* },
|
|
442
|
-
* })
|
|
443
|
-
*
|
|
444
|
-
* const hash = await Actions.amm.burn(config, {
|
|
445
|
-
* userToken: '0x20c0...beef',
|
|
446
|
-
* validatorToken: '0x20c0...babe',
|
|
447
|
-
* liquidity: 50n,
|
|
448
|
-
* to: '0xfeed...fede',
|
|
449
|
-
* })
|
|
450
|
-
* ```
|
|
451
|
-
*
|
|
452
|
-
* @param config - Config.
|
|
453
|
-
* @param parameters - Parameters.
|
|
454
|
-
* @returns The transaction hash.
|
|
455
|
-
*/
|
|
456
|
-
export async function burn<config extends Config>(
|
|
457
|
-
config: config,
|
|
458
|
-
parameters: burn.Parameters<config>,
|
|
459
|
-
): Promise<viem_Actions.burn.ReturnValue> {
|
|
460
|
-
const { account, chainId, connector } = parameters
|
|
461
|
-
|
|
462
|
-
const client = await getConnectorClient(config, {
|
|
463
|
-
account,
|
|
464
|
-
assertChainId: false,
|
|
465
|
-
chainId,
|
|
466
|
-
connector,
|
|
467
|
-
})
|
|
468
|
-
|
|
469
|
-
return viem_Actions.burn(client, parameters as never)
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
export declare namespace burn {
|
|
473
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
474
|
-
ConnectorParameter &
|
|
475
|
-
UnionOmit<
|
|
476
|
-
viem_Actions.burn.Parameters<config['chains'][number], Account>,
|
|
477
|
-
'chain'
|
|
478
|
-
>
|
|
479
|
-
|
|
480
|
-
export type ReturnValue = viem_Actions.burn.ReturnValue
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Removes liquidity from a pool.
|
|
485
|
-
*
|
|
486
|
-
* @example
|
|
487
|
-
* ```ts
|
|
488
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
489
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
490
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
491
|
-
*
|
|
492
|
-
* const config = createConfig({
|
|
493
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
494
|
-
* transports: {
|
|
495
|
-
* [tempo.id]: http(),
|
|
496
|
-
* },
|
|
497
|
-
* })
|
|
498
|
-
*
|
|
499
|
-
* const result = await Actions.amm.burnSync(config, {
|
|
500
|
-
* userToken: '0x20c0...beef',
|
|
501
|
-
* validatorToken: '0x20c0...babe',
|
|
502
|
-
* liquidity: 50n,
|
|
503
|
-
* to: '0xfeed...fede',
|
|
504
|
-
* })
|
|
505
|
-
* ```
|
|
506
|
-
*
|
|
507
|
-
* @param config - Config.
|
|
508
|
-
* @param parameters - Parameters.
|
|
509
|
-
* @returns The transaction receipt and event data.
|
|
510
|
-
*/
|
|
511
|
-
export async function burnSync<config extends Config>(
|
|
512
|
-
config: config,
|
|
513
|
-
parameters: burnSync.Parameters<config>,
|
|
514
|
-
): Promise<viem_Actions.burnSync.ReturnValue> {
|
|
515
|
-
const { account, chainId, connector } = parameters
|
|
516
|
-
|
|
517
|
-
const client = await getConnectorClient(config, {
|
|
518
|
-
account,
|
|
519
|
-
assertChainId: false,
|
|
520
|
-
chainId,
|
|
521
|
-
connector,
|
|
522
|
-
})
|
|
523
|
-
|
|
524
|
-
return viem_Actions.burnSync(client, parameters as never)
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
export declare namespace burnSync {
|
|
528
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
529
|
-
ConnectorParameter &
|
|
530
|
-
UnionOmit<
|
|
531
|
-
viem_Actions.burnSync.Parameters<config['chains'][number], Account>,
|
|
532
|
-
'chain'
|
|
533
|
-
>
|
|
534
|
-
|
|
535
|
-
export type ReturnValue = viem_Actions.burnSync.ReturnValue
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Watches for rebalance swap events.
|
|
540
|
-
*
|
|
541
|
-
* @example
|
|
542
|
-
* ```ts
|
|
543
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
544
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
545
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
546
|
-
*
|
|
547
|
-
* const config = createConfig({
|
|
548
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
549
|
-
* transports: {
|
|
550
|
-
* [tempo.id]: http(),
|
|
551
|
-
* },
|
|
552
|
-
* })
|
|
553
|
-
*
|
|
554
|
-
* const unwatch = Actions.amm.watchRebalanceSwap(config, {
|
|
555
|
-
* onRebalanceSwap: (args, log) => {
|
|
556
|
-
* console.log('Rebalance swap:', args)
|
|
557
|
-
* },
|
|
558
|
-
* })
|
|
559
|
-
* ```
|
|
560
|
-
*
|
|
561
|
-
* @param config - Config.
|
|
562
|
-
* @param parameters - Parameters.
|
|
563
|
-
* @returns A function to unsubscribe from the event.
|
|
564
|
-
*/
|
|
565
|
-
export function watchRebalanceSwap<config extends Config>(
|
|
566
|
-
config: config,
|
|
567
|
-
parameters: watchRebalanceSwap.Parameters<config>,
|
|
568
|
-
) {
|
|
569
|
-
const { chainId, ...rest } = parameters
|
|
570
|
-
const client = config.getClient({ chainId })
|
|
571
|
-
return viem_Actions.watchRebalanceSwap(client, rest)
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
export declare namespace watchRebalanceSwap {
|
|
575
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
576
|
-
viem_Actions.watchRebalanceSwap.Parameters
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* Watches for fee swap events.
|
|
581
|
-
*
|
|
582
|
-
* @example
|
|
583
|
-
* ```ts
|
|
584
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
585
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
586
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
587
|
-
*
|
|
588
|
-
* const config = createConfig({
|
|
589
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
590
|
-
* transports: {
|
|
591
|
-
* [tempo.id]: http(),
|
|
592
|
-
* },
|
|
593
|
-
* })
|
|
594
|
-
*
|
|
595
|
-
* const unwatch = Actions.amm.watchFeeSwap(config, {
|
|
596
|
-
* onFeeSwap: (args, log) => {
|
|
597
|
-
* console.log('Fee swap:', args)
|
|
598
|
-
* },
|
|
599
|
-
* })
|
|
600
|
-
* ```
|
|
601
|
-
*
|
|
602
|
-
* @param config - Config.
|
|
603
|
-
* @param parameters - Parameters.
|
|
604
|
-
* @returns A function to unsubscribe from the event.
|
|
605
|
-
*/
|
|
606
|
-
export function watchFeeSwap<config extends Config>(
|
|
607
|
-
config: config,
|
|
608
|
-
parameters: watchFeeSwap.Parameters<config>,
|
|
609
|
-
) {
|
|
610
|
-
const { chainId, ...rest } = parameters
|
|
611
|
-
const client = config.getClient({ chainId })
|
|
612
|
-
return viem_Actions.watchFeeSwap(client, rest)
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
export declare namespace watchFeeSwap {
|
|
616
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
617
|
-
viem_Actions.watchFeeSwap.Parameters
|
|
618
|
-
}
|
|
619
|
-
|
|
620
315
|
/**
|
|
621
316
|
* Watches for liquidity mint events.
|
|
622
317
|
*
|
|
@@ -657,44 +352,3 @@ export declare namespace watchMint {
|
|
|
657
352
|
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
658
353
|
viem_Actions.watchMint.Parameters
|
|
659
354
|
}
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Watches for liquidity burn events.
|
|
663
|
-
*
|
|
664
|
-
* @example
|
|
665
|
-
* ```ts
|
|
666
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
667
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
668
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
669
|
-
*
|
|
670
|
-
* const config = createConfig({
|
|
671
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
672
|
-
* transports: {
|
|
673
|
-
* [tempo.id]: http(),
|
|
674
|
-
* },
|
|
675
|
-
* })
|
|
676
|
-
*
|
|
677
|
-
* const unwatch = Actions.amm.watchBurn(config, {
|
|
678
|
-
* onBurn: (args, log) => {
|
|
679
|
-
* console.log('Liquidity removed:', args)
|
|
680
|
-
* },
|
|
681
|
-
* })
|
|
682
|
-
* ```
|
|
683
|
-
*
|
|
684
|
-
* @param config - Config.
|
|
685
|
-
* @param parameters - Parameters.
|
|
686
|
-
* @returns A function to unsubscribe from the event.
|
|
687
|
-
*/
|
|
688
|
-
export function watchBurn<config extends Config>(
|
|
689
|
-
config: config,
|
|
690
|
-
parameters: watchBurn.Parameters<config>,
|
|
691
|
-
) {
|
|
692
|
-
const { chainId, ...rest } = parameters
|
|
693
|
-
const client = config.getClient({ chainId })
|
|
694
|
-
return viem_Actions.watchBurn(client, rest)
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
export declare namespace watchBurn {
|
|
698
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
699
|
-
viem_Actions.watchBurn.Parameters
|
|
700
|
-
}
|
|
@@ -5,31 +5,6 @@ import { config, queryClient, setupToken } from '../../../test/wagmi/config.js'
|
|
|
5
5
|
import * as actions from './reward.js'
|
|
6
6
|
import * as tokenActions from './token.js'
|
|
7
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
8
|
// TODO: unskip
|
|
34
9
|
describe.skip('claimSync', () => {
|
|
35
10
|
test('default', async () => {
|
|
@@ -59,7 +34,6 @@ describe.skip('claimSync', () => {
|
|
|
59
34
|
// Start immediate reward
|
|
60
35
|
await actions.startSync(config, {
|
|
61
36
|
amount: rewardAmount,
|
|
62
|
-
seconds: 0,
|
|
63
37
|
token,
|
|
64
38
|
})
|
|
65
39
|
|
|
@@ -89,55 +63,6 @@ describe.skip('claimSync', () => {
|
|
|
89
63
|
})
|
|
90
64
|
})
|
|
91
65
|
|
|
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
66
|
describe('getTotalPerSecond', () => {
|
|
142
67
|
test('default', async () => {
|
|
143
68
|
const { token } = await setupToken()
|
|
@@ -184,27 +109,3 @@ describe('setRecipientSync', () => {
|
|
|
184
109
|
expect(recipient).toBe(account.address)
|
|
185
110
|
})
|
|
186
111
|
})
|
|
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
|
-
})
|
|
@@ -5,118 +5,6 @@ import type { Account } from 'viem'
|
|
|
5
5
|
import type { RequiredBy, UnionOmit } from '../../internal/types.js'
|
|
6
6
|
import * as viem_Actions from '../../viem/Actions/reward.js'
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Cancels an active reward stream and refunds remaining tokens.
|
|
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({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
19
|
-
* transports: {
|
|
20
|
-
* [tempo.id]: http(),
|
|
21
|
-
* },
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* const hash = await Actions.reward.cancel(config, {
|
|
25
|
-
* id: 1n,
|
|
26
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
27
|
-
* })
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @param config - Config.
|
|
31
|
-
* @param parameters - Parameters.
|
|
32
|
-
* @returns The transaction hash.
|
|
33
|
-
*/
|
|
34
|
-
export async function cancel<config extends Config>(
|
|
35
|
-
config: config,
|
|
36
|
-
parameters: cancel.Parameters<config>,
|
|
37
|
-
): Promise<viem_Actions.cancel.ReturnValue> {
|
|
38
|
-
const { account, chainId, connector } = parameters
|
|
39
|
-
|
|
40
|
-
const client = await getConnectorClient(config, {
|
|
41
|
-
account,
|
|
42
|
-
assertChainId: false,
|
|
43
|
-
chainId,
|
|
44
|
-
connector,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
return viem_Actions.cancel(client, parameters as never)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export declare namespace cancel {
|
|
51
|
-
export type Parameters<config extends Config = Config> =
|
|
52
|
-
ChainIdParameter<config> &
|
|
53
|
-
ConnectorParameter &
|
|
54
|
-
UnionOmit<
|
|
55
|
-
viem_Actions.cancel.Parameters<config['chains'][number], Account>,
|
|
56
|
-
'chain'
|
|
57
|
-
>
|
|
58
|
-
|
|
59
|
-
export type ReturnValue = viem_Actions.cancel.ReturnValue
|
|
60
|
-
|
|
61
|
-
export type ErrorType = viem_Actions.cancel.ErrorType
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Cancels an active reward stream and waits for confirmation.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```ts
|
|
69
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
70
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
71
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
72
|
-
*
|
|
73
|
-
* const config = createConfig({
|
|
74
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
75
|
-
* transports: {
|
|
76
|
-
* [tempo.id]: http(),
|
|
77
|
-
* },
|
|
78
|
-
* })
|
|
79
|
-
*
|
|
80
|
-
* const result = await Actions.reward.cancelSync(config, {
|
|
81
|
-
* id: 1n,
|
|
82
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
83
|
-
* })
|
|
84
|
-
* ```
|
|
85
|
-
*
|
|
86
|
-
* @param config - Config.
|
|
87
|
-
* @param parameters - Parameters.
|
|
88
|
-
* @returns The transaction receipt and event data.
|
|
89
|
-
*/
|
|
90
|
-
export async function cancelSync<config extends Config>(
|
|
91
|
-
config: config,
|
|
92
|
-
parameters: cancelSync.Parameters<config>,
|
|
93
|
-
): Promise<viem_Actions.cancelSync.ReturnValue> {
|
|
94
|
-
const { account, chainId, connector } = parameters
|
|
95
|
-
|
|
96
|
-
const client = await getConnectorClient(config, {
|
|
97
|
-
account,
|
|
98
|
-
assertChainId: false,
|
|
99
|
-
chainId,
|
|
100
|
-
connector,
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
return viem_Actions.cancelSync(client, parameters as never)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export declare namespace cancelSync {
|
|
107
|
-
export type Parameters<config extends Config = Config> =
|
|
108
|
-
ChainIdParameter<config> &
|
|
109
|
-
ConnectorParameter &
|
|
110
|
-
UnionOmit<
|
|
111
|
-
viem_Actions.cancelSync.Parameters<config['chains'][number], Account>,
|
|
112
|
-
'chain'
|
|
113
|
-
>
|
|
114
|
-
|
|
115
|
-
export type ReturnValue = viem_Actions.cancelSync.ReturnValue
|
|
116
|
-
|
|
117
|
-
export type ErrorType = viem_Actions.cancelSync.ErrorType
|
|
118
|
-
}
|
|
119
|
-
|
|
120
8
|
/**
|
|
121
9
|
* Claims accumulated rewards for a recipient.
|
|
122
10
|
*
|
|
@@ -227,97 +115,6 @@ export declare namespace claimSync {
|
|
|
227
115
|
export type ErrorType = viem_Actions.claimSync.ErrorType
|
|
228
116
|
}
|
|
229
117
|
|
|
230
|
-
/**
|
|
231
|
-
* Gets a reward stream by its ID.
|
|
232
|
-
*
|
|
233
|
-
* @example
|
|
234
|
-
* ```ts
|
|
235
|
-
* import { createConfig, http } from '@wagmi/core'
|
|
236
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
237
|
-
* import { Actions } from 'tempo.ts/wagmi'
|
|
238
|
-
*
|
|
239
|
-
* const config = createConfig({
|
|
240
|
-
* chains: [tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })],
|
|
241
|
-
* transports: {
|
|
242
|
-
* [tempo.id]: http(),
|
|
243
|
-
* },
|
|
244
|
-
* })
|
|
245
|
-
*
|
|
246
|
-
* const stream = await Actions.reward.getStream(config, {
|
|
247
|
-
* id: 1n,
|
|
248
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
249
|
-
* })
|
|
250
|
-
* ```
|
|
251
|
-
*
|
|
252
|
-
* @param config - Config.
|
|
253
|
-
* @param parameters - Parameters.
|
|
254
|
-
* @returns The reward stream details.
|
|
255
|
-
*/
|
|
256
|
-
export function getStream<config extends Config>(
|
|
257
|
-
config: config,
|
|
258
|
-
parameters: getStream.Parameters<config>,
|
|
259
|
-
) {
|
|
260
|
-
const { chainId, ...rest } = parameters
|
|
261
|
-
const client = config.getClient({ chainId })
|
|
262
|
-
return viem_Actions.getStream(client, rest)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export namespace getStream {
|
|
266
|
-
export type Parameters<config extends Config> = ChainIdParameter<config> &
|
|
267
|
-
viem_Actions.getStream.Parameters
|
|
268
|
-
|
|
269
|
-
export type ReturnValue = viem_Actions.getStream.ReturnValue
|
|
270
|
-
|
|
271
|
-
export function queryKey<config extends Config>(
|
|
272
|
-
parameters: Parameters<config>,
|
|
273
|
-
) {
|
|
274
|
-
return ['getStream', parameters] as const
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export type QueryKey<config extends Config> = ReturnType<
|
|
278
|
-
typeof queryKey<config>
|
|
279
|
-
>
|
|
280
|
-
|
|
281
|
-
export function queryOptions<config extends Config, selectData = ReturnValue>(
|
|
282
|
-
config: Config,
|
|
283
|
-
parameters: queryOptions.Parameters<config, selectData>,
|
|
284
|
-
): queryOptions.ReturnValue<config, selectData> {
|
|
285
|
-
const { query, ...rest } = parameters
|
|
286
|
-
return {
|
|
287
|
-
...query,
|
|
288
|
-
queryKey: queryKey(rest),
|
|
289
|
-
async queryFn({ queryKey }) {
|
|
290
|
-
const [, parameters] = queryKey
|
|
291
|
-
return await getStream(config, parameters)
|
|
292
|
-
},
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export declare namespace queryOptions {
|
|
297
|
-
export type Parameters<
|
|
298
|
-
config extends Config,
|
|
299
|
-
selectData = getStream.ReturnValue,
|
|
300
|
-
> = getStream.Parameters<config> & {
|
|
301
|
-
query?:
|
|
302
|
-
| Omit<ReturnValue<config, selectData>, 'queryKey' | 'queryFn'>
|
|
303
|
-
| undefined
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export type ReturnValue<
|
|
307
|
-
config extends Config,
|
|
308
|
-
selectData = getStream.ReturnValue,
|
|
309
|
-
> = RequiredBy<
|
|
310
|
-
Query.QueryOptions<
|
|
311
|
-
getStream.ReturnValue,
|
|
312
|
-
Query.DefaultError,
|
|
313
|
-
selectData,
|
|
314
|
-
getStream.QueryKey<config>
|
|
315
|
-
>,
|
|
316
|
-
'queryKey' | 'queryFn'
|
|
317
|
-
>
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
118
|
/**
|
|
322
119
|
* Gets the total reward per second rate for all active streams.
|
|
323
120
|
*
|
|
@@ -3,6 +3,7 @@ import { cdp } from 'vitest/browser'
|
|
|
3
3
|
import { useAccount, useConnect } from 'wagmi'
|
|
4
4
|
import { renderHook } from '../../test/wagmi/config.js'
|
|
5
5
|
import { webAuthn } from './Connector.js'
|
|
6
|
+
import * as KeyManager from './KeyManager.js'
|
|
6
7
|
|
|
7
8
|
async function setupWebAuthn() {
|
|
8
9
|
const client = cdp()
|
|
@@ -39,7 +40,9 @@ test('connect', async (context) => {
|
|
|
39
40
|
expect(result.current.useAccount.status).toEqual('disconnected')
|
|
40
41
|
|
|
41
42
|
result.current.useConnect.connect({
|
|
42
|
-
connector: webAuthn(
|
|
43
|
+
connector: webAuthn({
|
|
44
|
+
keyManager: KeyManager.localStorage(),
|
|
45
|
+
}),
|
|
43
46
|
capabilities: { createAccount: { label: 'Test Account' } },
|
|
44
47
|
})
|
|
45
48
|
|