mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-10-14 00:59:21 +00:00
Merge pull request #71 from planetmint/70-add-ta-registry
70 add ta registry
This commit is contained in:
commit
8b072d3186
@ -541,6 +541,7 @@ func New(
|
||||
keys[machinemoduletypes.TAIndexKey],
|
||||
keys[machinemoduletypes.IssuerPlanetmintIndexKey],
|
||||
keys[machinemoduletypes.IssuerLiquidIndexKey],
|
||||
keys[machinemoduletypes.TrustAnchorKey],
|
||||
keys[machinemoduletypes.MemStoreKey],
|
||||
app.GetSubspace(machinemoduletypes.ModuleName),
|
||||
)
|
||||
|
7
docs/static/openapi.yml
vendored
7
docs/static/openapi.yml
vendored
@ -75428,6 +75428,8 @@ definitions:
|
||||
type: string
|
||||
planetmintgo.machine.MsgAttestMachineResponse:
|
||||
type: object
|
||||
planetmintgo.machine.MsgRegisterTrustAnchorResponse:
|
||||
type: object
|
||||
planetmintgo.machine.Params:
|
||||
type: object
|
||||
description: Params defines the parameters for the module.
|
||||
@ -75478,3 +75480,8 @@ definitions:
|
||||
description: params holds all the parameters of this module.
|
||||
type: object
|
||||
description: QueryParamsResponse is response type for the Query/Params RPC method.
|
||||
planetmintgo.machine.TrustAnchor:
|
||||
type: object
|
||||
properties:
|
||||
pubkey:
|
||||
type: string
|
||||
|
8
proto/planetmintgo/machine/trust_anchor.proto
Normal file
8
proto/planetmintgo/machine/trust_anchor.proto
Normal file
@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
package planetmintgo.machine;
|
||||
|
||||
option go_package = "planetmint-go/x/machine/types";
|
||||
|
||||
message TrustAnchor {
|
||||
string pubkey = 1;
|
||||
}
|
@ -3,12 +3,14 @@ syntax = "proto3";
|
||||
package planetmintgo.machine;
|
||||
|
||||
import "planetmintgo/machine/machine.proto";
|
||||
import "planetmintgo/machine/trust_anchor.proto";
|
||||
|
||||
option go_package = "planetmint-go/x/machine/types";
|
||||
|
||||
// Msg defines the Msg service.
|
||||
service Msg {
|
||||
rpc AttestMachine (MsgAttestMachine) returns (MsgAttestMachineResponse);
|
||||
rpc AttestMachine (MsgAttestMachine ) returns (MsgAttestMachineResponse );
|
||||
rpc RegisterTrustAnchor (MsgRegisterTrustAnchor) returns (MsgRegisterTrustAnchorResponse);
|
||||
}
|
||||
message MsgAttestMachine {
|
||||
string creator = 1;
|
||||
@ -17,3 +19,10 @@ message MsgAttestMachine {
|
||||
|
||||
message MsgAttestMachineResponse {}
|
||||
|
||||
message MsgRegisterTrustAnchor {
|
||||
string creator = 1;
|
||||
TrustAnchor trustAnchor = 2;
|
||||
}
|
||||
|
||||
message MsgRegisterTrustAnchorResponse {}
|
||||
|
||||
|
@ -23,6 +23,7 @@ func MachineKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
||||
taIndexStoreKey := sdk.NewKVStoreKey(types.TAIndexKey)
|
||||
issuerPlanetmintIndexStoreKey := sdk.NewKVStoreKey(types.IssuerPlanetmintIndexKey)
|
||||
issuerLiquidIndexStoreKey := sdk.NewKVStoreKey(types.IssuerLiquidIndexKey)
|
||||
trustAnchorStoreKey := sdk.NewKVStoreKey(types.TrustAnchorKey)
|
||||
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey)
|
||||
|
||||
db := tmdb.NewMemDB()
|
||||
@ -31,6 +32,7 @@ func MachineKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
||||
stateStore.MountStoreWithDB(taIndexStoreKey, storetypes.StoreTypeIAVL, db)
|
||||
stateStore.MountStoreWithDB(issuerPlanetmintIndexStoreKey, storetypes.StoreTypeIAVL, db)
|
||||
stateStore.MountStoreWithDB(issuerLiquidIndexStoreKey, storetypes.StoreTypeIAVL, db)
|
||||
stateStore.MountStoreWithDB(trustAnchorStoreKey, storetypes.StoreTypeIAVL, db)
|
||||
stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil)
|
||||
require.NoError(t, stateStore.LoadLatestVersion())
|
||||
|
||||
@ -50,6 +52,7 @@ func MachineKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
||||
taIndexStoreKey,
|
||||
issuerPlanetmintIndexStoreKey,
|
||||
issuerLiquidIndexStoreKey,
|
||||
trustAnchorStoreKey,
|
||||
memStoreKey,
|
||||
paramsSubspace,
|
||||
)
|
||||
|
@ -120,3 +120,9 @@ func ExtendedKeyPair(cfg chaincfg.Params) (string, string) {
|
||||
}
|
||||
return xprivKey.String(), xpubKey.String()
|
||||
}
|
||||
|
||||
func TrustAnchor() machinetypes.TrustAnchor {
|
||||
return machinetypes.TrustAnchor{
|
||||
Pubkey: PubKey,
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ func GetTxCmd() *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.AddCommand(CmdAttestMachine())
|
||||
cmd.AddCommand(CmdRegisterTrustAnchor())
|
||||
// this line is used by starport scaffolding # 1
|
||||
|
||||
return cmd
|
||||
|
47
x/machine/client/cli/tx_register_trust_anchor.go
Normal file
47
x/machine/client/cli/tx_register_trust_anchor.go
Normal file
@ -0,0 +1,47 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"encoding/json"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/spf13/cobra"
|
||||
"planetmint-go/x/machine/types"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdRegisterTrustAnchor() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "register-trust-anchor [trust-anchor]",
|
||||
Short: "Broadcast message register-trust-anchor",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
argTrustAnchor := new(types.TrustAnchor)
|
||||
err = json.Unmarshal([]byte(args[0]), argTrustAnchor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgRegisterTrustAnchor(
|
||||
clientCtx.GetFromAddress().String(),
|
||||
argTrustAnchor,
|
||||
)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
@ -19,6 +19,7 @@ type (
|
||||
taIndexStoreKey storetypes.StoreKey
|
||||
issuerPlanetmintIndexStoreKey storetypes.StoreKey
|
||||
issuerLiquidIndexStoreKey storetypes.StoreKey
|
||||
taStoreKey storetypes.StoreKey
|
||||
memKey storetypes.StoreKey
|
||||
paramstore paramtypes.Subspace
|
||||
}
|
||||
@ -30,6 +31,7 @@ func NewKeeper(
|
||||
indexStoreKey,
|
||||
issuerPlanetmintIndexStoreKey,
|
||||
issuerLiquidIndexStoreKey,
|
||||
taStoreKey,
|
||||
memKey storetypes.StoreKey,
|
||||
ps paramtypes.Subspace,
|
||||
) *Keeper {
|
||||
@ -44,6 +46,7 @@ func NewKeeper(
|
||||
taIndexStoreKey: indexStoreKey,
|
||||
issuerPlanetmintIndexStoreKey: issuerPlanetmintIndexStoreKey,
|
||||
issuerLiquidIndexStoreKey: issuerLiquidIndexStoreKey,
|
||||
taStoreKey: taStoreKey,
|
||||
memKey: memKey,
|
||||
paramstore: ps,
|
||||
}
|
||||
|
49
x/machine/keeper/msg_server_register_trust_anchor.go
Normal file
49
x/machine/keeper/msg_server_register_trust_anchor.go
Normal file
@ -0,0 +1,49 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
|
||||
"planetmint-go/x/machine/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func (k msgServer) RegisterTrustAnchor(goCtx context.Context, msg *types.MsgRegisterTrustAnchor) (*types.MsgRegisterTrustAnchorResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
isValidTrustAnchorPubkey := validatePublicKey(msg.TrustAnchor.Pubkey)
|
||||
if !isValidTrustAnchorPubkey {
|
||||
return nil, errors.New("invalid trust anchor pubkey")
|
||||
}
|
||||
|
||||
_, _, found := k.GetTrustAnchor(ctx, msg.TrustAnchor.Pubkey)
|
||||
if found {
|
||||
return nil, errors.New("trust anchor is already registered")
|
||||
}
|
||||
|
||||
k.StoreTrustAnchor(ctx, *msg.TrustAnchor, false)
|
||||
|
||||
return &types.MsgRegisterTrustAnchorResponse{}, nil
|
||||
}
|
||||
|
||||
func validatePublicKey(pubkey string) bool {
|
||||
pubkeyBytes, err := hex.DecodeString(pubkey)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if byte slice has correct length
|
||||
if len(pubkeyBytes) != 33 {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check if byte slice starts with 0x02 or 0x03
|
||||
firstByte := pubkeyBytes[0]
|
||||
if firstByte != 0x02 && firstByte != 0x03 {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
@ -46,3 +46,38 @@ func TestMsgServerAttestMachineInvalidLiquidKey(t *testing.T) {
|
||||
_, err := msgServer.AttestMachine(ctx, msg)
|
||||
assert.EqualError(t, err, "invalid liquid key")
|
||||
}
|
||||
|
||||
func TestMsgServerRegisterTrustAnchor(t *testing.T) {
|
||||
_, pk := sample.KeyPair()
|
||||
ta := sample.TrustAnchor()
|
||||
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
||||
msgServer, ctx := setupMsgServer(t)
|
||||
res, err := msgServer.RegisterTrustAnchor(ctx, msg)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, &types.MsgRegisterTrustAnchorResponse{}, res)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMsgServerRegisterTrustAnchorTwice(t *testing.T) {
|
||||
_, pk := sample.KeyPair()
|
||||
ta := sample.TrustAnchor()
|
||||
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
||||
msgServer, ctx := setupMsgServer(t)
|
||||
res, err := msgServer.RegisterTrustAnchor(ctx, msg)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equal(t, &types.MsgRegisterTrustAnchorResponse{}, res)
|
||||
}
|
||||
_, err = msgServer.RegisterTrustAnchor(ctx, msg)
|
||||
assert.EqualError(t, err, "trust anchor is already registered")
|
||||
}
|
||||
|
||||
func TestMsgServerRegisterTrustAnchorInvalidPubkey(t *testing.T) {
|
||||
_, pk := sample.KeyPair()
|
||||
ta := types.TrustAnchor{
|
||||
Pubkey: "invalidpublickey",
|
||||
}
|
||||
msg := types.NewMsgRegisterTrustAnchor(pk, &ta)
|
||||
msgServer, ctx := setupMsgServer(t)
|
||||
_, err := msgServer.RegisterTrustAnchor(ctx, msg)
|
||||
assert.EqualError(t, err, "invalid trust anchor pubkey")
|
||||
}
|
||||
|
41
x/machine/keeper/trust_anchor.go
Normal file
41
x/machine/keeper/trust_anchor.go
Normal file
@ -0,0 +1,41 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"planetmint-go/x/machine/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func (k Keeper) StoreTrustAnchor(ctx sdk.Context, ta types.TrustAnchor, activated bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.taStoreKey), types.KeyPrefix(types.TrustAnchorKey))
|
||||
// if activated is set to true then store 1 else 0
|
||||
var appendValue []byte
|
||||
if activated {
|
||||
appendValue = []byte{1}
|
||||
} else {
|
||||
appendValue = []byte{0}
|
||||
}
|
||||
store.Set(GetTrustAnchorBytes(ta.Pubkey), appendValue)
|
||||
}
|
||||
|
||||
func (k Keeper) GetTrustAnchor(ctx sdk.Context, pubKey string) (val types.TrustAnchor, activated bool, found bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.taStoreKey), types.KeyPrefix(types.TrustAnchorKey))
|
||||
trustAnchorActivated := store.Get(GetTrustAnchorBytes(pubKey))
|
||||
|
||||
if trustAnchorActivated == nil {
|
||||
return val, false, false
|
||||
}
|
||||
|
||||
// if stored byte is 1 then return activated equals true
|
||||
val.Pubkey = pubKey
|
||||
if trustAnchorActivated[0] == 1 {
|
||||
return val, true, true
|
||||
} else {
|
||||
return val, false, true
|
||||
}
|
||||
}
|
||||
|
||||
func GetTrustAnchorBytes(pubKey string) []byte {
|
||||
return []byte(pubKey)
|
||||
}
|
60
x/machine/keeper/trust_anchor_test.go
Normal file
60
x/machine/keeper/trust_anchor_test.go
Normal file
@ -0,0 +1,60 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
keepertest "planetmint-go/testutil/keeper"
|
||||
|
||||
"planetmint-go/x/machine/keeper"
|
||||
"planetmint-go/x/machine/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func createNTrustAnchor(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.TrustAnchor {
|
||||
items := make([]types.TrustAnchor, n)
|
||||
for i := range items {
|
||||
items[i].Pubkey = fmt.Sprintf("pubkey%v", i)
|
||||
var activated bool
|
||||
if i%2 == 1 {
|
||||
activated = true
|
||||
} else {
|
||||
activated = false
|
||||
}
|
||||
keeper.StoreTrustAnchor(ctx, items[i], activated)
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func TestGetTrustAnchor(t *testing.T) {
|
||||
keeper, ctx := keepertest.MachineKeeper(t)
|
||||
items := createNTrustAnchor(keeper, ctx, 10)
|
||||
for i, item := range items {
|
||||
ta, activated, found := keeper.GetTrustAnchor(ctx, item.Pubkey)
|
||||
assert.True(t, found)
|
||||
assert.Equal(t, item, ta)
|
||||
if i%2 == 1 {
|
||||
assert.True(t, activated)
|
||||
} else {
|
||||
assert.False(t, activated)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateTrustAnchor(t *testing.T) {
|
||||
keeper, ctx := keepertest.MachineKeeper(t)
|
||||
items := createNTrustAnchor(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
ta, activated, _ := keeper.GetTrustAnchor(ctx, item.Pubkey)
|
||||
if !activated {
|
||||
keeper.StoreTrustAnchor(ctx, ta, true)
|
||||
}
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
_, activated, _ := keeper.GetTrustAnchor(ctx, item.Pubkey)
|
||||
assert.True(t, activated)
|
||||
}
|
||||
}
|
@ -27,6 +27,10 @@ const (
|
||||
// TODO: Determine the simulation weight value
|
||||
defaultWeightMsgAttestMachine int = 100
|
||||
|
||||
opWeightMsgRegisterTrustAnchor = "op_weight_msg_register_trust_anchor"
|
||||
// TODO: Determine the simulation weight value
|
||||
defaultWeightMsgRegisterTrustAnchor int = 100
|
||||
|
||||
// this line is used by starport scaffolding # simapp/module/const
|
||||
)
|
||||
|
||||
@ -68,6 +72,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
|
||||
machinesimulation.SimulateMsgAttestMachine(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||
))
|
||||
|
||||
var weightMsgRegisterTrustAnchor int
|
||||
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgRegisterTrustAnchor, &weightMsgRegisterTrustAnchor, nil,
|
||||
func(_ *rand.Rand) {
|
||||
weightMsgRegisterTrustAnchor = defaultWeightMsgRegisterTrustAnchor
|
||||
},
|
||||
)
|
||||
operations = append(operations, simulation.NewWeightedOperation(
|
||||
weightMsgRegisterTrustAnchor,
|
||||
machinesimulation.SimulateMsgRegisterTrustAnchor(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||
))
|
||||
|
||||
// this line is used by starport scaffolding # simapp/module/operation
|
||||
|
||||
return operations
|
||||
@ -84,6 +99,14 @@ func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Wei
|
||||
return nil
|
||||
},
|
||||
),
|
||||
simulation.NewWeightedProposalMsg(
|
||||
opWeightMsgRegisterTrustAnchor,
|
||||
defaultWeightMsgRegisterTrustAnchor,
|
||||
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
|
||||
machinesimulation.SimulateMsgRegisterTrustAnchor(am.accountKeeper, am.bankKeeper, am.keeper)
|
||||
return nil
|
||||
},
|
||||
),
|
||||
// this line is used by starport scaffolding # simapp/module/OpMsg
|
||||
}
|
||||
}
|
||||
|
29
x/machine/simulation/register_trust_anchor.go
Normal file
29
x/machine/simulation/register_trust_anchor.go
Normal file
@ -0,0 +1,29 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"planetmint-go/x/machine/keeper"
|
||||
"planetmint-go/x/machine/types"
|
||||
)
|
||||
|
||||
func SimulateMsgRegisterTrustAnchor(
|
||||
ak types.AccountKeeper,
|
||||
bk types.BankKeeper,
|
||||
k keeper.Keeper,
|
||||
) simtypes.Operation {
|
||||
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
|
||||
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
|
||||
simAccount, _ := simtypes.RandomAcc(r, accs)
|
||||
msg := &types.MsgRegisterTrustAnchor{
|
||||
Creator: simAccount.Address.String(),
|
||||
}
|
||||
|
||||
// TODO: Handling the RegisterTrustAnchor simulation
|
||||
|
||||
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "RegisterTrustAnchor simulation not implemented"), nil, nil
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
func RegisterCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(&MsgAttestMachine{}, "machine/AttestMachine", nil)
|
||||
cdc.RegisterConcrete(&MsgRegisterTrustAnchor{}, "machine/RegisterTrustAnchor", nil)
|
||||
// this line is used by starport scaffolding # 2
|
||||
}
|
||||
|
||||
@ -16,6 +17,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgAttestMachine{},
|
||||
)
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgRegisterTrustAnchor{},
|
||||
)
|
||||
// this line is used by starport scaffolding # 3
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
|
@ -20,6 +20,8 @@ const (
|
||||
IssuerPlanetmintIndexKey = "Machine/IssuerPlanetmintIndex/"
|
||||
|
||||
IssuerLiquidIndexKey = "Machine/IssuerLiquidIndex/"
|
||||
|
||||
TrustAnchorKey = "Machine/trustAnchor/"
|
||||
)
|
||||
|
||||
func KeyPrefix(p string) []byte {
|
||||
|
47
x/machine/types/message_register_trust_anchor.go
Normal file
47
x/machine/types/message_register_trust_anchor.go
Normal file
@ -0,0 +1,47 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
const TypeMsgRegisterTrustAnchor = "register_trust_anchor"
|
||||
|
||||
var _ sdk.Msg = &MsgRegisterTrustAnchor{}
|
||||
|
||||
func NewMsgRegisterTrustAnchor(creator string, trustAnchor *TrustAnchor) *MsgRegisterTrustAnchor {
|
||||
return &MsgRegisterTrustAnchor{
|
||||
Creator: creator,
|
||||
TrustAnchor: trustAnchor,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *MsgRegisterTrustAnchor) Route() string {
|
||||
return RouterKey
|
||||
}
|
||||
|
||||
func (msg *MsgRegisterTrustAnchor) Type() string {
|
||||
return TypeMsgRegisterTrustAnchor
|
||||
}
|
||||
|
||||
func (msg *MsgRegisterTrustAnchor) GetSigners() []sdk.AccAddress {
|
||||
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{creator}
|
||||
}
|
||||
|
||||
func (msg *MsgRegisterTrustAnchor) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg *MsgRegisterTrustAnchor) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
}
|
||||
return nil
|
||||
}
|
34
x/machine/types/message_register_trust_anchor_test.go
Normal file
34
x/machine/types/message_register_trust_anchor_test.go
Normal file
@ -0,0 +1,34 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMsgRegisterTrustAnchor_ValidateBasic(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
msg MsgRegisterTrustAnchor
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgRegisterTrustAnchor{
|
||||
Creator: "invalid_address",
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.msg.ValidateBasic()
|
||||
if tt.err != nil {
|
||||
require.ErrorIs(t, err, tt.err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
316
x/machine/types/trust_anchor.pb.go
Normal file
316
x/machine/types/trust_anchor.pb.go
Normal file
@ -0,0 +1,316 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: planetmintgo/machine/trust_anchor.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/cosmos/gogoproto/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type TrustAnchor struct {
|
||||
Pubkey string `protobuf:"bytes,1,opt,name=pubkey,proto3" json:"pubkey,omitempty"`
|
||||
}
|
||||
|
||||
func (m *TrustAnchor) Reset() { *m = TrustAnchor{} }
|
||||
func (m *TrustAnchor) String() string { return proto.CompactTextString(m) }
|
||||
func (*TrustAnchor) ProtoMessage() {}
|
||||
func (*TrustAnchor) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_c743aa40c45e7aac, []int{0}
|
||||
}
|
||||
func (m *TrustAnchor) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *TrustAnchor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_TrustAnchor.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *TrustAnchor) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TrustAnchor.Merge(m, src)
|
||||
}
|
||||
func (m *TrustAnchor) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *TrustAnchor) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TrustAnchor.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TrustAnchor proto.InternalMessageInfo
|
||||
|
||||
func (m *TrustAnchor) GetPubkey() string {
|
||||
if m != nil {
|
||||
return m.Pubkey
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*TrustAnchor)(nil), "planetmintgo.machine.TrustAnchor")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("planetmintgo/machine/trust_anchor.proto", fileDescriptor_c743aa40c45e7aac)
|
||||
}
|
||||
|
||||
var fileDescriptor_c743aa40c45e7aac = []byte{
|
||||
// 149 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2f, 0xc8, 0x49, 0xcc,
|
||||
0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0xcf, 0x4d, 0x4c, 0xce, 0xc8, 0xcc, 0x4b,
|
||||
0xd5, 0x2f, 0x29, 0x2a, 0x2d, 0x2e, 0x89, 0x4f, 0xcc, 0x4b, 0xce, 0xc8, 0x2f, 0xd2, 0x2b, 0x28,
|
||||
0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0x56, 0xa8, 0x07, 0x55, 0xa8, 0xa4, 0xca, 0xc5, 0x1d, 0x02,
|
||||
0x52, 0xeb, 0x08, 0x56, 0x2a, 0x24, 0xc6, 0xc5, 0x56, 0x50, 0x9a, 0x94, 0x9d, 0x5a, 0x29, 0xc1,
|
||||
0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe5, 0x39, 0x99, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91,
|
||||
0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3,
|
||||
0xb1, 0x1c, 0x43, 0x94, 0x2c, 0xc2, 0x58, 0xdd, 0xf4, 0x7c, 0xfd, 0x0a, 0x84, 0x13, 0x2a, 0x0b,
|
||||
0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x96, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x05, 0x42, 0xb6,
|
||||
0x02, 0xa7, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *TrustAnchor) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *TrustAnchor) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *TrustAnchor) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Pubkey) > 0 {
|
||||
i -= len(m.Pubkey)
|
||||
copy(dAtA[i:], m.Pubkey)
|
||||
i = encodeVarintTrustAnchor(dAtA, i, uint64(len(m.Pubkey)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTrustAnchor(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTrustAnchor(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *TrustAnchor) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Pubkey)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTrustAnchor(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTrustAnchor(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozTrustAnchor(x uint64) (n int) {
|
||||
return sovTrustAnchor(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *TrustAnchor) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTrustAnchor
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: TrustAnchor: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: TrustAnchor: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Pubkey", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTrustAnchor
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTrustAnchor
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTrustAnchor
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Pubkey = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTrustAnchor(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTrustAnchor
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTrustAnchor(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTrustAnchor
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTrustAnchor
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowTrustAnchor
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthTrustAnchor
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupTrustAnchor
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthTrustAnchor
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthTrustAnchor = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowTrustAnchor = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupTrustAnchor = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
@ -115,29 +115,125 @@ func (m *MsgAttestMachineResponse) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_MsgAttestMachineResponse proto.InternalMessageInfo
|
||||
|
||||
type MsgRegisterTrustAnchor struct {
|
||||
Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"`
|
||||
TrustAnchor *TrustAnchor `protobuf:"bytes,2,opt,name=trustAnchor,proto3" json:"trustAnchor,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchor) Reset() { *m = MsgRegisterTrustAnchor{} }
|
||||
func (m *MsgRegisterTrustAnchor) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgRegisterTrustAnchor) ProtoMessage() {}
|
||||
func (*MsgRegisterTrustAnchor) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_85ac37e5c8e5251d, []int{2}
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchor) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchor) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgRegisterTrustAnchor.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchor) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgRegisterTrustAnchor.Merge(m, src)
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchor) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchor) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgRegisterTrustAnchor.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgRegisterTrustAnchor proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgRegisterTrustAnchor) GetCreator() string {
|
||||
if m != nil {
|
||||
return m.Creator
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchor) GetTrustAnchor() *TrustAnchor {
|
||||
if m != nil {
|
||||
return m.TrustAnchor
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MsgRegisterTrustAnchorResponse struct {
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchorResponse) Reset() { *m = MsgRegisterTrustAnchorResponse{} }
|
||||
func (m *MsgRegisterTrustAnchorResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgRegisterTrustAnchorResponse) ProtoMessage() {}
|
||||
func (*MsgRegisterTrustAnchorResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_85ac37e5c8e5251d, []int{3}
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchorResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgRegisterTrustAnchorResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchorResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgRegisterTrustAnchorResponse.Merge(m, src)
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchorResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchorResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgRegisterTrustAnchorResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgRegisterTrustAnchorResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgAttestMachine)(nil), "planetmintgo.machine.MsgAttestMachine")
|
||||
proto.RegisterType((*MsgAttestMachineResponse)(nil), "planetmintgo.machine.MsgAttestMachineResponse")
|
||||
proto.RegisterType((*MsgRegisterTrustAnchor)(nil), "planetmintgo.machine.MsgRegisterTrustAnchor")
|
||||
proto.RegisterType((*MsgRegisterTrustAnchorResponse)(nil), "planetmintgo.machine.MsgRegisterTrustAnchorResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("planetmintgo/machine/tx.proto", fileDescriptor_85ac37e5c8e5251d) }
|
||||
|
||||
var fileDescriptor_85ac37e5c8e5251d = []byte{
|
||||
// 216 bytes of a gzipped FileDescriptorProto
|
||||
// 305 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc8, 0x49, 0xcc,
|
||||
0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0xcf, 0x4d, 0x4c, 0xce, 0xc8, 0xcc, 0x4b,
|
||||
0xd5, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x41, 0x96, 0xd6, 0x83, 0x4a,
|
||||
0x4b, 0x29, 0x61, 0xd5, 0x04, 0xa5, 0x21, 0x3a, 0x95, 0x52, 0xb9, 0x04, 0x7c, 0x8b, 0xd3, 0x1d,
|
||||
0x4b, 0x4a, 0x52, 0x8b, 0x4b, 0x7c, 0x21, 0x32, 0x42, 0x12, 0x5c, 0xec, 0xc9, 0x45, 0xa9, 0x89,
|
||||
0x25, 0xf9, 0x45, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x39, 0x17, 0x3b,
|
||||
0x54, 0xbb, 0x04, 0x93, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xac, 0x1e, 0x36, 0x9b, 0xf5, 0xa0, 0x26,
|
||||
0x05, 0xc1, 0x54, 0x2b, 0x49, 0x71, 0x49, 0xa0, 0x5b, 0x13, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57,
|
||||
0x9c, 0x6a, 0x94, 0xc7, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0x94, 0xce, 0xc5, 0x8b, 0xea, 0x0c, 0x35,
|
||||
0x1c, 0x66, 0xa3, 0x99, 0x23, 0xa5, 0x47, 0x9c, 0x3a, 0x98, 0x7d, 0x4e, 0xe6, 0x27, 0x1e, 0xc9,
|
||||
0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e,
|
||||
0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x85, 0x14, 0xca, 0xba, 0xe9, 0xf9, 0xfa, 0x15, 0x88,
|
||||
0x80, 0xae, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x07, 0x99, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff,
|
||||
0x78, 0x82, 0x2b, 0xac, 0x8d, 0x01, 0x00, 0x00,
|
||||
0x4b, 0x29, 0x61, 0xd5, 0x04, 0xa5, 0x21, 0x3a, 0xa5, 0xd4, 0xb1, 0x1b, 0x5c, 0x54, 0x5a, 0x5c,
|
||||
0x12, 0x9f, 0x98, 0x97, 0x9c, 0x91, 0x5f, 0x04, 0x51, 0xa8, 0x94, 0xca, 0x25, 0xe0, 0x5b, 0x9c,
|
||||
0xee, 0x58, 0x52, 0x92, 0x5a, 0x5c, 0xe2, 0x0b, 0x51, 0x26, 0x24, 0xc1, 0xc5, 0x9e, 0x5c, 0x94,
|
||||
0x9a, 0x58, 0x92, 0x5f, 0x24, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe3, 0x0a, 0x99, 0x73,
|
||||
0xb1, 0x43, 0xcd, 0x92, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x36, 0x92, 0xd5, 0xc3, 0xe6, 0x44, 0x3d,
|
||||
0xa8, 0x49, 0x41, 0x30, 0xd5, 0x4a, 0x52, 0x5c, 0x12, 0xe8, 0xd6, 0x04, 0xa5, 0x16, 0x17, 0xe4,
|
||||
0xe7, 0x15, 0xa7, 0x2a, 0x95, 0x73, 0x89, 0xf9, 0x16, 0xa7, 0x07, 0xa5, 0xa6, 0x67, 0x16, 0x97,
|
||||
0xa4, 0x16, 0x85, 0x80, 0xdc, 0xe8, 0x08, 0x76, 0x22, 0x1e, 0x87, 0x38, 0x73, 0x71, 0x97, 0x20,
|
||||
0x14, 0x42, 0x1d, 0xa3, 0x88, 0xdd, 0x31, 0x48, 0x26, 0x06, 0x21, 0xeb, 0x52, 0x52, 0xe0, 0x92,
|
||||
0xc3, 0x6e, 0x31, 0xcc, 0x69, 0x46, 0x2f, 0x19, 0xb9, 0x98, 0x7d, 0x8b, 0xd3, 0x85, 0xd2, 0xb9,
|
||||
0x78, 0x51, 0x83, 0x48, 0x0d, 0x87, 0xbf, 0xd1, 0xfc, 0x28, 0xa5, 0x47, 0x9c, 0x3a, 0x98, 0x85,
|
||||
0x42, 0x95, 0x5c, 0xc2, 0xd8, 0x02, 0x42, 0x07, 0xa7, 0x31, 0x58, 0x54, 0x4b, 0x99, 0x90, 0xa2,
|
||||
0x1a, 0x66, 0xb5, 0x93, 0xf9, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24,
|
||||
0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x21,
|
||||
0xa5, 0x52, 0xdd, 0xf4, 0x7c, 0xfd, 0x0a, 0x44, 0x7a, 0xaa, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03,
|
||||
0xa7, 0x24, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x66, 0xa7, 0x9c, 0x05, 0xcd, 0x02, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -153,6 +249,7 @@ const _ = grpc.SupportPackageIsVersion4
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type MsgClient interface {
|
||||
AttestMachine(ctx context.Context, in *MsgAttestMachine, opts ...grpc.CallOption) (*MsgAttestMachineResponse, error)
|
||||
RegisterTrustAnchor(ctx context.Context, in *MsgRegisterTrustAnchor, opts ...grpc.CallOption) (*MsgRegisterTrustAnchorResponse, error)
|
||||
}
|
||||
|
||||
type msgClient struct {
|
||||
@ -172,9 +269,19 @@ func (c *msgClient) AttestMachine(ctx context.Context, in *MsgAttestMachine, opt
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *msgClient) RegisterTrustAnchor(ctx context.Context, in *MsgRegisterTrustAnchor, opts ...grpc.CallOption) (*MsgRegisterTrustAnchorResponse, error) {
|
||||
out := new(MsgRegisterTrustAnchorResponse)
|
||||
err := c.cc.Invoke(ctx, "/planetmintgo.machine.Msg/RegisterTrustAnchor", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MsgServer is the server API for Msg service.
|
||||
type MsgServer interface {
|
||||
AttestMachine(context.Context, *MsgAttestMachine) (*MsgAttestMachineResponse, error)
|
||||
RegisterTrustAnchor(context.Context, *MsgRegisterTrustAnchor) (*MsgRegisterTrustAnchorResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
|
||||
@ -184,6 +291,9 @@ type UnimplementedMsgServer struct {
|
||||
func (*UnimplementedMsgServer) AttestMachine(ctx context.Context, req *MsgAttestMachine) (*MsgAttestMachineResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AttestMachine not implemented")
|
||||
}
|
||||
func (*UnimplementedMsgServer) RegisterTrustAnchor(ctx context.Context, req *MsgRegisterTrustAnchor) (*MsgRegisterTrustAnchorResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RegisterTrustAnchor not implemented")
|
||||
}
|
||||
|
||||
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
|
||||
s.RegisterService(&_Msg_serviceDesc, srv)
|
||||
@ -207,6 +317,24 @@ func _Msg_AttestMachine_Handler(srv interface{}, ctx context.Context, dec func(i
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Msg_RegisterTrustAnchor_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgRegisterTrustAnchor)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MsgServer).RegisterTrustAnchor(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/planetmintgo.machine.Msg/RegisterTrustAnchor",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MsgServer).RegisterTrustAnchor(ctx, req.(*MsgRegisterTrustAnchor))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "planetmintgo.machine.Msg",
|
||||
HandlerType: (*MsgServer)(nil),
|
||||
@ -215,6 +343,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{
|
||||
MethodName: "AttestMachine",
|
||||
Handler: _Msg_AttestMachine_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RegisterTrustAnchor",
|
||||
Handler: _Msg_RegisterTrustAnchor_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "planetmintgo/machine/tx.proto",
|
||||
@ -285,6 +417,71 @@ func (m *MsgAttestMachineResponse) MarshalToSizedBuffer(dAtA []byte) (int, error
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchor) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchor) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchor) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.TrustAnchor != nil {
|
||||
{
|
||||
size, err := m.TrustAnchor.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintTx(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Creator) > 0 {
|
||||
i -= len(m.Creator)
|
||||
copy(dAtA[i:], m.Creator)
|
||||
i = encodeVarintTx(dAtA, i, uint64(len(m.Creator)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchorResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchorResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovTx(v)
|
||||
base := offset
|
||||
@ -322,6 +519,32 @@ func (m *MsgAttestMachineResponse) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchor) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Creator)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
if m.TrustAnchor != nil {
|
||||
l = m.TrustAnchor.Size()
|
||||
n += 1 + l + sovTx(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MsgRegisterTrustAnchorResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func sovTx(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
@ -496,6 +719,174 @@ func (m *MsgAttestMachineResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchor) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MsgRegisterTrustAnchor: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgRegisterTrustAnchor: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Creator = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field TrustAnchor", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.TrustAnchor == nil {
|
||||
m.TrustAnchor = &TrustAnchor{}
|
||||
}
|
||||
if err := m.TrustAnchor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgRegisterTrustAnchorResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTx
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: MsgRegisterTrustAnchorResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgRegisterTrustAnchorResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTx(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthTx
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipTx(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user