Skip to content

Commit

Permalink
feat(types): updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Pautov committed Oct 28, 2021
1 parent d95830c commit df0733c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lifinance/types",
"version": "0.0.9",
"version": "0.1.0",
"description": "Types for lifi projects",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,15 +632,15 @@ export const supportedChains: Array<Chain> = [
// https://faucet.buni.finance/
]

export const getChainByKey = (chainKey: ChainKey): Chain => {
export const getChainByKey = (chainKey: ChainKey) => {
const chain = supportedChains.find((chain) => chain.key === chainKey)
if (!chain) {
throw new Error('Invalid chainKey')
}
return chain
}

export const getChainById = (chainId: number): Chain => {
export const getChainById = (chainId: number) => {
const chain = supportedChains.find((chain) => chain.id === chainId)
if (!chain) {
throw new Error('Invalid chainId')
Expand Down
7 changes: 4 additions & 3 deletions src/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ export const defaultCoins: Array<Coin> = [
},
]

export const findDefaultCoin = (coinKey: CoinKey): Coin => {
export const findDefaultCoin = (coinKey: CoinKey) => {
const coin = defaultCoins.find((coin) => coin.key === coinKey)
if (!coin) {
throw new Error('Invalid Coin')
Expand All @@ -970,9 +970,10 @@ export const findDefaultCoin = (coinKey: CoinKey): Coin => {
export const findDefaultCoinOnChain = (
coinKey: CoinKey,
chainKey: ChainKey
): Token => {
) => {
const coin = findDefaultCoin(coinKey)
return coin.chains[chainKey]
const token = coin.chains[chainKey]
return token
}

export const defaultTokens: { [ChainKey: string]: Array<Token> } = {
Expand Down
22 changes: 14 additions & 8 deletions src/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ export interface BaseEstimate {
}
}

export type DepositEstimate = BaseEstimate
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DepositEstimate extends BaseEstimate {}

export interface SwapEstimate extends BaseEstimate {
type: 'swap'
data: unknown
toAmountMin: string
data: any
}

export interface CrossEstimate extends BaseEstimate {
type: 'cross'
data: unknown
data: any
}

export type WithdrawEstimate = BaseEstimate
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface WithdrawEstimate extends BaseEstimate {}

export interface FailedEstimate {
type: 'error'
Expand All @@ -47,7 +50,7 @@ export type Status =
| 'FAILED'
| 'DONE'

type AcceptableMessages = string | unknown
type AcceptableMessages = string | any
export type ProcessMessage =
| AcceptableMessages
| { message: AcceptableMessages; footer: AcceptableMessages }
Expand All @@ -56,13 +59,13 @@ export interface Process {
startedAt: number
doneAt?: number
failedAt?: number
errorMessage?: unknown
errorCode?: unknown
errorMessage?: any
errorCode?: any
message: ProcessMessage
status: Status

// additional information
[key: string]: unknown
[key: string]: any
}

export interface Execution {
Expand All @@ -76,6 +79,7 @@ export const emptyExecution: Execution = {
status: 'NOT_STARTED',
process: [],
}

// ACTION
interface ActionBase {
type: string
Expand All @@ -91,12 +95,14 @@ export interface DepositAction extends ActionBase {
export interface WithdrawAction extends ActionBase {
type: 'withdraw'
toAddress: string
slippage: number
}

export interface SwapAction extends ActionBase {
type: 'swap'
tool: string
toToken: Token
slippage: number
}

export interface CrossAction extends ActionBase {
Expand Down

0 comments on commit df0733c

Please sign in to comment.