├── .env.example ├── .gitattributes ├── .gitignore ├── .gitmodules ├── .vscode └── settings.json ├── Makefile ├── README.md ├── netlify.toml ├── next-env.d.ts ├── package.json ├── public ├── favicon.ico ├── logo.png ├── logo.svg ├── metamask-fox.svg ├── metamask.svg ├── walletconnect-logo.svg └── walletconnect.png ├── src ├── NextjsChakraDapp.sol ├── NextjsChakraDapp.t.sol ├── assets │ ├── DiscordSVG.tsx │ ├── HeadlineSVG.tsx │ ├── MetaMask.ts │ ├── TwitterSVG.tsx │ ├── WalletConnect.ts │ ├── index.ts │ └── trippyimage.png ├── components │ ├── Footer.tsx │ ├── Header.tsx │ ├── Hero.tsx │ ├── Main.tsx │ ├── MainSection.tsx │ ├── account │ │ ├── AccountModal.tsx │ │ ├── Identicon.tsx │ │ └── index.ts │ ├── index.ts │ ├── landingpage │ │ ├── LandingPageMain.tsx │ │ ├── TrippyArt.tsx │ │ └── index.ts │ ├── mintpage │ │ ├── AppPageMain.tsx │ │ ├── NFTFrame.tsx │ │ ├── OpenBidsFrame.tsx │ │ ├── PlaceBidFrame.tsx │ │ └── index.ts │ └── shared │ │ ├── CTA.tsx │ │ ├── ConnectWallet.tsx │ │ ├── Container.tsx │ │ ├── DarkModeSwitch.tsx │ │ ├── FAQ.tsx │ │ ├── FAQModal.tsx │ │ ├── GlitchButton.tsx │ │ ├── GradientContainer.tsx │ │ ├── GrayButton.tsx │ │ ├── LaunchAppButton.tsx │ │ ├── MintButton.tsx │ │ ├── NascentBadge.tsx │ │ ├── Navbar.tsx │ │ ├── NoShadowButton.tsx │ │ ├── Terminal.tsx │ │ └── index.ts ├── contexts │ ├── Web3Context.tsx │ └── index.ts ├── hooks │ ├── AuthedCallback.ts │ ├── SmallScreen.ts │ └── index.ts ├── pages │ ├── _app.tsx │ ├── _document.tsx │ ├── app.tsx │ └── index.tsx ├── theme.tsx ├── utils │ ├── ChakraUtils.tsx │ ├── ProviderOptions.ts │ ├── Web3Providers.ts │ └── index.ts └── web3context-sdk │ ├── Cache.ts │ ├── Web3ContextClass.ts │ ├── abi │ └── ERC20.json │ ├── index.ts │ ├── node_modules │ ├── .yarn-integrity │ ├── axios │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── SECURITY.md │ │ ├── UPGRADE_GUIDE.md │ │ ├── dist │ │ │ ├── axios.js │ │ │ ├── axios.map │ │ │ ├── axios.min.js │ │ │ └── axios.min.map │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── lib │ │ │ ├── adapters │ │ │ │ ├── README.md │ │ │ │ ├── http.js │ │ │ │ └── xhr.js │ │ │ ├── axios.js │ │ │ ├── cancel │ │ │ │ ├── Cancel.js │ │ │ │ ├── CancelToken.js │ │ │ │ └── isCancel.js │ │ │ ├── core │ │ │ │ ├── Axios.js │ │ │ │ ├── InterceptorManager.js │ │ │ │ ├── README.md │ │ │ │ ├── buildFullPath.js │ │ │ │ ├── createError.js │ │ │ │ ├── dispatchRequest.js │ │ │ │ ├── enhanceError.js │ │ │ │ ├── mergeConfig.js │ │ │ │ ├── settle.js │ │ │ │ └── transformData.js │ │ │ ├── defaults.js │ │ │ ├── helpers │ │ │ │ ├── README.md │ │ │ │ ├── bind.js │ │ │ │ ├── buildURL.js │ │ │ │ ├── combineURLs.js │ │ │ │ ├── cookies.js │ │ │ │ ├── deprecatedMethod.js │ │ │ │ ├── isAbsoluteURL.js │ │ │ │ ├── isAxiosError.js │ │ │ │ ├── isURLSameOrigin.js │ │ │ │ ├── normalizeHeaderName.js │ │ │ │ ├── parseHeaders.js │ │ │ │ ├── spread.js │ │ │ │ └── validator.js │ │ │ └── utils.js │ │ └── package.json │ ├── big.js │ │ ├── CHANGELOG.md │ │ ├── LICENCE.md │ │ ├── README.md │ │ ├── big.js │ │ ├── big.mjs │ │ └── package.json │ └── follow-redirects │ │ ├── LICENSE │ │ ├── README.md │ │ ├── debug.js │ │ ├── http.js │ │ ├── https.js │ │ ├── index.js │ │ └── package.json │ ├── package.json │ └── yarn.lock ├── tsconfig.json └── yarn.lock /.env.example: -------------------------------------------------------------------------------- 1 | MAINNET_ENDPOINT= 2 | PRIVATE_KEY= 3 | RINKEBY_ENDPOINT= 4 | ETHERSCAN_API_KEY= 5 | NODE_ENV= 6 | DEPLOYED_MAINNET_CONTRACT_ADDRESS= 7 | DEPLOYED_RINKEBY_CONTRACT_ADDRESS= 8 | INFURA_PROJECT_ID= 9 | LOG_ROCKET_ID= 10 | DISCORD_INVITE_LINK= 11 | TWITTER_HANDLE= -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # env files 4 | .env 5 | 6 | .vscode/*.log 7 | 8 | # dependencies 9 | /node_modules 10 | /.pnp 11 | .pnp.js 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | 32 | # local env files 33 | .env.local 34 | .env.development.local 35 | .env.test.local 36 | .env.production.local 37 | 38 | # vercel 39 | .vercel 40 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ds-test"] 2 | path = lib/ds-test 3 | url = https://github.com/dapphub/ds-test 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "makefile.extensionOutputFolder": "./.vscode" 3 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all :; dapp build 2 | clean :; dapp clean 3 | test :; dapp test 4 | deploy :; dapp create NextjsChakraDapp 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nextjs, Typescript, Chakra-ui Dapp and Smart Contract Template 2 | 3 | Built with 4 | [Nextjs](https://nextjs.org/), 5 | [Typescript](https://www.typescriptlang.org/), 6 | and [chakra-ui](https://github.com/chakra-ui/chakra-ui). 7 | 8 | ## Using the template 9 | 10 | You can click the `Use this template` button on this repository or clone the repo directly from your terminal with: 11 | 12 | ``` 13 | npx degit abigger87/nextjs-chakra-dapp 14 | ``` 15 | 16 | Then, run the development server: 17 | 18 | ``` 19 | yarn dev 20 | # or 21 | npm run dev 22 | ``` 23 | 24 | Open http://localhost:3000 with your browser to see the result. 25 | 26 | You can start editing the page by modifying src/pages/index.js. The page auto-updates as you edit the file. 27 | 28 | ## Deploying 29 | 30 | [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/abigger87/nextjs-chakra-dapp&project-name=nextjs-chakra-dapp&repository-name=nextjs-chakra-dapp) 31 | 32 | ` 33 | 34 | ## How to use 35 | 36 | Install dependencies with `yarn` 37 | 38 | Run in development mode with `yarn dev` 39 | 40 | ## Where can I learn more? 41 | 42 | #### Next.js 43 | 44 | To learn more about Next.js, take a look at the following resources: 45 | 46 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 47 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 48 | 49 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 50 | 51 | #### Chakra-ui 52 | 53 | [Chakra-ui Documentation](https://chakra-ui.com/docs/getting-started) - learn about Chakra-ui features and API. 54 | 55 | ## Smart Contracts 56 | 57 | Created with the best smart contract framework: [Dapptools](https://dapp.tools/). 58 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "yarn build && yarn export" 3 | publish = "out" -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | 5 | // NOTE: This file should not be edited 6 | // see https://nextjs.org/docs/basic-features/typescript for more information. 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nextjs-chakra-dapp", 3 | "description": "A template web3 Dapp based on nextjs and chakra-ui.", 4 | "author": "Andreas Bigger ", 5 | "private": false, 6 | "license": "MIT", 7 | "scripts": { 8 | "dev": "next dev", 9 | "build": "next build", 10 | "start": "next start", 11 | "lint": "next lint" 12 | }, 13 | "dependencies": { 14 | "@chakra-ui/icons": "^1.0.5", 15 | "@chakra-ui/react": "^1.4.2", 16 | "@chakra-ui/theme-tools": "1.1.2", 17 | "@emotion/react": "11.1.5", 18 | "@emotion/styled": "11.1.5", 19 | "@ensdomains/react-ens-address": "^0.0.30", 20 | "@metamask/jazzicon": "^2.0.0", 21 | "@walletconnect/web3-provider": "^1.6.5", 22 | "@web3-react/core": "^6.1.9", 23 | "@web3-react/injected-connector": "^6.0.7", 24 | "@web3-react/walletconnect-connector": "^6.2.4", 25 | "autoprefixer": "^10.3.4", 26 | "classnames": "^2.3.1", 27 | "debounce": "^1.2.1", 28 | "dotenv": "^10.0.0", 29 | "ethers": "^5.4.7", 30 | "framer-motion": "^4.0.3", 31 | "logrocket": "^2.1.1", 32 | "material-react-toastify": "^1.0.1", 33 | "next": "latest", 34 | "react": "^17.0.2", 35 | "react-console-emulator": "^5.0.1", 36 | "react-dom": "^17.0.2", 37 | "react-i18next": "^11.12.0", 38 | "styled-components": "^5.3.1", 39 | "web3": "^1.5.3", 40 | "web3modal": "^1.9.4" 41 | }, 42 | "devDependencies": { 43 | "@nomiclabs/hardhat-ethers": "^2.0.2", 44 | "@nomiclabs/hardhat-etherscan": "^2.1.6", 45 | "@nomiclabs/hardhat-ganache": "^2.0.1", 46 | "@nomiclabs/hardhat-waffle": "^2.0.1", 47 | "@openzeppelin/contracts": "^4.3.1", 48 | "@types/node": "^14.6.0", 49 | "@types/react": "^17.0.3", 50 | "@types/react-dom": "^17.0.3", 51 | "chai": "^4.3.4", 52 | "dotenv": "^10.0.0", 53 | "eslint": "7.32.0", 54 | "eslint-config-next": "11.1.2", 55 | "ethereum-waffle": "^3.4.0", 56 | "ethers": "^5.4.6", 57 | "hardhat": "^2.6.4", 58 | "prettier": "^2.4.0", 59 | "prettier-plugin-solidity": "^1.0.0-beta.18", 60 | "typescript": "4.3.2" 61 | }, 62 | "prettier": { 63 | "overrides": [ 64 | { 65 | "files": "*.sol", 66 | "options": { 67 | "printWidth": 1000 68 | } 69 | } 70 | ] 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/refcell/nextjs-chakra-dapp/4543c4db141c8c1559630b506999b8046ee3a43f/public/favicon.ico -------------------------------------------------------------------------------- /public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/refcell/nextjs-chakra-dapp/4543c4db141c8c1559630b506999b8046ee3a43f/public/logo.png -------------------------------------------------------------------------------- /public/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/metamask-fox.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 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 | 50 | 51 | 52 | 54 | 56 | 57 | 58 | 59 | 61 | 62 | -------------------------------------------------------------------------------- /public/walletconnect-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WalletConnect 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /public/walletconnect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/refcell/nextjs-chakra-dapp/4543c4db141c8c1559630b506999b8046ee3a43f/public/walletconnect.png -------------------------------------------------------------------------------- /src/NextjsChakraDapp.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.6; 4 | 5 | contract NextjsChakraDapp { 6 | } 7 | -------------------------------------------------------------------------------- /src/NextjsChakraDapp.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.6; 4 | 5 | import "ds-test/test.sol"; 6 | 7 | import "./NextjsChakraDapp.sol"; 8 | 9 | contract NextjsChakraDappTest is DSTest { 10 | NextjsChakraDapp dapp; 11 | 12 | function setUp() public { 13 | dapp = new NextjsChakraDapp(); 14 | } 15 | 16 | function testFail_basic_sanity() public { 17 | assertTrue(false); 18 | } 19 | 20 | function test_basic_sanity() public { 21 | assertTrue(true); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/assets/DiscordSVG.tsx: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | 3 | const Discord = () => ( 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | 16 | const DiscordWrapper = styled.div` 17 | margin: auto; 18 | cursor: pointer; 19 | `; 20 | 21 | const DiscordSVG = ({ mx="0.5em" }) => ( 22 | 23 | 24 | 25 | ); 26 | 27 | export default DiscordSVG 28 | -------------------------------------------------------------------------------- /src/assets/HeadlineSVG.tsx: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | 3 | const Headline = () => ( 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ); 21 | 22 | const HeadlineWrapper = styled.div` 23 | // margin: auto; 24 | // width: 766px; 25 | // height: 254px; 26 | // flex-grow: 0; 27 | // margin: 86px 193px 22px; 28 | // background-image: linear-gradient(70deg, #ff02cc 2%, #8444df 32%, #63cea6 66%, #d67336 115%); 29 | // fill: linear-gradient(70deg, #ff02cc 2%, #8444df 32%, #63cea6 66%, #d67336 115%); 30 | `; 31 | 32 | const HeadlineSVG = () => ( 33 | 34 | 35 | 36 | ); 37 | 38 | export default HeadlineSVG; -------------------------------------------------------------------------------- /src/assets/TwitterSVG.tsx: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | 3 | const Twitter = () => ( 4 | 5 | 6 | 7 | 8 | 9 | ); 10 | 11 | const TwitterWrapper = styled.div` 12 | margin: auto; 13 | cursor: pointer; 14 | `; 15 | 16 | const TwitterSVG = ({ mx="0.5em" }) => ( 17 | 18 | 19 | 20 | ); 21 | 22 | export default TwitterSVG; -------------------------------------------------------------------------------- /src/assets/index.ts: -------------------------------------------------------------------------------- 1 | export { default as DiscordSVG } from './DiscordSVG'; 2 | export { default as HeadlineSVG } from './HeadlineSVG'; 3 | export { default as MetaMask } from './MetaMask'; 4 | export { default as TwitterSVG } from './TwitterSVG'; 5 | export { default as WalletConnect } from './WalletConnect'; -------------------------------------------------------------------------------- /src/assets/trippyimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/refcell/nextjs-chakra-dapp/4543c4db141c8c1559630b506999b8046ee3a43f/src/assets/trippyimage.png -------------------------------------------------------------------------------- /src/components/Footer.tsx: -------------------------------------------------------------------------------- 1 | import { Flex, FlexProps } from '@chakra-ui/react' 2 | 3 | const Footer = (props: FlexProps) => ( 4 | 5 | ) 6 | 7 | export default Footer -------------------------------------------------------------------------------- /src/components/Header.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | import Link from "next/link"; 3 | 4 | const Header = ({ logoText, menuItems, showMenuItems }) => { 5 | const [isMobile, setIsMobile] = useState(false); 6 | const [showMoreDesktop, setShowMoreDesktop] = useState(false); 7 | const [showMoreMobile, setShowMoreMobile] = useState(false); 8 | 9 | function windowIsMobile() { 10 | const mobileQuery = getComputedStyle(document.body).getPropertyValue( 11 | "--phoneWidth" 12 | ); 13 | return window.matchMedia(mobileQuery).matches; 14 | } 15 | 16 | useEffect(() => { 17 | setIsMobile(windowIsMobile()); 18 | }, []); 19 | 20 | useEffect(() => { 21 | window.addEventListener("resize", () => { 22 | setIsMobile(windowIsMobile()); 23 | }); 24 | }, []); 25 | 26 | const shownItems = menuItems.slice(0, showMenuItems); 27 | const hiddenItems = menuItems.slice(showMenuItems); 28 | 29 | function renderMenuItems(items) { 30 | return items.map((item) => ( 31 |
  • 32 | 33 | {item.name} 34 | 35 |
  • 36 | )); 37 | } 38 | 39 | return ( 40 |
    41 |
    42 | 47 | {!!menuItems.length && ( 48 |
    setShowMoreMobile((prev) => !prev)} 51 | > 52 | menu 53 |
    54 | )} 55 |
    56 | 82 |
    83 | ); 84 | } 85 | 86 | export default Header; -------------------------------------------------------------------------------- /src/components/Hero.tsx: -------------------------------------------------------------------------------- 1 | import { Flex, Heading } from '@chakra-ui/react' 2 | 3 | const Hero = ({ title = 'Nextjs Chakra Dapp Template' }: { title: string }) => ( 4 | 10 | 🤖 11 | {title} 12 | 13 | 14 | ) 15 | 16 | export default Hero; -------------------------------------------------------------------------------- /src/components/Main.tsx: -------------------------------------------------------------------------------- 1 | import { Stack, StackProps } from "@chakra-ui/react"; 2 | 3 | const Main = (props: StackProps) => ( 4 | 13 | ); 14 | 15 | export default Main; 16 | -------------------------------------------------------------------------------- /src/components/MainSection.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import Web3 from "web3"; 3 | import Web3Modal from "web3modal"; 4 | import { ConnectWallet, MintButton } from './'; 5 | import { useWeb3React, Web3ReactProvider } from "@web3-react/core"; 6 | import { Button, Container, useColorMode } from "@chakra-ui/react"; 7 | import styled from "@emotion/styled"; 8 | import { ProviderOptions } from "src/utils"; 9 | import { Web3Provider } from "@ethersproject/providers"; 10 | 11 | const MainSection = () => { 12 | const { colorMode } = useColorMode(); 13 | const [provider, setProvider] = useState(null); 14 | const [web3, setWeb3] = useState(null); 15 | const [web3Modal, setWeb3Modal] = useState(null); 16 | const [account, setAccount] = useState(null); 17 | const [connected, setConnected] = useState(false); 18 | 19 | useEffect(() => { 20 | if(provider) { 21 | setConnected(provider.isConnected()); 22 | } 23 | }, [provider]) 24 | 25 | useEffect(() => { 26 | if(window !== undefined) { 27 | setWeb3Modal(new Web3Modal({ 28 | cacheProvider: false, 29 | providerOptions: ProviderOptions, 30 | theme: colorMode == 'light' ? 'light' : 'dark' 31 | })); 32 | } 33 | }, []); 34 | 35 | // ** Function to get the current account 36 | const getAccount = async (curr_web3) => { 37 | const accounts = await curr_web3.eth.getAccounts(); 38 | setAccount(accounts[0]); 39 | } 40 | 41 | // ** Function to open web3 modal 42 | const openModal = async () => { 43 | if(web3Modal) { 44 | const new_provider = await web3Modal.connect(); 45 | const new_web3 = new Web3(new_provider); 46 | getAccount(new_web3); 47 | 48 | // ** Subscribe to accounts change 49 | new_provider.on("accountsChanged", (accounts) => { 50 | console.log("account changed!") 51 | getAccount(new_web3); 52 | }); 53 | 54 | // ** Subscribe to chainId change 55 | new_provider.on("chainChanged", (chainId) => { 56 | console.log("chain changed!"); 57 | getAccount(new_web3); 58 | }); 59 | 60 | // ** Subscribe to networkId change 61 | new_provider.on("networkChanged", (networkId) => { 62 | console.log("network changed!"); 63 | getAccount(new_web3); 64 | }); 65 | 66 | // ** Update State 67 | setProvider(new_provider); 68 | setWeb3(new_web3); 69 | } 70 | } 71 | 72 | // ** Function to disconnect web3 account 73 | const disconnectModal = async () => { 74 | console.log("in disconnect modal func"); 75 | console.log("provider:", provider); 76 | try { 77 | console.log("web3 current provider:", web3.currentProvider); 78 | console.log(web3Modal); 79 | await web3.currentProvider.disconnect(); 80 | await web3Modal.clearCachedProvider(); 81 | setProvider(null); 82 | } catch (e) { 83 | console.error("Failed to close provider:", e) 84 | } 85 | 86 | } 87 | 88 | return ( 89 | web3}> 90 | 99 | 111 | 112 | 113 | ) 114 | } 115 | 116 | const NoMarginContainer = styled(Container)` 117 | margin-top: 0 !important; 118 | `; 119 | 120 | export default MainSection; 121 | -------------------------------------------------------------------------------- /src/components/account/AccountModal.tsx: -------------------------------------------------------------------------------- 1 | // AccountModal.tsx 2 | import { 3 | Box, 4 | Button, 5 | Flex, 6 | Link, 7 | Modal, 8 | ModalOverlay, 9 | ModalContent, 10 | ModalHeader, 11 | ModalFooter, 12 | ModalBody, 13 | ModalCloseButton, 14 | Text, 15 | } from "@chakra-ui/react"; 16 | import { ExternalLinkIcon, CopyIcon } from "@chakra-ui/icons"; 17 | import Identicon from "./Identicon"; 18 | import { useWeb3Context } from "src/contexts/Web3Context"; 19 | 20 | type AccountModalProps = { 21 | isOpen: any; 22 | onClose: any; 23 | }; 24 | 25 | const AccountModal = ({ isOpen, onClose }: AccountModalProps) => { 26 | const { address, logout } = useWeb3Context(); 27 | 28 | // ** Deactivate/logout with Disclosure ** 29 | function handleDeactivateAccount() { 30 | logout(); 31 | onClose(); 32 | } 33 | 34 | return ( 35 | 36 | 37 | 44 | 45 | Account 46 | 47 | 54 | 55 | 65 | 66 | 67 | Connected with MetaMask 68 | 69 | 88 | 89 | 90 | 91 | 98 | {address && 99 | `${address.slice(0, 6)}...${address.slice( 100 | address.length - 4, 101 | address.length 102 | )}`} 103 | 104 | 105 | 106 | 119 | 132 | 133 | View on Explorer 134 | 135 | 136 | 137 | 138 | 139 | 146 | 152 | Your transactions willl appear here... 153 | 154 | 155 | 156 | 157 | ); 158 | }; 159 | 160 | export default AccountModal; 161 | -------------------------------------------------------------------------------- /src/components/account/Identicon.tsx: -------------------------------------------------------------------------------- 1 | // Identicon.tsx 2 | import { useEffect, useRef } from "react"; 3 | import styled from "@emotion/styled"; 4 | import { useWeb3Context } from "src/contexts/Web3Context"; 5 | import Jazzicon from "@metamask/jazzicon"; 6 | 7 | const StyledIdenticon = styled.div` 8 | height: 1rem; 9 | width: 1rem; 10 | border-radius: 1.125rem; 11 | background-color: black; 12 | `; 13 | 14 | export default function Identicon() { 15 | const ref = useRef(); 16 | const { address } = useWeb3Context(); 17 | 18 | useEffect(() => { 19 | if (address && ref.current) { 20 | ref.current.innerHTML = ""; 21 | ref.current.appendChild(Jazzicon(16, parseInt(address.slice(2, 10), 16))); 22 | } 23 | }, [address]); 24 | 25 | return ; 26 | } 27 | -------------------------------------------------------------------------------- /src/components/account/index.ts: -------------------------------------------------------------------------------- 1 | export { default as AccountModal } from "./AccountModal"; 2 | export { default as Identicon } from "./Identicon"; 3 | -------------------------------------------------------------------------------- /src/components/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./account"; 2 | export * from "./landingpage"; 3 | export * from "./mintpage"; 4 | export * from "./shared"; 5 | 6 | export { default as Footer } from "./Footer"; 7 | export { default as Header } from "./Header"; 8 | export { default as Hero } from "./Hero"; 9 | export { default as Main } from "./Main"; 10 | export { default as MainSection } from './MainSection'; -------------------------------------------------------------------------------- /src/components/landingpage/LandingPageMain.tsx: -------------------------------------------------------------------------------- 1 | import { Flex } from "@chakra-ui/react"; 2 | import styled from "@emotion/styled"; 3 | import { TrippyArt } from "."; 4 | 5 | const PageGroup = styled.div` 6 | margin-left: auto; 7 | margin-right: auto; 8 | display: flex; 9 | flex-direction: column; 10 | align-items: center; 11 | padding-top: 1em; 12 | max-width: 800px; 13 | 14 | @media (max-width: 900px) { 15 | max-width: 600px; 16 | } 17 | `; 18 | 19 | const MinorHeading = styled.p` 20 | font-family: Impact; 21 | font-size: 26px; 22 | font-weight: lighter; 23 | line-height: 1.35; 24 | letter-spacing: 0.028em; 25 | text-align: center; 26 | color: #fff; 27 | padding-top: 1em; 28 | padding-bottom: 1em; 29 | max-width: 600px; 30 | margin-left: auto; 31 | margin-right: auto; 32 | 33 | @media (max-width: 900px) { 34 | font-size: 22px; 35 | max-width: 400px; 36 | } 37 | `; 38 | 39 | const BigBreak = styled.div` 40 | padding: 2em; 41 | `; 42 | 43 | const LandingPageMainBlurb = styled.h1` 44 | padding-top: 0.5em; 45 | padding-bottom: 0.5em; 46 | font-family: Impact; 47 | font-size: 60px; 48 | line-height: 60px; 49 | font-weight: 900; 50 | font-stretch: normal; 51 | font-style: normal; 52 | background-image: linear-gradient( 53 | 70deg, 54 | #ff02cc 2%, 55 | #8444df 32%, 56 | #63cea6 66%, 57 | #d67336 115% 58 | ); 59 | text-transform: uppercase; 60 | background-clip: text; 61 | color: transparent !important; 62 | text-align: center; 63 | letter-spacing: 0.02em; 64 | text-decoration: none; 65 | display: inline-block; 66 | transform: scale(1, 1.6); 67 | -webkit-transform: scale(1, 1.6); /* Safari and Chrome */ 68 | -moz-transform: scale(1, 1.6); /* Firefox */ 69 | -ms-transform: scale(1, 1.6); /* IE 9+ */ 70 | -o-transform: scale(1, 1.6); /* Opera */ 71 | 72 | @media (max-width: 900px) { 73 | font-size: 60px; 74 | line-height: 60px; 75 | } 76 | 77 | @media (max-width: 600px) { 78 | padding-bottom: 1em; 79 | } 80 | `; 81 | 82 | const LandingPageMain = () => ( 83 | 84 | 85 | 86 | ⚡ Supercharge your Dapp ⚡ 87 | 88 | 89 | Leverage Nextjs and Chakra for your dapp. 90 | 91 | 92 | 93 | 94 | 95 | ); 96 | 97 | export default LandingPageMain; 98 | -------------------------------------------------------------------------------- /src/components/landingpage/TrippyArt.tsx: -------------------------------------------------------------------------------- 1 | import { Flex } from "@chakra-ui/layout"; 2 | import React from "react"; 3 | import styled from "styled-components"; 4 | 5 | const MainTrippyImage = styled.img` 6 | width: 212px; 7 | height: 213px; 8 | flex-grow: 0; 9 | margin: auto; 10 | transform: rotate(13deg); 11 | border-radius: 16px; 12 | grid-column-start: 1; 13 | grid-row-start: 1; 14 | z-index: 1; 15 | `; 16 | 17 | const MainShadowBackground = styled.div` 18 | width: 215px; 19 | height: 215px; 20 | flex-grow: 0; 21 | margin: auto; 22 | transform: rotate(13deg); 23 | -webkit-filter: blur(25px); 24 | filter: blur(25px); 25 | background-color: #d42bd2; 26 | grid-column-start: 1; 27 | grid-row-start: 1; 28 | `; 29 | 30 | const TrippyArt = () => { 31 | return ( 32 | 33 | 34 | 35 | 36 | 37 | 38 | ); 39 | }; 40 | 41 | export default TrippyArt; 42 | -------------------------------------------------------------------------------- /src/components/landingpage/index.ts: -------------------------------------------------------------------------------- 1 | export { default as LandingPageMain } from "./LandingPageMain"; 2 | export { default as TrippyArt } from "./TrippyArt"; 3 | -------------------------------------------------------------------------------- /src/components/mintpage/AppPageMain.tsx: -------------------------------------------------------------------------------- 1 | import { Flex } from "@chakra-ui/react"; 2 | import styled from "@emotion/styled"; 3 | import { PlaceBidFrame, NFTFrame, OpenBidsFrame } from "."; 4 | 5 | const PageGroup = styled.div` 6 | flex-grow: 1; 7 | display: flex; 8 | flex-direction: column; 9 | align-items: center; 10 | `; 11 | 12 | const BidRow = styled.div` 13 | width: 100%; 14 | display: flex; 15 | flex-direction: row; 16 | align-items: center; 17 | justify-content: space-between; 18 | padding-bottom: 2em; 19 | `; 20 | 21 | const OpenBidRow = styled.div` 22 | margin: auto; 23 | width: 100%; 24 | flex-grow: 1; 25 | display: flex; 26 | flex-direction: row; 27 | align-items: center; 28 | justify-content: space-between; 29 | `; 30 | 31 | const MarginEightPix = styled.div` 32 | max-width: 800px; 33 | width: 100%; 34 | margin: 2em auto auto auto; 35 | `; 36 | 37 | const AppPageMain = () => ( 38 | 39 | 40 | 41 |

    insert stuff here...

    42 | {/* 43 | 44 | 45 | 46 | 47 | 48 | */} 49 |
    50 |
    51 |
    52 | ); 53 | 54 | export default AppPageMain; 55 | -------------------------------------------------------------------------------- /src/components/mintpage/NFTFrame.tsx: -------------------------------------------------------------------------------- 1 | import { Flex } from "@chakra-ui/layout"; 2 | import styled from "@emotion/styled"; 3 | 4 | const NFTBox = styled.div` 5 | height: auto; 6 | margin: 0 0 auto auto; 7 | border-radius: 24px; 8 | display: flex; 9 | flex-direction: column; 10 | `; 11 | 12 | const TrippyImage = styled.img` 13 | width: 212px; 14 | height: 213px; 15 | flex-grow: 0; 16 | margin: auto; 17 | border-radius: 16px; 18 | grid-column-start: 1; 19 | grid-row-start: 1; 20 | z-index: 1; 21 | `; 22 | 23 | const ShadowBackground = styled.div` 24 | width: 215px; 25 | height: 215px; 26 | flex-grow: 0; 27 | margin: auto; 28 | -webkit-filter: blur(25px); 29 | filter: blur(25px); 30 | background-color: #d42bd2; 31 | grid-column-start: 1; 32 | grid-row-start: 1; 33 | `; 34 | 35 | const DropTitle = styled.p` 36 | min-width: 157px; 37 | min-height: 28px; 38 | font-family: Roboto; 39 | font-weight: bold; 40 | font-size: 20px; 41 | font-stretch: normal; 42 | font-style: normal; 43 | line-height: 1.4; 44 | letter-spacing: normal; 45 | text-align: left; 46 | color: #fff; 47 | padding: 0.5em 0 0.5em 0; 48 | `; 49 | 50 | const DropDateTime = styled.p` 51 | min-width: 105px; 52 | min-height: 56px; 53 | width: min-width; 54 | font-family: Roboto; 55 | font-size: 20px; 56 | font-weight: 300; 57 | font-stretch: normal; 58 | font-style: normal; 59 | line-height: 1.4; 60 | letter-spacing: normal; 61 | text-align: left; 62 | color: #fff; 63 | padding: 0.2em 0 0 0; 64 | `; 65 | 66 | const LeftAutoMarginWrapper = styled.div` 67 | margin-left: auto; 68 | `; 69 | 70 | const NFTFrame = ({ 71 | title = "ArtBlocks Launch", 72 | dateTime = "04/02/2021 16:40 PST", 73 | }) => { 74 | return ( 75 | 76 | 77 | 78 | 79 | 80 | 81 | {title} 82 | {dateTime} 83 | 84 | 85 | ); 86 | }; 87 | 88 | export default NFTFrame; 89 | -------------------------------------------------------------------------------- /src/components/mintpage/OpenBidsFrame.tsx: -------------------------------------------------------------------------------- 1 | import { Table } from "@chakra-ui/table"; 2 | import styled from "@emotion/styled"; 3 | 4 | const BidBox = styled.div` 5 | min-width: 480px; 6 | height: auto; 7 | width: 100%; 8 | margin: 2em auto auto 0; 9 | padding: 1em; 10 | border-radius: 24px; 11 | background-color: #191b1f; 12 | display: flex; 13 | flex-direction: column; 14 | justify-content: space-between; 15 | `; 16 | 17 | const PlaceBidText = styled.p` 18 | height: auto; 19 | // margin: auto; 20 | font-family: Roboto; 21 | font-size: 20px; 22 | font-weight: bold; 23 | font-stretch: normal; 24 | font-style: normal; 25 | line-height: 1.4; 26 | letter-spacing: normal; 27 | text-align: left; 28 | color: #fff; 29 | padding-bottom: 1em; 30 | `; 31 | 32 | const DataFormText = styled.div` 33 | padding-top: 1em; 34 | padding-bottom: 1em; 35 | display: flex; 36 | justify-content: space-between; 37 | flex-direction: row; 38 | `; 39 | 40 | const HeaderText = styled.p` 41 | height: auto; 42 | // margin: auto; 43 | font-family: Roboto; 44 | font-size: 18px; 45 | font-weight: 300; 46 | font-stretch: normal; 47 | font-style: normal; 48 | line-height: 1.56; 49 | letter-spacing: normal; 50 | text-align: left; 51 | color: #fff; 52 | `; 53 | 54 | const CustomTable = styled(Table)` 55 | width: 100%; 56 | height: auto; 57 | margin: auto; 58 | border-radius: 1em; 59 | border: solid 1px #2c2f36; 60 | background-color: #212429; 61 | `; 62 | 63 | const OpenBidsFrame = () => { 64 | return ( 65 | 66 | Open Bids 67 | 68 | Date 69 | Quantity 70 | Total 71 | 72 | 73 | 74 | ); 75 | }; 76 | 77 | export default OpenBidsFrame; 78 | -------------------------------------------------------------------------------- /src/components/mintpage/index.ts: -------------------------------------------------------------------------------- 1 | export { default as OpenBidsFrame } from "./OpenBidsFrame"; 2 | export { default as PlaceBidFrame } from "./PlaceBidFrame"; 3 | export { default as AppPageMain } from "./AppPageMain"; 4 | export { default as NFTFrame } from "./NFTFrame"; 5 | -------------------------------------------------------------------------------- /src/components/shared/CTA.tsx: -------------------------------------------------------------------------------- 1 | import { Link as ChakraLink, Text, Flex } from "@chakra-ui/react"; 2 | import { useTranslation } from "react-i18next"; 3 | 4 | import { FAQModal, GrayButton } from "."; 5 | 6 | const CTA = ({ onOpen }) => { 7 | const { t } = useTranslation(); 8 | return ( 9 | 18 | 19 | 27 | 28 | 29 | {t("FAQ")} 30 | 31 | 32 | 39 | Github 40 | 41 | 42 | 49 | 50 | Built with ❤️ by{" "} 51 | 56 | Andreas Bigger 57 | {" "} 58 | @{" "} 59 | 60 | Nascent 61 | {" "} 62 | and{" "} 63 | 68 | Permætheus 69 | {" "} 70 | 71 | 72 | 79 | 80 | Say thanks by donating to{" "} 81 | 86 | The Giving Block Charities 87 | {" "} 88 | ❤️ 89 | 90 | 91 | 92 | 93 | ); 94 | }; 95 | 96 | export default CTA; 97 | -------------------------------------------------------------------------------- /src/components/shared/ConnectWallet.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Box, Text, useDisclosure } from "@chakra-ui/react"; 2 | import { useCallback } from "react"; 3 | import styled from "@emotion/styled"; 4 | import { useTranslation } from "react-i18next"; 5 | 6 | import { Identicon, AccountModal } from "src/components"; 7 | import { useWeb3Context } from "src/contexts/Web3Context"; 8 | import { useAuthedCallback, useIsSmallScreen } from "src/hooks"; 9 | 10 | const ButtonWrapper = styled.div` 11 | margin-left: var(--chakra-space-2); 12 | margin-right: var(--chakra-space-2); 13 | flex-grow: 0; 14 | `; 15 | 16 | const NoShadowButton = styled(Button)` 17 | &:focus { 18 | outline: 0 !important; 19 | box-shadow: none !important; 20 | } 21 | `; 22 | 23 | const ConnectWallet = ({ fullWidth = false, darkerBackground = false }) => { 24 | const { address, isAuthed, balance, login, isAttemptingLogin } = useWeb3Context(); 25 | 26 | const { 27 | isOpen: isWeb3ModalOpen, 28 | onOpen: openWeb3Modal, 29 | onClose: closeWeb3Modal, 30 | } = useDisclosure(); 31 | 32 | const openModal = useAuthedCallback(openWeb3Modal); 33 | 34 | const { t } = useTranslation(); 35 | 36 | const isMobile = useIsSmallScreen(); 37 | 38 | const handleAccountButtonClick = useCallback(() => { 39 | if (isAuthed) { 40 | openModal(); 41 | } else login(); 42 | }, [isAuthed, login, openModal]); 43 | 44 | return ( 45 | 46 | {isAuthed ? ( 47 | 54 | 55 | 56 | {balance && balance.toFixed(3)} ETH 57 | 58 | 59 | 74 | 75 | {address && 76 | `${address.slice(0, 6)}...${address.slice( 77 | address.length - 4, 78 | address.length 79 | )}`} 80 | 81 | 82 | 83 | 84 | 85 | ) : ( 86 | 99 | {t("Connect Wallet")} 100 | 101 | )} 102 | 103 | ); 104 | }; 105 | 106 | export default ConnectWallet; 107 | -------------------------------------------------------------------------------- /src/components/shared/Container.tsx: -------------------------------------------------------------------------------- 1 | import { Flex, useColorMode, FlexProps } from "@chakra-ui/react"; 2 | 3 | const Container = (props: FlexProps) => { 4 | const { colorMode } = useColorMode(); 5 | 6 | const bgColor = { light: "gray.50", dark: "gray.900" }; 7 | 8 | const color = { light: "black", dark: "white" }; 9 | 10 | return ( 11 | 19 | ); 20 | }; 21 | 22 | export default Container; 23 | -------------------------------------------------------------------------------- /src/components/shared/DarkModeSwitch.tsx: -------------------------------------------------------------------------------- 1 | import { useColorMode } from '@chakra-ui/react' 2 | import { MoonIcon, SunIcon } from '@chakra-ui/icons' 3 | 4 | const DarkModeSwitch = () => { 5 | const { colorMode, toggleColorMode } = useColorMode() 6 | const isDark = colorMode === 'dark' 7 | return isDark ? ( 8 | toggleColorMode()} /> 9 | ) : ( 10 | toggleColorMode()} /> 11 | ); 12 | } 13 | 14 | export default DarkModeSwitch -------------------------------------------------------------------------------- /src/components/shared/FAQ.tsx: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | 3 | const FAQP = styled.p` 4 | width: auto; 5 | height: auto; 6 | flex-grow: 0; 7 | font-family: Roboto; 8 | font-size: 16px; 9 | font-weight: bold; 10 | font-stretch: normal; 11 | font-style: normal; 12 | line-height: 2.03; 13 | letter-spacing: normal; 14 | text-align: left; 15 | color: #c8cacf; 16 | cursor: pointer; 17 | margin: auto; 18 | `; 19 | 20 | const FAQ = ({ mx = "0.5em" }) => ( 21 | FAQ 22 | ); 23 | 24 | export default FAQ; 25 | -------------------------------------------------------------------------------- /src/components/shared/FAQModal.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | Modal, 3 | ModalOverlay, 4 | ModalContent, 5 | ModalHeader, 6 | ModalFooter, 7 | ModalBody, 8 | ModalCloseButton, 9 | Button, 10 | Heading, 11 | Text, 12 | OrderedList, 13 | ListItem, 14 | Link as ChakraLink, 15 | UnorderedList, 16 | Stack, 17 | Flex, 18 | Code, 19 | } from "@chakra-ui/react"; 20 | import { ExternalLinkIcon } from "@chakra-ui/icons"; 21 | import { useTranslation } from "react-i18next"; 22 | 23 | import { NascentBadge } from "."; 24 | 25 | const FAQModal = ({ isOpen = false, onClose = () => {} }) => { 26 | const { t } = useTranslation(); 27 | return ( 28 | 29 | 30 | 31 | {t("FAQ")} 32 | 33 | 34 | 35 | 36 | {t("Why Nextjs Chakra Dapp?")} 37 | 38 | {t("The current web3 dapp landscape is difficult to navigate.")} 39 | 40 | {t("This is a clean project slate using")} 41 | 46 | 53 | Next.js 54 | 55 | 56 | 57 | 58 | {" "} 59 | and 60 | 65 | 72 | Chakra-ui 73 | 74 | 75 | 76 | 77 | 78 | 79 | {t("Building on this template means:")} 80 | 81 | 82 | {t( 83 | "You don't have to manage web3 independently in each page. It is abstracted in a custom hook." 84 | )} 85 | 86 | 87 | {t( 88 | "You can relieve your styling worries using the many Chakra prebuilt components!" 89 | )} 90 | 91 | {t("You can quickly deploy on Vercel for extremely rapid development.")} 92 | 93 | 94 | 95 | 96 | 97 | {t("What Can't Nextjs Chakra Dapp Do?")} 98 | 99 | {t("We do not provide contracts. Basic Dapptools-generated contracts exists in the src/ directory.")} 100 | {t("Not guaranteed to be bug free! This was basically hacked together in one sitting!")} 101 | {t("Provide the contract SDK to integrate into the Dapp. This must be done yourself in the src/web3context-sdk directory.")} 102 | 103 | 104 | 105 | 106 | {t("Who's built Nextjs Chakra Dapp?")} 107 | 108 | 109 | 110 | 111 | 118 | Andreas Bigger 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 135 | Permætheus 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | {t("How to reach out to the Nextjs Chakra Dapp builders?")} 148 | 149 | 150 | 151 | {t( 152 | "Reach out to us on Twitter (links above) or create an issue on the" 153 | )} 154 | 155 | 160 | 166 | github 167 | 168 | 169 | 170 | 171 | ! 172 | 173 | 174 | 175 | 176 | 177 | 180 | 181 | 182 | 183 | ); 184 | }; 185 | 186 | export default FAQModal; 187 | -------------------------------------------------------------------------------- /src/components/shared/GlitchButton.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import styled from 'styled-components'; 3 | 4 | const BtnButton = styled.button` 5 | width: 100%; 6 | max-width: 200px; 7 | padding: 0.5em; 8 | height: auto; 9 | min-height: 40px; 10 | border: 0; 11 | outline: none; 12 | background-color: #000000; 13 | cursor: pointer; 14 | position: relative; 15 | font-family: Tomorrow, sans-serif; 16 | font-size: .85rem; 17 | text-transform: uppercase; 18 | color: #000000; 19 | display: inline-block; 20 | clip-path: polygon(92% 0, 100% 25%, 100% 100%, 8% 100%, 0% 75%, 0 0); 21 | `; 22 | 23 | interface BtnContentProps { 24 | color: string; 25 | } 26 | 27 | const BtnContent = styled.span` 28 | display: flex; 29 | align-items: center; 30 | justify-content: center; 31 | position: absolute; 32 | top: 2px; 33 | left: 2px; 34 | right: 2px; 35 | bottom: 2px; 36 | background-color: ${props => props.color}; 37 | clip-path: polygon(92% 0, 100% 25%, 100% 100%, 8% 100%, 0% 75%, 0 0); 38 | `; 39 | 40 | BtnContent.defaultProps = { 41 | color: "" 42 | } 43 | 44 | const BtnGlitch = styled.span` 45 | display: none; 46 | position: absolute; 47 | top: 0; 48 | left: 0; 49 | width: 100%; 50 | height: 100%; 51 | background-color: ${props => props.color}; 52 | filter: drop-shadow(-2px 3px ${props => props.color}) drop-shadow(-1px -3px ${props => props.color}) drop-shadow(2px 1px ${props => props.color}); 53 | `; 54 | 55 | const GlitchButton = ({ disabled=false, id = "glitch-btn", color, glitchColor, content = "", onclick }: { disabled: boolean, id: string, color: string, glitchColor: string, content: string, onclick: Function }) => { 56 | 57 | return ( 58 | <> 59 | 60 | {content} 61 | 62 | r25 63 | 64 | 165 | 166 | ) 167 | } 168 | 169 | export default GlitchButton; -------------------------------------------------------------------------------- /src/components/shared/GradientContainer.tsx: -------------------------------------------------------------------------------- 1 | import styled from "@emotion/styled"; 2 | import { Container } from "."; 3 | 4 | const GC = styled(Container)` 5 | height: auto; 6 | min-height: 100%; 7 | background-image: linear-gradient(to bottom, #243027, #1c1818); 8 | `; 9 | 10 | const GradientContainer = ({ children }) => {children}; 11 | 12 | export default GradientContainer; 13 | -------------------------------------------------------------------------------- /src/components/shared/GrayButton.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from "@chakra-ui/react"; 2 | import styled from "@emotion/styled"; 3 | 4 | const GrayButton = styled(Button)` 5 | border: 1px; 6 | border-color: var(--chakra-colors-gray-600); 7 | background: var(--chakra-colors-gray-700); 8 | border-style: solid; 9 | 10 | &:hover { 11 | border-color: var(--chakra-colors-blue-800); 12 | background-color: var(--chakra-colors-gray-600); 13 | } 14 | 15 | &:focus { 16 | outline: 0 !important; 17 | box-shadow: none !important; 18 | } 19 | `; 20 | 21 | export default GrayButton; 22 | -------------------------------------------------------------------------------- /src/components/shared/LaunchAppButton.tsx: -------------------------------------------------------------------------------- 1 | import { Link as ChakraLink, Button } from "@chakra-ui/react"; 2 | import { GrayButton } from "./"; 3 | 4 | const LaunchAppButton = () => { 5 | return ( 6 | 7 | Launch App 8 | 9 | ); 10 | }; 11 | 12 | export default LaunchAppButton; 13 | -------------------------------------------------------------------------------- /src/components/shared/MintButton.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | Link as ChakraLink, 3 | Button 4 | } from '@chakra-ui/react'; 5 | 6 | const MintButton = ({ 7 | className, 8 | link = "https://github.com/abigger87/nextjs-chakra-dapp", 9 | ...props 10 | }) => { 11 | return ( 12 | 18 | 21 | 22 | ); 23 | }; 24 | 25 | export default MintButton; -------------------------------------------------------------------------------- /src/components/shared/NascentBadge.tsx: -------------------------------------------------------------------------------- 1 | import { Link as ChakraLink, Badge } from "@chakra-ui/react"; 2 | 3 | const NascentBadge = () => { 4 | return ( 5 | 6 | 7 | Nascent 8 | 9 | 10 | ); 11 | }; 12 | 13 | export default NascentBadge; 14 | -------------------------------------------------------------------------------- /src/components/shared/Navbar.tsx: -------------------------------------------------------------------------------- 1 | import { Link as ChakraLink, Flex, Heading} from "@chakra-ui/react"; 2 | import styled from "@emotion/styled"; 3 | import { DiscordSVG, TwitterSVG } from "src/assets"; 4 | import { ConnectWallet, FAQ, LaunchAppButton } from "."; 5 | 6 | const StyledTitle = styled.div` 7 | margin-right: auto; 8 | margin-left: 1em; 9 | `; 10 | 11 | const LaunchGroup = styled.div` 12 | margin-left: auto; 13 | display: flex; 14 | flex-direction: row; 15 | min-width: 300px; 16 | 17 | @media (max-width: 600px) { 18 | min-width: 100px; 19 | flex-direction: column; 20 | margin: auto 0 auto auto; 21 | } 22 | `; 23 | 24 | const NavbarFlex = styled(Flex)` 25 | min-height: 100px; 26 | height: auto; 27 | max-height: 150px; 28 | padding: var(--chakra-space-8); 29 | `; 30 | 31 | const LinkWrapper = styled.div` 32 | display: flex; 33 | flex-direction: row; 34 | 35 | @media (max-width: 600px) { 36 | position: absolute; 37 | top: 0.5em; 38 | width: 100%; 39 | left: 0; 40 | justify-content: center; 41 | } 42 | `; 43 | 44 | const NoShadowLink = styled(ChakraLink)` 45 | text-decoration: none !important; 46 | &:focus { 47 | outline: 0 !important; 48 | box-shadow: none !important; 49 | } 50 | `; 51 | 52 | const Navbar = ({ accountButton = false, launchApp = false, onOpen }) => { 53 | return ( 54 | 55 | 61 | 62 | Nextjs Chakra Dapp 63 | 64 | 65 | 66 | 67 | 73 | 74 | 75 | 82 | 83 | 84 | 91 | 92 | 93 | 94 | {accountButton ? : null} 95 | {launchApp ? : null} 96 | 97 | 98 | ); 99 | }; 100 | 101 | export default Navbar; 102 | -------------------------------------------------------------------------------- /src/components/shared/NoShadowButton.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from "@chakra-ui/react"; 2 | import styled from "@emotion/styled"; 3 | 4 | const NoShadowButton = styled(Button)` 5 | &:focus { 6 | outline: 0 !important; 7 | box-shadow: none !important; 8 | } 9 | `; 10 | 11 | export default NoShadowButton; 12 | -------------------------------------------------------------------------------- /src/components/shared/Terminal.tsx: -------------------------------------------------------------------------------- 1 | import { useRef } from 'react'; 2 | // import { Terminal as RCETerm } from 'react-console-emulator' 3 | import { 4 | Link as ChakraLink, 5 | Text 6 | } from '@chakra-ui/react'; 7 | import styled from 'styled-components'; 8 | import { ToastContainer, toast } from 'material-react-toastify'; 9 | import { Container } from '.' 10 | 11 | // ** Container changes to flex-direction column for small screens 12 | const FlexContainer = styled(Container)` 13 | @media (max-width: 1000px) { 14 | flex-direction: column; 15 | } 16 | `; 17 | 18 | const InnerFlexContainer = styled(Container)` 19 | @media (max-width: 1000px) { 20 | width: 100%; 21 | padding-left: 1em; 22 | padding-right: 1em; 23 | margin: auto; 24 | max-width: 800px; 25 | } 26 | `; 27 | 28 | const Terminal = () => { 29 | const term_ref = useRef(); 30 | 31 | return ( 32 | 38 | 49 | 53 | 60 | {/* 69 | 92 | No data entered here is recorded GitHub 97 | */} 98 | 99 | 100 | 101 | ) 102 | }; 103 | 104 | export default Terminal; -------------------------------------------------------------------------------- /src/components/shared/index.ts: -------------------------------------------------------------------------------- 1 | export { default as ConnectWallet } from './ConnectWallet'; 2 | export { default as Container } from './Container'; 3 | export { default as CTA } from "./CTA"; 4 | export { default as DarkModeSwitch } from "./DarkModeSwitch"; 5 | export { default as FAQ } from "./FAQ"; 6 | export { default as FAQModal } from "./FAQModal"; 7 | export { default as GlitchButton } from "./GlitchButton"; 8 | export { default as GradientContainer } from "./GradientContainer"; 9 | export { default as GrayButton } from "./GrayButton"; 10 | // index.ts 11 | export { default as LaunchAppButton } from "./LaunchAppButton"; 12 | export { default as MintButton } from './MintButton'; 13 | export { default as NascentBadge } from "./NascentBadge"; 14 | export { default as Navbar } from "./Navbar"; 15 | export { default as NoShadowButton } from "./NoShadowButton"; 16 | export { default as Terminal } from "./Terminal"; -------------------------------------------------------------------------------- /src/contexts/Web3Context.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | createContext, 3 | useContext, 4 | useState, 5 | useCallback, 6 | useEffect, 7 | useMemo, 8 | ReactNode, 9 | } from "react"; 10 | import { useRouter } from "next/router"; 11 | import { useTranslation } from "react-i18next"; 12 | import LogRocket from "logrocket"; 13 | import { useToast } from "@chakra-ui/react"; 14 | import { Web3ContextClass } from "../web3context-sdk/index"; 15 | import { formatEther } from "@ethersproject/units"; 16 | 17 | import WalletConnectProvider from "@walletconnect/web3-provider"; 18 | import Web3Modal from "web3modal"; 19 | 20 | import { chooseBestWeb3Provider, alchemyURL } from "../utils"; 21 | 22 | const launchModalLazy = async ( 23 | t: (text: string, extra?: any) => string, 24 | cacheProvider: boolean = true 25 | ) => { 26 | const providerOptions = { 27 | injected: { 28 | display: { 29 | description: t("Connect with a browser extension"), 30 | }, 31 | package: null, 32 | }, 33 | walletconnect: { 34 | package: WalletConnectProvider.default, 35 | options: { 36 | rpc: { 37 | 1: alchemyURL, 38 | }, 39 | }, 40 | display: { 41 | description: t("Scan with a wallet to connect"), 42 | }, 43 | }, 44 | }; 45 | if (!cacheProvider) { 46 | localStorage.removeItem("WEB3_CONNECT_CACHED_PROVIDER"); 47 | localStorage.removeItem("walletconnect"); 48 | } 49 | const web3Modal = new Web3Modal({ 50 | cacheProvider, 51 | providerOptions, 52 | theme: { 53 | background: "#121212", 54 | main: "#FFFFFF", 55 | secondary: "#858585", 56 | border: "#272727", 57 | hover: "#000000", 58 | }, 59 | }); 60 | 61 | return web3Modal.connect(); 62 | } 63 | 64 | export interface Web3ContextData { 65 | web3Context: any; // to be replaced with an imported sdk (ex at top of file) 66 | web3ModalProvider: any | null; 67 | isAuthed: boolean; 68 | login: (cacheProvider?: boolean) => Promise; 69 | logout: () => any; 70 | address: string; 71 | // ** account ethers balance in ETH ** 72 | balance: number; 73 | chainId: number; 74 | isAttemptingLogin: boolean; 75 | } 76 | 77 | const EmptyAddress = "0x0000000000000000000000000000000000000000"; 78 | const InternalWeb3Context = createContext( 79 | undefined 80 | ); 81 | 82 | const Web3ContextProvider = ({ children }: { children: ReactNode }) => { 83 | const { t } = useTranslation(); 84 | 85 | const { query } = useRouter(); 86 | 87 | const [web3Context, setWeb3Context] = useState( 88 | () => new Web3ContextClass(chooseBestWeb3Provider()) 89 | ); 90 | 91 | const [isAttemptingLogin, setIsAttemptingLogin] = useState(false); 92 | const toast = useToast(); 93 | 94 | // ** Save chainId for context switches ** 95 | const [chainId, setChainId] = useState(-1); 96 | 97 | // ** Only allow one network toast notification at a time ** 98 | const [toastingNetwork, setToastingNetwork] = useState(false); 99 | 100 | // ** Lock setting context and address 101 | const [updatingLock, setUpdatingLock] = useState(false); 102 | 103 | // ** Refresh chain id ** 104 | const refreshChainId = ({ contextInstance = web3Context }) => { 105 | if (!toastingNetwork) { 106 | setToastingNetwork(true); 107 | Promise.all([ 108 | contextInstance.web3.eth.net.getId(), 109 | contextInstance.web3.eth.getChainId(), 110 | ]).then(([netId, currChainId]) => { 111 | setChainId(currChainId); 112 | // ** Don't show "wrong network" toasts if dev 113 | // if (process.env.NODE_ENV === "development") { 114 | // console.log("[NODE_ENV] Development") 115 | // return; 116 | // } 117 | 118 | if (netId !== 1 || currChainId !== 1) { 119 | // ** Prevent Fast Reentrancy 120 | setTimeout(() => { 121 | toast({ 122 | title: "Wrong network!", 123 | description: 124 | "You are on the wrong network! Switch to the mainnet!", 125 | status: "warning", 126 | position: "bottom", 127 | duration: 3000, 128 | isClosable: true, 129 | }); 130 | setTimeout(() => setToastingNetwork(false), 3000); 131 | }, 1500); 132 | } 133 | }); 134 | } 135 | }; 136 | 137 | useEffect(() => { 138 | // refreshChainId({}); 139 | if (localStorage.WEB3_CONNECT_CACHED_PROVIDER) { 140 | // if(!isAttemptingLogin) { 141 | login(); 142 | // } 143 | } else { 144 | // ** If we weren't previously connected, let's try to logout ** 145 | logout(); 146 | } 147 | }, []); 148 | 149 | const [address, setAddress] = useState(EmptyAddress); 150 | const [balance, setBalance] = useState(0); 151 | const [web3ModalProvider, setWeb3ModalProvider] = useState(null); 152 | 153 | const [chainChange, setChainChange] = useState(false); 154 | // ** For successfuly chain change toast 155 | useEffect(() => { 156 | if(chainChange) { 157 | setChainChange(false); 158 | if(address !== EmptyAddress && chainId === 1) { 159 | // ** Prevent Fast Reentrancy 160 | setTimeout(() => { 161 | toast({ 162 | title: "Connected!", 163 | description: 164 | "Connected to the correct network!", 165 | status: "success", 166 | position: "bottom", 167 | duration: 3000, 168 | isClosable: true, 169 | }); 170 | }, 1500); 171 | } 172 | } 173 | }, [chainId]); 174 | 175 | const setWeb3ContextAndAddressFromModal = (modalProvider) => { 176 | if (!updatingLock) { 177 | setUpdatingLock(true); 178 | const contextInstance = new Web3ContextClass(modalProvider); 179 | setWeb3Context(contextInstance); 180 | 181 | contextInstance.web3.eth.getAccounts().then((addresses) => { 182 | if (addresses.length === 0) { 183 | if (typeof window !== "undefined") { 184 | console.log("reloading window"); 185 | setIsAttemptingLogin(true); 186 | logout(); 187 | setAddress(EmptyAddress); 188 | return; 189 | } 190 | } 191 | 192 | // ** We only want to refresh the chain id and do the rest if we have addresses ** 193 | refreshChainId({ contextInstance }); 194 | 195 | // ** Set the new address ** 196 | const address = addresses[0] as string; 197 | const requestedAddress = query.address as string; 198 | LogRocket.identify(address); 199 | setAddress(requestedAddress ?? address); 200 | 201 | // ** Get the selected address balance 202 | contextInstance.web3.eth 203 | .getBalance(requestedAddress ?? address) 204 | .then((bal) => { 205 | setBalance(parseFloat(formatEther(bal))); 206 | 207 | // TODO: show connected balance here ?? 208 | }) 209 | .catch((balance_err) => 210 | console.error( 211 | "Failed to get account ethers with error:", 212 | balance_err 213 | ) 214 | ); 215 | }); 216 | } 217 | }; 218 | 219 | const login = async (cacheProvider: boolean = true) => { 220 | try { 221 | setIsAttemptingLogin(true); 222 | let provider = await launchModalLazy(t, cacheProvider); 223 | setWeb3ModalProvider(provider); 224 | setWeb3ContextAndAddressFromModal(provider); 225 | setIsAttemptingLogin(false); 226 | } catch (err) { 227 | setIsAttemptingLogin(false); 228 | return console.error(err); 229 | } 230 | }; 231 | 232 | const refetchAccountData = () => { 233 | setWeb3ContextAndAddressFromModal(web3ModalProvider); 234 | }; 235 | 236 | const logout = () => { 237 | setWeb3ModalProvider((past: any) => { 238 | try { 239 | past.clearCachedProvider().then((res) => { 240 | console.log("Cleared past cached provider!", res); 241 | }); 242 | console.log(past); 243 | console.log(web3ModalProvider); 244 | past.request({ 245 | method: "wallet_requestPermissions", 246 | params: [ 247 | { 248 | eth_accounts: {}, 249 | }, 250 | ], 251 | }); 252 | } catch (e) { 253 | console.error("Failed to close web3 modal provider"); 254 | console.error(e); 255 | } 256 | if (past?.off) { 257 | past.off("accountsChanged", refetchAccountData); 258 | past.off("chainChanged", refetchAccountData); 259 | } 260 | return null; 261 | }); 262 | localStorage.removeItem("WEB3_CONNECT_CACHED_PROVIDER"); 263 | localStorage.removeItem("walletconnect"); 264 | setAddress(EmptyAddress); 265 | }; 266 | 267 | useEffect(() => { 268 | if (web3ModalProvider !== null && web3ModalProvider.on) { 269 | web3ModalProvider.on("accountsChanged", refetchAccountData); 270 | web3ModalProvider.on("chainChanged", () => { 271 | setChainChange(true); 272 | refetchAccountData(); 273 | }); 274 | } 275 | return () => { 276 | if (web3ModalProvider?.off) { 277 | web3ModalProvider.off("accountsChanged", refetchAccountData); 278 | web3ModalProvider.off("chainChanged", refetchAccountData); 279 | } 280 | }; 281 | }, [web3ModalProvider, refetchAccountData]); 282 | 283 | const value = useMemo( 284 | () => ({ 285 | web3ModalProvider, 286 | web3Context, 287 | isAuthed: address !== EmptyAddress, 288 | login, 289 | logout, 290 | address, 291 | balance, 292 | chainId, 293 | isAttemptingLogin, 294 | }), 295 | [ 296 | web3Context, 297 | web3ModalProvider, 298 | login, 299 | logout, 300 | address, 301 | balance, 302 | chainId, 303 | isAttemptingLogin, 304 | ] 305 | ); 306 | 307 | return ( 308 | {children} 309 | ); 310 | }; 311 | 312 | const useWeb3Context = () => { 313 | const context = useContext(InternalWeb3Context); 314 | 315 | if (context === undefined) { 316 | throw new Error(`useWeb3Context must be used within a Web3ContextProvider`); 317 | } 318 | 319 | return context; 320 | } 321 | 322 | // ** Exports 323 | export { 324 | useWeb3Context, 325 | Web3ContextProvider, 326 | EmptyAddress, 327 | InternalWeb3Context, 328 | launchModalLazy 329 | } 330 | -------------------------------------------------------------------------------- /src/contexts/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Web3Context'; -------------------------------------------------------------------------------- /src/hooks/AuthedCallback.ts: -------------------------------------------------------------------------------- 1 | import { useWeb3Context } from "../contexts/Web3Context"; 2 | 3 | const useAuthedCallback = (callback: () => any) => { 4 | const { login, isAuthed } = useWeb3Context(); 5 | 6 | const authedCallback = () => { 7 | if (isAuthed) { 8 | return callback(); 9 | } else { 10 | return login(); 11 | } 12 | }; 13 | 14 | return authedCallback; 15 | }; 16 | 17 | export default useAuthedCallback; 18 | -------------------------------------------------------------------------------- /src/hooks/SmallScreen.ts: -------------------------------------------------------------------------------- 1 | import { useWindowSize } from "src/utils/"; 2 | 3 | const useIsSmallScreen = () => { 4 | const { width } = useWindowSize(); 5 | return width < 1030; 6 | }; 7 | 8 | export default useIsSmallScreen; 9 | -------------------------------------------------------------------------------- /src/hooks/index.ts: -------------------------------------------------------------------------------- 1 | export { default as useAuthedCallback } from "./AuthedCallback"; 2 | export { default as useIsSmallScreen } from "./SmallScreen"; 3 | -------------------------------------------------------------------------------- /src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import { ChakraProvider } from '@chakra-ui/react' 2 | import Head from "next/head"; 3 | import theme from '../theme' 4 | import { AppProps } from 'next/app' 5 | import 'material-react-toastify/dist/ReactToastify.css'; 6 | import { Web3ContextProvider } from "src/contexts/Web3Context"; 7 | 8 | import LogRocket from "logrocket"; 9 | // @ts-ignore 10 | import { version } from "../../package.json"; 11 | export { version }; 12 | 13 | if (process.env.NODE_ENV === "production") { 14 | console.log("Connecting to LogRocket..."); 15 | LogRocket.init(process.env.LOG_ROCKET_ID, { 16 | console: { 17 | shouldAggregateConsoleErrors: true, 18 | }, 19 | release: version, 20 | }); 21 | } 22 | 23 | function MyApp({ Component, pageProps }: AppProps) { 24 | return ( 25 | 26 | 27 | Nextjs Chakra Dapp 28 | 29 | 30 | 31 | 32 | 45 | 46 | ) 47 | } 48 | 49 | export default MyApp 50 | -------------------------------------------------------------------------------- /src/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import NextDocument, { Html, Head, Main, NextScript } from 'next/document' 2 | import { ColorModeScript } from '@chakra-ui/react' 3 | 4 | export default class Document extends NextDocument { 5 | render() { 6 | return ( 7 | 8 | 9 | 10 | Nextjs Chakra Dapp Template 11 | 15 | 16 | 17 | 18 | {/* Make Color mode to persists when you refresh the page. */} 19 | 20 |
    21 | 22 | 33 | 34 | 35 | ) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/pages/app.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | Navbar, 3 | Main, 4 | GradientContainer, 5 | AppPageMain, 6 | CTA, 7 | FAQModal, 8 | } from "src/components"; 9 | 10 | import { useDisclosure } from "@chakra-ui/react"; 11 | 12 | const App = () => { 13 | const { isOpen, onOpen, onClose } = useDisclosure(); 14 | 15 | return ( 16 | 17 |
    18 | 19 | 20 | 21 | 22 |
    23 |
    24 | ); 25 | }; 26 | 27 | export default App; 28 | -------------------------------------------------------------------------------- /src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | Navbar, 3 | Main, 4 | GradientContainer, 5 | LandingPageMain, 6 | FAQModal, 7 | } from "src/components"; 8 | 9 | import { useDisclosure } from "@chakra-ui/react"; 10 | 11 | const Index = () => { 12 | const { isOpen, onOpen, onClose } = useDisclosure(); 13 | 14 | return ( 15 | 16 |
    17 | 18 | 19 | 20 |
    21 |
    22 | ); 23 | }; 24 | 25 | export default Index; 26 | -------------------------------------------------------------------------------- /src/theme.tsx: -------------------------------------------------------------------------------- 1 | import { extendTheme } from '@chakra-ui/react' 2 | import { createBreakpoints } from '@chakra-ui/theme-tools' 3 | 4 | const fonts = { mono: `'Menlo', monospace` } 5 | 6 | const breakpoints = createBreakpoints({ 7 | sm: '40em', 8 | md: '52em', 9 | lg: '64em', 10 | xl: '80em', 11 | }) 12 | 13 | const theme = extendTheme({ 14 | config: { 15 | initialColorMode: 'dark', 16 | useSystemColorMode: false, 17 | }, 18 | colors: { 19 | black: '#16161D', 20 | white: 'var(--chakra-colors-whiteAlpha-700)' 21 | }, 22 | fonts, 23 | breakpoints, 24 | }) 25 | 26 | export default theme 27 | -------------------------------------------------------------------------------- /src/utils/ProviderOptions.ts: -------------------------------------------------------------------------------- 1 | import WalletConnectProvider from "@walletconnect/web3-provider"; 2 | import { MetaMask, WalletConnect } from "src/assets"; 3 | 4 | const ProviderOptions = { 5 | injected: { 6 | display: { 7 | logo: MetaMask, 8 | name: "Injected", 9 | description: "Connect with the provider in your Browser" 10 | }, 11 | package: null 12 | }, 13 | walletconnect: { 14 | display: { 15 | logo: WalletConnect, 16 | name: "Mobile", 17 | description: "Scan qrcode with your mobile wallet" 18 | }, 19 | package: WalletConnectProvider, 20 | options: { 21 | infuraId: process.env.INFURA_PROJECT_ID 22 | } 23 | } 24 | }; 25 | 26 | export default ProviderOptions; -------------------------------------------------------------------------------- /src/utils/Web3Providers.ts: -------------------------------------------------------------------------------- 1 | export const alchemyURL = `https://eth-mainnet.alchemyapi.io/v2/${ 2 | process.env.ALCHEMY_PROD_API_KEY ? process.env.ALCHEMY_PROD_API_KEY : "" 3 | }`; 4 | export const testnetURL = `http://localhost:8545`; 5 | 6 | export function chooseBestWeb3Provider() { 7 | if (typeof window === "undefined") { 8 | return alchemyURL; 9 | } 10 | 11 | if (window.ethereum) { 12 | return window.ethereum; 13 | } else if (window.web3) { 14 | return window.web3.currentProvider; 15 | } else { 16 | return alchemyURL; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./ChakraUtils"; 2 | export * from "./Web3Providers"; 3 | export { default as ProviderOptions } from "./ProviderOptions"; 4 | -------------------------------------------------------------------------------- /src/web3context-sdk/Cache.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | class Cache { 4 | _raw = {}; 5 | 6 | constructor(timeouts) { 7 | for (const key of Object.keys(timeouts)) 8 | this._raw[key] = { value: null, lastUpdated: 0, timeout: timeouts[key] }; 9 | } 10 | 11 | async getOrUpdate(key, asyncMethod) { 12 | var now = new Date().getTime() / 1000; 13 | 14 | if ( 15 | this._raw[key].value == null || 16 | now > this._raw[key].lastUpdated + this._raw[key].timeout 17 | ) { 18 | var self = this; 19 | if (this._raw[key].updating) 20 | return await new Promise(async function (resolve) { 21 | if (typeof self._raw[key].onUpdate === "undefined") 22 | self._raw[key].onUpdate = []; 23 | self._raw[key].onUpdate.push(resolve); 24 | }); 25 | this._raw[key].updating = true; 26 | this._raw[key].value = await asyncMethod(); 27 | this._raw[key].lastUpdated = now; 28 | this._raw[key].updating = false; 29 | if ( 30 | typeof this._raw[key].onUpdate !== "undefined" && 31 | this._raw[key].onUpdate.length > 0 32 | ) { 33 | for (const onUpdate of this._raw[key].onUpdate) 34 | onUpdate(this._raw[key].value); 35 | this._raw[key].onUpdate = []; 36 | } 37 | } 38 | 39 | return this._raw[key].value; 40 | } 41 | 42 | update(key, value) { 43 | var now = new Date().getTime() / 1000; 44 | this._raw[key].value = value; 45 | this._raw[key].lastUpdated = now; 46 | return this._raw[key].value; 47 | } 48 | 49 | clear(key) { 50 | this._raw[key].value = null; 51 | this._raw[key].lastUpdated = 0; 52 | } 53 | } 54 | 55 | export default Cache; 56 | -------------------------------------------------------------------------------- /src/web3context-sdk/Web3ContextClass.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import Web3 from "web3"; 3 | import axios from "axios"; 4 | import Big from "big.js"; 5 | 6 | import { Cache } from "."; 7 | 8 | // var erc20Abi = require("." + "/abi/ERC20.json"); 9 | 10 | class Web3ContextClass { 11 | // ** ------------------------------ ** 12 | // ** TYPE YOUR STATE VARIABLES HERE ** 13 | // ** ------------------------------ ** 14 | 15 | // ** Types ** 16 | web3: Web3; 17 | cache: Cache; 18 | getEthUsdPriceBN: () => Big; 19 | someAsyncFunction: () => Promise; 20 | 21 | // ** Class Statics ** 22 | static Web3 = Web3; 23 | 24 | // ?? web3 utils should have BN ?? 25 | // @ts-ignore 26 | static BN = Web3.utils.BN; 27 | 28 | // ** Constructor ** 29 | constructor(web3Provider) { 30 | // ** -------------------------------- ** 31 | // ** DEFINE YOUR STATE VARIABLES HERE ** 32 | // ** -------------------------------- ** 33 | 34 | this.web3 = new Web3(web3Provider); 35 | this.cache = new Cache({ allTokens: 86400, ethUsdPrice: 300 }); 36 | 37 | var self = this; 38 | 39 | // ** --------------------- ** 40 | // ** DEFINE FUNCTIONS HERE ** 41 | // ** (functions are vars) ** 42 | // ** --------------------- ** 43 | 44 | this.getEthUsdPriceBN = async function () { 45 | return await self.cache.getOrUpdate("ethUsdPrice", async function () { 46 | try { 47 | return Web3.utils.toBN( 48 | new Big( 49 | ( 50 | await axios.get( 51 | "https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd&ids=ethereum" 52 | ) 53 | ).data.ethereum.usd 54 | ) 55 | .mul(1e18) 56 | .toFixed(0) 57 | ); 58 | } catch (error) { 59 | throw new Error("Error retrieving data from Coingecko API: " + error); 60 | } 61 | }); 62 | }; 63 | 64 | this.someAsyncFunction = async function (cacheTimeout = 86400) { 65 | // ** example async function definition 66 | }; 67 | } 68 | } 69 | 70 | export default Web3ContextClass; 71 | -------------------------------------------------------------------------------- /src/web3context-sdk/abi/ERC20.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "name", 6 | "outputs": [ 7 | { 8 | "name": "", 9 | "type": "string" 10 | } 11 | ], 12 | "payable": false, 13 | "stateMutability": "view", 14 | "type": "function" 15 | }, 16 | { 17 | "constant": false, 18 | "inputs": [ 19 | { 20 | "name": "_spender", 21 | "type": "address" 22 | }, 23 | { 24 | "name": "_value", 25 | "type": "uint256" 26 | } 27 | ], 28 | "name": "approve", 29 | "outputs": [ 30 | { 31 | "name": "", 32 | "type": "bool" 33 | } 34 | ], 35 | "payable": false, 36 | "stateMutability": "nonpayable", 37 | "type": "function" 38 | }, 39 | { 40 | "constant": true, 41 | "inputs": [], 42 | "name": "totalSupply", 43 | "outputs": [ 44 | { 45 | "name": "", 46 | "type": "uint256" 47 | } 48 | ], 49 | "payable": false, 50 | "stateMutability": "view", 51 | "type": "function" 52 | }, 53 | { 54 | "constant": false, 55 | "inputs": [ 56 | { 57 | "name": "_from", 58 | "type": "address" 59 | }, 60 | { 61 | "name": "_to", 62 | "type": "address" 63 | }, 64 | { 65 | "name": "_value", 66 | "type": "uint256" 67 | } 68 | ], 69 | "name": "transferFrom", 70 | "outputs": [ 71 | { 72 | "name": "", 73 | "type": "bool" 74 | } 75 | ], 76 | "payable": false, 77 | "stateMutability": "nonpayable", 78 | "type": "function" 79 | }, 80 | { 81 | "constant": true, 82 | "inputs": [], 83 | "name": "decimals", 84 | "outputs": [ 85 | { 86 | "name": "", 87 | "type": "uint8" 88 | } 89 | ], 90 | "payable": false, 91 | "stateMutability": "view", 92 | "type": "function" 93 | }, 94 | { 95 | "constant": true, 96 | "inputs": [ 97 | { 98 | "name": "_owner", 99 | "type": "address" 100 | } 101 | ], 102 | "name": "balanceOf", 103 | "outputs": [ 104 | { 105 | "name": "balance", 106 | "type": "uint256" 107 | } 108 | ], 109 | "payable": false, 110 | "stateMutability": "view", 111 | "type": "function" 112 | }, 113 | { 114 | "constant": true, 115 | "inputs": [], 116 | "name": "symbol", 117 | "outputs": [ 118 | { 119 | "name": "", 120 | "type": "string" 121 | } 122 | ], 123 | "payable": false, 124 | "stateMutability": "view", 125 | "type": "function" 126 | }, 127 | { 128 | "constant": false, 129 | "inputs": [ 130 | { 131 | "name": "_to", 132 | "type": "address" 133 | }, 134 | { 135 | "name": "_value", 136 | "type": "uint256" 137 | } 138 | ], 139 | "name": "transfer", 140 | "outputs": [ 141 | { 142 | "name": "", 143 | "type": "bool" 144 | } 145 | ], 146 | "payable": false, 147 | "stateMutability": "nonpayable", 148 | "type": "function" 149 | }, 150 | { 151 | "constant": true, 152 | "inputs": [ 153 | { 154 | "name": "_owner", 155 | "type": "address" 156 | }, 157 | { 158 | "name": "_spender", 159 | "type": "address" 160 | } 161 | ], 162 | "name": "allowance", 163 | "outputs": [ 164 | { 165 | "name": "", 166 | "type": "uint256" 167 | } 168 | ], 169 | "payable": false, 170 | "stateMutability": "view", 171 | "type": "function" 172 | }, 173 | { 174 | "payable": true, 175 | "stateMutability": "payable", 176 | "type": "fallback" 177 | }, 178 | { 179 | "anonymous": false, 180 | "inputs": [ 181 | { 182 | "indexed": true, 183 | "name": "owner", 184 | "type": "address" 185 | }, 186 | { 187 | "indexed": true, 188 | "name": "spender", 189 | "type": "address" 190 | }, 191 | { 192 | "indexed": false, 193 | "name": "value", 194 | "type": "uint256" 195 | } 196 | ], 197 | "name": "Approval", 198 | "type": "event" 199 | }, 200 | { 201 | "anonymous": false, 202 | "inputs": [ 203 | { 204 | "indexed": true, 205 | "name": "from", 206 | "type": "address" 207 | }, 208 | { 209 | "indexed": true, 210 | "name": "to", 211 | "type": "address" 212 | }, 213 | { 214 | "indexed": false, 215 | "name": "value", 216 | "type": "uint256" 217 | } 218 | ], 219 | "name": "Transfer", 220 | "type": "event" 221 | } 222 | ] 223 | -------------------------------------------------------------------------------- /src/web3context-sdk/index.ts: -------------------------------------------------------------------------------- 1 | export { default as Cache } from "./Cache"; 2 | export { default as Web3ContextClass } from "./Web3ContextClass"; 3 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/.yarn-integrity: -------------------------------------------------------------------------------- 1 | { 2 | "systemParams": "darwin-x64-93", 3 | "modulesFolders": [ 4 | "node_modules" 5 | ], 6 | "flags": [], 7 | "linkedModules": [], 8 | "topLevelPatterns": [ 9 | "axios@^0.21.1", 10 | "big.js@^6.0.3" 11 | ], 12 | "lockfileEntries": { 13 | "axios@^0.21.1": "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575", 14 | "big.js@^6.0.3": "https://registry.yarnpkg.com/big.js/-/big.js-6.1.1.tgz#63b35b19dc9775c94991ee5db7694880655d5537", 15 | "follow-redirects@^1.14.0": "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" 16 | }, 17 | "files": [], 18 | "artifacts": {} 19 | } -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-present Matt Zabriskie 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | Please report security issues to jasonsaayman@gmail.com 6 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/UPGRADE_GUIDE.md: -------------------------------------------------------------------------------- 1 | # Upgrade Guide 2 | 3 | ### 0.15.x -> 0.16.0 4 | 5 | #### `Promise` Type Declarations 6 | 7 | The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details. 8 | 9 | ### 0.13.x -> 0.14.0 10 | 11 | #### TypeScript Definitions 12 | 13 | The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax. 14 | 15 | Please use the following `import` statement to import axios in TypeScript: 16 | 17 | ```typescript 18 | import axios from 'axios'; 19 | 20 | axios.get('/foo') 21 | .then(response => console.log(response)) 22 | .catch(error => console.log(error)); 23 | ``` 24 | 25 | #### `agent` Config Option 26 | 27 | The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead. 28 | 29 | ```js 30 | { 31 | // Define a custom agent for HTTP 32 | httpAgent: new http.Agent({ keepAlive: true }), 33 | // Define a custom agent for HTTPS 34 | httpsAgent: new https.Agent({ keepAlive: true }) 35 | } 36 | ``` 37 | 38 | #### `progress` Config Option 39 | 40 | The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options. 41 | 42 | ```js 43 | { 44 | // Define a handler for upload progress events 45 | onUploadProgress: function (progressEvent) { 46 | // ... 47 | }, 48 | 49 | // Define a handler for download progress events 50 | onDownloadProgress: function (progressEvent) { 51 | // ... 52 | } 53 | } 54 | ``` 55 | 56 | ### 0.12.x -> 0.13.0 57 | 58 | The `0.13.0` release contains several changes to custom adapters and error handling. 59 | 60 | #### Error Handling 61 | 62 | Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response. 63 | 64 | ```js 65 | axios.get('/user/12345') 66 | .catch((error) => { 67 | console.log(error.message); 68 | console.log(error.code); // Not always specified 69 | console.log(error.config); // The config that was used to make the request 70 | console.log(error.response); // Only available if response was received from the server 71 | }); 72 | ``` 73 | 74 | #### Request Adapters 75 | 76 | This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter. 77 | 78 | 1. Response transformer is now called outside of adapter. 79 | 2. Request adapter returns a `Promise`. 80 | 81 | This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter. 82 | 83 | Previous code: 84 | 85 | ```js 86 | function myAdapter(resolve, reject, config) { 87 | var response = { 88 | data: transformData( 89 | responseData, 90 | responseHeaders, 91 | config.transformResponse 92 | ), 93 | status: request.status, 94 | statusText: request.statusText, 95 | headers: responseHeaders 96 | }; 97 | settle(resolve, reject, response); 98 | } 99 | ``` 100 | 101 | New code: 102 | 103 | ```js 104 | function myAdapter(config) { 105 | return new Promise(function (resolve, reject) { 106 | var response = { 107 | data: responseData, 108 | status: request.status, 109 | statusText: request.statusText, 110 | headers: responseHeaders 111 | }; 112 | settle(resolve, reject, response); 113 | }); 114 | } 115 | ``` 116 | 117 | See the related commits for more details: 118 | - [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) 119 | - [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) 120 | 121 | ### 0.5.x -> 0.6.0 122 | 123 | The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading. 124 | 125 | #### ES6 Promise Polyfill 126 | 127 | Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it. 128 | 129 | ```js 130 | require('es6-promise').polyfill(); 131 | var axios = require('axios'); 132 | ``` 133 | 134 | This will polyfill the global environment, and only needs to be done once. 135 | 136 | #### `axios.success`/`axios.error` 137 | 138 | The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. 139 | 140 | ```js 141 | axios.get('some/url') 142 | .then(function (res) { 143 | /* ... */ 144 | }) 145 | .catch(function (err) { 146 | /* ... */ 147 | }); 148 | ``` 149 | 150 | #### UMD 151 | 152 | Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build. 153 | 154 | ```js 155 | // AMD 156 | require(['bower_components/axios/dist/axios'], function (axios) { 157 | /* ... */ 158 | }); 159 | 160 | // CommonJS 161 | var axios = require('axios/dist/axios'); 162 | ``` 163 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/index.d.ts: -------------------------------------------------------------------------------- 1 | export interface AxiosTransformer { 2 | (data: any, headers?: any): any; 3 | } 4 | 5 | export interface AxiosAdapter { 6 | (config: AxiosRequestConfig): AxiosPromise; 7 | } 8 | 9 | export interface AxiosBasicCredentials { 10 | username: string; 11 | password: string; 12 | } 13 | 14 | export interface AxiosProxyConfig { 15 | host: string; 16 | port: number; 17 | auth?: { 18 | username: string; 19 | password:string; 20 | }; 21 | protocol?: string; 22 | } 23 | 24 | export type Method = 25 | | 'get' | 'GET' 26 | | 'delete' | 'DELETE' 27 | | 'head' | 'HEAD' 28 | | 'options' | 'OPTIONS' 29 | | 'post' | 'POST' 30 | | 'put' | 'PUT' 31 | | 'patch' | 'PATCH' 32 | | 'purge' | 'PURGE' 33 | | 'link' | 'LINK' 34 | | 'unlink' | 'UNLINK' 35 | 36 | export type ResponseType = 37 | | 'arraybuffer' 38 | | 'blob' 39 | | 'document' 40 | | 'json' 41 | | 'text' 42 | | 'stream' 43 | 44 | export interface TransitionalOptions{ 45 | silentJSONParsing: boolean; 46 | forcedJSONParsing: boolean; 47 | clarifyTimeoutError: boolean; 48 | } 49 | 50 | export interface AxiosRequestConfig { 51 | url?: string; 52 | method?: Method; 53 | baseURL?: string; 54 | transformRequest?: AxiosTransformer | AxiosTransformer[]; 55 | transformResponse?: AxiosTransformer | AxiosTransformer[]; 56 | headers?: any; 57 | params?: any; 58 | paramsSerializer?: (params: any) => string; 59 | data?: any; 60 | timeout?: number; 61 | timeoutErrorMessage?: string; 62 | withCredentials?: boolean; 63 | adapter?: AxiosAdapter; 64 | auth?: AxiosBasicCredentials; 65 | responseType?: ResponseType; 66 | xsrfCookieName?: string; 67 | xsrfHeaderName?: string; 68 | onUploadProgress?: (progressEvent: any) => void; 69 | onDownloadProgress?: (progressEvent: any) => void; 70 | maxContentLength?: number; 71 | validateStatus?: ((status: number) => boolean) | null; 72 | maxBodyLength?: number; 73 | maxRedirects?: number; 74 | socketPath?: string | null; 75 | httpAgent?: any; 76 | httpsAgent?: any; 77 | proxy?: AxiosProxyConfig | false; 78 | cancelToken?: CancelToken; 79 | decompress?: boolean; 80 | transitional?: TransitionalOptions 81 | } 82 | 83 | export interface AxiosResponse { 84 | data: T; 85 | status: number; 86 | statusText: string; 87 | headers: any; 88 | config: AxiosRequestConfig; 89 | request?: any; 90 | } 91 | 92 | export interface AxiosError extends Error { 93 | config: AxiosRequestConfig; 94 | code?: string; 95 | request?: any; 96 | response?: AxiosResponse; 97 | isAxiosError: boolean; 98 | toJSON: () => object; 99 | } 100 | 101 | export interface AxiosPromise extends Promise> { 102 | } 103 | 104 | export interface CancelStatic { 105 | new (message?: string): Cancel; 106 | } 107 | 108 | export interface Cancel { 109 | message: string; 110 | } 111 | 112 | export interface Canceler { 113 | (message?: string): void; 114 | } 115 | 116 | export interface CancelTokenStatic { 117 | new (executor: (cancel: Canceler) => void): CancelToken; 118 | source(): CancelTokenSource; 119 | } 120 | 121 | export interface CancelToken { 122 | promise: Promise; 123 | reason?: Cancel; 124 | throwIfRequested(): void; 125 | } 126 | 127 | export interface CancelTokenSource { 128 | token: CancelToken; 129 | cancel: Canceler; 130 | } 131 | 132 | export interface AxiosInterceptorManager { 133 | use(onFulfilled?: (value: V) => T | Promise, onRejected?: (error: any) => any): number; 134 | eject(id: number): void; 135 | } 136 | 137 | export interface AxiosInstance { 138 | (config: AxiosRequestConfig): AxiosPromise; 139 | (url: string, config?: AxiosRequestConfig): AxiosPromise; 140 | defaults: AxiosRequestConfig; 141 | interceptors: { 142 | request: AxiosInterceptorManager; 143 | response: AxiosInterceptorManager; 144 | }; 145 | getUri(config?: AxiosRequestConfig): string; 146 | request> (config: AxiosRequestConfig): Promise; 147 | get>(url: string, config?: AxiosRequestConfig): Promise; 148 | delete>(url: string, config?: AxiosRequestConfig): Promise; 149 | head>(url: string, config?: AxiosRequestConfig): Promise; 150 | options>(url: string, config?: AxiosRequestConfig): Promise; 151 | post>(url: string, data?: any, config?: AxiosRequestConfig): Promise; 152 | put>(url: string, data?: any, config?: AxiosRequestConfig): Promise; 153 | patch>(url: string, data?: any, config?: AxiosRequestConfig): Promise; 154 | } 155 | 156 | export interface AxiosStatic extends AxiosInstance { 157 | create(config?: AxiosRequestConfig): AxiosInstance; 158 | Cancel: CancelStatic; 159 | CancelToken: CancelTokenStatic; 160 | isCancel(value: any): boolean; 161 | all(values: (T | Promise)[]): Promise; 162 | spread(callback: (...args: T[]) => R): (array: T[]) => R; 163 | isAxiosError(payload: any): payload is AxiosError; 164 | } 165 | 166 | declare const axios: AxiosStatic; 167 | 168 | export default axios; 169 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/axios'); -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/adapters/README.md: -------------------------------------------------------------------------------- 1 | # axios // adapters 2 | 3 | The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received. 4 | 5 | ## Example 6 | 7 | ```js 8 | var settle = require('./../core/settle'); 9 | 10 | module.exports = function myAdapter(config) { 11 | // At this point: 12 | // - config has been merged with defaults 13 | // - request transformers have already run 14 | // - request interceptors have already run 15 | 16 | // Make the request using config provided 17 | // Upon response settle the Promise 18 | 19 | return new Promise(function(resolve, reject) { 20 | 21 | var response = { 22 | data: responseData, 23 | status: request.status, 24 | statusText: request.statusText, 25 | headers: responseHeaders, 26 | config: config, 27 | request: request 28 | }; 29 | 30 | settle(resolve, reject, response); 31 | 32 | // From here: 33 | // - response transformers will run 34 | // - response interceptors will run 35 | }); 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/adapters/xhr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | var settle = require('./../core/settle'); 5 | var cookies = require('./../helpers/cookies'); 6 | var buildURL = require('./../helpers/buildURL'); 7 | var buildFullPath = require('../core/buildFullPath'); 8 | var parseHeaders = require('./../helpers/parseHeaders'); 9 | var isURLSameOrigin = require('./../helpers/isURLSameOrigin'); 10 | var createError = require('../core/createError'); 11 | 12 | module.exports = function xhrAdapter(config) { 13 | return new Promise(function dispatchXhrRequest(resolve, reject) { 14 | var requestData = config.data; 15 | var requestHeaders = config.headers; 16 | var responseType = config.responseType; 17 | 18 | if (utils.isFormData(requestData)) { 19 | delete requestHeaders['Content-Type']; // Let the browser set it 20 | } 21 | 22 | var request = new XMLHttpRequest(); 23 | 24 | // HTTP basic authentication 25 | if (config.auth) { 26 | var username = config.auth.username || ''; 27 | var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; 28 | requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 29 | } 30 | 31 | var fullPath = buildFullPath(config.baseURL, config.url); 32 | request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); 33 | 34 | // Set the request timeout in MS 35 | request.timeout = config.timeout; 36 | 37 | function onloadend() { 38 | if (!request) { 39 | return; 40 | } 41 | // Prepare the response 42 | var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 43 | var responseData = !responseType || responseType === 'text' || responseType === 'json' ? 44 | request.responseText : request.response; 45 | var response = { 46 | data: responseData, 47 | status: request.status, 48 | statusText: request.statusText, 49 | headers: responseHeaders, 50 | config: config, 51 | request: request 52 | }; 53 | 54 | settle(resolve, reject, response); 55 | 56 | // Clean up request 57 | request = null; 58 | } 59 | 60 | if ('onloadend' in request) { 61 | // Use onloadend if available 62 | request.onloadend = onloadend; 63 | } else { 64 | // Listen for ready state to emulate onloadend 65 | request.onreadystatechange = function handleLoad() { 66 | if (!request || request.readyState !== 4) { 67 | return; 68 | } 69 | 70 | // The request errored out and we didn't get a response, this will be 71 | // handled by onerror instead 72 | // With one exception: request that using file: protocol, most browsers 73 | // will return status as 0 even though it's a successful request 74 | if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 75 | return; 76 | } 77 | // readystate handler is calling before onerror or ontimeout handlers, 78 | // so we should call onloadend on the next 'tick' 79 | setTimeout(onloadend); 80 | }; 81 | } 82 | 83 | // Handle browser request cancellation (as opposed to a manual cancellation) 84 | request.onabort = function handleAbort() { 85 | if (!request) { 86 | return; 87 | } 88 | 89 | reject(createError('Request aborted', config, 'ECONNABORTED', request)); 90 | 91 | // Clean up request 92 | request = null; 93 | }; 94 | 95 | // Handle low level network errors 96 | request.onerror = function handleError() { 97 | // Real errors are hidden from us by the browser 98 | // onerror should only fire if it's a network error 99 | reject(createError('Network Error', config, null, request)); 100 | 101 | // Clean up request 102 | request = null; 103 | }; 104 | 105 | // Handle timeout 106 | request.ontimeout = function handleTimeout() { 107 | var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; 108 | if (config.timeoutErrorMessage) { 109 | timeoutErrorMessage = config.timeoutErrorMessage; 110 | } 111 | reject(createError( 112 | timeoutErrorMessage, 113 | config, 114 | config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', 115 | request)); 116 | 117 | // Clean up request 118 | request = null; 119 | }; 120 | 121 | // Add xsrf header 122 | // This is only done if running in a standard browser environment. 123 | // Specifically not if we're in a web worker, or react-native. 124 | if (utils.isStandardBrowserEnv()) { 125 | // Add xsrf header 126 | var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? 127 | cookies.read(config.xsrfCookieName) : 128 | undefined; 129 | 130 | if (xsrfValue) { 131 | requestHeaders[config.xsrfHeaderName] = xsrfValue; 132 | } 133 | } 134 | 135 | // Add headers to the request 136 | if ('setRequestHeader' in request) { 137 | utils.forEach(requestHeaders, function setRequestHeader(val, key) { 138 | if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 139 | // Remove Content-Type if data is undefined 140 | delete requestHeaders[key]; 141 | } else { 142 | // Otherwise add header to the request 143 | request.setRequestHeader(key, val); 144 | } 145 | }); 146 | } 147 | 148 | // Add withCredentials to request if needed 149 | if (!utils.isUndefined(config.withCredentials)) { 150 | request.withCredentials = !!config.withCredentials; 151 | } 152 | 153 | // Add responseType to request if needed 154 | if (responseType && responseType !== 'json') { 155 | request.responseType = config.responseType; 156 | } 157 | 158 | // Handle progress if needed 159 | if (typeof config.onDownloadProgress === 'function') { 160 | request.addEventListener('progress', config.onDownloadProgress); 161 | } 162 | 163 | // Not all browsers support upload events 164 | if (typeof config.onUploadProgress === 'function' && request.upload) { 165 | request.upload.addEventListener('progress', config.onUploadProgress); 166 | } 167 | 168 | if (config.cancelToken) { 169 | // Handle cancellation 170 | config.cancelToken.promise.then(function onCanceled(cancel) { 171 | if (!request) { 172 | return; 173 | } 174 | 175 | request.abort(); 176 | reject(cancel); 177 | // Clean up request 178 | request = null; 179 | }); 180 | } 181 | 182 | if (!requestData) { 183 | requestData = null; 184 | } 185 | 186 | // Send the request 187 | request.send(requestData); 188 | }); 189 | }; 190 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/axios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./utils'); 4 | var bind = require('./helpers/bind'); 5 | var Axios = require('./core/Axios'); 6 | var mergeConfig = require('./core/mergeConfig'); 7 | var defaults = require('./defaults'); 8 | 9 | /** 10 | * Create an instance of Axios 11 | * 12 | * @param {Object} defaultConfig The default config for the instance 13 | * @return {Axios} A new instance of Axios 14 | */ 15 | function createInstance(defaultConfig) { 16 | var context = new Axios(defaultConfig); 17 | var instance = bind(Axios.prototype.request, context); 18 | 19 | // Copy axios.prototype to instance 20 | utils.extend(instance, Axios.prototype, context); 21 | 22 | // Copy context to instance 23 | utils.extend(instance, context); 24 | 25 | return instance; 26 | } 27 | 28 | // Create the default instance to be exported 29 | var axios = createInstance(defaults); 30 | 31 | // Expose Axios class to allow class inheritance 32 | axios.Axios = Axios; 33 | 34 | // Factory for creating new instances 35 | axios.create = function create(instanceConfig) { 36 | return createInstance(mergeConfig(axios.defaults, instanceConfig)); 37 | }; 38 | 39 | // Expose Cancel & CancelToken 40 | axios.Cancel = require('./cancel/Cancel'); 41 | axios.CancelToken = require('./cancel/CancelToken'); 42 | axios.isCancel = require('./cancel/isCancel'); 43 | 44 | // Expose all/spread 45 | axios.all = function all(promises) { 46 | return Promise.all(promises); 47 | }; 48 | axios.spread = require('./helpers/spread'); 49 | 50 | // Expose isAxiosError 51 | axios.isAxiosError = require('./helpers/isAxiosError'); 52 | 53 | module.exports = axios; 54 | 55 | // Allow use of default import syntax in TypeScript 56 | module.exports.default = axios; 57 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/cancel/Cancel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * A `Cancel` is an object that is thrown when an operation is canceled. 5 | * 6 | * @class 7 | * @param {string=} message The message. 8 | */ 9 | function Cancel(message) { 10 | this.message = message; 11 | } 12 | 13 | Cancel.prototype.toString = function toString() { 14 | return 'Cancel' + (this.message ? ': ' + this.message : ''); 15 | }; 16 | 17 | Cancel.prototype.__CANCEL__ = true; 18 | 19 | module.exports = Cancel; 20 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/cancel/CancelToken.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Cancel = require('./Cancel'); 4 | 5 | /** 6 | * A `CancelToken` is an object that can be used to request cancellation of an operation. 7 | * 8 | * @class 9 | * @param {Function} executor The executor function. 10 | */ 11 | function CancelToken(executor) { 12 | if (typeof executor !== 'function') { 13 | throw new TypeError('executor must be a function.'); 14 | } 15 | 16 | var resolvePromise; 17 | this.promise = new Promise(function promiseExecutor(resolve) { 18 | resolvePromise = resolve; 19 | }); 20 | 21 | var token = this; 22 | executor(function cancel(message) { 23 | if (token.reason) { 24 | // Cancellation has already been requested 25 | return; 26 | } 27 | 28 | token.reason = new Cancel(message); 29 | resolvePromise(token.reason); 30 | }); 31 | } 32 | 33 | /** 34 | * Throws a `Cancel` if cancellation has been requested. 35 | */ 36 | CancelToken.prototype.throwIfRequested = function throwIfRequested() { 37 | if (this.reason) { 38 | throw this.reason; 39 | } 40 | }; 41 | 42 | /** 43 | * Returns an object that contains a new `CancelToken` and a function that, when called, 44 | * cancels the `CancelToken`. 45 | */ 46 | CancelToken.source = function source() { 47 | var cancel; 48 | var token = new CancelToken(function executor(c) { 49 | cancel = c; 50 | }); 51 | return { 52 | token: token, 53 | cancel: cancel 54 | }; 55 | }; 56 | 57 | module.exports = CancelToken; 58 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/cancel/isCancel.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function isCancel(value) { 4 | return !!(value && value.__CANCEL__); 5 | }; 6 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/Axios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | var buildURL = require('../helpers/buildURL'); 5 | var InterceptorManager = require('./InterceptorManager'); 6 | var dispatchRequest = require('./dispatchRequest'); 7 | var mergeConfig = require('./mergeConfig'); 8 | var validator = require('../helpers/validator'); 9 | 10 | var validators = validator.validators; 11 | /** 12 | * Create a new instance of Axios 13 | * 14 | * @param {Object} instanceConfig The default config for the instance 15 | */ 16 | function Axios(instanceConfig) { 17 | this.defaults = instanceConfig; 18 | this.interceptors = { 19 | request: new InterceptorManager(), 20 | response: new InterceptorManager() 21 | }; 22 | } 23 | 24 | /** 25 | * Dispatch a request 26 | * 27 | * @param {Object} config The config specific for this request (merged with this.defaults) 28 | */ 29 | Axios.prototype.request = function request(config) { 30 | /*eslint no-param-reassign:0*/ 31 | // Allow for axios('example/url'[, config]) a la fetch API 32 | if (typeof config === 'string') { 33 | config = arguments[1] || {}; 34 | config.url = arguments[0]; 35 | } else { 36 | config = config || {}; 37 | } 38 | 39 | config = mergeConfig(this.defaults, config); 40 | 41 | // Set config.method 42 | if (config.method) { 43 | config.method = config.method.toLowerCase(); 44 | } else if (this.defaults.method) { 45 | config.method = this.defaults.method.toLowerCase(); 46 | } else { 47 | config.method = 'get'; 48 | } 49 | 50 | var transitional = config.transitional; 51 | 52 | if (transitional !== undefined) { 53 | validator.assertOptions(transitional, { 54 | silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'), 55 | forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'), 56 | clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0') 57 | }, false); 58 | } 59 | 60 | // filter out skipped interceptors 61 | var requestInterceptorChain = []; 62 | var synchronousRequestInterceptors = true; 63 | this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 64 | if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { 65 | return; 66 | } 67 | 68 | synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; 69 | 70 | requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); 71 | }); 72 | 73 | var responseInterceptorChain = []; 74 | this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 75 | responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); 76 | }); 77 | 78 | var promise; 79 | 80 | if (!synchronousRequestInterceptors) { 81 | var chain = [dispatchRequest, undefined]; 82 | 83 | Array.prototype.unshift.apply(chain, requestInterceptorChain); 84 | chain = chain.concat(responseInterceptorChain); 85 | 86 | promise = Promise.resolve(config); 87 | while (chain.length) { 88 | promise = promise.then(chain.shift(), chain.shift()); 89 | } 90 | 91 | return promise; 92 | } 93 | 94 | 95 | var newConfig = config; 96 | while (requestInterceptorChain.length) { 97 | var onFulfilled = requestInterceptorChain.shift(); 98 | var onRejected = requestInterceptorChain.shift(); 99 | try { 100 | newConfig = onFulfilled(newConfig); 101 | } catch (error) { 102 | onRejected(error); 103 | break; 104 | } 105 | } 106 | 107 | try { 108 | promise = dispatchRequest(newConfig); 109 | } catch (error) { 110 | return Promise.reject(error); 111 | } 112 | 113 | while (responseInterceptorChain.length) { 114 | promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); 115 | } 116 | 117 | return promise; 118 | }; 119 | 120 | Axios.prototype.getUri = function getUri(config) { 121 | config = mergeConfig(this.defaults, config); 122 | return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 123 | }; 124 | 125 | // Provide aliases for supported request methods 126 | utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 127 | /*eslint func-names:0*/ 128 | Axios.prototype[method] = function(url, config) { 129 | return this.request(mergeConfig(config || {}, { 130 | method: method, 131 | url: url, 132 | data: (config || {}).data 133 | })); 134 | }; 135 | }); 136 | 137 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 138 | /*eslint func-names:0*/ 139 | Axios.prototype[method] = function(url, data, config) { 140 | return this.request(mergeConfig(config || {}, { 141 | method: method, 142 | url: url, 143 | data: data 144 | })); 145 | }; 146 | }); 147 | 148 | module.exports = Axios; 149 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/InterceptorManager.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | function InterceptorManager() { 6 | this.handlers = []; 7 | } 8 | 9 | /** 10 | * Add a new interceptor to the stack 11 | * 12 | * @param {Function} fulfilled The function to handle `then` for a `Promise` 13 | * @param {Function} rejected The function to handle `reject` for a `Promise` 14 | * 15 | * @return {Number} An ID used to remove interceptor later 16 | */ 17 | InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { 18 | this.handlers.push({ 19 | fulfilled: fulfilled, 20 | rejected: rejected, 21 | synchronous: options ? options.synchronous : false, 22 | runWhen: options ? options.runWhen : null 23 | }); 24 | return this.handlers.length - 1; 25 | }; 26 | 27 | /** 28 | * Remove an interceptor from the stack 29 | * 30 | * @param {Number} id The ID that was returned by `use` 31 | */ 32 | InterceptorManager.prototype.eject = function eject(id) { 33 | if (this.handlers[id]) { 34 | this.handlers[id] = null; 35 | } 36 | }; 37 | 38 | /** 39 | * Iterate over all the registered interceptors 40 | * 41 | * This method is particularly useful for skipping over any 42 | * interceptors that may have become `null` calling `eject`. 43 | * 44 | * @param {Function} fn The function to call for each interceptor 45 | */ 46 | InterceptorManager.prototype.forEach = function forEach(fn) { 47 | utils.forEach(this.handlers, function forEachHandler(h) { 48 | if (h !== null) { 49 | fn(h); 50 | } 51 | }); 52 | }; 53 | 54 | module.exports = InterceptorManager; 55 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/README.md: -------------------------------------------------------------------------------- 1 | # axios // core 2 | 3 | The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are: 4 | 5 | - Dispatching requests 6 | - Requests sent via `adapters/` (see lib/adapters/README.md) 7 | - Managing interceptors 8 | - Handling config 9 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/buildFullPath.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var isAbsoluteURL = require('../helpers/isAbsoluteURL'); 4 | var combineURLs = require('../helpers/combineURLs'); 5 | 6 | /** 7 | * Creates a new URL by combining the baseURL with the requestedURL, 8 | * only when the requestedURL is not already an absolute URL. 9 | * If the requestURL is absolute, this function returns the requestedURL untouched. 10 | * 11 | * @param {string} baseURL The base URL 12 | * @param {string} requestedURL Absolute or relative URL to combine 13 | * @returns {string} The combined full path 14 | */ 15 | module.exports = function buildFullPath(baseURL, requestedURL) { 16 | if (baseURL && !isAbsoluteURL(requestedURL)) { 17 | return combineURLs(baseURL, requestedURL); 18 | } 19 | return requestedURL; 20 | }; 21 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/createError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var enhanceError = require('./enhanceError'); 4 | 5 | /** 6 | * Create an Error with the specified message, config, error code, request and response. 7 | * 8 | * @param {string} message The error message. 9 | * @param {Object} config The config. 10 | * @param {string} [code] The error code (for example, 'ECONNABORTED'). 11 | * @param {Object} [request] The request. 12 | * @param {Object} [response] The response. 13 | * @returns {Error} The created error. 14 | */ 15 | module.exports = function createError(message, config, code, request, response) { 16 | var error = new Error(message); 17 | return enhanceError(error, config, code, request, response); 18 | }; 19 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/dispatchRequest.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | var transformData = require('./transformData'); 5 | var isCancel = require('../cancel/isCancel'); 6 | var defaults = require('../defaults'); 7 | 8 | /** 9 | * Throws a `Cancel` if cancellation has been requested. 10 | */ 11 | function throwIfCancellationRequested(config) { 12 | if (config.cancelToken) { 13 | config.cancelToken.throwIfRequested(); 14 | } 15 | } 16 | 17 | /** 18 | * Dispatch a request to the server using the configured adapter. 19 | * 20 | * @param {object} config The config that is to be used for the request 21 | * @returns {Promise} The Promise to be fulfilled 22 | */ 23 | module.exports = function dispatchRequest(config) { 24 | throwIfCancellationRequested(config); 25 | 26 | // Ensure headers exist 27 | config.headers = config.headers || {}; 28 | 29 | // Transform request data 30 | config.data = transformData.call( 31 | config, 32 | config.data, 33 | config.headers, 34 | config.transformRequest 35 | ); 36 | 37 | // Flatten headers 38 | config.headers = utils.merge( 39 | config.headers.common || {}, 40 | config.headers[config.method] || {}, 41 | config.headers 42 | ); 43 | 44 | utils.forEach( 45 | ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 46 | function cleanHeaderConfig(method) { 47 | delete config.headers[method]; 48 | } 49 | ); 50 | 51 | var adapter = config.adapter || defaults.adapter; 52 | 53 | return adapter(config).then(function onAdapterResolution(response) { 54 | throwIfCancellationRequested(config); 55 | 56 | // Transform response data 57 | response.data = transformData.call( 58 | config, 59 | response.data, 60 | response.headers, 61 | config.transformResponse 62 | ); 63 | 64 | return response; 65 | }, function onAdapterRejection(reason) { 66 | if (!isCancel(reason)) { 67 | throwIfCancellationRequested(config); 68 | 69 | // Transform response data 70 | if (reason && reason.response) { 71 | reason.response.data = transformData.call( 72 | config, 73 | reason.response.data, 74 | reason.response.headers, 75 | config.transformResponse 76 | ); 77 | } 78 | } 79 | 80 | return Promise.reject(reason); 81 | }); 82 | }; 83 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/enhanceError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Update an Error with the specified config, error code, and response. 5 | * 6 | * @param {Error} error The error to update. 7 | * @param {Object} config The config. 8 | * @param {string} [code] The error code (for example, 'ECONNABORTED'). 9 | * @param {Object} [request] The request. 10 | * @param {Object} [response] The response. 11 | * @returns {Error} The error. 12 | */ 13 | module.exports = function enhanceError(error, config, code, request, response) { 14 | error.config = config; 15 | if (code) { 16 | error.code = code; 17 | } 18 | 19 | error.request = request; 20 | error.response = response; 21 | error.isAxiosError = true; 22 | 23 | error.toJSON = function toJSON() { 24 | return { 25 | // Standard 26 | message: this.message, 27 | name: this.name, 28 | // Microsoft 29 | description: this.description, 30 | number: this.number, 31 | // Mozilla 32 | fileName: this.fileName, 33 | lineNumber: this.lineNumber, 34 | columnNumber: this.columnNumber, 35 | stack: this.stack, 36 | // Axios 37 | config: this.config, 38 | code: this.code 39 | }; 40 | }; 41 | return error; 42 | }; 43 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/mergeConfig.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | 5 | /** 6 | * Config-specific merge-function which creates a new config-object 7 | * by merging two configuration objects together. 8 | * 9 | * @param {Object} config1 10 | * @param {Object} config2 11 | * @returns {Object} New object resulting from merging config2 to config1 12 | */ 13 | module.exports = function mergeConfig(config1, config2) { 14 | // eslint-disable-next-line no-param-reassign 15 | config2 = config2 || {}; 16 | var config = {}; 17 | 18 | var valueFromConfig2Keys = ['url', 'method', 'data']; 19 | var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; 20 | var defaultToConfig2Keys = [ 21 | 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', 22 | 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', 23 | 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', 24 | 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', 25 | 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' 26 | ]; 27 | var directMergeKeys = ['validateStatus']; 28 | 29 | function getMergedValue(target, source) { 30 | if (utils.isPlainObject(target) && utils.isPlainObject(source)) { 31 | return utils.merge(target, source); 32 | } else if (utils.isPlainObject(source)) { 33 | return utils.merge({}, source); 34 | } else if (utils.isArray(source)) { 35 | return source.slice(); 36 | } 37 | return source; 38 | } 39 | 40 | function mergeDeepProperties(prop) { 41 | if (!utils.isUndefined(config2[prop])) { 42 | config[prop] = getMergedValue(config1[prop], config2[prop]); 43 | } else if (!utils.isUndefined(config1[prop])) { 44 | config[prop] = getMergedValue(undefined, config1[prop]); 45 | } 46 | } 47 | 48 | utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { 49 | if (!utils.isUndefined(config2[prop])) { 50 | config[prop] = getMergedValue(undefined, config2[prop]); 51 | } 52 | }); 53 | 54 | utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); 55 | 56 | utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { 57 | if (!utils.isUndefined(config2[prop])) { 58 | config[prop] = getMergedValue(undefined, config2[prop]); 59 | } else if (!utils.isUndefined(config1[prop])) { 60 | config[prop] = getMergedValue(undefined, config1[prop]); 61 | } 62 | }); 63 | 64 | utils.forEach(directMergeKeys, function merge(prop) { 65 | if (prop in config2) { 66 | config[prop] = getMergedValue(config1[prop], config2[prop]); 67 | } else if (prop in config1) { 68 | config[prop] = getMergedValue(undefined, config1[prop]); 69 | } 70 | }); 71 | 72 | var axiosKeys = valueFromConfig2Keys 73 | .concat(mergeDeepPropertiesKeys) 74 | .concat(defaultToConfig2Keys) 75 | .concat(directMergeKeys); 76 | 77 | var otherKeys = Object 78 | .keys(config1) 79 | .concat(Object.keys(config2)) 80 | .filter(function filterAxiosKeys(key) { 81 | return axiosKeys.indexOf(key) === -1; 82 | }); 83 | 84 | utils.forEach(otherKeys, mergeDeepProperties); 85 | 86 | return config; 87 | }; 88 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/settle.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var createError = require('./createError'); 4 | 5 | /** 6 | * Resolve or reject a Promise based on response status. 7 | * 8 | * @param {Function} resolve A function that resolves the promise. 9 | * @param {Function} reject A function that rejects the promise. 10 | * @param {object} response The response. 11 | */ 12 | module.exports = function settle(resolve, reject, response) { 13 | var validateStatus = response.config.validateStatus; 14 | if (!response.status || !validateStatus || validateStatus(response.status)) { 15 | resolve(response); 16 | } else { 17 | reject(createError( 18 | 'Request failed with status code ' + response.status, 19 | response.config, 20 | null, 21 | response.request, 22 | response 23 | )); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/core/transformData.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | var defaults = require('./../defaults'); 5 | 6 | /** 7 | * Transform the data for a request or a response 8 | * 9 | * @param {Object|String} data The data to be transformed 10 | * @param {Array} headers The headers for the request or response 11 | * @param {Array|Function} fns A single function or Array of functions 12 | * @returns {*} The resulting transformed data 13 | */ 14 | module.exports = function transformData(data, headers, fns) { 15 | var context = this || defaults; 16 | /*eslint no-param-reassign:0*/ 17 | utils.forEach(fns, function transform(fn) { 18 | data = fn.call(context, data, headers); 19 | }); 20 | 21 | return data; 22 | }; 23 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/defaults.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./utils'); 4 | var normalizeHeaderName = require('./helpers/normalizeHeaderName'); 5 | var enhanceError = require('./core/enhanceError'); 6 | 7 | var DEFAULT_CONTENT_TYPE = { 8 | 'Content-Type': 'application/x-www-form-urlencoded' 9 | }; 10 | 11 | function setContentTypeIfUnset(headers, value) { 12 | if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 13 | headers['Content-Type'] = value; 14 | } 15 | } 16 | 17 | function getDefaultAdapter() { 18 | var adapter; 19 | if (typeof XMLHttpRequest !== 'undefined') { 20 | // For browsers use XHR adapter 21 | adapter = require('./adapters/xhr'); 22 | } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 23 | // For node use HTTP adapter 24 | adapter = require('./adapters/http'); 25 | } 26 | return adapter; 27 | } 28 | 29 | function stringifySafely(rawValue, parser, encoder) { 30 | if (utils.isString(rawValue)) { 31 | try { 32 | (parser || JSON.parse)(rawValue); 33 | return utils.trim(rawValue); 34 | } catch (e) { 35 | if (e.name !== 'SyntaxError') { 36 | throw e; 37 | } 38 | } 39 | } 40 | 41 | return (encoder || JSON.stringify)(rawValue); 42 | } 43 | 44 | var defaults = { 45 | 46 | transitional: { 47 | silentJSONParsing: true, 48 | forcedJSONParsing: true, 49 | clarifyTimeoutError: false 50 | }, 51 | 52 | adapter: getDefaultAdapter(), 53 | 54 | transformRequest: [function transformRequest(data, headers) { 55 | normalizeHeaderName(headers, 'Accept'); 56 | normalizeHeaderName(headers, 'Content-Type'); 57 | 58 | if (utils.isFormData(data) || 59 | utils.isArrayBuffer(data) || 60 | utils.isBuffer(data) || 61 | utils.isStream(data) || 62 | utils.isFile(data) || 63 | utils.isBlob(data) 64 | ) { 65 | return data; 66 | } 67 | if (utils.isArrayBufferView(data)) { 68 | return data.buffer; 69 | } 70 | if (utils.isURLSearchParams(data)) { 71 | setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 72 | return data.toString(); 73 | } 74 | if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) { 75 | setContentTypeIfUnset(headers, 'application/json'); 76 | return stringifySafely(data); 77 | } 78 | return data; 79 | }], 80 | 81 | transformResponse: [function transformResponse(data) { 82 | var transitional = this.transitional; 83 | var silentJSONParsing = transitional && transitional.silentJSONParsing; 84 | var forcedJSONParsing = transitional && transitional.forcedJSONParsing; 85 | var strictJSONParsing = !silentJSONParsing && this.responseType === 'json'; 86 | 87 | if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) { 88 | try { 89 | return JSON.parse(data); 90 | } catch (e) { 91 | if (strictJSONParsing) { 92 | if (e.name === 'SyntaxError') { 93 | throw enhanceError(e, this, 'E_JSON_PARSE'); 94 | } 95 | throw e; 96 | } 97 | } 98 | } 99 | 100 | return data; 101 | }], 102 | 103 | /** 104 | * A timeout in milliseconds to abort a request. If set to 0 (default) a 105 | * timeout is not created. 106 | */ 107 | timeout: 0, 108 | 109 | xsrfCookieName: 'XSRF-TOKEN', 110 | xsrfHeaderName: 'X-XSRF-TOKEN', 111 | 112 | maxContentLength: -1, 113 | maxBodyLength: -1, 114 | 115 | validateStatus: function validateStatus(status) { 116 | return status >= 200 && status < 300; 117 | } 118 | }; 119 | 120 | defaults.headers = { 121 | common: { 122 | 'Accept': 'application/json, text/plain, */*' 123 | } 124 | }; 125 | 126 | utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 127 | defaults.headers[method] = {}; 128 | }); 129 | 130 | utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 131 | defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 132 | }); 133 | 134 | module.exports = defaults; 135 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/README.md: -------------------------------------------------------------------------------- 1 | # axios // helpers 2 | 3 | The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like: 4 | 5 | - Browser polyfills 6 | - Managing cookies 7 | - Parsing HTTP headers 8 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/bind.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function bind(fn, thisArg) { 4 | return function wrap() { 5 | var args = new Array(arguments.length); 6 | for (var i = 0; i < args.length; i++) { 7 | args[i] = arguments[i]; 8 | } 9 | return fn.apply(thisArg, args); 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/buildURL.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | function encode(val) { 6 | return encodeURIComponent(val). 7 | replace(/%3A/gi, ':'). 8 | replace(/%24/g, '$'). 9 | replace(/%2C/gi, ','). 10 | replace(/%20/g, '+'). 11 | replace(/%5B/gi, '['). 12 | replace(/%5D/gi, ']'); 13 | } 14 | 15 | /** 16 | * Build a URL by appending params to the end 17 | * 18 | * @param {string} url The base of the url (e.g., http://www.google.com) 19 | * @param {object} [params] The params to be appended 20 | * @returns {string} The formatted url 21 | */ 22 | module.exports = function buildURL(url, params, paramsSerializer) { 23 | /*eslint no-param-reassign:0*/ 24 | if (!params) { 25 | return url; 26 | } 27 | 28 | var serializedParams; 29 | if (paramsSerializer) { 30 | serializedParams = paramsSerializer(params); 31 | } else if (utils.isURLSearchParams(params)) { 32 | serializedParams = params.toString(); 33 | } else { 34 | var parts = []; 35 | 36 | utils.forEach(params, function serialize(val, key) { 37 | if (val === null || typeof val === 'undefined') { 38 | return; 39 | } 40 | 41 | if (utils.isArray(val)) { 42 | key = key + '[]'; 43 | } else { 44 | val = [val]; 45 | } 46 | 47 | utils.forEach(val, function parseValue(v) { 48 | if (utils.isDate(v)) { 49 | v = v.toISOString(); 50 | } else if (utils.isObject(v)) { 51 | v = JSON.stringify(v); 52 | } 53 | parts.push(encode(key) + '=' + encode(v)); 54 | }); 55 | }); 56 | 57 | serializedParams = parts.join('&'); 58 | } 59 | 60 | if (serializedParams) { 61 | var hashmarkIndex = url.indexOf('#'); 62 | if (hashmarkIndex !== -1) { 63 | url = url.slice(0, hashmarkIndex); 64 | } 65 | 66 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 67 | } 68 | 69 | return url; 70 | }; 71 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/combineURLs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Creates a new URL by combining the specified URLs 5 | * 6 | * @param {string} baseURL The base URL 7 | * @param {string} relativeURL The relative URL 8 | * @returns {string} The combined URL 9 | */ 10 | module.exports = function combineURLs(baseURL, relativeURL) { 11 | return relativeURL 12 | ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 13 | : baseURL; 14 | }; 15 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/cookies.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | module.exports = ( 6 | utils.isStandardBrowserEnv() ? 7 | 8 | // Standard browser envs support document.cookie 9 | (function standardBrowserEnv() { 10 | return { 11 | write: function write(name, value, expires, path, domain, secure) { 12 | var cookie = []; 13 | cookie.push(name + '=' + encodeURIComponent(value)); 14 | 15 | if (utils.isNumber(expires)) { 16 | cookie.push('expires=' + new Date(expires).toGMTString()); 17 | } 18 | 19 | if (utils.isString(path)) { 20 | cookie.push('path=' + path); 21 | } 22 | 23 | if (utils.isString(domain)) { 24 | cookie.push('domain=' + domain); 25 | } 26 | 27 | if (secure === true) { 28 | cookie.push('secure'); 29 | } 30 | 31 | document.cookie = cookie.join('; '); 32 | }, 33 | 34 | read: function read(name) { 35 | var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 36 | return (match ? decodeURIComponent(match[3]) : null); 37 | }, 38 | 39 | remove: function remove(name) { 40 | this.write(name, '', Date.now() - 86400000); 41 | } 42 | }; 43 | })() : 44 | 45 | // Non standard browser env (web workers, react-native) lack needed support. 46 | (function nonStandardBrowserEnv() { 47 | return { 48 | write: function write() {}, 49 | read: function read() { return null; }, 50 | remove: function remove() {} 51 | }; 52 | })() 53 | ); 54 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/deprecatedMethod.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /*eslint no-console:0*/ 4 | 5 | /** 6 | * Supply a warning to the developer that a method they are using 7 | * has been deprecated. 8 | * 9 | * @param {string} method The name of the deprecated method 10 | * @param {string} [instead] The alternate method to use if applicable 11 | * @param {string} [docs] The documentation URL to get further details 12 | */ 13 | module.exports = function deprecatedMethod(method, instead, docs) { 14 | try { 15 | console.warn( 16 | 'DEPRECATED method `' + method + '`.' + 17 | (instead ? ' Use `' + instead + '` instead.' : '') + 18 | ' This method will be removed in a future release.'); 19 | 20 | if (docs) { 21 | console.warn('For more information about usage see ' + docs); 22 | } 23 | } catch (e) { /* Ignore */ } 24 | }; 25 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/isAbsoluteURL.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Determines whether the specified URL is absolute 5 | * 6 | * @param {string} url The URL to test 7 | * @returns {boolean} True if the specified URL is absolute, otherwise false 8 | */ 9 | module.exports = function isAbsoluteURL(url) { 10 | // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). 11 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 12 | // by any combination of letters, digits, plus, period, or hyphen. 13 | return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); 14 | }; 15 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/isAxiosError.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Determines whether the payload is an error thrown by Axios 5 | * 6 | * @param {*} payload The value to test 7 | * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false 8 | */ 9 | module.exports = function isAxiosError(payload) { 10 | return (typeof payload === 'object') && (payload.isAxiosError === true); 11 | }; 12 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/isURLSameOrigin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | module.exports = ( 6 | utils.isStandardBrowserEnv() ? 7 | 8 | // Standard browser envs have full support of the APIs needed to test 9 | // whether the request URL is of the same origin as current location. 10 | (function standardBrowserEnv() { 11 | var msie = /(msie|trident)/i.test(navigator.userAgent); 12 | var urlParsingNode = document.createElement('a'); 13 | var originURL; 14 | 15 | /** 16 | * Parse a URL to discover it's components 17 | * 18 | * @param {String} url The URL to be parsed 19 | * @returns {Object} 20 | */ 21 | function resolveURL(url) { 22 | var href = url; 23 | 24 | if (msie) { 25 | // IE needs attribute set twice to normalize properties 26 | urlParsingNode.setAttribute('href', href); 27 | href = urlParsingNode.href; 28 | } 29 | 30 | urlParsingNode.setAttribute('href', href); 31 | 32 | // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 33 | return { 34 | href: urlParsingNode.href, 35 | protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 36 | host: urlParsingNode.host, 37 | search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 38 | hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 39 | hostname: urlParsingNode.hostname, 40 | port: urlParsingNode.port, 41 | pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 42 | urlParsingNode.pathname : 43 | '/' + urlParsingNode.pathname 44 | }; 45 | } 46 | 47 | originURL = resolveURL(window.location.href); 48 | 49 | /** 50 | * Determine if a URL shares the same origin as the current location 51 | * 52 | * @param {String} requestURL The URL to test 53 | * @returns {boolean} True if URL shares the same origin, otherwise false 54 | */ 55 | return function isURLSameOrigin(requestURL) { 56 | var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 57 | return (parsed.protocol === originURL.protocol && 58 | parsed.host === originURL.host); 59 | }; 60 | })() : 61 | 62 | // Non standard browser envs (web workers, react-native) lack needed support. 63 | (function nonStandardBrowserEnv() { 64 | return function isURLSameOrigin() { 65 | return true; 66 | }; 67 | })() 68 | ); 69 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/normalizeHeaderName.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('../utils'); 4 | 5 | module.exports = function normalizeHeaderName(headers, normalizedName) { 6 | utils.forEach(headers, function processHeader(value, name) { 7 | if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 8 | headers[normalizedName] = value; 9 | delete headers[name]; 10 | } 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/parseHeaders.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('./../utils'); 4 | 5 | // Headers whose duplicates are ignored by node 6 | // c.f. https://nodejs.org/api/http.html#http_message_headers 7 | var ignoreDuplicateOf = [ 8 | 'age', 'authorization', 'content-length', 'content-type', 'etag', 9 | 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 10 | 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 11 | 'referer', 'retry-after', 'user-agent' 12 | ]; 13 | 14 | /** 15 | * Parse headers into an object 16 | * 17 | * ``` 18 | * Date: Wed, 27 Aug 2014 08:58:49 GMT 19 | * Content-Type: application/json 20 | * Connection: keep-alive 21 | * Transfer-Encoding: chunked 22 | * ``` 23 | * 24 | * @param {String} headers Headers needing to be parsed 25 | * @returns {Object} Headers parsed into an object 26 | */ 27 | module.exports = function parseHeaders(headers) { 28 | var parsed = {}; 29 | var key; 30 | var val; 31 | var i; 32 | 33 | if (!headers) { return parsed; } 34 | 35 | utils.forEach(headers.split('\n'), function parser(line) { 36 | i = line.indexOf(':'); 37 | key = utils.trim(line.substr(0, i)).toLowerCase(); 38 | val = utils.trim(line.substr(i + 1)); 39 | 40 | if (key) { 41 | if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 42 | return; 43 | } 44 | if (key === 'set-cookie') { 45 | parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 46 | } else { 47 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 48 | } 49 | } 50 | }); 51 | 52 | return parsed; 53 | }; 54 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/spread.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Syntactic sugar for invoking a function and expanding an array for arguments. 5 | * 6 | * Common use case would be to use `Function.prototype.apply`. 7 | * 8 | * ```js 9 | * function f(x, y, z) {} 10 | * var args = [1, 2, 3]; 11 | * f.apply(null, args); 12 | * ``` 13 | * 14 | * With `spread` this example can be re-written. 15 | * 16 | * ```js 17 | * spread(function(x, y, z) {})([1, 2, 3]); 18 | * ``` 19 | * 20 | * @param {Function} callback 21 | * @returns {Function} 22 | */ 23 | module.exports = function spread(callback) { 24 | return function wrap(arr) { 25 | return callback.apply(null, arr); 26 | }; 27 | }; 28 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/helpers/validator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var pkg = require('./../../package.json'); 4 | 5 | var validators = {}; 6 | 7 | // eslint-disable-next-line func-names 8 | ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { 9 | validators[type] = function validator(thing) { 10 | return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; 11 | }; 12 | }); 13 | 14 | var deprecatedWarnings = {}; 15 | var currentVerArr = pkg.version.split('.'); 16 | 17 | /** 18 | * Compare package versions 19 | * @param {string} version 20 | * @param {string?} thanVersion 21 | * @returns {boolean} 22 | */ 23 | function isOlderVersion(version, thanVersion) { 24 | var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr; 25 | var destVer = version.split('.'); 26 | for (var i = 0; i < 3; i++) { 27 | if (pkgVersionArr[i] > destVer[i]) { 28 | return true; 29 | } else if (pkgVersionArr[i] < destVer[i]) { 30 | return false; 31 | } 32 | } 33 | return false; 34 | } 35 | 36 | /** 37 | * Transitional option validator 38 | * @param {function|boolean?} validator 39 | * @param {string?} version 40 | * @param {string} message 41 | * @returns {function} 42 | */ 43 | validators.transitional = function transitional(validator, version, message) { 44 | var isDeprecated = version && isOlderVersion(version); 45 | 46 | function formatMessage(opt, desc) { 47 | return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); 48 | } 49 | 50 | // eslint-disable-next-line func-names 51 | return function(value, opt, opts) { 52 | if (validator === false) { 53 | throw new Error(formatMessage(opt, ' has been removed in ' + version)); 54 | } 55 | 56 | if (isDeprecated && !deprecatedWarnings[opt]) { 57 | deprecatedWarnings[opt] = true; 58 | // eslint-disable-next-line no-console 59 | console.warn( 60 | formatMessage( 61 | opt, 62 | ' has been deprecated since v' + version + ' and will be removed in the near future' 63 | ) 64 | ); 65 | } 66 | 67 | return validator ? validator(value, opt, opts) : true; 68 | }; 69 | }; 70 | 71 | /** 72 | * Assert object's properties type 73 | * @param {object} options 74 | * @param {object} schema 75 | * @param {boolean?} allowUnknown 76 | */ 77 | 78 | function assertOptions(options, schema, allowUnknown) { 79 | if (typeof options !== 'object') { 80 | throw new TypeError('options must be an object'); 81 | } 82 | var keys = Object.keys(options); 83 | var i = keys.length; 84 | while (i-- > 0) { 85 | var opt = keys[i]; 86 | var validator = schema[opt]; 87 | if (validator) { 88 | var value = options[opt]; 89 | var result = value === undefined || validator(value, opt, options); 90 | if (result !== true) { 91 | throw new TypeError('option ' + opt + ' must be ' + result); 92 | } 93 | continue; 94 | } 95 | if (allowUnknown !== true) { 96 | throw Error('Unknown option ' + opt); 97 | } 98 | } 99 | } 100 | 101 | module.exports = { 102 | isOlderVersion: isOlderVersion, 103 | assertOptions: assertOptions, 104 | validators: validators 105 | }; 106 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/lib/utils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var bind = require('./helpers/bind'); 4 | 5 | // utils is a library of generic helper functions non-specific to axios 6 | 7 | var toString = Object.prototype.toString; 8 | 9 | /** 10 | * Determine if a value is an Array 11 | * 12 | * @param {Object} val The value to test 13 | * @returns {boolean} True if value is an Array, otherwise false 14 | */ 15 | function isArray(val) { 16 | return toString.call(val) === '[object Array]'; 17 | } 18 | 19 | /** 20 | * Determine if a value is undefined 21 | * 22 | * @param {Object} val The value to test 23 | * @returns {boolean} True if the value is undefined, otherwise false 24 | */ 25 | function isUndefined(val) { 26 | return typeof val === 'undefined'; 27 | } 28 | 29 | /** 30 | * Determine if a value is a Buffer 31 | * 32 | * @param {Object} val The value to test 33 | * @returns {boolean} True if value is a Buffer, otherwise false 34 | */ 35 | function isBuffer(val) { 36 | return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) 37 | && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); 38 | } 39 | 40 | /** 41 | * Determine if a value is an ArrayBuffer 42 | * 43 | * @param {Object} val The value to test 44 | * @returns {boolean} True if value is an ArrayBuffer, otherwise false 45 | */ 46 | function isArrayBuffer(val) { 47 | return toString.call(val) === '[object ArrayBuffer]'; 48 | } 49 | 50 | /** 51 | * Determine if a value is a FormData 52 | * 53 | * @param {Object} val The value to test 54 | * @returns {boolean} True if value is an FormData, otherwise false 55 | */ 56 | function isFormData(val) { 57 | return (typeof FormData !== 'undefined') && (val instanceof FormData); 58 | } 59 | 60 | /** 61 | * Determine if a value is a view on an ArrayBuffer 62 | * 63 | * @param {Object} val The value to test 64 | * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 65 | */ 66 | function isArrayBufferView(val) { 67 | var result; 68 | if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 69 | result = ArrayBuffer.isView(val); 70 | } else { 71 | result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); 72 | } 73 | return result; 74 | } 75 | 76 | /** 77 | * Determine if a value is a String 78 | * 79 | * @param {Object} val The value to test 80 | * @returns {boolean} True if value is a String, otherwise false 81 | */ 82 | function isString(val) { 83 | return typeof val === 'string'; 84 | } 85 | 86 | /** 87 | * Determine if a value is a Number 88 | * 89 | * @param {Object} val The value to test 90 | * @returns {boolean} True if value is a Number, otherwise false 91 | */ 92 | function isNumber(val) { 93 | return typeof val === 'number'; 94 | } 95 | 96 | /** 97 | * Determine if a value is an Object 98 | * 99 | * @param {Object} val The value to test 100 | * @returns {boolean} True if value is an Object, otherwise false 101 | */ 102 | function isObject(val) { 103 | return val !== null && typeof val === 'object'; 104 | } 105 | 106 | /** 107 | * Determine if a value is a plain Object 108 | * 109 | * @param {Object} val The value to test 110 | * @return {boolean} True if value is a plain Object, otherwise false 111 | */ 112 | function isPlainObject(val) { 113 | if (toString.call(val) !== '[object Object]') { 114 | return false; 115 | } 116 | 117 | var prototype = Object.getPrototypeOf(val); 118 | return prototype === null || prototype === Object.prototype; 119 | } 120 | 121 | /** 122 | * Determine if a value is a Date 123 | * 124 | * @param {Object} val The value to test 125 | * @returns {boolean} True if value is a Date, otherwise false 126 | */ 127 | function isDate(val) { 128 | return toString.call(val) === '[object Date]'; 129 | } 130 | 131 | /** 132 | * Determine if a value is a File 133 | * 134 | * @param {Object} val The value to test 135 | * @returns {boolean} True if value is a File, otherwise false 136 | */ 137 | function isFile(val) { 138 | return toString.call(val) === '[object File]'; 139 | } 140 | 141 | /** 142 | * Determine if a value is a Blob 143 | * 144 | * @param {Object} val The value to test 145 | * @returns {boolean} True if value is a Blob, otherwise false 146 | */ 147 | function isBlob(val) { 148 | return toString.call(val) === '[object Blob]'; 149 | } 150 | 151 | /** 152 | * Determine if a value is a Function 153 | * 154 | * @param {Object} val The value to test 155 | * @returns {boolean} True if value is a Function, otherwise false 156 | */ 157 | function isFunction(val) { 158 | return toString.call(val) === '[object Function]'; 159 | } 160 | 161 | /** 162 | * Determine if a value is a Stream 163 | * 164 | * @param {Object} val The value to test 165 | * @returns {boolean} True if value is a Stream, otherwise false 166 | */ 167 | function isStream(val) { 168 | return isObject(val) && isFunction(val.pipe); 169 | } 170 | 171 | /** 172 | * Determine if a value is a URLSearchParams object 173 | * 174 | * @param {Object} val The value to test 175 | * @returns {boolean} True if value is a URLSearchParams object, otherwise false 176 | */ 177 | function isURLSearchParams(val) { 178 | return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; 179 | } 180 | 181 | /** 182 | * Trim excess whitespace off the beginning and end of a string 183 | * 184 | * @param {String} str The String to trim 185 | * @returns {String} The String freed of excess whitespace 186 | */ 187 | function trim(str) { 188 | return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); 189 | } 190 | 191 | /** 192 | * Determine if we're running in a standard browser environment 193 | * 194 | * This allows axios to run in a web worker, and react-native. 195 | * Both environments support XMLHttpRequest, but not fully standard globals. 196 | * 197 | * web workers: 198 | * typeof window -> undefined 199 | * typeof document -> undefined 200 | * 201 | * react-native: 202 | * navigator.product -> 'ReactNative' 203 | * nativescript 204 | * navigator.product -> 'NativeScript' or 'NS' 205 | */ 206 | function isStandardBrowserEnv() { 207 | if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || 208 | navigator.product === 'NativeScript' || 209 | navigator.product === 'NS')) { 210 | return false; 211 | } 212 | return ( 213 | typeof window !== 'undefined' && 214 | typeof document !== 'undefined' 215 | ); 216 | } 217 | 218 | /** 219 | * Iterate over an Array or an Object invoking a function for each item. 220 | * 221 | * If `obj` is an Array callback will be called passing 222 | * the value, index, and complete array for each item. 223 | * 224 | * If 'obj' is an Object callback will be called passing 225 | * the value, key, and complete object for each property. 226 | * 227 | * @param {Object|Array} obj The object to iterate 228 | * @param {Function} fn The callback to invoke for each item 229 | */ 230 | function forEach(obj, fn) { 231 | // Don't bother if no value provided 232 | if (obj === null || typeof obj === 'undefined') { 233 | return; 234 | } 235 | 236 | // Force an array if not already something iterable 237 | if (typeof obj !== 'object') { 238 | /*eslint no-param-reassign:0*/ 239 | obj = [obj]; 240 | } 241 | 242 | if (isArray(obj)) { 243 | // Iterate over array values 244 | for (var i = 0, l = obj.length; i < l; i++) { 245 | fn.call(null, obj[i], i, obj); 246 | } 247 | } else { 248 | // Iterate over object keys 249 | for (var key in obj) { 250 | if (Object.prototype.hasOwnProperty.call(obj, key)) { 251 | fn.call(null, obj[key], key, obj); 252 | } 253 | } 254 | } 255 | } 256 | 257 | /** 258 | * Accepts varargs expecting each argument to be an object, then 259 | * immutably merges the properties of each object and returns result. 260 | * 261 | * When multiple objects contain the same key the later object in 262 | * the arguments list will take precedence. 263 | * 264 | * Example: 265 | * 266 | * ```js 267 | * var result = merge({foo: 123}, {foo: 456}); 268 | * console.log(result.foo); // outputs 456 269 | * ``` 270 | * 271 | * @param {Object} obj1 Object to merge 272 | * @returns {Object} Result of all merge properties 273 | */ 274 | function merge(/* obj1, obj2, obj3, ... */) { 275 | var result = {}; 276 | function assignValue(val, key) { 277 | if (isPlainObject(result[key]) && isPlainObject(val)) { 278 | result[key] = merge(result[key], val); 279 | } else if (isPlainObject(val)) { 280 | result[key] = merge({}, val); 281 | } else if (isArray(val)) { 282 | result[key] = val.slice(); 283 | } else { 284 | result[key] = val; 285 | } 286 | } 287 | 288 | for (var i = 0, l = arguments.length; i < l; i++) { 289 | forEach(arguments[i], assignValue); 290 | } 291 | return result; 292 | } 293 | 294 | /** 295 | * Extends object a by mutably adding to it the properties of object b. 296 | * 297 | * @param {Object} a The object to be extended 298 | * @param {Object} b The object to copy properties from 299 | * @param {Object} thisArg The object to bind function to 300 | * @return {Object} The resulting value of object a 301 | */ 302 | function extend(a, b, thisArg) { 303 | forEach(b, function assignValue(val, key) { 304 | if (thisArg && typeof val === 'function') { 305 | a[key] = bind(val, thisArg); 306 | } else { 307 | a[key] = val; 308 | } 309 | }); 310 | return a; 311 | } 312 | 313 | /** 314 | * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) 315 | * 316 | * @param {string} content with BOM 317 | * @return {string} content value without BOM 318 | */ 319 | function stripBOM(content) { 320 | if (content.charCodeAt(0) === 0xFEFF) { 321 | content = content.slice(1); 322 | } 323 | return content; 324 | } 325 | 326 | module.exports = { 327 | isArray: isArray, 328 | isArrayBuffer: isArrayBuffer, 329 | isBuffer: isBuffer, 330 | isFormData: isFormData, 331 | isArrayBufferView: isArrayBufferView, 332 | isString: isString, 333 | isNumber: isNumber, 334 | isObject: isObject, 335 | isPlainObject: isPlainObject, 336 | isUndefined: isUndefined, 337 | isDate: isDate, 338 | isFile: isFile, 339 | isBlob: isBlob, 340 | isFunction: isFunction, 341 | isStream: isStream, 342 | isURLSearchParams: isURLSearchParams, 343 | isStandardBrowserEnv: isStandardBrowserEnv, 344 | forEach: forEach, 345 | merge: merge, 346 | extend: extend, 347 | trim: trim, 348 | stripBOM: stripBOM 349 | }; 350 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/axios/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "axios", 3 | "version": "0.21.4", 4 | "description": "Promise based HTTP client for the browser and node.js", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "grunt test", 8 | "start": "node ./sandbox/server.js", 9 | "build": "NODE_ENV=production grunt build", 10 | "preversion": "npm test", 11 | "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json", 12 | "postversion": "git push && git push --tags", 13 | "examples": "node ./examples/server.js", 14 | "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", 15 | "fix": "eslint --fix lib/**/*.js" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/axios/axios.git" 20 | }, 21 | "keywords": [ 22 | "xhr", 23 | "http", 24 | "ajax", 25 | "promise", 26 | "node" 27 | ], 28 | "author": "Matt Zabriskie", 29 | "license": "MIT", 30 | "bugs": { 31 | "url": "https://github.com/axios/axios/issues" 32 | }, 33 | "homepage": "https://axios-http.com", 34 | "devDependencies": { 35 | "coveralls": "^3.0.0", 36 | "es6-promise": "^4.2.4", 37 | "grunt": "^1.3.0", 38 | "grunt-banner": "^0.6.0", 39 | "grunt-cli": "^1.2.0", 40 | "grunt-contrib-clean": "^1.1.0", 41 | "grunt-contrib-watch": "^1.0.0", 42 | "grunt-eslint": "^23.0.0", 43 | "grunt-karma": "^4.0.0", 44 | "grunt-mocha-test": "^0.13.3", 45 | "grunt-ts": "^6.0.0-beta.19", 46 | "grunt-webpack": "^4.0.2", 47 | "istanbul-instrumenter-loader": "^1.0.0", 48 | "jasmine-core": "^2.4.1", 49 | "karma": "^6.3.2", 50 | "karma-chrome-launcher": "^3.1.0", 51 | "karma-firefox-launcher": "^2.1.0", 52 | "karma-jasmine": "^1.1.1", 53 | "karma-jasmine-ajax": "^0.1.13", 54 | "karma-safari-launcher": "^1.0.0", 55 | "karma-sauce-launcher": "^4.3.6", 56 | "karma-sinon": "^1.0.5", 57 | "karma-sourcemap-loader": "^0.3.8", 58 | "karma-webpack": "^4.0.2", 59 | "load-grunt-tasks": "^3.5.2", 60 | "minimist": "^1.2.0", 61 | "mocha": "^8.2.1", 62 | "sinon": "^4.5.0", 63 | "terser-webpack-plugin": "^4.2.3", 64 | "typescript": "^4.0.5", 65 | "url-search-params": "^0.10.0", 66 | "webpack": "^4.44.2", 67 | "webpack-dev-server": "^3.11.0" 68 | }, 69 | "browser": { 70 | "./lib/adapters/http.js": "./lib/adapters/xhr.js" 71 | }, 72 | "jsdelivr": "dist/axios.min.js", 73 | "unpkg": "dist/axios.min.js", 74 | "typings": "./index.d.ts", 75 | "dependencies": { 76 | "follow-redirects": "^1.14.0" 77 | }, 78 | "bundlesize": [ 79 | { 80 | "path": "./dist/axios.min.js", 81 | "threshold": "5kB" 82 | } 83 | ] 84 | } 85 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/big.js/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | #### 6.1.1 2 | 3 | * 03/05/21 4 | * #169 Bugfix: `round`, `toFixed` etc. using original constructor `RM` (bug introduced in *v6.0.0*). 5 | * #169 Correct rounding mode documentation. 6 | * Add version number to legacy documentation. 7 | 8 | #### 6.1.0 9 | 10 | * 26/04/21 11 | * #165 Add missing documentation of `toFixed` etc. rounding mode parameter. 12 | * #150 Add static rounding modes to `Big` constructor. 13 | 14 | #### 6.0.3 15 | 16 | * 02/12/20 17 | * #148 Bugfix: primitive numbers passed to constructor internally in strict mode. 18 | 19 | #### 6.0.2 20 | 21 | * 31/10/20 22 | * #147 Change `toJSON` to be an alias of `toString`. 23 | 24 | #### 6.0.1 25 | 26 | * 30/09/20 27 | * Correct `sqrt` initial estimate. 28 | 29 | #### 6.0.0 30 | 31 | * 25/09/20 32 | * Add optional rounding mode parameter to `toExponential`, `toFixed` and `toPrecision`. 33 | * Add a strict mode to disallow imprecise number/Big conversions when `Big.strict = true`. 34 | * Add `toNumber` method. 35 | * Add `prec` method to round a Big to a specified number of significant digits. 36 | * Add version selector to API documentation. 37 | * Change `toJSON` to return exponential format. 38 | * Remove *big.min.js*. 39 | * Remove `Big.version`. 40 | * Rename *doc* folder to *docs* to use it as the GitHub publishing source. 41 | * Add legacy API documentation to *docs*. 42 | * Add *README* to *perf* directory. 43 | * Refactor test suite, and add `toNumber` and `prec` tests. 44 | * Update *README*. 45 | 46 | #### 5.2.2 47 | 48 | * 18/10/18 49 | * #109 Remove opencollective dependency. 50 | 51 | #### 5.2.1 52 | 53 | * Delete *bower.json*. 54 | 55 | #### 5.2.0 56 | 57 | * 09/10/18 58 | * #63 Allow negative argument for `round`. 59 | * #107 `sqrt` of large number. 60 | 61 | #### 5.1.2 62 | 63 | * 24/05/18 64 | * #95 Add `browser` field to *package.json*. 65 | * Restore named export to enable `import {Big}`. 66 | 67 | #### 5.1.1 68 | 69 | * 22/05/18 70 | * #95 Remove named export. 71 | 72 | #### 5.1.0 73 | 74 | * 22/05/18 75 | * Amend *.mjs* exports. 76 | * Remove extension from `main` field in *package.json*. 77 | 78 | #### 5.0.3 79 | 80 | * 23/10/17 81 | * #89 Optimisation of internal `round` function. 82 | 83 | #### 5.0.2 84 | 85 | * 13/10/17 86 | * Update *README.md*. 87 | 88 | #### 5.0.1 89 | 90 | * 13/10/17 91 | * Correct `Big.version` number. 92 | 93 | #### 5.0.0 94 | 95 | * 13/10/17 96 | * Return `-0` from `valueOf` for negative zero. 97 | * Refactor the methods which return a string. 98 | * Amend error messaging. 99 | * Update API document and change its colour scheme. 100 | * Add `Big.version`. 101 | * Remove bitcoin address. 102 | 103 | #### 4.0.2 104 | 105 | * 28/09/17 106 | * Add *big.mjs* for use with Node.js with `--experimental-modules` flag. 107 | 108 | #### 4.0.0 109 | 110 | * 27/09/17 111 | * Rename `Big.E_POS` to `Big.PE`, `Big.E_NEG` to `Big.NE`. 112 | * Refactor error messaging. 113 | * Throw if `null` is passed to `toFixed` etc. 114 | 115 | #### 3.2.0 116 | 117 | * 14/09/17 Aid ES6 import. 118 | 119 | #### 3.1.3 120 | 121 | * Minor documentation updates. 122 | 123 | #### 3.1.2 124 | 125 | * README typo. 126 | 127 | #### 3.1.1 128 | 129 | * API documentation update, including FAQ additions. 130 | 131 | #### 3.1.0 132 | 133 | * Renamed and exposed `TO_EXP_NEG` and `TO_EXP_POS` as `Big.E_NEG` and `Big.E_POS`. 134 | 135 | #### 3.0.2 136 | 137 | * Remove *.npmignore*, use `files` field in *package.json* instead. 138 | 139 | #### 3.0.1 140 | 141 | * Added `sub`, `add` and `mul` aliases. 142 | * Clean-up after lint. 143 | 144 | #### 3.0.0 145 | 146 | * 10/12/14 Added [multiple constructor functionality](http://mikemcl.github.io/big.js/#faq). 147 | * No breaking changes or other additions, but a major code reorganisation, so *v3* seemed appropiate. 148 | 149 | #### 2.5.2 150 | 151 | * 1/11/14 Added bower.json. 152 | 153 | #### 2.5.1 154 | 155 | * 8/06/14 Amend README requires. 156 | 157 | #### 2.5.0 158 | 159 | * 26/01/14 Added `toJSON` method so serialization uses `toString`. 160 | 161 | #### 2.4.1 162 | 163 | * 17/10/13 Conform signed zero to IEEEE 754 (2008). 164 | 165 | #### 2.4.0 166 | 167 | * 19/09/13 Throw instances of `Error`. 168 | 169 | #### 2.3.0 170 | 171 | * 16/09/13 Added `cmp` method. 172 | 173 | #### 2.2.0 174 | 175 | * 11/07/13 Added 'round up' mode. 176 | 177 | #### 2.1.0 178 | 179 | * 26/06/13 Allow e.g. `.1` and `2.`. 180 | 181 | #### 2.0.0 182 | 183 | * 12/05/13 Added `abs` method and replaced `cmp` with `eq`, `gt`, `gte`, `lt`, and `lte` methods. 184 | 185 | #### 1.0.1 186 | 187 | * Changed default value of MAX_DP to 1E6 188 | 189 | #### 1.0.0 190 | 191 | * 7/11/2012 Initial release 192 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/big.js/LICENCE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © `<2021>` `Michael Mclaughlin` 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/big.js/README.md: -------------------------------------------------------------------------------- 1 | # big.js 2 | 3 | **A small, fast JavaScript library for arbitrary-precision decimal arithmetic.** 4 | 5 | [![npm version](https://img.shields.io/npm/v/big.js.svg)](https://www.npmjs.com/package/big.js) 6 | [![npm downloads](https://img.shields.io/npm/dw/big.js)](https://www.npmjs.com/package/big.js) 7 | 8 | ## Features 9 | 10 | - Simple API 11 | - Faster, smaller and easier-to-use than JavaScript versions of Java's BigDecimal 12 | - Only 6 KB minified 13 | - Replicates the `toExponential`, `toFixed` and `toPrecision` methods of JavaScript Numbers 14 | - Stores values in an accessible decimal floating point format 15 | - Comprehensive [documentation](http://mikemcl.github.io/big.js/) and test set 16 | - No dependencies 17 | - Uses ECMAScript 3 only, so works in all browsers 18 | 19 | The little sister to [bignumber.js](https://github.com/MikeMcl/bignumber.js/) and [decimal.js](https://github.com/MikeMcl/decimal.js/). See [here](https://github.com/MikeMcl/big.js/wiki) for some notes on the difference between them. 20 | 21 | ## Install 22 | 23 | The library is the single JavaScript file *big.js* or the ES module *big.mjs*. 24 | 25 | ### Browsers 26 | 27 | Add Big to global scope: 28 | 29 | ```html 30 | 31 | ``` 32 | 33 | ES module: 34 | 35 | ```html 36 | 44 | ``` 45 | 46 | ### [Node.js](http://nodejs.org) 47 | 48 | ```bash 49 | $ npm install big.js 50 | ``` 51 | 52 | CommonJS: 53 | 54 | ```javascript 55 | const Big = require('big.js'); 56 | ``` 57 | 58 | ES module: 59 | 60 | ```javascript 61 | import Big from 'big.js'; 62 | ``` 63 | 64 | ### [Deno](https://deno.land/) 65 | 66 | ```javascript 67 | import Big from 'https://raw.githubusercontent.com/mikemcl/big.js/v6.0.0/big.mjs'; 68 | import Big from 'https://unpkg.com/big.js@6.0.0/big.mjs'; 69 | ``` 70 | 71 | ## Use 72 | 73 | *In the code examples below, semicolons and `toString` calls are not shown.* 74 | 75 | The library exports a single constructor function, `Big`. 76 | 77 | A Big number is created from a primitive number, string, or other Big number. 78 | 79 | ```javascript 80 | x = new Big(123.4567) 81 | y = Big('123456.7e-3') // 'new' is optional 82 | z = new Big(x) 83 | x.eq(y) && x.eq(z) && y.eq(z) // true 84 | ``` 85 | 86 | In Big strict mode, creating a Big number from a primitive number is disallowed. 87 | 88 | ```javascript 89 | Big.strict = true 90 | x = new Big(1) // TypeError: [big.js] Invalid number 91 | y = new Big('1.0000000000000001') 92 | y.toNumber() // Error: [big.js] Imprecise conversion 93 | ``` 94 | 95 | A Big number is immutable in the sense that it is not changed by its methods. 96 | 97 | ```javascript 98 | 0.3 - 0.1 // 0.19999999999999998 99 | x = new Big(0.3) 100 | x.minus(0.1) // "0.2" 101 | x // "0.3" 102 | ``` 103 | 104 | The methods that return a Big number can be chained. 105 | 106 | ```javascript 107 | x.div(y).plus(z).times(9).minus('1.234567801234567e+8').plus(976.54321).div('2598.11772') 108 | x.sqrt().div(y).pow(3).gt(y.mod(z)) // true 109 | ``` 110 | 111 | Like JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods. 112 | 113 | ```javascript 114 | x = new Big(255.5) 115 | x.toExponential(5) // "2.55500e+2" 116 | x.toFixed(5) // "255.50000" 117 | x.toPrecision(5) // "255.50" 118 | ``` 119 | 120 | The arithmetic methods always return the exact result except `div`, `sqrt` and `pow` 121 | (with negative exponent), as these methods involve division. 122 | 123 | The maximum number of decimal places and the rounding mode used to round the results of these methods is determined by the value of the `DP` and `RM` properties of the `Big` number constructor. 124 | 125 | ```javascript 126 | Big.DP = 10 127 | Big.RM = Big.roundHalfUp 128 | 129 | x = new Big(2); 130 | y = new Big(3); 131 | z = x.div(y) // "0.6666666667" 132 | z.sqrt() // "0.8164965809" 133 | z.pow(-3) // "3.3749999995" 134 | z.times(z) // "0.44444444448888888889" 135 | z.times(z).round(10) // "0.4444444445" 136 | ``` 137 | 138 | The value of a Big number is stored in a decimal floating point format in terms of a coefficient, exponent and sign. 139 | 140 | ```javascript 141 | x = new Big(-123.456); 142 | x.c // [1,2,3,4,5,6] coefficient (i.e. significand) 143 | x.e // 2 exponent 144 | x.s // -1 sign 145 | ``` 146 | 147 | For advanced usage, multiple Big number constructors can be created, each with an independent configuration. 148 | 149 | For further information see the [API](http://mikemcl.github.io/big.js/) reference documentation. 150 | 151 | ## Minify 152 | 153 | To minify using, for example, npm and [terser](https://github.com/terser/terser) 154 | 155 | ```bash 156 | $ npm install -g terser 157 | ``` 158 | 159 | ```bash 160 | $ terser big.js -c -m -o big.min.js 161 | ``` 162 | 163 | ## Test 164 | 165 | The *test* directory contains the test scripts for each Big number method. 166 | 167 | The tests can be run with Node.js or a browser. 168 | 169 | Run all the tests: 170 | 171 | ```bash 172 | $ npm test 173 | ``` 174 | 175 | Test a single method: 176 | 177 | ```bash 178 | $ node test/toFixed 179 | ``` 180 | 181 | For the browser, see *runner.html* and *test.html* in the *test/browser* directory. 182 | 183 | *big-vs-number.html* is a old application that enables some of the methods of big.js to be compared with those of JavaScript's Number type. 184 | 185 | ## TypeScript 186 | 187 | The [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped) project has a Typescript type definitions file for big.js. 188 | 189 | ```bash 190 | $ npm install --save-dev @types/big.js 191 | ``` 192 | 193 | Any questions about the TypeScript type definitions file should be addressed to the DefinitelyTyped project. 194 | 195 | ## Licence 196 | 197 | [MIT](LICENCE.md) 198 | 199 | ## Contributors 200 | 201 | 202 | 203 | ## Financial supporters 204 | 205 | Thank you to all who have supported this project via [Open Collective](https://opencollective.com/bigjs), particularly [Coinbase](https://www.coinbase.com/). 206 | 207 | 208 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/big.js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "big.js", 3 | "description": "A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic", 4 | "version": "6.1.1", 5 | "keywords": [ 6 | "arbitrary", 7 | "precision", 8 | "arithmetic", 9 | "big", 10 | "number", 11 | "decimal", 12 | "float", 13 | "biginteger", 14 | "bigdecimal", 15 | "bignumber", 16 | "bigint", 17 | "bignum" 18 | ], 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/MikeMcl/big.js.git" 22 | }, 23 | "main": "big", 24 | "browser": "big.js", 25 | "module": "big.mjs", 26 | "author": { 27 | "name": "Michael Mclaughlin", 28 | "email": "M8ch88l@gmail.com" 29 | }, 30 | "bugs": { 31 | "url": "https://github.com/MikeMcl/big.js/issues" 32 | }, 33 | "engines": { 34 | "node": "*" 35 | }, 36 | "license": "MIT", 37 | "scripts": { 38 | "test": "node ./test/runner.js" 39 | }, 40 | "files": [ 41 | "big.js", 42 | "big.mjs" 43 | ], 44 | "funding": { 45 | "type": "opencollective", 46 | "url": "https://opencollective.com/bigjs" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/follow-redirects/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014–present Olivier Lalonde , James Talmage , Ruben Verborgh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 18 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/follow-redirects/README.md: -------------------------------------------------------------------------------- 1 | ## Follow Redirects 2 | 3 | Drop-in replacement for Node's `http` and `https` modules that automatically follows redirects. 4 | 5 | [![npm version](https://img.shields.io/npm/v/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects) 6 | [![Build Status](https://github.com/follow-redirects/follow-redirects/workflows/CI/badge.svg)](https://github.com/follow-redirects/follow-redirects/actions) 7 | [![Coverage Status](https://coveralls.io/repos/follow-redirects/follow-redirects/badge.svg?branch=master)](https://coveralls.io/r/follow-redirects/follow-redirects?branch=master) 8 | [![npm downloads](https://img.shields.io/npm/dm/follow-redirects.svg)](https://www.npmjs.com/package/follow-redirects) 9 | [![Sponsor on GitHub](https://img.shields.io/static/v1?label=Sponsor&message=%F0%9F%92%96&logo=GitHub)](https://github.com/sponsors/RubenVerborgh) 10 | 11 | `follow-redirects` provides [request](https://nodejs.org/api/http.html#http_http_request_options_callback) and [get](https://nodejs.org/api/http.html#http_http_get_options_callback) 12 | methods that behave identically to those found on the native [http](https://nodejs.org/api/http.html#http_http_request_options_callback) and [https](https://nodejs.org/api/https.html#https_https_request_options_callback) 13 | modules, with the exception that they will seamlessly follow redirects. 14 | 15 | ```javascript 16 | const { http, https } = require('follow-redirects'); 17 | 18 | http.get('http://bit.ly/900913', response => { 19 | response.on('data', chunk => { 20 | console.log(chunk); 21 | }); 22 | }).on('error', err => { 23 | console.error(err); 24 | }); 25 | ``` 26 | 27 | You can inspect the final redirected URL through the `responseUrl` property on the `response`. 28 | If no redirection happened, `responseUrl` is the original request URL. 29 | 30 | ```javascript 31 | const request = https.request({ 32 | host: 'bitly.com', 33 | path: '/UHfDGO', 34 | }, response => { 35 | console.log(response.responseUrl); 36 | // 'http://duckduckgo.com/robots.txt' 37 | }); 38 | request.end(); 39 | ``` 40 | 41 | ## Options 42 | ### Global options 43 | Global options are set directly on the `follow-redirects` module: 44 | 45 | ```javascript 46 | const followRedirects = require('follow-redirects'); 47 | followRedirects.maxRedirects = 10; 48 | followRedirects.maxBodyLength = 20 * 1024 * 1024; // 20 MB 49 | ``` 50 | 51 | The following global options are supported: 52 | 53 | - `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted. 54 | 55 | - `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted. 56 | 57 | ### Per-request options 58 | Per-request options are set by passing an `options` object: 59 | 60 | ```javascript 61 | const url = require('url'); 62 | const { http, https } = require('follow-redirects'); 63 | 64 | const options = url.parse('http://bit.ly/900913'); 65 | options.maxRedirects = 10; 66 | options.beforeRedirect = (options, { headers }) => { 67 | // Use this to adjust the request options upon redirecting, 68 | // to inspect the latest response headers, 69 | // or to cancel the request by throwing an error 70 | if (options.hostname === "example.com") { 71 | options.auth = "user:password"; 72 | } 73 | }; 74 | http.request(options); 75 | ``` 76 | 77 | In addition to the [standard HTTP](https://nodejs.org/api/http.html#http_http_request_options_callback) and [HTTPS options](https://nodejs.org/api/https.html#https_https_request_options_callback), 78 | the following per-request options are supported: 79 | - `followRedirects` (default: `true`) – whether redirects should be followed. 80 | 81 | - `maxRedirects` (default: `21`) – sets the maximum number of allowed redirects; if exceeded, an error will be emitted. 82 | 83 | - `maxBodyLength` (default: 10MB) – sets the maximum size of the request body; if exceeded, an error will be emitted. 84 | 85 | - `beforeRedirect` (default: `undefined`) – optionally change the request `options` on redirects, or abort the request by throwing an error. 86 | 87 | - `agents` (default: `undefined`) – sets the `agent` option per protocol, since HTTP and HTTPS use different agents. Example value: `{ http: new http.Agent(), https: new https.Agent() }` 88 | 89 | - `trackRedirects` (default: `false`) – whether to store the redirected response details into the `redirects` array on the response object. 90 | 91 | 92 | ### Advanced usage 93 | By default, `follow-redirects` will use the Node.js default implementations 94 | of [`http`](https://nodejs.org/api/http.html) 95 | and [`https`](https://nodejs.org/api/https.html). 96 | To enable features such as caching and/or intermediate request tracking, 97 | you might instead want to wrap `follow-redirects` around custom protocol implementations: 98 | 99 | ```javascript 100 | const { http, https } = require('follow-redirects').wrap({ 101 | http: require('your-custom-http'), 102 | https: require('your-custom-https'), 103 | }); 104 | ``` 105 | 106 | Such custom protocols only need an implementation of the `request` method. 107 | 108 | ## Browser Usage 109 | 110 | Due to the way the browser works, 111 | the `http` and `https` browser equivalents perform redirects by default. 112 | 113 | By requiring `follow-redirects` this way: 114 | ```javascript 115 | const http = require('follow-redirects/http'); 116 | const https = require('follow-redirects/https'); 117 | ``` 118 | you can easily tell webpack and friends to replace 119 | `follow-redirect` by the built-in versions: 120 | 121 | ```json 122 | { 123 | "follow-redirects/http" : "http", 124 | "follow-redirects/https" : "https" 125 | } 126 | ``` 127 | 128 | ## Contributing 129 | 130 | Pull Requests are always welcome. Please [file an issue](https://github.com/follow-redirects/follow-redirects/issues) 131 | detailing your proposal before you invest your valuable time. Additional features and bug fixes should be accompanied 132 | by tests. You can run the test suite locally with a simple `npm test` command. 133 | 134 | ## Debug Logging 135 | 136 | `follow-redirects` uses the excellent [debug](https://www.npmjs.com/package/debug) for logging. To turn on logging 137 | set the environment variable `DEBUG=follow-redirects` for debug output from just this module. When running the test 138 | suite it is sometimes advantageous to set `DEBUG=*` to see output from the express server as well. 139 | 140 | ## Authors 141 | 142 | - [Ruben Verborgh](https://ruben.verborgh.org/) 143 | - [Olivier Lalonde](mailto:olalonde@gmail.com) 144 | - [James Talmage](mailto:james@talmage.io) 145 | 146 | ## License 147 | 148 | [MIT License](https://github.com/follow-redirects/follow-redirects/blob/master/LICENSE) 149 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/follow-redirects/debug.js: -------------------------------------------------------------------------------- 1 | var debug; 2 | 3 | module.exports = function () { 4 | if (!debug) { 5 | try { 6 | /* eslint global-require: off */ 7 | debug = require("debug")("follow-redirects"); 8 | } 9 | catch (error) { /* */ } 10 | if (typeof debug !== "function") { 11 | debug = function () { /* */ }; 12 | } 13 | } 14 | debug.apply(null, arguments); 15 | }; 16 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/follow-redirects/http.js: -------------------------------------------------------------------------------- 1 | module.exports = require("./").http; 2 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/follow-redirects/https.js: -------------------------------------------------------------------------------- 1 | module.exports = require("./").https; 2 | -------------------------------------------------------------------------------- /src/web3context-sdk/node_modules/follow-redirects/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "follow-redirects", 3 | "version": "1.14.4", 4 | "description": "HTTP and HTTPS modules that follow redirects.", 5 | "license": "MIT", 6 | "main": "index.js", 7 | "files": [ 8 | "*.js" 9 | ], 10 | "engines": { 11 | "node": ">=4.0" 12 | }, 13 | "scripts": { 14 | "test": "npm run lint && npm run mocha", 15 | "lint": "eslint *.js test", 16 | "mocha": "nyc mocha" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git@github.com:follow-redirects/follow-redirects.git" 21 | }, 22 | "homepage": "https://github.com/follow-redirects/follow-redirects", 23 | "bugs": { 24 | "url": "https://github.com/follow-redirects/follow-redirects/issues" 25 | }, 26 | "keywords": [ 27 | "http", 28 | "https", 29 | "url", 30 | "redirect", 31 | "client", 32 | "location", 33 | "utility" 34 | ], 35 | "author": "Ruben Verborgh (https://ruben.verborgh.org/)", 36 | "contributors": [ 37 | "Olivier Lalonde (http://www.syskall.com)", 38 | "James Talmage " 39 | ], 40 | "funding": [ 41 | { 42 | "type": "individual", 43 | "url": "https://github.com/sponsors/RubenVerborgh" 44 | } 45 | ], 46 | "peerDependenciesMeta": { 47 | "debug": { 48 | "optional": true 49 | } 50 | }, 51 | "devDependencies": { 52 | "concat-stream": "^2.0.0", 53 | "eslint": "^5.16.0", 54 | "express": "^4.16.4", 55 | "lolex": "^3.1.0", 56 | "mocha": "^6.0.2", 57 | "nyc": "^14.1.1" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/web3context-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "web3context-sdk", 3 | "version": "0.1.0", 4 | "description": "General Web3 Context SDK", 5 | "main": "index.ts", 6 | "author": "Andreas Bigger ", 7 | "license": "AGPL-3.0-only", 8 | "dependencies": { 9 | "axios": "^0.21.1", 10 | "big.js": "^6.0.3" 11 | }, 12 | "peerDependencies": { 13 | "web3": "^1.2.11" 14 | }, 15 | "react-native": { 16 | "zlib": "browserify-zlib", 17 | "console": "console-browserify", 18 | "constants": "constants-browserify", 19 | "crypto": "react-native-crypto", 20 | "dns": "dns.js", 21 | "net": "react-native-tcp", 22 | "domain": "domain-browser", 23 | "http": "@tradle/react-native-http", 24 | "https": "https-browserify", 25 | "os": "react-native-os", 26 | "path": "path-browserify", 27 | "querystring": "querystring-es3", 28 | "fs": "react-native-level-fs", 29 | "_stream_transform": "readable-stream/transform", 30 | "_stream_readable": "readable-stream/readable", 31 | "_stream_writable": "readable-stream/writable", 32 | "_stream_duplex": "readable-stream/duplex", 33 | "_stream_passthrough": "readable-stream/passthrough", 34 | "dgram": "react-native-udp", 35 | "stream": "stream-browserify", 36 | "timers": "timers-browserify", 37 | "tty": "tty-browserify", 38 | "vm": "vm-browserify", 39 | "tls": false 40 | }, 41 | "browser": { 42 | "zlib": "browserify-zlib", 43 | "console": "console-browserify", 44 | "constants": "constants-browserify", 45 | "crypto": "react-native-crypto", 46 | "dns": "dns.js", 47 | "net": "react-native-tcp", 48 | "domain": "domain-browser", 49 | "http": "@tradle/react-native-http", 50 | "https": "https-browserify", 51 | "os": "react-native-os", 52 | "path": "path-browserify", 53 | "querystring": "querystring-es3", 54 | "fs": "react-native-level-fs", 55 | "_stream_transform": "readable-stream/transform", 56 | "_stream_readable": "readable-stream/readable", 57 | "_stream_writable": "readable-stream/writable", 58 | "_stream_duplex": "readable-stream/duplex", 59 | "_stream_passthrough": "readable-stream/passthrough", 60 | "dgram": "react-native-udp", 61 | "stream": "stream-browserify", 62 | "timers": "timers-browserify", 63 | "tty": "tty-browserify", 64 | "vm": "vm-browserify", 65 | "tls": false 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/web3context-sdk/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | axios@^0.21.1: 6 | version "0.21.4" 7 | resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" 8 | integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== 9 | dependencies: 10 | follow-redirects "^1.14.0" 11 | 12 | big.js@^6.0.3: 13 | version "6.1.1" 14 | resolved "https://registry.yarnpkg.com/big.js/-/big.js-6.1.1.tgz#63b35b19dc9775c94991ee5db7694880655d5537" 15 | integrity sha512-1vObw81a8ylZO5ePrtMay0n018TcftpTA5HFKDaSuiUDBo8biRBtjIobw60OpwuvrGk+FsxKamqN4cnmj/eXdg== 16 | 17 | follow-redirects@^1.14.0: 18 | version "1.14.4" 19 | resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" 20 | integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g== 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "strict": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "noEmit": true, 14 | "esModuleInterop": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "jsx": "preserve", 20 | "baseUrl": ".", 21 | "paths": { 22 | "@components/*": [ 23 | "components/*" 24 | ], 25 | "@utils/*": [ 26 | "utils/*" 27 | ] 28 | } 29 | }, 30 | "include": [ 31 | "next-env.d.ts", 32 | "**/*.ts", 33 | "**/*.tsx" 34 | ], 35 | "exclude": [ 36 | "node_modules" 37 | ] 38 | } --------------------------------------------------------------------------------