viem 2.55.17 → 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.
- package/CHANGELOG.md +16 -0
- package/_cjs/chains/definitions/morphTachyon.js +25 -0
- package/_cjs/chains/definitions/morphTachyon.js.map +1 -0
- package/_cjs/chains/definitions/morphTachyonTestnet.js +26 -0
- package/_cjs/chains/definitions/morphTachyonTestnet.js.map +1 -0
- package/_cjs/chains/definitions/ynxTestnet.js +26 -0
- package/_cjs/chains/definitions/ynxTestnet.js.map +1 -0
- package/_cjs/chains/index.js +13 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Abis.js +102 -1
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Account.js +188 -16
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js +8 -0
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Formatters.js +1 -1
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/Selectors.js +7 -1
- package/_cjs/tempo/Selectors.js.map +1 -1
- package/_cjs/tempo/Transaction.js +31 -10
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/actions/accessKey.js +49 -8
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +12 -4
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/index.js +2 -1
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/multisig.js +95 -0
- package/_cjs/tempo/actions/multisig.js.map +1 -0
- package/_cjs/tempo/actions/zone.js +16 -16
- package/_cjs/tempo/actions/zone.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +58 -29
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/internal/multisig.js +56 -0
- package/_cjs/tempo/internal/multisig.js.map +1 -0
- package/_cjs/tempo/zones/Abis.js +2 -2
- package/_cjs/tempo/zones/Abis.js.map +1 -1
- package/_esm/chains/definitions/morphTachyon.js +22 -0
- package/_esm/chains/definitions/morphTachyon.js.map +1 -0
- package/_esm/chains/definitions/morphTachyonTestnet.js +23 -0
- package/_esm/chains/definitions/morphTachyonTestnet.js.map +1 -0
- package/_esm/chains/definitions/ynxTestnet.js +23 -0
- package/_esm/chains/definitions/ynxTestnet.js.map +1 -0
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Abis.js +101 -0
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Account.js +196 -66
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Addresses.js +1 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Decorator.js +8 -0
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Formatters.js +3 -6
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/Selectors.js +6 -0
- package/_esm/tempo/Selectors.js.map +1 -1
- package/_esm/tempo/Transaction.js +31 -10
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/actions/accessKey.js +65 -23
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/earn.js +14 -6
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/index.js +1 -0
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/multisig.js +245 -0
- package/_esm/tempo/actions/multisig.js.map +1 -0
- package/_esm/tempo/actions/zone.js +17 -17
- package/_esm/tempo/actions/zone.js.map +1 -1
- package/_esm/tempo/chainConfig.js +65 -35
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/internal/multisig.js +56 -0
- package/_esm/tempo/internal/multisig.js.map +1 -0
- package/_esm/tempo/zones/Abis.js +2 -2
- package/_esm/tempo/zones/Abis.js.map +1 -1
- package/_types/chains/definitions/morphTachyon.d.ts +51 -0
- package/_types/chains/definitions/morphTachyon.d.ts.map +1 -0
- package/_types/chains/definitions/morphTachyonTestnet.d.ts +51 -0
- package/_types/chains/definitions/morphTachyonTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +30 -2
- package/_types/chains/definitions/tempo.d.ts.map +1 -1
- package/_types/chains/definitions/tempoDevnet.d.ts +30 -2
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +30 -2
- package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoModerato.d.ts +30 -2
- package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
- package/_types/chains/definitions/ynxTestnet.d.ts +51 -0
- package/_types/chains/definitions/ynxTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Abis.d.ts +321 -0
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Account.d.ts +42 -26
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +1 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +34 -2
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/Selectors.d.ts +6 -0
- package/_types/tempo/Selectors.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +17 -2
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/actions/accessKey.d.ts +35 -17
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/actions/earn.d.ts +5 -5
- package/_types/tempo/actions/earn.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/multisig.d.ts +472 -0
- package/_types/tempo/actions/multisig.d.ts.map +1 -0
- package/_types/tempo/actions/zone.d.ts +17 -17
- package/_types/tempo/actions/zone.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +15 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/internal/multisig.d.ts +13 -0
- package/_types/tempo/internal/multisig.d.ts.map +1 -0
- package/_types/tempo/zones/Abis.d.ts +2 -2
- package/_types/tempo/zones/zone.d.ts +90 -6
- package/_types/tempo/zones/zone.d.ts.map +1 -1
- package/chains/definitions/morphTachyon.ts +22 -0
- package/chains/definitions/morphTachyonTestnet.ts +23 -0
- package/chains/definitions/ynxTestnet.ts +23 -0
- package/chains/index.ts +3 -0
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Abis.ts +102 -0
- package/tempo/Account.ts +329 -51
- package/tempo/Addresses.ts +1 -0
- package/tempo/Decorator.ts +52 -2
- package/tempo/Formatters.ts +4 -5
- package/tempo/Selectors.ts +7 -0
- package/tempo/Transaction.ts +52 -12
- package/tempo/actions/accessKey.ts +128 -32
- package/tempo/actions/earn.ts +19 -11
- package/tempo/actions/index.ts +1 -0
- package/tempo/actions/multisig.ts +356 -0
- package/tempo/actions/zone.ts +35 -31
- package/tempo/chainConfig.ts +82 -35
- package/tempo/internal/multisig.ts +72 -0
- package/tempo/zones/Abis.ts +2 -2
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import type { Address } from 'abitype'
|
|
2
|
+
import { MultisigConfig } from 'ox/tempo'
|
|
3
|
+
import type { Account } from '../../accounts/types.js'
|
|
4
|
+
import type { ReadContractReturnType } from '../../actions/public/readContract.js'
|
|
5
|
+
import { readContract } from '../../actions/public/readContract.js'
|
|
6
|
+
import type { WriteContractReturnType } from '../../actions/wallet/writeContract.js'
|
|
7
|
+
import { writeContract } from '../../actions/wallet/writeContract.js'
|
|
8
|
+
import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
|
|
9
|
+
import type { Client } from '../../clients/createClient.js'
|
|
10
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
11
|
+
import type { BaseErrorType } from '../../errors/base.js'
|
|
12
|
+
import type { Chain } from '../../types/chain.js'
|
|
13
|
+
import type { GetEventArgs } from '../../types/contract.js'
|
|
14
|
+
import type { Log } from '../../types/log.js'
|
|
15
|
+
import type { Compute } from '../../types/utils.js'
|
|
16
|
+
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
17
|
+
import * as Abis from '../Abis.js'
|
|
18
|
+
import * as Addresses from '../Addresses.js'
|
|
19
|
+
import type { ReadParameters, WriteParameters } from '../internal/types.js'
|
|
20
|
+
import { defineCall } from '../internal/utils.js'
|
|
21
|
+
import type { TransactionReceipt } from '../Transaction.js'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Checks whether an address is an initialized native multisig account.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { createClient, http } from 'viem'
|
|
29
|
+
* import { tempo } from 'viem/chains'
|
|
30
|
+
* import { Actions } from 'viem/tempo'
|
|
31
|
+
*
|
|
32
|
+
* const client = createClient({
|
|
33
|
+
* chain: tempo,
|
|
34
|
+
* transport: http(),
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const initialized = await Actions.multisig.isInitialized(client, {
|
|
38
|
+
* account: '0x...',
|
|
39
|
+
* })
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param client - Client.
|
|
43
|
+
* @param parameters - Parameters.
|
|
44
|
+
* @returns Whether the account is an initialized native multisig account.
|
|
45
|
+
*/
|
|
46
|
+
export async function isInitialized<
|
|
47
|
+
chain extends Chain | undefined,
|
|
48
|
+
account extends Account | undefined,
|
|
49
|
+
>(
|
|
50
|
+
client: Client<Transport, chain, account>,
|
|
51
|
+
parameters: isInitialized.Parameters,
|
|
52
|
+
): Promise<isInitialized.ReturnValue> {
|
|
53
|
+
const { account, ...rest } = parameters
|
|
54
|
+
return readContract(client, {
|
|
55
|
+
...rest,
|
|
56
|
+
...isInitialized.call({ account }),
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export namespace isInitialized {
|
|
61
|
+
export type Parameters = ReadParameters & Args
|
|
62
|
+
|
|
63
|
+
export type Args = {
|
|
64
|
+
/** Account address. */
|
|
65
|
+
account: Address
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type ReturnValue = ReadContractReturnType<
|
|
69
|
+
typeof Abis.nativeMultisig,
|
|
70
|
+
'isMultisigAccount',
|
|
71
|
+
never
|
|
72
|
+
>
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Defines a call to the precompile's `isMultisigAccount` function.
|
|
76
|
+
*
|
|
77
|
+
* Can be passed to [`multicall`](https://viem.sh/docs/contract/multicall).
|
|
78
|
+
*
|
|
79
|
+
* @param args - Arguments.
|
|
80
|
+
* @returns The call.
|
|
81
|
+
*/
|
|
82
|
+
export function call(args: Args) {
|
|
83
|
+
return defineCall({
|
|
84
|
+
address: Addresses.nativeMultisig,
|
|
85
|
+
abi: Abis.nativeMultisig,
|
|
86
|
+
args: [args.account],
|
|
87
|
+
functionName: 'isMultisigAccount',
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Gets the current configuration for an initialized native multisig account.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* import { createClient, http } from 'viem'
|
|
98
|
+
* import { tempo } from 'viem/chains'
|
|
99
|
+
* import { Actions } from 'viem/tempo'
|
|
100
|
+
*
|
|
101
|
+
* const client = createClient({
|
|
102
|
+
* chain: tempo,
|
|
103
|
+
* transport: http(),
|
|
104
|
+
* })
|
|
105
|
+
*
|
|
106
|
+
* const config = await Actions.multisig.getConfig(client, {
|
|
107
|
+
* account: '0x...',
|
|
108
|
+
* })
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @param client - Client.
|
|
112
|
+
* @param parameters - Parameters.
|
|
113
|
+
* @returns The current version, threshold, and owners.
|
|
114
|
+
*/
|
|
115
|
+
export async function getConfig<
|
|
116
|
+
chain extends Chain | undefined,
|
|
117
|
+
account extends Account | undefined,
|
|
118
|
+
>(
|
|
119
|
+
client: Client<Transport, chain, account>,
|
|
120
|
+
parameters: getConfig.Parameters,
|
|
121
|
+
): Promise<getConfig.ReturnValue> {
|
|
122
|
+
const { account, ...rest } = parameters
|
|
123
|
+
return readContract(client, {
|
|
124
|
+
...rest,
|
|
125
|
+
...getConfig.call({ account }),
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export namespace getConfig {
|
|
130
|
+
export type Parameters = ReadParameters & Args
|
|
131
|
+
|
|
132
|
+
export type Args = {
|
|
133
|
+
/** Initialized multisig account address. */
|
|
134
|
+
account: Address
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type ReturnValue = ReadContractReturnType<
|
|
138
|
+
typeof Abis.nativeMultisig,
|
|
139
|
+
'getConfig',
|
|
140
|
+
never
|
|
141
|
+
>
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Defines a call to the `getConfig` function.
|
|
145
|
+
*
|
|
146
|
+
* Can be passed to [`multicall`](https://viem.sh/docs/contract/multicall).
|
|
147
|
+
*
|
|
148
|
+
* @param args - Arguments.
|
|
149
|
+
* @returns The call.
|
|
150
|
+
*/
|
|
151
|
+
export function call(args: Args) {
|
|
152
|
+
return defineCall({
|
|
153
|
+
address: Addresses.nativeMultisig,
|
|
154
|
+
abi: Abis.nativeMultisig,
|
|
155
|
+
args: [args.account],
|
|
156
|
+
functionName: 'getConfig',
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Replaces the current configuration for a native multisig account.
|
|
163
|
+
*
|
|
164
|
+
* The transaction must be authorized directly by the account's current owner
|
|
165
|
+
* quorum. Local owner-signing flows can include {@link updateConfig.call} in a
|
|
166
|
+
* prepared transaction before collecting approvals.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* import { createClient, http } from 'viem'
|
|
171
|
+
* import { sendTransactionSync } from 'viem/actions'
|
|
172
|
+
* import { tempoLocalnet } from 'viem/chains'
|
|
173
|
+
* import { Account, Actions } from 'viem/tempo'
|
|
174
|
+
*
|
|
175
|
+
* const owner = Account.fromSecp256k1(
|
|
176
|
+
* '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
|
|
177
|
+
* )
|
|
178
|
+
* const account = Account.fromMultisig({ owners: [owner] })
|
|
179
|
+
* const client = createClient({
|
|
180
|
+
* chain: tempoLocalnet,
|
|
181
|
+
* transport: http(),
|
|
182
|
+
* })
|
|
183
|
+
*
|
|
184
|
+
* await sendTransactionSync(client, {
|
|
185
|
+
* account,
|
|
186
|
+
* to: account.address,
|
|
187
|
+
* })
|
|
188
|
+
*
|
|
189
|
+
* const hash = await Actions.multisig.updateConfig(client, {
|
|
190
|
+
* account,
|
|
191
|
+
* threshold: 1,
|
|
192
|
+
* owners: [{ owner: owner.address, weight: 1 }],
|
|
193
|
+
* })
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @param client - Client.
|
|
197
|
+
* @param parameters - Parameters.
|
|
198
|
+
* @returns The transaction hash.
|
|
199
|
+
*/
|
|
200
|
+
export async function updateConfig<
|
|
201
|
+
chain extends Chain | undefined,
|
|
202
|
+
account extends Account | undefined,
|
|
203
|
+
>(
|
|
204
|
+
client: Client<Transport, chain, account>,
|
|
205
|
+
parameters: updateConfig.Parameters<chain, account>,
|
|
206
|
+
): Promise<updateConfig.ReturnValue> {
|
|
207
|
+
return updateConfig.inner(writeContract, client, parameters)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export namespace updateConfig {
|
|
211
|
+
export type Parameters<
|
|
212
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
213
|
+
account extends Account | undefined = Account | undefined,
|
|
214
|
+
> = WriteParameters<chain, account> & Args
|
|
215
|
+
|
|
216
|
+
export type Args = {
|
|
217
|
+
/** New multisig owners and their weights. */
|
|
218
|
+
owners: MultisigConfig.Config['owners']
|
|
219
|
+
/** New signature weight required to authorize the account. */
|
|
220
|
+
threshold: MultisigConfig.Config['threshold']
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export type ReturnValue = WriteContractReturnType
|
|
224
|
+
|
|
225
|
+
// TODO: exhaustive error type
|
|
226
|
+
export type ErrorType = BaseErrorType
|
|
227
|
+
|
|
228
|
+
/** @internal */
|
|
229
|
+
export async function inner<
|
|
230
|
+
action extends typeof writeContract | typeof writeContractSync,
|
|
231
|
+
chain extends Chain | undefined,
|
|
232
|
+
account extends Account | undefined,
|
|
233
|
+
>(
|
|
234
|
+
action: action,
|
|
235
|
+
client: Client<Transport, chain, account>,
|
|
236
|
+
parameters: Parameters<chain, account>,
|
|
237
|
+
): Promise<ReturnType<action>> {
|
|
238
|
+
const { owners, threshold, ...rest } = parameters
|
|
239
|
+
return (await action(client, {
|
|
240
|
+
...rest,
|
|
241
|
+
...updateConfig.call({ owners, threshold }),
|
|
242
|
+
} as never)) as never
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Defines a call to the `updateConfig` function.
|
|
247
|
+
*
|
|
248
|
+
* Can be passed as a parameter to:
|
|
249
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate gas
|
|
250
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the update
|
|
251
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): include the update in a call batch
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* import { Actions } from 'viem/tempo'
|
|
256
|
+
*
|
|
257
|
+
* const call = Actions.multisig.updateConfig.call({
|
|
258
|
+
* threshold: 1,
|
|
259
|
+
* owners: [{ owner: '0x...', weight: 1 }],
|
|
260
|
+
* })
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
263
|
+
* @param args - New multisig configuration.
|
|
264
|
+
* @returns The call.
|
|
265
|
+
*/
|
|
266
|
+
export function call(args: Args) {
|
|
267
|
+
const config = MultisigConfig.from(args)
|
|
268
|
+
return defineCall({
|
|
269
|
+
address: Addresses.nativeMultisig,
|
|
270
|
+
abi: Abis.nativeMultisig,
|
|
271
|
+
args: [config.threshold, config.owners],
|
|
272
|
+
functionName: 'updateConfig',
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Extracts the `MultisigConfigUpdated` event from logs.
|
|
278
|
+
*
|
|
279
|
+
* @param logs - Transaction logs.
|
|
280
|
+
* @returns The configuration update event.
|
|
281
|
+
*/
|
|
282
|
+
export function extractEvent(logs: Log[]) {
|
|
283
|
+
const [log] = parseEventLogs({
|
|
284
|
+
abi: Abis.nativeMultisig,
|
|
285
|
+
logs,
|
|
286
|
+
eventName: 'MultisigConfigUpdated',
|
|
287
|
+
strict: true,
|
|
288
|
+
})
|
|
289
|
+
if (!log) throw new Error('`MultisigConfigUpdated` event not found.')
|
|
290
|
+
return log
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Replaces a native multisig configuration and waits for confirmation.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* import { createWalletClient, custom, type EIP1193Provider } from 'viem'
|
|
300
|
+
* import { tempo } from 'viem/chains'
|
|
301
|
+
* import { Actions } from 'viem/tempo'
|
|
302
|
+
*
|
|
303
|
+
* declare const provider: EIP1193Provider
|
|
304
|
+
*
|
|
305
|
+
* const client = createWalletClient({
|
|
306
|
+
* account: '0x...',
|
|
307
|
+
* chain: tempo,
|
|
308
|
+
* transport: custom(provider),
|
|
309
|
+
* })
|
|
310
|
+
*
|
|
311
|
+
* const { receipt } = await Actions.multisig.updateConfigSync(client, {
|
|
312
|
+
* threshold: 1,
|
|
313
|
+
* owners: [{ owner: '0x...', weight: 1 }],
|
|
314
|
+
* })
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* @param client - Client.
|
|
318
|
+
* @param parameters - Parameters.
|
|
319
|
+
* @returns The updated configuration event and transaction receipt.
|
|
320
|
+
*/
|
|
321
|
+
export async function updateConfigSync<
|
|
322
|
+
chain extends Chain | undefined,
|
|
323
|
+
account extends Account | undefined,
|
|
324
|
+
>(
|
|
325
|
+
client: Client<Transport, chain, account>,
|
|
326
|
+
parameters: updateConfigSync.Parameters<chain, account>,
|
|
327
|
+
): Promise<updateConfigSync.ReturnValue> {
|
|
328
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters
|
|
329
|
+
const receipt = await updateConfig.inner(writeContractSync, client, {
|
|
330
|
+
...rest,
|
|
331
|
+
throwOnReceiptRevert,
|
|
332
|
+
} as never)
|
|
333
|
+
const { args } = updateConfig.extractEvent(receipt.logs)
|
|
334
|
+
return { ...args, receipt } as never
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export namespace updateConfigSync {
|
|
338
|
+
export type Parameters<
|
|
339
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
340
|
+
account extends Account | undefined = Account | undefined,
|
|
341
|
+
> = updateConfig.Parameters<chain, account>
|
|
342
|
+
|
|
343
|
+
export type Args = updateConfig.Args
|
|
344
|
+
|
|
345
|
+
export type ReturnValue = Compute<
|
|
346
|
+
GetEventArgs<
|
|
347
|
+
typeof Abis.nativeMultisig,
|
|
348
|
+
'MultisigConfigUpdated',
|
|
349
|
+
{ IndexedOnly: false; Required: true }
|
|
350
|
+
> & {
|
|
351
|
+
receipt: TransactionReceipt
|
|
352
|
+
}
|
|
353
|
+
>
|
|
354
|
+
|
|
355
|
+
export type ErrorType = updateConfig.ErrorType
|
|
356
|
+
}
|
package/tempo/actions/zone.ts
CHANGED
|
@@ -76,8 +76,6 @@ export type EncryptedPayload = {
|
|
|
76
76
|
export type PreparedEncryptedDeposit = {
|
|
77
77
|
/** Amount of tokens to deposit. */
|
|
78
78
|
amount: bigint
|
|
79
|
-
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
80
|
-
bouncebackRecipient: Address
|
|
81
79
|
/** Parent chain ID (e.g. `42431` for moderato). */
|
|
82
80
|
chainId: number
|
|
83
81
|
/** Encrypted deposit payload. */
|
|
@@ -88,6 +86,8 @@ export type PreparedEncryptedDeposit = {
|
|
|
88
86
|
portalAddress: Address
|
|
89
87
|
/** Address that will call the Zone portal. */
|
|
90
88
|
sender: Address
|
|
89
|
+
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
90
|
+
tempoRefundRecipient: Address
|
|
91
91
|
/** Token address or ID to deposit. */
|
|
92
92
|
token: TokenId.TokenIdOrAddress
|
|
93
93
|
/** Zone ID (e.g. `7`). */
|
|
@@ -153,12 +153,13 @@ export async function deposit<
|
|
|
153
153
|
if (!account_) throw new Error('`account` is required.')
|
|
154
154
|
|
|
155
155
|
const recipient = parameters.recipient ?? account_.address
|
|
156
|
-
const
|
|
156
|
+
const tempoRefundRecipient =
|
|
157
|
+
parameters.tempoRefundRecipient ?? account_.address
|
|
157
158
|
const args = {
|
|
158
159
|
...parameters,
|
|
159
|
-
bouncebackRecipient,
|
|
160
160
|
chainId,
|
|
161
161
|
recipient,
|
|
162
|
+
tempoRefundRecipient,
|
|
162
163
|
}
|
|
163
164
|
return sendTransaction(client, {
|
|
164
165
|
...rest,
|
|
@@ -172,18 +173,16 @@ export namespace deposit {
|
|
|
172
173
|
chain extends Chain | undefined = Chain | undefined,
|
|
173
174
|
account extends Account | undefined = Account | undefined,
|
|
174
175
|
> = WriteParameters<chain, account> &
|
|
175
|
-
Omit<Args, '
|
|
176
|
-
/** Refund recipient on the parent chain. @default `account.address` */
|
|
177
|
-
bouncebackRecipient?: Address | undefined
|
|
176
|
+
Omit<Args, 'chainId' | 'recipient' | 'tempoRefundRecipient'> & {
|
|
178
177
|
/** Recipient address in the zone. @default `account.address` */
|
|
179
178
|
recipient?: Address | undefined
|
|
179
|
+
/** Refund recipient on the parent chain. @default `account.address` */
|
|
180
|
+
tempoRefundRecipient?: Address | undefined
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
export type Args = {
|
|
183
184
|
/** Amount of tokens to deposit. */
|
|
184
185
|
amount: bigint
|
|
185
|
-
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
186
|
-
bouncebackRecipient: Address
|
|
187
186
|
/** Parent chain ID (e.g. `42431` for moderato). */
|
|
188
187
|
chainId: number
|
|
189
188
|
/** Optional deposit memo. @default `0x00...00` */
|
|
@@ -192,6 +191,8 @@ export namespace deposit {
|
|
|
192
191
|
portalAddress?: Address | undefined
|
|
193
192
|
/** Recipient address in the zone. */
|
|
194
193
|
recipient: Address
|
|
194
|
+
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
195
|
+
tempoRefundRecipient: Address
|
|
195
196
|
/** Token address or ID to deposit. */
|
|
196
197
|
token: TokenId.TokenIdOrAddress
|
|
197
198
|
/** Zone ID (e.g. `7`). */
|
|
@@ -212,10 +213,10 @@ export namespace deposit {
|
|
|
212
213
|
export function calls(args: Args) {
|
|
213
214
|
const {
|
|
214
215
|
amount,
|
|
215
|
-
bouncebackRecipient,
|
|
216
216
|
chainId,
|
|
217
217
|
memo = zeroHash,
|
|
218
218
|
recipient,
|
|
219
|
+
tempoRefundRecipient,
|
|
219
220
|
token,
|
|
220
221
|
zoneId,
|
|
221
222
|
} = args
|
|
@@ -232,7 +233,7 @@ export namespace deposit {
|
|
|
232
233
|
address: portalAddress,
|
|
233
234
|
abi: ZoneAbis.zonePortal,
|
|
234
235
|
functionName: 'deposit',
|
|
235
|
-
args: [tokenAddress, recipient, amount, memo,
|
|
236
|
+
args: [tokenAddress, recipient, amount, memo, tempoRefundRecipient],
|
|
236
237
|
})
|
|
237
238
|
return [approveCall, depositCall]
|
|
238
239
|
}
|
|
@@ -286,12 +287,13 @@ export async function depositSync<
|
|
|
286
287
|
if (!account_) throw new Error('`account` is required.')
|
|
287
288
|
|
|
288
289
|
const recipient = parameters.recipient ?? account_.address
|
|
289
|
-
const
|
|
290
|
+
const tempoRefundRecipient =
|
|
291
|
+
parameters.tempoRefundRecipient ?? account_.address
|
|
290
292
|
const args = {
|
|
291
293
|
...parameters,
|
|
292
|
-
bouncebackRecipient,
|
|
293
294
|
chainId,
|
|
294
295
|
recipient,
|
|
296
|
+
tempoRefundRecipient,
|
|
295
297
|
}
|
|
296
298
|
const receipt = await sendTransactionSync(client, {
|
|
297
299
|
...rest,
|
|
@@ -478,7 +480,8 @@ export async function encryptedDeposit<
|
|
|
478
480
|
const account_ = account ? parseAccount(account) : undefined
|
|
479
481
|
if (!account_) throw new Error('`account` is required.')
|
|
480
482
|
|
|
481
|
-
const
|
|
483
|
+
const tempoRefundRecipient =
|
|
484
|
+
parameters.tempoRefundRecipient ?? account_.address
|
|
482
485
|
|
|
483
486
|
if ('encrypted' in parameters) {
|
|
484
487
|
if (parameters.chainId !== chainId) {
|
|
@@ -490,7 +493,7 @@ export async function encryptedDeposit<
|
|
|
490
493
|
...pickWriteParameters(parameters as never),
|
|
491
494
|
calls: encryptedDeposit.calls({
|
|
492
495
|
...parameters,
|
|
493
|
-
|
|
496
|
+
tempoRefundRecipient,
|
|
494
497
|
}),
|
|
495
498
|
} as never) as never
|
|
496
499
|
}
|
|
@@ -499,11 +502,11 @@ export async function encryptedDeposit<
|
|
|
499
502
|
|
|
500
503
|
const prepared = await encryptedDeposit.prepare(client, {
|
|
501
504
|
amount: parameters.amount,
|
|
502
|
-
bouncebackRecipient,
|
|
503
505
|
memo: parameters.memo,
|
|
504
506
|
portalAddress: parameters.portalAddress,
|
|
505
507
|
recipient,
|
|
506
508
|
sender: account_.address,
|
|
509
|
+
tempoRefundRecipient,
|
|
507
510
|
token: parameters.token,
|
|
508
511
|
zoneId: parameters.zoneId,
|
|
509
512
|
})
|
|
@@ -522,16 +525,16 @@ export namespace encryptedDeposit {
|
|
|
522
525
|
(
|
|
523
526
|
| (Omit<
|
|
524
527
|
Args,
|
|
525
|
-
| 'bouncebackRecipient'
|
|
526
528
|
| 'chainId'
|
|
527
529
|
| 'encrypted'
|
|
528
530
|
| 'keyIndex'
|
|
529
531
|
| 'recipient'
|
|
532
|
+
| 'tempoRefundRecipient'
|
|
530
533
|
> & {
|
|
531
|
-
/** Refund recipient on the parent chain. @default `account.address` */
|
|
532
|
-
bouncebackRecipient?: Address | undefined
|
|
533
534
|
/** Recipient address in the zone. @default `account.address` */
|
|
534
535
|
recipient?: Address | undefined
|
|
536
|
+
/** Refund recipient on the parent chain. @default `account.address` */
|
|
537
|
+
tempoRefundRecipient?: Address | undefined
|
|
535
538
|
})
|
|
536
539
|
| PreparedEncryptedDeposit
|
|
537
540
|
)
|
|
@@ -539,8 +542,6 @@ export namespace encryptedDeposit {
|
|
|
539
542
|
export type Args = {
|
|
540
543
|
/** Amount of tokens to deposit. */
|
|
541
544
|
amount: bigint
|
|
542
|
-
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
543
|
-
bouncebackRecipient: Address
|
|
544
545
|
/** Parent chain ID (e.g. `42431` for moderato). */
|
|
545
546
|
chainId: number
|
|
546
547
|
/** Encrypted deposit payload. */
|
|
@@ -553,6 +554,8 @@ export namespace encryptedDeposit {
|
|
|
553
554
|
portalAddress?: Address | undefined
|
|
554
555
|
/** Recipient address in the zone. */
|
|
555
556
|
recipient: Address
|
|
557
|
+
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
558
|
+
tempoRefundRecipient: Address
|
|
556
559
|
/** Token address or ID to deposit. */
|
|
557
560
|
token: TokenId.TokenIdOrAddress
|
|
558
561
|
/** Zone ID (e.g. `7`). */
|
|
@@ -581,9 +584,9 @@ export namespace encryptedDeposit {
|
|
|
581
584
|
* const prepared = await Actions.zone.encryptedDeposit.prepare(client, {
|
|
582
585
|
* token: '0x20c0...0001',
|
|
583
586
|
* amount: 1_000_000n,
|
|
584
|
-
* bouncebackRecipient: '0x...',
|
|
585
587
|
* recipient: '0x...',
|
|
586
588
|
* sender: '0x...',
|
|
589
|
+
* tempoRefundRecipient: '0x...',
|
|
587
590
|
* zoneId: 7,
|
|
588
591
|
* })
|
|
589
592
|
* ```
|
|
@@ -604,11 +607,11 @@ export namespace encryptedDeposit {
|
|
|
604
607
|
|
|
605
608
|
const {
|
|
606
609
|
amount,
|
|
607
|
-
bouncebackRecipient,
|
|
608
610
|
memo,
|
|
609
611
|
portalAddress: portalAddress_,
|
|
610
612
|
recipient,
|
|
611
613
|
sender: sender_ = client.account?.address,
|
|
614
|
+
tempoRefundRecipient,
|
|
612
615
|
token,
|
|
613
616
|
zoneId,
|
|
614
617
|
...rest
|
|
@@ -634,12 +637,12 @@ export namespace encryptedDeposit {
|
|
|
634
637
|
|
|
635
638
|
return {
|
|
636
639
|
amount,
|
|
637
|
-
bouncebackRecipient,
|
|
638
640
|
chainId,
|
|
639
641
|
encrypted,
|
|
640
642
|
keyIndex,
|
|
641
643
|
portalAddress,
|
|
642
644
|
sender,
|
|
645
|
+
tempoRefundRecipient,
|
|
643
646
|
token,
|
|
644
647
|
zoneId,
|
|
645
648
|
}
|
|
@@ -661,8 +664,6 @@ export namespace encryptedDeposit {
|
|
|
661
664
|
export type Args = {
|
|
662
665
|
/** Amount of tokens to deposit. */
|
|
663
666
|
amount: bigint
|
|
664
|
-
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
665
|
-
bouncebackRecipient: Address
|
|
666
667
|
/** Optional deposit memo. @default `0x00...00` */
|
|
667
668
|
memo?: Hex.Hex | undefined
|
|
668
669
|
/** Zone portal address. @default resolved via the portal registry. */
|
|
@@ -671,6 +672,8 @@ export namespace encryptedDeposit {
|
|
|
671
672
|
recipient: Address
|
|
672
673
|
/** Address that will call the Zone portal. */
|
|
673
674
|
sender: Address
|
|
675
|
+
/** Refund recipient on the parent chain if the deposit bounces. */
|
|
676
|
+
tempoRefundRecipient: Address
|
|
674
677
|
/** Token address or ID to deposit. */
|
|
675
678
|
token: TokenId.TokenIdOrAddress
|
|
676
679
|
/** Zone ID (e.g. `7`). */
|
|
@@ -796,10 +799,10 @@ export namespace encryptedDeposit {
|
|
|
796
799
|
export function calls(args: Args | PreparedEncryptedDeposit) {
|
|
797
800
|
const {
|
|
798
801
|
amount,
|
|
799
|
-
bouncebackRecipient,
|
|
800
802
|
chainId,
|
|
801
803
|
encrypted,
|
|
802
804
|
keyIndex,
|
|
805
|
+
tempoRefundRecipient,
|
|
803
806
|
token,
|
|
804
807
|
zoneId,
|
|
805
808
|
} = args
|
|
@@ -828,7 +831,7 @@ export namespace encryptedDeposit {
|
|
|
828
831
|
amount,
|
|
829
832
|
keyIndex,
|
|
830
833
|
encryptedPayload,
|
|
831
|
-
|
|
834
|
+
tempoRefundRecipient,
|
|
832
835
|
],
|
|
833
836
|
})
|
|
834
837
|
return [approveCall, depositCall]
|
|
@@ -882,7 +885,8 @@ export async function encryptedDepositSync<
|
|
|
882
885
|
const account_ = account ? parseAccount(account) : undefined
|
|
883
886
|
if (!account_) throw new Error('`account` is required.')
|
|
884
887
|
|
|
885
|
-
const
|
|
888
|
+
const tempoRefundRecipient =
|
|
889
|
+
parameters.tempoRefundRecipient ?? account_.address
|
|
886
890
|
|
|
887
891
|
if ('encrypted' in parameters) {
|
|
888
892
|
if (parameters.chainId !== chainId) {
|
|
@@ -896,7 +900,7 @@ export async function encryptedDepositSync<
|
|
|
896
900
|
throwOnReceiptRevert,
|
|
897
901
|
calls: encryptedDeposit.calls({
|
|
898
902
|
...parameters,
|
|
899
|
-
|
|
903
|
+
tempoRefundRecipient,
|
|
900
904
|
}),
|
|
901
905
|
} as never)
|
|
902
906
|
return { receipt }
|
|
@@ -906,11 +910,11 @@ export async function encryptedDepositSync<
|
|
|
906
910
|
|
|
907
911
|
const prepared = await encryptedDeposit.prepare(client, {
|
|
908
912
|
amount: parameters.amount,
|
|
909
|
-
bouncebackRecipient,
|
|
910
913
|
memo: parameters.memo,
|
|
911
914
|
portalAddress: parameters.portalAddress,
|
|
912
915
|
recipient,
|
|
913
916
|
sender: account_.address,
|
|
917
|
+
tempoRefundRecipient,
|
|
914
918
|
token: parameters.token,
|
|
915
919
|
zoneId: parameters.zoneId,
|
|
916
920
|
})
|