Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/standardize #585

Merged
merged 3 commits into from
Feb 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,13 @@ pub fn handler<'info>(
ctx: Context<'_, '_, '_, 'info, TempStandardizeEntity<'info>>,
args: TempStandardizeEntityArgs,
) -> Result<()> {
let mut sub_uri = ENTITY_METADATA_URL;
if args.current_metadata.symbol.to_lowercase() == "subscriber" {
sub_uri = "https://sol.hellohelium.com/api/metadata"
}
let uri = format!(
"{}/v2/{}/{}",
ENTITY_METADATA_URL,
sub_uri,
args.current_metadata.symbol.to_lowercase(),
ctx.accounts.key_to_asset.key()
);
Expand Down
2 changes: 1 addition & 1 deletion utils/hpl-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn send_and_confirm_messages_with_spinner<
}

let mut last_resend = Instant::now() - TRANSACTION_RESEND_INTERVAL;
while block_height <= last_valid_block_height {
while block_height <= last_valid_block_height && pending_transactions.len() > 0 {
let num_transactions = pending_transactions.len();

// Periodically re-send all pending transactions
Expand Down
134 changes: 75 additions & 59 deletions utils/standardize-hotspot-metadata/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ use serde::{Deserialize, Serialize};
use serde_json::json;
use solana_client::tpu_client::{TpuClient, TpuClientConfig};
use solana_sdk::{
commitment_config::CommitmentConfig, instruction::Instruction, pubkey::Pubkey,
signature::read_keypair_file, signer::Signer,
commitment_config::CommitmentConfig,
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
signature::read_keypair_file,
signer::Signer,
};

const BUBBLEGUM_PROGRAM_ID: &str = "BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY";
Expand Down Expand Up @@ -67,6 +70,12 @@ struct AssetResponse {
grouping: Vec<Grouping>,
creators: Vec<Creator>,
ownership: Ownership,
compression: Compression,
}

#[derive(Debug, Serialize, Deserialize)]
struct Compression {
leaf_id: u32,
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -155,7 +164,7 @@ async fn main() -> Result<()> {
.map(|(k, maker)| (maker.collection, (k, maker)))
.collect();
let entity_creator = Pubkey::from_str("Fv5hf1Fg58htfC7YEXKNEfkpuogUUQDDTLgjGWxxv48H").unwrap();
let dao = Pubkey::from_str("Fv5hf1Fg58htfC7YEXKNEfkpuogUUQDDTLgjGWxxv48H").unwrap();
let dao = Pubkey::from_str("BQ3MCuTT5zVBhNfQ4SjMh3NPVhFy73MPV8rjfq5d1zie").unwrap();
let data_only_config = Pubkey::find_program_address(
&["data_only_config".as_bytes(), dao.as_ref()],
&helium_entity_program.id(),
Expand Down Expand Up @@ -242,74 +251,81 @@ async fn main() -> Result<()> {
let collection = maker_opt
.map(|m| m.1.collection)
.unwrap_or_else(|| data_only_collection);

Ok(
helium_entity_program
.request()
.args(helium_entity_manager::instruction::TempStandardizeEntity {
args: TempStandardizeEntityArgs {
root: root.to_bytes(),
index: proof.node_index,
current_metadata: MetadataArgs {
name: asset.content.metadata.name.clone(),
symbol: asset.content.metadata.symbol.clone(),
uri: asset.content.json_uri.clone(),
creators: asset
.creators
.iter()
.map(|c| helium_entity_manager::Creator {
address: Pubkey::from_str(&c.address).unwrap(),
verified: c.verified,
share: c.share,
})
.collect(),
},
let mut instructions = helium_entity_program
.request()
.args(helium_entity_manager::instruction::TempStandardizeEntity {
args: TempStandardizeEntityArgs {
root: root.to_bytes(),
index: asset.compression.leaf_id,
current_metadata: MetadataArgs {
name: asset.content.metadata.name.clone(),
symbol: asset.content.metadata.symbol.clone(),
uri: asset.content.json_uri.clone(),
creators: asset
.creators
.iter()
.map(|c| helium_entity_manager::Creator {
address: Pubkey::from_str(&c.address).unwrap(),
verified: c.verified,
share: c.share,
})
.collect(),
},
})
.accounts(TempStandardizeEntity {
key_to_asset,
merkle_tree,
maker: maker_opt.map(|m| *m.0),
collection,
data_only_config,
tree_authority: Pubkey::find_program_address(
&[merkle_tree.as_ref()],
&bubblegum_program_id,
)
.0,
authority: me,
collection_metadata: Pubkey::find_program_address(
&[
"metadata".as_bytes(),
tm_program_id.as_ref(),
collection.as_ref(),
],
&tm_program_id,
)
.0,
leaf_owner: Pubkey::from_str(&asset.ownership.owner).unwrap(),
payer: me,
log_wrapper: log_wrapper_program_id,
compression_program: compression_program_id,
bubblegum_program: bubblegum_program_id,
token_metadata_program: tm_program_id,
system_program: solana_sdk::system_program::id(),
})
.instructions()?,
)
},
})
.accounts(TempStandardizeEntity {
key_to_asset,
merkle_tree,
maker: maker_opt.map(|m| *m.0),
collection,
data_only_config,
tree_authority: Pubkey::find_program_address(
&[merkle_tree.as_ref()],
&bubblegum_program_id,
)
.0,
authority: me,
collection_metadata: Pubkey::find_program_address(
&[
"metadata".as_bytes(),
tm_program_id.as_ref(),
collection.as_ref(),
],
&tm_program_id,
)
.0,
leaf_owner: Pubkey::from_str(&asset.ownership.owner).unwrap(),
payer: me,
log_wrapper: log_wrapper_program_id,
compression_program: compression_program_id,
bubblegum_program: bubblegum_program_id,
token_metadata_program: tm_program_id,
system_program: solana_sdk::system_program::id(),
})
.instructions()?;
instructions[0]
.accounts
.extend(proof.proof.iter().take(3).map(|p| AccountMeta {
pubkey: Pubkey::from_str(p).unwrap(),
is_signer: false,
is_writable: false,
}));
Ok(instructions)
})
.collect::<Result<Vec<Vec<Instruction>>>>()?
.into_iter()
.flatten()
.collect();

construct_and_send_txs(
if let Err(r) = construct_and_send_txs(
&helium_entity_program.rpc(),
&tpu_client,
instructions,
&kp,
false,
)?;
) {
println!("Failed to send txs: {:?}", r);
};
counter += 1;
}

Expand Down
Loading