-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: This contains breaking changes
- Loading branch information
1 parent
2740825
commit 827db57
Showing
205 changed files
with
67,904 additions
and
11,436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,8 @@ module.exports = { | |
'style', | ||
'test', | ||
'major', | ||
], | ||
], | ||
}, | ||
'code' | ||
] | ||
] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
.sst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Simple dApp</title> | ||
</head> | ||
<body> | ||
<header><radix-connect-button /></header> | ||
<div id="app"></div> | ||
|
||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "simple-dapp", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite --host", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"deploy": "sst deploy" | ||
}, | ||
"dependencies": { | ||
"@radixdlt/radix-dapp-toolkit": "*" | ||
}, | ||
"devDependencies": { | ||
"sst": "^2.41.3", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.1.6", | ||
"vite-plugin-ngrok": "^1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dApps": [ | ||
{} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import './style.css' | ||
import { | ||
RadixDappToolkit, | ||
RadixNetwork, | ||
LocalStorageClient, | ||
Logger, | ||
RequestItemClient, | ||
ConnectorExtensionClient, | ||
DataRequestBuilder, | ||
} from '@radixdlt/radix-dapp-toolkit' | ||
|
||
const dAppDefinitionAddress = import.meta.env.VITE_DAPP_DEFINITION_ADDRESS | ||
const networkId = RadixNetwork.Stokenet | ||
const storageClient = LocalStorageClient( | ||
`rdt:${dAppDefinitionAddress}:${networkId}`, | ||
) | ||
const requestsStore = storageClient.getPartition('requests') | ||
const sessionStore = storageClient.getPartition('sessions') | ||
const identityStore = storageClient.getPartition('identities') | ||
const stateStore = storageClient.getPartition('state') | ||
|
||
const content = document.getElementById('app')! | ||
|
||
content.innerHTML = ` | ||
<button id="reset">Reset</button> | ||
<pre id="sessions"></pre> | ||
<pre id="keyPairs"></pre> | ||
<pre id="walletResponse"></pre> | ||
<pre id="requests"></pre> | ||
<pre id="state"></pre> | ||
<pre id="device"></pre> | ||
<pre id="logs"></pre> | ||
` | ||
const resetButton = document.getElementById('reset')! | ||
const sessions = document.getElementById('sessions')! | ||
const keyPairs = document.getElementById('keyPairs')! | ||
const requests = document.getElementById('requests')! | ||
const walletResponse = document.getElementById('walletResponse')! | ||
const device = document.getElementById('device')! | ||
const logs = document.getElementById('logs')! | ||
const state = document.getElementById('state')! | ||
|
||
const logger = Logger() | ||
|
||
logger.attachTransport((logObj) => { | ||
const { _meta, ...rest } = logObj | ||
logs.innerHTML = `${logs.innerHTML} | ||
[${_meta.name}] | ||
${JSON.stringify(rest, null, 2)}` | ||
}) | ||
|
||
const requestItemClient = RequestItemClient({ | ||
logger, | ||
providers: { storageClient: storageClient.getPartition('requests') }, | ||
}) | ||
|
||
const dAppToolkit = RadixDappToolkit({ | ||
dAppDefinitionAddress, | ||
networkId, | ||
enableMobile: true, | ||
providers: { | ||
storageClient, | ||
requestItemClient, | ||
transports: [ | ||
ConnectorExtensionClient({ logger, providers: { requestItemClient } }), | ||
], | ||
}, | ||
logger, | ||
}) | ||
|
||
dAppToolkit.walletApi.provideChallengeGenerator(async () => | ||
[...window.crypto.getRandomValues(new Uint8Array(32))] | ||
.map((x) => x.toString(16).padStart(2, '0')) | ||
.join(''), | ||
) | ||
|
||
dAppToolkit.walletApi.setRequestData(DataRequestBuilder.persona().withProof()) | ||
|
||
resetButton.onclick = () => { | ||
sessionStore.clear() | ||
requestsStore.clear() | ||
stateStore.clear() | ||
identityStore.clear() | ||
window.location.hash = `` | ||
window.location.replace(window.location.origin) | ||
} | ||
|
||
setInterval(() => { | ||
requestsStore.getState().map((value: any) => { | ||
requests.innerHTML = JSON.stringify({ requests: value ?? {} }, null, 2) | ||
}) | ||
stateStore.getState().map((value: any) => { | ||
state.innerHTML = JSON.stringify({ state: value ?? {} }, null, 2) | ||
}) | ||
sessionStore.getItemList().map((value: any) => { | ||
sessions.innerHTML = JSON.stringify({ sessions: value }, null, 2) | ||
}) | ||
// storageClient.getPartition('identities') | ||
// .getState((state) => { | ||
// keyPairs.innerHTML = JSON.stringify(state, null, 2) | ||
// debugger | ||
// }) | ||
// .map((items) => { | ||
// keyPairs.innerHTML = JSON.stringify(items, null, 2) | ||
// }) | ||
// storageClient | ||
// .getData< | ||
// Record<string, { createdAt: number; status: string }> | ||
// >(`rdt:${dAppDefinitionAddress}:${networkId}:sessions`) | ||
// .map((items) => { | ||
// sessions.innerHTML = JSON.stringify({ sessions: items }, null, 2) | ||
// }) | ||
// const url = new URL(window.location.href) | ||
// const entries = Object.fromEntries([...url.searchParams.entries()]) | ||
// walletResponse.innerHTML = JSON.stringify({ walletResponse: entries }, null, 2) | ||
// device.innerHTML = JSON.stringify( | ||
// { device: navigator.userAgent, isAndroid: navigator.userAgent.includes('Android') }, | ||
// null, | ||
// 2 | ||
// ) | ||
}, 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="vite/client" /> | ||
interface ImportMetaEnv {} | ||
interface ImportMeta { | ||
readonly env: ImportMetaEnv | ||
} |
Oops, something went wrong.