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 deprecated submitAndAwait operation #3548

Merged
merged 6 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/shiny-meals-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": minor
---

chore!: remove deprecated `submitAndAwait` operation
6 changes: 0 additions & 6 deletions packages/account/src/providers/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -822,12 +822,6 @@ query getConsensusParametersVersion {
}
}

subscription submitAndAwait($encodedTransaction: HexString!) {
submitAndAwait(tx: $encodedTransaction) {
...transactionStatusSubscriptionFragment
}
}

subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
submitAndAwaitStatus(tx: $encodedTransaction) {
...transactionStatusSubscriptionFragment
Expand Down
58 changes: 30 additions & 28 deletions packages/account/src/providers/provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ Supported fuel-core version: ${mock.supportedVersion}.`
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
const responseObject = {
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SuccessStatus',
time: 'data: 4611686020137152060',
},
Expand All @@ -1457,11 +1457,11 @@ Supported fuel-core version: ${mock.supportedVersion}.`
);
});

for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
encodedTransaction: "it's mocked so doesn't matter",
})) {
expect(submitAndAwait.type).toEqual('SuccessStatus');
expect((<SubmittedStatus>submitAndAwait).time).toEqual('data: 4611686020137152060');
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
expect((<SubmittedStatus>submitAndAwaitStatus).time).toEqual('data: 4611686020137152060');
}
});

Expand All @@ -1476,11 +1476,11 @@ Supported fuel-core version: ${mock.supportedVersion}.`
const encoder = new TextEncoder();

controller.enqueue(
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwait: { a: 0 } } })}\n\n`)
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwaitStatus: { a: 0 } } })}\n\n`)
);
controller.enqueue(encoder.encode(':keep-alive-text\n\n'));
controller.enqueue(
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwait: { a: 1 } } })}\n\n`)
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwaitStatus: { a: 1 } } })}\n\n`)
);
controller.close();
},
Expand All @@ -1489,7 +1489,7 @@ Supported fuel-core version: ${mock.supportedVersion}.`

let numberOfEvents = 0;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
encodedTransaction: "it's mocked so doesn't matter",
})) {
numberOfEvents += 1;
Expand All @@ -1505,14 +1505,14 @@ Supported fuel-core version: ${mock.supportedVersion}.`
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
const event1 = {
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SubmittedStatus',
},
},
};
const event2 = {
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SuccessStatus',
},
},
Expand All @@ -1536,16 +1536,16 @@ Supported fuel-core version: ${mock.supportedVersion}.`

let numberOfEvents = 0;

for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
encodedTransaction: "it's mocked so doesn't matter",
})) {
numberOfEvents += 1;

if (numberOfEvents === 1) {
expect(submitAndAwait.type).toEqual('SubmittedStatus');
expect(submitAndAwaitStatus.type).toEqual('SubmittedStatus');
}
if (numberOfEvents === 2) {
expect(submitAndAwait.type).toEqual('SuccessStatus');
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
}
}

Expand All @@ -1558,7 +1558,7 @@ Supported fuel-core version: ${mock.supportedVersion}.`
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
const responseObject = JSON.stringify({
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SuccessStatus',
},
},
Expand All @@ -1584,10 +1584,10 @@ Supported fuel-core version: ${mock.supportedVersion}.`
);
});

for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
encodedTransaction: "it's mocked so doesn't matter",
})) {
expect(submitAndAwait.type).toEqual('SuccessStatus');
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
}
});

Expand All @@ -1598,14 +1598,14 @@ Supported fuel-core version: ${mock.supportedVersion}.`
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
const event1 = {
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SubmittedStatus',
},
},
};
const event2 = JSON.stringify({
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SuccessStatus',
},
},
Expand All @@ -1632,16 +1632,16 @@ Supported fuel-core version: ${mock.supportedVersion}.`

let numberOfEvents = 0;

for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
encodedTransaction: "it's mocked so doesn't matter",
})) {
numberOfEvents += 1;

if (numberOfEvents === 1) {
expect(submitAndAwait.type).toEqual('SubmittedStatus');
expect(submitAndAwaitStatus.type).toEqual('SubmittedStatus');
}
if (numberOfEvents === 2) {
expect(submitAndAwait.type).toEqual('SuccessStatus');
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
}
}

Expand All @@ -1655,14 +1655,14 @@ Supported fuel-core version: ${mock.supportedVersion}.`
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
const event1 = JSON.stringify({
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SubmittedStatus',
},
},
});
const event2 = JSON.stringify({
data: {
submitAndAwait: {
submitAndAwaitStatus: {
type: 'SuccessStatus',
},
},
Expand Down Expand Up @@ -1691,16 +1691,16 @@ Supported fuel-core version: ${mock.supportedVersion}.`

let numberOfEvents = 0;

for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
encodedTransaction: "it's mocked so doesn't matter",
})) {
numberOfEvents += 1;

if (numberOfEvents === 1) {
expect(submitAndAwait.type).toEqual('SubmittedStatus');
expect(submitAndAwaitStatus.type).toEqual('SubmittedStatus');
}
if (numberOfEvents === 2) {
expect(submitAndAwait.type).toEqual('SuccessStatus');
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
}
}

Expand Down Expand Up @@ -1729,9 +1729,11 @@ Supported fuel-core version: ${mock.supportedVersion}.`
await expectToThrowFuelError(
async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
encodedTransaction: "it's mocked so doesn't matter",
})) {
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus(
{
encodedTransaction: "it's mocked so doesn't matter",
}
)) {
// shouldn't be reached!
expect(true).toBeFalsy();
}
Expand Down
15 changes: 1 addition & 14 deletions packages/account/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,7 @@ type NodeInfoCache = Record<string, NodeInfo>;

type Operations = ReturnType<typeof getOperationsSdk>;

type SdkOperations = Omit<
Operations,
'submitAndAwait' | 'statusChange' | 'submitAndAwaitStatus'
> & {
/**
* This method is DEPRECATED and will be REMOVED in v1.
*
* This method will hang until the transaction is fully processed, as described in https://github.com/FuelLabs/fuel-core/issues/2108.
*
* Please use the `submitAndAwaitStatus` method instead.
*/
submitAndAwait: (
...args: Parameters<Operations['submitAndAwait']>
) => Promise<ReturnType<Operations['submitAndAwait']>>;
type SdkOperations = Omit<Operations, 'statusChange' | 'submitAndAwaitStatus'> & {
statusChange: (
...args: Parameters<Operations['statusChange']>
) => Promise<ReturnType<Operations['statusChange']>>;
Expand Down
10 changes: 6 additions & 4 deletions packages/fuel-gauge/src/transaction-response.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe('TransactionResponse', () => {
);

it(
'should throw error for a SqueezedOut status update [waitForResult]',
'should throw error for a SqueezedOut status update [submitAndAwaitStatus]',
{ timeout: 10_000, retry: 10 },
async () => {
/**
Expand Down Expand Up @@ -258,7 +258,7 @@ describe('TransactionResponse', () => {
);

it(
'should throw error for a SqueezedOut status update [submitAndAwait]',
'should throw error for a SqueezedOut status update [statusChange]',
{ retry: 10 },
async () => {
using launched = await launchTestNode({
Expand Down Expand Up @@ -294,11 +294,13 @@ describe('TransactionResponse', () => {
genesisWallet.address,
await genesisWallet.signTransaction(request)
);
const submit = await provider.sendTransaction(request);

const txResponse = new TransactionResponse(submit.id, provider);
nedsalk marked this conversation as resolved.
Show resolved Hide resolved

await expectToThrowFuelError(
async () => {
const submit = await provider.sendTransaction(request);
await submit.waitForResult();
await txResponse.waitForResult();
},
{ code: ErrorCode.TRANSACTION_SQUEEZED_OUT }
);
Expand Down
Loading