-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp(dymns): patch
x/dymns
follow audit report (#1265)
- Loading branch information
1 parent
b738cff
commit 3d1c96d
Showing
66 changed files
with
2,935 additions
and
4,237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
"github.com/cosmos/cosmos-sdk/version" | ||
dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types" | ||
dymnsutils "github.com/dymensionxyz/dymension/v3/x/dymns/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewCancelSellOrderTxCmd is the CLI command for close a Sell-Order. | ||
func NewCancelSellOrderTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "cancel-sell-order [Name/Alias/Handle] [myname/x]", | ||
Aliases: []string{"cancel-so"}, | ||
Short: "Cancel a sell-order (only when no bid placed)", | ||
Example: fmt.Sprintf( | ||
`$ %s tx %s cancel-sell-order name myname --%s owner | ||
$ %s tx %s cancel-sell-order alias x --%s owner`, | ||
version.AppName, dymnstypes.ModuleName, flags.FlagFrom, | ||
version.AppName, dymnstypes.ModuleName, flags.FlagFrom, | ||
), | ||
Args: cobra.ExactArgs(2), | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
target := args[1] | ||
var assetType dymnstypes.AssetType | ||
|
||
switch strings.ToLower(args[0]) { | ||
case "name", "dym-name", "dymname", "n": | ||
assetType = dymnstypes.TypeName | ||
if !dymnsutils.IsValidDymName(target) { | ||
return fmt.Errorf("input is not a valid Dym-Name: %s", target) | ||
} | ||
case "alias", "handle", "handles", "a": | ||
assetType = dymnstypes.TypeAlias | ||
if !dymnsutils.IsValidAlias(target) { | ||
return fmt.Errorf("input is not a valid Alias: %s", target) | ||
} | ||
default: | ||
return fmt.Errorf("invalid asset type: %s, must be 'Name' or 'Alias'/'Handle'", args[0]) | ||
} | ||
|
||
owner := clientCtx.GetFromAddress().String() | ||
if owner == "" { | ||
return fmt.Errorf("flag --%s is required", flags.FlagFrom) | ||
} | ||
|
||
msg := &dymnstypes.MsgCancelSellOrder{ | ||
AssetId: target, | ||
AssetType: assetType, | ||
Owner: owner, | ||
} | ||
|
||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
"github.com/cosmos/cosmos-sdk/version" | ||
dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types" | ||
dymnsutils "github.com/dymensionxyz/dymension/v3/x/dymns/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewCompleteSellOrderTxCmd is the CLI command for completing a Sell-Order. | ||
func NewCompleteSellOrderTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "complete-sell-order [Name/Alias/Handle] [myname/x]", | ||
Aliases: []string{"complete-so"}, | ||
Short: "Complete a sell-order (must be expired and has at least one bid)", | ||
Long: "Request to complete a sell-order (must be expired and has at least one bid). Can be submitted by either the owner or the highest bidder.", | ||
Example: fmt.Sprintf( | ||
`$ %s tx %s complete-sell-order name myname --%s owner/bidder | ||
$ %s tx %s complete-sell-order alias x --%s owner/bidder`, | ||
version.AppName, dymnstypes.ModuleName, flags.FlagFrom, | ||
version.AppName, dymnstypes.ModuleName, flags.FlagFrom, | ||
), | ||
Args: cobra.ExactArgs(2), | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
target := args[1] | ||
var assetType dymnstypes.AssetType | ||
|
||
switch strings.ToLower(args[0]) { | ||
case "name", "dym-name", "dymname", "n": | ||
assetType = dymnstypes.TypeName | ||
if !dymnsutils.IsValidDymName(target) { | ||
return fmt.Errorf("input is not a valid Dym-Name: %s", target) | ||
} | ||
case "alias", "handle", "handles", "a": | ||
assetType = dymnstypes.TypeAlias | ||
if !dymnsutils.IsValidAlias(target) { | ||
return fmt.Errorf("input is not a valid Alias: %s", target) | ||
} | ||
default: | ||
return fmt.Errorf("invalid asset type: %s, must be 'Name' or 'Alias'/'Handle'", args[0]) | ||
} | ||
|
||
participant := clientCtx.GetFromAddress().String() | ||
if participant == "" { | ||
return fmt.Errorf("flag --%s is required", flags.FlagFrom) | ||
} | ||
|
||
msg := &dymnstypes.MsgCompleteSellOrder{ | ||
AssetId: target, | ||
AssetType: assetType, | ||
Participant: participant, | ||
} | ||
|
||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.