@ocap/state 1.31.1 → 1.31.2
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/esm/states/account.d.mts +7 -2
- package/esm/states/account.mjs +29 -4
- package/esm/states/chain.d.mts +9 -1
- package/esm/states/chain.mjs +6 -3
- package/esm/states/rollup-bridge.d.mts +78 -0
- package/esm/states/rollup-bridge.mjs +165 -0
- package/esm/states/rollup-v2.d.mts +188 -0
- package/esm/states/rollup-v2.mjs +597 -0
- package/esm/states/rollup.d.mts +4 -2
- package/esm/states/rollup.mjs +52 -2
- package/esm/states/token-factory.mjs +2 -1
- package/esm/states/tx.mjs +30 -1
- package/lib/states/account.cjs +27 -1
- package/lib/states/account.d.cts +7 -2
- package/lib/states/chain.cjs +6 -3
- package/lib/states/chain.d.cts +9 -1
- package/lib/states/rollup-bridge.cjs +170 -0
- package/lib/states/rollup-bridge.d.cts +78 -0
- package/lib/states/rollup-v2.cjs +637 -0
- package/lib/states/rollup-v2.d.cts +188 -0
- package/lib/states/rollup.cjs +96 -2
- package/lib/states/rollup.d.cts +4 -2
- package/lib/states/token-factory.cjs +2 -1
- package/lib/states/tx.cjs +30 -1
- package/package.json +9 -9
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
import { isEthereumDid, isFromPublicKey } from "@arcblock/did";
|
|
2
|
+
import { toChecksumAddress } from "@arcblock/did/lib/type";
|
|
3
|
+
import { CustomError } from "@ocap/util/lib/error";
|
|
4
|
+
|
|
5
|
+
//#region src/states/rollup-v2.ts
|
|
6
|
+
/**
|
|
7
|
+
* v2 bridge body (bridge/docs/ocap-protocols.md §v2.1-v2.3).
|
|
8
|
+
*
|
|
9
|
+
* A v2 bridge is a `RollupState` whose extension field `data` (`google.protobuf.Any`) carries a typed, versioned object
|
|
10
|
+
* `data.value = { version: 2, ... }`. This module owns that object: its schema, the epoch / pause / owner arithmetic,
|
|
11
|
+
* the typed `update_rollup` patch and the structural transition rules the state layer enforces on every update.
|
|
12
|
+
*
|
|
13
|
+
* Everything here is pure and deterministic: time always comes from the caller (`txSec`, the node-assigned tx time in
|
|
14
|
+
* seconds), never from a local clock.
|
|
15
|
+
*/
|
|
16
|
+
const BRIDGE_MIN_EPOCH_LEAD = 3600;
|
|
17
|
+
const BRIDGE_MAX_EPOCH_LEAD = 2 * 86400;
|
|
18
|
+
const BRIDGE_OWNER_TIMELOCK = 14 * 86400;
|
|
19
|
+
const BRIDGE_LONE_PAUSE_TTL = 24 * 3600;
|
|
20
|
+
const BRIDGE_LONE_PAUSE_COOLDOWN = 7 * 86400;
|
|
21
|
+
const BRIDGE_RESERVE_MIGRATION_WINDOW = 30 * 86400;
|
|
22
|
+
const BRIDGE_MAX_PAUSERS = 3;
|
|
23
|
+
const BRIDGE_MIN_VALIDATORS = 3;
|
|
24
|
+
const BRIDGE_MAX_VALIDATORS = 16;
|
|
25
|
+
const BRIDGE_MAX_DELAY = 90 * 86400;
|
|
26
|
+
const BRIDGE_VERSION = 2;
|
|
27
|
+
/** Keys a creator may put in `itx.data.value` of a v2 `create_rollup`. Everything else is derived by the chain. */
|
|
28
|
+
const BRIDGE_CREATE_KEYS = [
|
|
29
|
+
"version",
|
|
30
|
+
"ethChainId",
|
|
31
|
+
"gateway",
|
|
32
|
+
"minDeposit",
|
|
33
|
+
"minWithdraw",
|
|
34
|
+
"maxWithdraw",
|
|
35
|
+
"withdrawFee",
|
|
36
|
+
"releaseDailyCap",
|
|
37
|
+
"refundDailyCap",
|
|
38
|
+
"releaseGrace",
|
|
39
|
+
"refundDelay",
|
|
40
|
+
"transitionPeriod",
|
|
41
|
+
"epochs",
|
|
42
|
+
"salt",
|
|
43
|
+
"pausers",
|
|
44
|
+
"ethOwnerAttestation",
|
|
45
|
+
"consents",
|
|
46
|
+
"initialReserve"
|
|
47
|
+
];
|
|
48
|
+
/** Keys `update_rollup` may patch. `proposeOwner` / `cancelOwnerProposal` / `cancelPendingEpoch` are actions. */
|
|
49
|
+
const BRIDGE_PATCH_VALUE_KEYS = [
|
|
50
|
+
"minDeposit",
|
|
51
|
+
"minWithdraw",
|
|
52
|
+
"maxWithdraw",
|
|
53
|
+
"releaseDailyCap",
|
|
54
|
+
"refundDailyCap",
|
|
55
|
+
"releaseGrace",
|
|
56
|
+
"refundDelay",
|
|
57
|
+
"pausers"
|
|
58
|
+
];
|
|
59
|
+
const BRIDGE_PATCH_ACTION_KEYS = [
|
|
60
|
+
"cancelPendingEpoch",
|
|
61
|
+
"proposeOwner",
|
|
62
|
+
"cancelOwnerProposal"
|
|
63
|
+
];
|
|
64
|
+
const bad = (message) => {
|
|
65
|
+
throw new CustomError("INVALID_ROLLUP_PROPS", message);
|
|
66
|
+
};
|
|
67
|
+
const badUpdate = (message) => {
|
|
68
|
+
throw new CustomError("INVALID_ROLLUP_UPDATE", message);
|
|
69
|
+
};
|
|
70
|
+
/** Whether a rollup `data` field (`{ type, value }`) is a v2 body. */
|
|
71
|
+
function isBridgeV2Data(data) {
|
|
72
|
+
const value = data?.value;
|
|
73
|
+
return !!value && typeof value === "object" && value.version === BRIDGE_VERSION;
|
|
74
|
+
}
|
|
75
|
+
/** Whether the rollup row is a v2 bridge. Rows without `data.value.version == 2` are v1 and keep today's behaviour. */
|
|
76
|
+
function isBridgeV2(state) {
|
|
77
|
+
return isBridgeV2Data(state?.data);
|
|
78
|
+
}
|
|
79
|
+
function getBridgeBody(state) {
|
|
80
|
+
return isBridgeV2(state) ? state.data.value : null;
|
|
81
|
+
}
|
|
82
|
+
const toSeconds = (iso) => {
|
|
83
|
+
const ms = iso === void 0 || iso === null || iso === "" ? NaN : new Date(iso).getTime();
|
|
84
|
+
if (!Number.isFinite(ms)) throw new CustomError("INVALID_TX_TIME", "tx time is not a valid time");
|
|
85
|
+
return Math.floor(ms / 1e3);
|
|
86
|
+
};
|
|
87
|
+
const lc = (address) => String(address || "").toLowerCase();
|
|
88
|
+
/** Ethereum addresses compare case-insensitively; OCAP addresses may carry a DID prefix. */
|
|
89
|
+
const sameAddress = (a, b) => typeof a === "string" && typeof b === "string" && !!a && lc(a.replace(/^did:abt:/, "")) === lc(b.replace(/^did:abt:/, ""));
|
|
90
|
+
const isDecimal = (s) => typeof s === "string" && /^(0|[1-9][0-9]*)$/.test(s);
|
|
91
|
+
const isUint = (n, max = Number.MAX_SAFE_INTEGER) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= max;
|
|
92
|
+
const isEthAddr = (s) => typeof s === "string" && /^0x[0-9a-fA-F]{40}$/.test(s) && !/^0x0{40}$/.test(s);
|
|
93
|
+
const big = (s) => BigInt(s);
|
|
94
|
+
const MAX_U256 = (1n << 256n) - 1n;
|
|
95
|
+
/** `epochAt(t) = max{ e : activeFrom(e) <= t }`, undefined (null) before the first epoch. */
|
|
96
|
+
function activeEpochAt(body, t) {
|
|
97
|
+
let found = null;
|
|
98
|
+
for (const e of body.epochs) if (e.activeFrom <= t) found = e;
|
|
99
|
+
return found;
|
|
100
|
+
}
|
|
101
|
+
/** The epoch whose `activeFrom` is still in the future at `t` (there is at most one). */
|
|
102
|
+
function pendingEpochAt(body, t) {
|
|
103
|
+
const pending = body.epochs.filter((e) => e.activeFrom > t);
|
|
104
|
+
return pending.length ? pending[pending.length - 1] : null;
|
|
105
|
+
}
|
|
106
|
+
function maxVoucherValidity(body) {
|
|
107
|
+
return body.epochs.reduce((m, e) => Math.max(m, e.voucherValidity), 0);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Effective pause at `t`. A lone pause expires 24h after it was issued, purely by time: the persisted `paused` flag
|
|
111
|
+
* stays true, so every reader MUST use this function instead of reading `paused`.
|
|
112
|
+
*/
|
|
113
|
+
function isBridgePausedAt(state, t) {
|
|
114
|
+
const body = getBridgeBody(state);
|
|
115
|
+
if (!body) return !!state?.paused;
|
|
116
|
+
if (!state.paused) return false;
|
|
117
|
+
if (body.lonePause && body.lonePause.until <= t) return false;
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
/** Quorum pause = paused with no running (or expired) lone pause marker. */
|
|
121
|
+
function isQuorumPaused(state) {
|
|
122
|
+
const body = getBridgeBody(state);
|
|
123
|
+
return !!body && !!state.paused && body.lonePause === null;
|
|
124
|
+
}
|
|
125
|
+
/** Whether the bridge is final at `t` (closed and `closingAt + maxVoucherValidity + refundDelay` has passed). */
|
|
126
|
+
function isBridgeFinalAt(body, t) {
|
|
127
|
+
return body.finalAt !== null && t >= body.finalAt;
|
|
128
|
+
}
|
|
129
|
+
/** The owner at `t`: a pending replacement takes effect `effectiveAt` after it was proposed. */
|
|
130
|
+
function effectiveOwnerAt(body, t) {
|
|
131
|
+
return body.pendingOwner && body.pendingOwner.effectiveAt <= t ? body.pendingOwner.address : body.owner;
|
|
132
|
+
}
|
|
133
|
+
const isHttpUrl = (s) => {
|
|
134
|
+
try {
|
|
135
|
+
return typeof s === "string" && ["http:", "https:"].includes(new URL(s).protocol);
|
|
136
|
+
} catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const ETH_ADDRESS_FORMAT = /^0x[0-9a-fA-F]{40}$/;
|
|
141
|
+
/**
|
|
142
|
+
* Whether a proposed owner can be written into `owner` / `seed_validators`: a bare (no DID prefix), checksummed,
|
|
143
|
+
* non-zero Ethereum address, the public key of that address, and an http(s) endpoint.
|
|
144
|
+
*/
|
|
145
|
+
function isValidOwnerCandidate(p) {
|
|
146
|
+
return !!p && typeof p.address === "string" && ETH_ADDRESS_FORMAT.test(p.address) && !/^0x0{40}$/.test(p.address) && p.address === toChecksumAddress(p.address) && typeof p.pk === "string" && !!p.pk && isFromPublicKey(p.address, p.pk) && isHttpUrl(p.endpoint);
|
|
147
|
+
}
|
|
148
|
+
const memberToValidator = (m) => ({
|
|
149
|
+
pk: m.pk,
|
|
150
|
+
address: m.address,
|
|
151
|
+
endpoint: m.endpoint
|
|
152
|
+
});
|
|
153
|
+
/**
|
|
154
|
+
* Re-derive the informational mirrors (`validators`, `min/maxSignerCount`) from the active epoch. Called on every v2
|
|
155
|
+
* state write, so they are exact as of the last governance tx. Authority checks never read them; they read `epochs`.
|
|
156
|
+
*/
|
|
157
|
+
function syncBridgeView(state, txSec) {
|
|
158
|
+
const body = getBridgeBody(state);
|
|
159
|
+
const active = activeEpochAt(body, txSec) ?? body.epochs[0];
|
|
160
|
+
if (!active) return state;
|
|
161
|
+
return {
|
|
162
|
+
...state,
|
|
163
|
+
validators: active.validators.map((a) => memberToValidator(body.members[a])),
|
|
164
|
+
minSignerCount: active.threshold,
|
|
165
|
+
maxSignerCount: active.validators.length
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Apply every time-driven transition that is due at `txSec` to the state: a pending owner replacement whose timelock
|
|
170
|
+
* has run out rewrites BOTH `owner` and `seedValidators`. Returns the (possibly new) state; never mutates its input.
|
|
171
|
+
*/
|
|
172
|
+
function materializeBridgeAt(state, txSec) {
|
|
173
|
+
const body = getBridgeBody(state);
|
|
174
|
+
if (!body || !body.pendingOwner || body.pendingOwner.effectiveAt > txSec) return state;
|
|
175
|
+
const p = body.pendingOwner;
|
|
176
|
+
if (!isValidOwnerCandidate(p)) return {
|
|
177
|
+
...state,
|
|
178
|
+
data: {
|
|
179
|
+
...state.data,
|
|
180
|
+
value: {
|
|
181
|
+
...body,
|
|
182
|
+
pendingOwner: null
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
const next = {
|
|
187
|
+
...body,
|
|
188
|
+
owner: p.address,
|
|
189
|
+
pendingOwner: null
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
...state,
|
|
193
|
+
seedValidators: [{
|
|
194
|
+
pk: p.pk,
|
|
195
|
+
address: p.address,
|
|
196
|
+
endpoint: p.endpoint
|
|
197
|
+
}],
|
|
198
|
+
data: {
|
|
199
|
+
...state.data,
|
|
200
|
+
value: next
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function validateEpochs(epochs, transitionPeriod) {
|
|
205
|
+
if (!Array.isArray(epochs) || epochs.length === 0) bad("epochs must be a non-empty array");
|
|
206
|
+
epochs.forEach((e, i) => {
|
|
207
|
+
if (!e || typeof e !== "object") bad(`epochs[${i}] is not an object`);
|
|
208
|
+
if (e.epoch !== i + 1) bad(`epochs[${i}].epoch must be ${i + 1}`);
|
|
209
|
+
if (!isUint(e.activeFrom)) bad(`epochs[${i}].activeFrom must be a non-negative integer`);
|
|
210
|
+
if (i === 0 ? e.activeFrom !== 0 : e.activeFrom <= epochs[i - 1].activeFrom) bad(`epochs[${i}].activeFrom must ${i === 0 ? "be 0" : "strictly increase"}`);
|
|
211
|
+
if (!Array.isArray(e.validators)) bad(`epochs[${i}].validators must be an array`);
|
|
212
|
+
const n = e.validators.length;
|
|
213
|
+
if (n < BRIDGE_MIN_VALIDATORS || n > BRIDGE_MAX_VALIDATORS) bad(`epochs[${i}] needs between ${BRIDGE_MIN_VALIDATORS} and ${BRIDGE_MAX_VALIDATORS} validators`);
|
|
214
|
+
e.validators.forEach((a, j) => {
|
|
215
|
+
if (!isEthAddr(a) || a !== lc(a)) bad(`epochs[${i}].validators[${j}] must be a lowercase non-zero address`);
|
|
216
|
+
if (j > 0 && BigInt(a) <= BigInt(e.validators[j - 1])) bad(`epochs[${i}].validators must be strictly ascending`);
|
|
217
|
+
});
|
|
218
|
+
if (!isUint(e.threshold, 4294967295) || e.threshold < 1 || e.threshold > n || 2 * e.threshold <= n) bad(`epochs[${i}].threshold must satisfy 1 <= threshold <= n and 2*threshold > n`);
|
|
219
|
+
if (!isUint(e.voucherValidity) || e.voucherValidity < 1 || e.voucherValidity > transitionPeriod) bad(`epochs[${i}].voucherValidity must be between 1 and transitionPeriod`);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function validateAmounts(b) {
|
|
223
|
+
for (const k of [
|
|
224
|
+
"minDeposit",
|
|
225
|
+
"minWithdraw",
|
|
226
|
+
"maxWithdraw",
|
|
227
|
+
"withdrawFee",
|
|
228
|
+
"releaseDailyCap",
|
|
229
|
+
"refundDailyCap"
|
|
230
|
+
]) if (!isDecimal(b[k]) || big(b[k]) > MAX_U256) bad(`${k} must be a decimal string that fits uint256`);
|
|
231
|
+
if (b.withdrawFee !== "0") bad("withdrawFee must be 0: bridges charge no fees");
|
|
232
|
+
if (big(b.minDeposit) < 1n) bad("minDeposit must be positive");
|
|
233
|
+
if (big(b.minWithdraw) < 1n) bad("minWithdraw must be positive");
|
|
234
|
+
if (big(b.maxWithdraw) < big(b.minWithdraw)) bad("maxWithdraw must be >= minWithdraw");
|
|
235
|
+
if (big(b.releaseDailyCap) < 1n) bad("releaseDailyCap must be positive");
|
|
236
|
+
if (big(b.refundDailyCap) < 1n) bad("refundDailyCap must be positive");
|
|
237
|
+
}
|
|
238
|
+
function validateDelays(b) {
|
|
239
|
+
if (!isUint(b.releaseGrace, BRIDGE_MAX_DELAY)) bad("releaseGrace must be an integer between 0 and 90 days");
|
|
240
|
+
if (!isUint(b.refundDelay, BRIDGE_MAX_DELAY)) bad("refundDelay must be an integer between 0 and 90 days");
|
|
241
|
+
if (!isUint(b.transitionPeriod, BRIDGE_MAX_DELAY) || b.transitionPeriod < 1) bad("transitionPeriod must be an integer between 1 second and 90 days");
|
|
242
|
+
}
|
|
243
|
+
function validatePausers(pausers) {
|
|
244
|
+
if (!Array.isArray(pausers) || pausers.length > BRIDGE_MAX_PAUSERS) bad(`pausers must be an array of at most ${BRIDGE_MAX_PAUSERS} addresses`);
|
|
245
|
+
const seen = /* @__PURE__ */ new Set();
|
|
246
|
+
for (const p of pausers) {
|
|
247
|
+
if (typeof p !== "string" || !p || p.length > 128 || p.startsWith("did:abt:")) bad("pausers must be address strings without a DID prefix");
|
|
248
|
+
if (seen.has(lc(p))) bad("pausers must be unique");
|
|
249
|
+
seen.add(lc(p));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/** Full structural validation of a stored v2 body. */
|
|
253
|
+
function validateBridgeBody(body) {
|
|
254
|
+
if (!body || typeof body !== "object" || body.version !== BRIDGE_VERSION) bad("bridge body version must be 2");
|
|
255
|
+
if (typeof body.owner !== "string" || !ETH_ADDRESS_FORMAT.test(body.owner) || !isEthereumDid(body.owner) || body.owner !== toChecksumAddress(body.owner)) bad("bridge owner must be a bare, checksummed ethereum address");
|
|
256
|
+
if (!isDecimal(body.ethChainId) || big(body.ethChainId) < 1n || big(body.ethChainId) > MAX_U256) bad("ethChainId must be a positive decimal string");
|
|
257
|
+
if (!isEthAddr(body.gateway) || body.gateway !== lc(body.gateway)) bad("gateway must be a lowercase non-zero address");
|
|
258
|
+
if (typeof body.reserve !== "string" || !body.reserve) bad("reserve is required");
|
|
259
|
+
if (typeof body.salt !== "string" || !/^0x[0-9a-f]{64}$/.test(body.salt)) bad("salt must be lowercase bytes32");
|
|
260
|
+
validateAmounts(body);
|
|
261
|
+
validateDelays(body);
|
|
262
|
+
validateEpochs(body.epochs, body.transitionPeriod);
|
|
263
|
+
validatePausers(body.pausers);
|
|
264
|
+
if (!body.members || typeof body.members !== "object") bad("members is required");
|
|
265
|
+
for (const e of body.epochs) for (const a of e.validators) {
|
|
266
|
+
const m = body.members[a];
|
|
267
|
+
if (!m || lc(m.address) !== a || typeof m.pk !== "string" || typeof m.endpoint !== "string") bad(`members is missing validator ${a}`);
|
|
268
|
+
}
|
|
269
|
+
if (body.lonePause !== null) {
|
|
270
|
+
if (!body.lonePause || typeof body.lonePause.by !== "string" || !isUint(body.lonePause.until)) bad("lonePause must be null or { by, until }");
|
|
271
|
+
}
|
|
272
|
+
if (!body.lastLonePause || typeof body.lastLonePause !== "object") bad("lastLonePause is required");
|
|
273
|
+
for (const k of ["owner", "others"]) {
|
|
274
|
+
const v = body.lastLonePause[k];
|
|
275
|
+
if (v !== void 0 && !isUint(v)) bad(`lastLonePause.${k} must be a time`);
|
|
276
|
+
}
|
|
277
|
+
if (body.pendingOwner !== null) {
|
|
278
|
+
const p = body.pendingOwner;
|
|
279
|
+
if (!isValidOwnerCandidate(p) || !isUint(p.proposedAt) || !isUint(p.effectiveAt)) bad("invalid pendingOwner");
|
|
280
|
+
}
|
|
281
|
+
if (body.pendingMigration !== null) {
|
|
282
|
+
const p = body.pendingMigration;
|
|
283
|
+
if (!p || typeof p.to !== "string" || !isUint(p.announcedAt) || !isUint(p.effectiveAt)) bad("invalid pendingMigration");
|
|
284
|
+
}
|
|
285
|
+
for (const k of ["closingAt", "finalAt"]) if (body[k] !== null && !isUint(body[k])) bad(`${k} must be null or a time`);
|
|
286
|
+
if (body.closingAt === null !== (body.finalAt === null)) bad("closingAt and finalAt are set together");
|
|
287
|
+
if (body.depositCutoffEthBlock !== null && !isDecimal(body.depositCutoffEthBlock)) bad("depositCutoffEthBlock must be null or a decimal string");
|
|
288
|
+
if (body.migratedTo !== null && typeof body.migratedTo !== "string") bad("migratedTo must be null or an address");
|
|
289
|
+
if (body.migratedAmount !== void 0 && body.migratedAmount !== null && !isDecimal(body.migratedAmount)) bad("migratedAmount must be null or a decimal string");
|
|
290
|
+
const att = body.ethOwnerAttestation;
|
|
291
|
+
if (!att || !isEthAddr(att.address) || typeof att.signature !== "string" || !/^0x[0-9a-fA-F]{130}$/.test(att.signature)) bad("ethOwnerAttestation must be { address, signature }");
|
|
292
|
+
return body;
|
|
293
|
+
}
|
|
294
|
+
/** Whether a v1 numeric field is "zero or empty" (the v2 requirement for unused v1 fields). */
|
|
295
|
+
function isZeroish(v) {
|
|
296
|
+
return v === void 0 || v === null || v === "" || v === 0 || v === "0" || v === false;
|
|
297
|
+
}
|
|
298
|
+
const V1_ZERO_FIELDS = [
|
|
299
|
+
"minStakeAmount",
|
|
300
|
+
"maxStakeAmount",
|
|
301
|
+
"minBlockSize",
|
|
302
|
+
"maxBlockSize",
|
|
303
|
+
"minBlockInterval",
|
|
304
|
+
"minDepositAmount",
|
|
305
|
+
"maxDepositAmount",
|
|
306
|
+
"minWithdrawAmount",
|
|
307
|
+
"maxWithdrawAmount",
|
|
308
|
+
"depositFeeRate",
|
|
309
|
+
"withdrawFeeRate",
|
|
310
|
+
"proposerFeeShare",
|
|
311
|
+
"publisherFeeShare",
|
|
312
|
+
"minDepositFee",
|
|
313
|
+
"maxDepositFee",
|
|
314
|
+
"minWithdrawFee",
|
|
315
|
+
"maxWithdrawFee",
|
|
316
|
+
"blockHeight",
|
|
317
|
+
"blockHash",
|
|
318
|
+
"leaveWaitingPeriod",
|
|
319
|
+
"publishWaitingPeriod",
|
|
320
|
+
"publishSlashRate"
|
|
321
|
+
];
|
|
322
|
+
/** v1 fields a v2 bridge must leave at zero / empty (stake, block size / interval, fees, block height / hash, waits). */
|
|
323
|
+
const BRIDGE_V1_ZERO_FIELDS = V1_ZERO_FIELDS;
|
|
324
|
+
function assertV1FieldsUnused(attrs, errorCode) {
|
|
325
|
+
for (const f of V1_ZERO_FIELDS) if (!isZeroish(attrs[f])) throw new CustomError(errorCode, `${f} is not used by a v2 bridge and must be zero or empty`);
|
|
326
|
+
for (const f of [
|
|
327
|
+
"targetType",
|
|
328
|
+
"targetChainId",
|
|
329
|
+
"supportedTokens",
|
|
330
|
+
"reserves",
|
|
331
|
+
"allowProposerSponsor",
|
|
332
|
+
"enforceReserveWatermark"
|
|
333
|
+
]) if (attrs[f] !== void 0 && attrs[f] !== null && !(Array.isArray(attrs[f]) && attrs[f].length === 0)) throw new CustomError(errorCode, `${f} is not used by a v2 bridge`);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Structural rules for any transition of a v2 row, enforced by the state layer on every `update`:
|
|
337
|
+
* `version`, `gateway`, `ethChainId`, `reserve`, `salt`, `withdrawFee`, `transitionPeriod`, `ethOwnerAttestation`,
|
|
338
|
+
* `issuer` and the token fields are immutable; epochs are append-only (one new epoch, or the last pending one removed);
|
|
339
|
+
* `members` only grows; the owner changes only through a due `pendingOwner`; `migratedTo` is written once.
|
|
340
|
+
*/
|
|
341
|
+
function assertBridgeTransition(prev, next, txSec) {
|
|
342
|
+
const p = getBridgeBody(prev);
|
|
343
|
+
const n = getBridgeBody(next);
|
|
344
|
+
if (!p) {
|
|
345
|
+
if (n) badUpdate("a v1 rollup can not be converted to a v2 bridge");
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (!n) badUpdate("a v2 bridge can not be converted to a v1 rollup");
|
|
349
|
+
const nb = n;
|
|
350
|
+
for (const k of [
|
|
351
|
+
"version",
|
|
352
|
+
"ethChainId",
|
|
353
|
+
"gateway",
|
|
354
|
+
"reserve",
|
|
355
|
+
"salt",
|
|
356
|
+
"withdrawFee",
|
|
357
|
+
"transitionPeriod"
|
|
358
|
+
]) if (p[k] !== nb[k]) badUpdate(`${k} is immutable in a v2 bridge`);
|
|
359
|
+
if (JSON.stringify(p.ethOwnerAttestation) !== JSON.stringify(nb.ethOwnerAttestation)) badUpdate("ethOwnerAttestation is immutable in a v2 bridge");
|
|
360
|
+
for (const k of [
|
|
361
|
+
"tokenAddress",
|
|
362
|
+
"issuer",
|
|
363
|
+
"address",
|
|
364
|
+
"contractAddress"
|
|
365
|
+
]) if (prev[k] !== next[k] && k !== "contractAddress") badUpdate(`${k} is immutable in a v2 bridge`);
|
|
366
|
+
if (prev.contractAddress !== next.contractAddress) badUpdate("contractAddress is immutable in a v2 bridge");
|
|
367
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
368
|
+
const pe = p.epochs;
|
|
369
|
+
const ne = nb.epochs;
|
|
370
|
+
const prefixLen = Math.min(pe.length, ne.length);
|
|
371
|
+
const removed = pe.length - ne.length;
|
|
372
|
+
const added = ne.length - pe.length;
|
|
373
|
+
for (let i = 0; i < prefixLen; i++) if (!same(pe[i], ne[i])) badUpdate("epochs are append-only");
|
|
374
|
+
if (added > 1) badUpdate("at most one epoch can be added per update");
|
|
375
|
+
if (removed > 1) badUpdate("at most one pending epoch can be removed per update");
|
|
376
|
+
if (removed === 1) {
|
|
377
|
+
const dropped = pe[pe.length - 1];
|
|
378
|
+
if (txSec === null || dropped.activeFrom <= txSec) badUpdate("only a pending epoch can be removed");
|
|
379
|
+
}
|
|
380
|
+
const inUse = new Set(p.epochs[p.epochs.length - 1].validators);
|
|
381
|
+
for (const e of p.epochs) if (txSec === null || e === activeEpochAt(p, txSec)) for (const a of e.validators) inUse.add(a);
|
|
382
|
+
for (const [addr, m] of Object.entries(p.members)) if (JSON.stringify(nb.members[addr]) !== JSON.stringify(m) && (inUse.has(addr) || !nb.members[addr])) badUpdate("members are append-only");
|
|
383
|
+
if (p.owner !== nb.owner) {
|
|
384
|
+
const po = p.pendingOwner;
|
|
385
|
+
if (!po || po.address !== nb.owner || txSec === null || po.effectiveAt > txSec || nb.pendingOwner !== null) badUpdate("the owner can only be replaced through a due owner proposal");
|
|
386
|
+
const seeds = next.seedValidators;
|
|
387
|
+
if (!seeds || seeds.length !== 1 || !sameAddress(seeds[0]?.address, nb.owner)) badUpdate("seed_validators must be rewritten to the new owner");
|
|
388
|
+
} else if (JSON.stringify((prev.seedValidators || []).map((x) => x.address)) !== JSON.stringify((next.seedValidators || []).map((x) => x.address))) badUpdate("seed_validators only change with the owner");
|
|
389
|
+
if (nb.refundDelay < p.refundDelay) badUpdate("refundDelay can only increase");
|
|
390
|
+
if (p.migratedTo !== null && p.migratedTo !== nb.migratedTo) badUpdate("migratedTo is written once");
|
|
391
|
+
const pa = p.migratedAmount ?? null;
|
|
392
|
+
const na = nb.migratedAmount ?? null;
|
|
393
|
+
if (pa === null && na !== null && (p.migratedTo !== null || nb.migratedTo === null)) badUpdate("migratedAmount is written together with migratedTo");
|
|
394
|
+
if (pa !== null && (na === null || BigInt(na) > BigInt(pa))) badUpdate("migratedAmount can only decrease");
|
|
395
|
+
if (p.closingAt !== null && (p.closingAt !== nb.closingAt || p.finalAt !== nb.finalAt)) badUpdate("closingAt and finalAt are written once");
|
|
396
|
+
if (p.closingAt !== null && (added > 0 || removed > 0)) badUpdate("epochs are frozen after closingAt");
|
|
397
|
+
}
|
|
398
|
+
/** Parse and validate `itx.data.value` of a v2 `create_rollup` (pure shape checks; signatures are checked by the protocol). */
|
|
399
|
+
function parseBridgeCreateData(value) {
|
|
400
|
+
if (!value || typeof value !== "object" || value.version !== BRIDGE_VERSION) bad("create data must carry version 2");
|
|
401
|
+
for (const k of Object.keys(value)) if (!BRIDGE_CREATE_KEYS.includes(k)) bad(`unknown key in v2 create data: ${k}`);
|
|
402
|
+
const epochs = value.epochs;
|
|
403
|
+
if (!Array.isArray(epochs) || epochs.length !== 1) bad("create data must carry exactly epoch 1");
|
|
404
|
+
const e1 = epochs[0];
|
|
405
|
+
const epoch = {
|
|
406
|
+
epoch: e1.epoch,
|
|
407
|
+
activeFrom: e1.activeFrom,
|
|
408
|
+
threshold: e1.threshold,
|
|
409
|
+
validators: Array.isArray(e1.validators) ? e1.validators.map((a) => lc(a)) : e1.validators,
|
|
410
|
+
voucherValidity: e1.voucherValidity
|
|
411
|
+
};
|
|
412
|
+
if (epoch.epoch !== 1 || epoch.activeFrom !== 0) bad("epoch 1 must have activeFrom 0");
|
|
413
|
+
const consents = value.consents;
|
|
414
|
+
if (!Array.isArray(consents)) bad("consents is required");
|
|
415
|
+
const initialReserve = value.initialReserve === void 0 ? "0" : value.initialReserve;
|
|
416
|
+
if (!isDecimal(initialReserve)) bad("initialReserve must be a decimal string");
|
|
417
|
+
const att = value.ethOwnerAttestation;
|
|
418
|
+
if (!att || !isEthAddr(att.address)) bad("ethOwnerAttestation.address is required");
|
|
419
|
+
const body = {
|
|
420
|
+
version: BRIDGE_VERSION,
|
|
421
|
+
ethChainId: value.ethChainId,
|
|
422
|
+
gateway: typeof value.gateway === "string" ? lc(value.gateway) : value.gateway,
|
|
423
|
+
minDeposit: value.minDeposit,
|
|
424
|
+
minWithdraw: value.minWithdraw,
|
|
425
|
+
maxWithdraw: value.maxWithdraw,
|
|
426
|
+
withdrawFee: value.withdrawFee === void 0 ? "0" : value.withdrawFee,
|
|
427
|
+
releaseDailyCap: value.releaseDailyCap,
|
|
428
|
+
refundDailyCap: value.refundDailyCap,
|
|
429
|
+
releaseGrace: value.releaseGrace,
|
|
430
|
+
refundDelay: value.refundDelay,
|
|
431
|
+
transitionPeriod: value.transitionPeriod,
|
|
432
|
+
epochs: [epoch],
|
|
433
|
+
salt: typeof value.salt === "string" ? lc(value.salt) : value.salt,
|
|
434
|
+
pausers: value.pausers === void 0 ? [] : value.pausers,
|
|
435
|
+
ethOwnerAttestation: {
|
|
436
|
+
address: lc(att.address),
|
|
437
|
+
signature: att.signature
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
if (!isDecimal(body.ethChainId) || big(body.ethChainId) < 1n || big(body.ethChainId) > MAX_U256) bad("ethChainId must be a positive decimal string");
|
|
441
|
+
if (!isEthAddr(body.gateway)) bad("gateway must be a non-zero address");
|
|
442
|
+
if (typeof body.salt !== "string" || !/^0x[0-9a-f]{64}$/.test(body.salt)) bad("salt must be bytes32");
|
|
443
|
+
validateAmounts(body);
|
|
444
|
+
validateDelays(body);
|
|
445
|
+
validateEpochs([epoch], body.transitionPeriod);
|
|
446
|
+
validatePausers(body.pausers);
|
|
447
|
+
if (!/^0x[0-9a-fA-F]{130}$/.test(att.signature)) bad("ethOwnerAttestation.signature must be 65 bytes");
|
|
448
|
+
return {
|
|
449
|
+
body,
|
|
450
|
+
consents,
|
|
451
|
+
initialReserve
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Validate an `update_rollup` patch (`itx.data.value`) against the allow-list and compute the resulting body.
|
|
456
|
+
* `proposeOwner` is its own transaction kind (2/3 quorum), `cancelOwnerProposal` needs the current owner alone, anything
|
|
457
|
+
* else needs owner + quorum. Frozen keys (version, epochs, reserve, gateway, ethChainId, token fields...) are rejected.
|
|
458
|
+
*/
|
|
459
|
+
function planBridgePatch(body, patch, txSec) {
|
|
460
|
+
if (!patch || typeof patch !== "object" || Array.isArray(patch)) badUpdate("update data must be a typed patch object");
|
|
461
|
+
const keys = Object.keys(patch);
|
|
462
|
+
if (keys.length === 0) badUpdate("update patch is empty");
|
|
463
|
+
const allowed = [...BRIDGE_PATCH_VALUE_KEYS, ...BRIDGE_PATCH_ACTION_KEYS];
|
|
464
|
+
for (const k of keys) if (!allowed.includes(k)) badUpdate(`key ${k} can not be updated in a v2 bridge`);
|
|
465
|
+
const has = (k) => patch[k] !== void 0;
|
|
466
|
+
const next = { ...body };
|
|
467
|
+
const ownerOnly = has("proposeOwner") || has("cancelOwnerProposal");
|
|
468
|
+
if (body.closingAt !== null && (!ownerOnly || body.migratedTo !== null)) badUpdate(body.migratedTo !== null ? "the reserve has migrated: the bridge is frozen" : "a closed bridge is frozen");
|
|
469
|
+
if (has("proposeOwner") || has("cancelOwnerProposal")) {
|
|
470
|
+
if (keys.length !== 1) badUpdate("proposeOwner and cancelOwnerProposal can not be combined with other keys");
|
|
471
|
+
if (has("cancelOwnerProposal")) {
|
|
472
|
+
if (patch.cancelOwnerProposal !== true) badUpdate("cancelOwnerProposal must be true");
|
|
473
|
+
if (!body.pendingOwner) badUpdate("there is no pending owner proposal to cancel");
|
|
474
|
+
next.pendingOwner = null;
|
|
475
|
+
return {
|
|
476
|
+
kind: "cancel-owner-proposal",
|
|
477
|
+
body: next,
|
|
478
|
+
cancelledEpoch: null
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
if (body.pendingOwner) badUpdate("an owner proposal is already pending");
|
|
482
|
+
const p = patch.proposeOwner;
|
|
483
|
+
if (!p || typeof p !== "object" || typeof p.address !== "string" || !ETH_ADDRESS_FORMAT.test(p.address)) badUpdate("proposeOwner.address must be a bare ethereum address (0x and 40 hex digits, no DID prefix)");
|
|
484
|
+
const address = toChecksumAddress(p.address);
|
|
485
|
+
if (!isEthereumDid(address) || /^0x0{40}$/.test(address)) badUpdate("proposeOwner.address is not valid");
|
|
486
|
+
if (typeof p.pk !== "string" || !p.pk || !isFromPublicKey(address, p.pk)) badUpdate("proposeOwner.pk must be the public key of proposeOwner.address");
|
|
487
|
+
if (!isHttpUrl(p.endpoint)) badUpdate("proposeOwner.endpoint must be an http(s) URL");
|
|
488
|
+
if (sameAddress(address, body.owner)) badUpdate("proposeOwner is already the owner");
|
|
489
|
+
next.pendingOwner = {
|
|
490
|
+
address,
|
|
491
|
+
pk: p.pk,
|
|
492
|
+
endpoint: p.endpoint,
|
|
493
|
+
proposedAt: txSec,
|
|
494
|
+
effectiveAt: txSec + BRIDGE_OWNER_TIMELOCK
|
|
495
|
+
};
|
|
496
|
+
return {
|
|
497
|
+
kind: "propose-owner",
|
|
498
|
+
body: next,
|
|
499
|
+
cancelledEpoch: null
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
let cancelledEpoch = null;
|
|
503
|
+
for (const k of [
|
|
504
|
+
"minDeposit",
|
|
505
|
+
"minWithdraw",
|
|
506
|
+
"maxWithdraw",
|
|
507
|
+
"releaseDailyCap",
|
|
508
|
+
"refundDailyCap"
|
|
509
|
+
]) if (has(k)) {
|
|
510
|
+
if (!isDecimal(patch[k])) badUpdate(`${k} must be a decimal string`);
|
|
511
|
+
next[k] = patch[k];
|
|
512
|
+
}
|
|
513
|
+
for (const k of ["releaseGrace", "refundDelay"]) if (has(k)) {
|
|
514
|
+
if (!isUint(patch[k], BRIDGE_MAX_DELAY)) badUpdate(`${k} must be an integer between 0 and 90 days`);
|
|
515
|
+
next[k] = patch[k];
|
|
516
|
+
}
|
|
517
|
+
if (has("pausers")) {
|
|
518
|
+
validatePausers(patch.pausers);
|
|
519
|
+
next.pausers = [...patch.pausers];
|
|
520
|
+
}
|
|
521
|
+
if (has("cancelPendingEpoch")) {
|
|
522
|
+
if (patch.cancelPendingEpoch !== true) badUpdate("cancelPendingEpoch must be true");
|
|
523
|
+
const pending = pendingEpochAt(body, txSec);
|
|
524
|
+
if (!pending) badUpdate("there is no pending epoch to cancel");
|
|
525
|
+
cancelledEpoch = pending;
|
|
526
|
+
next.epochs = body.epochs.slice(0, -1);
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
validateAmounts(next);
|
|
530
|
+
validateDelays(next);
|
|
531
|
+
} catch (err) {
|
|
532
|
+
badUpdate(err.message);
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
kind: "owner-quorum",
|
|
536
|
+
body: next,
|
|
537
|
+
cancelledEpoch
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/** Epoch rules of §v2.2: `epoch = last + 1`, lead window, `2*threshold > n`, `n >= 3`, at most one pending epoch. */
|
|
541
|
+
function planMembership(body, req, txSec) {
|
|
542
|
+
if (body.closingAt !== null) bad("membership is frozen after closingAt");
|
|
543
|
+
const last = body.epochs[body.epochs.length - 1];
|
|
544
|
+
const active = activeEpochAt(body, txSec);
|
|
545
|
+
if (!active) bad("no epoch is active yet");
|
|
546
|
+
if (pendingEpochAt(body, txSec)) bad("an epoch change is already pending: wait for it or cancel it");
|
|
547
|
+
const v = lc(req.validator);
|
|
548
|
+
if (!isEthAddr(v)) bad("validator must be a non-zero ethereum address");
|
|
549
|
+
const base = last.validators;
|
|
550
|
+
let validators;
|
|
551
|
+
if (req.action === "join") {
|
|
552
|
+
if (base.includes(v)) bad(`${v} is already a validator`);
|
|
553
|
+
validators = [...base, v];
|
|
554
|
+
} else {
|
|
555
|
+
if (!base.includes(v)) bad(`${v} is not a validator`);
|
|
556
|
+
validators = base.filter((x) => x !== v);
|
|
557
|
+
}
|
|
558
|
+
validators.sort((a, b) => BigInt(a) < BigInt(b) ? -1 : BigInt(a) > BigInt(b) ? 1 : 0);
|
|
559
|
+
if (!isUint(req.activeFrom) || req.activeFrom <= last.activeFrom) bad("activeFrom must be after the last epoch");
|
|
560
|
+
if (req.activeFrom < txSec + BRIDGE_MIN_EPOCH_LEAD || req.activeFrom > txSec + BRIDGE_MAX_EPOCH_LEAD) bad("activeFrom must be between txTime + 1h and txTime + 2d");
|
|
561
|
+
const epoch = {
|
|
562
|
+
epoch: last.epoch + 1,
|
|
563
|
+
activeFrom: req.activeFrom,
|
|
564
|
+
threshold: req.threshold,
|
|
565
|
+
validators,
|
|
566
|
+
voucherValidity: req.voucherValidity
|
|
567
|
+
};
|
|
568
|
+
validateEpochs([...body.epochs, epoch], body.transitionPeriod);
|
|
569
|
+
return {
|
|
570
|
+
epoch,
|
|
571
|
+
signingEpoch: active
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function lonePauseTrack(body, by) {
|
|
575
|
+
return sameAddress(by, body.owner) ? "owner" : "others";
|
|
576
|
+
}
|
|
577
|
+
/** Validate and apply a lone pause by `by` (a member of `pausers`) at `txSec`. */
|
|
578
|
+
function applyLonePause(body, by, txSec) {
|
|
579
|
+
if (!body.pausers.some((p) => sameAddress(p, by))) bad("sender is not an allowed pauser");
|
|
580
|
+
const track = lonePauseTrack(body, by);
|
|
581
|
+
const last = body.lastLonePause[track];
|
|
582
|
+
if (last !== void 0 && txSec < last + BRIDGE_LONE_PAUSE_COOLDOWN) bad(`lone pause cooldown: ${track === "owner" ? "the owner" : "the pausers"} can pause again after ${(/* @__PURE__ */ new Date((last + BRIDGE_LONE_PAUSE_COOLDOWN) * 1e3)).toISOString()}`);
|
|
583
|
+
return {
|
|
584
|
+
...body,
|
|
585
|
+
lonePause: {
|
|
586
|
+
by,
|
|
587
|
+
until: txSec + BRIDGE_LONE_PAUSE_TTL
|
|
588
|
+
},
|
|
589
|
+
lastLonePause: {
|
|
590
|
+
...body.lastLonePause,
|
|
591
|
+
[track]: txSec
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
//#endregion
|
|
597
|
+
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, effectiveOwnerAt, getBridgeBody, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isQuorumPaused, isValidOwnerCandidate, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, parseBridgeCreateData, pendingEpochAt, planBridgePatch, planMembership, sameAddress, syncBridgeView, toSeconds, validateBridgeBody };
|
package/esm/states/rollup.d.mts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { StateContextInput } from "../contexts/state.mjs";
|
|
2
|
+
import { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, effectiveOwnerAt, getBridgeBody, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isQuorumPaused, isValidOwnerCandidate, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, parseBridgeCreateData, pendingEpochAt, planBridgePatch, planMembership, sameAddress, syncBridgeView, toSeconds, validateBridgeBody } from "./rollup-v2.mjs";
|
|
3
|
+
import { bridgeSchema, createBridge, updateBridge, validateBridge } from "./rollup-bridge.mjs";
|
|
2
4
|
import { v } from "@arcblock/validator";
|
|
3
5
|
import { IRollupState } from "@ocap/types";
|
|
4
6
|
|
|
5
7
|
//#region src/states/rollup.d.ts
|
|
6
8
|
declare namespace rollup_d_exports {
|
|
7
|
-
export { RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, close, create, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isProposerSponsoredDepositAllowed, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, migrateContract, migrateVault, pause, recordRollupDeposit, recordRollupWithdraw, resume, schema, update, validate };
|
|
9
|
+
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bridgeSchema, close, create, createBridge, effectiveOwnerAt, getBridgeBody, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isProposerSponsoredDepositAllowed, isQuorumPaused, isTokenSupportedByRollup, isValidOwnerCandidate, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, migrateContract, migrateVault, parseBridgeCreateData, pause, pendingEpochAt, planBridgePatch, planMembership, recordRollupDeposit, recordRollupWithdraw, resume, sameAddress, schema, syncBridgeView, toSeconds, update, updateBridge, validate, validateBridge, validateBridgeBody };
|
|
8
10
|
}
|
|
9
11
|
type RollupTargetType = 'EVM' | 'OCAP_ISOMORPHIC';
|
|
10
12
|
interface RollupTokenReserve {
|
|
@@ -103,4 +105,4 @@ declare const recordRollupDeposit: (state: IRollupState & Record<string, any>, t
|
|
|
103
105
|
declare const recordRollupWithdraw: (state: IRollupState & Record<string, any>, tokenAddress: string, amount: string, context: StateContextInput) => IRollupState;
|
|
104
106
|
declare const validate: (state: IRollupState & Record<string, any>) => IRollupState;
|
|
105
107
|
//#endregion
|
|
106
|
-
export { RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, close, create, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isProposerSponsoredDepositAllowed, isTokenSupportedByRollup, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, migrateContract, migrateVault, pause, recordRollupDeposit, recordRollupWithdraw, resume, rollup_d_exports, schema, update, validate };
|
|
108
|
+
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bridgeSchema, close, create, createBridge, effectiveOwnerAt, getBridgeBody, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isProposerSponsoredDepositAllowed, isQuorumPaused, isTokenSupportedByRollup, isValidOwnerCandidate, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, migrateContract, migrateVault, parseBridgeCreateData, pause, pendingEpochAt, planBridgePatch, planMembership, recordRollupDeposit, recordRollupWithdraw, resume, rollup_d_exports, sameAddress, schema, syncBridgeView, toSeconds, update, updateBridge, validate, validateBridge, validateBridgeBody };
|