ox 0.14.55 → 0.14.57
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 +48 -0
- package/_cjs/tempo/{MultisigConfig.js → AccountConfig.js} +32 -9
- package/_cjs/tempo/AccountConfig.js.map +1 -0
- package/_cjs/tempo/{MultisigOperation.js → AccountOperation.js} +29 -29
- package/_cjs/tempo/AccountOperation.js.map +1 -0
- package/_cjs/tempo/{MultisigSimulation.js → AccountSimulation.js} +22 -13
- package/_cjs/tempo/AccountSimulation.js.map +1 -0
- package/_cjs/tempo/KeyAuthorization.js +10 -18
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +64 -64
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +15 -10
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/index.js +4 -4
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/{MultisigConfig.js → AccountConfig.js} +161 -64
- package/_esm/tempo/AccountConfig.js.map +1 -0
- package/_esm/tempo/{MultisigOperation.js → AccountOperation.js} +64 -64
- package/_esm/tempo/AccountOperation.js.map +1 -0
- package/_esm/tempo/{MultisigSimulation.js → AccountSimulation.js} +35 -25
- package/_esm/tempo/AccountSimulation.js.map +1 -0
- package/_esm/tempo/KeyAuthorization.js +16 -19
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +71 -71
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +15 -10
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/index.js +50 -48
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +156 -66
- package/_types/tempo/AccountConfig.d.ts.map +1 -0
- package/_types/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +62 -62
- package/_types/tempo/AccountOperation.d.ts.map +1 -0
- package/_types/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +25 -21
- package/_types/tempo/AccountSimulation.d.ts.map +1 -0
- package/_types/tempo/KeyAuthorization.d.ts +28 -23
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/RpcSchemaTempo.d.ts +13 -13
- package/_types/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +36 -33
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +11 -9
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +50 -48
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +31 -31
- package/tempo/AccountConfig/package.json +6 -0
- package/tempo/AccountConfig.test-d/package.json +6 -0
- package/tempo/AccountConfig.test-d.ts +72 -0
- package/tempo/AccountConfig.test.ts +642 -0
- package/tempo/{MultisigConfig.ts → AccountConfig.ts} +212 -75
- package/tempo/AccountOperation/package.json +6 -0
- package/tempo/AccountOperation.test-d/package.json +6 -0
- package/tempo/AccountOperation.test-d.ts +71 -0
- package/tempo/{MultisigOperation.test.ts → AccountOperation.test.ts} +129 -129
- package/tempo/{MultisigOperation.ts → AccountOperation.ts} +95 -97
- package/tempo/AccountSimulation/package.json +6 -0
- package/tempo/AccountSimulation.test-d/package.json +6 -0
- package/tempo/{MultisigSimulation.test-d.ts → AccountSimulation.test-d.ts} +7 -9
- package/tempo/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +73 -29
- package/tempo/{MultisigSimulation.ts → AccountSimulation.ts} +47 -35
- package/tempo/KeyAuthorization.test-d.ts +19 -29
- package/tempo/KeyAuthorization.test.ts +151 -74
- package/tempo/KeyAuthorization.ts +40 -61
- package/tempo/RpcSchemaTempo.test-d.ts +20 -20
- package/tempo/RpcSchemaTempo.ts +13 -13
- package/tempo/SignatureEnvelope.test-d.ts +7 -7
- package/tempo/SignatureEnvelope.test.ts +34 -34
- package/tempo/SignatureEnvelope.ts +107 -103
- package/tempo/Transaction.test.ts +4 -4
- package/tempo/TransactionRequest.test-d.ts +17 -8
- package/tempo/TransactionRequest.test.ts +31 -21
- package/tempo/TransactionRequest.ts +29 -20
- package/tempo/{multisig.e2e.test.ts → configurableAccounts.e2e.test.ts} +16 -16
- package/tempo/index.ts +50 -48
- package/version.ts +1 -1
- package/_cjs/tempo/MultisigConfig.js.map +0 -1
- package/_cjs/tempo/MultisigOperation.js.map +0 -1
- package/_cjs/tempo/MultisigSimulation.js.map +0 -1
- package/_esm/tempo/MultisigConfig.js.map +0 -1
- package/_esm/tempo/MultisigOperation.js.map +0 -1
- package/_esm/tempo/MultisigSimulation.js.map +0 -1
- package/_types/tempo/MultisigConfig.d.ts.map +0 -1
- package/_types/tempo/MultisigOperation.d.ts.map +0 -1
- package/_types/tempo/MultisigSimulation.d.ts.map +0 -1
- package/tempo/MultisigConfig/package.json +0 -6
- package/tempo/MultisigConfig.test-d/package.json +0 -6
- package/tempo/MultisigConfig.test-d.ts +0 -52
- package/tempo/MultisigConfig.test.ts +0 -391
- package/tempo/MultisigOperation/package.json +0 -6
- package/tempo/MultisigOperation.test-d/package.json +0 -6
- package/tempo/MultisigOperation.test-d.ts +0 -71
- package/tempo/MultisigSimulation/package.json +0 -6
- package/tempo/MultisigSimulation.test-d/package.json +0 -6
|
@@ -7,20 +7,25 @@ import * as Hex from '../core/Hex.js';
|
|
|
7
7
|
import type { Compute } from '../core/internal/types.js';
|
|
8
8
|
/** Maximum encoded byte length for one primitive owner approval. */
|
|
9
9
|
export declare const maxOwnerSignatureBytes = 2049;
|
|
10
|
-
/** Maximum number of owners allowed in
|
|
10
|
+
/** Maximum number of owners allowed in an account config. */
|
|
11
11
|
export declare const maxOwners = 48;
|
|
12
|
-
/** Maximum number of owner approvals in a
|
|
12
|
+
/** Maximum number of owner approvals in a configurable account signature. */
|
|
13
13
|
export declare const maxSignatures = 8;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Maximum threshold accepted by an account config.
|
|
16
|
+
*
|
|
17
|
+
* The threshold must also be reachable by at most {@link ox#AccountConfig.maxSignatures}
|
|
18
|
+
* owner approvals.
|
|
19
|
+
*/
|
|
20
|
+
export declare const maxThreshold = 255;
|
|
21
|
+
/** Maximum version accepted by an account config. */
|
|
17
22
|
export declare const maxVersion: bigint;
|
|
18
|
-
/** Tempo signature type byte for
|
|
23
|
+
/** Tempo signature type byte for configurable account signatures. */
|
|
19
24
|
export declare const signatureTypeByte: "0x05";
|
|
20
25
|
/** Zero 32-byte salt (the default when no salt is provided). */
|
|
21
26
|
export declare const zeroSalt: `0x${string}`;
|
|
22
27
|
/**
|
|
23
|
-
* Complete
|
|
28
|
+
* Complete account configuration witness.
|
|
24
29
|
*/
|
|
25
30
|
export type Config<bigintType = bigint, numberType = number> = Compute<{
|
|
26
31
|
/** Weighted owner list, strictly ascending by owner address. */
|
|
@@ -32,13 +37,13 @@ export type Config<bigintType = bigint, numberType = number> = Compute<{
|
|
|
32
37
|
/** Configuration version. Zero identifies the initial configuration. */
|
|
33
38
|
version: bigintType;
|
|
34
39
|
}>;
|
|
35
|
-
/** Input accepted when constructing
|
|
40
|
+
/** Input accepted when constructing an account configuration. */
|
|
36
41
|
export type Input<versionType extends bigint | number = bigint | number, numberType = number> = Compute<{
|
|
37
42
|
/** Weighted owner list (strictly ascending by `owner` address). */
|
|
38
43
|
owners: readonly Owner<numberType>[];
|
|
39
44
|
/**
|
|
40
45
|
* Caller-chosen 32-byte salt mixed into the derived account address.
|
|
41
|
-
* Defaults to the zero salt (`
|
|
46
|
+
* Defaults to the zero salt (`AccountConfig.zeroSalt`) when omitted.
|
|
42
47
|
*/
|
|
43
48
|
salt?: Hex.Hex | undefined;
|
|
44
49
|
/** Minimum total owner weight required to authorize a transaction. */
|
|
@@ -46,16 +51,16 @@ export type Input<versionType extends bigint | number = bigint | number, numberT
|
|
|
46
51
|
/** Configuration version as a safe integer or bigint. Defaults to `0n`. */
|
|
47
52
|
version?: versionType | undefined;
|
|
48
53
|
}>;
|
|
49
|
-
/**
|
|
54
|
+
/** Account config owner entry. */
|
|
50
55
|
export type Owner<numberType = number> = {
|
|
51
56
|
/** Owner address (recovered from the owner's approval). */
|
|
52
57
|
owner: Address.Address;
|
|
53
58
|
/** Nonzero owner weight. */
|
|
54
59
|
weight: numberType;
|
|
55
60
|
};
|
|
56
|
-
/** JSON-RPC representation of
|
|
61
|
+
/** JSON-RPC representation of an account configuration. */
|
|
57
62
|
export type Rpc = Config<Hex.Hex, number>;
|
|
58
|
-
/** RLP tuple representation of a {@link ox#
|
|
63
|
+
/** RLP tuple representation of a {@link ox#AccountConfig.Config}. */
|
|
59
64
|
export type Tuple = readonly [
|
|
60
65
|
salt: Hex.Hex,
|
|
61
66
|
version: Hex.Hex,
|
|
@@ -63,7 +68,7 @@ export type Tuple = readonly [
|
|
|
63
68
|
owners: readonly Hex.Hex[][]
|
|
64
69
|
];
|
|
65
70
|
/**
|
|
66
|
-
* Asserts that
|
|
71
|
+
* Asserts that an {@link ox#AccountConfig.Config} is valid.
|
|
67
72
|
*
|
|
68
73
|
* Mirrors the Tempo configuration rules: owners non-empty and
|
|
69
74
|
* `<= maxOwners`, strictly ascending unique nonzero owner addresses, nonzero
|
|
@@ -73,9 +78,9 @@ export type Tuple = readonly [
|
|
|
73
78
|
*
|
|
74
79
|
* @example
|
|
75
80
|
* ```ts twoslash
|
|
76
|
-
* import {
|
|
81
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
77
82
|
*
|
|
78
|
-
*
|
|
83
|
+
* AccountConfig.assert({
|
|
79
84
|
* threshold: 1,
|
|
80
85
|
* owners: [
|
|
81
86
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
@@ -83,23 +88,23 @@ export type Tuple = readonly [
|
|
|
83
88
|
* })
|
|
84
89
|
* ```
|
|
85
90
|
*
|
|
86
|
-
* @param config - The
|
|
91
|
+
* @param config - The account config.
|
|
87
92
|
*/
|
|
88
93
|
export declare function assert<versionType extends bigint | number = bigint | number, numberType = number>(config: Input<versionType, numberType>): void;
|
|
89
94
|
export declare namespace assert {
|
|
90
95
|
type ErrorType = InvalidConfigError | Errors.GlobalErrorType;
|
|
91
96
|
}
|
|
92
97
|
/**
|
|
93
|
-
* Normalizes
|
|
98
|
+
* Normalizes an {@link ox#AccountConfig.Config}.
|
|
94
99
|
*
|
|
95
100
|
* Sorts owners into strictly ascending `owner` address order (the canonical
|
|
96
101
|
* form required for account derivation) and asserts the config is valid.
|
|
97
102
|
*
|
|
98
103
|
* @example
|
|
99
104
|
* ```ts twoslash
|
|
100
|
-
* import {
|
|
105
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
101
106
|
*
|
|
102
|
-
* const config =
|
|
107
|
+
* const config = AccountConfig.from({
|
|
103
108
|
* owners: [
|
|
104
109
|
* { owner: '0x2222222222222222222222222222222222222222', weight: 1 },
|
|
105
110
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
@@ -109,8 +114,8 @@ export declare namespace assert {
|
|
|
109
114
|
* // owners are now sorted ascending by address
|
|
110
115
|
* ```
|
|
111
116
|
*
|
|
112
|
-
* @param config - The
|
|
113
|
-
* @returns The normalized
|
|
117
|
+
* @param config - The account config.
|
|
118
|
+
* @returns The normalized account config.
|
|
114
119
|
*/
|
|
115
120
|
export declare function from<numberType = number>(config: Input<0 | 0n, numberType> & {
|
|
116
121
|
version?: 0 | 0n | undefined;
|
|
@@ -123,13 +128,13 @@ export declare function from<numberType = number>(config: Input<number, numberTy
|
|
|
123
128
|
}): Config<bigint, numberType>;
|
|
124
129
|
export declare function from<numberType = number>(config: Input<bigint | number, numberType>): Config<bigint, numberType>;
|
|
125
130
|
/**
|
|
126
|
-
* Converts a JSON-RPC
|
|
131
|
+
* Converts a JSON-RPC account configuration to its domain representation.
|
|
127
132
|
*
|
|
128
133
|
* @example
|
|
129
134
|
* ```ts twoslash
|
|
130
|
-
* import {
|
|
135
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
131
136
|
*
|
|
132
|
-
* const config =
|
|
137
|
+
* const config = AccountConfig.fromRpc({
|
|
133
138
|
* owners: [
|
|
134
139
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
135
140
|
* ],
|
|
@@ -139,22 +144,22 @@ export declare function from<numberType = number>(config: Input<bigint | number,
|
|
|
139
144
|
* })
|
|
140
145
|
* ```
|
|
141
146
|
*
|
|
142
|
-
* @param config - The JSON-RPC
|
|
143
|
-
* @returns The normalized
|
|
147
|
+
* @param config - The JSON-RPC account configuration.
|
|
148
|
+
* @returns The normalized account configuration.
|
|
144
149
|
*/
|
|
145
150
|
export declare function fromRpc(config: Rpc): Config;
|
|
146
151
|
export declare namespace fromRpc {
|
|
147
152
|
type ErrorType = assert.ErrorType | Hex.toBigInt.ErrorType | Errors.GlobalErrorType;
|
|
148
153
|
}
|
|
149
154
|
/**
|
|
150
|
-
* Converts an RLP {@link ox#
|
|
151
|
-
* {@link ox#
|
|
155
|
+
* Converts an RLP {@link ox#AccountConfig.Tuple} back to a
|
|
156
|
+
* {@link ox#AccountConfig.Config}.
|
|
152
157
|
*
|
|
153
158
|
* @example
|
|
154
159
|
* ```ts twoslash
|
|
155
|
-
* import {
|
|
160
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
156
161
|
*
|
|
157
|
-
* const config =
|
|
162
|
+
* const config = AccountConfig.fromTuple([
|
|
158
163
|
* `0x${'00'.repeat(32)}`,
|
|
159
164
|
* '0x',
|
|
160
165
|
* '0x01',
|
|
@@ -163,38 +168,81 @@ export declare namespace fromRpc {
|
|
|
163
168
|
* ```
|
|
164
169
|
*
|
|
165
170
|
* @param tuple - The RLP tuple.
|
|
166
|
-
* @returns The
|
|
171
|
+
* @returns The account config.
|
|
167
172
|
*/
|
|
168
173
|
export declare function fromTuple(tuple: Tuple): Config;
|
|
169
174
|
/**
|
|
170
|
-
* Derives the
|
|
175
|
+
* Derives the configuration an existing account installs when it migrates in
|
|
176
|
+
* place with the `upgradeAccount` precompile call
|
|
177
|
+
* ([TIP-1113](https://tips.sh/1113)).
|
|
178
|
+
*
|
|
179
|
+
* The account keeps its address. Its salt is
|
|
180
|
+
* `keccak256("tempo:configurable-account:upgrade" || account)` and its version
|
|
181
|
+
* is `1n`. Owners are sorted into canonical order and the config is validated.
|
|
182
|
+
* The account itself may be listed as an owner.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts twoslash
|
|
186
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
187
|
+
*
|
|
188
|
+
* const config = AccountConfig.fromUpgrade(
|
|
189
|
+
* '0x3333333333333333333333333333333333333333',
|
|
190
|
+
* {
|
|
191
|
+
* owners: [
|
|
192
|
+
* {
|
|
193
|
+
* owner: '0x1111111111111111111111111111111111111111',
|
|
194
|
+
* weight: 1
|
|
195
|
+
* }
|
|
196
|
+
* ],
|
|
197
|
+
* threshold: 1
|
|
198
|
+
* }
|
|
199
|
+
* )
|
|
200
|
+
* // config.version === 1n
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @param account - The account migrating in place.
|
|
204
|
+
* @param options - The owners and threshold to install.
|
|
205
|
+
* @returns The installed account config.
|
|
206
|
+
*/
|
|
207
|
+
export declare function fromUpgrade<numberType = number>(account: Address.Address, options: fromUpgrade.Options<numberType>): Config<1n, numberType>;
|
|
208
|
+
export declare namespace fromUpgrade {
|
|
209
|
+
type Options<numberType = number> = {
|
|
210
|
+
/** Weighted owners to install. Sorted into canonical order. */
|
|
211
|
+
owners: readonly Owner<numberType>[];
|
|
212
|
+
/** Minimum total owner weight required for authorization. */
|
|
213
|
+
threshold: numberType;
|
|
214
|
+
};
|
|
215
|
+
type ErrorType = Address.assert.ErrorType | assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Derives the stable configurable account address.
|
|
171
219
|
*
|
|
172
220
|
* The initial config is hashed into a CREATE2 salt using fixed-width
|
|
173
221
|
* big-endian fields, not RLP. The account uses the chain-configured recovery
|
|
174
|
-
* factory and
|
|
222
|
+
* factory and account proxy init-code hash.
|
|
175
223
|
*
|
|
176
224
|
* The address is derived once from the initial version-0 config. Config
|
|
177
225
|
* updates do not change it.
|
|
178
226
|
*
|
|
179
227
|
* @example
|
|
180
228
|
* ```ts twoslash
|
|
181
|
-
* import {
|
|
229
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
182
230
|
*
|
|
183
|
-
* const initialConfig =
|
|
231
|
+
* const initialConfig = AccountConfig.from({
|
|
184
232
|
* owners: [
|
|
185
233
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
186
234
|
* ],
|
|
187
235
|
* threshold: 1,
|
|
188
236
|
* })
|
|
189
237
|
*
|
|
190
|
-
* const address =
|
|
238
|
+
* const address = AccountConfig.getAddress(initialConfig, {
|
|
191
239
|
* factory: '0x7171717171717171717171717171717171717171'
|
|
192
240
|
* })
|
|
193
241
|
* ```
|
|
194
242
|
*
|
|
195
|
-
* @param config - The initial
|
|
243
|
+
* @param config - The initial account config.
|
|
196
244
|
* @param options - The recovery factory configured by the chain.
|
|
197
|
-
* @returns The
|
|
245
|
+
* @returns The configurable account address.
|
|
198
246
|
*/
|
|
199
247
|
export declare function getAddress(config: Input, options: getAddress.Options): Address.Address;
|
|
200
248
|
export declare namespace getAddress {
|
|
@@ -205,16 +253,16 @@ export declare namespace getAddress {
|
|
|
205
253
|
type ErrorType = assert.ErrorType | ContractAddress.fromCreate2.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType;
|
|
206
254
|
}
|
|
207
255
|
/**
|
|
208
|
-
* Computes the commitment for
|
|
256
|
+
* Computes the commitment for an account configuration.
|
|
209
257
|
*
|
|
210
258
|
* The commitment uses raw fixed-width fields, not RLP or ABI encoding:
|
|
211
|
-
* `keccak256("tempo:
|
|
259
|
+
* `keccak256("tempo:configurable-account:config" || salt || uint64be(version) || uint8(threshold) || uint8(owners.length) || owners)`.
|
|
212
260
|
*
|
|
213
261
|
* @example
|
|
214
262
|
* ```ts twoslash
|
|
215
|
-
* import {
|
|
263
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
216
264
|
*
|
|
217
|
-
* const commitment =
|
|
265
|
+
* const commitment = AccountConfig.getCommitment({
|
|
218
266
|
* owners: [
|
|
219
267
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
220
268
|
* ],
|
|
@@ -223,7 +271,7 @@ export declare namespace getAddress {
|
|
|
223
271
|
* })
|
|
224
272
|
* ```
|
|
225
273
|
*
|
|
226
|
-
* @param config - The complete
|
|
274
|
+
* @param config - The complete account configuration.
|
|
227
275
|
* @returns The configuration commitment.
|
|
228
276
|
*/
|
|
229
277
|
export declare function getCommitment(config: Input): Hex.Hex;
|
|
@@ -231,9 +279,9 @@ export declare namespace getCommitment {
|
|
|
231
279
|
type ErrorType = assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType;
|
|
232
280
|
}
|
|
233
281
|
/**
|
|
234
|
-
* Computes the digest a
|
|
282
|
+
* Computes the digest a configurable account owner approves (signs).
|
|
235
283
|
*
|
|
236
|
-
* `keccak256("tempo:
|
|
284
|
+
* `keccak256("tempo:configurable-account:signature" || inner_digest || account || uint64be(version))`,
|
|
237
285
|
* where `inner_digest` is the transaction sign payload
|
|
238
286
|
* ({@link ox#TxEnvelopeTempo.(getSignPayload:function)}).
|
|
239
287
|
*
|
|
@@ -243,9 +291,9 @@ export declare namespace getCommitment {
|
|
|
243
291
|
*
|
|
244
292
|
* @example
|
|
245
293
|
* ```ts twoslash
|
|
246
|
-
* import {
|
|
294
|
+
* import { AccountConfig, TxEnvelopeTempo } from 'ox/tempo'
|
|
247
295
|
*
|
|
248
|
-
* const config =
|
|
296
|
+
* const config = AccountConfig.from({
|
|
249
297
|
* owners: [
|
|
250
298
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
251
299
|
* ],
|
|
@@ -257,8 +305,8 @@ export declare namespace getCommitment {
|
|
|
257
305
|
* calls: [],
|
|
258
306
|
* })
|
|
259
307
|
*
|
|
260
|
-
* const digest =
|
|
261
|
-
* account:
|
|
308
|
+
* const digest = AccountConfig.getSignPayload({
|
|
309
|
+
* account: AccountConfig.getAddress(config, {
|
|
262
310
|
* factory: '0x7171717171717171717171717171717171717171'
|
|
263
311
|
* }),
|
|
264
312
|
* config,
|
|
@@ -272,7 +320,7 @@ export declare namespace getCommitment {
|
|
|
272
320
|
export declare function getSignPayload(value: getSignPayload.Value): Hex.Hex;
|
|
273
321
|
export declare namespace getSignPayload {
|
|
274
322
|
type Value = {
|
|
275
|
-
/** The
|
|
323
|
+
/** The configurable account address. */
|
|
276
324
|
account: Address.Address;
|
|
277
325
|
/** Configuration whose version applies to the approval. */
|
|
278
326
|
config: Pick<Config<bigint | number>, 'version'>;
|
|
@@ -282,13 +330,13 @@ export declare namespace getSignPayload {
|
|
|
282
330
|
type ErrorType = assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.from.ErrorType | Hex.fromNumber.ErrorType | Errors.GlobalErrorType;
|
|
283
331
|
}
|
|
284
332
|
/**
|
|
285
|
-
* Converts
|
|
333
|
+
* Converts an account configuration to its JSON-RPC representation.
|
|
286
334
|
*
|
|
287
335
|
* @example
|
|
288
336
|
* ```ts twoslash
|
|
289
|
-
* import {
|
|
337
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
290
338
|
*
|
|
291
|
-
* const config =
|
|
339
|
+
* const config = AccountConfig.toRpc({
|
|
292
340
|
* owners: [
|
|
293
341
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
294
342
|
* ],
|
|
@@ -296,15 +344,15 @@ export declare namespace getSignPayload {
|
|
|
296
344
|
* })
|
|
297
345
|
* ```
|
|
298
346
|
*
|
|
299
|
-
* @param config - The
|
|
300
|
-
* @returns The JSON-RPC
|
|
347
|
+
* @param config - The account configuration.
|
|
348
|
+
* @returns The JSON-RPC account configuration.
|
|
301
349
|
*/
|
|
302
350
|
export declare function toRpc(config: Input): Rpc;
|
|
303
351
|
export declare namespace toRpc {
|
|
304
352
|
type ErrorType = assert.ErrorType | Hex.fromNumber.ErrorType | Errors.GlobalErrorType;
|
|
305
353
|
}
|
|
306
354
|
/**
|
|
307
|
-
* Converts a {@link ox#
|
|
355
|
+
* Converts a {@link ox#AccountConfig.Config} to its RLP tuple form.
|
|
308
356
|
*
|
|
309
357
|
* Tuple shape: `[salt, version, threshold, [[owner, weight], ...]]`. The
|
|
310
358
|
* 32-byte `salt` encodes as a full fixed-width string; other integers use
|
|
@@ -312,9 +360,9 @@ export declare namespace toRpc {
|
|
|
312
360
|
*
|
|
313
361
|
* @example
|
|
314
362
|
* ```ts twoslash
|
|
315
|
-
* import {
|
|
363
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
316
364
|
*
|
|
317
|
-
* const tuple =
|
|
365
|
+
* const tuple = AccountConfig.toTuple({
|
|
318
366
|
* owners: [
|
|
319
367
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
320
368
|
* ],
|
|
@@ -322,19 +370,61 @@ export declare namespace toRpc {
|
|
|
322
370
|
* })
|
|
323
371
|
* ```
|
|
324
372
|
*
|
|
325
|
-
* @param config - The
|
|
373
|
+
* @param config - The account config.
|
|
326
374
|
* @returns The RLP tuple.
|
|
327
375
|
*/
|
|
328
376
|
export declare function toTuple(config: Input): Tuple;
|
|
329
377
|
/**
|
|
330
|
-
*
|
|
378
|
+
* Derives the configuration that replaces the current one in an owner update.
|
|
379
|
+
*
|
|
380
|
+
* Mirrors the `updateConfig` precompile ([TIP-1109](https://tips.sh/1109)):
|
|
381
|
+
* keeps the current salt, increments the version by one, and replaces the
|
|
382
|
+
* owners and threshold. Owners are sorted into canonical order and the next
|
|
383
|
+
* configuration is validated. The account address does not change.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```ts twoslash
|
|
387
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
388
|
+
*
|
|
389
|
+
* const initialConfig = AccountConfig.from({
|
|
390
|
+
* owners: [
|
|
391
|
+
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
392
|
+
* ],
|
|
393
|
+
* threshold: 1,
|
|
394
|
+
* })
|
|
395
|
+
*
|
|
396
|
+
* const config = AccountConfig.update(initialConfig, {
|
|
397
|
+
* owners: [
|
|
398
|
+
* { owner: '0x2222222222222222222222222222222222222222', weight: 1 },
|
|
399
|
+
* ],
|
|
400
|
+
* threshold: 1,
|
|
401
|
+
* })
|
|
402
|
+
* // config.version === 1n, with the initial salt
|
|
403
|
+
* ```
|
|
404
|
+
*
|
|
405
|
+
* @param config - The current account config.
|
|
406
|
+
* @param options - The replacement owners and threshold.
|
|
407
|
+
* @returns The next account config.
|
|
408
|
+
*/
|
|
409
|
+
export declare function update<numberType = number>(config: Input<bigint | number, numberType>, options: update.Options<numberType>): Config<bigint, numberType>;
|
|
410
|
+
export declare namespace update {
|
|
411
|
+
type Options<numberType = number> = {
|
|
412
|
+
/** Replacement weighted owners. Sorted into canonical order. */
|
|
413
|
+
owners: readonly Owner<numberType>[];
|
|
414
|
+
/** Replacement minimum total owner weight required for authorization. */
|
|
415
|
+
threshold: numberType;
|
|
416
|
+
};
|
|
417
|
+
type ErrorType = assert.ErrorType | InvalidConfigError | Errors.GlobalErrorType;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Validates an {@link ox#AccountConfig.Config}. Returns `true`
|
|
331
421
|
* if valid, `false` otherwise.
|
|
332
422
|
*
|
|
333
423
|
* @example
|
|
334
424
|
* ```ts twoslash
|
|
335
|
-
* import {
|
|
425
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
336
426
|
*
|
|
337
|
-
* const valid =
|
|
427
|
+
* const valid = AccountConfig.validate({
|
|
338
428
|
* owners: [
|
|
339
429
|
* { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
|
|
340
430
|
* ],
|
|
@@ -343,15 +433,15 @@ export declare function toTuple(config: Input): Tuple;
|
|
|
343
433
|
* // @log: true
|
|
344
434
|
* ```
|
|
345
435
|
*
|
|
346
|
-
* @param config - The
|
|
436
|
+
* @param config - The account config.
|
|
347
437
|
* @returns Whether the config is valid.
|
|
348
438
|
*/
|
|
349
439
|
export declare function validate(config: Input): boolean;
|
|
350
|
-
/** Thrown when
|
|
440
|
+
/** Thrown when an account config is invalid. */
|
|
351
441
|
export declare class InvalidConfigError extends Errors.BaseError {
|
|
352
|
-
readonly name = "
|
|
442
|
+
readonly name = "AccountConfig.InvalidConfigError";
|
|
353
443
|
constructor({ reason }: {
|
|
354
444
|
reason: string;
|
|
355
445
|
});
|
|
356
446
|
}
|
|
357
|
-
//# sourceMappingURL=
|
|
447
|
+
//# sourceMappingURL=AccountConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountConfig.d.ts","sourceRoot":"","sources":["../../tempo/AccountConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,KAAK,KAAK,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,eAAe,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;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