Skip to content

Commit

Permalink
chore: ton scam dapp connect
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 committed Sep 6, 2024
1 parent 0a85ecb commit 940861b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
1 change: 1 addition & 0 deletions packages/example/components/chains/scdo/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AxiosInstance } from 'axios';
import Axios from 'axios';

// https://scdo-project.gitbook.io/scdo-wiki/developer/api/rpc
export class ScdoNodeClient {
public readonly axios: AxiosInstance;

Expand Down
59 changes: 43 additions & 16 deletions packages/example/components/chains/ton/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,38 @@ import {
import InfoLayout from '../../InfoLayout';
import params from './params';
import { TonProofDemoApi } from './TonProofDemoApi';
import { Switch } from '../../ui/switch';

const TON_SCAM_DAPP_ENABLE_KEY = 'ton_scam_dapp_enable';

export function Example() {
const userFriendlyAddress = useTonAddress();
const rawAddress = useTonAddress(false);
const wallet = useTonWallet();
const [tonConnectUI, setOptions] = useTonConnectUI();

const enable = localStorage.getItem(TON_SCAM_DAPP_ENABLE_KEY);

return (
<>
<TonConnectButton />

<InfoLayout title="Base Info">
<div>
<p>伪装欺诈模式</p>
<Switch checked={!!enable} onCheckedChange={async (checked) => {
if (tonConnectUI.connected) {
await tonConnectUI?.disconnect();
TonProofDemoApi.reset();
}
if (checked) {
localStorage.setItem(TON_SCAM_DAPP_ENABLE_KEY, 'true');
} else {
localStorage.removeItem(TON_SCAM_DAPP_ENABLE_KEY);
}
window.location.reload();
}} />
</div>
{userFriendlyAddress && <p>userFriendlyAddress: {userFriendlyAddress}</p>}
{rawAddress && <p>rawAddress: {rawAddress}</p>}
{wallet?.device?.appName && <p>Wallet AppName: {wallet?.device?.appName}</p>}
Expand Down Expand Up @@ -126,22 +146,29 @@ export function Example() {
}

export default function App() {

const enable = localStorage.getItem(TON_SCAM_DAPP_ENABLE_KEY);

const manifestUrl = enable ? "https://dapp-example.onekeytest.com/scam-tonconnect-manifest.json" : "https://dapp-example.onekeytest.com/tonconnect-manifest.json";

return (
<TonConnectUIProvider manifestUrl="https://dapp-example.onekeytest.com/tonconnect-manifest.json"
walletsListConfiguration={{
includeWallets: [
{
appName: "onekey",
name: "OneKey",
imageUrl: "https://common.onekey-asset.com/logo/onekey.png",
aboutUrl: "https://onekey.so",
jsBridgeKey: "onekeyTonWallet",
platforms: ["chrome"]
},
]
}}>
{/* <TonConnectUIProvider manifestUrl="https://ton-connect.github.io/demo-dapp-with-react-ui/tonconnect-manifest.json"> */}
<Example />
</TonConnectUIProvider>
<>
<TonConnectUIProvider manifestUrl={manifestUrl}
walletsListConfiguration={{
includeWallets: [
{
appName: "onekey",
name: "OneKey",
imageUrl: "https://common.onekey-asset.com/logo/onekey.png",
aboutUrl: "https://onekey.so",
jsBridgeKey: "onekeyTonWallet",
platforms: ["chrome"]
},
]
}}>
{/* <TonConnectUIProvider manifestUrl="https://ton-connect.github.io/demo-dapp-with-react-ui/tonconnect-manifest.json"> */}
<Example />
</TonConnectUIProvider>
</>
);
}
7 changes: 7 additions & 0 deletions packages/example/public/scam-tonconnect-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"url": "https://app.ston.fi/",
"name": "STON.fi",
"iconUrl": "https://static.ston.fi/logo/external-logo.jpg",
"termsOfUseUrl": "https://ston.fi/terms",
"privacyPolicyUrl": "https://ston.fi/privacy"
}

0 comments on commit 940861b

Please sign in to comment.