Skip to content

Commit

Permalink
Bugfix/standardize (#585)
Browse files Browse the repository at this point in the history
* Bugfixes when standardizing accounts

* More fixes

* Bugfix to allow subscriber url
  • Loading branch information
ChewingGlass authored Feb 18, 2024
1 parent 8560ad2 commit 9777076
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 61 deletions.
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

0 comments on commit 9777076

Please sign in to comment.