Skip to content

Commit 3fb38fe

Browse files
authored
Merge pull request #231 from curaOS/mainnet-config
Mainnet config
2 parents 80ade85 + 9f37cd6 commit 3fb38fe

File tree

5 files changed

+42
-22
lines changed

5 files changed

+42
-22
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ packages/commands/build/release
1616
!.yarn/plugins
1717
!.yarn/releases
1818
!.yarn/sdks
19-
!.yarn/versions
19+
!.yarn/versions
20+
21+
.idea

examples/frontend/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
YSN_ADDRESS: 'ysn-1_0_0.ysn.testnet',
44
SHARE_ADDRESS: 'share.ysn-1_0_0.ysn.testnet',
55
SHARE_MARKET_ADDRESS: 'market.share.ysn-1_0_0.ysn.testnet',
6+
NEAR_ENV: 'testnet',
67
},
78
future: {
89
webpack5: true,

packages/components/src/History.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {Box, Heading, Text, Link} from "theme-ui";
22
import moment from "moment";
33

4+
const EXPLORER_URL = process?.env?.NEAR_ENV == 'mainnet' ?
5+
'https://explorer.near.org' : 'https://explorer.testnet.near.org';
46

57
type historyProps = {
68
type: string
@@ -49,7 +51,7 @@ function HistoryItemLayout(
4951
color: 'gray.8'
5052
}
5153
}}
52-
href={`https://explorer.testnet.near.org/blocks/${blockHash58}`} target={"_blank"}>
54+
href={`${EXPLORER_URL}/blocks/${blockHash58}`} target={"_blank"}>
5355
<Text>
5456
{moment(Number(timestamp)/1000000).format("dddd, DD MMMM YYYY, HH:mm:ss")}
5557
</Text>
@@ -62,42 +64,42 @@ function HistoryItemLayout(
6264
function Burn({ accountId } : { accountId : string }){
6365
return(
6466
<Box>
65-
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{ accountId }</Link> burned this NFT.
67+
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{ accountId }</Link> burned this NFT.
6668
</Box>
6769
)
6870
}
6971

7072
function Mint({ accountId } : { accountId : string }){
7173
return(
7274
<Box>
73-
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> minted this NFT.
75+
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> minted this NFT.
7476
</Box>
7577
)
7678
}
7779

7880
function Bid({ accountId } : { accountId : string }){
7981
return(
8082
<Box>
81-
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> placed a bid.
83+
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> placed a bid.
8284
</Box>
8385
)
8486
}
8587

8688
function BidRemove({ accountId } : { accountId : string }){
8789
return(
8890
<Box>
89-
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> removed their bid.
91+
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> removed their bid.
9092
</Box>
9193
)
9294
}
9395

9496
function BidAccept({ accountId, receiverId } : { accountId : string, receiverId: string }){
9597
return(
9698
<Box>
97-
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>
99+
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>
98100
{accountId}
99101
</Link> accepted{" "}
100-
<Link href={`https://explorer.testnet.near.org/accounts/${receiverId}`} target={"_blank"}>
102+
<Link href={`${EXPLORER_URL}/accounts/${receiverId}`} target={"_blank"}>
101103
{ receiverId }
102104
</Link>
103105
's bid.
@@ -108,7 +110,7 @@ function BidAccept({ accountId, receiverId } : { accountId : string, receiverId:
108110
function BidUpdate({ accountId } : { accountId : string }){
109111
return(
110112
<Box>
111-
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> updated their bid.
113+
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> updated their bid.
112114
</Box>
113115
)
114116
}
@@ -117,10 +119,10 @@ function BidUpdate({ accountId } : { accountId : string }){
117119
function Transfer({ accountId, receiverId } : { accountId : string, receiverId: string }){
118120
return(
119121
<Box>
120-
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>
122+
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>
121123
{accountId}
122124
</Link> transferred this NFT to{" "}
123-
<Link href={`https://explorer.testnet.near.org/accounts/${receiverId}`} target={"_blank"}>
125+
<Link href={`${EXPLORER_URL}/accounts/${receiverId}`} target={"_blank"}>
124126
{ receiverId}
125127
</Link>
126128
</Box>

packages/components/src/Metadata.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import { Box, Flex, Heading, Text, Link } from 'theme-ui'
44
import { Placeholder } from './Placeholder'
55

6+
const EXPLORER_URL = process?.env?.NEAR_ENV == 'mainnet' ?
7+
'https://explorer.near.org' : 'https://explorer.testnet.near.org';
8+
69
type NFTMetadataType = {
710
creator_id?: string
811
owner_id?:
@@ -65,7 +68,7 @@ function MetadataLoaded({
6568
CREATED BY
6669
</Heading>
6770
<Link
68-
href={`https://explorer.testnet.near.org/accounts/${creator}`}
71+
href={`${EXPLORER_URL}/accounts/${creator}`}
6972
target="_blank"
7073
variant="explorer"
7174
>
@@ -80,7 +83,7 @@ function MetadataLoaded({
8083
OWNED BY
8184
</Heading>
8285
<Link
83-
href={`https://explorer.testnet.near.org/accounts/${owner}`}
86+
href={`${EXPLORER_URL}/accounts/${owner}`}
8487
target="_blank"
8588
variant="explorer"
8689
>

packages/hooks/src/near-utils.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
function getConfig() {
2-
let config = {
3-
networkId: 'testnet',
4-
nodeUrl: 'https://rpc.testnet.near.org',
5-
walletUrl: 'https://wallet.testnet.near.org',
6-
helperUrl: 'https://helper.testnet.near.org',
1+
function getConfig(env: string) {
2+
switch (env) {
3+
case 'mainnet':
4+
return {
5+
networkId: 'mainnet',
6+
nodeUrl: 'https://rpc.mainnet.near.org',
7+
walletUrl: 'https://wallet.near.org',
8+
helperUrl: 'https://helper.mainnet.near.org',
9+
explorerUrl: 'https://explorer.near.org'
10+
}
11+
case 'testnet':
12+
return {
13+
networkId: 'testnet',
14+
nodeUrl: 'https://rpc.testnet.near.org',
15+
walletUrl: 'https://wallet.testnet.near.org',
16+
helperUrl: 'https://helper.testnet.near.org',
17+
explorerUrl: 'https://explorer.testnet.near.org',
18+
}
19+
default:
20+
throw Error('Environment not found.')
721
}
8-
9-
return config
1022
}
1123

12-
export const { nodeUrl, networkId, walletUrl } = getConfig()
24+
export const { nodeUrl, networkId, walletUrl, explorerUrl } = getConfig(process.env.NEAR_ENV || 'testnet')
1325

1426
export function getContractMethods(contractName: string) {
1527
switch (contractName) {

0 commit comments

Comments
 (0)