Skip to content

Commit a0e4557

Browse files
authored
Dev (#95)
* Sandpac POC1 * Fix: As requested by Anirudh, top left logo on docs site links to docs homepage and not Arcana Network website * Add Auth and Gasless sample by fetching files from server side * Improvise PoC code * Theme sync up at the start * Refer to sandpack/github files * Fix: #AR-7698 Sandpack works for auth SDK example integration * Fix gasless sandpack on the home page, runtime errors * fix netlify script CORS issue * fix netlify script CORS issue * update Netlify script-src-elem * Increase sandpack preview height * Fix footer and feedback section * Biconomy Gasless SDK v4 in use by SCW v0.0.35 * Biconomy v4 docs * Fix sandpack to use scw 0.0.30 only
1 parent b62740d commit a0e4557

File tree

5 files changed

+238
-11
lines changed

5 files changed

+238
-11
lines changed

docs/about-auth/user-flows/steps/_auth_dkg_steps.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
3. Auth SDK registers that the user belongs to that dApp and informs the Gateway node.
44
4. Gateway node relays a meta-transaction to the Arcana blockchain.
55
5. Blockchain returns the user-registration transaction hash to the Gateway node.
6-
6. The Gateway node informs Auth SDK that the dApp user is successfully registered into the Arcana Network.
6+
6. The Gateway node informs Auth SDK that the dApp user is successfully registered into the Arcana Network.

docs/overrides/newintro.html

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,40 @@ <h3>Concepts</h3>
782782
</div>
783783
</div>
784784

785+
<div class="top-hr">
786+
<div class="hr">
787+
<h2 style="text-align: left">Try Auth!</h2>
788+
</div>
789+
</div>
790+
791+
<div style="margin-top: 1rem; margin-bottom: 1rem"id="authsandpack"></div>
792+
793+
<div class="top-hr">
794+
<div class="hr">
795+
<h2 style="text-align: left">Try Gasless!</h2>
796+
</div>
797+
</div>
798+
799+
<div style="margin-top: 1rem; margin-bottom: 1rem" id="gaslesssandpack"></div>
800+
801+
<div class="top-hr">
802+
<div class="hr">
803+
<h2 style="text-align: left">Share Your Feedback</h2>
804+
</div>
805+
</div>
806+
807+
<div class="top-hr">
808+
<div class="hr">
809+
<i>👋 Hi there!</i>
810+
</div>
811+
</div>
812+
<div class="top-hr">
813+
<div class="hr">
814+
<i>How was your experience with Arcana Auth and/or Gasless SDKs?</i>
815+
<b><a href="{{ config.site_url }}/support/">Let us know...</a></b>
816+
</div>
817+
</div>
818+
785819
{% include "partials/content.html" %}
786820

787821
{% endblock %}
@@ -806,6 +840,187 @@ <h3>Concepts</h3>
806840
</script>
807841
--->
808842

843+
<!--
844+
Sandpack PoC
845+
-->
846+
<script type="importmap">
847+
{
848+
"imports": {
849+
"react": "https://esm.sh/react@18.2.0",
850+
"react-dom": "https://esm.sh/react-dom@18.2.0",
851+
"react-dom/": "https://esm.sh/react-dom@18.2.0/",
852+
"@codesandbox/sandpack-react": "https://esm.sh/@codesandbox/sandpack-react@2.8.0"
853+
}
854+
}
855+
</script>
856+
857+
<script type="module">
858+
import React from "react";
859+
import { createRoot } from "react-dom/client";
860+
import { Sandpack } from "@codesandbox/sandpack-react";
861+
862+
const authsandpack = createRoot(document.getElementById("authsandpack"));
863+
const gaslesssandpack = createRoot(document.getElementById("gaslesssandpack"));
864+
865+
let themeType;
866+
let currentTheme;
867+
let updateSP;
868+
869+
// Current Theme check
870+
const startCurrentTheme = document.body.getAttribute("data-md-color-scheme");
871+
872+
if (startCurrentTheme === "slate") {
873+
themeType = "dark";
874+
}
875+
//const {sPtheme, setsPTheme} = useState('light');
876+
/*
877+
const watchMedia = window.matchMedia("(data-md-color-scheme: "slate")");
878+
let themetype;
879+
880+
function getTheme(e) {
881+
if (e.matches)
882+
themetype = "dark";
883+
else
884+
themetype = "default";
885+
}
886+
watchMedia.addEventListener("change", getTheme);
887+
*/
888+
889+
/*
890+
const prefersDarkMode = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
891+
const themetype = prefersDarkMode ? "dark" : "light";
892+
*/
893+
894+
//Try Observer method
895+
896+
// Select the node that will be observed for mutations
897+
const targetNode = document.body;
898+
899+
// Options for the observer (which mutations to observe)
900+
const config = { attributes: true, childList: false, subtree: false };
901+
902+
// Callback function to execute when mutations are observed
903+
const callback = (mutationList, observer) => {
904+
for (const mutation of mutationList) {
905+
if (mutation.type === "attributes" && mutation.attributeName === "data-md-color-scheme") {
906+
console.log(`The ${mutation.attributeName} attribute was modified.`);
907+
console.log("Mutation:", mutation);
908+
909+
const currentTheme = document.body.getAttribute("data-md-color-scheme");
910+
console.log("Current theme:", currentTheme);
911+
912+
// Determine theme type based on current theme
913+
if (currentTheme === "slate") {
914+
themeType = "dark";
915+
} else if (currentTheme === "default") {
916+
themeType = "light";
917+
}
918+
console.log("Theme type:", themeType);
919+
}
920+
}
921+
};
922+
923+
// Create an observer instance linked to the callback function
924+
const observer = new MutationObserver(callback);
925+
926+
// Start observing the target node for configured mutations
927+
observer.observe(targetNode, config);
928+
929+
window.onbeforeunload = function(){
930+
// Later, you can stop observing
931+
observer.disconnect();
932+
return 'The observer is now disconnected!';
933+
};
934+
935+
function fetchAndStoreFiles(fileUrls, targetObject) {
936+
const filePromises = fileUrls.map(url => {
937+
return fetch(url)
938+
.then(response => {
939+
if (!response.ok) {
940+
throw new Error(`Failed to fetch ${url}`);
941+
}
942+
return response.text();
943+
})
944+
.then(data => {
945+
const fileName = url.substring(url.lastIndexOf('/') + 1);
946+
targetObject[`/${fileName}`] = data;
947+
});
948+
});
949+
950+
return Promise.all(filePromises);
951+
}
952+
953+
function renderSandpack(template, theme, files, sandpackInstance) {
954+
const sandpackComponent = React.createElement(
955+
Sandpack,
956+
{
957+
template,
958+
customSetup: {
959+
dependencies: {
960+
"dotenv": "^16.3.1",
961+
"parcel": "^2.9.3"
962+
}
963+
},
964+
theme,
965+
options: {
966+
showNavigator: true,
967+
showTabs: true,
968+
showConsole: true,
969+
showConsoleButton: true,
970+
externalResources: [
971+
"https://cdn.jsdelivr.net/npm/@arcana/auth",
972+
"https://cdnjs.cloudflare.com/ajax/libs/ethers/5.7.2/ethers.umd.min.js",
973+
"https://unpkg.com/@arcana/scw@0.0.30/dist/standalone/scw.umd.js",
974+
//"https://cdn.jsdelivr.net/npm/@arcana/scw",
975+
],
976+
editorHeight: '95vh',
977+
autoReload: true,
978+
initMode: "user-visible",
979+
resizablePanels: true,
980+
},
981+
files,
982+
},
983+
null
984+
);
985+
sandpackInstance.render(sandpackComponent);
986+
}
987+
988+
const fileUrls = [
989+
'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/auth/index.html',
990+
'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/auth/index.js',
991+
'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/auth/styles.css',
992+
// 'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/auth/package.json',
993+
];
994+
//../sandpack/auth/index.html
995+
const files = {};
996+
fetchAndStoreFiles(fileUrls, files)
997+
.then(() => {
998+
console.log('Sandpack files:', files);
999+
renderSandpack('vanilla', themeType, files, authsandpack);
1000+
})
1001+
.catch(error => {
1002+
console.error('Error loading sample files:', error);
1003+
});
1004+
1005+
const gaslessFileUrls = [
1006+
'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/gl/index.html',
1007+
'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/gl/index.js',
1008+
'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/gl/styles.css',
1009+
'https://raw.githubusercontent.com/arcana-network/sandpack-examples/main/gl/myerc20.js',
1010+
];
1011+
1012+
const glFiles = {};
1013+
fetchAndStoreFiles(gaslessFileUrls, glFiles)
1014+
.then(() => {
1015+
console.log('Gasless Sandpack files:', glFiles);
1016+
renderSandpack('vanilla', themeType, glFiles, gaslesssandpack);
1017+
})
1018+
.catch(error => {
1019+
console.error('Error loading gasless sample files:', error);
1020+
});
1021+
1022+
</script>
1023+
8091024
<!-- Chatbase bot script -->
8101025
<script>
8111026
window.chatbaseConfig = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<span><a href="https://docs.biconomy.io/3.0" target="_blank">Biconomy Gasless SDK v3</a></span>
1+
<span><a href="https://docs.biconomy.io/" target="_blank">Biconomy Gasless SDK v4</a></span>

mkdocs.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,26 @@ theme:
5151
- content.tabs.link
5252
- header.autohide
5353
palette:
54+
# Auto Mode
55+
- media: "(prefers-color-scheme)"
56+
scheme: auto
57+
toggle:
58+
icon: material/brightness-auto
59+
name: Switch to Light Mode
5460
# Light Mode
55-
- scheme: default
61+
- media: "(prefers-color-scheme: light)"
62+
scheme: default
5663
toggle:
57-
icon: material/brightness-4
64+
icon: material/brightness-7
5865
name: Switch to Dark Mode
5966
# Dark Mode
60-
- scheme: slate
67+
- media: "(prefers-color-scheme: dark)"
68+
scheme: slate
69+
primary: custom
70+
accent: custom
6171
toggle:
62-
icon: material/brightness-7
63-
name: Switch to Light Mode
72+
icon: material/brightness-4
73+
name: Switch to System Mode
6474

6575
extra_javascript:
6676
- javascripts/mathjax.js
@@ -111,7 +121,8 @@ extra:
111121
mobile_react_native_sdk_pkg_name: auth-react-native
112122
gaming_sdk_pkg_name: arcana-auth-sdk
113123
exclude_content_tag: exclude
114-
homepage: https://arcana.network
124+
# Allow top left logo to browse website
125+
#homepage: https://arcana.network
115126
social:
116127
- icon: fontawesome/brands/twitter
117128
link: https://twitter.com/arcananetwork
@@ -127,7 +138,7 @@ extra:
127138
provider: google
128139
property: !ENV [GOOGLE_ANALYTICS_ID, default='XXXXXXXXXX']
129140
feedback:
130-
title: <hr>Is this information useful?
141+
title: <i>Did you find what you were looking for today?</i>
131142
ratings:
132143
- icon: material/thumb-up-outline
133144
name: Yes, it was useful.

netlify.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
Content-Security-Policy = '''
88
font-src 'self' fonts.gstatic.com gstatic.com *.gstatic.com *.jsdelivr.net;
99
img-src 'self' data: *.arcana.network *.chatbase.co;
10-
script-src 'self' 'unsafe-inline' *.google-analytics.com *.googletagmanager.com *.marker.io *.chatbase.co polyfill.io *.jsdelivr.net *.netlify.app unpkg.com;
10+
script-src 'self' 'unsafe-inline' 'unsafe-eval' *.google-analytics.com *.googletagmanager.com *.marker.io *.chatbase.co polyfill.io *.jsdelivr.net *.netlify.app unpkg.com *.arcana.network esm.sh;
11+
script-src-elem 'self' 'unsafe-inline' *.google-analytics.com *.googletagmanager.com *.marker.io *.chatbase.co polyfill.io *.jsdelivr.net *.netlify.app unpkg.com *.arcana.network esm.sh;
1112
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
12-
frame-src *.arcana.network *.chatbase.co youtube.com https://www.youtube.com *.netlify.com;
13+
frame-src *.arcana.network *.chatbase.co youtube.com https://www.youtube.com esm.sh *.codesandbox.io *.netlify.com;
1314
frame-ancestors 'self';
1415
'''

0 commit comments

Comments
 (0)