Initial working version

This commit is contained in:
nitowa
2022-11-21 13:22:53 +01:00
commit 3175b262c2
30 changed files with 29678 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
build/*
!build/.gítkeep
gateway/*
!gateway/index.html
gui/*
!gui/.gitkeep
lib
node_modules
src/frontend/build
src/frontend/dist
src/frontend/.angular
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<script src="https://bundle.run/browserify-zlib@0.2.0"></script>
<script src="https://bundle.run/buffer@6.0.3"></script>
<script src="https://cdn.jsdelivr.net/npm/ripple-lib@1.10.0/build/ripple-latest-min.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xrpl@2.1.1"></script>
</head>
<body>
Loading ...
</body>
<script src="main.js"></script>
</html>
View File
+6884
View File
File diff suppressed because it is too large Load Diff
+42
View File
@@ -0,0 +1,42 @@
{
"name": "rjsvm",
"version": "1.0.0",
"description": "",
"main": "lib/Launcher.js",
"scripts": {
"clean": "rm -rf gui/* gateway/main.js lib",
"start": "npm run build && npm run deploy",
"tsc": "tsc",
"build": "npm run clean && npm run build-scripts && npm run build-gui && npm run copy-gui",
"build-scripts": "tsc",
"build-gui": "cd src/frontend && npm run build",
"copy-gui": "cp src/frontend/build/index.html gui",
"webpack-gateway": "webpack --config webpack.gateway.js --progress && cp build/gateway/main.js gateway",
"deploy": "node ./lib/Deploy.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"chai": "^4.3.4",
"node-fetch": "^2.6.1",
"xrpio": "^0.1.6",
"buffer": "^6.0.3",
"xrpl": "^2.6.0-beta.0"
},
"devDependencies": {
"@types/node": "^18.11.9",
"base-64": "^1.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"mocha": "^8.3.2",
"process": "^0.11.10",
"ts-loader": "^8.1.0",
"typescript": "^4.9.3",
"url": "^0.11.0",
"utf8": "^3.0.0",
"webpack": "^5.75.0",
"webpack-bundle-analyzer": "^4.7.0",
"webpack-cli": "^5.0.0"
}
}
+5
View File
@@ -0,0 +1,5 @@
(window as any).global = window;
(window as any).Buffer = (window as any).buffer.Buffer;
const rippleApi = require('xrpio')
window['xrpIO'] = rippleApi.xrpIO
+8
View File
@@ -0,0 +1,8 @@
export const config = {
"oracle": true,
"secret": "sEdTP9Wkb4FSeaFhBavaob336sUTnqy",
"treasuryAddress": "rffH6RPq8xcKAWVvdYsiGEFrz1mz2iH3oj",
"contractAddress": "rDXi28Ud76cz9LtR2vAwsmGfqMcnfCTm8g", //pk: sEdSMv9Ztd2njbAhL3tTYqVRTKMQEME
"rippleNode": "wss://s.altnet.rippletest.net:51233",
}
+20
View File
@@ -0,0 +1,20 @@
import fs from 'fs/promises';
import { config } from './Configuration';
import { xrpIO } from 'xrpio'
const child_process = require('child_process');
const path = require('path');
(async () => {
const api = new xrpIO(config.rippleNode)
await api.connect()
const htmlPath = path.join(__dirname, "..", "gui", "index.html")
console.log("Getting html from "+htmlPath)
const htmlBuf = await fs.readFile(htmlPath)
const html = htmlBuf.toString('ascii')
const dataHash = await api.treeWrite(html, config.contractAddress, config.secret)
await api.disconnect()
console.log("Done. Your upload is at: ", dataHash);
console.log("Building gateway ...")
child_process.exec(`DATA_HASH=${dataHash} npm run webpack-gateway`, console.log)
})()
+13
View File
@@ -0,0 +1,13 @@
(window as any).global = window;
(window as any).Buffer = (window as any).Buffer || require('buffer/').Buffer;
(window as any).buffer = (window as any).Buffer
import { xrpIO } from 'xrpio';
(window as any).xrpIO = xrpIO;
declare const DATA_HASH: string
const api = new xrpIO("wss://s.altnet.rippletest.net:51233")
api.connect().then(async _ => {
const data = await api.treeRead([DATA_HASH]);
alert("Writing to document now")
document.write(data)
})
+17
View File
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
+108
View File
@@ -0,0 +1,108 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-cli": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular-cli",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"./node_modules/@cds/city/css/bundles/default.min.css",
"./node_modules/@cds/core/global.min.css",
"./node_modules/normalize.css/normalize.css",
"node_modules/@clr/icons/clr-icons.min.css",
"node_modules/@clr/ui/clr-ui.min.css",
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "3mb",
"maximumError": "10mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "angular-cli:build:production"
},
"development": {
"browserTarget": "angular-cli:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular-cli:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
}
}
}
}
},
"defaultProject": "angular-cli"
}
+22103
View File
File diff suppressed because it is too large Load Diff
+55
View File
@@ -0,0 +1,55 @@
{
"name": "angular-cli",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"postinstall": "npm run start",
"start": "ng serve",
"build": "npm run build-aot && npm run bundle",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"build-aot": "ng build --aot --optimization --build-optimizer",
"bundle": "webpack --config webpack-bundle.config.js --progress",
"clean": "rm -rf dist/* build/*"
},
"private": true,
"dependencies": {
"@angular/animations": "~14.0.0",
"@angular/common": "~14.0.0",
"@angular/compiler": "~14.0.0",
"@angular/core": "~14.0.0",
"@angular/forms": "~14.0.0",
"@angular/platform-browser": "~14.0.0",
"@angular/platform-browser-dynamic": "~14.0.0",
"@angular/router": "~14.0.0",
"@cds/angular": "^6.0.0",
"@cds/city": "^1.1.0",
"@cds/core": "^6.0.0",
"@clr/angular": "~13.0.0",
"@clr/icons": "~13.0.0",
"@clr/ui": "~13.0.0",
"mini-css-extract-plugin": "^1.6.0",
"normalize.css": "^8.0.1",
"rxjs": "~6.6.0",
"style-loader": "^3.3.1",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~14.0.0",
"@angular/cli": "~14.0.0",
"@angular/compiler-cli": "~14.0.0",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"css-loader": "^6.7.2",
"html-webpack-plugin": "^5.5.0",
"inline-chunk-html-plugin": "^1.1.1",
"jasmine-core": "~3.7.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"typescript": "~4.7.0"
}
}
@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {}
+26
View File
@@ -0,0 +1,26 @@
<div class="main-container">
<header class="header-2">
<div class="branding">
<a class="nav-link">
<cds-icon shape="home" size="lg"></cds-icon>
<span class="title">Clarity</span>
</a>
</div>
<div class="header-nav">
<a class="active nav-link nav-text">Home</a>
</div>
</header>
<div class="content-container">
<div class="content-area">
<h3>Clarity Starter Instructions:</h3>
<ul>
<li>Start by clicking Fork in the toolbar above.</li>
<li>Implement the problem in the new editor.</li>
<li>
Save the result, and share the url in a GitHub or StackOverflow issue.
</li>
</ul>
</div>
</div>
</div>
+10
View File
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
title = 'angular-cli';
}
+21
View File
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CdsModule } from '@cds/angular';
import { ClarityModule } from '@clr/angular';
import { ClarityIcons, homeIcon } from '@cds/core/icon';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, AppRoutingModule, ClarityModule, CdsModule],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {
constructor() {
ClarityIcons.addIcons(homeIcon);
}
}
@@ -0,0 +1,3 @@
export const environment = {
production: true
};
@@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
+14
View File
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>AngularCli</title>
<base href="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body cds-text="body">
<app-root></app-root>
</body>
</html>
+13
View File
@@ -0,0 +1,13 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.error(err));
+64
View File
@@ -0,0 +1,64 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/**
* IE11 requires the following for NgClass support on SVG elements
*/
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
+4
View File
@@ -0,0 +1,4 @@
@import '~modern-normalize/modern-normalize.css';
@import '~@cds/core/global.min.css';
@import '~@cds/city/css/bundles/default.min.css';
@import '~@cds/core/styles/theme.dark.min.css';
+15
View File
@@ -0,0 +1,15 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}
+27
View File
@@ -0,0 +1,27 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2020",
"module": "es2020",
"lib": ["es2018", "dom"]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
+44
View File
@@ -0,0 +1,44 @@
const HtmlWebpackPlugin = require('html-webpack-plugin')
const InlineChunkHtmlPlugin = require('inline-chunk-html-plugin')
const webpack = require('webpack')
const path = require('path')
const fs = require('fs')
const distDir = path.resolve(__dirname, 'dist', 'angular-cli')
const buildDir = path.resolve(__dirname, 'build')
const srcDir = path.resolve(__dirname, 'src')
module.exports = {
mode: 'production',
target: 'web',
entry: fs.readdirSync(distDir)
.filter(name => name.match(/(\.(js|css))$/))
.map(name => path.resolve(distDir, name)),
output: {
publicPath: '',
filename: '[name].js',
path: buildDir,
},
resolve: {
extensions: ['', '.js', '.jsx', '.css'],
},
plugins: [
new HtmlWebpackPlugin({
inject: "body",
template: path.resolve(srcDir, 'index.html'),
}),
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/.*/]),
],
optimization: {
},
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
],
},
externals: {
},
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"strictPropertyInitialization": false,
"noImplicitAny": false,
"target": "esNext",
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"baseUrl": "./",
"outDir": "./lib",
"strictNullChecks": false,
"esModuleInterop": true
},
"include": ["src", "test"],
"exclude": ["src/gui"]
}
+62
View File
@@ -0,0 +1,62 @@
const path = require('path');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
if(!process.env['DATA_HASH']){
console.log("Environment DATA_HASH not set")
process.exit(1)
}else{
console.log(`Webpacking Gateway with DATA_HASH=${process.env['DATA_HASH']}`)
}
module.exports = {
mode: 'production',
target: "web",
entry: path.resolve(__dirname, 'src', 'Gateway.ts'),
output: {
path: path.resolve(__dirname, 'build', 'gateway'),
filename: '[name].js'
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
//new BundleAnalyzerPlugin(),
//new webpack.IgnorePlugin(/.*ripple-lib.*/),
new webpack.DefinePlugin({
DATA_HASH: JSON.stringify(process.env['DATA_HASH'])
})
],
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"],
fallback: {
"fs": false,
"tls": false,
"net": false,
"path": false,
"zlib": false,
"http": false,
"https": false,
"stream": false,
"crypto": false,
"Buffer": require.resolve('buffer'),
"crypto-browserify": require.resolve('crypto-browserify'),
}
},
externals: {
'lodash': ['_'],
'xrpl': ['xrpl'],
'ripple-lib': ['ripple'],
'RippleAPI': ['ripple-lib', 'RippleAPI'],
'bn.js': ['BN'],
'Buffer': ['buffer'],
'buffer': ['buffer'],
'zlib': ['browserifyZlib']
},
module: {
rules: [
{ test: /\.ts?$/, loader: "ts-loader", }
]
},
}
+50
View File
@@ -0,0 +1,50 @@
const path = require('path');
const webpack = require('webpack');
module.exports = {
mode: 'production',
target: "web",
entry: path.resolve(__dirname, 'src', 'Browser.ts'),
output: {
path: path.resolve(__dirname, 'build', 'gui'),
filename: '[name].js',
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
resolve: {
extensions: [".ts", ".tsx", ".js"],
fallback: {
"fs": false,
"tls": false,
"net": false,
"path": false,
"zlib": false,
"http": false,
"https": false,
"stream": false,
"crypto": false,
"Buffer": require.resolve('buffer'),
"crypto-browserify": require.resolve('crypto-browserify'),
}
},
externals: {
'lodash': ['_'],
'ripple-lib': ['ripple'],
'RippleAPI': ['ripple-lib', 'RippleAPI'],
'bn.js': ['BN'],
'Buffer': ['buffer'],
'buffer': ['buffer'],
'zlib': ['browserifyZlib']
},
module: {
rules: [
{ test: /\.ts?$/, loader: "ts-loader", }
]
},
optimization:{
minimize: false
}
}