Skip to content

Commit 568c226

Browse files
authored
Merge branch 'v2' into feat/menu
2 parents 05a3d52 + 188e761 commit 568c226

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ artifacts
4646
# contract type generation
4747
/contracts/types
4848

49-
package-lock.json
49+
package-lock.json
50+
51+
version.js

get_version.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# git tag -l|tail -1 >.version && git rev-parse --short HEAD >>.version
2+
import subprocess
3+
import sys
4+
import textwrap
5+
6+
result = subprocess.run(['git', 'tag', '-l'], stdout=subprocess.PIPE)
7+
r = result.stdout.decode('u8').strip()
8+
vtag = r.split('\n')[-1]
9+
# print(vtag)
10+
11+
result = subprocess.run(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE)
12+
r = result.stdout.decode('u8').strip()
13+
vhash = r.split('\n')[-1]
14+
# print(vhash)
15+
16+
ver = '{}+{}'.format(vtag, vhash)
17+
# print(ver)
18+
19+
20+
txt = f'''const FrontendVersion = '{ver}'
21+
'''
22+
txt+="""
23+
export {
24+
FrontendVersion,
25+
}
26+
"""
27+
# print(txt)
28+
29+
open('version.js', 'w').write(txt)

pages/_app.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import "../styles/globals.css"
22
import "../styles/markdown.css"
3+
import { FrontendVersion } from "../version.js"
34
import Head from "next/head"
45
import { useState } from "react"
56
import { ethers } from "ethers"
67
import { Menu, Transition } from "@headlessui/react"
78
import { Fragment, useEffect } from "react"
89
import { ChevronDownIcon } from "@heroicons/react/solid"
910
import {Navigation} from "../components/Navigation";
11+
import axios from "axios"
1012

1113
// On production, you should use something like web3Modal
1214
// to support additional wallet providers, like WalletConnect
@@ -17,6 +19,7 @@ function Marketplace({ Component, pageProps }) {
1719
const [ethAccount, setethAccount] = useState(null)
1820
const [Logined, setLogined] = useState(false)
1921
const [loadingState, setLoadingState] = useState("not-loaded")
22+
const [BackendVersion, setBackendVersion] = useState("err")
2023

2124
useEffect(() => {
2225
if (typeof window !== "undefined") {
@@ -41,9 +44,22 @@ function Marketplace({ Component, pageProps }) {
4144
})
4245
}
4346
listenMMAccount()
47+
getBackendVersion()
4448
}
4549
}, [])
4650

51+
async function getBackendVersion() {
52+
try {
53+
const dweb_search_ver_api = "https://dweb-search-api.anwen.cc/version"
54+
const ret = await axios.get(dweb_search_ver_api)
55+
if (ret.status == 200 && 'version' in ret.data) {
56+
setBackendVersion(ret.data['version'])
57+
}
58+
} catch (error) {
59+
console.log(error)
60+
}
61+
}
62+
4763
async function loginSig() {
4864
// change network and sig login
4965
const sig_login = localStorage.getItem("sig_login")
@@ -230,10 +246,13 @@ function Marketplace({ Component, pageProps }) {
230246

231247
<Component {...pageProps} />
232248

233-
234-
235249
<footer className="border-b p-6">
236-
<p>Version v0.4.4 Powered by Dweb Lab</p>
250+
<p>Frontend Version: {FrontendVersion} &nbsp;
251+
Backend Version: {BackendVersion} &nbsp;
252+
& <a href="https://mumbai.polygonscan.com/">Polygon (MATIC) Mumbai TESTNET</a>
253+
254+
&nbsp;| Powered by Dweb Lab.
255+
</p>
237256
</footer>
238257

239258
</div>

pages/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ export default function Home() {
8787
</li>
8888
<li>
8989
🌃 There is also an IPFS version:
90-
ipfs://QmSp1Y8TJLQ2dJyYd5uZS7iqGDLPChf2rSsK1R8KkTgY2i{" "} not newest
91-
newest version: b8b6db
90+
ipfs://QmeHJjYjFDLnu4pehAjRyy2MTbZCuVkXFRsvUYVfVUaYxL maybe not newest version
9291
</li>
9392
</ul>
9493
</div>

0 commit comments

Comments
 (0)