From adef7e0c8cb1b3c81fe199f45dc7dca31d1712be Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Tue, 17 Dec 2024 15:59:14 +0100 Subject: [PATCH] Minor cleanups (#3045) * Deduplicate wait_for_next_round. * Remove unused WorkerError::MissingExecutedBlockInProposal. * Make debug logs in Project::create_new consistently uppercase. * Use consistent GraphQL indentation in READMEs. --- examples/amm/README.md | 72 ++++++++++++------------- examples/amm/src/lib.rs | 72 ++++++++++++------------- examples/counter/README.md | 12 ++--- examples/counter/src/lib.rs | 12 ++--- examples/crowd-funding/README.md | 14 ++--- examples/crowd-funding/src/lib.rs | 14 ++--- examples/fungible/README.md | 82 ++++++++++++++--------------- examples/fungible/src/lib.rs | 82 ++++++++++++++--------------- examples/gen-nft/README.md | 58 ++++++++++---------- examples/gen-nft/src/lib.rs | 58 ++++++++++---------- examples/matching-engine/README.md | 58 ++++++++++---------- examples/matching-engine/src/lib.rs | 58 ++++++++++---------- examples/native-fungible/README.md | 82 ++++++++++++++--------------- examples/native-fungible/src/lib.rs | 82 ++++++++++++++--------------- examples/non-fungible/README.md | 74 +++++++++++++------------- examples/non-fungible/src/lib.rs | 74 +++++++++++++------------- examples/social/README.md | 34 ++++++------ examples/social/src/lib.rs | 34 ++++++------ linera-core/src/worker.rs | 2 - linera-service/src/node_service.rs | 39 +++----------- linera-service/src/project.rs | 14 ++--- 21 files changed, 501 insertions(+), 526 deletions(-) diff --git a/examples/amm/README.md b/examples/amm/README.md index 011faf4752b..a939a898e24 100644 --- a/examples/amm/README.md +++ b/examples/amm/README.md @@ -107,31 +107,31 @@ To properly setup the tokens in the proper chains, we need to do some transfer o of the GraphiQL interface for the FUN1 app. Navigate to that URL and enter: ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN1_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_1", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_1", } + ) +} ``` - Transfer 50 FUN1 from `$OWNER_AMM` in `$CHAIN_AMM` to `$OWNER_2` in `$CHAIN_2`, so they're in the proper chain: ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN1_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_2", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_2", } + ) +} ``` - Transfer 50 FUN2 from `$OWNER_AMM` in `$CHAIN_AMM` to `$OWNER_1` in `$CHAIN_1`, so they're in the proper chain. @@ -139,31 +139,31 @@ To properly setup the tokens in the proper chains, we need to do some transfer o `echo "http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN2_APP_ID"`. ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN2_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_1", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_1", } + ) +} ``` - Transfer 50 FUN2 from `$OWNER_AMM` in `$CHAIN_AMM` to `$OWNER_2` in `$CHAIN_2`, so they're in the proper chain: ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN2_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_2", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_2", } + ) +} ``` All operations can only be from a remote chain i.e. other than the chain on which `AMM` is deployed to. diff --git a/examples/amm/src/lib.rs b/examples/amm/src/lib.rs index 29acda0043b..9a155f5e970 100644 --- a/examples/amm/src/lib.rs +++ b/examples/amm/src/lib.rs @@ -111,31 +111,31 @@ To properly setup the tokens in the proper chains, we need to do some transfer o of the GraphiQL interface for the FUN1 app. Navigate to that URL and enter: ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN1_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_1", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_1", } + ) +} ``` - Transfer 50 FUN1 from `$OWNER_AMM` in `$CHAIN_AMM` to `$OWNER_2` in `$CHAIN_2`, so they're in the proper chain: ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN1_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_2", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_2", } + ) +} ``` - Transfer 50 FUN2 from `$OWNER_AMM` in `$CHAIN_AMM` to `$OWNER_1` in `$CHAIN_1`, so they're in the proper chain. @@ -143,31 +143,31 @@ To properly setup the tokens in the proper chains, we need to do some transfer o `echo "http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN2_APP_ID"`. ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN2_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_1", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_1", } + ) +} ``` - Transfer 50 FUN2 from `$OWNER_AMM` in `$CHAIN_AMM` to `$OWNER_2` in `$CHAIN_2`, so they're in the proper chain: ```gql,uri=http://localhost:8080/chains/$CHAIN_AMM/applications/$FUN2_APP_ID - mutation { - transfer( - owner: "User:$OWNER_AMM", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_2", - } - ) +mutation { + transfer( + owner: "User:$OWNER_AMM", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_2", } + ) +} ``` All operations can only be from a remote chain i.e. other than the chain on which `AMM` is deployed to. diff --git a/examples/counter/README.md b/examples/counter/README.md index ab4005e52ad..cb6f8425273 100644 --- a/examples/counter/README.md +++ b/examples/counter/README.md @@ -71,15 +71,15 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - 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 { - value - } +query { + value +} ``` - To increase the value of the counter by 3, perform the `increment` operation. ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID - mutation Increment { - increment(value: 3) - } +mutation Increment { + increment(value: 3) +} ``` - Running the query again would yield `4`. diff --git a/examples/counter/src/lib.rs b/examples/counter/src/lib.rs index ad6dbdab7eb..f4e417f4dd7 100644 --- a/examples/counter/src/lib.rs +++ b/examples/counter/src/lib.rs @@ -75,15 +75,15 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - 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 { - value - } +query { + value +} ``` - To increase the value of the counter by 3, perform the `increment` operation. ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APPLICATION_ID - mutation Increment { - increment(value: 3) - } +mutation Increment { + increment(value: 3) +} ``` - Running the query again would yield `4`. diff --git a/examples/crowd-funding/README.md b/examples/crowd-funding/README.md index 62e4e4ced6d..e2f16d24147 100644 --- a/examples/crowd-funding/README.md +++ b/examples/crowd-funding/README.md @@ -161,7 +161,7 @@ Point your browser to http://localhost:8080, and enter the query: ```gql,uri=http://localhost:8080 query { applications( - chainId: "$CHAIN_0" + chainId: "$CHAIN_0" ) { id link } } ``` @@ -173,8 +173,8 @@ there yet. Request `crowd-funding` from the other chain. As an application ID, u ```gql,uri=http://localhost:8081 mutation { requestApplication( - chainId: "$CHAIN_1" - applicationId: "$APP_ID_1" + chainId: "$CHAIN_1" + applicationId: "$APP_ID_1" ) } ``` @@ -192,8 +192,8 @@ and run the following query: ```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1 mutation { pledge( - owner:"User:$OWNER_0", - amount:"30." + owner:"User:$OWNER_0", + amount:"30." ) } ``` @@ -226,7 +226,7 @@ You can check that the 200 tokens have arrived: ```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0 query { - accounts { entry(key: "User:$OWNER_1") { value } } + accounts { entry(key: "User:$OWNER_1") { value } } } ``` @@ -255,7 +255,7 @@ then check that we have received 110 tokens, in addition to the ```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0 query { - accounts { entry(key: "User:$OWNER_0") { value } } + accounts { entry(key: "User:$OWNER_0") { value } } } ``` diff --git a/examples/crowd-funding/src/lib.rs b/examples/crowd-funding/src/lib.rs index 6a973b4fae4..e292488affc 100644 --- a/examples/crowd-funding/src/lib.rs +++ b/examples/crowd-funding/src/lib.rs @@ -169,7 +169,7 @@ Point your browser to http://localhost:8080, and enter the query: ```gql,uri=http://localhost:8080 query { applications( - chainId: "$CHAIN_0" + chainId: "$CHAIN_0" ) { id link } } ``` @@ -181,8 +181,8 @@ there yet. Request `crowd-funding` from the other chain. As an application ID, u ```gql,uri=http://localhost:8081 mutation { requestApplication( - chainId: "$CHAIN_1" - applicationId: "$APP_ID_1" + chainId: "$CHAIN_1" + applicationId: "$APP_ID_1" ) } ``` @@ -200,8 +200,8 @@ and run the following query: ```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1 mutation { pledge( - owner:"User:$OWNER_0", - amount:"30." + owner:"User:$OWNER_0", + amount:"30." ) } ``` @@ -234,7 +234,7 @@ You can check that the 200 tokens have arrived: ```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0 query { - accounts { entry(key: "User:$OWNER_1") { value } } + accounts { entry(key: "User:$OWNER_1") { value } } } ``` @@ -263,7 +263,7 @@ then check that we have received 110 tokens, in addition to the ```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0 query { - accounts { entry(key: "User:$OWNER_0") { value } } + accounts { entry(key: "User:$OWNER_0") { value } } } ``` */ diff --git a/examples/fungible/README.md b/examples/fungible/README.md index b2af9b49827..c2183d39a15 100644 --- a/examples/fungible/README.md +++ b/examples/fungible/README.md @@ -133,72 +133,72 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To get the current balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the current balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` - To transfer 50 tokens from $OWNER_1 to $OWNER_2 ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - owner: "User:$OWNER_1", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + owner: "User:$OWNER_1", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` - To get the new balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the new balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` ### Using web frontend diff --git a/examples/fungible/src/lib.rs b/examples/fungible/src/lib.rs index 1362b7479aa..a2be3424e40 100644 --- a/examples/fungible/src/lib.rs +++ b/examples/fungible/src/lib.rs @@ -137,72 +137,72 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To get the current balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the current balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` - To transfer 50 tokens from $OWNER_1 to $OWNER_2 ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - owner: "User:$OWNER_1", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + owner: "User:$OWNER_1", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` - To get the new balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the new balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` ### Using web frontend diff --git a/examples/gen-nft/README.md b/examples/gen-nft/README.md index 59f334d6790..844b196e2d4 100644 --- a/examples/gen-nft/README.md +++ b/examples/gen-nft/README.md @@ -90,20 +90,20 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To mint an NFT, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - mint( - minter: "User:$OWNER_1", - prompt: "Hello!" - ) - } +mutation { + mint( + minter: "User:$OWNER_1", + prompt: "Hello!" + ) +} ``` - To check that it's assigned to the owner, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - ownedNfts(owner: "User:$OWNER_1") - } +query { + ownedNfts(owner: "User:$OWNER_1") +} ``` Set the `QUERY_RESULT` variable to have the result returned by the previous query, and `TOKEN_ID` will be properly set for you. @@ -116,37 +116,37 @@ TOKEN_ID=$(echo "$QUERY_RESULT" | jq -r '.ownedNfts[].tokenId') - To check that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nft(tokenId: "$TOKEN_ID") { - tokenId, - owner, - prompt, - minter, - } - } +query { + nft(tokenId: "$TOKEN_ID") { + tokenId, + owner, + prompt, + minter, + } +} ``` - To check everything that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nfts - } +query { + nfts +} ``` - To transfer the NFT to user `$OWNER_2`, still on chain `$CHAIN_1`, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - sourceOwner: "User:$OWNER_1", - tokenId: "$TOKEN_ID", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + sourceOwner: "User:$OWNER_1", + tokenId: "$TOKEN_ID", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` ### Using Web Frontend diff --git a/examples/gen-nft/src/lib.rs b/examples/gen-nft/src/lib.rs index 5db5663b1d4..61fe8440e57 100644 --- a/examples/gen-nft/src/lib.rs +++ b/examples/gen-nft/src/lib.rs @@ -94,20 +94,20 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To mint an NFT, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - mint( - minter: "User:$OWNER_1", - prompt: "Hello!" - ) - } +mutation { + mint( + minter: "User:$OWNER_1", + prompt: "Hello!" + ) +} ``` - To check that it's assigned to the owner, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - ownedNfts(owner: "User:$OWNER_1") - } +query { + ownedNfts(owner: "User:$OWNER_1") +} ``` Set the `QUERY_RESULT` variable to have the result returned by the previous query, and `TOKEN_ID` will be properly set for you. @@ -120,37 +120,37 @@ TOKEN_ID=$(echo "$QUERY_RESULT" | jq -r '.ownedNfts[].tokenId') - To check that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nft(tokenId: "$TOKEN_ID") { - tokenId, - owner, - prompt, - minter, - } - } +query { + nft(tokenId: "$TOKEN_ID") { + tokenId, + owner, + prompt, + minter, + } +} ``` - To check everything that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nfts - } +query { + nfts +} ``` - To transfer the NFT to user `$OWNER_2`, still on chain `$CHAIN_1`, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - sourceOwner: "User:$OWNER_1", - tokenId: "$TOKEN_ID", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + sourceOwner: "User:$OWNER_1", + tokenId: "$TOKEN_ID", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` ### Using Web Frontend diff --git a/examples/matching-engine/README.md b/examples/matching-engine/README.md index e74bf2bf99d..9bd4782cda4 100644 --- a/examples/matching-engine/README.md +++ b/examples/matching-engine/README.md @@ -185,17 +185,17 @@ First, owner 2 should claim their tokens. Navigate to the URL you get by running ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$FUN1_APP_ID mutation { - claim( - sourceAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2", - } - amount: "100.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_3" - } - ) + claim( + sourceAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2", + } + amount: "100.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_3" + } + ) } ``` @@ -203,17 +203,17 @@ And to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_2/a ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$FUN2_APP_ID mutation { - claim( - sourceAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2", - } - amount: "150.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_2" - } - ) + claim( + sourceAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2", + } + amount: "150.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_2" + } + ) } ``` @@ -224,7 +224,7 @@ for 5 FUN2 from owner 1. This leaves 5 FUN2 of owner 2 on chain 1. On the URL yo mutation { executeOrder( order: { - Insert : { + Insert : { owner: "User:$OWNER_2", amount: "2", nature: Ask, @@ -247,13 +247,13 @@ Owner 2 should now get back their tokens, and have 145 FUN2 left. On the URL you ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$FUN2_APP_ID query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } } ``` diff --git a/examples/matching-engine/src/lib.rs b/examples/matching-engine/src/lib.rs index d2db28e4d78..72e854316d4 100644 --- a/examples/matching-engine/src/lib.rs +++ b/examples/matching-engine/src/lib.rs @@ -189,17 +189,17 @@ First, owner 2 should claim their tokens. Navigate to the URL you get by running ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$FUN1_APP_ID mutation { - claim( - sourceAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2", - } - amount: "100.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_3" - } - ) + claim( + sourceAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2", + } + amount: "100.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_3" + } + ) } ``` @@ -207,17 +207,17 @@ And to the URL you get by running `echo "http://localhost:8080/chains/$CHAIN_2/a ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$FUN2_APP_ID mutation { - claim( - sourceAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2", - } - amount: "150.", - targetAccount: { - chainId: "$CHAIN_2", - owner: "User:$OWNER_2" - } - ) + claim( + sourceAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2", + } + amount: "150.", + targetAccount: { + chainId: "$CHAIN_2", + owner: "User:$OWNER_2" + } + ) } ``` @@ -228,7 +228,7 @@ for 5 FUN2 from owner 1. This leaves 5 FUN2 of owner 2 on chain 1. On the URL yo mutation { executeOrder( order: { - Insert : { + Insert : { owner: "User:$OWNER_2", amount: "2", nature: Ask, @@ -251,13 +251,13 @@ Owner 2 should now get back their tokens, and have 145 FUN2 left. On the URL you ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$FUN2_APP_ID query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } } ``` */ diff --git a/examples/native-fungible/README.md b/examples/native-fungible/README.md index 1c9936b0ad2..030614c698a 100644 --- a/examples/native-fungible/README.md +++ b/examples/native-fungible/README.md @@ -74,72 +74,72 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To get the current balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the current balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` - To transfer 50 tokens from $OWNER_1 to $OWNER_2 ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - owner: "User:$OWNER_1", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + owner: "User:$OWNER_1", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` - To get the new balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the new balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` ### Using web frontend diff --git a/examples/native-fungible/src/lib.rs b/examples/native-fungible/src/lib.rs index aef68c0901e..a86f54b3feb 100644 --- a/examples/native-fungible/src/lib.rs +++ b/examples/native-fungible/src/lib.rs @@ -78,72 +78,72 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To get the current balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the current balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` - To transfer 50 tokens from $OWNER_1 to $OWNER_2 ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - owner: "User:$OWNER_1", - amount: "50.", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + owner: "User:$OWNER_1", + amount: "50.", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` - To get the new balance of user $OWNER_1, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_1" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_1" + ) { + value } + } +} ``` - To get the new balance of user $OWNER_2, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - accounts { - entry( - key: "User:$OWNER_2" - ) { - value - } - } +query { + accounts { + entry( + key: "User:$OWNER_2" + ) { + value } + } +} ``` ### Using web frontend diff --git a/examples/non-fungible/README.md b/examples/non-fungible/README.md index 47aae575c90..3904a092c92 100644 --- a/examples/non-fungible/README.md +++ b/examples/non-fungible/README.md @@ -90,12 +90,12 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To publish a blob, run the mutation: ```gql,uri=http://localhost:8080/ - mutation { - publishDataBlob( - chainId: "$CHAIN_1", - bytes: [1, 2, 3, 4] - ) - } +mutation { + publishDataBlob( + chainId: "$CHAIN_1", + bytes: [1, 2, 3, 4] + ) +} ``` Set the `QUERY_RESULT` variable to have the result returned by the previous query, and `BLOB_HASH` will be properly set for you. @@ -109,21 +109,21 @@ BLOB_HASH=$(echo "$QUERY_RESULT" | jq -r '.publishDataBlob') - To mint an NFT, run the mutation: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - mint( - minter: "User:$OWNER_1", - name: "nft1", - blobHash: "$BLOB_HASH", - ) - } +mutation { + mint( + minter: "User:$OWNER_1", + name: "nft1", + blobHash: "$BLOB_HASH", + ) +} ``` - To check that it's assigned to the owner, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - ownedNfts(owner: "User:$OWNER_1") - } +query { + ownedNfts(owner: "User:$OWNER_1") +} ``` Set the `QUERY_RESULT` variable to have the result returned by the previous query, and `TOKEN_ID` will be properly set for you. @@ -136,38 +136,38 @@ TOKEN_ID=$(echo "$QUERY_RESULT" | jq -r '.ownedNfts[].tokenId') - To check that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nft(tokenId: "$TOKEN_ID") { - tokenId, - owner, - name, - minter, - payload - } - } +query { + nft(tokenId: "$TOKEN_ID") { + tokenId, + owner, + name, + minter, + payload + } +} ``` - To check everything that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nfts - } +query { + nfts +} ``` - To transfer the NFT to user `$OWNER_2`, still on chain `$CHAIN_1`, run the mutation: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - sourceOwner: "User:$OWNER_1", - tokenId: "$TOKEN_ID", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + sourceOwner: "User:$OWNER_1", + tokenId: "$TOKEN_ID", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` ### Using Web Frontend diff --git a/examples/non-fungible/src/lib.rs b/examples/non-fungible/src/lib.rs index 2094d545758..ad513a0cf7a 100644 --- a/examples/non-fungible/src/lib.rs +++ b/examples/non-fungible/src/lib.rs @@ -94,12 +94,12 @@ Type each of these in the GraphiQL interface and substitute the env variables wi - To publish a blob, run the mutation: ```gql,uri=http://localhost:8080/ - mutation { - publishDataBlob( - chainId: "$CHAIN_1", - bytes: [1, 2, 3, 4] - ) - } +mutation { + publishDataBlob( + chainId: "$CHAIN_1", + bytes: [1, 2, 3, 4] + ) +} ``` Set the `QUERY_RESULT` variable to have the result returned by the previous query, and `BLOB_HASH` will be properly set for you. @@ -113,21 +113,21 @@ BLOB_HASH=$(echo "$QUERY_RESULT" | jq -r '.publishDataBlob') - To mint an NFT, run the mutation: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - mint( - minter: "User:$OWNER_1", - name: "nft1", - blobHash: "$BLOB_HASH", - ) - } +mutation { + mint( + minter: "User:$OWNER_1", + name: "nft1", + blobHash: "$BLOB_HASH", + ) +} ``` - To check that it's assigned to the owner, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - ownedNfts(owner: "User:$OWNER_1") - } +query { + ownedNfts(owner: "User:$OWNER_1") +} ``` Set the `QUERY_RESULT` variable to have the result returned by the previous query, and `TOKEN_ID` will be properly set for you. @@ -140,38 +140,38 @@ TOKEN_ID=$(echo "$QUERY_RESULT" | jq -r '.ownedNfts[].tokenId') - To check that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nft(tokenId: "$TOKEN_ID") { - tokenId, - owner, - name, - minter, - payload - } - } +query { + nft(tokenId: "$TOKEN_ID") { + tokenId, + owner, + name, + minter, + payload + } +} ``` - To check everything that it's there, run the query: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - query { - nfts - } +query { + nfts +} ``` - To transfer the NFT to user `$OWNER_2`, still on chain `$CHAIN_1`, run the mutation: ```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID - mutation { - transfer( - sourceOwner: "User:$OWNER_1", - tokenId: "$TOKEN_ID", - targetAccount: { - chainId: "$CHAIN_1", - owner: "User:$OWNER_2" - } - ) +mutation { + transfer( + sourceOwner: "User:$OWNER_1", + tokenId: "$TOKEN_ID", + targetAccount: { + chainId: "$CHAIN_1", + owner: "User:$OWNER_2" } + ) +} ``` ### Using Web Frontend diff --git a/examples/social/README.md b/examples/social/README.md index 345d08a2b05..df455b2d750 100644 --- a/examples/social/README.md +++ b/examples/social/README.md @@ -90,10 +90,10 @@ one of the chain where it isn't registered yet: ```gql,uri=http://localhost:8081 mutation { - requestApplication( - chainId: "$CHAIN_1", - applicationId: "$APP_ID" - ) + requestApplication( + chainId: "$CHAIN_1", + applicationId: "$APP_ID" + ) } ``` @@ -102,12 +102,12 @@ application and provide a link to its GraphQL API. Remember to use each wallet's ```gql,uri=http://localhost:8081 query { - applications( - chainId: "$CHAIN_1" - ) { - id - link - } + applications( + chainId: "$CHAIN_1" + ) { + id + link + } } ``` @@ -117,9 +117,9 @@ to print the URL to navigate to, then subscribe to the other chain using the fol ```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID mutation { - subscribe( - chainId: "$CHAIN_2" - ) + subscribe( + chainId: "$CHAIN_2" + ) } ``` @@ -127,10 +127,10 @@ Run `echo "http://localhost:8080/chains/$CHAIN_2/applications/$APP_ID"` to print ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$APP_ID mutation { - post( - text: "Linera Social is the new Mastodon!" - imageUrl: "https://linera.org/img/logo.svg" # optional - ) + post( + text: "Linera Social is the new Mastodon!" + imageUrl: "https://linera.org/img/logo.svg" # optional + ) } ``` diff --git a/examples/social/src/lib.rs b/examples/social/src/lib.rs index defc866c130..557fd0b98e4 100644 --- a/examples/social/src/lib.rs +++ b/examples/social/src/lib.rs @@ -99,10 +99,10 @@ one of the chain where it isn't registered yet: ```gql,uri=http://localhost:8081 mutation { - requestApplication( - chainId: "$CHAIN_1", - applicationId: "$APP_ID" - ) + requestApplication( + chainId: "$CHAIN_1", + applicationId: "$APP_ID" + ) } ``` @@ -111,12 +111,12 @@ application and provide a link to its GraphQL API. Remember to use each wallet's ```gql,uri=http://localhost:8081 query { - applications( - chainId: "$CHAIN_1" - ) { - id - link - } + applications( + chainId: "$CHAIN_1" + ) { + id + link + } } ``` @@ -126,9 +126,9 @@ to print the URL to navigate to, then subscribe to the other chain using the fol ```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID mutation { - subscribe( - chainId: "$CHAIN_2" - ) + subscribe( + chainId: "$CHAIN_2" + ) } ``` @@ -136,10 +136,10 @@ Run `echo "http://localhost:8080/chains/$CHAIN_2/applications/$APP_ID"` to print ```gql,uri=http://localhost:8080/chains/$CHAIN_2/applications/$APP_ID mutation { - post( - text: "Linera Social is the new Mastodon!" - imageUrl: "https://linera.org/img/logo.svg" # optional - ) + post( + text: "Linera Social is the new Mastodon!" + imageUrl: "https://linera.org/img/logo.svg" # optional + ) } ``` diff --git a/linera-core/src/worker.rs b/linera-core/src/worker.rs index ebe04bdaf35..40cb80484fb 100644 --- a/linera-core/src/worker.rs +++ b/linera-core/src/worker.rs @@ -202,8 +202,6 @@ pub enum WorkerError { UnneededBlob { blob_id: BlobId }, #[error("The blobs provided in the proposal were not the published ones, in order.")] WrongBlobsInProposal, - #[error("The certificate in the block proposal is not a ValidatedBlock")] - MissingExecutedBlockInProposal, #[error("Fast blocks cannot query oracles")] FastBlockUsingOracles, #[error("Blobs not found: {0:?}")] diff --git a/linera-service/src/node_service.rs b/linera-service/src/node_service.rs index b19e2eab459..2548512759f 100644 --- a/linera-service/src/node_service.rs +++ b/linera-service/src/node_service.rs @@ -12,16 +12,11 @@ use async_graphql::{ }; use async_graphql_axum::{GraphQLRequest, GraphQLResponse, GraphQLSubscription}; use axum::{extract::Path, http::StatusCode, response, response::IntoResponse, Extension, Router}; -use futures::{ - future::{self}, - lock::Mutex, - Future, -}; +use futures::{lock::Mutex, Future}; use linera_base::{ crypto::{CryptoError, CryptoHash, PublicKey}, data_types::{ - Amount, ApplicationPermissions, BlobBytes, Bytecode, TimeDelta, Timestamp, - UserApplicationDescription, + Amount, ApplicationPermissions, BlobBytes, Bytecode, TimeDelta, UserApplicationDescription, }, identifiers::{ApplicationId, BytecodeId, ChainId, Owner, UserApplicationId}, ownership::{ChainOwnership, TimeoutConfig}, @@ -34,9 +29,8 @@ use linera_chain::{ use linera_client::chain_listener::{ChainListener, ChainListenerConfig, ClientContext}; use linera_core::{ client::{ChainClient, ChainClientError}, - data_types::{ClientOutcome, RoundTimeout}, - node::NotificationStream, - worker::{Notification, Reason}, + data_types::ClientOutcome, + worker::Notification, }; use linera_execution::{ committee::{Committee, Epoch}, @@ -48,7 +42,6 @@ use serde::{Deserialize, Serialize}; use serde_json::json; use thiserror::Error as ThisError; use tokio::sync::OwnedRwLockReadGuard; -use tokio_stream::StreamExt; use tower_http::cors::CorsLayer; use tracing::{debug, error, info, instrument}; @@ -221,7 +214,7 @@ where ClientOutcome::WaitForTimeout(timeout) => timeout, }; drop(client); - wait_for_next_round(&mut stream, timeout).await; + util::wait_for_next_round(&mut stream, timeout).await; } } } @@ -246,7 +239,7 @@ where Some(timestamp) => { let mut stream = client.subscribe().await?; drop(client); - wait_for_next_round(&mut stream, timestamp).await; + util::wait_for_next_round(&mut stream, timestamp).await; } } } @@ -655,7 +648,7 @@ where }; let mut stream = client.subscribe().await?; drop(client); - wait_for_next_round(&mut stream, timeout).await; + util::wait_for_next_round(&mut stream, timeout).await; } } } @@ -1073,7 +1066,7 @@ where let mut stream = client.subscribe().await.map_err(|_| { ChainClientError::InternalError("Could not subscribe to the local node.") })?; - wait_for_next_round(&mut stream, timeout).await; + util::wait_for_next_round(&mut stream, timeout).await; }; Ok(async_graphql::Response::new(hash.to_value())) } @@ -1123,19 +1116,3 @@ where Ok(response.into()) } } - -/// Returns after the specified time or if we receive a notification that a new round has started. -pub async fn wait_for_next_round(stream: &mut NotificationStream, timeout: RoundTimeout) { - let mut stream = stream.filter(|notification| match ¬ification.reason { - Reason::NewBlock { height, .. } => *height >= timeout.next_block_height, - Reason::NewRound { round, .. } => *round > timeout.current_round, - Reason::NewIncomingBundle { .. } => false, - }); - future::select( - Box::pin(stream.next()), - Box::pin(linera_base::time::timer::sleep( - timeout.timestamp.duration_since(Timestamp::now()), - )), - ) - .await; -} diff --git a/linera-service/src/project.rs b/linera-service/src/project.rs index 8e1335157c3..e9047a75334 100644 --- a/linera-service/src/project.rs +++ b/linera-service/src/project.rs @@ -46,25 +46,25 @@ impl Project { debug!("Initializing git repository"); Self::initialize_git_repository(&root)?; - debug!("writing Cargo.toml"); + debug!("Writing Cargo.toml"); Self::create_cargo_toml(&root, name, linera_root)?; - debug!("writing rust-toolchain.toml"); + debug!("Writing rust-toolchain.toml"); Self::create_rust_toolchain(&root)?; - debug!("writing state.rs"); + debug!("Writing state.rs"); Self::create_state_file(&source_directory, name)?; - debug!("writing lib.rs"); + debug!("Writing lib.rs"); Self::create_lib_file(&source_directory, name)?; - debug!("writing contract.rs"); + debug!("Writing contract.rs"); Self::create_contract_file(&source_directory, name)?; - debug!("writing service.rs"); + debug!("Writing service.rs"); Self::create_service_file(&source_directory, name)?; - debug!("writing single_chain.rs"); + debug!("Writing single_chain.rs"); Self::create_test_file(&test_directory, name)?; Ok(Self { root })