Skip to content

Commit

Permalink
refactor: update sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Aug 22, 2024
1 parent 4743fef commit 6f900ca
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 57 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"@cartridge/connector": "^0.3.41",
"@cartridge/controller": "^0.3.41",
"@dojoengine/torii-wasm": "^1.0.0-alpha.5",
"@twa-dev/sdk": "^7.8.0",
"@starknet-react/chains": "^0.1.7",
"@starknet-react/core": "^2.9.0",
"@telegram-apps/sdk": "^1.1.3",
"@telegram-apps/sdk-react": "^1.1.3",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"starknet": "^6.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"starknet": "^6.11.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
Expand Down
39 changes: 8 additions & 31 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@ import twaLogo from './assets/tapps.png'
import viteLogo from '/vite.svg'
import './App.css'

import WebApp from '@twa-dev/sdk'
import { useConnect, useDisconnect, useAccount } from '@starknet-react/core'
import { useBiometryManager } from '@telegram-apps/sdk-react'

WebApp.SettingsButton.isVisible = true
WebApp.SettingsButton.onClick = () => {
return WebApp.SettingsButton.show()
}
WebApp.BiometricManager.init()
WebApp.BiometricManager.authenticate({
reason: 'we need'
})
function App() {
const [count] = useState(0)

function App() {
const { connect, connectors } = useConnect()
const { disconnect } = useDisconnect()
const { account } = useAccount()
Expand All @@ -26,6 +17,7 @@ function App() {
const cartridgeConnector = connectors[0]

const [credentials, setCredentials] = useState<Credential | null>(null)
const biometryManager = useBiometryManager()

return (
<>
Expand All @@ -52,29 +44,14 @@ function App() {
connector: cartridgeConnector,
})
}}>
count is {count}
connect controller
</button>
</div>

<button onClick={() => {
WebApp.BiometricManager.init(() => {
WebApp.showConfirm('give data', () => WebApp.BiometricManager.requestAccess({
reason: 'we need your biometric data',
}, () => {
WebApp.showPopup({
message: 'thank'
})
}))
})
WebApp.showConfirm('give data', () => WebApp.BiometricManager.requestAccess({
reason: 'we need your biometric data',
}, () => {
WebApp.showPopup({
message: 'thank'
})
}))
biometryManager?.requestAccess({ reason: 'pwease'}).then(console.log)
}}>
ok
gib data
</button>
<button onClick={async () => {
const publicKeyCredentialCreationOptions = {
Expand Down Expand Up @@ -105,7 +82,7 @@ function App() {
{credentials ? JSON.stringify(credentials) : 'create'}
</button>
<div className="card">
<button onClick={() => WebApp.BiometricManager.openSettings()}>
<button onClick={() => biometryManager?.openSettings()}>
Bio settings
</button>
</div>
Expand Down
28 changes: 14 additions & 14 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./index.css";

import WebApp from '@twa-dev/sdk'
import { StarknetProvider } from './providers/StarknetProvider.tsx'
import { StarknetProvider } from "./providers/StarknetProvider.tsx";
import { SDKProvider } from "@telegram-apps/sdk-react";

WebApp.ready();

ReactDOM.createRoot(document.getElementById('root')!).render(
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<StarknetProvider>
<App />
</StarknetProvider>
</React.StrictMode>,
)
<SDKProvider debug acceptCustomStyles>
<StarknetProvider>
<App />
</StarknetProvider>
</SDKProvider>
</React.StrictMode>
);
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -497,17 +497,17 @@
dependencies:
"@tanstack/query-core" "5.52.0"

"@twa-dev/sdk@^7.8.0":
version "7.8.0"
resolved "https://registry.yarnpkg.com/@twa-dev/sdk/-/sdk-7.8.0.tgz#a21d3791b836717057fe6045a8e37d1bcfde3c1b"
integrity sha512-fVnTSqef6UL2cUU/li8z+KEnswBsvVqA1yjNYBKTy4BRcOs6TVjqHMUgVqn9PJJqyCN4Z0QWyA0y0nprYRVvCw==
"@telegram-apps/sdk-react@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@telegram-apps/sdk-react/-/sdk-react-1.1.3.tgz#eb3bd8b2ef3e23c97baf33b2f162864a083a0294"
integrity sha512-osddnacMIC4/KPvghsHQysPsomNXFQkr2K1owoMgf8MzmPQ2qZahR98xjeUlWU0JTCG+aAY9OHaPUFDNoxW/Bg==
dependencies:
"@twa-dev/types" "^7.8.0"
"@telegram-apps/sdk" "^1.1.3"

"@twa-dev/types@^7.8.0":
version "7.8.0"
resolved "https://registry.yarnpkg.com/@twa-dev/types/-/types-7.8.0.tgz#1b0d7992913d686ef98447b082891ff45796b637"
integrity sha512-nZR1j3Q+YlqLw1WoQXvmi5kdaKSw3C9ChFeycdFKqSnDZb/rqT3qJ3h6wGTyZuxGJNf+JB6bY1pGRrzYfTx3WQ==
"@telegram-apps/sdk@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@telegram-apps/sdk/-/sdk-1.1.3.tgz#e536b59968804ca3c29eacd7c29749221c6a32df"
integrity sha512-gvcXNttbCouDNTxjDUbO5FS/BdaHYO0ibSddQxiYitShPIDZDxGon0Eh3OSsgUIVPSQSNdXqkXaeqYgA+jeY0A==

"@types/json-schema@^7.0.12":
version "7.0.12"
Expand Down

0 comments on commit 6f900ca

Please sign in to comment.