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!: remove receipts deprecated properties #3552

Merged
merged 4 commits into from
Jan 7, 2025
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
7 changes: 7 additions & 0 deletions .changeset/rude-flowers-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@fuel-ts/transactions": minor
"@fuel-ts/account": minor
"@fuel-ts/program": minor
---

chore!: remove receipts deprecated properties
4 changes: 0 additions & 4 deletions packages/account/src/providers/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,6 @@ describe('Provider', () => {
{
type: ReceiptType.Log,
id: ZeroBytes32,
val0: bn(202),
val1: bn(186),
val2: bn(0),
val3: bn(0),
ra: bn(202),
rb: bn(186),
rc: bn(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export function getDecodedLogs<T = unknown>(

const data =
receipt.type === ReceiptType.Log
? new BigNumberCoder('u64').encode(receipt.val0)
? new BigNumberCoder('u64').encode(receipt.ra)
: receipt.data;

const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
logs.push(decodedLog);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,6 @@ describe('operations', () => {
const expected: TransactionResultTransferOutReceipt = {
amount: bn('0x5f5e100'),
assetId: '0x0000000000000000000000000000000000000000000000000000000000000000',
from: '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
id: '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
is: bn('0x4370'),
pc: bn('0x57dc'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function extractTransferOperationFromReceipt(
changeOutputs: OutputChange[]
) {
const { to: toAddress, assetId, amount } = receipt;
let { from: fromAddress } = receipt;
let { id: fromAddress } = receipt;

const toType = contractInputs.some((input) => input.contractID === toAddress)
? AddressType.contract
Expand Down
22 changes: 11 additions & 11 deletions packages/account/src/providers/utils/receipts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('assembleReceiptByType', () => {

expect(receipt.type).toBe(ReceiptType.Call);
expect(receipt.assetId).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.assetId);
expect(receipt.from).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.contractId);
expect(receipt.id).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.contractId);
expect(receipt.to).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.to);
expect(receipt.amount).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.amount));
expect(receipt.gas).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.gas));
Expand Down Expand Up @@ -113,10 +113,10 @@ describe('assembleReceiptByType', () => {
expect(receipt.id).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.contractId);
expect(receipt.is).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.is));
expect(receipt.pc).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.pc));
expect(receipt.val0).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.ra));
expect(receipt.val1).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rb));
expect(receipt.val2).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rc));
expect(receipt.val3).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rd));
expect(receipt.ra).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.ra));
expect(receipt.rb).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rb));
expect(receipt.rc).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rc));
expect(receipt.rd).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rd));
});

it('should return a ReceiptLogData receipt when GqlReceiptType.LogData is provided', () => {
Expand All @@ -132,8 +132,8 @@ describe('assembleReceiptByType', () => {
expect(receipt.pc).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.pc));
expect(receipt.ptr).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.ptr));
expect(receipt.len).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.len));
expect(receipt.val0).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.ra));
expect(receipt.val1).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rb));
expect(receipt.ra).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.ra));
expect(receipt.rb).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.rb));
expect(receipt.data).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.data);
});

Expand All @@ -144,7 +144,7 @@ describe('assembleReceiptByType', () => {
}) as ReceiptTransfer;

expect(receipt.type).toBe(ReceiptType.Transfer);
expect(receipt.from).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.contractId);
expect(receipt.id).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.contractId);
expect(receipt.to).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.to);
expect(receipt.assetId).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.assetId);
expect(receipt.is).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.is));
Expand All @@ -159,7 +159,7 @@ describe('assembleReceiptByType', () => {
}) as ReceiptTransferOut;

expect(receipt.type).toBe(ReceiptType.TransferOut);
expect(receipt.from).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.contractId);
expect(receipt.id).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.contractId);
expect(receipt.to).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.toAddress);
expect(receipt.assetId).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.assetId);
expect(receipt.is).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.is));
Expand All @@ -174,7 +174,7 @@ describe('assembleReceiptByType', () => {
}) as ReceiptTransferOut;

expect(receipt.type).toBe(ReceiptType.TransferOut);
expect(receipt.from).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.contractId);
expect(receipt.id).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.contractId);
expect(receipt.to).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.to);
expect(receipt.assetId).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT.assetId);
expect(receipt.is).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT.is));
Expand All @@ -189,7 +189,7 @@ describe('assembleReceiptByType', () => {
}) as ReceiptTransferOut;

expect(receipt.type).toBe(ReceiptType.TransferOut);
expect(receipt.from).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.contractId);
expect(receipt.id).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.contractId);
expect(receipt.to).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.toAddress);
expect(receipt.assetId).toStrictEqual(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.assetId);
expect(receipt.is).toStrictEqual(new BN(MOCK_GQL_RECEIPT_FRAGMENT_TO_ADDRESS.is));
Expand Down
9 changes: 0 additions & 9 deletions packages/account/src/providers/utils/receipts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) {
const callReceipt: ReceiptCall = {
type: ReceiptType.Call,
id,
from: id,
to: hexOrZero(receipt?.to),
amount: bn(receipt.amount),
assetId: hexOrZero(receipt.assetId),
Expand Down Expand Up @@ -148,10 +147,6 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) {
rb,
rc,
rd,
val0: ra,
val1: rb,
val2: rc,
val3: rd,
pc: bn(receipt.pc),
is: bn(receipt.is),
};
Expand All @@ -167,8 +162,6 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) {
id: hexOrZero(receipt.id || receipt.contractId),
ra,
rb,
val0: ra,
val1: rb,
ptr: bn(receipt.ptr),
len: bn(receipt.len),
digest: hexOrZero(receipt.digest),
Expand All @@ -184,7 +177,6 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) {
const transferReceipt: ReceiptTransfer = {
type: ReceiptType.Transfer,
id,
from: id,
to: hexOrZero(receipt.toAddress || receipt?.to),
amount: bn(receipt.amount),
assetId: hexOrZero(receipt.assetId),
Expand All @@ -200,7 +192,6 @@ export function assembleReceiptByType(receipt: GqlReceiptFragment) {
const transferOutReceipt: ReceiptTransferOut = {
type: ReceiptType.TransferOut,
id,
from: id,
to: hexOrZero(receipt.toAddress || receipt.to),
amount: bn(receipt.amount),
assetId: hexOrZero(receipt.assetId),
Expand Down
3 changes: 0 additions & 3 deletions packages/account/test/fixtures/transaction-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export const MOCK_OUTPUT_CONTRACT_CREATED: OutputContractCreated = {

export const MOCK_RECEIPT_CALL: TransactionResultCallReceipt = {
type: ReceiptType.Call,
from: '0x0000000000000000000000000000000000000000000000000000000000000000',
id: '0x0000000000000000000000000000000000000000000000000000000000000000',
to: '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
amount: bn(100000000),
Expand All @@ -131,7 +130,6 @@ export const MOCK_RECEIPT_RETURN: TransactionResultReturnReceipt = {
export const MOCK_RECEIPT_TRANSFER: TransactionResultTransferReceipt = {
type: ReceiptType.Transfer,
id: '0x0000000000000000000000000000000000000000000000000000000000000000',
from: '0x0000000000000000000000000000000000000000000000000000000000000000',
to: '0xaab4884920fa4d3a35fc2977cc442b0caddf87e001ef62321b6c02f5ab0f4115',
amount: bn(988),
assetId: '0x0000000000000000000000000000000000000000000000000000000000000000',
Expand All @@ -142,7 +140,6 @@ export const MOCK_RECEIPT_TRANSFER: TransactionResultTransferReceipt = {
export const MOCK_RECEIPT_TRANSFER_OUT: TransactionResultTransferOutReceipt = {
type: ReceiptType.TransferOut,
id: '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
from: '0x0a98320d39c03337401a4e46263972a9af6ce69ec2f35a5420b1bd35784c74b1',
to: '0x3e7ddda4d0d3f8307ae5f1aed87623992c1c4decefec684936960775181b2302',
amount: bn(100000000),
assetId: '0x0000000000000000000000000000000000000000000000000000000000000000',
Expand Down
4 changes: 2 additions & 2 deletions packages/program/src/contract-call-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ const getMainCallReceipt = (
contractId: string
): TransactionResultCallReceipt | undefined =>
receipts.find(
({ type, from, to }) =>
type === ReceiptType.Call && from === SCRIPT_WRAPPER_CONTRACT_ID && to === contractId
({ type, id, to }) =>
type === ReceiptType.Call && id === SCRIPT_WRAPPER_CONTRACT_ID && to === contractId
);

const scriptResultDecoder = (contractId: AbstractAddress) => (result: ScriptResult) => {
Expand Down
36 changes: 0 additions & 36 deletions packages/transactions/src/receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export enum ReceiptType /* u8 */ {

export type ReceiptCall = {
type: ReceiptType.Call;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `id` instead.
*/
from: string;
/** Contract ID of current context if in an internal context, zero otherwise (b256) */
id: string;
/** Contract ID of called contract (b256) */
Expand Down Expand Up @@ -108,28 +104,12 @@ export type ReceiptLog = {
type: ReceiptType.Log;
/** Contract ID of current context if in an internal context, zero otherwise (b256) */
id: string;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `ra` instead.
*/
val0: BN;
/** Value of register $rA (u64) */
ra: BN;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `rb` instead.
*/
val1: BN;
/** Value of register $rB (u64) */
rb: BN;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `rc` instead.
*/
val2: BN;
/** Value of register $rC (u64) */
rc: BN;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `rd` instead.
*/
val3: BN;
/** Value of register $rD (u64) */
rd: BN;
/** Value of register $pc (u64) */
Expand All @@ -144,16 +124,8 @@ export type ReceiptLogData = {
id: string;
/** Value of register $rA (u64) */
ra: BN;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `ra` instead.
*/
val0: BN;
/** Value of register $rB (u64) */
rb: BN;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `rb` instead.
*/
val1: BN;
/** Value of register $rC (u64) */
ptr: BN;
/** Value of register $rD (u64) */
Expand All @@ -170,10 +142,6 @@ export type ReceiptLogData = {

export type ReceiptTransfer = {
type: ReceiptType.Transfer;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `id` instead.
*/
from: string;
/** Contract ID of current context if in an internal context, zero otherwise (b256) */
id: string;
/** Contract ID of contract to transfer coins to (b256) */
Expand All @@ -190,10 +158,6 @@ export type ReceiptTransfer = {

export type ReceiptTransferOut = {
type: ReceiptType.TransferOut;
/**
* @deprecated This property is deprecated and it will be removed soon. Use property `id` instead.
*/
from: string;
/** Contract ID of current context if in an internal context, zero otherwise (b256) */
id: string;
/** Address to transfer coins to (b256) */
Expand Down
Loading