Skip to content

Commit

Permalink
feat(#575): Standardize all rewardable entities in url and creators (#…
Browse files Browse the repository at this point in the history
…584)

* WIP: Standardizing url

* Create txn sender

* Fix build

* Add our own key

* Lint
  • Loading branch information
ChewingGlass authored Feb 15, 2024
1 parent 1d368e5 commit 8560ad2
Show file tree
Hide file tree
Showing 20 changed files with 6,942 additions and 262 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ exclude = [
"utils/generate-test-gateway-txn",
"utils/active-hotspot-oracle",
"utils/backfill-onboarding-fees",
"utils/standardize-hotspot-metadata",
]

[workspace.dependencies]
anchor-lang = { version = "0.28.0", features = ["init-if-needed"] }
anchor-spl = { version = "0.28.0", features = ["mint", "token"] }
mpl-token-metadata = { version = "3.2.0" }
account-compression-cpi = { rev = "a2d12e4a157d91feb73aa40a97fe297fd477dd87", git = "https://github.com/helium/account-compression-anchor-gen.git", features = ["cpi"]}
bubblegum-cpi = { rev = "a2d12e4a157d91feb73aa40a97fe297fd477dd87", git = "https://github.com/helium/account-compression-anchor-gen.git", features = ["cpi"]}
account-compression-cpi = { rev = "a499196", git = "https://github.com/helium/account-compression-anchor-gen.git", features = ["cpi"]}
bubblegum-cpi = { rev = "a499196", git = "https://github.com/helium/account-compression-anchor-gen.git", features = ["cpi"]}
solana-security-txt = "1.1.1"
default-env = "0.1.1"
shared-utils = { path = "./utils/shared-utils" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ pub fn handler(ctx: Context<IssueDataOnlyEntityV0>, args: IssueDataOnlyEntityArg
let metadata = MetadataArgs {
name: name[..min(name.len(), 32)].to_owned(),
symbol: String::from("HOTSPOT"),
uri: format!("{}/{}", ENTITY_METADATA_URL, key_str),
uri: format!(
"{}/v2/hotspot/{}",
ENTITY_METADATA_URL,
ctx.accounts.key_to_asset.key()
),
collection: Some(Collection {
key: ctx.accounts.collection.key(),
verified: false, // Verified in cpi
Expand Down
16 changes: 5 additions & 11 deletions programs/helium-entity-manager/src/instructions/issue_entity_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,11 @@ pub fn handler(ctx: Context<IssueEntityV0>, args: IssueEntityArgsV0) -> Result<(
]];

let name = animal_name.to_string();
let mut uri = format!("{}/{}", ENTITY_METADATA_URL, key_str);

// HACK: Handle wifi hotspots with v1 uri. TODO: Find a way to do this for all hotspots after migration
// https://docs.google.com/document/d/1Q6VdcDA3McehQYb1MzWL8Iy421D84T7UrmJE7Z9Vc_Y/edit?usp=sharing
if uri.len() > 200 {
uri = format!(
"{}/v1/{}",
ENTITY_METADATA_URL,
ctx.accounts.key_to_asset.key()
);
}
let uri = format!(
"{}/v2/hotspot/{}",
ENTITY_METADATA_URL,
ctx.accounts.key_to_asset.key(),
);
let metadata = MetadataArgs {
name: name[..min(name.len(), 32)].to_owned(),
symbol: String::from("HOTSPOT"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ pub fn handler(ctx: Context<IssueProgramEntityV0>, args: IssueProgramEntityArgsV
require!(args.name.len() <= 32, ErrorCode::InvalidStringLength);
require!(args.symbol.len() <= 10, ErrorCode::InvalidStringLength);

let key_str = match args.key_serialization {
KeySerialization::B58 => bs58::encode(&args.entity_key).into_string(),
KeySerialization::UTF8 => std::str::from_utf8(&args.entity_key).unwrap().to_string(),
};
let asset_id = get_asset_id(
&ctx.accounts.merkle_tree.key(),
ctx.accounts.tree_authority.num_minted,
Expand All @@ -149,9 +145,13 @@ pub fn handler(ctx: Context<IssueProgramEntityV0>, args: IssueProgramEntityArgsV
key_serialization: args.key_serialization,
});

let mut metadata_uri = format!("{}/{}", ENTITY_METADATA_URL, key_str);
let mut metadata_uri = format!(
"{}/v2/entity/{}",
ENTITY_METADATA_URL,
ctx.accounts.key_to_asset.key()
);
if let Some(metadata_url) = args.metadata_url {
let formated_metadata_url = format!("{}/{}", metadata_url, key_str);
let formated_metadata_url = format!("{}/{}", metadata_url, ctx.accounts.key_to_asset.key());

require!(
formated_metadata_url.len() <= 200,
Expand Down
2 changes: 2 additions & 0 deletions programs/helium-entity-manager/src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod revoke_program_v0;
pub mod set_entity_active_v0;
pub mod set_maker_tree_v0;
pub mod temp_pay_mobile_onboarding_fee_v0;
pub mod temp_standardize_entity;
pub mod update_data_only_tree_v0;
pub mod update_iot_info_v0;
pub mod update_maker_tree_v0;
Expand All @@ -41,6 +42,7 @@ pub use revoke_program_v0::*;
pub use set_entity_active_v0::*;
pub use set_maker_tree_v0::*;
pub use temp_pay_mobile_onboarding_fee_v0::*;
pub use temp_standardize_entity::*;
pub use update_data_only_tree_v0::*;
pub use update_iot_info_v0::*;
pub use update_maker_tree_v0::*;
Expand Down
Loading

0 comments on commit 8560ad2

Please sign in to comment.