app_store: new process_lib

This commit is contained in:
bitful-pannul 2024-07-05 21:03:38 +03:00
parent cc99136c07
commit 497b1acdb0
3 changed files with 17 additions and 21 deletions

6
Cargo.lock generated
View File

@ -970,7 +970,7 @@ dependencies = [
"alloy-sol-types", "alloy-sol-types",
"anyhow", "anyhow",
"bincode", "bincode",
"kinode_process_lib 0.8.3 (git+https://github.com/kinode-dao/process_lib?rev=c45e40a)", "kinode_process_lib 0.8.3 (git+https://github.com/kinode-dao/process_lib?rev=f8500a6)",
"rand 0.8.5", "rand 0.8.5",
"serde", "serde",
"serde_json", "serde_json",
@ -3558,7 +3558,7 @@ dependencies = [
[[package]] [[package]]
name = "kinode_process_lib" name = "kinode_process_lib"
version = "0.8.3" version = "0.8.3"
source = "git+https://github.com/kinode-dao/process_lib?rev=c45e40a#c45e40ac22e37462d135362d6854ac7a3d191776" source = "git+https://github.com/kinode-dao/process_lib?rev=c8442ef#c8442ef6e0f6aefc1d8caa30b32a991303da8dd9"
dependencies = [ dependencies = [
"alloy 0.1.1", "alloy 0.1.1",
"alloy-primitives", "alloy-primitives",
@ -3580,7 +3580,7 @@ dependencies = [
[[package]] [[package]]
name = "kinode_process_lib" name = "kinode_process_lib"
version = "0.8.3" version = "0.8.3"
source = "git+https://github.com/kinode-dao/process_lib?rev=c8442ef#c8442ef6e0f6aefc1d8caa30b32a991303da8dd9" source = "git+https://github.com/kinode-dao/process_lib?rev=f8500a6#f8500a62a07c0558145ee1583155331f83dfd018"
dependencies = [ dependencies = [
"alloy 0.1.1", "alloy 0.1.1",
"alloy-primitives", "alloy-primitives",

View File

@ -11,7 +11,7 @@ alloy-primitives = "0.7.6"
alloy-sol-types = "0.7.6" alloy-sol-types = "0.7.6"
anyhow = "1.0" anyhow = "1.0"
bincode = "1.3.3" bincode = "1.3.3"
kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "c45e40a" } kinode_process_lib = { git = "https://github.com/kinode-dao/process_lib", rev = "f8500a6" }
rand = "0.8" rand = "0.8"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"

View File

@ -1,5 +1,5 @@
use crate::VFS_TIMEOUT;
use crate::{utils, DownloadRequest, LocalRequest}; use crate::{utils, DownloadRequest, LocalRequest};
use crate::{KIMAP_ADDRESS, VFS_TIMEOUT};
use alloy_sol_types::{sol, SolEvent}; use alloy_sol_types::{sol, SolEvent};
use kinode_process_lib::kernel_types::Erc721Metadata; use kinode_process_lib::kernel_types::Erc721Metadata;
use kinode_process_lib::{ use kinode_process_lib::{
@ -9,6 +9,7 @@ use kinode_process_lib::{
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::str::FromStr;
sol! { sol! {
event Note(bytes32 indexed nodehash, bytes32 indexed notehash, bytes indexed labelhash, bytes note, bytes data); event Note(bytes32 indexed nodehash, bytes32 indexed notehash, bytes indexed labelhash, bytes note, bytes data);
@ -374,6 +375,9 @@ impl State {
let note_str = String::from_utf8_lossy(&note.note).to_string(); let note_str = String::from_utf8_lossy(&note.note).to_string();
let kimap = self
.provider
.kimap_with_address(eth::Address::from_str(KIMAP_ADDRESS).unwrap());
// println!("got note {note_str} for {name}"); // println!("got note {note_str} for {name}");
// let notehash = note.notehash.to_string(); // let notehash = note.notehash.to_string();
// let full_name = format!("{note_str}.{name}"); // let full_name = format!("{note_str}.{name}");
@ -384,20 +388,16 @@ impl State {
// generate ~metadata-hash notehash // generate ~metadata-hash notehash
let meta_note_name = format!("~metadata-hash.{name}"); let meta_note_name = format!("~metadata-hash.{name}");
let package_hash_note = namehash(&meta_note_name); let package_hash_note = namehash(&meta_note_name);
let (_tba, _owner, data) = let (_tba, _owner, data) = kimap.get(&package_hash_note).map_err(|e| {
self.provider.get(&package_hash_note).map_err(|e| { println!("Error getting metadata hash: {:?}", e);
println!("Error getting metadata hash: {:?}", e); AppStoreLogError::DecodeLogError
AppStoreLogError::DecodeLogError })?;
})?;
if let Some(hash_note) = data { if let Some(hash_note) = data {
let metadata_hash = String::from_utf8_lossy(&hash_note).to_string(); let metadata_hash = String::from_utf8_lossy(&hash_note).to_string();
println!("got metadata_url, and from that the hash {metadata_url} {metadata_hash}");
let metadata = let metadata =
utils::fetch_metadata_from_url(&metadata_url, &metadata_hash, 5)?; utils::fetch_metadata_from_url(&metadata_url, &metadata_hash, 5)?;
println!("got metadata: {:?}", metadata);
// if this fails and doesn't check out, do nothing // if this fails and doesn't check out, do nothing
let (package_name, publisher_name) = name let (package_name, publisher_name) = name
@ -452,20 +452,16 @@ impl State {
// generate ~metadata-uri notehash // generate ~metadata-uri notehash
let meta_note_name = format!("~metadata-uri.{name}"); let meta_note_name = format!("~metadata-uri.{name}");
let package_uri_note = namehash(&meta_note_name); let package_uri_note = namehash(&meta_note_name);
let (_tba, _owner, data) = let (_tba, _owner, data) = kimap.get(&package_uri_note).map_err(|e| {
self.provider.get(&package_uri_note).map_err(|e| { println!("Error getting metadata uri: {:?}", e);
println!("Error getting metadata uri: {:?}", e); AppStoreLogError::DecodeLogError
AppStoreLogError::DecodeLogError })?;
})?;
if let Some(uri_note) = data { if let Some(uri_note) = data {
let metadata_url = String::from_utf8_lossy(&uri_note).to_string(); let metadata_url = String::from_utf8_lossy(&uri_note).to_string();
println!("got metadata_hash, and from that the url {metadata_hash} {metadata_url}");
let metadata = let metadata =
utils::fetch_metadata_from_url(&metadata_url, &metadata_hash, 5)?; utils::fetch_metadata_from_url(&metadata_url, &metadata_hash, 5)?;
println!("got metadata: {:?}", metadata);
let (package_name, publisher_name) = name let (package_name, publisher_name) = name
.split_once('.') .split_once('.')
.ok_or(AppStoreLogError::InvalidPublisherName) .ok_or(AppStoreLogError::InvalidPublisherName)