Skip to content

Commit

Permalink
wallet-ui: init project
Browse files Browse the repository at this point in the history
* app shows an `under construction` message (in popup and new tab)
* after installing the extension, a new tab will open with the app
* build tools: webpack, typescript, eslint, stylelint & prettier
* the ui part is a react app
  • Loading branch information
pchrysochoidis committed May 9, 2022
1 parent 755dcff commit 65716da
Show file tree
Hide file tree
Showing 37 changed files with 16,757 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/actions/diffs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
with:
filters: |
isRust:
- '!(explorer|doc|.github|sdk)/**'
- '!(explorer|doc|.github|sdk|wallet)/**'
- '.github/workflows/bench.yml'
- '.github/workflows/codecov.yml'
- '.github/workflows/rust.yml'
Expand Down
1 change: 1 addition & 0 deletions wallet/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chrome >= 88
2 changes: 2 additions & 0 deletions wallet/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
47 changes: 47 additions & 0 deletions wallet/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'react-app',
'react-app/jest',
'prettier',
],
rules: {
'react/jsx-no-bind': ['error'],
'import/order': [
'warn',
{
groups: [
['builtin', 'external'],
['internal', 'parent', 'sibling', 'index'],
'type',
],
pathGroups: [
{
pattern: '{.,..}/**/*.?(s)css',
group: 'type',
position: 'after',
},
],
'newlines-between': 'always',
alphabetize: { order: 'asc' },
warnOnUnassignedImports: true,
},
],
'import/no-duplicates': ['error'],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: true,
},
],
'no-console': ['warn'],
},
};
4 changes: 4 additions & 0 deletions wallet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.log
.DS_Store
node_modules
dist
5 changes: 5 additions & 0 deletions wallet/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/
package-lock.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
4 changes: 4 additions & 0 deletions wallet/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"tabWidth": 4
}
2 changes: 2 additions & 0 deletions wallet/.stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
6 changes: 6 additions & 0 deletions wallet/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"stylelint-config-standard-scss",
"stylelint-config-prettier-scss"
]
}
45 changes: 45 additions & 0 deletions wallet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Sui Wallet

A chrome (v88+) extension wallet for [Sui](https://sui.io).

# Set up

**Requirements**: Node 14.0.0 or later.

Run `npm i` first to install the required `node modules`

Then one of the following build steps is required:

## Build in watch mode (dev)

To build the extension and watch for changes run

```
npm start
```

This will build the app in the [dist/](./dist/) directory, watch for changes and rebuild it. (Also runs prettier to format the files that changed.)

## Build once in dev mode

To build the app once in development mode (no optimizations etc) run

```
npm run build:dev
```

The output directory is the same [dist/](./dist/), all build artifacts will go there

## Build once in prod mode

To build the app once in production mode run

```
npm run build:prod
```

Same as above the output is [dist/](./dist/).

## Install the extension to Chrome

After building the app, the extension needs to be installed to Chrome. Follow the steps [here](https://developer.chrome.com/docs/extensions/mv3/getstarted/#unpacked) and install the app from the [dist/](./dist/) directory.
20 changes: 20 additions & 0 deletions wallet/configs/ts/tsconfig.common.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es6",
"module": "esnext",
"allowJs": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"noEmit": false,
"isolatedModules": true,
"outDir": "../../dist"
},
"include": ["../../src"],
"exclude": ["../../build", "../../node_modules"]
}
6 changes: 6 additions & 0 deletions wallet/configs/ts/tsconfig.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.common",
"compilerOptions": {
"jsx": "react-jsxdev"
}
}
6 changes: 6 additions & 0 deletions wallet/configs/ts/tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.common",
"compilerOptions": {
"jsx": "react-jsx"
}
}
8 changes: 8 additions & 0 deletions wallet/configs/ts/tsconfig.webpack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.common",
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"esModuleInterop": true
}
}
97 changes: 97 additions & 0 deletions wallet/configs/webpack/webpack.config.common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import CopyPlugin from 'copy-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import { resolve } from 'path';

import packageJson from '../../package.json';

import type { Configuration } from 'webpack';

const APP_NAME = 'Sui Wallet';
const PROJECT_ROOT = resolve(__dirname, '..', '..');
const CONFIGS_ROOT = resolve(PROJECT_ROOT, 'configs');
const SRC_ROOT = resolve(PROJECT_ROOT, 'src');
const OUTPUT_ROOT = resolve(PROJECT_ROOT, 'dist');

const tsConfigFilename = `tsconfig.${
process.env.NODE_ENV === 'development' ? 'dev' : 'prod'
}.json`;

const commonConfig: Configuration = {
context: SRC_ROOT,
entry: {
background: './background',
ui: './ui',
},
output: {
path: OUTPUT_ROOT,
clean: true,
},
stats: {
preset: 'summary',
timings: true,
errors: true,
},
resolve: {
extensions: ['.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.(t|j)sx?$/,
loader: 'ts-loader',
options: {
configFile: resolve(CONFIGS_ROOT, 'ts', tsConfigFilename),
},
},
{
test: /\.(s)?css$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'sass-loader',
],
},
{
test: /\.(png|jpg|jpeg|gif)$/,
type: 'asset/resource',
},
],
},
plugins: [
new MiniCssExtractPlugin(),
new HtmlWebpackPlugin({
chunks: ['ui'],
filename: 'ui.html',
template: resolve(SRC_ROOT, 'ui', 'index.template.html'),
title: APP_NAME,
}),
new CopyPlugin({
patterns: [
{
from: resolve(SRC_ROOT, 'manifest', 'icons', '**', '*'),
},
{
from: resolve(SRC_ROOT, 'manifest', 'manifest.json'),
to: resolve(OUTPUT_ROOT, '[name][ext]'),
transform: (content) => {
const { description, version } = packageJson;
const manifestJson = {
...JSON.parse(content.toString()),
name: APP_NAME,
description,
version,
};
return JSON.stringify(manifestJson, null, 4);
},
},
],
}),
],
};

export default commonConfig;
21 changes: 21 additions & 0 deletions wallet/configs/webpack/webpack.config.dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import ESLintPlugin from 'eslint-webpack-plugin';
import StyleLintPlugin from 'stylelint-webpack-plugin';
import { merge } from 'webpack-merge';

import configCommon from './webpack.config.common';

import type { Configuration } from 'webpack';

const configDev: Configuration = {
mode: 'development',
devtool: 'cheap-source-map',
plugins: [new ESLintPlugin(), new StyleLintPlugin()],
watchOptions: {
aggregateTimeout: 600,
},
};

export default merge(configCommon, configDev);
14 changes: 14 additions & 0 deletions wallet/configs/webpack/webpack.config.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { merge } from 'webpack-merge';

import configCommon from './webpack.config.common';

import type { Configuration } from 'webpack';

const configProd: Configuration = {
mode: 'production',
};

export default merge(configCommon, configProd);
Loading

0 comments on commit 65716da

Please sign in to comment.