Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
import React, { Component } from 'react';
import light from '@parity/light.js-react';
import { Modal } from 'fether-ui';
import { startWith, catchError } from 'rxjs/operators';
import { versionInfo$ } from '@parity/light.js';
import { of } from 'rxjs';
import semver from 'semver';
import { parity } from 'fether/package.json';
const requiredVersion = parity.version;
@light({
versionInfo: props =>
versionInfo$().pipe(
startWith(undefined),
catchError(e => {
/*
* parity_versionInfo was implemented on the LC with Parity v2.4.1
* If the RPC errors out, it means we're using Parity < v2.4.1
* Checking the version of Parity Ethereum in Fether was first released
* (Fether v0.3) along with a feature (#394) that requires Parity
* Ethereum >= v2.4.0
* Fether v0.3 should theoretically work with v2.4.0, but since there is
* no way to check for this exact version, we made Fether v0.3 require
* >= v2.4.1 (which we can check).
*
* If the RPC errors out, we're using Parity < v2.4.1 and Fether v0.3
* is "officially" not compatible with this version.
*/
return of({ version: { major: 0, minor: 0, patch: 0 } });
})
)
})
class RequireParityVersion extends Component {
render () {
const { versionInfo } = this.props;
if (versionInfo) {
const { major, minor, patch } = versionInfo.version;
if (!semver.satisfies(`${major}.${minor}.${patch}`, requiredVersion)) {
const friendlyVersion =
major === 0 && minor === 0 && patch === 0
? '<2.4.1'
: `${major}.${minor}.${patch}`;
return (
<Modal
title='Unsupported version'
description={`You are running Parity Ethereum ${friendlyVersion}, which is unsupported. Please use Parity Ethereum ${requiredVersion}`}
visible
/>
);
}
}
return this.props.children;
}
}
export default RequireParityVersion;