Skip to content

Commit

Permalink
Merge branch 'master' of github.com:FuelLabs/fuels-ts into ps/chore/r…
Browse files Browse the repository at this point in the history
…emoved-interfaces-package
  • Loading branch information
petertonysmith94 committed Jan 7, 2025
2 parents fbe028d + 75fae34 commit 2fb1e89
Show file tree
Hide file tree
Showing 21 changed files with 405 additions and 1,577 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-fireants-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": minor
---

chore!: remove unused operations
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
5 changes: 5 additions & 0 deletions .changeset/shaggy-donkeys-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/transactions": minor
---

chore!: remove receipt coders
5 changes: 5 additions & 0 deletions .changeset/strange-experts-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": patch
---

chore: removing obsolete `Provider.create` method
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Provider } from 'fuels';

const NETWORK_URL = 'https://mainnet.fuel.network/v1/graphql';

const provider = await Provider.create(NETWORK_URL);
const provider = new Provider(NETWORK_URL);

const baseAssetId = provider.getBaseAssetId();
const chainId = provider.getChainId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Provider, ScriptTransactionRequest, Wallet } from 'fuels';
import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../../../env';
import { ScriptSum } from '../../../../typegend';

const provider = await Provider.create(LOCAL_NETWORK_URL);
const provider = new Provider(LOCAL_NETWORK_URL);
const wallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider);

// #region auto-cost
Expand Down
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
12 changes: 0 additions & 12 deletions packages/account/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,18 +507,6 @@ export default class Provider {
};
}

/**
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
* @deprecated Use `new Provider(...)` instead.
*
* @param url - GraphQL endpoint of the Fuel node
* @param options - Additional options for the provider
* @returns A promise that resolves to a Provider instance.
*/
static async create(url: string, options: ProviderOptions = {}): Promise<Provider> {
return new Provider(url, options).init();
}

/**
* Initialize Provider async stuff
*/
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
20 changes: 0 additions & 20 deletions packages/account/src/providers/transaction-summary/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,6 @@ export enum OperationName {
transfer = 'Transfer asset',
contractCall = 'Contract call',
receive = 'Receive asset',
/**
* @deprecated This value was added by mistake and has never been used.
* It will be removed in future versions.
*/
mint = 'Mint asset',
/**
* @deprecated This value was added by mistake and has never been used.
* It will be removed in future versions.
*/
predicatecall = 'Predicate call',
/**
* @deprecated This value was added by mistake and has never been used.
* It will be removed in future versions.
*/
script = 'Script',
/**
* @deprecated This value was added by mistake and has never been used.
* It will be removed in future versions.
*/
sent = 'Sent asset',
withdrawFromFuel = 'Withdraw from Fuel',
}

Expand Down
30 changes: 15 additions & 15 deletions packages/account/src/providers/utils/receipts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
ReceiptTransfer,
ReceiptTransferOut,
} from '@fuel-ts/transactions';
import { ReceiptBurnCoder, ReceiptMessageOutCoder, ReceiptType } from '@fuel-ts/transactions';
import { getMintedAssetId, getMessageId, ReceiptType } from '@fuel-ts/transactions';
import { arrayify } from '@fuel-ts/utils';

import {
Expand All @@ -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 Expand Up @@ -222,7 +222,7 @@ describe('assembleReceiptByType', () => {
const digest = MOCK_GQL_RECEIPT_FRAGMENT.digest;
const len = Number(MOCK_GQL_RECEIPT_FRAGMENT.len);

const messageId = ReceiptMessageOutCoder.getMessageId({
const messageId = getMessageId({
sender,
recipient,
nonce,
Expand All @@ -244,7 +244,7 @@ describe('assembleReceiptByType', () => {
it('should return a ReceiptMint when GqlReceiptType.Mint is provided', () => {
const contractId = MOCK_GQL_RECEIPT_FRAGMENT.id || '';
const subId = MOCK_GQL_RECEIPT_FRAGMENT.subId || '';
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
const assetId = getMintedAssetId(contractId, subId);

const receipt = assembleReceiptByType({
...MOCK_GQL_RECEIPT_FRAGMENT,
Expand All @@ -263,7 +263,7 @@ describe('assembleReceiptByType', () => {
it('should return a ReceiptBurn when GqlReceiptType.Burn is provided', () => {
const contractId = MOCK_GQL_RECEIPT_FRAGMENT.id || '';
const subId = MOCK_GQL_RECEIPT_FRAGMENT.subId || '';
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
const assetId = getMintedAssetId(contractId, subId);

const receipt = assembleReceiptByType({
...MOCK_GQL_RECEIPT_FRAGMENT,
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: Address) => (result: ScriptResult) => {
Expand Down
Loading

0 comments on commit 2fb1e89

Please sign in to comment.