|
15 | 15 | */ |
16 | 16 |
|
17 | 17 | import { Convert } from '../../core/format/Convert'; |
18 | | -import { UnresolvedMapping } from "../../core/utils/UnresolvedMapping"; |
19 | | -import { GeneratorUtils } from '../../infrastructure/catbuffer/GeneratorUtils'; |
| 18 | +import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping'; |
| 19 | +import { AddressDto } from '../../infrastructure/catbuffer/AddressDto'; |
| 20 | +import { AmountDto } from '../../infrastructure/catbuffer/AmountDto'; |
| 21 | +import { BalanceTransferReceiptBuilder } from '../../infrastructure/catbuffer/BalanceTransferReceiptBuilder'; |
| 22 | +import { KeyDto } from '../../infrastructure/catbuffer/KeyDto'; |
| 23 | +import { MosaicBuilder } from '../../infrastructure/catbuffer/MosaicBuilder'; |
| 24 | +import { MosaicIdDto } from '../../infrastructure/catbuffer/MosaicIdDto'; |
20 | 25 | import { Address } from '../account/Address'; |
21 | 26 | import { PublicAccount } from '../account/PublicAccount'; |
22 | 27 | import { MosaicId } from '../mosaic/MosaicId'; |
@@ -70,15 +75,11 @@ export class BalanceTransferReceipt extends Receipt { |
70 | 75 | * @return {Uint8Array} |
71 | 76 | */ |
72 | 77 | public serialize(): Uint8Array { |
73 | | - const recipient = this.getRecipientBytes(); |
74 | | - const buffer = new Uint8Array(52 + recipient.length); |
75 | | - buffer.set(GeneratorUtils.uintToBuffer(ReceiptVersion.BALANCE_TRANSFER, 2)); |
76 | | - buffer.set(GeneratorUtils.uintToBuffer(this.type, 2), 2); |
77 | | - buffer.set(GeneratorUtils.uint64ToBuffer(UInt64.fromHex(this.mosaicId.toHex()).toDTO()), 4); |
78 | | - buffer.set(GeneratorUtils.uint64ToBuffer(UInt64.fromHex(this.amount.toHex()).toDTO()), 12); |
79 | | - buffer.set(Convert.hexToUint8(this.sender.publicKey), 20); |
80 | | - buffer.set(recipient, 52); |
81 | | - return buffer; |
| 78 | + return new BalanceTransferReceiptBuilder(ReceiptVersion.BALANCE_TRANSFER, this.type.valueOf(), |
| 79 | + new MosaicBuilder(new MosaicIdDto(this.mosaicId.toDTO()), new AmountDto(this.amount.toDTO())), |
| 80 | + new KeyDto(Convert.hexToUint8(this.sender.publicKey)), |
| 81 | + new AddressDto(this.getRecipientBytes()), |
| 82 | + ).serialize(); |
82 | 83 | } |
83 | 84 |
|
84 | 85 | /** |
|
0 commit comments