-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): add
/settings
api for settings shared with frontend (#…
…637) * feat(server): create api to return shared settings with client * feat(ui-ux): add lazy query for settings * feat(ui-ux): get txn fee from settings api
- Loading branch information
1 parent
8f4782b
commit 934b018
Showing
10 changed files
with
92 additions
and
5 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
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 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { SupportedDFCTokenSymbols, SupportedEVMTokenSymbols } from 'src/AppConfig'; | ||
|
||
import { SettingsModel } from './SettingsInterface'; | ||
|
||
@Controller('settings') | ||
export class SettingsController { | ||
constructor(private configService: ConfigService) {} | ||
|
||
@Get() | ||
public getSettings(): SettingsModel { | ||
const supportedDfcTokens = this.configService.getOrThrow('defichain.supportedTokens'); | ||
const supportedEvmTokens = this.configService.getOrThrow('ethereum.supportedTokens'); | ||
const settings = { | ||
defichain: { | ||
transferFee: this.configService.getOrThrow('defichain.transferFee') as `${number}`, | ||
supportedTokens: supportedDfcTokens.split(',') as Array<keyof typeof SupportedDFCTokenSymbols>, | ||
}, | ||
ethereum: { | ||
transferFee: this.configService.getOrThrow('ethereum.transferFee') as `${number}`, | ||
supportedTokens: supportedEvmTokens.split(',') as Array<keyof typeof SupportedEVMTokenSymbols>, | ||
}, | ||
}; | ||
|
||
return settings; | ||
} | ||
} |
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,11 @@ | ||
import { SupportedDFCTokenSymbols, SupportedEVMTokenSymbols } from 'src/AppConfig'; | ||
|
||
interface Settings { | ||
transferFee: `${number}` | number; | ||
supportedTokens: Array<keyof typeof SupportedEVMTokenSymbols | keyof typeof SupportedDFCTokenSymbols>; | ||
} | ||
|
||
export interface SettingsModel { | ||
defichain: Settings; | ||
ethereum: Settings; | ||
} |
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,8 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { SettingsController } from './SettingsController'; | ||
|
||
@Module({ | ||
controllers: [SettingsController], | ||
}) | ||
export class SettingsModule {} |
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
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