Skip to content

Commit

Permalink
Merge pull request #53 from holaplex/mpw/colored-codeblocks
Browse files Browse the repository at this point in the history
syntax highlighting for codeblocks
  • Loading branch information
mpwsh authored Aug 4, 2023
2 parents def6aae + af4b986 commit bf7bece
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 76 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This command generates static content into the `build` directory and can be serv

Retrieve the most recent version of the GraphQL schema and generate documentation pages for the "API Reference."

```
```bash
$ yarn run graphql-to-doc
```

Expand Down
40 changes: 27 additions & 13 deletions docs/hub/Guides/creating-a-customer-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ In this guide, we'll walk you through the process of creating a customer and a w
- Hub API Playground: [https://api.holaplex.com](https://api.holaplex.com/). You could also use a GraphQL client such as [Apollo Client](https://www.apollographql.com/client/) or a tool like [GraphQL Playground](https://github.com/graphql/graphql-playground)

For all API requests to Hub, you'll need to include an authentication header of the form
```
{
"Authorization": "<access-token>"
}

```json
{
"Authorization": "<access-token>"
}
```

## Step 1: Create a Customer

The first step is creating a customer associated to a project in Hub. To do this, you need to send a `createCustomer` mutation with the required input parameters.

#### Mutation

```graphql
mutation CreateCustomer($input: CreateCustomerInput!) {
createCustomer(input: $input) {
Expand All @@ -35,6 +37,7 @@ mutation CreateCustomer($input: CreateCustomerInput!) {
```

#### Variables

```json
{
"input": {
Expand All @@ -46,9 +49,11 @@ mutation CreateCustomer($input: CreateCustomerInput!) {
The `project-id` can be found in Hub, by clicking the menu button next to the project name.

#### Example Curl Request
```

```bash
curl 'https://api.holaplex.com/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: file://' -H 'Authorization: ACCESS-TOKEN' --data-binary '{"query":"mutation CreateCustomer($input: CreateCustomerInput!) {\n createCustomer(input: $input) {\n customer {\n id\n }\n }\n}\n","variables":{"input":{"project":"PROJECT-ID"}}}' --compressed
```

Replace `ACCESS-TOKEN` and `PROJECT-ID`

### Response
Expand All @@ -70,6 +75,7 @@ Replace `ACCESS-TOKEN` and `PROJECT-ID`
After creating a customer, the next step is to create a wallet for that customer using the `createCustomerWallet` mutation. Note that creating a wallet will use credits.

#### Mutation

```graphql
mutation CreateCustomerWallet($input: CreateCustomerWalletInput!) {
createCustomerWallet(input: $input) {
Expand All @@ -81,6 +87,7 @@ mutation CreateCustomerWallet($input: CreateCustomerWalletInput!) {
```

#### Variables

```json
{
"input": {
Expand All @@ -89,12 +96,15 @@ mutation CreateCustomerWallet($input: CreateCustomerWalletInput!) {
}
}
```

Check out the list of supported asset types on the [enums documentation](../../api/enums/asset-type.mdx). We currently support `"assetType": "SOL"`.

#### Example Curl Request
```

```bash
curl 'https://api.holaplex.com/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: file://' -H 'Authorization: ACCESS-TOKEN' --data-binary '{"query":"mutation CreateCustomerWallet($input: CreateCustomerWalletInput!) {\n createCustomerWallet(input: $input) {\n wallet {\n address\n }\n }\n}","variables":{"input":{"customer":"CUSTOMER-ID","assetType":"SOL"}}}' --compressed
```

Replace `ACCESS-TOKEN` and `CUSTOMER-ID`

### Response
Expand All @@ -112,24 +122,28 @@ Replace `ACCESS-TOKEN` and `CUSTOMER-ID`
```

After completing these two steps, you will have successfully created a wallet for the customer in Holaplex Hub.
The wallet address can be used for minting NFTs, trading, and other wallet-related operations.
The wallet address can be used for minting NFTs, trading, and other wallet-related operations.
Customers and wallets can be viewed on the project page in Hub.

Note to find a customer's wallet address, perform the following query, e.g.:
```

```graphql
{
project(id:"a56e7745-37a2-40b7-9d25-d5c20b6fc137") {
name
customer(id:"33dedde4-543d-4653-bc10-db0a38e719cc") {
project(id: "a56e7745-37a2-40b7-9d25-d5c20b6fc137") {
name
customer(id: "33dedde4-543d-4653-bc10-db0a38e719cc") {
wallet {
address
}
}
}
}
```

CURL:
```

```bash
curl 'https://api.holaplex.com/graphql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: file://' -H 'Authorization: ACCESS-TOKEN' --data-binary '{"query":"{\n project(id:\"PROJECT-ID\") {\n\t\tname\n customer(id:\"CUSTOMER-ID\") {\n wallet {\n address\n }\n }\n }\n}"}' --compressed
```
Replace `ACCESS-TOKEN`, `PROJECT-ID`, and `CUSTOMER-ID`

Replace `ACCESS-TOKEN`, `PROJECT-ID`, and `CUSTOMER-ID`
88 changes: 36 additions & 52 deletions docs/hub/Guides/hosting-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
sidebar_position: 7
---

Hosting Locally
===============
# Hosting Locally

Overview
========
# Overview

In this guide, we are going to locally host this repository [](https://github.com/holaplex/eluvio-sxsw)<https://github.com/holaplex/eluvio-sxsw> and in the process, we'll learn how a complete application using Hub can be run locally, so that you can tinker around with the various parts and test how everything works.

Expand All @@ -20,19 +18,15 @@ Before we get started, log into Hub and create a project and a few drops inside

Let's begin.

Table of Contents
-----------------
## Table of Contents

1. Installation
2. Usage
3. Setting Up Google SSO
4. Setting Up ngrok for Webhooks
5. Configuration



Setting Up Google SSO
---------------------
## Setting Up Google SSO

To set up Single Sign-On (SSO) with Google, follow these steps:

Expand All @@ -45,8 +39,7 @@ To set up Single Sign-On (SSO) with Google, follow these steps:
7. Set the "Authorized redirect URIs" field to `http://localhost:3000/api/auth/callback/google`.
8. Click "Create" to generate your `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`.

Setting Up Ngrok for Webhooks
-----------------------------
## Setting Up Ngrok for Webhooks

To test webhooks locally, you can use [ngrok](https://ngrok.com/) to expose your local server to the internet.

Expand All @@ -61,8 +54,7 @@ To test webhooks locally, you can use [ngrok](https://ngrok.com/) to expose

3. Copy Forwarding URL provided by ngrok (e.g., `https://yoursubdomain.ngrok.io`or `yoursubdomain.ngrok-free.app`)

Creating Webhooks
-----------------
## Creating Webhooks

1. Log into Hub and navigate to the Webhooks section
2. Click on the "Add Webhook" button.
Expand All @@ -72,40 +64,38 @@ Creating Webhooks
6. Choose the Events for the webhook namely, "Customer created", "Customer treasury created", "Customer wallet created", "Drop created" & "Drop minted".
7. The webhook secret key should be copied and pasted in your `.env` file.
Configuration
------------
## Configuration
Create a `.env` file at the root of the project and add the following environment variables:
```
NEXT_PUBLIC_FQDN=http://localhost:3000
# Set up SSO with Google
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# Database
DATABASE_URL=postgres://postgres:holaplex@localhost:5432/hub-starter
POSTGRES_DB=hub-starter
POSTGRES_PASSWORD=holaplex
# Holaplex
HOLAPLEX_API_ENDPOINT=your_holaplex_api_endpoint
HOLAPLEX_AUTH_TOKEN=your_holaplex_auth_token
HOLAPLEX_WEBHOOK_SECRET=your_holaplex_webhook_secret
HOLAPLEX_PROJECT_ID=your_holaplex_project_id
NEXT_PUBLIC_FQDN=http://localhost:3000
```
```bash
NEXT_PUBLIC_FQDN=http://localhost:3000
# Set up SSO with Google
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# Database
DATABASE_URL=postgres://postgres:holaplex@localhost:5432/hub-starter
POSTGRES_DB=hub-starter
POSTGRES_PASSWORD=holaplex
# Holaplex
HOLAPLEX_API_ENDPOINT=your_holaplex_api_endpoint
HOLAPLEX_AUTH_TOKEN=your_holaplex_auth_token
HOLAPLEX_WEBHOOK_SECRET=your_holaplex_webhook_secret
HOLAPLEX_PROJECT_ID=your_holaplex_project_id
NEXT_PUBLIC_FQDN=http://localhost:3000
```
Replace the placeholder values with your actual credentials and API keys. The `HOLAPLEX_AUTH_TOKEN` can be created in the Hub, in the Organization's "Credentials" section.

Your `HOLAPLEX_PROJECT_ID` refers to the numbers & letters you see in the url bar after /projects/.
Your `HOLAPLEX_PROJECT_ID` refers to the numbers & letters you see in the url bar after /projects/.
In the same way, you can navigate to each of your drops by the copying the part of the url after the /drops/ section & and pasting it after localhost.

Adding the drop id after the [localhost:3000/](http://localhost:3000/) url should bring you to the relevant drops page from where you'll be able to mint your NFT.
Installation
------------
## Installation
1. **Ensure you have Node.js and Docker installed on your workstation.**
Expand All @@ -114,51 +104,45 @@ Installation
```bash
git clone <https://github.com/holaplex/eluvio-sxsw>
cd eluvio-sxsw
```
4. **Start PostgreSQL in a Docker container:**
3. **Start PostgreSQL in a Docker container:**
```bash
docker compose up -d
```
5. **Install dependencies:**
4. **Install dependencies:**
```bash
npm install
```
6. **Set up the database:**
5. **Set up the database:**
```bash
npm run reset
```
7. **Set up Prisma client:**
6. **Set up Prisma client:**
```bash
npm run generate
```
Usage
-----
## Usage
After completing the installation steps, you can run the application using the following command:
```bash
npm run dev
```
You can access the application at [](http://localhost:3000/)<http://localhost:3000>.
At any point if things don't work, reset the database, generate the client and try again:
```

```bash
npm run reset
npm run generate
```
```
23 changes: 13 additions & 10 deletions docs/hub/Guides/transfer-out-of-hub-wallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ In this guide, we'll use Hub API to transfer a Hub-minted token out of a Hub wal
- A token minted out of a drop within [Holaplex Hub](https://hub.holaplex.com/) or via Hub API
- Access to the Holaplex Hub GraphQL API (an access token can be generated on Hub's "Credentials" page)
- Hub API Playground: [https://api.holaplex.com](https://api.holaplex.com/). You could also use a GraphQL client such as [Apollo Client](https://www.apollographql.com/client/) or a tool like [GraphQL Playground](https://github.com/graphql/graphql-playground)
-
-

For all API requests to Hub, you'll need to include an authentication header of the form
```
{
"Authorization": "<access-token>"
}

```json
{
"Authorization": "<access-token>"
}
```

The first step is creating a customer associated to a project in Hub. To do this, you need to send a `createCustomer` mutation with the required input parameters.

## Mutation

```graphql
mutation TransferAsset($input:TransferAssetInput!) {
transferAsset(input:$input) {
mutation TransferAsset($input: TransferAssetInput!) {
transferAsset(input: $input) {
mint {
id
address
Expand All @@ -35,11 +37,12 @@ mutation TransferAsset($input:TransferAssetInput!) {
```

### Variables

```json
{
"input": {
"id": "<mint-id>",
"recipient":"<destination-wallet-address>"
"recipient": "<destination-wallet-address>"
}
}
```
Expand All @@ -52,11 +55,11 @@ mutation TransferAsset($input:TransferAssetInput!) {
"transferAsset": {
"mint": {
"id": "<mint-id>",
"address": "<token-address>",
"address": "<token-address>"
}
}
}
}
```

Note that the API only supports transfering an NFT out of a Hub wallet. If a transfer is requested from an external wallet (even if the token was minted by Hub), Hub will return an error.
Note that the API only supports transfering an NFT out of a Hub wallet. If a transfer is requested from an external wallet (even if the token was minted by Hub), Hub will return an error.

0 comments on commit bf7bece

Please sign in to comment.