mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-22 08:01:47 +03:00
app_store: new process_lib
This commit is contained in:
parent
cc99136c07
commit
497b1acdb0
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -970,7 +970,7 @@ dependencies = [
|
||||
"alloy-sol-types",
|
||||
"anyhow",
|
||||
"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",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -3558,7 +3558,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "kinode_process_lib"
|
||||
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 = [
|
||||
"alloy 0.1.1",
|
||||
"alloy-primitives",
|
||||
@ -3580,7 +3580,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "kinode_process_lib"
|
||||
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 = [
|
||||
"alloy 0.1.1",
|
||||
"alloy-primitives",
|
||||
|
@ -11,7 +11,7 @@ alloy-primitives = "0.7.6"
|
||||
alloy-sol-types = "0.7.6"
|
||||
anyhow = "1.0"
|
||||
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"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::VFS_TIMEOUT;
|
||||
use crate::{utils, DownloadRequest, LocalRequest};
|
||||
use crate::{KIMAP_ADDRESS, VFS_TIMEOUT};
|
||||
use alloy_sol_types::{sol, SolEvent};
|
||||
use kinode_process_lib::kernel_types::Erc721Metadata;
|
||||
use kinode_process_lib::{
|
||||
@ -9,6 +9,7 @@ use kinode_process_lib::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::str::FromStr;
|
||||
|
||||
sol! {
|
||||
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(¬e.note).to_string();
|
||||
|
||||
let kimap = self
|
||||
.provider
|
||||
.kimap_with_address(eth::Address::from_str(KIMAP_ADDRESS).unwrap());
|
||||
// println!("got note {note_str} for {name}");
|
||||
// let notehash = note.notehash.to_string();
|
||||
// let full_name = format!("{note_str}.{name}");
|
||||
@ -384,20 +388,16 @@ impl State {
|
||||
// generate ~metadata-hash notehash
|
||||
let meta_note_name = format!("~metadata-hash.{name}");
|
||||
let package_hash_note = namehash(&meta_note_name);
|
||||
let (_tba, _owner, data) =
|
||||
self.provider.get(&package_hash_note).map_err(|e| {
|
||||
println!("Error getting metadata hash: {:?}", e);
|
||||
AppStoreLogError::DecodeLogError
|
||||
})?;
|
||||
let (_tba, _owner, data) = kimap.get(&package_hash_note).map_err(|e| {
|
||||
println!("Error getting metadata hash: {:?}", e);
|
||||
AppStoreLogError::DecodeLogError
|
||||
})?;
|
||||
|
||||
if let Some(hash_note) = data {
|
||||
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 =
|
||||
utils::fetch_metadata_from_url(&metadata_url, &metadata_hash, 5)?;
|
||||
|
||||
println!("got metadata: {:?}", metadata);
|
||||
|
||||
// if this fails and doesn't check out, do nothing
|
||||
|
||||
let (package_name, publisher_name) = name
|
||||
@ -452,20 +452,16 @@ impl State {
|
||||
// generate ~metadata-uri notehash
|
||||
let meta_note_name = format!("~metadata-uri.{name}");
|
||||
let package_uri_note = namehash(&meta_note_name);
|
||||
let (_tba, _owner, data) =
|
||||
self.provider.get(&package_uri_note).map_err(|e| {
|
||||
println!("Error getting metadata uri: {:?}", e);
|
||||
AppStoreLogError::DecodeLogError
|
||||
})?;
|
||||
let (_tba, _owner, data) = kimap.get(&package_uri_note).map_err(|e| {
|
||||
println!("Error getting metadata uri: {:?}", e);
|
||||
AppStoreLogError::DecodeLogError
|
||||
})?;
|
||||
|
||||
if let Some(uri_note) = data {
|
||||
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 =
|
||||
utils::fetch_metadata_from_url(&metadata_url, &metadata_hash, 5)?;
|
||||
|
||||
println!("got metadata: {:?}", metadata);
|
||||
|
||||
let (package_name, publisher_name) = name
|
||||
.split_once('.')
|
||||
.ok_or(AppStoreLogError::InvalidPublisherName)
|
||||
|
Loading…
Reference in New Issue
Block a user