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

Add MPL-404 #156

Open
wants to merge 2 commits into
base: gibwork-mpl-404
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/cmds-solana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pyth-sdk-solana = { git = "https://github.com/space-operator/pyth-sdk-rs", rev =
# anchor
anchor-lang = "=0.28.0"
anchor-spl = "=0.28.0"
mpl-hybrid = "0.1.0"

# clockwork-client = "=2.0.1"
# clockwork-utils = "=2.0.1"
Expand Down
240 changes: 240 additions & 0 deletions crates/cmds-solana/node-definitions/mpl_hybrid/mpl_hybrid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
{
"type": "native",
"data": {
"node_definition_version": "0.1",
"unique_id": "",
"node_id": "mpl_hybrid",
"version": "0.1",
"display_name": "MplHybrid",
"description": "Mpl hybrid impl",
"tags": [],
"related_to": [
{
"id": "",
"type": "",
"relationship": ""
}
],
"resources": {
"source_code_url": "",
"documentation_url": ""
},
"usage": {
"license": "Apache-2.0",
"license_url": "",
"pricing": {
"currency": "USDC",
"purchase_price": 0,
"price_per_run": 0,
"custom": {
"unit": "monthly",
"value": "0"
}
}
},
"authors": [
{
"name": "Space Operator",
"contact": ""
}
],
"design": null,
"options": null,
"instruction_info": {
"before": [],
"signature": "signature",
"after": []
}
},
"sources": [
{
"name": "signature",
"type": "signature",
"defaultValue": null,
"tooltip": "",
"optional": true
}
],
"targets": [
{
"name": "fee_payer",
"type_bounds": ["keypair"],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": true
},
{
"name": "owner",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "authority",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "escrow",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "asset",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "collection",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "user_token_account",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "escrow_token_account",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "token",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "fee_token_account",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "fee_sol_account",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "fee_project_account",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "recent_blockhashes",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "mpl_core",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "system_program",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "token_program",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "associated_token_program",
"type_bounds": [
"pubkey"
],
"required": true,
"defaultValue": null,
"tooltip": "",
"passthrough": false
},
{
"name": "submit",
"type_bounds": [
"bool"
],
"required": false,
"defaultValue": true,
"tooltip": "",
"passthrough": false
}
],
"targets_form.ui_schema": {},
"targets_form.json_schema": {}
}
102 changes: 102 additions & 0 deletions crates/cmds-solana/src/mpl_hybrid/mpl_hybrid.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
use flow_lib::command::prelude::*;
const NAME: &str = "mpl_hybrid";
flow_lib::submit!(CommandDescription::new(NAME, | _ | build()));
fn build() -> BuildResult {
const DEFINITION: &str = flow_lib::node_definition!("mpl_hybrid/mpl_hybrid.json");
static CACHE: BuilderCache = BuilderCache::new(|| {
CmdBuilder::new(DEFINITION)?.check_name(NAME)
});
Ok(CACHE.clone()?.build(run))
}
#[serde_as]
#[derive(Deserialize, Serialize, Debug)]
pub struct Input {
#[serde(with = "value::keypair")]
pub fee_payer: Keypair,
#[serde_as(as = "AsPubkey")]
owner: Pubkey,
#[serde_as(as = "AsPubkey")]
authority: Pubkey,
#[serde_as(as = "AsPubkey")]
escrow: Pubkey,
#[serde_as(as = "AsPubkey")]
asset: Pubkey,
#[serde_as(as = "AsPubkey")]
collection: Pubkey,
#[serde_as(as = "AsPubkey")]
user_token_account: Pubkey,
#[serde_as(as = "AsPubkey")]
escrow_token_account: Pubkey,
#[serde_as(as = "AsPubkey")]
token: Pubkey,
#[serde_as(as = "AsPubkey")]
fee_token_account: Pubkey,
#[serde_as(as = "AsPubkey")]
fee_sol_account: Pubkey,
#[serde_as(as = "AsPubkey")]
fee_project_account: Pubkey,
#[serde_as(as = "AsPubkey")]
recent_blockhashes: Pubkey,
#[serde_as(as = "AsPubkey")]
mpl_core: Pubkey,
#[serde_as(as = "AsPubkey")]
system_program: Pubkey,
#[serde_as(as = "AsPubkey")]
token_program: Pubkey,
#[serde_as(as = "AsPubkey")]
associated_token_program: Pubkey,
#[serde(default = "value::default::bool_true")]
submit: bool,
}
#[serde_as]
#[derive(Deserialize, Serialize, Debug)]
pub struct Output {
#[serde_as(as = "Option<AsSignature>")]
pub signature: Option<Signature>,
}
async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
tracing::info!("input: {:?}", input);
let recent_blockhash = client.get_latest_blockhash().await?;
let blockhash_as_str = recent_blockhash.clone().to_string();
let capture_instraction = mpl_hybrid::instructions::CaptureV1{
input.owner,
input.authority,
input.escrow,
input.asset,
input.collection,
input.user_token_account,
input.escrow_token_account,
input.token,
input.fee_token_account,
input.fee_sol_account,
input.fee_project_account,
input.fee_token_account,
input.recent_blockhashes,
input.mpl_core,
input.system_program,
input.token_program,
input.associated_token_program,
}.instruction_with_remaining_accounts(&[]);

let instructions = Instructions {
fee_payer: input.fee_payer.pubkey(),
signers: [input.fee_payer.clone_keypair()].into(),
instructions: [capture_instraction].into(),
};
let signature = ctx.execute(instructions, <_>::default()).await?.signature;

Ok(Output { signature })
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_build() {
build().unwrap();
}
#[tokio::test]
async fn test_run() {
let ctx = Context::default();
build().unwrap().run(ctx, ValueSet::new()).await.unwrap_err();
}
}
2 changes: 1 addition & 1 deletion crates/cmds-solana/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn execute(
instructions: &[Instruction],
) -> crate::Result<(Transaction, Hash)> {
let recent_blockhash = client.get_latest_blockhash().await?;

let message = Message::new_with_blockhash(instructions, Some(fee_payer), &recent_blockhash);

let transaction = Transaction::new_unsigned(message);
Expand Down