-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,349 additions
and
1,617 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
[features] | ||
seeds = false | ||
[programs.devnet] | ||
create_token = "5yRmjtx87UJMJF4NEeqjpmgAu7MBJZACW6ksiCYqQxVh" | ||
skip-lint = false | ||
|
||
[programs.localnet] | ||
create_token = "2B6MrsKB2pVq6W6tY8dJLcnSd3Uv1KE7yRaboBjdQoEX" | ||
|
||
[registry] | ||
url = "https://anchor.projectserum.com" | ||
url = "https://api.apr.dev" | ||
|
||
[provider] | ||
cluster = "devnet" | ||
cluster = "localnet" | ||
wallet = "~/.config/solana/id.json" | ||
|
||
[scripts] | ||
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" | ||
|
||
[test] | ||
startup_wait = 5000 | ||
shutdown_wait = 2000 | ||
|
||
[test.validator] | ||
bind_address = "0.0.0.0" | ||
url = "https://api.mainnet-beta.solana.com" | ||
ledger = ".anchor/test-ledger" | ||
rpc_port = 8899 | ||
|
||
[[test.validator.clone]] | ||
address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{ | ||
"dependencies": { | ||
"@metaplex-foundation/mpl-token-metadata": "^2.5.2", | ||
"@project-serum/anchor": "^0.24.2" | ||
}, | ||
"devDependencies": { | ||
"@types/bn.js": "^5.1.0", | ||
"@types/chai": "^4.3.0", | ||
"@types/mocha": "^9.0.0", | ||
"chai": "^4.3.4", | ||
"mocha": "^9.0.3", | ||
"ts-mocha": "^10.0.0", | ||
"typescript": "^4.3.5" | ||
} | ||
"dependencies": { | ||
"@coral-xyz/anchor": "^0.28.1-beta.2", | ||
"@metaplex-foundation/mpl-token-metadata": "^2.5.2" | ||
}, | ||
"devDependencies": { | ||
"@types/bn.js": "^5.1.0", | ||
"@types/chai": "^4.3.0", | ||
"@types/mocha": "^9.0.0", | ||
"chai": "^4.3.4", | ||
"mocha": "^9.0.3", | ||
"ts-mocha": "^10.0.0", | ||
"typescript": "^4.3.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,91 @@ | ||
import { | ||
PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID | ||
} from '@metaplex-foundation/mpl-token-metadata'; | ||
import * as anchor from "@project-serum/anchor"; | ||
import { PROGRAM_ID as TOKEN_METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; | ||
import * as anchor from "@coral-xyz/anchor"; | ||
import { TOKEN_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; | ||
import { CreateToken } from "../target/types/create_token"; | ||
|
||
import { | ||
PublicKey, | ||
Keypair, | ||
SYSVAR_RENT_PUBKEY, | ||
SystemProgram, | ||
} from "@solana/web3.js"; | ||
|
||
describe("Create Tokens", () => { | ||
|
||
const provider = anchor.AnchorProvider.env(); | ||
anchor.setProvider(provider); | ||
const payer = provider.wallet as anchor.Wallet; | ||
const program = anchor.workspace.CreateToken as anchor.Program<CreateToken>; | ||
|
||
const tokenTitle = "Solana Gold"; | ||
const tokenSymbol = "GOLDSOL"; | ||
const tokenUri = "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json"; | ||
const metadata = { | ||
name: "Solana Gold", | ||
symbol: "GOLDSOL", | ||
uri: "https://raw.githubusercontent.com/solana-developers/program-examples/new-examples/tokens/tokens/.assets/spl-token.json", | ||
}; | ||
|
||
it("Create an SPL Token!", async () => { | ||
// Generate new keypair to use as address for mint account. | ||
const mintKeypair = new Keypair(); | ||
|
||
const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); | ||
|
||
const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( | ||
// Derive the PDA of the metadata account for the mint. | ||
const [metadataAddress] = PublicKey.findProgramAddressSync( | ||
[ | ||
Buffer.from("metadata"), | ||
TOKEN_METADATA_PROGRAM_ID.toBuffer(), | ||
mintKeypair.publicKey.toBuffer(), | ||
], | ||
TOKEN_METADATA_PROGRAM_ID | ||
))[0]; | ||
); | ||
|
||
// SPL Token default = 9 decimals | ||
// | ||
const sx = await program.methods.createTokenMint( | ||
tokenTitle, tokenSymbol, tokenUri, 9 | ||
) | ||
const transactionSignature = await program.methods | ||
.createTokenMint(metadata.name, metadata.symbol, metadata.uri, 9) | ||
.accounts({ | ||
payer: payer.publicKey, | ||
metadataAccount: metadataAddress, | ||
mintAccount: mintKeypair.publicKey, | ||
mintAuthority: payer.publicKey, | ||
payer: payer.publicKey, | ||
rent: anchor.web3.SYSVAR_RENT_PUBKEY, | ||
systemProgram: anchor.web3.SystemProgram.programId, | ||
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID, | ||
rent: SYSVAR_RENT_PUBKEY, | ||
systemProgram: SystemProgram.programId, | ||
tokenProgram: TOKEN_PROGRAM_ID, | ||
tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, | ||
}) | ||
.signers([mintKeypair, payer.payer]) | ||
.signers([mintKeypair]) | ||
.rpc(); | ||
|
||
console.log("Success!"); | ||
console.log(` Mint Address: ${mintKeypair.publicKey}`); | ||
console.log(` Tx Signature: ${sx}`); | ||
console.log(` Mint Address: ${mintKeypair.publicKey}`); | ||
console.log(` Transaction Signature: ${transactionSignature}`); | ||
}); | ||
|
||
it("Create an NFT!", async () => { | ||
|
||
const mintKeypair: anchor.web3.Keypair = anchor.web3.Keypair.generate(); | ||
// Generate new keypair to use as address for mint account. | ||
const mintKeypair = new Keypair(); | ||
|
||
const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress( | ||
// Derive the PDA of the metadata account for the mint. | ||
const [metadataAddress] = PublicKey.findProgramAddressSync( | ||
[ | ||
Buffer.from("metadata"), | ||
TOKEN_METADATA_PROGRAM_ID.toBuffer(), | ||
mintKeypair.publicKey.toBuffer(), | ||
], | ||
TOKEN_METADATA_PROGRAM_ID | ||
))[0]; | ||
); | ||
|
||
// NFT default = 0 decimals | ||
// | ||
const sx = await program.methods.createTokenMint( | ||
tokenTitle, tokenSymbol, tokenUri, 0 | ||
) | ||
const transactionSignature = await program.methods | ||
.createTokenMint(metadata.name, metadata.symbol, metadata.uri, 0) | ||
.accounts({ | ||
payer: payer.publicKey, | ||
metadataAccount: metadataAddress, | ||
mintAccount: mintKeypair.publicKey, | ||
mintAuthority: payer.publicKey, | ||
payer: payer.publicKey, | ||
rent: anchor.web3.SYSVAR_RENT_PUBKEY, | ||
systemProgram: anchor.web3.SystemProgram.programId, | ||
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID, | ||
rent: SYSVAR_RENT_PUBKEY, | ||
systemProgram: SystemProgram.programId, | ||
tokenProgram: TOKEN_PROGRAM_ID, | ||
tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, | ||
}) | ||
.signers([mintKeypair, payer.payer]) | ||
.signers([mintKeypair]) | ||
.rpc(); | ||
|
||
console.log("Success!"); | ||
console.log(` Mint Address: ${mintKeypair.publicKey}`); | ||
console.log(` Tx Signature: ${sx}`); | ||
console.log(` Mint Address: ${mintKeypair.publicKey}`); | ||
console.log(` Transaction Signature: ${transactionSignature}`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
[features] | ||
seeds = false | ||
[programs.devnet] | ||
nft_minter = "A6itasS5iqANkC9yrzP1HJPBnJxj9tC8G5TmJzQGogGG" | ||
skip-lint = false | ||
|
||
[registry] | ||
url = "https://anchor.projectserum.com" | ||
[programs.localnet] | ||
nft_minter = "3qHNM98iLTaQtwmj2NkViXnHZQjNBS5PTHT2AuPxHXYN" | ||
|
||
[provider] | ||
cluster = "devnet" | ||
cluster = "localnet" | ||
wallet = "~/.config/solana/id.json" | ||
|
||
[scripts] | ||
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" | ||
|
||
[test] | ||
startup_wait = 5000 | ||
shutdown_wait = 2000 | ||
|
||
[test.validator] | ||
bind_address = "0.0.0.0" | ||
url = "https://api.mainnet-beta.solana.com" | ||
ledger = ".anchor/test-ledger" | ||
rpc_port = 8899 | ||
|
||
[[test.validator.clone]] | ||
address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
[workspace] | ||
members = [ | ||
"programs/*" | ||
] | ||
members = ["programs/*"] | ||
|
||
[profile.release] | ||
overflow-checks = true | ||
|
Oops, something went wrong.