Skip to content

Commit 2c7585e

Browse files
committed
refactor: extend Tx type to include ImportTx and update initBuilder method signatures
TICKET: WIN-7770
1 parent 600c0eb commit 2c7585e

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
OutputOwners,
1515
} from '@flarenetwork/flarejs';
1616
import utils from './utils';
17-
import { DecodedUtxoObj, SECP256K1_Transfer_Output, FlareTransactionType } from './iface';
17+
import { DecodedUtxoObj, SECP256K1_Transfer_Output, FlareTransactionType, Tx } from './iface';
1818

1919
export class ExportInPTxBuilder extends AtomicTransactionBuilder {
2020
private _amount: bigint;
@@ -39,8 +39,8 @@ export class ExportInPTxBuilder extends AtomicTransactionBuilder {
3939
return this;
4040
}
4141

42-
initBuilder(tx: UnsignedTx): this {
43-
const baseTx = tx.getTx() as evmSerial.ExportTx;
42+
initBuilder(tx: Tx): this {
43+
const baseTx = tx as evmSerial.ExportTx;
4444
if (!this.verifyTxType(baseTx._type)) {
4545
throw new NotSupported('Transaction cannot be parsed or has an unsupported transaction type');
4646
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
avmSerial,
1616
} from '@flarenetwork/flarejs';
1717
import utils from './utils';
18-
import { DecodedUtxoObj, FlareTransactionType, SECP256K1_Transfer_Output } from './iface';
18+
import { DecodedUtxoObj, FlareTransactionType, SECP256K1_Transfer_Output, Tx } from './iface';
1919

2020
export class ImportInCTxBuilder extends AtomicInCTransactionBuilder {
2121
constructor(_coinConfig: Readonly<CoinConfig>) {
@@ -36,8 +36,8 @@ export class ImportInCTxBuilder extends AtomicInCTransactionBuilder {
3636
return TransactionType.Import;
3737
}
3838

39-
initBuilder(tx: UnsignedTx): this {
40-
const baseTx = tx.getTx() as evmSerial.ImportTx;
39+
initBuilder(tx: Tx): this {
40+
const baseTx = tx as evmSerial.ImportTx;
4141
if (!this.verifyTxType(baseTx._type)) {
4242
throw new NotSupported('Transaction cannot be parsed or has an unsupported transaction type');
4343
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
BigIntPr,
1313
} from '@flarenetwork/flarejs';
1414
import utils from './utils';
15-
import { DecodedUtxoObj, FlareTransactionType, SECP256K1_Transfer_Output } from './iface';
15+
import { DecodedUtxoObj, FlareTransactionType, SECP256K1_Transfer_Output, Tx } from './iface';
1616

1717
export class ImportInPTxBuilder extends AtomicTransactionBuilder {
1818
constructor(_coinConfig: Readonly<CoinConfig>) {
@@ -29,8 +29,8 @@ export class ImportInPTxBuilder extends AtomicTransactionBuilder {
2929
return TransactionType.Import;
3030
}
3131

32-
initBuilder(tx: UnsignedTx): this {
33-
const baseTx = tx.getTx() as evmSerial.ImportTx;
32+
initBuilder(tx: Tx): this {
33+
const baseTx = tx as evmSerial.ImportTx;
3434
if (!this.verifyTxType(baseTx._type)) {
3535
throw new NotSupported('Transaction cannot be parsed or has an unsupported transaction type');
3636
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ export const ADDRESS_SEPARATOR = '~';
8181
export const INPUT_SEPARATOR = ':';
8282

8383
// Simplified type definitions for Flare
84-
export type Tx = pvmSerial.BaseTx | UnsignedTx | evmSerial.ExportTx;
84+
export type Tx =
85+
| pvmSerial.BaseTx
86+
| UnsignedTx
87+
| evmSerial.ExportTx
88+
| evmSerial.ImportTx
89+
| pvmSerial.ExportTx
90+
| pvmSerial.ImportTx;
8591
export type BaseTx = pvmSerial.BaseTx;
8692
export type Output = TransferableOutput;
8793
export type DeprecatedTx = unknown;

0 commit comments

Comments
 (0)