-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ec47566
Showing
35 changed files
with
18,109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"presets": ["next/babel"], | ||
"plugins": [ | ||
[ | ||
"styled-components", | ||
{ | ||
"ssr": true | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.next | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module.exports = { | ||
extends: ['plugin:prettier/recommended', 'next/core-web-vitals', 'prettier'], | ||
plugins: ['prettier'], | ||
parser: '@typescript-eslint/parser', | ||
rules: { | ||
'prettier/prettier': 'error', | ||
'react/react-in-jsx-scope': 0, | ||
'react/display-name': 0, | ||
'no-confusing-arrow': 0, | ||
'arrow-parens': 0, | ||
'implicit-arrow-linebreak': 0, | ||
'no-unused-vars': 1, | ||
'react/jsx-props-no-spreading': 0, | ||
'no-shadow': 1, | ||
'react/destructuring-assignment': 0, | ||
'react/require-default-props': 0, | ||
'import/prefer-default-export': 0, | ||
'consistent-return': 0, | ||
semi: 0, | ||
'react/forbid-prop-types': 0, | ||
'react-hooks/rules-of-hooks': 'error', | ||
'react-hooks/exhaustive-deps': 'warn', | ||
'jsx-a11y/anchor-is-valid': 0, | ||
'no-shadow': 0, | ||
camelcase: 0, | ||
'import/no-named-as-default': 0, | ||
'import/no-anonymous-default-export': 0, | ||
'no-unused-vars': [ | ||
'error', | ||
{ | ||
argsIgnorePattern: '^_' | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Basic dependabot.yml file with | ||
# minimum configuration for two package managers | ||
|
||
version: 2 | ||
updates: | ||
# Enable version updates for npm | ||
- package-ecosystem: "npm" | ||
# Look for `package.json` and `lock` files in the `root` directory | ||
directory: "/" | ||
# Check the npm registry for updates every day (weekdays) | ||
schedule: | ||
interval: "daily" | ||
# Enable updates to github actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: tests | ||
|
||
on: [pull_request, push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
node: [14] | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/[email protected] | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm i | ||
- run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env* | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
deploy_key | ||
|
||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"bracketSpacing": true, | ||
"semi": false, | ||
"jsxSingleQuote": true, | ||
"singleQuote": true, | ||
"trailingComma": "none", | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export default { | ||
'@context': 'http://schema.org/', | ||
'@type': 'WebApplication', | ||
name: 'Glif Explorer', | ||
description: 'A Filecoin analytics UI.', | ||
url: 'https://beta.explorer.glif.io', | ||
knowsAbout: [ | ||
{ | ||
'@type': 'SoftwareApplication', | ||
name: 'Filecoin', | ||
url: 'https://filecoin.io', | ||
applicationCategory: 'Blockchain network', | ||
operatingSystem: 'All' | ||
} | ||
], | ||
parentOrganization: { | ||
'@type': 'Organization', | ||
name: 'Glif', | ||
description: '.', | ||
url: 'https://apps.glif.io' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Glif Explorer | ||
|
||
<!-- Glif art/branding --> | ||
|
||
|
||
The Glif Explorer is a Filecoin analytics UI built with Next.js | ||
|
||
### A huge thank you to the [Lily](https://lilium.sh/lily/) team from Protocol Labs for building our high confidence dataset. | ||
|
||
#### Filecoin module package local development | ||
|
||
In order to develop packages locally and see the changes live in this local wallet repository, the [npm link](https://docs.npmjs.com/cli/v7/commands/npm-link) tool can be used to symlink to the packages in your local modules repo. | ||
|
||
Package linking is a two-step process. | ||
|
||
First, from your local package folder, run: | ||
``` | ||
npm link | ||
``` | ||
|
||
Next, from this main wallet repository, run: | ||
``` | ||
npm link @glif/<package-name> | ||
``` | ||
for example, use `npm link @glif/react-components` to symlink the `react-components` package to your local version. See the npm link docs for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { ApolloClient, InMemoryCache, HttpLink, split } from '@apollo/client' | ||
import { getMainDefinition } from '@apollo/client/utilities' | ||
import { WebSocketLink } from '@apollo/client/link/ws' | ||
import { defaultMessageHistoryClientCacheConfig } from '@glif/react-components' | ||
|
||
const URI = process.env.NEXT_PUBLIC_GRAPH_API_URL | ||
|
||
const httpLink = new HttpLink({ | ||
uri: `https://${URI}` | ||
}) | ||
|
||
const wsLink = process.browser | ||
? new WebSocketLink({ | ||
uri: `wss://${URI}`, | ||
options: { | ||
reconnect: true, | ||
lazy: true | ||
} | ||
}) | ||
: null | ||
|
||
export function createApolloClient() { | ||
// The split function takes three parameters: | ||
// | ||
// * A function that's called for each operation to execute | ||
// * The Link to use for an operation if the function returns a "truthy" value | ||
// * The Link to use for an operation if the function returns a "falsy" value | ||
const link = process.browser //only create the split in the browser | ||
? split( | ||
({ query }) => { | ||
const definition = getMainDefinition(query) | ||
return ( | ||
definition.kind === 'OperationDefinition' && | ||
definition.operation === 'subscription' | ||
) | ||
}, | ||
wsLink, | ||
httpLink | ||
) | ||
: httpLink | ||
|
||
return new ApolloClient({ | ||
link, | ||
cache: new InMemoryCache({ ...defaultMessageHistoryClientCacheConfig }) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* PAGES */ | ||
export enum PAGE { | ||
LANDING = '/' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { shape, string, oneOfType, number, oneOf, object } from 'prop-types' | ||
import { validateAddressString } from '@glif/filecoin-address' | ||
import { validatePath } from '@glif/filecoin-wallet-provider' | ||
import { validateMnemonic } from 'bip39' | ||
import { | ||
SINGLE_KEY, | ||
IMPORT_MNEMONIC, | ||
IMPORT_SINGLE_KEY, | ||
LEDGER | ||
} from './constants' | ||
|
||
export const ADDRESS_PROPTYPE = (props, propName, componentName) => { | ||
if (!validateAddressString(props[propName])) | ||
return new Error( | ||
`Invalid prop: ${propName} supplied to ${componentName}. Validation failed.` | ||
) | ||
|
||
return null | ||
} | ||
|
||
export const MNEMONIC_PROPTYPE = (props, propName, componentName) => { | ||
if (!validateMnemonic(props[propName])) | ||
return new Error( | ||
`Invalid prop: ${propName} supplied to ${componentName}. Validation failed.` | ||
) | ||
|
||
return null | ||
} | ||
|
||
export const FILECOIN_NUMBER_PROP = (props, propName, componentName) => { | ||
// instanceof prop checking is broken in nextjs on server side render cycles | ||
const representsANum = Number.isNaN(Number(props[propName].toString())) | ||
const hasFilecoinNumMethods = !!( | ||
props[propName].toFil && | ||
props[propName].toAttoFil && | ||
props[propName].toPicoFil | ||
) | ||
if (!(representsANum || hasFilecoinNumMethods)) | ||
return new Error( | ||
`Invalid prop: ${propName} supplied to ${componentName}. Validation failed.` | ||
) | ||
|
||
return null | ||
} | ||
|
||
export const HD_PATH_PROP = (props, propName, componentName) => { | ||
if (!validatePath(props[propName]) && props[propName] !== SINGLE_KEY) | ||
return new Error( | ||
`Invalid prop: ${propName} supplied to ${componentName}. Validation failed.` | ||
) | ||
|
||
return null | ||
} | ||
|
||
export const WALLET_PROP_TYPE = shape({ | ||
balance: FILECOIN_NUMBER_PROP, | ||
address: ADDRESS_PROPTYPE, | ||
path: HD_PATH_PROP, | ||
type: oneOf([IMPORT_MNEMONIC, IMPORT_SINGLE_KEY, LEDGER]), | ||
index: number | ||
}) | ||
|
||
export const NO_WALLET_PROP_TYPE = shape({ | ||
balance: FILECOIN_NUMBER_PROP, | ||
address: string, | ||
path: string, | ||
index: number | ||
}) | ||
|
||
export const MESSAGE_PROPS = shape({ | ||
/** | ||
* Message sent to this address | ||
*/ | ||
to: ADDRESS_PROPTYPE, | ||
/** | ||
* Message sent from this address | ||
*/ | ||
from: ADDRESS_PROPTYPE, | ||
/** | ||
* The amount of FIL sent in the message | ||
*/ | ||
value: string.isRequired, | ||
/** | ||
* The message's cid | ||
*/ | ||
cid: string.isRequired, | ||
/** | ||
* Either pending or confirmed | ||
*/ | ||
status: oneOf(['confirmed', 'pending']).isRequired, | ||
timestamp: oneOfType([string, number]).isRequired, | ||
method: string.isRequired, | ||
params: object.isRequired | ||
}) |
Oops, something went wrong.