VSCode extension to quickly write and customize well tested Solana snippets.

Overview

Solana Snippets

The Solana Snippets VSCode Extension allows you to quickly insert Solana snippets into your code. This snippets are well tested in a real Solana program and compiled to the VSCode Snippets format (JSON) using a custom compiler.

Solana Snippets

Snippets

When there's multiple inputs to fill in the snippet like a transfer execution [sender, receiver, amount], use TAB to switch to the next input. If the default input (placeholder) is sufficient, press TAB to keep it and pass to the following input. Repeated inputs only need to be filled once.

Title Command Description Inputs
Pack Account apack Packs an Account account
Unpack Account aunpack Unpacks an Account account
Check Rent Exempt chrent Check if an account is rent exempt account, type
Get Accounts Iterator gaccs Start iterator to get accounts of instruction account
Get Account gacc Get next account in the accounts iterator account
Get Clock Sysvar gclock Get the Clock Sysvar varname
Get Rent Sysvar grent Get the Rent Sysvar varname
Delegate Tokens tka Delegate any tokens using the Token Program token, delegate, authority, amount
Burn Tokens tkb Burn any tokens using the Token Program token, mint, authority, amount
Init Token tki Initialize an associated token account using the Token Program token, mint, owner
Revoke Tokens Delegation tkr Revoke the delegation of any tokens using the Token Program token, delegate, authority
Transfer Tokens tkt Transfer any tokens using the Token Program sender, receiver, authority, amount
Transfer Native SOL tsol Transfer SOL sender, receiver, amount

All the snippets are defined in different Rust files. This files uses comments to define the beginning and ending of the snippet. This approach allows to build and test the snippets before compiling the snippets in the JSON VSCode format.

State

Currently, the snippets are statically generated. The next step is to add dynamic generation in base to the source code of the project. This could lead to snippets like parsing all the accounts mentioned in the Instruction parser or getting a sysvar automatically when user uses an snippet that requires it.

let account_info_iter = &mut accounts.iter();
let account_one_info = next_account_info(account_info_iter)?;
let account_two_info = next_account_info(account_info_iter)?;
...

Release Process

The extension is currently tagged and released manually. Once a new version have tested all the snippets and deemed ready for release:

Bump Version

  • Increment the version number in the package.json file.
  • Run yarn build to test and compile the snippets and build the extension.
  • Open a PR with these version changes and merge after passing CI.

Create Github tag

Snippets extension tag are of the form solana-snippets-vX.Y.Z. Create the new tag at the version-bump commit and push to the repository, eg:

git tag solana-snippets-v1.0.0 b24bfe7
git push upstream --tags

Publish release

  • Go to GitHub Releases UI
  • Click "Draft new release", and enter the new tag in the "Tag version" box.
  • Title the release "Solana Snippets vX.Y.Z", complete the description, and attach the solana_snippets-v0.0.1.vsix.
  • Click "Publish release"
You might also like...
Galleries of NFTs using Solana and Rust for contracts

About this Package created to simplify the process of parsing NFTs on Solana. It consists of: Package basic things like fetch all NFTs for specific wa

hello-world geyser plugin to stream accounts and transactions from a solana node

src/lib.rs: entrypoint src/plugin.rs: main plugin code to run: cargo build && solana-test-validator -r --geyser-plugin-config config.json note: make s

This is a solana lite rpc which optimizes sending transactions and confirming transactions strategies.

Solana Lite RPC This project aims to create a lite rpc server which is responsible only for sending and confirming the transactions. The lite-rpc serv

Extract data from helium-programs via Solana RPC and serves it via HTTP

hnt-explorer This application extracts data from helium-programs via Solana RPC and serves it via HTTP. There are CLI commands meant to run and test t

A tool for bulk downloading and exporting the account data inside Solana snapshots.

Memento Memento is a tool used to load and save accounts from old Solana snapshots in Google Cloud Storage. Why should I use Memento? No fighting sola

Automated Solana tool for quick arbitrage, customizable, with real-time data and wallet integration. Trade responsibly.
Automated Solana tool for quick arbitrage, customizable, with real-time data and wallet integration. Trade responsibly.

Solana Arbitrage Trading Tool The Solana Arbitrage Trading Tool is an automated solution crafted to spot and capitalize on arbitrage opportunities wit

A re-write of polkadot staking miner using subxt to avoid hard dependency to each runtime version

Staking Miner v2 WARNING this library is under active development DO NOT USE IN PRODUCTION. The library is a re-write of polkadot staking miner using

Write Extism plugins in JavaScript (Experimental)

Extism JavaScript PDK Note: This is very experimental. If you are interested in helping or following development, join the #js-pdk room in our discord

Write UTXO-based Susbtrate Runtimes

Tuxedo Write UTXO-based Substrate Runtimes Table of Contents Architecture Repository Contents Tuxedo Core Template Runtime Template Node Wallet Fundin

Comments
  • Auto import use modules when snippet is triggered

    Auto import use modules when snippet is triggered

    Currently, an snippet only add itself to the codebase but its dependencies are not added automatically.

    VSCode Snippets doesn't allow the declaration of modules/imports in the snippets.json. However, Rust Analyzer allows the declaration of snippets overwritting the propiety rust-analyzer.completion.snippets.custom.

    To resolve this issue, the snippet-lang should include snippet-requires-start/end tags and the compiler should be able to convert them to the Rust Analyzer format. The location of the snippets will be the inside the contributes of the extension's package.json.

    enhancement 
    opened by patriciobcs 0
  • Migrate snippets compiler to its own repository

    Migrate snippets compiler to its own repository

    The compiler can become a generic snippets compiler for all use case. It can be use to compile snippets for other blockchains, platforms, systems and even other languages.

    The current approach that the majority of extensions use (in VSCode) is to define all the snippets in JSON directly, this means that they have no way to test that the snippet actually works. Maybe in web2 is not a real problem due to bug can easily be fixed. However, in web3 we can't rely in untested code, even if it is for learning or non-production purpose.

    The compiler fix this problem and it can be a great step in order to create more snippets in other platforms/languages.

    The next steps are:

    • [ ] Improve the compiler in order to make it platform/blokchain agnostic.
    • [ ] Migrate the compiler codebase to a new repository and cross reference it
    • [ ] Delete the compiler codebase from this repository and reference the new compiler repository as a submodule
    opened by patriciobcs 0
  • Add snippet request or contribute process

    Add snippet request or contribute process

    Define the process to follow to require or contribute a new snippet.

    • [ ] Define all the files that need to be added
    • [ ] Define the minimun requirements each file needs to acheive
    • [ ] Give an example
    documentation 
    opened by patriciobcs 0
Releases(solana-snippets-v0.0.2)
Owner
patriciobcs
Rust
patriciobcs
Demonstrates Solana data account versioning used in supporting the Solana Cookbook article: Account Data Versioning

versioning-solana This repo demonstrates ONE rudimentary way to upgrade/migrate account data changes with solana program changes. What is data version

Frank V. Castellucci 6 Sep 30, 2022
My attempt at learning Solana program (smart contract) development through RareSkill's Solana course.

60-days-of-solana My attempt at learning Solana program (smart contract) development through RareSkill's Solana course. Originally, I was trying to cr

Jasper 3 Feb 25, 2024
Substreams development kit for Ethereum chains, contains Firehose Block model and helpers as well as utilities for Ethereum ABI encoding/decoding.

Substreams Ethereum Substreams development kit for Ethereum chains, contains Rust Firehose Block model and helpers as well as utilities for Ethereum A

StreamingFast 15 Oct 25, 2022
๐Ÿšฃโ€โ™€๏ธ <1kloc, well-documented Raft consensus algorithm implementation

miniraft A <1kloc, well-documented Raft consensus algorithm implementation This crate is a minimal implementation of the Raft consensus protocol with

Jacky Zhao 25 Dec 1, 2022
A framework for creating PoC's for Solana Smart Contracts in a painless and intuitive way

Solana PoC Framework DISCLAIMER: any illegal usage of this framework is heavily discouraged. Most projects on Solana offer a more than generous bug bo

Neodyme 165 Dec 18, 2022
The Voting example based on MoonZoon and Solana + Anchor framework.

The Voting example based on MoonZoon and Solana + Anchor framework.

Martin Kavรญk 6 Aug 13, 2022
A suite of programs for Solana key management and security.

?? goki Goki is a suite of programs for Solana key management and security. It currently features: Goki Smart Wallet: A wallet loosely based on the Se

Goki Protocol 157 Dec 8, 2022
Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) โ›๐Ÿ‘ท๐Ÿšงโš ๏ธ

Solana BPF Boilerplate Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana This boilerplate provides the following. Si

ono 6 Jan 30, 2022
๐Ÿง‘โ€โœˆ Version control and key management for Solana programs.

captain ??โ€โœˆ๏ธ Version control and key management for Solana programs. Automatic versioning of program binaries based on Cargo Separation of deployer a

Saber 35 Mar 1, 2022
Making Token Exchange program with Solana(Rust), Web3, and Vue

Escrow program for Solana blockchain Tech stack Program (Smart Contract) Rust crates: solana-program, spl-token Solana CLI for test validator UI Types

Hoon Wee 3 May 10, 2022