Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions apps/bridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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?
.vercel

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
1 change: 1 addition & 0 deletions apps/bridge/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
80 changes: 80 additions & 0 deletions apps/bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Push Simulate Application

A simulation and testing platform built with React, TypeScript, and Vite, integrated with the Push Protocol. This application provides a sandbox environment for testing and simulating various blockchain interactions and Push Protocol features.

## 🚀 Features

- Interactive simulation environment
- Integration with Push Protocol for testing
- Form validation with Formik and Yup
- Real-time blockchain interaction simulation
- TypeScript for type safety
- Vite for fast development and building
- Devnet integration for testing

## 🛠️ Prerequisites

- Node.js (v18 or higher)
- Yarn package manager
- Git

## 📦 Installation

1. First, build the shared components:

```bash
cd packages/shared-components
yarn install
yarn build
```

2. Then, install and run the simulate application:

```bash
cd ../../examples/apps/simulate
yarn install
```

## 🏃‍♂️ Running the Application

### Development Mode

```bash
yarn dev
```

This will start the development server at `http://localhost:5173`

## 🛠️ Tech Stack

- React 18
- TypeScript
- Vite
- Push Protocol for testing
- Viem for Ethereum interactions
- Formik for form handling
- Yup for form validation
- React Router for navigation
- PushChain Devnet for testing

## 📚 Project Structure

```
simulate/
├── src/ # Source files
├── public/ # Static assets
├── vite.config.ts # Vite configuration
└── package.json # Project dependencies
```

## 🤝 Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📝 License

This project is licensed under the MIT License - see the LICENSE file for details.
28 changes: 28 additions & 0 deletions apps/bridge/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
53 changes: 53 additions & 0 deletions apps/bridge/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Connect to Wallet</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script checks to see if a redirect is present in the query string,
// converts it back into the correct url and adds it to the
// browser's history using window.history.replaceState(...),
// which won't cause the browser to attempt to load the new url.
// When the single page app is loaded further down in this file,
// the correct url will be waiting in the browser's history for
// the single page app to route accordingly.
(function (l) {
if (l.search[1] === "/") {
var decoded = l.search
.slice(1)
.split("&")
.map(function (s) {
return s.replace(/~and~/g, "&");
})
.join("?");
window.history.replaceState(
null,
null,
l.pathname.slice(0, -1) + decoded + l.hash
);
}
})(window.location);
</script>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-75GYJ2T6F1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-75GYJ2T6F1');
</script>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
42 changes: 42 additions & 0 deletions apps/bridge/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "core-connection",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"preinstall": "cd ../../packages/shared-components && yarn install && yarn build",
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview",
"deploy:vercel": "vercel build --prod && vercel deploy --prebuilt --prod",
"deploy": "VITE_DEPLOYMENT_MODE=production npm run build && echo 'simulate.push.org' > ./dist/CNAME && gh-pages -d dist -r https://github.com/push-protocol/simulate-dev-deployment",
"deploy:alpha": "VITE_DEPLOYMENT_MODE=alpha npm run build && echo 'simulate-alpha.push.org' > ./dist/CNAME && gh-pages -d dist -r https://github.com/push-protocol/simulate-alpha-deployment"
},
"dependencies": {
"@pushchain/ui-kit": "2.1.3",
"@radix-ui/react-popover": "^1.1.2",
"gh-pages": "^6.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-icons": "^5.5.0",
"react-router-dom": "^7.0.2",
"shared-components": "file:../../packages/shared-components",
"viem": "^2.21.34"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react-swc": "^3.10.2",
"eslint": "^9.9.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.1",
"vite": "^5.4.1",
"vite-plugin-node-polyfills": "^0.23.0"
}
}
52 changes: 52 additions & 0 deletions apps/bridge/public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Single Page Apps for GitHub Pages</title>
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script takes the current url and converts the path and query
// string into just a query string, and then redirects the browser
// to the new url with only a query string and hash fragment,
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
// Note: this 404.html file must be at least 512 bytes for it to work
// with Internet Explorer (it is currently > 512 bytes)

// If you're creating a Project Pages site and NOT using a custom domain,
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
// This way the code will only replace the route part of the path, and not
// the real directory in which the app resides, for example:
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
// Otherwise, leave pathSegmentsToKeep as 0.

var isTestURL = window.location.pathname.includes('/core-connection');
var pathSegmentsToKeep = isTestURL ? 1 : 0;

var l = window.location;
l.replace(
l.protocol +
'//' +
l.hostname +
(l.port ? ':' + l.port : '') +
l.pathname
.split('/')
.slice(0, 1 + pathSegmentsToKeep)
.join('/') +
'/?/' +
l.pathname
.slice(1)
.split('/')
.slice(pathSegmentsToKeep)
.join('/')
.replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);
</script>
</head>
<body></body>
</html>
Binary file added apps/bridge/public/BridgeLogo.png
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 apps/bridge/public/Discord.png
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 apps/bridge/public/PushFooter.png
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 apps/bridge/public/PushTitle.png
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 apps/bridge/public/Success.png
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 apps/bridge/public/Twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions apps/bridge/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { useEffect } from 'react';
import { Box } from 'shared-components';
import Header from './components/Header';
import Footer from './components/Footer';
import Bridge from './components/bridge';
import { usePushChainClient, PushUI, usePushWalletContext } from '@pushchain/ui-kit';

const App: React.FC = () => {
const { pushChainClient } = usePushChainClient();
const { handleUserLogOutEvent } = usePushWalletContext();

useEffect(() => {
if (pushChainClient && pushChainClient.universal.origin.chain === PushUI.CONSTANTS.CHAIN_CONFIG.PUSH_TESTNET) {
handleUserLogOutEvent();
}
}, [pushChainClient])

return (
<Box>
<Header />
<Box
display='flex'
alignItems='center'
justifyContent='center'
padding={{ initial: 'spacing-xxxl', tb: 'spacing-xl spacing-sm' }}
width={{ initial: 'auto', tb: 'calc(100% - 2 * var(--spacing-sm))' }}
>
<Bridge />
</Box>
<Footer />
</Box>
);
};

export default App;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading