Skip to content

Commit

Permalink
fix: angular
Browse files Browse the repository at this point in the history
  • Loading branch information
davidecarpini committed Mar 26, 2024
1 parent a1dc14f commit acb1466
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 69 deletions.
8 changes: 7 additions & 1 deletion examples/sample-angular-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const Config = require('@vechain/repo-config');

module.exports = Config.EslintLibrary;
module.exports = {
...Config.EslintLibrary,
rules: {
'no-constant-binary-expression': 'off',
'eslint-comments/disable-enable-pair': 'off',
},
};
8 changes: 7 additions & 1 deletion examples/sample-angular-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ RUN apk add git

RUN yarn

RUN yarn global add @angular/cli

RUN yarn global add serve

COPY . .

RUN yarn e2e-build

EXPOSE 5004

CMD [ "yarn", "dev" ]
CMD [ "serve", "dist/easy-angular", "-p", "5004"]
8 changes: 0 additions & 8 deletions examples/sample-angular-app/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/assets/img/favicon/favicon.ico",
"src/assets"
],
"styles": [],
"scripts": []
},
Expand Down Expand Up @@ -92,10 +88,6 @@
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/assets/img/favicon/favicon.ico",
"src/assets"
],
"styles": [],
"scripts": []
}
Expand Down
1 change: 1 addition & 0 deletions examples/sample-angular-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "ng build --configuration development --base-href '/vechain-dapp-kit/angular/'",
"clean": "rm -rf dist .turbo .angular",
"dev": "ng serve --port 5004",
"e2e-build": "ng build --configuration development",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
"purge": "yarn clean; rm -rf node_modules",
"watch": "ng build --watch --configuration development"
Expand Down
19 changes: 18 additions & 1 deletion examples/sample-angular-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,25 @@ export class AppComponent implements OnInit {
// -------------------------------------------------------------------------------

public ngOnInit(): void {
// custom button configuration
const walletConnectOptions = {
projectId: 'a0b855ceaf109dbc8426479a4c3d38d8',
metadata: {
name: 'Sample VeChain dApp',
description: 'A sample VeChain dApp',
url: window.location.origin,
icons: [`${window.location.origin}/images/logo/my-dapp.png`],
},
};

const vechainDAppKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test',
walletConnectOptions,
usePersistence: true,
};
DAppKitUI.configure(vechainDAppKitOptions);

// custom button configuration
const customButton = document.getElementById('custom-button');
if (customButton) {
const handleConnected = (address: string | null): void => {
Expand Down
26 changes: 0 additions & 26 deletions examples/sample-angular-app/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,6 @@
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />

<link
rel="icon"
type="image/x-icon"
href="./assets/img/favicon/favicon.ico"
/>

<!-- NOTE RealFavIconGenerator -->
<link
rel="apple-touch-icon"
sizes="180x180"
href="assets/img/favicon/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="assets/img/favicon/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="assets/img/favicon/favicon-16x16.png"
/>
<link rel="manifest" href="assets/img/favicon/manifest.json" />
<link
rel="mask-icon"
href="assets/img/favicon/safari-pinned-tab.svg"
Expand Down
20 changes: 0 additions & 20 deletions examples/sample-angular-app/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
import { DAppKitUI } from '@vechain/dapp-kit-ui';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent, {
providers: [],
// eslint-disable-next-line no-console
}).catch((err) => console.error(err));

const walletConnectOptions = {
projectId: 'a0b855ceaf109dbc8426479a4c3d38d8',
metadata: {
name: 'Sample VeChain dApp',
description: 'A sample VeChain dApp',
url: window.location.origin,
icons: [`${window.location.origin}/images/logo/my-dapp.png`],
},
};

const vechainDAppKitOptions = {
nodeUrl: 'https://testnet.vechain.org/',
genesis: 'test',
walletConnectOptions,
usePersistence: true,
};

DAppKitUI.configure(vechainDAppKitOptions);
8 changes: 7 additions & 1 deletion examples/sample-angular-app/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
Expand Down Expand Up @@ -52,5 +54,9 @@ import 'zone.js'; // Included with Angular CLI.
*/

import '@angular/localize/init';
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(window as any).global = window;
global.Buffer = global.Buffer || require('buffer').Buffer;
(window as any).process = {
env: { DEBUG: undefined },
version: '', // to avoid undefined.slice error
};
14 changes: 7 additions & 7 deletions tests/e2e/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ services:
ports:
- 5003:5003

# sample-angular-app:
# container_name: sample-angular-app
# build:
# context: ../../examples/sample-angular-app
# dockerfile: Dockerfile
# ports:
# - 5004:5004
sample-angular-app:
container_name: sample-angular-app
build:
context: ../../examples/sample-angular-app
dockerfile: Dockerfile
ports:
- 5004:5004

sample-svelte-app:
container_name: sample-svelte-app
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/src/config/hooks/ContainerHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ BeforeAll(async function () {
'Accepting connections at http://localhost:5003',
),
)
.withWaitStrategy(
'sample-angular-app',
Wait.forLogMessage(
'Accepting connections at http://localhost:5004',
),
)
.withWaitStrategy(
'sample-svelte-app',
Wait.forLogMessage('Local: http://localhost:5005'),
Expand All @@ -50,10 +56,6 @@ BeforeAll(async function () {
'sample-vue-app',
Wait.forLogMessage('Local: http://localhost:5006'),
)
// .withWaitStrategy(
// 'sample-angular-app',
// Wait.forLogMessage('Server running at http://localhost:5004'),
// )
.withWaitStrategy('mockserver', Wait.forLogMessage('INFO'))
.up();
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/src/features/connect-wallet.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Feature: The user can connect to a wallet
* The user connect to VeWorld wallet in dapp "<dapp>"
Examples:
| dapp |
| angular |
| vanilla |
| react |
| next |
Expand Down

0 comments on commit acb1466

Please sign in to comment.