Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
Osmosis_Sync
Commits
8caa7677
Commit
8caa7677
authored
2 years ago
by
mattverse
Browse files
Options
Download
Email Patches
Plain Diff
Add Clien support for proposals, wire it to gov module
parent
eb3ea480
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
app/keepers/modules.go
+3
-0
app/keepers/modules.go
x/gamm/client/cli/flags.go
+2
-0
x/gamm/client/cli/flags.go
x/gamm/client/cli/tx.go
+192
-0
x/gamm/client/cli/tx.go
x/gamm/client/proposal_handler.go
+13
-0
x/gamm/client/proposal_handler.go
x/gamm/client/rest/tx.go
+27
-0
x/gamm/client/rest/tx.go
with
237 additions
and
0 deletions
+237
-0
app/keepers/modules.go
+
3
-
0
View file @
8caa7677
...
...
@@ -34,6 +34,7 @@ import (
downtimemodule
"github.com/osmosis-labs/osmosis/v15/x/downtime-detector/module"
"github.com/osmosis-labs/osmosis/v15/x/epochs"
"github.com/osmosis-labs/osmosis/v15/x/gamm"
gammclient
"github.com/osmosis-labs/osmosis/v15/x/gamm/client"
"github.com/osmosis-labs/osmosis/v15/x/ibc-rate-limit/ibcratelimitmodule"
"github.com/osmosis-labs/osmosis/v15/x/incentives"
"github.com/osmosis-labs/osmosis/v15/x/lockup"
...
...
@@ -75,6 +76,8 @@ var AppModuleBasics = []module.AppModuleBasic{
superfluidclient
.
SetSuperfluidAssetsProposalHandler
,
superfluidclient
.
RemoveSuperfluidAssetsProposalHandler
,
superfluidclient
.
UpdateUnpoolWhitelistProposalHandler
,
gammclient
.
ReplaceMigrationRecordsProposalHandler
,
gammclient
.
UpdateMigrationRecordsProposalHandler
,
)
...
,
),
params
.
AppModuleBasic
{},
...
...
This diff is collapsed.
Click to expand it.
x/gamm/client/cli/flags.go
+
2
-
0
View file @
8caa7677
...
...
@@ -40,6 +40,8 @@ const (
FlagSwapRouteDenoms
=
"swap-route-denoms"
// FlagScalingFactors represents the flag name for the scaling factors.
FlagScalingFactors
=
"scaling-factors"
FlagMigrationRecords
=
"migration-records"
)
type
createBalancerPoolInputs
struct
{
...
...
This diff is collapsed.
Click to expand it.
x/gamm/client/cli/tx.go
+
192
-
0
View file @
8caa7677
...
...
@@ -17,7 +17,10 @@ import (
poolmanagertypes
"github.com/osmosis-labs/osmosis/v15/x/poolmanager/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk
"github.com/cosmos/cosmos-sdk/types"
govcli
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtypes
"github.com/cosmos/cosmos-sdk/x/gov/types"
)
func
NewTxCmd
()
*
cobra
.
Command
{
...
...
@@ -178,6 +181,115 @@ func NewStableSwapAdjustScalingFactorsCmd() *cobra.Command {
return
cmd
}
// NewCmdSubmitReplaceMigrationRecordsProposal implements a command handler for replace migration records proposal
func
NewCmdSubmitReplaceMigrationRecordsProposal
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"replace-migration-records-proposal [flags]"
,
Args
:
cobra
.
ExactArgs
(
0
),
Short
:
"Submit a replace migration record proposal"
,
Long
:
strings
.
TrimSpace
(
`Submit a replace migration record proposal.
Passing in poolIds separated by commas would be parsed automatically to pairs of migration record.
Ex) 2,4,1,5 -> [(Balancer 2, CL 4), (Balancer 1, CL 5)]
`
),
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
clientCtx
,
err
:=
client
.
GetClientTxContext
(
cmd
)
if
err
!=
nil
{
return
err
}
content
,
err
:=
parseReplaceMigrationRecordsArgsToContent
(
cmd
)
if
err
!=
nil
{
return
err
}
from
:=
clientCtx
.
GetFromAddress
()
depositStr
,
err
:=
cmd
.
Flags
()
.
GetString
(
govcli
.
FlagDeposit
)
if
err
!=
nil
{
return
err
}
deposit
,
err
:=
sdk
.
ParseCoinsNormalized
(
depositStr
)
if
err
!=
nil
{
return
err
}
msg
,
err
:=
govtypes
.
NewMsgSubmitProposal
(
content
,
deposit
,
from
)
if
err
!=
nil
{
return
err
}
if
err
=
msg
.
ValidateBasic
();
err
!=
nil
{
return
err
}
return
tx
.
GenerateOrBroadcastTxCLI
(
clientCtx
,
cmd
.
Flags
(),
msg
)
},
}
cmd
.
Flags
()
.
String
(
govcli
.
FlagTitle
,
""
,
"title of proposal"
)
cmd
.
Flags
()
.
String
(
govcli
.
FlagDescription
,
""
,
"description of proposal"
)
cmd
.
Flags
()
.
String
(
govcli
.
FlagDeposit
,
""
,
"deposit of proposal"
)
cmd
.
Flags
()
.
String
(
FlagMigrationRecords
,
""
,
"The migration records array"
)
return
cmd
}
// NewCmdSubmitUpdateMigrationRecordsProposal implements a command handler for replace migration records proposal
func
NewCmdSubmitUpdateMigrationRecordsProposal
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"update-migration-records-proposal [flags]"
,
Args
:
cobra
.
ExactArgs
(
0
),
Short
:
"Submit a update migration record proposal"
,
Long
:
strings
.
TrimSpace
(
`Submit a update migration record proposal.
Passing in poolIds separated by commas would be parsed automatically to pairs of migration record.
Ex) 2,4,1,5 -> [(Balancer 2, CL 4), (Balancer 1, CL 5)]
`
),
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
clientCtx
,
err
:=
client
.
GetClientTxContext
(
cmd
)
if
err
!=
nil
{
return
err
}
content
,
err
:=
parseUpdateMigrationRecordsArgsToContent
(
cmd
)
if
err
!=
nil
{
return
err
}
from
:=
clientCtx
.
GetFromAddress
()
depositStr
,
err
:=
cmd
.
Flags
()
.
GetString
(
govcli
.
FlagDeposit
)
if
err
!=
nil
{
return
err
}
deposit
,
err
:=
sdk
.
ParseCoinsNormalized
(
depositStr
)
if
err
!=
nil
{
return
err
}
msg
,
err
:=
govtypes
.
NewMsgSubmitProposal
(
content
,
deposit
,
from
)
if
err
!=
nil
{
return
err
}
if
err
=
msg
.
ValidateBasic
();
err
!=
nil
{
return
err
}
return
tx
.
GenerateOrBroadcastTxCLI
(
clientCtx
,
cmd
.
Flags
(),
msg
)
},
}
cmd
.
Flags
()
.
String
(
govcli
.
FlagTitle
,
""
,
"title of proposal"
)
cmd
.
Flags
()
.
String
(
govcli
.
FlagDescription
,
""
,
"description of proposal"
)
cmd
.
Flags
()
.
String
(
govcli
.
FlagDeposit
,
""
,
"deposit of proposal"
)
cmd
.
Flags
()
.
String
(
FlagMigrationRecords
,
""
,
"The migration records array"
)
return
cmd
}
func
BuildCreatePoolCmd
(
clientCtx
client
.
Context
,
args
[]
string
,
fs
*
flag
.
FlagSet
)
(
sdk
.
Msg
,
error
)
{
poolType
,
err
:=
fs
.
GetString
(
FlagPoolType
)
if
err
!=
nil
{
...
...
@@ -513,3 +625,83 @@ func ParseCoinsNoSort(coinsStr string) (sdk.Coins, error) {
}
return
sdk
.
NormalizeCoins
(
decCoins
),
nil
}
func
parseMigrationRecords
(
cmd
*
cobra
.
Command
)
([]
types
.
BalancerToConcentratedPoolLink
,
error
)
{
assetsStr
,
err
:=
cmd
.
Flags
()
.
GetString
(
FlagMigrationRecords
)
if
err
!=
nil
{
return
nil
,
err
}
assets
:=
strings
.
Split
(
assetsStr
,
","
)
replaceMigrations
:=
[]
types
.
BalancerToConcentratedPoolLink
{}
i
:=
0
for
i
<
len
(
assets
)
{
balancerPoolId
,
err
:=
strconv
.
Atoi
(
assets
[
i
])
if
err
!=
nil
{
return
nil
,
err
}
clPoolId
,
err
:=
strconv
.
Atoi
(
assets
[
i
+
1
])
if
err
!=
nil
{
return
nil
,
err
}
replaceMigrations
=
append
(
replaceMigrations
,
types
.
BalancerToConcentratedPoolLink
{
BalancerPoolId
:
uint64
(
balancerPoolId
),
ClPoolId
:
uint64
(
clPoolId
),
})
// increase counter by the next 2
i
=
i
+
2
}
return
replaceMigrations
,
nil
}
func
parseReplaceMigrationRecordsArgsToContent
(
cmd
*
cobra
.
Command
)
(
govtypes
.
Content
,
error
)
{
title
,
err
:=
cmd
.
Flags
()
.
GetString
(
govcli
.
FlagTitle
)
if
err
!=
nil
{
return
nil
,
err
}
description
,
err
:=
cmd
.
Flags
()
.
GetString
(
govcli
.
FlagDescription
)
if
err
!=
nil
{
return
nil
,
err
}
replaceMigrations
,
err
:=
parseMigrationRecords
(
cmd
)
if
err
!=
nil
{
return
nil
,
err
}
content
:=
&
types
.
ReplaceMigrationRecordsProposal
{
Title
:
title
,
Description
:
description
,
Records
:
replaceMigrations
,
}
return
content
,
nil
}
func
parseUpdateMigrationRecordsArgsToContent
(
cmd
*
cobra
.
Command
)
(
govtypes
.
Content
,
error
)
{
title
,
err
:=
cmd
.
Flags
()
.
GetString
(
govcli
.
FlagTitle
)
if
err
!=
nil
{
return
nil
,
err
}
description
,
err
:=
cmd
.
Flags
()
.
GetString
(
govcli
.
FlagDescription
)
if
err
!=
nil
{
return
nil
,
err
}
replaceMigrations
,
err
:=
parseMigrationRecords
(
cmd
)
if
err
!=
nil
{
return
nil
,
err
}
content
:=
&
types
.
UpdateMigrationRecordsProposal
{
Title
:
title
,
Description
:
description
,
Records
:
replaceMigrations
,
}
return
content
,
nil
}
This diff is collapsed.
Click to expand it.
x/gamm/client/proposal_handler.go
0 → 100644
+
13
-
0
View file @
8caa7677
package
client
import
(
"github.com/osmosis-labs/osmosis/v15/x/gamm/client/cli"
"github.com/osmosis-labs/osmosis/v15/x/gamm/client/rest"
govclient
"github.com/cosmos/cosmos-sdk/x/gov/client"
)
var
(
ReplaceMigrationRecordsProposalHandler
=
govclient
.
NewProposalHandler
(
cli
.
NewCmdSubmitReplaceMigrationRecordsProposal
,
rest
.
ProposalUpdateMigrationRecordsRESTHandler
)
UpdateMigrationRecordsProposalHandler
=
govclient
.
NewProposalHandler
(
cli
.
NewCmdSubmitUpdateMigrationRecordsProposal
,
rest
.
ProposalUpdateMigrationRecordsRESTHandler
)
)
This diff is collapsed.
Click to expand it.
x/gamm/client/rest/tx.go
0 → 100644
+
27
-
0
View file @
8caa7677
package
rest
import
(
"net/http"
"github.com/cosmos/cosmos-sdk/client"
govrest
"github.com/cosmos/cosmos-sdk/x/gov/client/rest"
)
func
ProposalReplaceMigrationRecordsRESTHandler
(
clientCtx
client
.
Context
)
govrest
.
ProposalRESTHandler
{
return
govrest
.
ProposalRESTHandler
{
SubRoute
:
"replace-migrations-records"
,
Handler
:
emptyHandler
(
clientCtx
),
}
}
func
ProposalUpdateMigrationRecordsRESTHandler
(
clientCtx
client
.
Context
)
govrest
.
ProposalRESTHandler
{
return
govrest
.
ProposalRESTHandler
{
SubRoute
:
"update-migrations-records"
,
Handler
:
emptyHandler
(
clientCtx
),
}
}
func
emptyHandler
(
clientCtx
client
.
Context
)
http
.
HandlerFunc
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets