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 d951d97
Show file tree
Hide file tree
Showing 3 changed files with 57 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
65 changes: 49 additions & 16 deletions packages/example/components/chains/ton/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,56 @@ export function Example() {
);
}

// 模拟诈骗 dapp
export function ScamDapp() {
const [tonConnectUI, setOptions] = useTonConnectUI();
const userFriendlyAddress = useTonAddress();

return (
<>
<ApiGroup title="Scam dApp Connect">
<ApiPayload
title="伪装 dapp"
description="伪装 STON.fi 连接 Wallet, 如果成功,则说明 Wallet 没有检查 dapp 域名"
allowCallWithoutProvider
onExecute={async (request: string) => {
if (tonConnectUI.connected) {
await tonConnectUI?.disconnect();
TonProofDemoApi.reset();
}
tonConnectUI.openModal();
}}
onValidate={async (request: string, response: string) => {
return !userFriendlyAddress;
}}
/>
</ApiGroup>
</>
);
}

export default function App() {
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="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="https://dapp-example.onekeytest.com/scam-tonconnect-manifest.json">
<ScamDapp />
</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 d951d97

Please sign in to comment.