Skip to content

Commit

Permalink
chore: remove ui-shared package
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Oct 18, 2024
1 parent 00750ae commit 1ad9ace
Show file tree
Hide file tree
Showing 278 changed files with 621 additions and 19,043 deletions.
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn --cwd ./packages/ui-shared lint-staged
yarn --cwd ./layer lint-staged
3 changes: 2 additions & 1 deletion layer/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
root: true,
extends: ['@nuxt/eslint-config', '@injectivelabs/eslint-config'],
extends: ['@injectivelabs/eslint-config'],
rules: {
'import/order': 'off',
'vue/max-attributes-per-line': 'off'
}
}
4 changes: 2 additions & 2 deletions layer/composables/useSharedBigNumberFormatted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function useSharedBigNumberFormatter(

const valueToFixed = computed(() => {
if (valueToBigNumber.value.isNaN() || valueToBigNumber.value.isZero()) {
return !!options.shouldTruncate
return !options.shouldTruncate
? '0'
: getFormattedZeroValue(decimalPlaces.value)
}
Expand All @@ -171,7 +171,7 @@ export function useSharedBigNumberFormatter(

const valueToString = computed(() => {
if (valueToBigNumber.value.isNaN() || valueToBigNumber.value.isZero()) {
return !!options.shouldTruncate
return !options.shouldTruncate
? '0'
: getFormattedZeroValue(decimalPlaces.value)
}
Expand Down
4 changes: 2 additions & 2 deletions layer/data/ibc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const canonicalChannelsToChainList = [
{ channelId: 'channel-183', chainA: 'Injective', chainB: 'Gateway' },
{ channelId: 'channel-213', chainA: 'Injective', chainB: 'Andromeda' },
{ channelId: 'channel-261', chainA: 'Injective', chainB: 'Saga' },
{ channelId: 'channel-283', chainA: 'Injective', chainB: 'fetchhub-4' },
{ channelId: 'channel-283', chainA: 'Injective', chainB: 'fetchhub-4' }
]

export const canonicalChannelIds = [
Expand Down Expand Up @@ -82,5 +82,5 @@ export const canonicalChannelIds = [
'channel-183',
'channel-213',
'channel-261',
'channel-283',
'channel-283'
]
1 change: 1 addition & 0 deletions layer/nuxt-config/bugsnag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const bugsnagConfig = {
}
}

// eslint-disable-next-line no-console
console.log(
`Instantiating bugsnag: ${shouldInstantiateBugsnag}`,
'\n',
Expand Down
4 changes: 2 additions & 2 deletions layer/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createResolver } from '@nuxt/kit'
import { defineNuxtConfig } from 'nuxt/config'
import { vite } from './nuxt-config'
import { createResolver } from '@nuxt/kit'
import bugsnag from './nuxt-config/bugsnag'
import { vitePlugins } from './nuxt-config/vite'

Expand Down Expand Up @@ -41,6 +41,6 @@ export default defineNuxtConfig({
client: true
},

//@ts-ignore
// @ts-ignore
bugsnag
})
6 changes: 6 additions & 0 deletions layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
"@pinia/nuxt": "^0.4.11",
"@types/fs-extra": "^11.0.1",
"eslint": "8.37.0",
"lint-staged": "13.2.3",
"nuxt": "3.13.2",
"typescript": "5.5.4",
"vite-tsconfig-paths": "^4.2.0"
},
"lint-staged": {
"**/*.{js,ts,vue}": [
"eslint --max-warnings 0 --no-ignore --fix"
]
}
}
4 changes: 2 additions & 2 deletions layer/pages/sandbox.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { ref, computed, onMounted } from 'vue'
import { ref, onMounted } from 'vue'
const iconsList = ref<string[]>([])
Expand All @@ -15,9 +15,9 @@ onMounted(() => {
<template>
<article class="px-4 grid md:grid-cols-4 grid-cols-6 gap-4">
<div
class="flex flex-col justify-center items-center py-4"
v-for="icon in iconsList"
:key="icon"
class="flex flex-col justify-center items-center py-4"
>
<SharedIcon :name="icon" />
<span>{{ icon }}</span>
Expand Down
2 changes: 1 addition & 1 deletion layer/plugins/tracking.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import VueGtag from 'vue-gtag'
import hotjar from 'vue-hotjar'
import { defineNuxtPlugin } from '#imports'
import { HOTJAR_KEY, GOOGLE_ANALYTICS_KEY } from './../utils/constant'
import { defineNuxtPlugin } from '#imports'

export default defineNuxtPlugin((nuxtApp) => {
if (GOOGLE_ANALYTICS_KEY) {
Expand Down
2 changes: 1 addition & 1 deletion layer/providers/cacheApi/derivative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
ExpiryFuturesMarket,
AllChronosDerivativeMarketSummary
} from '@injectivelabs/sdk-ts'
import { BaseCacheApi } from './base'
import {
indexerDerivativesApi,
indexerRestDerivativeChronosApi
} from '../../Service'
import { BaseCacheApi } from './base'
import { IS_MAINNET } from './../../utils/constant'

export class DerivativeCacheApi extends BaseCacheApi {
Expand Down
4 changes: 2 additions & 2 deletions layer/providers/cacheApi/spot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SpotMarket, AllChronosSpotMarketSummary } from '@injectivelabs/sdk-ts'
import { BaseCacheApi } from './base'
import { IS_MAINNET } from './../../utils/constant'
import { indexerRestSpotChronosApi, indexerSpotApi } from '../../Service'
import { IS_MAINNET } from './../../utils/constant'
import { BaseCacheApi } from './base'

export class SpotCacheApi extends BaseCacheApi {
async fetchMarkets() {
Expand Down
2 changes: 1 addition & 1 deletion layer/providers/cacheApi/staking.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Pagination, Validator } from '@injectivelabs/sdk-ts'
import { BaseCacheApi } from './base'
import { stakingApi } from '../../Service'
import { IS_MAINNET } from './../../utils/constant'
import { BaseCacheApi } from './base'

export class StakingCacheApi extends BaseCacheApi {
async fetchValidators(_params?: any) {
Expand Down
2 changes: 1 addition & 1 deletion layer/providers/cacheApi/token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Pagination, TotalSupply } from '@injectivelabs/sdk-ts'
import { BaseCacheApi } from './base'
import { bankApi } from '../../Service'
import { BaseCacheApi } from './base'
import { IS_MAINNET } from './../../utils/constant'

export class TokenCacheApi extends BaseCacheApi {
Expand Down
7 changes: 3 additions & 4 deletions layer/services/Web3Client.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Network, isTestnetOrDevnet } from '@injectivelabs/networks'
import { BigNumberInWei } from '@injectivelabs/utils'
import { Web3Exception } from '@injectivelabs/exceptions'
import { injToken } from '../data/token'
import { Alchemy, Network as AlchemyNetwork } from 'alchemy-sdk'
import { injToken, injErc20Token, injectivePeggyAddress } from '../data/token'
import { getKeyFromRpcUrl, peggyDenomToContractAddress } from './utils'
import { injErc20Token, injectivePeggyAddress } from '../data/token'

/**
* Preparing and broadcasting
Expand Down Expand Up @@ -43,7 +42,7 @@ export class Web3Client {
}

try {
const alchemy = await this.getAlchemy()
const alchemy = this.getAlchemy()
const ethersProvider = await alchemy.config.getProvider()
const tokenAddress = peggyDenomToContractAddress(contractAddress)
const tokenContractAddress =
Expand Down Expand Up @@ -103,7 +102,7 @@ export class Web3Client {
}
}

private async getAlchemy() {
private getAlchemy() {
if (this.alchemy) {
return this.alchemy
}
Expand Down
14 changes: 7 additions & 7 deletions layer/services/bonfida/InjBonfidaNameService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { GeneralException } from '@injectivelabs/exceptions'
import {
Network,
NetworkEndpoints,
getNetworkEndpoints,
getNetworkEndpoints
} from '@injectivelabs/networks'
import {
toBase64,
binaryToBase64,
ChainGrpcWasmApi,
ChainGrpcWasmApi
} from '@injectivelabs/sdk-ts'
import { getBonfidaContractAddress } from './utils'

Expand All @@ -18,7 +18,7 @@ export class InjBonfidaNameService {

constructor(
network: Network = Network.MainnetSentry,
endpoints?: NetworkEndpoints,
endpoints?: NetworkEndpoints
) {
const networkEndpoints = endpoints || getNetworkEndpoints(network)

Expand All @@ -29,20 +29,20 @@ export class InjBonfidaNameService {
async fetchInjAddress(name: string) {
const query = {
resolve: {
domain_name: name.replace('.sol', ''),
},
domain_name: name.replace('.sol', '')
}
}
const response = await this.client.fetchSmartContractState(
this.contractAddress,
toBase64(query),
toBase64(query)
)

return Buffer.from(binaryToBase64(response.data), 'base64')
.toString()
.replace(/["]/g, '')
}

async fetchInjName(_address: string) {
fetchInjName(_address: string) {
throw new GeneralException(new Error(`Not suported for this name service`))
}
}
1 change: 0 additions & 1 deletion layer/services/ethGasPrice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface EthGasStationResult {
safeLowWait: number
blockNum: number
avgWait: number
// eslint-disable-next-line camelcase
block_time: number
speed: number
fastest: number
Expand Down
2 changes: 1 addition & 1 deletion layer/services/nameService/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const validateName = (name: string) => {
}

const blackList =
// eslint-disable-next-line no-control-regex,no-misleading-character-class
// eslint-disable-next-line no-control-regex,no-misleading-character-class,unicorn/escape-case
/[\u0000-\u002c\u002e-\u002f\u003a-\u005e\u0060\u007b-\u007f\u200b\u200c\u200d\ufeff]/g

if (blackList.test(name)) {
Expand Down
16 changes: 7 additions & 9 deletions layer/services/pythClient.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
HttpRestClient,
} from '@injectivelabs/utils'
/* eslint-disable camelcase, no-console */
import { HttpRestClient } from '@injectivelabs/utils'

const PYTH_SERVICE_URL = 'https://benchmarks.pyth.network/v1/'

export class PythService {
private restClient: HttpRestClient


constructor() {
this.restClient = new HttpRestClient(PYTH_SERVICE_URL)
}
Expand All @@ -16,15 +14,15 @@ export class PythService {
try {
const {
data: {
market_hours: { is_open },
market_hours: { is_open }
}
} = (await this.restClient.get(`price_feeds/${pythId}`)) as {
data: {
market_hours: {
is_open: boolean;
};
};
};
is_open: boolean
}
}
}

return is_open
} catch (e: unknown) {
Expand Down
26 changes: 13 additions & 13 deletions layer/services/tokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class SharedTokenClient {
private cachedInsuranceFunds: InsuranceFund[] = []
private cachedTokens: Record<string, TokenStatic> = {}

constructor() {}
// constructor() {}

async queryToken(denom: string): Promise<TokenStatic | undefined> {
const cachedToken = this.cachedTokens[denom.toLowerCase()]
Expand All @@ -32,15 +32,15 @@ export class SharedTokenClient {
}

if (denom.startsWith('share')) {
return this.#getInsuranceToken(denom)
return await this.#getInsuranceToken(denom)
}

if (denom.startsWith('peggy') || denom.startsWith('0x')) {
return this.#getPeggyToken(denom)
return await this.#getPeggyToken(denom)
}

if (denom.startsWith('ibc')) {
return this.#getIbcToken(denom)
return await this.#getIbcToken(denom)
}

if (denom.startsWith('factory')) {
Expand All @@ -51,13 +51,11 @@ export class SharedTokenClient {
}

if (isCw20ContractAddress(contractAddress)) {
return this.#getCw20Token(denom)
return await this.#getCw20Token(denom)
}

return this.#getTokenFactoryToken(denom)
return await this.#getTokenFactoryToken(denom)
}

return
}

async #getIbcToken(denom: string): Promise<TokenStatic | undefined> {
Expand Down Expand Up @@ -142,19 +140,21 @@ export class SharedTokenClient {
const defaultToken = {
...unknownToken,
denom,
address: address
address
}

const contractInfo = (await wasmApi
.fetchContractInfo(address)
.catch(() => {})) as ContractInfo | undefined
const contractInfo = (await wasmApi.fetchContractInfo(address).catch(() => {
// silently fail
})) as ContractInfo | undefined

const contractStateResponse = (await wasmApi
.fetchContractState({
contractAddress: address,
pagination: { reverse: true }
})
.catch(() => {})) as ContractStateWithPagination | undefined
.catch(() => {
// silently fail
})) as ContractStateWithPagination | undefined

if (
!contractStateResponse ||
Expand Down
2 changes: 1 addition & 1 deletion layer/services/tokenPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class TokenPrice {
*/
const response = await Promise.all(
chunks.map(async (chunk, index) => {
let prices = {} as Record<string, number>
const prices = {} as Record<string, number>

for (let i = 0; i < chunk.length; i += 1) {
const price = await this.fetchUsdTokenPriceFromCoinGeckoNoThrow(
Expand Down
2 changes: 1 addition & 1 deletion layer/store/geo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const useSharedGeoStore = defineStore('sharedGeo', {
}
},

async showVpnToast(docLink?: string) {
showVpnToast(docLink?: string) {
const sharedNotificationStore = useSharedNotificationStore()

sharedNotificationStore.info({
Expand Down
Loading

0 comments on commit 1ad9ace

Please sign in to comment.