Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit 3165f9e

Browse files
authored
Merge pull request #282 from zallo-labs:fix-tx-schema
Fix-tx-schema
2 parents 3d1ee08 + f154d7b commit 3165f9e

File tree

9 files changed

+111
-102
lines changed

9 files changed

+111
-102
lines changed

api/schema.graphql

+37-4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ interface Confirmed implements Node & Result {
172172
gasUsed: BigInt!
173173
id: ID!
174174
networkEthFee: Decimal!
175+
response: Bytes!
176+
systemTx: SystemTx
175177
timestamp: DateTime!
176178
transaction: Transaction!
177179
transfers: [Transfer!]!
@@ -185,6 +187,8 @@ type ConfirmedFailure implements Confirmed & Failure & Node & Result {
185187
id: ID!
186188
networkEthFee: Decimal!
187189
reason: String!
190+
response: Bytes!
191+
systemTx: SystemTx
188192
timestamp: DateTime!
189193
transaction: Transaction!
190194
transfers: [Transfer!]!
@@ -198,6 +202,7 @@ type ConfirmedSuccess implements Confirmed & Node & Result & Success {
198202
id: ID!
199203
networkEthFee: Decimal!
200204
response: Bytes!
205+
systemTx: SystemTx
201206
timestamp: DateTime!
202207
transaction: Transaction!
203208
transfers: [Transfer!]!
@@ -302,8 +307,11 @@ input ExecuteTransactionInput {
302307

303308
interface Failure implements Node & Result {
304309
events: [Event!]!
310+
gasUsed: BigInt!
305311
id: ID!
306312
reason: String!
313+
response: Bytes!
314+
systemTx: SystemTx
307315
timestamp: DateTime!
308316
transaction: Transaction!
309317
transfers: [Transfer!]!
@@ -412,8 +420,10 @@ input OperationInput {
412420

413421
type OptimisticSuccess implements Node & Result & Success {
414422
events: [Event!]!
423+
gasUsed: BigInt!
415424
id: ID!
416425
response: Bytes!
426+
systemTx: SystemTx
417427
timestamp: DateTime!
418428
transaction: Transaction!
419429
transfers: [Transfer!]!
@@ -692,7 +702,10 @@ input RequestTokensInput {
692702

693703
interface Result implements Node {
694704
events: [Event!]!
705+
gasUsed: BigInt!
695706
id: ID!
707+
response: Bytes!
708+
systemTx: SystemTx
696709
timestamp: DateTime!
697710
transaction: Transaction!
698711
transfers: [Transfer!]!
@@ -701,8 +714,11 @@ interface Result implements Node {
701714
type Scheduled implements Node & Result {
702715
cancelled: Boolean!
703716
events: [Event!]!
717+
gasUsed: BigInt!
704718
id: ID!
719+
response: Bytes!
705720
scheduledFor: DateTime!
721+
systemTx: SystemTx
706722
timestamp: DateTime!
707723
transaction: Transaction!
708724
transfers: [Transfer!]!
@@ -711,11 +727,27 @@ type Scheduled implements Node & Result {
711727
"""function selector (4-byte hex string)"""
712728
scalar Selector
713729

714-
type Simulation implements Node {
730+
type SimulatedFailure implements Failure & Node & Result {
731+
events: [Event!]!
732+
gasUsed: BigInt!
715733
id: ID!
716-
responses: [Bytes!]!
717-
success: Boolean!
734+
reason: String!
735+
response: Bytes!
736+
systemTx: SystemTx
718737
timestamp: DateTime!
738+
transaction: Transaction!
739+
transfers: [Transfer!]!
740+
}
741+
742+
type SimulatedSuccess implements Node & Result & Success {
743+
events: [Event!]!
744+
gasUsed: BigInt!
745+
id: ID!
746+
reason: String!
747+
response: Bytes!
748+
systemTx: SystemTx
749+
timestamp: DateTime!
750+
transaction: Transaction!
719751
transfers: [Transfer!]!
720752
}
721753

@@ -735,8 +767,10 @@ type Subscription {
735767

736768
interface Success implements Node & Result {
737769
events: [Event!]!
770+
gasUsed: BigInt!
738771
id: ID!
739772
response: Bytes!
773+
systemTx: SystemTx
740774
timestamp: DateTime!
741775
transaction: Transaction!
742776
transfers: [Transfer!]!
@@ -841,7 +875,6 @@ type Transaction implements Node & Proposal {
841875
rejections: [Rejection!]!
842876
result: Result
843877
results: [Result!]!
844-
simulation: Simulation
845878
status: TransactionStatus!
846879
systx: SystemTx
847880
systxs: [SystemTx!]!

api/src/feat/faucet/faucet.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class FaucetService implements OnModuleInit {
4242

4343
this.tokens = tokens.map((t) => ({
4444
address: asUAddress(t.address),
45-
amount: parseUnits(isEthToken(asAddress(t.address)) ? '0.01' : '1', t.decimals),
45+
amount: parseUnits(isEthToken(asAddress(t.address)) ? '0.005' : '1', t.decimals),
4646
}));
4747
}
4848

api/src/feat/simulations/simulations.model.ts

-20
This file was deleted.

api/src/feat/system-txs/results.model.ts

+18-8
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,22 @@ import { Node, NodeInterface, NodeType } from '~/common/decorators/interface.dec
88
import { Hex } from 'lib';
99
import { BytesField } from '~/common/scalars';
1010
import { Transaction } from '../transactions/transactions.model';
11+
import { SystemTx } from './system-tx.model';
1112

1213
@NodeInterface()
1314
export class Result extends Node {
1415
@Field(() => Transaction)
1516
transaction: Transaction;
1617

18+
@Field(() => SystemTx, { nullable: true })
19+
systemTx?: SystemTx;
20+
21+
@BytesField()
22+
response: Hex;
23+
24+
@Field(() => GraphQLBigInt)
25+
gasUsed: bigint;
26+
1727
@Field(() => Date)
1828
timestamp: Date;
1929

@@ -25,28 +35,28 @@ export class Result extends Node {
2535
}
2636

2737
@NodeInterface({ implements: [Result] })
28-
export class Success extends Result {
29-
@BytesField()
30-
response: Hex;
31-
}
38+
export class Success extends Result {}
3239

3340
@NodeInterface({ implements: [Result] })
3441
export class Failure extends Result {
3542
@Field(() => String)
3643
reason: string;
3744
}
3845

39-
@NodeType({ implements: [Success] })
46+
@NodeType({ implements: [Result, Success] })
47+
export class SimulatedSuccess extends Failure {}
48+
49+
@NodeType({ implements: [Result, Failure] })
50+
export class SimulatedFailure extends Failure {}
51+
52+
@NodeType({ implements: [Result, Success] })
4053
export class OptimisticSuccess extends Success {}
4154

4255
@NodeInterface({ implements: [Result] })
4356
export class Confirmed extends Result {
4457
@Field(() => GraphQLBigInt)
4558
block: bigint;
4659

47-
@Field(() => GraphQLBigInt)
48-
gasUsed: bigint;
49-
5060
@DecimalField()
5161
ethFeePerGas: Decimal;
5262

api/src/feat/transactions/transactions.model.ts

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { GraphQLBigInt } from 'graphql-scalars';
33
import { SystemTx } from '../system-txs/system-tx.model';
44
import { Operation } from '../operations/operations.model';
55
import { Token } from '../tokens/tokens.model';
6-
import { Simulation } from '../simulations/simulations.model';
76
import { Proposal } from '../proposals/proposals.model';
87
import { AddressField } from '~/common/scalars/Address.scalar';
98
import { Address, PolicyKey, UAddress } from 'lib';
@@ -34,9 +33,6 @@ export class Transaction extends Proposal {
3433
@Field(() => PaymasterFees)
3534
paymasterEthFees: PaymasterFees;
3635

37-
@Field(() => Simulation, { nullable: true })
38-
simulation?: Simulation;
39-
4036
@Field(() => Boolean)
4137
executable: boolean;
4238

app/src/components/transaction/OperationsSection.tsx

+49-32
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ const Transaction = graphql`
1919
operations {
2020
...OperationSection_operation
2121
}
22-
simulation {
22+
result {
23+
__typename
2324
id
24-
success
25-
responses
25+
response
26+
... on Failure {
27+
reason
28+
}
2629
}
2730
...OperationSection_transaction
2831
}
@@ -36,23 +39,10 @@ export function OperationsSection(props: OperationsSectionProps) {
3639
const { styles } = useStyles(stylesheet);
3740
const p = useFragment(Transaction, props.transaction);
3841

39-
const simulatedErrorSelector =
40-
p.simulation?.responses.length &&
41-
bytesize(p.simulation.responses[0]) >= 4 &&
42-
slice(p.simulation.responses[0], 0, 4);
43-
44-
const expectedFailureItem = p.simulation?.success === false && (
45-
<ListItem
46-
leading={<AlertIcon size={ICON_SIZE.medium} color={styles.error.color} />}
47-
headline={({ Text }) => <Text style={styles.error}>Expected to fail</Text>}
48-
supporting={
49-
simulatedErrorSelector
50-
? `Error: ${simulatedErrorSelector}`
51-
: 'No error message was provided'
52-
}
53-
trailing={simulatedErrorSelector ? SearchIcon : undefined}
54-
/>
55-
);
42+
const errorSelector =
43+
p.result?.__typename === 'SimulatedFailure' &&
44+
bytesize(p.result.response) >= 4 &&
45+
slice(p.result.response, 0, 4);
5646

5747
return (
5848
<>
@@ -62,18 +52,45 @@ export function OperationsSection(props: OperationsSectionProps) {
6252
<OperationSection key={i} transaction={p} operation={operation} />
6353
))}
6454

65-
{expectedFailureItem &&
66-
(simulatedErrorSelector ? (
67-
<Link
68-
asChild
69-
href={`https://openchain.xyz/signatures?query=${simulatedErrorSelector}`}
70-
target="_blank"
71-
>
72-
{expectedFailureItem}
73-
</Link>
74-
) : (
75-
expectedFailureItem
76-
))}
55+
{p.result?.__typename.includes('Failure') && (
56+
<>
57+
{p.result?.reason && (
58+
<ListItem
59+
leading={<AlertIcon size={ICON_SIZE.medium} color={styles.error.color} />}
60+
headline={({ Text }) => <Text style={styles.error}>Expected to fail</Text>}
61+
supporting={p.result.reason}
62+
/>
63+
)}
64+
65+
{errorSelector ? (
66+
<Link
67+
asChild
68+
href={`https://openchain.xyz/signatures?query=${errorSelector}`}
69+
target="_blank"
70+
>
71+
<ListItem
72+
leading={<AlertIcon size={ICON_SIZE.medium} color={styles.error.color} />}
73+
headline={({ Text }) => <Text style={styles.error}>Expected to fail</Text>}
74+
supporting={`Error: ${errorSelector}`}
75+
trailing={SearchIcon}
76+
/>
77+
</Link>
78+
) : (
79+
<ListItem
80+
leading={<AlertIcon size={ICON_SIZE.medium} color={styles.error.color} />}
81+
headline={({ Text }) => <Text style={styles.error}>Expected to fail</Text>}
82+
supporting="No error message was provided"
83+
/>
84+
)}
85+
86+
<ListItem
87+
leading={<AlertIcon size={ICON_SIZE.medium} color={styles.error.color} />}
88+
headline={({ Text }) => <Text style={styles.error}>Expected to fail</Text>}
89+
supporting={errorSelector ? `Error: ${errorSelector}` : 'No error message was provided'}
90+
trailing={errorSelector ? SearchIcon : undefined}
91+
/>
92+
</>
93+
)}
7794
</>
7895
);
7996
}

app/src/components/transaction/TransactionActions.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ const Transaction = graphql`
2828
validationErrors {
2929
reason
3030
}
31-
simulation {
31+
result {
32+
__typename
3233
id
33-
success
3434
}
3535
systx {
3636
id
@@ -77,7 +77,8 @@ export const TransactionActions = (props: TransactionActionsProps) => {
7777
});
7878

7979
const blockExplorer = CHAINS[p.account.chain].blockExplorers?.default;
80-
const showForceExecute = p.status === 'Pending' && p.executable && !p.simulation?.success;
80+
const showForceExecute =
81+
p.status === 'Pending' && p.executable && p.result?.__typename === 'SimulatedFailure';
8182

8283
return (
8384
<Actions>

app/src/components/transaction/TransactionValue.tsx

+1-11
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ const Transaction = graphql`
1515
isFeeTransfer
1616
}
1717
}
18-
simulation {
19-
id
20-
transfers {
21-
id
22-
value
23-
isFeeTransfer
24-
}
25-
}
2618
}
2719
`;
2820

@@ -34,9 +26,7 @@ export interface TransactionValueProps {
3426
export function TransactionValue(props: TransactionValueProps) {
3527
const p = useFragment(Transaction, props.transaction);
3628

37-
const transfers = [...(p.result?.transfers ?? p.simulation?.transfers ?? [])].filter(
38-
(t) => !t.isFeeTransfer,
39-
);
29+
const transfers = (p.result?.transfers ?? []).filter((t) => !t.isFeeTransfer);
4030

4131
const value = Decimal.sum(0, ...transfers.map((t) => t.value ?? 0));
4232

0 commit comments

Comments
 (0)