Skip to content

Commit e36241b

Browse files
committed
feat: torus and mew not working
1 parent 398e26c commit e36241b

4 files changed

Lines changed: 68 additions & 32 deletions

File tree

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module "eth-provider";
2+
declare module "@myetherwallet/mewconnect-web-client";

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@mui/material": "latest",
2424
"@myetherwallet/mewconnect-connector": "^0.1.8",
2525
"@myetherwallet/mewconnect-web-client": "^2.2.0-beta.16",
26+
"@toruslabs/torus-embed": "^1.19.0",
2627
"@walletconnect/web3-provider": "^1.7.1",
2728
"@web3-react/abstract-connector": "^6.0.7",
2829
"@web3-react/core": "^6.1.9",
@@ -37,6 +38,7 @@
3738
"react": "latest",
3839
"react-dom": "latest",
3940
"reflect-metadata": "^0.1.13",
41+
"walletlink": "2.3.0",
4042
"web3modal": "^1.9.5"
4143
},
4244
"devDependencies": {

src/layouts/WalletConnectWidget.tsx

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import dynamic from "next/dynamic";
1919
// @ts-ignore
2020
// const ethProvider = dynamic(() => import('eth-provider'), { ssr: false })
2121
// @ts-ignore
22-
// const MewConnect = dynamic(() => import('@myetherwallet/mewconnect-web-client'), { ssr: false })
22+
const MewConnect = dynamic(() => import('@myetherwallet/mewconnect-web-client'), { ssr: false })
2323

2424
// @ts-ignore
2525
// const WalletConnect = dynamic(() => import('@walletconnect/web3-provider'), { ssr: false })
2626
// @ts-ignore
27-
// const Torus = dynamic(() => import('@toruslabs/torus-embed'), { ssr: false })
27+
const Torus = dynamic(() => import('@toruslabs/torus-embed'), { ssr: false })
2828
// @ts-ignore
2929
// const WalletLink = dynamic(() => import('walletlink'), { ssr: false })
3030

@@ -45,11 +45,11 @@ export default function WalletConnectWidget() {
4545
const [selectedInstance, setSelectedInstance] = useState(null as any);
4646

4747
const [web3Modal, setWeb3Modal] = useState(null as any);
48-
const [ethProvider, setEthProvider] = useState(null as any);
49-
const [mewConnect, setMewConnect] = useState(null as any);
50-
const [walletConnect, setWalletConnect] = useState(null as any);
51-
const [torus, setTorus] = useState(null as any);
52-
const [walletLink, setWalletLink] = useState(null as any);
48+
// const [ethProvider, setEthProvider] = useState(null as any);
49+
// const [mewConnect, setMewConnect] = useState(null as any);
50+
// const [walletConnect, setWalletConnect] = useState(null as any);
51+
// const [Torus, setTorus] = useState(null as unknown as Torus);
52+
// const [walletLink, setWalletLink] = useState(null as any);
5353

5454
useEffect(() => {
5555
// if (!ethProvider) {
@@ -79,15 +79,15 @@ export default function WalletConnectWidget() {
7979
// console.log('Error while creating Web3Modal');
8080
// }
8181
// }
82-
if (!torus) {
83-
try {
84-
import("@toruslabs/torus-embed").then(Torus => {
85-
setTorus(Torus)
86-
})
87-
} catch (e) {
88-
console.log('Error while creating Web3Modal');
89-
}
90-
}
82+
// if (!Torus) {
83+
// try {
84+
// import("@toruslabs/torus-embed").then(Torus => {
85+
// setTorus(Torus)
86+
// })
87+
// } catch (e) {
88+
// console.log('Error while creating Web3Modal');
89+
// }
90+
// }
9191

9292
// if (!walletLink) {
9393
// try {
@@ -134,7 +134,7 @@ export default function WalletConnectWidget() {
134134
});
135135
};
136136

137-
137+
console.log('torus:: ', Torus)
138138
const getProviderOptions = () => {
139139
const chainId: ChainId = 1;
140140
const networkConfig = getNetworkConfig(chainId);
@@ -153,17 +153,30 @@ export default function WalletConnectWidget() {
153153
preferredNetworkId: chainId,
154154
}
155155
},
156+
torus: {
157+
package: Torus,
158+
// options: {
159+
// chainId,
160+
// initOptions: {
161+
// network: {
162+
// host: chainId === ChainId.polygon ? 'matic' : chainId,
163+
// },
164+
// showTorusButton: false,
165+
// enableLogging: false,
166+
// enabledVerifiers: false,
167+
// }
168+
// }
169+
},
156170
// torus: {
157-
// package: torus,
171+
// package: Torus, // required
158172
// options: {
159-
// chainId,
160-
// initOptions: {
161-
// network: {
162-
// host: chainId === ChainId.polygon ? 'matic' : chainId,
163-
// },
164-
// showTorusButton: false,
165-
// enableLogging: false,
166-
// enabledVerifiers: false,
173+
// networkParams: {
174+
// host: "https://localhost:8545", // optional
175+
// chainId: 1337, // optional
176+
// networkId: 1337 // optional
177+
// },
178+
// config: {
179+
// buildEnv: "development" // optional
167180
// }
168181
// }
169182
// },
@@ -176,19 +189,19 @@ export default function WalletConnectWidget() {
176189
}
177190
},
178191
// mewconnect: {
179-
// package: mewConnect, // required
192+
// package: MewConnect, // required
180193
// options: {
181194
// url:
182195
// networkConfig.privateJsonRPCWSUrl ||
183196
// networkConfig.privateJsonRPCUrl ||
184197
// networkConfig.publicJsonRPCWSUrl ||
185198
// networkConfig.publicJsonRPCUrl[0],
186-
// windowClosedError: true,
199+
// // windowClosedError: true,
187200
// }
188201
// },
189202
frame: {
190203
package: ethProvider, // required
191-
options: { supportedChainIds }
204+
// options: { supportedChainIds }
192205
}
193206
};
194207
return providerOptions;
@@ -220,8 +233,8 @@ export default function WalletConnectWidget() {
220233

221234

222235
const provider = new ethers.providers.Web3Provider(instance);
223-
setSelectedProvider(provider);
224-
setSelectedInstance(instance);
236+
// setSelectedProvider(provider);
237+
// setSelectedInstance(instance);
225238
}
226239
};
227240

yarn.lock

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@
12221222
keccak "^3.0.2"
12231223
randombytes "^2.1.0"
12241224

1225-
"@toruslabs/torus-embed@^1.18.3":
1225+
"@toruslabs/torus-embed@^1.18.3", "@toruslabs/torus-embed@^1.19.0":
12261226
version "1.20.2"
12271227
resolved "https://registry.yarnpkg.com/@toruslabs/torus-embed/-/torus-embed-1.20.2.tgz#8c2a1b22b3ba9c24a927f0fc4b7517f1dc5d3c38"
12281228
integrity sha512-+HCoDFXP2XPl4Qf82LwjNvu2lQEQd5OiRs8KupDIlTFv2qh8i+42erP4A+VuLDrJGEYmdSwc2ERulzA5FOYsmQ==
@@ -8312,6 +8312,25 @@ vue@^2.6.10:
83128312
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.14.tgz#e51aa5250250d569a3fbad3a8a5a687d6036e235"
83138313
integrity sha512-x2284lgYvjOMj3Za7kqzRcUSxBboHqtgRE2zlos1qWaOye5yUmHn42LB1250NJBLRwEcdrB0JRwyPTEPhfQjiQ==
83148314

8315+
walletlink@2.3.0:
8316+
version "2.3.0"
8317+
resolved "https://registry.yarnpkg.com/walletlink/-/walletlink-2.3.0.tgz#1b7ac5da78e5fa17f35dc880674cf7f6c493d2a5"
8318+
integrity sha512-CXPYFnWFN/2Xgf62LBhApAiqQIazH7MeRw+Y/TB6oKpdBLQSLzL6k4sqZ6VBKb7wU5HDk+ErXY0QZ9OIFB+Ifw==
8319+
dependencies:
8320+
"@metamask/safe-event-emitter" "2.0.0"
8321+
bind-decorator "^1.0.11"
8322+
bn.js "^5.1.1"
8323+
clsx "^1.1.0"
8324+
eth-block-tracker "4.4.3"
8325+
eth-json-rpc-filters "4.2.2"
8326+
eth-rpc-errors "4.0.2"
8327+
js-sha256 "0.9.0"
8328+
json-rpc-engine "6.1.0"
8329+
keccak "^3.0.1"
8330+
preact "^10.5.9"
8331+
rxjs "^6.6.3"
8332+
stream-browserify "^3.0.0"
8333+
83158334
walletlink@^2.2.6:
83168335
version "2.4.2"
83178336
resolved "https://registry.yarnpkg.com/walletlink/-/walletlink-2.4.2.tgz#c218d1e0906537eac2a2e0bb24ee8ad19ecc23a6"

0 commit comments

Comments
 (0)