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

feat!: read malleable fields from transaction status on subscription #2962

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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/famous-pans-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": minor
---

feat!: read malleable fields from transaction status on subscription
nedsalk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,7 @@ describe('querying the chain', () => {
const { nonce } = result.receipts[0] as TransactionResultMessageOutReceipt;

// Retrieves the message proof for the transaction ID and nonce using the next block Id
const messageProof = await provider.getMessageProof(
result.gqlTransaction.id,
nonce,
latestBlock?.id
);
const messageProof = await provider.getMessageProof(result.id, nonce, latestBlock?.id);
// #endregion Message-getMessageProof-blockId

expect(messageProof?.amount.toNumber()).toEqual(100);
Expand Down Expand Up @@ -283,7 +279,7 @@ describe('querying the chain', () => {

// Retrieves the message proof for the transaction ID and nonce using the block height
const messageProof = await provider.getMessageProof(
result.gqlTransaction.id,
result.id,
nonce,
undefined,
latestBlock?.height
Expand Down
1 change: 0 additions & 1 deletion apps/docs/src/guide/transactions/transaction-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Once a transaction has been submitted, you may want to extract information regar
- The status (submitted, success, squeezed out, or failure)
- Receipts (return data, logs, mints/burns, transfers and panic/reverts)
- Gas fees and usages
- The raw payload of the transaction including inputs and outputs
- Date and time of the transaction
- The block the transaction was included in

Expand Down
4 changes: 2 additions & 2 deletions packages/account/src/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ describe('Account', () => {

const messageOutReceipt = <providersMod.TransactionResultMessageOutReceipt>result.receipts[0];
const messageProof = await provider.getMessageProof(
result.gqlTransaction.id,
result.id,
messageOutReceipt.nonce,
nextBlock.blockId
);
Expand Down Expand Up @@ -763,7 +763,7 @@ describe('Account', () => {

const messageOutReceipt = <providersMod.TransactionResultMessageOutReceipt>result.receipts[0];
expect(result.isStatusSuccess).toBeTruthy();
expect(result.gqlTransaction.id).toEqual(messageOutReceipt.sender);
expect(result.id).toEqual(messageOutReceipt.sender);
expect(recipient.toHexString()).toEqual(messageOutReceipt.recipient);
expect(amount.toString()).toEqual(messageOutReceipt.amount.toString());
});
Expand Down
58 changes: 56 additions & 2 deletions packages/account/src/providers/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,64 @@ fragment transactionStatusFragment on TransactionStatus {
}
}

fragment malleableTransactionFieldsFragment on Transaction {
receiptsRoot
inputs {
type: __typename
... on InputCoin {
txPointer
}
... on InputContract {
txPointer
}
}
outputs {
type: __typename
... on CoinOutput {
to
amount
assetId
}
... on ContractOutput {
inputIndex
balanceRoot
stateRoot
}
... on ChangeOutput {
to
amount
assetId
}
... on VariableOutput {
to
amount
assetId
}
... on ContractCreated {
contract
stateRoot
}
}
}
nedsalk marked this conversation as resolved.
Show resolved Hide resolved

fragment transactionStatusSubscriptionFragment on TransactionStatus {
type: __typename
... on SubmittedStatus {
...SubmittedStatusFragment
}
... on SuccessStatus {
...SuccessStatusFragment
transaction {
...malleableTransactionFieldsFragment
}
}
... on FailureStatus {
...FailureStatusFragment
transaction {
...malleableTransactionFieldsFragment
}
}
... on SqueezedOutStatus {
reason
...SqueezedOutStatusFragment
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ Supported fuel-core version: ${supportedVersion}.`
} = await this.operations.submit({ encodedTransaction });
this.#cacheInputs(transactionRequest.inputs, transactionId);

return new TransactionResponse(transactionId, this, abis);
return new TransactionResponse(transactionRequest, this, abis);
}

/**
Expand Down
Loading
Loading