Skip to content

Add Minimal Angular Template #3

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

Merged
merged 4 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions .github/workflows/web3js-angular-dapp-min.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: web3js-angular-dapp-min Build & Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
types: [ opened, reopened, synchronize ]
jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: templates/min/web3js-angular-dapp-min
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i
- run: npm run build
- run: npx ng test --no-watch --no-progress --browsers=ChromeHeadless
16 changes: 16 additions & 0 deletions templates/min/web3js-angular-dapp-min/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions templates/min/web3js-angular-dapp-min/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
21 changes: 21 additions & 0 deletions templates/min/web3js-angular-dapp-min/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 web3js-angular-dapp-min

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions templates/min/web3js-angular-dapp-min/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Web3.js + Angular Minimal dApp Template

This project is a minimal template for using [Web3.js](https://web3js.org/) with
[Angular](https://angular.dev/).

- [Web3.js Docs](https://docs.web3js.org/)
- [Angular Docs](https://angular.dev/overview)

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version
18.2.4.

## Getting Started

Install the project dependencies with a dependency manager like npm or Yarn. Use `npm start` to
start a local development server and navigate to http://localhost:4200/ to view the dApp.

## Project Design

This project defines an [injectable service](https://angular.dev/guide/di) in
[./src/app/web3/web3.service.ts](./src/app/web3/web3.service.ts) that exposes an instance of the
[`Web3` class](https://docs.web3js.org/api/web3/class/Web3) and an
[EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider, if present. If the provider is
present, it's used by the `Web3` instance to communicate with the network and the service registers
a [`chainChanged` handler](https://docs.metamask.io/wallet/reference/provider-api/#chainchanged)
that reloads the page. Refer to [./src/app/app.component.ts](./src/app/app.component.ts) and
[./src/app/app.component.html](./src/app/app.component.html) for an example of using the service.
96 changes: 96 additions & 0 deletions templates/min/web3js-angular-dapp-min/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"web3js-angular-dapp-min": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/web3js-angular-dapp-min",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kB",
"maximumError": "4kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "web3js-angular-dapp-min:build:production"
},
"development": {
"buildTarget": "web3js-angular-dapp-min:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
],
"scripts": []
}
}
}
}
}
}
Loading