Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rel. 1] Mutable Web. B.O.S-Gateway patch #230

Open
wants to merge 88 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
10076cb
feat: integrate mutable web engine
alsakhaev Dec 29, 2023
039fa8d
build: use mutable-web-engine dependency from github
alsakhaev Jan 11, 2024
47e7d08
refactor: initialize `near-social-vm` outside the mutable web engine
alsakhaev Jan 22, 2024
8b49adf
chore: update deps
alsakhaev Jan 22, 2024
f7ed0c5
Merge remote-tracking branch 'upstream/master'
alsakhaev Jan 23, 2024
db67ff1
chore: update deps
alsakhaev Jan 25, 2024
96f1e8c
chore: update deps
alsakhaev Jan 26, 2024
6f490a2
chore: update deps
alsakhaev Feb 5, 2024
7bba9ef
chore: update deps
alsakhaev Feb 5, 2024
ac107e2
chore: update deps
alsakhaev Feb 9, 2024
13dfb00
refactor: export reusable dapplet overlay component
alsakhaev Feb 9, 2024
58750e9
feat: added mutation dropdown
Lisofffa Feb 12, 2024
bade6a1
fix: removed unused props and files
Lisofffa Feb 13, 2024
1f551ca
build: remove package-lock.json
alsakhaev Feb 14, 2024
9e8fbb4
build: revert yarn.lock
alsakhaev Feb 14, 2024
bddb4b0
chore: upgrade deps
alsakhaev Feb 14, 2024
16c0b99
feat: introduce mutations
alsakhaev Feb 14, 2024
0aed1e9
fix: added styles-components for Mutation
Lisofffa Feb 14, 2024
7e042ac
refactor: merge MutationDropdown with its item
alsakhaev Feb 15, 2024
63853b6
build: remove npm package-lock
alsakhaev Feb 15, 2024
340267e
chore: revert yarn lock
alsakhaev Feb 15, 2024
903203e
chore: upgrade deps
alsakhaev Feb 15, 2024
0079acb
feat: close mutation dropdown after switching
alsakhaev Feb 15, 2024
2502b8b
feat: introduce mutation switcher (DAP-4346)
alsakhaev Feb 15, 2024
2945c2f
Merge remote-tracking branch 'upstream/master'
alsakhaev Feb 15, 2024
30603be
chore: upgrade deps
alsakhaev Feb 15, 2024
c297271
chore: upgrade deps
alsakhaev Feb 20, 2024
a1d96b4
feat: save selected mutation to the local storage
alsakhaev Feb 20, 2024
d2d9913
fix: changed open dropdown
Lisofffa Feb 21, 2024
5c159e1
Merge pull request #2 from dapplets/dap-4366
alsakhaev Feb 21, 2024
67c5e98
feat: save selected mutation id in the session storage
alsakhaev Feb 21, 2024
89dce29
feat: save selected mutation id in the session storage
alsakhaev Feb 21, 2024
eae5ee5
chore: restore original yarn.lock + upgrade near-social-vm fork
alsakhaev Feb 22, 2024
0c20fa8
feat: added cursor for active mutation block
Lisofffa Feb 27, 2024
cd6ee43
fix: move the dropdown to the center
Ni-2 Mar 1, 2024
ba6a542
fix: mutable dropdown is not adaptive; add dropdown to mobile version
Ni-2 Mar 6, 2024
076916e
fix: image component is unavailable in testnet
alsakhaev Mar 12, 2024
9e44506
chore: update dependency
alsakhaev Mar 12, 2024
08920a4
Merge branch 'master' of github.com:dapplets/mutable-web-gateway
alsakhaev Mar 12, 2024
8551f49
feat: add new testnet domains
alsakhaev Mar 12, 2024
a986f6d
chore: upgrade deps
alsakhaev Mar 14, 2024
9a16dca
Merge branch 'master' into netlify
alsakhaev Mar 14, 2024
872d31b
chore: upgrade deps
alsakhaev Mar 20, 2024
5e03766
Merge branch 'master' into netlify
alsakhaev Mar 20, 2024
d5de0b8
chore: upgrade deps
alsakhaev Mar 22, 2024
3a03a8f
Merge branch 'master' into netlify
alsakhaev Mar 22, 2024
6f5ca2d
fix: changed counter mutations
Lisofffa Mar 26, 2024
62b4203
refactor: remove React namespace
alsakhaev Mar 26, 2024
db802b6
Merge branch 'dap-4476' of https://github.com/dapplets/mutable-web-ga…
Lisofffa Mar 27, 2024
500108c
fix: removed text
Lisofffa Mar 27, 2024
ef3dc74
fix: cannot start engine after stopping (DAP-4484)
alsakhaev Apr 1, 2024
7d8bedc
chore: upgrade deps
alsakhaev Apr 1, 2024
27e6972
Merge branch 'dap-4484'
alsakhaev Apr 5, 2024
7e9535b
revert: remove "No mutations applied"
alsakhaev Apr 5, 2024
7f34a4b
Merge remote-tracking branch 'origin/dap-4373'
alsakhaev Apr 5, 2024
b97f87b
merge upstream
alsakhaev Apr 12, 2024
cfbee1c
fix: added fallbackImage
Lisofffa Apr 22, 2024
916512d
fix: update fallback icon
Lisofffa Apr 22, 2024
99023cf
Merge commit 'b97f87bef123d9fbfb7964e8f93c3c1f1f44feae'
alsakhaev May 13, 2024
ffb8375
feat: introduce near sessions, connect bootstrap (DAP-4506) (#6)
alsakhaev May 13, 2024
436d01a
merge upstream
alsakhaev May 13, 2024
c34db4f
chore: upgrade deps
alsakhaev May 13, 2024
536228c
feat: use mweb portals
alsakhaev May 13, 2024
23b9e42
feat: introduce new custom elements
alsakhaev May 13, 2024
733353a
chore: upgrade engine
alsakhaev May 15, 2024
c612a07
feat: add mweb selectors to mutation dropdown
Ni-2 May 15, 2024
f132957
Merge remote-tracking branch 'origin/master'
Ni-2 May 15, 2024
cb5f86f
feat: add Mutable Web Mini Overlay
Ni-2 May 24, 2024
8f21897
fix: delete console log
Ni-2 May 24, 2024
05bf67e
Revert "fix: delete console log"
Ni-2 May 24, 2024
890de06
Revert "feat: add Mutable Web Mini Overlay"
Ni-2 May 24, 2024
fe394f9
Revert "Revert "feat: add Mutable Web Mini Overlay""
Ni-2 May 27, 2024
72aea7b
Revert "Revert "fix: delete console log""
Ni-2 May 27, 2024
f5bcc78
fix: engine upgrade
Ni-2 May 27, 2024
93d4516
refactor: reuse the Mutable Web Overlay component from the Engine (#7)
Ni-2 May 29, 2024
ab37d53
chore: ugrade engine
alsakhaev May 29, 2024
479686b
chore: upgrade engine
alsakhaev May 31, 2024
780c608
feat: use getblock rpc api
alsakhaev Jun 13, 2024
ef83c61
feat: switch to self-hosted rpc provider
alsakhaev Jun 18, 2024
94c0b7d
feat: switch to self-hosted rpc provider
alsakhaev Jun 18, 2024
19cc7ae
feat: collect analytics
alsakhaev Jun 26, 2024
e5fb57d
fix: analytics crashes site
alsakhaev Jun 26, 2024
59db3bd
ci: add captain-definition
alsakhaev Jun 26, 2024
a044bc1
ci: dockerize project
alsakhaev Jun 26, 2024
38d7c19
ci: adopt dockerfile for caprover
alsakhaev Jun 26, 2024
b079f50
ci: adopt dockerfile for caprover
alsakhaev Jun 26, 2024
2b87539
ci: adopt dockerfile for caprover
alsakhaev Jun 26, 2024
f304f13
ci: adopt dockerfile for caprover
alsakhaev Jun 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
dist
npm-debug.log

yarn-debug.log*
yarn-error.log*
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:20.15-alpine as build
WORKDIR /app
COPY package.json ./
COPY yarn.lock ./
RUN yarn
COPY . .
RUN yarn build

FROM nginx:1.11.13-alpine
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion functions/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export async function socialGet(keys, blockHeight, parse) {
}

export async function viewCall({ contractId, method, args }) {
const res = await fetch("https://rpc.mainnet.near.org", {
const res = await fetch("https://mainnet.near.dapplets.org", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"dompurify": "^3.0.6",
"error-polyfill": "^0.1.2",
"local-storage": "^2.0.0",
"mutable-web-engine": "github:dapplets/mutable-web-engine",
"near-api-js": "^2.1.3",
"near-social-vm": "git+https://github.com/NearSocial/VM.git#2.6.1",
"near-social-vm": "github:dapplets/near-social-vm",
"near-social-vm-types": "^1.0.0",
"prettier": "^2.7.1",
"qrcode.react": "^3.1.0",
Expand Down
89 changes: 67 additions & 22 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import { NetworkId, Widgets } from "./data/widgets";
import { useEthersProviderContext } from "./data/web3";
import SignInPage from "./pages/SignInPage";
import { isValidAttribute } from "dompurify";
import { Engine, customElements } from "mutable-web-engine";
import { MutableWebProvider } from "./contexts/mutable-web-context";
import MutableOverlayContainer from "./components/navigation/MutableOverlayContainer";
import { useMatomoAnalytics } from "./hooks/useMatomoAnalytics";

export const refreshAllowanceObj = {};
const documentationHref = "https://social.near-docs.io/";
Expand All @@ -41,7 +45,7 @@ const getNetworkPreset = (networkId) => {
case "mainnet":
return {
networkId,
nodeUrl: "https://rpc.mainnet.near.org",
nodeUrl: "https://mainnet.near.dapplets.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://nearblocks.io",
indexerUrl: "https://api.kitwallet.app",
Expand All @@ -65,6 +69,7 @@ function App(props) {
const [signedAccountId, setSignedAccountId] = useState(null);
const [availableStorage, setAvailableStorage] = useState(null);
const [walletModal, setWalletModal] = useState(null);
const [mutationEngine, setMutationEngine] = useState(null);
const [widgetSrc, setWidgetSrc] = useState(null);

const ethersProviderContext = useEthersProviderContext();
Expand All @@ -77,13 +82,18 @@ function App(props) {
const injectedConfig = window?.InjectedConfig;

useEffect(() => {
const features = {};
const features = {
enableComponentPropsDataKey: true,
enableComponentSrcDataKey: true,
skipTxConfirmationPopup: true,
};

const rpcUrl =
injectedConfig?.rpcUrl ??
(window.location.hostname === "near.social"
? "https://rpc.fastnear.com"
: NetworkId === "mainnet"
? "https://free.rpc.fastnear.com"
? "https://mainnet.near.dapplets.org"
: "https://rpc.testnet.near.org");
if (injectedConfig?.skipConfirmations) {
features.commitModalBypass = {
Expand Down Expand Up @@ -127,6 +137,7 @@ function App(props) {
}
return <Link {...props} />;
},
...customElements,
},
config: {
defaultFinality: undefined,
Expand All @@ -149,6 +160,30 @@ function App(props) {
});
}, [near]);

useEffect(() => {
if (!near) {
return;
}
near.selector.then((selector) => {
const engine = new Engine({
networkId: NetworkId,
selector: selector,
gatewayId: "near-social",
bosElementStyleSrc: "/bootstrap.min.css",
});

const mutationId = window.sessionStorage.getItem("mutableweb:mutationId");

if (!mutationId) {
engine.start().then(() => setMutationEngine(engine));
} else if (mutationId !== "null") {
engine.start(mutationId).then(() => setMutationEngine(engine));
} else {
setMutationEngine(engine);
}
});
}, [near]);

const requestSignIn = useCallback(
(e) => {
e && e.preventDefault();
Expand Down Expand Up @@ -195,6 +230,12 @@ function App(props) {
);
}, [account]);

// Mutable Web
useMatomoAnalytics({
matomoUrl: "https://mtmo.mooo.com",
siteId: 4,
});

const passProps = {
refreshAllowance: () => refreshAllowance(),
setWidgetSrc,
Expand All @@ -207,30 +248,34 @@ function App(props) {
requestSignIn,
widgets: Widgets,
documentationHref,
mutationEngine,
};

return (
<div className="App">
<EthersProviderContext.Provider value={ethersProviderContext}>
<Router basename={process.env.PUBLIC_URL}>
<Switch>
<Route path={"/signin"}>
<NavigationWrapper {...passProps} />
<SignInPage {...passProps} />
</Route>
<Route path={"/embed/:widgetSrc*"}>
<EmbedPage {...passProps} />
</Route>
<Route path={"/edit/:widgetSrc*"}>
<NavigationWrapper {...passProps} />
<EditorPage {...passProps} />
</Route>
<Route path={"/:widgetSrc*"}>
<NavigationWrapper {...passProps} />
<ViewPage {...passProps} />
</Route>
</Switch>
</Router>
<MutableWebProvider engine={mutationEngine}>
<Router basename={process.env.PUBLIC_URL}>
<Switch>
<Route path={"/signin"}>
<NavigationWrapper {...passProps} />
<SignInPage {...passProps} />
</Route>
<Route path={"/embed/:widgetSrc*"}>
<EmbedPage {...passProps} />
</Route>
<Route path={"/edit/:widgetSrc*"}>
<NavigationWrapper {...passProps} />
<EditorPage {...passProps} />
</Route>
<Route path={"/:widgetSrc*"}>
<NavigationWrapper {...passProps} />
<ViewPage {...passProps} />
</Route>
</Switch>
</Router>
<MutableOverlayContainer />
</MutableWebProvider>
</EthersProviderContext.Provider>
</div>
);
Expand Down
15 changes: 15 additions & 0 deletions src/components/icons/Arrow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'

export function Arrow() {
return (
<svg width="14" height="8" viewBox="0 0 14 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M1 1L7 7L13 1"
stroke="#C1C6CE"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
}
22 changes: 22 additions & 0 deletions src/components/icons/Back.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'

export function Back() {
return (
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M0.75 3V7.5H5.25"
stroke="#3D7FFF"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M2.6325 11.25C3.1188 12.6302 4.0405 13.8151 5.25874 14.626C6.47698 15.4369 7.92576 15.8299 9.38679 15.7458C10.8478 15.6617 12.2419 15.1051 13.3591 14.1598C14.4763 13.2145 15.2559 11.9317 15.5807 10.5047C15.9054 9.07777 15.7576 7.58393 15.1595 6.24829C14.5614 4.91264 13.5454 3.80756 12.2646 3.09953C10.9839 2.39151 9.50768 2.11891 8.05851 2.3228C6.60934 2.52669 5.26568 3.19603 4.23 4.22996L0.75 7.49996"
stroke="#3D7FFF"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
}
30 changes: 30 additions & 0 deletions src/components/navigation/MutableOverlayContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { MiniOverlay, AppSwitcher } from "mutable-web-engine";
import {
useMutableWeb,
useMutationApp,
} from "../../contexts/mutable-web-context";

function AppSwitcherContainer({ app }) {
const { enableApp, disableApp, isLoading } = useMutationApp(app.id);
return (
<AppSwitcher
app={app}
enableApp={enableApp}
disableApp={disableApp}
isLoading={isLoading}
/>
);
}

function MutableOverlayContainer() {
const { selectedMutation, mutationApps } = useMutableWeb();
return (
<MiniOverlay baseMutation={selectedMutation} mutationApps={mutationApps}>
{mutationApps.map((app) => (
<AppSwitcherContainer key={app.id} app={app} />
))}
</MiniOverlay>
);
}
export default MutableOverlayContainer;
15 changes: 13 additions & 2 deletions src/components/navigation/desktop/DesktopNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SignInButton } from "../SignInButton";
import { UserDropdown } from "./UserDropdown";
import { DevActionsDropdown } from "./DevActionsDropdown";
import { NotificationWidget } from "../NotificationWidget";
import { MutationDropdown } from "./MutationDropdown";
import { StarButton } from "../StarButton";

const StyledNavigation = styled.div`
Expand All @@ -27,7 +28,7 @@ const StyledNavigation = styled.div`
}
}

.container {
.container-xl {
display: flex;
align-items: center;

Expand Down Expand Up @@ -58,13 +59,20 @@ const StyledNavigation = styled.div`
.arrow-up-right {
margin-left: 4px;
}

.mutable-section {
margin-left: auto;
transform: translate(-16px);
flex: 1;
max-width: 292px;
}
}
`;

export function DesktopNavigation(props) {
return (
<StyledNavigation>
<div className="container">
<div className="container-xl">
<Link
to="/"
className="logo-link"
Expand All @@ -82,6 +90,9 @@ export function DesktopNavigation(props) {
<ArrowUpRight />
</NavigationButton>
</div>
<div className="mutable-section">
<MutationDropdown imageSrc={props.widgets.image} />
</div>
<div className="user-section">
<StarButton {...props} />
<DevActionsDropdown {...props} />
Expand Down
Loading