Skip to content

Commit

Permalink
feat: add template web
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Mar 8, 2024
1 parent a19699c commit c412543
Show file tree
Hide file tree
Showing 66 changed files with 7,261 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def get_env_or_default(env_name: str, default: Any, validation: Any = None) -> A


WEBUI_PORT = get_env_or_default("DAN_TESTING_WEBUI_PORT", "auto")
TEMPLATE_WEB_PORT = get_env_or_default("DAN_TESTING_TEMPLATE_WEB_PORT", "auto")
DATA_FOLDER = get_env_or_default("DAN_TESTING_DATA_FOLDER", "Data")
TARI_BINS_FOLDER = get_env_or_default("TARI_BINS_FOLDER", "bins")
TARI_DAN_BINS_FOLDER = get_env_or_default("TARI_DAN_BINS_FOLDER", "bins")
Expand All @@ -62,10 +63,7 @@ def get_env_or_default(env_name: str, default: Any, validation: Any = None) -> A
# Specify args e.g. mint=10000,10001,1. Start the value with "w:" to choose Workspace arg, specify multiples with | e.g. fungible::mint=w:0|fungible::mint=10000,10001,1
# use ! to dump the buckets into the account
# DEFAULT_TEMPLATE_FUNCTION = "mint"
DEFAULT_TEMPLATE_FUNCTION = get_env_or_default(
"DAN_TESTING_DEFAULT_TEMPLATE_FUNCTION",
""
)
DEFAULT_TEMPLATE_FUNCTION = get_env_or_default("DAN_TESTING_DEFAULT_TEMPLATE_FUNCTION", "")
BURN_AMOUNT = int(get_env_or_default("DAN_TESTING_BURN_AMOUNT", 1000000))
NO_FEES = is_boolstring_true(get_env_or_default("DAN_TESTING_NO_FEES", "false", is_boolstring))

Expand Down
6 changes: 6 additions & 0 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from Collections.dan_wallet_daemons import dan_wallets
from Collections.base_nodes import base_nodes
from Common.local_ip import local_ip
from template_web import TemplateWebServer
import os
import base64
import json
Expand All @@ -20,11 +21,13 @@ class Commands:
def __init__(
self,
tari_connector_sample: Optional[TariConnectorSample],
template_web_server: Optional[TemplateWebServer],
server: Server,
signaling_server: SignalingServer,
) -> None:
self.miner = miner
self.tari_connector_sample = tari_connector_sample
self.template_web_server = template_web_server
self.server = server
self.signaling_server = signaling_server
self.indexers = indexers
Expand Down Expand Up @@ -106,4 +109,7 @@ def http(self, what: str) -> Optional[str]:
if process_type.is_connector(what):
if self.tari_connector_sample:
return f"http://{local_ip}:{self.tari_connector_sample.http_port}"
if process_type.is_template_web(what):
if self.template_web_server:
return f"http://{local_ip}:{self.template_web_server.http_port}"
return None
11 changes: 8 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from Common.local_ip import local_ip
from commands import Commands
from webui import JrpcWebuiServer
from template_web import TemplateWebServer
import os
import re
import shutil
Expand All @@ -45,8 +46,7 @@
from Collections.validator_nodes import validator_nodes
from Collections.indexers import indexers
from Collections.dan_wallet_daemons import dan_wallets
from typing import Any, Optional
import signal
from typing import Any

accounts: dict[str, Any] = {}

Expand Down Expand Up @@ -228,6 +228,7 @@ def check_executable(bins_folder: str, file_name: str):
server = None
tari_connector_sample = None
webui_server = None
template_web_server = None
commands = None

try:
Expand Down Expand Up @@ -279,9 +280,12 @@ def check_executable(bins_folder: str, file_name: str):
print_step("Starting tari-connector test website")
tari_connector_sample = TariConnectorSample(signaling_server_address=signaling_server.address)

commands = Commands(tari_connector_sample, server, signaling_server)
if signaling_server.address:
template_web_server = TemplateWebServer(signaling_server.address)

commands = Commands(tari_connector_sample, template_web_server, server, signaling_server)
webui_server = JrpcWebuiServer(commands)

templates: dict[str, Template] = {}
if STEPS_CREATE_TEMPLATE:
print_step("GENERATING TEMPLATE")
Expand Down Expand Up @@ -484,6 +488,7 @@ def create_account(i: int, amount: int):
print("ctrl-c pressed during setup")

del webui_server
del template_web_server
del commands
del tari_connector_sample
del signaling_server
Expand Down
4 changes: 4 additions & 0 deletions process_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def is_connector(what: str) -> bool:
return what.startswith("TariConnector")


def is_template_web(what: str) -> bool:
return what.startswith("TemplateWeb")


def get_index(what: str) -> Optional[int]:
try:
_, id = what.split("_")
Expand Down
11 changes: 11 additions & 0 deletions template-web/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

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

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions template-web/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
**/templates
18 changes: 18 additions & 0 deletions template-web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
1 change: 1 addition & 0 deletions template-web/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
24 changes: 24 additions & 0 deletions template-web/.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?
13 changes: 13 additions & 0 deletions template-web/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Stan Bondi <sdbondi@users.noreply.github.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
21 changes: 21 additions & 0 deletions template-web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Tari Template Website

UNDER DEVELOPMENT

Provides a basic Vite + React interface to construct and submit transactions from a given WASM template address.

Currently, only the wallet JSON-RPC interface is supported.

### TODO

- [x] Add support for [Tari snap](https://github.com/tari-project/tari-snap)
- [ ] Support for dry-runs
- [ ] Support for transaction fee estimation
- [ ] Improved handling of argument and return types (e.g. Proof, Bucket etc)
- [ ] Improved badge usage
- [ ] Dashboard that displays well-formatted data from managed components
- [ ] Previous transactions list
- [ ] Customization of transactions before submitting
- [ ] UX


16 changes: 16 additions & 0 deletions template-web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tari Template Explorer</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit c412543

Please sign in to comment.