Commit d293362
authored
add pinocchio create-token example (#599)
* add pinocchio create-token example
* create-token pinocchio: address review feedback
- prepare.mjs: dump program via 'solana program dump -um' instead of
mutating the user's Solana CLI config
- reuse pinocchio_token Mint::LEN instead of a hand-rolled MINT_SIZE const
- move CreateTokenArgs into create_token.rs (ix-specific) and the borsh
string helpers into a util module; slim mod.rs to module wiring
- tests: run async bankrun setup in a before() hook so the it() blocks
actually register (a describe callback runs synchronously)
* create-token pinocchio: fix runtime failure exposed by the now-running tests
The tests were previously registered inside an async describe callback, so
mocha ran 0 of them and CI passed without ever executing the program. With
the before() hook they actually run — and surfaced a real failure:
Program log: Instruction: CreateToken
failed: unsupported BPF instruction
Root cause: Rent::try_minimum_balance() takes a floating-point path for the
exemption threshold (an f64), which the current platform-tools lower to a
float instruction the solana-bankrun VM rejects. Compute the rent-exempt
minimum with integer math using pinocchio's default rent constants instead
(DEFAULT_LAMPORTS_PER_BYTE already folds in the 2-year threshold).
While here, make the program alloc-free: build the Metaplex instruction data
in a fixed stack buffer and switch to program_entrypoint! + no_allocator!,
matching the other pinocchio examples.
Verified with cargo build-sbf (Solana 4.1.1 / platform-tools v1.54) + the
bankrun test: both cases pass.
* create-token pinocchio: rustfmt write_bytes signature
* create-token pinocchio: move Metaplex helpers into util_metaplex
Address review feedback: the Metaplex Token Metadata program ID, the
CreateMetadataAccountV3 discriminator, the metadata-data size bound, and
the instruction-data builder now live in util_metaplex.rs, keeping
create_token.rs focused on the account/CPI flow.
---------
Co-authored-by: MarkFeder <5670736+MarkFeder@users.noreply.github.com>1 parent 9389865 commit d293362
16 files changed
Lines changed: 1869 additions & 1 deletion
File tree
- tokens/create-token/pinocchio
- program
- src
- instructions
- tests
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments