Skip to content

Commit 259a872

Browse files
authored
🔧 Use runtime config for constant (#181)
1 parent 6c5d581 commit 259a872

37 files changed

+213
-175
lines changed

‎.env

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
IS_TESTNET=TRUE
2+
3+
SITE_URL=https://likecoin-nft-book-press-testnet.netlify.app
4+
5+
CHAIN_ID=likecoin-public-testnet-5
6+
CHAIN_NAME=LikeCoin public test chain
7+
CHAIN_DENOM=EKIL
8+
CHAIN_MINIMAL_DENOM=nanoekil
9+
COINGECKO_ID=| undefined
10+
RPC_URL=https://node.testnet.like.co/rpc/
11+
LCD_URL=https://node.testnet.like.co
12+
CHAIN_EXPLORER_URL=https://node.testnet.like.co/cosmos/tx/v1beta1/txs
13+
14+
LIKER_NFT_FEE_WALLET=like1yney2cqn5qdrlc50yr5l53898ufdhxafqz9gxp
15+
LIKER_NFT_TARGET_ADDRESS=like1yney2cqn5qdrlc50yr5l53898ufdhxafqz9gxp
16+
17+
AUTHCORE_API_HOST=https://likecoin-integration-test.authcore.io
18+
LIKER_LAND_URL=https://rinkeby.liker.land
19+
LIKE_CO_HOST=https://rinkeby.like.co
20+
LIKE_CO_API=https://api.rinkeby.like.co
21+
APP_LIKE_CO_URL=https://app.rinkeby.like.co
22+
NFT_MARKETPLACE_URL=https://likecoin-nft-marketplace-testnet.netlify.app
23+
ISCN_TOOLS_URL=https://likecoin-iscn-nft-tools-testnet.netlify.app

‎.env.production

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
IS_TESTNET=FALSE
2+
3+
SITE_URL=https://likecoin.github.io/nft-book-press
4+
5+
CHAIN_ID=likecoin-mainnet-2
6+
CHAIN_NAME=LikeCoin
7+
CHAIN_DENOM=LIKE
8+
CHAIN_MINIMAL_DENOM=nanolike
9+
COINGECKO_ID=likecoin
10+
RPC_URL=https://mainnet-node.like.co/rpc/
11+
LCD_URL=https://mainnet-node.like.co
12+
CHAIN_EXPLORER_URL=https://ping.pub/likecoin/tx
13+
14+
LIKER_NFT_FEE_WALLET=like10ywsmztkxjl55xarxnhlxwc83z9v2hkxtsajwl
15+
LIKER_NFT_TARGET_ADDRESS=like17m4vwrnhjmd20uu7tst7nv0kap6ee7js69jfrs
16+
17+
AUTHCORE_API_HOST=https://authcore.like.co
18+
LIKER_LAND_URL=https://liker.land
19+
LIKE_CO_HOST=https://like.co
20+
LIKE_CO_API=https://api.like.co
21+
APP_LIKE_CO_URL=https://app.like.co
22+
NFT_MARKETPLACE_URL=https://likecoin.github.io/likecoin-nft-marketplace
23+
ISCN_TOOLS_URL=https://likecoin.github.io/iscn-nft-tools

‎.github/workflows/cd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: yarn
2828

2929
- name: Generate
30-
run: NUXT_APP_BASE_URL=/${{ github.event.repository.name }}/ yarn generate
30+
run: NUXT_APP_BASE_URL=/${{ github.event.repository.name }}/ yarn generate:production
3131

3232
- name: Deploy
3333
uses: peaceiris/actions-gh-pages@v3

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ node_modules
44
.nitro
55
.cache
66
.output
7-
.env
87
dist
98
.DS_Store

‎README.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,41 @@ Make sure to install the dependencies:
99
```bash
1010
# yarn
1111
yarn install
12-
13-
# npm
14-
npm install
15-
16-
# pnpm
17-
pnpm install
1812
```
1913

2014
## Development Server
2115

22-
Start the development server on `http://localhost:3000`
16+
Start the development server on `http://localhost:3000`:
17+
18+
```bash
19+
yarn dev
20+
```
2321

22+
Run in production config:
2423
```bash
25-
npm run dev
24+
yarn dev:production
2625
```
2726

2827
## Production
2928

3029
Build the application for production:
3130

3231
```bash
33-
npm run build
32+
yarn build:production
3433
```
3534

3635
Locally preview production build:
3736

3837
```bash
39-
npm run preview
38+
yarn preview
39+
```
40+
41+
### Static Site
42+
43+
Build the application for static site hosting (e.g. Netlify):
44+
45+
```bash
46+
yarn generate:production
4047
```
4148

4249
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

‎components/SiteMenu.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</template>
3737

3838
<script setup lang="ts">
39-
import { ISCN_TOOLS_URL } from '~/constant'
39+
const { ISCN_TOOLS_URL } = useRuntimeConfig().public
4040
4141
const props = defineProps({
4242
isLarge: {

‎components/SiteNavigation.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
:to="{ name: 'index' }"
99
/>
1010
<UBadge
11-
v-if="IS_TESTNET"
11+
v-if="isTestnet"
1212
label="TESTNET"
1313
variant="subtle"
1414
color="amber"
@@ -25,5 +25,5 @@
2525
</template>
2626

2727
<script setup lang="ts">
28-
import { IS_TESTNET } from '~/constant'
28+
const isTestnet = getIsTestnet()
2929
</script>

‎components/StripeConnectCard.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@
141141
</template>
142142

143143
<script setup lang="ts">
144-
import { LIKE_ADDRESS_REGEX, LIKE_CO_API } from '~/constant'
144+
import { LIKE_ADDRESS_REGEX } from '~/constant'
145145
import { useStripeStore } from '~/stores/stripe'
146146
147+
const { LIKE_CO_API } = useRuntimeConfig().public
148+
147149
const stripeStore = useStripeStore()
148150
149151
const { fetchStripeConnectStatus } = stripeStore

‎constant/index.ts

-34
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,7 @@
1-
export const IS_TESTNET = false
2-
3-
export const SITE_URL = IS_TESTNET ? 'https://likecoin-nft-book-press-testnet.netlify.app' : 'https://likecoin.github.io/nft-book-press'
4-
5-
export const CHAIN_ID = IS_TESTNET
6-
? 'likecoin-public-testnet-5'
7-
: 'likecoin-chain-2'
8-
export const RPC_URL = IS_TESTNET
9-
? 'https://node.testnet.like.co/rpc/'
10-
: 'https://mainnet-node.like.co/rpc/'
11-
export const LCD_URL = IS_TESTNET
12-
? 'https://node.testnet.like.co'
13-
: 'https://mainnet-node.like.co'
14-
export const LIKER_LAND_HOST = `${IS_TESTNET ? 'rinkeby.' : ''}liker.land`
15-
16-
export const LIKER_NFT_FEE_WALLET = IS_TESTNET
17-
? 'like1yney2cqn5qdrlc50yr5l53898ufdhxafqz9gxp'
18-
: 'like10ywsmztkxjl55xarxnhlxwc83z9v2hkxtsajwl'
19-
20-
export const LIKER_NFT_TARGET_ADDRESS = IS_TESTNET
21-
? 'like1yney2cqn5qdrlc50yr5l53898ufdhxafqz9gxp'
22-
: 'like17m4vwrnhjmd20uu7tst7nv0kap6ee7js69jfrs'
23-
24-
export const LIKE_CO_HOST = `https://${IS_TESTNET ? 'rinkeby.' : ''}like.co`
25-
export const LIKE_CO_API = `https://api.${IS_TESTNET ? 'rinkeby.' : ''}like.co`
26-
export const APP_LIKE_CO_URL = `https://app.${IS_TESTNET ? 'rinkeby.' : ''}like.co`
27-
export const LIKER_LAND_URL = `https://${LIKER_LAND_HOST}`
28-
291
export const ARWEAVE_ENDPOINT = 'https://arweave.net'
302

313
export const IPFS_VIEW_GATEWAY_URL = 'https://ipfs.io/ipfs'
324

33-
export const CHAIN_EXPLORER_URL = IS_TESTNET ? 'https://node.testnet.like.co/cosmos/tx/v1beta1/txs' : 'https://ping.pub/likecoin/tx'
34-
35-
export const NFT_MARKETPLACE_URL = IS_TESTNET ? 'https://likecoin-nft-marketplace-testnet.netlify.app' : 'https://likecoin.github.io/likecoin-nft-marketplace'
36-
37-
export const ISCN_TOOLS_URL = IS_TESTNET ? 'https://likecoin-iscn-nft-tools-testnet.netlify.app' : 'https://likecoin.github.io/iscn-nft-tools'
38-
395
export const MINIMAL_PRICE = 0.99
406
export const DEFAULT_PRICE = 4.99
417

‎constant/network.ts

-95
This file was deleted.

‎nuxt.config.ts

+27
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,33 @@ export default defineNuxtConfig({
2929
}
3030
}
3131
},
32+
runtimeConfig: {
33+
public: {
34+
IS_TESTNET: process.env.IS_TESTNET,
35+
36+
SITE_URL: process.env.SITE_URL,
37+
38+
CHAIN_ID: process.env.CHAIN_ID,
39+
CHAIN_NAME: process.env.CHAIN_NAME,
40+
CHAIN_DENOM: process.env.CHAIN_DENOM,
41+
CHAIN_MINIMAL_DENOM: process.env.CHAIN_MINIMAL_DENOM,
42+
COINGECKO_ID: process.env.COINGECKO_ID,
43+
RPC_URL: process.env.RPC_URL,
44+
LCD_URL: process.env.LCD_URL,
45+
CHAIN_EXPLORER_URL: process.env.CHAIN_EXPLORER_URL,
46+
47+
LIKER_NFT_FEE_WALLET: process.env.LIKER_NFT_FEE_WALLET,
48+
LIKER_NFT_TARGET_ADDRESS: process.env.LIKER_NFT_TARGET_ADDRESS,
49+
50+
AUTHCORE_API_HOST: process.env.AUTHCORE_API_HOST,
51+
LIKER_LAND_URL: process.env.LIKER_LAND_URL,
52+
LIKE_CO_HOST: process.env.LIKE_CO_HOST,
53+
LIKE_CO_API: process.env.LIKE_CO_API,
54+
APP_LIKE_CO_URL: process.env.APP_LIKE_CO_URL,
55+
NFT_MARKETPLACE_URL: process.env.NFT_MARKETPLACE_URL,
56+
ISCN_TOOLS_URL: process.env.ISCN_TOOLS_URL
57+
}
58+
},
3259
app: {
3360
pageTransition: { name: 'page', mode: 'out-in' },
3461
layoutTransition: { name: 'page', mode: 'out-in' }

‎package.json

+3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
},
66
"scripts": {
77
"build": "nuxt build",
8+
"build:production": "nuxt build --dotenv .env.production",
89
"dev": "nuxt dev",
10+
"dev:production": "nuxt dev --dotenv .env.production",
911
"generate": "nuxt generate",
12+
"generate:production": "nuxt generate --dotenv .env.production",
1013
"lint": "eslint . --ext \".js,.vue,.ts\" --fix",
1114
"preview": "nuxt preview",
1215
"postinstall": "nuxt prepare"

‎pages/affiliation-link.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,11 @@
206206

207207
<script setup lang="ts">
208208
import { type FileExtension } from '@likecoin/qr-code-styling'
209-
import { AFFILIATION_CHANNELS, LIKE_CO_API } from '~/constant'
209+
import { AFFILIATION_CHANNELS } from '~/constant'
210210
import { useCollectionStore } from '~/stores/collection'
211211
import { getPurchaseLink } from '~/utils'
212212
213+
const { LIKE_CO_API } = useRuntimeConfig().public
213214
const collectionStore = useCollectionStore()
214215
const route = useRoute()
215216
const router = useRouter()

‎pages/mint-nft/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,9 @@ import { stringify } from 'csv-stringify/sync'
412412
import type { FormError } from '#ui/types'
413413
414414
import { useWalletStore } from '~/stores/wallet'
415-
import { LCD_URL, APP_LIKE_CO_URL, LIKER_LAND_URL } from '~/constant'
416415
import { downloadFile, convertArrayOfObjectsToCSV, sleep } from '~/utils'
417416
417+
const { LCD_URL, APP_LIKE_CO_URL, LIKER_LAND_URL } = useRuntimeConfig().public
418418
const router = useRouter()
419419
const route = useRoute()
420420

‎pages/nft-book-store/collection/new.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ import { MdEditor, ToolbarNames, config } from 'md-editor-v3'
425425
import 'md-editor-v3/lib/style.css'
426426
import DOMPurify from 'dompurify'
427427
428-
import { DEFAULT_PRICE, MINIMAL_PRICE, LCD_URL } from '~/constant'
428+
import { DEFAULT_PRICE, MINIMAL_PRICE } from '~/constant'
429429
import { useBookStoreApiStore } from '~/stores/book-store-api'
430430
import { useWalletStore } from '~/stores/wallet'
431431
import { useNftStore } from '~/stores/nft'
@@ -434,6 +434,7 @@ import { getPortfolioURL, deliverMethodOptions } from '~/utils'
434434
import { getNFTAuthzGrants, sendNFTsToAPIWallet } from '~/utils/cosmos'
435435
import { useCollectionStore } from '~/stores/collection'
436436
437+
const { LCD_URL } = useRuntimeConfig().public
437438
const walletStore = useWalletStore()
438439
const bookStoreApiStore = useBookStoreApiStore()
439440
const collectionStore = useCollectionStore()

‎pages/nft-book-store/collection/send/[collectionId].vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@
154154
<script setup lang="ts">
155155
import { DeliverTxResponse } from '@cosmjs/stargate'
156156
import { storeToRefs } from 'pinia'
157-
import { LIKE_CO_API, LCD_URL } from '~/constant'
158157
import { useBookStoreApiStore } from '~/stores/book-store-api'
159158
import { useWalletStore } from '~/stores/wallet'
160159
import { useNftStore } from '~/stores/nft'
161160
import { useCollectionStore } from '~/stores/collection'
162161
import { parseImageURLFromMetadata } from '~/utils'
163162
import { getNFTs, getNFTOwner, signExecNFTSendAuthz, signSendNFTs } from '~/utils/cosmos'
164163
164+
const { LIKE_CO_API, LCD_URL } = useRuntimeConfig().public
165165
const store = useWalletStore()
166166
const { wallet, signer } = storeToRefs(store)
167167
const { connect } = store

0 commit comments

Comments
 (0)