From c353cf11ee9ba41e25972c3d8ddb00049a4b636a Mon Sep 17 00:00:00 2001 From: nedsalk Date: Mon, 6 Jan 2025 13:27:55 +0100 Subject: [PATCH 1/3] chore!: remove deprecated `submitAndAwait` operation --- .changeset/shiny-meals-jog.md | 5 ++ .../account/src/providers/operations.graphql | 6 -- .../account/src/providers/provider.test.ts | 58 ++++++++++--------- packages/account/src/providers/provider.ts | 15 +---- .../src/transaction-response.test.ts | 8 ++- 5 files changed, 41 insertions(+), 51 deletions(-) create mode 100644 .changeset/shiny-meals-jog.md 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 d9775e3252d..707ef03e3c5 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -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', }, @@ -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((submitAndAwait).time).toEqual('data: 4611686020137152060'); + expect(submitAndAwaitStatus.type).toEqual('SuccessStatus'); + expect((submitAndAwaitStatus).time).toEqual('data: 4611686020137152060'); } }); @@ -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(); }, @@ -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; @@ -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', }, }, @@ -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'); } } @@ -1558,7 +1558,7 @@ Supported fuel-core version: ${mock.supportedVersion}.` vi.spyOn(global, 'fetch').mockImplementationOnce(() => { const responseObject = JSON.stringify({ data: { - submitAndAwait: { + submitAndAwaitStatus: { type: 'SuccessStatus', }, }, @@ -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'); } }); @@ -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', }, }, @@ -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'); } } @@ -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', }, }, @@ -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'); } } @@ -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(); } diff --git a/packages/account/src/providers/provider.ts b/packages/account/src/providers/provider.ts index 5f9ffe88f42..ab095fbc0e9 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 b1c2e7d8043..16f1dbce691 100644 --- a/packages/fuel-gauge/src/transaction-response.test.ts +++ b/packages/fuel-gauge/src/transaction-response.test.ts @@ -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 expectToThrowFuelError( async () => { - const submit = await provider.sendTransaction(request); - await submit.waitForResult(); + await txResponse.waitForResult(); }, { code: ErrorCode.TRANSACTION_SQUEEZED_OUT } ); From d05cd5c01d63e82e726cf319003000d40fcf8b6e Mon Sep 17 00:00:00 2001 From: nedsalk Date: Mon, 6 Jan 2025 13:32:03 +0100 Subject: [PATCH 2/3] rename test --- packages/fuel-gauge/src/transaction-response.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/transaction-response.test.ts b/packages/fuel-gauge/src/transaction-response.test.ts index 16f1dbce691..ee957f2a21c 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 () => { /** From 6631b4109140f414b7871d640d7dd9df7dad0f39 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Mon, 6 Jan 2025 17:23:10 +0100 Subject: [PATCH 3/3] fix lint --- packages/fuel-gauge/src/transaction-response.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/transaction-response.test.ts b/packages/fuel-gauge/src/transaction-response.test.ts index 51be31a28e5..4ca32f8c800 100644 --- a/packages/fuel-gauge/src/transaction-response.test.ts +++ b/packages/fuel-gauge/src/transaction-response.test.ts @@ -296,7 +296,7 @@ describe('TransactionResponse', () => { ); const submit = await provider.sendTransaction(request); - const txResponse = new TransactionResponse(submit.id, provider); + const txResponse = new TransactionResponse(submit.id, provider, await provider.getChainId()); await expectToThrowFuelError( async () => {