On how to test the CLI will work properly when released.
-
Checking what are files to be published
pnpm publish --dry-run
-
Checking how the publish data looks like
WITH selected_validators AS ( | |
SELECT vote_account FROM UNNEST([ | |
'EdGevanAjM8a6Gg9KxBVrmVdZAUGAZ9xaVd7t9R4H2x', | |
'Haz7b47sZBpxh9SwggGndN3fAyNQ1S949BPdxWXS3ab6', | |
'juicQdAnksqZ5Yb8NQwCLjLWhykvXGktxnQCDvMe6Nx', | |
'5iJDEVRi1nMLwKAWhYbEokZnvBAe15rgFaHGkggVEP9z', | |
'51JBzSTU5rAM8gLAVQKgp4WoZerQcSqWC7BitBzgUNAm', | |
'LAKEuKJQYVFpf4vyjX7iuf9ajHo3k9FiyewYKf6VxPV', | |
'ErvMUdtMC7AX55zKdYSyy4DnWNCrTsWn5GwprSG7ocnx', | |
'FQwewNXahV7MiZcLpY6p1xhUs2acVGQ3U5Xxc7FzV571', -- blockdaemon |
On how to test the CLI will work properly when released.
Checking what are files to be published
pnpm publish --dry-run
Checking how the publish data looks like
export RPC_URL=... | |
# --- Finding the list of blocks that were created in epoch | |
SLOTS_PER_EPOCH=432000 | |
START_BLOCK=302400000 | |
EPOCH=$(($START_BLOCK/$SLOTS_PER_EPOCH)) | |
echo "Epoch: $EPOCH" | |
I=0 | |
is_end=false | |
while ! $is_end; do |
-- block first/end: https://github.com/ochaloup/solana-list-epoch-boundaries | |
WITH claim_settlements AS (select | |
floor(block_id/432000) AS epoch, | |
sum(pre_balances[0])- sum(post_balances[0]) as spending, | |
from solana.core.fact_transactions, | |
LATERAL FLATTEN(input => instructions) ixs, | |
where 1=1 | |
and ixs.value:programId = 'vBoNdEvzMrSai7is21XgVYik65mqtaKXuSdMBJ1xkW4' | |
-- tx fee payer is at the first account key index 0 | |
and account_keys[0]:pubkey = 'BNFeevU8uB8xtMSVXMDddzLQvPdKoV82S8dSWVv1KQre' |
# gettting anchor discriminator (8 bytes at start of the Solana anchor generated account) | |
git clone https://github.com/marinade-finance/liquid-staking-program | |
cd liquid-staking-program | |
anchor expand | |
grep -e 'Discriminator.*TicketAccountData' -A 3 .anchor/expanded-macros/marinade-finance/marinade-finance-* | |
> impl anchor_lang::Discriminator for TicketAccountData { | |
> const DISCRIMINATOR: [u8; 8] = [133, 77, 18, 98, 211, 1, 231, 3]; |
Points on how to work with solana-bankrun
, to update the code and then test it in a project on local computer.
As of the PR kevinheavey/solana-bankrun#31 the change consists of update of src/lib.rs
to update linking to solana program test
: https://github.com/anza-xyz/agave/blob/v2.0.9/program-test/src/lib.rs#L1016
From changes in src/lib.rs
the linking to TypeScript is needed to be coded into index.ts
.
I used to have a site bookmarked with a table of all these functions, but the link is dead. Here's a matrix of Option and Result conversion functions. These become second nature once you have used Rust for any significant length of time, but it's useful to have a table reference.
For each of the below:
T
is the value possibly contained in an input Ok
Result
or Some
Option
.U
is a new value created by transforming or replacing an input T
. Note that when
U
appears in methods like map
, U ?= T
, for example by callingfn main() { | |
let data: &mut [u8] = &mut [0, 0, 0, 0]; // your byte slice | |
let index: usize = 2; // the position where you want to write the byte | |
let byte: u8 = 42; // the byte you want to write; 42 => | |
// Write the byte to the specified position in the byte slice | |
data[index] = byte; | |
print_byte(&byte); | |
#!/bin/bash | |
# Using different scripts from the gist | |
# bintodec.sh | |
# - https://discord.com/channels/@me/1017776053873287258/1247924569319149649 | |
# arraybyindex.sh | |
# - https://gist.github.com/ochaloup/4d6ca93a6826a65c3f1f781d5af59d4b | |
# tobase58.py | |
# - https://discord.com/channels/@me/1017776053873287258/1247924569319149649 |
if [ "$1" == "-h" ] || [ $# -eq 0 ] || [ $# -gt 1 ]; then | |
echo "Expecting one parameter, a path to binary file, e.g. 'solana -um account -o /tmp/data.bin'" | |
echo "$0 /tmp/data.bin" | |
exit 0 | |
fi | |
FILE="$1" | |
decimal_array=($(od -v -An -t u1 < "$FILE")) | |
echo -n '['$(echo -n ${decimal_array[@]} | sed 's/ /,/g')']' |