Skip to content

Commit c9c52a5

Browse files
committed
feat: expose onSignature related callbacks for eth_signTypedData_v4 request
1 parent be836e2 commit c9c52a5

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@frames.js/render": patch
3+
---
4+
5+
feat: expose onSignature callbacks for eth_signTypedData request from server

docs/pages/reference/render/use-frame.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ A function to handle redirect responses from the frame. This happens when you cl
8888

8989
A function to handle transaction button presses, returns the transaction hash or null. The function is called when a user presses a transaction button and endpoint specified by `target` returns transaction data.
9090

91+
### `onSignature`
92+
93+
- Type: `OnSignatureFunc`
94+
95+
A function to handle transaction button presses, returns the signature or null. The function is called when a user presses a transaction button and endpoint specified by `target` returns typed data for signing (`eth_signTypedData_v4`).
96+
9197
### `transactionDataSuffix`
9298

9399
- Type: `0x${string}`

packages/render/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ export type UseFetchFrameOptions<
126126
onTransaction: OnTransactionFunc;
127127
/** Transaction data suffix */
128128
transactionDataSuffix?: `0x${string}`;
129+
/**
130+
* Called after transaction data has been returned from the server and user needs to sign the typed data.
131+
*/
129132
onSignature: OnSignatureFunc;
130133
onComposerFormAction: OnComposerFormActionFunc;
131134
/**
@@ -281,6 +284,9 @@ export type UseFrameOptions<
281284
| "onTransactionError"
282285
| "onTransactionStart"
283286
| "onTransactionSuccess"
287+
| "onSignatureError"
288+
| "onSignatureStart"
289+
| "onSignatureSuccess"
284290
| "onTransactionProcessingError"
285291
| "onTransactionProcessingStart"
286292
| "onTransactionProcessingSuccess"

packages/render/src/unstable-types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ export type UseFrameOptions<
211211
| "onTransactionError"
212212
| "onTransactionStart"
213213
| "onTransactionSuccess"
214+
| "onSignatureError"
215+
| "onSignatureStart"
216+
| "onSignatureSuccess"
214217
| "onTransactionProcessingError"
215218
| "onTransactionProcessingStart"
216219
| "onTransactionProcessingSuccess"
@@ -515,6 +518,9 @@ export type UseFetchFrameOptions<
515518
onTransaction: OnTransactionFunction;
516519
/** Transaction data suffix */
517520
transactionDataSuffix?: `0x${string}`;
521+
/**
522+
* Called after transaction data has been returned from the server and user needs to sign the typed data.
523+
*/
518524
onSignature: OnSignatureFunction;
519525
/**
520526
* This function can be used to customize how error is reported to the user.

packages/render/src/unstable-use-frame.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ export function useFrame_unstable<
186186
onTransactionError,
187187
onTransactionStart,
188188
onTransactionSuccess,
189+
onSignatureError,
190+
onSignatureStart,
191+
onSignatureSuccess,
189192
onTransactionProcessingError,
190193
onTransactionProcessingStart,
191194
onTransactionProcessingSuccess,
@@ -235,6 +238,9 @@ export function useFrame_unstable<
235238
onTransactionError,
236239
onTransactionStart,
237240
onTransactionSuccess,
241+
onSignatureError,
242+
onSignatureStart,
243+
onSignatureSuccess,
238244
onTransactionProcessingError,
239245
onTransactionProcessingStart,
240246
onTransactionProcessingSuccess,

packages/render/src/use-frame.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,14 @@ export function useFrame<
183183
onTransactionDataStart,
184184
onTransactionDataSuccess,
185185
onTransactionError,
186+
onTransactionStart,
187+
onTransactionSuccess,
188+
onSignatureError,
189+
onSignatureStart,
190+
onSignatureSuccess,
186191
onTransactionProcessingError,
187192
onTransactionProcessingStart,
188193
onTransactionProcessingSuccess,
189-
onTransactionStart,
190-
onTransactionSuccess,
191194
}: UseFrameOptions<
192195
TSignerStorageType,
193196
TFrameActionBodyType,
@@ -231,11 +234,14 @@ export function useFrame<
231234
onTransactionDataStart,
232235
onTransactionDataSuccess,
233236
onTransactionError,
237+
onTransactionStart,
238+
onTransactionSuccess,
239+
onSignatureError,
240+
onSignatureStart,
241+
onSignatureSuccess,
234242
onTransactionProcessingError,
235243
onTransactionProcessingStart,
236244
onTransactionProcessingSuccess,
237-
onTransactionStart,
238-
onTransactionSuccess,
239245
});
240246

241247
const fetchFrameRef = useFreshRef(fetchFrame);
@@ -325,6 +331,7 @@ export function useFrame<
325331
homeframeUrl,
326332
signerState.hasSigner,
327333
signerState.signer,
334+
onErrorRef,
328335
]
329336
);
330337

@@ -395,6 +402,7 @@ export function useFrame<
395402
connectedAddress,
396403
homeframeUrl,
397404
signerState,
405+
onErrorRef,
398406
]
399407
);
400408

@@ -516,6 +524,7 @@ export function useFrame<
516524
onPostButton,
517525
onTransactionButton,
518526
signerState,
527+
onErrorRef,
519528
]
520529
);
521530

0 commit comments

Comments
 (0)