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...
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

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

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

A suite of programs for Solana key management and security.
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

Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) โ›๐Ÿ‘ท๐Ÿšงโš ๏ธ
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

๐Ÿง‘โ€โœˆ 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

Making Token Exchange program with Solana(Rust), Web3, and Vue
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

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

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 tool for quickly collecting function selectors and decoding signatures from on-chain EVM bytecode.

Overview | Disclaimer | Tests | Installation | Usage | Examples | Aknowledgements | License Overview Sigmund provides a CLI that allows users to colle

wavefnx 46 Jul 22, 2024
The implementation of the chain extension for `pallet-assets`

Pallet assets chain extension โš ๏ธ Chain extension contains vulnerabilities: Don't use it in the production. Fixing vulnerabilities requires changes on

Supercolony 2 Aug 22, 2022
Helpers crate to simplify ink! chain extension development

OpenBrush Chain Extension library The library provides tools and primitives to simplify the development of chain extensions for ink! and for the subst

Supercolony 7 Dec 1, 2022
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

Parity Technologies 19 Dec 28, 2022
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

Extism 6 Jan 18, 2023
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

Off-Narrative Labs 12 Mar 19, 2023