Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed May 16, 2024
1 parent 0fe6736 commit f1ec988
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
52 changes: 39 additions & 13 deletions tools/walletextension/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,61 @@
# The Ten gateway
# Ten Gateway

See the documentation [here](https://docs.ten.xyz/wallet-extension/wallet-extension/).
Ten Gateway is available as a hosted service
(read more about it [here](https://docs.ten.xyz/docs/tools-infrastructure/hosted-gateway)),
but we also provide the source code for running it locally.
In this document, we will explain how to run and use Ten Gateway locally.

## Developer notes
## Running Ten Gateway locally

Running gateway frontend locally requires building static files first.
To do that, run `npm run build` in `tools/walletextension/frontend` folder.
Ten Gateway consists of two main parts:
- backend (which handles all api and rpc requests and is responsible for communication with the Ten node and encrypting/decrypting traffic)
- frontend (which is a web application that allows users to interact with the Ten network and manage their accounts in a user-friendly way through web browsers)

### Running the backend
To run Ten Gateway backend, you need to build and run the `walletextension` tool.

The precompiled binaries for macOS ARM64, macOS AMD64, Windows AMD64 and Linux AMD64 can be built by running the
following commands from the `tools/walletextension/main` folder:

```
env GOOS=darwin GOARCH=amd64 go build -o ../bin/wallet_extension_macos_amd64 .
env GOOS=darwin GOARCH=arm64 go build -o ../bin/wallet_extension_macos_arm64 .
env GOOS=darwin GOARCH=arm64 go build -o ../bin/wallet_extension_macos_arm64 .
env GOOS=windows GOARCH=amd64 go build -o ../bin/wallet_extension_win_amd64.exe .
env GOOS=linux GOARCH=amd64 go build -o ../bin/wallet_extension_linux_amd64 .
```

The binaries will be created in the `tools/walletextension/bin` folder.
To run it you need to run built binary with the following command (depending on your OS):

```
./wallet_extension_macos_amd64
```

You can see the available flags (and default values) by running the binary with the `-h` flag.

### Structure
#### Verifying the API

To verify that the API is working correctly, you can use `curl` to send a request to the `network-health` endpoint. This endpoint is accessible at `http://127.0.0.1:3000/v1/network-health`.

Open a terminal and run the following `curl` command:

```sh
curl -X GET http://127.0.0.1:3000/v1/network-health/
```

The Expected response is:
```json
{"id":"1","jsonrpc":"2.0","result":{"Errors":[],"OverallHealth":true}
```

This package follows the same structure of `host` and `enclave`.
### Running the frontend
To run Ten Gateway frontend you need to go to `go-ten/tools/walletextension/frontend` and run the following commands:

It uses a container to wrap the services that are required to allow the wallet extension to fulfill the business logic.
`npm run build` - to build the frontend (if you are using a different port/host you need to set environment variable `NEXT_PUBLIC_API_GATEWAY_URL` to match that change)

### Running Wallet Extension with Docker
`npm run start` - to start the frontend

To build a docker image use docker build command. Please note that you need to run it from the root of the repository.
To run the container you can use `./docker_run.sh`. You can add parameters to the script, and they are passed to the wallet extension
(example: `-host=0.0.0.0` to be able to access wallet extension endpoints via localhost).


### HTTP Endpoints
Expand Down
2 changes: 1 addition & 1 deletion tools/walletextension/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func main() {

walletExtensionAddr := fmt.Sprintf("%s:%d", common.Localhost, config.WalletExtensionPortHTTP)
fmt.Printf("💡 Wallet extension started \n") // Some tests rely on seeing this message. Removed in next PR.
fmt.Printf("💡 Obscuro Gateway started - visit http://%s/static to use it.\n", walletExtensionAddr)
fmt.Printf("💡 Obscuro Gateway started: http://%s/\n", walletExtensionAddr)

select {}
}

0 comments on commit f1ec988

Please sign in to comment.