Coder Social home page Coder Social logo

solana-playground / solana-playground Goto Github PK

View Code? Open in Web Editor NEW
392.0 12.0 127.0 31.95 MB

Quickly develop, deploy and test Solana programs from browsers

Home Page: https://beta.solpg.io

License: Apache License 2.0

TypeScript 18.52% CSS 0.01% JavaScript 1.42% Rust 79.66% Python 0.34% Shell 0.05% Dockerfile 0.02%
solana solana-program solana-development solana-playground solana-ide rust playground wasm webassembly blockchain

solana-playground's Introduction

Solana Playground

SolPg allows you to quickly develop, deploy and test Solana programs(smart contracts) from browsers.

Supported crates

Crate Version
anchor-lang 0.29.0
anchor-spl 0.29.0
arrayref 0.3.7
borsh 0.10.3
borsh-derive 0.10.3
bytemuck 1.14.0
bytemuck_derive 1.5.0
mpl-bubblegum 1.0.0
mpl-token-auth-rules 1.4.3
mpl-token-metadata 3.2.3
num-derive 0.4.0
num-traits 0.2.16
pyth-sdk 0.8.0
pyth-sdk-solana 0.8.0
serde 1.0.193
solana-program 1.16.24
spl-account-compression 0.2.0
spl-associated-token-account 2.2.0
spl-pod 0.1.0
spl-tlv-account-resolution 0.4.0
spl-token 4.0.0
spl-token-2022 0.9.0
spl-token-metadata-interface 0.2.0
spl-transfer-hook-interface 0.3.0
spl-type-length-value 0.3.0
switchboard-solana 0.29.79
switchboard-v2 0.4.0
thiserror 1.0.48

You can open an issue to request more crates.

Note: Playground is still in beta and everything is subject to change.

Run locally

You can run the client locally by cloning the repository and running the following commands in the project directory.

Setup and start the dev server:

cd client # change directory to client
yarn setup # run the setup script(only once)
yarn start # start local dev server
Recommended versions
rustc --version
# rustc 1.75.0 (82e1608df 2023-12-21)

wasm-pack --version
# wasm-pack 0.10.3

node --version
# v18.15.0

yarn --version
# 1.22.19

Contributing

Anyone is welcome to contribute to Solana Playground no matter how big or small.

License

Public libraries(e.g. solana-client-wasm, solana-extra-wasm) are licensed under Apache-2.0 and the rest are licensed under GPL-3.0.

solana-playground's People

Contributors

0xdeepmehta avatar 0xproflupin avatar acheroncrypto avatar aursen avatar avasisht23 avatar borkborked avatar borovkovsergey avatar cardene777 avatar cleon30 avatar dhruvsol avatar eliascm17 avatar gitbolt avatar hardhatchad avatar jacobcreech avatar jim4067 avatar lostintime101 avatar mcintyre94 avatar nickgarfield avatar omahs avatar steveluscher avatar tanim0la avatar woody4618 avatar zyjliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

solana-playground's Issues

Docker for api

Did we have Docker for api for local implement?

I think we can add Run capability for simple client/helloworld.rs rust client that interact with program we already deploy.
I know this may be out of scope of this project but what we have here is pretty close to rust's playground+solana create already.

FYI: I just having fun playing around here so feel free to say no. :)

Support crates spl-token

Hi thanks for awesome work.

Can you help to add spl-token crate ๐Ÿ˜‡.

Thanks you ๐Ÿ™Œ

Allow `.so` file import

We should allow users to import their .so file and deploy from playground because many people have deployment problems with the solana-cli.

[Feature Request] Code snippet sharing

Just riffing with the idea of code snippet sharing on SolPg.

  • Share code snippets with a shortened URL, makes sharing small PoCs easier for devs.
  • Have an option to import the code from a git repo like GitHub (May cause an issue with Anchor.toml, Cargo.toml file imports)
  • Have an option to export the files from SolPg into a compressed package.

Terminal keybinds

Users should be able to use the following commands to interact with the terminal(ctrl = cmd):

  • ctrl + ` to toggle the terminal
  • ctrl + l to clear the terminal

AbiExample could not find `log` in the list of imported crates

I got this error in vscode

solana_frozen_abi_macro
proc_macro AbiExample
failed to resolve: could not find `log` in the list of imported crates
could not find `log` in the list of imported cratesrustc[E0433](https://doc.rust-lang.org/error-index.html#E0433)
conflicting implementations of trait `solana_frozen_abi::abi_example::AbiExample` for type `program::vote::authorized_voters::AuthorizedVoters`
conflicting implementation in crate `solana_frozen_abi`:
- impl<T> AbiExample for T;rustc[E0119](https://doc.rust-lang.org/error-index.html#E0119)

and also this error while build solana-client

fox:solana-client katopz$ cargo build
   Compiling rand v0.7.3
   Compiling zeroize v1.3.0
   Compiling sha2 v0.9.9
   Compiling borsh v0.9.3
   Compiling curve25519-dalek v3.2.1
   Compiling libsecp256k1 v0.6.0
   Compiling ed25519-dalek v1.0.1
   Compiling ed25519-dalek-bip32 v0.2.0
   Compiling solana-program v1.11.0
   Compiling solana-sdk v1.11.0
   Compiling solana-extra-wasm v1.11.0-alpha (/Users/katopz/git/katopz/solana-playground/wasm/utils/solana-extra)
error[E0433]: failed to resolve: could not find `log` in the list of imported crates
 --> utils/solana-extra/src/program/vote/authorized_voters.rs:7:72
  |
7 | #[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, Clone, AbiExample)]
  |                                                                        ^^^^^^^^^^ could not find `log` in the list of imported crates
  |
  = note: this error originates in the derive macro `AbiExample` (in Nightly builds, run with -Z macro-backtrace for more info)

not sure what i miss, anyway what's rust version you have there?

Memory leak on api requests

There can be memory leak if a user changes explorer pages during an async request. We should check to see if the component is still mounted at the end of the request before updating the state.

Tabs functionality

Users should be able to:

  • Drag and drop tabs
  • Close all open tabs
  • Close tabs to the right
  • Close other tabs

Add TextMate Grammar Support

Monaco editor uses Monarch grammars by default which results in faster performance but worse syntax highlighting.

VSCode is using TextMate grammars which many people are familiar with. We can add support for it by looking at the example implementation here.

This would not only allow for much better syntax highlighting but also would make it much easier to integrate VSCode themes.

Invalid Account Data for Instruction

failed to send transaction: Transaction simulation failed: Error processing Instruction 1: invalid account data for instruction

Its showing during deployment to devnet.

SystemTime library not working

Im trying to use System::now() with UNIX_EPOCH to get the time stamp but seems to be giving error on it. kindly fix asap

Autocomplete

We should add basic autocomplete to the editor and improve it over time.

Add client tests

Would be great to have ts/js tests directly integrated in the playground like mentioned in #53.

Requirements

  1. Run tests without a server
  2. Sandboxed environment inside the browser
  3. Allow access to testing libraries, web3.js and anchor

Make sure deployment succeeds

Current version of deployment process doesn't expect Solana to be congested. This is not an issue with the localhost but it's a potential issue with devnet, testnet and mainnet-beta If a transaction gets dropped or deployment doesn't finish in a short period of time, the deployment could fail.

We can make sure the deployment succeeds if we implement a custom logic like solana-deployer.

Could you share dev instructions?

Would love to look at how I could contribute to this!

Specific questions:

  • Do you need to run the wasm things locally and how do you do so?
  • I cloned the repo locally, in client ran yarn and then yarn start, and I'm getting some TS errors:
Compiled with problems:X

ERROR in src/components/Panels/Side/Right/Test/Function.tsx:62:5

TS2322: Type 'never[]' is not assignable to type 'KV'.
  Index signature for type 'string' is missing in type 'never[]'.
    60 |   const [txVals, setTxVals] = useState<TxVals>({
    61 |     name: ixs.name,
  > 62 |     additionalSigners: [],
       |     ^^^^^^^^^^^^^^^^^
    63 |   });
    64 |   const [errors, setErrors] = useState<{ [key: string]: number }>({});
    65 |   const [loading, setLoading] = useState(false);


ERROR in src/utils/pg/test.ts:298:54

TS2345: Argument of type '(string | number | PublicKey | Signer | BN)[]' is not assignable to parameter of type 'Signer[]'.
  Type 'string | number | PublicKey | Signer | BN' is not assignable to type 'Signer'.
    Type 'string' is not assignable to type 'Signer'.
    296 |     }
    297 |
  > 298 |     const txHash = await PgTx.send(tx, conn, wallet, additionalSigners);
        |                                                      ^^^^^^^^^^^^^^^^^
    299 |     return txHash;
    300 |   }
    301 | }

Is there something else I need to do/some specific config I could be missing to get it running locally? I'm using Node v16.16.0 (latest LTS).

[Feature Request] UI to fetch account data

I think the test UI would be even more useful if there was a way to fetch the account data from the deployed program and view it in the playground.

I think a way to do program.account.newAccount.fetch(publicKey) and program.account.newAccount.all() would add a huge amount of value. This would let us test an instruction and immediately see its effect on-chain.

I expect the UI for this would allow selecting an account (parsed from the IDL), either selecting all or optionally entering a specific address, and it'd then display the fetched data as nicely formatted JSON.

Improve wallet UX

Currently the wallet is sort of hidden in the bottom left corner. User should be able to connect when doing their task without looking for where the wallet is. Users should also receive auto-airdrop when they first connect so that they can deploy without effort.

Add progress indicator for deployment

We check and confirm every deploy transaction because we want to guarantee the deployment. This process could be slow depending on network conditions. Users should be able to see some kind of progress indicator for better UX.

Can we have support for the reqwest crate?

Thanks for making solana-playground, it is super helpful, especially for people new to Rust and Solana development!

I want to try and make a GET call to an API inside of my solana program, and I see that I need reqwest in order to do that. I don't see reqwest as a supported crate in your list of supported crates.

I apologize if this is actually an unreasonable request, I am new to Rust and Solana and I am not sure what is possible.

Multiple anchor version

Hi, I also wanted to create my playground, mainly for rust. However, since this project exists, I would like to leave you with an idea.

It is worth adding support for multiple anchor versions by creating a template for each version. The compilation of the versions can be done by the docker project serum which is updated every version by the serum.

https://hub.docker.com/r/projectserum/build/tags

With this setup, you would be able to automatically add support for the new anchor version thanks to github actions.

Allow users to export IDL

It would be convenient to have a download IDL button for the people who want to use the IDL in their frontend or do local testing.

Unable to 'anchor build' two programs that are dependent on each other

I want to import both Solana programs on https://github.com/cardinal-labs/cardinal-staking/tree/main/programs.

I import it via Github so I have two Projects titled with:

  1. github-cardinal-labs/cardinal-staking/programs/cardinal-stake-pool
  2. github-cardinal-labs/cardinal-staking/programs/cardinal-reward-distributor

When trying to use the anchor build it shows:

Building...
$    error[E0432]: unresolved import `cardinal_token_manager`
 --> /src/instructions/claim_receipt_mint.rs:9:9
  |
9 |         self,
  |         ^^^^ no external crate `cardinal_token_manager`
 
error[E0433]: failed to resolve: use of undeclared crate or module `cardinal_token_manager`
 --> /src/instructions/return_receipt_mint.rs:5:5
  |
5 |     cardinal_token_manager::{program::CardinalTokenManager, state::TokenManager},
  |     ^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `cardinal_token_manager`
 
error[E0432]: unresolved import `cardinal_token_manager`
  --> /src/instructions/init_stake_mint.rs:13:30
   |
13 |     cardinal_token_manager::{self, program::CardinalTokenManager},
   |                              ^^^^ no external crate `cardinal_token_manager`
 
error[E0433]: failed to resolve: use of undeclared type `TokenManagerKind`
  --> /src/instructions/claim_receipt_mint.rs:72:30
   |
72 |         token_manager_kind = TokenManagerKind::Edition;
   |                              ^^^^^^^^^^^^^^^^ use of undeclared type `TokenManagerKind`
 
error[E0433]: failed to resolve: use of undeclared type `TokenManagerKind`
  --> /src/instructions/claim_receipt_mint.rs:75:30
   |
75 |         token_manager_kind = TokenManagerKind::Managed;
   |                              ^^^^^^^^^^^^^^^^ use of undeclared type `TokenManagerKind`
 
error[E0433]: failed to resolve: use of undeclared type `InvalidationType`
  --> /src/instructions/claim_receipt_mint.rs:84:28
   |
84 |         invalidation_type: InvalidationType::Return as u8,
   |                            ^^^^^^^^^^^^^^^^ use of undeclared type `InvalidationType`
 
error[E0433]: failed to resolve: use of undeclared crate or module `cardinal_token_manager`
  --> /src/instructions/return_receipt_mint.rs:47:28
   |
47 |         let cpi_accounts = cardinal_token_manager::cpi::accounts::InvalidateCtx {
   |                            ^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `cardinal_token_manager`
 
error[E0433]: failed to resolve: use of undeclared crate or module `cardinal_token_manager`
  --> /src/instructions/return_receipt_mint.rs:58:9
   |
58 |         cardinal_token_manager::cpi::invalidate(cpi_ctx)?;
   |         ^^^^^^^^^^^^^^^^^^^^^^ use of undeclared crate or module `cardinal_token_manager`
 
error[E0412]: cannot find type `CardinalTokenManager` in this scope
  --> /src/instructions/claim_receipt_mint.rs:53:43
   |
16 | pub struct ClaimReceiptMintCtx<'info> {
   |                                     - help: you might be missing a type parameter: `, CardinalTokenManager`
...
53 |     token_manager_program: Program<'info, CardinalTokenManager>,
   |                                           ^^^^^^^^^^^^^^^^^^^^ not found in this scope
 
error[E0412]: cannot find type `CardinalTokenManager` in this scope
  --> /src/instructions/init_stake_mint.rs:53:43
   |
27 | pub struct InitStakeMintCtx<'info> {
   |                                  - help: you might be missing a type parameter: `, CardinalTokenManager`
...
53 |     token_manager_program: Program<'info, CardinalTokenManager>,
   |                                           ^^^^^^^^^^^^^^^^^^^^ not found in this scope
 
error[E0412]: cannot find type `TokenManager` in this scope
  --> /src/instructions/return_receipt_mint.rs:16:39
   |
9  | pub struct ReturnReceiptMintCtx<'info> {
   |                                      - help: you might be missing a type parameter: `, TokenManager`
...
16 |     token_manager: Box<Account<'info, TokenManager>>,
   |                                       ^^^^^^^^^^^^ not found in this scope
 
error[E0412]: cannot find type `CardinalTokenManager` in this scope
  --> /src/instructions/return_receipt_mint.rs:30:43
   |
9  | pub struct ReturnReceiptMintCtx<'info> {
   |                                      - help: you might be missing a type parameter: `, CardinalTokenManager`
...
30 |     token_manager_program: Program<'info, CardinalTokenManager>,
   |                                           ^^^^^^^^^^^^^^^^^^^^ not found in this scope
 
Some errors have detailed explanations: E0412, E0432, E0433.
error: could not compile `solpg` due to 12 previous errors

I compile it in my Visual Studio and deploy it successfully. I think this can be solved via several methods:

  1. Allowing the Github import of parents file
  2. Disable each Github import will create a new project, making the Github import of multiple programs available in one project

What do you think?

Linting

We should implement basic linting for easier error spotting.

add cargo.toml file as editable

Kindly add cargo.toml in the src folder, So packages can be get easily, Which would make things easier for getting stuff thats custom and not supported here. e.g: access_control.

Resize sidebar

Users should be able to resize the sidebar. It especially helps during tests.

Terminal commands

Users should be able to use Solana-CLI and common UNIX commands(i.e mkdir).

Add an option to import and export keypair

Some users might want to load their existing wallets into Playground Wallet. We should have an option to do so both when user first connects to Playground Wallet and also in the wallet menu(bottom left). Users should also be able to export their keypairs, ideally download as a json file.

Unable to input struct in Solanapg

Hello,
I am new to Solana development. I am using Solana Playground IDE to implement the Tic-Tac-Toe implementation guide.
I have run the setupGame function and can fetch the game details using the address for the game.
I have also implemented the play function which takes game address key, player address key and tile input (tile is a struct implementation with row and column values in it). I am facing issue in inputting the struct value "{0,1}" into the play function and run the function as the second player. But I am able to run the play function as first player and "{}" value for Tile input.
Can you kindly help how should I input the tile struct value "{0,1}" into play function?

Posting here as I do not see any other forum for discussion (hopefully that will change in future :))

Attaching screenshot of disabled button
image

Undo delete functionality for files and folders

What happened:
I was editing in this browser, and all to quickly hit the 'delete' key while focused on the wrong part of the page. I was already about to type 'Enter', and so I deleted my entire lib.rs file with no way of recovery.

What would help:
An "Undo Delete" feature would improve the usability of this project by helping users avoid painful losses from a mistroke of the keyboard.

Possible Implementation, High-Level:
All files and folders could be deleted "softly", so that if the user focuses the sidebar and presses 'Crl+Z', or clicks an 'Undo' icon, they can restore their file. This would likely require storing the file data in either localStorage, or not really removing it from state and instead moving it to a 'deleted' state, that can be recovered.

  • Factors like the size of the file(s) deleted or time after deletion could also be used to hard delete files if that optimization is desired

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.