@silvana-one/upgradable 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ export * from "./validators.js";
2
+ export * from "./upgrade.js";
3
+ export * from "./upgradable.js";
@@ -0,0 +1,4 @@
1
+ export * from "./validators.js";
2
+ export * from "./upgrade.js";
3
+ export * from "./upgradable.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,294 @@
1
+ import { Bool, PublicKey, SmartContract, VerificationKey, Field, Option } from "o1js";
2
+ export { UpgradeAuthorityBase, VerificationKeyUpgradeData, UpgradeAuthorityContractConstructor, UpgradableContract, PublicKeyOption, UpgradeAuthorityAnswer, };
3
+ declare const VerificationKeyUpgradeData_base: (new (value: {
4
+ address: PublicKey;
5
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
6
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
7
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
8
+ }) => {
9
+ address: PublicKey;
10
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
11
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
12
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
13
+ }) & {
14
+ _isStruct: true;
15
+ } & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
16
+ address: PublicKey;
17
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
18
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
19
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
20
+ }, {
21
+ address: {
22
+ x: bigint;
23
+ isOdd: boolean;
24
+ };
25
+ tokenId: bigint;
26
+ previousVerificationKeyHash: bigint;
27
+ newVerificationKeyHash: bigint;
28
+ }>, "fromFields"> & {
29
+ fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
30
+ address: PublicKey;
31
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
32
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
33
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
34
+ };
35
+ } & {
36
+ fromValue: (value: {
37
+ address: PublicKey | {
38
+ x: Field | bigint;
39
+ isOdd: Bool | boolean;
40
+ };
41
+ tokenId: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
42
+ previousVerificationKeyHash: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
43
+ newVerificationKeyHash: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
44
+ }) => {
45
+ address: PublicKey;
46
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
47
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
48
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
49
+ };
50
+ toInput: (x: {
51
+ address: PublicKey;
52
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
53
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
54
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
55
+ }) => {
56
+ fields?: Field[] | undefined;
57
+ packed?: [Field, number][] | undefined;
58
+ };
59
+ toJSON: (x: {
60
+ address: PublicKey;
61
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
62
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
63
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
64
+ }) => {
65
+ address: string;
66
+ tokenId: string;
67
+ previousVerificationKeyHash: string;
68
+ newVerificationKeyHash: string;
69
+ };
70
+ fromJSON: (x: {
71
+ address: string;
72
+ tokenId: string;
73
+ previousVerificationKeyHash: string;
74
+ newVerificationKeyHash: string;
75
+ }) => {
76
+ address: PublicKey;
77
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
78
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
79
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
80
+ };
81
+ empty: () => {
82
+ address: PublicKey;
83
+ tokenId: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
84
+ previousVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
85
+ newVerificationKeyHash: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
86
+ };
87
+ };
88
+ /**
89
+ * Represents the data required to upgrade a contract's verification key.
90
+ * It includes the contract's address, token ID, previous verification key hash,
91
+ * and the new verification key hash. This class also provides a `hash()` method
92
+ * to generate a unique identifier for the upgrade data.
93
+ */
94
+ declare class VerificationKeyUpgradeData extends VerificationKeyUpgradeData_base {
95
+ /**
96
+ * Generates a unique hash for the upgrade data using the Poseidon hash function.
97
+ * @returns {Field} The hash representing the upgrade data.
98
+ */
99
+ hash(): Field;
100
+ }
101
+ declare const PublicKeyOption_base: Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<Option<PublicKey, {
102
+ x: bigint;
103
+ isOdd: boolean;
104
+ }>, {
105
+ x: bigint;
106
+ isOdd: boolean;
107
+ } | undefined>, "fromFields"> & {
108
+ fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => Option<PublicKey, {
109
+ x: bigint;
110
+ isOdd: boolean;
111
+ }>;
112
+ } & (new (option: {
113
+ isSome: Bool;
114
+ value: PublicKey;
115
+ }) => Option<PublicKey, {
116
+ x: bigint;
117
+ isOdd: boolean;
118
+ }>) & {
119
+ fromValue(value: PublicKey | {
120
+ x: bigint;
121
+ isOdd: boolean;
122
+ } | {
123
+ isSome: boolean | Bool;
124
+ value: PublicKey | {
125
+ x: bigint;
126
+ isOdd: boolean;
127
+ };
128
+ } | undefined): Option<PublicKey, {
129
+ x: bigint;
130
+ isOdd: boolean;
131
+ }>;
132
+ from(value?: PublicKey | {
133
+ x: bigint;
134
+ isOdd: boolean;
135
+ } | undefined): Option<PublicKey, {
136
+ x: bigint;
137
+ isOdd: boolean;
138
+ }>;
139
+ none(): Option<PublicKey, {
140
+ x: bigint;
141
+ isOdd: boolean;
142
+ }>;
143
+ };
144
+ /**
145
+ * An optional `PublicKey` type, used to specify the next upgrade authority if needed.
146
+ * This is crucial when the current upgrade authority cannot be used in future upgrades
147
+ * due to changes in the o1js version or other factors.
148
+ */
149
+ declare class PublicKeyOption extends PublicKeyOption_base {
150
+ }
151
+ declare const UpgradeAuthorityAnswer_base: (new (value: {
152
+ nextUpgradeAuthority: PublicKeyOption;
153
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
154
+ }) => {
155
+ nextUpgradeAuthority: PublicKeyOption;
156
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
157
+ }) & {
158
+ _isStruct: true;
159
+ } & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
160
+ nextUpgradeAuthority: PublicKeyOption;
161
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
162
+ }, {
163
+ nextUpgradeAuthority: {
164
+ x: bigint;
165
+ isOdd: boolean;
166
+ } | undefined;
167
+ isVerified: boolean;
168
+ }>, "fromFields"> & {
169
+ fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
170
+ nextUpgradeAuthority: PublicKeyOption;
171
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
172
+ };
173
+ } & {
174
+ fromValue: (value: {
175
+ nextUpgradeAuthority: PublicKey | {
176
+ x: bigint;
177
+ isOdd: boolean;
178
+ } | PublicKeyOption | {
179
+ isSome: boolean | Bool;
180
+ value: PublicKey | {
181
+ x: bigint;
182
+ isOdd: boolean;
183
+ };
184
+ } | undefined;
185
+ isVerified: boolean | import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
186
+ }) => {
187
+ nextUpgradeAuthority: PublicKeyOption;
188
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
189
+ };
190
+ toInput: (x: {
191
+ nextUpgradeAuthority: PublicKeyOption;
192
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
193
+ }) => {
194
+ fields?: Field[] | undefined;
195
+ packed?: [Field, number][] | undefined;
196
+ };
197
+ toJSON: (x: {
198
+ nextUpgradeAuthority: PublicKeyOption;
199
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
200
+ }) => {
201
+ nextUpgradeAuthority: {
202
+ prototype: {
203
+ isSome: boolean;
204
+ value: any;
205
+ assertSome: {};
206
+ assertNone: {};
207
+ orElse: {};
208
+ };
209
+ toFields: {};
210
+ toAuxiliary: {};
211
+ sizeInFields: {};
212
+ check: {};
213
+ toValue: {};
214
+ fromValue: {};
215
+ toCanonical?: {} | null | undefined;
216
+ fromFields: {};
217
+ from: {};
218
+ none: {};
219
+ };
220
+ isVerified: boolean;
221
+ };
222
+ fromJSON: (x: {
223
+ nextUpgradeAuthority: {
224
+ prototype: {
225
+ isSome: boolean;
226
+ value: any;
227
+ assertSome: {};
228
+ assertNone: {};
229
+ orElse: {};
230
+ };
231
+ toFields: {};
232
+ toAuxiliary: {};
233
+ sizeInFields: {};
234
+ check: {};
235
+ toValue: {};
236
+ fromValue: {};
237
+ toCanonical?: {} | null | undefined;
238
+ fromFields: {};
239
+ from: {};
240
+ none: {};
241
+ };
242
+ isVerified: boolean;
243
+ }) => {
244
+ nextUpgradeAuthority: PublicKeyOption;
245
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
246
+ };
247
+ empty: () => {
248
+ nextUpgradeAuthority: PublicKeyOption;
249
+ isVerified: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
250
+ };
251
+ };
252
+ /**
253
+ * Represents the response from the upgrade authority after verifying the upgrade data.
254
+ * It contains the next upgrade authority's public key if a change is required, and a boolean
255
+ * indicating whether the upgrade data has been successfully verified.
256
+ */
257
+ declare class UpgradeAuthorityAnswer extends UpgradeAuthorityAnswer_base {
258
+ }
259
+ /**
260
+ * Interface that any upgrade authority contract should implement.
261
+ * Extends `SmartContract` and requires the implementation of the `verifyUpgradeData()` method,
262
+ * which takes `VerificationKeyUpgradeData` as input and returns an `UpgradeAuthorityAnswer`.
263
+ */
264
+ type UpgradeAuthorityBase = SmartContract & {
265
+ /**
266
+ * Verifies the upgrade data for upgrading a contract's verification key.
267
+ * @param {VerificationKeyUpgradeData} data - The data required for verification.
268
+ * @returns {Promise<UpgradeAuthorityAnswer>} The result of the verification.
269
+ */
270
+ verifyUpgradeData(data: VerificationKeyUpgradeData): Promise<UpgradeAuthorityAnswer>;
271
+ };
272
+ /**
273
+ * Interface for contracts that can be upgraded.
274
+ * Extends `SmartContract` and requires methods to retrieve the associated upgrade authority contract
275
+ * and to upgrade the contract's verification key using the provided verification key.
276
+ */
277
+ type UpgradableContract = SmartContract & {
278
+ /**
279
+ * Retrieves the associated upgrade authority contract.
280
+ * @returns {Promise<UpgradeAuthorityBase>} The upgrade authority contract.
281
+ */
282
+ getUpgradeContract(): Promise<UpgradeAuthorityBase>;
283
+ /**
284
+ * Upgrades the contract's verification key using the provided verification key.
285
+ * @param {VerificationKey} vk - The new verification key.
286
+ * @returns {Promise<void>}
287
+ */
288
+ upgradeVerificationKey(vk: VerificationKey): Promise<void>;
289
+ };
290
+ /**
291
+ * Defines a constructor for contracts implementing `UpgradeAuthorityBase`,
292
+ * accepting an `upgradeAuthority` public key and returning an instance of `UpgradeAuthorityBase`.
293
+ */
294
+ type UpgradeAuthorityContractConstructor = new (upgradeAuthority: PublicKey) => UpgradeAuthorityBase;
@@ -0,0 +1,54 @@
1
+ import { Bool, PublicKey, Field, Struct, Poseidon, Option, } from "o1js";
2
+ export { VerificationKeyUpgradeData, PublicKeyOption, UpgradeAuthorityAnswer, };
3
+ /**
4
+ * Represents the data required to upgrade a contract's verification key.
5
+ * It includes the contract's address, token ID, previous verification key hash,
6
+ * and the new verification key hash. This class also provides a `hash()` method
7
+ * to generate a unique identifier for the upgrade data.
8
+ */
9
+ class VerificationKeyUpgradeData extends Struct({
10
+ /** The address of the contract to be upgraded. */
11
+ address: PublicKey,
12
+ /** The token ID associated with the contract. */
13
+ tokenId: Field,
14
+ /** The hash of the previous verification key. */
15
+ previousVerificationKeyHash: Field,
16
+ /** The hash of the new verification key. */
17
+ newVerificationKeyHash: Field,
18
+ }) {
19
+ /**
20
+ * Generates a unique hash for the upgrade data using the Poseidon hash function.
21
+ * @returns {Field} The hash representing the upgrade data.
22
+ */
23
+ hash() {
24
+ return Poseidon.hash(VerificationKeyUpgradeData.toFields(this));
25
+ }
26
+ }
27
+ /**
28
+ * An optional `PublicKey` type, used to specify the next upgrade authority if needed.
29
+ * This is crucial when the current upgrade authority cannot be used in future upgrades
30
+ * due to changes in the o1js version or other factors.
31
+ */
32
+ class PublicKeyOption extends Option(PublicKey) {
33
+ }
34
+ /**
35
+ * Represents the response from the upgrade authority after verifying the upgrade data.
36
+ * It contains the next upgrade authority's public key if a change is required, and a boolean
37
+ * indicating whether the upgrade data has been successfully verified.
38
+ */
39
+ class UpgradeAuthorityAnswer extends Struct({
40
+ /**
41
+ * The public key of the next upgrade authority, if a change is required.
42
+ *
43
+ * If we upgrade the verification key, we may not be able to use the same upgrade
44
+ * authority next time because the new o1js version can break the verification key
45
+ * of the upgrade authority too, and since the upgrade authority serves many
46
+ * contracts, it cannot be upgraded. In this case, we need to use another upgrade
47
+ * authority with the public key that will be provided in `nextUpgradeAuthority`.
48
+ */
49
+ nextUpgradeAuthority: PublicKeyOption,
50
+ /** Indicates whether the upgrade data has been successfully verified. */
51
+ isVerified: Bool,
52
+ }) {
53
+ }
54
+ //# sourceMappingURL=upgradable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgradable.js","sourceRoot":"","sources":["../../src/upgradable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,SAAS,EAGT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,GACP,MAAM,MAAM,CAAC;AAEd,OAAO,EAEL,0BAA0B,EAG1B,eAAe,EACf,sBAAsB,GACvB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,0BAA2B,SAAQ,MAAM,CAAC;IAC9C,kDAAkD;IAClD,OAAO,EAAE,SAAS;IAClB,iDAAiD;IACjD,OAAO,EAAE,KAAK;IACd,iDAAiD;IACjD,2BAA2B,EAAE,KAAK;IAClC,4CAA4C;IAC5C,sBAAsB,EAAE,KAAK;CAC9B,CAAC;IACA;;;OAGG;IACH,IAAI;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,eAAgB,SAAQ,MAAM,CAAC,SAAS,CAAC;CAAG;AAElD;;;;GAIG;AACH,MAAM,sBAAuB,SAAQ,MAAM,CAAC;IAC1C;;;;;;;;OAQG;IACH,oBAAoB,EAAE,eAAe;IACrC,yEAAyE;IACzE,UAAU,EAAE,IAAI;CACjB,CAAC;CAAG"}
@@ -0,0 +1,186 @@
1
+ import { SmartContract, State, VerificationKey, Field, UInt32 } from "o1js";
2
+ import { IndexedMapSerialized, Storage } from "@silvana-one/storage";
3
+ import { UpgradeAuthorityBase, VerificationKeyUpgradeData, UpgradeAuthorityAnswer } from "./upgradable.js";
4
+ import { UpgradeAuthorityDatabase, ValidatorsState, UpgradeDatabaseState, ValidatorsVotingProof, UpgradeDatabaseStatePacked } from "./validators.js";
5
+ export { VerificationKeyUpgradeAuthority, UpgradeAuthorityDatabase, ValidatorsListEvent, ValidatorsListData, };
6
+ /**
7
+ * Interface representing the data for a list of validators.
8
+ */
9
+ interface ValidatorsListData {
10
+ validators: {
11
+ publicKey: string;
12
+ authorizedToVote: boolean;
13
+ }[];
14
+ validatorsCount: number;
15
+ root: string;
16
+ map: IndexedMapSerialized;
17
+ }
18
+ declare const ValidatorsListEvent_base: (new (value: {
19
+ validators: ValidatorsState;
20
+ storage: Storage;
21
+ }) => {
22
+ validators: ValidatorsState;
23
+ storage: Storage;
24
+ }) & {
25
+ _isStruct: true;
26
+ } & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
27
+ validators: ValidatorsState;
28
+ storage: Storage;
29
+ }, {
30
+ validators: {
31
+ chainId: bigint;
32
+ root: bigint;
33
+ count: bigint;
34
+ };
35
+ storage: {
36
+ url: bigint[];
37
+ };
38
+ }>, "fromFields"> & {
39
+ fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
40
+ validators: ValidatorsState;
41
+ storage: Storage;
42
+ };
43
+ } & {
44
+ fromValue: (value: {
45
+ validators: ValidatorsState | {
46
+ chainId: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
47
+ root: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
48
+ count: bigint | UInt32;
49
+ };
50
+ storage: Storage | {
51
+ url: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[] | bigint[];
52
+ };
53
+ }) => {
54
+ validators: ValidatorsState;
55
+ storage: Storage;
56
+ };
57
+ toInput: (x: {
58
+ validators: ValidatorsState;
59
+ storage: Storage;
60
+ }) => {
61
+ fields?: Field[] | undefined;
62
+ packed?: [Field, number][] | undefined;
63
+ };
64
+ toJSON: (x: {
65
+ validators: ValidatorsState;
66
+ storage: Storage;
67
+ }) => {
68
+ validators: {
69
+ chainId: string;
70
+ root: string;
71
+ count: string;
72
+ };
73
+ storage: {
74
+ url: string[];
75
+ };
76
+ };
77
+ fromJSON: (x: {
78
+ validators: {
79
+ chainId: string;
80
+ root: string;
81
+ count: string;
82
+ };
83
+ storage: {
84
+ url: string[];
85
+ };
86
+ }) => {
87
+ validators: ValidatorsState;
88
+ storage: Storage;
89
+ };
90
+ empty: () => {
91
+ validators: ValidatorsState;
92
+ storage: Storage;
93
+ };
94
+ };
95
+ /**
96
+ * Event emitted when the validators list is updated.
97
+ */
98
+ declare class ValidatorsListEvent extends ValidatorsListEvent_base {
99
+ }
100
+ /**
101
+ * **VerificationKeyUpgradeAuthority** is a smart contract that provides a secure mechanism
102
+ * for upgrading the verification keys of other contracts without requiring redeployment.
103
+ * It manages a list of validators who can vote on upgrade proposals, ensuring that only
104
+ * authorized upgrades are applied.
105
+ *
106
+ * **Key Features:**
107
+ * - **Verification Key Management**: Allows for secure upgrades of verification keys for other contracts.
108
+ * - **Validators Governance**: Maintains a list of authorized validators who can vote on upgrade proposals.
109
+ * - **Secure Voting Mechanism**: Implements Zero-Knowledge proofs to validate votes from validators without revealing sensitive information.
110
+ * - **Upgrade Database Management**: Keeps track of upgrade proposals and their validity periods.
111
+ * - **Event Emissions**: Emits events when validators list or upgrade database is updated.
112
+ */
113
+ declare class VerificationKeyUpgradeAuthority extends SmartContract implements UpgradeAuthorityBase {
114
+ /**
115
+ * The hash of the verification key.
116
+ * @type {State<Field>}
117
+ */
118
+ verificationKeyHash: State<import("node_modules/o1js/dist/node/lib/provable/field.js").Field>;
119
+ /**
120
+ * The hash representing the current state of the validators list.
121
+ * @type {State<Field>}
122
+ */
123
+ validators: State<import("node_modules/o1js/dist/node/lib/provable/field.js").Field>;
124
+ /**
125
+ * Packed state containing the upgrade database information.
126
+ * @type {State<UpgradeDatabaseStatePacked>}
127
+ */
128
+ upgradeDatabasePacked: State<UpgradeDatabaseStatePacked>;
129
+ /**
130
+ * The events emitted by the VerificationKeyUpgradeAuthority contract.
131
+ */
132
+ events: {
133
+ validatorsList: typeof ValidatorsListEvent;
134
+ updateDatabase: typeof UpgradeDatabaseState;
135
+ };
136
+ /**
137
+ * Deploys the contract and sets the initial state.
138
+ */
139
+ deploy(): Promise<void>;
140
+ /**
141
+ * Initializes the contract with validators and sets the verification key hash.
142
+ *
143
+ * @param {ValidatorsState} validators - The initial validators state.
144
+ * @param {Storage} storage - Off-chain storage information, e.g., IPFS hash.
145
+ * @param {Field} verificationKeyHash - The hash of the verification key.
146
+ */
147
+ initialize(validators: ValidatorsState, storage: Storage, verificationKeyHash: Field): Promise<void>;
148
+ /**
149
+ * Sets the validators list and emits an event.
150
+ *
151
+ * @param {ValidatorsState} validators - The validators state to set.
152
+ * @param {Storage} storage - The storage associated with the validators list.
153
+ */
154
+ setValidatorsList(validators: ValidatorsState, storage: Storage): Promise<void>;
155
+ /**
156
+ * Verifies the upgrade data provided by another contract.
157
+ *
158
+ * @param {VerificationKeyUpgradeData} data - The upgrade data to verify.
159
+ * @returns {Promise<UpgradeAuthorityAnswer>} - The answer indicating verification result.
160
+ */
161
+ verifyUpgradeData(data: VerificationKeyUpgradeData): Promise<UpgradeAuthorityAnswer>;
162
+ /**
163
+ * Updates the upgrade database after validator consensus.
164
+ *
165
+ * @param {ValidatorsVotingProof} proof - The proof of validators voting.
166
+ * @param {VerificationKey} vk - The verification key to validate the proof.
167
+ */
168
+ updateDatabase(proof: ValidatorsVotingProof, vk: VerificationKey, validators: ValidatorsState): Promise<void>;
169
+ /**
170
+ * Updates the validators list based on validator votes.
171
+ *
172
+ * @param {ValidatorsState} validators - The new validators state.
173
+ * @param {Storage} storage - The storage associated with the validators list.
174
+ * @param {ValidatorsVotingProof} proof - The proof of validators voting.
175
+ * @param {VerificationKey} vk - The verification key to validate the proof.
176
+ */
177
+ updateValidatorsList(validators: ValidatorsState, storage: Storage, proof: ValidatorsVotingProof, vk: VerificationKey): Promise<void>;
178
+ /**
179
+ * Checks the validators' decision by verifying the provided proof.
180
+ *
181
+ * @param {ValidatorsVotingProof} proof - The proof to verify.
182
+ * @param {VerificationKey} vk - The verification key to validate the proof.
183
+ * @param {Field} decisionType - The type of decision being validated.
184
+ */
185
+ checkValidatorsDecision(proof: ValidatorsVotingProof, vk: VerificationKey, decisionType: Field, validatorsState: ValidatorsState): Promise<void>;
186
+ }