Skip to content

Commit

Permalink
Add ics20 marker creation for receiving marker via ibc sends (#1678)
Browse files Browse the repository at this point in the history
* Add Osmosis IBC-Hooks Initial port

* ibchooks lint fixes

* lint fixes and depguard config for golang-ci lint

* Remove import comments

* wip/adding testing system

* clean up tests

* fix wasm keeper hooks wiring

* add basic simulation wiring to ibchooks

* set default ibchooks params in upgrade

* remove unused golangci-lint linters

* lint work

* protection for quotes in quoted json

* changelog

* temporary fix for invalid simulation handling for staking denom

* restore supply increase proposal simulation for valid markers

* use calculated temporary supply increase

* wip: build fix

* Further proposal disabling for marker supply tests

* switch to reference contracts from embedded wasm

* start hook entry point file, start marker hooks file

* refactor structure to allow for ics20 marker hook calls

* do lint-fix

* fix mock's lint

* fix more lint issues

* add marker send packet override

* update marker hooks logic

* add some more logic flow

* check if denom is not from source chain to do marker mutations

* do not try and create marker if denom is from source

* fix lint issues with imports

* update test

* test fix json

* test json change

* move marker memo struct to types

* move wasm structs to type... still needs some reworking to correct json

* refactor json structs, add tests, add constructors

* comment one test case for now.  Test needs fixing not implementation

* add send packet functions

* add map for processing after SendPacket

* move memo processing on the receiver, process transfer auths in memo

* finalize creating remote marker and transfer permissions, decided if it is restricted or coin type on creation, start fixing some broken tests

* add chain id and denom meta data

* add callback data to post send processing, refactor packet bytes order in send function, fix tests

* add new marker error type, emit error on acknowledgement if error processing memo

* add error handling for reset marker access grants

* remove unused bank keeper from constructor of maker hooks

* remove unused parameter from get chain id

* rename variables

* remove unused variable from memo processing

* refactor send processing fn parameters

* add call back validation checks in wasm processing function, various lint fixies

* add start to maker hooks tests, remove todo comment

* add happy path test for ProcessMarkerMemo

* refactor way memo creation and processing works, refactor method names, start a few more tests

* complete process marker memo tests

* finish reset permissions tests

* add more tests

* rename pre send data processing functions

* add pre send packet data processing test for marker hooks

* refactor processing loop

* review PR and add updates to method comments and refactor function name

* more refactors

* add change log

* fix method comments

* add test

* change logic flow

* refactor AddUpdateMarker flow

* fix lint

* rename method

* update tests

* change codeID

* add allow force transfer flag

* extract updating of auth-transfers and allow force transfer into own function

---------

Co-authored-by: Ira Miller <[email protected]>
Co-authored-by: Ira Miller <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent d5fb7d1 commit e4b5d91
Show file tree
Hide file tree
Showing 40 changed files with 3,752 additions and 253 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
Holds are also reflected in the `x/bank` module's `SpendableBalances` query.
* Add new MaxSupply param to marker module and deprecate MaxTotalSupply. [#1292](https://github.com/provenance-io/provenance/issues/1292).
* Add hidden docgen command to output documentation in different formats. [#1468](https://github.com/provenance-io/provenance/issues/1468).
* Add ics20 marker creation for receiving marker via ibc sends [#1127](https://github.com/provenance-io/provenance/issues/1127).

### Improvements

Expand Down
12 changes: 11 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ type App struct {

TransferStack *ibchooks.IBCMiddleware
Ics20WasmHooks *ibchooks.WasmHooks
Ics20MarkerHooks *ibchooks.MarkerHooks
IbcHooks *ibchooks.IbcHooks
HooksICS4Wrapper ibchooks.ICS4Middleware

// the module manager
Expand Down Expand Up @@ -509,9 +511,14 @@ func New(
addrPrefix := sdk.GetConfig().GetBech32AccountAddrPrefix() // We use this approach so running tests which use "cosmos" will work while we use "pb"
wasmHooks := ibchooks.NewWasmHooks(&hooksKeeper, nil, addrPrefix) // The contract keeper needs to be set later
app.Ics20WasmHooks = &wasmHooks
markerHooks := ibchooks.NewMarkerHooks(nil)
app.Ics20MarkerHooks = &markerHooks
ibcHooks := ibchooks.NewIbcHooks(appCodec, &hooksKeeper, app.IBCKeeper, app.Ics20WasmHooks, app.Ics20MarkerHooks, nil)
app.IbcHooks = &ibcHooks

app.HooksICS4Wrapper = ibchooks.NewICS4Middleware(
app.IBCKeeper.ChannelKeeper,
app.Ics20WasmHooks,
app.IbcHooks,
)

// Create Transfer Keepers
Expand Down Expand Up @@ -641,6 +648,9 @@ func New(
app.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper)
app.Ics20WasmHooks.ContractKeeper = app.WasmKeeper // app.ContractKeeper -- this changes in the next version of wasm to a permissioned keeper
app.IBCHooksKeeper.ContractKeeper = app.ContractKeeper
app.Ics20MarkerHooks.MarkerKeeper = &app.MarkerKeeper

app.IbcHooks.SendPacketPreProcessors = []ibchookstypes.PreSendPacketDataProcessingFn{app.Ics20MarkerHooks.SetupMarkerMemoFn, app.Ics20WasmHooks.GetWasmSendPacketPreProcessor}

app.ScopedOracleKeeper = scopedOracleKeeper
app.OracleKeeper = *oraclekeeper.NewKeeper(
Expand Down
Loading

0 comments on commit e4b5d91

Please sign in to comment.