viem 2.55.18 → 2.55.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/_cjs/chains/definitions/morphTachyon.js +25 -0
  3. package/_cjs/chains/definitions/morphTachyon.js.map +1 -0
  4. package/_cjs/chains/definitions/morphTachyonTestnet.js +26 -0
  5. package/_cjs/chains/definitions/morphTachyonTestnet.js.map +1 -0
  6. package/_cjs/chains/definitions/ynxTestnet.js +26 -0
  7. package/_cjs/chains/definitions/ynxTestnet.js.map +1 -0
  8. package/_cjs/chains/index.js +13 -7
  9. package/_cjs/chains/index.js.map +1 -1
  10. package/_cjs/errors/version.js +1 -1
  11. package/_cjs/tempo/Abis.js +102 -1
  12. package/_cjs/tempo/Abis.js.map +1 -1
  13. package/_cjs/tempo/Account.js +188 -16
  14. package/_cjs/tempo/Account.js.map +1 -1
  15. package/_cjs/tempo/Addresses.js +2 -1
  16. package/_cjs/tempo/Addresses.js.map +1 -1
  17. package/_cjs/tempo/Decorator.js +8 -0
  18. package/_cjs/tempo/Decorator.js.map +1 -1
  19. package/_cjs/tempo/Formatters.js +1 -1
  20. package/_cjs/tempo/Formatters.js.map +1 -1
  21. package/_cjs/tempo/Selectors.js +7 -1
  22. package/_cjs/tempo/Selectors.js.map +1 -1
  23. package/_cjs/tempo/Transaction.js +31 -10
  24. package/_cjs/tempo/Transaction.js.map +1 -1
  25. package/_cjs/tempo/actions/accessKey.js +49 -8
  26. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  27. package/_cjs/tempo/actions/index.js +2 -1
  28. package/_cjs/tempo/actions/index.js.map +1 -1
  29. package/_cjs/tempo/actions/multisig.js +95 -0
  30. package/_cjs/tempo/actions/multisig.js.map +1 -0
  31. package/_cjs/tempo/chainConfig.js +58 -29
  32. package/_cjs/tempo/chainConfig.js.map +1 -1
  33. package/_cjs/tempo/internal/multisig.js +56 -0
  34. package/_cjs/tempo/internal/multisig.js.map +1 -0
  35. package/_esm/chains/definitions/morphTachyon.js +22 -0
  36. package/_esm/chains/definitions/morphTachyon.js.map +1 -0
  37. package/_esm/chains/definitions/morphTachyonTestnet.js +23 -0
  38. package/_esm/chains/definitions/morphTachyonTestnet.js.map +1 -0
  39. package/_esm/chains/definitions/ynxTestnet.js +23 -0
  40. package/_esm/chains/definitions/ynxTestnet.js.map +1 -0
  41. package/_esm/chains/index.js +3 -0
  42. package/_esm/chains/index.js.map +1 -1
  43. package/_esm/errors/version.js +1 -1
  44. package/_esm/tempo/Abis.js +101 -0
  45. package/_esm/tempo/Abis.js.map +1 -1
  46. package/_esm/tempo/Account.js +196 -66
  47. package/_esm/tempo/Account.js.map +1 -1
  48. package/_esm/tempo/Addresses.js +1 -0
  49. package/_esm/tempo/Addresses.js.map +1 -1
  50. package/_esm/tempo/Decorator.js +8 -0
  51. package/_esm/tempo/Decorator.js.map +1 -1
  52. package/_esm/tempo/Formatters.js +3 -6
  53. package/_esm/tempo/Formatters.js.map +1 -1
  54. package/_esm/tempo/Selectors.js +6 -0
  55. package/_esm/tempo/Selectors.js.map +1 -1
  56. package/_esm/tempo/Transaction.js +31 -10
  57. package/_esm/tempo/Transaction.js.map +1 -1
  58. package/_esm/tempo/actions/accessKey.js +65 -23
  59. package/_esm/tempo/actions/accessKey.js.map +1 -1
  60. package/_esm/tempo/actions/index.js +1 -0
  61. package/_esm/tempo/actions/index.js.map +1 -1
  62. package/_esm/tempo/actions/multisig.js +245 -0
  63. package/_esm/tempo/actions/multisig.js.map +1 -0
  64. package/_esm/tempo/chainConfig.js +65 -35
  65. package/_esm/tempo/chainConfig.js.map +1 -1
  66. package/_esm/tempo/internal/multisig.js +56 -0
  67. package/_esm/tempo/internal/multisig.js.map +1 -0
  68. package/_types/chains/definitions/morphTachyon.d.ts +51 -0
  69. package/_types/chains/definitions/morphTachyon.d.ts.map +1 -0
  70. package/_types/chains/definitions/morphTachyonTestnet.d.ts +51 -0
  71. package/_types/chains/definitions/morphTachyonTestnet.d.ts.map +1 -0
  72. package/_types/chains/definitions/tempo.d.ts +30 -2
  73. package/_types/chains/definitions/tempo.d.ts.map +1 -1
  74. package/_types/chains/definitions/tempoDevnet.d.ts +30 -2
  75. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  76. package/_types/chains/definitions/tempoLocalnet.d.ts +30 -2
  77. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  78. package/_types/chains/definitions/tempoModerato.d.ts +30 -2
  79. package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
  80. package/_types/chains/definitions/ynxTestnet.d.ts +51 -0
  81. package/_types/chains/definitions/ynxTestnet.d.ts.map +1 -0
  82. package/_types/chains/index.d.ts +3 -0
  83. package/_types/chains/index.d.ts.map +1 -1
  84. package/_types/errors/version.d.ts +1 -1
  85. package/_types/tempo/Abis.d.ts +321 -0
  86. package/_types/tempo/Abis.d.ts.map +1 -1
  87. package/_types/tempo/Account.d.ts +42 -26
  88. package/_types/tempo/Account.d.ts.map +1 -1
  89. package/_types/tempo/Addresses.d.ts +1 -0
  90. package/_types/tempo/Addresses.d.ts.map +1 -1
  91. package/_types/tempo/Decorator.d.ts +32 -0
  92. package/_types/tempo/Decorator.d.ts.map +1 -1
  93. package/_types/tempo/Formatters.d.ts.map +1 -1
  94. package/_types/tempo/Selectors.d.ts +6 -0
  95. package/_types/tempo/Selectors.d.ts.map +1 -1
  96. package/_types/tempo/Transaction.d.ts +17 -2
  97. package/_types/tempo/Transaction.d.ts.map +1 -1
  98. package/_types/tempo/actions/accessKey.d.ts +35 -17
  99. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  100. package/_types/tempo/actions/index.d.ts +1 -0
  101. package/_types/tempo/actions/index.d.ts.map +1 -1
  102. package/_types/tempo/actions/multisig.d.ts +472 -0
  103. package/_types/tempo/actions/multisig.d.ts.map +1 -0
  104. package/_types/tempo/chainConfig.d.ts +15 -1
  105. package/_types/tempo/chainConfig.d.ts.map +1 -1
  106. package/_types/tempo/internal/multisig.d.ts +13 -0
  107. package/_types/tempo/internal/multisig.d.ts.map +1 -0
  108. package/_types/tempo/zones/zone.d.ts +90 -6
  109. package/_types/tempo/zones/zone.d.ts.map +1 -1
  110. package/chains/definitions/morphTachyon.ts +22 -0
  111. package/chains/definitions/morphTachyonTestnet.ts +23 -0
  112. package/chains/definitions/ynxTestnet.ts +23 -0
  113. package/chains/index.ts +3 -0
  114. package/errors/version.ts +1 -1
  115. package/package.json +2 -2
  116. package/tempo/Abis.ts +102 -0
  117. package/tempo/Account.ts +329 -51
  118. package/tempo/Addresses.ts +1 -0
  119. package/tempo/Decorator.ts +50 -0
  120. package/tempo/Formatters.ts +4 -5
  121. package/tempo/Selectors.ts +7 -0
  122. package/tempo/Transaction.ts +52 -12
  123. package/tempo/actions/accessKey.ts +128 -32
  124. package/tempo/actions/index.ts +1 -0
  125. package/tempo/actions/multisig.ts +356 -0
  126. package/tempo/chainConfig.ts +82 -35
  127. package/tempo/internal/multisig.ts +72 -0
@@ -118,15 +118,14 @@ export function formatTransactionRequest(
118
118
  if (request.feePayer === true && !request.feePayerSignature)
119
119
  delete request.feeToken
120
120
 
121
- // `multisig` / `signatures` are client-side only (TIP-1061). They drive
122
- // sender derivation, owner signing, and final envelope assembly, but are
123
- // never sent as raw RPC fields — the wire payload is the serialized tx.
124
- // `multisigInit` / `multisigSignatureCount` are wire fields: the node
125
- // prices multisig gas from them during simulation.
121
+ // Client-only TIP-1061 fields drive local signing and envelope assembly.
122
+ // `multisigInit` and `multisigSignatureCount` remain wire fields for gas modeling.
126
123
  const {
127
124
  multisig: _multisig,
128
125
  multisigInit,
126
+ multisigOwnerStates: _multisigOwnerStates,
129
127
  multisigSignatureCount,
128
+ multisigVersion: _multisigVersion,
130
129
  signatures: _signatures,
131
130
  ...rpcRequest
132
131
  } = request
@@ -49,6 +49,13 @@ export const addressRegistry = {
49
49
  resolveVirtualAddress: '0xe2fc56ef',
50
50
  } as const satisfies FunctionSelectors<typeof Abis.addressRegistry>
51
51
 
52
+ export const nativeMultisig = {
53
+ deriveAccount: '0xce8e071c',
54
+ getConfig: '0xe48a5f7b',
55
+ isMultisigAccount: '0x9fbf029a',
56
+ updateConfig: '0xe175d479',
57
+ } as const satisfies FunctionSelectors<typeof Abis.nativeMultisig>
58
+
52
59
  export const nonce = {
53
60
  getNonce: '0x89535803',
54
61
  } as const satisfies FunctionSelectors<typeof Abis.nonce>
@@ -112,6 +112,14 @@ export type TransactionReceiptRpc = TransactionReceipt<
112
112
  ox_TransactionReceipt.RpcType
113
113
  >
114
114
 
115
+ /** @internal */
116
+ export type MultisigOwnerState = {
117
+ account: Address
118
+ config?: Pick<MultisigConfig.Config, 'owners' | 'threshold'> | undefined
119
+ initialized: boolean
120
+ version: bigint
121
+ }
122
+
115
123
  export type TransactionRequestTempo<
116
124
  quantity = bigint,
117
125
  index = number,
@@ -124,7 +132,7 @@ export type TransactionRequestTempo<
124
132
  feePayer?: Account | true | undefined
125
133
  feeToken?: TempoAddress.Address | bigint | undefined
126
134
  keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
127
- multisig?: MultisigConfig.Config<index> | undefined
135
+ multisig?: Address | MultisigConfig.Config<index> | undefined
128
136
  /** Bootstrap multisig config hint for node-side gas modeling (TIP-1061). Attached automatically when `multisig` is present; the node ignores it for registered senders. */
129
137
  multisigInit?:
130
138
  | {
@@ -133,8 +141,12 @@ export type TransactionRequestTempo<
133
141
  owners: readonly { owner: Address; weight: number }[]
134
142
  }
135
143
  | undefined
144
+ /** @internal Local signing state for nested multisig owner accounts. */
145
+ multisigOwnerStates?: readonly MultisigOwnerState[] | undefined
136
146
  /** Modeled owner approval count for node-side gas modeling (TIP-1061). */
137
147
  multisigSignatureCount?: number | undefined
148
+ /** Current multisig config version. Inferred during request preparation; defaults to `0n` for bootstrap. */
149
+ multisigVersion?: bigint | undefined
138
150
  nonceKey?: 'expiring' | quantity | undefined
139
151
  signatures?: readonly SignatureEnvelope.Serialized[] | undefined
140
152
  validBefore?: index | undefined
@@ -157,7 +169,11 @@ export type TransactionSerializableTempo<
157
169
  feePayerSignature?: viem_Signature | null | undefined
158
170
  from?: Address | undefined
159
171
  keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
160
- multisig?: MultisigConfig.Config<index> | undefined
172
+ multisig?: Address | MultisigConfig.Config<index> | undefined
173
+ /** @internal Local signing state for nested multisig owner accounts. */
174
+ multisigOwnerStates?: readonly MultisigOwnerState[] | undefined
175
+ /** Current multisig config version. Inferred during request preparation; defaults to `0n` for bootstrap. */
176
+ multisigVersion?: bigint | undefined
161
177
  nonceKey?: quantity | undefined
162
178
  signature?: SignatureEnvelope.SignatureEnvelope<quantity, index> | undefined
163
179
  signatures?: readonly SignatureEnvelope.Serialized[] | undefined
@@ -191,6 +207,7 @@ export function getType(
191
207
  typeof transaction.feeToken !== 'undefined' ||
192
208
  typeof transaction.keyAuthorization !== 'undefined' ||
193
209
  typeof transaction.multisig !== 'undefined' ||
210
+ typeof transaction.multisigVersion !== 'undefined' ||
194
211
  typeof transaction.nonceKey !== 'undefined' ||
195
212
  typeof transaction.signature !== 'undefined' ||
196
213
  typeof transaction.signatures !== 'undefined' ||
@@ -325,14 +342,17 @@ async function serializeTempo(
325
342
  const hasPrefilledFeePayerSignature =
326
343
  typeof transaction.feePayerSignature !== 'undefined' &&
327
344
  transaction.feePayerSignature !== null
345
+ const hasSenderSignature =
346
+ typeof signature_provided !== 'undefined' ||
347
+ Boolean(transaction.multisig && transaction.signatures)
328
348
  // Sponsorship sender signatures omit `feeToken`.
329
349
  const shouldStripFeeTokenForSponsorship =
330
350
  // Relay fills a partial sender envelope first.
331
- (feePayer === true && (!signature_provided || !feePayerSignature)) ||
351
+ (feePayer === true && (!hasSenderSignature || !feePayerSignature)) ||
332
352
  // Local fee-payer accounts sign after sender serialization.
333
- (typeof feePayer === 'object' && !signature_provided) ||
353
+ (typeof feePayer === 'object' && !hasSenderSignature) ||
334
354
  // Filled transactions can already include fee-payer approval.
335
- (!signature_provided && hasPrefilledFeePayerSignature)
355
+ (!hasSenderSignature && hasPrefilledFeePayerSignature)
336
356
 
337
357
  const transaction_ox = {
338
358
  ...rest,
@@ -371,15 +391,35 @@ async function serializeTempo(
371
391
  const signatures = transaction.signatures.map((approval) =>
372
392
  SignatureEnvelope.from(approval),
373
393
  )
374
- const sorted = SignatureEnvelope.sortMultisigApprovals({
375
- payload,
376
- signatures,
377
- genesisConfig: transaction.multisig,
378
- })
394
+ const sorted =
395
+ typeof transaction.multisig === 'string'
396
+ ? SignatureEnvelope.sortMultisigApprovals({
397
+ account: transaction.multisig,
398
+ payload,
399
+ signatures,
400
+ version: transaction.multisigVersion,
401
+ })
402
+ : SignatureEnvelope.sortMultisigApprovals({
403
+ initialConfig: transaction.multisig,
404
+ payload,
405
+ signatures,
406
+ version: transaction.multisigVersion,
407
+ })
408
+ const keyAuthorizationSignature = transaction.keyAuthorization?.signature
409
+ const keyAuthorizationInitializes =
410
+ keyAuthorizationSignature?.type === 'multisig' &&
411
+ typeof keyAuthorizationSignature.init !== 'undefined'
412
+ if (typeof transaction.multisig === 'string')
413
+ return SignatureEnvelope.from({
414
+ account: transaction.multisig,
415
+ signatures: sorted,
416
+ })
379
417
  return SignatureEnvelope.from({
380
- genesisConfig: transaction.multisig,
418
+ initialConfig: transaction.multisig,
381
419
  signatures: sorted,
382
- ...(nonce || transaction.nonceKey ? {} : { init: true }),
420
+ ...(nonce || transaction.nonceKey || keyAuthorizationInitializes
421
+ ? {}
422
+ : { init: true }),
383
423
  })
384
424
  })()
385
425
 
@@ -1,5 +1,9 @@
1
1
  import type { Address } from 'abitype'
2
- import type { KeyAuthorization } from 'ox/tempo'
2
+ import {
3
+ type KeyAuthorization,
4
+ MultisigConfig,
5
+ type SignatureEnvelope,
6
+ } from 'ox/tempo'
3
7
  import type { Account } from '../../accounts/types.js'
4
8
  import { parseAccount } from '../../accounts/utils/parseAccount.js'
5
9
  import type { ReadContractReturnType } from '../../actions/public/readContract.js'
@@ -21,10 +25,21 @@ import type { Hex } from '../../types/misc.js'
21
25
  import type { Compute, UnionOmit } from '../../types/utils.js'
22
26
  import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
23
27
  import * as Abis from '../Abis.js'
24
- import type { AccessKeyAccount, resolveAccessKey } from '../Account.js'
25
- import { signKeyAuthorization } from '../Account.js'
28
+ import type {
29
+ AccessKeyAccount,
30
+ MultisigAccount,
31
+ resolveAccessKey,
32
+ } from '../Account.js'
33
+ import {
34
+ getKeyAuthorizationSignPayload,
35
+ signKeyAuthorization,
36
+ } from '../Account.js'
26
37
  import * as Addresses from '../Addresses.js'
27
38
  import * as Hardfork from '../Hardfork.js'
39
+ import {
40
+ createMultisigStateResolver,
41
+ getMultisigOwnerStates,
42
+ } from '../internal/multisig.js'
28
43
  import type {
29
44
  GetAccountParameter,
30
45
  ReadParameters,
@@ -32,6 +47,7 @@ import type {
32
47
  } from '../internal/types.js'
33
48
  import { defineCall } from '../internal/utils.js'
34
49
  import type { TransactionReceipt } from '../Transaction.js'
50
+ import * as multisig from './multisig.js'
35
51
 
36
52
  /** @internal */
37
53
  const signatureTypes = {
@@ -155,10 +171,10 @@ export namespace authorize {
155
171
  const account_ = rest.account ?? client.account
156
172
  if (!account_) throw new Error('account is required.')
157
173
  if (!chainId) throw new Error('chainId is required.')
158
- const parsed = parseAccount(account_)
159
- const keyAuthorization = await signKeyAuthorization(parsed as never, {
160
- chainId: BigInt(chainId),
161
- key: accessKey,
174
+ const keyAuthorization = await signAuthorization(client, {
175
+ account: account_,
176
+ accessKey,
177
+ chainId,
162
178
  admin,
163
179
  expiry,
164
180
  limits,
@@ -1003,52 +1019,73 @@ export namespace revokeSync {
1003
1019
  }
1004
1020
 
1005
1021
  /**
1006
- * Signs a key authorization for an access key.
1022
+ * Prepares a key authorization for signing.
1007
1023
  *
1008
1024
  * @example
1009
1025
  * ```ts
1010
- * import { generatePrivateKey } from 'viem/accounts'
1011
- * import { Account, Actions } from 'viem/tempo'
1012
- *
1013
- * const account = Account.from({ privateKey: '0x...' })
1014
- * const accessKey = Account.fromP256(generatePrivateKey(), {
1015
- * access: account,
1026
+ * const authorization = await Actions.accessKey.prepareAuthorization(client, {
1027
+ * account,
1028
+ * accessKey,
1016
1029
  * })
1017
- *
1018
1030
  * const keyAuthorization = await Actions.accessKey.signAuthorization(
1019
1031
  * client,
1020
- * {
1021
- * account,
1022
- * accessKey,
1023
- * expiry: Math.floor((Date.now() + 30_000) / 1000),
1024
- * },
1032
+ * authorization,
1025
1033
  * )
1026
1034
  * ```
1027
1035
  *
1028
1036
  * @param client - Client.
1029
1037
  * @param parameters - Parameters.
1030
- * @returns The signed key authorization.
1038
+ * @returns Prepared key authorization parameters.
1031
1039
  */
1032
- export async function signAuthorization<
1040
+ export async function prepareAuthorization<
1033
1041
  chain extends Chain | undefined,
1034
1042
  account extends Account | undefined,
1035
1043
  >(
1036
1044
  client: Client<Transport, chain, account>,
1037
- parameters: signAuthorization.Parameters<account>,
1038
- ): Promise<signAuthorization.ReturnValue> {
1039
- const { accessKey, chainId = client.chain?.id, ...rest } = parameters
1040
- const account_ = rest.account ?? client.account
1045
+ parameters: prepareAuthorization.Parameters<account>,
1046
+ ): Promise<prepareAuthorization.ReturnValue> {
1047
+ const { chainId = client.chain?.id } = parameters
1048
+ const account_ = parameters.account ?? client.account
1041
1049
  if (!account_) throw new Error('account is required.')
1042
1050
  if (!chainId) throw new Error('chainId is required.')
1043
1051
  const parsed = parseAccount(account_)
1044
- return signKeyAuthorization(parsed as never, {
1045
- chainId: BigInt(chainId),
1046
- key: accessKey,
1047
- ...rest,
1048
- })
1052
+ const multisigState = await (async () => {
1053
+ if ('multisig' in parameters) return parameters.multisig
1054
+ if (parsed.source !== 'multisig') return undefined
1055
+ const account = parsed as MultisigAccount
1056
+ const getState = createMultisigStateResolver((account) =>
1057
+ multisig.getConfig(client, { account }),
1058
+ )
1059
+ const states = await getMultisigOwnerStates(account, getState)
1060
+ const state = states[0]!
1061
+ return { init: !state.initialized, states, version: state.version }
1062
+ })()
1063
+ const authorizationSignPayload = getKeyAuthorizationSignPayload(
1064
+ parsed as never,
1065
+ {
1066
+ ...parameters,
1067
+ chainId: BigInt(chainId),
1068
+ key: parameters.accessKey,
1069
+ },
1070
+ )
1071
+ const signPayload =
1072
+ parsed.source === 'multisig' && multisigState
1073
+ ? MultisigConfig.getSignPayload({
1074
+ account: parsed.address,
1075
+ payload: authorizationSignPayload,
1076
+ version: multisigState.version,
1077
+ })
1078
+ : authorizationSignPayload
1079
+ return {
1080
+ ...parameters,
1081
+ account: parsed,
1082
+ chainId,
1083
+ multisig: multisigState,
1084
+ signPayload,
1085
+ } as never
1049
1086
  }
1050
1087
 
1051
- export namespace signAuthorization {
1088
+ export namespace prepareAuthorization {
1052
1089
  export type Parameters<
1053
1090
  account extends Account | undefined = Account | undefined,
1054
1091
  > = GetAccountParameter<account> & {
@@ -1070,6 +1107,8 @@ export namespace signAuthorization {
1070
1107
  limits?:
1071
1108
  | { token: Address; limit: bigint; period?: number | undefined }[]
1072
1109
  | undefined
1110
+ /** @internal Prepared multisig state. */
1111
+ multisig?: signKeyAuthorization.Parameters['multisig']
1073
1112
  /** Call scopes restricting which contracts/selectors this key can call. */
1074
1113
  scopes?: KeyAuthorization.Scope[] | undefined
1075
1114
  /**
@@ -1085,6 +1124,63 @@ export namespace signAuthorization {
1085
1124
  witness?: Hex | undefined
1086
1125
  }
1087
1126
 
1127
+ export type ReturnValue = Compute<
1128
+ Omit<Parameters<Account | undefined>, 'account' | 'chainId'> & {
1129
+ account: Account
1130
+ chainId: number
1131
+ multisig: signKeyAuthorization.Parameters['multisig']
1132
+ /** Payload that the authorizing account or multisig owners sign. */
1133
+ signPayload: Hex
1134
+ }
1135
+ >
1136
+ }
1137
+
1138
+ /**
1139
+ * Signs a key authorization for an access key.
1140
+ *
1141
+ * Use {@link prepareAuthorization} before this action when signing requires
1142
+ * transient user activation.
1143
+ *
1144
+ * @param client - Client.
1145
+ * @param parameters - Parameters or the prepared result.
1146
+ * @returns The signed key authorization.
1147
+ */
1148
+ export async function signAuthorization<
1149
+ chain extends Chain | undefined,
1150
+ account extends Account | undefined,
1151
+ >(
1152
+ client: Client<Transport, chain, account>,
1153
+ parameters: signAuthorization.Parameters<account>,
1154
+ ): Promise<signAuthorization.ReturnValue> {
1155
+ const prepared = (
1156
+ 'multisig' in parameters
1157
+ ? parameters
1158
+ : await prepareAuthorization(client, parameters)
1159
+ ) as prepareAuthorization.ReturnValue
1160
+ const {
1161
+ accessKey,
1162
+ account: account_,
1163
+ chainId,
1164
+ multisig: multisigState,
1165
+ signPayload: _,
1166
+ ...rest
1167
+ } = prepared
1168
+ return signKeyAuthorization(account_ as never, {
1169
+ chainId: BigInt(chainId),
1170
+ key: accessKey,
1171
+ multisig: multisigState,
1172
+ ...rest,
1173
+ })
1174
+ }
1175
+
1176
+ export namespace signAuthorization {
1177
+ export type Parameters<
1178
+ account extends Account | undefined = Account | undefined,
1179
+ > = prepareAuthorization.Parameters<account> & {
1180
+ /** Serialized approvals from external multisig owners. */
1181
+ signatures?: readonly SignatureEnvelope.Serialized[] | undefined
1182
+ }
1183
+
1088
1184
  export type ReturnValue = Awaited<ReturnType<typeof signKeyAuthorization>>
1089
1185
  }
1090
1186
 
@@ -6,6 +6,7 @@ export * as dex from './dex.js'
6
6
  export * as earn from './earn.js'
7
7
  export * as faucet from './faucet.js'
8
8
  export * as fee from './fee.js'
9
+ export * as multisig from './multisig.js'
9
10
  export * as nonce from './nonce.js'
10
11
  export * as policy from './policy.js'
11
12
  export * as receivePolicy from './receivePolicy.js'