From 2bc6afd5771f7800d571b8fa3d54a1e7d3d92405 Mon Sep 17 00:00:00 2001 From: acheron Date: Wed, 4 Oct 2023 22:38:10 +0200 Subject: [PATCH 1/2] spl: Fix compilation error and warnings --- spl/src/metadata.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/spl/src/metadata.rs b/spl/src/metadata.rs index f24bdf9bce..52a87337fd 100644 --- a/spl/src/metadata.rs +++ b/spl/src/metadata.rs @@ -106,18 +106,8 @@ pub fn create_metadata_accounts_v3<'info>( ctx: CpiContext<'_, '_, '_, 'info, CreateMetadataAccountsV3<'info>>, data: mpl_token_metadata::types::DataV2, is_mutable: bool, - update_authority_is_signer: bool, - details: Option, + collection_details: Option, ) -> Result<()> { - let mpl_token_metadata::types::DataV2 { - name, - symbol, - uri, - creators, - seller_fee_basis_points, - collection, - uses, - } = data; let ix = mpl_token_metadata::instructions::CreateMetadataAccountV3 { metadata: *ctx.accounts.metadata.key, mint: *ctx.accounts.mint.key, @@ -129,7 +119,7 @@ pub fn create_metadata_accounts_v3<'info>( } .instruction( mpl_token_metadata::instructions::CreateMetadataAccountV3InstructionArgs { - collection_details: details, + collection_details, data, is_mutable, }, @@ -468,7 +458,7 @@ pub fn remove_creator_verification<'info>( pub fn utilize<'info>( ctx: CpiContext<'_, '_, '_, 'info, Utilize<'info>>, - use_authority_record_pda: Option, + use_authority_record: Option, burner: Option, number_of_uses: u64, ) -> Result<()> { @@ -483,7 +473,7 @@ pub fn utilize<'info>( token_account: *ctx.accounts.token_account.key, token_program: spl_token::ID, use_authority: *ctx.accounts.use_authority.key, - use_authority_record: None, + use_authority_record, } .instruction(mpl_token_metadata::instructions::UtilizeInstructionArgs { number_of_uses }); solana_program::program::invoke_signed( From 9255be025981ee8b1c9c4465294adfa76f13eaec Mon Sep 17 00:00:00 2001 From: acheron Date: Wed, 4 Oct 2023 22:54:35 +0200 Subject: [PATCH 2/2] Add a compile test for `metadata` feature --- .github/workflows/reusable-tests.yaml | 2 ++ tests/package.json | 1 + tests/spl/metadata/Anchor.toml | 9 +++++++++ tests/spl/metadata/Cargo.toml | 13 ++++++++++++ tests/spl/metadata/package.json | 16 +++++++++++++++ .../spl/metadata/programs/metadata/Cargo.toml | 20 +++++++++++++++++++ .../spl/metadata/programs/metadata/Xargo.toml | 2 ++ .../spl/metadata/programs/metadata/src/lib.rs | 8 ++++++++ tests/spl/metadata/tests/metadata.ts | 12 +++++++++++ tests/spl/metadata/tsconfig.json | 9 +++++++++ 10 files changed, 92 insertions(+) create mode 100644 tests/spl/metadata/Anchor.toml create mode 100644 tests/spl/metadata/Cargo.toml create mode 100644 tests/spl/metadata/package.json create mode 100644 tests/spl/metadata/programs/metadata/Cargo.toml create mode 100644 tests/spl/metadata/programs/metadata/Xargo.toml create mode 100644 tests/spl/metadata/programs/metadata/src/lib.rs create mode 100644 tests/spl/metadata/tests/metadata.ts create mode 100644 tests/spl/metadata/tsconfig.json diff --git a/.github/workflows/reusable-tests.yaml b/.github/workflows/reusable-tests.yaml index 7c297cf87b..d9f36cda2e 100644 --- a/.github/workflows/reusable-tests.yaml +++ b/.github/workflows/reusable-tests.yaml @@ -379,6 +379,8 @@ jobs: path: tests/composite - cmd: cd tests/errors && anchor test --skip-lint && npx tsc --noEmit path: tests/errors + - cmd: cd tests/spl/metadata && anchor test --skip-lint + path: spl/metadata - cmd: cd tests/spl/token-proxy && anchor test --skip-lint path: spl/token-proxy - cmd: cd tests/spl/token-wrapper && anchor test --skip-lint diff --git a/tests/package.json b/tests/package.json index bb619e9505..dc9b0a061b 100644 --- a/tests/package.json +++ b/tests/package.json @@ -30,6 +30,7 @@ "relations-derivation", "pyth", "realloc", + "spl/metadata", "spl/token-proxy", "spl/token-wrapper", "swap", diff --git a/tests/spl/metadata/Anchor.toml b/tests/spl/metadata/Anchor.toml new file mode 100644 index 0000000000..5a811fd8db --- /dev/null +++ b/tests/spl/metadata/Anchor.toml @@ -0,0 +1,9 @@ +[programs.localnet] +metadata = "Metadata11111111111111111111111111111111111" + +[provider] +cluster = "localnet" +wallet = "~/.config/solana/id.json" + +[scripts] +test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" diff --git a/tests/spl/metadata/Cargo.toml b/tests/spl/metadata/Cargo.toml new file mode 100644 index 0000000000..ef17a63c0a --- /dev/null +++ b/tests/spl/metadata/Cargo.toml @@ -0,0 +1,13 @@ +[workspace] +members = [ + "programs/*" +] + +[profile.release] +overflow-checks = true +lto = "fat" +codegen-units = 1 +[profile.release.build-override] +opt-level = 3 +incremental = false +codegen-units = 1 diff --git a/tests/spl/metadata/package.json b/tests/spl/metadata/package.json new file mode 100644 index 0000000000..2685ca46c7 --- /dev/null +++ b/tests/spl/metadata/package.json @@ -0,0 +1,16 @@ +{ + "name": "metadata", + "version": "0.28.0", + "license": "(MIT OR Apache-2.0)", + "homepage": "https://github.com/coral-xyz/anchor#readme", + "bugs": { + "url": "https://github.com/coral-xyz/anchor/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/coral-xyz/anchor.git" + }, + "engines": { + "node": ">=17" + } +} diff --git a/tests/spl/metadata/programs/metadata/Cargo.toml b/tests/spl/metadata/programs/metadata/Cargo.toml new file mode 100644 index 0000000000..c38e0fb52f --- /dev/null +++ b/tests/spl/metadata/programs/metadata/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "metadata" +version = "0.1.0" +description = "Created with Anchor" +rust-version = "1.60" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "metadata" + +[features] +no-entrypoint = [] +no-idl = [] +cpi = ["no-entrypoint"] +default = [] + +[dependencies] +anchor-lang = { path = "../../../../../lang" } +anchor-spl = { path = "../../../../../spl", features = ["metadata"] } diff --git a/tests/spl/metadata/programs/metadata/Xargo.toml b/tests/spl/metadata/programs/metadata/Xargo.toml new file mode 100644 index 0000000000..1744f098ae --- /dev/null +++ b/tests/spl/metadata/programs/metadata/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] \ No newline at end of file diff --git a/tests/spl/metadata/programs/metadata/src/lib.rs b/tests/spl/metadata/programs/metadata/src/lib.rs new file mode 100644 index 0000000000..cfb7194612 --- /dev/null +++ b/tests/spl/metadata/programs/metadata/src/lib.rs @@ -0,0 +1,8 @@ +//! Only tests whether `anchor-spl` builds with `metadata` feature enabled. + +use anchor_lang::prelude::*; + +declare_id!("Metadata11111111111111111111111111111111111"); + +#[program] +pub mod metadata {} diff --git a/tests/spl/metadata/tests/metadata.ts b/tests/spl/metadata/tests/metadata.ts new file mode 100644 index 0000000000..a374d675ff --- /dev/null +++ b/tests/spl/metadata/tests/metadata.ts @@ -0,0 +1,12 @@ +import * as anchor from "@coral-xyz/anchor"; + +import { Metadata } from "../target/types/metadata"; + +describe("Client interactions", () => { + anchor.setProvider(anchor.AnchorProvider.env()); + const program = anchor.workspace.metadata as anchor.Program; + + it("Builds and deploys", () => { + console.log("Program ID:", program.programId.toBase58()); + }); +}); diff --git a/tests/spl/metadata/tsconfig.json b/tests/spl/metadata/tsconfig.json new file mode 100644 index 0000000000..774260253f --- /dev/null +++ b/tests/spl/metadata/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "types": ["mocha", "chai"], + "lib": ["es2015"], + "module": "commonjs", + "target": "es6", + "esModuleInterop": true + } +}