Skip to content

Commit 4623c57

Browse files
committed
interface improvements
1 parent 83cc66a commit 4623c57

File tree

9 files changed

+92
-6
lines changed

9 files changed

+92
-6
lines changed

app/src/ipc/wallet-internal-interface.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export type InternalWalletInterface = Omit<Wallet, "getAccounts"> & {
9090
getInteractions(): Promise<WalletInteraction<WalletInteractionType>[]>;
9191
getExecutionTrace(
9292
interactionId: string
93-
): Promise<{ trace?: DecodedExecutionTrace; stats?: any } | undefined>;
93+
): Promise<{ trace?: DecodedExecutionTrace; stats?: any; from?: string; embeddedPaymentMethodFeePayer?: string } | undefined>;
9494
resolveAuthorization(response: AuthorizationResponse): void;
9595
onWalletUpdate(callback: OnWalletUpdateListener): void;
9696
onAuthorizationRequest(callback: OnAuthorizationRequestListener): void;
@@ -151,6 +151,8 @@ export const InternalWalletInterfaceSchema: ApiSchemaFor<InternalWalletInterface
151151
.returns(z.object({
152152
trace: DecodedExecutionTraceSchema.optional(),
153153
stats: z.any().optional(),
154+
from: z.string().optional(),
155+
embeddedPaymentMethodFeePayer: z.string().optional(),
154156
}).optional()),
155157
// @ts-ignore
156158
resolveAuthorization: z.function().args(

app/src/ui/components/authorization/AuthorizeSendTxContent.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import Typography from "@mui/material/Typography";
2+
import Box from "@mui/material/Box";
3+
import Alert from "@mui/material/Alert";
4+
import { AztecAddress } from "@aztec/stdlib/aztec-address";
25
import type { AuthorizationItem } from "../../../wallet/types/authorization";
36
import type { ReadableCallAuthorization } from "../../../wallet/decoding/call-authorization-formatter";
47
import type { DecodedExecutionTrace } from "../../../wallet/decoding/tx-callstack-decoder";
@@ -18,10 +21,17 @@ export function AuthorizeSendTxContent({
1821
callAuthorizations?: ReadableCallAuthorization[];
1922
executionTrace?: DecodedExecutionTrace;
2023
stats?: any;
24+
from?: string;
25+
embeddedPaymentMethodFeePayer?: string;
2126
};
2227
const callAuthorizations = params.callAuthorizations || [];
2328
const executionTrace = params.executionTrace;
2429
const stats = params.stats;
30+
const from = params.from;
31+
const embeddedPaymentMethodFeePayer = params.embeddedPaymentMethodFeePayer;
32+
33+
const isFromZero = from && AztecAddress.fromString(from).equals(AztecAddress.ZERO);
34+
const hasEmbeddedFeePayer = !!embeddedPaymentMethodFeePayer;
2535

2636
return (
2737
<>
@@ -32,6 +42,18 @@ export function AuthorizeSendTxContent({
3242
</Typography>
3343
)}
3444

45+
{isFromZero && (
46+
<Alert severity="info" sx={{ mb: 2 }}>
47+
This request uses the MulticallEntrypoint and does not execute from any of your accounts.
48+
</Alert>
49+
)}
50+
51+
{hasEmbeddedFeePayer && (
52+
<Alert severity="success" sx={{ mb: 2 }}>
53+
The app is providing the fee payment method for this transaction.
54+
</Alert>
55+
)}
56+
3557
{executionTrace && (
3658
<ExecutionTraceDisplay
3759
trace={executionTrace}

app/src/ui/components/authorization/AuthorizeSimulateTxContent.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Typography from "@mui/material/Typography";
22
import Box from "@mui/material/Box";
3+
import Alert from "@mui/material/Alert";
4+
import { AztecAddress } from "@aztec/stdlib/aztec-address";
35
import type { AuthorizationItem } from "../../../wallet/types/authorization";
46
import type { ReadableCallAuthorization } from "../../../wallet/decoding/call-authorization-formatter";
57
import type { DecodedExecutionTrace } from "../../../wallet/decoding/tx-callstack-decoder";
@@ -21,11 +23,18 @@ export function AuthorizeSimulateTxContent({
2123
executionTrace?: DecodedExecutionTrace | any;
2224
isUtility?: boolean;
2325
stats?: any;
26+
from?: string;
27+
embeddedPaymentMethodFeePayer?: string;
2428
};
2529
const callAuthorizations = params.callAuthorizations || [];
2630
const executionTrace = params.executionTrace;
2731
const isUtility = params.isUtility || request.method === "simulateUtility";
2832
const stats = params.stats;
33+
const from = params.from;
34+
const embeddedPaymentMethodFeePayer = params.embeddedPaymentMethodFeePayer;
35+
36+
const isFromZero = from && AztecAddress.fromString(from).equals(AztecAddress.ZERO);
37+
const hasEmbeddedFeePayer = !!embeddedPaymentMethodFeePayer;
2938

3039
return (
3140
<>
@@ -37,6 +46,18 @@ export function AuthorizeSimulateTxContent({
3746
</Typography>
3847
)}
3948

49+
{isFromZero && (
50+
<Alert severity="info" sx={{ mb: 2 }}>
51+
This request uses the MulticallEntrypoint and does not execute from any of your accounts.
52+
</Alert>
53+
)}
54+
55+
{hasEmbeddedFeePayer && (
56+
<Alert severity="success" sx={{ mb: 2 }}>
57+
The app is providing the fee payment method for this transaction.
58+
</Alert>
59+
)}
60+
4061
{executionTrace && (
4162
<Box sx={{ mb: 2 }}>
4263
<Typography variant="subtitle2" gutterBottom>

app/src/ui/components/dialogs/ExecutionTraceDialog.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import DialogActions from "@mui/material/DialogActions";
55
import Button from "@mui/material/Button";
66
import IconButton from "@mui/material/IconButton";
77
import CloseIcon from "@mui/icons-material/Close";
8+
import Alert from "@mui/material/Alert";
9+
import { AztecAddress } from "@aztec/stdlib/aztec-address";
810
import { ExecutionTraceDisplay } from "../shared/ExecutionTraceDisplay";
911
import type { DecodedExecutionTrace } from "../../../wallet/decoding/tx-callstack-decoder";
1012

@@ -13,16 +15,23 @@ interface ExecutionTraceDialogProps {
1315
onClose: () => void;
1416
trace: DecodedExecutionTrace | null;
1517
stats?: any;
18+
from?: string | null;
19+
embeddedPaymentMethodFeePayer?: string | null;
1620
}
1721

1822
export function ExecutionTraceDialog({
1923
open,
2024
onClose,
2125
trace,
2226
stats,
27+
from,
28+
embeddedPaymentMethodFeePayer,
2329
}: ExecutionTraceDialogProps) {
2430
if (!trace) return null;
2531

32+
const isFromZero = from && AztecAddress.fromString(from).equals(AztecAddress.ZERO);
33+
const hasEmbeddedFeePayer = !!embeddedPaymentMethodFeePayer;
34+
2635
return (
2736
<Dialog
2837
open={open}
@@ -54,6 +63,16 @@ export function ExecutionTraceDialog({
5463
</IconButton>
5564
</DialogTitle>
5665
<DialogContent dividers>
66+
{isFromZero && (
67+
<Alert severity="info" sx={{ mb: 2 }}>
68+
This request uses the MulticallEntrypoint and does not execute from any of your accounts.
69+
</Alert>
70+
)}
71+
{hasEmbeddedFeePayer && (
72+
<Alert severity="success" sx={{ mb: 2 }}>
73+
The app is providing the fee payment method for this transaction.
74+
</Alert>
75+
)}
5776
<ExecutionTraceDisplay
5877
trace={trace}
5978
accordionBgColor="background.default"

app/src/ui/components/sections/interactions/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ export function InteractionsList({
107107
const [selectedTrace, setSelectedTrace] =
108108
useState<DecodedExecutionTrace | null>(null);
109109
const [selectedStats, setSelectedStats] = useState<any | null>(null);
110+
const [selectedFrom, setSelectedFrom] = useState<string | null>(null);
111+
const [selectedFeePayer, setSelectedFeePayer] = useState<string | null>(null);
110112
const [traceDialogOpen, setTraceDialogOpen] = useState(false);
111113

112114
const handleInteractionClick = async (
@@ -123,6 +125,8 @@ export function InteractionsList({
123125
if (result?.trace) {
124126
setSelectedTrace(result.trace);
125127
setSelectedStats(result.stats);
128+
setSelectedFrom(result.from || null);
129+
setSelectedFeePayer(result.embeddedPaymentMethodFeePayer || null);
126130
setTraceDialogOpen(true);
127131
}
128132
} catch (error) {
@@ -323,6 +327,8 @@ export function InteractionsList({
323327
onClose={() => setTraceDialogOpen(false)}
324328
trace={selectedTrace}
325329
stats={selectedStats}
330+
from={selectedFrom}
331+
embeddedPaymentMethodFeePayer={selectedFeePayer}
326332
/>
327333
</Box>
328334
);

app/src/wallet/core/internal-wallet.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export class InternalWallet extends BaseNativeWallet {
195195

196196
async getExecutionTrace(
197197
interactionId: string
198-
): Promise<{ trace?: DecodedExecutionTrace; stats?: any } | undefined> {
198+
): Promise<{ trace?: DecodedExecutionTrace; stats?: any; from?: string; embeddedPaymentMethodFeePayer?: string } | undefined> {
199199
// First check if it's a utility trace (simple trace)
200200
const utilityData = await this.db.getUtilityTrace(interactionId);
201201
if (utilityData) {
@@ -220,7 +220,12 @@ export class InternalWallet extends BaseNativeWallet {
220220
const { executionTrace } = await decodingService.decodeTransaction(
221221
parsedSimulationResult
222222
);
223-
return { trace: executionTrace, stats: parsedSimulationResult.stats };
223+
return {
224+
trace: executionTrace,
225+
stats: parsedSimulationResult.stats,
226+
from: data.metadata?.from,
227+
embeddedPaymentMethodFeePayer: data.metadata?.embeddedPaymentMethodFeePayer,
228+
};
224229
}
225230

226231
// App authorization management methods

app/src/wallet/database/wallet-db.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,13 @@ export class WalletDB {
441441
async storeTxSimulation(
442442
payloadHash: string,
443443
simulationResult: TxSimulationResult,
444-
txRequest: TxExecutionRequest
444+
txRequest: TxExecutionRequest,
445+
metadata?: { from?: string; embeddedPaymentMethodFeePayer?: string }
445446
) {
446447
const data = jsonStringify({
447448
simulationResult,
448449
txRequest,
450+
metadata,
449451
});
450452
await this.txSimulations.set(payloadHash, data);
451453
this.logger.info(
@@ -455,7 +457,7 @@ export class WalletDB {
455457

456458
async getTxSimulation(
457459
payloadHash: string
458-
): Promise<{ simulationResult: any; txRequest: any } | undefined> {
460+
): Promise<{ simulationResult: any; txRequest: any; metadata?: { from?: string; embeddedPaymentMethodFeePayer?: string } } | undefined> {
459461
const result = await this.txSimulations.getAsync(payloadHash);
460462
if (!result) {
461463
return undefined;

app/src/wallet/operations/send-tx-operation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type SendTxDisplayData = {
5252
callAuthorizations: ReadableCallAuthorization[];
5353
executionTrace?: DecodedExecutionTrace;
5454
stats?: any;
55+
embeddedPaymentMethodFeePayer?: AztecAddress;
5556
};
5657

5758
/**
@@ -185,6 +186,7 @@ export class SendTxOperation extends ExternalOperation<
185186
callAuthorizations,
186187
executionTrace,
187188
stats: prepared.displayData?.stats,
189+
embeddedPaymentMethodFeePayer: opts.fee?.embeddedPaymentMethodFeePayer,
188190
},
189191
executionData: {
190192
txRequest,
@@ -213,6 +215,7 @@ export class SendTxOperation extends ExternalOperation<
213215
title: displayData.title,
214216
from: displayData.from.toString(),
215217
stats: displayData.stats,
218+
embeddedPaymentMethodFeePayer: displayData.embeddedPaymentMethodFeePayer?.toString(),
216219
},
217220
timestamp: Date.now(),
218221
},

app/src/wallet/operations/simulate-tx-operation.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type SimulateTxDisplayData = {
8080
from: AztecAddress;
8181
decoded: ReadableTxInformation;
8282
stats?: SimulationStats;
83+
embeddedPaymentMethodFeePayer?: AztecAddress;
8384
} & Record<string, unknown>;
8485

8586
/**
@@ -200,7 +201,10 @@ export class SimulateTxOperation extends ExternalOperation<
200201
{ contracts: contractOverrides }
201202
);
202203

203-
await this.db.storeTxSimulation(payloadHash, simulationResult, txRequest);
204+
await this.db.storeTxSimulation(payloadHash, simulationResult, txRequest, {
205+
from: opts.from.toString(),
206+
embeddedPaymentMethodFeePayer: opts.fee?.embeddedPaymentMethodFeePayer?.toString(),
207+
});
204208

205209
const decodingService = new TxDecodingService(this.decodingCache);
206210
const decoded = await decodingService.decodeTransaction(simulationResult);
@@ -212,6 +216,7 @@ export class SimulateTxOperation extends ExternalOperation<
212216
from: opts.from,
213217
decoded,
214218
stats: simulationResult.stats,
219+
embeddedPaymentMethodFeePayer: opts.fee?.embeddedPaymentMethodFeePayer,
215220
},
216221
executionData: {
217222
simulationResult,
@@ -275,6 +280,7 @@ export class SimulateTxOperation extends ExternalOperation<
275280
title: displayData.title,
276281
from: displayData.from.toString(),
277282
stats: displayData.stats,
283+
embeddedPaymentMethodFeePayer: displayData.embeddedPaymentMethodFeePayer?.toString(),
278284
},
279285
timestamp: Date.now(),
280286
persistence,

0 commit comments

Comments
 (0)