Skip to content

Commit

Permalink
spl: Fix compilation error and warnings (#2647)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Oct 5, 2023
1 parent 5602244 commit 51578bc
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/reusable-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 4 additions & 14 deletions spl/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<mpl_token_metadata::types::CollectionDetails>,
collection_details: Option<mpl_token_metadata::types::CollectionDetails>,
) -> 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,
Expand All @@ -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,
},
Expand Down Expand Up @@ -468,7 +458,7 @@ pub fn remove_creator_verification<'info>(

pub fn utilize<'info>(
ctx: CpiContext<'_, '_, '_, 'info, Utilize<'info>>,
use_authority_record_pda: Option<Pubkey>,
use_authority_record: Option<Pubkey>,
burner: Option<Pubkey>,
number_of_uses: u64,
) -> Result<()> {
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"relations-derivation",
"pyth",
"realloc",
"spl/metadata",
"spl/token-proxy",
"spl/token-wrapper",
"swap",
Expand Down
9 changes: 9 additions & 0 deletions tests/spl/metadata/Anchor.toml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 13 additions & 0 deletions tests/spl/metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions tests/spl/metadata/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
20 changes: 20 additions & 0 deletions tests/spl/metadata/programs/metadata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
2 changes: 2 additions & 0 deletions tests/spl/metadata/programs/metadata/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.bpfel-unknown-unknown.dependencies.std]
features = []
8 changes: 8 additions & 0 deletions tests/spl/metadata/programs/metadata/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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 {}
12 changes: 12 additions & 0 deletions tests/spl/metadata/tests/metadata.ts
Original file line number Diff line number Diff line change
@@ -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<Metadata>;

it("Builds and deploys", () => {
console.log("Program ID:", program.programId.toBase58());
});
});
9 changes: 9 additions & 0 deletions tests/spl/metadata/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"types": ["mocha", "chai"],
"lib": ["es2015"],
"module": "commonjs",
"target": "es6",
"esModuleInterop": true
}
}

1 comment on commit 51578bc

@vercel
Copy link

@vercel vercel bot commented on 51578bc Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anchor-docs – ./

anchor-docs-git-master-200ms.vercel.app
anchor-lang.com
www.anchor-lang.com
anchor-docs-200ms.vercel.app

Please sign in to comment.