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

Standalone swap widget #327

Merged
merged 14 commits into from
Dec 11, 2024
Merged
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
6 changes: 6 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ jobs:
environment: 'main'
secrets: inherit

swap-widget-build:
uses: ./.github/workflows/swap-widget-build.yaml
with:
environment: 'main'
secrets: inherit

web-tests:
needs: web-build
uses: ./.github/workflows/web-tests.yaml
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/deploy-swap-widget.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Tonkeeper Swap Widget Deploy
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Deploy to env
required: true
options:
- dev
- main

jobs:
swap-widget:
uses: ./.github/workflows/swap-widget-build.yaml
with:
environment: ${{ inputs.environment }}
secrets: inherit
8 changes: 7 additions & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tonkeeper Pull-Request
name: PR
on:
workflow_dispatch:
pull_request:
Expand Down Expand Up @@ -263,6 +263,12 @@ jobs:
uses: ./.github/workflows/ipad-build.yaml
secrets: inherit

swap-widget-build:
uses: ./.github/workflows/swap-widget-build.yaml
with:
environment: ${{ github.head_ref }}
secrets: inherit

web-tests:
needs: web-build
uses: ./.github/workflows/web-tests.yaml
Expand Down
103 changes: 103 additions & 0 deletions .github/workflows/swap-widget-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Tonkeeper Swap Widget Build
on:
workflow_call:
inputs:
environment:
required: true
type: string
secrets:
REACT_APP_AMPLITUDE_EXTENSION:
required: true
REACT_APP_MEASUREMENT_ID:
required: true
VITE_APP_APTABASE:
required: true
REACT_APP_TG_BOT_ID:
required: true
REACT_APP_STONFI_REFERRAL_ADDRESS:
required: true
CLOUDFLARE_API_TOKEN:
required: true
CLOUDFLARE_ACCOUNT_ID:
required: true
outputs:
deployment-url:
description: 'The app deployment url'
value: ${{ jobs.web-build.outputs.deployment-url }}
env:
node-version: 20.11.1

jobs:
swap-widget:
name: Swap Widget
runs-on: ubuntu-latest
timeout-minutes: 10

outputs:
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
steps:
- name: Checkout to git repository
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}

- name: Enable Corepack
run: |
corepack enable

- name: Yarn cache
uses: actions/cache@v4
with:
path: ./.yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Run install
uses: borales/actions-yarn@v5
with:
cmd: install

- name: Run build
uses: borales/actions-yarn@v5
env:
VITE_APP_MEASUREMENT_ID: ${{ secrets.REACT_APP_MEASUREMENT_ID }}
VITE_APP_APTABASE: ${{ secrets.VITE_APP_APTABASE }}
VITE_APP_APTABASE_HOST: https://anonymous-analytics.tonkeeper.com
VITE_APP_LOCALES: en,zh_TW,zh_CN,id,ru,it,es,uk,tr,bg,uz,bn
VITE_APP_TONCONSOLE_HOST: https://pro.tonconsole.com
VITE_APP_TG_BOT_ID: ${{ secrets.REACT_APP_TG_BOT_ID }}
VITE_APP_STONFI_REFERRAL_ADDRESS: UQCV6ZyNxqQ4Um30lhk2_1EgnzB6KMN8bHgxDOFAq3irZfgx
with:
cmd: build:swap-widget

- name: Publish to Cloudflare Pages
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command:
pages deploy apps/web-swap-widget/dist --project-name=tonkeeper-swap-widget
--branch=${{ inputs.environment }}

- name: Summary
run: |
echo '### Successful swap widget deployment 🚀🚀🚀' >> $GITHUB_STEP_SUMMARY
echo 'Well done!' >> $GITHUB_STEP_SUMMARY
echo 'Link to test environment:' >> $GITHUB_STEP_SUMMARY
echo '${{ steps.deploy.outputs.deployment-url }}' >> $GITHUB_STEP_SUMMARY

- name: Comment PR
uses: thollander/actions-comment-pull-request@v3
if: github.event_name == 'pull_request'
with:
message: |
### Successful swap widget deployment 🚀🚀🚀
Well done!
Link to test environment:
${{ steps.deploy.outputs.deployment-url }}
comment-tag: swap_widget_deploy
Empty file.
3 changes: 3 additions & 0 deletions apps/web-swap-widget/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['../../.eslintrc.js']
};
25 changes: 25 additions & 0 deletions apps/web-swap-widget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

public/locales
46 changes: 46 additions & 0 deletions apps/web-swap-widget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
20 changes: 20 additions & 0 deletions apps/web-swap-widget/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en" style="--app-height:100vh;">
<head>
<meta charset="utf-8" />
<title>Tonkeeper Swap</title>
<meta name="description" content="Tonkeeper is the easiest way to store, send, and receive Toncoin on The Open Network.">

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no,viewport-fit=cover">

<link
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&amp;display=swap"
rel="stylesheet"
/>
</head>
<body style="background:#10161F;margin: 0;" class="top bottom">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
66 changes: 66 additions & 0 deletions apps/web-swap-widget/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "@tonkeeper/web-swap-widget",
"version": "3.0.0",
"author": "Ton APPS UK Limited <[email protected]>",
"description": "Web swap widget for Tonkeeper",
"dependencies": {
"@amplitude/analytics-browser": "^2.1.0",
"@aptabase/web": "^0.4.2",
"@tanstack/react-query": "4.3.4",
"@ton/core": "^0.56.0",
"@tonkeeper/core": "0.1.0",
"@tonkeeper/locales": "0.1.0",
"@tonkeeper/uikit": "0.1.0",
"buffer": "^6.0.3",
"copy-to-clipboard": "^3.3.3",
"i18next": "^22.1.4",
"i18next-browser-languagedetector": "^7.0.2",
"i18next-http-backend": "^2.0.2",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^12.1.1",
"styled-components": "^6.1.1"
},
"devDependencies": {
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^27.5.2",
"@types/node": "^20.11.0",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@types/styled-components": "^5.1.26",
"@vitejs/plugin-react": "^4.2.1",
"fs-extra": "^11.2.0",
"react-is": "^18.2.0",
"ts-node": "^10.9.1",
"typescript": "5.2.2",
"vite": "^5.0.11",
"vite-plugin-node-polyfills": "0.17.0"
},
"scripts": {
"locales": "ts-node ./task/locales",
"start": "yarn locales && vite dev",
"preview": "vite preview",
"build": "tsc && vite build && yarn locales",
"build:swap-widget": "yarn build"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"ts-standard": {
"project": "./tsconfig.json"
}
}
Binary file added apps/web-swap-widget/public/favicon.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 not shown.
Binary file not shown.
Binary file added apps/web-swap-widget/public/img/swap/dedust.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/web-swap-widget/public/img/swap/stonfi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions apps/web-swap-widget/public/img/toncoin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions apps/web-swap-widget/public/img/usdt.svg
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/web-swap-widget/public/logo-128x128.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/web-swap-widget/public/logo-16x16.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/web-swap-widget/public/logo-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions apps/web-swap-widget/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "Tonkeeper",
"name": "Tonkeeper Web",
"icons": [
{
"src": "favicon.png",
"type": "image/png",
"sizes": "32x32"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions apps/web-swap-widget/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Loading
Loading