Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Svelte kit #7

Draft
wants to merge 49 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ceff822
Start with heavy refactor towards Svelte Kit
acuarica Dec 2, 2021
5699b46
Add wallet store to manage MetaMask
acuarica Dec 2, 2021
d351f71
Add MetaMask providers to use its type definition
acuarica Dec 3, 2021
d9d07e5
Enhance vite env typings and docs
acuarica Dec 3, 2021
d03f583
Fix type conversion
acuarica Dec 3, 2021
e2072b5
Export chain id
acuarica Dec 3, 2021
e977bc8
Improve wallet reactivity
acuarica Dec 3, 2021
c88f871
Improve warning look&feel
acuarica Dec 3, 2021
9bdef40
Move inside `pools/` route
acuarica Dec 5, 2021
42461e5
Set up vite mode
acuarica Dec 5, 2021
962a453
Add new info endpoints
acuarica Dec 5, 2021
d93615a
Add new env types
acuarica Dec 5, 2021
257c58e
Add storybook
acuarica Dec 5, 2021
40adce8
Refactor to decouple from store
acuarica Dec 5, 2021
0463352
Add network info component
acuarica Dec 5, 2021
1e56b21
Fix deposit/withdraw routes
acuarica Dec 5, 2021
f3d64e1
Import without $lib
acuarica Dec 5, 2021
4efebce
Import without $lib
acuarica Dec 5, 2021
48a623b
Use RenPool address from env
acuarica Dec 5, 2021
04385a0
Add component stories
acuarica Dec 5, 2021
b32578c
Improve error handling
acuarica Dec 5, 2021
2fd15b4
Add some jsdoc
acuarica Dec 5, 2021
2d90d67
Remove comments
acuarica Dec 5, 2021
12a71dc
Add ren allowance PoC
acuarica Dec 5, 2021
68e2fd3
Remove hardhat
acuarica Dec 6, 2021
34909b1
Decouple components from env
acuarica Dec 7, 2021
fa60d50
Refactor main layout into component
acuarica Dec 7, 2021
6c0bf43
Rename to support jest testing
acuarica Dec 8, 2021
af98ce2
Add jest packages and config
acuarica Dec 8, 2021
3fdcb0e
Allows ide support when import .svelte files
acuarica Dec 8, 2021
ac34993
Add some tests
acuarica Dec 8, 2021
d00f886
Separate constants from config
acuarica Dec 9, 2021
0664fda
Fix config/bond imports
acuarica Dec 9, 2021
4e03eb8
Add address type alias
acuarica Dec 9, 2021
8de489c
Refactor to use types
acuarica Dec 9, 2021
9a06c0f
Use context instead of module variable
acuarica Dec 9, 2021
17a4bab
Showcase multiple Howtos in one page
acuarica Dec 9, 2021
8cb4534
Use context for EtherscanLink
acuarica Dec 9, 2021
70ef0a2
Use prop instead of module variable
acuarica Dec 9, 2021
e106237
Unify contract usage
acuarica Dec 9, 2021
3185cdd
moving h1 and h2 tags to global theme (#10)
fede-rodes Dec 11, 2021
02f1c9f
introducing Chip component (#11)
fede-rodes Dec 13, 2021
7baa4cf
moving Chip to lib folder
fede-rodes Dec 13, 2021
23b5160
Feat/format (#12)
fede-rodes Dec 13, 2021
dc47301
adding missing dep (#13)
fede-rodes Dec 14, 2021
b7c81fb
Feat/format2 (#14)
fede-rodes Dec 15, 2021
a7bcbae
fix import
fede-rodes Dec 23, 2021
56f75f9
update storybook config to only process svelte files
fede-rodes Dec 23, 2021
54bdffb
Feat/comp lib (#15)
fede-rodes Dec 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.kovan-fork
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_CHAIN_ID=42
VITE_JSON_RPC_PROVIDER_URL=http://127.0.0.1:8545
VITE_REN_POOL=0xbF115A5538290D234fA31e917241a58A20a847Bc
3 changes: 3 additions & 0 deletions .env.mainnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_CHAIN_ID=1
VITE_JSON_RPC_PROVIDER_URL=https://eth-mainnet.alchemyapi.io/v2/4qQo8naBUQPUU4UWex6jJupYRxlfIdxl
VITE_REN_POOL=0xf1e98770ab8ed1364371B8c7DBdA56633F7cB6a9
3 changes: 3 additions & 0 deletions .env.mainnet-fork
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_CHAIN_ID=1
VITE_JSON_RPC_PROVIDER_URL=http://localhost:8545
VITE_REN_POOL=0xf1e98770ab8ed1364371B8c7DBdA56633F7cB6a9
4 changes: 2 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
REACT_APP_CHAIN_ID=42
REACT_APP_INFURA_PROJECT_ID=XXX
VITE_CHAIN_ID=
INFURA_PROJECT_ID=
24 changes: 24 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
plugins: ["svelte3", "@typescript-eslint"],
ignorePatterns: ["*.cjs"],
overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }],
settings: {
"svelte3/typescript": () => require("typescript"),
},
parserOptions: {
sourceType: "module",
ecmaVersion: 2019,
},
env: {
browser: true,
es2017: true,
node: true,
},
};
34 changes: 0 additions & 34 deletions .eslintrc.js

This file was deleted.

19 changes: 5 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
/.svelte-kit
/node_modules/

# testing
/coverage
Expand All @@ -12,13 +8,8 @@
/build

# misc
.DS_Store
.env
.env.kovan
.env.dev

npm-debug.log*
yarn-debug.log*
yarn-error.log*
/.env
/.env.kovan
/.env.dev

/.netlify
7 changes: 7 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
arrowParens: "avoid",
tabWidth: 4,
svelteStrictMode: true,
svelteSortOrder: "options-scripts-markup-styles",
plugins: ["prettier-plugin-svelte"],
};
37 changes: 37 additions & 0 deletions .storybook/main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const preprocess = require("svelte-preprocess");

module.exports = {
stories: [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx|svelte)",
],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-svelte-csf",
{
name: "@storybook/addon-postcss",
options: {
cssLoaderOptions: {
// When you have splitted your css over multiple files
// and use @import('./other-styles.css')
importLoaders: 1,
},
postcssLoaderOptions: {
// When using postCSS 8
implementation: require("postcss"),
},
},
},
"@storybook/addon-interactions",
],
framework: "@storybook/svelte",
svelteOptions: {
// "preprocess": config.preprocess,
preprocess: [
preprocess({
postcss: true,
}),
],
},
};
11 changes: 11 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "../src/app.css";

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
# renpool-app

RenPool's client app

## Manually deploy client app

[https://www.freecodecamp.org/news/how-to-deploy-a-react-application-to-netlify-363b8a98a985/](https://www.freecodecamp.org/news/how-to-deploy-a-react-application-to-netlify-363b8a98a985/)

Install Netlify CLI: `npm install netlify-cli -g`.

```bash
>> yarn run setEnv:<TARGET_NETWORK>
>> yarn run deploy
```

The app is deployed to [https://renpool.netlify.app/](https://renpool.netlify.app/)

## Usage

1. Open the Brownie console. Starting the console launches a fresh [Ganache](https://www.trufflesuite.com/ganache) instance in the background.

```bash
$ brownie console
Brownie v1.9.0 - Python development framework for Ethereum

ReactMixProject is the active project.
Launching 'ganache-cli'...
Brownie environment is ready.
```

2. Run the [deployment script](scripts/deploy.py) to deploy the project's smart contracts.

```python
>>> run("deploy")
Running 'scripts.deploy.main'...
Transaction sent: 0xd1000d04fe99a07db864bcd1095ddf5cb279b43be8e159f94dbff9d4e4809c70
Gas price: 0.0 gwei Gas limit: 6721975
SolidityStorage.constructor confirmed - Block: 1 Gas used: 110641 (1.65%)
SolidityStorage deployed at: 0xF104A50668c3b1026E8f9B0d9D404faF8E42e642

Transaction sent: 0xee112392522ed24ac6ab8cc8ba09bfe51c5d699d9d1b39294ba87e5d2a56212c
Gas price: 0.0 gwei Gas limit: 6721975
VyperStorage.constructor confirmed - Block: 2 Gas used: 134750 (2.00%)
VyperStorage deployed at: 0xB8485421abC325D172652123dBd71D58b8117070
```

3. While Brownie is still running, start the React app in a different terminal.

```bash
# make sure to use a different terminal, not the brownie console
cd client
yarn start
```

4. Connect Metamask to the local Ganache network. In the upper right corner, click the network dropdown menu. Select `Localhost 8545`, or:

```bash
New Custom RPC
http://localhost:8545
```

5. Interact with the smart contracts using the web interface or via the Brownie console.

```python
# get the newest vyper storage contract
>>> vyper_storage = VyperStorage[-1]

# the default sender of the transaction is the contract creator
>>> vyper_storage.set(1337)
```

Any changes to the contracts from the console should show on the website after a refresh, and vice versa.

## Ending a Session

When you close the Brownie console, the Ganache instance also terminates and the deployment artifacts are deleted.

To retain your deployment artifacts (and their functionality) you can launch Ganache yourself prior to launching Brownie. Brownie automatically attaches to the ganache instance where you can deploy the contracts. After closing Brownie, the chain and deployment artifacts will persist.
1 change: 0 additions & 1 deletion _redirects

This file was deleted.

35 changes: 14 additions & 21 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
module.exports = {
// The root of your source code, typically /src
// `<rootDir>` is a token Jest substitutes
roots: ['<rootDir>/src'],
// Jest transformations -- this adds support for TypeScript
// using ts-jest
/** @type {import('ts-jest').InitialOptionsTsJest} */
const config = {
transform: {
'^.+\\.tsx?$': 'ts-jest'
'^.+\\.ts$': 'ts-jest',
'^.+\\.svelte$': [
'svelte-jester',
{
preprocess: true,
},
],
},
// Runs special logic, such as cleaning up components
// when using React Testing Library and adds special
// extended assertions to Jest
setupFilesAfterEnv: [
'@testing-library/react/cleanup-after-each',
'@testing-library/jest-dom/extend-expect'
],
// Test spec file resolution pattern
// Look for tests inside the `src` folder and filename
// should contain `test` or `spec`.
testRegex: '(/**/.*|(\\.|/)(test|spec))\\.tsx?$',
// Module file extensions for importing
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
}
moduleFileExtensions: ['js', 'ts', 'svelte'],
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
};

export default config;
Loading