Skip to content

Commit

Permalink
Merge pull request #64 from gRoussac/dev
Browse files Browse the repository at this point in the history
Update port sse
  • Loading branch information
gRoussac authored Mar 4, 2024
2 parents 0574caf + 67e50d9 commit 5b03b65
Show file tree
Hide file tree
Showing 12 changed files with 687 additions and 465 deletions.
3 changes: 3 additions & 0 deletions casper-escrow.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
},
{
"path": "www"
},
{
"path": "docker"
}
],
"settings": {}
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ RUN unzip -q ./*.zip -d ${TMP}
RUN mv ${TMP}/*/casper-sdk/ ./
RUN mv ${TMP}/*/w* ./ && rm -rf ${TMP} *.zip
WORKDIR /app/www
ENV PORT=4200
RUN npm install --verbose
RUN npm run build --verbose
CMD npm run serve
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 deletions www/apps/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
"targets": {
"build": {
"executor": "@nrwl/webpack:webpack",
"outputs": ["{options.outputPath}"],
"outputs": [
"{options.outputPath}"
],
"options": {
"target": "node",
"compiler": "tsc",
"outputPath": "dist/apps/api",
"main": "apps/api/src/main.ts",
"tsConfig": "apps/api/tsconfig.app.json",
"assets": ["apps/api/src/assets"],
"assets": [
"apps/api/src/assets"
],
"webpackConfig": "apps/api/webpack.config.js"
},
"configurations": {
Expand Down Expand Up @@ -43,19 +47,25 @@
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": ["apps/api/**/*.ts"]
"lintFilePatterns": [
"apps/api/**/*.ts"
]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/apps/api"],
"outputs": [
"{workspaceRoot}/coverage/apps/api"
],
"options": {
"jestConfig": "apps/api/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
}
}
1 change: 0 additions & 1 deletion www/apps/api/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ export const environment = {
users,
apiUrl: 'https://rpc.testnet.casperlabs.io',
sseUrl: 'https://rpc.testnet.casperlabs.io'
// apiUrl: 'http://localhost:11101/rpc'
};
2 changes: 1 addition & 1 deletion www/apps/frontend/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false
production: false,
};

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class PutDeployComponent implements AfterViewInit, OnDestroy {
session_args_json: string = this.argsElt?.nativeElement.value?.trim() || '',
payment_amount: string = this.gasFeeElt?.nativeElement.value?.trim() || '',
ttl: string = this.TTLElt?.nativeElement.value?.trim() || '',
session_call_package: boolean = !!this.isPackageElt?.nativeElement.checked;
session_call_package = !!this.isPackageElt?.nativeElement.checked;

this.deploy = this.deployService.makeDeploy(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, OnDestroy, ViewChild } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CommonModule, DOCUMENT } from '@angular/common';
import { Peer } from '@casper-api/api-interfaces';
import { DeployerService } from '@casper-data/data-access-deployer';
import { Subscription } from 'rxjs';
Expand All @@ -21,6 +21,7 @@ export class StateRootHashComponent implements OnDestroy, AfterViewInit {
private getStateRootHashSubscription!: Subscription;
private getPeersSubscription!: Subscription;
private getStatusSubscription!: Subscription;
private window!: (Window & typeof globalThis) | null;

peers!: Peer[];
status = '';
Expand All @@ -30,12 +31,14 @@ export class StateRootHashComponent implements OnDestroy, AfterViewInit {

constructor(
@Inject(ENV_CONFIG) public readonly config: EnvironmentConfig,
@Inject(DOCUMENT) private document: Document,
private readonly deployerService: DeployerService,
private readonly resultService: ResultService,
private readonly routeurHubService: RouteurHubService,
private readonly changeDetectorRef: ChangeDetectorRef,
private readonly storageService: StorageService
) {
this.window = this.document.defaultView;
this.defaults = [
this.config['default_node_localhost'],
this.config['default_node_testnet'],
Expand All @@ -54,7 +57,12 @@ export class StateRootHashComponent implements OnDestroy, AfterViewInit {
this.defaults.push(this.apiUrl);
}
} else {
this.apiUrl = this.defaults[0];
const currentHost = this.window?.location.hostname;
if (currentHost && this.defaults[0].includes(currentHost)) {
this.apiUrl = this.defaults[0];
} else {
this.apiUrl = this.defaults[1];
}
}
this.getPeers();
});
Expand Down
3 changes: 2 additions & 1 deletion www/libs/util/config/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export type EnvironmentConfig = {
const rpc_port = '7777';
const sse_port = '9999';
const rpc_port_localhost = '11101';
const sse_port_localhost = '4200';
const currentPort = window?.location?.port;
const sse_port_localhost = currentPort || '4200';
const localhost = "http://localhost";
const default_node_localhost = [localhost, rpc_port_localhost].join(':');
const default_node_testnet = "https://rpc.testnet.casperlabs.io";
Expand Down
5 changes: 3 additions & 2 deletions www/libs/util/services/wasm/src/lib/wasm.factory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApplicationInitStatus, APP_INITIALIZER, inject, InjectionToken, Provider } from "@angular/core";
import * as deployer from "deployer";
import * as casper_sdk from "casper-sdk";
import { config } from "@casper-util/config";

const initDeployer = deployer.default;
const Deployer = deployer.Deployer;
Expand All @@ -18,7 +19,7 @@ export const fetchWasmFactory = async (): Promise<deployer.Deployer> => {

export const fetchSDKFactory = async (): Promise<casper_sdk.SDK> => {
const wasm = await initSDK('assets/casper_rust_wasm_sdk_bg.wasm');
const casperSDK = new SDK('http://localhost:4200');
const casperSDK = new SDK(config['default_node_localhost']);
return wasm && casperSDK;
};

Expand Down Expand Up @@ -47,4 +48,4 @@ export function provideSafeAsync<T>(
},
},
];
}
};
Loading

0 comments on commit 5b03b65

Please sign in to comment.