Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an escrow module for swaping starnames and tokens #98

Merged
merged 82 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
e929e9f
WIP: escrow
LeCodeurDuDimanche Jun 1, 2021
73e8016
WIP: escrow
LeCodeurDuDimanche Jun 3, 2021
96e5fe4
WIP: escrow
LeCodeurDuDimanche Jun 3, 2021
2869a05
WIP: escrow
LeCodeurDuDimanche Jun 8, 2021
5d77c5f
Make the escrow module compile
LeCodeurDuDimanche Jun 8, 2021
ef30fa9
Adds escrow integration into the starname module and app
LeCodeurDuDimanche Jun 8, 2021
d8bafa1
Remove old HLTC tests
LeCodeurDuDimanche Jun 8, 2021
d21e735
Remove references to HTLC in the escrow code
LeCodeurDuDimanche Jun 9, 2021
7bf845f
Add escrow creation functionality to starname and fix issues
LeCodeurDuDimanche Jun 9, 2021
e68e288
Remove buyer address from escrow and automatic escrow refund
LeCodeurDuDimanche Jun 14, 2021
637d865
Enhance error messages and interface for managing escrows
LeCodeurDuDimanche Jun 14, 2021
79ddb42
Fix validation function with expired escrows and fix some TODOs
LeCodeurDuDimanche Jun 14, 2021
255d6da
Checks that sender/updater addresses are not blocked in message server
LeCodeurDuDimanche Jun 14, 2021
5ed345d
Minors fixes and add a comment about possible transfer errors
LeCodeurDuDimanche Jun 14, 2021
3ffd940
Fix escrow creation errors not taken into account
LeCodeurDuDimanche Jun 14, 2021
1cb871f
Fix harcoding of starname owner hen creating an escrow
LeCodeurDuDimanche Jun 14, 2021
d723aa1
Add escrow creation on REST API
LeCodeurDuDimanche Jun 14, 2021
52c33d6
Fix some TODOs in the escrow module
LeCodeurDuDimanche Jun 14, 2021
5c44640
Adds an invariant for the escrow states
LeCodeurDuDimanche Jun 14, 2021
7cbe950
Cleanup escrow proto files and fix generation error for MsgUpdateEscrow
LeCodeurDuDimanche Jun 14, 2021
9f05887
Revert "Remove old HLTC tests"
LeCodeurDuDimanche Jun 14, 2021
9a2f9e8
WIP
LeCodeurDuDimanche Jun 15, 2021
b8f56ef
Remove store holders from escrow keeper constructor
LeCodeurDuDimanche Jun 16, 2021
b3b7dbd
Remove unused methods from escrow expected keepers and use `GetModule…
LeCodeurDuDimanche Jun 16, 2021
97c59c2
Merge branch 'escrow' into escrow-tests
LeCodeurDuDimanche Jun 16, 2021
2e0e38f
Add tests for the escrow keeper package
LeCodeurDuDimanche Jun 18, 2021
c344573
Fix old documentation and comments
LeCodeurDuDimanche Jun 29, 2021
7b56202
Fix keeper tests and expiration methods on the escrow keeper
LeCodeurDuDimanche Jun 29, 2021
b5b70d1
Adds and fixes tests to escrow
LeCodeurDuDimanche Jun 30, 2021
7612481
Drop tmbytes for id in escrows iterators in favor of string ids
LeCodeurDuDimanche Jun 30, 2021
4d3bbb1
Adds a check in MsgCreateEscrow.ValidateBasic() over the object type
LeCodeurDuDimanche Jun 30, 2021
3c6bf6e
Fixes ValidateGenesis expecting a created escrow's object to belong t…
LeCodeurDuDimanche Jun 30, 2021
f5e6793
Fix TestObjects used in test: use the protobuf TestObject for all obj…
LeCodeurDuDimanche Jul 1, 2021
a9fbc7d
Fixes last escrow tests
LeCodeurDuDimanche Jul 1, 2021
9bf0784
Adds escrow fees to configuration module
LeCodeurDuDimanche Jul 1, 2021
1ce908f
Add fees and a fee payer to all escrows operations
LeCodeurDuDimanche Jul 1, 2021
59d5775
Use a simpler fee system for creating escrows
LeCodeurDuDimanche Jul 5, 2021
a9cde7f
Adds tests for escrow fees and a just expired deadline for invariants
LeCodeurDuDimanche Jul 6, 2021
74097b3
Adds the escrow_commission, escrow_broker and escrow_max_period param…
LeCodeurDuDimanche Jul 8, 2021
aed091a
Adds the commission, broker and max_period to the escrow module, clos…
LeCodeurDuDimanche Jul 8, 2021
b0b218f
Merge branch 'master' into escrow
LeCodeurDuDimanche Jul 8, 2021
c274b04
Migrate escrows storage to crud.Store
LeCodeurDuDimanche Jul 8, 2021
e350e96
WIP: Adds queries by seller, state and object to escrow module
LeCodeurDuDimanche Jul 9, 2021
bd150ce
Fix missing fee payer flag definition in escrow
LeCodeurDuDimanche Jul 13, 2021
6f67dea
Fix infinite loop when querying escrows
LeCodeurDuDimanche Jul 13, 2021
9af4399
Adds the escrows REST query and fix REST response marshalling
LeCodeurDuDimanche Jul 13, 2021
b526f9a
Update TODOs in code
LeCodeurDuDimanche Jul 13, 2021
d7864dc
Tests no fees are taken if transaction fails for escrows
LeCodeurDuDimanche Jul 14, 2021
ef90265
Fix escrow module CLI queries formatting
LeCodeurDuDimanche Jul 15, 2021
a29ddac
Gives TransferableObject interface more specific method names
LeCodeurDuDimanche Jul 15, 2021
7c6a290
Adds starname's Domain as a valid object for escrow
LeCodeurDuDimanche Jul 15, 2021
fe8baa6
Adds custom creation fees logic for escrows
LeCodeurDuDimanche Jul 15, 2021
fea2bc9
Fixes a crash with custom fees when object is nil (should be only wit…
LeCodeurDuDimanche Jul 15, 2021
be19d13
Adds test for the custom deadline check in the escrow module
LeCodeurDuDimanche Jul 15, 2021
20494a6
Makes Account and Domain implement ObjectWithTimeConstraint
LeCodeurDuDimanche Jul 15, 2021
9d23cd8
Adds a more helpful error message when an object rejects a deadline
LeCodeurDuDimanche Jul 15, 2021
e104305
CLI escrow query now returns an error instead of panic'ing for an inv…
LeCodeurDuDimanche Jul 15, 2021
8e050f7
Merge pull request #96 from iov-one/escrow-custom-check
LeCodeurDuDimanche Jul 15, 2021
ec7e6da
Split escrow invariant into multiple invariariants
LeCodeurDuDimanche Jul 15, 2021
baa9485
Resolve some escrow TODOs and FIXMEs
LeCodeurDuDimanche Jul 15, 2021
dcb0299
Tidy up some code of escrow module
LeCodeurDuDimanche Jul 15, 2021
0d0c8b8
Add events when creating, updating, completing and refunding an escrow
LeCodeurDuDimanche Jul 15, 2021
35b4007
Adds integration tests for escrows
LeCodeurDuDimanche Jul 19, 2021
ef5b781
WIP: use existing starname transfer methods for escrow transfer
LeCodeurDuDimanche Jul 19, 2021
499a85b
Rework TransferableObject interface and prevent account escrow from b…
LeCodeurDuDimanche Jul 20, 2021
bbf5c9a
Adds REST integration test for escrows
LeCodeurDuDimanche Jul 20, 2021
d57c65e
Merge branch 'master' into escrow
LeCodeurDuDimanche Jul 20, 2021
96c733d
Remove unwanted file test-genesis.sh
LeCodeurDuDimanche Jul 22, 2021
c4f71b6
Fix deadline check in validation.go
LeCodeurDuDimanche Jul 22, 2021
49332a8
Change GetCRUDObject() to GetUniqueKey() in the TransferableObject in…
LeCodeurDuDimanche Jul 22, 2021
07d4d23
Adds documentation to the escrow module
LeCodeurDuDimanche Jul 22, 2021
c836850
Add a string argument to GetModuleAddress() to prepare to sub-account…
LeCodeurDuDimanche Jul 22, 2021
b3e5d87
Adds escrow documentation to swagger
LeCodeurDuDimanche Jul 23, 2021
acaa880
Adds a ModuleEnabled param in escrow
LeCodeurDuDimanche Jul 23, 2021
533c112
Enable escrow for the integration tests
davepuchyr Jul 29, 2021
fda9433
Fix escrow parameters not initialized in genesis, fix panic
LeCodeurDuDimanche Aug 2, 2021
c3650a7
Merge branch 'master' into escrow
LeCodeurDuDimanche Nov 4, 2021
bdc67d2
Make the transfer type for domain in escrow TransferResetNone
LeCodeurDuDimanche Nov 4, 2021
e12ec01
Add escrow parameters for update-config CLI command
LeCodeurDuDimanche Nov 11, 2021
f2d28da
Fix various escrows bugs and add support for open domain accounts
LeCodeurDuDimanche Nov 14, 2021
2876464
Make command naming consistent so that they are grouped nicely on `st…
davepuchyr Nov 15, 2021
9f05209
Add some extremely important info to the `domain-transfer` command
davepuchyr Nov 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,9 @@ import (
"strconv"
"strings"

"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -87,8 +77,20 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

"github.com/iov-one/starnamed/x/configuration"
"github.com/iov-one/starnamed/x/escrow"
escrowkeeper "github.com/iov-one/starnamed/x/escrow/keeper"
escrowtypes "github.com/iov-one/starnamed/x/escrow/types"
"github.com/iov-one/starnamed/x/starname"
"github.com/iov-one/starnamed/x/wasm"
wasmclient "github.com/iov-one/starnamed/x/wasm/client"
Expand Down Expand Up @@ -192,6 +194,7 @@ var (
vesting.AppModuleBasic{},
configuration.AppModuleBasic{},
starname.AppModuleBasic{},
escrow.AppModuleBasic{},
)

// module account permissions
Expand All @@ -204,6 +207,7 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
wasm.ModuleName: {authtypes.Burner},
escrowtypes.ModuleName: nil,
}

// module accounts that are allowed to receive tokens
Expand Down Expand Up @@ -250,6 +254,7 @@ type WasmApp struct {
wasmKeeper wasm.Keeper
configKeeper configuration.Keeper
starnameKeeper starname.Keeper
escrowKeeper escrowkeeper.Keeper

scopedIBCKeeper capabilitykeeper.ScopedKeeper
scopedTransferKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -281,7 +286,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
wasm.StoreKey, configuration.StoreKey, starname.DomainStoreKey,
wasm.StoreKey, configuration.StoreKey, starname.DomainStoreKey, escrowtypes.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -408,12 +413,22 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
app.getSubspace(configuration.ModuleName),
)

// Create the escrow keeper
app.escrowKeeper = escrowkeeper.NewKeeper(appCodec,
keys[escrowtypes.StoreKey],
app.getSubspace(escrowtypes.ModuleName),
app.accountKeeper,
app.bankKeeper,
app.configKeeper,
app.ModuleAccountAddrs(),
)
// starname keeper
app.starnameKeeper = starname.NewKeeper(
appCodec,
keys[starname.DomainStoreKey],
app.configKeeper,
app.bankKeeper,
app.escrowKeeper,
app.getSubspace(starname.ModuleName),
)

Expand Down Expand Up @@ -464,6 +479,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
transferModule,
configuration.NewAppModule(app.configKeeper),
starname.NewAppModule(app.starnameKeeper),
escrow.NewAppModule(appCodec, app.escrowKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand All @@ -472,7 +488,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
// NOTE: staking module is required if HistoricalEntries param > 0
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, escrowtypes.ModuleName,
)
app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName)

Expand All @@ -488,7 +504,7 @@ func NewWasmApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest b
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName,
ibchost.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName, configuration.ModuleName, starname.ModuleName,
wasm.ModuleName, configuration.ModuleName, starname.ModuleName, escrowtypes.ModuleName,
)

app.mm.RegisterInvariants(&app.crisisKeeper)
Expand Down Expand Up @@ -694,6 +710,7 @@ func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyA
paramsKeeper.Subspace(wasm.ModuleName)
paramsKeeper.Subspace(configuration.ModuleName)
paramsKeeper.Subspace(starname.ModuleName)
paramsKeeper.Subspace(escrowtypes.ModuleName)

return paramsKeeper
}
5 changes: 3 additions & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"os"
"testing"

"github.com/iov-one/starnamed/x/wasm"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
db "github.com/tendermint/tm-db"

"github.com/iov-one/starnamed/x/wasm"
)

var emptyWasmOpts []wasm.Option = nil
Expand Down Expand Up @@ -88,7 +89,7 @@ func TestGetEnabledProposals(t *testing.T) {
}
}

func setGenesis(gapp *WasmApp) error {
func SetGenesis(gapp *WasmApp) error {
genesisState := NewDefaultGenesisState()
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
{
"url": "./tmp-swagger-gen/iov/configuration/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/iov/escrow/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/iov/starname/v1beta1/query.swagger.json"
},
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading