diff --git a/.changeset/shiny-meals-jog.md b/.changeset/shiny-meals-jog.md new file mode 100644 index 00000000000..cc75a33a8a1 --- /dev/null +++ b/.changeset/shiny-meals-jog.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": minor +--- + +chore!: remove deprecated `submitAndAwait` operation diff --git a/packages/account/src/providers/operations.graphql b/packages/account/src/providers/operations.graphql index 97f5bb2916c..8d40845b9bf 100644 --- a/packages/account/src/providers/operations.graphql +++ b/packages/account/src/providers/operations.graphql @@ -822,12 +822,6 @@ query getConsensusParametersVersion { } } -subscription submitAndAwait($encodedTransaction: HexString!) { - submitAndAwait(tx: $encodedTransaction) { - ...transactionStatusSubscriptionFragment - } -} - subscription submitAndAwaitStatus($encodedTransaction: HexString!) { submitAndAwaitStatus(tx: $encodedTransaction) { ...transactionStatusSubscriptionFragment diff --git a/packages/account/src/providers/provider.test.ts b/packages/account/src/providers/provider.test.ts index cf20f316843..85278eb880a 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -1415,7 +1415,7 @@ Supported fuel-core version: ${mock.supportedVersion}.` vi.spyOn(global, 'fetch').mockImplementationOnce(() => { const responseObject = { data: { - submitAndAwait: { + submitAndAwaitStatus: { type: 'SuccessStatus', time: 'data: 4611686020137152060', }, @@ -1436,11 +1436,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((submitAndAwait).time).toEqual('data: 4611686020137152060'); + expect(submitAndAwaitStatus.type).toEqual('SuccessStatus'); + expect((submitAndAwaitStatus).time).toEqual('data: 4611686020137152060'); } }); @@ -1455,11 +1455,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(); }, @@ -1468,7 +1468,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; @@ -1484,14 +1484,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', }, }, @@ -1515,16 +1515,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'); } } @@ -1537,7 +1537,7 @@ Supported fuel-core version: ${mock.supportedVersion}.` vi.spyOn(global, 'fetch').mockImplementationOnce(() => { const responseObject = JSON.stringify({ data: { - submitAndAwait: { + submitAndAwaitStatus: { type: 'SuccessStatus', }, }, @@ -1563,10 +1563,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'); } }); @@ -1577,14 +1577,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', }, }, @@ -1611,16 +1611,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'); } } @@ -1634,14 +1634,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', }, }, @@ -1670,16 +1670,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'); } } @@ -1708,9 +1708,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(); } diff --git a/packages/account/src/providers/provider.ts b/packages/account/src/providers/provider.ts index 201c4dad7bf..200f9f2a2a9 100644 --- a/packages/account/src/providers/provider.ts +++ b/packages/account/src/providers/provider.ts @@ -377,20 +377,7 @@ type NodeInfoCache = Record; type Operations = ReturnType; -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 - ) => Promise>; +type SdkOperations = Omit & { statusChange: ( ...args: Parameters ) => Promise>; diff --git a/packages/fuel-gauge/src/transaction-response.test.ts b/packages/fuel-gauge/src/transaction-response.test.ts index 1300d348f57..4ca32f8c800 100644 --- a/packages/fuel-gauge/src/transaction-response.test.ts +++ b/packages/fuel-gauge/src/transaction-response.test.ts @@ -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 () => { /** @@ -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({ @@ -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, await provider.getChainId()); await expectToThrowFuelError( async () => { - const submit = await provider.sendTransaction(request); - await submit.waitForResult(); + await txResponse.waitForResult(); }, { code: ErrorCode.TRANSACTION_SQUEEZED_OUT } );