viem 2.50.4 → 2.51.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 +22 -0
- package/_cjs/actions/index.js +5 -3
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/createAccessList.js +3 -0
- package/_cjs/actions/public/createAccessList.js.map +1 -1
- package/_cjs/actions/public/getBlockReceipts.js +19 -0
- package/_cjs/actions/public/getBlockReceipts.js.map +1 -0
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/chains/definitions/somnia.js +7 -0
- package/_cjs/chains/definitions/somnia.js.map +1 -1
- package/_cjs/chains/definitions/somniaTestnet.js +3 -2
- package/_cjs/chains/definitions/somniaTestnet.js.map +1 -1
- package/_cjs/clients/decorators/public.js +2 -0
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/op-stack/actions/buildProveWithdrawal.js +10 -2
- package/_cjs/op-stack/actions/buildProveWithdrawal.js.map +1 -1
- package/_cjs/op-stack/actions/getGame.js.map +1 -1
- package/_cjs/op-stack/actions/getGames.js +3 -1
- package/_cjs/op-stack/actions/getGames.js.map +1 -1
- package/_cjs/op-stack/actions/getTimeToProve.js +3 -3
- package/_cjs/op-stack/actions/getTimeToProve.js.map +1 -1
- package/_cjs/op-stack/actions/getWithdrawalStatus.js +1 -1
- package/_cjs/op-stack/actions/getWithdrawalStatus.js.map +1 -1
- package/_cjs/op-stack/actions/waitToProve.js +4 -3
- package/_cjs/op-stack/actions/waitToProve.js.map +1 -1
- package/_cjs/op-stack/gameTypes.js +9 -0
- package/_cjs/op-stack/gameTypes.js.map +1 -0
- package/_cjs/op-stack/index.js +7 -1
- package/_cjs/op-stack/index.js.map +1 -1
- package/_cjs/op-stack/utils/getL2BlockNumberAtTimestamp.js +29 -0
- package/_cjs/op-stack/utils/getL2BlockNumberAtTimestamp.js.map +1 -0
- package/_cjs/tempo/Abis.js +477 -11
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Account.js +27 -1
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Decorator.js +17 -0
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Transaction.js +10 -2
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/actions/channel.js +377 -0
- package/_cjs/tempo/actions/channel.js.map +1 -0
- package/_cjs/tempo/actions/index.js +2 -1
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/token.js +57 -27
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/index.js +2 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/createAccessList.js +3 -0
- package/_esm/actions/public/createAccessList.js.map +1 -1
- package/_esm/actions/public/getBlockReceipts.js +39 -0
- package/_esm/actions/public/getBlockReceipts.js.map +1 -0
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/chains/definitions/somnia.js +7 -0
- package/_esm/chains/definitions/somnia.js.map +1 -1
- package/_esm/chains/definitions/somniaTestnet.js +3 -2
- package/_esm/chains/definitions/somniaTestnet.js.map +1 -1
- package/_esm/clients/decorators/public.js +2 -0
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/op-stack/actions/buildProveWithdrawal.js +10 -2
- package/_esm/op-stack/actions/buildProveWithdrawal.js.map +1 -1
- package/_esm/op-stack/actions/getGame.js.map +1 -1
- package/_esm/op-stack/actions/getGames.js +3 -1
- package/_esm/op-stack/actions/getGames.js.map +1 -1
- package/_esm/op-stack/actions/getTimeToProve.js +3 -3
- package/_esm/op-stack/actions/getTimeToProve.js.map +1 -1
- package/_esm/op-stack/actions/getWithdrawalStatus.js +1 -1
- package/_esm/op-stack/actions/getWithdrawalStatus.js.map +1 -1
- package/_esm/op-stack/actions/waitToProve.js +4 -3
- package/_esm/op-stack/actions/waitToProve.js.map +1 -1
- package/_esm/op-stack/gameTypes.js +9 -0
- package/_esm/op-stack/gameTypes.js.map +1 -0
- package/_esm/op-stack/index.js +2 -0
- package/_esm/op-stack/index.js.map +1 -1
- package/_esm/op-stack/utils/getL2BlockNumberAtTimestamp.js +33 -0
- package/_esm/op-stack/utils/getL2BlockNumberAtTimestamp.js.map +1 -0
- package/_esm/tempo/Abis.js +476 -10
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Account.js +27 -2
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Decorator.js +17 -0
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Transaction.js +16 -11
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/actions/channel.js +736 -0
- package/_esm/tempo/actions/channel.js.map +1 -0
- package/_esm/tempo/actions/index.js +1 -0
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/token.js +61 -28
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/index.js +1 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/utils/formatters/transactionRequest.js.map +1 -1
- package/_esm/utils/index.js.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/createAccessList.d.ts +2 -1
- package/_types/actions/public/createAccessList.d.ts.map +1 -1
- package/_types/actions/public/getBlockReceipts.d.ts +53 -0
- package/_types/actions/public/getBlockReceipts.d.ts.map +1 -0
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +4 -5
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/chains/definitions/somnia.d.ts +7 -10
- package/_types/chains/definitions/somnia.d.ts.map +1 -1
- package/_types/chains/definitions/somniaTestnet.d.ts +3 -3
- package/_types/chains/definitions/somniaTestnet.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +23 -0
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +2 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/actions/buildProveWithdrawal.d.ts +2 -1
- package/_types/op-stack/actions/buildProveWithdrawal.d.ts.map +1 -1
- package/_types/op-stack/actions/getGame.d.ts +7 -0
- package/_types/op-stack/actions/getGame.d.ts.map +1 -1
- package/_types/op-stack/actions/getGames.d.ts +7 -0
- package/_types/op-stack/actions/getGames.d.ts.map +1 -1
- package/_types/op-stack/actions/getTimeToProve.d.ts +4 -0
- package/_types/op-stack/actions/getTimeToProve.d.ts.map +1 -1
- package/_types/op-stack/actions/getWithdrawalStatus.d.ts +4 -0
- package/_types/op-stack/actions/getWithdrawalStatus.d.ts.map +1 -1
- package/_types/op-stack/actions/waitToProve.d.ts +4 -0
- package/_types/op-stack/actions/waitToProve.d.ts.map +1 -1
- package/_types/op-stack/gameTypes.d.ts +7 -0
- package/_types/op-stack/gameTypes.d.ts.map +1 -0
- package/_types/op-stack/index.d.ts +2 -0
- package/_types/op-stack/index.d.ts.map +1 -1
- package/_types/op-stack/utils/getL2BlockNumberAtTimestamp.d.ts +21 -0
- package/_types/op-stack/utils/getL2BlockNumberAtTimestamp.d.ts.map +1 -0
- package/_types/tempo/Abis.d.ts +3784 -2271
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +32 -1
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +246 -1
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/actions/accessKey.d.ts +339 -0
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/actions/channel.d.ts +4390 -0
- package/_types/tempo/actions/channel.d.ts.map +1 -0
- package/_types/tempo/actions/dex.d.ts +140 -0
- package/_types/tempo/actions/dex.d.ts.map +1 -1
- package/_types/tempo/actions/fee.d.ts +0 -48
- package/_types/tempo/actions/fee.d.ts.map +1 -1
- package/_types/tempo/actions/index.d.ts +1 -0
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/reward.d.ts +74 -18
- package/_types/tempo/actions/reward.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts +629 -141
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/actions/virtualAddress.d.ts +11 -0
- package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +1 -1
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +13 -0
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +6 -1
- package/_types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/_types/utils/index.d.ts +1 -1
- package/_types/utils/index.d.ts.map +1 -1
- package/actions/index.ts +6 -0
- package/actions/public/createAccessList.ts +4 -0
- package/actions/public/getBlockReceipts.ts +101 -0
- package/actions/wallet/prepareTransactionRequest.ts +7 -10
- package/chains/definitions/somnia.ts +7 -0
- package/chains/definitions/somniaTestnet.ts +3 -2
- package/clients/decorators/public.ts +30 -0
- package/errors/version.ts +1 -1
- package/index.ts +6 -0
- package/op-stack/actions/buildProveWithdrawal.ts +17 -2
- package/op-stack/actions/getGame.ts +7 -0
- package/op-stack/actions/getGames.ts +10 -1
- package/op-stack/actions/getTimeToProve.ts +7 -3
- package/op-stack/actions/getWithdrawalStatus.ts +6 -1
- package/op-stack/actions/waitToProve.ts +8 -3
- package/op-stack/gameTypes.ts +9 -0
- package/op-stack/index.ts +7 -1
- package/op-stack/utils/getL2BlockNumberAtTimestamp.ts +57 -0
- package/package.json +2 -2
- package/tempo/Abis.ts +477 -10
- package/tempo/Account.ts +67 -2
- package/tempo/Decorator.ts +299 -1
- package/tempo/Transaction.ts +18 -11
- package/tempo/actions/channel.ts +1197 -0
- package/tempo/actions/index.ts +1 -0
- package/tempo/actions/token.ts +85 -26
- package/tempo/index.ts +1 -0
- package/types/eip1193.ts +13 -0
- package/utils/formatters/transactionRequest.ts +13 -1
- package/utils/index.ts +1 -0
package/tempo/Account.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as P256 from 'ox/P256'
|
|
|
4
4
|
import * as PublicKey from 'ox/PublicKey'
|
|
5
5
|
import * as Secp256k1 from 'ox/Secp256k1'
|
|
6
6
|
import * as Signature from 'ox/Signature'
|
|
7
|
-
import { KeyAuthorization, SignatureEnvelope } from 'ox/tempo'
|
|
7
|
+
import { Channel, KeyAuthorization, SignatureEnvelope } from 'ox/tempo'
|
|
8
8
|
import * as WebAuthnP256 from 'ox/WebAuthnP256'
|
|
9
9
|
import * as WebCryptoP256 from 'ox/WebCryptoP256'
|
|
10
10
|
import type {
|
|
@@ -27,6 +27,8 @@ export type Account_base<source extends string = string> = RequiredBy<
|
|
|
27
27
|
> & {
|
|
28
28
|
/** Key type. */
|
|
29
29
|
keyType: SignatureEnvelope.Type
|
|
30
|
+
/** Sign fn. */
|
|
31
|
+
sign: NonNullable<LocalAccount['sign']>
|
|
30
32
|
/** Sign transaction fn. */
|
|
31
33
|
signTransaction: <
|
|
32
34
|
serializer extends
|
|
@@ -40,6 +42,10 @@ export type Account_base<source extends string = string> = RequiredBy<
|
|
|
40
42
|
}
|
|
41
43
|
| undefined,
|
|
42
44
|
) => Promise<Hex.Hex>
|
|
45
|
+
/** Sign voucher fn. */
|
|
46
|
+
signVoucher: (
|
|
47
|
+
parameters: signVoucher.Parameters,
|
|
48
|
+
) => Promise<signVoucher.ReturnValue>
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
export type RootAccount = Account_base<'root'> & {
|
|
@@ -56,6 +62,21 @@ export type RootAccount = Account_base<'root'> & {
|
|
|
56
62
|
export type AccessKeyAccount = Account_base<'accessKey'> & {
|
|
57
63
|
/** Access key ID. */
|
|
58
64
|
accessKeyAddress: Address.Address
|
|
65
|
+
/**
|
|
66
|
+
* Signs a hash.
|
|
67
|
+
*
|
|
68
|
+
* By default, access key accounts sign through a keychain envelope so the
|
|
69
|
+
* signature authorizes the parent account.
|
|
70
|
+
*
|
|
71
|
+
* Set `raw` to `true` to sign directly with the access key, without keychain
|
|
72
|
+
* hashing or keychain enveloping.
|
|
73
|
+
*/
|
|
74
|
+
sign: (parameters: {
|
|
75
|
+
/** Hash to sign. */
|
|
76
|
+
hash: Hex.Hex
|
|
77
|
+
/** Sign directly with the access key, without keychain hashing or enveloping. */
|
|
78
|
+
raw?: boolean | undefined
|
|
79
|
+
}) => Promise<Hex.Hex>
|
|
59
80
|
}
|
|
60
81
|
|
|
61
82
|
export type Account = OneOf<RootAccount | AccessKeyAccount>
|
|
@@ -377,6 +398,44 @@ export declare namespace fromWebCryptoP256 {
|
|
|
377
398
|
from.ReturnValue<options>
|
|
378
399
|
}
|
|
379
400
|
|
|
401
|
+
export async function signVoucher(
|
|
402
|
+
account: LocalAccount,
|
|
403
|
+
parameters: signVoucher.Parameters,
|
|
404
|
+
): Promise<signVoucher.ReturnValue> {
|
|
405
|
+
return account.sign!({
|
|
406
|
+
hash: getVoucherSignPayload(parameters),
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function getVoucherSignPayload(parameters: signVoucher.Parameters) {
|
|
411
|
+
const { chainId, channel, cumulativeAmount } = parameters
|
|
412
|
+
const channelId =
|
|
413
|
+
typeof channel === 'string'
|
|
414
|
+
? channel
|
|
415
|
+
: Channel.computeId(channel, {
|
|
416
|
+
chainId,
|
|
417
|
+
})
|
|
418
|
+
|
|
419
|
+
return Channel.getVoucherSignPayload({
|
|
420
|
+
chainId,
|
|
421
|
+
channelId,
|
|
422
|
+
cumulativeAmount,
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export declare namespace signVoucher {
|
|
427
|
+
type Parameters = {
|
|
428
|
+
/** Chain ID. */
|
|
429
|
+
chainId: number | bigint
|
|
430
|
+
/** Channel descriptor or ID. */
|
|
431
|
+
channel: Channel.computeId.Channel | Hex.Hex
|
|
432
|
+
/** Total voucher amount signed for the channel. */
|
|
433
|
+
cumulativeAmount: bigint
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
type ReturnValue = Hex.Hex
|
|
437
|
+
}
|
|
438
|
+
|
|
380
439
|
export async function signKeyAuthorization(
|
|
381
440
|
account: LocalAccount,
|
|
382
441
|
parameters: signKeyAuthorization.Parameters,
|
|
@@ -431,7 +490,8 @@ function fromBase(parameters: fromBase.Parameters): Account_base {
|
|
|
431
490
|
includePrefix: false,
|
|
432
491
|
})
|
|
433
492
|
|
|
434
|
-
async function sign({ hash }: { hash: Hex.Hex }) {
|
|
493
|
+
async function sign({ hash, raw }: { hash: Hex.Hex; raw?: boolean }) {
|
|
494
|
+
if (raw) return await parameters.sign({ hash })
|
|
435
495
|
const innerHash =
|
|
436
496
|
parentAddress && internal_version === 'v2'
|
|
437
497
|
? keccak256(Hex.concat('0x04', hash, parentAddress))
|
|
@@ -496,6 +556,11 @@ function fromBase(parameters: fromBase.Parameters): Account_base {
|
|
|
496
556
|
async signTypedData(typedData) {
|
|
497
557
|
return await sign({ hash: hashTypedData(typedData) })
|
|
498
558
|
},
|
|
559
|
+
async signVoucher(parameters) {
|
|
560
|
+
return await sign({
|
|
561
|
+
hash: getVoucherSignPayload(parameters),
|
|
562
|
+
})
|
|
563
|
+
},
|
|
499
564
|
publicKey,
|
|
500
565
|
source,
|
|
501
566
|
type: 'local',
|
package/tempo/Decorator.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { Transport } from '../clients/transports/createTransport.js'
|
|
|
5
5
|
import type { Chain } from '../types/chain.js'
|
|
6
6
|
import * as accessKeyActions from './actions/accessKey.js'
|
|
7
7
|
import * as ammActions from './actions/amm.js'
|
|
8
|
+
import * as channelActions from './actions/channel.js'
|
|
8
9
|
import * as dexActions from './actions/dex.js'
|
|
9
10
|
import * as faucetActions from './actions/faucet.js'
|
|
10
11
|
import * as feeActions from './actions/fee.js'
|
|
@@ -570,6 +571,280 @@ export type Decorator<
|
|
|
570
571
|
parameters: ammActions.watchRebalanceSwap.Parameters,
|
|
571
572
|
) => () => void
|
|
572
573
|
}
|
|
574
|
+
channel: {
|
|
575
|
+
/**
|
|
576
|
+
* Closes a TIP-20 channel reserve channel from the payee or operator side.
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* ```ts
|
|
580
|
+
* import { parseUnits } from 'viem'
|
|
581
|
+
*
|
|
582
|
+
* const hash = await client.channel.close({
|
|
583
|
+
* captureAmount: parseUnits('40', 6),
|
|
584
|
+
* cumulativeAmount: parseUnits('80', 6),
|
|
585
|
+
* channel,
|
|
586
|
+
* signature: '0x...',
|
|
587
|
+
* })
|
|
588
|
+
* ```
|
|
589
|
+
*
|
|
590
|
+
* @param parameters - Parameters.
|
|
591
|
+
* @returns The transaction hash.
|
|
592
|
+
*/
|
|
593
|
+
close: (
|
|
594
|
+
parameters: channelActions.close.Parameters<chain, account>,
|
|
595
|
+
) => Promise<channelActions.close.ReturnValue>
|
|
596
|
+
/**
|
|
597
|
+
* Closes a TIP-20 channel reserve channel and waits for the transaction receipt.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```ts
|
|
601
|
+
* import { parseUnits } from 'viem'
|
|
602
|
+
*
|
|
603
|
+
* const result = await client.channel.closeSync({
|
|
604
|
+
* captureAmount: parseUnits('40', 6),
|
|
605
|
+
* cumulativeAmount: parseUnits('80', 6),
|
|
606
|
+
* channel,
|
|
607
|
+
* signature: '0x...',
|
|
608
|
+
* })
|
|
609
|
+
* ```
|
|
610
|
+
*
|
|
611
|
+
* @param parameters - Parameters.
|
|
612
|
+
* @returns The transaction receipt and event data.
|
|
613
|
+
*/
|
|
614
|
+
closeSync: (
|
|
615
|
+
parameters: channelActions.closeSync.Parameters<chain, account>,
|
|
616
|
+
) => Promise<channelActions.closeSync.ReturnValue>
|
|
617
|
+
/**
|
|
618
|
+
* Gets TIP-20 channel reserve state for a channel ID or channel.
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```ts
|
|
622
|
+
* import { createClient, http } from 'viem'
|
|
623
|
+
* import { tempo } from 'viem/chains'
|
|
624
|
+
* import { tempoActions } from 'viem/tempo'
|
|
625
|
+
*
|
|
626
|
+
* const client = createClient({
|
|
627
|
+
* chain: tempo.extend({ feeToken: '0x20c...001' }),
|
|
628
|
+
* transport: http(),
|
|
629
|
+
* }).extend(tempoActions())
|
|
630
|
+
*
|
|
631
|
+
* const state = await client.channel.getStates({
|
|
632
|
+
* channel: '0x...',
|
|
633
|
+
* })
|
|
634
|
+
* ```
|
|
635
|
+
*
|
|
636
|
+
* @param parameters - Parameters.
|
|
637
|
+
* @returns Channel state for a single channel, or channel states for multiple channels.
|
|
638
|
+
*/
|
|
639
|
+
getStates: <
|
|
640
|
+
const channel extends
|
|
641
|
+
| channelActions.getStates.Channel
|
|
642
|
+
| readonly channelActions.getStates.Channel[],
|
|
643
|
+
>(
|
|
644
|
+
parameters: channelActions.getStates.Parameters<channel>,
|
|
645
|
+
) => Promise<channelActions.getStates.ReturnValue<channel>>
|
|
646
|
+
/**
|
|
647
|
+
* Opens and funds a TIP-20 channel reserve channel.
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* ```ts
|
|
651
|
+
* import { parseUnits } from 'viem'
|
|
652
|
+
*
|
|
653
|
+
* const hash = await client.channel.open({
|
|
654
|
+
* deposit: parseUnits('100', 6),
|
|
655
|
+
* payee: '0x...',
|
|
656
|
+
* token: 1n,
|
|
657
|
+
* })
|
|
658
|
+
* ```
|
|
659
|
+
*
|
|
660
|
+
* @param parameters - Parameters.
|
|
661
|
+
* @returns The transaction hash.
|
|
662
|
+
*/
|
|
663
|
+
open: (
|
|
664
|
+
parameters: channelActions.open.Parameters<chain, account>,
|
|
665
|
+
) => Promise<channelActions.open.ReturnValue>
|
|
666
|
+
/**
|
|
667
|
+
* Opens and funds a TIP-20 channel reserve channel and waits for the transaction receipt.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```ts
|
|
671
|
+
* import { parseUnits } from 'viem'
|
|
672
|
+
*
|
|
673
|
+
* const result = await client.channel.openSync({
|
|
674
|
+
* deposit: parseUnits('100', 6),
|
|
675
|
+
* payee: '0x...',
|
|
676
|
+
* token: 1n,
|
|
677
|
+
* })
|
|
678
|
+
* ```
|
|
679
|
+
*
|
|
680
|
+
* @param parameters - Parameters.
|
|
681
|
+
* @returns The transaction receipt and event data.
|
|
682
|
+
*/
|
|
683
|
+
openSync: (
|
|
684
|
+
parameters: channelActions.openSync.Parameters<chain, account>,
|
|
685
|
+
) => Promise<channelActions.openSync.ReturnValue>
|
|
686
|
+
/**
|
|
687
|
+
* Starts the payer close timer for a TIP-20 channel reserve channel.
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```ts
|
|
691
|
+
* const hash = await client.channel.requestClose({
|
|
692
|
+
* channel,
|
|
693
|
+
* })
|
|
694
|
+
* ```
|
|
695
|
+
*
|
|
696
|
+
* @param parameters - Parameters.
|
|
697
|
+
* @returns The transaction hash.
|
|
698
|
+
*/
|
|
699
|
+
requestClose: (
|
|
700
|
+
parameters: channelActions.requestClose.Parameters<chain, account>,
|
|
701
|
+
) => Promise<channelActions.requestClose.ReturnValue>
|
|
702
|
+
/**
|
|
703
|
+
* Starts the payer close timer and waits for the transaction receipt.
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* ```ts
|
|
707
|
+
* const result = await client.channel.requestCloseSync({
|
|
708
|
+
* channel,
|
|
709
|
+
* })
|
|
710
|
+
* ```
|
|
711
|
+
*
|
|
712
|
+
* @param parameters - Parameters.
|
|
713
|
+
* @returns The transaction receipt and event data.
|
|
714
|
+
*/
|
|
715
|
+
requestCloseSync: (
|
|
716
|
+
parameters: channelActions.requestCloseSync.Parameters<chain, account>,
|
|
717
|
+
) => Promise<channelActions.requestCloseSync.ReturnValue>
|
|
718
|
+
/**
|
|
719
|
+
* Settles a TIP-20 channel reserve voucher.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```ts
|
|
723
|
+
* import { parseUnits } from 'viem'
|
|
724
|
+
*
|
|
725
|
+
* const hash = await client.channel.settle({
|
|
726
|
+
* cumulativeAmount: parseUnits('40', 6),
|
|
727
|
+
* channel,
|
|
728
|
+
* signature: '0x...',
|
|
729
|
+
* })
|
|
730
|
+
* ```
|
|
731
|
+
*
|
|
732
|
+
* @param parameters - Parameters.
|
|
733
|
+
* @returns The transaction hash.
|
|
734
|
+
*/
|
|
735
|
+
settle: (
|
|
736
|
+
parameters: channelActions.settle.Parameters<chain, account>,
|
|
737
|
+
) => Promise<channelActions.settle.ReturnValue>
|
|
738
|
+
/**
|
|
739
|
+
* Settles a TIP-20 channel reserve voucher and waits for the transaction receipt.
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* ```ts
|
|
743
|
+
* import { parseUnits } from 'viem'
|
|
744
|
+
*
|
|
745
|
+
* const result = await client.channel.settleSync({
|
|
746
|
+
* cumulativeAmount: parseUnits('40', 6),
|
|
747
|
+
* channel,
|
|
748
|
+
* signature: '0x...',
|
|
749
|
+
* })
|
|
750
|
+
* ```
|
|
751
|
+
*
|
|
752
|
+
* @param parameters - Parameters.
|
|
753
|
+
* @returns The transaction receipt and event data.
|
|
754
|
+
*/
|
|
755
|
+
settleSync: (
|
|
756
|
+
parameters: channelActions.settleSync.Parameters<chain, account>,
|
|
757
|
+
) => Promise<channelActions.settleSync.ReturnValue>
|
|
758
|
+
/**
|
|
759
|
+
* Signs a TIP-20 channel reserve voucher.
|
|
760
|
+
*
|
|
761
|
+
* @example
|
|
762
|
+
* ```ts
|
|
763
|
+
* import { parseUnits } from 'viem'
|
|
764
|
+
*
|
|
765
|
+
* const signature = await client.channel.signVoucher({
|
|
766
|
+
* channel,
|
|
767
|
+
* cumulativeAmount: parseUnits('40', 6),
|
|
768
|
+
* })
|
|
769
|
+
* ```
|
|
770
|
+
*
|
|
771
|
+
* @param parameters - Parameters.
|
|
772
|
+
* @returns The voucher signature.
|
|
773
|
+
*/
|
|
774
|
+
signVoucher: (
|
|
775
|
+
parameters: channelActions.signVoucher.Parameters<account>,
|
|
776
|
+
) => Promise<channelActions.signVoucher.ReturnValue>
|
|
777
|
+
/**
|
|
778
|
+
* Adds deposit to a TIP-20 channel reserve channel.
|
|
779
|
+
*
|
|
780
|
+
* @example
|
|
781
|
+
* ```ts
|
|
782
|
+
* import { parseUnits } from 'viem'
|
|
783
|
+
*
|
|
784
|
+
* const hash = await client.channel.topUp({
|
|
785
|
+
* additionalDeposit: parseUnits('50', 6),
|
|
786
|
+
* channel,
|
|
787
|
+
* })
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* @param parameters - Parameters.
|
|
791
|
+
* @returns The transaction hash.
|
|
792
|
+
*/
|
|
793
|
+
topUp: (
|
|
794
|
+
parameters: channelActions.topUp.Parameters<chain, account>,
|
|
795
|
+
) => Promise<channelActions.topUp.ReturnValue>
|
|
796
|
+
/**
|
|
797
|
+
* Adds deposit to a TIP-20 channel reserve channel and waits for the transaction receipt.
|
|
798
|
+
*
|
|
799
|
+
* @example
|
|
800
|
+
* ```ts
|
|
801
|
+
* import { parseUnits } from 'viem'
|
|
802
|
+
*
|
|
803
|
+
* const result = await client.channel.topUpSync({
|
|
804
|
+
* additionalDeposit: parseUnits('50', 6),
|
|
805
|
+
* channel,
|
|
806
|
+
* })
|
|
807
|
+
* ```
|
|
808
|
+
*
|
|
809
|
+
* @param parameters - Parameters.
|
|
810
|
+
* @returns The transaction receipt and event data.
|
|
811
|
+
*/
|
|
812
|
+
topUpSync: (
|
|
813
|
+
parameters: channelActions.topUpSync.Parameters<chain, account>,
|
|
814
|
+
) => Promise<channelActions.topUpSync.ReturnValue>
|
|
815
|
+
/**
|
|
816
|
+
* Withdraws payer funds after the close grace period elapses.
|
|
817
|
+
*
|
|
818
|
+
* @example
|
|
819
|
+
* ```ts
|
|
820
|
+
* const hash = await client.channel.withdraw({
|
|
821
|
+
* channel,
|
|
822
|
+
* })
|
|
823
|
+
* ```
|
|
824
|
+
*
|
|
825
|
+
* @param parameters - Parameters.
|
|
826
|
+
* @returns The transaction hash.
|
|
827
|
+
*/
|
|
828
|
+
withdraw: (
|
|
829
|
+
parameters: channelActions.withdraw.Parameters<chain, account>,
|
|
830
|
+
) => Promise<channelActions.withdraw.ReturnValue>
|
|
831
|
+
/**
|
|
832
|
+
* Withdraws payer funds and waits for the transaction receipt.
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```ts
|
|
836
|
+
* const result = await client.channel.withdrawSync({
|
|
837
|
+
* channel,
|
|
838
|
+
* })
|
|
839
|
+
* ```
|
|
840
|
+
*
|
|
841
|
+
* @param parameters - Parameters.
|
|
842
|
+
* @returns The transaction receipt and event data.
|
|
843
|
+
*/
|
|
844
|
+
withdrawSync: (
|
|
845
|
+
parameters: channelActions.withdrawSync.Parameters<chain, account>,
|
|
846
|
+
) => Promise<channelActions.withdrawSync.ReturnValue>
|
|
847
|
+
}
|
|
573
848
|
dex: {
|
|
574
849
|
/**
|
|
575
850
|
* Buys a specific amount of tokens.
|
|
@@ -2507,6 +2782,7 @@ export type Decorator<
|
|
|
2507
2782
|
* name: 'My Token',
|
|
2508
2783
|
* symbol: 'MTK',
|
|
2509
2784
|
* currency: 'USD',
|
|
2785
|
+
* logoURI: 'https://example.com/token.svg',
|
|
2510
2786
|
* })
|
|
2511
2787
|
* ```
|
|
2512
2788
|
*
|
|
@@ -2537,6 +2813,7 @@ export type Decorator<
|
|
|
2537
2813
|
* name: 'My Token',
|
|
2538
2814
|
* symbol: 'MTK',
|
|
2539
2815
|
* currency: 'USD',
|
|
2816
|
+
* logoURI: 'https://example.com/token.svg',
|
|
2540
2817
|
* })
|
|
2541
2818
|
* ```
|
|
2542
2819
|
*
|
|
@@ -2602,7 +2879,7 @@ export type Decorator<
|
|
|
2602
2879
|
parameters: tokenActions.getBalance.Parameters<account>,
|
|
2603
2880
|
) => Promise<tokenActions.getBalance.ReturnValue>
|
|
2604
2881
|
/**
|
|
2605
|
-
* Gets TIP20 token metadata including name, symbol, currency, decimals, and total supply.
|
|
2882
|
+
* Gets TIP20 token metadata including name, symbol, logo URI, currency, decimals, and total supply.
|
|
2606
2883
|
*
|
|
2607
2884
|
* @example
|
|
2608
2885
|
* ```ts
|
|
@@ -4299,6 +4576,27 @@ export function decorator() {
|
|
|
4299
4576
|
watchRebalanceSwap: (parameters) =>
|
|
4300
4577
|
ammActions.watchRebalanceSwap(client, parameters),
|
|
4301
4578
|
},
|
|
4579
|
+
channel: {
|
|
4580
|
+
close: (parameters) => channelActions.close(client, parameters),
|
|
4581
|
+
closeSync: (parameters) => channelActions.closeSync(client, parameters),
|
|
4582
|
+
getStates: (parameters) => channelActions.getStates(client, parameters),
|
|
4583
|
+
open: (parameters) => channelActions.open(client, parameters),
|
|
4584
|
+
openSync: (parameters) => channelActions.openSync(client, parameters),
|
|
4585
|
+
requestClose: (parameters) =>
|
|
4586
|
+
channelActions.requestClose(client, parameters),
|
|
4587
|
+
requestCloseSync: (parameters) =>
|
|
4588
|
+
channelActions.requestCloseSync(client, parameters),
|
|
4589
|
+
settle: (parameters) => channelActions.settle(client, parameters),
|
|
4590
|
+
settleSync: (parameters) =>
|
|
4591
|
+
channelActions.settleSync(client, parameters),
|
|
4592
|
+
signVoucher: (parameters) =>
|
|
4593
|
+
channelActions.signVoucher(client, parameters),
|
|
4594
|
+
topUp: (parameters) => channelActions.topUp(client, parameters),
|
|
4595
|
+
topUpSync: (parameters) => channelActions.topUpSync(client, parameters),
|
|
4596
|
+
withdraw: (parameters) => channelActions.withdraw(client, parameters),
|
|
4597
|
+
withdrawSync: (parameters) =>
|
|
4598
|
+
channelActions.withdrawSync(client, parameters),
|
|
4599
|
+
},
|
|
4302
4600
|
dex: {
|
|
4303
4601
|
buy: (parameters) => dexActions.buy(client, parameters),
|
|
4304
4602
|
buySync: (parameters) => dexActions.buySync(client, parameters),
|
package/tempo/Transaction.ts
CHANGED
|
@@ -303,6 +303,12 @@ async function serializeTempo(
|
|
|
303
303
|
if (feePayerSignature === null || feePayer) return null
|
|
304
304
|
return undefined
|
|
305
305
|
})()
|
|
306
|
+
const hasPrefilledFeePayerSignature =
|
|
307
|
+
typeof transaction.feePayerSignature !== 'undefined' &&
|
|
308
|
+
transaction.feePayerSignature !== null
|
|
309
|
+
const shouldStripFeeTokenForSponsorship =
|
|
310
|
+
(feePayer === true && (!signature || !feePayerSignature)) ||
|
|
311
|
+
(!signature && hasPrefilledFeePayerSignature)
|
|
306
312
|
|
|
307
313
|
const transaction_ox = {
|
|
308
314
|
...rest,
|
|
@@ -325,16 +331,11 @@ async function serializeTempo(
|
|
|
325
331
|
...(nonce ? { nonce: BigInt(nonce) } : {}),
|
|
326
332
|
} satisfies TxTempo.TxEnvelopeTempo
|
|
327
333
|
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
// Once the fee payer has signed (`feePayerSignature` is populated),
|
|
334
|
-
// the relay has chosen a token and signed over it. The broadcast
|
|
335
|
-
// envelope must therefore include `feeToken` so the chain can verify
|
|
336
|
-
// the fee payer's signature and identify which token to charge.
|
|
337
|
-
if (feePayer === true && !feePayerSignature) delete transaction_ox.feeToken
|
|
334
|
+
// Sender does not commit to `feeToken` under sponsorship. Strip it
|
|
335
|
+
// for the sender sign payload and the partial sponsorship handoff envelope.
|
|
336
|
+
// Keep it only on the final broadcast envelope so the chain can verify
|
|
337
|
+
// the fee payer.
|
|
338
|
+
if (shouldStripFeeTokenForSponsorship) delete transaction_ox.feeToken
|
|
338
339
|
|
|
339
340
|
if (signature && typeof transaction.feePayer === 'object') {
|
|
340
341
|
const tx = TxTempo.from(transaction_ox, {
|
|
@@ -364,7 +365,13 @@ async function serializeTempo(
|
|
|
364
365
|
})
|
|
365
366
|
}
|
|
366
367
|
|
|
367
|
-
if (feePayer === true) {
|
|
368
|
+
if (feePayer === true || (!signature && hasPrefilledFeePayerSignature)) {
|
|
369
|
+
// Fee payer signature was prefilled during `eth_fillTransaction` -- emit
|
|
370
|
+
// a full envelope with both signatures to skip `eth_signRawTransaction`.
|
|
371
|
+
if (signature && feePayerSignature)
|
|
372
|
+
return TxTempo.serialize(transaction_ox, {
|
|
373
|
+
signature,
|
|
374
|
+
})
|
|
368
375
|
if (signature)
|
|
369
376
|
return TxTempo.serialize(transaction_ox, {
|
|
370
377
|
format: 'feePayer',
|