Skip to content

Commit ea37bc4

Browse files
committed
refactor: improve transaction builder descriptions and enhance transaction handling
TICKET: WIN-7770
1 parent b555379 commit ea37bc4

File tree

5 files changed

+67
-64
lines changed

5 files changed

+67
-64
lines changed

modules/sdk-coin-avaxp/test/unit/lib/exportC2PTxBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('AvaxP Export C2P Tx Builder', () => {
3434
});
3535
});
3636

37-
describe('should build ', () => {
37+
describe('should build C to P transaction', () => {
3838
const newTxBuilder = () =>
3939
factory
4040
.getExportInCBuilder()

modules/sdk-coin-flrp/src/lib/atomicInCTransactionBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ export abstract class AtomicInCTransactionBuilder extends AtomicTransactionBuild
5858
}
5959

6060
private initializeChainIds(): void {
61-
this._externalChainId = utils.cb58Decode(this._network.blockchainID);
62-
this._blockchainID = utils.cb58Decode(this._network.cChainBlockchainID);
61+
this._externalChainId = utils.cb58Decode(this.transaction._network.blockchainID);
62+
this._blockchainID = utils.cb58Decode(this.transaction._network.cChainBlockchainID);
6363
}
6464

6565
private setFeeRate(n: bigint): void {

modules/sdk-coin-flrp/src/lib/atomicTransactionBuilder.ts

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
TRANSACTION_ID_HEX_LENGTH,
1010
PRIVATE_KEY_HEX_LENGTH,
1111
SECP256K1_SIGNATURE_LENGTH,
12-
TRANSACTION_ID_PREFIX,
1312
HEX_PREFIX,
1413
HEX_PREFIX_LENGTH,
1514
DECIMAL_RADIX,
@@ -23,13 +22,10 @@ import {
2322
ERROR_SIGNATURES_ARRAY,
2423
ERROR_SIGNATURES_EMPTY,
2524
ERROR_INVALID_PRIVATE_KEY,
26-
ERROR_UTXOS_REQUIRED_BUILD,
27-
ERROR_ENHANCED_BUILD_FAILED,
2825
ERROR_ENHANCED_PARSE_FAILED,
2926
ERROR_FLAREJS_SIGNING_FAILED,
3027
ERROR_CREATE_CREDENTIAL_FAILED,
3128
ERROR_UNKNOWN,
32-
FLARE_ATOMIC_PREFIX,
3329
FLARE_ATOMIC_PARSED_PREFIX,
3430
HEX_ENCODING,
3531
} from './constants';
@@ -328,62 +324,62 @@ export abstract class AtomicTransactionBuilder extends TransactionBuilder {
328324
/**
329325
* Build the transaction using FlareJS compatibility
330326
*/
331-
async build(): Promise<BaseTransaction> {
332-
// FlareJS UnsignedTx creation with atomic transaction support
333-
try {
334-
// Validate transaction requirements
335-
if (!this._utxos || this._utxos.length === 0) {
336-
throw new BuildTransactionError(ERROR_UTXOS_REQUIRED_BUILD);
337-
}
338-
339-
// Create FlareJS transaction structure with atomic support
340-
const transaction = {
341-
_id: `${TRANSACTION_ID_PREFIX}${Date.now()}`,
342-
_inputs: [],
343-
_outputs: [],
344-
_type: this.transactionType,
345-
signature: [] as string[],
346-
347-
fromAddresses: this._fromAddresses,
348-
validationErrors: [],
349-
350-
// FlareJS methods with atomic support
351-
toBroadcastFormat: () => `${TRANSACTION_ID_PREFIX}${Date.now()}`,
352-
toJson: () => ({
353-
type: this.transactionType,
354-
}),
355-
356-
explainTransaction: (): TransactionExplanation => ({
357-
type: this.transactionType,
358-
inputs: [],
359-
outputs: [],
360-
outputAmount: AMOUNT_STRING_ZERO,
361-
rewardAddresses: [],
362-
id: `${FLARE_ATOMIC_PREFIX}${Date.now()}`,
363-
changeOutputs: [],
364-
changeAmount: AMOUNT_STRING_ZERO,
365-
fee: { fee: this._fee.fee },
366-
}),
367-
368-
isTransactionForCChain: false,
369-
loadInputsAndOutputs: () => {
370-
/* FlareJS atomic transaction loading */
371-
},
372-
inputs: () => [],
373-
outputs: () => [],
374-
fee: () => ({ fee: this._fee.fee }),
375-
feeRate: () => 0,
376-
id: () => `${FLARE_ATOMIC_PREFIX}${Date.now()}`,
377-
type: this.transactionType,
378-
} as unknown as BaseTransaction;
379-
380-
return transaction;
381-
} catch (error) {
382-
throw new BuildTransactionError(
383-
`${ERROR_ENHANCED_BUILD_FAILED}: ${error instanceof Error ? error.message : ERROR_UNKNOWN}`
384-
);
385-
}
386-
}
327+
// async build(): Promise<BaseTransaction> {
328+
// // FlareJS UnsignedTx creation with atomic transaction support
329+
// try {
330+
// // Validate transaction requirements
331+
// if (!this._utxos || this._utxos.length === 0) {
332+
// throw new BuildTransactionError(ERROR_UTXOS_REQUIRED_BUILD);
333+
// }
334+
335+
// // Create FlareJS transaction structure with atomic support
336+
// const transaction = {
337+
// _id: `${TRANSACTION_ID_PREFIX}${Date.now()}`,
338+
// _inputs: [],
339+
// _outputs: [],
340+
// _type: this.transactionType,
341+
// signature: [] as string[],
342+
343+
// fromAddresses: this._fromAddresses,
344+
// validationErrors: [],
345+
346+
// // FlareJS methods with atomic support
347+
// toBroadcastFormat: () => `${TRANSACTION_ID_PREFIX}${Date.now()}`,
348+
// toJson: () => ({
349+
// type: this.transactionType,
350+
// }),
351+
352+
// explainTransaction: (): TransactionExplanation => ({
353+
// type: this.transactionType,
354+
// inputs: [],
355+
// outputs: [],
356+
// outputAmount: AMOUNT_STRING_ZERO,
357+
// rewardAddresses: [],
358+
// id: `${FLARE_ATOMIC_PREFIX}${Date.now()}`,
359+
// changeOutputs: [],
360+
// changeAmount: AMOUNT_STRING_ZERO,
361+
// fee: { fee: this._fee.fee },
362+
// }),
363+
364+
// isTransactionForCChain: false,
365+
// loadInputsAndOutputs: () => {
366+
// /* FlareJS atomic transaction loading */
367+
// },
368+
// inputs: () => [],
369+
// outputs: () => [],
370+
// fee: () => ({ fee: this._fee.fee }),
371+
// feeRate: () => 0,
372+
// id: () => `${FLARE_ATOMIC_PREFIX}${Date.now()}`,
373+
// type: this.transactionType,
374+
// } as unknown as BaseTransaction;
375+
376+
// return transaction;
377+
// } catch (error) {
378+
// throw new BuildTransactionError(
379+
// `${ERROR_ENHANCED_BUILD_FAILED}: ${error instanceof Error ? error.message : ERROR_UNKNOWN}`
380+
// );
381+
// }
382+
// }
387383

388384
/**
389385
* Parse and explain a transaction from hex using FlareJS compatibility
@@ -472,4 +468,8 @@ export abstract class AtomicTransactionBuilder extends TransactionBuilder {
472468
validateTransaction(transaction?: Transaction): void {
473469
// throw new NotImplementedError('validateTransaction not implemented');
474470
}
471+
472+
// setTransaction(tx: any): void {
473+
// this._flrpTransaction = tx;
474+
// }
475475
}

modules/sdk-coin-flrp/src/lib/exportInCTxBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ export class ExportInCTxBuilder extends AtomicInCTransactionBuilder {
235235
console.log('Unsigned Export Tx:', unsigned);
236236

237237
// Create signed transaction structure
238-
// const signed: FlareSignedExportTx = { unsignedTx: unsigned, credentials: [] };
238+
const signed: FlareSignedExportTx = { unsignedTx: unsigned, credentials: [] };
239+
240+
console.log('Signed Export Tx:', signed);
239241

240242
// Update transaction fee information
241243
this.transaction._fee.fee = totalFee.toString();

modules/sdk-coin-flrp/test/unit/lib/exportInCTxBuilder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe('ExportInCTxBuilder', function () {
7878
});
7979
});
8080
});
81+
8182
describe('should build a export txn from C to P', () => {
8283
const newTxBuilder = () =>
8384
factory

0 commit comments

Comments
 (0)