viem 3.0.0-next.13 → 3.0.0-next.14
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/dist/chains/definitions/arcTestnet.d.ts +5 -5
- package/dist/chains/definitions/arcTestnet.d.ts.map +1 -1
- package/dist/chains/definitions/arcTestnet.js +11 -8
- package/dist/chains/definitions/arcTestnet.js.map +1 -1
- package/dist/chains/definitions/qmsTestnet.d.ts +27 -0
- package/dist/chains/definitions/qmsTestnet.d.ts.map +1 -0
- package/dist/chains/definitions/qmsTestnet.js +23 -0
- package/dist/chains/definitions/qmsTestnet.js.map +1 -0
- package/dist/chains/definitions/tempo.d.ts +1 -1
- package/dist/chains/definitions/tempo.js +1 -1
- package/dist/chains/definitions/tempoModerato.d.ts +2 -2
- package/dist/chains/definitions/tempoModerato.js +2 -2
- package/dist/chains/index.d.ts +1 -0
- package/dist/chains/index.d.ts.map +1 -1
- package/dist/chains/index.js +1 -0
- package/dist/chains/index.js.map +1 -1
- package/dist/core/actions/transaction/waitForReceipt.d.ts +1 -1
- package/dist/core/actions/transaction/waitForReceipt.d.ts.map +1 -1
- package/dist/core/actions/transaction/waitForReceipt.js +5 -2
- package/dist/core/actions/transaction/waitForReceipt.js.map +1 -1
- package/dist/core/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
- package/dist/core/actions/wallet/waitForCallsStatus.js +24 -1
- package/dist/core/actions/wallet/waitForCallsStatus.js.map +1 -1
- package/dist/internal/inference.d.ts +3 -3
- package/dist/internal/inference.d.ts.map +1 -1
- package/dist/tempo/Abis.d.ts +1935 -899
- package/dist/tempo/Abis.d.ts.map +1 -1
- package/dist/tempo/Abis.js +215 -0
- package/dist/tempo/Abis.js.map +1 -1
- package/dist/tempo/Account.d.ts +30 -30
- package/dist/tempo/Account.d.ts.map +1 -1
- package/dist/tempo/Account.js +43 -43
- package/dist/tempo/Account.js.map +1 -1
- package/dist/tempo/Addresses.d.ts +2 -0
- package/dist/tempo/Addresses.d.ts.map +1 -1
- package/dist/tempo/Addresses.js +2 -0
- package/dist/tempo/Addresses.js.map +1 -1
- package/dist/tempo/Decorator.d.ts +33 -10
- package/dist/tempo/Decorator.d.ts.map +1 -1
- package/dist/tempo/Decorator.js +9 -8
- package/dist/tempo/Decorator.js.map +1 -1
- package/dist/tempo/ExecutionError.js +1 -1
- package/dist/tempo/ExecutionError.js.map +1 -1
- package/dist/tempo/KeyAuthorizationManager.d.ts +24 -13
- package/dist/tempo/KeyAuthorizationManager.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorizationManager.js +44 -25
- package/dist/tempo/KeyAuthorizationManager.js.map +1 -1
- package/dist/tempo/Relay.d.ts +61 -12
- package/dist/tempo/Relay.d.ts.map +1 -1
- package/dist/tempo/Relay.js +48 -8
- package/dist/tempo/Relay.js.map +1 -1
- package/dist/tempo/Selectors.d.ts +12 -0
- package/dist/tempo/Selectors.d.ts.map +1 -1
- package/dist/tempo/Selectors.js +12 -0
- package/dist/tempo/Selectors.js.map +1 -1
- package/dist/tempo/Transport.d.ts +19 -6
- package/dist/tempo/Transport.d.ts.map +1 -1
- package/dist/tempo/Transport.js +18 -12
- package/dist/tempo/Transport.js.map +1 -1
- package/dist/tempo/{multisig → accounts}/Config.d.ts +8 -8
- package/dist/tempo/accounts/Config.d.ts.map +1 -0
- package/dist/tempo/{multisig → accounts}/Config.js +14 -14
- package/dist/tempo/{multisig → accounts}/Config.js.map +1 -1
- package/dist/tempo/{multisig → accounts}/Operation.d.ts +8 -8
- package/dist/tempo/{multisig → accounts}/Operation.d.ts.map +1 -1
- package/dist/tempo/{multisig → accounts}/Operation.js +17 -17
- package/dist/tempo/{multisig → accounts}/Operation.js.map +1 -1
- package/dist/tempo/{multisig → accounts}/Signature.d.ts +1 -1
- package/dist/tempo/accounts/Signature.d.ts.map +1 -0
- package/dist/tempo/accounts/Signature.js +9 -0
- package/dist/tempo/accounts/Signature.js.map +1 -0
- package/dist/tempo/actions/accessKey/index.d.ts +1 -0
- package/dist/tempo/actions/accessKey/index.d.ts.map +1 -1
- package/dist/tempo/actions/accessKey/index.js +1 -0
- package/dist/tempo/actions/accessKey/index.js.map +1 -1
- package/dist/tempo/actions/accessKey/prepareAuthorization.d.ts +4 -4
- package/dist/tempo/actions/accessKey/prepareAuthorization.d.ts.map +1 -1
- package/dist/tempo/actions/accessKey/prepareAuthorization.js +10 -10
- package/dist/tempo/actions/accessKey/prepareAuthorization.js.map +1 -1
- package/dist/tempo/actions/accessKey/saveAuthorization.d.ts +40 -0
- package/dist/tempo/actions/accessKey/saveAuthorization.d.ts.map +1 -0
- package/dist/tempo/actions/accessKey/saveAuthorization.js +32 -0
- package/dist/tempo/actions/accessKey/saveAuthorization.js.map +1 -0
- package/dist/tempo/actions/accessKey/signAuthorization.d.ts +17 -13
- package/dist/tempo/actions/accessKey/signAuthorization.d.ts.map +1 -1
- package/dist/tempo/actions/accessKey/signAuthorization.js +43 -30
- package/dist/tempo/actions/accessKey/signAuthorization.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getConfig.d.ts +5 -5
- package/dist/tempo/actions/accounts/getConfig.d.ts.map +1 -0
- package/dist/tempo/actions/{multisig → accounts}/getConfig.js +5 -5
- package/dist/tempo/actions/accounts/getConfig.js.map +1 -0
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.d.ts +3 -3
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.js +2 -2
- package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getOperation.d.ts +4 -4
- package/dist/tempo/actions/{multisig → accounts}/getOperation.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/getOperation.js +4 -4
- package/dist/tempo/actions/accounts/getOperation.js.map +1 -0
- package/dist/tempo/actions/{multisig → accounts}/index.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/index.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.d.ts +12 -12
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.js +16 -21
- package/dist/tempo/actions/{multisig → accounts}/updateConfig.js.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.d.ts +6 -6
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.d.ts.map +1 -1
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.js +6 -6
- package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.js.map +1 -1
- package/dist/tempo/actions/index.d.ts +2 -2
- package/dist/tempo/actions/index.d.ts.map +1 -1
- package/dist/tempo/actions/index.js +2 -2
- package/dist/tempo/actions/index.js.map +1 -1
- package/dist/tempo/chainConfig.d.ts +16 -16
- package/dist/tempo/chainConfig.d.ts.map +1 -1
- package/dist/tempo/chainConfig.js +52 -52
- package/dist/tempo/chainConfig.js.map +1 -1
- package/dist/tempo/index.d.ts +2 -2
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +2 -2
- package/dist/tempo/index.js.map +1 -1
- package/dist/tempo/internal/relay/accounts.d.ts +15 -0
- package/dist/tempo/internal/relay/accounts.d.ts.map +1 -0
- package/dist/tempo/internal/relay/{multisig.js → accounts.js} +96 -101
- package/dist/tempo/internal/relay/accounts.js.map +1 -0
- package/dist/tempo/internal/relay/feePayer.js +5 -5
- package/dist/tempo/internal/relay/feePayer.js.map +1 -1
- package/dist/tempo/internal/relay/keyAuthorization.d.ts +25 -0
- package/dist/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
- package/dist/tempo/internal/relay/keyAuthorization.js +339 -0
- package/dist/tempo/internal/relay/keyAuthorization.js.map +1 -0
- package/dist/tempo/internal/relay/plugin.d.ts +6 -3
- package/dist/tempo/internal/relay/plugin.d.ts.map +1 -1
- package/dist/tempo/internal/relay/plugin.js +15 -6
- package/dist/tempo/internal/relay/plugin.js.map +1 -1
- package/dist/tempo/internal/relay/utils.d.ts +8 -0
- package/dist/tempo/internal/relay/utils.d.ts.map +1 -1
- package/dist/utils/RpcClient.d.ts.map +1 -1
- package/dist/utils/RpcClient.js +36 -19
- package/dist/utils/RpcClient.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/chains/definitions/arcTestnet.ts +11 -8
- package/src/chains/definitions/qmsTestnet.ts +23 -0
- package/src/chains/definitions/tempo.ts +1 -1
- package/src/chains/definitions/tempoModerato.ts +2 -2
- package/src/chains/index.ts +1 -0
- package/src/core/actions/transaction/waitForReceipt.ts +5 -3
- package/src/core/actions/wallet/waitForCallsStatus.ts +25 -1
- package/src/internal/inference.ts +3 -3
- package/src/tempo/Abis.ts +216 -0
- package/src/tempo/Account.ts +97 -87
- package/src/tempo/Addresses.ts +2 -0
- package/src/tempo/Decorator.ts +55 -28
- package/src/tempo/ExecutionError.ts +1 -1
- package/src/tempo/KeyAuthorizationManager.ts +53 -31
- package/src/tempo/Relay.ts +69 -14
- package/src/tempo/Selectors.ts +13 -0
- package/src/tempo/Transport.ts +46 -20
- package/src/tempo/{multisig → accounts}/Config.ts +21 -21
- package/src/tempo/{multisig → accounts}/Operation.ts +26 -26
- package/src/tempo/{multisig → accounts}/Signature.ts +5 -3
- package/src/tempo/actions/accessKey/index.ts +1 -0
- package/src/tempo/actions/accessKey/prepareAuthorization.ts +16 -15
- package/src/tempo/actions/accessKey/saveAuthorization.ts +51 -0
- package/src/tempo/actions/accessKey/signAuthorization.ts +73 -51
- package/src/tempo/actions/{multisig → accounts}/getConfig.ts +7 -7
- package/src/tempo/actions/{multisig → accounts}/getConfigCommitment.ts +3 -3
- package/src/tempo/actions/{multisig → accounts}/getOperation.ts +6 -6
- package/src/tempo/actions/{multisig → accounts}/updateConfig.ts +21 -26
- package/src/tempo/actions/{multisig → accounts}/updateConfigSync.ts +7 -7
- package/src/tempo/actions/index.ts +2 -3
- package/src/tempo/chainConfig.ts +87 -85
- package/src/tempo/index.ts +4 -4
- package/src/tempo/internal/relay/{multisig.ts → accounts.ts} +121 -121
- package/src/tempo/internal/relay/feePayer.ts +5 -5
- package/src/tempo/internal/relay/keyAuthorization.ts +419 -0
- package/src/tempo/internal/relay/plugin.ts +20 -7
- package/src/utils/RpcClient.ts +38 -21
- package/src/version.ts +1 -1
- package/dist/tempo/actions/multisig/getConfig.d.ts.map +0 -1
- package/dist/tempo/actions/multisig/getConfig.js.map +0 -1
- package/dist/tempo/actions/multisig/getOperation.js.map +0 -1
- package/dist/tempo/internal/relay/multisig.d.ts +0 -4
- package/dist/tempo/internal/relay/multisig.d.ts.map +0 -1
- package/dist/tempo/internal/relay/multisig.js.map +0 -1
- package/dist/tempo/multisig/Config.d.ts.map +0 -1
- package/dist/tempo/multisig/Signature.d.ts.map +0 -1
- package/dist/tempo/multisig/Signature.js +0 -9
- package/dist/tempo/multisig/Signature.js.map +0 -1
- /package/dist/tempo/actions/{multisig → accounts}/index.d.ts +0 -0
- /package/dist/tempo/actions/{multisig → accounts}/index.js +0 -0
- /package/src/tempo/actions/{multisig → accounts}/index.ts +0 -0
package/src/tempo/Addresses.ts
CHANGED
|
@@ -47,6 +47,8 @@ export const validator = '0xcccccccc00000000000000000000000000000000'
|
|
|
47
47
|
export const validatorV2 = '0xcccccccc00000000000000000000000000000001'
|
|
48
48
|
export const zoneFactory = '0x5aF2000000000000000000000000000000000000'
|
|
49
49
|
export const zoneMessenger = '0x5A4d000000000000000000000000000000000000'
|
|
50
|
+
/** Address of the zone inbox precompile. */
|
|
51
|
+
export const zoneInbox = '0x1c00000000000000000000000000000000000001'
|
|
50
52
|
/** Address of the zone outbox precompile. */
|
|
51
53
|
export const zoneOutbox = '0x1c00000000000000000000000000000000000002'
|
|
52
54
|
export const zonePortalImplementation =
|
package/src/tempo/Decorator.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type * as Chain from '../core/Chain.js'
|
|
|
3
3
|
import type * as Client from '../core/Client.js'
|
|
4
4
|
import type * as Transport from '../core/Transport.js'
|
|
5
5
|
import * as accessKey from './actions/accessKey/index.js'
|
|
6
|
+
import * as accounts from './actions/accounts/index.js'
|
|
6
7
|
import * as amm from './actions/amm/index.js'
|
|
7
8
|
import * as channel from './actions/channel/index.js'
|
|
8
9
|
import * as dex from './actions/dex/index.js'
|
|
9
10
|
import * as earn from './actions/earn.js'
|
|
10
11
|
import * as faucet from './actions/faucet/index.js'
|
|
11
12
|
import * as fee from './actions/fee/index.js'
|
|
12
|
-
import * as multisig from './actions/multisig/index.js'
|
|
13
13
|
import * as nonce from './actions/nonce/index.js'
|
|
14
14
|
import * as policy from './actions/policy/index.js'
|
|
15
15
|
import * as propAmmActions from './actions/propAmm.js'
|
|
@@ -55,6 +55,8 @@ export function tempoActions() {
|
|
|
55
55
|
isWitnessBurned: (options) => accessKey.isWitnessBurned(client, options),
|
|
56
56
|
revoke: (options) => accessKey.revoke(client, options),
|
|
57
57
|
revokeSync: (options) => accessKey.revokeSync(client, options),
|
|
58
|
+
saveAuthorization: (options) =>
|
|
59
|
+
accessKey.saveAuthorization(client, options),
|
|
58
60
|
signAuthorization: ((options: accessKey.signAuthorization.Options) =>
|
|
59
61
|
accessKey.signAuthorization(
|
|
60
62
|
client,
|
|
@@ -71,6 +73,14 @@ export function tempoActions() {
|
|
|
71
73
|
watchWitnessBurned: (options) =>
|
|
72
74
|
accessKey.watchWitnessBurned(client, options),
|
|
73
75
|
},
|
|
76
|
+
accounts: {
|
|
77
|
+
getConfig: (options) => accounts.getConfig(client, options),
|
|
78
|
+
getConfigCommitment: (options) =>
|
|
79
|
+
accounts.getConfigCommitment(client, options),
|
|
80
|
+
getOperation: (options) => accounts.getOperation(client, options),
|
|
81
|
+
updateConfig: (options) => accounts.updateConfig(client, options),
|
|
82
|
+
updateConfigSync: (options) => accounts.updateConfigSync(client, options),
|
|
83
|
+
},
|
|
74
84
|
amm: {
|
|
75
85
|
burn: (options) => amm.burn(client, options),
|
|
76
86
|
burnSync: (options) => amm.burnSync(client, options),
|
|
@@ -289,14 +299,6 @@ export function tempoActions() {
|
|
|
289
299
|
get: (options) => nonce.get(client, options),
|
|
290
300
|
watchIncremented: (options) => nonce.watchIncremented(client, options),
|
|
291
301
|
},
|
|
292
|
-
multisig: {
|
|
293
|
-
getConfig: (options) => multisig.getConfig(client, options),
|
|
294
|
-
getConfigCommitment: (options) =>
|
|
295
|
-
multisig.getConfigCommitment(client, options),
|
|
296
|
-
getOperation: (options) => multisig.getOperation(client, options),
|
|
297
|
-
updateConfig: (options) => multisig.updateConfig(client, options),
|
|
298
|
-
updateConfigSync: (options) => multisig.updateConfigSync(client, options),
|
|
299
|
-
},
|
|
300
302
|
policy: {
|
|
301
303
|
create: (options) => policy.create(client, options),
|
|
302
304
|
createSync: (options) => policy.createSync(client, options),
|
|
@@ -726,6 +728,31 @@ export type Decorator<
|
|
|
726
728
|
revokeSync: (
|
|
727
729
|
options: accessKey.revokeSync.Options,
|
|
728
730
|
) => Promise<accessKey.revokeSync.ReturnType>
|
|
731
|
+
/**
|
|
732
|
+
* Saves a signed key authorization to a relay with key authorization storage.
|
|
733
|
+
*
|
|
734
|
+
* The relay attaches the authorization to the access key's next transaction
|
|
735
|
+
* until the key is active onchain. Requires a relay running the
|
|
736
|
+
* `Relay.keyAuthorization` plugin.
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* ```ts
|
|
740
|
+
* import { Client, http, withRelay } from 'viem/tempo'
|
|
741
|
+
*
|
|
742
|
+
* const client = Client.create({
|
|
743
|
+
* transport: withRelay(http(), http('https://relay.example.com'), {
|
|
744
|
+
* keyAuthorization: true,
|
|
745
|
+
* }),
|
|
746
|
+
* })
|
|
747
|
+
*
|
|
748
|
+
* await client.accessKey.saveAuthorization({ keyAuthorization })
|
|
749
|
+
* ```
|
|
750
|
+
*
|
|
751
|
+
* @param options - Options.
|
|
752
|
+
*/
|
|
753
|
+
saveAuthorization: (
|
|
754
|
+
options: accessKey.saveAuthorization.Options,
|
|
755
|
+
) => Promise<accessKey.saveAuthorization.ReturnType>
|
|
729
756
|
/**
|
|
730
757
|
* Signs a key authorization for an access key.
|
|
731
758
|
*
|
|
@@ -764,7 +791,7 @@ export type Decorator<
|
|
|
764
791
|
options: accessKey.signAuthorization.LocalOptions<account>,
|
|
765
792
|
): Promise<accessKey.signAuthorization.ReturnType>
|
|
766
793
|
}
|
|
767
|
-
/** Prepares a key authorization for local or
|
|
794
|
+
/** Prepares a key authorization for local or configurable account signing. */
|
|
768
795
|
prepareAuthorization: (
|
|
769
796
|
options: accessKey.prepareAuthorization.Options<account>,
|
|
770
797
|
) => Promise<accessKey.prepareAuthorization.ReturnType>
|
|
@@ -920,6 +947,24 @@ export type Decorator<
|
|
|
920
947
|
options?: accessKey.watchWitnessBurned.Options,
|
|
921
948
|
) => accessKey.watchWitnessBurned.ReturnType
|
|
922
949
|
}
|
|
950
|
+
/** Configurable account configuration and coordinated operations. */
|
|
951
|
+
accounts: {
|
|
952
|
+
getConfig: (
|
|
953
|
+
options: accounts.getConfig.Options,
|
|
954
|
+
) => Promise<accounts.getConfig.ReturnType>
|
|
955
|
+
getConfigCommitment: (
|
|
956
|
+
options: accounts.getConfigCommitment.Options,
|
|
957
|
+
) => Promise<accounts.getConfigCommitment.ReturnType>
|
|
958
|
+
getOperation: (
|
|
959
|
+
options: accounts.getOperation.Options,
|
|
960
|
+
) => Promise<accounts.getOperation.ReturnType>
|
|
961
|
+
updateConfig: (
|
|
962
|
+
options: accounts.updateConfig.Options,
|
|
963
|
+
) => Promise<accounts.updateConfig.ReturnType>
|
|
964
|
+
updateConfigSync: (
|
|
965
|
+
options: accounts.updateConfigSync.Options,
|
|
966
|
+
) => Promise<accounts.updateConfigSync.ReturnType>
|
|
967
|
+
}
|
|
923
968
|
amm: {
|
|
924
969
|
/**
|
|
925
970
|
* Removes liquidity from a pool.
|
|
@@ -2945,24 +2990,6 @@ export type Decorator<
|
|
|
2945
2990
|
options?: nonce.watchIncremented.Options,
|
|
2946
2991
|
) => nonce.watchIncremented.ReturnType
|
|
2947
2992
|
}
|
|
2948
|
-
/** Native multisig configuration and coordinated operations. */
|
|
2949
|
-
multisig: {
|
|
2950
|
-
getConfig: (
|
|
2951
|
-
options: multisig.getConfig.Options,
|
|
2952
|
-
) => Promise<multisig.getConfig.ReturnType>
|
|
2953
|
-
getConfigCommitment: (
|
|
2954
|
-
options: multisig.getConfigCommitment.Options,
|
|
2955
|
-
) => Promise<multisig.getConfigCommitment.ReturnType>
|
|
2956
|
-
getOperation: (
|
|
2957
|
-
options: multisig.getOperation.Options,
|
|
2958
|
-
) => Promise<multisig.getOperation.ReturnType>
|
|
2959
|
-
updateConfig: (
|
|
2960
|
-
options: multisig.updateConfig.Options,
|
|
2961
|
-
) => Promise<multisig.updateConfig.ReturnType>
|
|
2962
|
-
updateConfigSync: (
|
|
2963
|
-
options: multisig.updateConfigSync.Options,
|
|
2964
|
-
) => Promise<multisig.updateConfigSync.ReturnType>
|
|
2965
|
-
}
|
|
2966
2993
|
|
|
2967
2994
|
policy: {
|
|
2968
2995
|
/**
|
|
@@ -115,7 +115,7 @@ export const messages: Record<`${AbiErrorName}(${string})`, string> = {
|
|
|
115
115
|
'InvalidMasterAddress()': 'Invalid master address.',
|
|
116
116
|
'InvalidMigrationIndex()': 'Invalid migration index.',
|
|
117
117
|
'InvalidMode()': 'Invalid mode.',
|
|
118
|
-
'InvalidMultisigOwner()': 'Invalid
|
|
118
|
+
'InvalidMultisigOwner()': 'Invalid owner.',
|
|
119
119
|
'InvalidNonceKey()': 'Invalid nonce key.',
|
|
120
120
|
'InvalidOwner()': 'Invalid owner.',
|
|
121
121
|
'InvalidOwnerOrder()': 'Invalid owner order.',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Address } from 'ox'
|
|
2
|
-
import
|
|
1
|
+
import type { Address, Hex } from 'ox'
|
|
2
|
+
import { KeyAuthorization } from 'ox/tempo'
|
|
3
3
|
|
|
4
4
|
import type { MaybePromise } from '../core/internal/types.js'
|
|
5
|
+
import * as Store from './Store.js'
|
|
5
6
|
|
|
6
7
|
/** Cache key identifying a signed key authorization. */
|
|
7
8
|
export type Key = {
|
|
@@ -13,42 +14,74 @@ export type Key = {
|
|
|
13
14
|
chainId: number
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
+
/** Pending key authorizations that the client attaches to an access key's next transaction. */
|
|
17
18
|
export type KeyAuthorizationManager = {
|
|
19
|
+
/** Reads the pending authorization for a key. */
|
|
18
20
|
get(key: Key): MaybePromise<KeyAuthorization.Signed | undefined>
|
|
21
|
+
/** Removes the pending authorization for a key. */
|
|
19
22
|
remove(key: Key): MaybePromise<void>
|
|
23
|
+
/** Stores a pending authorization for a key. */
|
|
20
24
|
set(key: Key, keyAuthorization: KeyAuthorization.Signed): MaybePromise<void>
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
|
-
*
|
|
28
|
+
* Creates a key authorization manager backed by a store.
|
|
29
|
+
*
|
|
30
|
+
* Entries use the same keys as the `Relay.keyAuthorization` plugin, so both can
|
|
31
|
+
* share one store.
|
|
25
32
|
*
|
|
26
33
|
* @example
|
|
27
34
|
* ```ts
|
|
28
|
-
* import { KeyAuthorizationManager } from 'viem/tempo'
|
|
35
|
+
* import { Account, KeyAuthorizationManager, Store } from 'viem/tempo'
|
|
29
36
|
*
|
|
30
|
-
* const
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* },
|
|
37
|
+
* const accessKey = Account.fromP256(privateKey, {
|
|
38
|
+
* access: root,
|
|
39
|
+
* keyAuthorizationManager: KeyAuthorizationManager.from({
|
|
40
|
+
* store: Store.session(),
|
|
41
|
+
* }),
|
|
36
42
|
* })
|
|
37
43
|
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param options - Options.
|
|
46
|
+
* @returns A key authorization manager.
|
|
38
47
|
*/
|
|
39
48
|
export function from(options: from.Options): KeyAuthorizationManager {
|
|
40
|
-
|
|
49
|
+
const { store } = options
|
|
50
|
+
return {
|
|
51
|
+
async get(key) {
|
|
52
|
+
const value = await store.getItem(getStoreKey(key))
|
|
53
|
+
if (!value) return undefined
|
|
54
|
+
try {
|
|
55
|
+
const { signature, ...rest } = KeyAuthorization.deserialize(
|
|
56
|
+
value as Hex.Hex,
|
|
57
|
+
)
|
|
58
|
+
if (!signature) return undefined
|
|
59
|
+
return { ...rest, signature }
|
|
60
|
+
} catch {
|
|
61
|
+
return undefined
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async remove(key) {
|
|
65
|
+
await store.removeItem(getStoreKey(key))
|
|
66
|
+
},
|
|
67
|
+
async set(key, keyAuthorization) {
|
|
68
|
+
await store.setItem(
|
|
69
|
+
getStoreKey(key),
|
|
70
|
+
KeyAuthorization.serialize(keyAuthorization),
|
|
71
|
+
)
|
|
72
|
+
},
|
|
73
|
+
}
|
|
41
74
|
}
|
|
42
75
|
|
|
43
76
|
export declare namespace from {
|
|
44
77
|
type Options = {
|
|
45
|
-
/**
|
|
46
|
-
|
|
78
|
+
/** Store for pending key authorizations. */
|
|
79
|
+
store: Store.Store
|
|
47
80
|
}
|
|
48
81
|
}
|
|
49
82
|
|
|
50
83
|
/**
|
|
51
|
-
* Creates
|
|
84
|
+
* Creates a key authorization manager backed by a process-local memory store.
|
|
52
85
|
*
|
|
53
86
|
* @example
|
|
54
87
|
* ```ts
|
|
@@ -56,27 +89,16 @@ export declare namespace from {
|
|
|
56
89
|
*
|
|
57
90
|
* const manager = KeyAuthorizationManager.memory()
|
|
58
91
|
* ```
|
|
92
|
+
*
|
|
93
|
+
* @returns A key authorization manager.
|
|
59
94
|
*/
|
|
60
95
|
export function memory(): KeyAuthorizationManager {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return from({
|
|
64
|
-
source: {
|
|
65
|
-
get(key) {
|
|
66
|
-
return keyAuthorizations.get(serializeKey(key))
|
|
67
|
-
},
|
|
68
|
-
remove(key) {
|
|
69
|
-
keyAuthorizations.delete(serializeKey(key))
|
|
70
|
-
},
|
|
71
|
-
set(key, keyAuthorization) {
|
|
72
|
-
keyAuthorizations.set(serializeKey(key), keyAuthorization)
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
})
|
|
96
|
+
return from({ store: Store.memory() })
|
|
76
97
|
}
|
|
77
98
|
|
|
78
|
-
function
|
|
99
|
+
function getStoreKey(key: Key) {
|
|
79
100
|
return [
|
|
101
|
+
'keyAuthorization',
|
|
80
102
|
key.chainId,
|
|
81
103
|
key.address.toLowerCase(),
|
|
82
104
|
key.accessKey.toLowerCase(),
|
package/src/tempo/Relay.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { ChainNotConfiguredError } from '../core/Client.js'
|
|
|
6
6
|
import type * as Transport from '../core/Transport.js'
|
|
7
7
|
import * as Sponsorship from './internal/relay/feePayer.js'
|
|
8
8
|
import * as FeeToken from './internal/relay/feeToken.js'
|
|
9
|
-
import * as
|
|
9
|
+
import * as Accounts from './internal/relay/accounts.js'
|
|
10
|
+
import * as KeyAuthorization from './internal/relay/keyAuthorization.js'
|
|
10
11
|
import * as Request_ from './internal/relay/request.js'
|
|
11
12
|
import * as Simulate from './internal/relay/simulate.js'
|
|
12
13
|
import * as internal from './internal/relay.js'
|
|
@@ -309,13 +310,19 @@ export declare namespace Plugin {
|
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
declare const
|
|
313
|
+
declare const accountsBrand: unique symbol
|
|
313
314
|
|
|
314
315
|
/**
|
|
315
|
-
*
|
|
316
|
+
* Serves configurable accounts using shared atomic storage.
|
|
317
|
+
*
|
|
318
|
+
* The chain stores only a commitment to each account's config, so the plugin
|
|
319
|
+
* records every config it relays (including configs left by `updateConfig`
|
|
320
|
+
* calls) and serves them through `account_getConfig`. It also collects owner
|
|
321
|
+
* approvals until the account's threshold is met, then submits.
|
|
316
322
|
*
|
|
317
323
|
* Memory storage is process-local. Independent clients and multiple server
|
|
318
|
-
* instances must use the same persistent store to share pending
|
|
324
|
+
* instances must use the same persistent store to share configs and pending
|
|
325
|
+
* approvals.
|
|
319
326
|
*
|
|
320
327
|
* @example
|
|
321
328
|
* ```ts
|
|
@@ -323,31 +330,31 @@ declare const multisigBrand: unique symbol
|
|
|
323
330
|
* import { Relay, Store, withRelay } from 'viem/tempo'
|
|
324
331
|
*
|
|
325
332
|
* const transport = withRelay(http(), {
|
|
326
|
-
* plugins: [Relay.
|
|
333
|
+
* plugins: [Relay.accounts({ store: Store.memory() })],
|
|
327
334
|
* })
|
|
328
335
|
* ```
|
|
329
336
|
*
|
|
330
337
|
* @param options - Shared atomic storage.
|
|
331
|
-
* @returns A plugin that
|
|
338
|
+
* @returns A plugin that handles configurable account requests and forwards other calls.
|
|
332
339
|
*/
|
|
333
|
-
export function
|
|
334
|
-
return
|
|
340
|
+
export function accounts(options: accounts.Options): accounts.ReturnType {
|
|
341
|
+
return Accounts.create(options)
|
|
335
342
|
}
|
|
336
343
|
|
|
337
|
-
export declare namespace
|
|
338
|
-
/**
|
|
344
|
+
export declare namespace accounts {
|
|
345
|
+
/** Configurable account options. */
|
|
339
346
|
export type Options = {
|
|
340
|
-
/** Store shared by
|
|
347
|
+
/** Store shared by relays, with atomic compare-and-set support. */
|
|
341
348
|
store: Store.Atomic
|
|
342
349
|
}
|
|
343
|
-
/** Middleware advertising
|
|
344
|
-
export type ReturnType = Plugin & { readonly [
|
|
350
|
+
/** Middleware advertising configurable account support. */
|
|
351
|
+
export type ReturnType = Plugin & { readonly [accountsBrand]: true }
|
|
345
352
|
}
|
|
346
353
|
|
|
347
354
|
/**
|
|
348
355
|
* Sponsors transactions with a local account or an external fee-payer relay.
|
|
349
356
|
*
|
|
350
|
-
* Place
|
|
357
|
+
* Place accounts before this plugin and fee-token selection after it.
|
|
351
358
|
*
|
|
352
359
|
* @example
|
|
353
360
|
* ```ts
|
|
@@ -402,6 +409,54 @@ export function feeToken(): Plugin {
|
|
|
402
409
|
return FeeToken.create()
|
|
403
410
|
}
|
|
404
411
|
|
|
412
|
+
declare const keyAuthorizationBrand: unique symbol
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Stores pending key authorizations and attaches them to the next fill that needs them.
|
|
416
|
+
*
|
|
417
|
+
* Signing a key authorization with `Actions.accessKey.signAuthorization` through a
|
|
418
|
+
* relay with this plugin saves it with `relay_saveKeyAuthorization`. Configurable
|
|
419
|
+
* account key authorizations are saved once they reach quorum. The next `eth_fillTransaction`
|
|
420
|
+
* from the access key includes the authorization until the key is active onchain.
|
|
421
|
+
* Remote `withRelay` transports opt in with `keyAuthorization: true`.
|
|
422
|
+
*
|
|
423
|
+
* Place this plugin before `Relay.accounts` so it can observe completed configurable
|
|
424
|
+
* account key authorizations, and before plugins that read the filled transaction.
|
|
425
|
+
*
|
|
426
|
+
* A saved authorization only replaces a pending authorization that expires earlier,
|
|
427
|
+
* so a replayed older authorization cannot replace a newer one.
|
|
428
|
+
*
|
|
429
|
+
* Memory storage is process-local. Multiple server instances must use the same
|
|
430
|
+
* persistent atomic store to share pending authorizations.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* import { http, Relay, Store, withRelay } from 'viem/tempo'
|
|
435
|
+
*
|
|
436
|
+
* const transport = withRelay(http(), {
|
|
437
|
+
* plugins: [Relay.keyAuthorization({ store: Store.memory() })],
|
|
438
|
+
* })
|
|
439
|
+
* ```
|
|
440
|
+
*
|
|
441
|
+
* @param options - Pending key authorization storage.
|
|
442
|
+
* @returns A plugin that stores and attaches pending key authorizations.
|
|
443
|
+
*/
|
|
444
|
+
export function keyAuthorization(
|
|
445
|
+
options: keyAuthorization.Options = {},
|
|
446
|
+
): keyAuthorization.ReturnType {
|
|
447
|
+
return KeyAuthorization.create(options)
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export declare namespace keyAuthorization {
|
|
451
|
+
/** Key authorization storage options. */
|
|
452
|
+
export type Options = {
|
|
453
|
+
/** Store for pending key authorizations, with atomic compare-and-set support. Defaults to a process-local memory store. */
|
|
454
|
+
store?: Store.Atomic | undefined
|
|
455
|
+
}
|
|
456
|
+
/** Middleware advertising pending key authorization storage. */
|
|
457
|
+
export type ReturnType = Plugin & { readonly [keyAuthorizationBrand]: true }
|
|
458
|
+
}
|
|
459
|
+
|
|
405
460
|
/**
|
|
406
461
|
* Adds balance changes, estimated fees, and execution errors to fill capabilities.
|
|
407
462
|
*
|
package/src/tempo/Selectors.ts
CHANGED
|
@@ -454,3 +454,16 @@ export const zoneOutbox = {
|
|
|
454
454
|
export const zoneMessenger = {
|
|
455
455
|
relayMessage: '0x11da5261',
|
|
456
456
|
} as const satisfies FunctionSelectors<typeof Abis.zoneMessenger>
|
|
457
|
+
|
|
458
|
+
export const zoneInbox = {
|
|
459
|
+
advanceTempo: '0x86516ec0',
|
|
460
|
+
advanceTempoHeaders: '0xae58328d',
|
|
461
|
+
claimRefund: '0xbffa55d5',
|
|
462
|
+
processedDepositNumber: '0x2d488482',
|
|
463
|
+
processedDepositQueueHash: '0x82648c3b',
|
|
464
|
+
processedEnabledTokenCount: '0x1b366d74',
|
|
465
|
+
processedTokenEnablementHash: '0x8f2e461a',
|
|
466
|
+
refunds: '0x857e85f8',
|
|
467
|
+
tempoPortal: '0xa21de6d9',
|
|
468
|
+
tempoState: '0x1fbb25ad',
|
|
469
|
+
} as const satisfies FunctionSelectors<typeof Abis.zoneInbox>
|
package/src/tempo/Transport.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type * as Relay_ from './Relay.js'
|
|
|
10
10
|
import * as Store from './Store.js'
|
|
11
11
|
|
|
12
12
|
/** A relay {@link Transport.Transport}: routes fee sponsorship traffic to a relay (fee payer service). */
|
|
13
|
-
export type Relay = Transport.Transport<'relay', {
|
|
13
|
+
export type Relay = Transport.Transport<'relay', { accounts: true }>
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Creates a {@link Transport.Transport} that routes requests between a
|
|
@@ -28,8 +28,10 @@ export type Relay = Transport.Transport<'relay', { multisig: true }>
|
|
|
28
28
|
* - `'sign-and-broadcast'`: the submission is forwarded to the relay, which
|
|
29
29
|
* co-signs and broadcasts it itself.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
* receipt lookups fall back to the relay for pending
|
|
31
|
+
* Owner approvals and submissions are sent to the relay. Transaction and
|
|
32
|
+
* receipt lookups fall back to the relay for pending account operations.
|
|
33
|
+
* Signed key authorizations are saved to relays with key authorization storage
|
|
34
|
+
* so they can attach them to the access key's next transaction.
|
|
33
35
|
* Other requests are forwarded to the default transport.
|
|
34
36
|
*
|
|
35
37
|
* @example
|
|
@@ -53,11 +55,11 @@ export function withRelay<
|
|
|
53
55
|
defaultTransport: transport,
|
|
54
56
|
options: withRelay.LocalOptions<plugins>,
|
|
55
57
|
): withRelay.LocalReturnValue<transport, plugins>
|
|
56
|
-
export function withRelay(
|
|
58
|
+
export function withRelay<const options extends withRelay.Options = {}>(
|
|
57
59
|
defaultTransport: Transport.Transport,
|
|
58
60
|
relayTransport: Transport.Transport,
|
|
59
|
-
options?: withRelay.Options,
|
|
60
|
-
):
|
|
61
|
+
options?: options | withRelay.Options,
|
|
62
|
+
): withRelay.ReturnValue<options>
|
|
61
63
|
export function withRelay(
|
|
62
64
|
defaultTransport: Transport.Transport,
|
|
63
65
|
relayTransport: Transport.Transport | withRelay.LocalOptions,
|
|
@@ -81,15 +83,20 @@ export function withRelay(
|
|
|
81
83
|
...options,
|
|
82
84
|
})) as typeof transport.request,
|
|
83
85
|
...(relayTransport.plugins?.some((plugin) =>
|
|
84
|
-
Plugin.
|
|
86
|
+
Plugin.isAccounts(plugin),
|
|
87
|
+
)
|
|
88
|
+
? { accounts: true }
|
|
89
|
+
: {}),
|
|
90
|
+
...(relayTransport.plugins?.some((plugin) =>
|
|
91
|
+
Plugin.isKeyAuthorization(plugin),
|
|
85
92
|
)
|
|
86
|
-
? {
|
|
93
|
+
? { keyAuthorization: true }
|
|
87
94
|
: {}),
|
|
88
95
|
}
|
|
89
96
|
},
|
|
90
97
|
}
|
|
91
98
|
|
|
92
|
-
const { policy = 'sign-only' } = options
|
|
99
|
+
const { keyAuthorization, policy = 'sign-only' } = options
|
|
93
100
|
return Transport.from({
|
|
94
101
|
key: options.key ?? 'relay',
|
|
95
102
|
name: options.name ?? 'Relay Proxy',
|
|
@@ -103,7 +110,8 @@ export function withRelay(
|
|
|
103
110
|
const relay = relayTransport.setup({ chain, retryCount: 0, timeout })
|
|
104
111
|
|
|
105
112
|
return {
|
|
106
|
-
|
|
113
|
+
accounts: true as const,
|
|
114
|
+
...(keyAuthorization ? { keyAuthorization: true as const } : {}),
|
|
107
115
|
methods: options.methods,
|
|
108
116
|
retryCount: 0,
|
|
109
117
|
retryDelay: options.retryDelay,
|
|
@@ -113,6 +121,9 @@ export function withRelay(
|
|
|
113
121
|
// The relay decides whether to sponsor from the fill request's `feePayer`.
|
|
114
122
|
if (method === 'eth_fillTransaction') return relay.request(args, opts)
|
|
115
123
|
|
|
124
|
+
if (method === 'relay_saveKeyAuthorization')
|
|
125
|
+
return relay.request(args, opts)
|
|
126
|
+
|
|
116
127
|
if (
|
|
117
128
|
method === 'eth_getTransactionByHash' ||
|
|
118
129
|
method === 'eth_getTransactionReceipt'
|
|
@@ -126,7 +137,7 @@ export function withRelay(
|
|
|
126
137
|
const operation = await (async () => {
|
|
127
138
|
try {
|
|
128
139
|
return await relay.request(
|
|
129
|
-
{ method: '
|
|
140
|
+
{ method: 'account_getOperation', params },
|
|
130
141
|
opts,
|
|
131
142
|
)
|
|
132
143
|
} catch (error) {
|
|
@@ -134,7 +145,7 @@ export function withRelay(
|
|
|
134
145
|
error instanceof RpcResponse.MethodNotFoundError ||
|
|
135
146
|
error instanceof RpcResponse.MethodNotSupportedError
|
|
136
147
|
) {
|
|
137
|
-
// Relays
|
|
148
|
+
// Relays without the accounts plugin do not expose this method.
|
|
138
149
|
return null
|
|
139
150
|
}
|
|
140
151
|
throw error
|
|
@@ -151,11 +162,11 @@ export function withRelay(
|
|
|
151
162
|
}
|
|
152
163
|
|
|
153
164
|
if (
|
|
154
|
-
method === '
|
|
155
|
-
method === '
|
|
156
|
-
method === '
|
|
157
|
-
method === '
|
|
158
|
-
method === '
|
|
165
|
+
method === 'account_approveKeyAuthorization' ||
|
|
166
|
+
method === 'account_approveRawTransaction' ||
|
|
167
|
+
method === 'account_approveRawTransactionSync' ||
|
|
168
|
+
method === 'account_getConfig' ||
|
|
169
|
+
method === 'account_getOperation'
|
|
159
170
|
)
|
|
160
171
|
return relay.request({ method, params: params as [Hex.Hex] }, opts)
|
|
161
172
|
|
|
@@ -178,7 +189,7 @@ export function withRelay(
|
|
|
178
189
|
return undefined
|
|
179
190
|
}
|
|
180
191
|
})()
|
|
181
|
-
if (envelope?.signature?.type === '
|
|
192
|
+
if (envelope?.signature?.type === 'configurable')
|
|
182
193
|
return relay.request(
|
|
183
194
|
{ method, params: [serialized as Hex.Hex] },
|
|
184
195
|
opts,
|
|
@@ -226,9 +237,15 @@ export declare namespace withRelay {
|
|
|
226
237
|
? Transport.Transport<
|
|
227
238
|
type,
|
|
228
239
|
properties &
|
|
229
|
-
(Extract<plugins[number], Relay_.
|
|
240
|
+
(Extract<plugins[number], Relay_.accounts.ReturnType> extends never
|
|
241
|
+
? {}
|
|
242
|
+
: { accounts: true }) &
|
|
243
|
+
(Extract<
|
|
244
|
+
plugins[number],
|
|
245
|
+
Relay_.keyAuthorization.ReturnType
|
|
246
|
+
> extends never
|
|
230
247
|
? {}
|
|
231
|
-
: {
|
|
248
|
+
: { keyAuthorization: true }),
|
|
232
249
|
request
|
|
233
250
|
>
|
|
234
251
|
: never
|
|
@@ -236,6 +253,8 @@ export declare namespace withRelay {
|
|
|
236
253
|
type Options = {
|
|
237
254
|
/** Transport key. @default 'relay' */
|
|
238
255
|
key?: string | undefined
|
|
256
|
+
/** Whether the relay stores key authorizations with `Relay.keyAuthorization`. @default false */
|
|
257
|
+
keyAuthorization?: boolean | undefined
|
|
239
258
|
/** RPC methods to include or exclude. */
|
|
240
259
|
methods?: { include?: string[] } | { exclude?: string[] } | undefined
|
|
241
260
|
/** Transport name. @default 'Relay Proxy' */
|
|
@@ -247,6 +266,13 @@ export declare namespace withRelay {
|
|
|
247
266
|
/** Base delay (ms) between retries. @default 150 */
|
|
248
267
|
retryDelay?: number | undefined
|
|
249
268
|
}
|
|
269
|
+
|
|
270
|
+
/** Remote relay transport, advertising key authorization storage when enabled. */
|
|
271
|
+
type ReturnValue<options extends Options = {}> = options extends {
|
|
272
|
+
keyAuthorization: true
|
|
273
|
+
}
|
|
274
|
+
? Transport.Transport<'relay', { accounts: true; keyAuthorization: true }>
|
|
275
|
+
: Relay
|
|
250
276
|
}
|
|
251
277
|
|
|
252
278
|
/**
|