Skip to content

Commit 8dce545

Browse files
committed
loopring provide
1 parent 39eb6d9 commit 8dce545

File tree

6 files changed

+49
-166
lines changed

6 files changed

+49
-166
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
<p align="center">
1+
<p align="center" >
22
<a href="https://github.com/Loopring/loopring-web-v2" rel="noopener" target="_blank"><img width="150" src="https://loopring.org/images/logo.svg" alt="Loopring-website"></a>
33
</p>
44

55

6-
<h1 align="center">Loopring Application</h1>
6+
<h1 align="center">Loopring web3-provider</h1>
77
<div align="center">
8-
<h2>Ethereum’s First zkRollup Layer2</h2>
9-
<p>Secure, Fast, and Cheap</p>
8+
<h2>A lite tool to connect web extension & Dapp</h2>
9+
<p>Open source and free use</p>
1010

11-
[![license](https://img.shields.io/badge/license-GPL-blue)](https://github.com/Loopring/loopring-web-v2/master/LICENSE)
11+
[![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/Loopring/loopring-web-v2/master/LICENSE)
1212

1313
[![type-badge](https://img.shields.io/npm/types/react-data-grid)](https://www.npmjs.com/package/react-data-grid)
1414

15-
<!-- [![Materi-UI](https://img.shields.io/npm/types/react-data-grid)](https://www.npmjs.com/package/react-data-grid) -->
16-
1715
</div>
1816

1917
## 🚀 Quick Start
2018

2119
```bash
2220
// with yarn
23-
yarn install
21+
yarn install @loopring-web/web3-provider
22+
```
23+
## 🛒 Support Provider
24+
- Metamask
25+
- WallectConnet
26+
- Coinbase
27+
- Coming soon
28+
29+
## env.product
30+
```.env.product
31+
RPC_URL_1=https://mainnet.eth.loopring.network
32+
RPC_URL_5=https://goerli.infura.io/v3/b951a403f3d3426fb2008c6923254dbc
33+
WALLET_CONNECT_BRIDGE=https://wcbridge.loopring.network
34+
WALLET_CONNECT_PING=https://wcbridge.loopring.network/hello
2435
```
36+
Demo for React hook
2537

2638
## 👉 [What is Loopring?](https://loopring.org/#/)
2739

demo/react/.env.example

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,8 @@
1-
NODE_ENV=production
2-
1+
#NODE_ENV=dev
2+
HTTPS=true
33
NODE_TLS_REJECT_UNAUTHORIZED=0
4-
54
ASSET_PATH = './'
6-
7-
#REACT_APP_RPC_URL_1=https://mainnet.infura.io/v3/84842078b09946638c03157f83405213
8-
REACT_APP_RPC_URL_1=https://mainnet.eth.loopring.network
9-
HTTPS=true
10-
11-
#REACT_APP_RPC_URL_1=http://18.220.83.236:8545
12-
REACT_APP_RPC_URL_5=https://goerli.infura.io/v3/b951a403f3d3426fb2008c6923254dbc
13-
14-
#REACT_APP_WALLET_CONNECT_BRIDGE=https://bridge.walletconnect.org
15-
#REACT_APP_WALLET_CONNECT_BRIDGE=http://ec2-3-143-67-250.us-east-2.compute.amazonaws.com:37821
16-
#REACT_APP_WALLET_CONNECT_BRIDGE=https://connect.loopring.io
17-
REACT_APP_WALLET_CONNECT_BRIDGE=https://wcbridge.loopring.network
18-
19-
REACT_APP_FORTMATIC_API_KEY=pk_test_A6260FCBAA2EBDFB
20-
REACT_APP_MAGIC_API_KEY=pk_test_398B82F5F0E88874
21-
REACT_APP_PORTIS_DAPP_ID=e9be171c-2b7f-4ff0-8db9-327707511ee2
22-
23-
#REACT_APP_API_URL=api.loopring.network
24-
#REACT_APP_API_URL_UAT=api.uat.loopring.pro
25-
REACT_APP_API_URL=api3.loopring.io
26-
REACT_APP_API_URL_UAT=uat2.loopring.io
27-
28-
SKIP_PREFLIGHT_CHECK=true
29-
30-
REACT_APP_WITH_PRO=true
5+
RPC_URL_1=https://mainnet.eth.loopring.network
6+
RPC_URL_5=https://goerli.infura.io/v3/b951a403f3d3426fb2008c6923254dbc
7+
WALLET_CONNECT_BRIDGE=https://wcbridge.loopring.network
8+
WALLET_CONNECT_PING=https://wcbridge.loopring.network/hello

src/command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const ExtensionSubscribe = (provider: any, web3: Web3) => {
2626
walletServices.sendDisconnect(-1, "disconnect for no account");
2727
}
2828
});
29-
provider.on("chainChanged", (chainId: number) => {
29+
provider.on("chainChanged", (_chainId: number) => {
3030
walletServices.sendConnect(web3, provider);
3131
});
3232
provider.on("disconnect", (code: number, reason: string) => {
@@ -51,6 +51,6 @@ export enum ConnectProviders {
5151
Coinbase = "Coinbase",
5252
}
5353
export const RPC_URLS: { [chainId: number]: string } = {
54-
1: process.env.REACT_APP_RPC_URL_1 as string,
55-
5: process.env.REACT_APP_RPC_URL_5 as string,
54+
1: process.env.RPC_URL_1 as string,
55+
5: process.env.RPC_URL_5 as string,
5656
};

src/walletConnect/provider.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ import { walletServices } from "../walletServices";
44
import { ConnectProviders, ErrorType, RPC_URLS } from "../command";
55
import { IsMobile } from "../utilities";
66
const POLLING_INTERVAL = 12000;
7-
7+
const DEFAULT_BRIDGE = "https://bridge.walletconnect.org"
88
export const WalletConnectProvide = async (props?: {
99
account?: string;
1010
darkMode?: boolean;
1111
}): Promise<{ provider?: WalletConnectProvider; web3?: Web3 } | undefined> => {
1212
try {
13-
const BRIDGE_URL = await fetch("https://wcbridge.loopring.network/hello")
14-
.then(({ status }) => {
15-
return status === 200
16-
? process.env.REACT_APP_WALLET_CONNECT_BRIDGE
17-
: "https://bridge.walletconnect.org";
18-
})
19-
.catch(() => {
20-
return "https://bridge.walletconnect.org";
21-
});
13+
const BRIDGE_URL = (await fetch(process.env.WALLET_CONNECT_PING??'')
14+
.then(({ status }) => {
15+
return status === 200
16+
? process.env.WALLET_CONNECT_BRIDGE
17+
: DEFAULT_BRIDGE;
18+
})
19+
.catch(() => {
20+
return DEFAULT_BRIDGE;
21+
}))??DEFAULT_BRIDGE
22+
23+
2224
// const BRIDGE_URL = "https://bridge.walletconnect.org";
2325

2426
const provider: WalletConnectProvider = new WalletConnectProvider({
@@ -72,7 +74,7 @@ export const WalletConnectProvide = async (props?: {
7274
export const WalletConnectSubscribe = (
7375
provider: any,
7476
web3: Web3,
75-
account?: string
77+
_account?: string
7678
) => {
7779
const { connector } = provider;
7880
if (provider && connector && connector.connected) {
@@ -192,8 +194,8 @@ export const WalletConnectUnsubscribe = async (provider: any) => {
192194
// const POLLING_INTERVAL = 12000
193195
//
194196
// const RPC_URLS: { [chainId: number]: string } = {
195-
// 1: process.env.REACT_APP_RPC_URL_1 as string,
196-
// 5: process.env.REACT_APP_RPC_URL_5 as string
197+
// 1: process.env.RPC_URL_1 as string,
198+
// 5: process.env.RPC_URL_5 as string
197199
// }
198200
//
199201
// myLog('RPC_URLS 1:', RPC_URLS[1])

src/walletServices.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { Subject } from "rxjs-compat";
21
import Web3 from "web3";
32
import { Commands, ErrorType, ProcessingType } from "./command";
43

4+
const { Subject } = require('rxjs');
5+
56
//TODO typeof account State
6-
const subject = new Subject<{ status: keyof typeof Commands; data: any }>();
7+
const subject = new Subject();
78

89
const AvaiableNetwork = [1, 5];
9-
export const walletServices = {subject,
10+
export const walletServices = {
11+
subject,
1012
sendProcess: async (type: keyof typeof ProcessingType, props?: any) => {
1113
subject.next({
1214
status: Commands.Processing,

yarn.lock

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,107 +1688,6 @@
16881688
dependencies:
16891689
"@types/node" "*"
16901690

1691-
"@types/rx-core-binding@*":
1692-
version "4.0.4"
1693-
resolved "https://registry.yarnpkg.com/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz#d969d32f15a62b89e2862c17b3ee78fe329818d3"
1694-
integrity sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==
1695-
dependencies:
1696-
"@types/rx-core" "*"
1697-
1698-
"@types/rx-core@*":
1699-
version "4.0.3"
1700-
resolved "https://registry.yarnpkg.com/@types/rx-core/-/rx-core-4.0.3.tgz#0b3354b1238cedbe2b74f6326f139dbc7a591d60"
1701-
integrity sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=
1702-
1703-
"@types/rx-lite-aggregates@*":
1704-
version "4.0.3"
1705-
resolved "https://registry.yarnpkg.com/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz#6efb2b7f3d5f07183a1cb2bd4b1371d7073384c2"
1706-
integrity sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==
1707-
dependencies:
1708-
"@types/rx-lite" "*"
1709-
1710-
"@types/rx-lite-async@*":
1711-
version "4.0.2"
1712-
resolved "https://registry.yarnpkg.com/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz#27fbf0caeff029f41e2d2aae638b05e91ceb600c"
1713-
integrity sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==
1714-
dependencies:
1715-
"@types/rx-lite" "*"
1716-
1717-
"@types/rx-lite-backpressure@*":
1718-
version "4.0.3"
1719-
resolved "https://registry.yarnpkg.com/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz#05abb19bdf87cc740196c355e5d0b37bb50b5d56"
1720-
integrity sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==
1721-
dependencies:
1722-
"@types/rx-lite" "*"
1723-
1724-
"@types/rx-lite-coincidence@*":
1725-
version "4.0.3"
1726-
resolved "https://registry.yarnpkg.com/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz#80bd69acc4054a15cdc1638e2dc8843498cd85c0"
1727-
integrity sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==
1728-
dependencies:
1729-
"@types/rx-lite" "*"
1730-
1731-
"@types/rx-lite-experimental@*":
1732-
version "4.0.1"
1733-
resolved "https://registry.yarnpkg.com/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz#c532f5cbdf3f2c15da16ded8930d1b2984023cbd"
1734-
integrity sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=
1735-
dependencies:
1736-
"@types/rx-lite" "*"
1737-
1738-
"@types/rx-lite-joinpatterns@*":
1739-
version "4.0.1"
1740-
resolved "https://registry.yarnpkg.com/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz#f70fe370518a8432f29158cc92ffb56b4e4afc3e"
1741-
integrity sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=
1742-
dependencies:
1743-
"@types/rx-lite" "*"
1744-
1745-
"@types/rx-lite-testing@*":
1746-
version "4.0.1"
1747-
resolved "https://registry.yarnpkg.com/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz#21b19d11f4dfd6ffef5a9d1648e9c8879bfe21e9"
1748-
integrity sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=
1749-
dependencies:
1750-
"@types/rx-lite-virtualtime" "*"
1751-
1752-
"@types/rx-lite-time@*":
1753-
version "4.0.3"
1754-
resolved "https://registry.yarnpkg.com/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz#0eda65474570237598f3448b845d2696f2dbb1c4"
1755-
integrity sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==
1756-
dependencies:
1757-
"@types/rx-lite" "*"
1758-
1759-
"@types/rx-lite-virtualtime@*":
1760-
version "4.0.3"
1761-
resolved "https://registry.yarnpkg.com/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz#4b30cacd0fe2e53af29f04f7438584c7d3959537"
1762-
integrity sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==
1763-
dependencies:
1764-
"@types/rx-lite" "*"
1765-
1766-
"@types/rx-lite@*":
1767-
version "4.0.6"
1768-
resolved "https://registry.yarnpkg.com/@types/rx-lite/-/rx-lite-4.0.6.tgz#3c02921c4244074234f26b772241bcc20c18c253"
1769-
integrity sha512-oYiDrFIcor9zDm0VDUca1UbROiMYBxMLMaM6qzz4ADAfOmA9r1dYEcAFH+2fsPI5BCCjPvV9pWC3X3flbrvs7w==
1770-
dependencies:
1771-
"@types/rx-core" "*"
1772-
"@types/rx-core-binding" "*"
1773-
1774-
"@types/rx@^4.1.2":
1775-
version "4.1.2"
1776-
resolved "https://registry.yarnpkg.com/@types/rx/-/rx-4.1.2.tgz#a4061b3d72b03cf11a38d69e2022a17334c54dc0"
1777-
integrity sha512-1r8ZaT26Nigq7o4UBGl+aXB2UMFUIdLPP/8bLIP0x3d0pZL46ybKKjhWKaJQWIkLl5QCLD0nK3qTOO1QkwdFaA==
1778-
dependencies:
1779-
"@types/rx-core" "*"
1780-
"@types/rx-core-binding" "*"
1781-
"@types/rx-lite" "*"
1782-
"@types/rx-lite-aggregates" "*"
1783-
"@types/rx-lite-async" "*"
1784-
"@types/rx-lite-backpressure" "*"
1785-
"@types/rx-lite-coincidence" "*"
1786-
"@types/rx-lite-experimental" "*"
1787-
"@types/rx-lite-joinpatterns" "*"
1788-
"@types/rx-lite-testing" "*"
1789-
"@types/rx-lite-time" "*"
1790-
"@types/rx-lite-virtualtime" "*"
1791-
17921691
"@types/secp256k1@^4.0.1":
17931692
version "4.0.3"
17941693
resolved "https://registry.yarnpkg.com/@types/secp256k1/-/secp256k1-4.0.3.tgz#1b8e55d8e00f08ee7220b4d59a6abe89c37a901c"
@@ -7868,11 +7767,6 @@ rustbn.js@~0.2.0:
78687767
resolved "https://registry.yarnpkg.com/rustbn.js/-/rustbn.js-0.2.0.tgz#8082cb886e707155fd1cb6f23bd591ab8d55d0ca"
78697768
integrity sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA==
78707769

7871-
rxjs-compat@^6.6.7:
7872-
version "6.6.7"
7873-
resolved "https://registry.yarnpkg.com/rxjs-compat/-/rxjs-compat-6.6.7.tgz#6eb4ef75c0a58ea672854a701ccc8d49f41e69cb"
7874-
integrity sha512-szN4fK+TqBPOFBcBcsR0g2cmTTUF/vaFEOZNuSdfU8/pGFnNmmn2u8SystYXG1QMrjOPBc6XTKHMVfENDf6hHw==
7875-
78767770
rxjs@^6.6.0, rxjs@^6.6.3:
78777771
version "6.6.7"
78787772
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.7.tgz#90ac018acabf491bf65044235d5863c4dab804c9"
@@ -8917,11 +8811,6 @@ typescript@^3.7.3:
89178811
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
89188812
integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==
89198813

8920-
typescript@^4.6.2:
8921-
version "4.6.2"
8922-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"
8923-
integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==
8924-
89258814
89268815
version "1.3.5"
89278816
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-1.3.5.tgz#4b5bfff9186effbaa888e4c9e94bd9fc4c94929d"

0 commit comments

Comments
 (0)