Skip to content

Commit 1d8b847

Browse files
authored
Merge pull request #5241 from swaponline/fix-qr-code-generation
Fix: correct QR generation in deposit
2 parents 3bea301 + 05ad1b2 commit 1d8b847

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# editors
22

33
.idea
4+
.vscode
45
.DS_Store
56
.eslintcache
67
*-lock.*

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@
241241
"graphql-request": "^3.4.0",
242242
"history": "^4.9.0",
243243
"human-standard-token-abi": "^2.0.0",
244+
"ip": "^2.0.1",
244245
"is-local-ip": "^1.1.0",
245246
"jdenticon": "^3.1.0",
246247
"json-stringify-safe": "^5.0.1",
@@ -272,6 +273,7 @@
272273
"react-items-carousel": "^2.8.0",
273274
"react-joyride": "^2.3.0",
274275
"react-loading-skeleton": "^3.0.1",
276+
"react-qr-code": "^2.0.12",
275277
"react-redux": "^7.2.2",
276278
"react-router": "^5.2.0",
277279
"react-router-dom": "^5.2.0",

src/front/shared/components/QR/QR.tsx

+12-35
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,34 @@
11
import React, { Component } from 'react'
22
import CSSModules from 'react-css-modules'
3-
import animateFetching from 'components/loaders/ContentLoader/ElementLoading.scss'
3+
import QRCode from "react-qr-code"
44

55
import styles from './QR.scss'
66

77
type ComponentProps = {
88
address: string
99
}
1010

11-
type ComponentState = {
12-
qrIsLoaded: boolean
13-
}
14-
15-
@CSSModules({ ...styles, ...animateFetching }, { allowMultiple: true })
16-
export default class QR extends Component<ComponentProps, ComponentState> {
11+
@CSSModules({ ...styles }, { allowMultiple: true })
12+
export default class QR extends Component<ComponentProps, any> {
1713

1814
constructor(props) {
1915
super(props)
20-
21-
this.state = {
22-
qrIsLoaded: false,
23-
}
24-
}
25-
26-
setSuccessLoading = () => {
27-
const { qrIsLoaded } = this.state
28-
29-
if (!qrIsLoaded) {
30-
this.setState(() => ({
31-
qrIsLoaded: true
32-
}))
33-
}
3416
}
3517

3618
render() {
3719
const { address } = this.props
38-
const { qrIsLoaded } = this.state
39-
const size = 270
4020

4121
return (
42-
<>
43-
<div className={styles.relativeWrapper}>
44-
<div className={styles.imageWrapper}>
45-
<img
46-
styleName={`${qrIsLoaded ? '' : 'hiddenEl'}`}
47-
src={`https://chart.googleapis.com/chart?chs=${size}x${size}&cht=qr&chl=${address}`}
48-
onLoad={this.setSuccessLoading}
49-
alt={address}
50-
/>
51-
<span styleName={`imageLoader ${qrIsLoaded ? 'hiddenEl' : 'animate-fetching'}`} />
52-
</div>
22+
<div className={styles.relativeWrapper}>
23+
<div className={styles.imageWrapper}>
24+
<QRCode
25+
size={270}
26+
value={address}
27+
bgColor="var(--color-background)"
28+
fgColor="var(--color)"
29+
/>
5330
</div>
54-
</>
31+
</div>
5532
)
5633
}
5734
}

0 commit comments

Comments
 (0)