Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecate all receipt coders #3106

Merged
merged 15 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/olive-apples-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/transactions": patch
Torres-ssf marked this conversation as resolved.
Show resolved Hide resolved
"@fuel-ts/account": patch
---

chore: deprecate all receipt coders
17 changes: 6 additions & 11 deletions packages/account/src/providers/utils/receipts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = {
Expand All @@ -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,
Expand All @@ -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,
Expand Down
82 changes: 82 additions & 0 deletions packages/transactions/src/coders/receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReceiptCall, ReceiptCall> {
constructor() {
super('ReceiptCall', 'struct ReceiptCall', 0);
Expand Down Expand Up @@ -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<ReceiptReturn, ReceiptReturn> {
constructor() {
super('ReceiptReturn', 'struct ReceiptReturn', 0);
Expand Down Expand Up @@ -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<ReceiptReturnData, ReceiptReturnData> {
constructor() {
super('ReceiptReturnData', 'struct ReceiptReturnData', 0);
Expand Down Expand Up @@ -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<ReceiptPanic, ReceiptPanic> {
constructor() {
super('ReceiptPanic', 'struct ReceiptPanic', 0);
Expand Down Expand Up @@ -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<ReceiptRevert, ReceiptRevert> {
constructor() {
super('ReceiptRevert', 'struct ReceiptRevert', 0);
Expand Down Expand Up @@ -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<ReceiptLog, ReceiptLog> {
constructor() {
super('ReceiptLog', 'struct ReceiptLog', 0);
Expand Down Expand Up @@ -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<ReceiptLogData, ReceiptLogData> {
constructor() {
super('ReceiptLogData', 'struct ReceiptLogData', 0);
Expand Down Expand Up @@ -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<ReceiptTransfer, ReceiptTransfer> {
constructor() {
super('ReceiptTransfer', 'struct ReceiptTransfer', 0);
Expand Down Expand Up @@ -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<ReceiptTransferOut, ReceiptTransferOut> {
constructor() {
super('ReceiptTransferOut', 'struct ReceiptTransferOut', 0);
Expand Down Expand Up @@ -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<ReceiptScriptResult, ReceiptScriptResult> {
constructor() {
super('ReceiptScriptResult', 'struct ReceiptScriptResult', 0);
Expand Down Expand Up @@ -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<ReceiptMessageOut, ReceiptMessageOut> {
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<ReceiptMessageOut, 'sender' | 'recipient' | 'nonce' | 'amount' | 'data'>
): string {
Expand Down Expand Up @@ -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<ReceiptMint, ReceiptMint> {
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);
}
Expand Down Expand Up @@ -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<ReceiptBurn, ReceiptBurn> {
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);
}
Expand Down Expand Up @@ -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<Receipt, Receipt> {
constructor() {
super('Receipt', 'struct Receipt', 0);
Expand Down
Loading