-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from klntsky/sqlite2pglite
SQLite -> PGLite, tests, generators
- Loading branch information
Showing
104 changed files
with
2,661 additions
and
1,590 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [22.x] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install dependencies | ||
run: npm install tsx | ||
|
||
- name: Run tests | ||
run: npx tsx --test --test-reporter spec '**/tests/**/*.ts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
/logs/ | ||
/.vscode/ | ||
/public/ | ||
main.db | ||
/data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
# ton_2x | ||
# Ton 2x Bot | ||
|
||
Twice as simple. Trading tools for everyone! | ||
|
||
## Description | ||
|
||
Ton 2x Bot simplifies trading and helps users save money during the mass adoption era of cryptocurrency. | ||
It proactively notifies users of their gains via Telegram, making it easy to manage owned tokens and seize good exit opportunities. | ||
|
||
## Features | ||
|
||
- **Simplistic Mini App**: Designed for inexperienced users new to DeFi and those with limited capital who trade for fun. | ||
- **Telegram Notifications**: Automatic setup for price alerts, ensuring users stay informed without needing complicated instruments. | ||
- **Profit and Loss Tracker**: Tracks the price since the last purchase and notifies users when their tokens achieve a 2x gain or 0.5x loss, helping them make a profit and avoid losses. | ||
|
||
## How It Works | ||
|
||
1. Link your wallet to Ton 2x Bot. | ||
2. Receive proactive notifications in Telegram about your token gains. | ||
3. Make informed trading decisions with minimal effort. | ||
|
||
## Links | ||
|
||
- [Bot](https://t.me/ton_2x_bot) | ||
- [Announcements](https://t.me/ton_2x_en) | ||
- [Announcements in Russian](https://t.me/ton_2x_ru) | ||
- [DoraHack: Ton 2x Bot](https://dorahacks.io/buidl/13230) | ||
|
||
## Tests | ||
|
||
All tests are located in the [tests](./tests) directory. Currently, there is one unit test for the main business function: | ||
|
||
- [tests/getNotifications.test.ts](./tests/getNotifications.test.ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { defineConfig } from 'drizzle-kit'; | ||
|
||
export default defineConfig({ | ||
schema: './src/db/schema/index.ts', | ||
out: './src/db/migrations', | ||
dialect: 'sqlite', | ||
dbCredentials: { | ||
url: './main.db', | ||
}, | ||
}); | ||
schema: './src/db/schema/index.ts', | ||
out: './src/db/migrations', | ||
dialect: 'postgresql', | ||
dbCredentials: { | ||
url: 'file://data/postgresql', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"semi": true, | ||
"semi": false, | ||
"singleQuote": true, | ||
"jsxSingleQuote": false, | ||
"arrowParens": "avoid" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,70 @@ | ||
import { useEffect } from 'react'; | ||
import { Chart } from './Components/Chart'; | ||
import { useTonConnectModal, useTonConnectUI } from '@tonconnect/ui-react'; | ||
import { useEffect } from 'react' | ||
import { useTonConnectModal, useTonConnectUI } from '@tonconnect/ui-react' | ||
import { | ||
bindMiniAppCSSVars, | ||
bindThemeParamsCSSVars, | ||
useMiniApp, | ||
useThemeParams, | ||
} from '@tma.js/sdk-react'; | ||
import { retrieveLaunchParams } from '@tma.js/sdk'; | ||
import { usePostData } from './Hooks'; | ||
import { useParams } from 'react-router-dom'; | ||
} from '@tma.js/sdk-react' | ||
import { retrieveLaunchParams } from '@tma.js/sdk' | ||
|
||
function App() { | ||
const query = useParams(); | ||
const modal = useTonConnectModal(); | ||
const [tonConnectUI] = useTonConnectUI(); | ||
const themeParams = useThemeParams(); | ||
const miniApp = useMiniApp(); | ||
const { mutate } = usePostData(); | ||
miniApp.ready(); | ||
import { Chart } from './components/Chart' | ||
import { usePostData } from './hooks' | ||
|
||
export const App = () => { | ||
const launchParams = retrieveLaunchParams() | ||
if (!launchParams.initData?.user?.id) { | ||
throw new Error(`There is no user id in launchParams`) | ||
} | ||
const modal = useTonConnectModal() | ||
const [tonConnectUI] = useTonConnectUI() | ||
const themeParams = useThemeParams() | ||
const miniApp = useMiniApp() | ||
const { mutate } = usePostData() | ||
miniApp.ready() | ||
|
||
useEffect(() => { | ||
return bindMiniAppCSSVars(miniApp, themeParams); | ||
}, [miniApp, themeParams]); | ||
return bindMiniAppCSSVars(miniApp, themeParams) | ||
}, [miniApp, themeParams]) | ||
|
||
useEffect(() => { | ||
return bindThemeParamsCSSVars(themeParams); | ||
}, [themeParams]); | ||
return bindThemeParamsCSSVars(themeParams) | ||
}, [themeParams]) | ||
|
||
// useEffect(() => { | ||
// if (modal.state.status === 'closed') { | ||
// if (!query.address) { | ||
// modal.open(); | ||
// } | ||
// } else { | ||
// if (query.address) { | ||
// modal.close(); | ||
// } | ||
// if (modal.state.status === 'closed' && !tonConnectUI.account?.address) { | ||
// modal.open(); | ||
// } | ||
// }, [modal, modal.state.status, query.address]); | ||
// }, [modal.state.status]); | ||
|
||
useEffect(() => { | ||
if (!query.address) { | ||
modal.open(); | ||
} | ||
modal.open() | ||
|
||
tonConnectUI.onStatusChange(wallet => { | ||
const myURL = new URL(window.location.href); | ||
const launchParams = retrieveLaunchParams(); | ||
const launchParams = retrieveLaunchParams() | ||
console.log(123, { | ||
id: launchParams.initData?.user?.id, | ||
address: wallet?.account.address, | ||
}); | ||
if (query.address || !wallet?.account.address) return; | ||
myURL.searchParams.set('address', wallet.account.address); | ||
window.location.href = myURL.toString(); | ||
}) | ||
if (!wallet?.account.address) return | ||
mutate({ | ||
url: '/postUserWallet', | ||
data: { | ||
id: launchParams.initData?.user?.id, | ||
address: wallet?.account.address, | ||
}, | ||
}); | ||
}); | ||
}, []); | ||
}) | ||
}) | ||
}, []) | ||
|
||
return ( | ||
<div className="App"> | ||
<Chart /> | ||
{tonConnectUI.account?.address ? ( | ||
<Chart | ||
address={tonConnectUI.account.address} | ||
userId={launchParams.initData.user.id} | ||
/> | ||
) : null} | ||
</div> | ||
); | ||
) | ||
} | ||
|
||
export default App; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import s from './styles.module.css' | ||
|
||
export const Loader = () => { | ||
return <div className={s.loader}></div> | ||
} |
File renamed without changes.
Oops, something went wrong.