forked from tornado-packages/tornado-core
Validate fetched events from relayer
This commit is contained in:
parent
61266bdb6e
commit
62a7d9a6aa
0
dist/events/schema.d.ts
vendored
Normal file
0
dist/events/schema.d.ts
vendored
Normal file
373
dist/index.js
vendored
373
dist/index.js
vendored
@ -145,27 +145,27 @@ function digest(bytes, algo = "SHA-384") {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var __defProp$5 = Object.defineProperty;
|
var __defProp$7 = Object.defineProperty;
|
||||||
var __defProps$4 = Object.defineProperties;
|
var __defProps$6 = Object.defineProperties;
|
||||||
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
||||||
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
||||||
var __getProtoOf$2 = Object.getPrototypeOf;
|
var __getProtoOf$2 = Object.getPrototypeOf;
|
||||||
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
||||||
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
||||||
var __reflectGet$2 = Reflect.get;
|
var __reflectGet$2 = Reflect.get;
|
||||||
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
var __spreadValues$5 = (a, b) => {
|
var __spreadValues$7 = (a, b) => {
|
||||||
for (var prop in b || (b = {}))
|
for (var prop in b || (b = {}))
|
||||||
if (__hasOwnProp$5.call(b, prop))
|
if (__hasOwnProp$7.call(b, prop))
|
||||||
__defNormalProp$5(a, prop, b[prop]);
|
__defNormalProp$7(a, prop, b[prop]);
|
||||||
if (__getOwnPropSymbols$5)
|
if (__getOwnPropSymbols$7)
|
||||||
for (var prop of __getOwnPropSymbols$5(b)) {
|
for (var prop of __getOwnPropSymbols$7(b)) {
|
||||||
if (__propIsEnum$5.call(b, prop))
|
if (__propIsEnum$7.call(b, prop))
|
||||||
__defNormalProp$5(a, prop, b[prop]);
|
__defNormalProp$7(a, prop, b[prop]);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
||||||
var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
|
var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
|
||||||
var __async$d = (__this, __arguments, generator) => {
|
var __async$d = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -317,7 +317,7 @@ const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$d(void 0, nu
|
|||||||
controller.abort();
|
controller.abort();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const init = __spreadProps$4(__spreadValues$5({}, options), {
|
const init = __spreadProps$6(__spreadValues$7({}, options), {
|
||||||
method: req.method || "POST",
|
method: req.method || "POST",
|
||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
body: req.body || void 0,
|
body: req.body || void 0,
|
||||||
@ -683,25 +683,25 @@ const GET_GOVERNANCE_APY = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
var __defProp$4 = Object.defineProperty;
|
var __defProp$6 = Object.defineProperty;
|
||||||
var __defProps$3 = Object.defineProperties;
|
var __defProps$5 = Object.defineProperties;
|
||||||
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
||||||
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
||||||
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
||||||
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
||||||
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
var __spreadValues$4 = (a, b) => {
|
var __spreadValues$6 = (a, b) => {
|
||||||
for (var prop in b || (b = {}))
|
for (var prop in b || (b = {}))
|
||||||
if (__hasOwnProp$4.call(b, prop))
|
if (__hasOwnProp$6.call(b, prop))
|
||||||
__defNormalProp$4(a, prop, b[prop]);
|
__defNormalProp$6(a, prop, b[prop]);
|
||||||
if (__getOwnPropSymbols$4)
|
if (__getOwnPropSymbols$6)
|
||||||
for (var prop of __getOwnPropSymbols$4(b)) {
|
for (var prop of __getOwnPropSymbols$6(b)) {
|
||||||
if (__propIsEnum$4.call(b, prop))
|
if (__propIsEnum$6.call(b, prop))
|
||||||
__defNormalProp$4(a, prop, b[prop]);
|
__defNormalProp$6(a, prop, b[prop]);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
||||||
var __async$c = (__this, __arguments, generator) => {
|
var __async$c = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
@ -734,7 +734,7 @@ function queryGraph(_0) {
|
|||||||
}) {
|
}) {
|
||||||
var _a;
|
var _a;
|
||||||
const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`;
|
const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`;
|
||||||
const { data, errors } = yield fetchData(graphUrl, __spreadProps$3(__spreadValues$4({}, fetchDataOptions2), {
|
const { data, errors } = yield fetchData(graphUrl, __spreadProps$5(__spreadValues$6({}, fetchDataOptions2), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -1722,19 +1722,19 @@ class BatchEventsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var __defProp$3 = Object.defineProperty;
|
var __defProp$5 = Object.defineProperty;
|
||||||
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
||||||
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
||||||
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
||||||
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
var __spreadValues$3 = (a, b) => {
|
var __spreadValues$5 = (a, b) => {
|
||||||
for (var prop in b || (b = {}))
|
for (var prop in b || (b = {}))
|
||||||
if (__hasOwnProp$3.call(b, prop))
|
if (__hasOwnProp$5.call(b, prop))
|
||||||
__defNormalProp$3(a, prop, b[prop]);
|
__defNormalProp$5(a, prop, b[prop]);
|
||||||
if (__getOwnPropSymbols$3)
|
if (__getOwnPropSymbols$5)
|
||||||
for (var prop of __getOwnPropSymbols$3(b)) {
|
for (var prop of __getOwnPropSymbols$5(b)) {
|
||||||
if (__propIsEnum$3.call(b, prop))
|
if (__propIsEnum$5.call(b, prop))
|
||||||
__defNormalProp$3(a, prop, b[prop]);
|
__defNormalProp$5(a, prop, b[prop]);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
@ -2318,10 +2318,10 @@ function addNetwork(newConfig) {
|
|||||||
enabledChains.push(
|
enabledChains.push(
|
||||||
...Object.keys(newConfig).map((netId) => Number(netId)).filter((netId) => !enabledChains.includes(netId))
|
...Object.keys(newConfig).map((netId) => Number(netId)).filter((netId) => !enabledChains.includes(netId))
|
||||||
);
|
);
|
||||||
exports.customConfig = __spreadValues$3(__spreadValues$3({}, exports.customConfig), newConfig);
|
exports.customConfig = __spreadValues$5(__spreadValues$5({}, exports.customConfig), newConfig);
|
||||||
}
|
}
|
||||||
function getNetworkConfig() {
|
function getNetworkConfig() {
|
||||||
const allConfig = __spreadValues$3(__spreadValues$3({}, defaultConfig), exports.customConfig);
|
const allConfig = __spreadValues$5(__spreadValues$5({}, defaultConfig), exports.customConfig);
|
||||||
return enabledChains.reduce((acc, curr) => {
|
return enabledChains.reduce((acc, curr) => {
|
||||||
acc[curr] = allConfig[curr];
|
acc[curr] = allConfig[curr];
|
||||||
return acc;
|
return acc;
|
||||||
@ -2373,12 +2373,244 @@ function getRelayerEnsSubdomains() {
|
|||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
const addressType = { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" };
|
const ajv = new Ajv({ allErrors: true });
|
||||||
const bnType = { type: "string", BN: true };
|
ajv.addKeyword({
|
||||||
|
keyword: "BN",
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema, data) => {
|
||||||
|
try {
|
||||||
|
BigInt(data);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true
|
||||||
|
});
|
||||||
|
ajv.addKeyword({
|
||||||
|
keyword: "isAddress",
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema, data) => {
|
||||||
|
try {
|
||||||
|
return ethers.isAddress(data);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var __defProp$4 = Object.defineProperty;
|
||||||
|
var __defProps$4 = Object.defineProperties;
|
||||||
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
||||||
|
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
||||||
|
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
||||||
|
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
||||||
|
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
|
var __spreadValues$4 = (a, b) => {
|
||||||
|
for (var prop in b || (b = {}))
|
||||||
|
if (__hasOwnProp$4.call(b, prop))
|
||||||
|
__defNormalProp$4(a, prop, b[prop]);
|
||||||
|
if (__getOwnPropSymbols$4)
|
||||||
|
for (var prop of __getOwnPropSymbols$4(b)) {
|
||||||
|
if (__propIsEnum$4.call(b, prop))
|
||||||
|
__defNormalProp$4(a, prop, b[prop]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
||||||
|
const addressSchemaType = {
|
||||||
|
type: "string",
|
||||||
|
pattern: "^0x[a-fA-F0-9]{40}$",
|
||||||
|
isAddress: true
|
||||||
|
};
|
||||||
|
const bnSchemaType = { type: "string", BN: true };
|
||||||
|
const proofSchemaType = { type: "string", pattern: "^0x[a-fA-F0-9]{512}$" };
|
||||||
|
const bytes32SchemaType = { type: "string", pattern: "^0x[a-fA-F0-9]{64}$" };
|
||||||
|
const bytes32BNSchemaType = __spreadProps$4(__spreadValues$4({}, bytes32SchemaType), { BN: true });
|
||||||
|
|
||||||
|
var __defProp$3 = Object.defineProperty;
|
||||||
|
var __defProps$3 = Object.defineProperties;
|
||||||
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
||||||
|
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
||||||
|
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
||||||
|
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
||||||
|
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
|
var __spreadValues$3 = (a, b) => {
|
||||||
|
for (var prop in b || (b = {}))
|
||||||
|
if (__hasOwnProp$3.call(b, prop))
|
||||||
|
__defNormalProp$3(a, prop, b[prop]);
|
||||||
|
if (__getOwnPropSymbols$3)
|
||||||
|
for (var prop of __getOwnPropSymbols$3(b)) {
|
||||||
|
if (__propIsEnum$3.call(b, prop))
|
||||||
|
__defNormalProp$3(a, prop, b[prop]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
||||||
|
const baseEventsSchemaProperty = {
|
||||||
|
blockNumber: {
|
||||||
|
type: "number"
|
||||||
|
},
|
||||||
|
logIndex: {
|
||||||
|
type: "number"
|
||||||
|
},
|
||||||
|
transactionHash: bytes32SchemaType
|
||||||
|
};
|
||||||
|
const baseEventsSchemaRequired = Object.keys(baseEventsSchemaProperty);
|
||||||
|
const governanceEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
id: { type: "number" },
|
||||||
|
proposer: addressSchemaType,
|
||||||
|
target: addressSchemaType,
|
||||||
|
startTime: { type: "number" },
|
||||||
|
endTime: { type: "number" },
|
||||||
|
description: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [
|
||||||
|
...baseEventsSchemaRequired,
|
||||||
|
"event",
|
||||||
|
"id",
|
||||||
|
"proposer",
|
||||||
|
"target",
|
||||||
|
"startTime",
|
||||||
|
"endTime",
|
||||||
|
"description"
|
||||||
|
],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
proposalId: { type: "number" },
|
||||||
|
voter: addressSchemaType,
|
||||||
|
support: { type: "boolean" },
|
||||||
|
votes: { type: "string" },
|
||||||
|
from: addressSchemaType,
|
||||||
|
input: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "event", "proposalId", "voter", "support", "votes", "from", "input"],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateTo: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "account", "delegateTo"],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateFrom: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "account", "delegateFrom"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const registeredEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
ensName: { type: "string" },
|
||||||
|
relayerAddress: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "ensName", "relayerAddress"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const depositsEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
commitment: bytes32SchemaType,
|
||||||
|
leafIndex: { type: "number" },
|
||||||
|
timestamp: { type: "number" },
|
||||||
|
from: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "commitment", "leafIndex", "timestamp", "from"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const withdrawalsEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
nullifierHash: bytes32SchemaType,
|
||||||
|
to: addressSchemaType,
|
||||||
|
fee: bnSchemaType,
|
||||||
|
timestamp: { type: "number" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "nullifierHash", "to", "fee", "timestamp"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const echoEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
address: addressSchemaType,
|
||||||
|
encryptedAccount: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "address", "encryptedAccount"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const encryptedNotesSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
encryptedNote: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "encryptedNote"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function getEventsSchemaValidator(type) {
|
||||||
|
if (type === DEPOSIT) {
|
||||||
|
return ajv.compile(depositsEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === WITHDRAWAL) {
|
||||||
|
return ajv.compile(withdrawalsEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "governance") {
|
||||||
|
return ajv.compile(governanceEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "registered") {
|
||||||
|
return ajv.compile(registeredEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "echo") {
|
||||||
|
return ajv.compile(echoEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "encrypted_notes") {
|
||||||
|
return ajv.compile(encryptedNotesSchema);
|
||||||
|
}
|
||||||
|
throw new Error("Unsupported event type for schema validation");
|
||||||
|
}
|
||||||
|
|
||||||
const statusSchema = {
|
const statusSchema = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
rewardAccount: addressType,
|
rewardAccount: addressSchemaType,
|
||||||
gasPrices: {
|
gasPrices: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
@ -2390,7 +2622,7 @@ const statusSchema = {
|
|||||||
netId: { type: "integer" },
|
netId: { type: "integer" },
|
||||||
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
|
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
|
||||||
latestBlock: { type: "number" },
|
latestBlock: { type: "number" },
|
||||||
latestBalance: { type: "string", BN: true },
|
latestBalance: bnSchemaType,
|
||||||
version: { type: "string" },
|
version: { type: "string" },
|
||||||
health: {
|
health: {
|
||||||
type: "object",
|
type: "object",
|
||||||
@ -2427,7 +2659,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
instanceAddress: {
|
instanceAddress: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: amounts.reduce((acc2, cur) => {
|
properties: amounts.reduce((acc2, cur) => {
|
||||||
acc2[cur] = addressType;
|
acc2[cur] = addressSchemaType;
|
||||||
return acc2;
|
return acc2;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: amounts.filter((amount) => !optionalInstances.includes(amount))
|
required: amounts.filter((amount) => !optionalInstances.includes(amount))
|
||||||
@ -2440,7 +2672,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
if (tokenAddress) {
|
if (tokenAddress) {
|
||||||
instanceProperties.properties.tokenAddress = addressType;
|
instanceProperties.properties.tokenAddress = addressSchemaType;
|
||||||
}
|
}
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
instanceProperties.properties.symbol = { enum: [symbol] };
|
instanceProperties.properties.symbol = { enum: [symbol] };
|
||||||
@ -2471,7 +2703,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
const ethPrices = {
|
const ethPrices = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: _tokens.reduce((acc, token) => {
|
properties: _tokens.reduce((acc, token) => {
|
||||||
acc[token] = bnType;
|
acc[token] = bnSchemaType;
|
||||||
return acc;
|
return acc;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: _tokens
|
required: _tokens
|
||||||
@ -2505,21 +2737,6 @@ const jobsSchema = {
|
|||||||
required: ["id", "status"]
|
required: ["id", "status"]
|
||||||
};
|
};
|
||||||
|
|
||||||
const ajv = new Ajv({ allErrors: true });
|
|
||||||
ajv.addKeyword({
|
|
||||||
keyword: "BN",
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
validate: (schema, data) => {
|
|
||||||
try {
|
|
||||||
BigInt(data);
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errors: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var __defProp$2 = Object.defineProperty;
|
var __defProp$2 = Object.defineProperty;
|
||||||
var __defProps$2 = Object.defineProperties;
|
var __defProps$2 = Object.defineProperties;
|
||||||
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
||||||
@ -3018,7 +3235,8 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
const lastBlock = newEvents.lastBlock || ((_a = allEvents[allEvents.length - 1]) == null ? void 0 : _a.blockNumber);
|
const lastBlock = newEvents.lastBlock || ((_a = allEvents[allEvents.length - 1]) == null ? void 0 : _a.blockNumber);
|
||||||
this.validateEvents({ events: allEvents, lastBlock });
|
this.validateEvents({ events: allEvents, lastBlock });
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
const saveCache = Boolean(savedEvents.fromCache && savedEvents.events.length);
|
||||||
|
if (saveCache || newEvents.events.length) {
|
||||||
yield this.saveEvents({ events: allEvents, lastBlock });
|
yield this.saveEvents({ events: allEvents, lastBlock });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -6848,6 +7066,7 @@ class TovarishClient extends RelayerClient {
|
|||||||
}) {
|
}) {
|
||||||
var _a;
|
var _a;
|
||||||
const url = `${(_a = this.selectedRelayer) == null ? void 0 : _a.url}events`;
|
const url = `${(_a = this.selectedRelayer) == null ? void 0 : _a.url}events`;
|
||||||
|
const schemaValidator = getEventsSchemaValidator(type);
|
||||||
try {
|
try {
|
||||||
const events = [];
|
const events = [];
|
||||||
let lastSyncBlock = fromBlock;
|
let lastSyncBlock = fromBlock;
|
||||||
@ -6865,6 +7084,10 @@ class TovarishClient extends RelayerClient {
|
|||||||
recent
|
recent
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
if (!schemaValidator(fetchedEvents)) {
|
||||||
|
const errMsg = `Schema validation failed for ${type} events`;
|
||||||
|
throw new Error(errMsg);
|
||||||
|
}
|
||||||
lastSyncBlock = currentBlock;
|
lastSyncBlock = currentBlock;
|
||||||
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
||||||
break;
|
break;
|
||||||
@ -7009,12 +7232,16 @@ exports.TovarishClient = TovarishClient;
|
|||||||
exports.WITHDRAWAL = WITHDRAWAL;
|
exports.WITHDRAWAL = WITHDRAWAL;
|
||||||
exports._META = _META;
|
exports._META = _META;
|
||||||
exports.addNetwork = addNetwork;
|
exports.addNetwork = addNetwork;
|
||||||
|
exports.addressSchemaType = addressSchemaType;
|
||||||
exports.ajv = ajv;
|
exports.ajv = ajv;
|
||||||
exports.base64ToBytes = base64ToBytes;
|
exports.base64ToBytes = base64ToBytes;
|
||||||
exports.bigIntReplacer = bigIntReplacer;
|
exports.bigIntReplacer = bigIntReplacer;
|
||||||
|
exports.bnSchemaType = bnSchemaType;
|
||||||
exports.bnToBytes = bnToBytes;
|
exports.bnToBytes = bnToBytes;
|
||||||
exports.buffPedersenHash = buffPedersenHash;
|
exports.buffPedersenHash = buffPedersenHash;
|
||||||
exports.bufferToBytes = bufferToBytes;
|
exports.bufferToBytes = bufferToBytes;
|
||||||
|
exports.bytes32BNSchemaType = bytes32BNSchemaType;
|
||||||
|
exports.bytes32SchemaType = bytes32SchemaType;
|
||||||
exports.bytesToBN = bytesToBN;
|
exports.bytesToBN = bytesToBN;
|
||||||
exports.bytesToBase64 = bytesToBase64;
|
exports.bytesToBase64 = bytesToBase64;
|
||||||
exports.bytesToHex = bytesToHex;
|
exports.bytesToHex = bytesToHex;
|
||||||
@ -7027,8 +7254,11 @@ exports.createDeposit = createDeposit;
|
|||||||
exports.crypto = crypto;
|
exports.crypto = crypto;
|
||||||
exports.defaultConfig = defaultConfig;
|
exports.defaultConfig = defaultConfig;
|
||||||
exports.defaultUserAgent = defaultUserAgent;
|
exports.defaultUserAgent = defaultUserAgent;
|
||||||
|
exports.depositsEventsSchema = depositsEventsSchema;
|
||||||
exports.digest = digest;
|
exports.digest = digest;
|
||||||
|
exports.echoEventsSchema = echoEventsSchema;
|
||||||
exports.enabledChains = enabledChains;
|
exports.enabledChains = enabledChains;
|
||||||
|
exports.encryptedNotesSchema = encryptedNotesSchema;
|
||||||
exports.factories = index;
|
exports.factories = index;
|
||||||
exports.fetch = fetch;
|
exports.fetch = fetch;
|
||||||
exports.fetchData = fetchData;
|
exports.fetchData = fetchData;
|
||||||
@ -7044,6 +7274,7 @@ exports.getAllWithdrawals = getAllWithdrawals;
|
|||||||
exports.getConfig = getConfig;
|
exports.getConfig = getConfig;
|
||||||
exports.getDeposits = getDeposits;
|
exports.getDeposits = getDeposits;
|
||||||
exports.getEncryptedNotes = getEncryptedNotes;
|
exports.getEncryptedNotes = getEncryptedNotes;
|
||||||
|
exports.getEventsSchemaValidator = getEventsSchemaValidator;
|
||||||
exports.getGovernanceEvents = getGovernanceEvents;
|
exports.getGovernanceEvents = getGovernanceEvents;
|
||||||
exports.getGraphEchoEvents = getGraphEchoEvents;
|
exports.getGraphEchoEvents = getGraphEchoEvents;
|
||||||
exports.getHttpAgent = getHttpAgent;
|
exports.getHttpAgent = getHttpAgent;
|
||||||
@ -7062,6 +7293,7 @@ exports.getTokenBalances = getTokenBalances;
|
|||||||
exports.getTovarishNetworks = getTovarishNetworks;
|
exports.getTovarishNetworks = getTovarishNetworks;
|
||||||
exports.getWeightRandom = getWeightRandom;
|
exports.getWeightRandom = getWeightRandom;
|
||||||
exports.getWithdrawals = getWithdrawals;
|
exports.getWithdrawals = getWithdrawals;
|
||||||
|
exports.governanceEventsSchema = governanceEventsSchema;
|
||||||
exports.hexToBytes = hexToBytes;
|
exports.hexToBytes = hexToBytes;
|
||||||
exports.initGroth16 = initGroth16;
|
exports.initGroth16 = initGroth16;
|
||||||
exports.isNode = isNode;
|
exports.isNode = isNode;
|
||||||
@ -7074,11 +7306,14 @@ exports.packEncryptedMessage = packEncryptedMessage;
|
|||||||
exports.pedersen = pedersen;
|
exports.pedersen = pedersen;
|
||||||
exports.pickWeightedRandomRelayer = pickWeightedRandomRelayer;
|
exports.pickWeightedRandomRelayer = pickWeightedRandomRelayer;
|
||||||
exports.populateTransaction = populateTransaction;
|
exports.populateTransaction = populateTransaction;
|
||||||
|
exports.proofSchemaType = proofSchemaType;
|
||||||
exports.queryGraph = queryGraph;
|
exports.queryGraph = queryGraph;
|
||||||
exports.rBigInt = rBigInt;
|
exports.rBigInt = rBigInt;
|
||||||
|
exports.registeredEventsSchema = registeredEventsSchema;
|
||||||
exports.sleep = sleep;
|
exports.sleep = sleep;
|
||||||
exports.substring = substring;
|
exports.substring = substring;
|
||||||
exports.toFixedHex = toFixedHex;
|
exports.toFixedHex = toFixedHex;
|
||||||
exports.toFixedLength = toFixedLength;
|
exports.toFixedLength = toFixedLength;
|
||||||
exports.unpackEncryptedMessage = unpackEncryptedMessage;
|
exports.unpackEncryptedMessage = unpackEncryptedMessage;
|
||||||
exports.validateUrl = validateUrl;
|
exports.validateUrl = validateUrl;
|
||||||
|
exports.withdrawalsEventsSchema = withdrawalsEventsSchema;
|
||||||
|
365
dist/index.mjs
vendored
365
dist/index.mjs
vendored
@ -1,4 +1,4 @@
|
|||||||
import { FetchRequest, Network, EnsPlugin, GasCostPlugin, JsonRpcProvider, Wallet, HDNodeWallet, VoidSigner, JsonRpcSigner, BrowserProvider, getAddress, parseEther, namehash, formatEther, Interface, Contract, computeAddress, parseUnits, Transaction, ZeroAddress } from 'ethers';
|
import { FetchRequest, Network, EnsPlugin, GasCostPlugin, JsonRpcProvider, Wallet, HDNodeWallet, VoidSigner, JsonRpcSigner, BrowserProvider, getAddress, isAddress, parseEther, namehash, formatEther, Interface, Contract, computeAddress, parseUnits, Transaction, ZeroAddress } from 'ethers';
|
||||||
import crossFetch from 'cross-fetch';
|
import crossFetch from 'cross-fetch';
|
||||||
import { webcrypto } from 'crypto';
|
import { webcrypto } from 'crypto';
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
@ -124,27 +124,27 @@ function digest(bytes, algo = "SHA-384") {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var __defProp$5 = Object.defineProperty;
|
var __defProp$7 = Object.defineProperty;
|
||||||
var __defProps$4 = Object.defineProperties;
|
var __defProps$6 = Object.defineProperties;
|
||||||
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
||||||
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
||||||
var __getProtoOf$2 = Object.getPrototypeOf;
|
var __getProtoOf$2 = Object.getPrototypeOf;
|
||||||
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
||||||
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
||||||
var __reflectGet$2 = Reflect.get;
|
var __reflectGet$2 = Reflect.get;
|
||||||
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
var __spreadValues$5 = (a, b) => {
|
var __spreadValues$7 = (a, b) => {
|
||||||
for (var prop in b || (b = {}))
|
for (var prop in b || (b = {}))
|
||||||
if (__hasOwnProp$5.call(b, prop))
|
if (__hasOwnProp$7.call(b, prop))
|
||||||
__defNormalProp$5(a, prop, b[prop]);
|
__defNormalProp$7(a, prop, b[prop]);
|
||||||
if (__getOwnPropSymbols$5)
|
if (__getOwnPropSymbols$7)
|
||||||
for (var prop of __getOwnPropSymbols$5(b)) {
|
for (var prop of __getOwnPropSymbols$7(b)) {
|
||||||
if (__propIsEnum$5.call(b, prop))
|
if (__propIsEnum$7.call(b, prop))
|
||||||
__defNormalProp$5(a, prop, b[prop]);
|
__defNormalProp$7(a, prop, b[prop]);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
||||||
var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
|
var __superGet$2 = (cls, obj, key) => __reflectGet$2(__getProtoOf$2(cls), key, obj);
|
||||||
var __async$d = (__this, __arguments, generator) => {
|
var __async$d = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -296,7 +296,7 @@ const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$d(void 0, nu
|
|||||||
controller.abort();
|
controller.abort();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const init = __spreadProps$4(__spreadValues$5({}, options), {
|
const init = __spreadProps$6(__spreadValues$7({}, options), {
|
||||||
method: req.method || "POST",
|
method: req.method || "POST",
|
||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
body: req.body || void 0,
|
body: req.body || void 0,
|
||||||
@ -662,25 +662,25 @@ const GET_GOVERNANCE_APY = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
var __defProp$4 = Object.defineProperty;
|
var __defProp$6 = Object.defineProperty;
|
||||||
var __defProps$3 = Object.defineProperties;
|
var __defProps$5 = Object.defineProperties;
|
||||||
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
||||||
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
||||||
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
||||||
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
||||||
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
var __spreadValues$4 = (a, b) => {
|
var __spreadValues$6 = (a, b) => {
|
||||||
for (var prop in b || (b = {}))
|
for (var prop in b || (b = {}))
|
||||||
if (__hasOwnProp$4.call(b, prop))
|
if (__hasOwnProp$6.call(b, prop))
|
||||||
__defNormalProp$4(a, prop, b[prop]);
|
__defNormalProp$6(a, prop, b[prop]);
|
||||||
if (__getOwnPropSymbols$4)
|
if (__getOwnPropSymbols$6)
|
||||||
for (var prop of __getOwnPropSymbols$4(b)) {
|
for (var prop of __getOwnPropSymbols$6(b)) {
|
||||||
if (__propIsEnum$4.call(b, prop))
|
if (__propIsEnum$6.call(b, prop))
|
||||||
__defNormalProp$4(a, prop, b[prop]);
|
__defNormalProp$6(a, prop, b[prop]);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
||||||
var __async$c = (__this, __arguments, generator) => {
|
var __async$c = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
@ -713,7 +713,7 @@ function queryGraph(_0) {
|
|||||||
}) {
|
}) {
|
||||||
var _a;
|
var _a;
|
||||||
const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`;
|
const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`;
|
||||||
const { data, errors } = yield fetchData(graphUrl, __spreadProps$3(__spreadValues$4({}, fetchDataOptions2), {
|
const { data, errors } = yield fetchData(graphUrl, __spreadProps$5(__spreadValues$6({}, fetchDataOptions2), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
@ -1701,19 +1701,19 @@ class BatchEventsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var __defProp$3 = Object.defineProperty;
|
var __defProp$5 = Object.defineProperty;
|
||||||
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
||||||
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
||||||
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
||||||
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
var __spreadValues$3 = (a, b) => {
|
var __spreadValues$5 = (a, b) => {
|
||||||
for (var prop in b || (b = {}))
|
for (var prop in b || (b = {}))
|
||||||
if (__hasOwnProp$3.call(b, prop))
|
if (__hasOwnProp$5.call(b, prop))
|
||||||
__defNormalProp$3(a, prop, b[prop]);
|
__defNormalProp$5(a, prop, b[prop]);
|
||||||
if (__getOwnPropSymbols$3)
|
if (__getOwnPropSymbols$5)
|
||||||
for (var prop of __getOwnPropSymbols$3(b)) {
|
for (var prop of __getOwnPropSymbols$5(b)) {
|
||||||
if (__propIsEnum$3.call(b, prop))
|
if (__propIsEnum$5.call(b, prop))
|
||||||
__defNormalProp$3(a, prop, b[prop]);
|
__defNormalProp$5(a, prop, b[prop]);
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
@ -2297,10 +2297,10 @@ function addNetwork(newConfig) {
|
|||||||
enabledChains.push(
|
enabledChains.push(
|
||||||
...Object.keys(newConfig).map((netId) => Number(netId)).filter((netId) => !enabledChains.includes(netId))
|
...Object.keys(newConfig).map((netId) => Number(netId)).filter((netId) => !enabledChains.includes(netId))
|
||||||
);
|
);
|
||||||
customConfig = __spreadValues$3(__spreadValues$3({}, customConfig), newConfig);
|
customConfig = __spreadValues$5(__spreadValues$5({}, customConfig), newConfig);
|
||||||
}
|
}
|
||||||
function getNetworkConfig() {
|
function getNetworkConfig() {
|
||||||
const allConfig = __spreadValues$3(__spreadValues$3({}, defaultConfig), customConfig);
|
const allConfig = __spreadValues$5(__spreadValues$5({}, defaultConfig), customConfig);
|
||||||
return enabledChains.reduce((acc, curr) => {
|
return enabledChains.reduce((acc, curr) => {
|
||||||
acc[curr] = allConfig[curr];
|
acc[curr] = allConfig[curr];
|
||||||
return acc;
|
return acc;
|
||||||
@ -2352,12 +2352,244 @@ function getRelayerEnsSubdomains() {
|
|||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
const addressType = { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" };
|
const ajv = new Ajv({ allErrors: true });
|
||||||
const bnType = { type: "string", BN: true };
|
ajv.addKeyword({
|
||||||
|
keyword: "BN",
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema, data) => {
|
||||||
|
try {
|
||||||
|
BigInt(data);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true
|
||||||
|
});
|
||||||
|
ajv.addKeyword({
|
||||||
|
keyword: "isAddress",
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema, data) => {
|
||||||
|
try {
|
||||||
|
return isAddress(data);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var __defProp$4 = Object.defineProperty;
|
||||||
|
var __defProps$4 = Object.defineProperties;
|
||||||
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
||||||
|
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
||||||
|
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
||||||
|
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
||||||
|
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
|
var __spreadValues$4 = (a, b) => {
|
||||||
|
for (var prop in b || (b = {}))
|
||||||
|
if (__hasOwnProp$4.call(b, prop))
|
||||||
|
__defNormalProp$4(a, prop, b[prop]);
|
||||||
|
if (__getOwnPropSymbols$4)
|
||||||
|
for (var prop of __getOwnPropSymbols$4(b)) {
|
||||||
|
if (__propIsEnum$4.call(b, prop))
|
||||||
|
__defNormalProp$4(a, prop, b[prop]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
||||||
|
const addressSchemaType = {
|
||||||
|
type: "string",
|
||||||
|
pattern: "^0x[a-fA-F0-9]{40}$",
|
||||||
|
isAddress: true
|
||||||
|
};
|
||||||
|
const bnSchemaType = { type: "string", BN: true };
|
||||||
|
const proofSchemaType = { type: "string", pattern: "^0x[a-fA-F0-9]{512}$" };
|
||||||
|
const bytes32SchemaType = { type: "string", pattern: "^0x[a-fA-F0-9]{64}$" };
|
||||||
|
const bytes32BNSchemaType = __spreadProps$4(__spreadValues$4({}, bytes32SchemaType), { BN: true });
|
||||||
|
|
||||||
|
var __defProp$3 = Object.defineProperty;
|
||||||
|
var __defProps$3 = Object.defineProperties;
|
||||||
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
||||||
|
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
||||||
|
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
||||||
|
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
||||||
|
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
|
var __spreadValues$3 = (a, b) => {
|
||||||
|
for (var prop in b || (b = {}))
|
||||||
|
if (__hasOwnProp$3.call(b, prop))
|
||||||
|
__defNormalProp$3(a, prop, b[prop]);
|
||||||
|
if (__getOwnPropSymbols$3)
|
||||||
|
for (var prop of __getOwnPropSymbols$3(b)) {
|
||||||
|
if (__propIsEnum$3.call(b, prop))
|
||||||
|
__defNormalProp$3(a, prop, b[prop]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
||||||
|
const baseEventsSchemaProperty = {
|
||||||
|
blockNumber: {
|
||||||
|
type: "number"
|
||||||
|
},
|
||||||
|
logIndex: {
|
||||||
|
type: "number"
|
||||||
|
},
|
||||||
|
transactionHash: bytes32SchemaType
|
||||||
|
};
|
||||||
|
const baseEventsSchemaRequired = Object.keys(baseEventsSchemaProperty);
|
||||||
|
const governanceEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
id: { type: "number" },
|
||||||
|
proposer: addressSchemaType,
|
||||||
|
target: addressSchemaType,
|
||||||
|
startTime: { type: "number" },
|
||||||
|
endTime: { type: "number" },
|
||||||
|
description: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [
|
||||||
|
...baseEventsSchemaRequired,
|
||||||
|
"event",
|
||||||
|
"id",
|
||||||
|
"proposer",
|
||||||
|
"target",
|
||||||
|
"startTime",
|
||||||
|
"endTime",
|
||||||
|
"description"
|
||||||
|
],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
proposalId: { type: "number" },
|
||||||
|
voter: addressSchemaType,
|
||||||
|
support: { type: "boolean" },
|
||||||
|
votes: { type: "string" },
|
||||||
|
from: addressSchemaType,
|
||||||
|
input: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "event", "proposalId", "voter", "support", "votes", "from", "input"],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateTo: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "account", "delegateTo"],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateFrom: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "account", "delegateFrom"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const registeredEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
ensName: { type: "string" },
|
||||||
|
relayerAddress: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "ensName", "relayerAddress"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const depositsEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
commitment: bytes32SchemaType,
|
||||||
|
leafIndex: { type: "number" },
|
||||||
|
timestamp: { type: "number" },
|
||||||
|
from: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "commitment", "leafIndex", "timestamp", "from"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const withdrawalsEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
nullifierHash: bytes32SchemaType,
|
||||||
|
to: addressSchemaType,
|
||||||
|
fee: bnSchemaType,
|
||||||
|
timestamp: { type: "number" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "nullifierHash", "to", "fee", "timestamp"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const echoEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
address: addressSchemaType,
|
||||||
|
encryptedAccount: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "address", "encryptedAccount"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const encryptedNotesSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: __spreadProps$3(__spreadValues$3({}, baseEventsSchemaProperty), {
|
||||||
|
encryptedNote: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "encryptedNote"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function getEventsSchemaValidator(type) {
|
||||||
|
if (type === DEPOSIT) {
|
||||||
|
return ajv.compile(depositsEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === WITHDRAWAL) {
|
||||||
|
return ajv.compile(withdrawalsEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "governance") {
|
||||||
|
return ajv.compile(governanceEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "registered") {
|
||||||
|
return ajv.compile(registeredEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "echo") {
|
||||||
|
return ajv.compile(echoEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "encrypted_notes") {
|
||||||
|
return ajv.compile(encryptedNotesSchema);
|
||||||
|
}
|
||||||
|
throw new Error("Unsupported event type for schema validation");
|
||||||
|
}
|
||||||
|
|
||||||
const statusSchema = {
|
const statusSchema = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
rewardAccount: addressType,
|
rewardAccount: addressSchemaType,
|
||||||
gasPrices: {
|
gasPrices: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
@ -2369,7 +2601,7 @@ const statusSchema = {
|
|||||||
netId: { type: "integer" },
|
netId: { type: "integer" },
|
||||||
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
|
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
|
||||||
latestBlock: { type: "number" },
|
latestBlock: { type: "number" },
|
||||||
latestBalance: { type: "string", BN: true },
|
latestBalance: bnSchemaType,
|
||||||
version: { type: "string" },
|
version: { type: "string" },
|
||||||
health: {
|
health: {
|
||||||
type: "object",
|
type: "object",
|
||||||
@ -2406,7 +2638,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
instanceAddress: {
|
instanceAddress: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: amounts.reduce((acc2, cur) => {
|
properties: amounts.reduce((acc2, cur) => {
|
||||||
acc2[cur] = addressType;
|
acc2[cur] = addressSchemaType;
|
||||||
return acc2;
|
return acc2;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: amounts.filter((amount) => !optionalInstances.includes(amount))
|
required: amounts.filter((amount) => !optionalInstances.includes(amount))
|
||||||
@ -2419,7 +2651,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
if (tokenAddress) {
|
if (tokenAddress) {
|
||||||
instanceProperties.properties.tokenAddress = addressType;
|
instanceProperties.properties.tokenAddress = addressSchemaType;
|
||||||
}
|
}
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
instanceProperties.properties.symbol = { enum: [symbol] };
|
instanceProperties.properties.symbol = { enum: [symbol] };
|
||||||
@ -2450,7 +2682,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
const ethPrices = {
|
const ethPrices = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: _tokens.reduce((acc, token) => {
|
properties: _tokens.reduce((acc, token) => {
|
||||||
acc[token] = bnType;
|
acc[token] = bnSchemaType;
|
||||||
return acc;
|
return acc;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: _tokens
|
required: _tokens
|
||||||
@ -2484,21 +2716,6 @@ const jobsSchema = {
|
|||||||
required: ["id", "status"]
|
required: ["id", "status"]
|
||||||
};
|
};
|
||||||
|
|
||||||
const ajv = new Ajv({ allErrors: true });
|
|
||||||
ajv.addKeyword({
|
|
||||||
keyword: "BN",
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
validate: (schema, data) => {
|
|
||||||
try {
|
|
||||||
BigInt(data);
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errors: true
|
|
||||||
});
|
|
||||||
|
|
||||||
var __defProp$2 = Object.defineProperty;
|
var __defProp$2 = Object.defineProperty;
|
||||||
var __defProps$2 = Object.defineProperties;
|
var __defProps$2 = Object.defineProperties;
|
||||||
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
||||||
@ -2997,7 +3214,8 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
const lastBlock = newEvents.lastBlock || ((_a = allEvents[allEvents.length - 1]) == null ? void 0 : _a.blockNumber);
|
const lastBlock = newEvents.lastBlock || ((_a = allEvents[allEvents.length - 1]) == null ? void 0 : _a.blockNumber);
|
||||||
this.validateEvents({ events: allEvents, lastBlock });
|
this.validateEvents({ events: allEvents, lastBlock });
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
const saveCache = Boolean(savedEvents.fromCache && savedEvents.events.length);
|
||||||
|
if (saveCache || newEvents.events.length) {
|
||||||
yield this.saveEvents({ events: allEvents, lastBlock });
|
yield this.saveEvents({ events: allEvents, lastBlock });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -6827,6 +7045,7 @@ class TovarishClient extends RelayerClient {
|
|||||||
}) {
|
}) {
|
||||||
var _a;
|
var _a;
|
||||||
const url = `${(_a = this.selectedRelayer) == null ? void 0 : _a.url}events`;
|
const url = `${(_a = this.selectedRelayer) == null ? void 0 : _a.url}events`;
|
||||||
|
const schemaValidator = getEventsSchemaValidator(type);
|
||||||
try {
|
try {
|
||||||
const events = [];
|
const events = [];
|
||||||
let lastSyncBlock = fromBlock;
|
let lastSyncBlock = fromBlock;
|
||||||
@ -6844,6 +7063,10 @@ class TovarishClient extends RelayerClient {
|
|||||||
recent
|
recent
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
if (!schemaValidator(fetchedEvents)) {
|
||||||
|
const errMsg = `Schema validation failed for ${type} events`;
|
||||||
|
throw new Error(errMsg);
|
||||||
|
}
|
||||||
lastSyncBlock = currentBlock;
|
lastSyncBlock = currentBlock;
|
||||||
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
||||||
break;
|
break;
|
||||||
@ -6941,4 +7164,4 @@ function calculateSnarkProof(input, circuit, provingKey) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, Invoice, MAX_FEE, MAX_TOVARISH_EVENTS, MIN_FEE, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, TovarishClient, WITHDRAWAL, _META, addNetwork, ajv, base64ToBytes, bigIntReplacer, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, digest, enabledChains, index as factories, fetch, fetchData, fetchGetUrlFunc, getActiveTokenInstances, getActiveTokens, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getRelayerEnsSubdomains, getStatistic, getStatusSchema, getSupportedInstances, getTokenBalances, getTovarishNetworks, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, jobsSchema, leBuff2Int, leInt2Buff, mimc, multicall, packEncryptedMessage, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, validateUrl };
|
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, Invoice, MAX_FEE, MAX_TOVARISH_EVENTS, MIN_FEE, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, TovarishClient, WITHDRAWAL, _META, addNetwork, addressSchemaType, ajv, base64ToBytes, bigIntReplacer, bnSchemaType, bnToBytes, buffPedersenHash, bufferToBytes, bytes32BNSchemaType, bytes32SchemaType, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, depositsEventsSchema, digest, echoEventsSchema, enabledChains, encryptedNotesSchema, index as factories, fetch, fetchData, fetchGetUrlFunc, getActiveTokenInstances, getActiveTokens, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getEventsSchemaValidator, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getRelayerEnsSubdomains, getStatistic, getStatusSchema, getSupportedInstances, getTokenBalances, getTovarishNetworks, getWeightRandom, getWithdrawals, governanceEventsSchema, hexToBytes, initGroth16, isNode, jobsSchema, leBuff2Int, leInt2Buff, mimc, multicall, packEncryptedMessage, pedersen, pickWeightedRandomRelayer, populateTransaction, proofSchemaType, queryGraph, rBigInt, registeredEventsSchema, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, validateUrl, withdrawalsEventsSchema };
|
||||||
|
2
dist/schemas/ajv.d.ts
vendored
Normal file
2
dist/schemas/ajv.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import Ajv from 'ajv';
|
||||||
|
export declare const ajv: Ajv;
|
297
dist/schemas/events.d.ts
vendored
Normal file
297
dist/schemas/events.d.ts
vendored
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
export declare const governanceEventsSchema: {
|
||||||
|
readonly type: "array";
|
||||||
|
readonly items: {
|
||||||
|
readonly anyOf: readonly [{
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly event: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly id: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly proposer: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly target: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly startTime: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly endTime: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly description: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "event", "id", "proposer", "target", "startTime", "endTime", "description"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
}, {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly event: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly proposalId: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly voter: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly support: {
|
||||||
|
readonly type: "boolean";
|
||||||
|
};
|
||||||
|
readonly votes: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly from: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly input: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "event", "proposalId", "voter", "support", "votes", "from", "input"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
}, {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly event: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly account: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly delegateTo: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "account", "delegateTo"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
}, {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly event: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly account: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly delegateFrom: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "account", "delegateFrom"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export declare const registeredEventsSchema: {
|
||||||
|
readonly type: "array";
|
||||||
|
readonly items: {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly ensName: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly relayerAddress: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "ensName", "relayerAddress"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export declare const depositsEventsSchema: {
|
||||||
|
readonly type: "array";
|
||||||
|
readonly items: {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly commitment: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
readonly leafIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly timestamp: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly from: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "commitment", "leafIndex", "timestamp", "from"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export declare const withdrawalsEventsSchema: {
|
||||||
|
readonly type: "array";
|
||||||
|
readonly items: {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly nullifierHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
readonly to: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly fee: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly BN: true;
|
||||||
|
};
|
||||||
|
readonly timestamp: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "nullifierHash", "to", "fee", "timestamp"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export declare const echoEventsSchema: {
|
||||||
|
readonly type: "array";
|
||||||
|
readonly items: {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly address: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
readonly encryptedAccount: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "address", "encryptedAccount"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export declare const encryptedNotesSchema: {
|
||||||
|
readonly type: "array";
|
||||||
|
readonly items: {
|
||||||
|
readonly type: "object";
|
||||||
|
readonly properties: {
|
||||||
|
readonly encryptedNote: {
|
||||||
|
readonly type: "string";
|
||||||
|
};
|
||||||
|
readonly blockNumber: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly logIndex: {
|
||||||
|
readonly type: "number";
|
||||||
|
};
|
||||||
|
readonly transactionHash: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
readonly required: readonly [...string[], "encryptedNote"];
|
||||||
|
readonly additionalProperties: false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export declare function getEventsSchemaValidator(type: string): import("ajv").ValidateFunction<unknown>;
|
5
dist/schemas/index.d.ts
vendored
5
dist/schemas/index.d.ts
vendored
@ -1,4 +1,5 @@
|
|||||||
import Ajv from 'ajv';
|
export * from './ajv';
|
||||||
export declare const ajv: Ajv;
|
export * from './events';
|
||||||
export * from './status';
|
export * from './status';
|
||||||
export * from './jobs';
|
export * from './jobs';
|
||||||
|
export * from './types';
|
||||||
|
18
dist/schemas/status.d.ts
vendored
18
dist/schemas/status.d.ts
vendored
@ -1,15 +1,16 @@
|
|||||||
import { Config, NetIdType } from '../networkConfig';
|
import { Config, NetIdType } from '../networkConfig';
|
||||||
|
import { addressSchemaType, bnSchemaType } from '.';
|
||||||
export type statusInstanceType = {
|
export type statusInstanceType = {
|
||||||
type: string;
|
type: string;
|
||||||
properties: {
|
properties: {
|
||||||
instanceAddress: {
|
instanceAddress: {
|
||||||
type: string;
|
type: string;
|
||||||
properties: {
|
properties: {
|
||||||
[key in string]: typeof addressType;
|
[key in string]: typeof addressSchemaType;
|
||||||
};
|
};
|
||||||
required: string[];
|
required: string[];
|
||||||
};
|
};
|
||||||
tokenAddress?: typeof addressType;
|
tokenAddress?: typeof addressSchemaType;
|
||||||
symbol?: {
|
symbol?: {
|
||||||
enum: string[];
|
enum: string[];
|
||||||
};
|
};
|
||||||
@ -29,14 +30,14 @@ export type statusInstancesType = {
|
|||||||
export type statusEthPricesType = {
|
export type statusEthPricesType = {
|
||||||
type: string;
|
type: string;
|
||||||
properties: {
|
properties: {
|
||||||
[key in string]: typeof bnType;
|
[key in string]: typeof bnSchemaType;
|
||||||
};
|
};
|
||||||
required?: string[];
|
required?: string[];
|
||||||
};
|
};
|
||||||
export type statusSchema = {
|
export type statusSchema = {
|
||||||
type: string;
|
type: string;
|
||||||
properties: {
|
properties: {
|
||||||
rewardAccount: typeof addressType;
|
rewardAccount: typeof addressSchemaType;
|
||||||
instances?: statusInstancesType;
|
instances?: statusInstancesType;
|
||||||
gasPrices: {
|
gasPrices: {
|
||||||
type: string;
|
type: string;
|
||||||
@ -102,13 +103,4 @@ export type statusSchema = {
|
|||||||
};
|
};
|
||||||
required: string[];
|
required: string[];
|
||||||
};
|
};
|
||||||
declare const addressType: {
|
|
||||||
type: string;
|
|
||||||
pattern: string;
|
|
||||||
};
|
|
||||||
declare const bnType: {
|
|
||||||
type: string;
|
|
||||||
BN: boolean;
|
|
||||||
};
|
|
||||||
export declare function getStatusSchema(netId: NetIdType, config: Config, tovarish: boolean): statusSchema;
|
export declare function getStatusSchema(netId: NetIdType, config: Config, tovarish: boolean): statusSchema;
|
||||||
export {};
|
|
||||||
|
22
dist/schemas/types.d.ts
vendored
Normal file
22
dist/schemas/types.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
export declare const addressSchemaType: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{40}$";
|
||||||
|
readonly isAddress: true;
|
||||||
|
};
|
||||||
|
export declare const bnSchemaType: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly BN: true;
|
||||||
|
};
|
||||||
|
export declare const proofSchemaType: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{512}$";
|
||||||
|
};
|
||||||
|
export declare const bytes32SchemaType: {
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
||||||
|
export declare const bytes32BNSchemaType: {
|
||||||
|
readonly BN: true;
|
||||||
|
readonly type: "string";
|
||||||
|
readonly pattern: "^0x[a-fA-F0-9]{64}$";
|
||||||
|
};
|
348
dist/tornado.umd.js
vendored
348
dist/tornado.umd.js
vendored
@ -59335,7 +59335,8 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
const lastBlock = newEvents.lastBlock || ((_a = allEvents[allEvents.length - 1]) == null ? void 0 : _a.blockNumber);
|
const lastBlock = newEvents.lastBlock || ((_a = allEvents[allEvents.length - 1]) == null ? void 0 : _a.blockNumber);
|
||||||
this.validateEvents({ events: allEvents, lastBlock });
|
this.validateEvents({ events: allEvents, lastBlock });
|
||||||
if (savedEvents.fromCache || newEvents.events.length) {
|
const saveCache = Boolean(savedEvents.fromCache && savedEvents.events.length);
|
||||||
|
if (saveCache || newEvents.events.length) {
|
||||||
yield this.saveEvents({ events: allEvents, lastBlock });
|
yield this.saveEvents({ events: allEvents, lastBlock });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -71542,7 +71543,7 @@ class TornadoBrowserProvider extends BrowserProvider {
|
|||||||
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(67418);
|
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(67418);
|
||||||
/* harmony import */ var _networkConfig__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(59499);
|
/* harmony import */ var _networkConfig__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(59499);
|
||||||
/* harmony import */ var _providers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(68434);
|
/* harmony import */ var _providers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(68434);
|
||||||
/* harmony import */ var _schemas__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7613);
|
/* harmony import */ var _schemas__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(59511);
|
||||||
|
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __defProps = Object.defineProperties;
|
var __defProps = Object.defineProperties;
|
||||||
@ -71798,32 +71799,292 @@ class RelayerClient {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 7613:
|
/***/ 59511:
|
||||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// EXPORTS
|
// EXPORTS
|
||||||
__webpack_require__.d(__webpack_exports__, {
|
__webpack_require__.d(__webpack_exports__, {
|
||||||
SS: () => (/* binding */ schemas_ajv),
|
SC: () => (/* reexport */ addressSchemaType),
|
||||||
|
SS: () => (/* reexport */ ajv_ajv),
|
||||||
|
iL: () => (/* reexport */ bnSchemaType),
|
||||||
|
i1: () => (/* reexport */ bytes32BNSchemaType),
|
||||||
|
yF: () => (/* reexport */ bytes32SchemaType),
|
||||||
|
CI: () => (/* reexport */ depositsEventsSchema),
|
||||||
|
ME: () => (/* reexport */ echoEventsSchema),
|
||||||
|
XW: () => (/* reexport */ encryptedNotesSchema),
|
||||||
|
ZC: () => (/* reexport */ getEventsSchemaValidator),
|
||||||
c_: () => (/* reexport */ getStatusSchema),
|
c_: () => (/* reexport */ getStatusSchema),
|
||||||
Us: () => (/* reexport */ jobsSchema)
|
FR: () => (/* reexport */ governanceEventsSchema),
|
||||||
|
Us: () => (/* reexport */ jobsSchema),
|
||||||
|
Y6: () => (/* reexport */ proofSchemaType),
|
||||||
|
dX: () => (/* reexport */ registeredEventsSchema),
|
||||||
|
$j: () => (/* reexport */ withdrawalsEventsSchema)
|
||||||
});
|
});
|
||||||
|
|
||||||
// EXTERNAL MODULE: ./node_modules/ajv/dist/ajv.js
|
// EXTERNAL MODULE: ./node_modules/ajv/dist/ajv.js
|
||||||
var ajv = __webpack_require__(63282);
|
var ajv = __webpack_require__(63282);
|
||||||
var ajv_default = /*#__PURE__*/__webpack_require__.n(ajv);
|
var ajv_default = /*#__PURE__*/__webpack_require__.n(ajv);
|
||||||
|
// EXTERNAL MODULE: ./node_modules/ethers/lib.esm/address/checks.js
|
||||||
|
var checks = __webpack_require__(41442);
|
||||||
|
;// CONCATENATED MODULE: ./src/schemas/ajv.ts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const ajv_ajv = new (ajv_default())({ allErrors: true });
|
||||||
|
ajv_ajv.addKeyword({
|
||||||
|
keyword: "BN",
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema, data) => {
|
||||||
|
try {
|
||||||
|
BigInt(data);
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true
|
||||||
|
});
|
||||||
|
ajv_ajv.addKeyword({
|
||||||
|
keyword: "isAddress",
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema, data) => {
|
||||||
|
try {
|
||||||
|
return (0,checks/* isAddress */.PW)(data);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// EXTERNAL MODULE: ./src/events/index.ts
|
||||||
|
var events = __webpack_require__(94513);
|
||||||
|
;// CONCATENATED MODULE: ./src/schemas/types.ts
|
||||||
|
|
||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __defProps = Object.defineProperties;
|
||||||
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||||
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||||
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||||
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
|
var __spreadValues = (a, b) => {
|
||||||
|
for (var prop in b || (b = {}))
|
||||||
|
if (__hasOwnProp.call(b, prop))
|
||||||
|
__defNormalProp(a, prop, b[prop]);
|
||||||
|
if (__getOwnPropSymbols)
|
||||||
|
for (var prop of __getOwnPropSymbols(b)) {
|
||||||
|
if (__propIsEnum.call(b, prop))
|
||||||
|
__defNormalProp(a, prop, b[prop]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||||
|
const addressSchemaType = {
|
||||||
|
type: "string",
|
||||||
|
pattern: "^0x[a-fA-F0-9]{40}$",
|
||||||
|
isAddress: true
|
||||||
|
};
|
||||||
|
const bnSchemaType = { type: "string", BN: true };
|
||||||
|
const proofSchemaType = { type: "string", pattern: "^0x[a-fA-F0-9]{512}$" };
|
||||||
|
const bytes32SchemaType = { type: "string", pattern: "^0x[a-fA-F0-9]{64}$" };
|
||||||
|
const bytes32BNSchemaType = __spreadProps(__spreadValues({}, bytes32SchemaType), { BN: true });
|
||||||
|
|
||||||
|
;// CONCATENATED MODULE: ./src/schemas/events.ts
|
||||||
|
|
||||||
|
var events_defProp = Object.defineProperty;
|
||||||
|
var events_defProps = Object.defineProperties;
|
||||||
|
var events_getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||||
|
var events_getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||||
|
var events_hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
var events_propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||||
|
var events_defNormalProp = (obj, key, value) => key in obj ? events_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||||
|
var events_spreadValues = (a, b) => {
|
||||||
|
for (var prop in b || (b = {}))
|
||||||
|
if (events_hasOwnProp.call(b, prop))
|
||||||
|
events_defNormalProp(a, prop, b[prop]);
|
||||||
|
if (events_getOwnPropSymbols)
|
||||||
|
for (var prop of events_getOwnPropSymbols(b)) {
|
||||||
|
if (events_propIsEnum.call(b, prop))
|
||||||
|
events_defNormalProp(a, prop, b[prop]);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
var events_spreadProps = (a, b) => events_defProps(a, events_getOwnPropDescs(b));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const baseEventsSchemaProperty = {
|
||||||
|
blockNumber: {
|
||||||
|
type: "number"
|
||||||
|
},
|
||||||
|
logIndex: {
|
||||||
|
type: "number"
|
||||||
|
},
|
||||||
|
transactionHash: bytes32SchemaType
|
||||||
|
};
|
||||||
|
const baseEventsSchemaRequired = Object.keys(baseEventsSchemaProperty);
|
||||||
|
const governanceEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
id: { type: "number" },
|
||||||
|
proposer: addressSchemaType,
|
||||||
|
target: addressSchemaType,
|
||||||
|
startTime: { type: "number" },
|
||||||
|
endTime: { type: "number" },
|
||||||
|
description: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [
|
||||||
|
...baseEventsSchemaRequired,
|
||||||
|
"event",
|
||||||
|
"id",
|
||||||
|
"proposer",
|
||||||
|
"target",
|
||||||
|
"startTime",
|
||||||
|
"endTime",
|
||||||
|
"description"
|
||||||
|
],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
proposalId: { type: "number" },
|
||||||
|
voter: addressSchemaType,
|
||||||
|
support: { type: "boolean" },
|
||||||
|
votes: { type: "string" },
|
||||||
|
from: addressSchemaType,
|
||||||
|
input: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "event", "proposalId", "voter", "support", "votes", "from", "input"],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateTo: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "account", "delegateTo"],
|
||||||
|
additionalProperties: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
event: { type: "string" },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateFrom: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "account", "delegateFrom"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const registeredEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
ensName: { type: "string" },
|
||||||
|
relayerAddress: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "ensName", "relayerAddress"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const depositsEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
commitment: bytes32SchemaType,
|
||||||
|
leafIndex: { type: "number" },
|
||||||
|
timestamp: { type: "number" },
|
||||||
|
from: addressSchemaType
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "commitment", "leafIndex", "timestamp", "from"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const withdrawalsEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
nullifierHash: bytes32SchemaType,
|
||||||
|
to: addressSchemaType,
|
||||||
|
fee: bnSchemaType,
|
||||||
|
timestamp: { type: "number" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "nullifierHash", "to", "fee", "timestamp"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const echoEventsSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
address: addressSchemaType,
|
||||||
|
encryptedAccount: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "address", "encryptedAccount"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const encryptedNotesSchema = {
|
||||||
|
type: "array",
|
||||||
|
items: {
|
||||||
|
type: "object",
|
||||||
|
properties: events_spreadProps(events_spreadValues({}, baseEventsSchemaProperty), {
|
||||||
|
encryptedNote: { type: "string" }
|
||||||
|
}),
|
||||||
|
required: [...baseEventsSchemaRequired, "encryptedNote"],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function getEventsSchemaValidator(type) {
|
||||||
|
if (type === events.DEPOSIT) {
|
||||||
|
return ajv_ajv.compile(depositsEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === events.WITHDRAWAL) {
|
||||||
|
return ajv_ajv.compile(withdrawalsEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "governance") {
|
||||||
|
return ajv_ajv.compile(governanceEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "registered") {
|
||||||
|
return ajv_ajv.compile(registeredEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "echo") {
|
||||||
|
return ajv_ajv.compile(echoEventsSchema);
|
||||||
|
}
|
||||||
|
if (type === "encrypted_notes") {
|
||||||
|
return ajv_ajv.compile(encryptedNotesSchema);
|
||||||
|
}
|
||||||
|
throw new Error("Unsupported event type for schema validation");
|
||||||
|
}
|
||||||
|
|
||||||
// EXTERNAL MODULE: ./src/networkConfig.ts
|
// EXTERNAL MODULE: ./src/networkConfig.ts
|
||||||
var networkConfig = __webpack_require__(59499);
|
var networkConfig = __webpack_require__(59499);
|
||||||
;// CONCATENATED MODULE: ./src/schemas/status.ts
|
;// CONCATENATED MODULE: ./src/schemas/status.ts
|
||||||
|
|
||||||
|
|
||||||
const addressType = { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" };
|
|
||||||
const bnType = { type: "string", BN: true };
|
|
||||||
const statusSchema = {
|
const statusSchema = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
rewardAccount: addressType,
|
rewardAccount: addressSchemaType,
|
||||||
gasPrices: {
|
gasPrices: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
@ -71835,7 +72096,7 @@ const statusSchema = {
|
|||||||
netId: { type: "integer" },
|
netId: { type: "integer" },
|
||||||
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
|
tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 },
|
||||||
latestBlock: { type: "number" },
|
latestBlock: { type: "number" },
|
||||||
latestBalance: { type: "string", BN: true },
|
latestBalance: bnSchemaType,
|
||||||
version: { type: "string" },
|
version: { type: "string" },
|
||||||
health: {
|
health: {
|
||||||
type: "object",
|
type: "object",
|
||||||
@ -71872,7 +72133,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
instanceAddress: {
|
instanceAddress: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: amounts.reduce((acc2, cur) => {
|
properties: amounts.reduce((acc2, cur) => {
|
||||||
acc2[cur] = addressType;
|
acc2[cur] = addressSchemaType;
|
||||||
return acc2;
|
return acc2;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: amounts.filter((amount) => !optionalInstances.includes(amount))
|
required: amounts.filter((amount) => !optionalInstances.includes(amount))
|
||||||
@ -71885,7 +72146,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
if (tokenAddress) {
|
if (tokenAddress) {
|
||||||
instanceProperties.properties.tokenAddress = addressType;
|
instanceProperties.properties.tokenAddress = addressSchemaType;
|
||||||
}
|
}
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
instanceProperties.properties.symbol = { enum: [symbol] };
|
instanceProperties.properties.symbol = { enum: [symbol] };
|
||||||
@ -71916,7 +72177,7 @@ function getStatusSchema(netId, config, tovarish) {
|
|||||||
const ethPrices = {
|
const ethPrices = {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: _tokens.reduce((acc, token) => {
|
properties: _tokens.reduce((acc, token) => {
|
||||||
acc[token] = bnType;
|
acc[token] = bnSchemaType;
|
||||||
return acc;
|
return acc;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: _tokens
|
required: _tokens
|
||||||
@ -71955,20 +72216,8 @@ const jobsSchema = {
|
|||||||
;// CONCATENATED MODULE: ./src/schemas/index.ts
|
;// CONCATENATED MODULE: ./src/schemas/index.ts
|
||||||
|
|
||||||
|
|
||||||
const schemas_ajv = new (ajv_default())({ allErrors: true });
|
|
||||||
schemas_ajv.addKeyword({
|
|
||||||
keyword: "BN",
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
validate: (schema, data) => {
|
|
||||||
try {
|
|
||||||
BigInt(data);
|
|
||||||
return true;
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errors: true
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -72086,9 +72335,10 @@ function getTokenBalances(_0) {
|
|||||||
/* harmony export */ E: () => (/* binding */ TovarishClient),
|
/* harmony export */ E: () => (/* binding */ TovarishClient),
|
||||||
/* harmony export */ o: () => (/* binding */ MAX_TOVARISH_EVENTS)
|
/* harmony export */ o: () => (/* binding */ MAX_TOVARISH_EVENTS)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(30031);
|
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(30031);
|
||||||
/* harmony import */ var _relayerClient__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57194);
|
/* harmony import */ var _relayerClient__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57194);
|
||||||
/* harmony import */ var _providers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(68434);
|
/* harmony import */ var _providers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(68434);
|
||||||
|
/* harmony import */ var _schemas__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59511);
|
||||||
|
|
||||||
var __defProp = Object.defineProperty;
|
var __defProp = Object.defineProperty;
|
||||||
var __defProps = Object.defineProperties;
|
var __defProps = Object.defineProperties;
|
||||||
@ -72135,6 +72385,7 @@ var __async = (__this, __arguments, generator) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const MAX_TOVARISH_EVENTS = 5e3;
|
const MAX_TOVARISH_EVENTS = 5e3;
|
||||||
class TovarishClient extends _relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .RelayerClient */ .OR {
|
class TovarishClient extends _relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .RelayerClient */ .OR {
|
||||||
constructor({ netId, config, fetchDataOptions }) {
|
constructor({ netId, config, fetchDataOptions }) {
|
||||||
@ -72169,7 +72420,7 @@ class TovarishClient extends _relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .Rela
|
|||||||
hostname,
|
hostname,
|
||||||
ensName,
|
ensName,
|
||||||
relayerAddress,
|
relayerAddress,
|
||||||
rewardAccount: (0,ethers__WEBPACK_IMPORTED_MODULE_2__/* .getAddress */ .b)(status.rewardAccount),
|
rewardAccount: (0,ethers__WEBPACK_IMPORTED_MODULE_3__/* .getAddress */ .b)(status.rewardAccount),
|
||||||
instances: (0,_relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .getSupportedInstances */ .XF)(status.instances),
|
instances: (0,_relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .getSupportedInstances */ .XF)(status.instances),
|
||||||
stakeBalance: relayer.stakeBalance,
|
stakeBalance: relayer.stakeBalance,
|
||||||
gasPrice: (_a = status.gasPrices) == null ? void 0 : _a.fast,
|
gasPrice: (_a = status.gasPrices) == null ? void 0 : _a.fast,
|
||||||
@ -72222,6 +72473,7 @@ class TovarishClient extends _relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .Rela
|
|||||||
}) {
|
}) {
|
||||||
var _a;
|
var _a;
|
||||||
const url = `${(_a = this.selectedRelayer) == null ? void 0 : _a.url}events`;
|
const url = `${(_a = this.selectedRelayer) == null ? void 0 : _a.url}events`;
|
||||||
|
const schemaValidator = (0,_schemas__WEBPACK_IMPORTED_MODULE_2__/* .getEventsSchemaValidator */ .ZC)(type);
|
||||||
try {
|
try {
|
||||||
const events = [];
|
const events = [];
|
||||||
let lastSyncBlock = fromBlock;
|
let lastSyncBlock = fromBlock;
|
||||||
@ -72239,6 +72491,10 @@ class TovarishClient extends _relayerClient__WEBPACK_IMPORTED_MODULE_0__/* .Rela
|
|||||||
recent
|
recent
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
if (!schemaValidator(fetchedEvents)) {
|
||||||
|
const errMsg = `Schema validation failed for ${type} events`;
|
||||||
|
throw new Error(errMsg);
|
||||||
|
}
|
||||||
lastSyncBlock = currentBlock;
|
lastSyncBlock = currentBlock;
|
||||||
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
||||||
break;
|
break;
|
||||||
@ -162074,11 +162330,11 @@ function getIcapAddress(address) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||||
/* harmony export */ $C: () => (/* binding */ isAddressable),
|
/* harmony export */ $C: () => (/* binding */ isAddressable),
|
||||||
|
/* harmony export */ PW: () => (/* binding */ isAddress),
|
||||||
/* harmony export */ tG: () => (/* binding */ resolveAddress)
|
/* harmony export */ tG: () => (/* binding */ resolveAddress)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* unused harmony export isAddress */
|
/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(57339);
|
||||||
/* harmony import */ var _utils_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57339);
|
/* harmony import */ var _address_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(30031);
|
||||||
/* harmony import */ var _address_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(30031);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162125,7 +162381,7 @@ function isAddressable(value) {
|
|||||||
*/
|
*/
|
||||||
function isAddress(value) {
|
function isAddress(value) {
|
||||||
try {
|
try {
|
||||||
getAddress(value);
|
(0,_address_js__WEBPACK_IMPORTED_MODULE_0__/* .getAddress */ .b)(value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (error) { }
|
catch (error) { }
|
||||||
@ -162134,10 +162390,10 @@ function isAddress(value) {
|
|||||||
async function checkAddress(target, promise) {
|
async function checkAddress(target, promise) {
|
||||||
const result = await promise;
|
const result = await promise;
|
||||||
if (result == null || result === "0x0000000000000000000000000000000000000000") {
|
if (result == null || result === "0x0000000000000000000000000000000000000000") {
|
||||||
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .vA)(typeof (target) !== "string", "unconfigured name", "UNCONFIGURED_NAME", { value: target });
|
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__/* .assert */ .vA)(typeof (target) !== "string", "unconfigured name", "UNCONFIGURED_NAME", { value: target });
|
||||||
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__/* .assertArgument */ .MR)(false, "invalid AddressLike value; did not resolve to a value address", "target", target);
|
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__/* .assertArgument */ .MR)(false, "invalid AddressLike value; did not resolve to a value address", "target", target);
|
||||||
}
|
}
|
||||||
return (0,_address_js__WEBPACK_IMPORTED_MODULE_1__/* .getAddress */ .b)(result);
|
return (0,_address_js__WEBPACK_IMPORTED_MODULE_0__/* .getAddress */ .b)(result);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Resolves to an address for the %%target%%, which may be any
|
* Resolves to an address for the %%target%%, which may be any
|
||||||
@ -162179,9 +162435,9 @@ async function checkAddress(target, promise) {
|
|||||||
function resolveAddress(target, resolver) {
|
function resolveAddress(target, resolver) {
|
||||||
if (typeof (target) === "string") {
|
if (typeof (target) === "string") {
|
||||||
if (target.match(/^0x[0-9a-f]{40}$/i)) {
|
if (target.match(/^0x[0-9a-f]{40}$/i)) {
|
||||||
return (0,_address_js__WEBPACK_IMPORTED_MODULE_1__/* .getAddress */ .b)(target);
|
return (0,_address_js__WEBPACK_IMPORTED_MODULE_0__/* .getAddress */ .b)(target);
|
||||||
}
|
}
|
||||||
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .vA)(resolver != null, "ENS resolution requires a provider", "UNSUPPORTED_OPERATION", { operation: "resolveName" });
|
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__/* .assert */ .vA)(resolver != null, "ENS resolution requires a provider", "UNSUPPORTED_OPERATION", { operation: "resolveName" });
|
||||||
return checkAddress(target, resolver.resolveName(target));
|
return checkAddress(target, resolver.resolveName(target));
|
||||||
}
|
}
|
||||||
else if (isAddressable(target)) {
|
else if (isAddressable(target)) {
|
||||||
@ -162190,7 +162446,7 @@ function resolveAddress(target, resolver) {
|
|||||||
else if (target && typeof (target.then) === "function") {
|
else if (target && typeof (target.then) === "function") {
|
||||||
return checkAddress(target, target);
|
return checkAddress(target, target);
|
||||||
}
|
}
|
||||||
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_0__/* .assertArgument */ .MR)(false, "unsupported addressable value", "target", target);
|
(0,_utils_index_js__WEBPACK_IMPORTED_MODULE_1__/* .assertArgument */ .MR)(false, "unsupported addressable value", "target", target);
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=checks.js.map
|
//# sourceMappingURL=checks.js.map
|
||||||
|
|
||||||
@ -173348,12 +173604,16 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ TovarishClient: () => (/* reexport safe */ _tovarishClient__WEBPACK_IMPORTED_MODULE_17__.E),
|
/* harmony export */ TovarishClient: () => (/* reexport safe */ _tovarishClient__WEBPACK_IMPORTED_MODULE_17__.E),
|
||||||
/* harmony export */ _META: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__._META),
|
/* harmony export */ _META: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__._META),
|
||||||
/* harmony export */ addNetwork: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.AE),
|
/* harmony export */ addNetwork: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.AE),
|
||||||
|
/* harmony export */ addressSchemaType: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.SC),
|
||||||
/* harmony export */ ajv: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.SS),
|
/* harmony export */ ajv: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.SS),
|
||||||
/* harmony export */ base64ToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.Kp),
|
/* harmony export */ base64ToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.Kp),
|
||||||
/* harmony export */ bigIntReplacer: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.gn),
|
/* harmony export */ bigIntReplacer: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.gn),
|
||||||
|
/* harmony export */ bnSchemaType: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.iL),
|
||||||
/* harmony export */ bnToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.jm),
|
/* harmony export */ bnToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.jm),
|
||||||
/* harmony export */ buffPedersenHash: () => (/* reexport safe */ _pedersen__WEBPACK_IMPORTED_MODULE_12__.UB),
|
/* harmony export */ buffPedersenHash: () => (/* reexport safe */ _pedersen__WEBPACK_IMPORTED_MODULE_12__.UB),
|
||||||
/* harmony export */ bufferToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.lY),
|
/* harmony export */ bufferToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.lY),
|
||||||
|
/* harmony export */ bytes32BNSchemaType: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.i1),
|
||||||
|
/* harmony export */ bytes32SchemaType: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.yF),
|
||||||
/* harmony export */ bytesToBN: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.Ju),
|
/* harmony export */ bytesToBN: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.Ju),
|
||||||
/* harmony export */ bytesToBase64: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__["if"]),
|
/* harmony export */ bytesToBase64: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__["if"]),
|
||||||
/* harmony export */ bytesToHex: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.My),
|
/* harmony export */ bytesToHex: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.My),
|
||||||
@ -173367,8 +173627,11 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ customConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.cX),
|
/* harmony export */ customConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.cX),
|
||||||
/* harmony export */ defaultConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.sb),
|
/* harmony export */ defaultConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.sb),
|
||||||
/* harmony export */ defaultUserAgent: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.mJ),
|
/* harmony export */ defaultUserAgent: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.mJ),
|
||||||
|
/* harmony export */ depositsEventsSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.CI),
|
||||||
/* harmony export */ digest: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.br),
|
/* harmony export */ digest: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.br),
|
||||||
|
/* harmony export */ echoEventsSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.ME),
|
||||||
/* harmony export */ enabledChains: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.Af),
|
/* harmony export */ enabledChains: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.Af),
|
||||||
|
/* harmony export */ encryptedNotesSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.XW),
|
||||||
/* harmony export */ factories: () => (/* reexport safe */ _typechain__WEBPACK_IMPORTED_MODULE_3__.XB),
|
/* harmony export */ factories: () => (/* reexport safe */ _typechain__WEBPACK_IMPORTED_MODULE_3__.XB),
|
||||||
/* harmony export */ fetch: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.hd),
|
/* harmony export */ fetch: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.hd),
|
||||||
/* harmony export */ fetchData: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.Fd),
|
/* harmony export */ fetchData: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.Fd),
|
||||||
@ -173384,6 +173647,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ getConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.zj),
|
/* harmony export */ getConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.zj),
|
||||||
/* harmony export */ getDeposits: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getDeposits),
|
/* harmony export */ getDeposits: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getDeposits),
|
||||||
/* harmony export */ getEncryptedNotes: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getEncryptedNotes),
|
/* harmony export */ getEncryptedNotes: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getEncryptedNotes),
|
||||||
|
/* harmony export */ getEventsSchemaValidator: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.ZC),
|
||||||
/* harmony export */ getGovernanceEvents: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getGovernanceEvents),
|
/* harmony export */ getGovernanceEvents: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getGovernanceEvents),
|
||||||
/* harmony export */ getGraphEchoEvents: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getGraphEchoEvents),
|
/* harmony export */ getGraphEchoEvents: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getGraphEchoEvents),
|
||||||
/* harmony export */ getHttpAgent: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.WU),
|
/* harmony export */ getHttpAgent: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.WU),
|
||||||
@ -173401,6 +173665,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ getTokenBalances: () => (/* reexport safe */ _tokens__WEBPACK_IMPORTED_MODULE_16__.H),
|
/* harmony export */ getTokenBalances: () => (/* reexport safe */ _tokens__WEBPACK_IMPORTED_MODULE_16__.H),
|
||||||
/* harmony export */ getWeightRandom: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.c$),
|
/* harmony export */ getWeightRandom: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.c$),
|
||||||
/* harmony export */ getWithdrawals: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getWithdrawals),
|
/* harmony export */ getWithdrawals: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.getWithdrawals),
|
||||||
|
/* harmony export */ governanceEventsSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.FR),
|
||||||
/* harmony export */ hexToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.aT),
|
/* harmony export */ hexToBytes: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.aT),
|
||||||
/* harmony export */ initGroth16: () => (/* reexport safe */ _websnark__WEBPACK_IMPORTED_MODULE_19__.O),
|
/* harmony export */ initGroth16: () => (/* reexport safe */ _websnark__WEBPACK_IMPORTED_MODULE_19__.O),
|
||||||
/* harmony export */ isNode: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.Ll),
|
/* harmony export */ isNode: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.Ll),
|
||||||
@ -173413,21 +173678,24 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ pedersen: () => (/* reexport safe */ _pedersen__WEBPACK_IMPORTED_MODULE_12__.NO),
|
/* harmony export */ pedersen: () => (/* reexport safe */ _pedersen__WEBPACK_IMPORTED_MODULE_12__.NO),
|
||||||
/* harmony export */ pickWeightedRandomRelayer: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.sN),
|
/* harmony export */ pickWeightedRandomRelayer: () => (/* reexport safe */ _relayerClient__WEBPACK_IMPORTED_MODULE_15__.sN),
|
||||||
/* harmony export */ populateTransaction: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.zr),
|
/* harmony export */ populateTransaction: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.zr),
|
||||||
|
/* harmony export */ proofSchemaType: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.Y6),
|
||||||
/* harmony export */ queryGraph: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.queryGraph),
|
/* harmony export */ queryGraph: () => (/* reexport safe */ _graphql__WEBPACK_IMPORTED_MODULE_1__.queryGraph),
|
||||||
/* harmony export */ rBigInt: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.ib),
|
/* harmony export */ rBigInt: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.ib),
|
||||||
|
/* harmony export */ registeredEventsSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.dX),
|
||||||
/* harmony export */ sleep: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.yy),
|
/* harmony export */ sleep: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.yy),
|
||||||
/* harmony export */ substring: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.uU),
|
/* harmony export */ substring: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.uU),
|
||||||
/* harmony export */ toFixedHex: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.$W),
|
/* harmony export */ toFixedHex: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.$W),
|
||||||
/* harmony export */ toFixedLength: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.sY),
|
/* harmony export */ toFixedLength: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.sY),
|
||||||
/* harmony export */ unpackEncryptedMessage: () => (/* reexport safe */ _encryptedNotes__WEBPACK_IMPORTED_MODULE_6__.ol),
|
/* harmony export */ unpackEncryptedMessage: () => (/* reexport safe */ _encryptedNotes__WEBPACK_IMPORTED_MODULE_6__.ol),
|
||||||
/* harmony export */ validateUrl: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.wv)
|
/* harmony export */ validateUrl: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_18__.wv),
|
||||||
|
/* harmony export */ withdrawalsEventsSchema: () => (/* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_2__.$j)
|
||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
/* harmony import */ var _events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(94513);
|
/* harmony import */ var _events__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(94513);
|
||||||
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
|
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
|
||||||
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _events__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _events__WEBPACK_IMPORTED_MODULE_0__[__WEBPACK_IMPORT_KEY__]
|
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _events__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _events__WEBPACK_IMPORTED_MODULE_0__[__WEBPACK_IMPORT_KEY__]
|
||||||
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
||||||
/* harmony import */ var _graphql__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(52049);
|
/* harmony import */ var _graphql__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(52049);
|
||||||
/* harmony import */ var _schemas__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7613);
|
/* harmony import */ var _schemas__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59511);
|
||||||
/* harmony import */ var _typechain__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21278);
|
/* harmony import */ var _typechain__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21278);
|
||||||
/* harmony import */ var _batch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9723);
|
/* harmony import */ var _batch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9723);
|
||||||
/* harmony import */ var _deposits__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7240);
|
/* harmony import */ var _deposits__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7240);
|
||||||
|
4
dist/tornado.umd.min.js
vendored
4
dist/tornado.umd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -336,7 +336,8 @@ export class BaseEventsService<EventType extends MinimalEvents> {
|
|||||||
this.validateEvents({ events: allEvents, lastBlock });
|
this.validateEvents({ events: allEvents, lastBlock });
|
||||||
|
|
||||||
// If the events are loaded from cache or we have found new events, save them
|
// If the events are loaded from cache or we have found new events, save them
|
||||||
if ((savedEvents as CachedEvents<EventType>).fromCache || newEvents.events.length) {
|
const saveCache = Boolean((savedEvents as CachedEvents<EventType>).fromCache && savedEvents.events.length);
|
||||||
|
if (saveCache || newEvents.events.length) {
|
||||||
await this.saveEvents({ events: allEvents, lastBlock });
|
await this.saveEvents({ events: allEvents, lastBlock });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
src/events/schema.ts
Normal file
0
src/events/schema.ts
Normal file
31
src/schemas/ajv.ts
Normal file
31
src/schemas/ajv.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import Ajv from 'ajv';
|
||||||
|
import { BigNumberish, isAddress } from 'ethers';
|
||||||
|
|
||||||
|
export const ajv = new Ajv({ allErrors: true });
|
||||||
|
|
||||||
|
ajv.addKeyword({
|
||||||
|
keyword: 'BN',
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema: any, data: BigNumberish) => {
|
||||||
|
try {
|
||||||
|
BigInt(data);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
ajv.addKeyword({
|
||||||
|
keyword: 'isAddress',
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
validate: (schema: any, data: string) => {
|
||||||
|
try {
|
||||||
|
return isAddress(data);
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
errors: true,
|
||||||
|
});
|
185
src/schemas/events.ts
Normal file
185
src/schemas/events.ts
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
import { DEPOSIT, WITHDRAWAL } from '../events';
|
||||||
|
import { ajv } from './ajv';
|
||||||
|
import { addressSchemaType, bnSchemaType, bytes32SchemaType } from './types';
|
||||||
|
|
||||||
|
const baseEventsSchemaProperty = {
|
||||||
|
blockNumber: {
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
logIndex: {
|
||||||
|
type: 'number',
|
||||||
|
},
|
||||||
|
transactionHash: bytes32SchemaType,
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
const baseEventsSchemaRequired = Object.keys(baseEventsSchemaProperty) as string[];
|
||||||
|
|
||||||
|
export const governanceEventsSchema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
anyOf: [
|
||||||
|
{
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
event: { type: 'string' },
|
||||||
|
id: { type: 'number' },
|
||||||
|
proposer: addressSchemaType,
|
||||||
|
target: addressSchemaType,
|
||||||
|
startTime: { type: 'number' },
|
||||||
|
endTime: { type: 'number' },
|
||||||
|
description: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: [
|
||||||
|
...baseEventsSchemaRequired,
|
||||||
|
'event',
|
||||||
|
'id',
|
||||||
|
'proposer',
|
||||||
|
'target',
|
||||||
|
'startTime',
|
||||||
|
'endTime',
|
||||||
|
'description',
|
||||||
|
],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
event: { type: 'string' },
|
||||||
|
proposalId: { type: 'number' },
|
||||||
|
voter: addressSchemaType,
|
||||||
|
support: { type: 'boolean' },
|
||||||
|
votes: { type: 'string' },
|
||||||
|
from: addressSchemaType,
|
||||||
|
input: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'event', 'proposalId', 'voter', 'support', 'votes', 'from', 'input'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
event: { type: 'string' },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateTo: addressSchemaType,
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'account', 'delegateTo'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
event: { type: 'string' },
|
||||||
|
account: addressSchemaType,
|
||||||
|
delegateFrom: addressSchemaType,
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'account', 'delegateFrom'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const registeredEventsSchema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
ensName: { type: 'string' },
|
||||||
|
relayerAddress: addressSchemaType,
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'ensName', 'relayerAddress'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const depositsEventsSchema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
commitment: bytes32SchemaType,
|
||||||
|
leafIndex: { type: 'number' },
|
||||||
|
timestamp: { type: 'number' },
|
||||||
|
from: addressSchemaType,
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'commitment', 'leafIndex', 'timestamp', 'from'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const withdrawalsEventsSchema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
nullifierHash: bytes32SchemaType,
|
||||||
|
to: addressSchemaType,
|
||||||
|
fee: bnSchemaType,
|
||||||
|
timestamp: { type: 'number' },
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'nullifierHash', 'to', 'fee', 'timestamp'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const echoEventsSchema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
address: addressSchemaType,
|
||||||
|
encryptedAccount: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'address', 'encryptedAccount'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export const encryptedNotesSchema = {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
...baseEventsSchemaProperty,
|
||||||
|
encryptedNote: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: [...baseEventsSchemaRequired, 'encryptedNote'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export function getEventsSchemaValidator(type: string) {
|
||||||
|
if (type === DEPOSIT) {
|
||||||
|
return ajv.compile(depositsEventsSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === WITHDRAWAL) {
|
||||||
|
return ajv.compile(withdrawalsEventsSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'governance') {
|
||||||
|
return ajv.compile(governanceEventsSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'registered') {
|
||||||
|
return ajv.compile(registeredEventsSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'echo') {
|
||||||
|
return ajv.compile(echoEventsSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === 'encrypted_notes') {
|
||||||
|
return ajv.compile(encryptedNotesSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error('Unsupported event type for schema validation');
|
||||||
|
}
|
@ -1,21 +1,5 @@
|
|||||||
import Ajv from 'ajv';
|
export * from './ajv';
|
||||||
import type { BigNumberish } from 'ethers';
|
export * from './events';
|
||||||
|
|
||||||
export const ajv = new Ajv({ allErrors: true });
|
|
||||||
|
|
||||||
ajv.addKeyword({
|
|
||||||
keyword: 'BN',
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
validate: (schema: any, data: BigNumberish) => {
|
|
||||||
try {
|
|
||||||
BigInt(data);
|
|
||||||
return true;
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
errors: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
export * from './status';
|
export * from './status';
|
||||||
export * from './jobs';
|
export * from './jobs';
|
||||||
|
export * from './types';
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Config, NetId, NetIdType } from '../networkConfig';
|
import { Config, NetId, NetIdType } from '../networkConfig';
|
||||||
|
import { addressSchemaType, bnSchemaType } from '.';
|
||||||
|
|
||||||
export type statusInstanceType = {
|
export type statusInstanceType = {
|
||||||
type: string;
|
type: string;
|
||||||
@ -6,11 +7,11 @@ export type statusInstanceType = {
|
|||||||
instanceAddress: {
|
instanceAddress: {
|
||||||
type: string;
|
type: string;
|
||||||
properties: {
|
properties: {
|
||||||
[key in string]: typeof addressType;
|
[key in string]: typeof addressSchemaType;
|
||||||
};
|
};
|
||||||
required: string[];
|
required: string[];
|
||||||
};
|
};
|
||||||
tokenAddress?: typeof addressType;
|
tokenAddress?: typeof addressSchemaType;
|
||||||
symbol?: { enum: string[] };
|
symbol?: { enum: string[] };
|
||||||
decimals: { enum: number[] };
|
decimals: { enum: number[] };
|
||||||
};
|
};
|
||||||
@ -28,7 +29,7 @@ export type statusInstancesType = {
|
|||||||
export type statusEthPricesType = {
|
export type statusEthPricesType = {
|
||||||
type: string;
|
type: string;
|
||||||
properties: {
|
properties: {
|
||||||
[key in string]: typeof bnType;
|
[key in string]: typeof bnSchemaType;
|
||||||
};
|
};
|
||||||
required?: string[];
|
required?: string[];
|
||||||
};
|
};
|
||||||
@ -36,7 +37,7 @@ export type statusEthPricesType = {
|
|||||||
export type statusSchema = {
|
export type statusSchema = {
|
||||||
type: string;
|
type: string;
|
||||||
properties: {
|
properties: {
|
||||||
rewardAccount: typeof addressType;
|
rewardAccount: typeof addressSchemaType;
|
||||||
instances?: statusInstancesType;
|
instances?: statusInstancesType;
|
||||||
gasPrices: {
|
gasPrices: {
|
||||||
type: string;
|
type: string;
|
||||||
@ -91,14 +92,10 @@ export type statusSchema = {
|
|||||||
required: string[];
|
required: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const addressType = { type: 'string', pattern: '^0x[a-fA-F0-9]{40}$' };
|
|
||||||
|
|
||||||
const bnType = { type: 'string', BN: true };
|
|
||||||
|
|
||||||
const statusSchema: statusSchema = {
|
const statusSchema: statusSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
rewardAccount: addressType,
|
rewardAccount: addressSchemaType,
|
||||||
gasPrices: {
|
gasPrices: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@ -110,7 +107,7 @@ const statusSchema: statusSchema = {
|
|||||||
netId: { type: 'integer' },
|
netId: { type: 'integer' },
|
||||||
tornadoServiceFee: { type: 'number', maximum: 20, minimum: 0 },
|
tornadoServiceFee: { type: 'number', maximum: 20, minimum: 0 },
|
||||||
latestBlock: { type: 'number' },
|
latestBlock: { type: 'number' },
|
||||||
latestBalance: { type: 'string', BN: true },
|
latestBalance: bnSchemaType,
|
||||||
version: { type: 'string' },
|
version: { type: 'string' },
|
||||||
health: {
|
health: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@ -151,8 +148,8 @@ export function getStatusSchema(netId: NetIdType, config: Config, tovarish: bool
|
|||||||
properties: {
|
properties: {
|
||||||
instanceAddress: {
|
instanceAddress: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: amounts.reduce((acc: { [key in string]: typeof addressType }, cur) => {
|
properties: amounts.reduce((acc: { [key in string]: typeof addressSchemaType }, cur) => {
|
||||||
acc[cur] = addressType;
|
acc[cur] = addressSchemaType;
|
||||||
return acc;
|
return acc;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: amounts.filter((amount) => !optionalInstances.includes(amount)),
|
required: amounts.filter((amount) => !optionalInstances.includes(amount)),
|
||||||
@ -166,7 +163,7 @@ export function getStatusSchema(netId: NetIdType, config: Config, tovarish: bool
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (tokenAddress) {
|
if (tokenAddress) {
|
||||||
instanceProperties.properties.tokenAddress = addressType;
|
instanceProperties.properties.tokenAddress = addressSchemaType;
|
||||||
}
|
}
|
||||||
if (symbol) {
|
if (symbol) {
|
||||||
instanceProperties.properties.symbol = { enum: [symbol] };
|
instanceProperties.properties.symbol = { enum: [symbol] };
|
||||||
@ -198,8 +195,8 @@ export function getStatusSchema(netId: NetIdType, config: Config, tovarish: bool
|
|||||||
if (_tokens.length) {
|
if (_tokens.length) {
|
||||||
const ethPrices: statusEthPricesType = {
|
const ethPrices: statusEthPricesType = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: _tokens.reduce((acc: { [key in string]: typeof bnType }, token: string) => {
|
properties: _tokens.reduce((acc: { [key in string]: typeof bnSchemaType }, token: string) => {
|
||||||
acc[token] = bnType;
|
acc[token] = bnSchemaType;
|
||||||
return acc;
|
return acc;
|
||||||
}, {}),
|
}, {}),
|
||||||
required: _tokens,
|
required: _tokens,
|
||||||
|
9
src/schemas/types.ts
Normal file
9
src/schemas/types.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export const addressSchemaType = {
|
||||||
|
type: 'string',
|
||||||
|
pattern: '^0x[a-fA-F0-9]{40}$',
|
||||||
|
isAddress: true,
|
||||||
|
} as const;
|
||||||
|
export const bnSchemaType = { type: 'string', BN: true } as const;
|
||||||
|
export const proofSchemaType = { type: 'string', pattern: '^0x[a-fA-F0-9]{512}$' } as const;
|
||||||
|
export const bytes32SchemaType = { type: 'string', pattern: '^0x[a-fA-F0-9]{64}$' } as const;
|
||||||
|
export const bytes32BNSchemaType = { ...bytes32SchemaType, BN: true } as const;
|
@ -10,6 +10,7 @@ import {
|
|||||||
} from './relayerClient';
|
} from './relayerClient';
|
||||||
import { fetchData } from './providers';
|
import { fetchData } from './providers';
|
||||||
import { CachedRelayerInfo, MinimalEvents } from './events';
|
import { CachedRelayerInfo, MinimalEvents } from './events';
|
||||||
|
import { getEventsSchemaValidator } from './schemas';
|
||||||
|
|
||||||
// Return no more than 5K events per query
|
// Return no more than 5K events per query
|
||||||
export const MAX_TOVARISH_EVENTS = 5000;
|
export const MAX_TOVARISH_EVENTS = 5000;
|
||||||
@ -181,6 +182,8 @@ export class TovarishClient extends RelayerClient {
|
|||||||
}: TovarishEventsQuery): Promise<BaseTovarishEvents<T>> {
|
}: TovarishEventsQuery): Promise<BaseTovarishEvents<T>> {
|
||||||
const url = `${this.selectedRelayer?.url}events`;
|
const url = `${this.selectedRelayer?.url}events`;
|
||||||
|
|
||||||
|
const schemaValidator = getEventsSchemaValidator(type);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const events = [];
|
const events = [];
|
||||||
let lastSyncBlock = fromBlock;
|
let lastSyncBlock = fromBlock;
|
||||||
@ -203,6 +206,11 @@ export class TovarishClient extends RelayerClient {
|
|||||||
}),
|
}),
|
||||||
})) as BaseTovarishEvents<T>;
|
})) as BaseTovarishEvents<T>;
|
||||||
|
|
||||||
|
if (!schemaValidator(fetchedEvents)) {
|
||||||
|
const errMsg = `Schema validation failed for ${type} events`;
|
||||||
|
throw new Error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
lastSyncBlock = currentBlock;
|
lastSyncBlock = currentBlock;
|
||||||
|
|
||||||
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
if (!Array.isArray(fetchedEvents) || !fetchedEvents.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user