@matterlabs/zksync-js 0.0.14 → 0.0.16
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/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.d.ts +1 -2
- package/dist/adapters/ethers/client.js +4 -5
- package/dist/adapters/ethers/index.cjs +200 -32
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +6 -7
- package/dist/adapters/ethers/resources/interop/index.d.ts +4 -1
- package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +4 -0
- package/dist/adapters/ethers/resources/interop/services/gas.d.ts +12 -0
- package/dist/adapters/ethers/sdk.cjs +200 -32
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +5 -6
- package/dist/adapters/viem/client.cjs +787 -3
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.d.ts +6 -1
- package/dist/adapters/viem/client.js +4 -5
- package/dist/adapters/viem/index.cjs +6502 -2966
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +5 -0
- package/dist/adapters/viem/index.js +6 -7
- package/dist/adapters/viem/resources/interop/address.d.ts +18 -0
- package/dist/adapters/viem/resources/interop/attributes/resource.d.ts +6 -0
- package/dist/adapters/viem/resources/interop/context.d.ts +31 -0
- package/dist/adapters/viem/resources/interop/index.d.ts +65 -0
- package/dist/adapters/viem/resources/interop/resolvers.d.ts +4 -0
- package/dist/adapters/viem/resources/interop/routes/direct.d.ts +2 -0
- package/dist/adapters/viem/resources/interop/routes/indirect.d.ts +2 -0
- package/dist/adapters/viem/resources/interop/routes/types.d.ts +23 -0
- package/dist/adapters/viem/resources/interop/services/erc20.d.ts +25 -0
- package/dist/adapters/viem/resources/interop/services/fee.d.ts +12 -0
- package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +19 -0
- package/dist/adapters/viem/resources/interop/services/finalization/data-fetchers.d.ts +17 -0
- package/dist/adapters/viem/resources/interop/services/finalization/decoders.d.ts +11 -0
- package/dist/adapters/viem/resources/interop/services/finalization/index.d.ts +13 -0
- package/dist/adapters/viem/resources/interop/services/finalization/polling.d.ts +7 -0
- package/dist/adapters/viem/resources/interop/services/finalization/status.d.ts +5 -0
- package/dist/adapters/viem/resources/interop/services/finalization/topics.d.ts +4 -0
- package/dist/adapters/viem/resources/interop/services/gas.d.ts +12 -0
- package/dist/adapters/viem/resources/interop/services/starter-data.d.ts +6 -0
- package/dist/adapters/viem/resources/interop/types.d.ts +8 -0
- package/dist/adapters/viem/sdk.cjs +6665 -3173
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +8 -1
- package/dist/adapters/viem/sdk.js +5 -5
- package/dist/{chunk-7CAVFIMW.js → chunk-24TE2NNJ.js} +2 -3
- package/dist/{chunk-75IOOODG.js → chunk-3KH5PCD6.js} +1233 -31
- package/dist/{chunk-XKRNLFET.js → chunk-5HG2DUYW.js} +150 -375
- package/dist/{chunk-OTXPSNNC.js → chunk-CK5UFAZK.js} +64 -7
- package/dist/{chunk-HP3EWKJL.js → chunk-JSBMIT4S.js} +1 -1
- package/dist/{chunk-5RRJDPAJ.js → chunk-NJK325XV.js} +2 -2
- package/dist/chunk-NLUCYVMX.js +658 -0
- package/dist/{chunk-XDRCN4FC.js → chunk-SBGBYZJM.js} +10 -2
- package/dist/{chunk-J47RI3G7.js → chunk-TYYUG5GA.js} +1 -1
- package/dist/{chunk-JY62QO3W.js → chunk-UEKFQAOS.js} +420 -6
- package/dist/core/index.js +2 -3
- package/dist/core/resources/deposits/chains.d.ts +1 -0
- package/dist/core/resources/deposits/gas.d.ts +7 -0
- package/dist/core/resources/deposits/priority.d.ts +4 -0
- package/dist/core/resources/interop/protocol.d.ts +3 -0
- package/dist/core/types/errors.d.ts +1 -0
- package/dist/core/types/flows/interop.d.ts +0 -2
- package/dist/core/types/primitives.d.ts +2 -0
- package/dist/index.js +2 -3
- package/package.json +1 -1
- package/dist/chunk-DYJKK5FW.js +0 -417
- package/dist/chunk-EOBXYHTZ.js +0 -265
|
@@ -7027,6 +7027,7 @@ var OP_INTEROP = {
|
|
|
7027
7027
|
tryWait: "interop.tryWait",
|
|
7028
7028
|
finalize: "interop.finalize",
|
|
7029
7029
|
tryFinalize: "interop.tryFinalize",
|
|
7030
|
+
verify: "interop.verify",
|
|
7030
7031
|
context: {
|
|
7031
7032
|
chainTypeManager: "interop.chainTypeManager",
|
|
7032
7033
|
protocolVersion: "interop.protocolVersion"
|
|
@@ -7078,20 +7079,20 @@ function createError(type, input) {
|
|
|
7078
7079
|
return new ZKsyncError({ ...input, type });
|
|
7079
7080
|
}
|
|
7080
7081
|
function shapeCause(err) {
|
|
7081
|
-
const
|
|
7082
|
+
const isRecord2 = (x) => x !== null && typeof x === "object";
|
|
7082
7083
|
let data = void 0;
|
|
7083
|
-
if (
|
|
7084
|
+
if (isRecord2(err)) {
|
|
7084
7085
|
const r2 = err;
|
|
7085
7086
|
const d = r2.data;
|
|
7086
|
-
if (
|
|
7087
|
+
if (isRecord2(d) && "data" in d) {
|
|
7087
7088
|
data = d.data;
|
|
7088
|
-
} else if ("error" in r2 &&
|
|
7089
|
+
} else if ("error" in r2 && isRecord2(r2.error) && "data" in r2.error) {
|
|
7089
7090
|
data = r2.error.data;
|
|
7090
7091
|
} else if ("data" in r2) {
|
|
7091
7092
|
data = r2.data;
|
|
7092
7093
|
}
|
|
7093
7094
|
}
|
|
7094
|
-
const r =
|
|
7095
|
+
const r = isRecord2(err) ? err : void 0;
|
|
7095
7096
|
const name = r && typeof r.name === "string" ? r.name : void 0;
|
|
7096
7097
|
const message = r && typeof r.message === "string" ? r.message : r && typeof r.shortMessage === "string" ? r.shortMessage : void 0;
|
|
7097
7098
|
const code = r && "code" in r ? r.code : void 0;
|
|
@@ -7103,4 +7104,417 @@ function shapeCause(err) {
|
|
|
7103
7104
|
};
|
|
7104
7105
|
}
|
|
7105
7106
|
|
|
7106
|
-
|
|
7107
|
+
// src/core/rpc/zks.ts
|
|
7108
|
+
var zks_exports = {};
|
|
7109
|
+
__export(zks_exports, {
|
|
7110
|
+
ProofTarget: () => ProofTarget,
|
|
7111
|
+
createZksRpc: () => createZksRpc,
|
|
7112
|
+
normalizeBlockMetadata: () => normalizeBlockMetadata,
|
|
7113
|
+
normalizeGenesis: () => normalizeGenesis,
|
|
7114
|
+
normalizeProof: () => normalizeProof
|
|
7115
|
+
});
|
|
7116
|
+
|
|
7117
|
+
// src/core/errors/rpc.ts
|
|
7118
|
+
async function withRpcOp(operation, message, ctx, fn) {
|
|
7119
|
+
try {
|
|
7120
|
+
return await fn();
|
|
7121
|
+
} catch (e) {
|
|
7122
|
+
if (isZKsyncError(e)) throw e;
|
|
7123
|
+
throw createError("RPC", {
|
|
7124
|
+
resource: "zksrpc",
|
|
7125
|
+
operation,
|
|
7126
|
+
message,
|
|
7127
|
+
context: ctx,
|
|
7128
|
+
cause: shapeCause(e)
|
|
7129
|
+
});
|
|
7130
|
+
}
|
|
7131
|
+
}
|
|
7132
|
+
|
|
7133
|
+
// src/core/rpc/zks.ts
|
|
7134
|
+
var ProofTarget = /* @__PURE__ */ ((ProofTarget2) => {
|
|
7135
|
+
ProofTarget2["L1BatchRoot"] = "l1BatchRoot";
|
|
7136
|
+
ProofTarget2["MessageRoot"] = "messageRoot";
|
|
7137
|
+
return ProofTarget2;
|
|
7138
|
+
})(ProofTarget || {});
|
|
7139
|
+
var METHODS = {
|
|
7140
|
+
getBridgehub: "zks_getBridgehubContract",
|
|
7141
|
+
getL2ToL1LogProof: "zks_getL2ToL1LogProof",
|
|
7142
|
+
getReceipt: "eth_getTransactionReceipt",
|
|
7143
|
+
getBytecodeSupplier: "zks_getBytecodeSupplierContract",
|
|
7144
|
+
getBlockMetadataByNumber: "zks_getBlockMetadataByNumber",
|
|
7145
|
+
getGenesis: "zks_getGenesis"
|
|
7146
|
+
};
|
|
7147
|
+
function toHexArray(arr) {
|
|
7148
|
+
const list = Array.isArray(arr) ? arr : [];
|
|
7149
|
+
return list.map((x) => x);
|
|
7150
|
+
}
|
|
7151
|
+
function normalizeProof(p) {
|
|
7152
|
+
try {
|
|
7153
|
+
const raw = p ?? {};
|
|
7154
|
+
const idRaw = raw?.id ?? raw?.index;
|
|
7155
|
+
const bnRaw = raw?.batch_number ?? raw?.batchNumber;
|
|
7156
|
+
const gwBlockNumberRaw = raw?.gatewayBlockNumber;
|
|
7157
|
+
if (idRaw == null || bnRaw == null) {
|
|
7158
|
+
throw createError("RPC", {
|
|
7159
|
+
resource: "zksrpc",
|
|
7160
|
+
operation: "zksrpc.normalizeProof",
|
|
7161
|
+
message: "Malformed proof: missing id or batch number.",
|
|
7162
|
+
context: { keys: Object.keys(raw ?? {}) }
|
|
7163
|
+
});
|
|
7164
|
+
}
|
|
7165
|
+
const toBig = (x) => isBigint(x) ? x : isNumber(x) ? BigInt(x) : typeof x === "string" ? BigInt(x) : (() => {
|
|
7166
|
+
throw createError("RPC", {
|
|
7167
|
+
resource: "zksrpc",
|
|
7168
|
+
operation: "zksrpc.normalizeProof",
|
|
7169
|
+
message: "Malformed proof: invalid numeric field.",
|
|
7170
|
+
context: { valueType: typeof x }
|
|
7171
|
+
});
|
|
7172
|
+
})();
|
|
7173
|
+
return {
|
|
7174
|
+
id: toBig(idRaw),
|
|
7175
|
+
batchNumber: toBig(bnRaw),
|
|
7176
|
+
proof: toHexArray(raw?.proof),
|
|
7177
|
+
root: raw.root,
|
|
7178
|
+
gatewayBlockNumber: gwBlockNumberRaw != null ? toBig(gwBlockNumberRaw) : void 0
|
|
7179
|
+
};
|
|
7180
|
+
} catch (e) {
|
|
7181
|
+
if (isZKsyncError(e)) throw e;
|
|
7182
|
+
throw createError("RPC", {
|
|
7183
|
+
resource: "zksrpc",
|
|
7184
|
+
operation: "zksrpc.normalizeProof",
|
|
7185
|
+
message: "Failed to normalize proof.",
|
|
7186
|
+
context: { receivedType: typeof p },
|
|
7187
|
+
cause: shapeCause(e)
|
|
7188
|
+
});
|
|
7189
|
+
}
|
|
7190
|
+
}
|
|
7191
|
+
function ensureHex(value, field, context) {
|
|
7192
|
+
if (typeof value === "string" && value.startsWith("0x")) return value;
|
|
7193
|
+
throw createError("RPC", {
|
|
7194
|
+
resource: "zksrpc",
|
|
7195
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7196
|
+
message: "Malformed genesis response: expected 0x-prefixed hex value.",
|
|
7197
|
+
context: { field, valueType: typeof value, ...context }
|
|
7198
|
+
});
|
|
7199
|
+
}
|
|
7200
|
+
function ensureNumber(value, field, opts) {
|
|
7201
|
+
const operation = opts?.operation;
|
|
7202
|
+
const messagePrefix = opts?.messagePrefix;
|
|
7203
|
+
if (isNumber(value)) return value;
|
|
7204
|
+
if (isBigint(value)) return Number(value);
|
|
7205
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
7206
|
+
const parsed = Number(value);
|
|
7207
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
7208
|
+
}
|
|
7209
|
+
throw createError("RPC", {
|
|
7210
|
+
resource: "zksrpc",
|
|
7211
|
+
operation,
|
|
7212
|
+
message: `${messagePrefix}: expected numeric value.`,
|
|
7213
|
+
context: { field, valueType: typeof value }
|
|
7214
|
+
});
|
|
7215
|
+
}
|
|
7216
|
+
function ensureBigInt(value, field, opts) {
|
|
7217
|
+
const operation = opts?.operation ?? "zksrpc.normalizeBlockMetadata";
|
|
7218
|
+
const messagePrefix = opts?.messagePrefix ?? "Malformed block metadata response";
|
|
7219
|
+
if (isBigint(value)) return value;
|
|
7220
|
+
if (isNumber(value)) {
|
|
7221
|
+
if (!Number.isInteger(value)) {
|
|
7222
|
+
throw createError("RPC", {
|
|
7223
|
+
resource: "zksrpc",
|
|
7224
|
+
operation,
|
|
7225
|
+
message: `${messagePrefix}: expected integer value.`,
|
|
7226
|
+
context: { field, valueType: typeof value }
|
|
7227
|
+
});
|
|
7228
|
+
}
|
|
7229
|
+
return BigInt(value);
|
|
7230
|
+
}
|
|
7231
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
7232
|
+
try {
|
|
7233
|
+
return BigInt(value);
|
|
7234
|
+
} catch {
|
|
7235
|
+
}
|
|
7236
|
+
}
|
|
7237
|
+
throw createError("RPC", {
|
|
7238
|
+
resource: "zksrpc",
|
|
7239
|
+
operation,
|
|
7240
|
+
message: `${messagePrefix}: expected bigint-compatible value.`,
|
|
7241
|
+
context: { field, valueType: typeof value }
|
|
7242
|
+
});
|
|
7243
|
+
}
|
|
7244
|
+
function isRecord(x) {
|
|
7245
|
+
return !!x && typeof x === "object" && !Array.isArray(x);
|
|
7246
|
+
}
|
|
7247
|
+
function normalizeContractTuple(tuple, index) {
|
|
7248
|
+
if (!Array.isArray(tuple) || tuple.length < 2) {
|
|
7249
|
+
throw createError("RPC", {
|
|
7250
|
+
resource: "zksrpc",
|
|
7251
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7252
|
+
message: "Malformed genesis response: invalid contract tuple.",
|
|
7253
|
+
context: { index, valueType: typeof tuple }
|
|
7254
|
+
});
|
|
7255
|
+
}
|
|
7256
|
+
const [addrRaw, bytecodeRaw] = tuple;
|
|
7257
|
+
return {
|
|
7258
|
+
address: ensureHex(addrRaw, "initial_contracts.address", { index }),
|
|
7259
|
+
bytecode: ensureHex(bytecodeRaw, "initial_contracts.bytecode", { index })
|
|
7260
|
+
};
|
|
7261
|
+
}
|
|
7262
|
+
function normalizeRawStorageTuple(tuple, index) {
|
|
7263
|
+
if (!Array.isArray(tuple) || tuple.length < 2) {
|
|
7264
|
+
throw createError("RPC", {
|
|
7265
|
+
resource: "zksrpc",
|
|
7266
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7267
|
+
message: "Malformed genesis response: invalid storage tuple.",
|
|
7268
|
+
context: { index, valueType: typeof tuple }
|
|
7269
|
+
});
|
|
7270
|
+
}
|
|
7271
|
+
const [keyRaw, valueRaw] = tuple;
|
|
7272
|
+
return {
|
|
7273
|
+
format: "raw",
|
|
7274
|
+
key: ensureHex(keyRaw, "additional_storage.key", { index }),
|
|
7275
|
+
value: ensureHex(valueRaw, "additional_storage.value", { index })
|
|
7276
|
+
};
|
|
7277
|
+
}
|
|
7278
|
+
function normalizeAdditionalStorage(value, record) {
|
|
7279
|
+
const effective = value ?? record["additional_storage_raw"];
|
|
7280
|
+
if (Array.isArray(effective)) {
|
|
7281
|
+
return effective.map((entry, index) => {
|
|
7282
|
+
const kv2 = normalizeRawStorageTuple(entry, index);
|
|
7283
|
+
return { format: "raw", key: kv2.key, value: kv2.value };
|
|
7284
|
+
});
|
|
7285
|
+
}
|
|
7286
|
+
if (isRecord(effective)) {
|
|
7287
|
+
const out = [];
|
|
7288
|
+
for (const [addrRaw, slotsRaw] of Object.entries(effective)) {
|
|
7289
|
+
const address = ensureHex(addrRaw, "additional_storage.address", {});
|
|
7290
|
+
if (!isRecord(slotsRaw)) {
|
|
7291
|
+
throw createError("RPC", {
|
|
7292
|
+
resource: "zksrpc",
|
|
7293
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7294
|
+
message: "Malformed genesis response: additional_storage[address] must be an object map.",
|
|
7295
|
+
context: { address, valueType: typeof slotsRaw }
|
|
7296
|
+
});
|
|
7297
|
+
}
|
|
7298
|
+
for (const [slotRaw, valRaw] of Object.entries(slotsRaw)) {
|
|
7299
|
+
out.push({
|
|
7300
|
+
format: "pretty",
|
|
7301
|
+
address,
|
|
7302
|
+
key: ensureHex(slotRaw, "additional_storage.key", { address }),
|
|
7303
|
+
value: ensureHex(valRaw, "additional_storage.value", { address, key: slotRaw })
|
|
7304
|
+
});
|
|
7305
|
+
}
|
|
7306
|
+
}
|
|
7307
|
+
return out;
|
|
7308
|
+
}
|
|
7309
|
+
throw createError("RPC", {
|
|
7310
|
+
resource: "zksrpc",
|
|
7311
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7312
|
+
message: "Malformed genesis response: additional_storage must be an array (raw) or an object map (pretty).",
|
|
7313
|
+
context: {
|
|
7314
|
+
valueType: typeof effective,
|
|
7315
|
+
hasAdditionalStorage: "additional_storage" in record,
|
|
7316
|
+
hasAdditionalStorageRaw: "additional_storage_raw" in record
|
|
7317
|
+
}
|
|
7318
|
+
});
|
|
7319
|
+
}
|
|
7320
|
+
function normalizeGenesis(raw) {
|
|
7321
|
+
try {
|
|
7322
|
+
if (!raw || typeof raw !== "object") {
|
|
7323
|
+
throw createError("RPC", {
|
|
7324
|
+
resource: "zksrpc",
|
|
7325
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7326
|
+
message: "Malformed genesis response: expected object.",
|
|
7327
|
+
context: { receivedType: typeof raw }
|
|
7328
|
+
});
|
|
7329
|
+
}
|
|
7330
|
+
const record = raw;
|
|
7331
|
+
const contractsRaw = record["initial_contracts"];
|
|
7332
|
+
if (!Array.isArray(contractsRaw)) {
|
|
7333
|
+
throw createError("RPC", {
|
|
7334
|
+
resource: "zksrpc",
|
|
7335
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7336
|
+
message: "Malformed genesis response: initial_contracts must be an array.",
|
|
7337
|
+
context: { valueType: typeof contractsRaw }
|
|
7338
|
+
});
|
|
7339
|
+
}
|
|
7340
|
+
const genesisRoot = ensureHex(record["genesis_root"], "genesis_root", {});
|
|
7341
|
+
const initialContracts = contractsRaw.map(
|
|
7342
|
+
(entry, index) => normalizeContractTuple(entry, index)
|
|
7343
|
+
);
|
|
7344
|
+
const additionalStorage = normalizeAdditionalStorage(record["additional_storage"], record);
|
|
7345
|
+
return {
|
|
7346
|
+
initialContracts,
|
|
7347
|
+
additionalStorage,
|
|
7348
|
+
genesisRoot
|
|
7349
|
+
};
|
|
7350
|
+
} catch (e) {
|
|
7351
|
+
if (isZKsyncError(e)) throw e;
|
|
7352
|
+
throw createError("RPC", {
|
|
7353
|
+
resource: "zksrpc",
|
|
7354
|
+
operation: "zksrpc.normalizeGenesis",
|
|
7355
|
+
message: "Failed to normalize genesis response.",
|
|
7356
|
+
context: { receivedType: typeof raw },
|
|
7357
|
+
cause: shapeCause(e)
|
|
7358
|
+
});
|
|
7359
|
+
}
|
|
7360
|
+
}
|
|
7361
|
+
function normalizeBlockMetadata(raw) {
|
|
7362
|
+
try {
|
|
7363
|
+
if (!raw || typeof raw !== "object") {
|
|
7364
|
+
throw createError("RPC", {
|
|
7365
|
+
resource: "zksrpc",
|
|
7366
|
+
operation: "zksrpc.normalizeBlockMetadata",
|
|
7367
|
+
message: "Malformed block metadata response: expected object.",
|
|
7368
|
+
context: { receivedType: typeof raw }
|
|
7369
|
+
});
|
|
7370
|
+
}
|
|
7371
|
+
const record = raw;
|
|
7372
|
+
const pubdataPricePerByte = ensureBigInt(
|
|
7373
|
+
record["pubdata_price_per_byte"] ?? record["pubdataPricePerByte"],
|
|
7374
|
+
"pubdata_price_per_byte",
|
|
7375
|
+
{
|
|
7376
|
+
operation: "zksrpc.normalizeBlockMetadata",
|
|
7377
|
+
messagePrefix: "Malformed block metadata response"
|
|
7378
|
+
}
|
|
7379
|
+
);
|
|
7380
|
+
const nativePrice = ensureBigInt(
|
|
7381
|
+
record["native_price"] ?? record["nativePrice"],
|
|
7382
|
+
"native_price",
|
|
7383
|
+
{
|
|
7384
|
+
operation: "zksrpc.normalizeBlockMetadata",
|
|
7385
|
+
messagePrefix: "Malformed block metadata response"
|
|
7386
|
+
}
|
|
7387
|
+
);
|
|
7388
|
+
const executionVersion = ensureNumber(
|
|
7389
|
+
record["execution_version"] ?? record["executionVersion"],
|
|
7390
|
+
"execution_version",
|
|
7391
|
+
{
|
|
7392
|
+
operation: "zksrpc.normalizeBlockMetadata",
|
|
7393
|
+
messagePrefix: "Malformed block metadata response"
|
|
7394
|
+
}
|
|
7395
|
+
);
|
|
7396
|
+
return {
|
|
7397
|
+
pubdataPricePerByte,
|
|
7398
|
+
nativePrice,
|
|
7399
|
+
executionVersion
|
|
7400
|
+
};
|
|
7401
|
+
} catch (e) {
|
|
7402
|
+
if (isZKsyncError(e)) throw e;
|
|
7403
|
+
throw createError("RPC", {
|
|
7404
|
+
resource: "zksrpc",
|
|
7405
|
+
operation: "zksrpc.normalizeBlockMetadata",
|
|
7406
|
+
message: "Failed to normalize block metadata response.",
|
|
7407
|
+
context: { receivedType: typeof raw },
|
|
7408
|
+
cause: shapeCause(e)
|
|
7409
|
+
});
|
|
7410
|
+
}
|
|
7411
|
+
}
|
|
7412
|
+
function createZksRpc(transport) {
|
|
7413
|
+
return {
|
|
7414
|
+
// Fetches the Bridgehub contract address.
|
|
7415
|
+
async getBridgehubAddress() {
|
|
7416
|
+
return withRpcOp(
|
|
7417
|
+
"zksrpc.getBridgehubAddress",
|
|
7418
|
+
"Failed to fetch Bridgehub address.",
|
|
7419
|
+
{},
|
|
7420
|
+
async () => {
|
|
7421
|
+
const addrRaw = await transport(METHODS.getBridgehub, []);
|
|
7422
|
+
if (typeof addrRaw !== "string" || !addrRaw.startsWith("0x")) {
|
|
7423
|
+
throw createError("RPC", {
|
|
7424
|
+
resource: "zksrpc",
|
|
7425
|
+
operation: "zksrpc.getBridgehubAddress",
|
|
7426
|
+
message: "Unexpected Bridgehub address response.",
|
|
7427
|
+
context: { valueType: typeof addrRaw }
|
|
7428
|
+
});
|
|
7429
|
+
}
|
|
7430
|
+
return addrRaw;
|
|
7431
|
+
}
|
|
7432
|
+
);
|
|
7433
|
+
},
|
|
7434
|
+
// Fetches the Bytecode Supplier contract address.
|
|
7435
|
+
async getBytecodeSupplierAddress() {
|
|
7436
|
+
return withRpcOp(
|
|
7437
|
+
"zksrpc.getBytecodeSupplierAddress",
|
|
7438
|
+
"Failed to fetch Bytecode Supplier address.",
|
|
7439
|
+
{},
|
|
7440
|
+
async () => {
|
|
7441
|
+
const addrRaw = await transport(METHODS.getBytecodeSupplier, []);
|
|
7442
|
+
if (typeof addrRaw !== "string" || !addrRaw.startsWith("0x")) {
|
|
7443
|
+
throw createError("RPC", {
|
|
7444
|
+
resource: "zksrpc",
|
|
7445
|
+
operation: "zksrpc.getBytecodeSupplierAddress",
|
|
7446
|
+
message: "Unexpected Bytecode Supplier address response.",
|
|
7447
|
+
context: { valueType: typeof addrRaw }
|
|
7448
|
+
});
|
|
7449
|
+
}
|
|
7450
|
+
return addrRaw;
|
|
7451
|
+
}
|
|
7452
|
+
);
|
|
7453
|
+
},
|
|
7454
|
+
// Fetches a proof for an L2→L1 log emitted in the given transaction.
|
|
7455
|
+
async getL2ToL1LogProof(txHash, index, proofTarget) {
|
|
7456
|
+
return withRpcOp(
|
|
7457
|
+
"zksrpc.getL2ToL1LogProof",
|
|
7458
|
+
"Failed to fetch L2\u2192L1 log proof.",
|
|
7459
|
+
{ txHash, index, proofTarget },
|
|
7460
|
+
async () => {
|
|
7461
|
+
const params = [txHash, index];
|
|
7462
|
+
if (proofTarget != void 0) params.push(proofTarget);
|
|
7463
|
+
const proof = await transport(METHODS.getL2ToL1LogProof, params);
|
|
7464
|
+
if (!proof) {
|
|
7465
|
+
throw createError("STATE", {
|
|
7466
|
+
resource: "zksrpc",
|
|
7467
|
+
operation: "zksrpc.getL2ToL1LogProof",
|
|
7468
|
+
message: "Proof not yet available. Please try again later.",
|
|
7469
|
+
context: { txHash, index }
|
|
7470
|
+
});
|
|
7471
|
+
}
|
|
7472
|
+
return normalizeProof(proof);
|
|
7473
|
+
}
|
|
7474
|
+
);
|
|
7475
|
+
},
|
|
7476
|
+
// Fetches the transaction receipt, including the `l2ToL1Logs` field.
|
|
7477
|
+
async getReceiptWithL2ToL1(txHash) {
|
|
7478
|
+
return withRpcOp(
|
|
7479
|
+
"zksrpc.getReceiptWithL2ToL1",
|
|
7480
|
+
"Failed to fetch transaction receipt.",
|
|
7481
|
+
{ txHash },
|
|
7482
|
+
async () => {
|
|
7483
|
+
const rcptRaw = await transport(METHODS.getReceipt, [txHash]);
|
|
7484
|
+
if (!rcptRaw) return null;
|
|
7485
|
+
const rcptObj = rcptRaw;
|
|
7486
|
+
const logs = Array.isArray(rcptObj["l2ToL1Logs"]) ? rcptObj["l2ToL1Logs"] : [];
|
|
7487
|
+
rcptObj["l2ToL1Logs"] = logs;
|
|
7488
|
+
return rcptObj;
|
|
7489
|
+
}
|
|
7490
|
+
);
|
|
7491
|
+
},
|
|
7492
|
+
// Fetches block metadata for the given block number.
|
|
7493
|
+
async getBlockMetadataByNumber(blockNumber) {
|
|
7494
|
+
return withRpcOp(
|
|
7495
|
+
"zksrpc.getBlockMetadataByNumber",
|
|
7496
|
+
"Failed to fetch block metadata.",
|
|
7497
|
+
{ blockNumber },
|
|
7498
|
+
async () => {
|
|
7499
|
+
const raw = await transport(METHODS.getBlockMetadataByNumber, [blockNumber]);
|
|
7500
|
+
if (raw == null) return null;
|
|
7501
|
+
return normalizeBlockMetadata(raw);
|
|
7502
|
+
}
|
|
7503
|
+
);
|
|
7504
|
+
},
|
|
7505
|
+
// Fetches the genesis configuration returned by `zks_getGenesis`.
|
|
7506
|
+
async getGenesis() {
|
|
7507
|
+
return withRpcOp(
|
|
7508
|
+
"zksrpc.getGenesis",
|
|
7509
|
+
"Failed to fetch genesis configuration.",
|
|
7510
|
+
{},
|
|
7511
|
+
async () => {
|
|
7512
|
+
const genesisRaw = await transport(METHODS.getGenesis, []);
|
|
7513
|
+
return normalizeGenesis(genesisRaw);
|
|
7514
|
+
}
|
|
7515
|
+
);
|
|
7516
|
+
}
|
|
7517
|
+
};
|
|
7518
|
+
}
|
|
7519
|
+
|
|
7520
|
+
export { IBaseToken_default, IBridgehub_default, IERC20_default, IERC7786Attributes_default, IInteropCenter_default, IInteropErrors_default, IInteropHandler_default, IInteropRootStorage_default, IL1AssetRouter_default, IL1ContractErrors_default, IL1Nullifier_default, IL2AssetRouter_default, L1NativeTokenVault_default, L2MessageVerification_default, L2NativeTokenVault_default, Mailbox_default, OP_CLIENT, OP_DEPOSITS, OP_INTEROP, OP_WITHDRAWALS, abi_exports, assertNever, createError, createZksRpc, factory_exports, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isBigint, isETH, isHash, isHash66, isHash66Array, isHashArray, isNumber, isReceiptNotFound, isZKsyncError, normalizeAddrEq, normalizeL1Token, shapeCause, sleep, zks_exports };
|
package/dist/core/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { pickDepositRoute } from '../chunk-
|
|
1
|
+
export { pickDepositRoute } from '../chunk-TYYUG5GA.js';
|
|
2
2
|
export { findL1MessageSentLog, isL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from '../chunk-3HHUZXSV.js';
|
|
3
3
|
export { makeTransportFromEthers, makeTransportFromViem } from '../chunk-BWKWWLY4.js';
|
|
4
|
-
export { zks_exports as zksRpc } from '../chunk-
|
|
5
|
-
export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, normalizeAddrEq, normalizeL1Token } from '../chunk-JY62QO3W.js';
|
|
4
|
+
export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, normalizeAddrEq, normalizeL1Token, zks_exports as zksRpc } from '../chunk-UEKFQAOS.js';
|
|
6
5
|
export { ETH_ADDRESS, FORMAL_ETH_ADDRESS, L1_MESSENGER_ADDRESS, L1_SOPH_TOKEN_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS } from '../chunk-MT4X5FEO.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEraVmChain(chainIdL2: bigint): boolean;
|
|
@@ -10,6 +10,13 @@ export type GasQuote = {
|
|
|
10
10
|
gasPerPubdata?: bigint;
|
|
11
11
|
maxCost: bigint;
|
|
12
12
|
};
|
|
13
|
+
export declare function applyGasBuffer(gasLimit: bigint, bufferPct?: bigint): bigint;
|
|
14
|
+
export declare function resolveCreateDepositL1GasLimit(input: {
|
|
15
|
+
chainIdL2: bigint;
|
|
16
|
+
stepKey: string;
|
|
17
|
+
preparedGasLimit?: bigint;
|
|
18
|
+
estimatedGasLimit?: bigint;
|
|
19
|
+
}): bigint | undefined;
|
|
13
20
|
export type QuoteL1GasInput = {
|
|
14
21
|
estimator: GasEstimator;
|
|
15
22
|
tx: CoreTransactionRequest;
|
|
@@ -194,6 +194,7 @@ export declare const OP_INTEROP: {
|
|
|
194
194
|
readonly tryWait: "interop.tryWait";
|
|
195
195
|
readonly finalize: "interop.finalize";
|
|
196
196
|
readonly tryFinalize: "interop.tryFinalize";
|
|
197
|
+
readonly verify: "interop.verify";
|
|
197
198
|
readonly context: {
|
|
198
199
|
readonly chainTypeManager: "interop.chainTypeManager";
|
|
199
200
|
readonly protocolVersion: "interop.protocolVersion";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type Address = `0x${string}`;
|
|
2
2
|
export type Hex = `0x${string}`;
|
|
3
3
|
export type Hash = Hex;
|
|
4
|
+
/** Semver protocol version tuple: [patch, minor, major] as returned by getSemverProtocolVersion(). */
|
|
5
|
+
export type ProtocolVersion = readonly [number, number, number];
|
|
4
6
|
export declare const ZERO_HASH: Hash;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { pickDepositRoute } from './chunk-
|
|
1
|
+
export { pickDepositRoute } from './chunk-TYYUG5GA.js';
|
|
2
2
|
export { findL1MessageSentLog, isL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-3HHUZXSV.js';
|
|
3
3
|
export { makeTransportFromEthers, makeTransportFromViem } from './chunk-BWKWWLY4.js';
|
|
4
|
-
export { zks_exports as zksRpc } from './chunk-
|
|
5
|
-
export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, normalizeAddrEq, normalizeL1Token } from './chunk-JY62QO3W.js';
|
|
4
|
+
export { abi_exports as abi, factory_exports as errors, formatEnvelopePretty, hexEq, isAddress, isAddressEq, isETH, isHash, isHash66, isHash66Array, isHashArray, normalizeAddrEq, normalizeL1Token, zks_exports as zksRpc } from './chunk-UEKFQAOS.js';
|
|
6
5
|
export { constants_exports as constants } from './chunk-MT4X5FEO.js';
|