Skip to content

Commit

Permalink
Fix: RPC error. (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinyuchan authored Oct 21, 2024
1 parent 08e7802 commit 4f18e5e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions evm-exporter/src/getter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::format;
use {
crate::{AccountBasic, Block, ConnectionType, Receipt, Result, TransactionStatus},
primitive_types::{H160, H256, U256},
Expand Down Expand Up @@ -92,7 +93,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT balance FROM balance WHERE address = $1 AND height = $2",
&[&address.to_string(), &(height as i64)],
&[&format!("{:?}", address), &(height as i64)],
)?
.get("balance"),
)?)
Expand All @@ -103,7 +104,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT nonce FROM nonce WHERE address = $1 AND height = $2",
&[&address.to_string(), &(height as i64)],
&[&format!("{:?}", address), &(height as i64)],
)?
.get("nonce"),
)?)
Expand All @@ -114,7 +115,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT code FROM byte_code WHERE address = $1 AND height = $2",
&[&address.to_string(), &(height as i64)],
&[&format!("{:?}", address), &(height as i64)],
)?
.get("code"),
)?)
Expand All @@ -132,7 +133,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT 1 FROM state WHERE address = $1 AND height = $2",
&[&address.to_string(), &(height as i64)],
&[&format!("{:?}", address), &(height as i64)],
)?
.is_empty())
}
Expand All @@ -142,7 +143,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT value FROM state WHERE idx = $1 AND address = $2 AND height = $3",
&[&index.to_string(), &address.to_string(), &(height as i64)],
&[&format!("{:?}", index), &format!("{:?}", address), &(height as i64)],
)?
.get("value"),
)?)
Expand All @@ -164,7 +165,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT block_height FROM block_info WHERE block_hash = $1",
&[&block_hash.to_string()],
&[&format!("{:?}", block_hash)],
)?
.get("block_height"),
)?))
Expand All @@ -175,7 +176,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT block FROM block_info WHERE block_hash = $1",
&[&block_hash.to_string()],
&[&format!("{:?}", block_hash)],
)?
.get("block"),
)?))
Expand All @@ -189,7 +190,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT receipt FROM block_info WHERE block_hash = $1",
&[&block_hash.to_string()],
&[&format!("{:?}", block_hash)],
)?
.get("receipt"),
)?))
Expand All @@ -203,7 +204,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT statuses FROM block_info WHERE block_hash = $1",
&[&block_hash.to_string()],
&[&format!("{:?}", block_hash)],
)?
.get("statuses"),
)?))
Expand All @@ -214,7 +215,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT transaction_index FROM transactions WHERE transaction_hash = $1",
&[&tx_hash.to_string()],
&[&format!("{:?}", tx_hash)],
)?
.get("transaction_index"),
)?))
Expand All @@ -225,7 +226,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT pending_balance FROM pending_transactions WHERE sign_address = $1",
&[&address.to_string()],
&[&format!("{:?}", address)],
)?
.get("pending_balance"),
)?))
Expand All @@ -236,7 +237,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT pending_nonce FROM pending_transactions WHERE sign_address = $1",
&[&address.to_string()],
&[&format!("{:?}", address)],
)?
.get("pending_nonce"),
)?))
Expand All @@ -247,7 +248,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT code FROM pending_byte_code WHERE address = $1",
&[&address.to_string()],
&[&format!("{:?}", address)],
)?
.get("code"),
)?))
Expand All @@ -258,7 +259,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT value FROM pending_state WHERE address = $1 AND idx = $2",
&[&address.to_string(), &index.to_string()],
&[&format!("{:?}", address), &format!("{:?}", index)],
)?
.get("value"),
)?))
Expand All @@ -280,7 +281,7 @@ impl Getter for PgGetter {
.get()?
.query_one(
"SELECT value FROM allowances WHERE owner = $1 AND spender = $2 AND height = $3",
&[&owner.to_string(),&spender.to_string(),&( height as i64 )],
&[&format!("{:?}", owner), &format!("{:?}", spender), &( height as i64 )],
)?
.get("value"),
)?)
Expand Down

0 comments on commit 4f18e5e

Please sign in to comment.