#44 part 3. A deposit is linked exactly: the NEAR mint is bridge-mng.near calling omft.near.ft_deposit, whose arguments carry the Intents account and BRIDGED_FROM's txHash — Blake2-256 of the depositor's Quantus transfer into their deposit address, length prefix included (checked: extrinsic 1 of block 180,029 hashes to 0xc4444afc…, the hash in mint piPTXyoq…). `chain_extrinsic.hash` is stored from now on and filled for the bridge's deposit transfers. `bridgescan` reads mints from gargravarr (bridge-mng.near is on shard 8), each confirmed executed before it is recorded. History before our nodes is found by bisecting the token's supply — 16 changes before gargravarr's oldest block, 204 archive calls — and a rise is accepted as mints only when the mints around it sum to it exactly. Withdrawals (ft_withdraw with WITHDRAW_TO) come from the intents scan, rewound to frankie's oldest block (migration 0018); custody's payout is matched by a strict, stated rule, as an inference, with the fee it implies — every pre-node withdrawal paid exactly 0.002 QTC less. `/bridge/deposits` and `/bridge/withdrawals`; a linked-transactions panel on the NEAR Intents page. Refs #44 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015pkwBsR54NRmZyU4QVhvfj
57 lines
2.7 KiB
SQL
57 lines
2.7 KiB
SQL
-- QTC bridge transactions linked across both chains.
|
|
-- blackbeard/observer#44.
|
|
--
|
|
-- A deposit is exact end to end: the depositor's Quantus transfer into their
|
|
-- deposit address has a hash (Blake2-256 of the encoded extrinsic), and the
|
|
-- bridge writes that hash into the NEAR mint's `ft_deposit` memo
|
|
-- (`BRIDGED_FROM:{…"txHash"}`) beside the Intents account it credits. A
|
|
-- withdrawal is exact on NEAR (`ft_withdraw` with `WITHDRAW_TO:<address>`)
|
|
-- and only inferred on Quantus, where custody's payout carries no NEAR hash.
|
|
|
|
-- Every QTC mint on NEAR, from the bridge's own call.
|
|
create table bridge_mint (
|
|
chain text not null references chain (id) on delete cascade,
|
|
near_height bigint not null,
|
|
tx_hash text not null,
|
|
at timestamptz not null,
|
|
-- The Intents account credited (`msg.receiver_id`).
|
|
account text not null,
|
|
amount numeric not null,
|
|
-- The depositor's Quantus transaction, `0x` lowercase hex.
|
|
quantus_tx text not null,
|
|
primary key (chain, tx_hash)
|
|
);
|
|
create index bridge_mint_quantus_tx on bridge_mint (chain, quantus_tx);
|
|
create index bridge_mint_account on bridge_mint (chain, account);
|
|
|
|
-- Every QTC withdrawal requested inside NEAR Intents.
|
|
create table bridge_withdrawal (
|
|
chain text not null references chain (id) on delete cascade,
|
|
near_height bigint not null,
|
|
tx_hash text not null,
|
|
intent_hash text not null,
|
|
at timestamptz not null,
|
|
account text not null,
|
|
-- The Quantus address `WITHDRAW_TO` names.
|
|
destination text not null,
|
|
amount numeric not null,
|
|
primary key (chain, tx_hash, intent_hash)
|
|
);
|
|
create index bridge_withdrawal_destination on bridge_withdrawal (chain, destination);
|
|
create index bridge_withdrawal_account on bridge_withdrawal (chain, account);
|
|
|
|
-- The extrinsic's hash, as wallets and explorers name a transaction. Written
|
|
-- for every extrinsic indexed from now on; filled for older ones only where a
|
|
-- link needs it (the bridge's deposit transfers), never by re-reading history.
|
|
alter table chain_extrinsic add column hash text;
|
|
create index chain_extrinsic_hash on chain_extrinsic (chain, hash) where hash is not null;
|
|
|
|
-- The intents scan must read QTC's withdrawals, which it has passed. Pull its
|
|
-- high end back to frankie's oldest block (#218,692,333 on 2026-10-07), not
|
|
-- further: the forward re-read is unpaced, and anything older than our node
|
|
-- would go to a rate-limited archive at full speed. Withdrawals before it are
|
|
-- found by bisecting the token's supply instead.
|
|
update intents_scan
|
|
set high = least(high, 218692400)
|
|
where asset = 'nep141:qtc.omft.near';
|