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 tokens/poseidon/transfer_tokens #284

Open
wants to merge 4 commits into
base: main
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
169 changes: 127 additions & 42 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions tokens/transfer-tokens/poseidon/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[toolchain]

[features]
resolution = true
skip-lint = false

[programs.localnet]
transfer_tokens = "4h2WWD9id7t75bNDwwWRoWYh759MDePhPZFiFJat9E9S"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "Localnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "pnpm run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

[test]
startup_wait = 5000
shutdown_wait = 2000
upgradeable = false

[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"
14 changes: 14 additions & 0 deletions tokens/transfer-tokens/poseidon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[workspace]
members = [
"programs/*"
]
resolver = "2"

[profile.release]
overflow-checks = true
lto = "fat"
codegen-units = 1
[profile.release.build-override]
opt-level = 3
incremental = false
codegen-units = 1
76 changes: 76 additions & 0 deletions tokens/transfer-tokens/poseidon/dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status
set -e

# Mainnet URL
MAINNET_URL="https://api.mainnet-beta.solana.com"

# Function to check Solana installation
check_solana_installation() {
if ! command -v solana &> /dev/null; then
echo "Error: Solana CLI is not installed or not in PATH"
return 1
fi

if ! solana --version &> /dev/null; then
echo "Error: Solana CLI is available but returned an error"
return 1
fi

return 0
}

# Function to check and set Solana network to mainnet
check_and_set_mainnet() {
# Get current cluster
current_cluster=$(solana config get | grep "RPC URL" | awk '{print $3}')

# If not on mainnet, switch to mainnet
if [[ "$current_cluster" != "$MAINNET_URL" ]]; then
echo "Switching Solana network to mainnet..."
solana config set --url "$MAINNET_URL"
fi
}

# Function to check if Solana test validator is running
check_test_validator() {
# Check if solana-test-validator process is running
if ! pgrep -f "solana-test-validator" &> /dev/null; then
echo "Error: Solana test validator is not running."
echo "Please start Solana test validator in a new terminal in this directory:"
echo "cd $(pwd) && solana-test-validator"
return 1
fi

return 0
}

# Main script
main() {
# Check if Solana is installed
if ! check_solana_installation; then
echo "Solana check failed"
exit 1
fi

# Check and set to mainnet if needed
check_and_set_mainnet

# Check if test validator is running
if ! check_test_validator; then
exit 1
fi

# Dump Solana program
if ! solana program dump metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s mpl_token_metadata.so; then
echo "Failed to dump Solana program"
exit 1
fi

echo "Solana program dumped successfully"
}

# Run the main function
main

12 changes: 12 additions & 0 deletions tokens/transfer-tokens/poseidon/migrations/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Migrations are an early feature. Currently, they're nothing more than this
// single deploy script that's invoked from the CLI, injecting a provider
// configured from the workspace's Anchor.toml.

const anchor = require('@coral-xyz/anchor');

module.exports = async (provider) => {
// Configure client to use the provider.
anchor.setProvider(provider);

// Add your deploy script here.
};
Binary file not shown.
25 changes: 25 additions & 0 deletions tokens/transfer-tokens/poseidon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"license": "ISC",
"scripts": {
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
"ts-mocha": "ts-mocha --project tsconfig.json"
},
"dependencies": {
"@coral-xyz/anchor": "^0.30.1",
"@solana/spl-token": "0.4.9",
"@solana/web3.js": "^1.95.5",
"anchor-bankrun": "^0.5.0",
"solana-bankrun": "^0.4.0"
},
"devDependencies": {
"@types/bn.js": "^5.1.6",
"@types/chai": "^4.3.20",
"@types/mocha": "^9.1.1",
"chai": "^4.5.0",
"mocha": "^9.2.2",
"prettier": "^2.8.8",
"ts-mocha": "^10.0.0",
"typescript": "^4.9.5"
}
}
Loading
Loading