From 3c57c6eb9e4f80f0a631c1dbccf0b22c070e2d02 Mon Sep 17 00:00:00 2001 From: BokkyPooBah Date: Tue, 19 Dec 2023 20:51:51 +1100 Subject: [PATCH] debugging --- docs/index.html | 108 ++++++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 50 deletions(-) diff --git a/docs/index.html b/docs/index.html index 2171419..8474c89 100644 --- a/docs/index.html +++ b/docs/index.html @@ -761,12 +761,12 @@
Troubleshooting
if (!devMode) { await this.syncApprovalEvents(provider, latestBlockNumber); } - if (!devMode) { - await this.syncNames(provider); - } if (!devMode) { await this.syncBlockTimestamps(); } + // if (!devMode) { + await this.syncAccounts(provider); + // } // if (devMode) { await this.processData(provider); // } @@ -775,7 +775,6 @@
Troubleshooting
}, async syncApprovalEvents(provider, latestBlockNumber) { - console.log(moment().format("HH:mm:ss") + " syncApprovalEvents BEGIN"); // ERC-20 Approval (index_topic_1 address owner, index_topic_2 address spender, uint256 value) // 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925 // ERC-721 Approval (index_topic_1 address owner, index_topic_2 address approved, index_topic_3 uint256 tokenId) @@ -784,6 +783,10 @@
Troubleshooting
// 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31 // ERC-1155 ApprovalForAll (index_topic_1 address account, index_topic_2 address operator, bool approved) // 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31 + console.log(moment().format("HH:mm:ss") + " syncApprovalEvents BEGIN"); + this.sync.completed = 0; + this.sync.total = 0; + this.sync.section = 'Approval Events'; const accounts = [this.coinbase]; const accountsAs32Bytes = accounts.map(e => '0x000000000000000000000000' + e.substring(2, 42).toLowerCase()); const approvalLogs = await provider.getLogs({ @@ -798,6 +801,7 @@
Troubleshooting
null ], }); + this.sync.completed = approvalLogs.length; const events = []; for (const log of approvalLogs) { const topic0 = log.topics[0]; @@ -826,8 +830,50 @@
Troubleshooting
console.log(moment().format("HH:mm:ss") + " syncApprovalEvents BEGIN"); }, - async syncNames(provider) { - console.log(moment().format("HH:mm:ss") + " syncNames BEGIN"); + async syncBlockTimestamps() { + console.log(moment().format("HH:mm:ss") + " syncBlockTimestamps BEGIN"); + const blockNumbersMap = {}; + for (const event of this.events) { + if (!(event.blockNumber in blockNumbersMap)) { + blockNumbersMap[event.blockNumber] = true; + } + } + const blockNumbers = Object.keys(blockNumbersMap); + this.sync.completed = 0; + this.sync.total = blockNumbers.length; + this.sync.section = 'Block Timestamps'; + const BATCHSIZE = 1000; + const blockTimestamps = {}; + for (let i = 0; i < blockNumbers.length; i += BATCHSIZE) { + const batch = blockNumbers.slice(i, parseInt(i) + BATCHSIZE); + const data = await fetch(BLOCKTIMESTAMPSUBGRAPHURL, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + body: JSON.stringify({ + query: BLOCKTIMESTAMPINQUERY, + variables: { blockNumbers: batch.map(e => parseInt(e)) }, + }) + }).then(response => response.json()) + .catch(function(e) { + console.log("error: " + e); + }); + const timestamps = data.data && data.data.blocks || []; + for (const timestampItem of timestamps) { + blockTimestamps[timestampItem.number] = parseInt(timestampItem.timestamp); + } + this.sync.completed += timestamps.length; + console.log(moment().format("HH:mm:ss") + " syncBlockTimestamps " + this.sync.completed + " of " + blockNumbers.length); + } + localStorage.approvalBlockTimestamps = JSON.stringify(blockTimestamps); + Vue.set(this, 'blockTimestamps', blockTimestamps); + console.log(moment().format("HH:mm:ss") + " syncBlockTimestamps END"); + }, + + async syncAccounts(provider) { + console.log(moment().format("HH:mm:ss") + " syncAccounts BEGIN"); const ownersMap = {}; const contractsMap = {}; const spendersMap = {}; @@ -861,6 +907,9 @@
Troubleshooting
} const erc721Helper = new ethers.Contract(ERC721HELPERADDRESS, ERC721HELPERABI, provider); const accountsToCheck = [...owners, ...contracts, ...spenders]; + this.sync.completed = 0; + this.sync.total = accountsToCheck.length; + this.sync.section = 'Addresses'; for (const account of accountsToCheck) { if (account in CUSTOMNAMES) { accounts[account].type = CUSTOMNAMES[account][0]; @@ -908,14 +957,15 @@
Troubleshooting
} } } catch (e) { - console.log("syncNames erc721Helper - ERROR: " + account + ", message: " + e.message); + console.log("syncAccounts erc721Helper - ERROR: " + account + ", message: " + e.message); accounts[account].type = "unknown0"; } } + this.sync.completed++; } localStorage.approvalAccounts = JSON.stringify(accounts); Vue.set(this, 'accounts', accounts); - console.log(moment().format("HH:mm:ss") + " syncNames END"); + console.log(moment().format("HH:mm:ss") + " syncAccounts END"); }, // // TODO: Refresh sync @@ -981,48 +1031,6 @@
Troubleshooting
// console.log(moment().format("HH:mm:ss") + " syncENSNames END"); // }, - async syncBlockTimestamps() { - console.log(moment().format("HH:mm:ss") + " syncBlockTimestamps BEGIN"); - const blockNumbersMap = {}; - for (const event of this.events) { - if (!(event.blockNumber in blockNumbersMap)) { - blockNumbersMap[event.blockNumber] = true; - } - } - const blockNumbers = Object.keys(blockNumbersMap); - this.sync.completed = 0; - this.sync.total = blockNumbers.length; - this.sync.section = 'Block Timestamps'; - const BATCHSIZE = 1000; - const blockTimestamps = {}; - for (let i = 0; i < blockNumbers.length; i += BATCHSIZE) { - const batch = blockNumbers.slice(i, parseInt(i) + BATCHSIZE); - const data = await fetch(BLOCKTIMESTAMPSUBGRAPHURL, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - }, - body: JSON.stringify({ - query: BLOCKTIMESTAMPINQUERY, - variables: { blockNumbers: batch.map(e => parseInt(e)) }, - }) - }).then(response => response.json()) - .catch(function(e) { - console.log("error: " + e); - }); - const timestamps = data.data && data.data.blocks || []; - for (const timestampItem of timestamps) { - blockTimestamps[timestampItem.number] = parseInt(timestampItem.timestamp); - } - this.sync.completed += timestamps.length; - console.log(moment().format("HH:mm:ss") + " syncBlockTimestamps " + this.sync.completed + " of " + blockNumbers.length); - } - localStorage.approvalBlockTimestamps = JSON.stringify(blockTimestamps); - Vue.set(this, 'blockTimestamps', blockTimestamps); - console.log(moment().format("HH:mm:ss") + " syncBlockTimestamps END"); - }, - async processData(provider) { console.log(moment().format("HH:mm:ss") + " processData BEGIN"); const accounts = this.accounts;