Implements the new sourcify:database import-creator-tx-hash, a script that goes through every creator-tx-hash.txt file in repository and store all related contract into a new table sourcify_transaction_hash.
Implements a new option for sourcify:database sync to allow specifying a custom sourcify_sync table
Refactors code so that import-creator-tx-hash and import-sync don't duplicate code
Process
Create a dedicated sourcify_sync like table (sourcify_transaction_hash with additional transaction_hash field)
CREATE TABLE sourcify_transaction_hash (
id BIGSERIAL NOT NULL,
chain_id numeric NOT NULL,
address bytea NOT NULL,
match_type varchar NOT NULL,
transaction_hash bytea NOT NULL,
synced bool NOT NULL DEFAULT false,
created_at timestamptz NOT NULL DEFAULT now(),
CONSTRAINT sourcify_transaction_hash_pkey PRIMARY KEY (id),
CONSTRAINT sourcify_transaction_hash_pseudo_pkey UNIQUE (chain_id, address)
);
Run the new import-creator-tx-hash script, pushing all the contracts that have a creator-tx-hash.txt from the legacy Argo repo to sourcify_transaction_hash
npm run sourcify:database import-creator-tx-hash /tmp/sourcify/repository/contracts
Create a new table from the comparison between contract_deployments.transaction_hash with sourcify_transaction_hash.transaction_hash finding all the contracts that don't have transaction_hash in contract_deployments but they have it in sourcify_transaction_hash
CREATE TABLE sourcify_sync_sourcify_transaction_hash AS
SELECT sth.*
FROM sourcify_transaction_hash sth
LEFT JOIN contract_deployments cd
ON sth.chain_id = cd.chain_id
AND sth.address = cd.address
AND sth.transaction_hash = cd.transaction_hash
WHERE cd.transaction_hash IS NULL;
Execute sync on the new sourcify_sync_sourcify_transaction_hash table
See #1573
PR
This PR:
sourcify:database import-creator-tx-hash
, a script that goes through everycreator-tx-hash.txt
file in repository and store all related contract into a new tablesourcify_transaction_hash
.sourcify:database sync
to allow specifying a customsourcify_sync
tableimport-creator-tx-hash
andimport-sync
don't duplicate codeProcess
sourcify_transaction_hash
with additionaltransaction_hash
field)import-creator-tx-hash
script, pushing all the contracts that have acreator-tx-hash.txt
from the legacy Argo repo tosourcify_transaction_hash
contract_deployments.transaction_hash
withsourcify_transaction_hash.transaction_hash
finding all the contracts that don't havetransaction_hash
incontract_deployments
but they have it insourcify_transaction_hash
sourcify_sync_sourcify_transaction_hash
table