diff --git a/.changeset/olive-apples-brush.md b/.changeset/olive-apples-brush.md new file mode 100644 index 00000000000..0429b5efa7c --- /dev/null +++ b/.changeset/olive-apples-brush.md @@ -0,0 +1,6 @@ +--- +"@fuel-ts/transactions": patch +"@fuel-ts/account": patch +--- + +chore: deprecate all receipt coders diff --git a/packages/account/src/providers/utils/receipts.ts b/packages/account/src/providers/utils/receipts.ts index c9b4575b2eb..ea3d181773a 100644 --- a/packages/account/src/providers/utils/receipts.ts +++ b/packages/account/src/providers/utils/receipts.ts @@ -16,14 +16,9 @@ import type { ReceiptTransfer, ReceiptTransferOut, } from '@fuel-ts/transactions'; -import { - ReceiptBurnCoder, - ReceiptMessageOutCoder, - ReceiptMintCoder, - ReceiptType, -} from '@fuel-ts/transactions'; +import { getMintedAssetId, InputMessageCoder, ReceiptType } from '@fuel-ts/transactions'; import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from '@fuel-ts/transactions/configs'; -import { arrayify } from '@fuel-ts/utils'; +import { arrayify, hexlify } from '@fuel-ts/utils'; import type { GqlReceiptFragment } from '../__generated__/operations'; import { GqlReceiptType } from '../__generated__/operations'; @@ -212,12 +207,12 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) { const data = receipt.data ? arrayify(receipt.data) : Uint8Array.from([]); const digest = hexOrZero(receipt.digest); - const messageId = ReceiptMessageOutCoder.getMessageId({ + const messageId = InputMessageCoder.getMessageId({ sender, recipient, nonce, amount, - data, + data: hexlify(data), }); const receiptMessageOut: ReceiptMessageOut = { @@ -237,7 +232,7 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) { case GqlReceiptType.Mint: { const contractId = hexOrZero(receipt.id || receipt.contractId); const subId = hexOrZero(receipt.subId); - const assetId = ReceiptMintCoder.getAssetId(contractId, subId); + const assetId = getMintedAssetId(contractId, subId); const mintReceipt: ReceiptMint = { type: ReceiptType.Mint, @@ -255,7 +250,7 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) { case GqlReceiptType.Burn: { const contractId = hexOrZero(receipt.id || receipt.contractId); const subId = hexOrZero(receipt.subId); - const assetId = ReceiptBurnCoder.getAssetId(contractId, subId); + const assetId = getMintedAssetId(contractId, subId); const burnReceipt: ReceiptBurn = { type: ReceiptType.Burn, diff --git a/packages/transactions/src/coders/receipt.ts b/packages/transactions/src/coders/receipt.ts index 9e8f54881e0..cb25b5bed29 100644 --- a/packages/transactions/src/coders/receipt.ts +++ b/packages/transactions/src/coders/receipt.ts @@ -46,6 +46,11 @@ export type ReceiptCall = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptCallCoder extends Coder { constructor() { super('ReceiptCall', 'struct ReceiptCall', 0); @@ -120,6 +125,11 @@ export type ReceiptReturn = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptReturnCoder extends Coder { constructor() { super('ReceiptReturn', 'struct ReceiptReturn', 0); @@ -178,6 +188,11 @@ export type ReceiptReturnData = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptReturnDataCoder extends Coder { constructor() { super('ReceiptReturnData', 'struct ReceiptReturnData', 0); @@ -242,6 +257,11 @@ export type ReceiptPanic = { contractId: string; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptPanicCoder extends Coder { constructor() { super('ReceiptPanic', 'struct ReceiptPanic', 0); @@ -300,6 +320,11 @@ export type ReceiptRevert = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptRevertCoder extends Coder { constructor() { super('ReceiptRevert', 'struct ReceiptRevert', 0); @@ -360,6 +385,11 @@ export type ReceiptLog = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptLogCoder extends Coder { constructor() { super('ReceiptLog', 'struct ReceiptLog', 0); @@ -434,6 +464,11 @@ export type ReceiptLogData = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptLogDataCoder extends Coder { constructor() { super('ReceiptLogData', 'struct ReceiptLogData', 0); @@ -508,6 +543,11 @@ export type ReceiptTransfer = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptTransferCoder extends Coder { constructor() { super('ReceiptTransfer', 'struct ReceiptTransfer', 0); @@ -574,6 +614,11 @@ export type ReceiptTransferOut = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptTransferOutCoder extends Coder { constructor() { super('ReceiptTransferOut', 'struct ReceiptTransferOut', 0); @@ -632,6 +677,11 @@ export type ReceiptScriptResult = { gasUsed: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptScriptResultCoder extends Coder { constructor() { super('ReceiptScriptResult', 'struct ReceiptScriptResult', 0); @@ -684,11 +734,20 @@ export type ReceiptMessageOut = { data: Uint8Array; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptMessageOutCoder extends Coder { constructor() { super('ReceiptMessageOut', 'struct ReceiptMessageOut', 0); } + /** + * @deprecated `ReceiptMessageOutCoder.getMessageId` is deprecated and will be removed in future versions. + * Use the static method `InputMessageCoder.getMessageId` instead. + */ static getMessageId( value: Pick ): string { @@ -779,11 +838,20 @@ export const createAssetId = (contractId: string, subId: string): AssetId => ({ bits: getMintedAssetId(contractId, subId), }); +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptMintCoder extends Coder { constructor() { super('ReceiptMint', 'struct ReceiptMint', 0); } + /** + * @deprecated `ReceiptMintCoder.getAssetId` is deprecated and will be removed in future versions. + * Use the helper function `getMintedAssetId` instead. + */ static getAssetId(contractId: string, subId: string): string { return getMintedAssetId(contractId, subId); } @@ -847,11 +915,20 @@ export type ReceiptBurn = { is: BN; }; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptBurnCoder extends Coder { constructor() { super('ReceiptBurn', 'struct ReceiptBurn', 0); } + /** + * @deprecated `ReceiptBurnCoder.getAssetId` is deprecated and will be removed in future versions. + * Use the helper function `getMintedAssetId` instead. + */ static getAssetId(contractId: string, subId: string): string { return getMintedAssetId(contractId, subId); } @@ -914,6 +991,11 @@ export type Receipt = | ReceiptMint | ReceiptBurn; +/** + * @deprecated Receipt Coders are deprecated and will be removed in future versions + * because decoding receipts is no longer necessary. No replacement is required as + * this functionality is obsolete. + */ export class ReceiptCoder extends Coder { constructor() { super('Receipt', 'struct Receipt', 0);