Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
d38deb9
updated sdk + airdrop
nikitindenis1 Jul 18, 2023
71a9670
airdrop
nikitindenis1 Jul 18, 2023
76b583a
airdrop ui polish
nikitindenis1 Jul 19, 2023
d5d701d
add verified dao
amihaz Jul 20, 2023
370bbca
airdrop redesign
nikitindenis1 Jul 20, 2023
25d70f8
airdrop updates
nikitindenis1 Jul 23, 2023
e990f2a
a
nikitindenis1 Jul 23, 2023
9d06ec6
a
nikitindenis1 Jul 25, 2023
ed41b67
a
nikitindenis1 Jul 25, 2023
1ff5436
a
nikitindenis1 Jul 26, 2023
6f6e82c
airdrop before review
nikitindenis1 Jul 26, 2023
2eaeeab
texrs
nikitindenis1 Jul 27, 2023
10c6e9d
a
nikitindenis1 Jul 27, 2023
cdc1e4a
a
nikitindenis1 Jul 27, 2023
d290ec9
a
nikitindenis1 Jul 27, 2023
5d0c4e6
allow to go back in airdrop
nikitindenis1 Jul 30, 2023
efdc7d4
latest comments
nikitindenis1 Jul 31, 2023
56ff715
change dev api endpoint
amihaz Aug 1, 2023
9ea6276
change dev endpoint
amihaz Aug 1, 2023
563d827
change dev api endpoint to hhtps after installing certificate
amihaz Aug 1, 2023
711d275
airdrop texts fix
nikitindenis1 Aug 3, 2023
bdccd6f
a
nikitindenis1 Aug 7, 2023
96e1c3a
merge
nikitindenis1 Aug 7, 2023
fe5ed8c
total weight
nikitindenis1 Aug 7, 2023
31454f2
a
nikitindenis1 Aug 7, 2023
8ab6d7e
a
nikitindenis1 Aug 7, 2023
9668b55
added validators option
nikitindenis1 Aug 8, 2023
5737c25
a
nikitindenis1 Aug 8, 2023
a2a6adf
a
nikitindenis1 Aug 8, 2023
b9b6bb0
a
nikitindenis1 Aug 8, 2023
4fd30c9
a
nikitindenis1 Aug 10, 2023
4a89640
a
nikitindenis1 Aug 13, 2023
17cc38b
a
nikitindenis1 Aug 13, 2023
a35bf8c
a
nikitindenis1 Aug 16, 2023
c3f6cce
ton balance validators
nikitindenis1 Aug 17, 2023
614ccbf
analytics refactor
nikitindenis1 Aug 20, 2023
45f5da5
a
nikitindenis1 Aug 20, 2023
08d4c59
a
nikitindenis1 Aug 20, 2023
c7242b0
a
nikitindenis1 Aug 20, 2023
4541077
a
nikitindenis1 Aug 20, 2023
0bcb74f
show selected vote in proposals list
nikitindenis1 Aug 20, 2023
f3e7b94
update space flow
nikitindenis1 Aug 20, 2023
ca72fa3
a
nikitindenis1 Aug 21, 2023
97cb867
a
nikitindenis1 Aug 23, 2023
7f9a496
a
nikitindenis1 Aug 23, 2023
68fb57d
a
nikitindenis1 Aug 31, 2023
c8e1cd2
a
nikitindenis1 Sep 3, 2023
4b7b4eb
added tests
nikitindenis1 Sep 4, 2023
202f4d5
merged with dev
nikitindenis1 Sep 4, 2023
c6b28eb
a
nikitindenis1 Sep 4, 2023
6ff763e
a
nikitindenis1 Sep 5, 2023
eb6db2a
a
nikitindenis1 Sep 6, 2023
56764a5
a
nikitindenis1 Sep 6, 2023
ebf0642
a
nikitindenis1 Sep 6, 2023
d7ad2de
a
nikitindenis1 Sep 7, 2023
407418b
a
nikitindenis1 Sep 7, 2023
031461e
a
nikitindenis1 Sep 7, 2023
338fa6f
a
nikitindenis1 Sep 7, 2023
8de2414
a
nikitindenis1 Sep 7, 2023
44e2276
a
nikitindenis1 Sep 10, 2023
9a49721
a
nikitindenis1 Sep 10, 2023
9b90dfd
a
nikitindenis1 Sep 11, 2023
04bb3ba
router refactor
nikitindenis1 Sep 11, 2023
6506ec0
Merge branch 'main' into dev
nikitindenis1 Sep 11, 2023
e683eee
Merge branch 'dev' into twa-demo
nikitindenis1 Sep 11, 2023
ed37928
lazy loading
nikitindenis1 Sep 11, 2023
8aa7ef0
twa create dao buttons fix
nikitindenis1 Sep 11, 2023
ced9453
a
nikitindenis1 Sep 11, 2023
571c5ef
a
nikitindenis1 Sep 28, 2023
54740c4
added redirect from twa
sarbloc Nov 16, 2023
9816c60
wrapper redirect in use effect
sarbloc Nov 17, 2023
f93cef8
Merge branch 'dev' of github.com:orbs-network/ton-vote into dev
sarbloc Nov 17, 2023
b2399d7
added log for testing
sarbloc Nov 17, 2023
1457ae7
downgraded tonconnect ui version
sarbloc Nov 17, 2023
aa0f656
updated redirect link
sarbloc Nov 20, 2023
921f2d9
uploaded gif for tg messages
sarbloc Nov 20, 2023
4fb31da
updated tg gif
sarbloc Nov 20, 2023
0a36722
added new gif
sarbloc Nov 23, 2023
8bb57d7
upload mp4 version of tg message gif
sarbloc Nov 23, 2023
1897401
webapp menu button fix
denis-orbs Nov 26, 2023
6ce16d1
Merge branch 'main' of https://github.com/orbs-network/ton-vote into …
sarbloc Nov 28, 2023
d72f50f
yarn lock updated
sarbloc Nov 30, 2023
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
1 change: 1 addition & 0 deletions __mocks__/react-markdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {}
7 changes: 7 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": [
"@babel/env",
["@babel/preset-react", { "runtime": "automatic" }],
"@babel/preset-typescript"
]
}
1 change: 1 addition & 0 deletions jest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom";
17 changes: 17 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// jest.config.js
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
testTimeout: 300_000,
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
},
preset: "ts-jest",
testEnvironment: "jsdom",
setupFilesAfterEnv: ["<rootDir>/jest-setup.ts"],
moduleDirectories: ["node_modules", "src"],
moduleNameMapper: {
"react-markdown": "<rootDir>/__mocks__/react-markdown.ts",
"@tonconnect/ui-react": "<rootDir>/__mocks__/react-markdown.ts",
},
};
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"force-dev": "VITE_STAGING=1 vite --force",
"force-prod": "vite --force",
"build": "tsc && vite build && cp dist/index.html dist/404.html",
"preview": "vite preview"
"preview": "vite preview",
"test": "jest --testMatch='**/*.test.tsx'"
},
"dependencies": {
"@emotion/react": "^11.10.5",
Expand All @@ -21,6 +22,7 @@
"@tanstack/react-query": "^4.23.0",
"@tanstack/react-query-devtools": "^4.23.0",
"@tonconnect/ui-react": "^1.0.0-beta.6",
"@twa-dev/sdk": "^6.7.1",
"async-retry": "^1.3.3",
"axios": "^1.3.2",
"axios-retry": "^3.5.0",
Expand Down Expand Up @@ -61,7 +63,7 @@
"react-router-dom": "^6.8.2",
"react-share": "^4.4.1",
"react-text-overflow": "^1.0.2",
"react-virtualized-auto-sizer": "^1.0.7",
"react-virtualized-auto-sizer": "^1.0.20",
"react-window": "^1.8.8",
"remove-markdown": "^0.5.0",
"ton": "^13.4.1",
Expand All @@ -73,8 +75,14 @@
"zustand": "^4.3.2"
},
"devDependencies": {
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.11",
"@testing-library/jest-dom": "^6.1.2",
"@testing-library/react": "^14.0.0",
"@testing-library/react-hooks": "^8.0.1",
"@types/async-retry": "^1.4.5",
"@types/draft-js": "^0.11.10",
"@types/jest": "^29.5.4",
"@types/lodash": "^4.14.191",
"@types/node": "^20.3.1",
"@types/react": "^18.0.26",
Expand All @@ -86,7 +94,11 @@
"@types/react-window": "^1.8.5",
"@types/remove-markdown": "^0.3.1",
"@vitejs/plugin-react": "^3.1.0",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"ton-crypto": "^3.2.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.3",
"vite": "^4.0.0",
"vite-tsconfig-paths": "^4.0.8"
Expand Down
Binary file added public/ton-vote-message-short.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/ton-vote-message.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/ton-vote.mp4
Binary file not shown.
42 changes: 27 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { GlobalStyles, ThemeProvider } from "@mui/material";
import { GlobalStyles, styled, ThemeProvider } from "@mui/material";
import { APP_NAME } from "config";
import { useAppSettings } from "hooks/hooks";
import { Suspense, useEffect, useMemo } from "react";
import { Helmet } from "react-helmet";
import { RouterProvider } from "react-router-dom";
import { getGlobalStyles } from "styles";
import { useRouter } from "router/router";
import { getGlobalStyles, StyledFlexColumn } from "styles";
import "styles";
import { darkTheme, lightTheme, useInitThemeMode } from "theme";
import { useWalletListener } from "analytics";
import { Webapp } from "WebApp";
import { router } from "router";

Webapp.init();

const useInitApp = () => {
useInitThemeMode();
};

function App() {
useInitApp();

useWalletListener();
useEffect(() => {
const loader = document.querySelector(".app-loader");
if (loader) {
Expand All @@ -26,16 +26,24 @@ function App() {
}
}, []);

useEffect(() => {
if (Webapp.redirectUrl) {
window.location.href = Webapp.redirectUrl;
}
}, []);
};

const useTheme = () => {
const { isDarkMode } = useAppSettings();
const router = useRouter();
return useMemo(() => (isDarkMode ? darkTheme : lightTheme), [isDarkMode]);
};

const theme = useMemo(
() => (isDarkMode ? darkTheme : lightTheme),
[isDarkMode]
);
function App() {
useInitApp();
const theme = useTheme();

return (
<>
<StyledApp>
<Helmet>
<title>{APP_NAME}</title>
</Helmet>
Expand All @@ -45,8 +53,12 @@ function App() {
<RouterProvider router={router} />
</Suspense>
</ThemeProvider>
</>
</StyledApp>
);
}

export default App;

const StyledApp = styled(StyledFlexColumn)({
minHeight: "100dvh",
});
141 changes: 141 additions & 0 deletions src/WebApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import {
useIsConnectionRestored,
useTonAddress,
useTonConnectUI,
useTonWallet,
} from "@tonconnect/ui-react";
import TWA from "@twa-dev/sdk";
import { MainButton } from "@twa-dev/sdk/react";
import { Back } from "components";
import { useAppNavigation } from "router/navigation";
import { Dao } from "types";
import { parseLanguage } from "utils";

const isEnabled =
!!TWA.initData || !!new URLSearchParams(window.location.search).get("webapp");

const hapticFeedback = (
type?: "light" | "medium" | "heavy" | "rigid" | "soft"
) => {
if (isEnabled) {
TWA.HapticFeedback.impactOccurred(type || "medium");
}
};

const mainButton = TWA.MainButton;

const isExpanded = () => TWA.isExpanded;

const expand = () => TWA.expand();

const enableClosingConfirmation = () => TWA.enableClosingConfirmation();
const init = () => {
// enableClosingConfirmation();
expand();
TWA.ready();
};

const onDaoSelect = (dao: Dao) => {
TWA.sendData(
JSON.stringify({
name: parseLanguage(dao.daoMetadata.metadataArgs.name),
address: dao.daoAddress,
groupId: new URLSearchParams(window.location.search).get("groupId"),
})
);
};



const BackBtn = ({ onClick }: { onClick?: () => void }) => {
if (!Webapp.isEnabled) return null;

return <Back back={onClick} />;
};

const getRedirectUrl = () => {
const paramKeys = {
dao: '_dao_',
proposal: '_proposal_',
separator: '-_-',
};
let daoAddress: string | null = null;
let proposalAddress: string | null = null;
const webAppParams = new URLSearchParams(window.location.search).get("tgWebAppStartParam")
webAppParams?.split(paramKeys.separator).forEach((param) => {
if (param.includes(paramKeys.dao)) {
daoAddress = param.split(paramKeys.dao)[1];
} else if (param.includes(paramKeys.proposal)) {
proposalAddress = param.split(paramKeys.proposal)[1];
}
});

let redirectUrl: string | null = null;

if (daoAddress) {
redirectUrl = `/${daoAddress}`;
if (proposalAddress) {
redirectUrl += `/proposal/${proposalAddress}`;
}
}

console.log('redirectUrl', redirectUrl)

return redirectUrl;
}


export const Webapp = {
hapticFeedback,
isExpanded,
isEnabled,
expand,
enableClosingConfirmation,
isDarkMode: TWA.colorScheme === "dark",
init,
onDaoSelect,
mainButton,
viewPortHeight: TWA.viewportHeight,
BackBtn,
redirectUrl: getRedirectUrl()
};

export const WebappConnectWalletButton = () => {
const address = useTonAddress();
const [tonConnect] = useTonConnectUI();
const values = useTonWallet();

if (address) return null;
return (
<MainButton
text={"Connect wallet"}
onClick={() => tonConnect.connectWallet()}
/>
);
};

export function WebappButton({
onClick,
text,
progress,
disabled,
}: {
onClick: () => void;
text?: string;
progress?: boolean;
disabled?: boolean;
}) {
const address = useTonAddress();
const connectionRestored = useIsConnectionRestored();

if (!address || !connectionRestored) return null;

return (
<MainButton
disabled={disabled}
text={text || ""}
onClick={onClick}
progress={progress}
/>
);
}
Loading