Skip to content

Commit

Permalink
feat: UI to mint tickets (#18)
Browse files Browse the repository at this point in the history
* chore: run `yarn create vite` to initialize the UI

* chore: add relevant dependencies and run `yarn install`

* feat: add SES lockdown

* feat: add relevant types, hooks, and store

* feat: add contract provider

* feat: add component for Mint and Inventory

* feat: organize all components in App

* fix: replace occurrences of items with tickets in interchain-ui code

* chore: add a yarn script for starting interchain-ui

* fix: use correct contract name to find the contract instance

* chore: install Tailwind CSS

* chore: configure template paths for Tailwind CSS

* fix: let vite know about the type definition for stringifyAmountValue

* chore: remove all existing css and add Tailwind directives

* ui: use tailwind to arrange the flex box for the app

* ui: remove old css classes and use tailwind to do styling instead

* ui: make the vertical divider show up

* chore: upgrade ses to 1.3.0

* feat: wire up Mint component to send actual offers to contract

* fix: update Inventory component to use the correct purse

* feat: add proper images for different kind of seats

* ui: remove some redundant styling

* ui: add a connect wallet button at top right corner

* ui: add app name on top left

* ui: update index.html with proper favicon and title

* chore: install daisyui

* chore: update tailwind config to use daisyui

* ui: use daisyui to style buttons

* ui: use daisyui to style the inventory card

* ui: style a navbar with daisyui

* ui: use daisyui-divider-horizontal

* ui: add agoric logo on the navbar

* ui: add a daisyui tab without hooking it up to contents below

* chore: add react-daisyui

* chore: configure daisyui-react

* ui: start styling a mint card through daisyui

Instead of using interchain-ui

* ui: styling the mint card

* chore: remove unused import

* chore: remove @interchain-ui/react as this package is no longer in use

* ui: add styling so items are aligned on vertical center

* ui: use self-center to align items individually

* ui: get radio tabs working

* ui: flex card action vertically instead

* ui: DRY out tab wrapper into TabWrapper component

And implement activate tab on click logic

* refactor: re-organize all components into a better hierarchy

* chore: remove redundant div

* chore: run `yarn add '@agoric/react-components'`

* chore: fix small formatting issue

* ui: implement notifications as toasts

* chore: bump web-components to 0.15.1-dev-09ca26c.0

* chore: remove unused declares in vite-env.d.ts

* chore: update code to use stringifyAmountValue from @agoric/web-components

* chore: update @agoric/react-components to the latest version

* chore: remove debugging logging statement

* chore: update @agoric/react-component to latest

* ui: add network dropdown component

* chore: remove mainnet from network configs

* chore: replace ui folder with interchain-ui folder

* chore: update package.json and ui/package.json

* chore: add a test script for ui workspace

* chore: add and update some yarn scripts

* chore: run `yarn install`

* chore: remove `print-key` yarn script

* chore: remove `print-key` make target

* chore: remove invoking print-key in start

* chore: add .node-version and .nvmrc file
  • Loading branch information
LuqiPan authored Apr 22, 2024
1 parent 5d800a0 commit f48420e
Show file tree
Hide file tree
Showing 49 changed files with 15,518 additions and 2,177 deletions.
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.18.0
1 change: 1 addition & 0 deletions .nvmrc
8 changes: 0 additions & 8 deletions contract/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ vote:
instance-q:
agd query vstorage data published.agoricNames.instance -o json

print-key: /root/.agoric/user1.key
@echo Import the following mnemonic into Keplr:
@cat $<
@echo
@echo -n 'The resulting address should be: '
@agd keys show user1 -a --keyring-backend="test"
@echo

start-contract: start-contract-mint start-contract-swap start-contract-pay

start-contract-mint:
Expand Down
2 changes: 1 addition & 1 deletion contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"docker:bash": "docker compose exec agd bash",
"docker:make": "docker compose exec agd make -C /workspace/contract",
"make:help": "make list",
"start": "make clean start-contract; yarn docker:make print-key",
"start": "make clean start-contract",
"build": "yarn build:deployer",
"build:deployer": "rollup -c rollup.config.mjs",
"test": "ava --verbose",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
"scripts": {
"postinstall": "patch-package",
"start:docker": "cd contract && docker compose up -d",
"stop:docker": "cd contract && docker compose down",
"docker:logs": "cd contract; docker compose logs --tail 200 -f",
"docker:bash": "cd contract; docker compose exec agd bash",
"docker:make": "cd contract; docker compose exec agd make -C /workspace/contract",
"make:help": "make -C contract list",
"start:contract": "cd contract && yarn start",
"print-key": "yarn docker:make print-acct",
"start:ui": "cd ui && yarn dev",
"lint": "yarn workspaces run lint",
"lint:fix": "yarn workspaces run lint:fix",
"test": "yarn workspaces run test",
"test:e2e": "yarn workspace agoric-basics-ui test:e2e",
"build": "yarn workspaces run build"
Expand Down
6 changes: 2 additions & 4 deletions ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:prettier/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh', 'prettier'],
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'prettier/prettier': 'error',
},
};
}
24 changes: 24 additions & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
30 changes: 30 additions & 0 deletions ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default {
// other rules...
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
2 changes: 1 addition & 1 deletion ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/agoric.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Agoric Basics</title>
<title>dApp Agoric Basics</title>
</head>
<body>
<div id="root"></div>
Expand Down
65 changes: 32 additions & 33 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,49 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"test": "vitest spec",
"test:e2e": "vitest e2e",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "yarn lint --fix",
"preview": "vite preview"
"preview": "vite preview",
"test": "exit 0",
"test:e2e": "exit 0"
},
"dependencies": {
"@agoric/react-components": "0.1.1-dev-8fc28e8.0",
"@agoric/ui-components": "^0.3.9-u13.0",
"@agoric/web-components": "0.15.1-dev-8fc28e8.0",
"buffer": "^6.0.3",
"chain-registry": "^1.28.1",
"cosmos-kit": "^2.9.0",
"daisyui": "^4.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-daisyui": "^5.0.0",
"react-dom": "^18.2.0",
"ses": "^1.2.0"
},
"devDependencies": {
"@agoric/eventual-send": "^0.14.1",
"@agoric/notifier": "^0.6.2",
"@agoric/rpc": "0.9.1-dev-f471a83.0",
"@agoric/store": "^0.9.2",
"@agoric/ui-components": "^0.9.0",
"@agoric/web-components": "^0.15.0",
"@testing-library/react": "^14.1.2",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.17",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"happy-dom": "^13.3.1",
"prettier": "^3.2.4",
"puppeteer": "^21.9.0",
"ses": "^1.3.0",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vitest": "^1.2.1",
"zustand": "^4.4.1"
},
"resolutions": {
"**/ses": "^1.3.0",
"**/@agoric/xsnap": "0.14.3-dev-9f085d3.0"
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.35",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.1.4"
},
"prettier": {
"trailingComma": "all",
"arrowParens": "avoid",
"singleQuote": true
"singleQuote": true,
"tabWidth": 2,
"plugins": [
"prettier-plugin-tailwindcss"
]
}
}
6 changes: 6 additions & 0 deletions ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 0 additions & 1 deletion ui/public/vite.svg

This file was deleted.

109 changes: 0 additions & 109 deletions ui/src/App.css

This file was deleted.

25 changes: 0 additions & 25 deletions ui/src/App.spec.tsx

This file was deleted.

Loading

0 comments on commit f48420e

Please sign in to comment.