66 */
77import * as assert from "assert" ;
88import { parseTransaction } from "../js/parser.js" ;
9+ import { Transaction } from "../js/transaction.js" ;
910
1011// Helper to decode base64 in tests
1112function base64ToBytes ( base64 : string ) : Uint8Array {
@@ -51,25 +52,25 @@ describe("BitGoJS Compatibility", () => {
5152
5253 it ( "should parse feePayer correctly" , ( ) => {
5354 const bytes = base64ToBytes ( TX_BASE64 ) ;
54- const parsed = parseTransaction ( bytes ) ;
55+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
5556 assert . strictEqual ( parsed . feePayer , EXPECTED . feePayer ) ;
5657 } ) ;
5758
5859 it ( "should parse nonce correctly" , ( ) => {
5960 const bytes = base64ToBytes ( TX_BASE64 ) ;
60- const parsed = parseTransaction ( bytes ) ;
61+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
6162 assert . strictEqual ( parsed . nonce , EXPECTED . nonce ) ;
6263 } ) ;
6364
6465 it ( "should parse numSignatures correctly" , ( ) => {
6566 const bytes = base64ToBytes ( TX_BASE64 ) ;
66- const parsed = parseTransaction ( bytes ) ;
67+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
6768 assert . strictEqual ( parsed . numSignatures , EXPECTED . numSignatures ) ;
6869 } ) ;
6970
7071 it ( "should detect durable nonce transaction" , ( ) => {
7172 const bytes = base64ToBytes ( TX_BASE64 ) ;
72- const parsed = parseTransaction ( bytes ) ;
73+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
7374 assert . ok ( parsed . durableNonce , "Should detect durable nonce" ) ;
7475 assert . strictEqual (
7576 parsed . durableNonce . walletNonceAddress ,
@@ -83,7 +84,7 @@ describe("BitGoJS Compatibility", () => {
8384
8485 it ( "should have NonceAdvance in both instructionsData and durableNonce" , ( ) => {
8586 const bytes = base64ToBytes ( TX_BASE64 ) ;
86- const parsed = parseTransaction ( bytes ) ;
87+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
8788 // WASM returns all instructions including NonceAdvance
8889 const nonceAdvance = parsed . instructionsData . find ( ( i ) => i . type === "NonceAdvance" ) ;
8990 assert . ok ( nonceAdvance , "NonceAdvance should be in instructionsData" ) ;
@@ -97,7 +98,7 @@ describe("BitGoJS Compatibility", () => {
9798
9899 it ( "should parse Transfer instruction correctly" , ( ) => {
99100 const bytes = base64ToBytes ( TX_BASE64 ) ;
100- const parsed = parseTransaction ( bytes ) ;
101+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
101102 // Transfer is at index 1 (after NonceAdvance)
102103 const instr = parsed . instructionsData [ 1 ] ;
103104
@@ -114,7 +115,7 @@ describe("BitGoJS Compatibility", () => {
114115
115116 it ( "should parse Memo instruction correctly" , ( ) => {
116117 const bytes = base64ToBytes ( TX_BASE64 ) ;
117- const parsed = parseTransaction ( bytes ) ;
118+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
118119 // Memo is at index 2 (after NonceAdvance and Transfer)
119120 const instr = parsed . instructionsData [ 2 ] ;
120121
@@ -129,7 +130,7 @@ describe("BitGoJS Compatibility", () => {
129130
130131 it ( "should have correct number of instructions" , ( ) => {
131132 const bytes = base64ToBytes ( TX_BASE64 ) ;
132- const parsed = parseTransaction ( bytes ) ;
133+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
133134 // 3 instructions: NonceAdvance + Transfer + Memo
134135 assert . strictEqual ( parsed . instructionsData . length , 3 ) ;
135136 } ) ;
@@ -154,7 +155,7 @@ describe("BitGoJS Compatibility", () => {
154155
155156 it ( "should parse multi-transfer with correct structure" , ( ) => {
156157 const bytes = base64ToBytes ( TX_BASE64 ) ;
157- const parsed = parseTransaction ( bytes ) ;
158+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
158159
159160 assert . strictEqual ( parsed . feePayer , EXPECTED_FEE_PAYER ) ;
160161 assert . strictEqual ( parsed . nonce , EXPECTED_NONCE ) ;
@@ -166,7 +167,7 @@ describe("BitGoJS Compatibility", () => {
166167
167168 it ( "should parse all transfer recipients correctly" , ( ) => {
168169 const bytes = base64ToBytes ( TX_BASE64 ) ;
169- const parsed = parseTransaction ( bytes ) ;
170+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
170171
171172 // Transfers are at indices 1-6 (index 0 is NonceAdvance)
172173 const transfers = parsed . instructionsData . slice ( 1 , 7 ) ;
@@ -185,7 +186,7 @@ describe("BitGoJS Compatibility", () => {
185186
186187 it ( "should have memo as last instruction" , ( ) => {
187188 const bytes = base64ToBytes ( TX_BASE64 ) ;
188- const parsed = parseTransaction ( bytes ) ;
189+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
189190 const lastInstr = parsed . instructionsData [ parsed . instructionsData . length - 1 ] ;
190191
191192 assert . strictEqual ( lastInstr . type , "Memo" ) ;
@@ -202,7 +203,7 @@ describe("BitGoJS Compatibility", () => {
202203
203204 it ( "should parse staking transaction structure" , ( ) => {
204205 const bytes = base64ToBytes ( TX_BASE64 ) ;
205- const parsed = parseTransaction ( bytes ) ;
206+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
206207
207208 assert . strictEqual ( parsed . feePayer , "5hr5fisPi6DXNuuRpm5XUbzpiEnmdyxXuBDTwzwZj5Pe" ) ;
208209 assert . ok ( parsed . instructionsData . length >= 1 , "Should have instructions" ) ;
@@ -225,7 +226,7 @@ describe("BitGoJS Compatibility", () => {
225226
226227 it ( "should parse token transfer transaction" , ( ) => {
227228 const bytes = base64ToBytes ( TX_BASE64 ) ;
228- const parsed = parseTransaction ( bytes ) ;
229+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
229230
230231 // Should have 4 instructions: NonceAdvance, SetPriorityFee, TokenTransfer, Memo
231232 assert . strictEqual ( parsed . instructionsData . length , 4 ) ;
@@ -252,7 +253,7 @@ describe("BitGoJS Compatibility", () => {
252253
253254 it ( "should parse basic unsigned transfer" , ( ) => {
254255 const bytes = base64ToBytes ( TX_BASE64 ) ;
255- const parsed = parseTransaction ( bytes ) ;
256+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
256257
257258 // This is a durable nonce transaction: NonceAdvance + Transfer
258259 assert . strictEqual ( parsed . instructionsData . length , 2 ) ;
@@ -275,7 +276,7 @@ describe("BitGoJS Compatibility", () => {
275276
276277 it ( "should parse Jito DepositSol instruction" , ( ) => {
277278 const bytes = base64ToBytes ( TX_BASE64 ) ;
278- const parsed = parseTransaction ( bytes ) ;
279+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
279280
280281 // Find the StakePoolDepositSol instruction
281282 const depositSolInstr = parsed . instructionsData . find ( ( i ) => i . type === "StakePoolDepositSol" ) ;
@@ -294,7 +295,7 @@ describe("BitGoJS Compatibility", () => {
294295
295296 it ( "should have correct fee payer for Jito transaction" , ( ) => {
296297 const bytes = base64ToBytes ( TX_BASE64 ) ;
297- const parsed = parseTransaction ( bytes ) ;
298+ const parsed = parseTransaction ( Transaction . fromBytes ( bytes ) ) ;
298299
299300 // Fee payer from BitGoJS tests
300301 assert . strictEqual ( parsed . feePayer , "5hr5fisPi6DXNuuRpm5XUbzpiEnmdyxXuBDTwzwZj5Pe" ) ;
0 commit comments