-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixing some error messages and such * lint 🤯 * fixing casing
- Loading branch information
1 parent
2789101
commit d78caa6
Showing
7 changed files
with
145 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package cli | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
uuid "github.com/google/uuid" | ||
filetypes "github.com/jackalLabs/canine-chain/v3/x/filetree/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var _ = strconv.Itoa(0) | ||
|
||
func CmdPostFilePublic() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "post-file-no-key [path] [account] [contents]", | ||
Short: "post a new file to an account's file explorer", | ||
Args: cobra.ExactArgs(3), | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
argHashpath := args[0] | ||
argAccount := args[1] | ||
argContents := args[2] | ||
|
||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
parentHash, childHash := merkleHelper(argHashpath) | ||
|
||
trackingNumber := uuid.NewString() | ||
|
||
viewers := make(map[string]string) | ||
editors := make(map[string]string) | ||
|
||
// Marshall everybody | ||
jsonViewers, jsonEditors, err := JSONMarshalViewersAndEditors(viewers, editors) | ||
if err != nil { | ||
return err | ||
} | ||
H := sha256.New() | ||
H.Write([]byte(argAccount)) | ||
hash := H.Sum(nil) | ||
accountHash := fmt.Sprintf("%x", hash) | ||
|
||
msg := filetypes.NewMsgPostFile( | ||
clientCtx.GetFromAddress().String(), | ||
accountHash, | ||
parentHash, | ||
childHash, | ||
argContents, | ||
string(jsonViewers), | ||
string(jsonEditors), | ||
trackingNumber, | ||
) | ||
if err := msg.ValidateBasic(); err != nil { | ||
return err | ||
} | ||
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
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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
package types | ||
|
||
// DONTCOVER | ||
|
||
import ( | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
// x/storage module sentinel errors | ||
// x/storage module error messages | ||
var ( | ||
ErrDivideByZero = sdkerrors.Register(ModuleName, 1110, "DivideByZero") | ||
ErrProviderNotFound = sdkerrors.Register(ModuleName, 1111, "Provider not found. Please init your provider.") | ||
ErrNotValidTotalSpace = sdkerrors.Register(ModuleName, 1112, "Not a valid total space. Please enter total number of bytes to provide.") | ||
ErrDealNotFound = sdkerrors.Register(ModuleName, 1114, "Cannot find active deal") | ||
ErrFormNotFound = sdkerrors.Register(ModuleName, 1115, "Cannot find attestation form") | ||
ErrAttestInvalid = sdkerrors.Register(ModuleName, 1116, "Cannot attest to form") | ||
ErrAttestAlreadyExists = sdkerrors.Register(ModuleName, 1117, "Attest already exists") | ||
ErrCannotVerifyProof = sdkerrors.Register(ModuleName, 1118, "Cannot verify Proof") | ||
ErrDivideByZero = sdkerrors.Register(ModuleName, 1110, "divide by zero") | ||
ErrProviderNotFound = sdkerrors.Register(ModuleName, 1111, "provider not found please init your provider") | ||
ErrNotValidTotalSpace = sdkerrors.Register(ModuleName, 1112, "not a valid total space please enter total number of bytes to provide") | ||
ErrDealNotFound = sdkerrors.Register(ModuleName, 1114, "cannot find active deal") | ||
ErrFormNotFound = sdkerrors.Register(ModuleName, 1115, "cannot find attestation form") | ||
ErrAttestInvalid = sdkerrors.Register(ModuleName, 1116, "cannot attest to form") | ||
ErrAttestAlreadyExists = sdkerrors.Register(ModuleName, 1117, "attest already exists") | ||
ErrCannotVerifyProof = sdkerrors.Register(ModuleName, 1118, "cannot verify proof") | ||
ErrNoCid = sdkerrors.Register(ModuleName, 1119, "cid does not exist") | ||
ErrProviderExists = sdkerrors.Register(ModuleName, 1120, "provider already exists") | ||
ErrCancelContract = sdkerrors.Register(ModuleName, 1121, "cannot cancel contract") | ||
) |