amorriscode / amorriscode/axolotl

Develop TypeScript library

Open
#3 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
16
Forks
0
PR merge metrics
No merged PRs in 30d

Description

The Axolotl TypeScript library will be used to:

- Provide Solana/Rust types to the user's TypeScript code
- Provide helper functions that are useful for developing Solana programs

# Types

Since Axolotl programs are written with TypeScript, we can provide types to the users. For Seahorse programs, [the types are included in a static file](https://github.com/ameliatastic/seahorse-lang/blob/main/data/seahorse_prelude.py) next to your Anchor program.

### Rust data types

Refer to the [Rust documentation](https://doc.rust-lang.org/book/ch03-02-data-types.html) for data types.

Anchor has defined [JavaScript --> Rust types](https://www.anchor-lang.com/docs/javascript-anchor-types). We'll be taking as much inspiration from their implementation as possible. Integers greater than 32 bytes will utilize [`bn.js`](https://github.com/indutny/bn.js/), common for both Anchor and Solana.

### Solana types

- [ ] `Pubkey`
- 32-byte account identifier
- [Source](https://github.com/solana-labs/solana/blob/master/sdk/program/src/pubkey.rs)
- [x] `AccountInfo`
- Account information
- [Source](https://github.com/solana-labs/solana/blob/master/sdk/program/src/account_info.rs)
- [ ] `Signer`
- [ ] `Program`
- Used for CPI
- [Source](https://github.com/solana-labs/solana/blob/master/sdk/program/src/program.rs)
- [ ] `Clock`
- Information about the network's time
- [Source](https://github.com/solana-labs/solana/blob/master/sdk/program/src/clock.rs)
- [ ] `TokenAccount`
- [ ] `TokenMint`

`@solana/web3.js` has [a lot of classes and types](https://solana-labs.github.io/solana-web3.js/modules.html) that we will likely be able to utilize/export from Axolotl.

### Anchor types

- [ ] [Accounts struct](https://www.anchor-lang.com/docs/the-accounts-struct)
- [Source](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/index.html)
- [ ] [Context](https://www.anchor-lang.com/docs/the-program-module#context)
- [Source](https://docs.rs/anchor-lang/latest/anchor_lang/context/index.html)
- [ ] [Errors](https://www.anchor-lang.com/docs/errors)

# Helper functions

- [ ] `declare_id` / ID helpers
- Generated by Anchor
- Instead of a user dealing with this, let's programmatically manage it with `.env` or something similar
- [ ] Helpers related to lamports?

### Release

- [ ] Released under `@axolotl/sol`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.