Skip to content

Commit

Permalink
Merge pull request #219 from kinode-dao/bp/publishfix
Browse files Browse the repository at this point in the history
publish: fakenodes fix
  • Loading branch information
barraguda authored Aug 28, 2024
2 parents 31ca352 + 67c39b8 commit b6761b2
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/publish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ sol! {
}

const FAKE_KIMAP_ADDRESS: &str = "0xEce71a05B36CA55B895427cD9a440eEF7Cf3669D";
const REAL_KIMAP_ADDRESS: &str = "0xcA92476B2483aBD5D82AEBF0b56701Bb2e9be658";

const FAKE_KINO_ACCOUNT_IMPL: &str = "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0";
const REAL_KINO_ACCOUNT_IMPL: &str = "0x38766C70a4FB2f23137D9251a1aA12b1143fC716";

const REAL_CHAIN_ID: u64 = 10;
const FAKE_CHAIN_ID: u64 = 31337;

const REAL_KIMAP_ADDRESS: &str = "0xcA92476B2483aBD5D82AEBF0b56701Bb2e9be658";
const MULTICALL_ADDRESS: &str = "0xcA11bde05977b3631167028862bE2a173976CA11";
const KINO_ACCOUNT_IMPL: &str = "0x38766C70a4FB2f23137D9251a1aA12b1143fC716";
const REAL_CHAIN_ID: u64 = 10;

fn is_valid_kimap_package_name(s: &str) -> bool {
s.chars().all(|c| c.is_ascii_lowercase() || c == '-' || c.is_ascii_digit())
Expand Down Expand Up @@ -209,11 +212,11 @@ fn make_multicall(
let calls = vec![
Call {
target: kimap,
callData: metadata_uri_call.into(),
callData: metadata_hash_call.into(),
},
Call {
target: kimap,
callData: metadata_hash_call.into(),
callData: metadata_uri_call.into(),
},
];

Expand Down Expand Up @@ -363,7 +366,13 @@ pub async fn execute(
}
)?;
let multicall_address = Address::from_str(MULTICALL_ADDRESS)?;
let kino_account_impl = Address::from_str(KINO_ACCOUNT_IMPL)?;
let kino_account_impl = Address::from_str(
if *real {
REAL_KINO_ACCOUNT_IMPL
} else {
FAKE_KINO_ACCOUNT_IMPL
}
)?;

let (to, call) = if *unpublish {
let app_node = format!("{}.{}", name, publisher);
Expand Down Expand Up @@ -394,22 +403,26 @@ pub async fn execute(
};

let nonce = provider.get_transaction_count(wallet_address).await?;
let gas_price = provider.get_gas_price().await?;

let estimate = provider.estimate_eip1559_fees(None).await?;

let suggested_max_fee_per_gas = estimate.max_fee_per_gas;
let suggested_max_priority_fee_per_gas = estimate.max_priority_fee_per_gas;

let tx = TransactionRequest::default()
.to(to)
.input(TransactionInput::new(call.into()))
.nonce(nonce)
.with_chain_id(chain_id)
.with_gas_limit(gas_limit)
.with_max_priority_fee_per_gas(max_priority_fee_per_gas.unwrap_or_else(|| gas_price))
.with_max_fee_per_gas(max_fee_per_gas.unwrap_or_else(|| gas_price));
.with_max_priority_fee_per_gas(max_priority_fee_per_gas.unwrap_or_else(|| suggested_max_priority_fee_per_gas))
.with_max_fee_per_gas(max_fee_per_gas.unwrap_or_else(|| suggested_max_fee_per_gas));

let tx_envelope = tx.build(&wallet).await?;
let tx_encoded = tx_envelope.encoded_2718();
let tx = provider.send_raw_transaction(&tx_encoded).await?;

let tx_hash = format!("{:?}", tx.tx_hash());
let receipt = tx.get_receipt().await?;
let tx_hash = format!("{:?}", receipt.transaction_hash);
let link = format!(
"\x1B]8;;https://optimistic.etherscan.io/tx/{}\x1B\\{}\x1B]8;;\x1B\\",
tx_hash,
Expand Down

0 comments on commit b6761b2

Please sign in to comment.