Skip to content

Commit

Permalink
Merge pull request #209 from napse-invest/dev
Browse files Browse the repository at this point in the history
fix(exchangeAccount): create fixed
  • Loading branch information
tomjeannesson authored Mar 12, 2024
2 parents 6cddcbf + b91ff7e commit 4d24339
Show file tree
Hide file tree
Showing 18 changed files with 218 additions and 84 deletions.
2 changes: 1 addition & 1 deletion desktop-app/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"semi": false,
"plugins": [
"prettier-plugin-tailwindcss",
"prettier-plugin-organize-imports"
"prettier-plugin-organize-imports"
]
}
6 changes: 1 addition & 5 deletions desktop-app/electron-builder.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
appId: com.example.nextron
productName: My Nextron App
productName: Napse
copyright: Copyright © 2018 Yoshihide Shiono
directories:
output: dist
Expand All @@ -10,8 +10,4 @@ files:
- package.json
- app

linux:
target: deb
icon: renderer/public/images/logo.svg

publish: null
9 changes: 6 additions & 3 deletions desktop-app/main/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (isProd) {
})
ipcMain.handle('fullCleanupAWS', async (event, args) => {
if (args.secrets) {
return await fullCleanupAWS(args.secrets, mainWindow)
return await fullCleanupAWS(args.secrets, args.deleteData, mainWindow)
}
})
ipcMain.handle('updateAWS', async (event, args) => {
Expand Down Expand Up @@ -83,9 +83,12 @@ if (isProd) {
EB_APP_NAME,
EB_ENV_NAME
)
if (environments) {
if (environments && environments.length > 0) {
for (const env of environments) {
if (env.Status != EnvironmentStatus.Ready) {
if (
env.Status != EnvironmentStatus.Terminated &&
env.Status != EnvironmentStatus.Ready
) {
allReady = false
break
}
Expand Down
25 changes: 19 additions & 6 deletions desktop-app/main/helpers/aws/deployToAWS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,27 @@ import {
} from 'main/helpers'
import path from 'path'

export const EB_BUCKET_NAME = 'napse-eb-bucket'
export const EB_APP_NAME = 'napse'
export const EB_BUCKET_NAME = `napse-eb-bucket${
process.env.NODE_ENV === 'production' ? '' : '-dev'
}`
export const EB_APP_NAME = `napse${
process.env.NODE_ENV === 'production' ? '' : '-dev'
}`
export const EB_APP_DESCRIPTION = 'No description'
export const EB_ENV_NAME = 'napse-env'
export const IAM_ROLE_NAME_SERVICE_ROLE = 'napse-iam-service-role'
export const IAM_ROLE_NAME_EC2_ROLE = 'napse-iam-ec2-role'
export const IAM_INSTANCE_PROFILE_NAME = 'napse-iam-instance-profile'
export const EB_ENV_NAME = `napse-env${
process.env.NODE_ENV === 'production' ? '' : '-dev'
}`
export const IAM_ROLE_NAME_SERVICE_ROLE = `napse-iam-service-role${
process.env.NODE_ENV === 'production' ? '' : '-dev'
}`
export const IAM_ROLE_NAME_EC2_ROLE = `napse-iam-ec2-role${
process.env.NODE_ENV === 'production' ? '' : '-dev'
}`
export const IAM_INSTANCE_PROFILE_NAME = `napse-iam-instance-profile${
process.env.NODE_ENV === 'production' ? '' : '-dev'
}`

console.log('EB_BUCKET_NAME', EB_BUCKET_NAME)
export default async function Main(
secrets: {
AWS__API_TOKEN: string
Expand Down
7 changes: 5 additions & 2 deletions desktop-app/main/helpers/aws/fullCleanupAWS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default async function Main(
AWS__API_SECRET: string
AWS__REGION: string
},
deleteData: boolean,
mainWindow: BrowserWindow
) {
updateStatus(mainWindow, 'fullReset', 'START')
Expand Down Expand Up @@ -101,7 +102,9 @@ export default async function Main(
await deleteIAMRole(secrets, mainWindow, IAM_ROLE_NAME_SERVICE_ROLE)
updateStatus(mainWindow, 'fullReset', 'deleteEBApp')
await deleteEBApp(secrets, mainWindow, EB_APP_NAME)
updateStatus(mainWindow, 'fullReset', 'deleteBucket')
await deleteBucket(secrets, mainWindow, EB_BUCKET_NAME)
if (deleteData) {
updateStatus(mainWindow, 'fullReset', 'deleteBucket')
await deleteBucket(secrets, mainWindow, EB_BUCKET_NAME)
}
updateStatus(mainWindow, 'fullReset', 'END')
}
5 changes: 3 additions & 2 deletions desktop-app/main/helpers/utils/updateStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const SATUS = {
busy: true
},
END: {
description: 'Full reset complete, see you soon!',
description: 'Reset complete, see you soon!',
busy: false
}
}
Expand All @@ -219,6 +219,7 @@ export default async function Main<T extends keyof typeof SATUS>(
busy: errorMessage ? false : (SATUS[stage][step] as StatusStep).busy,
progress: (index / (Object.keys(SATUS[stage]).length - 1)) * 100,
errorMessage: errorMessage,
extraData: extraData
extraData: extraData,
step: step
})
}
8 changes: 7 additions & 1 deletion desktop-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
"name": "napse",
"description": "Napse Desktop App",
"homepage": "https://napse-invest.com",
"version": "1.0.0",
"version": "1.4.0",
"author": "Napse Invest <napse.invest@gmail.com>",
"main": "app/background.js",
"scripts": {
"start": "nextron",
"build": "nextron build",
"build:mac": "nextron build --mac",
"build:mac:universal": "nextron build --mac --universal",
"build:linux": "nextron build --linux",
"build:win32": "nextron build --win --ia32",
"build:win64": "nextron build --win --x64",
"build:all": "nextron build --mac --linux --win --x64",
"postinstall": "electron-builder install-app-deps",
"lint": "next lint"
},
Expand Down
5 changes: 4 additions & 1 deletion desktop-app/renderer/api/exchangeAccounts/exchangeAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ export interface BaseExchangeAccount {
description: string
exchange: string
testing: boolean
privateKey: string
publicKey: string
}
export interface ExchangeAccount extends BaseExchangeAccount {
uuid: string
}
export interface RetreivedExchangeAccount extends ExchangeAccount {}
export interface RetreivedExchangeAccount
extends Omit<Omit<ExchangeAccount, 'privateKey'>, 'publicKey'> {}

export async function getExchangeAccount(
searchParams: ReturnType<typeof useSearchParams>,
Expand Down
10 changes: 7 additions & 3 deletions desktop-app/renderer/components/custom/selectedObject/inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,14 @@ export default function CustomForm<T extends Object>({
) : (
<Button
type="submit"
onClick={(e) => {
console.log('props', e)
onClick={async (e) => {
setIsLoading(true)
return form.handleSubmit(onSubmit)(e)
const submit = form.handleSubmit(onSubmit)(e)

await new Promise((resolve) => setTimeout(resolve, 400))
setIsLoading(false)

return submit
}}
>
{buttonDescription ?? 'Submit'}
Expand Down
5 changes: 3 additions & 2 deletions desktop-app/renderer/components/layout/breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ExchangeAccount,
RetreivedExchangeAccount,
getExchangeAccount
} from '@/api/exchangeAccounts/exchangeAccount'
import { RetrievedNapseSpace, retrieveSpace } from '@/api/spaces/spaces'
Expand All @@ -22,7 +22,8 @@ export default function BreadcrumbLayout() {
const bot = searchParams.get('bot') || ''
const server = getServer(serverID)

const [exchangeAccount, setExchangeAccount] = useState<ExchangeAccount>()
const [exchangeAccount, setExchangeAccount] =
useState<RetreivedExchangeAccount>()
useEffect(() => {
const fetchData = async () => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const defaultExchangeAccount: BaseExchangeAccount = {
name: 'My Exchange Account',
description: 'My Exchange Account Description',
testing: true,
exchange: 'BINANCE'
exchange: 'BINANCE',
privateKey: '',
publicKey: ''
}

export default function CreateExchangeAccountDialog({
Expand All @@ -41,9 +43,7 @@ export default function CreateExchangeAccountDialog({
}): JSX.Element {
const searchParams = useSearchParams()
const [possibleExchanges, setPossibleExchanges] = useState<string[]>([])
const [exchangeAccount, setExchangeAccount] = useState<BaseExchangeAccount>(
defaultExchangeAccount
)

useEffect(() => {
const fetchPossibleExchanges = async () => {
try {
Expand Down Expand Up @@ -118,6 +118,20 @@ export default function CreateExchangeAccountDialog({
type: 'switch',
zod: z.boolean(),
default: defaultExchangeAccount.testing
},
{
label: 'Public API Key',
key: 'publicKey',
type: 'input',
zod: z.string(),
default: defaultExchangeAccount.publicKey
},
{
label: 'Private API Key',
key: 'privateKey',
type: 'input',
zod: z.string(),
default: defaultExchangeAccount.privateKey
}
]}
onSubmit={async (values) => {
Expand Down
Loading

0 comments on commit 4d24339

Please sign in to comment.