Skip to content

Commit

Permalink
Configure dprint (#134)
Browse files Browse the repository at this point in the history
* add Dockerfile support

* dprint fmt

* Configure dprint on CI

* padding

* Fix markdown nested items

* dprint fmt
  • Loading branch information
Lohann committed Jul 3, 2023
1 parent d632881 commit 0d99d92
Show file tree
Hide file tree
Showing 32 changed files with 382 additions and 222 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/assign-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ assignees: ''
- [ ] Feature 3

**Tests instructions**

- Unit tests
- Integration tests

**References Material**

- Technical Specs
- Related docs
- Example code
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/report-a-bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ _Replace the example steps below with actual steps to reproduce the bug you're r
3. step 2
4. bug...


**Logs, Errors or Screenshots**

_Please provide the text of any logs or errors that you experienced; if
Expand Down
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/suggest-a-feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ assignees: ''
---

**Motivation**
*Describe the problem, need, or specific use-case that motivated you to make this suggestion.*
_Describe the problem, need, or specific use-case that motivated you to make this suggestion._

**Problem Statement**
*Details here.*
_Details here._

**Suggested Solution**
*Describe your suggested solution.*
_Describe your suggested solution._

**Alternatives**
*Describe any alternative solutions or features you considered and why you believe your suggested solution is preferable.*
_Describe any alternative solutions or features you considered and why you believe your suggested solution is preferable._

**Additional Information**
*Provide any additional information that you believe may help us evaluate your suggestion.*
_Provide any additional information that you believe may help us evaluate your suggestion._
13 changes: 7 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Description

Summary of the change and which issue is fixed. Please also include relevant motivation and context.
Summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

Expand All @@ -21,9 +21,10 @@ Describe the tests that you ran to verify your changes. Please also list any rel
- [ ] Test B

**Test Configuration**:
* Firmware version:
* Hardware:
* Toolchain:

- Firmware version:
- Hardware:
- Toolchain:

## Code review prechecks:

Expand All @@ -32,5 +33,5 @@ Describe the tests that you ran to verify your changes. Please also list any rel
- [ ] Inline comments have been added for each method
- [ ] I have made corresponding changes to the documentation
- [ ] Code changes introduces no new problems or warnings
- [ ] Test cases have been added
- [ ] Dependent changes have been merged and published in downstream modules
- [ ] Test cases have been added
- [ ] Dependent changes have been merged and published in downstream modules
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
with:
components: rustfmt

- name: dprint check
uses: dprint/check@v2.2

- name: cargo fmt
run: cargo fmt --all -- --check

Expand Down
36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[workspace]
members = [
"chains/astar/config",
"chains/astar/server",
"chains/bitcoin/config",
"chains/bitcoin/server",
"chains/ethereum/config",
"chains/ethereum/server",
"chains/ethereum/tx",
"chains/polkadot/config",
"chains/polkadot/server",
"chains/polkadot/tx",
"rosetta-cli",
"rosetta-client",
"rosetta-core",
"rosetta-crypto",
"rosetta-docker",
"rosetta-server",
"rosetta-types",
"rosetta-wallet",
"chains/astar/config",
"chains/astar/server",
"chains/bitcoin/config",
"chains/bitcoin/server",
"chains/ethereum/config",
"chains/ethereum/server",
"chains/ethereum/tx",
"chains/polkadot/config",
"chains/polkadot/server",
"chains/polkadot/tx",
"rosetta-cli",
"rosetta-client",
"rosetta-core",
"rosetta-crypto",
"rosetta-docker",
"rosetta-server",
"rosetta-types",
"rosetta-wallet",
]
resolver = "2"
84 changes: 57 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,78 @@
# Rosetta SDK Documentation
The Rosetta SDK is a Rust-based package that implements Coinbase’s [Rosetta API](https://www.rosetta-api.org/docs/welcome.html) specifications. This repo provides a framework for Analog’s connectors — special nodes hosted by time node operators — to simplify their interactions with Analog-connected chains in a manner compliant with the Analog Network’s protocol.

The Rosetta SDK is a Rust-based package that implements Coinbase’s [Rosetta API](https://www.rosetta-api.org/docs/welcome.html) specifications. This repo provides a framework for Analog’s connectors — special nodes hosted by time node operators — to simplify their interactions with Analog-connected chains in a manner compliant with the Analog Network’s protocol.

## Repository structure

This repo contains the following modules:

- `rosetta-core`. Provides traits and definitions shared by the server and client crates.
- `rosetta-server`. This is a generic implementation of the Rosetta Server. The Rosetta Server is a standalone server that a connector on any Analog-supported chain can connect to and listen to the port specified in the settings.
- `rosetta-client`. This is a standard client that interacts with the Rosetta Server.
- `rosetta-types`. It contains the request and response structs used by the client and server. It is initially autogenerated using the openapi-generator.
- `rosetta-server`. This is a generic implementation of the Rosetta Server. The Rosetta Server is a standalone server that a connector on any Analog-supported chain can connect to and listen to the port specified in the settings.
- `rosetta-client`. This is a standard client that interacts with the Rosetta Server.
- `rosetta-types`. It contains the request and response structs used by the client and server. It is initially autogenerated using the openapi-generator.
- `rosetta-crypto`. It has cryptographic primitives used by the rosetta-client.
- `rosetta-wallet`. This is a command line interface (CLI) built with the rosetta-client.
- `rosetta-cli`. This is a CLI built with the rosetta-client.
- `rosetta-docker`. This is a generic Rosetta Server testing infrastructure.
- `chains`. These are chain-specific client/server components.

## Getting started

<!--This section needs to be refined -->

To get started with the Rosetta SDK, you must ensure you have [installed the latest version of Docker](https://www.docker.com/get-started/).
Run the following command to download chain-connectors:
To get started with the Rosetta SDK, you must ensure you have [installed the latest version of Docker](https://www.docker.com/get-started/).\
Run the following command to download chain-connectors:

```
$ git clone https://github.com/Analog-Labs/chain-connectors.git
```

You can also download the latest pre-built Docker image release from GitHub by running the following command:
You can also download the latest pre-built Docker image release from GitHub by running the following command:

```
curl -sSfL https://raw.githubusercontent.com/Analog-Labs/chain-connectors/master/install.sh | sh -s
```
After cloning this repo, simply run the following command:
```

After cloning this repo, simply run the following command:

```
make build-local
```
```

### Connector deployment

<!-- This section needs to describe how operators will deploy their connectors.-->
<!--I am assuming here is where we initiate the rosetta-server and rosetta-client.-->
<!--I am assuming here is where we initiate the rosetta-server and rosetta-client.-->

### Install CLI tools

Install the CLI tools by running the commands below:

### Install CLI tools
Install the CLI tools by running the commands below:
```
cargo install --path rosetta-cli
cargo install --path rosetta-wallet
```
```

To run any command with **rosetta-cli**, simply execute the **rosetta-cli** tool from the command line as follows:

```
rosetta-cli [command]
```

Similarly, to run a command with the **rosetta-wallet**, simply execute the **rosetta-wallet** tool from the command line as follows:
```

Similarly, to run a command with the **rosetta-wallet**, simply execute the **rosetta-wallet** tool from the command line as follows:

```
rosetta-wallet [command]
```
```

## Reference wallet implementations
To help you get started with wallets on specific chains, we have developed complete Rosetta API reference implementations for Bitcoin (deprioritized for now), Ethereum, and Substrate-based chains.

### Ethereum example
To help you get started with wallets on specific chains, we have developed complete Rosetta API reference implementations for Bitcoin (deprioritized for now), Ethereum, and Substrate-based chains.

### Ethereum example

We have tested this implementation on an [AWS c5.2xlarge instance](https://aws.amazon.com/ec2/instance-types/c5). This instance type provides 8 vCPUs and 16 GB RAM. To use this repository, you need to fork it and start playing with the code. For example, running these commands will help you learn more about Rosetta API implementation for the Ethereum-based wallets:

```
rosetta-wallet --chain eth --keyfile /tmp/alice faucet 100000000000000
rosetta-wallet --chain eth --keyfile /tmp/alice balance
Expand All @@ -65,26 +82,34 @@ rosetta-wallet --chain eth --keyfile /tmp/bob balance
```

### Substrate example

We have tested this implementation on an [AWS c5.2xlarge instance](https://aws.amazon.com/ec2/instance-types/c5). This instance type provides 8 vCPUs and 16 GB RAM. To use this repository, you need to fork it and start playing with the code. For example, running these commands will help you learn more about Rosetta API implementation for Substrate-based wallets:

```
rosetta-wallet --chain dot --keyfile /tmp/alice faucet 3000000000000000
rosetta-wallet --chain dot --keyfile /tmp/bob account
rosetta-wallet --chain dot --keyfile /tmp/alice transfer bob_acc_key 1500000000000000
rosetta-wallet --chain dot --keyfile /tmp/bob balance
```

### Bitcoin example

To use this repository, you need to fork it and start playing with the code. For example, running these commands will help you learn more about Rosetta API implementation for Bitcoin wallets:

```
rosetta-wallet --chain btc --keyfile /tmp/alice faucet 1000
rosetta-wallet --chain btc --keyfile /tmp/bob account
rosetta-wallet --chain btc --keyfile /tmp/alice transfer bob_acc_key 1000
rosetta-wallet --chain btc --keyfile /tmp/alice faucet 1
rosetta-wallet --chain btc --keyfile /tmp/bob balance
```
## Reference CLI implementation
To help you get started with rosetta-cli, we have developed a standard indexer endpoint that you can leverage to integrate external blockchains automatically. The indexer endpoint complements the existing Data and Construction API endpoints in Rosetta API specifications, allowing developers to fully support asset integration.
```

## Reference CLI implementation

To help you get started with rosetta-cli, we have developed a standard indexer endpoint that you can leverage to integrate external blockchains automatically. The indexer endpoint complements the existing Data and Construction API endpoints in Rosetta API specifications, allowing developers to fully support asset integration.

You will need an indexer URL that gets passed with the “—indexer-URL” flag to run an indexer. For example, in a local environment, you can run these commands to use the indexer:

You will need an indexer URL that gets passed with the “—indexer-URL” flag to run an indexer. For example, in a local environment, you can run these commands to use the indexer:
```
rosetta-cli --chain=btc search --indexer-url=http://localhost:8083 --type=Transfer --success=true
Expand All @@ -94,11 +119,14 @@ rosetta-cli --chain=dot search --indexer-url=http://localhost:8085 --type=Transf
```

### Block Explorer

To launch the Block Explorer in your browser, simply open your browser and point it to:
http://rosetta.analog.one:3000
http://rosetta.analog.one:3000

### Run local testnet

Running a local testnet with docker compose up initiates a number of containers, including:

- bitcoin: http://127.0.0.1:8080
- ethereum: http://127.0.0.1:8081
- polkadot: http://127.0.0.1:8082
Expand All @@ -107,12 +135,14 @@ Running a local testnet with docker compose up initiates a number of containers,
You can override the default URL in rosetta-cli and rosetta-wallet with the “—URL” flag.

## Update AWS deployment

Create a new tag, push to master and use it to create a new github release.

## Contributing

You can contribute to this repo in a number of ways, including:

- [Asking questions](https://github.com/Analog-Labs/chain-connectors/issues/new?assignees=&labels=question&template=ask-a-question.md&title=)
- [Giving feedback](https://github.com/Analog-Labs/chain-connectors/issues/new?assignees=&labels=enhancement&template=suggest-a-feature.md&title=)
- [Reporting bugs](https://github.com/Analog-Labs/chain-connectors/issues/new?assignees=&labels=bug&template=report-a-bug.md&title=)
Read our [contribution guidelines](https://github.com/Analog-Labs/.github-private/wiki/Contribution-Guidelines) for more information on how to contribute to this repo.

Read our [contribution guidelines](https://github.com/Analog-Labs/.github-private/wiki/Contribution-Guidelines) for more information on how to contribute to this repo.
4 changes: 2 additions & 2 deletions chains/astar/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
name = "rosetta-config-astar"
version = "0.4.0"
edition = "2021"
description = "Polkadot configuration."
repository = "https://github.com/analog-labs/chain-connectors"
license = "MIT"
repository = "https://github.com/analog-labs/chain-connectors"
description = "Polkadot configuration."

[dependencies]
anyhow = "1.0.69"
Expand Down
8 changes: 3 additions & 5 deletions chains/astar/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
name = "rosetta-server-astar"
version = "0.4.0"
edition = "2021"
description = "Astar rosetta server."
repository = "https://github.com/analog-labs/chain-connectors"
license = "MIT"
repository = "https://github.com/analog-labs/chain-connectors"
description = "Astar rosetta server."

[dependencies]
anyhow = "1.0.69"
Expand All @@ -27,7 +27,5 @@ ethers-solc = "2.0.1"
hex = "0.4.3"
rosetta-client = { version = "0.4.0", path = "../../../rosetta-client" }
rosetta-docker = { version = "0.4.0", path = "../../../rosetta-docker" }
rosetta-server = { version = "0.4.0", path = "../../../rosetta-server", features = [
"tests",
] }
rosetta-server = { version = "0.4.0", path = "../../../rosetta-server", features = ["tests"] }
sha3 = "0.10.6"
Loading

0 comments on commit 0d99d92

Please sign in to comment.