Skip to content

Commit d404734

Browse files
authored
chore!: remove deprecated submitAndAwait operation (#3548)
1 parent 458b7cf commit d404734

File tree

5 files changed

+42
-52
lines changed

5 files changed

+42
-52
lines changed

.changeset/shiny-meals-jog.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fuel-ts/account": minor
3+
---
4+
5+
chore!: remove deprecated `submitAndAwait` operation

packages/account/src/providers/operations.graphql

-6
Original file line numberDiff line numberDiff line change
@@ -822,12 +822,6 @@ query getConsensusParametersVersion {
822822
}
823823
}
824824

825-
subscription submitAndAwait($encodedTransaction: HexString!) {
826-
submitAndAwait(tx: $encodedTransaction) {
827-
...transactionStatusSubscriptionFragment
828-
}
829-
}
830-
831825
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
832826
submitAndAwaitStatus(tx: $encodedTransaction) {
833827
...transactionStatusSubscriptionFragment

packages/account/src/providers/provider.test.ts

+30-28
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ Supported fuel-core version: ${mock.supportedVersion}.`
14151415
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
14161416
const responseObject = {
14171417
data: {
1418-
submitAndAwait: {
1418+
submitAndAwaitStatus: {
14191419
type: 'SuccessStatus',
14201420
time: 'data: 4611686020137152060',
14211421
},
@@ -1436,11 +1436,11 @@ Supported fuel-core version: ${mock.supportedVersion}.`
14361436
);
14371437
});
14381438

1439-
for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
1439+
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
14401440
encodedTransaction: "it's mocked so doesn't matter",
14411441
})) {
1442-
expect(submitAndAwait.type).toEqual('SuccessStatus');
1443-
expect((<SubmittedStatus>submitAndAwait).time).toEqual('data: 4611686020137152060');
1442+
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
1443+
expect((<SubmittedStatus>submitAndAwaitStatus).time).toEqual('data: 4611686020137152060');
14441444
}
14451445
});
14461446

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

14571457
controller.enqueue(
1458-
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwait: { a: 0 } } })}\n\n`)
1458+
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwaitStatus: { a: 0 } } })}\n\n`)
14591459
);
14601460
controller.enqueue(encoder.encode(':keep-alive-text\n\n'));
14611461
controller.enqueue(
1462-
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwait: { a: 1 } } })}\n\n`)
1462+
encoder.encode(`data:${JSON.stringify({ data: { submitAndAwaitStatus: { a: 1 } } })}\n\n`)
14631463
);
14641464
controller.close();
14651465
},
@@ -1468,7 +1468,7 @@ Supported fuel-core version: ${mock.supportedVersion}.`
14681468

14691469
let numberOfEvents = 0;
14701470
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1471-
for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
1471+
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
14721472
encodedTransaction: "it's mocked so doesn't matter",
14731473
})) {
14741474
numberOfEvents += 1;
@@ -1484,14 +1484,14 @@ Supported fuel-core version: ${mock.supportedVersion}.`
14841484
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
14851485
const event1 = {
14861486
data: {
1487-
submitAndAwait: {
1487+
submitAndAwaitStatus: {
14881488
type: 'SubmittedStatus',
14891489
},
14901490
},
14911491
};
14921492
const event2 = {
14931493
data: {
1494-
submitAndAwait: {
1494+
submitAndAwaitStatus: {
14951495
type: 'SuccessStatus',
14961496
},
14971497
},
@@ -1515,16 +1515,16 @@ Supported fuel-core version: ${mock.supportedVersion}.`
15151515

15161516
let numberOfEvents = 0;
15171517

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

15231523
if (numberOfEvents === 1) {
1524-
expect(submitAndAwait.type).toEqual('SubmittedStatus');
1524+
expect(submitAndAwaitStatus.type).toEqual('SubmittedStatus');
15251525
}
15261526
if (numberOfEvents === 2) {
1527-
expect(submitAndAwait.type).toEqual('SuccessStatus');
1527+
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
15281528
}
15291529
}
15301530

@@ -1537,7 +1537,7 @@ Supported fuel-core version: ${mock.supportedVersion}.`
15371537
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
15381538
const responseObject = JSON.stringify({
15391539
data: {
1540-
submitAndAwait: {
1540+
submitAndAwaitStatus: {
15411541
type: 'SuccessStatus',
15421542
},
15431543
},
@@ -1563,10 +1563,10 @@ Supported fuel-core version: ${mock.supportedVersion}.`
15631563
);
15641564
});
15651565

1566-
for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
1566+
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus({
15671567
encodedTransaction: "it's mocked so doesn't matter",
15681568
})) {
1569-
expect(submitAndAwait.type).toEqual('SuccessStatus');
1569+
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
15701570
}
15711571
});
15721572

@@ -1577,14 +1577,14 @@ Supported fuel-core version: ${mock.supportedVersion}.`
15771577
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
15781578
const event1 = {
15791579
data: {
1580-
submitAndAwait: {
1580+
submitAndAwaitStatus: {
15811581
type: 'SubmittedStatus',
15821582
},
15831583
},
15841584
};
15851585
const event2 = JSON.stringify({
15861586
data: {
1587-
submitAndAwait: {
1587+
submitAndAwaitStatus: {
15881588
type: 'SuccessStatus',
15891589
},
15901590
},
@@ -1611,16 +1611,16 @@ Supported fuel-core version: ${mock.supportedVersion}.`
16111611

16121612
let numberOfEvents = 0;
16131613

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

16191619
if (numberOfEvents === 1) {
1620-
expect(submitAndAwait.type).toEqual('SubmittedStatus');
1620+
expect(submitAndAwaitStatus.type).toEqual('SubmittedStatus');
16211621
}
16221622
if (numberOfEvents === 2) {
1623-
expect(submitAndAwait.type).toEqual('SuccessStatus');
1623+
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
16241624
}
16251625
}
16261626

@@ -1634,14 +1634,14 @@ Supported fuel-core version: ${mock.supportedVersion}.`
16341634
vi.spyOn(global, 'fetch').mockImplementationOnce(() => {
16351635
const event1 = JSON.stringify({
16361636
data: {
1637-
submitAndAwait: {
1637+
submitAndAwaitStatus: {
16381638
type: 'SubmittedStatus',
16391639
},
16401640
},
16411641
});
16421642
const event2 = JSON.stringify({
16431643
data: {
1644-
submitAndAwait: {
1644+
submitAndAwaitStatus: {
16451645
type: 'SuccessStatus',
16461646
},
16471647
},
@@ -1670,16 +1670,16 @@ Supported fuel-core version: ${mock.supportedVersion}.`
16701670

16711671
let numberOfEvents = 0;
16721672

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

16781678
if (numberOfEvents === 1) {
1679-
expect(submitAndAwait.type).toEqual('SubmittedStatus');
1679+
expect(submitAndAwaitStatus.type).toEqual('SubmittedStatus');
16801680
}
16811681
if (numberOfEvents === 2) {
1682-
expect(submitAndAwait.type).toEqual('SuccessStatus');
1682+
expect(submitAndAwaitStatus.type).toEqual('SuccessStatus');
16831683
}
16841684
}
16851685

@@ -1708,9 +1708,11 @@ Supported fuel-core version: ${mock.supportedVersion}.`
17081708
await expectToThrowFuelError(
17091709
async () => {
17101710
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1711-
for await (const { submitAndAwait } of await provider.operations.submitAndAwait({
1712-
encodedTransaction: "it's mocked so doesn't matter",
1713-
})) {
1711+
for await (const { submitAndAwaitStatus } of await provider.operations.submitAndAwaitStatus(
1712+
{
1713+
encodedTransaction: "it's mocked so doesn't matter",
1714+
}
1715+
)) {
17141716
// shouldn't be reached!
17151717
expect(true).toBeFalsy();
17161718
}

packages/account/src/providers/provider.ts

+1-14
Original file line numberDiff line numberDiff line change
@@ -377,20 +377,7 @@ type NodeInfoCache = Record<string, NodeInfo>;
377377

378378
type Operations = ReturnType<typeof getOperationsSdk>;
379379

380-
type SdkOperations = Omit<
381-
Operations,
382-
'submitAndAwait' | 'statusChange' | 'submitAndAwaitStatus'
383-
> & {
384-
/**
385-
* This method is DEPRECATED and will be REMOVED in v1.
386-
*
387-
* This method will hang until the transaction is fully processed, as described in https://github.com/FuelLabs/fuel-core/issues/2108.
388-
*
389-
* Please use the `submitAndAwaitStatus` method instead.
390-
*/
391-
submitAndAwait: (
392-
...args: Parameters<Operations['submitAndAwait']>
393-
) => Promise<ReturnType<Operations['submitAndAwait']>>;
380+
type SdkOperations = Omit<Operations, 'statusChange' | 'submitAndAwaitStatus'> & {
394381
statusChange: (
395382
...args: Parameters<Operations['statusChange']>
396383
) => Promise<ReturnType<Operations['statusChange']>>;

packages/fuel-gauge/src/transaction-response.test.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe('TransactionResponse', () => {
204204
);
205205

206206
it(
207-
'should throw error for a SqueezedOut status update [waitForResult]',
207+
'should throw error for a SqueezedOut status update [submitAndAwaitStatus]',
208208
{ timeout: 10_000, retry: 10 },
209209
async () => {
210210
/**
@@ -258,7 +258,7 @@ describe('TransactionResponse', () => {
258258
);
259259

260260
it(
261-
'should throw error for a SqueezedOut status update [submitAndAwait]',
261+
'should throw error for a SqueezedOut status update [statusChange]',
262262
{ retry: 10 },
263263
async () => {
264264
using launched = await launchTestNode({
@@ -294,11 +294,13 @@ describe('TransactionResponse', () => {
294294
genesisWallet.address,
295295
await genesisWallet.signTransaction(request)
296296
);
297+
const submit = await provider.sendTransaction(request);
298+
299+
const txResponse = new TransactionResponse(submit.id, provider, await provider.getChainId());
297300

298301
await expectToThrowFuelError(
299302
async () => {
300-
const submit = await provider.sendTransaction(request);
301-
await submit.waitForResult();
303+
await txResponse.waitForResult();
302304
},
303305
{ code: ErrorCode.TRANSACTION_SQUEEZED_OUT }
304306
);

0 commit comments

Comments
 (0)