forked from FuelLabs/fuel-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed end to end export data for account
- Loading branch information
Showing
6 changed files
with
325 additions
and
82 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/app-explorer/src/systems/Statistics/getExportData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use server'; | ||
|
||
import { z } from 'zod'; | ||
import { act } from '../../systems/Core/utils/act-server'; | ||
import { sdk } from '../../systems/Core/utils/sdk'; | ||
|
||
const schema = z.object({ | ||
account: z.string().optional().nullable(), | ||
startDate: z.string(), | ||
endDate: z.string(), | ||
}); | ||
|
||
export const getTransactionStats = act( | ||
schema, | ||
async ({ account, startDate, endDate }) => { | ||
if (!account) { | ||
throw new Error('Account is required'); | ||
} | ||
|
||
// Prepare parameters for the GraphQL query | ||
const params = { | ||
account, | ||
startDate, | ||
endDate, | ||
}; | ||
|
||
// Call the getTransactionsByAccountAndDate function from the sdk | ||
const data = await sdk.getTransactionsByAccountAndDate(params); | ||
|
||
// Check if any transactions are available | ||
if (!data.data.transactionsByAccountAndDate) { | ||
return []; | ||
} | ||
|
||
// Destructure transactions and return the raw data | ||
const transactions = data.data.transactionsByAccountAndDate; | ||
|
||
return transactions; | ||
}, | ||
); |
38 changes: 30 additions & 8 deletions
38
packages/graphql/src/graphql/queries/provider/getTransactionsByAccountAndDate.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
query getTransactionsByAccountAndDate($account: String!, $startDate: String!, $endDate: String!) { | ||
query getTransactionsByAccountAndDate($account: String!, $startDate: String!, $endDate: String!){ | ||
transactionsByAccountAndDate(account: $account, startDate: $startDate, endDate: $endDate) { | ||
tx_hash | ||
timestamp | ||
totalGas | ||
totalFee | ||
isMint | ||
inputs { | ||
owner | ||
amount | ||
assetId | ||
... on InputCoin { | ||
owner | ||
amount | ||
assetId | ||
} | ||
... on InputContract { | ||
contractId | ||
balanceRoot | ||
stateRoot | ||
} | ||
... on InputMessage { | ||
sender | ||
recipient | ||
amount | ||
} | ||
} | ||
outputs { | ||
to | ||
amount | ||
assetId | ||
type | ||
... on VariableOutput { | ||
to | ||
amount | ||
assetId | ||
} | ||
... on ChangeOutput { | ||
to | ||
amount | ||
assetId | ||
} | ||
... on ContractOutput { | ||
inputIndex | ||
balanceRoot | ||
} | ||
} | ||
} | ||
} |
38 changes: 30 additions & 8 deletions
38
packages/graphql/src/graphql/queries/sdk/getTransactionsByAccountAndDate.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,42 @@ | ||
query getTransactionsByAccountAndDate($account: String!, $startDate: String!, $endDate: String!) { | ||
query getTransactionsByAccountAndDate($account: String!, $startDate: String!, $endDate: String!){ | ||
transactionsByAccountAndDate(account: $account, startDate: $startDate, endDate: $endDate) { | ||
tx_hash | ||
timestamp | ||
totalGas | ||
totalFee | ||
isMint | ||
inputs { | ||
owner | ||
amount | ||
assetId | ||
... on InputCoin { | ||
owner | ||
amount | ||
assetId | ||
} | ||
... on InputContract { | ||
contractId | ||
balanceRoot | ||
stateRoot | ||
} | ||
... on InputMessage { | ||
sender | ||
recipient | ||
amount | ||
} | ||
} | ||
outputs { | ||
to | ||
amount | ||
assetId | ||
type | ||
... on VariableOutput { | ||
to | ||
amount | ||
assetId | ||
} | ||
... on ChangeOutput { | ||
to | ||
amount | ||
assetId | ||
} | ||
... on ContractOutput { | ||
inputIndex | ||
balanceRoot | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.