@@ -12,76 +12,26 @@ You can also use `getXmtpFrameMessage` to access useful information such as:
12
12
13
13
Note that if the ` message ` is not valid, it will be undefined.
14
14
15
- ** In order to use ` getXmtpFrameMessage ` you must also install ` @xmtp/frames-validator ` in your app, alongside onchainkit**
16
-
17
- ``` sh
18
- yarn add @xmtp/frames-validator
19
- # OR
20
- npm i --save @xmtp/frames-validator
21
- ```
22
-
23
15
``` ts
24
- import { FrameRequest , getFrameMessage } from ' @coinbase/onchainkit' ;
25
- import { isXmtpFrameRequest , getXmtpFrameMessage } from ' @coinbase/onchainkit/xmtp' ;
26
- import { NextRequest , NextResponse } from ' next/server' ;
16
+ import { FrameRequest } from ' @coinbase/onchainkit' ;
17
+ import { isXmtpFrameRequest , getXmtpFrameMessage } from ' @coinbase/onchainkit/xmtp' ; // [!code focus]
18
+ import { NextResponse } from ' next/server' ;
27
19
28
20
async function getResponse(req : any ): Promise <NextResponse > {
29
- // Step 2. Read the body from the Next Request
30
21
const body: FrameRequest = await req .json ();
31
22
if (isXmtpFrameRequest (body )) {
32
- const { isValid, message } = await getXmtpFrameMessage (body );
23
+ const { isValid, message } = await getXmtpFrameMessage (body ); // [!code focus]
33
24
// ... do something with the message if isValid is true
34
25
} else {
35
- const { isValid, message } = await getFrameMessage (body , {
36
- neynarApiKey ,
37
- });
38
- // ... do something with the message if isValid is true
26
+ // ...
39
27
}
40
28
}
41
-
42
- export async function POST(req : NextRequest ): Promise <Response > {
43
- return getResponse (req );
44
- }
45
29
```
46
30
47
31
## Returns
48
32
49
- ``` ts
50
- type Promise <XmtpFrameValidationResponse >;
51
-
52
- type XmtpFrameValidationResponse =
53
- | { isValid: true ; message: XmtpFrameValidationData }
54
- | { isValid: false ; message: undefined };
55
-
56
- interface FrameValidationData {
57
- frameUrl: string ;
58
- buttonIndex: number ;
59
- timestamp: number ;
60
- identifier: string ;
61
- verifiedWalletAddress: string ;
62
- // Same as verifiedWalletAddress
63
- identifier: string ;
64
- }
65
- ```
33
+ [ ` Promise<XmtpFrameValidationResponse> ` ] ( /xmtpkit/types#xmtpframevalidationresponse )
66
34
67
- ## Param
35
+ ## Parameters
68
36
69
- ``` ts
70
- export type UntrustedData = {
71
- url: string ;
72
- timestamp: number ;
73
- buttonIndex: number ;
74
- inputText? : string ;
75
- opaqueConversationIdentifier: string ;
76
- walletAddress: string ;
77
- };
78
-
79
- // The Frame Signature Packet body
80
- export type XmtpFramesRequest = {
81
- clientProtocol: ` xmtp@${string } ` ;
82
- untrustedData: UntrustedData ;
83
- trustedData: {
84
- messageBytes: string ;
85
- };
86
- };
87
- ```
37
+ [ ` Promise<XmtpFramesRequest> ` ] ( /xmtpkit/types#xmtpframesrequest )
0 commit comments