Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postTransaction support #223

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fifty-lemons-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@xmtp/frames-client": minor
---

add postTransaction support
5 changes: 5 additions & 0 deletions packages/frames-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ const { redirectedTo } = await framesClient.proxy.postRedirect(
framePostUrl,
payload,
);
// If the button action type was `postTransaction`
const transactionInfo = await framesClient.proxy.postTransaction(
framePostUrl,
payload,
);
```
2 changes: 1 addition & 1 deletion packages/frames-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"dependencies": {
"@noble/hashes": "^1.3.3",
"@open-frames/proxy-client": "^0.2.1",
"@open-frames/proxy-client": "^0.3.0",
"@xmtp/proto": "3.45.0",
"long": "^5.2.3"
},
Expand Down
11 changes: 11 additions & 0 deletions packages/frames-client/src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
FramePostPayload,
FramesApiRedirectResponse,
FramesApiResponse,
FramesTransactionApiResponse,
} from "./types";

export default class OpenFramesProxy {
Expand All @@ -28,6 +29,16 @@ export default class OpenFramesProxy {
return this.inner.postRedirect(url, payload);
}

postTransaction(
url: string,
payload: FramePostPayload,
): Promise<FramesTransactionApiResponse> {
return this.inner.postTransaction(url, {
...payload,
address: payload.untrustedData.walletAddress,
});
}

mediaUrl(url: string): string {
if (url?.startsWith("data:")) {
return url;
Expand Down
3 changes: 3 additions & 0 deletions packages/frames-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import type { OpenFramesUntrustedData } from "@open-frames/types";
import type {
GetMetadataResponse,
PostRedirectResponse,
TransactionResponse,
} from "@open-frames/proxy-client";

export type FramesApiResponse = GetMetadataResponse;

export type FramesApiRedirectResponse = PostRedirectResponse;

export type FramesTransactionApiResponse = TransactionResponse;

export type FramePostUntrustedData = OpenFramesUntrustedData & {
walletAddress: string; // Untrusted version of the wallet address
opaqueConversationIdentifier: string; // A hash of the conversation topic and the participants
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2925,21 +2925,21 @@ __metadata:
languageName: node
linkType: hard

"@open-frames/proxy-client@npm:^0.2.1":
version: 0.2.1
resolution: "@open-frames/proxy-client@npm:0.2.1"
"@open-frames/proxy-client@npm:^0.3.0":
version: 0.3.0
resolution: "@open-frames/proxy-client@npm:0.3.0"
dependencies:
"@open-frames/proxy-types": "npm:0.1.1"
checksum: 10/ea6cdfa9d768aee30c1be69ae88a2ce6cf9da042c9ab74fb02346519520095aef4b1d388ea9f886fb4db48379c3b5573a223d3600e5cbb6b021ae4d2d339b4d3
"@open-frames/proxy-types": "npm:0.2.0"
checksum: 10/cca2f209be860e9328cf7768d3da3672eb5f079c9b27e31536e25cd1a59baeba7a074305a68236a222d7e6c72d7877b3dfcc49c750eb98072438f324b83b75dd
languageName: node
linkType: hard

"@open-frames/proxy-types@npm:0.1.1":
version: 0.1.1
resolution: "@open-frames/proxy-types@npm:0.1.1"
"@open-frames/proxy-types@npm:0.2.0":
version: 0.2.0
resolution: "@open-frames/proxy-types@npm:0.2.0"
peerDependencies:
typescript: ^5.3.3
checksum: 10/ed7ad6d0bb7ac4d872ec4e6c39ddedb24c0a4e29da8a52fcf354f2b0c1778f18e61977b51ee8e62795b95de96ecef27db14a2b79a16e5eefc0dff9d020b7b35b
checksum: 10/7bb09f290624abf75097055dad57657ba244a60f72dec3f839aaa08aeb9b7e98f49a1423f48f98620202ee2c1aa8075e5cfbd0888876f3f277cae98d0e976909
languageName: node
linkType: hard

Expand Down Expand Up @@ -5408,7 +5408,7 @@ __metadata:
resolution: "@xmtp/frames-client@workspace:packages/frames-client"
dependencies:
"@noble/hashes": "npm:^1.3.3"
"@open-frames/proxy-client": "npm:^0.2.1"
"@open-frames/proxy-client": "npm:^0.3.0"
"@open-frames/types": "npm:^0.0.7"
"@rollup/plugin-terser": "npm:^0.4.4"
"@rollup/plugin-typescript": "npm:^11.1.6"
Expand Down