Skip to content

Commit

Permalink
feat: working sample
Browse files Browse the repository at this point in the history
  • Loading branch information
gllm-dev committed Oct 29, 2024
1 parent 935a4eb commit d1523e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion frontend/src/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ export const HomePage: FC = () => {
}
}, [embeddedState]); // Runs when embeddedState changes

function mintNFT() {
console.log("Minting NFT...");
if (!initDataRaw) {
console.error("No init data found");
return;
}

openfortService.mintNFT(initDataRaw).then((res) => {
console.log("NFT minted!");
console.log("Transaction hash:", res);
document.getElementById("msg")!.innerHTML = `<a href="https://www.oklink.com/amoy/tx/${res}" target="_blank">View transaction</a>`;
}).catch((error) => {
console.error("Failed to mint NFT:", error);
document.getElementById("msg")!.innerHTML = "Failed to mint NFT";
});
}


return (
<Page back={false}>
Expand All @@ -53,8 +70,9 @@ export const HomePage: FC = () => {
) : embeddedState === EmbeddedState.READY ? (
<>
<div>
<button className="mint-button">Mint</button>
<button className="mint-button" onClick={mintNFT}>Mint</button>
</div>
<div id="msg"></div>
<a onClick={() => openfortService.logout()} className="disconnect-text">Logout</a>
</>
) : (
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/services/openfortService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@openfort/openfort-js';
import openfort from '../utils/openfortConfig';
import axios from 'axios';
import {ShieldAuthProvider} from "@openfort/openfort-node/models/preGenerateEmbeddedAccountRequest";

const chainId = Number(import.meta.env.VITE_CHAIN_ID);

Expand Down Expand Up @@ -112,7 +113,7 @@ class OpenfortService {
const shieldAuth: ShieldAuthentication = {
auth: ShieldAuthType.OPENFORT,
token: identityToken,
authProvider: "telegramMiniApp",
authProvider: ShieldAuthProvider.TELEGRAM_MINI_APP,
tokenType: "customToken",
encryptionSession: await this.getEncryptionSession(),
};
Expand Down

0 comments on commit d1523e8

Please sign in to comment.