Skip to content

Commit

Permalink
Some fixes on README's
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva91 committed Oct 7, 2024
1 parent cf21868 commit c281952
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 128 deletions.
20 changes: 10 additions & 10 deletions examples/amm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mutation {
Note: The above mutation has to be performed from `http://localhost:8080`.

Before performing any operation we need to provide liquidity to it, so we will use the `AddLiquidity` operation,
navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID`.
navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"`.

To perform `AddLiquidity` operation:

Expand All @@ -209,7 +209,7 @@ mutation {

Note: The above mutation has to be performed from `http://localhost:8080`.

To perform `Swap` operation, navigate to `http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID` and
To perform `Swap` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:

```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID
Expand All @@ -222,7 +222,7 @@ mutation {
}
```

To perform the `RemoveLiquidity` operation, navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID` and
To perform the `RemoveLiquidity` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
Expand All @@ -235,7 +235,7 @@ mutation {
}
```

To perform the `RemoveAllAddedLiquidity` operation, navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID` and
To perform the `RemoveAllAddedLiquidity` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
Expand Down Expand Up @@ -275,8 +275,8 @@ linera --wait-for-outgoing-messages change-application-permissions \
linera service --port $PORT &
```

First, let's add some liquidity again to the AMM. Navigate to
`http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID` and perform the following mutation:
First, let's add some liquidity again to the AMM. Navigate to the URL you get by running
`echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"` and perform the following mutation:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
mutation {
Expand All @@ -288,15 +288,15 @@ mutation {
}
```

The only way to close the chain is via the application. Navigate to
`http://localhost:8080/chains/$CHAIN_AMM/applications/$AMM_APPLICATION_ID` and perform the following mutation:
The only way to close the chain is via the application. Navigate to the URL you get by running
`echo "http://localhost:8080/chains/$CHAIN_AMM/applications/$AMM_APPLICATION_ID"` and perform the following mutation:

```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$AMM_APPLICATION_ID
mutation { closeChain }
```

Owner 1 should now get back their tokens, and have around 49 FUN1 left and 51 FUN2 left. To check that, navigate
to `http://localhost:8080/chains/$CHAIN_1/applications/$FUN1_APP_ID`, and perform the following mutation:
to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$FUN1_APP_ID"`, and perform the following mutation:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$FUN1_APP_ID
query {
Expand All @@ -310,7 +310,7 @@ query {
}
```

Then navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$FUN2_APP_ID`, and perform the following mutation:
Then navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$FUN2_APP_ID"`, and perform the following mutation:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$FUN2_APP_ID
query {
Expand Down
20 changes: 10 additions & 10 deletions examples/amm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ mutation {
Note: The above mutation has to be performed from `http://localhost:8080`.
Before performing any operation we need to provide liquidity to it, so we will use the `AddLiquidity` operation,
navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID`.
navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"`.
To perform `AddLiquidity` operation:
Expand All @@ -213,7 +213,7 @@ mutation {
Note: The above mutation has to be performed from `http://localhost:8080`.
To perform `Swap` operation, navigate to `http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID` and
To perform `Swap` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:
```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$AMM_APPLICATION_ID
Expand All @@ -226,7 +226,7 @@ mutation {
}
```
To perform the `RemoveLiquidity` operation, navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID` and
To perform the `RemoveLiquidity` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
Expand All @@ -239,7 +239,7 @@ mutation {
}
```
To perform the `RemoveAllAddedLiquidity` operation, navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID` and
To perform the `RemoveAllAddedLiquidity` operation, navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"` and
perform the following mutation:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
Expand Down Expand Up @@ -279,8 +279,8 @@ linera --wait-for-outgoing-messages change-application-permissions \
linera service --port $PORT &
```
First, let's add some liquidity again to the AMM. Navigate to
`http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID` and perform the following mutation:
First, let's add some liquidity again to the AMM. Navigate to the URL you get by running
`echo "http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID"` and perform the following mutation:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$AMM_APPLICATION_ID
mutation {
Expand All @@ -292,15 +292,15 @@ mutation {
}
```
The only way to close the chain is via the application. Navigate to
`http://localhost:8080/chains/$CHAIN_AMM/applications/$AMM_APPLICATION_ID` and perform the following mutation:
The only way to close the chain is via the application. Navigate to the URL you get by running
`echo "http://localhost:8080/chains/$CHAIN_AMM/applications/$AMM_APPLICATION_ID"` and perform the following mutation:
```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$AMM_APPLICATION_ID
mutation { closeChain }
```
Owner 1 should now get back their tokens, and have around 49 FUN1 left and 51 FUN2 left. To check that, navigate
to `http://localhost:8080/chains/$CHAIN_1/applications/$FUN1_APP_ID`, and perform the following mutation:
to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$FUN1_APP_ID"`, and perform the following mutation:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$FUN1_APP_ID
query {
Expand All @@ -314,7 +314,7 @@ query {
}
```
Then navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$FUN2_APP_ID`, and perform the following mutation:
Then navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$FUN2_APP_ID"`, and perform the following mutation:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$FUN2_APP_ID
query {
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ linera service --port $PORT &

Type each of these in the GraphiQL interface and substitute the env variables with their actual values that we've defined above.

- Navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID`.
- Navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID"`.
- To get the current value of `counter`, run the query:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID
query {
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ linera service --port $PORT &
Type each of these in the GraphiQL interface and substitute the env variables with their actual values that we've defined above.
- Navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID`.
- Navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID"`.
- To get the current value of `counter`, run the query:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID
query {
Expand Down
49 changes: 18 additions & 31 deletions examples/crowd-funding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,11 @@ On both http://localhost:8080 and http://localhost:8081, you recognize the crowd
application by its ID. The entry also has a field `link`. If you open that in a new tab, you
see the GraphQL API for that application on that chain.

Let's pledge 30 tokens by the campaign creator themself, i.e.
[`$OWNER_0` on 8080](http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1):
Let's pledge 30 tokens by the campaign creator themself.
For `$OWNER_0` on 8080, run `echo "http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1"` to get the URL, open it
and run the following query:

Let's give it a variable for testing (for instance with `curl -g -X POST -H "Content-Type: application/json" -d '{ "query": "'$QUERY'" }' $URI | jq -e .data`):

```bash
CAMPAIGN=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
```

```gql,uri=$CAMPAIGN
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
mutation { pledge(
owner:"User:$OWNER_0",
amount:"30."
Expand All @@ -204,20 +199,16 @@ mutation { pledge(

This will make the owner show up if we list everyone who has made a pledge so far:

```gql,uri=$CAMPAIGN
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
query { pledges { keys } }
```

To also have `$OWNER_1` make a pledge, they first need to claim their tokens. Those are still
on the other chain, where the application was created. Find the [link on 8081
for the fungible application](http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0),
open it and run the following query.

```bash
TOKEN1=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
```
on the other chain, where the application was created. To get the link on 8081
for the fungible application, run `echo "http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0"`,
open it and run the following query:

```gql,uri=$TOKEN1
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
mutation { claim(
sourceAccount: {
owner: "User:$OWNER_1",
Expand All @@ -233,21 +224,17 @@ mutation { claim(

You can check that the 200 tokens have arrived:

```gql,uri=$TOKEN1
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
query {
accounts { entry(key: "User:$OWNER_1") { value } }
}
```

Now, also on 8081, you can open the [link for the crowd-funding
application](http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1)
Now, also on 8081, you can open the link for the crowd-funding
application you get when you run `echo "http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1"`
and run:

```bash
PLEDGE1=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1
```

```gql,uri=$PLEDGE1
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1
mutation { pledge(
owner:"User:$OWNER_1",
amount:"80."
Expand All @@ -257,14 +244,14 @@ mutation { pledge(
This pledges another 80 tokens. With 110 pledged in total, we have now reached the campaign
goal. Now the campaign owner (on 8080) can collect the funds:

```gql,uri=$CAMPAIGN
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
mutation { collect }
```

[In the fungible application on
8080](http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0),
check that we have received 110 tokens, in addition to the
70 that we had left after pledging 30:
Get the fungible application on
8080 URL by running `echo "http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0"`,
then check that we have received 110 tokens, in addition to the
70 that we had left after pledging 30 by running the following query:

```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0
query {
Expand Down
49 changes: 18 additions & 31 deletions examples/crowd-funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,11 @@ On both http://localhost:8080 and http://localhost:8081, you recognize the crowd
application by its ID. The entry also has a field `link`. If you open that in a new tab, you
see the GraphQL API for that application on that chain.
Let's pledge 30 tokens by the campaign creator themself, i.e.
[`$OWNER_0` on 8080](http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1):
Let's pledge 30 tokens by the campaign creator themself.
For `$OWNER_0` on 8080, run `echo "http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1"` to get the URL, open it
and run the following query:
Let's give it a variable for testing (for instance with `curl -g -X POST -H "Content-Type: application/json" -d '{ "query": "'$QUERY'" }' $URI | jq -e .data`):
```bash
CAMPAIGN=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
```
```gql,uri=$CAMPAIGN
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
mutation { pledge(
owner:"User:$OWNER_0",
amount:"30."
Expand All @@ -212,20 +207,16 @@ mutation { pledge(
This will make the owner show up if we list everyone who has made a pledge so far:
```gql,uri=$CAMPAIGN
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
query { pledges { keys } }
```
To also have `$OWNER_1` make a pledge, they first need to claim their tokens. Those are still
on the other chain, where the application was created. Find the [link on 8081
for the fungible application](http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0),
open it and run the following query.
```bash
TOKEN1=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
```
on the other chain, where the application was created. To get the link on 8081
for the fungible application, run `echo "http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0"`,
open it and run the following query:
```gql,uri=$TOKEN1
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
mutation { claim(
sourceAccount: {
owner: "User:$OWNER_1",
Expand All @@ -241,21 +232,17 @@ mutation { claim(
You can check that the 200 tokens have arrived:
```gql,uri=$TOKEN1
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
query {
accounts { entry(key: "User:$OWNER_1") { value } }
}
```
Now, also on 8081, you can open the [link for the crowd-funding
application](http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1)
Now, also on 8081, you can open the link for the crowd-funding
application you get when you run `echo "http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1"`
and run:
```bash
PLEDGE1=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1
```
```gql,uri=$PLEDGE1
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1
mutation { pledge(
owner:"User:$OWNER_1",
amount:"80."
Expand All @@ -265,14 +252,14 @@ mutation { pledge(
This pledges another 80 tokens. With 110 pledged in total, we have now reached the campaign
goal. Now the campaign owner (on 8080) can collect the funds:
```gql,uri=$CAMPAIGN
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
mutation { collect }
```
[In the fungible application on
8080](http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0),
check that we have received 110 tokens, in addition to the
70 that we had left after pledging 30:
Get the fungible application on
8080 URL by running `echo "http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0"`,
then check that we have received 110 tokens, in addition to the
70 that we had left after pledging 30 by running the following query:
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0
query {
Expand Down
2 changes: 1 addition & 1 deletion examples/fungible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ linera service --port $PORT &

Type each of these in the GraphiQL interface and substitute the env variables with their actual values that we've defined above.

- Navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID`.
- Navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID"`.
- To get the current balance of user $OWNER_1, run the query:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID
Expand Down
2 changes: 1 addition & 1 deletion examples/fungible/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ linera service --port $PORT &
Type each of these in the GraphiQL interface and substitute the env variables with their actual values that we've defined above.
- Navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID`.
- Navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID"`.
- To get the current balance of user $OWNER_1, run the query:
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID
Expand Down
5 changes: 4 additions & 1 deletion examples/gen-nft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ linera service --port $PORT &

Type each of these in the GraphiQL interface and substitute the env variables with their actual values that we've defined above.

- Navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID`.
- Navigate to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID"`.
- To mint an NFT, run the query:

```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID
Expand All @@ -106,6 +106,9 @@ Type each of these in the GraphiQL interface and substitute the env variables wi
}
```

Set the `QUERY_RESULT` variable to have the result returned by the previous query, and `TOKEN_ID` will be properly set for you.
Alternatively you can set the `TOKEN_ID` variable to the `tokenId` value returned by the previous query yourself.

```bash
TOKEN_ID=$(echo "$QUERY_RESULT" | jq -r '.ownedNfts[].tokenId')
```
Expand Down
Loading

0 comments on commit c281952

Please sign in to comment.