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

mpl 3.1.0 #4

Merged
merged 3 commits into from
Nov 8, 2023
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
13 changes: 7 additions & 6 deletions crates/cmds-solana/src/nft/candy_machine_v3/initialize.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
use crate::{nft::CandyMachineDataAlias, prelude::*};
use crate::{
nft::{CandyMachineDataAlias, TokenStandard},
prelude::*,
};
use anchor_lang::{InstructionData, ToAccountMetas};
use solana_program::{instruction::Instruction, system_instruction, system_program};
use solana_sdk::pubkey::Pubkey;

use mpl_candy_machine_core::{instruction::InitializeV2, CandyMachineData};
use mpl_token_metadata::{
accounts::{MasterEdition, Metadata},
instruction::MetadataDelegateRole,
state::TokenStandard,
types::MetadataDelegateRole,
};

// Command Name
const INITIALIZE_CANDY_MACHINE: &str = "initialize_candy_machine";

const DEFINITION: &str =
flow_lib::node_definition!("solana/NFT/candy_machine/initialize.json");
const DEFINITION: &str = flow_lib::node_definition!("solana/NFT/candy_machine/initialize.json");

fn build() -> BuildResult {
use once_cell::sync::Lazy;

Check warning on line 21 in crates/cmds-solana/src/nft/candy_machine_v3/initialize.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `once_cell::sync::Lazy`

warning: unused import: `once_cell::sync::Lazy` --> crates/cmds-solana/src/nft/candy_machine_v3/initialize.rs:21:9 | 21 | use once_cell::sync::Lazy; | ^^^^^^^^^^^^^^^^^^^^^

Check warning on line 21 in crates/cmds-solana/src/nft/candy_machine_v3/initialize.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `once_cell::sync::Lazy`

warning: unused import: `once_cell::sync::Lazy` --> crates/cmds-solana/src/nft/candy_machine_v3/initialize.rs:21:9 | 21 | use once_cell::sync::Lazy; | ^^^^^^^^^^^^^^^^^^^^^
static CACHE: BuilderCache = BuilderCache::new(|| {
CmdBuilder::new(DEFINITION)?
.check_name(INITIALIZE_CANDY_MACHINE)?
Expand Down Expand Up @@ -82,7 +83,7 @@

// Collection Delegate Record PDA
let collection_delegate_record =
mpl_token_metadata::pda::find_metadata_delegate_record_account(
mpl_token_metadata::accounts::MetadataDelegateRecord::find_pda(
&input.collection_mint,
MetadataDelegateRole::Collection,
&input.collection_update_authority.pubkey(),
Expand Down
11 changes: 5 additions & 6 deletions crates/cmds-solana/src/nft/candy_machine_v3/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@

use mpl_token_metadata::{
accounts::{MasterEdition, Metadata},
instructions::MetadataDelegateRole,
types::MetadataDelegateRole,
};

use super::CandyGuardData;

// Command Name
const MINT: &str = "mint";

const DEFINITION: &str =
flow_lib::node_definition!("solana/NFT/candy_machine/mint.json");
const DEFINITION: &str = flow_lib::node_definition!("solana/NFT/candy_machine/mint.json");

fn build() -> BuildResult {
use once_cell::sync::Lazy;

Check warning on line 20 in crates/cmds-solana/src/nft/candy_machine_v3/mint.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `once_cell::sync::Lazy`

warning: unused import: `once_cell::sync::Lazy` --> crates/cmds-solana/src/nft/candy_machine_v3/mint.rs:20:9 | 20 | use once_cell::sync::Lazy; | ^^^^^^^^^^^^^^^^^^^^^

Check warning on line 20 in crates/cmds-solana/src/nft/candy_machine_v3/mint.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `once_cell::sync::Lazy`

warning: unused import: `once_cell::sync::Lazy` --> crates/cmds-solana/src/nft/candy_machine_v3/mint.rs:20:9 | 20 | use once_cell::sync::Lazy; | ^^^^^^^^^^^^^^^^^^^^^
static CACHE: BuilderCache = BuilderCache::new(|| {
CmdBuilder::new(DEFINITION)?
.check_name(MINT)?
Expand Down Expand Up @@ -71,7 +70,7 @@
}

async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
let token_metadata_program = mpl_token_metadata::id();
let token_metadata_program = mpl_token_metadata::ID;
let candy_machine_program = mpl_candy_machine_core::id();
let candy_guard_program = mpl_candy_guard::id();

Expand All @@ -96,15 +95,15 @@
);

// Metadata TokenRecord Account
let nft_token_record = mpl_token_metadata::pda::find_token_record_account(
let nft_token_record = mpl_token_metadata::accounts::TokenRecord::find_pda(
&input.mint_account,
&nft_associated_token_account,
)
.0;

// Collection Delegate Record PDA
let collection_delegate_record =
mpl_token_metadata::pda::find_metadata_delegate_record_account(
mpl_token_metadata::accounts::MetadataDelegateRecord::find_pda(
&input.collection_mint,
MetadataDelegateRole::Collection,
&input.collection_update_authority,
Expand Down
2 changes: 1 addition & 1 deletion crates/cmds-solana/src/nft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
// pub mod approve_use_authority;
pub mod arweave_file_upload;
pub mod arweave_nft_upload;
// pub mod candy_machine_v3;
pub mod candy_machine_v3;
pub mod create_master_edition;
pub mod create_metadata_account;
pub mod v1;
Expand Down
14 changes: 14 additions & 0 deletions crates/db/src/connection/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ impl AdminConn {
Self { conn }
}

pub async fn get_natives_commands(self) -> crate::Result<Vec<String>> {
self.conn
.query(
r#"SELECT data->>'node_id' FROM nodes WHERE type = 'native' AND "isPublic""#,
&[],
)
.await
.map_err(Error::exec("get_natives_commands"))?
.into_iter()
.map(|r| r.try_get::<_, String>(0))
.collect::<Result<Vec<_>, _>>()
.map_err(Error::data("nodes.data->>'node_id'"))
}

pub async fn copy_in_flow_run_logs<I>(&self, rows: I) -> crate::Result<u64>
where
I: IntoIterator,
Expand Down
53 changes: 45 additions & 8 deletions crates/flow-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
user::{SignatureAuth, SupabaseAuth},
wss, Config,
};
use futures_util::future::ok;
use std::convert::Infallible;
use futures_util::{future::ok, TryFutureExt};
use hashbrown::HashSet;
use std::{borrow::Cow, convert::Infallible};
use utils::address_book::AddressBook;

// avoid commands being optimized out by the compiler
Expand Down Expand Up @@ -83,6 +84,32 @@
}
};

if let DbPool::Real(db) = &db {
let res = db
.get_admin_conn()
.and_then(move |conn| async move {
let names = conn.get_natives_commands().await?;
let mut missing = HashSet::new();
for name in names {
if !natives.contains(&&Cow::Borrowed(name.as_str())) {
missing.insert(name);
}
}
Ok(missing)
})
.await;
match res {
Ok(missing) => {
if !missing.is_empty() {
tracing::warn!("missing native commands: {:?}", missing);
}
}
Err(error) => {
tracing::error!("{}", error);
}
}
}

let db_worker = db_worker::DBWorker::new(db.clone(), config.clone(), actors).start();

let sig_auth = SignatureAuth::new(rand::random());
Expand All @@ -100,18 +127,18 @@
tracing::info!("listening on {:?} port {:?}", host, port);

HttpServer::new(move || {
let auth = if let Some(supabase_auth) = &supabase_auth {
Some(
web::scope("/auth")
.app_data(web::Data::new(sig_auth))
.app_data(web::Data::new(supabase_auth.clone()))
.service(api::claim_token::service(&config, db.clone()))
.service(api::init_auth::service(&config))
.service(api::confirm_auth::service(&config)),
)
} else {
None
};

Check warning on line 141 in crates/flow-server/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

manual implementation of `Option::map`

warning: manual implementation of `Option::map` --> crates/flow-server/src/main.rs:130:20 | 130 | let auth = if let Some(supabase_auth) = &supabase_auth { | ____________________^ 131 | | Some( 132 | | web::scope("/auth") 133 | | .app_data(web::Data::new(sig_auth)) ... | 140 | | None 141 | | }; | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map = note: `#[warn(clippy::manual_map)]` on by default help: try | 130 ~ let auth = supabase_auth.as_ref().map(|supabase_auth| web::scope("/auth") 131 + .app_data(web::Data::new(sig_auth)) 132 + .app_data(web::Data::new(supabase_auth.clone())) 133 + .service(api::claim_token::service(&config, db.clone())) 134 + .service(api::init_auth::service(&config)) 135 ~ .service(api::confirm_auth::service(&config))); |

let flow = web::scope("/flow")
.service(api::start_flow::service(&config, db.clone()))
Expand All @@ -133,11 +160,18 @@
.service(api::kvstore::write_item::service(&config, db.clone()))
.service(api::kvstore::delete_item::service(&config, db.clone()))
.service(api::kvstore::read_item::service(&config, db.clone()));
let db_route = web::scope("/proxy")
.service(api::db_rpc::service(&config, db.clone()))
.service(api::db_push_logs::service(&config, db.clone()))
.service(api::auth_proxy::service(&config, db.clone()))
.service(api::ws_auth_proxy::service(&config, db.clone()));

let db_proxy = if matches!(db, DbPool::Real(_)) {
Some(
web::scope("/proxy")
.service(api::db_rpc::service(&config, db.clone()))
.service(api::db_push_logs::service(&config, db.clone()))
.service(api::auth_proxy::service(&config, db.clone()))
.service(api::ws_auth_proxy::service(&config, db.clone())),
)
} else {
None
};

let app = App::new()
.wrap(Logger::new(r#""%r" %s %b %Dms"#).exclude("/healthcheck"))
Expand All @@ -153,12 +187,15 @@
app = app.service(auth);
}

if let Some(db_proxy) = db_proxy {
app = app.service(db_proxy);
}

app.service(flow)
.service(signature)
.service(apikeys)
.service(websocket)
.service(kvstore)
.service(db_route)
.service(healthcheck)
})
.bind((host, port))
Expand Down
Loading