style: enable strict gofumpt (#15579)
This commit is contained in:
parent
383fed4c6d
commit
37ba88872d
@ -4,7 +4,6 @@ run:
|
||||
sort-results: true
|
||||
allow-parallel-runners: true
|
||||
exclude-dir: testutil/testdata
|
||||
concurrency: 4
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
@ -54,6 +53,10 @@ issues:
|
||||
max-same-issues: 10000
|
||||
|
||||
linters-settings:
|
||||
gofumpt:
|
||||
# Choose whether to use the extra rules.
|
||||
# Default: false
|
||||
extra-rules: true
|
||||
dogsled:
|
||||
max-blank-identifiers: 3
|
||||
maligned:
|
||||
|
||||
@ -190,7 +190,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, []byte, error) {
|
||||
func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs []cryptotypes.PrivKey, accNums, accSeqs []uint64, chainID string) (xauthsigning.Tx, []byte, error) {
|
||||
// First round: we gather all the signer infos. We use the "set empty
|
||||
// signature" hack to do that.
|
||||
var sigsV2 []signing.SignatureV2
|
||||
|
||||
@ -20,7 +20,7 @@ type AccountRetriever interface {
|
||||
GetAccount(clientCtx Context, addr sdk.AccAddress) (Account, error)
|
||||
GetAccountWithHeight(clientCtx Context, addr sdk.AccAddress) (Account, int64, error)
|
||||
EnsureExists(clientCtx Context, addr sdk.AccAddress) error
|
||||
GetAccountNumberSequence(clientCtx Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error)
|
||||
GetAccountNumberSequence(clientCtx Context, addr sdk.AccAddress) (accNum, accSeq uint64, err error)
|
||||
}
|
||||
|
||||
var _ AccountRetriever = (*MockAccountRetriever)(nil)
|
||||
|
||||
@ -90,7 +90,7 @@ func bytesToPubkey(bz []byte, keytype string) (cryptotypes.PubKey, bool) {
|
||||
// getPubKeyFromRawString returns a PubKey (PubKeyEd25519 or PubKeySecp256k1) by attempting
|
||||
// to decode the pubkey string from hex, base64, and finally bech32. If all
|
||||
// encodings fail, an error is returned.
|
||||
func getPubKeyFromRawString(pkstr string, keytype string) (cryptotypes.PubKey, error) {
|
||||
func getPubKeyFromRawString(pkstr, keytype string) (cryptotypes.PubKey, error) {
|
||||
// Try hex decoding
|
||||
bz, err := hex.DecodeString(pkstr)
|
||||
if err == nil {
|
||||
|
||||
@ -47,7 +47,7 @@ func GetChainHeight(clientCtx client.Context) (int64, error) {
|
||||
// tx.height = 5 # all txs of the fifth block
|
||||
//
|
||||
// For more information, see the /subscribe CometBFT RPC endpoint documentation
|
||||
func QueryBlocks(clientCtx client.Context, page, limit int, query string, orderBy string) (*sdk.SearchBlocksResult, error) {
|
||||
func QueryBlocks(clientCtx client.Context, page, limit int, query, orderBy string) (*sdk.SearchBlocksResult, error) {
|
||||
node, err := clientCtx.GetNode()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -74,7 +74,7 @@ func (t TestAccountRetriever) EnsureExists(_ Context, addr sdk.AccAddress) error
|
||||
}
|
||||
|
||||
// GetAccountNumberSequence implements AccountRetriever.GetAccountNumberSequence
|
||||
func (t TestAccountRetriever) GetAccountNumberSequence(_ Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) {
|
||||
func (t TestAccountRetriever) GetAccountNumberSequence(_ Context, addr sdk.AccAddress) (accNum, accSeq uint64, err error) {
|
||||
acc, ok := t.Accounts[addr.String()]
|
||||
if !ok {
|
||||
return 0, 0, fmt.Errorf("account %s not found", addr)
|
||||
|
||||
@ -168,7 +168,7 @@ func (f Factory) WithFees(fees string) Factory {
|
||||
}
|
||||
|
||||
// WithTips returns a copy of the Factory with an updated tip.
|
||||
func (f Factory) WithTips(tip string, tipper string) Factory {
|
||||
func (f Factory) WithTips(tip, tipper string) Factory {
|
||||
parsedTips, err := sdk.ParseCoinsNormalized(tip)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -128,7 +128,7 @@ func unarmorBytes(armorStr, blockType string) (bz []byte, header map[string]stri
|
||||
// encrypt/decrypt with armor
|
||||
|
||||
// Encrypt and armor the private key.
|
||||
func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, algo string) string {
|
||||
func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase, algo string) string {
|
||||
saltBytes, encBytes := encryptPrivKey(privKey, passphrase)
|
||||
header := map[string]string{
|
||||
"kdf": "bcrypt",
|
||||
@ -147,7 +147,7 @@ func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, algo st
|
||||
// encrypt the given privKey with the passphrase using a randomly
|
||||
// generated salt and the xsalsa20 cipher. returns the salt and the
|
||||
// encrypted priv key.
|
||||
func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) {
|
||||
func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes, encBytes []byte) {
|
||||
saltBytes = crypto.CRandBytes(16)
|
||||
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)
|
||||
if err != nil {
|
||||
@ -161,7 +161,7 @@ func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes [
|
||||
}
|
||||
|
||||
// UnarmorDecryptPrivKey returns the privkey byte slice, a string of the algo type, and an error
|
||||
func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey cryptotypes.PrivKey, algo string, err error) {
|
||||
func UnarmorDecryptPrivKey(armorStr, passphrase string) (privKey cryptotypes.PrivKey, algo string, err error) {
|
||||
blockType, header, encBytes, err := DecodeArmor(armorStr)
|
||||
if err != nil {
|
||||
return privKey, "", err
|
||||
@ -193,7 +193,7 @@ func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey cryptoty
|
||||
return privKey, header[headerType], err
|
||||
}
|
||||
|
||||
func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey cryptotypes.PrivKey, err error) {
|
||||
func decryptPrivKey(saltBytes, encBytes []byte, passphrase string) (privKey cryptotypes.PrivKey, err error) {
|
||||
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)
|
||||
if err != nil {
|
||||
return privKey, errorsmod.Wrap(err, "error generating bcrypt key from passphrase")
|
||||
|
||||
@ -50,7 +50,7 @@ func TestArmorUnarmorPrivKey(t *testing.T) {
|
||||
require.Contains(t, err.Error(), "unrecognized armor type")
|
||||
|
||||
// armor key manually
|
||||
encryptPrivKeyFn := func(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) {
|
||||
encryptPrivKeyFn := func(privKey cryptotypes.PrivKey, passphrase string) (saltBytes, encBytes []byte) {
|
||||
saltBytes = cmtcrypto.CRandBytes(16)
|
||||
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), crypto.BcryptSecurityParameter)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -26,12 +26,12 @@ const (
|
||||
var Secp256k1 = secp256k1Algo{}
|
||||
|
||||
type (
|
||||
DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error)
|
||||
DeriveFn func(mnemonic, bip39Passphrase, hdPath string) ([]byte, error)
|
||||
GenerateFn func(bz []byte) types.PrivKey
|
||||
)
|
||||
|
||||
type WalletGenerator interface {
|
||||
Derive(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error)
|
||||
Derive(mnemonic, bip39Passphrase, hdPath string) ([]byte, error)
|
||||
Generate(bz []byte) types.PrivKey
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ func (s secp256k1Algo) Name() PubKeyType {
|
||||
|
||||
// Derive derives and returns the secp256k1 private key for the given seed and HD path.
|
||||
func (s secp256k1Algo) Derive() DeriveFn {
|
||||
return func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) {
|
||||
return func(mnemonic, bip39Passphrase, hdPath string) ([]byte, error) {
|
||||
seed, err := bip39.NewSeedWithErrorChecking(mnemonic, bip39Passphrase)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -156,7 +156,7 @@ func (p BIP44Params) String() string {
|
||||
}
|
||||
|
||||
// ComputeMastersFromSeed returns the master secret key's, and chain code.
|
||||
func ComputeMastersFromSeed(seed []byte) (secret [32]byte, chainCode [32]byte) {
|
||||
func ComputeMastersFromSeed(seed []byte) (secret, chainCode [32]byte) {
|
||||
curveIdentifier := []byte("Bitcoin seed")
|
||||
secret, chainCode = i64(curveIdentifier, seed)
|
||||
|
||||
@ -216,7 +216,7 @@ func DerivePrivateKeyForPath(privKeyBytes, chainCode [32]byte, path string) ([]b
|
||||
// It returns the new private key and new chain code.
|
||||
// For more information on hardened keys see:
|
||||
// - https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
|
||||
func derivePrivateKey(privKeyBytes [32]byte, chainCode [32]byte, index uint32, harden bool) ([32]byte, [32]byte) {
|
||||
func derivePrivateKey(privKeyBytes, chainCode [32]byte, index uint32, harden bool) ([32]byte, [32]byte) {
|
||||
var data []byte
|
||||
|
||||
if harden {
|
||||
@ -244,7 +244,7 @@ func derivePrivateKey(privKeyBytes [32]byte, chainCode [32]byte, index uint32, h
|
||||
}
|
||||
|
||||
// modular big endian addition
|
||||
func addScalars(a []byte, b []byte) [32]byte {
|
||||
func addScalars(a, b []byte) [32]byte {
|
||||
aInt := new(big.Int).SetBytes(a)
|
||||
bInt := new(big.Int).SetBytes(b)
|
||||
sInt := new(big.Int).Add(aInt, bInt)
|
||||
@ -263,7 +263,7 @@ func uint32ToBytes(i uint32) []byte {
|
||||
}
|
||||
|
||||
// i64 returns the two halfs of the SHA512 HMAC of key and data.
|
||||
func i64(key []byte, data []byte) (il [32]byte, ir [32]byte) {
|
||||
func i64(key, data []byte) (il, ir [32]byte) {
|
||||
mac := hmac.New(sha512.New, key)
|
||||
// sha512 does not err
|
||||
_, _ = mac.Write(data)
|
||||
|
||||
@ -1978,7 +1978,7 @@ func TestChangeBcrypt(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func requireEqualRenamedKey(t *testing.T, key *Record, mnemonic *Record, nameMatch bool) {
|
||||
func requireEqualRenamedKey(t *testing.T, key, mnemonic *Record, nameMatch bool) {
|
||||
if nameMatch {
|
||||
require.Equal(t, key.Name, mnemonic.Name)
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ type hashed struct {
|
||||
// cost. If the cost given is less than MinCost, the cost will be set to
|
||||
// DefaultCost, instead. Use CompareHashAndPassword, as defined in this package,
|
||||
// to compare the returned hashed password with its cleartext version.
|
||||
func GenerateFromPassword(salt []byte, password []byte, cost uint32) ([]byte, error) {
|
||||
func GenerateFromPassword(salt, password []byte, cost uint32) ([]byte, error) {
|
||||
if len(salt) != maxSaltSize {
|
||||
return nil, fmt.Errorf("salt len must be %v", maxSaltSize)
|
||||
}
|
||||
@ -129,7 +129,7 @@ func Cost(hashedPassword []byte) (uint32, error) {
|
||||
return p.cost, nil
|
||||
}
|
||||
|
||||
func newFromPassword(salt []byte, password []byte, cost uint32) (*hashed, error) {
|
||||
func newFromPassword(salt, password []byte, cost uint32) (*hashed, error) {
|
||||
if cost < MinCost {
|
||||
cost = DefaultCost
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ func (pubKey *PubKey) Bytes() []byte {
|
||||
return pubKey.Key
|
||||
}
|
||||
|
||||
func (pubKey *PubKey) VerifySignature(msg []byte, sig []byte) bool {
|
||||
func (pubKey *PubKey) VerifySignature(msg, sig []byte) bool {
|
||||
// make sure we use the same algorithm to sign
|
||||
if len(sig) != SignatureSize {
|
||||
return false
|
||||
|
||||
@ -39,7 +39,7 @@ func NormalizeS(sigS *big.Int) *big.Int {
|
||||
// signatureRaw will serialize signature to R || S.
|
||||
// R, S are padded to 32 bytes respectively.
|
||||
// code roughly copied from secp256k1_nocgo.go
|
||||
func signatureRaw(r *big.Int, s *big.Int) []byte {
|
||||
func signatureRaw(r, s *big.Int) []byte {
|
||||
rBytes := r.Bytes()
|
||||
sBytes := s.Bytes()
|
||||
sigBytes := make([]byte, 64)
|
||||
|
||||
@ -61,7 +61,7 @@ func (pk *PubKey) Bytes() []byte {
|
||||
// where the s integer component of the signature is in the
|
||||
// lower half of the curve order
|
||||
// 7/21/21 - expects raw encoded signature (fixed-width 64-bytes, R || S)
|
||||
func (pk *PubKey) VerifySignature(msg []byte, sig []byte) bool {
|
||||
func (pk *PubKey) VerifySignature(msg, sig []byte) bool {
|
||||
// check length for raw signature
|
||||
// which is two 32-byte padded big.Ints
|
||||
// concatenated
|
||||
|
||||
@ -100,7 +100,7 @@ func (m *LegacyAminoPubKey) VerifyMultisignature(getSignBytes multisigtypes.GetS
|
||||
// VerifySignature implements cryptotypes.PubKey VerifySignature method,
|
||||
// it panics because it can't handle MultiSignatureData
|
||||
// cf. https://github.com/cosmos/cosmos-sdk/issues/7109#issuecomment-686329936
|
||||
func (m *LegacyAminoPubKey) VerifySignature(msg []byte, sig []byte) bool {
|
||||
func (m *LegacyAminoPubKey) VerifySignature(msg, sig []byte) bool {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ var (
|
||||
// The caller is responsible for ensuring that msg cannot be chosen
|
||||
// directly by an attacker. It is usually preferable to use a cryptographic
|
||||
// hash function on any input before handing it to this function.
|
||||
func Sign(msg []byte, seckey []byte) ([]byte, error) {
|
||||
func Sign(msg, seckey []byte) ([]byte, error) {
|
||||
if len(msg) != 32 {
|
||||
return nil, ErrInvalidMsgLen
|
||||
}
|
||||
@ -102,7 +102,7 @@ func Sign(msg []byte, seckey []byte) ([]byte, error) {
|
||||
// msg must be the 32-byte hash of the message to be signed.
|
||||
// sig must be a 65-byte compact ECDSA signature containing the
|
||||
// recovery id as the last element.
|
||||
func RecoverPubkey(msg []byte, sig []byte) ([]byte, error) {
|
||||
func RecoverPubkey(msg, sig []byte) ([]byte, error) {
|
||||
if len(msg) != 32 {
|
||||
return nil, ErrInvalidMsgLen
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) {
|
||||
|
||||
// VerifyBytes verifies a signature of the form R || S.
|
||||
// It rejects signatures which are not in lower-S form.
|
||||
func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool {
|
||||
func (pubKey *PubKey) VerifySignature(msg, sigStr []byte) bool {
|
||||
if len(sigStr) != 64 {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ func (m *PubKey) Type() string {
|
||||
}
|
||||
|
||||
// VerifySignature implements SDK PubKey interface.
|
||||
func (m *PubKey) VerifySignature(msg []byte, sig []byte) bool {
|
||||
func (m *PubKey) VerifySignature(msg, sig []byte) bool {
|
||||
return m.Key.VerifySignature(msg, sig)
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
)
|
||||
|
||||
func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool) {
|
||||
func checkAminoJSON(t *testing.T, src, dst interface{}, isNil bool) {
|
||||
// Marshal to JSON bytes.
|
||||
js, err := cdc.MarshalJSON(src)
|
||||
require.Nil(t, err, "%+v", err)
|
||||
|
||||
@ -11,7 +11,7 @@ type PubKey interface {
|
||||
|
||||
Address() Address
|
||||
Bytes() []byte
|
||||
VerifySignature(msg []byte, sig []byte) bool
|
||||
VerifySignature(msg, sig []byte) bool
|
||||
Equals(PubKey) bool
|
||||
Type() string
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ var ErrCiphertextDecrypt = errors.New("ciphertext decryption failed")
|
||||
|
||||
// secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
|
||||
// The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
|
||||
func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte) {
|
||||
func EncryptSymmetric(plaintext, secret []byte) (ciphertext []byte) {
|
||||
if len(secret) != secretLen {
|
||||
panic(fmt.Sprintf("Secret must be 32 bytes long, got len %v", len(secret)))
|
||||
}
|
||||
@ -36,7 +36,7 @@ func EncryptSymmetric(plaintext []byte, secret []byte) (ciphertext []byte) {
|
||||
|
||||
// secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase))
|
||||
// The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext.
|
||||
func DecryptSymmetric(ciphertext []byte, secret []byte) (plaintext []byte, err error) {
|
||||
func DecryptSymmetric(ciphertext, secret []byte) (plaintext []byte, err error) {
|
||||
if len(secret) != secretLen {
|
||||
panic(fmt.Sprintf("Secret must be 32 bytes long, got len %v", len(secret)))
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func CombineErrors(ret error, also error, desc string) error {
|
||||
func CombineErrors(ret, also error, desc string) error {
|
||||
if also != nil {
|
||||
if ret != nil {
|
||||
ret = fmt.Errorf("%w; %v: %v", ret, desc, also)
|
||||
|
||||
@ -136,14 +136,14 @@ func (s kvStoreAdapter) Has(key []byte) bool {
|
||||
return has
|
||||
}
|
||||
|
||||
func (s kvStoreAdapter) Set(key []byte, value []byte) {
|
||||
func (s kvStoreAdapter) Set(key, value []byte) {
|
||||
err := s.store.Set(key, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s kvStoreAdapter) Iterator(start []byte, end []byte) dbm.Iterator {
|
||||
func (s kvStoreAdapter) Iterator(start, end []byte) dbm.Iterator {
|
||||
it, err := s.store.Iterator(start, end)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -151,7 +151,7 @@ func (s kvStoreAdapter) Iterator(start []byte, end []byte) dbm.Iterator {
|
||||
return it
|
||||
}
|
||||
|
||||
func (s kvStoreAdapter) ReverseIterator(start []byte, end []byte) dbm.Iterator {
|
||||
func (s kvStoreAdapter) ReverseIterator(start, end []byte) dbm.Iterator {
|
||||
it, err := s.store.ReverseIterator(start, end)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -34,7 +34,7 @@ type AppI interface {
|
||||
LoadHeight(height int64) error
|
||||
|
||||
// Exports the state of the application for a genesis file.
|
||||
ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string) (types.ExportedApp, error)
|
||||
ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (types.ExportedApp, error)
|
||||
|
||||
// Helper for the simulation framework.
|
||||
SimulationManager() *module.SimulationManager
|
||||
|
||||
@ -126,7 +126,7 @@ func serializeProtoMessages(messages []proto.Message) [][]byte {
|
||||
}
|
||||
|
||||
func (s *GRPCWebTestSuite) makeRequest(
|
||||
verb string, method string, headers http.Header, body io.Reader, isText bool,
|
||||
verb, method string, headers http.Header, body io.Reader, isText bool,
|
||||
) (*http.Response, error) {
|
||||
val := s.network.Validators[0]
|
||||
contentType := "application/grpc-web"
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
// server context object with the appropriate server and client objects injected
|
||||
// into the underlying stdlib Context. It also handles adding core CLI flags,
|
||||
// specifically the logging flags. It returns an error upon execution failure.
|
||||
func Execute(rootCmd *cobra.Command, envPrefix string, defaultHome string) error {
|
||||
func Execute(rootCmd *cobra.Command, envPrefix, defaultHome string) error {
|
||||
// Create and set a client.Context on the command's Context. During the pre-run
|
||||
// of the root command, a default initialized client.Context is provided to
|
||||
// seed child command execution with values such as AccountRetriever, Keyring,
|
||||
|
||||
@ -37,7 +37,7 @@ func (t testPubKey) Address() cryptotypes.Address { return t.address.Bytes() }
|
||||
|
||||
func (t testPubKey) Bytes() []byte { panic("not implemented") }
|
||||
|
||||
func (t testPubKey) VerifySignature(msg []byte, sig []byte) bool { panic("not implemented") }
|
||||
func (t testPubKey) VerifySignature(msg, sig []byte) bool { panic("not implemented") }
|
||||
|
||||
func (t testPubKey) Equals(key cryptotypes.PubKey) bool { panic("not implemented") }
|
||||
|
||||
@ -53,7 +53,7 @@ func (msg *KVStoreTx) GetSignaturesV2() (res []txsigning.SignatureV2, err error)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (msg *KVStoreTx) VerifySignature(msgByte []byte, sig []byte) bool {
|
||||
func (msg *KVStoreTx) VerifySignature(msgByte, sig []byte) bool {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
|
||||
@ -294,7 +294,7 @@ func newPrecedenceCommon(t *testing.T) precedenceCommon {
|
||||
return retval
|
||||
}
|
||||
|
||||
func (v precedenceCommon) setAll(t *testing.T, setFlag *string, setEnvVar *string, setConfigFile *string) {
|
||||
func (v precedenceCommon) setAll(t *testing.T, setFlag, setEnvVar, setConfigFile *string) {
|
||||
if setFlag != nil {
|
||||
if err := v.cmd.Flags().Set(v.flagName, *setFlag); err != nil {
|
||||
t.Fatalf("Failed setting flag %q", v.flagName)
|
||||
|
||||
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
// DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests.
|
||||
func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Context {
|
||||
func DefaultContext(key, tkey storetypes.StoreKey) sdk.Context {
|
||||
db := dbm.NewMemDB()
|
||||
cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
|
||||
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
|
||||
@ -37,7 +37,7 @@ type TestContext struct {
|
||||
CMS store.CommitMultiStore
|
||||
}
|
||||
|
||||
func DefaultContextWithDB(t *testing.T, key storetypes.StoreKey, tkey storetypes.StoreKey) TestContext {
|
||||
func DefaultContextWithDB(t *testing.T, key, tkey storetypes.StoreKey) TestContext {
|
||||
db := dbm.NewMemDB()
|
||||
cms := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics())
|
||||
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
|
||||
|
||||
@ -196,7 +196,7 @@ func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalance
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeFile(name string, dir string, contents []byte) error {
|
||||
func writeFile(name, dir string, contents []byte) error {
|
||||
file := filepath.Join(dir, name)
|
||||
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
|
||||
@ -60,7 +60,7 @@ func GetRequest(url string) ([]byte, error) {
|
||||
|
||||
// PostRequest defines a wrapper around an HTTP POST request with a provided URL and data.
|
||||
// An error is returned if the request or reading the body fails.
|
||||
func PostRequest(url string, contentType string, data []byte) ([]byte, error) {
|
||||
func PostRequest(url, contentType string, data []byte) ([]byte, error) {
|
||||
res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while sending post request: %w", err)
|
||||
|
||||
@ -100,7 +100,7 @@ func CreateRandomAccounts(accNum int) []sdk.AccAddress {
|
||||
return testAddrs
|
||||
}
|
||||
|
||||
func TestAddr(addr string, bech string) (sdk.AccAddress, error) {
|
||||
func TestAddr(addr, bech string) (sdk.AccAddress, error) {
|
||||
res, err := sdk.AccAddressFromHexUnsafe(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -131,7 +131,7 @@ func GetSimulationLog(storeName string, sdr simtypes.StoreDecoderRegistry, kvAs,
|
||||
|
||||
// DiffKVStores compares two KVstores and returns all the key/value pairs
|
||||
// that differ from one another. It also skips value comparison for a set of provided prefixes.
|
||||
func DiffKVStores(a storetypes.KVStore, b storetypes.KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) {
|
||||
func DiffKVStores(a, b storetypes.KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []kv.Pair) {
|
||||
iterA := a.Iterator(nil, nil)
|
||||
|
||||
defer iterA.Close()
|
||||
|
||||
@ -88,6 +88,6 @@ func Module(moduleName string, derivationKeys ...[]byte) []byte {
|
||||
// Derive derives a new address from the main `address` and a derivation `key`.
|
||||
// This function is used to create a sub accounts. To create a module accounts use the
|
||||
// `Module` function.
|
||||
func Derive(address []byte, key []byte) []byte {
|
||||
func Derive(address, key []byte) []byte {
|
||||
return Hash(conv.UnsafeBytesToStr(address), key)
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ var invalidStrs = []string{
|
||||
types.Bech32PrefixConsPub + "6789",
|
||||
}
|
||||
|
||||
func (s *addressTestSuite) testMarshal(original interface{}, res interface{}, marshal func() ([]byte, error), unmarshal func([]byte) error) {
|
||||
func (s *addressTestSuite) testMarshal(original, res interface{}, marshal func() ([]byte, error), unmarshal func([]byte) error) {
|
||||
bz, err := marshal()
|
||||
s.Require().Nil(err)
|
||||
s.Require().Nil(unmarshal(bz))
|
||||
|
||||
@ -11,7 +11,7 @@ func coinName(suffix int) string {
|
||||
|
||||
func BenchmarkCoinsAdditionIntersect(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
|
||||
benchmarkingFunc := func(numCoinsA, numCoinsB int) func(b *testing.B) {
|
||||
return func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
coinsA := Coins(make([]Coin, numCoinsA))
|
||||
@ -42,7 +42,7 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) {
|
||||
|
||||
func BenchmarkCoinsAdditionNoIntersect(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
|
||||
benchmarkingFunc := func(numCoinsA, numCoinsB int) func(b *testing.B) {
|
||||
return func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
coinsA := Coins(make([]Coin, numCoinsA))
|
||||
|
||||
@ -36,7 +36,7 @@ func (t testPubKey) Address() cryptotypes.Address { return t.address.Bytes() }
|
||||
|
||||
func (t testPubKey) Bytes() []byte { panic("not implemented") }
|
||||
|
||||
func (t testPubKey) VerifySignature(msg []byte, sig []byte) bool { panic("not implemented") }
|
||||
func (t testPubKey) VerifySignature(msg, sig []byte) bool { panic("not implemented") }
|
||||
|
||||
func (t testPubKey) Equals(key cryptotypes.PubKey) bool { panic("not implemented") }
|
||||
|
||||
|
||||
@ -464,7 +464,7 @@ func (s *MempoolTestSuite) TestRandomWalkTxs() {
|
||||
seed, s.iterations, duration.Milliseconds())
|
||||
}
|
||||
|
||||
func genRandomTxs(seed int64, countTx int, countAccount int) (res []testTx) {
|
||||
func genRandomTxs(seed int64, countTx, countAccount int) (res []testTx) {
|
||||
maxPriority := 100
|
||||
r := rand.New(rand.NewSource(seed))
|
||||
accounts := simtypes.RandomAccounts(r, countAccount)
|
||||
@ -491,7 +491,7 @@ func genRandomTxs(seed int64, countTx int, countAccount int) (res []testTx) {
|
||||
|
||||
// since there are multiple valid ordered graph traversals for a given set of txs strict
|
||||
// validation against the ordered txs generated from this function is not possible as written
|
||||
func genOrderedTxs(seed int64, maxTx int, numAcc int) (ordered []testTx, shuffled []testTx) {
|
||||
func genOrderedTxs(seed int64, maxTx, numAcc int) (ordered, shuffled []testTx) {
|
||||
r := rand.New(rand.NewSource(seed))
|
||||
accountNonces := make(map[string]uint64)
|
||||
prange := 10
|
||||
|
||||
@ -85,7 +85,7 @@ func (c *configurator) Error() error {
|
||||
}
|
||||
|
||||
// NewConfigurator returns a new Configurator instance
|
||||
func NewConfigurator(cdc codec.Codec, msgServer grpc.Server, queryServer grpc.Server) Configurator {
|
||||
func NewConfigurator(cdc codec.Codec, msgServer, queryServer grpc.Server) Configurator {
|
||||
return &configurator{
|
||||
cdc: cdc,
|
||||
msgServer: msgServer,
|
||||
|
||||
@ -258,7 +258,7 @@ func encodeCollKey[K, V any, C Collection[K, V]](coll C, key K) ([]byte, error)
|
||||
return buffer, err
|
||||
}
|
||||
|
||||
func getCollIter[K, V any, C Collection[K, V]](ctx context.Context, coll C, prefix []byte, start []byte, reverse bool) (collections.Iterator[K, V], error) {
|
||||
func getCollIter[K, V any, C Collection[K, V]](ctx context.Context, coll C, prefix, start []byte, reverse bool) (collections.Iterator[K, V], error) {
|
||||
var end []byte
|
||||
if prefix != nil {
|
||||
start = append(prefix, start...)
|
||||
|
||||
@ -48,7 +48,7 @@ func TestCollectionPagination(t *testing.T) {
|
||||
type test struct {
|
||||
req *PageRequest
|
||||
expResp *PageResponse
|
||||
filter func(key uint64, value uint64) bool
|
||||
filter func(key, value uint64) bool
|
||||
expResults []collections.KeyValue[uint64, uint64]
|
||||
wantErr error
|
||||
}
|
||||
@ -101,7 +101,7 @@ func TestCollectionPagination(t *testing.T) {
|
||||
expResp: &PageResponse{
|
||||
NextKey: encodeKey(5),
|
||||
},
|
||||
filter: func(key uint64, value uint64) bool {
|
||||
filter: func(key, value uint64) bool {
|
||||
return key%2 == 0
|
||||
},
|
||||
expResults: []collections.KeyValue[uint64, uint64]{
|
||||
@ -118,7 +118,7 @@ func TestCollectionPagination(t *testing.T) {
|
||||
expResp: &PageResponse{
|
||||
NextKey: encodeKey(7),
|
||||
},
|
||||
filter: func(key uint64, value uint64) bool {
|
||||
filter: func(key, value uint64) bool {
|
||||
return key%2 == 0
|
||||
},
|
||||
expResults: []collections.KeyValue[uint64, uint64]{
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
func FilteredPaginate(
|
||||
prefixStore types.KVStore,
|
||||
pageRequest *PageRequest,
|
||||
onResult func(key []byte, value []byte, accumulate bool) (bool, error),
|
||||
onResult func(key, value []byte, accumulate bool) (bool, error),
|
||||
) (*PageResponse, error) {
|
||||
// if the PageRequest is nil, use default PageRequest
|
||||
if pageRequest == nil {
|
||||
|
||||
@ -195,7 +195,7 @@ func (s *paginationTestSuite) TestFilteredPaginate() {
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
|
||||
var balResult sdk.Coins
|
||||
pageRes, err := query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
pageRes, err := query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
@ -226,7 +226,7 @@ func execFilterPaginate(store storetypes.KVStore, pageReq *query.PageRequest, ap
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
|
||||
var balResult sdk.Coins
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
@ -268,7 +268,7 @@ func (s *paginationTestSuite) TestFilteredPaginationsNextKey() {
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
|
||||
var balResult sdk.Coins
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
|
||||
@ -85,7 +85,7 @@ func FuzzPagination(f *testing.F) {
|
||||
authStore := suite.ctx.KVStore(suite.app.UnsafeFindStoreKey(types.StoreKey))
|
||||
balancesStore := prefix.NewStore(authStore, types.BalancesPrefix)
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
_, _ = query.Paginate(accountStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
_, _ = query.Paginate(accountStore, req.Pagination, func(key, value []byte) error {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
|
||||
@ -52,7 +52,7 @@ func ParsePagination(pageReq *PageRequest) (page, limit int, err error) {
|
||||
func Paginate(
|
||||
prefixStore types.KVStore,
|
||||
pageRequest *PageRequest,
|
||||
onResult func(key []byte, value []byte) error,
|
||||
onResult func(key, value []byte) error,
|
||||
) (*PageResponse, error) {
|
||||
// if the PageRequest is nil, use default PageRequest
|
||||
if pageRequest == nil {
|
||||
|
||||
@ -354,7 +354,7 @@ func (s *paginationTestSuite) TestPaginate() {
|
||||
authStore := s.ctx.KVStore(s.app.UnsafeFindStoreKey(types.StoreKey))
|
||||
balancesStore := prefix.NewStore(authStore, types.BalancesPrefix)
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key, value []byte) error {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
|
||||
@ -230,7 +230,7 @@ func WrapServiceResult(ctx Context, res proto.Message, err error) (*Result, erro
|
||||
}
|
||||
|
||||
// calculate total pages in an overflow safe manner
|
||||
func calcTotalPages(totalCount int64, limit int64) int64 {
|
||||
func calcTotalPages(totalCount, limit int64) int64 {
|
||||
totalPages := int64(0)
|
||||
if totalCount != 0 && limit != 0 {
|
||||
if totalCount%limit > 0 {
|
||||
|
||||
@ -25,7 +25,7 @@ var (
|
||||
)
|
||||
|
||||
// TokensToConsensusPower - convert input tokens to potential consensus-engine power
|
||||
func TokensToConsensusPower(tokens sdkmath.Int, powerReduction sdkmath.Int) int64 {
|
||||
func TokensToConsensusPower(tokens, powerReduction sdkmath.Int) int64 {
|
||||
return (tokens.Quo(powerReduction)).Int64()
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ func AppendLengthPrefixedBytes(args ...[]byte) []byte {
|
||||
}
|
||||
|
||||
// ParseLengthPrefixedBytes panics when store key length is not equal to the given length.
|
||||
func ParseLengthPrefixedBytes(key []byte, startIndex int, sliceLength int) ([]byte, int) {
|
||||
func ParseLengthPrefixedBytes(key []byte, startIndex, sliceLength int) ([]byte, int) {
|
||||
neededLength := startIndex + sliceLength
|
||||
endIndex := neededLength - 1
|
||||
kv.AssertKeyAtLeastLength(key, neededLength)
|
||||
|
||||
@ -192,7 +192,7 @@ func (suite *AnteTestSuite) RunTestCase(t *testing.T, tc TestCase, args TestCase
|
||||
// CreateTestTx is a helper function to create a tx given multiple inputs.
|
||||
func (suite *AnteTestSuite) CreateTestTx(
|
||||
ctx sdk.Context, privs []cryptotypes.PrivKey,
|
||||
accNums []uint64, accSeqs []uint64,
|
||||
accNums, accSeqs []uint64,
|
||||
chainID string, signMode signing.SignMode,
|
||||
) (xauthsigning.Tx, error) {
|
||||
// First round: we gather all the signer infos. We use the "set empty
|
||||
|
||||
@ -54,7 +54,7 @@ func TxValidateSignaturesExec(clientCtx client.Context, filename string) (testut
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetValidateSignaturesCommand(), args)
|
||||
}
|
||||
|
||||
func TxMultiSignExec(clientCtx client.Context, from string, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
func TxMultiSignExec(clientCtx client.Context, from, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID),
|
||||
filename,
|
||||
@ -97,7 +97,7 @@ func QueryAccountExec(clientCtx client.Context, address fmt.Stringer, extraArgs
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAccountCmd(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxMultiSignBatchExec(clientCtx client.Context, filename string, from string, sigFile1 string, sigFile2 string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
func TxMultiSignBatchExec(clientCtx client.Context, filename, from, sigFile1, sigFile2 string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
filename,
|
||||
|
||||
@ -80,7 +80,7 @@ var _ AccountKeeperI = &AccountKeeper{}
|
||||
// may use auth.Keeper to access the accounts permissions map.
|
||||
func NewAccountKeeper(
|
||||
cdc codec.BinaryCodec, storeService store.KVStoreService, proto func() sdk.AccountI,
|
||||
maccPerms map[string][]string, bech32Prefix string, authority string,
|
||||
maccPerms map[string][]string, bech32Prefix, authority string,
|
||||
) AccountKeeper {
|
||||
permAddrs := make(map[string]types.PermissionsForAddress)
|
||||
for name, perms := range maccPerms {
|
||||
|
||||
@ -641,7 +641,7 @@ func TestMigrateVestingAccounts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func trackingCorrected(ctx sdk.Context, t *testing.T, ak keeper.AccountKeeper, addr sdk.AccAddress, expDelVesting sdk.Coins, expDelFree sdk.Coins) {
|
||||
func trackingCorrected(ctx sdk.Context, t *testing.T, ak keeper.AccountKeeper, addr sdk.AccAddress, expDelVesting, expDelFree sdk.Coins) {
|
||||
t.Helper()
|
||||
baseAccount := ak.GetAccount(ctx, addr)
|
||||
vDA, ok := baseAccount.(exported.VestingAccount)
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func AssertError(t *testing.T, err error, expectedErr error, expectedErrMsg string) {
|
||||
func AssertError(t *testing.T, err, expectedErr error, expectedErrMsg string) {
|
||||
switch {
|
||||
case expectedErr != nil:
|
||||
require.ErrorIs(t, err, expectedErr)
|
||||
|
||||
@ -55,7 +55,7 @@ func (m *ModuleCredential) Bytes() []byte {
|
||||
}
|
||||
|
||||
// VerifySignature returns always false, making the account unclaimable
|
||||
func (m *ModuleCredential) VerifySignature(_ []byte, _ []byte) bool {
|
||||
func (m *ModuleCredential) VerifySignature(_, _ []byte) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,6 @@ import (
|
||||
// for creating vesting accounts with funds.
|
||||
type BankKeeper interface {
|
||||
IsSendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error
|
||||
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
BlockedAddr(addr sdk.AccAddress) bool
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ func (k Keeper) getGrant(ctx sdk.Context, skey []byte) (grant authz.Grant, found
|
||||
return grant, true
|
||||
}
|
||||
|
||||
func (k Keeper) update(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, updated authz.Authorization) error {
|
||||
func (k Keeper) update(ctx sdk.Context, grantee, granter sdk.AccAddress, updated authz.Authorization) error {
|
||||
skey := grantStoreKey(grantee, granter, updated.MsgTypeURL())
|
||||
grant, found := k.getGrant(ctx, skey)
|
||||
if !found {
|
||||
@ -205,7 +205,7 @@ func (k Keeper) SaveGrant(ctx sdk.Context, grantee, granter sdk.AccAddress, auth
|
||||
|
||||
// DeleteGrant revokes any authorization for the provided message type granted to the grantee
|
||||
// by the granter.
|
||||
func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error {
|
||||
func (k Keeper) DeleteGrant(ctx sdk.Context, grantee, granter sdk.AccAddress, msgType string) error {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
skey := grantStoreKey(grantee, granter, msgType)
|
||||
grant, found := k.getGrant(ctx, skey)
|
||||
@ -230,7 +230,7 @@ func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk
|
||||
}
|
||||
|
||||
// GetAuthorizations Returns list of `Authorizations` granted to the grantee by the granter.
|
||||
func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress) ([]authz.Authorization, error) {
|
||||
func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee, granter sdk.AccAddress) ([]authz.Authorization, error) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
key := grantStoreKey(grantee, granter, "")
|
||||
iter := storetypes.KVStorePrefixIterator(store, key)
|
||||
@ -259,7 +259,7 @@ func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee sdk.AccAddress, grant
|
||||
// - No grant is found.
|
||||
// - A grant is found, but it is expired.
|
||||
// - There was an error getting the authorization from the grant.
|
||||
func (k Keeper) GetAuthorization(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) {
|
||||
func (k Keeper) GetAuthorization(ctx sdk.Context, grantee, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) {
|
||||
grant, found := k.getGrant(ctx, grantStoreKey(grantee, granter, msgType))
|
||||
if !found || (grant.Expiration != nil && grant.Expiration.Before(ctx.BlockHeader().Time)) {
|
||||
return nil, nil
|
||||
@ -278,7 +278,7 @@ func (k Keeper) GetAuthorization(ctx sdk.Context, grantee sdk.AccAddress, grante
|
||||
// It should not be used in query or msg services without charging additional gas.
|
||||
// The iteration stops when the handler function returns true or the iterator exhaust.
|
||||
func (k Keeper) IterateGrants(ctx sdk.Context,
|
||||
handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool,
|
||||
handler func(granterAddr, granteeAddr sdk.AccAddress, grant authz.Grant) bool,
|
||||
) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
iter := storetypes.KVStorePrefixIterator(store, GrantKey)
|
||||
@ -308,7 +308,7 @@ func (k Keeper) getGrantQueueItem(ctx sdk.Context, expiration time.Time, granter
|
||||
}
|
||||
|
||||
func (k Keeper) setGrantQueueItem(ctx sdk.Context, expiration time.Time,
|
||||
granter sdk.AccAddress, grantee sdk.AccAddress, queueItems *authz.GrantQueueItem,
|
||||
granter, grantee sdk.AccAddress, queueItems *authz.GrantQueueItem,
|
||||
) error {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz, err := k.cdc.Marshal(queueItems)
|
||||
|
||||
@ -29,7 +29,7 @@ const StoreKey = authz.ModuleName
|
||||
// Items are stored with the following key: values
|
||||
//
|
||||
// - 0x01<granterAddressLen (1 Byte)><granterAddress_Bytes><granteeAddressLen (1 Byte)><granteeAddress_Bytes><msgType_Bytes>: Grant
|
||||
func grantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) []byte {
|
||||
func grantStoreKey(grantee, granter sdk.AccAddress, msgType string) []byte {
|
||||
m := conv.UnsafeStrToBytes(msgType)
|
||||
granter = address.MustLengthPrefix(granter)
|
||||
grantee = address.MustLengthPrefix(grantee)
|
||||
@ -79,7 +79,7 @@ func parseGrantQueueKey(key []byte) (time.Time, sdk.AccAddress, sdk.AccAddress,
|
||||
// Key format is:
|
||||
//
|
||||
// 0x02<expiration><granterAddressLen (1 Byte)><granterAddressBytes><granteeAddressLen (1 Byte)><granteeAddressBytes>: GrantQueueItem
|
||||
func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte {
|
||||
func GrantQueueKey(expiration time.Time, granter, grantee sdk.AccAddress) []byte {
|
||||
exp := sdk.FormatTimeBytes(expiration)
|
||||
granter = address.MustLengthPrefix(granter)
|
||||
grantee = address.MustLengthPrefix(grantee)
|
||||
|
||||
@ -23,7 +23,7 @@ var (
|
||||
// Key format is
|
||||
//
|
||||
// - 0x02<grant_expiration_Bytes>: GrantQueueItem
|
||||
func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte {
|
||||
func GrantQueueKey(expiration time.Time, granter, grantee sdk.AccAddress) []byte {
|
||||
exp := sdk.FormatTimeBytes(expiration)
|
||||
granter = address.MustLengthPrefix(granter)
|
||||
grantee = address.MustLengthPrefix(grantee)
|
||||
@ -41,7 +41,7 @@ func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.Acc
|
||||
// Items are stored with the following key: values
|
||||
//
|
||||
// - 0x01<granterAddressLen (1 Byte)><granterAddress_Bytes><granteeAddressLen (1 Byte)><granteeAddress_Bytes><msgType_Bytes>: Grant
|
||||
func GrantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) []byte {
|
||||
func GrantStoreKey(grantee, granter sdk.AccAddress, msgType string) []byte {
|
||||
m := conv.UnsafeStrToBytes(msgType)
|
||||
granter = address.MustLengthPrefix(granter)
|
||||
grantee = address.MustLengthPrefix(grantee)
|
||||
|
||||
@ -30,7 +30,7 @@ var (
|
||||
// NewMsgGrant creates a new MsgGrant
|
||||
//
|
||||
//nolint:interfacer
|
||||
func NewMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) {
|
||||
func NewMsgGrant(granter, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) {
|
||||
m := &MsgGrant{
|
||||
Granter: granter.String(),
|
||||
Grantee: grantee.String(),
|
||||
@ -111,7 +111,7 @@ func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error {
|
||||
// NewMsgRevoke creates a new MsgRevoke
|
||||
//
|
||||
//nolint:interfacer
|
||||
func NewMsgRevoke(granter sdk.AccAddress, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke {
|
||||
func NewMsgRevoke(granter, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke {
|
||||
return MsgRevoke{
|
||||
Granter: granter.String(),
|
||||
Grantee: grantee.String(),
|
||||
|
||||
@ -244,7 +244,7 @@ func (k BaseKeeper) DenomOwners(
|
||||
pageRes, err := query.FilteredPaginate(
|
||||
denomPrefixStore,
|
||||
req.Pagination,
|
||||
func(key []byte, _ []byte, accumulate bool) (bool, error) {
|
||||
func(key, _ []byte, accumulate bool) (bool, error) {
|
||||
if accumulate {
|
||||
address, _, err := types.AddressAndDenomFromBalancesStore(key)
|
||||
if err != nil {
|
||||
|
||||
@ -78,11 +78,11 @@ func newIbcCoin(amt int64) sdk.Coin {
|
||||
return sdk.NewInt64Coin(getIBCDenom(ibcPath, ibcBaseDenom), amt)
|
||||
}
|
||||
|
||||
func getIBCDenom(path string, baseDenom string) string {
|
||||
func getIBCDenom(path, baseDenom string) string {
|
||||
return fmt.Sprintf("%s/%s", "ibc", hex.EncodeToString(getIBCHash(path, baseDenom)))
|
||||
}
|
||||
|
||||
func getIBCHash(path string, baseDenom string) []byte {
|
||||
func getIBCHash(path, baseDenom string) []byte {
|
||||
hash := sha256.Sum256([]byte(path + "/" + baseDenom))
|
||||
return hash[:]
|
||||
}
|
||||
@ -173,7 +173,7 @@ func (suite *KeeperTestSuite) mockBurnCoins(moduleAcc *authtypes.ModuleAccount)
|
||||
suite.authKeeper.EXPECT().GetAccount(suite.ctx, moduleAcc.GetAddress()).Return(moduleAcc)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) mockSendCoinsFromModuleToModule(sender *authtypes.ModuleAccount, receiver *authtypes.ModuleAccount) {
|
||||
func (suite *KeeperTestSuite) mockSendCoinsFromModuleToModule(sender, receiver *authtypes.ModuleAccount) {
|
||||
suite.authKeeper.EXPECT().GetModuleAddress(sender.Name).Return(sender.GetAddress())
|
||||
suite.authKeeper.EXPECT().GetModuleAccount(suite.ctx, receiver.Name).Return(receiver)
|
||||
suite.authKeeper.EXPECT().GetAccount(suite.ctx, sender.GetAddress()).Return(sender)
|
||||
@ -213,7 +213,7 @@ func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc sdk.Accoun
|
||||
suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) {
|
||||
func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc, mAcc sdk.AccountI) {
|
||||
vacc, ok := acc.(banktypes.VestingAccount)
|
||||
if ok {
|
||||
suite.authKeeper.EXPECT().SetAccount(ctx, vacc)
|
||||
@ -222,7 +222,7 @@ func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc sdk.Account
|
||||
suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc sdk.AccountI, mAcc sdk.AccountI) {
|
||||
func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc, mAcc sdk.AccountI) {
|
||||
vacc, ok := acc.(banktypes.VestingAccount)
|
||||
if ok {
|
||||
suite.authKeeper.EXPECT().SetAccount(ctx, vacc)
|
||||
|
||||
@ -21,7 +21,7 @@ type SendKeeper interface {
|
||||
ViewKeeper
|
||||
|
||||
InputOutputCoins(ctx sdk.Context, inputs types.Input, outputs []types.Output) error
|
||||
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
|
||||
GetParams(ctx sdk.Context) types.Params
|
||||
SetParams(ctx sdk.Context, params types.Params) error
|
||||
@ -171,7 +171,7 @@ func (k BaseSendKeeper) InputOutputCoins(ctx sdk.Context, input types.Input, out
|
||||
|
||||
// SendCoins transfers amt coins from a sending account to a receiving account.
|
||||
// An error is returned upon failure.
|
||||
func (k BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error {
|
||||
func (k BaseSendKeeper) SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error {
|
||||
err := k.subUnlockedCoins(ctx, fromAddr, amt)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -58,7 +58,7 @@ func AddressAndDenomFromBalancesStore(key []byte) (sdk.AccAddress, string, error
|
||||
|
||||
// CreatePrefixedAccountStoreKey returns the key for the given account and denomination.
|
||||
// This method can be used when performing an ABCI query for the balance of an account.
|
||||
func CreatePrefixedAccountStoreKey(addr []byte, denom []byte) []byte {
|
||||
func CreatePrefixedAccountStoreKey(addr, denom []byte) []byte {
|
||||
return append(CreateAccountBalancesPrefix(addr), denom...)
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
func cloneAppend(bz []byte, tail []byte) (res []byte) {
|
||||
func cloneAppend(bz, tail []byte) (res []byte) {
|
||||
res = make([]byte, len(bz)+len(tail))
|
||||
copy(res, bz)
|
||||
copy(res[len(bz):], tail)
|
||||
|
||||
@ -32,7 +32,7 @@ type Keeper struct {
|
||||
// NewKeeper creates a new Keeper object
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, invCheckPeriod uint,
|
||||
supplyKeeper types.SupplyKeeper, feeCollectorName string, authority string,
|
||||
supplyKeeper types.SupplyKeeper, feeCollectorName, authority string,
|
||||
) *Keeper {
|
||||
return &Keeper{
|
||||
storeKey: storeKey,
|
||||
|
||||
@ -104,7 +104,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
|
||||
params := k.GetParams(ctx)
|
||||
|
||||
dwi := make([]types.DelegatorWithdrawInfo, 0)
|
||||
k.IterateDelegatorWithdrawAddrs(ctx, func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool) {
|
||||
k.IterateDelegatorWithdrawAddrs(ctx, func(del, addr sdk.AccAddress) (stop bool) {
|
||||
dwi = append(dwi, types.DelegatorWithdrawInfo{
|
||||
DelegatorAddress: del.String(),
|
||||
WithdrawAddress: addr.String(),
|
||||
|
||||
@ -31,7 +31,7 @@ type Keeper struct {
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec, key storetypes.StoreKey,
|
||||
ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper,
|
||||
feeCollectorName string, authority string,
|
||||
feeCollectorName, authority string,
|
||||
) Keeper {
|
||||
// ensure distribution module account is set
|
||||
if addr := ak.GetModuleAddress(types.ModuleName); addr == nil {
|
||||
@ -60,7 +60,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
}
|
||||
|
||||
// SetWithdrawAddr sets a new address that will receive the rewards upon withdrawal
|
||||
func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) error {
|
||||
func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr, withdrawAddr sdk.AccAddress) error {
|
||||
if k.bankKeeper.BlockedAddr(withdrawAddr) {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive external funds", withdrawAddr)
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ func (k Keeper) DeleteDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAd
|
||||
}
|
||||
|
||||
// iterate over delegator withdraw addrs
|
||||
func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool)) {
|
||||
func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del, addr sdk.AccAddress) (stop bool)) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
iter := storetypes.KVStorePrefixIterator(store, types.DelegatorWithdrawAddrPrefix)
|
||||
defer iter.Close()
|
||||
@ -332,7 +332,7 @@ func (k Keeper) SetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, heig
|
||||
}
|
||||
|
||||
// iterate over slash events between heights, inclusive
|
||||
func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValAddress, startingHeight uint64, endingHeight uint64,
|
||||
func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValAddress, startingHeight, endingHeight uint64,
|
||||
handler func(height uint64, event types.ValidatorSlashEvent) (stop bool),
|
||||
) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
@ -24,7 +24,7 @@ type BankKeeper interface {
|
||||
|
||||
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
|
||||
|
||||
SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error
|
||||
SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error
|
||||
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ type QueryValidatorSlashesParams struct {
|
||||
}
|
||||
|
||||
// creates a new instance of QueryValidatorSlashesParams
|
||||
func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight uint64, endingHeight uint64) QueryValidatorSlashesParams {
|
||||
func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight, endingHeight uint64) QueryValidatorSlashesParams {
|
||||
return QueryValidatorSlashesParams{
|
||||
ValidatorAddress: validatorAddr,
|
||||
StartingHeight: startingHeight,
|
||||
|
||||
@ -143,7 +143,7 @@ func (q Keeper) Votes(c context.Context, req *v1.QueryVotesRequest) (*v1.QueryVo
|
||||
store := ctx.KVStore(q.storeKey)
|
||||
votesStore := prefix.NewStore(store, types.VotesKey(req.ProposalId))
|
||||
|
||||
pageRes, err := query.Paginate(votesStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(votesStore, req.Pagination, func(key, value []byte) error {
|
||||
var vote v1.Vote
|
||||
if err := q.cdc.Unmarshal(value, &vote); err != nil {
|
||||
return err
|
||||
@ -239,7 +239,7 @@ func (q Keeper) Deposits(c context.Context, req *v1.QueryDepositsRequest) (*v1.Q
|
||||
store := ctx.KVStore(q.storeKey)
|
||||
depositStore := prefix.NewStore(store, types.DepositsKey(req.ProposalId))
|
||||
|
||||
pageRes, err := query.Paginate(depositStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(depositStore, req.Pagination, func(key, value []byte) error {
|
||||
var deposit v1.Deposit
|
||||
if err := q.cdc.Unmarshal(value, &deposit); err != nil {
|
||||
return err
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
|
||||
// Tally iterates over the votes and updates the tally of a proposal based on the voting power of the
|
||||
// voters
|
||||
func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes bool, burnDeposits bool, tallyResults v1.TallyResult) {
|
||||
func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes, burnDeposits bool, tallyResults v1.TallyResult) {
|
||||
results := make(map[v1.VoteOption]sdk.Dec)
|
||||
results[v1.OptionYes] = math.LegacyZeroDec()
|
||||
results[v1.OptionAbstain] = math.LegacyZeroDec()
|
||||
|
||||
@ -105,7 +105,7 @@ func (x Dec) IsNegative() bool {
|
||||
}
|
||||
|
||||
// Add adds x and y
|
||||
func Add(x Dec, y Dec) (Dec, error) {
|
||||
func Add(x, y Dec) (Dec, error) {
|
||||
return x.Add(y)
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ func (x Dec) IsZero() bool {
|
||||
|
||||
// SubNonNegative subtracts the value of y from x and returns the result with
|
||||
// arbitrary precision. Returns an error if the result is negative.
|
||||
func SubNonNegative(x Dec, y Dec) (Dec, error) {
|
||||
func SubNonNegative(x, y Dec) (Dec, error) {
|
||||
z, err := x.Sub(y)
|
||||
if err != nil {
|
||||
return Dec{}, err
|
||||
|
||||
@ -112,7 +112,7 @@ func (a AutoUInt64Table) PrefixScan(store storetypes.KVStore, start, end uint64)
|
||||
// this as an endpoint to the public without further limits. See `LimitIterator`
|
||||
//
|
||||
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
|
||||
func (a AutoUInt64Table) ReversePrefixScan(store storetypes.KVStore, start uint64, end uint64) (Iterator, error) {
|
||||
func (a AutoUInt64Table) ReversePrefixScan(store storetypes.KVStore, start, end uint64) (Iterator, error) {
|
||||
return a.table.ReversePrefixScan(store, EncodeSequence(start), EncodeSequence(end))
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ func TestAutoUInt64PrefixScan(t *testing.T) {
|
||||
expResult []testdata.TableModel
|
||||
expRowIDs []RowID
|
||||
expError *errorsmod.Error
|
||||
method func(store storetypes.KVStore, start uint64, end uint64) (Iterator, error)
|
||||
method func(store storetypes.KVStore, start, end uint64) (Iterator, error)
|
||||
}{
|
||||
"first element": {
|
||||
start: 1,
|
||||
|
||||
@ -134,7 +134,7 @@ func (i MultiKeyIndex) GetPaginated(store types.KVStore, searchKey interface{},
|
||||
// it = LimitIterator(it, defaultLimit)
|
||||
//
|
||||
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
|
||||
func (i MultiKeyIndex) PrefixScan(store types.KVStore, startI interface{}, endI interface{}) (Iterator, error) {
|
||||
func (i MultiKeyIndex) PrefixScan(store types.KVStore, startI, endI interface{}) (Iterator, error) {
|
||||
start, end, err := getStartEndBz(startI, endI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -154,7 +154,7 @@ func (i MultiKeyIndex) PrefixScan(store types.KVStore, startI interface{}, endI
|
||||
// this as an endpoint to the public without further limits. See `LimitIterator`
|
||||
//
|
||||
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
|
||||
func (i MultiKeyIndex) ReversePrefixScan(store types.KVStore, startI interface{}, endI interface{}) (Iterator, error) {
|
||||
func (i MultiKeyIndex) ReversePrefixScan(store types.KVStore, startI, endI interface{}) (Iterator, error) {
|
||||
start, end, err := getStartEndBz(startI, endI)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -167,7 +167,7 @@ func (i MultiKeyIndex) ReversePrefixScan(store types.KVStore, startI interface{}
|
||||
|
||||
// getStartEndBz gets the start and end bytes to be passed into the SDK store
|
||||
// iterator.
|
||||
func getStartEndBz(startI interface{}, endI interface{}) ([]byte, []byte, error) {
|
||||
func getStartEndBz(startI, endI interface{}) ([]byte, []byte, error) {
|
||||
start, err := getPrefixScanKeyBytes(startI)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
@ -177,7 +177,7 @@ func multiKeyAddFunc(store storetypes.KVStore, secondaryIndexKey interface{}, ro
|
||||
}
|
||||
|
||||
// difference returns the list of elements that are in a but not in b.
|
||||
func difference(a []interface{}, b []interface{}) ([]interface{}, error) {
|
||||
func difference(a, b []interface{}) ([]interface{}, error) {
|
||||
set := make(map[interface{}]struct{}, len(b))
|
||||
for _, v := range b {
|
||||
bt, err := keyPartBytes(v, true)
|
||||
|
||||
@ -273,7 +273,7 @@ func ReadAll(it Iterator, dest ModelSlicePtr) ([]RowID, error) {
|
||||
// assertDest checks that the provided dest is not nil and a pointer to a slice.
|
||||
// It also verifies that the slice elements implement *codec.ProtoMarshaler.
|
||||
// It overwrites destRef and tmpSlice using reflection.
|
||||
func assertDest(dest ModelSlicePtr, destRef *reflect.Value, tmpSlice *reflect.Value) (reflect.Type, error) {
|
||||
func assertDest(dest ModelSlicePtr, destRef, tmpSlice *reflect.Value) (reflect.Type, error) {
|
||||
if dest == nil {
|
||||
return nil, errorsmod.Wrap(errors.ErrORMInvalidArgument, "destination must not be nil")
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ type Index interface {
|
||||
// it = LimitIterator(it, defaultLimit)
|
||||
//
|
||||
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
|
||||
PrefixScan(store storetypes.KVStore, startI interface{}, endI interface{}) (Iterator, error)
|
||||
PrefixScan(store storetypes.KVStore, startI, endI interface{}) (Iterator, error)
|
||||
|
||||
// ReversePrefixScan returns an Iterator over a domain of keys in descending order. End is exclusive.
|
||||
// Start is an MultiKeyIndex key or prefix. It must be less than end, or the Iterator is invalid and error is returned.
|
||||
@ -75,7 +75,7 @@ type Index interface {
|
||||
// this as an endpoint to the public without further limits. See `LimitIterator`
|
||||
//
|
||||
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
|
||||
ReversePrefixScan(store storetypes.KVStore, startI interface{}, endI interface{}) (Iterator, error)
|
||||
ReversePrefixScan(store storetypes.KVStore, startI, endI interface{}) (Iterator, error)
|
||||
}
|
||||
|
||||
// Iterator allows iteration through a sequence of key value pairs
|
||||
|
||||
@ -210,7 +210,7 @@ func (s *GenesisTestSuite) TestInitExportGenesis() {
|
||||
s.Require().Equal(genesisState.ProposalSeq, exportedGenesisState.ProposalSeq)
|
||||
}
|
||||
|
||||
func (s *GenesisTestSuite) assertGroupPoliciesEqual(g *group.GroupPolicyInfo, other *group.GroupPolicyInfo) {
|
||||
func (s *GenesisTestSuite) assertGroupPoliciesEqual(g, other *group.GroupPolicyInfo) {
|
||||
require := s.Require()
|
||||
require.Equal(g.Address, other.Address)
|
||||
require.Equal(g.GroupId, other.GroupId)
|
||||
@ -224,7 +224,7 @@ func (s *GenesisTestSuite) assertGroupPoliciesEqual(g *group.GroupPolicyInfo, ot
|
||||
require.Equal(dp1, dp2)
|
||||
}
|
||||
|
||||
func (s *GenesisTestSuite) assertProposalsEqual(g *group.Proposal, other *group.Proposal) {
|
||||
func (s *GenesisTestSuite) assertProposalsEqual(g, other *group.Proposal) {
|
||||
require := s.Require()
|
||||
require.Equal(g.Id, other.Id)
|
||||
require.Equal(g.GroupPolicyAddress, other.GroupPolicyAddress)
|
||||
|
||||
@ -897,7 +897,7 @@ type (
|
||||
|
||||
// doUpdateGroupPolicy first makes sure that the group policy admin initiated the group policy update,
|
||||
// before performing the group policy update and emitting an event.
|
||||
func (k Keeper) doUpdateGroupPolicy(ctx sdk.Context, groupPolicy string, admin string, action groupPolicyActionFn, note string) error {
|
||||
func (k Keeper) doUpdateGroupPolicy(ctx sdk.Context, groupPolicy, admin string, action groupPolicyActionFn, note string) error {
|
||||
groupPolicyInfo, err := k.getGroupPolicyInfo(ctx, groupPolicy)
|
||||
if err != nil {
|
||||
return errorsmod.Wrap(err, "load group policy")
|
||||
@ -975,7 +975,7 @@ func (k Keeper) doAuthenticated(ctx sdk.Context, req authNGroupReq, action actio
|
||||
|
||||
// assertMetadataLength returns an error if given metadata length
|
||||
// is greater than a pre-defined maxMetadataLen.
|
||||
func (k Keeper) assertMetadataLength(metadata string, description string) error {
|
||||
func (k Keeper) assertMetadataLength(metadata, description string) error {
|
||||
if metadata != "" && uint64(len(metadata)) > k.config.MaxMetadataLen {
|
||||
return errorsmod.Wrapf(errors.ErrMaxLimit, description)
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ var (
|
||||
)
|
||||
|
||||
// NewMsgCreateGroupWithPolicy creates a new MsgCreateGroupWithPolicy.
|
||||
func NewMsgCreateGroupWithPolicy(admin string, members []MemberRequest, groupMetadata string, groupPolicyMetadata string, groupPolicyAsAdmin bool, decisionPolicy DecisionPolicy) (*MsgCreateGroupWithPolicy, error) {
|
||||
func NewMsgCreateGroupWithPolicy(admin string, members []MemberRequest, groupMetadata, groupPolicyMetadata string, groupPolicyAsAdmin bool, decisionPolicy DecisionPolicy) (*MsgCreateGroupWithPolicy, error) {
|
||||
m := &MsgCreateGroupWithPolicy{
|
||||
Admin: admin,
|
||||
Members: members,
|
||||
@ -344,7 +344,7 @@ var (
|
||||
)
|
||||
|
||||
// NewMsgUpdateGroupPolicyDecisionPolicy creates a new MsgUpdateGroupPolicyDecisionPolicy.
|
||||
func NewMsgUpdateGroupPolicyDecisionPolicy(admin sdk.AccAddress, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupPolicyDecisionPolicy, error) {
|
||||
func NewMsgUpdateGroupPolicyDecisionPolicy(admin, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupPolicyDecisionPolicy, error) {
|
||||
m := &MsgUpdateGroupPolicyDecisionPolicy{
|
||||
Admin: admin.String(),
|
||||
GroupPolicyAddress: address.String(),
|
||||
|
||||
@ -51,7 +51,7 @@ type DecisionPolicy interface {
|
||||
var _ DecisionPolicy = &ThresholdDecisionPolicy{}
|
||||
|
||||
// NewThresholdDecisionPolicy creates a threshold DecisionPolicy
|
||||
func NewThresholdDecisionPolicy(threshold string, votingPeriod time.Duration, minExecutionPeriod time.Duration) DecisionPolicy {
|
||||
func NewThresholdDecisionPolicy(threshold string, votingPeriod, minExecutionPeriod time.Duration) DecisionPolicy {
|
||||
return &ThresholdDecisionPolicy{threshold, &DecisionPolicyWindows{votingPeriod, minExecutionPeriod}}
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ func (p *ThresholdDecisionPolicy) Validate(g GroupInfo, config Config) error {
|
||||
var _ DecisionPolicy = &PercentageDecisionPolicy{}
|
||||
|
||||
// NewPercentageDecisionPolicy creates a new percentage DecisionPolicy
|
||||
func NewPercentageDecisionPolicy(percentage string, votingPeriod time.Duration, executionPeriod time.Duration) DecisionPolicy {
|
||||
func NewPercentageDecisionPolicy(percentage string, votingPeriod, executionPeriod time.Duration) DecisionPolicy {
|
||||
return &PercentageDecisionPolicy{percentage, &DecisionPolicyWindows{votingPeriod, executionPeriod}}
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
)
|
||||
|
||||
func min(a int, b int) int {
|
||||
func min(a, b int) int {
|
||||
if a <= b {
|
||||
return a
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ type Subspace struct {
|
||||
}
|
||||
|
||||
// NewSubspace constructs a store with namestore
|
||||
func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key storetypes.StoreKey, tkey storetypes.StoreKey, name string) Subspace {
|
||||
func NewSubspace(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey, name string) Subspace {
|
||||
return Subspace{
|
||||
cdc: cdc,
|
||||
legacyAmino: legacyAmino,
|
||||
|
||||
@ -73,7 +73,7 @@ func NewOperationQueue() OperationQueue {
|
||||
}
|
||||
|
||||
// queueOperations adds all future operations into the operation queue.
|
||||
func queueOperations(queuedOps OperationQueue, queuedTimeOps []simulation.FutureOperation, futureOps []simulation.FutureOperation) {
|
||||
func queueOperations(queuedOps OperationQueue, queuedTimeOps, futureOps []simulation.FutureOperation) {
|
||||
if futureOps == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ func (k Keeper) SigningInfos(c context.Context, req *types.QuerySigningInfosRequ
|
||||
var signInfos []types.ValidatorSigningInfo
|
||||
|
||||
sigInfoStore := prefix.NewStore(store, types.ValidatorSigningInfoKeyPrefix)
|
||||
pageRes, err := query.Paginate(sigInfoStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(sigInfoStore, req.Pagination, func(key, value []byte) error {
|
||||
var info types.ValidatorSigningInfo
|
||||
err := k.cdc.Unmarshal(value, &info)
|
||||
if err != nil {
|
||||
|
||||
@ -150,7 +150,7 @@ func (k Querier) ValidatorUnbondingDelegations(c context.Context, req *types.Que
|
||||
|
||||
srcValPrefix := types.GetUBDsByValIndexKey(valAddr)
|
||||
ubdStore := prefix.NewStore(store, srcValPrefix)
|
||||
pageRes, err := query.Paginate(ubdStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(ubdStore, req.Pagination, func(key, value []byte) error {
|
||||
storeKey := types.GetUBDKeyFromValIndexKey(append(srcValPrefix, key...))
|
||||
storeValue := store.Get(storeKey)
|
||||
|
||||
@ -266,7 +266,7 @@ func (k Querier) DelegatorDelegations(c context.Context, req *types.QueryDelegat
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
delStore := prefix.NewStore(store, types.GetDelegationsKey(delAddr))
|
||||
pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(delStore, req.Pagination, func(key, value []byte) error {
|
||||
delegation, err := types.UnmarshalDelegation(k.cdc, value)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -337,7 +337,7 @@ func (k Querier) DelegatorUnbondingDelegations(c context.Context, req *types.Que
|
||||
}
|
||||
|
||||
unbStore := prefix.NewStore(store, types.GetUBDsKey(delAddr))
|
||||
pageRes, err := query.Paginate(unbStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(unbStore, req.Pagination, func(key, value []byte) error {
|
||||
unbond, err := types.UnmarshalUBD(k.cdc, value)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -422,7 +422,7 @@ func (k Querier) DelegatorValidators(c context.Context, req *types.QueryDelegato
|
||||
}
|
||||
|
||||
delStore := prefix.NewStore(store, types.GetDelegationsKey(delAddr))
|
||||
pageRes, err := query.Paginate(delStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(delStore, req.Pagination, func(key, value []byte) error {
|
||||
delegation, err := types.UnmarshalDelegation(k.cdc, value)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -502,7 +502,7 @@ func queryRedelegationsFromSrcValidator(store storetypes.KVStore, k Querier, req
|
||||
|
||||
srcValPrefix := types.GetREDsFromValSrcIndexKey(valAddr)
|
||||
redStore := prefix.NewStore(store, srcValPrefix)
|
||||
res, err = query.Paginate(redStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
res, err = query.Paginate(redStore, req.Pagination, func(key, value []byte) error {
|
||||
storeKey := types.GetREDKeyFromValSrcIndexKey(append(srcValPrefix, key...))
|
||||
storeValue := store.Get(storeKey)
|
||||
red, err := types.UnmarshalRED(k.cdc, storeValue)
|
||||
@ -523,7 +523,7 @@ func queryAllRedelegations(store storetypes.KVStore, k Querier, req *types.Query
|
||||
}
|
||||
|
||||
redStore := prefix.NewStore(store, types.GetREDsKey(delAddr))
|
||||
res, err = query.Paginate(redStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
res, err = query.Paginate(redStore, req.Pagination, func(key, value []byte) error {
|
||||
redelegation, err := types.UnmarshalRED(k.cdc, value)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -30,7 +30,7 @@ import (
|
||||
//
|
||||
// Infraction was committed at the current height or at a past height,
|
||||
// not at a height in the future
|
||||
func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec) math.Int {
|
||||
func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec) math.Int {
|
||||
logger := k.Logger(ctx)
|
||||
|
||||
if slashFactor.IsNegative() {
|
||||
@ -157,7 +157,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh
|
||||
}
|
||||
|
||||
// SlashWithInfractionReason implementation doesn't require the infraction (types.Infraction) to work but is required by Interchain Security.
|
||||
func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec, _ types.Infraction) math.Int {
|
||||
func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight, power int64, slashFactor sdk.Dec, _ types.Infraction) math.Int {
|
||||
return k.Slash(ctx, consAddr, infractionHeight, power, slashFactor)
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ const gasCostPerIteration = uint64(10)
|
||||
var _ authz.Authorization = &StakeAuthorization{}
|
||||
|
||||
// NewStakeAuthorization creates a new StakeAuthorization object.
|
||||
func NewStakeAuthorization(allowed []sdk.ValAddress, denied []sdk.ValAddress, authzType AuthorizationType, amount *sdk.Coin) (*StakeAuthorization, error) {
|
||||
func NewStakeAuthorization(allowed, denied []sdk.ValAddress, authzType AuthorizationType, amount *sdk.Coin) (*StakeAuthorization, error) {
|
||||
allowedValidators, deniedValidators, err := validateAllowAndDenyValidators(allowed, denied)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -150,7 +150,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validateAllowAndDenyValidators(allowed []sdk.ValAddress, denied []sdk.ValAddress) ([]string, []string, error) {
|
||||
func validateAllowAndDenyValidators(allowed, denied []sdk.ValAddress) ([]string, []string, error) {
|
||||
if len(allowed) == 0 && len(denied) == 0 {
|
||||
return nil, nil, sdkerrors.ErrInvalidRequest.Wrap("both allowed & deny list cannot be empty")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user