Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ async fn execute(
usage: clap::builder::StyledStr,
matches: Option<(&str, &clap::ArgMatches)>,
) -> Result<()> {
println!("execute");
match matches {
Some(("boot-fake-node", matches)) => {
let runtime_path = matches
Expand Down Expand Up @@ -1277,7 +1276,6 @@ async fn make_app(current_dir: &std::ffi::OsString) -> Result<Command> {
#[instrument(level = "trace", skip_all)]
#[tokio::main]
async fn main() -> Result<()> {
println!("main");
let log_path =
std::env::var("KIT_LOG_PATH").unwrap_or_else(|_| KIT_LOG_PATH_DEFAULT.to_string());
let log_path = PathBuf::from(log_path);
Expand All @@ -1290,13 +1288,9 @@ async fn main() -> Result<()> {
.into_os_string();
let mut app = make_app(&current_dir).await?;

println!("main a");
let usage = app.render_usage();
println!("main b");
let matches = app.get_matches();
println!("main c");
let matches = matches.subcommand();
println!("main d");

let result = match execute(usage, matches).await {
Ok(()) => Ok(()),
Expand Down
44 changes: 22 additions & 22 deletions src/publish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tracing::{info, instrument};
use hyperware_process_lib::kernel_types::Erc721Metadata;

use crate::build::{download_file, make_pkg_publisher, read_and_update_metadata, zip_pkg};
use crate::new::is_kimap_safe;
use crate::new::is_hypermap_safe;

sol! {
function mint (
Expand Down Expand Up @@ -68,10 +68,10 @@ sol! {
}

const FAKE_KIMAP_ADDRESS: &str = "0xEce71a05B36CA55B895427cD9a440eEF7Cf3669D";
const REAL_KIMAP_ADDRESS: &str = "0x000000000033e5CCbC52Ec7BDa87dB768f9aA93F";
const REAL_KIMAP_ADDRESS: &str = "0x000000000044C6B8Cb4d8f0F889a3E47664EAeda";

const FAKE_KINO_ACCOUNT_IMPL: &str = "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0";
const REAL_KINO_ACCOUNT_IMPL: &str = "0x83119A31628F2c19f578b0CAC9A43eAbA8d8512b";
const REAL_KINO_ACCOUNT_IMPL: &str = "0x0000000000691b70A051CFAF82F9622E150369f3";

const REAL_CHAIN_ID: u64 = 8453;
const FAKE_CHAIN_ID: u64 = 31337;
Expand Down Expand Up @@ -206,7 +206,7 @@ fn check_pkg_hash(metadata: &Erc721Metadata, package_dir: &Path, metadata_uri: &
fn make_multicall(
metadata_uri: &str,
metadata_hash: &str,
kimap: Address,
hypermap: Address,
multicall_address: Address,
) -> Vec<u8> {
// Create metadata calls
Expand All @@ -223,11 +223,11 @@ fn make_multicall(

let calls = vec![
Call {
target: kimap,
target: hypermap,
callData: metadata_hash_call.into(),
},
Call {
target: kimap,
target: hypermap,
callData: metadata_uri_call.into(),
},
];
Expand All @@ -246,14 +246,14 @@ fn make_multicall(
}

#[instrument(level = "trace", skip_all)]
async fn kimap_get(
async fn hypermap_get(
node: &str,
kimap: Address,
hypermap: Address,
provider: &RootProvider<PubSubFrontend>,
) -> Result<(Address, Address, Option<Bytes>)> {
let node = namehash(&node);
let get_tx = TransactionRequest::default()
.to(kimap)
.to(hypermap)
.input(getCall { node: node.into() }.abi_encode().into());

let get_call = provider.call(&get_tx).await?;
Expand All @@ -270,25 +270,25 @@ async fn kimap_get(
}

#[instrument(level = "trace", skip_all)]
async fn prepare_kimap_put(
async fn prepare_hypermap_put(
multicall: Vec<u8>,
name: String,
publisher: &str,
kimap: Address,
hypermap: Address,
provider: &RootProvider<PubSubFrontend>,
wallet_address: Address,
kino_account_impl: Address,
) -> Result<(Address, Vec<u8>)> {
// if app_tba exists, update existing state;
// else mint it & add new state
let (app_tba, owner, _) =
kimap_get(&format!("{}.{}", name, publisher), kimap, &provider).await?;
hypermap_get(&format!("{}.{}", name, publisher), hypermap, &provider).await?;
let is_update = app_tba != Address::default() && owner == wallet_address;

let (to, call) = if is_update {
(app_tba, multicall)
} else {
let (publisher_tba, _, _) = kimap_get(&publisher, kimap, &provider).await?;
let (publisher_tba, _, _) = hypermap_get(&publisher, hypermap, &provider).await?;
let mint_call = mintCall {
who: wallet_address,
label: name.into(),
Expand All @@ -297,7 +297,7 @@ async fn prepare_kimap_put(
}
.abi_encode();
let call = executeCall {
to: kimap,
to: hypermap,
value: U256::from(0),
data: mint_call.into(),
operation: 0,
Expand Down Expand Up @@ -347,12 +347,12 @@ pub async fn execute(
let name = metadata.name.clone().unwrap();
let publisher = metadata.properties.publisher.clone();

if !is_kimap_safe(&name, false) {
if !is_hypermap_safe(&name, false) {
return Err(eyre!(
"The App Store requires package names have only lowercase letters, digits, and `-`s"
));
}
if !is_kimap_safe(&publisher, true) {
if !is_hypermap_safe(&publisher, true) {
return Err(eyre!(
"The App Store requires publisher names have only lowercase letters, digits, `-`s, and `.`s"
));
Expand All @@ -364,7 +364,7 @@ pub async fn execute(
let ws = WsConnect::new(rpc_uri);
let provider: RootProvider<PubSubFrontend> = ProviderBuilder::default().on_ws(ws).await?;

let kimap = Address::from_str(if *real {
let hypermap = Address::from_str(if *real {
REAL_KIMAP_ADDRESS
} else {
FAKE_KIMAP_ADDRESS
Expand All @@ -378,22 +378,22 @@ pub async fn execute(

let (to, call) = if *unpublish {
let app_node = format!("{}.{}", name, publisher);
let (app_tba, owner, _) = kimap_get(&app_node, kimap, &provider).await?;
let (app_tba, owner, _) = hypermap_get(&app_node, hypermap, &provider).await?;
let exists = app_tba != Address::default() && owner == wallet_address;
if !exists {
return Err(eyre!("Can't find {app_node} to unpublish."));
}

let multicall = make_multicall("", "", kimap, multicall_address);
let multicall = make_multicall("", "", hypermap, multicall_address);
(app_tba, multicall)
} else {
let multicall = make_multicall(metadata_uri, &metadata_hash, kimap, multicall_address);
let multicall = make_multicall(metadata_uri, &metadata_hash, hypermap, multicall_address);

prepare_kimap_put(
prepare_hypermap_put(
multicall,
name.clone(),
&publisher,
kimap,
hypermap,
&provider,
wallet_address,
kino_account_impl,
Expand Down