Skip to content
Draft
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
3 changes: 1 addition & 2 deletions modules/sdk-coin-sol/src/lib/explainTransactionWasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from './constants';
import { StakingAuthorizeParams, TransactionExplanation as SolLibTransactionExplanation } from './iface';
import { findTokenName } from './instructionParamsFactory';
import bs58 from 'bs58';

export interface ExplainTransactionWasmOptions {
txBase64: string;
Expand Down Expand Up @@ -110,7 +109,7 @@ function isWasmConfidentialTransferInstruction(instr: InstructionParams): boolea
// Token-2022 CT extension: byte 0 = CT_EXT_DISCRIMINATOR, byte 1 ∈ CT_SUB_DISCRIMINATORS
const TOKEN_2022_PROGRAM_ID = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
if (programId === TOKEN_2022_PROGRAM_ID) {
const dataBytes = bs58.decode(instr.data);
const dataBytes = Buffer.from(instr.data, 'base64');
if (dataBytes.length >= 2) {
return dataBytes[0] === CT_EXT_DISCRIMINATOR && CT_SUB_DISCRIMINATORS.has(dataBytes[1]);
}
Expand Down
15 changes: 15 additions & 0 deletions modules/sdk-coin-sol/test/unit/explainTransactionWasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ describe('explainTransactionWasm', function () {
explained.tokenEnablements?.[0].tokenName.should.equal('3VDBJWgzRUscjQzzAp52na1dDquExZmD1PkCvH9svGF6');
});

it('should classify a Token-2022 BurnChecked unknown instruction as CustomTx', function () {
// BurnChecked is not decoded by the WASM parser, so it is emitted as Unknown with
// base64-encoded data. This must not throw while checking for confidential transfers.
const TOKEN_2022_BURN_CHECKED_BASE64 =
'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAIEd4VubrtXALIH766Ipu/Fvh26FyvOPjpBMkYBe3UO30SFN5lu5h+qbiflw3DnoJGsdJ035d0WtazcVkIoE5FhOgk/IBzpsSfv2fKcdhTIHFEQKNBi10zrLtUIacusFNtQBt324e51j94YQl285GzN2rYa/E2DuQ0n/r35KNihi/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEDAwECAAoKQEIPAAAAAAAG';

const explained = explainSolTransaction({
txBase64: TOKEN_2022_BURN_CHECKED_BASE64,
feeInfo: { fee: '5000' },
coinName: 'tsol',
});

explained.type.should.equal('CustomTx');
});

it('should classify token transfer with Token ACL permissionless thaw as Send', function () {
// TokenTransfer (transferChecked, Token-2022) + Token ACL ThawPermissionlessIdempotent for
// the destination ATA. The Unknown thaw instruction previously triggered the CustomTx
Expand Down
Loading