Skip to content

Commit

Permalink
feat!: read malleable fields from transaction status on subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
nedsalk committed Aug 16, 2024
1 parent 5727b17 commit 4617e15
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 77 deletions.
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
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 malleableFieldsFragment 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
}
}
}

fragment transactionStatusSubscriptionFragment on TransactionStatus {
type: __typename
... on SubmittedStatus {
...SubmittedStatusFragment
}
... on SuccessStatus {
...SuccessStatusFragment
transaction {
...malleableFieldsFragment
}
}
... on FailureStatus {
...FailureStatusFragment
transaction {
...malleableFieldsFragment
}
}
... 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 @@ -757,7 +757,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

0 comments on commit 4617e15

Please sign in to comment.