Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"@solana-program/token-2022": "^0.12.0",
"@solana/kit": "^7.0.0",
"@solana/sysvars": "^6.10.0",
"borsh": "^2.0.0",
"litesvm": "^1.3.0"
Comment thread
amilz marked this conversation as resolved.
},
"devDependencies": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
appendTransactionMessageInstruction,
createTransactionMessage,
generateKeyPairSigner,
getStructEncoder,
getU8Encoder,
lamports,
pipe,
setTransactionMessageFeePayerSigner,
Expand All @@ -14,15 +16,11 @@ import {
import { SYSVAR_RENT_ADDRESS } from '@solana/sysvars';
import { SYSTEM_PROGRAM_ADDRESS } from '@solana-program/system';
import { AccountState, getMintDecoder, TOKEN_2022_PROGRAM_ADDRESS } from '@solana-program/token-2022';
import * as borsh from 'borsh';
import { assert } from 'chai';
import { FailedTransactionMetadata, LiteSVM } from 'litesvm';

// Borsh schema for the instruction data, matching the program's
// `CreateTokenArgs` (and the native example's wire format).
const CreateTokenArgsSchema: borsh.Schema = {
struct: { token_decimals: 'u8' },
};
// Instruction data layout, matching the program's `CreateTokenArgs`.
const createTokenArgsEncoder = getStructEncoder([['tokenDecimals', getU8Encoder()]]);

// Token-2022 lays a mint with one extension out as:
// base account length (165) + account-type byte (1) + TLV entry (5) = 171
Expand Down Expand Up @@ -57,7 +55,7 @@ describe('Token-2022 Default Account State (Pinocchio)', () => {

const mint = await generateKeyPairSigner();

const data = borsh.serialize(CreateTokenArgsSchema, { token_decimals: decimals });
const data = createTokenArgsEncoder.encode({ tokenDecimals: decimals });

const ix = {
programAddress: programId,
Expand Down
Loading