Skip to content

Commit

Permalink
Merge pull request #231 from curaOS/mainnet-config
Browse files Browse the repository at this point in the history
Mainnet config
  • Loading branch information
bestatigen authored Jul 5, 2022
2 parents 80ade85 + 9f37cd6 commit 3fb38fe
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ packages/commands/build/release
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/versions

.idea
1 change: 1 addition & 0 deletions examples/frontend/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
YSN_ADDRESS: 'ysn-1_0_0.ysn.testnet',
SHARE_ADDRESS: 'share.ysn-1_0_0.ysn.testnet',
SHARE_MARKET_ADDRESS: 'market.share.ysn-1_0_0.ysn.testnet',
NEAR_ENV: 'testnet',
},
future: {
webpack5: true,
Expand Down
22 changes: 12 additions & 10 deletions packages/components/src/History.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {Box, Heading, Text, Link} from "theme-ui";
import moment from "moment";

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

type historyProps = {
type: string
Expand Down Expand Up @@ -49,7 +51,7 @@ function HistoryItemLayout(
color: 'gray.8'
}
}}
href={`https://explorer.testnet.near.org/blocks/${blockHash58}`} target={"_blank"}>
href={`${EXPLORER_URL}/blocks/${blockHash58}`} target={"_blank"}>
<Text>
{moment(Number(timestamp)/1000000).format("dddd, DD MMMM YYYY, HH:mm:ss")}
</Text>
Expand All @@ -62,42 +64,42 @@ function HistoryItemLayout(
function Burn({ accountId } : { accountId : string }){
return(
<Box>
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{ accountId }</Link> burned this NFT.
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{ accountId }</Link> burned this NFT.
</Box>
)
}

function Mint({ accountId } : { accountId : string }){
return(
<Box>
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> minted this NFT.
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> minted this NFT.
</Box>
)
}

function Bid({ accountId } : { accountId : string }){
return(
<Box>
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> placed a bid.
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> placed a bid.
</Box>
)
}

function BidRemove({ accountId } : { accountId : string }){
return(
<Box>
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> removed their bid.
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> removed their bid.
</Box>
)
}

function BidAccept({ accountId, receiverId } : { accountId : string, receiverId: string }){
return(
<Box>
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>
{accountId}
</Link> accepted{" "}
<Link href={`https://explorer.testnet.near.org/accounts/${receiverId}`} target={"_blank"}>
<Link href={`${EXPLORER_URL}/accounts/${receiverId}`} target={"_blank"}>
{ receiverId }
</Link>
's bid.
Expand All @@ -108,7 +110,7 @@ function BidAccept({ accountId, receiverId } : { accountId : string, receiverId:
function BidUpdate({ accountId } : { accountId : string }){
return(
<Box>
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> updated their bid.
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>{accountId}</Link> updated their bid.
</Box>
)
}
Expand All @@ -117,10 +119,10 @@ function BidUpdate({ accountId } : { accountId : string }){
function Transfer({ accountId, receiverId } : { accountId : string, receiverId: string }){
return(
<Box>
<Link href={`https://explorer.testnet.near.org/accounts/${accountId}`} target={"_blank"}>
<Link href={`${EXPLORER_URL}/accounts/${accountId}`} target={"_blank"}>
{accountId}
</Link> transferred this NFT to{" "}
<Link href={`https://explorer.testnet.near.org/accounts/${receiverId}`} target={"_blank"}>
<Link href={`${EXPLORER_URL}/accounts/${receiverId}`} target={"_blank"}>
{ receiverId}
</Link>
</Box>
Expand Down
7 changes: 5 additions & 2 deletions packages/components/src/Metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import { Box, Flex, Heading, Text, Link } from 'theme-ui'
import { Placeholder } from './Placeholder'

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

type NFTMetadataType = {
creator_id?: string
owner_id?:
Expand Down Expand Up @@ -65,7 +68,7 @@ function MetadataLoaded({
CREATED BY
</Heading>
<Link
href={`https://explorer.testnet.near.org/accounts/${creator}`}
href={`${EXPLORER_URL}/accounts/${creator}`}
target="_blank"
variant="explorer"
>
Expand All @@ -80,7 +83,7 @@ function MetadataLoaded({
OWNED BY
</Heading>
<Link
href={`https://explorer.testnet.near.org/accounts/${owner}`}
href={`${EXPLORER_URL}/accounts/${owner}`}
target="_blank"
variant="explorer"
>
Expand Down
30 changes: 21 additions & 9 deletions packages/hooks/src/near-utils.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
function getConfig() {
let config = {
networkId: 'testnet',
nodeUrl: 'https://rpc.testnet.near.org',
walletUrl: 'https://wallet.testnet.near.org',
helperUrl: 'https://helper.testnet.near.org',
function getConfig(env: string) {
switch (env) {
case 'mainnet':
return {
networkId: 'mainnet',
nodeUrl: 'https://rpc.mainnet.near.org',
walletUrl: 'https://wallet.near.org',
helperUrl: 'https://helper.mainnet.near.org',
explorerUrl: 'https://explorer.near.org'
}
case 'testnet':
return {
networkId: 'testnet',
nodeUrl: 'https://rpc.testnet.near.org',
walletUrl: 'https://wallet.testnet.near.org',
helperUrl: 'https://helper.testnet.near.org',
explorerUrl: 'https://explorer.testnet.near.org',
}
default:
throw Error('Environment not found.')
}

return config
}

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

export function getContractMethods(contractName: string) {
switch (contractName) {
Expand Down

1 comment on commit 3fb38fe

@vercel
Copy link

@vercel vercel bot commented on 3fb38fe Jul 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.