diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 00000000..8ed77375 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,5 @@ +[codespell] +skip = *.pulsar.go,*.pb.go,*.pb.gw.go,*.cosmos_orm.go,*.json,*.git,*.js,crypto/keys,fuzz,*.h,proto/tendermint,*.bin,*.sum,*.mod,*_test.go +ignore-words-list = userA,users,create,crate +count = +quiet-level = 3 \ No newline at end of file diff --git a/.github/markdown-link-check-config.json b/.github/markdown-link-check-config.json new file mode 100644 index 00000000..015a3ed2 --- /dev/null +++ b/.github/markdown-link-check-config.json @@ -0,0 +1,10 @@ +{ + "timeout": "20s", + "retryOn429": true, + "retryCount": 5, + "fallbackRetryDelay": "30s", + "aliveStatusCodes": [ + 200, + 206 + ] +} \ No newline at end of file diff --git a/.github/workflows/ibc-hooks.yml b/.github/workflows/ibc-hooks.yml index 933a0202..fc50c4cd 100644 --- a/.github/workflows/ibc-hooks.yml +++ b/.github/workflows/ibc-hooks.yml @@ -1,19 +1,19 @@ name: ibc-hooks -on: +on: pull_request: paths: - 'modules/ibc-hooks/**' - '.github/workflows/ibc-hooks.yml' env: - LINT_VERSION: v1.52 + LINT_VERSION: v1.55.2 GO_VERSION: 1.21.0 WORKING_DIRECTORY: modules/ibc-hooks jobs: golangci: - name: Linter - runs-on: ubuntu-latest + name: Linter + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -37,4 +37,4 @@ jobs: - name: Test run: go test ./... - working-directory: ${{ env.WORKING_DIRECTORY }} \ No newline at end of file + working-directory: ${{ env.WORKING_DIRECTORY }} \ No newline at end of file diff --git a/.github/workflows/markdown-linter.yaml b/.github/workflows/markdown-linter.yaml new file mode 100644 index 00000000..172ab9a8 --- /dev/null +++ b/.github/workflows/markdown-linter.yaml @@ -0,0 +1,13 @@ +name: Check Markdown links +on: + pull_request: +jobs: + markdown-link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 + with: + # markdown-link-check .github/markdown-link-check-config.json *.md + config-file: '.github/markdown-link-check-config.json' + folder-path: '.' \ No newline at end of file diff --git a/.github/workflows/mispell.yml b/.github/workflows/mispell.yml new file mode 100644 index 00000000..1e4524a7 --- /dev/null +++ b/.github/workflows/mispell.yml @@ -0,0 +1,17 @@ +name: typos + +on: + pull_request: + +jobs: + fix: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run codespell + continue-on-error: true + run: | + # .codespellrc is used + sudo apt-get install codespell -y + codespell -w --config .codespellrc + exit $? \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1f1af982..ca0adf44 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,12 +23,12 @@ For features, every module should have [interchain-test](https://github.com/stra For modules, ensure full test coverage and compatibility with the main branch. -## New contributer approval process +## New contributor approval process - [ ] Submit a Github issue titled "I should be a maintainer because..." - [ ] After approval, write privileges will be granted to a member of an external team. - [ ] Merging PRs will require approval from more than one team -Privileges will be revoked in case of failure to comply with the [Code of Conduct](../CODE_OF_CONDUCT.md) +Privileges will be revoked in case of failure to comply with the [Code of Conduct](./CODE_OF_CONDUCT.md) ## Versioning diff --git a/README.md b/README.md index befca7f1..23075e3f 100644 --- a/README.md +++ b/README.md @@ -7,17 +7,17 @@ IBC applications and middleware for Cosmos SDK blockchains 🌌 Why have an ibc-apps repo? ================================ -Early IBC work started in the [ibc-go](https://github.com/cosmos/ibc-go) repo. As the repo grew, the need arose to parallelize the work among many teams. +Early IBC work started in the [ibc-go](https://github.com/cosmos/ibc-go) repo. As the repo grew, the need arose to parallelize the work among many teams. The ibc-apps repo is meant to be an easily discoverable, navigable, central place for modules and middleware. 🌌🌌 Who's it for? =================== -IBC-Apps is for: +IBC-Apps is for: - _Core **ibc-go** contributors_; it frees them from having to maintain IBC Apps, -- _Publishers of **ibc apps**_, so their apps can be easily found, and +- _Publishers of **ibc apps**_, so their apps can be easily found, and - _Everyone who uses IBC_ and wants to benefit from the full range of its capabilities. @@ -40,21 +40,17 @@ IBC apps can be split into two categories - modules and middleware. IBC Modules are self-contained applications that enable packets to be sent to and received from other IBC-enabled chains. IBC application developers do not need to concern themselves with the low-level details of clients, connections, and proof verification. -IBC Middleware are self-contained modules that sit between core IBC and an underlying IBC application. This allows developers to customize lower-level packet handling. Multiple middleware modules can be chained together. +IBC Middleware are self-contained modules that sit between core IBC and an underlying IBC application. This allows developers to customize lower-level packet handling. Multiple middleware modules can be chained together. 🌌🌌🌌🌌 How to Use this repo ============================= -If you'd like to include software in this repo, please see [contributing](../ibc-apps/CONTRIBUTING.md). +If you'd like to include software in this repo, please see [contributing](CONTRIBUTING.md). 🌌🌌🌌🌌🌌 Bonus Content ============================= -## Hello World - -An [example IBC app](./examples/hello-world/) - ## Maintained Branches | **Branch Name** | **IBC-Go** | @@ -68,7 +64,7 @@ An [example IBC app](./examples/hello-world/) ## List of Apps | Name | Type | Example | Stakeholders | Description | -| ---- | ---- | ------- | ------------ | ----------- | +| ---- | ---- | ------- | ------------ | ----------- | | [Async Interchain Query](./modules/async-icq/) | Module | Link | [Strangelove](https://github.com/strangelove-ventures/) | Interchain Queries enable blockchains to query the state of an account on another chain without the need for ICA auth. | | [IBC Hooks](./modules/ibc-hooks/) | Module | [Link](./modules/ibc-hooks/simapp/app.go) | [Osmosis](https://github.com/osmosis-labs) | The IBC hooks module is an IBC middleware that enables ICS-20 token transfers to initiate contract calls. | | [Packet Forward Middleware](./middleware/packet-forward-middleware) | Middleware | Link | [Strangelove](https://github.com/strangelove-ventures/) | Middleware for forwarding IBC packets. | @@ -78,12 +74,13 @@ An [example IBC app](./examples/hello-world/) Modules and middleware developed by other awesome teams in the ecosystem: | Name | Type | Stakeholders | Description | -| ---- | ---- | ------------ | ----------- | +| ---- | ---- | ------------ | ----------- | | [Interchain KV Queries](https://github.com/ingenuity-build/interchain-queries) | Module | [Ingenuity](https://github.com/ingenuity-build) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. | | [query](https://github.com/defund-labs/defund/tree/main/x/query) | Module | [Defund Labs](https://github.com/defund-labs) | An application that enables on chain querying of another IBC enabled chains state without the need for the chain being queried to implement the application. Similar to the interchain-queries application in the row above but without callbacks. | | [NFT Transfer (ICS 721)](https://github.com/bianjieai/nft-transfer) | Module | [Bianjieai](https://github.com/bianjieai) | An application that enables cross chain NFT transfer. | -| [CosmWasm NFT Transfer (ICS 721)](https://github.com/public-awesome/cw-ics721) | WASM Contract | [Public Awesome (Stargaze)](https://github.com/public-awesome), [Ark Protocol](https://twitter.com/ArkProtocol) | An application that enables cross chain NFT transfer. CosmWasm implementation of the above, written in Rust. | -| [recovery](https://github.com/evmos/evmos/tree/main/x/recovery) | Middleware | [Evmos](https://github.com/evmos) | Middleware enabling the recovery of tokens sent to unsupported addresses. | + +| [CosmWasm NFT Transfer (ICS 721)](https://github.com/public-awesome/cw-ics721) | WASM Contract | [Public Awesome (Stargaze)](https://github.com/public-awesome), [Ark Protocol](https://x.com/ArkProtocol) | An application that enables cross chain NFT transfer. CosmWasm implementation of the above, written in Rust. | +| [recovery](https://github.com/evmos/evmos/tree/v15.0.0/x/recovery) | Middleware | [Evmos](https://github.com/evmos) | Middleware enabling the recovery of tokens sent to unsupported addresses. | | [ibc-rate-limit](https://github.com/osmosis-labs/osmosis/tree/main/x/ibc-rate-limit) | Middleware | [Osmosis Labs](https://github.com/osmosis-labs) | Middleware that limits the in or out flow of an asset in a certain time period to minimise the risks of cross chain token transfers. This is implemented as a middleware wrapping ICS20 with the rate limiting logic implemented by cosmwasm contracts. | -| [Interchain Atomic Swap](https://github.com/sideprotocol/ibcswap-wasm/tree/main/contracts/ics100) | WASM Contract | [Side Labs](https://github.com/sideprotocol) | An application that facilitates inter-blockchain peer-to-peer asset swaps. | +| [Interchain Atomic Swap](https://github.com/sideprotocol/mesh-liquidity-wasm/tree/v0.1.0/contracts/ics100) | WASM Contract | [Side Labs](https://github.com/sideprotocol) | An application that facilitates inter-blockchain peer-to-peer asset swaps. | | [Interchain Liquidity](https://github.com/sideprotocol/ibcswap-wasm/tree/main/contracts/ics101) | WASM Contract | [Side Labs](https://github.com/sideprotocol) | An application that splits the state of a weighted liquidity pool between two chains, enabling inter-blockchain automated asset swaps. | diff --git a/middleware/packet-forward-middleware/README.md b/middleware/packet-forward-middleware/README.md index ddb1dc98..f32ff3fe 100644 --- a/middleware/packet-forward-middleware/README.md +++ b/middleware/packet-forward-middleware/README.md @@ -5,12 +5,12 @@ Asynchronous acknowledgements are utilized for atomic multi-hop packet flows. Th ## About -The packet-forward-middleware is an IBC middleware module built for Cosmos blockchains utilizing the IBC protocol. A chain which incorporates the -packet-forward-middleware is able to route incoming IBC packets from a source chain to a destination chain. As the Cosmos SDK/IBC become commonplace in the -blockchain space more and more zones will come online, these new zones joining are noticing a problem: they need to maintain a large amount of infrastructure -(archive nodes and relayers for each counterparty chain) to connect with all the chains in the ecosystem, a number that is continuing to increase quickly. Luckily -this problem has been anticipated and IBC has been architected to accommodate multi-hop transactions. However, a packet forwarding/routing feature was not in the -initial IBC release. +The packet-forward-middleware is an IBC middleware module built for Cosmos blockchains utilizing the IBC protocol. A chain which incorporates the +packet-forward-middleware is able to route incoming IBC packets from a source chain to a destination chain. As the Cosmos SDK/IBC become commonplace in the +blockchain space more and more zones will come online, these new zones joining are noticing a problem: they need to maintain a large amount of infrastructure +(archive nodes and relayers for each counterparty chain) to connect with all the chains in the ecosystem, a number that is continuing to increase quickly. Luckily +this problem has been anticipated and IBC has been architected to accommodate multi-hop transactions. However, a packet forwarding/routing feature was not in the +initial IBC release. ## Sequence diagrams @@ -100,7 +100,7 @@ memo: - The packet data `receiver` for the `MsgTransfer` on Chain A is set to `"pfm"` or some other invalid bech32 string.* - The forward metadata `receiver` for the hop from Chain B to Chain C is set to `"pfm"` or some other invalid bech32 string.* - The packet `memo` is included in `MsgTransfer` by user on Chain A. -- A packet timeout of 10 minutes and 2 retries is set for both forwards. +- A packet timeout of 10 minutes and 2 retries is set for both forwards. In the case of a timeout after 10 minutes for either forward, the packet would be retried up to 2 times, at which case an error ack would be written to issue a refund on the prior chain. @@ -152,7 +152,7 @@ The examples above show the intended usage of the `receiver` field for one or mu ## Implementation details -Flow sequence mainly encoded in [middleware](packetforward/ibc_middleware.go) and in [keeper](packetforward/keeper/keeper.go). +Flow sequence mainly encoded in [middleware](packetforward/ibc_middleware.go) and in [keeper](packetforward/keeper/keeper.go). Describes `A` sending to `C` via `B` in several scenarios with operational opened channels, enabled denom composition, fees and available to refund, but no retries. @@ -170,13 +170,13 @@ Generally without `memo` to handle, all handling by this module is delegated to 8. `B` Store tracking `in flight packet` under next `(channel, port, ICS-20 transfer sequence)`, do not `ACK` packet yet. 9. `C` Handle ICS-020 packet as usual. 10. `B` On ICS-020 ACK from `C` find `in flight packet`, delete it and write `ACK` for original packet from `A`. -11. `A` Handle ICS-020 `ACK` as usual +11. `A` Handle ICS-020 `ACK` as usual -[Example](https://testnet.mintscan.io/osmosis-testnet/txs/FAB912347B8729FFCA92AC35E6B1E83BC8169DE7CC2C254A5A3F70C8EC35D771?height=3788973) of USDC transfer from Osmosis -> Noble -> Sei +[Example](https://mintscan.io/osmosis-testnet/txs/FAB912347B8729FFCA92AC35E6B1E83BC8169DE7CC2C254A5A3F70C8EC35D771?height=3788973) of USDC transfer from Osmosis -> Noble -> Sei ### A -> B -> C with C error ACK -10. `B` On ICS-020 ACK from `C` find `in flight packet`, delete it +10. `B` On ICS-020 ACK from `C` find `in flight packet`, delete it 11. `B` Burns or escrows tokens. 12. `B` And write error `ACK` for original packet from `A`. 13. `A` Handle ICS-020 timeout as usual diff --git a/middleware/packet-forward-middleware/docs/integration.md b/middleware/packet-forward-middleware/docs/integration.md index bcb49f27..e27f2ba3 100644 --- a/middleware/packet-forward-middleware/docs/integration.md +++ b/middleware/packet-forward-middleware/docs/integration.md @@ -126,7 +126,7 @@ Here is an example of how to create an application stack using `transfer` and `p The following `transferStack` is configured in `app/app.go` and added to the IBC `Router`. The in-line comments describe the execution flow of packets between the application stack and IBC core. -For more information on configuring an IBC application stack see the ibc-go docs [here](https://github.com/cosmos/ibc-go/blob/main/docs/middleware/ics29-fee/integration.md#configuring-an-application-stack-with-fee-middleware). +For more information on configuring an IBC application stack see the ibc-go docs [here](https://github.com/cosmos/ibc-go/blob/e69a833de764fa0f5bdf0338d9452fd6e579a675/docs/docs/04-middleware/01-ics29-fee/02-integration.md#configuring-an-application-stack-with-fee-middleware). ```go diff --git a/middleware/packet-forward-middleware/packetforward/keeper/keeper.go b/middleware/packet-forward-middleware/packetforward/keeper/keeper.go index 19763616..16c01ec9 100644 --- a/middleware/packet-forward-middleware/packetforward/keeper/keeper.go +++ b/middleware/packet-forward-middleware/packetforward/keeper/keeper.go @@ -260,7 +260,7 @@ func (k *Keeper) WriteAcknowledgementForForwardedPacket( ctx, transfertypes.ModuleName, newToken, ); err != nil { // NOTE: should not happen as the module account was - // retrieved on the step above and it has enough balace + // retrieved on the step above and it has enough balance // to burn. panic(fmt.Sprintf("cannot burn coins after a successful send from escrow account to module account: %v", err)) } diff --git a/middleware/packet-forward-middleware/testing/simapp/params/encoding.go b/middleware/packet-forward-middleware/testing/simapp/params/encoding.go index 84247b6e..259b1bc1 100644 --- a/middleware/packet-forward-middleware/testing/simapp/params/encoding.go +++ b/middleware/packet-forward-middleware/testing/simapp/params/encoding.go @@ -18,7 +18,7 @@ type EncodingConfig struct { // MakeTestEncodingConfig creates an EncodingConfig for a non-amino based test configuration. // This function should be used only internally (in the SDK). -// App user should'nt create new codecs - use the app.AppCodec instead. +// App user shouldn't create new codecs - use the app.AppCodec instead. // [DEPRECATED] func MakeTestEncodingConfig() EncodingConfig { cdc := codec.NewLegacyAmino() diff --git a/modules/async-icq/keeper/cache_ctx.go b/modules/async-icq/keeper/cache_ctx.go index 95c1a846..8a51b9e3 100644 --- a/modules/async-icq/keeper/cache_ctx.go +++ b/modules/async-icq/keeper/cache_ctx.go @@ -12,7 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// This function lets you run the function f, but if theres an error or panic +// This function lets you run the function f, but if there's an error or panic // drop the state machine change and log the error. // If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness) // Try to avoid usage of iterators in f. diff --git a/modules/async-icq/module.go b/modules/async-icq/module.go index aab0801f..0c9f4170 100644 --- a/modules/async-icq/module.go +++ b/modules/async-icq/module.go @@ -54,7 +54,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesis()) } -// ValidateGenesis performs genesis state validation for the IBC interchain acounts module +// ValidateGenesis performs genesis state validation for the IBC interchain accounts module func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var gs types.GenesisState if err := cdc.UnmarshalJSON(bz, &gs); err != nil { @@ -103,7 +103,7 @@ func NewAppModule(keeper keeper.Keeper, ss exported.Subspace) AppModule { } } -// InitModule will initialize the interchain query moudule. It should only be +// InitModule will initialize the interchain query module. It should only be // called once and as an alternative to InitGenesis. func (am AppModule) InitModule(ctx sdk.Context, params types.Params) { if err := am.keeper.SetParams(ctx, params); err != nil { diff --git a/modules/async-icq/testing/demo-simapp/x/interquery/keeper/msg_server_send_query_all_balances.go b/modules/async-icq/testing/demo-simapp/x/interquery/keeper/msg_server_send_query_all_balances.go index b3d7b545..c94768bd 100644 --- a/modules/async-icq/testing/demo-simapp/x/interquery/keeper/msg_server_send_query_all_balances.go +++ b/modules/async-icq/testing/demo-simapp/x/interquery/keeper/msg_server_send_query_all_balances.go @@ -34,7 +34,7 @@ func (k msgServer) SendQueryAllBalances(goCtx context.Context, msg *types.MsgSen }, } - // timeoutTimestamp set to max value with the unsigned bit shifted to sastisfy hermes timestamp conversion + // timeoutTimestamp set to max value with the unsigned bit shifted to satisfy hermes timestamp conversion // it is the responsibility of the auth module developer to ensure an appropriate timeout timestamp timeoutTimestamp := ctx.BlockTime().Add(time.Minute).UnixNano() seq, err := k.SendQuery(ctx, types.PortID, msg.ChannelId, chanCap, reqs, clienttypes.ZeroHeight(), uint64(timeoutTimestamp)) diff --git a/modules/ibc-hooks/README.md b/modules/ibc-hooks/README.md index 6ff5a792..82fe1043 100644 --- a/modules/ibc-hooks/README.md +++ b/modules/ibc-hooks/README.md @@ -5,14 +5,14 @@ ## IBC hooks The IBC hooks module is an IBC middleware that enables ICS-20 token transfers to initiate contract calls. -This functionality allows cross-chain contract calls that involve token movement. +This functionality allows cross-chain contract calls that involve token movement. IBC hooks are useful for a variety of use cases, including cross-chain swaps, which are an extremely powerful primitive. ## How do IBC hooks work? IBC hooks are made possible through the `memo` field included in every ICS-20 transfer packet, as introduced in [IBC v3.4.0](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b). -The IBC hooks IBC middleware parses an ICS20 transfer, and if the `memo` field is of a particular form, executes a Wasm contract call. +The IBC hooks IBC middleware parses an ICS20 transfer, and if the `memo` field is of a particular form, executes a Wasm contract call. The following sections detail the `memo` format for Wasm contract calls and the execution guarantees provided. @@ -33,13 +33,14 @@ type MsgExecuteContract struct { } ``` -For use with IBC hooks, the message fields above can be derived from the following: +For use with IBC hooks, the message fields above can be derived from the following: -- `Sender`: IBC packet senders cannot be explicitly trusted, as they can be deceitful. Chains cannot risk the sender being confused with a particular local user or module address. To prevent this, the `sender` is replaced with an account that represents the sender prefixed by the channel and a Wasm module prefix. This is done by setting the sender to `Bech32(Hash("ibc-wasm-hook-intermediary" || channelID || sender))`, where the `channelId` is the channel id on the local chain. +- `Sender`: IBC packet senders cannot be explicitly trusted, as they can be deceitful. Chains cannot risk the sender being confused with a particular local user or module address. To prevent this, the `sender` is replaced with an account that represents the sender prefixed by the channel and a Wasm module prefix. This is done by setting the sender to `Bech32(Hash("ibc-wasm-hook-intermediary" || channelID || sender))`, where the `channelId` is the channel id on the local chain. - `Contract`: This field should be directly obtained from the ICS-20 packet metadata - `Msg`: This field should be directly obtained from the ICS-20 packet metadata. - `Funds`: This field is set to the amount of funds being sent over in the ICS-20 packet. The denom in the packet must be specified as the counterparty chain's representation of the denom. + > **_WARNING:_** Due to a [bug](https://twitter.com/SCVSecurity/status/1682329758020022272) in the packet forward middleware, we cannot trust the sender from chains that use PFM. Until that is fixed, we recommend chains to not trust the sender on contracts executed via IBC hooks. @@ -63,7 +64,7 @@ msg := MsgExecuteContract{ Given the details above, you can propagate the implied ICS-20 packet data structure. ICS20 is JSON native, so you can use JSON for the memo format. -```json +```json { //... other ibc fields that we don't care about "data":{ @@ -86,15 +87,15 @@ ICS20 is JSON native, so you can use JSON for the memo format. An ICS-20 packet is formatted correctly for IBC hooks if all of the following are true: - The `memo` is not blank. -- The`memo` is valid JSON. +- The`memo` is valid JSON. - The `memo` has at least one key, with the value `"wasm"`. -- The `memo["wasm"]` has exactly two entries, `"contract"` and `"msg"`. +- The `memo["wasm"]` has exactly two entries, `"contract"` and `"msg"`. - The `memo["wasm"]["msg"]` is a valid JSON object. -- The `receiver == "" || receiver == memo["wasm"]["contract"]`. +- The `receiver == "" || receiver == memo["wasm"]["contract"]`. An ICS-20 packet is directed toward IBC hooks if all of the following are true: -- The `memo` is not blank. +- The `memo` is not blank. - The `memo` is valid JSON. - The `memo` has at least one key, with the name `"wasm"`. @@ -105,7 +106,7 @@ If an ICS-20 packet is directed towards IBC hooks, and is formatted incorrectly, 1. Pre-IBC hooks: -- Ensure the incoming IBC packet is cryptographically valid. +- Ensure the incoming IBC packet is cryptographically valid. - Ensure the incoming IBC packet is not timed out. 2. In IBC hooks, pre-packet execution: @@ -127,14 +128,14 @@ contracts to listen in on the `ack` of specific packets. ### Design -The sender of an IBC transfer packet may specify a callback for when the `Ack` of that packet is received in the memo -field of the transfer packet. +The sender of an IBC transfer packet may specify a callback for when the `Ack` of that packet is received in the memo +field of the transfer packet. Crucially, **only the IBC packet sender can set the callback**. ### Use case -The cross-chain swaps implementation sends an IBC transfer. If the transfer were to fail, the sender should be able to retrieve their funds which would otherwise be stuck in the contract. To do this, users should be allowed to retrieve the funds after the timeout has passed. However, without the `Ack` information, one cannot guarantee that the send hasn't failed (i.e.: returned an error ack notifying that the receiving chain didn't accept it). +The cross-chain swaps implementation sends an IBC transfer. If the transfer were to fail, the sender should be able to retrieve their funds which would otherwise be stuck in the contract. To do this, users should be allowed to retrieve the funds after the timeout has passed. However, without the `Ack` information, one cannot guarantee that the send hasn't failed (i.e.: returned an error ack notifying that the receiving chain didn't accept it). ### Implementation @@ -188,7 +189,7 @@ pub enum SudoMsg { Follow these steps to install the IBC hooks module. The following lines are all added to `app.go` -1. Import the following packages. +1. Import the following packages. ```go // import ( @@ -200,7 +201,7 @@ Follow these steps to install the IBC hooks module. The following lines are all // ) ``` -2. Add the module. +2. Add the module. ```go // var ( @@ -209,10 +210,10 @@ Follow these steps to install the IBC hooks module. The following lines are all ... ibchooks.AppModuleBasic{}, ... - // ) + // ) ``` -3. Add the IBC hooks keeper. +3. Add the IBC hooks keeper. ```go @@ -237,7 +238,7 @@ Follow these steps to install the IBC hooks module. The following lines are all app.keys[ibchookstypes.StoreKey], ) app.Ics20WasmHooks = ibchooks.NewWasmHooks(&app.IBCHooksKeeper, nil, AccountAddressPrefix) // The contract keeper needs to be set later - + // initialize the wasm keeper with // wasmKeeper := wasm.NewKeeper( ... ) app.WasmKeeper = &wasmKeeper @@ -256,7 +257,7 @@ Follow these steps to install the IBC hooks module. The following lines are all ... ``` -5. Register the genesis, begin blocker and end block hooks. +5. Register the genesis, begin blocker and end block hooks. ```go ... @@ -358,4 +359,4 @@ Follow these steps to install the IBC hooks module. The following lines are all ``` ## Tests -Tests are included in the [tests folder](./tests/testdata/counter/README.md). \ No newline at end of file +Tests are included in the [tests folder](./tests/unit/testdata/counter/README.md). \ No newline at end of file diff --git a/modules/ibc-hooks/wasm_hook.go b/modules/ibc-hooks/wasm_hook.go index 0aef149b..91df074b 100644 --- a/modules/ibc-hooks/wasm_hook.go +++ b/modules/ibc-hooks/wasm_hook.go @@ -94,7 +94,7 @@ func (h WasmHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packe amount, ok := sdk.NewIntFromString(data.GetAmount()) if !ok { - // This should never happen, as it should've been caught in the underlaying call to OnRecvPacket, + // This should never happen, as it should've been caught in the underlying call to OnRecvPacket, // but returning here for completeness return NewEmitErrorAcknowledgement(ctx, types.ErrInvalidPacket, "Amount is not an int") }