2023-04-20 10:28:54 +00:00
|
|
|
package state
|
2023-02-27 22:16:52 +00:00
|
|
|
|
|
|
|
const (
|
2023-03-05 07:45:53 +00:00
|
|
|
GetContractCodePgStr = `SELECT data FROM ipld.blocks WHERE key = $1`
|
2023-02-28 17:34:45 +00:00
|
|
|
GetStateAccount = `SELECT balance, nonce, code_hash, storage_root, removed FROM eth.state_cids
|
2023-02-27 22:16:52 +00:00
|
|
|
INNER JOIN eth.header_cids ON (
|
|
|
|
state_cids.header_id = header_cids.block_hash
|
|
|
|
AND state_cids.block_number = header_cids.block_number
|
|
|
|
)
|
|
|
|
WHERE state_leaf_key = $1
|
|
|
|
AND header_cids.block_number <= (SELECT block_number
|
|
|
|
FROM eth.header_cids
|
|
|
|
WHERE block_hash = $2)
|
2023-09-20 06:16:44 +00:00
|
|
|
AND header_cids.canonical
|
2023-02-27 22:16:52 +00:00
|
|
|
ORDER BY header_cids.block_number DESC
|
|
|
|
LIMIT 1`
|
2023-03-08 02:40:28 +00:00
|
|
|
GetStorageSlot = `SELECT val, removed, state_leaf_removed FROM get_storage_at_by_hash($1, $2, $3)`
|
2023-02-27 22:16:52 +00:00
|
|
|
)
|
2023-02-28 17:43:07 +00:00
|
|
|
|
|
|
|
// StorageSlotResult struct for unpacking GetStorageSlot result
|
|
|
|
type StorageSlotResult struct {
|
2023-03-08 02:40:28 +00:00
|
|
|
Value []byte `db:"val"`
|
|
|
|
Removed bool `db:"removed"`
|
|
|
|
StateLeafRemoved bool `db:"state_leaf_removed"`
|
2023-02-28 17:43:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// StateAccountResult struct for unpacking GetStateAccount result
|
|
|
|
type StateAccountResult struct {
|
|
|
|
Balance string `db:"balance"`
|
|
|
|
Nonce uint64 `db:"nonce"`
|
2023-03-05 07:45:53 +00:00
|
|
|
CodeHash string `db:"code_hash"`
|
2023-02-28 17:43:07 +00:00
|
|
|
StorageRoot string `db:"storage_root"`
|
|
|
|
Removed bool `db:"removed"`
|
|
|
|
}
|