/solana-contracts

Thales Solana contracts

Primary LanguageJavaScript

solana-contracts

Thales Solana contracts

TESTING CODE IN SOLANA PLAYBOOK

Import from github

  1. Go to: Solana Playbook environment
  2. Create a new project Anchor (Rust) with dummy name
  3. In the Projects menu -> import from github
  4. copy-paste https://github.com/thales-markets/solana-contracts and press import
  5. Go to Build & Deploy (top left corner second menu or press Ctrl+Shift+B)
  6. Run Build
  7. Connect to Playground wallet
  8. Create new keypair by connecting to Playground wallet
  9. Use the terminal to obtain airdrop by running: solana airdrop 5
  10. In tests, right-click on playbook_test.test.ts -> run Test

Manual way:

  1. Go to: Solana Playbook environment
  2. Create a new project
  3. Add name and choose framework: Anchor (Rust)
  4. Copy-paste from `programs/speed-markets/src/lib.rs into src-> lib.rs
  5. Copy-paste from tests/playbook.ts to tests-> anchor.test.rs
  6. Go to Build & Deploy (top left corner second menu or press Ctrl+Shift+B)
  7. Run Build
  8. Create new keypair by connecting to Playground wallet
  9. Use the terminal to obtain airdrop by running: solana airdrop 5
    OR go to Wallet (top right corner -> left (...) menu -> airdrop)
  10. After successful airdrop, run Deploy
  11. Run test in the terminal

Speed Markets

Main logic in:
speed-markets/program/speed-markets/src/lib.rs

Installing packages in:
speed-markets/program/speed-markets/src/Cargo.toml

Main tests in:
speed-markets/tests/speed-markets_devnet.js

Playbook test:
speed-markets/tests/playbook_test.ts

Branches

main - branch currently suitable for testing successful flow init -> create -> resolve

playbook_working_code - branch with most advanced logic, lacks proper testing

Local Environment setup

Used this source for installation

Needed:

Development notes

Adding dependencies to programs

  • In the programs/<program_id>/, run: cargo add mpl-token-metadata to add the mpl-token-metadata package as dependency
  • Other important dependencies: anchor-spl (SPL tokens), mpl-token-metadata (Tokens metadata);
  • Adding a new custom program to the package: anhor new <program-name> (kebab style of naming)
  • Local imports: puppet = { path = "../puppet", features = ["cpi"]} imports puppet program to be used with Cross Program Invokation (CPI)