diff --git a/README.md b/README.md index 01d846d..d561629 100644 --- a/README.md +++ b/README.md @@ -3,78 +3,7 @@ > [!WARNING] > This repository is under construction 🚧. We are actively improving it hackathon-style. -This is a Rust implementation of the [CCIP gateway](https://alpha-docs.ens.domains/resolvers/ccip). It allows you to issue unlimited gasless subdomains for your name, as well as to create, manage, and moderate namespaces. +## Offchain Gateway Example -> [!NOTE] -> This gateway is built to be an **Opinionated ENS Subname Issuer**, if youre looking for something more generic, please checkout [ensdomains/offchain-resolver](https://github.com/ensdomains/offchain-resolver), and [ensdomains/offchain-resolver-example](https://github.com/ensdomains/offchain-resolver-example). +If you are looking for the original code that was in this repository please see [examples/full](examples/full). -## Features - -- CCIP Spec Compliant Gateway Endpoint -- `postgres` - Transparent Database backend. -- `self-service` - Authentication-based updating records. -- `eoa-self-service` - EOA-based Authentication. (TODO) -- Modular authentication for EOA, Admin API, & more. -- View endpoint for profile data. - -## Setup - -### Run the gateway -The gateway is just a docker container / standalone binary. You can run it with docker-compose or just run the binary. - -```yaml -cargo run -``` - -### Deploy a Resolver - -Using a CCIP Gateway requires a resolver contract to be acting on behalf of the name. Although you could write your own contract, we recommend you deploy a proxy contract through [ccip.tools](https://ccip.tools/). - -[![](.github/ccip-tools.png)](https://ccip.tools/) - -(Source for the contracts can be found at [ensdomains/ccip-tools](https://github.com/ensdomains/ccip-tools/tree/master/contracts)) - -When asked for the `Gateway URL` supply your gateway's url (for eg: `https://gateway.example.com/{sender}.json`), and for the `Signers` field supply the address of your gateway (for eg: `[0x225f137127d9067788314bc7fcc1f36746a3c3B5]`), you can find this in the logs of your gateway. - -> [!NOTE] -> There are gas costs associated with deploying a resolver, at the time of writing this (30 gwei), it costs ~0.004 ETH (8 USD) to deploy a resolver (see [txs](https://etherscan.io/tx/0x0c90da0a122f38125a8ad1f48ef23cf5f7d399846bd5369b664ff288a31f797c)). - -### Set your Resolver - -Finally you need to instruct the onchain registry to use your resolver. You can do this by visiting your name in the [ENS Manager App](https://ens.app/) and under the `More` tab, set the `Resolver` field to the address of your resolver. - -## Fork this 🍴 -Don't like the implementation? Fork this repo and make it your own! - -You might also be interested in the [resolution logic](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/gateway/resolution.rs) and [database modularity](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/database/mod.rs). - -## Integration - -This gateway implementation is designed to be modular, light, and easy to integrate. It comes with the abstract Datastore idea, (by default implemented with postgres), authentication, simple resolution logic, and a self-service API. - -This means that depending on your use case you can easily swap out the database, the resolution logic, and customize authentication. - -### Issuing a name - -To issue a name from an trusted server, you can simply `POST` to `example.com/update` with a JSON body such as - -```json -{ - "name": "luc.willbreak.eth", - "records": { - "name": "Luc", - "text": "hello world", - "avatar": "https://avatars.githubusercontent.com/u/11744586?v=4", - }, - "addresses": { - "60": "0x225f137127d9067788314bc7fcc1f36746a3c3B5" - }, - "auth": "yes" -} -``` - -In a similar fashion users could self-service their names by using this api endpoint and custom authentication logic. - -### Viewing a name - -In events were our app might not have access to ethereum specific tooling, we can use the `GET` endpoint `example.com/view/luc.willbreak.eth` to view the data of a name. This endpoint can be helpful for showing profile editing pages and more. diff --git a/.env.example b/examples/full/.env.example similarity index 100% rename from .env.example rename to examples/full/.env.example diff --git a/.gitignore b/examples/full/.gitignore similarity index 100% rename from .gitignore rename to examples/full/.gitignore diff --git a/Cargo.lock b/examples/full/Cargo.lock similarity index 100% rename from Cargo.lock rename to examples/full/Cargo.lock diff --git a/Cargo.toml b/examples/full/Cargo.toml similarity index 100% rename from Cargo.toml rename to examples/full/Cargo.toml diff --git a/Dockerfile b/examples/full/Dockerfile similarity index 100% rename from Dockerfile rename to examples/full/Dockerfile diff --git a/examples/full/README.md b/examples/full/README.md new file mode 100644 index 0000000..01d846d --- /dev/null +++ b/examples/full/README.md @@ -0,0 +1,80 @@ +# Offchain Gateway (Rust) + +> [!WARNING] +> This repository is under construction 🚧. We are actively improving it hackathon-style. + +This is a Rust implementation of the [CCIP gateway](https://alpha-docs.ens.domains/resolvers/ccip). It allows you to issue unlimited gasless subdomains for your name, as well as to create, manage, and moderate namespaces. + +> [!NOTE] +> This gateway is built to be an **Opinionated ENS Subname Issuer**, if youre looking for something more generic, please checkout [ensdomains/offchain-resolver](https://github.com/ensdomains/offchain-resolver), and [ensdomains/offchain-resolver-example](https://github.com/ensdomains/offchain-resolver-example). + +## Features + +- CCIP Spec Compliant Gateway Endpoint +- `postgres` - Transparent Database backend. +- `self-service` - Authentication-based updating records. +- `eoa-self-service` - EOA-based Authentication. (TODO) +- Modular authentication for EOA, Admin API, & more. +- View endpoint for profile data. + +## Setup + +### Run the gateway +The gateway is just a docker container / standalone binary. You can run it with docker-compose or just run the binary. + +```yaml +cargo run +``` + +### Deploy a Resolver + +Using a CCIP Gateway requires a resolver contract to be acting on behalf of the name. Although you could write your own contract, we recommend you deploy a proxy contract through [ccip.tools](https://ccip.tools/). + +[![](.github/ccip-tools.png)](https://ccip.tools/) + +(Source for the contracts can be found at [ensdomains/ccip-tools](https://github.com/ensdomains/ccip-tools/tree/master/contracts)) + +When asked for the `Gateway URL` supply your gateway's url (for eg: `https://gateway.example.com/{sender}.json`), and for the `Signers` field supply the address of your gateway (for eg: `[0x225f137127d9067788314bc7fcc1f36746a3c3B5]`), you can find this in the logs of your gateway. + +> [!NOTE] +> There are gas costs associated with deploying a resolver, at the time of writing this (30 gwei), it costs ~0.004 ETH (8 USD) to deploy a resolver (see [txs](https://etherscan.io/tx/0x0c90da0a122f38125a8ad1f48ef23cf5f7d399846bd5369b664ff288a31f797c)). + +### Set your Resolver + +Finally you need to instruct the onchain registry to use your resolver. You can do this by visiting your name in the [ENS Manager App](https://ens.app/) and under the `More` tab, set the `Resolver` field to the address of your resolver. + +## Fork this 🍴 +Don't like the implementation? Fork this repo and make it your own! + +You might also be interested in the [resolution logic](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/gateway/resolution.rs) and [database modularity](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/database/mod.rs). + +## Integration + +This gateway implementation is designed to be modular, light, and easy to integrate. It comes with the abstract Datastore idea, (by default implemented with postgres), authentication, simple resolution logic, and a self-service API. + +This means that depending on your use case you can easily swap out the database, the resolution logic, and customize authentication. + +### Issuing a name + +To issue a name from an trusted server, you can simply `POST` to `example.com/update` with a JSON body such as + +```json +{ + "name": "luc.willbreak.eth", + "records": { + "name": "Luc", + "text": "hello world", + "avatar": "https://avatars.githubusercontent.com/u/11744586?v=4", + }, + "addresses": { + "60": "0x225f137127d9067788314bc7fcc1f36746a3c3B5" + }, + "auth": "yes" +} +``` + +In a similar fashion users could self-service their names by using this api endpoint and custom authentication logic. + +### Viewing a name + +In events were our app might not have access to ethereum specific tooling, we can use the `GET` endpoint `example.com/view/luc.willbreak.eth` to view the data of a name. This endpoint can be helpful for showing profile editing pages and more. diff --git a/docker-compose.yaml b/examples/full/docker-compose.yaml similarity index 100% rename from docker-compose.yaml rename to examples/full/docker-compose.yaml diff --git a/src/ccip/lookup/mod.rs b/examples/full/src/ccip/lookup/mod.rs similarity index 100% rename from src/ccip/lookup/mod.rs rename to examples/full/src/ccip/lookup/mod.rs diff --git a/src/ccip/mod.rs b/examples/full/src/ccip/mod.rs similarity index 100% rename from src/ccip/mod.rs rename to examples/full/src/ccip/mod.rs diff --git a/src/database/mod.rs b/examples/full/src/database/mod.rs similarity index 100% rename from src/database/mod.rs rename to examples/full/src/database/mod.rs diff --git a/src/gateway/endpoint.rs b/examples/full/src/gateway/endpoint.rs similarity index 100% rename from src/gateway/endpoint.rs rename to examples/full/src/gateway/endpoint.rs diff --git a/src/gateway/mod.rs b/examples/full/src/gateway/mod.rs similarity index 100% rename from src/gateway/mod.rs rename to examples/full/src/gateway/mod.rs diff --git a/src/gateway/payload.rs b/examples/full/src/gateway/payload.rs similarity index 100% rename from src/gateway/payload.rs rename to examples/full/src/gateway/payload.rs diff --git a/src/gateway/resolution.rs b/examples/full/src/gateway/resolution.rs similarity index 100% rename from src/gateway/resolution.rs rename to examples/full/src/gateway/resolution.rs diff --git a/src/gateway/response.rs b/examples/full/src/gateway/response.rs similarity index 100% rename from src/gateway/response.rs rename to examples/full/src/gateway/response.rs diff --git a/src/gateway/signing.rs b/examples/full/src/gateway/signing.rs similarity index 100% rename from src/gateway/signing.rs rename to examples/full/src/gateway/signing.rs diff --git a/src/http.rs b/examples/full/src/http.rs similarity index 100% rename from src/http.rs rename to examples/full/src/http.rs diff --git a/src/main.rs b/examples/full/src/main.rs similarity index 100% rename from src/main.rs rename to examples/full/src/main.rs diff --git a/src/multicoin/cointype/coins.rs b/examples/full/src/multicoin/cointype/coins.rs similarity index 100% rename from src/multicoin/cointype/coins.rs rename to examples/full/src/multicoin/cointype/coins.rs diff --git a/src/multicoin/cointype/mod.rs b/examples/full/src/multicoin/cointype/mod.rs similarity index 100% rename from src/multicoin/cointype/mod.rs rename to examples/full/src/multicoin/cointype/mod.rs diff --git a/src/multicoin/cointype/slip44.rs b/examples/full/src/multicoin/cointype/slip44.rs similarity index 100% rename from src/multicoin/cointype/slip44.rs rename to examples/full/src/multicoin/cointype/slip44.rs diff --git a/src/multicoin/encoding/binance.rs b/examples/full/src/multicoin/encoding/binance.rs similarity index 100% rename from src/multicoin/encoding/binance.rs rename to examples/full/src/multicoin/encoding/binance.rs diff --git a/src/multicoin/encoding/bitcoin.rs b/examples/full/src/multicoin/encoding/bitcoin.rs similarity index 100% rename from src/multicoin/encoding/bitcoin.rs rename to examples/full/src/multicoin/encoding/bitcoin.rs diff --git a/src/multicoin/encoding/cardano.rs b/examples/full/src/multicoin/encoding/cardano.rs similarity index 100% rename from src/multicoin/encoding/cardano.rs rename to examples/full/src/multicoin/encoding/cardano.rs diff --git a/src/multicoin/encoding/checksum_address.rs b/examples/full/src/multicoin/encoding/checksum_address.rs similarity index 100% rename from src/multicoin/encoding/checksum_address.rs rename to examples/full/src/multicoin/encoding/checksum_address.rs diff --git a/src/multicoin/encoding/hedera.rs b/examples/full/src/multicoin/encoding/hedera.rs similarity index 100% rename from src/multicoin/encoding/hedera.rs rename to examples/full/src/multicoin/encoding/hedera.rs diff --git a/src/multicoin/encoding/mod.rs b/examples/full/src/multicoin/encoding/mod.rs similarity index 100% rename from src/multicoin/encoding/mod.rs rename to examples/full/src/multicoin/encoding/mod.rs diff --git a/src/multicoin/encoding/p2pkh.rs b/examples/full/src/multicoin/encoding/p2pkh.rs similarity index 100% rename from src/multicoin/encoding/p2pkh.rs rename to examples/full/src/multicoin/encoding/p2pkh.rs diff --git a/src/multicoin/encoding/p2sh.rs b/examples/full/src/multicoin/encoding/p2sh.rs similarity index 100% rename from src/multicoin/encoding/p2sh.rs rename to examples/full/src/multicoin/encoding/p2sh.rs diff --git a/src/multicoin/encoding/polkadot.rs b/examples/full/src/multicoin/encoding/polkadot.rs similarity index 100% rename from src/multicoin/encoding/polkadot.rs rename to examples/full/src/multicoin/encoding/polkadot.rs diff --git a/src/multicoin/encoding/ripple.rs b/examples/full/src/multicoin/encoding/ripple.rs similarity index 100% rename from src/multicoin/encoding/ripple.rs rename to examples/full/src/multicoin/encoding/ripple.rs diff --git a/src/multicoin/encoding/segwit.rs b/examples/full/src/multicoin/encoding/segwit.rs similarity index 100% rename from src/multicoin/encoding/segwit.rs rename to examples/full/src/multicoin/encoding/segwit.rs diff --git a/src/multicoin/encoding/solana.rs b/examples/full/src/multicoin/encoding/solana.rs similarity index 100% rename from src/multicoin/encoding/solana.rs rename to examples/full/src/multicoin/encoding/solana.rs diff --git a/src/multicoin/encoding/stellar.rs b/examples/full/src/multicoin/encoding/stellar.rs similarity index 100% rename from src/multicoin/encoding/stellar.rs rename to examples/full/src/multicoin/encoding/stellar.rs diff --git a/src/multicoin/mod.rs b/examples/full/src/multicoin/mod.rs similarity index 100% rename from src/multicoin/mod.rs rename to examples/full/src/multicoin/mod.rs diff --git a/src/selfservice/endpoint.rs b/examples/full/src/selfservice/endpoint.rs similarity index 100% rename from src/selfservice/endpoint.rs rename to examples/full/src/selfservice/endpoint.rs diff --git a/src/selfservice/mod.rs b/examples/full/src/selfservice/mod.rs similarity index 100% rename from src/selfservice/mod.rs rename to examples/full/src/selfservice/mod.rs diff --git a/src/selfservice/view.rs b/examples/full/src/selfservice/view.rs similarity index 100% rename from src/selfservice/view.rs rename to examples/full/src/selfservice/view.rs diff --git a/src/state.rs b/examples/full/src/state.rs similarity index 100% rename from src/state.rs rename to examples/full/src/state.rs diff --git a/src/utils/axum_json.rs b/examples/full/src/utils/axum_json.rs similarity index 100% rename from src/utils/axum_json.rs rename to examples/full/src/utils/axum_json.rs diff --git a/src/utils/dns.rs b/examples/full/src/utils/dns.rs similarity index 100% rename from src/utils/dns.rs rename to examples/full/src/utils/dns.rs diff --git a/src/utils/mod.rs b/examples/full/src/utils/mod.rs similarity index 100% rename from src/utils/mod.rs rename to examples/full/src/utils/mod.rs diff --git a/src/utils/sha256.rs b/examples/full/src/utils/sha256.rs similarity index 100% rename from src/utils/sha256.rs rename to examples/full/src/utils/sha256.rs