Fixed token price calculation
This commit is contained in:
parent
c06ade8901
commit
767883f1e7
233
dist/index.js
vendored
233
dist/index.js
vendored
@ -2667,7 +2667,7 @@ function substring(str, length = 10) {
|
|||||||
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$e = (__this, __arguments, generator) => {
|
var __async$f = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -2688,7 +2688,7 @@ var __async$e = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
function multicall(Multicall2, calls) {
|
function multicall(Multicall2, calls) {
|
||||||
return __async$e(this, null, function* () {
|
return __async$f(this, null, function* () {
|
||||||
const calldata = calls.map((call) => {
|
const calldata = calls.map((call) => {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
const target = ((_a = call.contract) == null ? void 0 : _a.target) || call.address;
|
const target = ((_a = call.contract) == null ? void 0 : _a.target) || call.address;
|
||||||
@ -2733,7 +2733,7 @@ var __spreadValues$5 = (a, b) => {
|
|||||||
};
|
};
|
||||||
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
||||||
var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
|
var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
|
||||||
var __async$d = (__this, __arguments, generator) => {
|
var __async$e = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -2779,7 +2779,7 @@ function getHttpAgent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function fetchData(_0) {
|
function fetchData(_0) {
|
||||||
return __async$d(this, arguments, function* (url, options = {}) {
|
return __async$e(this, arguments, function* (url, options = {}) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
const MAX_RETRY = (_a = options.maxRetry) != null ? _a : 3;
|
const MAX_RETRY = (_a = options.maxRetry) != null ? _a : 3;
|
||||||
const RETRY_ON = (_b = options.retryOn) != null ? _b : 500;
|
const RETRY_ON = (_b = options.retryOn) != null ? _b : 500;
|
||||||
@ -2871,7 +2871,7 @@ function fetchData(_0) {
|
|||||||
throw errorObject;
|
throw errorObject;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$d(void 0, null, function* () {
|
const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$e(void 0, null, function* () {
|
||||||
let signal;
|
let signal;
|
||||||
if (_signal) {
|
if (_signal) {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
@ -2905,7 +2905,7 @@ const oracleMapper = /* @__PURE__ */ new Map();
|
|||||||
const multicallMapper = /* @__PURE__ */ new Map();
|
const multicallMapper = /* @__PURE__ */ new Map();
|
||||||
function getGasOraclePlugin(networkKey, fetchOptions) {
|
function getGasOraclePlugin(networkKey, fetchOptions) {
|
||||||
const gasStationApi = (fetchOptions == null ? void 0 : fetchOptions.gasStationApi) || "https://gasstation.polygon.technology/v2";
|
const gasStationApi = (fetchOptions == null ? void 0 : fetchOptions.gasStationApi) || "https://gasstation.polygon.technology/v2";
|
||||||
return new ethers.FetchUrlFeeDataNetworkPlugin(gasStationApi, (fetchFeeData, provider, request) => __async$d(this, null, function* () {
|
return new ethers.FetchUrlFeeDataNetworkPlugin(gasStationApi, (fetchFeeData, provider, request) => __async$e(this, null, function* () {
|
||||||
if (!oracleMapper.has(networkKey)) {
|
if (!oracleMapper.has(networkKey)) {
|
||||||
oracleMapper.set(networkKey, GasPriceOracle__factory.connect(fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle, provider));
|
oracleMapper.set(networkKey, GasPriceOracle__factory.connect(fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle, provider));
|
||||||
}
|
}
|
||||||
@ -2964,7 +2964,7 @@ function getGasOraclePlugin(networkKey, fetchOptions) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
function getProvider(rpcUrl, fetchOptions) {
|
function getProvider(rpcUrl, fetchOptions) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
const fetchReq = new ethers.FetchRequest(rpcUrl);
|
const fetchReq = new ethers.FetchRequest(rpcUrl);
|
||||||
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
||||||
const _staticNetwork = yield new ethers.JsonRpcProvider(fetchReq).getNetwork();
|
const _staticNetwork = yield new ethers.JsonRpcProvider(fetchReq).getNetwork();
|
||||||
@ -3014,7 +3014,7 @@ function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) {
|
|||||||
provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || pollInterval * 1e3;
|
provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || pollInterval * 1e3;
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
const populateTransaction = (signer, tx) => __async$d(void 0, null, function* () {
|
const populateTransaction = (signer, tx) => __async$e(void 0, null, function* () {
|
||||||
const provider = signer.provider;
|
const provider = signer.provider;
|
||||||
if (!tx.from) {
|
if (!tx.from) {
|
||||||
tx.from = signer.address;
|
tx.from = signer.address;
|
||||||
@ -3023,7 +3023,7 @@ const populateTransaction = (signer, tx) => __async$d(void 0, null, function* ()
|
|||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
const [feeData, nonce] = yield Promise.all([
|
const [feeData, nonce] = yield Promise.all([
|
||||||
(() => __async$d(void 0, null, function* () {
|
(() => __async$e(void 0, null, function* () {
|
||||||
if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
|
if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
|
||||||
return new ethers.FeeData(null, BigInt(tx.maxFeePerGas), BigInt(tx.maxPriorityFeePerGas));
|
return new ethers.FeeData(null, BigInt(tx.maxFeePerGas), BigInt(tx.maxPriorityFeePerGas));
|
||||||
}
|
}
|
||||||
@ -3045,7 +3045,7 @@ const populateTransaction = (signer, tx) => __async$d(void 0, null, function* ()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}))(),
|
}))(),
|
||||||
(() => __async$d(void 0, null, function* () {
|
(() => __async$e(void 0, null, function* () {
|
||||||
if (tx.nonce) {
|
if (tx.nonce) {
|
||||||
return tx.nonce;
|
return tx.nonce;
|
||||||
}
|
}
|
||||||
@ -3075,7 +3075,7 @@ const populateTransaction = (signer, tx) => __async$d(void 0, null, function* ()
|
|||||||
delete tx.maxFeePerGas;
|
delete tx.maxFeePerGas;
|
||||||
delete tx.maxPriorityFeePerGas;
|
delete tx.maxPriorityFeePerGas;
|
||||||
}
|
}
|
||||||
tx.gasLimit = tx.gasLimit || (yield (() => __async$d(void 0, null, function* () {
|
tx.gasLimit = tx.gasLimit || (yield (() => __async$e(void 0, null, function* () {
|
||||||
try {
|
try {
|
||||||
const gasLimit = yield provider.estimateGas(tx);
|
const gasLimit = yield provider.estimateGas(tx);
|
||||||
return gasLimit === BigInt(21e3) ? gasLimit : gasLimit * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4);
|
return gasLimit === BigInt(21e3) ? gasLimit : gasLimit * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4);
|
||||||
@ -3103,7 +3103,7 @@ class TornadoWallet extends ethers.Wallet {
|
|||||||
return new TornadoWallet(privateKey, provider, options);
|
return new TornadoWallet(privateKey, provider, options);
|
||||||
}
|
}
|
||||||
populateTransaction(tx) {
|
populateTransaction(tx) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
const txObject = yield populateTransaction(this, tx);
|
const txObject = yield populateTransaction(this, tx);
|
||||||
this.nonce = txObject.nonce;
|
this.nonce = txObject.nonce;
|
||||||
return __superGet$1(TornadoWallet.prototype, this, "populateTransaction").call(this, txObject);
|
return __superGet$1(TornadoWallet.prototype, this, "populateTransaction").call(this, txObject);
|
||||||
@ -3119,7 +3119,7 @@ class TornadoVoidSigner extends ethers.VoidSigner {
|
|||||||
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
||||||
}
|
}
|
||||||
populateTransaction(tx) {
|
populateTransaction(tx) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
const txObject = yield populateTransaction(this, tx);
|
const txObject = yield populateTransaction(this, tx);
|
||||||
this.nonce = txObject.nonce;
|
this.nonce = txObject.nonce;
|
||||||
return __superGet$1(TornadoVoidSigner.prototype, this, "populateTransaction").call(this, txObject);
|
return __superGet$1(TornadoVoidSigner.prototype, this, "populateTransaction").call(this, txObject);
|
||||||
@ -3135,7 +3135,7 @@ class TornadoRpcSigner extends ethers.JsonRpcSigner {
|
|||||||
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
||||||
}
|
}
|
||||||
sendUncheckedTransaction(tx) {
|
sendUncheckedTransaction(tx) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
return __superGet$1(TornadoRpcSigner.prototype, this, "sendUncheckedTransaction").call(this, yield populateTransaction(this, tx));
|
return __superGet$1(TornadoRpcSigner.prototype, this, "sendUncheckedTransaction").call(this, yield populateTransaction(this, tx));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3146,7 +3146,7 @@ class TornadoBrowserProvider extends ethers.BrowserProvider {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
getSigner(address) {
|
getSigner(address) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
||||||
const signerAddress = (yield __superGet$1(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address;
|
const signerAddress = (yield __superGet$1(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address;
|
||||||
if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$1(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) {
|
if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$1(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) {
|
||||||
@ -3374,7 +3374,7 @@ var __spreadValues$4 = (a, b) => {
|
|||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
||||||
var __async$c = (__this, __arguments, generator) => {
|
var __async$d = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -3397,7 +3397,7 @@ var __async$c = (__this, __arguments, generator) => {
|
|||||||
const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length;
|
const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length;
|
||||||
const first = 1e3;
|
const first = 1e3;
|
||||||
function queryGraph(_0) {
|
function queryGraph(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
query,
|
query,
|
||||||
@ -3426,7 +3426,7 @@ function queryGraph(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getStatistic(_0) {
|
function getStatistic(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
currency,
|
currency,
|
||||||
@ -3473,7 +3473,7 @@ function getStatistic(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getMeta(_0) {
|
function getMeta(_0) {
|
||||||
return __async$c(this, arguments, function* ({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) {
|
return __async$d(this, arguments, function* ({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
_meta: {
|
_meta: {
|
||||||
@ -3518,7 +3518,7 @@ function getRegisters({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllRegisters(_0) {
|
function getAllRegisters(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -3607,7 +3607,7 @@ function getDeposits({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllDeposits(_0) {
|
function getAllDeposits(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
currency,
|
currency,
|
||||||
@ -3704,7 +3704,7 @@ function getWithdrawals({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllWithdrawals(_0) {
|
function getAllWithdrawals(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
currency,
|
currency,
|
||||||
@ -3780,7 +3780,7 @@ function getAllWithdrawals(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getNoteAccounts(_0) {
|
function getNoteAccounts(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
address,
|
address,
|
||||||
@ -3833,7 +3833,7 @@ function getGraphEchoEvents({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllGraphEchoEvents(_0) {
|
function getAllGraphEchoEvents(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -3922,7 +3922,7 @@ function getEncryptedNotes({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllEncryptedNotes(_0) {
|
function getAllEncryptedNotes(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -4007,7 +4007,7 @@ function getGovernanceEvents({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllGovernanceEvents(_0) {
|
function getAllGovernanceEvents(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -4166,7 +4166,7 @@ var graph = /*#__PURE__*/Object.freeze({
|
|||||||
queryGraph: queryGraph
|
queryGraph: queryGraph
|
||||||
});
|
});
|
||||||
|
|
||||||
var __async$b = (__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) => {
|
||||||
try {
|
try {
|
||||||
@ -4205,7 +4205,7 @@ class BatchBlockService {
|
|||||||
this.retryOn = retryOn;
|
this.retryOn = retryOn;
|
||||||
}
|
}
|
||||||
getBlock(blockTag) {
|
getBlock(blockTag) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
const blockObject = yield this.provider.getBlock(blockTag);
|
const blockObject = yield this.provider.getBlock(blockTag);
|
||||||
if (!blockObject) {
|
if (!blockObject) {
|
||||||
const errMsg = `No block for ${blockTag}`;
|
const errMsg = `No block for ${blockTag}`;
|
||||||
@ -4215,9 +4215,9 @@ class BatchBlockService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createBatchRequest(batchArray) {
|
createBatchRequest(batchArray) {
|
||||||
return batchArray.map((blocks, index) => __async$b(this, null, function* () {
|
return batchArray.map((blocks, index) => __async$c(this, null, function* () {
|
||||||
yield sleep(20 * index);
|
yield sleep(20 * index);
|
||||||
return (() => __async$b(this, null, function* () {
|
return (() => __async$c(this, null, function* () {
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
let err;
|
let err;
|
||||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||||
@ -4234,7 +4234,7 @@ class BatchBlockService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
getBatchBlocks(blocks) {
|
getBatchBlocks(blocks) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
let blockCount = 0;
|
let blockCount = 0;
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) {
|
for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) {
|
||||||
@ -4272,7 +4272,7 @@ class BatchTransactionService {
|
|||||||
this.retryOn = retryOn;
|
this.retryOn = retryOn;
|
||||||
}
|
}
|
||||||
getTransaction(txHash) {
|
getTransaction(txHash) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
const txObject = yield this.provider.getTransaction(txHash);
|
const txObject = yield this.provider.getTransaction(txHash);
|
||||||
if (!txObject) {
|
if (!txObject) {
|
||||||
const errMsg = `No transaction for ${txHash}`;
|
const errMsg = `No transaction for ${txHash}`;
|
||||||
@ -4282,9 +4282,9 @@ class BatchTransactionService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createBatchRequest(batchArray) {
|
createBatchRequest(batchArray) {
|
||||||
return batchArray.map((txs, index) => __async$b(this, null, function* () {
|
return batchArray.map((txs, index) => __async$c(this, null, function* () {
|
||||||
yield sleep(20 * index);
|
yield sleep(20 * index);
|
||||||
return (() => __async$b(this, null, function* () {
|
return (() => __async$c(this, null, function* () {
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
let err;
|
let err;
|
||||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||||
@ -4301,7 +4301,7 @@ class BatchTransactionService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
getBatchTransactions(txs) {
|
getBatchTransactions(txs) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
let txCount = 0;
|
let txCount = 0;
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) {
|
for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) {
|
||||||
@ -4337,7 +4337,7 @@ class BatchEventsService {
|
|||||||
this.retryOn = retryOn;
|
this.retryOn = retryOn;
|
||||||
}
|
}
|
||||||
getPastEvents(_0) {
|
getPastEvents(_0) {
|
||||||
return __async$b(this, arguments, function* ({ fromBlock, toBlock, type }) {
|
return __async$c(this, arguments, function* ({ fromBlock, toBlock, type }) {
|
||||||
let err;
|
let err;
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||||
@ -4357,13 +4357,13 @@ class BatchEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createBatchRequest(batchArray) {
|
createBatchRequest(batchArray) {
|
||||||
return batchArray.map((event, index) => __async$b(this, null, function* () {
|
return batchArray.map((event, index) => __async$c(this, null, function* () {
|
||||||
yield sleep(20 * index);
|
yield sleep(20 * index);
|
||||||
return this.getPastEvents(event);
|
return this.getPastEvents(event);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
getBatchEvents(_0) {
|
getBatchEvents(_0) {
|
||||||
return __async$b(this, arguments, function* ({ fromBlock, toBlock, type = "*" }) {
|
return __async$c(this, arguments, function* ({ fromBlock, toBlock, type = "*" }) {
|
||||||
if (!toBlock) {
|
if (!toBlock) {
|
||||||
toBlock = yield this.provider.getBlockNumber();
|
toBlock = yield this.provider.getBlockNumber();
|
||||||
}
|
}
|
||||||
@ -4416,7 +4416,7 @@ var __spreadValues$3 = (a, b) => {
|
|||||||
};
|
};
|
||||||
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
||||||
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
||||||
var __async$a = (__this, __arguments, generator) => {
|
var __async$b = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -4491,7 +4491,7 @@ class BaseEventsService {
|
|||||||
}
|
}
|
||||||
/* eslint-enable @typescript-eslint/no-unused-vars */
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return yield new Promise((resolve) => resolve(events));
|
return yield new Promise((resolve) => resolve(events));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4499,7 +4499,7 @@ class BaseEventsService {
|
|||||||
* Get saved or cached events
|
* Get saved or cached events
|
||||||
*/
|
*/
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
lastBlock: null
|
lastBlock: null
|
||||||
@ -4507,7 +4507,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
lastBlock: null
|
lastBlock: null
|
||||||
@ -4515,7 +4515,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getSavedEvents() {
|
getSavedEvents() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
let cachedEvents = yield this.getEventsFromDB();
|
let cachedEvents = yield this.getEventsFromDB();
|
||||||
if (!cachedEvents || !cachedEvents.events.length) {
|
if (!cachedEvents || !cachedEvents.events.length) {
|
||||||
cachedEvents = yield this.getEventsFromCache();
|
cachedEvents = yield this.getEventsFromCache();
|
||||||
@ -4527,7 +4527,7 @@ class BaseEventsService {
|
|||||||
* Get latest events
|
* Get latest events
|
||||||
*/
|
*/
|
||||||
getEventsFromGraph(_0) {
|
getEventsFromGraph(_0) {
|
||||||
return __async$a(this, arguments, function* ({
|
return __async$b(this, arguments, function* ({
|
||||||
fromBlock,
|
fromBlock,
|
||||||
methodName = ""
|
methodName = ""
|
||||||
}) {
|
}) {
|
||||||
@ -4547,7 +4547,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromRpc(_0) {
|
getEventsFromRpc(_0) {
|
||||||
return __async$a(this, arguments, function* ({
|
return __async$b(this, arguments, function* ({
|
||||||
fromBlock,
|
fromBlock,
|
||||||
toBlock
|
toBlock
|
||||||
}) {
|
}) {
|
||||||
@ -4585,7 +4585,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getLatestEvents(_0) {
|
getLatestEvents(_0) {
|
||||||
return __async$a(this, arguments, function* ({ fromBlock }) {
|
return __async$b(this, arguments, function* ({ fromBlock }) {
|
||||||
const allEvents = [];
|
const allEvents = [];
|
||||||
const graphEvents = yield this.getEventsFromGraph({ fromBlock });
|
const graphEvents = yield this.getEventsFromGraph({ fromBlock });
|
||||||
const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock;
|
const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock;
|
||||||
@ -4607,14 +4607,14 @@ class BaseEventsService {
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$a(this, arguments, function* ({ events, lastBlock }) {
|
return __async$b(this, arguments, function* ({ events, lastBlock }) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Trigger saving and receiving latest events
|
* Trigger saving and receiving latest events
|
||||||
*/
|
*/
|
||||||
updateEvents() {
|
updateEvents() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
const savedEvents = yield this.getSavedEvents();
|
const savedEvents = yield this.getSavedEvents();
|
||||||
let fromBlock = this.deployedBlock;
|
let fromBlock = this.deployedBlock;
|
||||||
if (savedEvents && savedEvents.lastBlock) {
|
if (savedEvents && savedEvents.lastBlock) {
|
||||||
@ -4688,7 +4688,7 @@ class BaseDepositsService extends BaseEventsService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
const type = this.getType().toLowerCase();
|
const type = this.getType().toLowerCase();
|
||||||
if (type === DEPOSIT) {
|
if (type === DEPOSIT) {
|
||||||
const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
@ -4767,7 +4767,7 @@ class BaseEchoService extends BaseEventsService {
|
|||||||
return "getAllGraphEchoEvents";
|
return "getAllGraphEchoEvents";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
const { who, data } = args;
|
const { who, data } = args;
|
||||||
if (who && data) {
|
if (who && data) {
|
||||||
@ -4785,7 +4785,7 @@ class BaseEchoService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromGraph(_0) {
|
getEventsFromGraph(_0) {
|
||||||
return __async$a(this, arguments, function* ({ fromBlock }) {
|
return __async$b(this, arguments, function* ({ fromBlock }) {
|
||||||
if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) {
|
if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
@ -4818,7 +4818,7 @@ class BaseEncryptedNotesService extends BaseEventsService {
|
|||||||
return "getAllEncryptedNotes";
|
return "getAllEncryptedNotes";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
const { encryptedNote } = args;
|
const { encryptedNote } = args;
|
||||||
if (encryptedNote) {
|
if (encryptedNote) {
|
||||||
@ -4861,7 +4861,7 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
return "getAllGovernanceEvents";
|
return "getAllGovernanceEvents";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
const proposalEvents = [];
|
const proposalEvents = [];
|
||||||
const votedEvents = [];
|
const votedEvents = [];
|
||||||
const delegatedEvents = [];
|
const delegatedEvents = [];
|
||||||
@ -4928,7 +4928,7 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromGraph(_0) {
|
getEventsFromGraph(_0) {
|
||||||
return __async$a(this, arguments, function* ({ fromBlock }) {
|
return __async$b(this, arguments, function* ({ fromBlock }) {
|
||||||
if (!this.graphApi || !this.subgraphName || this.graphApi.includes("api.thegraph.com")) {
|
if (!this.graphApi || !this.subgraphName || this.graphApi.includes("api.thegraph.com")) {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
@ -4963,7 +4963,7 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
return "getAllRegisters";
|
return "getAllRegisters";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
const eventObjects = {
|
const eventObjects = {
|
||||||
blockNumber,
|
blockNumber,
|
||||||
@ -4978,13 +4978,13 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
fetchRelayers() {
|
fetchRelayers() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return (yield this.updateEvents()).events;
|
return (yield this.updateEvents()).events;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$9 = (__this, __arguments, generator) => {
|
var __async$a = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -5005,7 +5005,7 @@ var __async$9 = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
function existsAsync(fileOrDir) {
|
function existsAsync(fileOrDir) {
|
||||||
return __async$9(this, null, function* () {
|
return __async$a(this, null, function* () {
|
||||||
try {
|
try {
|
||||||
yield promises.stat(fileOrDir);
|
yield promises.stat(fileOrDir);
|
||||||
return true;
|
return true;
|
||||||
@ -5037,7 +5037,7 @@ function unzipAsync(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function saveUserFile(_0) {
|
function saveUserFile(_0) {
|
||||||
return __async$9(this, arguments, function* ({
|
return __async$a(this, arguments, function* ({
|
||||||
fileName,
|
fileName,
|
||||||
userDirectory,
|
userDirectory,
|
||||||
dataString
|
dataString
|
||||||
@ -5055,7 +5055,7 @@ function saveUserFile(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function loadSavedEvents(_0) {
|
function loadSavedEvents(_0) {
|
||||||
return __async$9(this, arguments, function* ({
|
return __async$a(this, arguments, function* ({
|
||||||
name,
|
name,
|
||||||
userDirectory,
|
userDirectory,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
@ -5084,7 +5084,7 @@ function loadSavedEvents(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function download(_0) {
|
function download(_0) {
|
||||||
return __async$9(this, arguments, function* ({ name, cacheDirectory }) {
|
return __async$a(this, arguments, function* ({ name, cacheDirectory }) {
|
||||||
const fileName = `${name}.json`.toLowerCase();
|
const fileName = `${name}.json`.toLowerCase();
|
||||||
const zipName = `${fileName}.zip`;
|
const zipName = `${fileName}.zip`;
|
||||||
const zipPath = path.join(cacheDirectory, zipName);
|
const zipPath = path.join(cacheDirectory, zipName);
|
||||||
@ -5094,7 +5094,7 @@ function download(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function loadCachedEvents(_0) {
|
function loadCachedEvents(_0) {
|
||||||
return __async$9(this, arguments, function* ({
|
return __async$a(this, arguments, function* ({
|
||||||
name,
|
name,
|
||||||
cacheDirectory,
|
cacheDirectory,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
@ -5124,7 +5124,7 @@ function loadCachedEvents(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$8 = (__this, __arguments, generator) => {
|
var __async$9 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -5209,7 +5209,7 @@ class NodeDepositsService extends BaseDepositsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(
|
console.log(
|
||||||
"Updating events for",
|
"Updating events for",
|
||||||
@ -5240,7 +5240,7 @@ class NodeDepositsService extends BaseDepositsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5262,7 +5262,7 @@ class NodeDepositsService extends BaseDepositsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5341,7 +5341,7 @@ class NodeEchoService extends BaseEchoService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain echo events
|
console.log(`Updating events for ${this.netId} chain echo events
|
||||||
`);
|
`);
|
||||||
@ -5367,7 +5367,7 @@ class NodeEchoService extends BaseEchoService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5389,7 +5389,7 @@ class NodeEchoService extends BaseEchoService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5467,7 +5467,7 @@ class NodeEncryptedNotesService extends BaseEncryptedNotesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain encrypted events
|
console.log(`Updating events for ${this.netId} chain encrypted events
|
||||||
`);
|
`);
|
||||||
@ -5493,7 +5493,7 @@ class NodeEncryptedNotesService extends BaseEncryptedNotesService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5515,7 +5515,7 @@ class NodeEncryptedNotesService extends BaseEncryptedNotesService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5598,7 +5598,7 @@ class NodeGovernanceService extends BaseGovernanceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain governance events
|
console.log(`Updating events for ${this.netId} chain governance events
|
||||||
`);
|
`);
|
||||||
@ -5624,7 +5624,7 @@ class NodeGovernanceService extends BaseGovernanceService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5646,7 +5646,7 @@ class NodeGovernanceService extends BaseGovernanceService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5724,7 +5724,7 @@ class NodeRegistryService extends BaseRegistryService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain registry events
|
console.log(`Updating events for ${this.netId} chain registry events
|
||||||
`);
|
`);
|
||||||
@ -5750,7 +5750,7 @@ class NodeRegistryService extends BaseRegistryService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5772,7 +5772,7 @@ class NodeRegistryService extends BaseRegistryService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -6603,7 +6603,7 @@ ajv.addKeyword({
|
|||||||
errors: true
|
errors: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var __async$7 = (__this, __arguments, generator) => {
|
var __async$8 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -6628,13 +6628,13 @@ class Pedersen {
|
|||||||
this.pedersenPromise = this.initPedersen();
|
this.pedersenPromise = this.initPedersen();
|
||||||
}
|
}
|
||||||
initPedersen() {
|
initPedersen() {
|
||||||
return __async$7(this, null, function* () {
|
return __async$8(this, null, function* () {
|
||||||
this.pedersenHash = yield circomlibjs.buildPedersenHash();
|
this.pedersenHash = yield circomlibjs.buildPedersenHash();
|
||||||
this.babyJub = this.pedersenHash.babyJub;
|
this.babyJub = this.pedersenHash.babyJub;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
unpackPoint(buffer) {
|
unpackPoint(buffer) {
|
||||||
return __async$7(this, null, function* () {
|
return __async$8(this, null, function* () {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
yield this.pedersenPromise;
|
yield this.pedersenPromise;
|
||||||
return (_b = this.babyJub) == null ? void 0 : _b.unpackPoint((_a = this.pedersenHash) == null ? void 0 : _a.hash(buffer));
|
return (_b = this.babyJub) == null ? void 0 : _b.unpackPoint((_a = this.pedersenHash) == null ? void 0 : _a.hash(buffer));
|
||||||
@ -6647,13 +6647,13 @@ class Pedersen {
|
|||||||
}
|
}
|
||||||
const pedersen = new Pedersen();
|
const pedersen = new Pedersen();
|
||||||
function buffPedersenHash(buffer) {
|
function buffPedersenHash(buffer) {
|
||||||
return __async$7(this, null, function* () {
|
return __async$8(this, null, function* () {
|
||||||
const [hash] = yield pedersen.unpackPoint(buffer);
|
const [hash] = yield pedersen.unpackPoint(buffer);
|
||||||
return pedersen.toStringBuffer(hash);
|
return pedersen.toStringBuffer(hash);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$6 = (__this, __arguments, generator) => {
|
var __async$7 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -6674,7 +6674,7 @@ var __async$6 = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
function createDeposit(_0) {
|
function createDeposit(_0) {
|
||||||
return __async$6(this, arguments, function* ({ nullifier, secret }) {
|
return __async$7(this, arguments, function* ({ nullifier, secret }) {
|
||||||
const preimage = new Uint8Array([...leInt2Buff(nullifier), ...leInt2Buff(secret)]);
|
const preimage = new Uint8Array([...leInt2Buff(nullifier), ...leInt2Buff(secret)]);
|
||||||
const noteHex = toFixedHex(bytesToBN(preimage), 62);
|
const noteHex = toFixedHex(bytesToBN(preimage), 62);
|
||||||
const commitment = BigInt(yield buffPedersenHash(preimage));
|
const commitment = BigInt(yield buffPedersenHash(preimage));
|
||||||
@ -6734,7 +6734,7 @@ class Deposit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
static createNote(_0) {
|
static createNote(_0) {
|
||||||
return __async$6(this, arguments, function* ({ currency, amount, netId, nullifier, secret }) {
|
return __async$7(this, arguments, function* ({ currency, amount, netId, nullifier, secret }) {
|
||||||
if (!nullifier) {
|
if (!nullifier) {
|
||||||
nullifier = rBigInt(31);
|
nullifier = rBigInt(31);
|
||||||
}
|
}
|
||||||
@ -6761,7 +6761,7 @@ class Deposit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
static parseNote(noteString) {
|
static parseNote(noteString) {
|
||||||
return __async$6(this, null, function* () {
|
return __async$7(this, null, function* () {
|
||||||
const noteRegex = new RegExp("tornado-(?<currency>\\w+)-(?<amount>[\\d.]+)-(?<netId>\\d+)-0x(?<note>[0-9a-fA-F]{124})", "g");
|
const noteRegex = new RegExp("tornado-(?<currency>\\w+)-(?<amount>[\\d.]+)-(?<netId>\\d+)-0x(?<note>[0-9a-fA-F]{124})", "g");
|
||||||
const match = noteRegex.exec(noteString);
|
const match = noteRegex.exec(noteString);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@ -7021,7 +7021,7 @@ class TornadoFeeOracle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$5 = (__this, __arguments, generator) => {
|
var __async$6 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -7046,7 +7046,7 @@ class Mimc {
|
|||||||
this.mimcPromise = this.initMimc();
|
this.mimcPromise = this.initMimc();
|
||||||
}
|
}
|
||||||
initMimc() {
|
initMimc() {
|
||||||
return __async$5(this, null, function* () {
|
return __async$6(this, null, function* () {
|
||||||
this.sponge = yield circomlibjs.buildMimcSponge();
|
this.sponge = yield circomlibjs.buildMimcSponge();
|
||||||
this.hash = (left, right) => {
|
this.hash = (left, right) => {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
@ -7055,7 +7055,7 @@ class Mimc {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getHash() {
|
getHash() {
|
||||||
return __async$5(this, null, function* () {
|
return __async$6(this, null, function* () {
|
||||||
yield this.mimcPromise;
|
yield this.mimcPromise;
|
||||||
return {
|
return {
|
||||||
sponge: this.sponge,
|
sponge: this.sponge,
|
||||||
@ -7066,7 +7066,7 @@ class Mimc {
|
|||||||
}
|
}
|
||||||
const mimc = new Mimc();
|
const mimc = new Mimc();
|
||||||
|
|
||||||
var __async$4 = (__this, __arguments, generator) => {
|
var __async$5 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -7109,7 +7109,7 @@ class MerkleTreeService {
|
|||||||
this.merkleWorkerPath = merkleWorkerPath;
|
this.merkleWorkerPath = merkleWorkerPath;
|
||||||
}
|
}
|
||||||
createTree(events) {
|
createTree(events) {
|
||||||
return __async$4(this, null, function* () {
|
return __async$5(this, null, function* () {
|
||||||
const { hash: hashFunction } = yield mimc.getHash();
|
const { hash: hashFunction } = yield mimc.getHash();
|
||||||
if (this.merkleWorkerPath) {
|
if (this.merkleWorkerPath) {
|
||||||
console.log("Using merkleWorker\n");
|
console.log("Using merkleWorker\n");
|
||||||
@ -7161,7 +7161,7 @@ class MerkleTreeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createPartialTree(_0) {
|
createPartialTree(_0) {
|
||||||
return __async$4(this, arguments, function* ({ edge, elements }) {
|
return __async$5(this, arguments, function* ({ edge, elements }) {
|
||||||
const { hash: hashFunction } = yield mimc.getHash();
|
const { hash: hashFunction } = yield mimc.getHash();
|
||||||
if (this.merkleWorkerPath) {
|
if (this.merkleWorkerPath) {
|
||||||
console.log("Using merkleWorker\n");
|
console.log("Using merkleWorker\n");
|
||||||
@ -7215,7 +7215,7 @@ class MerkleTreeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
verifyTree(events) {
|
verifyTree(events) {
|
||||||
return __async$4(this, null, function* () {
|
return __async$5(this, null, function* () {
|
||||||
console.log(
|
console.log(
|
||||||
`
|
`
|
||||||
Creating deposit tree for ${this.netId} ${this.amount} ${this.currency.toUpperCase()} would take a while
|
Creating deposit tree for ${this.netId} ${this.amount} ${this.currency.toUpperCase()} would take a while
|
||||||
@ -7300,6 +7300,26 @@ function parseRecoveryKey(value) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var __async$4 = (__this, __arguments, generator) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var fulfilled = (value) => {
|
||||||
|
try {
|
||||||
|
step(generator.next(value));
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var rejected = (value) => {
|
||||||
|
try {
|
||||||
|
step(generator.throw(value));
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
class TokenPriceOracle {
|
class TokenPriceOracle {
|
||||||
constructor(provider, multicall2, oracle) {
|
constructor(provider, multicall2, oracle) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
@ -7307,17 +7327,22 @@ class TokenPriceOracle {
|
|||||||
this.oracle = oracle;
|
this.oracle = oracle;
|
||||||
}
|
}
|
||||||
fetchPrices(tokens) {
|
fetchPrices(tokens) {
|
||||||
if (!this.oracle) {
|
return __async$4(this, null, function* () {
|
||||||
return new Promise((resolve) => resolve(tokens.map(() => ethers.parseEther("0.0001"))));
|
if (!this.oracle) {
|
||||||
}
|
return new Promise((resolve) => resolve(tokens.map(() => ethers.parseEther("0.0001"))));
|
||||||
return multicall(
|
}
|
||||||
this.multicall,
|
const prices = yield multicall(
|
||||||
tokens.map((token) => ({
|
this.multicall,
|
||||||
contract: this.oracle,
|
tokens.map(({ tokenAddress }) => ({
|
||||||
name: "getRateToEth",
|
contract: this.oracle,
|
||||||
params: [token, true]
|
name: "getRateToEth",
|
||||||
}))
|
params: [tokenAddress, true]
|
||||||
);
|
}))
|
||||||
|
);
|
||||||
|
return prices.map((price, index) => {
|
||||||
|
return price * BigInt(10 ** tokens[index].decimals) / BigInt(10 ** 18);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
233
dist/index.mjs
vendored
233
dist/index.mjs
vendored
@ -2646,7 +2646,7 @@ function substring(str, length = 10) {
|
|||||||
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$e = (__this, __arguments, generator) => {
|
var __async$f = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -2667,7 +2667,7 @@ var __async$e = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
function multicall(Multicall2, calls) {
|
function multicall(Multicall2, calls) {
|
||||||
return __async$e(this, null, function* () {
|
return __async$f(this, null, function* () {
|
||||||
const calldata = calls.map((call) => {
|
const calldata = calls.map((call) => {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
const target = ((_a = call.contract) == null ? void 0 : _a.target) || call.address;
|
const target = ((_a = call.contract) == null ? void 0 : _a.target) || call.address;
|
||||||
@ -2712,7 +2712,7 @@ var __spreadValues$5 = (a, b) => {
|
|||||||
};
|
};
|
||||||
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
||||||
var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
|
var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj);
|
||||||
var __async$d = (__this, __arguments, generator) => {
|
var __async$e = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -2758,7 +2758,7 @@ function getHttpAgent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function fetchData(_0) {
|
function fetchData(_0) {
|
||||||
return __async$d(this, arguments, function* (url, options = {}) {
|
return __async$e(this, arguments, function* (url, options = {}) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
const MAX_RETRY = (_a = options.maxRetry) != null ? _a : 3;
|
const MAX_RETRY = (_a = options.maxRetry) != null ? _a : 3;
|
||||||
const RETRY_ON = (_b = options.retryOn) != null ? _b : 500;
|
const RETRY_ON = (_b = options.retryOn) != null ? _b : 500;
|
||||||
@ -2850,7 +2850,7 @@ function fetchData(_0) {
|
|||||||
throw errorObject;
|
throw errorObject;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$d(void 0, null, function* () {
|
const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$e(void 0, null, function* () {
|
||||||
let signal;
|
let signal;
|
||||||
if (_signal) {
|
if (_signal) {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
@ -2884,7 +2884,7 @@ const oracleMapper = /* @__PURE__ */ new Map();
|
|||||||
const multicallMapper = /* @__PURE__ */ new Map();
|
const multicallMapper = /* @__PURE__ */ new Map();
|
||||||
function getGasOraclePlugin(networkKey, fetchOptions) {
|
function getGasOraclePlugin(networkKey, fetchOptions) {
|
||||||
const gasStationApi = (fetchOptions == null ? void 0 : fetchOptions.gasStationApi) || "https://gasstation.polygon.technology/v2";
|
const gasStationApi = (fetchOptions == null ? void 0 : fetchOptions.gasStationApi) || "https://gasstation.polygon.technology/v2";
|
||||||
return new FetchUrlFeeDataNetworkPlugin(gasStationApi, (fetchFeeData, provider, request) => __async$d(this, null, function* () {
|
return new FetchUrlFeeDataNetworkPlugin(gasStationApi, (fetchFeeData, provider, request) => __async$e(this, null, function* () {
|
||||||
if (!oracleMapper.has(networkKey)) {
|
if (!oracleMapper.has(networkKey)) {
|
||||||
oracleMapper.set(networkKey, GasPriceOracle__factory.connect(fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle, provider));
|
oracleMapper.set(networkKey, GasPriceOracle__factory.connect(fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle, provider));
|
||||||
}
|
}
|
||||||
@ -2943,7 +2943,7 @@ function getGasOraclePlugin(networkKey, fetchOptions) {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
function getProvider(rpcUrl, fetchOptions) {
|
function getProvider(rpcUrl, fetchOptions) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
const fetchReq = new FetchRequest(rpcUrl);
|
const fetchReq = new FetchRequest(rpcUrl);
|
||||||
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
||||||
const _staticNetwork = yield new JsonRpcProvider(fetchReq).getNetwork();
|
const _staticNetwork = yield new JsonRpcProvider(fetchReq).getNetwork();
|
||||||
@ -2993,7 +2993,7 @@ function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) {
|
|||||||
provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || pollInterval * 1e3;
|
provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || pollInterval * 1e3;
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
const populateTransaction = (signer, tx) => __async$d(void 0, null, function* () {
|
const populateTransaction = (signer, tx) => __async$e(void 0, null, function* () {
|
||||||
const provider = signer.provider;
|
const provider = signer.provider;
|
||||||
if (!tx.from) {
|
if (!tx.from) {
|
||||||
tx.from = signer.address;
|
tx.from = signer.address;
|
||||||
@ -3002,7 +3002,7 @@ const populateTransaction = (signer, tx) => __async$d(void 0, null, function* ()
|
|||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
const [feeData, nonce] = yield Promise.all([
|
const [feeData, nonce] = yield Promise.all([
|
||||||
(() => __async$d(void 0, null, function* () {
|
(() => __async$e(void 0, null, function* () {
|
||||||
if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
|
if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) {
|
||||||
return new FeeData(null, BigInt(tx.maxFeePerGas), BigInt(tx.maxPriorityFeePerGas));
|
return new FeeData(null, BigInt(tx.maxFeePerGas), BigInt(tx.maxPriorityFeePerGas));
|
||||||
}
|
}
|
||||||
@ -3024,7 +3024,7 @@ const populateTransaction = (signer, tx) => __async$d(void 0, null, function* ()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}))(),
|
}))(),
|
||||||
(() => __async$d(void 0, null, function* () {
|
(() => __async$e(void 0, null, function* () {
|
||||||
if (tx.nonce) {
|
if (tx.nonce) {
|
||||||
return tx.nonce;
|
return tx.nonce;
|
||||||
}
|
}
|
||||||
@ -3054,7 +3054,7 @@ const populateTransaction = (signer, tx) => __async$d(void 0, null, function* ()
|
|||||||
delete tx.maxFeePerGas;
|
delete tx.maxFeePerGas;
|
||||||
delete tx.maxPriorityFeePerGas;
|
delete tx.maxPriorityFeePerGas;
|
||||||
}
|
}
|
||||||
tx.gasLimit = tx.gasLimit || (yield (() => __async$d(void 0, null, function* () {
|
tx.gasLimit = tx.gasLimit || (yield (() => __async$e(void 0, null, function* () {
|
||||||
try {
|
try {
|
||||||
const gasLimit = yield provider.estimateGas(tx);
|
const gasLimit = yield provider.estimateGas(tx);
|
||||||
return gasLimit === BigInt(21e3) ? gasLimit : gasLimit * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4);
|
return gasLimit === BigInt(21e3) ? gasLimit : gasLimit * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4);
|
||||||
@ -3082,7 +3082,7 @@ class TornadoWallet extends Wallet {
|
|||||||
return new TornadoWallet(privateKey, provider, options);
|
return new TornadoWallet(privateKey, provider, options);
|
||||||
}
|
}
|
||||||
populateTransaction(tx) {
|
populateTransaction(tx) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
const txObject = yield populateTransaction(this, tx);
|
const txObject = yield populateTransaction(this, tx);
|
||||||
this.nonce = txObject.nonce;
|
this.nonce = txObject.nonce;
|
||||||
return __superGet$1(TornadoWallet.prototype, this, "populateTransaction").call(this, txObject);
|
return __superGet$1(TornadoWallet.prototype, this, "populateTransaction").call(this, txObject);
|
||||||
@ -3098,7 +3098,7 @@ class TornadoVoidSigner extends VoidSigner {
|
|||||||
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
||||||
}
|
}
|
||||||
populateTransaction(tx) {
|
populateTransaction(tx) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
const txObject = yield populateTransaction(this, tx);
|
const txObject = yield populateTransaction(this, tx);
|
||||||
this.nonce = txObject.nonce;
|
this.nonce = txObject.nonce;
|
||||||
return __superGet$1(TornadoVoidSigner.prototype, this, "populateTransaction").call(this, txObject);
|
return __superGet$1(TornadoVoidSigner.prototype, this, "populateTransaction").call(this, txObject);
|
||||||
@ -3114,7 +3114,7 @@ class TornadoRpcSigner extends JsonRpcSigner {
|
|||||||
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
this.bumpNonce = bumpNonce != null ? bumpNonce : false;
|
||||||
}
|
}
|
||||||
sendUncheckedTransaction(tx) {
|
sendUncheckedTransaction(tx) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
return __superGet$1(TornadoRpcSigner.prototype, this, "sendUncheckedTransaction").call(this, yield populateTransaction(this, tx));
|
return __superGet$1(TornadoRpcSigner.prototype, this, "sendUncheckedTransaction").call(this, yield populateTransaction(this, tx));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3125,7 +3125,7 @@ class TornadoBrowserProvider extends BrowserProvider {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
getSigner(address) {
|
getSigner(address) {
|
||||||
return __async$d(this, null, function* () {
|
return __async$e(this, null, function* () {
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
||||||
const signerAddress = (yield __superGet$1(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address;
|
const signerAddress = (yield __superGet$1(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address;
|
||||||
if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$1(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) {
|
if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$1(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) {
|
||||||
@ -3353,7 +3353,7 @@ var __spreadValues$4 = (a, b) => {
|
|||||||
return a;
|
return a;
|
||||||
};
|
};
|
||||||
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
||||||
var __async$c = (__this, __arguments, generator) => {
|
var __async$d = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -3376,7 +3376,7 @@ var __async$c = (__this, __arguments, generator) => {
|
|||||||
const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length;
|
const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length;
|
||||||
const first = 1e3;
|
const first = 1e3;
|
||||||
function queryGraph(_0) {
|
function queryGraph(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
query,
|
query,
|
||||||
@ -3405,7 +3405,7 @@ function queryGraph(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getStatistic(_0) {
|
function getStatistic(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
currency,
|
currency,
|
||||||
@ -3452,7 +3452,7 @@ function getStatistic(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getMeta(_0) {
|
function getMeta(_0) {
|
||||||
return __async$c(this, arguments, function* ({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) {
|
return __async$d(this, arguments, function* ({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
_meta: {
|
_meta: {
|
||||||
@ -3497,7 +3497,7 @@ function getRegisters({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllRegisters(_0) {
|
function getAllRegisters(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -3586,7 +3586,7 @@ function getDeposits({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllDeposits(_0) {
|
function getAllDeposits(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
currency,
|
currency,
|
||||||
@ -3683,7 +3683,7 @@ function getWithdrawals({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllWithdrawals(_0) {
|
function getAllWithdrawals(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
currency,
|
currency,
|
||||||
@ -3759,7 +3759,7 @@ function getAllWithdrawals(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getNoteAccounts(_0) {
|
function getNoteAccounts(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
address,
|
address,
|
||||||
@ -3812,7 +3812,7 @@ function getGraphEchoEvents({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllGraphEchoEvents(_0) {
|
function getAllGraphEchoEvents(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -3901,7 +3901,7 @@ function getEncryptedNotes({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllEncryptedNotes(_0) {
|
function getAllEncryptedNotes(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -3986,7 +3986,7 @@ function getGovernanceEvents({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function getAllGovernanceEvents(_0) {
|
function getAllGovernanceEvents(_0) {
|
||||||
return __async$c(this, arguments, function* ({
|
return __async$d(this, arguments, function* ({
|
||||||
graphApi,
|
graphApi,
|
||||||
subgraphName,
|
subgraphName,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
@ -4145,7 +4145,7 @@ var graph = /*#__PURE__*/Object.freeze({
|
|||||||
queryGraph: queryGraph
|
queryGraph: queryGraph
|
||||||
});
|
});
|
||||||
|
|
||||||
var __async$b = (__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) => {
|
||||||
try {
|
try {
|
||||||
@ -4184,7 +4184,7 @@ class BatchBlockService {
|
|||||||
this.retryOn = retryOn;
|
this.retryOn = retryOn;
|
||||||
}
|
}
|
||||||
getBlock(blockTag) {
|
getBlock(blockTag) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
const blockObject = yield this.provider.getBlock(blockTag);
|
const blockObject = yield this.provider.getBlock(blockTag);
|
||||||
if (!blockObject) {
|
if (!blockObject) {
|
||||||
const errMsg = `No block for ${blockTag}`;
|
const errMsg = `No block for ${blockTag}`;
|
||||||
@ -4194,9 +4194,9 @@ class BatchBlockService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createBatchRequest(batchArray) {
|
createBatchRequest(batchArray) {
|
||||||
return batchArray.map((blocks, index) => __async$b(this, null, function* () {
|
return batchArray.map((blocks, index) => __async$c(this, null, function* () {
|
||||||
yield sleep(20 * index);
|
yield sleep(20 * index);
|
||||||
return (() => __async$b(this, null, function* () {
|
return (() => __async$c(this, null, function* () {
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
let err;
|
let err;
|
||||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||||
@ -4213,7 +4213,7 @@ class BatchBlockService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
getBatchBlocks(blocks) {
|
getBatchBlocks(blocks) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
let blockCount = 0;
|
let blockCount = 0;
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) {
|
for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) {
|
||||||
@ -4251,7 +4251,7 @@ class BatchTransactionService {
|
|||||||
this.retryOn = retryOn;
|
this.retryOn = retryOn;
|
||||||
}
|
}
|
||||||
getTransaction(txHash) {
|
getTransaction(txHash) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
const txObject = yield this.provider.getTransaction(txHash);
|
const txObject = yield this.provider.getTransaction(txHash);
|
||||||
if (!txObject) {
|
if (!txObject) {
|
||||||
const errMsg = `No transaction for ${txHash}`;
|
const errMsg = `No transaction for ${txHash}`;
|
||||||
@ -4261,9 +4261,9 @@ class BatchTransactionService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createBatchRequest(batchArray) {
|
createBatchRequest(batchArray) {
|
||||||
return batchArray.map((txs, index) => __async$b(this, null, function* () {
|
return batchArray.map((txs, index) => __async$c(this, null, function* () {
|
||||||
yield sleep(20 * index);
|
yield sleep(20 * index);
|
||||||
return (() => __async$b(this, null, function* () {
|
return (() => __async$c(this, null, function* () {
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
let err;
|
let err;
|
||||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||||
@ -4280,7 +4280,7 @@ class BatchTransactionService {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
getBatchTransactions(txs) {
|
getBatchTransactions(txs) {
|
||||||
return __async$b(this, null, function* () {
|
return __async$c(this, null, function* () {
|
||||||
let txCount = 0;
|
let txCount = 0;
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) {
|
for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) {
|
||||||
@ -4316,7 +4316,7 @@ class BatchEventsService {
|
|||||||
this.retryOn = retryOn;
|
this.retryOn = retryOn;
|
||||||
}
|
}
|
||||||
getPastEvents(_0) {
|
getPastEvents(_0) {
|
||||||
return __async$b(this, arguments, function* ({ fromBlock, toBlock, type }) {
|
return __async$c(this, arguments, function* ({ fromBlock, toBlock, type }) {
|
||||||
let err;
|
let err;
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) {
|
||||||
@ -4336,13 +4336,13 @@ class BatchEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createBatchRequest(batchArray) {
|
createBatchRequest(batchArray) {
|
||||||
return batchArray.map((event, index) => __async$b(this, null, function* () {
|
return batchArray.map((event, index) => __async$c(this, null, function* () {
|
||||||
yield sleep(20 * index);
|
yield sleep(20 * index);
|
||||||
return this.getPastEvents(event);
|
return this.getPastEvents(event);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
getBatchEvents(_0) {
|
getBatchEvents(_0) {
|
||||||
return __async$b(this, arguments, function* ({ fromBlock, toBlock, type = "*" }) {
|
return __async$c(this, arguments, function* ({ fromBlock, toBlock, type = "*" }) {
|
||||||
if (!toBlock) {
|
if (!toBlock) {
|
||||||
toBlock = yield this.provider.getBlockNumber();
|
toBlock = yield this.provider.getBlockNumber();
|
||||||
}
|
}
|
||||||
@ -4395,7 +4395,7 @@ var __spreadValues$3 = (a, b) => {
|
|||||||
};
|
};
|
||||||
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
||||||
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
||||||
var __async$a = (__this, __arguments, generator) => {
|
var __async$b = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -4470,7 +4470,7 @@ class BaseEventsService {
|
|||||||
}
|
}
|
||||||
/* eslint-enable @typescript-eslint/no-unused-vars */
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return yield new Promise((resolve) => resolve(events));
|
return yield new Promise((resolve) => resolve(events));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4478,7 +4478,7 @@ class BaseEventsService {
|
|||||||
* Get saved or cached events
|
* Get saved or cached events
|
||||||
*/
|
*/
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
lastBlock: null
|
lastBlock: null
|
||||||
@ -4486,7 +4486,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
lastBlock: null
|
lastBlock: null
|
||||||
@ -4494,7 +4494,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getSavedEvents() {
|
getSavedEvents() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
let cachedEvents = yield this.getEventsFromDB();
|
let cachedEvents = yield this.getEventsFromDB();
|
||||||
if (!cachedEvents || !cachedEvents.events.length) {
|
if (!cachedEvents || !cachedEvents.events.length) {
|
||||||
cachedEvents = yield this.getEventsFromCache();
|
cachedEvents = yield this.getEventsFromCache();
|
||||||
@ -4506,7 +4506,7 @@ class BaseEventsService {
|
|||||||
* Get latest events
|
* Get latest events
|
||||||
*/
|
*/
|
||||||
getEventsFromGraph(_0) {
|
getEventsFromGraph(_0) {
|
||||||
return __async$a(this, arguments, function* ({
|
return __async$b(this, arguments, function* ({
|
||||||
fromBlock,
|
fromBlock,
|
||||||
methodName = ""
|
methodName = ""
|
||||||
}) {
|
}) {
|
||||||
@ -4526,7 +4526,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromRpc(_0) {
|
getEventsFromRpc(_0) {
|
||||||
return __async$a(this, arguments, function* ({
|
return __async$b(this, arguments, function* ({
|
||||||
fromBlock,
|
fromBlock,
|
||||||
toBlock
|
toBlock
|
||||||
}) {
|
}) {
|
||||||
@ -4564,7 +4564,7 @@ class BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getLatestEvents(_0) {
|
getLatestEvents(_0) {
|
||||||
return __async$a(this, arguments, function* ({ fromBlock }) {
|
return __async$b(this, arguments, function* ({ fromBlock }) {
|
||||||
const allEvents = [];
|
const allEvents = [];
|
||||||
const graphEvents = yield this.getEventsFromGraph({ fromBlock });
|
const graphEvents = yield this.getEventsFromGraph({ fromBlock });
|
||||||
const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock;
|
const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock;
|
||||||
@ -4586,14 +4586,14 @@ class BaseEventsService {
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$a(this, arguments, function* ({ events, lastBlock }) {
|
return __async$b(this, arguments, function* ({ events, lastBlock }) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Trigger saving and receiving latest events
|
* Trigger saving and receiving latest events
|
||||||
*/
|
*/
|
||||||
updateEvents() {
|
updateEvents() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
const savedEvents = yield this.getSavedEvents();
|
const savedEvents = yield this.getSavedEvents();
|
||||||
let fromBlock = this.deployedBlock;
|
let fromBlock = this.deployedBlock;
|
||||||
if (savedEvents && savedEvents.lastBlock) {
|
if (savedEvents && savedEvents.lastBlock) {
|
||||||
@ -4667,7 +4667,7 @@ class BaseDepositsService extends BaseEventsService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
const type = this.getType().toLowerCase();
|
const type = this.getType().toLowerCase();
|
||||||
if (type === DEPOSIT) {
|
if (type === DEPOSIT) {
|
||||||
const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
@ -4746,7 +4746,7 @@ class BaseEchoService extends BaseEventsService {
|
|||||||
return "getAllGraphEchoEvents";
|
return "getAllGraphEchoEvents";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
const { who, data } = args;
|
const { who, data } = args;
|
||||||
if (who && data) {
|
if (who && data) {
|
||||||
@ -4764,7 +4764,7 @@ class BaseEchoService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromGraph(_0) {
|
getEventsFromGraph(_0) {
|
||||||
return __async$a(this, arguments, function* ({ fromBlock }) {
|
return __async$b(this, arguments, function* ({ fromBlock }) {
|
||||||
if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) {
|
if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
@ -4797,7 +4797,7 @@ class BaseEncryptedNotesService extends BaseEventsService {
|
|||||||
return "getAllEncryptedNotes";
|
return "getAllEncryptedNotes";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
const { encryptedNote } = args;
|
const { encryptedNote } = args;
|
||||||
if (encryptedNote) {
|
if (encryptedNote) {
|
||||||
@ -4840,7 +4840,7 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
return "getAllGovernanceEvents";
|
return "getAllGovernanceEvents";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
const proposalEvents = [];
|
const proposalEvents = [];
|
||||||
const votedEvents = [];
|
const votedEvents = [];
|
||||||
const delegatedEvents = [];
|
const delegatedEvents = [];
|
||||||
@ -4907,7 +4907,7 @@ class BaseGovernanceService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromGraph(_0) {
|
getEventsFromGraph(_0) {
|
||||||
return __async$a(this, arguments, function* ({ fromBlock }) {
|
return __async$b(this, arguments, function* ({ fromBlock }) {
|
||||||
if (!this.graphApi || !this.subgraphName || this.graphApi.includes("api.thegraph.com")) {
|
if (!this.graphApi || !this.subgraphName || this.graphApi.includes("api.thegraph.com")) {
|
||||||
return {
|
return {
|
||||||
events: [],
|
events: [],
|
||||||
@ -4942,7 +4942,7 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
return "getAllRegisters";
|
return "getAllRegisters";
|
||||||
}
|
}
|
||||||
formatEvents(events) {
|
formatEvents(events) {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => {
|
||||||
const eventObjects = {
|
const eventObjects = {
|
||||||
blockNumber,
|
blockNumber,
|
||||||
@ -4957,13 +4957,13 @@ class BaseRegistryService extends BaseEventsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
fetchRelayers() {
|
fetchRelayers() {
|
||||||
return __async$a(this, null, function* () {
|
return __async$b(this, null, function* () {
|
||||||
return (yield this.updateEvents()).events;
|
return (yield this.updateEvents()).events;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$9 = (__this, __arguments, generator) => {
|
var __async$a = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -4984,7 +4984,7 @@ var __async$9 = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
function existsAsync(fileOrDir) {
|
function existsAsync(fileOrDir) {
|
||||||
return __async$9(this, null, function* () {
|
return __async$a(this, null, function* () {
|
||||||
try {
|
try {
|
||||||
yield stat(fileOrDir);
|
yield stat(fileOrDir);
|
||||||
return true;
|
return true;
|
||||||
@ -5016,7 +5016,7 @@ function unzipAsync(data) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function saveUserFile(_0) {
|
function saveUserFile(_0) {
|
||||||
return __async$9(this, arguments, function* ({
|
return __async$a(this, arguments, function* ({
|
||||||
fileName,
|
fileName,
|
||||||
userDirectory,
|
userDirectory,
|
||||||
dataString
|
dataString
|
||||||
@ -5034,7 +5034,7 @@ function saveUserFile(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function loadSavedEvents(_0) {
|
function loadSavedEvents(_0) {
|
||||||
return __async$9(this, arguments, function* ({
|
return __async$a(this, arguments, function* ({
|
||||||
name,
|
name,
|
||||||
userDirectory,
|
userDirectory,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
@ -5063,7 +5063,7 @@ function loadSavedEvents(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function download(_0) {
|
function download(_0) {
|
||||||
return __async$9(this, arguments, function* ({ name, cacheDirectory }) {
|
return __async$a(this, arguments, function* ({ name, cacheDirectory }) {
|
||||||
const fileName = `${name}.json`.toLowerCase();
|
const fileName = `${name}.json`.toLowerCase();
|
||||||
const zipName = `${fileName}.zip`;
|
const zipName = `${fileName}.zip`;
|
||||||
const zipPath = path.join(cacheDirectory, zipName);
|
const zipPath = path.join(cacheDirectory, zipName);
|
||||||
@ -5073,7 +5073,7 @@ function download(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function loadCachedEvents(_0) {
|
function loadCachedEvents(_0) {
|
||||||
return __async$9(this, arguments, function* ({
|
return __async$a(this, arguments, function* ({
|
||||||
name,
|
name,
|
||||||
cacheDirectory,
|
cacheDirectory,
|
||||||
deployedBlock
|
deployedBlock
|
||||||
@ -5103,7 +5103,7 @@ function loadCachedEvents(_0) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$8 = (__this, __arguments, generator) => {
|
var __async$9 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -5188,7 +5188,7 @@ class NodeDepositsService extends BaseDepositsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(
|
console.log(
|
||||||
"Updating events for",
|
"Updating events for",
|
||||||
@ -5219,7 +5219,7 @@ class NodeDepositsService extends BaseDepositsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5241,7 +5241,7 @@ class NodeDepositsService extends BaseDepositsService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5320,7 +5320,7 @@ class NodeEchoService extends BaseEchoService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain echo events
|
console.log(`Updating events for ${this.netId} chain echo events
|
||||||
`);
|
`);
|
||||||
@ -5346,7 +5346,7 @@ class NodeEchoService extends BaseEchoService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5368,7 +5368,7 @@ class NodeEchoService extends BaseEchoService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5446,7 +5446,7 @@ class NodeEncryptedNotesService extends BaseEncryptedNotesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain encrypted events
|
console.log(`Updating events for ${this.netId} chain encrypted events
|
||||||
`);
|
`);
|
||||||
@ -5472,7 +5472,7 @@ class NodeEncryptedNotesService extends BaseEncryptedNotesService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5494,7 +5494,7 @@ class NodeEncryptedNotesService extends BaseEncryptedNotesService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5577,7 +5577,7 @@ class NodeGovernanceService extends BaseGovernanceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain governance events
|
console.log(`Updating events for ${this.netId} chain governance events
|
||||||
`);
|
`);
|
||||||
@ -5603,7 +5603,7 @@ class NodeGovernanceService extends BaseGovernanceService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5625,7 +5625,7 @@ class NodeGovernanceService extends BaseGovernanceService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -5703,7 +5703,7 @@ class NodeRegistryService extends BaseRegistryService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getEventsFromDB() {
|
getEventsFromDB() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.userDirectory) {
|
if (!this.userDirectory) {
|
||||||
console.log(`Updating events for ${this.netId} chain registry events
|
console.log(`Updating events for ${this.netId} chain registry events
|
||||||
`);
|
`);
|
||||||
@ -5729,7 +5729,7 @@ class NodeRegistryService extends BaseRegistryService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getEventsFromCache() {
|
getEventsFromCache() {
|
||||||
return __async$8(this, null, function* () {
|
return __async$9(this, null, function* () {
|
||||||
if (!this.cacheDirectory) {
|
if (!this.cacheDirectory) {
|
||||||
console.log(`cachedEvents count - ${0}`);
|
console.log(`cachedEvents count - ${0}`);
|
||||||
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
console.log(`cachedEvents lastBlock - ${this.deployedBlock}
|
||||||
@ -5751,7 +5751,7 @@ class NodeRegistryService extends BaseRegistryService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
saveEvents(_0) {
|
saveEvents(_0) {
|
||||||
return __async$8(this, arguments, function* ({ events, lastBlock }) {
|
return __async$9(this, arguments, function* ({ events, lastBlock }) {
|
||||||
const instanceName = this.getInstanceName();
|
const instanceName = this.getInstanceName();
|
||||||
console.log("\ntotalEvents count - ", events.length);
|
console.log("\ntotalEvents count - ", events.length);
|
||||||
console.log(
|
console.log(
|
||||||
@ -6582,7 +6582,7 @@ ajv.addKeyword({
|
|||||||
errors: true
|
errors: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var __async$7 = (__this, __arguments, generator) => {
|
var __async$8 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -6607,13 +6607,13 @@ class Pedersen {
|
|||||||
this.pedersenPromise = this.initPedersen();
|
this.pedersenPromise = this.initPedersen();
|
||||||
}
|
}
|
||||||
initPedersen() {
|
initPedersen() {
|
||||||
return __async$7(this, null, function* () {
|
return __async$8(this, null, function* () {
|
||||||
this.pedersenHash = yield buildPedersenHash();
|
this.pedersenHash = yield buildPedersenHash();
|
||||||
this.babyJub = this.pedersenHash.babyJub;
|
this.babyJub = this.pedersenHash.babyJub;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
unpackPoint(buffer) {
|
unpackPoint(buffer) {
|
||||||
return __async$7(this, null, function* () {
|
return __async$8(this, null, function* () {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
yield this.pedersenPromise;
|
yield this.pedersenPromise;
|
||||||
return (_b = this.babyJub) == null ? void 0 : _b.unpackPoint((_a = this.pedersenHash) == null ? void 0 : _a.hash(buffer));
|
return (_b = this.babyJub) == null ? void 0 : _b.unpackPoint((_a = this.pedersenHash) == null ? void 0 : _a.hash(buffer));
|
||||||
@ -6626,13 +6626,13 @@ class Pedersen {
|
|||||||
}
|
}
|
||||||
const pedersen = new Pedersen();
|
const pedersen = new Pedersen();
|
||||||
function buffPedersenHash(buffer) {
|
function buffPedersenHash(buffer) {
|
||||||
return __async$7(this, null, function* () {
|
return __async$8(this, null, function* () {
|
||||||
const [hash] = yield pedersen.unpackPoint(buffer);
|
const [hash] = yield pedersen.unpackPoint(buffer);
|
||||||
return pedersen.toStringBuffer(hash);
|
return pedersen.toStringBuffer(hash);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$6 = (__this, __arguments, generator) => {
|
var __async$7 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -6653,7 +6653,7 @@ var __async$6 = (__this, __arguments, generator) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
function createDeposit(_0) {
|
function createDeposit(_0) {
|
||||||
return __async$6(this, arguments, function* ({ nullifier, secret }) {
|
return __async$7(this, arguments, function* ({ nullifier, secret }) {
|
||||||
const preimage = new Uint8Array([...leInt2Buff(nullifier), ...leInt2Buff(secret)]);
|
const preimage = new Uint8Array([...leInt2Buff(nullifier), ...leInt2Buff(secret)]);
|
||||||
const noteHex = toFixedHex(bytesToBN(preimage), 62);
|
const noteHex = toFixedHex(bytesToBN(preimage), 62);
|
||||||
const commitment = BigInt(yield buffPedersenHash(preimage));
|
const commitment = BigInt(yield buffPedersenHash(preimage));
|
||||||
@ -6713,7 +6713,7 @@ class Deposit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
static createNote(_0) {
|
static createNote(_0) {
|
||||||
return __async$6(this, arguments, function* ({ currency, amount, netId, nullifier, secret }) {
|
return __async$7(this, arguments, function* ({ currency, amount, netId, nullifier, secret }) {
|
||||||
if (!nullifier) {
|
if (!nullifier) {
|
||||||
nullifier = rBigInt(31);
|
nullifier = rBigInt(31);
|
||||||
}
|
}
|
||||||
@ -6740,7 +6740,7 @@ class Deposit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
static parseNote(noteString) {
|
static parseNote(noteString) {
|
||||||
return __async$6(this, null, function* () {
|
return __async$7(this, null, function* () {
|
||||||
const noteRegex = new RegExp("tornado-(?<currency>\\w+)-(?<amount>[\\d.]+)-(?<netId>\\d+)-0x(?<note>[0-9a-fA-F]{124})", "g");
|
const noteRegex = new RegExp("tornado-(?<currency>\\w+)-(?<amount>[\\d.]+)-(?<netId>\\d+)-0x(?<note>[0-9a-fA-F]{124})", "g");
|
||||||
const match = noteRegex.exec(noteString);
|
const match = noteRegex.exec(noteString);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@ -7000,7 +7000,7 @@ class TornadoFeeOracle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var __async$5 = (__this, __arguments, generator) => {
|
var __async$6 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -7025,7 +7025,7 @@ class Mimc {
|
|||||||
this.mimcPromise = this.initMimc();
|
this.mimcPromise = this.initMimc();
|
||||||
}
|
}
|
||||||
initMimc() {
|
initMimc() {
|
||||||
return __async$5(this, null, function* () {
|
return __async$6(this, null, function* () {
|
||||||
this.sponge = yield buildMimcSponge();
|
this.sponge = yield buildMimcSponge();
|
||||||
this.hash = (left, right) => {
|
this.hash = (left, right) => {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
@ -7034,7 +7034,7 @@ class Mimc {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getHash() {
|
getHash() {
|
||||||
return __async$5(this, null, function* () {
|
return __async$6(this, null, function* () {
|
||||||
yield this.mimcPromise;
|
yield this.mimcPromise;
|
||||||
return {
|
return {
|
||||||
sponge: this.sponge,
|
sponge: this.sponge,
|
||||||
@ -7045,7 +7045,7 @@ class Mimc {
|
|||||||
}
|
}
|
||||||
const mimc = new Mimc();
|
const mimc = new Mimc();
|
||||||
|
|
||||||
var __async$4 = (__this, __arguments, generator) => {
|
var __async$5 = (__this, __arguments, generator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var fulfilled = (value) => {
|
var fulfilled = (value) => {
|
||||||
try {
|
try {
|
||||||
@ -7088,7 +7088,7 @@ class MerkleTreeService {
|
|||||||
this.merkleWorkerPath = merkleWorkerPath;
|
this.merkleWorkerPath = merkleWorkerPath;
|
||||||
}
|
}
|
||||||
createTree(events) {
|
createTree(events) {
|
||||||
return __async$4(this, null, function* () {
|
return __async$5(this, null, function* () {
|
||||||
const { hash: hashFunction } = yield mimc.getHash();
|
const { hash: hashFunction } = yield mimc.getHash();
|
||||||
if (this.merkleWorkerPath) {
|
if (this.merkleWorkerPath) {
|
||||||
console.log("Using merkleWorker\n");
|
console.log("Using merkleWorker\n");
|
||||||
@ -7140,7 +7140,7 @@ class MerkleTreeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
createPartialTree(_0) {
|
createPartialTree(_0) {
|
||||||
return __async$4(this, arguments, function* ({ edge, elements }) {
|
return __async$5(this, arguments, function* ({ edge, elements }) {
|
||||||
const { hash: hashFunction } = yield mimc.getHash();
|
const { hash: hashFunction } = yield mimc.getHash();
|
||||||
if (this.merkleWorkerPath) {
|
if (this.merkleWorkerPath) {
|
||||||
console.log("Using merkleWorker\n");
|
console.log("Using merkleWorker\n");
|
||||||
@ -7194,7 +7194,7 @@ class MerkleTreeService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
verifyTree(events) {
|
verifyTree(events) {
|
||||||
return __async$4(this, null, function* () {
|
return __async$5(this, null, function* () {
|
||||||
console.log(
|
console.log(
|
||||||
`
|
`
|
||||||
Creating deposit tree for ${this.netId} ${this.amount} ${this.currency.toUpperCase()} would take a while
|
Creating deposit tree for ${this.netId} ${this.amount} ${this.currency.toUpperCase()} would take a while
|
||||||
@ -7279,6 +7279,26 @@ function parseRecoveryKey(value) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var __async$4 = (__this, __arguments, generator) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var fulfilled = (value) => {
|
||||||
|
try {
|
||||||
|
step(generator.next(value));
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var rejected = (value) => {
|
||||||
|
try {
|
||||||
|
step(generator.throw(value));
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
class TokenPriceOracle {
|
class TokenPriceOracle {
|
||||||
constructor(provider, multicall2, oracle) {
|
constructor(provider, multicall2, oracle) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
@ -7286,17 +7306,22 @@ class TokenPriceOracle {
|
|||||||
this.oracle = oracle;
|
this.oracle = oracle;
|
||||||
}
|
}
|
||||||
fetchPrices(tokens) {
|
fetchPrices(tokens) {
|
||||||
if (!this.oracle) {
|
return __async$4(this, null, function* () {
|
||||||
return new Promise((resolve) => resolve(tokens.map(() => parseEther("0.0001"))));
|
if (!this.oracle) {
|
||||||
}
|
return new Promise((resolve) => resolve(tokens.map(() => parseEther("0.0001"))));
|
||||||
return multicall(
|
}
|
||||||
this.multicall,
|
const prices = yield multicall(
|
||||||
tokens.map((token) => ({
|
this.multicall,
|
||||||
contract: this.oracle,
|
tokens.map(({ tokenAddress }) => ({
|
||||||
name: "getRateToEth",
|
contract: this.oracle,
|
||||||
params: [token, true]
|
name: "getRateToEth",
|
||||||
}))
|
params: [tokenAddress, true]
|
||||||
);
|
}))
|
||||||
|
);
|
||||||
|
return prices.map((price, index) => {
|
||||||
|
return price * BigInt(10 ** tokens[index].decimals) / BigInt(10 ** 18);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
47
dist/index.umd.js
vendored
47
dist/index.umd.js
vendored
@ -67531,6 +67531,26 @@ function buffPedersenHash(buffer) {
|
|||||||
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(99770);
|
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(99770);
|
||||||
/* harmony import */ var _multicall__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(48486);
|
/* harmony import */ var _multicall__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(48486);
|
||||||
|
|
||||||
|
var __async = (__this, __arguments, generator) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var fulfilled = (value) => {
|
||||||
|
try {
|
||||||
|
step(generator.next(value));
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var rejected = (value) => {
|
||||||
|
try {
|
||||||
|
step(generator.throw(value));
|
||||||
|
} catch (e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class TokenPriceOracle {
|
class TokenPriceOracle {
|
||||||
@ -67540,17 +67560,22 @@ class TokenPriceOracle {
|
|||||||
this.oracle = oracle;
|
this.oracle = oracle;
|
||||||
}
|
}
|
||||||
fetchPrices(tokens) {
|
fetchPrices(tokens) {
|
||||||
if (!this.oracle) {
|
return __async(this, null, function* () {
|
||||||
return new Promise((resolve) => resolve(tokens.map(() => (0,ethers__WEBPACK_IMPORTED_MODULE_0__/* .parseEther */ .g5)("0.0001"))));
|
if (!this.oracle) {
|
||||||
}
|
return new Promise((resolve) => resolve(tokens.map(() => (0,ethers__WEBPACK_IMPORTED_MODULE_0__/* .parseEther */ .g5)("0.0001"))));
|
||||||
return (0,_multicall__WEBPACK_IMPORTED_MODULE_1__/* .multicall */ .C)(
|
}
|
||||||
this.multicall,
|
const prices = yield (0,_multicall__WEBPACK_IMPORTED_MODULE_1__/* .multicall */ .C)(
|
||||||
tokens.map((token) => ({
|
this.multicall,
|
||||||
contract: this.oracle,
|
tokens.map(({ tokenAddress }) => ({
|
||||||
name: "getRateToEth",
|
contract: this.oracle,
|
||||||
params: [token, true]
|
name: "getRateToEth",
|
||||||
}))
|
params: [tokenAddress, true]
|
||||||
);
|
}))
|
||||||
|
);
|
||||||
|
return prices.map((price, index) => {
|
||||||
|
return price * BigInt(10 ** tokens[index].decimals) / BigInt(10 ** 18);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
dist/prices.d.ts
vendored
5
dist/prices.d.ts
vendored
@ -5,5 +5,8 @@ export declare class TokenPriceOracle {
|
|||||||
multicall: Multicall;
|
multicall: Multicall;
|
||||||
provider: Provider;
|
provider: Provider;
|
||||||
constructor(provider: Provider, multicall: Multicall, oracle?: OffchainOracle);
|
constructor(provider: Provider, multicall: Multicall, oracle?: OffchainOracle);
|
||||||
fetchPrices(tokens: string[]): Promise<bigint[]>;
|
fetchPrices(tokens: {
|
||||||
|
tokenAddress: string;
|
||||||
|
decimals: number;
|
||||||
|
}[]): Promise<bigint[]>;
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,28 @@ export class TokenPriceOracle {
|
|||||||
this.oracle = oracle;
|
this.oracle = oracle;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchPrices(tokens: string[]): Promise<bigint[]> {
|
async fetchPrices(
|
||||||
|
tokens: {
|
||||||
|
tokenAddress: string;
|
||||||
|
decimals: number;
|
||||||
|
}[],
|
||||||
|
): Promise<bigint[]> {
|
||||||
// setup mock price for testnets
|
// setup mock price for testnets
|
||||||
if (!this.oracle) {
|
if (!this.oracle) {
|
||||||
return new Promise((resolve) => resolve(tokens.map(() => parseEther('0.0001'))));
|
return new Promise((resolve) => resolve(tokens.map(() => parseEther('0.0001'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return multicall(
|
const prices = (await multicall(
|
||||||
this.multicall,
|
this.multicall,
|
||||||
tokens.map((token) => ({
|
tokens.map(({ tokenAddress }) => ({
|
||||||
contract: this.oracle,
|
contract: this.oracle,
|
||||||
name: 'getRateToEth',
|
name: 'getRateToEth',
|
||||||
params: [token, true],
|
params: [tokenAddress, true],
|
||||||
})),
|
})),
|
||||||
);
|
)) as bigint[];
|
||||||
|
|
||||||
|
return prices.map((price, index) => {
|
||||||
|
return (price * BigInt(10 ** tokens[index].decimals)) / BigInt(10 ** 18);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user