From b369ec2c0a1ad9cdf0046791f5ae8a7d01e40c24 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 27 Jun 2024 01:02:59 +0200 Subject: [PATCH 1/7] fix the realayer for the ibc guides --- docs/docs/02-guide/06-ibc.md | 143 ++++++------------ .../02-guide/07-interchange/03-walkthrough.md | 18 ++- 2 files changed, 63 insertions(+), 98 deletions(-) diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index abddcd9c14..8d59262f17 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -433,26 +433,26 @@ build: proto: path: proto accounts: -- name: alice - coins: - - 1000token - - 100000000stake -- name: bob - coins: - - 500token - - 100000000stake + - name: alice + coins: + - 1000token + - 100000000stake + - name: bob + coins: + - 500token + - 100000000stake faucet: name: bob coins: - - 5token - - 100000stake + - 5token + - 100000stake host: 0.0.0.0:4500 genesis: chain_id: earth validators: -- name: alice - bonded: 100000000stake - home: $HOME/.earth + - name: alice + bonded: 100000000stake + home: $HOME/.earth ``` ```yaml title="mars.yml" @@ -461,39 +461,39 @@ build: proto: path: proto accounts: -- name: alice - coins: - - 1000token - - 1000000000stake -- name: bob - coins: - - 500token - - 100000000stake + - name: alice + coins: + - 1000token + - 1000000000stake + - name: bob + coins: + - 500token + - 100000000stake faucet: name: bob coins: - - 5token - - 100000stake + - 5token + - 100000stake host: :4501 genesis: chain_id: mars validators: -- name: alice - bonded: 100000000stake - app: - api: - address: :1318 - grpc: - address: :9092 - grpc-web: - address: :9093 - config: - p2p: - laddr: :26658 - rpc: - laddr: :26659 - pprof_laddr: :6061 - home: $HOME/.mars + - name: alice + bonded: 100000000stake + app: + api: + address: :1318 + grpc: + address: :9092 + grpc-web: + address: :9093 + config: + p2p: + laddr: :26658 + rpc: + laddr: :26659 + pprof_laddr: :6061 + home: $HOME/.mars ``` Open a terminal window and run the following command to start the `earth` @@ -526,70 +526,27 @@ found` and no action is taken. ### Configure and start the relayer -First, configure the relayer. Use the Ignite CLI `configure` command with the -`--advanced` option: +First, add the Hermes relayer app. ```bash -ignite relayer configure -a \ - --source-rpc "http://0.0.0.0:26657" \ - --source-faucet "http://0.0.0.0:4500" \ - --source-port "blog" \ - --source-version "blog-1" \ - --source-gasprice "0.0000025stake" \ - --source-prefix "cosmos" \ - --source-gaslimit 300000 \ - --target-rpc "http://0.0.0.0:26659" \ - --target-faucet "http://0.0.0.0:4501" \ - --target-port "blog" \ - --target-version "blog-1" \ - --target-gasprice "0.0000025stake" \ - --target-prefix "cosmos" \ - --target-gaslimit 300000 -``` - -When prompted, press Enter to accept the default values for `Source Account` and -`Target Account`. - -The output looks like: - -``` ---------------------------------------------- -Setting up chains ---------------------------------------------- - -🔐 Account on "source" is "cosmos1xcxgzq75yrxzd0tu2kwmwajv7j550dkj7m00za" - - |· received coins from a faucet - |· (balance: 100000stake,5token) - -🔐 Account on "target" is "cosmos1nxg8e4mfp5v7sea6ez23a65rvy0j59kayqr8cx" - - |· received coins from a faucet - |· (balance: 100000stake,5token) - -⛓ Configured chains: earth-mars +ignite app install -g github.com/ignite/apps/hermes ``` -In a new terminal window, start the relayer process: +and after configure the relayer. ```bash -ignite relayer connect +ignite relayer hermes configure \ +"earth-1" "http://localhost:26657" "http://localhost:9090" --chain-a-faucet "http://0.0.0.0:4500" \ +"mars-1" "http://localhost:26659" "http://localhost:9092" --chain-b-faucet "http://0.0.0.0:4501" ``` -Results: - -``` ------- -Paths ------- +When prompted, press Enter to accept the default values for `Chain A Account` and +`Chain B Account`. -earth-mars: - earth > (port: blog) (channel: channel-0) - mars > (port: blog) (channel: channel-0) +Now start the relayer: ------- -Listening and relaying packets between chains... ------- +```bash +ignite relayer hermes start "earth-1" "mars-1" ``` ### Send packets diff --git a/docs/docs/02-guide/07-interchange/03-walkthrough.md b/docs/docs/02-guide/07-interchange/03-walkthrough.md index c6c1caa8d2..72ee8d01e7 100644 --- a/docs/docs/02-guide/07-interchange/03-walkthrough.md +++ b/docs/docs/02-guide/07-interchange/03-walkthrough.md @@ -58,20 +58,28 @@ in the past, reset the relayer configuration directory: rm -rf ~/.ignite/relayer ``` -Now you can use the `ignite relayer configure` command. This command allows you +First, add the Hermes relayer app. + +```bash +ignite app install -g github.com/ignite/apps/hermes +``` + +Now you can use the `ignite relayer hermes configure` command. This command allows you to specify the source and target chains, along with their respective RPC endpoints, faucet URLs, port numbers, versions, gas prices, and gas limits. -``` -ignite relayer configure -a --source-rpc "http://0.0.0.0:26657" --source-faucet "http://0.0.0.0:4500" --source-port "dex" --source-version "dex-1" --source-gasprice "0.0000025stake" --source-prefix "cosmos" --source-gaslimit 300000 --target-rpc "http://0.0.0.0:26659" --target-faucet "http://0.0.0.0:4501" --target-port "dex" --target-version "dex-1" --target-gasprice "0.0000025stake" --target-prefix "cosmos" --target-gaslimit 300000 +```bash +ignite relayer hermes configure \ +"earth-1" "http://localhost:26657" "http://localhost:9090" --chain-a-faucet "http://0.0.0.0:4500" \ +"mars-1" "http://localhost:26659" "http://localhost:9092" --chain-b-faucet "http://0.0.0.0:4501" ``` To create a connection between the two chains, you can use the ignite relayer connect command. This command will establish a connection between the source and target chains, allowing you to transfer data and assets between them. -``` -ignite relayer connect +```bash +ignite relayer hermes start "earth-1" "mars-1" ``` Now that we have two separate blockchain networks up and running, and a relayer From 03cbb75798a8320a58fea81e9a9f5c5ddb2683c9 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 27 Jun 2024 11:50:17 +0200 Subject: [PATCH 2/7] fix chain-id --- docs/docs/02-guide/06-ibc.md | 104 +++++++++++------- .../02-guide/07-interchange/03-walkthrough.md | 8 +- 2 files changed, 67 insertions(+), 45 deletions(-) diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index 8d59262f17..92dba0b159 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -433,26 +433,26 @@ build: proto: path: proto accounts: - - name: alice - coins: - - 1000token - - 100000000stake - - name: bob - coins: - - 500token - - 100000000stake +- name: alice + coins: + - 1000token + - 100000000stake +- name: bob + coins: + - 500token + - 100000000stake faucet: name: bob coins: - - 5token - - 100000stake + - 5token + - 100000stake host: 0.0.0.0:4500 genesis: chain_id: earth validators: - - name: alice - bonded: 100000000stake - home: $HOME/.earth +- name: alice + bonded: 100000000stake + home: $HOME/.earth ``` ```yaml title="mars.yml" @@ -461,39 +461,39 @@ build: proto: path: proto accounts: - - name: alice - coins: - - 1000token - - 1000000000stake - - name: bob - coins: - - 500token - - 100000000stake +- name: alice + coins: + - 1000token + - 1000000000stake +- name: bob + coins: + - 500token + - 100000000stake faucet: name: bob coins: - - 5token - - 100000stake + - 5token + - 100000stake host: :4501 genesis: chain_id: mars validators: - - name: alice - bonded: 100000000stake - app: - api: - address: :1318 - grpc: - address: :9092 - grpc-web: - address: :9093 - config: - p2p: - laddr: :26658 - rpc: - laddr: :26659 - pprof_laddr: :6061 - home: $HOME/.mars +- name: alice + bonded: 100000000stake + app: + api: + address: :1318 + grpc: + address: :9092 + grpc-web: + address: :9093 + config: + p2p: + laddr: :26658 + rpc: + laddr: :26659 + pprof_laddr: :6061 + home: $HOME/.mars ``` Open a terminal window and run the following command to start the `earth` @@ -536,17 +536,37 @@ and after configure the relayer. ```bash ignite relayer hermes configure \ -"earth-1" "http://localhost:26657" "http://localhost:9090" --chain-a-faucet "http://0.0.0.0:4500" \ -"mars-1" "http://localhost:26659" "http://localhost:9092" --chain-b-faucet "http://0.0.0.0:4501" +"earth" "http://localhost:26657" "http://localhost:9090" \ +"mars" "http://localhost:26659" "http://localhost:9092" \ +--chain-a-faucet "http://0.0.0.0:4500" \ +--chain-b-faucet "http://0.0.0.0:4501" ``` When prompted, press Enter to accept the default values for `Chain A Account` and `Chain B Account`. +The output looks like: + +``` +Hermes config created at ~/.ignite/relayer/hermes/earth_mars +? Chain earth doesn't have a default Hermes key. Type your mnemonic to continue or type enter to generate a new one: (optional) +New mnemonic generated: +Chain earth key created +Chain earth relayer wallet: cosmos1qzls22j2ym2q442pducl4dhjrtyt9w9jd9fewu +? Chain mars doesn't have a default Hermes key. Type your mnemonic to continue or type enter to generate a new one: (optional) +New mnemonic generated: +Chain mars key created +Chain mars relayer wallet: cosmos1x6y0raeqjuctcxglxrc8rstqlmmd43ucwqx2es +Client '07-tendermint-0' created (earth -> mars) +Client 07-tendermint-0' created (mars -> earth) +Connection 'earth (connection-0) <-> mars (connection-0)' created +Channel 'earth (channel-0) <-> mars (channel-0)' created +``` + Now start the relayer: ```bash -ignite relayer hermes start "earth-1" "mars-1" +ignite relayer hermes start "earth" "mars" ``` ### Send packets diff --git a/docs/docs/02-guide/07-interchange/03-walkthrough.md b/docs/docs/02-guide/07-interchange/03-walkthrough.md index 72ee8d01e7..fcb32070bf 100644 --- a/docs/docs/02-guide/07-interchange/03-walkthrough.md +++ b/docs/docs/02-guide/07-interchange/03-walkthrough.md @@ -70,8 +70,10 @@ endpoints, faucet URLs, port numbers, versions, gas prices, and gas limits. ```bash ignite relayer hermes configure \ -"earth-1" "http://localhost:26657" "http://localhost:9090" --chain-a-faucet "http://0.0.0.0:4500" \ -"mars-1" "http://localhost:26659" "http://localhost:9092" --chain-b-faucet "http://0.0.0.0:4501" +"earth" "http://localhost:26657" "http://localhost:9090" \ +"mars" "http://localhost:26659" "http://localhost:9092" \ +--chain-a-faucet "http://0.0.0.0:4500" \ +--chain-b-faucet "http://0.0.0.0:4501" ``` To create a connection between the two chains, you can use the ignite relayer @@ -79,7 +81,7 @@ connect command. This command will establish a connection between the source and target chains, allowing you to transfer data and assets between them. ```bash -ignite relayer hermes start "earth-1" "mars-1" +ignite relayer hermes start "earth" "mars" ``` Now that we have two separate blockchain networks up and running, and a relayer From 887f0a9cc79494bf740d90da22009d1a639f41c1 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 27 Jun 2024 12:59:31 +0200 Subject: [PATCH 3/7] fix port-id for ibc transfers --- docs/docs/02-guide/06-ibc.md | 14 +++---- .../02-guide/07-interchange/03-walkthrough.md | 42 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index 92dba0b159..c8fd70bc84 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -574,7 +574,7 @@ ignite relayer hermes start "earth" "mars" You can now send packets and verify the received posts: ```bash -planetd tx blog send-ibc-post blog channel-0 "Hello" "Hello Mars, I'm Alice from Earth" --from alice --chain-id earth --home ~/.earth +planetd tx blog send-ibc-post transfer channel-0 "Hello" "Hello Mars, I'm Alice from Earth" --from alice --chain-id earth --home ~/.earth ``` To verify that the post has been received on Mars: @@ -588,7 +588,7 @@ The packet has been received: ```yaml Post: - content: Hello Mars, I'm Alice from Earth - creator: blog-channel-0-cosmos1aew8dk9cs3uzzgeldatgzvm5ca2k4m98xhy20x + creator: transfer-channel-0-cosmos1aew8dk9cs3uzzgeldatgzvm5ca2k4m98xhy20x id: "0" title: Hello pagination: @@ -606,7 +606,7 @@ Output: ```yaml SentPost: - - chain: blog-channel-0 + - chain: transfer-channel-0 creator: cosmos1aew8dk9cs3uzzgeldatgzvm5ca2k4m98xhy20x id: "0" postID: "0" @@ -620,7 +620,7 @@ To test timeout, set the timeout time of a packet to 1 nanosecond, verify that the packet is timed out, and check the timed-out posts: ```bash -planetd tx blog send-ibc-post blog channel-0 "Sorry" "Sorry Mars, you will never see this post" --from alice --chain-id earth --home ~/.earth --packet-timeout-timestamp 1 +planetd tx blog send-ibc-post transfer channel-0 "Sorry" "Sorry Mars, you will never see this post" --from alice --chain-id earth --home ~/.earth --packet-timeout-timestamp 1 ``` Check the timed-out posts: @@ -633,7 +633,7 @@ Results: ```yaml TimedoutPost: - - chain: blog-channel-0 + - chain: transfer-channel-0 creator: cosmos1fhpcsxn0g8uask73xpcgwxlfxtuunn3ey5ptjv id: "0" title: Sorry @@ -645,7 +645,7 @@ pagination: You can also send a post from Mars: ```bash -planetd tx blog send-ibc-post blog channel-0 "Hello" "Hello Earth, I'm Alice from Mars" --from alice --chain-id mars --home ~/.mars --node tcp://localhost:26659 +planetd tx blog send-ibc-post transfer channel-0 "Hello" "Hello Earth, I'm Alice from Mars" --from alice --chain-id mars --home ~/.mars --node tcp://localhost:26659 ``` List post on Earth: @@ -659,7 +659,7 @@ Results: ```yaml Post: - content: Hello Earth, I'm Alice from Mars - creator: blog-channel-0-cosmos1xtpx43l826348s59au24p22pxg6q248638q2tf + creator: transfer-channel-0-cosmos1xtpx43l826348s59au24p22pxg6q248638q2tf id: "0" title: Hello pagination: diff --git a/docs/docs/02-guide/07-interchange/03-walkthrough.md b/docs/docs/02-guide/07-interchange/03-walkthrough.md index fcb32070bf..177d10ae57 100644 --- a/docs/docs/02-guide/07-interchange/03-walkthrough.md +++ b/docs/docs/02-guide/07-interchange/03-walkthrough.md @@ -95,7 +95,7 @@ assets between the two chains. To create an order book for a pair of tokens, you can use the following command: ``` -interchanged tx dex send-create-pair dex channel-0 marscoin venuscoin --from alice --chain-id mars --home ~/.mars +interchanged tx dex send-create-pair transfer channel-0 marscoin venuscoin --from alice --chain-id mars --home ~/.mars ``` This command will create an order book for the pair of tokens `marscoin` and @@ -119,7 +119,7 @@ sellOrderBook: book: idCount: 0 orders: [] - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -136,7 +136,7 @@ buyOrderBook: book: idCount: 0 orders: [] - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -161,7 +161,7 @@ transaction with a message that locks a specified amount of tokens and creates a sell order on the Mars blockchain. ``` -interchanged tx dex send-sell-order dex channel-0 marscoin 10 venuscoin 15 --from alice --chain-id mars --home ~/.mars +interchanged tx dex send-sell-order transfer channel-0 marscoin 10 venuscoin 15 --from alice --chain-id mars --home ~/.mars ``` In the example provided, the `send-sell-order` command is used to create a sell @@ -194,7 +194,7 @@ sellOrderBook: creator: cosmos14ntyzr6d2dx4ppds9tvenx53fn0xl5jcakrtm4 id: 0 price: 15 - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -206,7 +206,7 @@ which is used to lock a specified amount of tokens and create a buy order on the Venus blockchain ``` -interchanged tx dex send-buy-order dex channel-0 marscoin 10 venuscoin 5 --from alice --chain-id venus --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex send-buy-order transfer channel-0 marscoin 10 venuscoin 5 --from alice --chain-id venus --home ~/.venus --node tcp://localhost:26659 ``` In the example provided, the `send-buy-order` command is used to create a buy @@ -241,7 +241,7 @@ buyOrderBook: creator: cosmos1mrrttwtdcp47pl4hq6sar3mwqpmtc7pcl9e6ss id: 0 price: 5 - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -258,7 +258,7 @@ To perform an exchange, you can send a sell order to the Mars chain using the following command: ``` -interchanged tx dex send-sell-order dex channel-0 marscoin 5 venuscoin 3 --from alice --home ~/.mars +interchanged tx dex send-sell-order transfer channel-0 marscoin 5 venuscoin 3 --from alice --home ~/.mars ``` This sell order, offering to sell 5 `marscoin` for 3 `venuscoin`, will be filled @@ -279,7 +279,7 @@ buyOrderBook: creator: cosmos1mrrttwtdcp47pl4hq6sar3mwqpmtc7pcl9e6ss id: 0 price: 5 - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -334,7 +334,7 @@ exchange to buy 5 `marscoin` for 15 `venuscoin`. This is done by running the following command: ``` -interchanged tx dex send-buy-order dex channel-0 marscoin 5 venuscoin 15 --from alice --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex send-buy-order transfer channel-0 marscoin 5 venuscoin 15 --from alice --home ~/.venus --node tcp://localhost:26659 ``` This buy order will be immediately filled on the Mars chain, and the creator of @@ -371,7 +371,7 @@ sellOrderBook: creator: cosmos14ntyzr6d2dx4ppds9tvenx53fn0xl5jcakrtm4 id: 0 price: 15 - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -401,7 +401,7 @@ to the decentralized exchange to sell 10 `marscoin` for 3 `venuscoin`. This is done by running the following command: ``` -interchanged tx dex send-sell-order dex channel-0 marscoin 10 venuscoin 3 --from alice --home ~/.mars +interchanged tx dex send-sell-order transfer channel-0 marscoin 10 venuscoin 3 --from alice --home ~/.mars ``` In this scenario, the sell amount is 10 `marscoin`, but there is an existing buy @@ -437,7 +437,7 @@ buyOrderBook: book: idCount: 1 orders: [] # buy order with amount 5marscoin has been closed - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -476,7 +476,7 @@ sellOrderBook: creator: cosmos14ntyzr6d2dx4ppds9tvenx53fn0xl5jcakrtm4 id: 1 price: 3 - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -487,7 +487,7 @@ to the decentralized exchange to buy 10 `marscoin` for 5 `venuscoin`. This is done by running the following command: ``` -interchanged tx dex send-buy-order dex channel-0 marscoin 10 venuscoin 5 --from alice --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex send-buy-order transfer channel-0 marscoin 10 venuscoin 5 --from alice --home ~/.venus --node tcp://localhost:26659 ``` In this scenario, the buy order is only partially filled for 5 `marscoin`. There @@ -525,7 +525,7 @@ sellOrderBook: id: 0 price: 15 # a sell order for 5 marscoin has been closed - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -567,7 +567,7 @@ buyOrderBook: creator: cosmos1mrrttwtdcp47pl4hq6sar3mwqpmtc7pcl9e6ss id: 1 price: 5 - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -586,7 +586,7 @@ connection, the `amount-denom` and `price-denom` of the order, and the To cancel a sell order on the Mars chain, you would run the following command: ``` -interchanged tx dex cancel-sell-order dex channel-0 marscoin venuscoin 0 --from alice --home ~/.mars +interchanged tx dex cancel-sell-order transfer channel-0 marscoin venuscoin 0 --from alice --home ~/.mars ``` This will cancel the sell order and remove it from the order book. The balance @@ -629,14 +629,14 @@ sellOrderBook: book: idCount: 2 orders: [] - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` To cancel a buy order on the `Venus` chain, you can run the following command: ``` -interchanged tx dex cancel-buy-order dex channel-0 marscoin venuscoin 1 --from alice --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex cancel-buy-order transfer channel-0 marscoin venuscoin 1 --from alice --home ~/.venus --node tcp://localhost:26659 ``` This will cancel the buy order and remove it from the order book. The balance of @@ -682,7 +682,7 @@ buyOrderBook: book: idCount: 2 orders: [] - index: dex-channel-0-marscoin-venuscoin + index: transfer-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` From cc18ab940c58fdb3ab6cee93ac3a3da24355af7a Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sat, 29 Jun 2024 02:59:27 +0200 Subject: [PATCH 4/7] fix channel version --- docs/docs/02-guide/06-ibc.md | 33 +++++++------ .../02-guide/07-interchange/03-walkthrough.md | 49 ++++++++++--------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index c8fd70bc84..5afc3cb6a4 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -535,11 +535,14 @@ ignite app install -g github.com/ignite/apps/hermes and after configure the relayer. ```bash -ignite relayer hermes configure \ +ignite relayer hermes configure \ "earth" "http://localhost:26657" "http://localhost:9090" \ "mars" "http://localhost:26659" "http://localhost:9092" \ --chain-a-faucet "http://0.0.0.0:4500" \ ---chain-b-faucet "http://0.0.0.0:4501" +--chain-b-faucet "http://0.0.0.0:4501" \ +--chain-a-port-id "blog" \ +--chain-b-port-id "blog" \ +--channel-version "blog-1" ``` When prompted, press Enter to accept the default values for `Chain A Account` and @@ -548,15 +551,17 @@ When prompted, press Enter to accept the default values for `Chain A Account` an The output looks like: ``` -Hermes config created at ~/.ignite/relayer/hermes/earth_mars +Hermes config created at /Users/danilopantani/.ignite/relayer/hermes/earth_mars ? Chain earth doesn't have a default Hermes key. Type your mnemonic to continue or type enter to generate a new one: (optional) -New mnemonic generated: +New mnemonic generated: danger plate flavor twist chimney myself sketch assist copy expand core tattoo ignore ensure quote mean forum carbon enroll gadget immense grab early maze Chain earth key created -Chain earth relayer wallet: cosmos1qzls22j2ym2q442pducl4dhjrtyt9w9jd9fewu +Chain earth relayer wallet: cosmos1jk6wmyl880j6t9vw6umy9v8ex0yhrfwgx0vv2d +New balance from faucet: 100000stake,5token ? Chain mars doesn't have a default Hermes key. Type your mnemonic to continue or type enter to generate a new one: (optional) -New mnemonic generated: +New mnemonic generated: invest box icon session lens demise purse link boss dwarf give minimum jazz eye vocal seven sunset coach express want ask version anger ranch Chain mars key created -Chain mars relayer wallet: cosmos1x6y0raeqjuctcxglxrc8rstqlmmd43ucwqx2es +Chain mars relayer wallet: cosmos1x9kt37c0sutanaqwy9gxpvq5990yt0qnpqntmp +New balance from faucet: 100000stake,5token Client '07-tendermint-0' created (earth -> mars) Client 07-tendermint-0' created (mars -> earth) Connection 'earth (connection-0) <-> mars (connection-0)' created @@ -574,7 +579,7 @@ ignite relayer hermes start "earth" "mars" You can now send packets and verify the received posts: ```bash -planetd tx blog send-ibc-post transfer channel-0 "Hello" "Hello Mars, I'm Alice from Earth" --from alice --chain-id earth --home ~/.earth +planetd tx blog send-ibc-post blog channel-0 "Hello" "Hello Mars, I'm Alice from Earth" --from alice --chain-id earth --home ~/.earth ``` To verify that the post has been received on Mars: @@ -588,7 +593,7 @@ The packet has been received: ```yaml Post: - content: Hello Mars, I'm Alice from Earth - creator: transfer-channel-0-cosmos1aew8dk9cs3uzzgeldatgzvm5ca2k4m98xhy20x + creator: blog-channel-0-cosmos1aew8dk9cs3uzzgeldatgzvm5ca2k4m98xhy20x id: "0" title: Hello pagination: @@ -606,7 +611,7 @@ Output: ```yaml SentPost: - - chain: transfer-channel-0 + - chain: blog-channel-0 creator: cosmos1aew8dk9cs3uzzgeldatgzvm5ca2k4m98xhy20x id: "0" postID: "0" @@ -620,7 +625,7 @@ To test timeout, set the timeout time of a packet to 1 nanosecond, verify that the packet is timed out, and check the timed-out posts: ```bash -planetd tx blog send-ibc-post transfer channel-0 "Sorry" "Sorry Mars, you will never see this post" --from alice --chain-id earth --home ~/.earth --packet-timeout-timestamp 1 +planetd tx blog send-ibc-post blog channel-0 "Sorry" "Sorry Mars, you will never see this post" --from alice --chain-id earth --home ~/.earth --packet-timeout-timestamp 1 ``` Check the timed-out posts: @@ -633,7 +638,7 @@ Results: ```yaml TimedoutPost: - - chain: transfer-channel-0 + - chain: blog-channel-0 creator: cosmos1fhpcsxn0g8uask73xpcgwxlfxtuunn3ey5ptjv id: "0" title: Sorry @@ -645,7 +650,7 @@ pagination: You can also send a post from Mars: ```bash -planetd tx blog send-ibc-post transfer channel-0 "Hello" "Hello Earth, I'm Alice from Mars" --from alice --chain-id mars --home ~/.mars --node tcp://localhost:26659 +planetd tx blog send-ibc-post blog channel-0 "Hello" "Hello Earth, I'm Alice from Mars" --from alice --chain-id mars --home ~/.mars --node tcp://localhost:26659 ``` List post on Earth: @@ -659,7 +664,7 @@ Results: ```yaml Post: - content: Hello Earth, I'm Alice from Mars - creator: transfer-channel-0-cosmos1xtpx43l826348s59au24p22pxg6q248638q2tf + creator: blog-channel-0-cosmos1xtpx43l826348s59au24p22pxg6q248638q2tf id: "0" title: Hello pagination: diff --git a/docs/docs/02-guide/07-interchange/03-walkthrough.md b/docs/docs/02-guide/07-interchange/03-walkthrough.md index 177d10ae57..d00a0f7777 100644 --- a/docs/docs/02-guide/07-interchange/03-walkthrough.md +++ b/docs/docs/02-guide/07-interchange/03-walkthrough.md @@ -69,11 +69,14 @@ to specify the source and target chains, along with their respective RPC endpoints, faucet URLs, port numbers, versions, gas prices, and gas limits. ```bash -ignite relayer hermes configure \ +ignite relayer hermes configure \ "earth" "http://localhost:26657" "http://localhost:9090" \ "mars" "http://localhost:26659" "http://localhost:9092" \ --chain-a-faucet "http://0.0.0.0:4500" \ ---chain-b-faucet "http://0.0.0.0:4501" +--chain-b-faucet "http://0.0.0.0:4501" \ +--chain-a-port-id "dex" \ +--chain-b-port-id "dex" \ +--channel-version "dex-1" ``` To create a connection between the two chains, you can use the ignite relayer @@ -95,7 +98,7 @@ assets between the two chains. To create an order book for a pair of tokens, you can use the following command: ``` -interchanged tx dex send-create-pair transfer channel-0 marscoin venuscoin --from alice --chain-id mars --home ~/.mars +interchanged tx dex send-create-pair dex channel-0 marscoin venuscoin --from alice --chain-id mars --home ~/.mars ``` This command will create an order book for the pair of tokens `marscoin` and @@ -119,7 +122,7 @@ sellOrderBook: book: idCount: 0 orders: [] - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -136,7 +139,7 @@ buyOrderBook: book: idCount: 0 orders: [] - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -161,7 +164,7 @@ transaction with a message that locks a specified amount of tokens and creates a sell order on the Mars blockchain. ``` -interchanged tx dex send-sell-order transfer channel-0 marscoin 10 venuscoin 15 --from alice --chain-id mars --home ~/.mars +interchanged tx dex send-sell-order dex channel-0 marscoin 10 venuscoin 15 --from alice --chain-id mars --home ~/.mars ``` In the example provided, the `send-sell-order` command is used to create a sell @@ -194,7 +197,7 @@ sellOrderBook: creator: cosmos14ntyzr6d2dx4ppds9tvenx53fn0xl5jcakrtm4 id: 0 price: 15 - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -206,7 +209,7 @@ which is used to lock a specified amount of tokens and create a buy order on the Venus blockchain ``` -interchanged tx dex send-buy-order transfer channel-0 marscoin 10 venuscoin 5 --from alice --chain-id venus --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex send-buy-order dex channel-0 marscoin 10 venuscoin 5 --from alice --chain-id venus --home ~/.venus --node tcp://localhost:26659 ``` In the example provided, the `send-buy-order` command is used to create a buy @@ -241,7 +244,7 @@ buyOrderBook: creator: cosmos1mrrttwtdcp47pl4hq6sar3mwqpmtc7pcl9e6ss id: 0 price: 5 - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -258,7 +261,7 @@ To perform an exchange, you can send a sell order to the Mars chain using the following command: ``` -interchanged tx dex send-sell-order transfer channel-0 marscoin 5 venuscoin 3 --from alice --home ~/.mars +interchanged tx dex send-sell-order dex channel-0 marscoin 5 venuscoin 3 --from alice --home ~/.mars ``` This sell order, offering to sell 5 `marscoin` for 3 `venuscoin`, will be filled @@ -279,7 +282,7 @@ buyOrderBook: creator: cosmos1mrrttwtdcp47pl4hq6sar3mwqpmtc7pcl9e6ss id: 0 price: 5 - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -334,7 +337,7 @@ exchange to buy 5 `marscoin` for 15 `venuscoin`. This is done by running the following command: ``` -interchanged tx dex send-buy-order transfer channel-0 marscoin 5 venuscoin 15 --from alice --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex send-buy-order dex channel-0 marscoin 5 venuscoin 15 --from alice --home ~/.venus --node tcp://localhost:26659 ``` This buy order will be immediately filled on the Mars chain, and the creator of @@ -371,7 +374,7 @@ sellOrderBook: creator: cosmos14ntyzr6d2dx4ppds9tvenx53fn0xl5jcakrtm4 id: 0 price: 15 - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -401,7 +404,7 @@ to the decentralized exchange to sell 10 `marscoin` for 3 `venuscoin`. This is done by running the following command: ``` -interchanged tx dex send-sell-order transfer channel-0 marscoin 10 venuscoin 3 --from alice --home ~/.mars +interchanged tx dex send-sell-order dex channel-0 marscoin 10 venuscoin 3 --from alice --home ~/.mars ``` In this scenario, the sell amount is 10 `marscoin`, but there is an existing buy @@ -437,7 +440,7 @@ buyOrderBook: book: idCount: 1 orders: [] # buy order with amount 5marscoin has been closed - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -476,7 +479,7 @@ sellOrderBook: creator: cosmos14ntyzr6d2dx4ppds9tvenx53fn0xl5jcakrtm4 id: 1 price: 3 - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -487,7 +490,7 @@ to the decentralized exchange to buy 10 `marscoin` for 5 `venuscoin`. This is done by running the following command: ``` -interchanged tx dex send-buy-order transfer channel-0 marscoin 10 venuscoin 5 --from alice --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex send-buy-order dex channel-0 marscoin 10 venuscoin 5 --from alice --home ~/.venus --node tcp://localhost:26659 ``` In this scenario, the buy order is only partially filled for 5 `marscoin`. There @@ -525,7 +528,7 @@ sellOrderBook: id: 0 price: 15 # a sell order for 5 marscoin has been closed - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -567,7 +570,7 @@ buyOrderBook: creator: cosmos1mrrttwtdcp47pl4hq6sar3mwqpmtc7pcl9e6ss id: 1 price: 5 - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` @@ -586,7 +589,7 @@ connection, the `amount-denom` and `price-denom` of the order, and the To cancel a sell order on the Mars chain, you would run the following command: ``` -interchanged tx dex cancel-sell-order transfer channel-0 marscoin venuscoin 0 --from alice --home ~/.mars +interchanged tx dex cancel-sell-order dex channel-0 marscoin venuscoin 0 --from alice --home ~/.mars ``` This will cancel the sell order and remove it from the order book. The balance @@ -629,14 +632,14 @@ sellOrderBook: book: idCount: 2 orders: [] - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` To cancel a buy order on the `Venus` chain, you can run the following command: ``` -interchanged tx dex cancel-buy-order transfer channel-0 marscoin venuscoin 1 --from alice --home ~/.venus --node tcp://localhost:26659 +interchanged tx dex cancel-buy-order dex channel-0 marscoin venuscoin 1 --from alice --home ~/.venus --node tcp://localhost:26659 ``` This will cancel the buy order and remove it from the order book. The balance of @@ -682,7 +685,7 @@ buyOrderBook: book: idCount: 2 orders: [] - index: transfer-channel-0-marscoin-venuscoin + index: dex-channel-0-marscoin-venuscoin priceDenom: venuscoin ``` From 04da619c0bee0ade2daf86ade818bdfccfc091b4 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sat, 29 Jun 2024 03:42:09 +0200 Subject: [PATCH 5/7] fix blog ibc guide for use collections --- docs/docs/02-guide/06-ibc.md | 85 +++++++++---------- integration/relayer/cmd_relayer_test.go | 104 ++++++++++-------------- 2 files changed, 81 insertions(+), 108 deletions(-) diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index 5afc3cb6a4..8e073dbc9c 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -228,7 +228,22 @@ import ( ) func (k msgServer) SendIbcPost(goCtx context.Context, msg *types.MsgSendIbcPost) (*types.MsgSendIbcPostResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) + // validate incoming message + if _, err := k.addressCodec.StringToBytes(msg.Creator); err != nil { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidAddress, fmt.Sprintf("invalid address: %s", err)) + } + + if msg.Port == "" { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid packet port") + } + + if msg.ChannelID == "" { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid packet channel") + } + + if msg.TimeoutTimestamp == 0 { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid packet timeout") + } // TODO: logic before transmitting the packet @@ -241,6 +256,7 @@ func (k msgServer) SendIbcPost(goCtx context.Context, msg *types.MsgSendIbcPost) packet.Creator = msg.Creator // Transmit the packet + ctx := sdk.UnwrapSDKContext(goCtx) _, err := k.TransmitIbcPostPacket( ctx, packet, @@ -298,19 +314,6 @@ Append the type instance as `PostId` on receiving the packet: - The `title` is the Title of the blog post - The `content` is the Content of the blog post -In the `x/blog/keeper/ibc_post.go` file, make sure to import `"strconv"` below -`"errors"`: - -```go title="x/blog/keeper/ibc_post.go" -import ( - //... - - "strconv" - -// ... -) -``` - Then modify the `OnRecvIbcPostPacket` keeper function with the following code: ```go @@ -319,23 +322,11 @@ package keeper // ... func (k Keeper) OnRecvIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, data types.IbcPostPacketData) (packetAck types.IbcPostPacketAck, err error) { - // validate packet data upon receiving - if err := data.ValidateBasic(); err != nil { + packetAck.PostId, err = k.PostSeq.Next(ctx) + if err != nil { return packetAck, err } - - id := k.AppendPost( - ctx, - types.Post{ - Creator: packet.SourcePort + "-" + packet.SourceChannel + "-" + data.Creator, - Title: data.Title, - Content: data.Content, - }, - ) - - packetAck.PostId = strconv.FormatUint(id, 10) - - return packetAck, nil + return packetAck, k.Post.Set(ctx, packetAck.PostId, types.Post{Title: data.Title, Content: data.Content}) } ``` @@ -365,23 +356,23 @@ func (k Keeper) OnAcknowledgementIbcPostPacket(ctx sdk.Context, packet channelty case *channeltypes.Acknowledgement_Result: // Decode the packet acknowledgment var packetAck types.IbcPostPacketAck - if err := types.ModuleCdc.UnmarshalJSON(dispatchedAck.Result, &packetAck); err != nil { // The counter-party module doesn't implement the correct acknowledgment format return errors.New("cannot unmarshal acknowledgment") } - k.AppendSentPost( - ctx, + seq, err := k.SentPostSeq.Next(ctx) + if err != nil { + return err + } + + return k.SentPost.Set(ctx, seq, types.SentPost{ - Creator: data.Creator, - PostId: packetAck.PostId, - Title: data.Title, - Chain: packet.DestinationPort + "-" + packet.DestinationChannel, + PostId: packetAck.PostId, + Title: data.Title, + Chain: packet.DestinationPort + "-" + packet.DestinationChannel, }, ) - - return nil default: return errors.New("the counter-party module does not implement the correct acknowledgment format") } @@ -395,18 +386,18 @@ posts. This logic follows the same format as `sentPost`. ```go title="x/blog/keeper/ibc_post.go" func (k Keeper) OnTimeoutIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, data types.IbcPostPacketData) error { - k.AppendTimedoutPost( - ctx, - types.TimedoutPost{ - Creator: data.Creator, - Title: data.Title, - Chain: packet.DestinationPort + "-" + packet.DestinationChannel, + seq, err := k.TimeoutPostSeq.Next(ctx) + if err != nil { + return err + } + + return k.TimeoutPost.Set(ctx, seq, + types.TimeoutPost{ + Title: data.Title, + Chain: packet.DestinationPort + "-" + packet.DestinationChannel, }, ) - - return nil } - ``` This last step completes the basic `blog` module setup. The blockchain is now diff --git a/integration/relayer/cmd_relayer_test.go b/integration/relayer/cmd_relayer_test.go index 9cedb817b1..4c91cb22de 100644 --- a/integration/relayer/cmd_relayer_test.go +++ b/integration/relayer/cmd_relayer_test.go @@ -127,75 +127,62 @@ var ( }, } - nameSendIbcPost = "SendIbcPost" - funcSendIbcPost = `package keeper -func (k msgServer) SendIbcPost(goCtx context.Context, msg *types.MsgSendIbcPost) (*types.MsgSendIbcPostResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - // Construct the packet - var packet types.IbcPostPacketData - packet.Title = msg.Title - packet.Content = msg.Content - // Transmit the packet - _, err := k.TransmitIbcPostPacket( - ctx, - packet, - msg.Port, - msg.ChannelID, - clienttypes.ZeroHeight(), - msg.TimeoutTimestamp, - ) - return &types.MsgSendIbcPostResponse{}, err -}` - nameOnRecvIbcPostPacket = "OnRecvIbcPostPacket" funcOnRecvIbcPostPacket = `package keeper func (k Keeper) OnRecvIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, data types.IbcPostPacketData) (packetAck types.IbcPostPacketAck, err error) { - // validate packet data upon receiving - if err := data.ValidateBasic(); err != nil { - return packetAck, err - } - packetAck.PostId = k.AppendPost(ctx, types.Post{Title: data.Title, Content: data.Content}) - return packetAck, nil + packetAck.PostId, err = k.PostSeq.Next(ctx) + if err != nil { + return packetAck, err + } + return packetAck, k.Post.Set(ctx, packetAck.PostId, types.Post{Title: data.Title, Content: data.Content}) }` nameOnAcknowledgementIbcPostPacket = "OnAcknowledgementIbcPostPacket" funcOnAcknowledgementIbcPostPacket = `package keeper func (k Keeper) OnAcknowledgementIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, data types.IbcPostPacketData, ack channeltypes.Acknowledgement) error { switch dispatchedAck := ack.Response.(type) { - case *channeltypes.Acknowledgement_Error: - // We will not treat acknowledgment error in this tutorial - return nil - case *channeltypes.Acknowledgement_Result: - // Decode the packet acknowledgment - var packetAck types.IbcPostPacketAck - if err := types.ModuleCdc.UnmarshalJSON(dispatchedAck.Result, &packetAck); err != nil { - // The counter-party module doesn't implement the correct acknowledgment format - return errors.New("cannot unmarshal acknowledgment") - } - - k.AppendSentPost(ctx, - types.SentPost{ - PostId: packetAck.PostId, - Title: data.Title, - Chain: packet.DestinationPort + "-" + packet.DestinationChannel, - }, - ) - return nil - default: - return errors.New("the counter-party module does not implement the correct acknowledgment format") - } + case *channeltypes.Acknowledgement_Error: + // We will not treat acknowledgment error in this tutorial + return nil + case *channeltypes.Acknowledgement_Result: + // Decode the packet acknowledgment + var packetAck types.IbcPostPacketAck + if err := types.ModuleCdc.UnmarshalJSON(dispatchedAck.Result, &packetAck); err != nil { + // The counter-party module doesn't implement the correct acknowledgment format + return errors.New("cannot unmarshal acknowledgment") + } + + seq, err := k.SentPostSeq.Next(ctx) + if err != nil { + return err + } + + return k.SentPost.Set(ctx, seq, + types.SentPost{ + PostId: packetAck.PostId, + Title: data.Title, + Chain: packet.DestinationPort + "-" + packet.DestinationChannel, + }, + ) + default: + return errors.New("the counter-party module does not implement the correct acknowledgment format") + } }` nameOnTimeoutIbcPostPacket = "OnTimeoutIbcPostPacket" funcOnTimeoutIbcPostPacket = `package keeper func (k Keeper) OnTimeoutIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, data types.IbcPostPacketData) error { - k.AppendTimeoutPost(ctx, - types.TimeoutPost{ - Title: data.Title, - Chain: packet.DestinationPort + "-" + packet.DestinationChannel, - }, - ) - return nil + seq, err := k.TimeoutPostSeq.Next(ctx) + if err != nil { + return err + } + + return k.TimeoutPost.Set(ctx, seq, + types.TimeoutPost{ + Title: data.Title, + Chain: packet.DestinationPort + "-" + packet.DestinationChannel, + }, + ) }` ) @@ -278,7 +265,7 @@ func runChain( func TestBlogIBC(t *testing.T) { var ( env = envtest.New(t) - app = env.Scaffold("github.com/test/planet") + app = env.Scaffold("github.com/ignite/blog", "--no-module") ctx = env.Ctx() tmpDir = t.TempDir() ) @@ -374,11 +361,6 @@ func TestBlogIBC(t *testing.T) { )) blogKeeperPath := filepath.Join(app.SourcePath(), "x/blog/keeper") - require.NoError(t, goanalysis.ReplaceCode( - blogKeeperPath, - nameSendIbcPost, - funcSendIbcPost, - )) require.NoError(t, goanalysis.ReplaceCode( blogKeeperPath, nameOnRecvIbcPostPacket, From aa0332b08f5da6d75f0fe63a66189f0d2d66cd9b Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Mon, 1 Jul 2024 18:07:44 +0200 Subject: [PATCH 6/7] fix typo into the parameters and set postid to uint --- docs/docs/02-guide/06-ibc.md | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index 8e073dbc9c..a9e1e8371b 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -110,21 +110,21 @@ transactions: - Creating blog posts - ```bash - ignite scaffold list post title content creator --no-message --module blog - ``` +```bash +ignite scaffold list post title content creator --no-message --module blog +``` - Processing acknowledgments for sent posts - ```bash - ignite scaffold list sentPost postID title chain creator --no-message --module blog - ``` +```bash +ignite scaffold list sentPost postID:uint title chain creator --no-message --module blog +``` - Managing post timeouts - ```bash - ignite scaffold list timedoutPost title chain creator --no-message --module blog - ``` +```bash +ignite scaffold list timeoutPost title chain creator --no-message --module blog +``` The scaffolded code includes proto files for defining data structures, messages, messages handlers, keepers for modifying the state, and CLI commands. @@ -137,7 +137,7 @@ ignite scaffold list [typeName] [field1] [field2] ... [flags] The first argument of the `ignite scaffold list [typeName]` command specifies the name of the type being created. For the blog app, you created `post`, -`sentPost`, and `timedoutPost` types. +`sentPost`, and `timeoutPost` types. The next arguments define the fields that are associated with the type. For the blog app, you created `title`, `content`, `postID`, and `chain` fields. @@ -168,7 +168,7 @@ to another blockchain. To scaffold a sendable and interpretable IBC packet: ```bash -ignite scaffold packet ibcPost title content --ack postID --module blog +ignite scaffold packet ibcPost title content --ack postID:uint --module blog ``` Notice the fields in the `ibcPost` packet match the fields in the `post` type @@ -316,7 +316,7 @@ Append the type instance as `PostId` on receiving the packet: Then modify the `OnRecvIbcPostPacket` keeper function with the following code: -```go +```go title="x/blog/keeper/ibc_post.go" package keeper // ... @@ -345,9 +345,6 @@ from the packet. ```go title="x/blog/keeper/ibc_post.go" package keeper -// ... - -// x/blog/keeper/ibc_post.go func (k Keeper) OnAcknowledgementIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, data types.IbcPostPacketData, ack channeltypes.Acknowledgement) error { switch dispatchedAck := ack.Response.(type) { case *channeltypes.Acknowledgement_Error: @@ -381,7 +378,7 @@ func (k Keeper) OnAcknowledgementIbcPostPacket(ctx sdk.Context, packet channelty ### Store information about the timed-out packet -Store posts that have not been received by target chains in `timedoutPost` +Store posts that have not been received by target chains in `timeoutPost` posts. This logic follows the same format as `sentPost`. ```go title="x/blog/keeper/ibc_post.go" @@ -622,13 +619,13 @@ planetd tx blog send-ibc-post blog channel-0 "Sorry" "Sorry Mars, you will never Check the timed-out posts: ```bash -planetd q blog list-timedout-post +planetd q blog list-timeout-post ``` Results: ```yaml -TimedoutPost: +TimeoutPost: - chain: blog-channel-0 creator: cosmos1fhpcsxn0g8uask73xpcgwxlfxtuunn3ey5ptjv id: "0" From 21d37cdb6bdc9f3565537883a831f02126c85ccc Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Mon, 1 Jul 2024 20:41:55 +0200 Subject: [PATCH 7/7] remove unused comments --- docs/docs/02-guide/06-ibc.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/docs/02-guide/06-ibc.md b/docs/docs/02-guide/06-ibc.md index a9e1e8371b..4813c51983 100644 --- a/docs/docs/02-guide/06-ibc.md +++ b/docs/docs/02-guide/06-ibc.md @@ -222,11 +222,6 @@ the `msg.Creator` value to the IBC `packet`. ```go title="x/blog/keeper/msg_server_ibc_post.go" package keeper -import ( - // ... - "planet/x/blog/types" -) - func (k msgServer) SendIbcPost(goCtx context.Context, msg *types.MsgSendIbcPost) (*types.MsgSendIbcPostResponse, error) { // validate incoming message if _, err := k.addressCodec.StringToBytes(msg.Creator); err != nil { @@ -319,8 +314,6 @@ Then modify the `OnRecvIbcPostPacket` keeper function with the following code: ```go title="x/blog/keeper/ibc_post.go" package keeper -// ... - func (k Keeper) OnRecvIbcPostPacket(ctx sdk.Context, packet channeltypes.Packet, data types.IbcPostPacketData) (packetAck types.IbcPostPacketAck, err error) { packetAck.PostId, err = k.PostSeq.Next(ctx) if err != nil {