@@ -22,6 +22,7 @@ import {
22
22
AddressHashMode ,
23
23
AuthType ,
24
24
FungibleConditionCode ,
25
+ PayloadType ,
25
26
PostConditionMode ,
26
27
} from '../src/constants' ;
27
28
import { createStacksPublicKey , privateKeyToPublic , publicKeyToHex } from '../src/keys' ;
@@ -46,6 +47,8 @@ import {
46
47
serializeTransaction ,
47
48
transactionToHex ,
48
49
} from '../src/transaction' ;
50
+ import fs from 'node:fs' ;
51
+ import assert from 'node:assert' ;
49
52
50
53
beforeEach ( ( ) => {
51
54
fetchMock . resetMocks ( ) ;
@@ -450,6 +453,25 @@ test('Coinbase pay to alt contract principal recipient deserialization', () => {
450
453
expect ( deserializedTx . transactionVersion ) . toBe ( TransactionVersion . Testnet ) ;
451
454
} ) ;
452
455
456
+ test ( 'deserialize wtf tx' , ( ) => {
457
+ const largeTxDeployBody = fs . readFileSync ( './tests/tx-contract-deploy-large-hex.txt' , 'utf8' ) ;
458
+ const reader = new BytesReader ( largeTxDeployBody ) ;
459
+ const deserialized = deserializeTransaction ( reader ) ;
460
+ expect ( deserialized . payload ) . toBeTruthy ( ) ;
461
+ assert ( deserialized . payload . payloadType === PayloadType . VersionedSmartContract ) ;
462
+ expect ( deserialized . payload . contractName . content ) . toBe ( 'tcat-01' ) ;
463
+ expect (
464
+ deserialized . payload . codeBody . content . startsWith (
465
+ `(use-trait nma 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.trait-sip-010.sip-010-trait) (use-trait nmb 'SP2AKWJYC7BNY18W1XXKPGP0YVEK63QJG4793Z2D4.sip-010-trait-ft-standard.sip-010-trait) (use-trait nmc 'SP2ZNGJ85ENDY6QRHQ5P2D4FXKGZWCKTB2T0Z55KS.dao-traits-v4.sip010-ft-trait`
466
+ )
467
+ ) ;
468
+ expect (
469
+ deserialized . payload . codeBody . content . endsWith (
470
+ `(use-trait nma 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.trait-sip-010.sip-010-trait) (use-trait nmb 'SP2AKWJYC7BNY18W1XXKPGP0YVEK63QJG4793Z2D4.sip-010-trait-ft-standard.sip-010-trait) (use-trait nmc 'SP2ZNGJ85ENDY6QRHQ5P2D4FXKGZWCKTB2T0Z55KS.dao-traits-v4.sip010-ft-trait`
471
+ )
472
+ ) ;
473
+ } ) ;
474
+
453
475
describe ( serializeTransaction . name , ( ) => {
454
476
const serializedTx =
455
477
'0x8080000000040055a0a92720d20398211cd4c7663d65d018efcc1f00000000000000030000000000000000010118da31f542913e8c56961b87ee4794924e655a28a2034e37ef4823eeddf074747285bd6efdfbd84eecdf62cffa7c1864e683c688f4c105f4db7429066735b4e2010200000000050000000000000000000000000000000000000000000000000000000000000000061aba27f99e007c7f605a8305e318c1abde3cd220ac0b68656c6c6f5f776f726c64' ;
0 commit comments