Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Snyk] Fix for 1 vulnerabilities #4

Open
wants to merge 54 commits into
base: V1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a7e5ca9
Updated typescript build issues
cjmcassar Nov 1, 2022
20e04f9
fixed typescript problems
cjmcassar Nov 1, 2022
25fa281
added mewconnect packages
cjmcassar Nov 1, 2022
1b4e994
updated ignore
cjmcassar Nov 1, 2022
6b30271
udpated mewconnect file
cjmcassar Nov 1, 2022
0a7574e
implemented mewconnect provider config
cjmcassar Nov 1, 2022
b9c9573
Added mew to providerOptions
cjmcassar Nov 1, 2022
ed319ad
*
cjmcassar Nov 1, 2022
e4d8609
added wally sdk
cjmcassar Nov 1, 2022
3eb680b
implemented wally via providers
cjmcassar Nov 2, 2022
7f7f170
Implement wally via custom provider
cjmcassar Nov 2, 2022
aba689f
*
cjmcassar Nov 3, 2022
1fd9489
Updated client id
cjmcassar Nov 3, 2022
bfbda1a
updated f
cjmcassar Nov 3, 2022
20cf609
*
cjmcassar Nov 3, 2022
4e82d4b
Added init and handleredirect
cjmcassar Nov 3, 2022
c1477eb
Added router
cjmcassar Nov 3, 2022
1328ced
removed error
cjmcassar Nov 3, 2022
1910c2e
Added state changes
cjmcassar Nov 4, 2022
5644f18
*
cjmcassar Nov 4, 2022
0b022d8
added condtional for provider
cjmcassar Nov 4, 2022
1434e3c
*
cjmcassar Nov 4, 2022
4c2e4fa
removed multiple reload issue
cjmcassar Nov 5, 2022
69d74db
*
cjmcassar Nov 5, 2022
d9dfe84
Added unmount
cjmcassar Nov 5, 2022
f275a04
*
cjmcassar Nov 5, 2022
ab77cb6
*
cjmcassar Nov 8, 2022
4970789
update sdk
cjmcassar Nov 8, 2022
37f82bc
Changed the request method
cjmcassar Nov 9, 2022
1539350
added web3.eth module request method
cjmcassar Nov 10, 2022
240774a
mapped network id to environment
cjmcassar Nov 10, 2022
248e807
Added comments
cjmcassar Nov 10, 2022
47276ad
removed unused buttons
cjmcassar Nov 11, 2022
8a8b4ab
updated env
cjmcassar Nov 11, 2022
186ab8d
Added chainId
cjmcassar Nov 12, 2022
508d926
Added changes for wally send transaction
cjmcassar Nov 12, 2022
f7144d2
Added dev routes
cjmcassar Nov 12, 2022
b93bd48
*
cjmcassar Nov 12, 2022
2317d65
removed init
cjmcassar Nov 14, 2022
0e28846
added init to main
cjmcassar Nov 14, 2022
66ae552
Removed C.L. and didHandleRedirect option
cjmcassar Nov 14, 2022
c85d725
changed to web3.eth method
cjmcassar Nov 14, 2022
5356c1d
removed provider var
cjmcassar Nov 14, 2022
463679b
updated trailing commas
cjmcassar Nov 15, 2022
f448adb
updated sdk
cjmcassar Nov 15, 2022
b944246
*
cjmcassar Nov 15, 2022
426910b
*
cjmcassar Nov 15, 2022
f410f8b
*
cjmcassar Nov 16, 2022
5c1b207
Updated wally v
cjmcassar Nov 16, 2022
1f5e004
minor variable name change
cjmcassar Nov 16, 2022
67e506a
import from s-dependency of wally
cjmcassar Nov 16, 2022
1453108
Cleaned up unused files
cjmcassar Nov 16, 2022
044f351
Merge pull request #2 from Wally-xyz/test-RPC-methods
cjmcassar Nov 16, 2022
f7dc601
fix: example/package.json & example/package-lock.json to reduce vulne…
snyk-bot Dec 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ lib
.DS_Store

yarn.lock
.eslintcache
.eslintcache
.env.local.example
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "es5"
}
36 changes: 5 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,18 @@
# Web3Modal
# Web3Modal + Wally

A single Web3 / Ethereum provider solution for all Wallets
A single Web3 / Ethereum provider solution with support for wally

## Introduction

Web3Modal is an easy-to-use library to help developers add support for multiple providers in their apps with a simple customizable configuration.

By default Web3Modal Library supports injected providers like ( **Metamask**,**Brave Wallet**, **Dapper**, **Frame**, **Gnosis Safe**, **Tally**, Web3 Browsers, etc) and **WalletConnect**. You can also easily configure the library to support **Coinbase Wallet**, **Torus**, **Portis**, **Fortmatic** and many more.
By default Web3Modal Library supports injected providers like ( **Metamask**,**Brave Wallet**, **Dapper**, **Frame**, **Gnosis Safe**, **Tally**, Web3 Browsers, etc) and **WalletConnect**. This library supports **Wally**, **Torus**, **Portis**, **Fortmatic** and many more.

## Preview

You can test the library on: https://web3modal.com/

![preview](./images/preview.png)

## Projects using `web3modal`

_Open a PR to add your project to the list!_

- [DAO Stack](https://alchemy.daostack.io/)
- [Gnosis Safe](https://gnosis-safe.io/)
- [3Box Hub](https://3box.io/hub/)
- [KnownOrigin](https://knownorigin.io/)
- [Clovers Network](https://clovers.network/)
- [Affogato](https://affogato.co/)
- [Linkdrop](https://dashboard.linkdrop.io/)
- [Dapparatus](https://github.com/austintgriffith/dapparatus/)
- [Totle Swap](https://swap.totle.com/)
- [Win Or Lose](https://www.winorlose.live/)
- [HODLbag NFT](https://hodlbag.org/)
- [Forever in Ether](https://ineth.net/)
- [Civilization](https://app.civfund.org/)
- [OlympusDAO](https://app.olympusdao.finance/)
- [The Unit](https://app.theunit.one/)
- [Sign-in with Ethereum](https://login.xyz/)
- [AngularWeb3Boilerplate](https://github.com/AntonioCardenas/AngularWeb3Boilerplate)
- [BalconyDAO](https://balconydao.com/)
- [LearnWeb3 DAO](https://learnweb3.io/)
- [The Miners Comic](https://theminersnft.com/)
- [Sealcred](https://sealcred.xyz/)
- etc
- [Wally](https://wally.app) - The easiest way to use Ethereum

## Related Efforts

Expand Down Expand Up @@ -105,6 +78,7 @@ const instance = await web3Modal.connect();
const provider = new ethers.providers.Web3Provider(instance);
const signer = provider.getSigner();
```

Here's a live example on [Codesandbox.io](https://codesandbox.io/s/j43b10)

## Using with [Vite](https://github.com/vitejs/vite)
Expand Down
4 changes: 4 additions & 0 deletions custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.png" {
const content: any;
export default content;
}
17 changes: 10 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"@babel/core": "7.12.3",
"@coinbase/wallet-sdk": "^3.0.4",
"@myetherwallet/mewconnect-web-client": "^2.2.0-beta.18",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.2",
"@svgr/webpack": "5.4.0",
"@testing-library/jest-dom": "^5.11.4",
Expand All @@ -22,7 +23,7 @@
"axios": "^0.21.2",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-loader": "8.2.4",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
"bfj": "^7.0.2",
Expand All @@ -47,17 +48,17 @@
"file-loader": "6.1.1",
"fortmatic": "^2.2.1",
"fs-extra": "^9.0.1",
"html-webpack-plugin": "4.5.0",
"html-webpack-plugin": "5.0.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.0",
"jest-circus": "26.6.0",
"jest-resolve": "26.6.0",
"jest-watch-typeahead": "0.6.1",
"mini-css-extract-plugin": "0.11.3",
"mini-css-extract-plugin": "1.0.0",
"optimize-css-assets-webpack-plugin": "5.0.4",
"pnp-webpack-plugin": "1.6.4",
"postcss-flexbugs-fixes": "4.2.1",
"postcss-loader": "3.0.0",
"postcss-loader": "4.0.0",
"postcss-normalize": "8.0.1",
"postcss-preset-env": "6.7.0",
"postcss-safe-parser": "5.0.2",
Expand All @@ -68,20 +69,22 @@
"react-dev-utils": "^11.0.4",
"react-dom": "^17.0.2",
"react-refresh": "^0.8.3",
"react-router-dom": "^6.4.3",
"resolve": "1.18.1",
"resolve-url-loader": "^3.1.2",
"sass-loader": "8.0.2",
"resolve-url-loader": "^4.0.0",
"sass-loader": "9.0.0",
"semver": "7.3.2",
"style-loader": "1.3.0",
"styled-components": "^5.3.3",
"terser-webpack-plugin": "4.2.3",
"ts-pnp": "1.2.0",
"typescript": "^4.0.3",
"url-loader": "4.1.1",
"wally-sdk": "^0.0.4",
"web-vitals": "^0.2.4",
"web3": "^1.3.1",
"web3modal": "file:..",
"webpack": "4.44.2",
"webpack": "5.0.0",
"webpack-dev-server": "3.11.0",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "5.1.4"
Expand Down
18 changes: 18 additions & 0 deletions example/src/components/Main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import { Route, Routes } from "react-router-dom";

import App from "../pages/App";
import HandleRedirect from "../pages/handle-redirect";

const Main = () => {
return (
<Routes>
{" "}
{/* The Switch decides which component to show based on the current URL.*/}
<Route path="/" element={<App />}></Route>
<Route path="/handle-redirect" element={<HandleRedirect />}></Route>
</Routes>
);
};

export default Main;
92 changes: 46 additions & 46 deletions example/src/helpers/bignumber.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
import BigNumber from 'bignumber.js'
import BigNumber from "bignumber.js";

export function isNaN(value: string | number): boolean {
return new BigNumber(`${value}`).isNaN()
return new BigNumber(`${value}`).isNaN();
}

export function isNumber(value: string | number): boolean {
const isNaNResult = isNaN(value)
return !isNaNResult
const isNaNResult = isNaN(value);
return !isNaNResult;
}

export function isInteger(value: string | number): boolean {
return new BigNumber(`${value}`).isInteger()
return new BigNumber(`${value}`).isInteger();
}

export function isPositive(value: string | number): boolean {
return new BigNumber(`${value}`).isPositive()
return new BigNumber(`${value}`).isPositive();
}

export function isNegative(value: string | number): boolean {
return new BigNumber(`${value}`).isNegative()
return new BigNumber(`${value}`).isNegative();
}

export function isZero(value: string | number): boolean {
return new BigNumber(`${value}`).isZero()
return new BigNumber(`${value}`).isZero();
}

export function countDecimalPlaces(value: string | number): number {
return new BigNumber(`${value}`).dp()
return new BigNumber(`${value}`).dp()!;
}

export function convertNumberToString(value: string | number): string {
return new BigNumber(`${value}`).toString()
return new BigNumber(`${value}`).toString();
}

export function convertStringToNumber(value: string | number): number {
return new BigNumber(`${value}`).toNumber()
return new BigNumber(`${value}`).toNumber();
}

export function convertHexToString(hex: string): string {
return new BigNumber(`${hex}`).toString()
return new BigNumber(`${hex}`).toString();
}

export function convertStringToHex(value: string | number): string {
return new BigNumber(`${value}`).toString(16)
return new BigNumber(`${value}`).toString(16);
}

export function greaterThan(
Expand All @@ -52,7 +52,7 @@ export function greaterThan(
return (
new BigNumber(`${numberOne}`).comparedTo(new BigNumber(`${numberTwo}`)) ===
1
)
);
}

export function greaterThanOrEqual(
Expand All @@ -61,7 +61,7 @@ export function greaterThanOrEqual(
): boolean {
return (
new BigNumber(`${numberOne}`).comparedTo(new BigNumber(`${numberTwo}`)) >= 0
)
);
}

export function smallerThan(
Expand All @@ -71,7 +71,7 @@ export function smallerThan(
return (
new BigNumber(`${numberOne}`).comparedTo(new BigNumber(`${numberTwo}`)) ===
-1
)
);
}

export function smallerThanOrEqual(
Expand All @@ -80,7 +80,7 @@ export function smallerThanOrEqual(
): boolean {
return (
new BigNumber(`${numberOne}`).comparedTo(new BigNumber(`${numberTwo}`)) <= 0
)
);
}

export function multiply(
Expand All @@ -89,7 +89,7 @@ export function multiply(
): string {
return new BigNumber(`${numberOne}`)
.times(new BigNumber(`${numberTwo}`))
.toString()
.toString();
}

export function divide(
Expand All @@ -98,7 +98,7 @@ export function divide(
): string {
return new BigNumber(`${numberOne}`)
.dividedBy(new BigNumber(`${numberTwo}`))
.toString()
.toString();
}

export function floorDivide(
Expand All @@ -107,7 +107,7 @@ export function floorDivide(
): string {
return new BigNumber(`${numberOne}`)
.dividedToIntegerBy(new BigNumber(`${numberTwo}`))
.toString()
.toString();
}

export function mod(
Expand All @@ -116,7 +116,7 @@ export function mod(
): string {
return new BigNumber(`${numberOne}`)
.mod(new BigNumber(`${numberTwo}`))
.toString()
.toString();
}

export function add(
Expand All @@ -125,7 +125,7 @@ export function add(
): string {
return new BigNumber(`${numberOne}`)
.plus(new BigNumber(`${numberTwo}`))
.toString()
.toString();
}

export function subtract(
Expand All @@ -134,25 +134,25 @@ export function subtract(
): string {
return new BigNumber(`${numberOne}`)
.minus(new BigNumber(`${numberTwo}`))
.toString()
.toString();
}

export function convertAmountToRawNumber(
value: string | number,
decimals: number = 18
): string {
return new BigNumber(`${value}`)
.times(new BigNumber('10').pow(decimals))
.toString()
.times(new BigNumber("10").pow(decimals))
.toString();
}

export function convertAmountFromRawNumber(
value: string | number,
decimals: number = 18
): string {
return new BigNumber(`${value}`)
.dividedBy(new BigNumber('10').pow(decimals))
.toString()
.dividedBy(new BigNumber("10").pow(decimals))
.toString();
}

export function handleSignificantDecimals(
Expand All @@ -164,42 +164,42 @@ export function handleSignificantDecimals(
!new BigNumber(`${decimals}`).isInteger() ||
(buffer && !new BigNumber(`${buffer}`).isInteger())
) {
return null
return null;
}
buffer = buffer ? convertStringToNumber(buffer) : 3
decimals = convertStringToNumber(decimals)
const absolute = new BigNumber(`${value}`).abs().toNumber()
buffer = buffer ? convertStringToNumber(buffer) : 3;
decimals = convertStringToNumber(decimals);
const absolute = new BigNumber(`${value}`).abs().toNumber();
if (smallerThan(absolute, 1)) {
decimals = value.slice(2).search(/[^0]/g) + buffer
decimals = decimals < 8 ? decimals : 8
decimals = value.slice(2).search(/[^0]/g) + buffer;
decimals = decimals < 8 ? decimals : 8;
} else {
decimals = decimals < buffer ? decimals : buffer
decimals = decimals < buffer ? decimals : buffer;
}
let result = new BigNumber(`${value}`).toFixed(decimals)
result = new BigNumber(`${result}`).toString()
return new BigNumber(`${result}`).dp() <= 2
let result = new BigNumber(`${value}`).toFixed(decimals);
result = new BigNumber(`${result}`).toString();
return new BigNumber(`${result}`).dp()! <= 2
? new BigNumber(`${result}`).toFormat(2)
: new BigNumber(`${result}`).toFormat()
: new BigNumber(`${result}`).toFormat();
}

export function formatFixedDecimals(value: string, decimals: number): string {
const _value = convertNumberToString(value)
const _decimals = convertStringToNumber(decimals)
const _value = convertNumberToString(value);
const _decimals = convertStringToNumber(decimals);
const result = new BigNumber(
new BigNumber(_value).toFixed(_decimals)
).toString()
return result
).toString();
return result;
}

export function formatInputDecimals(
inputOne: string,
inputTwo: string
): string {
const _nativeAmountDecimalPlaces = countDecimalPlaces(inputTwo)
const _nativeAmountDecimalPlaces = countDecimalPlaces(inputTwo);
const decimals =
_nativeAmountDecimalPlaces > 8 ? _nativeAmountDecimalPlaces : 8
_nativeAmountDecimalPlaces > 8 ? _nativeAmountDecimalPlaces : 8;
const result = new BigNumber(formatFixedDecimals(inputOne, decimals))
.toFormat()
.replace(/,/g, '')
return result
.replace(/,/g, "");
return result;
}
Loading