add domain to machine proto

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2023-07-26 14:44:01 +02:00 committed by Julian Strobl
parent f6c96094c6
commit 722eb60bcf
No known key found for this signature in database
GPG Key ID: E0A8F9AD733499A7
8 changed files with 113 additions and 138 deletions

View File

@ -7,13 +7,14 @@ message Machine {
string name = 1;
string ticker = 2;
bool reissue = 3;
uint64 amount = 4;
uint64 precision = 5;
string issuerPlanetmint = 6;
string issuerLiquid = 7;
string machineId = 8;
Metadata metadata = 9;
string domain = 3;
bool reissue = 4;
uint64 amount = 5;
uint64 precision = 6;
string issuerPlanetmint = 7;
string issuerLiquid = 8;
string machineId = 9;
Metadata metadata = 10;
}
message Metadata {

View File

@ -15,10 +15,7 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
typesparams "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
machinetestutils "planetmint-go/x/machine/testutil"
)
func MachineKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
@ -47,9 +44,6 @@ func MachineKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
"MachineParams",
)
ctrl := gomock.NewController(t)
oscMockClient := machinetestutils.NewMockClient(ctrl)
k := keeper.NewKeeper(
cdc,
storeKey,
@ -58,7 +52,6 @@ func MachineKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
issuerLiquidIndexStoreKey,
memStoreKey,
paramsSubspace,
oscMockClient,
)
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger())

View File

@ -50,6 +50,7 @@ func Machine(name, pubKey string) machinetypes.Machine {
m := machinetypes.Machine{
Name: name,
Ticker: name + "_ticker",
Domain: "lab.r3c.net",
Reissue: true,
Amount: 1000,
Precision: 8,

View File

@ -8,7 +8,6 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/crgimenes/go-osc"
"planetmint-go/x/machine/types"
)
@ -22,7 +21,6 @@ type (
issuerLiquidIndexStoreKey storetypes.StoreKey
memKey storetypes.StoreKey
paramstore paramtypes.Subspace
oscClient osc.Client
}
)
@ -34,7 +32,6 @@ func NewKeeper(
issuerLiquidIndexStoreKey,
memKey storetypes.StoreKey,
ps paramtypes.Subspace,
oscClient osc.Client,
) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
@ -49,7 +46,6 @@ func NewKeeper(
issuerLiquidIndexStoreKey: issuerLiquidIndexStoreKey,
memKey: memKey,
paramstore: ps,
oscClient: oscClient,
}
}

View File

@ -41,10 +41,13 @@ func validateIssuerLiquid(issuerLiquid string) bool {
}
func (k msgServer) reissueMachineNFT(machine *types.Machine) {
// client := osc.NewClient("localhost", 8765)
msg := osc.NewMessage("/osc/address")
msg.Append(int32(111))
msg.Append(true)
msg.Append("hello")
k.oscClient.Send(msg)
client := osc.NewClient("localhost", 8765)
msg := osc.NewMessage("/rddl/*")
msg.Append(machine.Name)
msg.Append(machine.Ticker)
msg.Append(machine.Domain)
msg.Append(machine.Amount)
msg.Append("1")
msg.Append(machine.Precision)
client.Send(msg)
}

View File

@ -1,8 +0,0 @@
package testutil
import "github.com/crgimenes/go-osc"
type Client interface {
Send(packet osc.Packet) error
SetLocalAddr(ip string, port int) error
}

View File

@ -1,63 +0,0 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: x/machine/testutil/osc_client_interface.go
// Package testutil is a generated GoMock package.
package testutil
import (
reflect "reflect"
osc "github.com/crgimenes/go-osc"
gomock "github.com/golang/mock/gomock"
)
// MockClient is a mock of Client interface.
type MockClient struct {
ctrl *gomock.Controller
recorder *MockClientMockRecorder
}
// MockClientMockRecorder is the mock recorder for MockClient.
type MockClientMockRecorder struct {
mock *MockClient
}
// NewMockClient creates a new mock instance.
func NewMockClient(ctrl *gomock.Controller) *MockClient {
mock := &MockClient{ctrl: ctrl}
mock.recorder = &MockClientMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockClient) EXPECT() *MockClientMockRecorder {
return m.recorder
}
// Send mocks base method.
func (m *MockClient) Send(packet osc.Packet) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Send", packet)
ret0, _ := ret[0].(error)
return ret0
}
// Send indicates an expected call of Send.
func (mr *MockClientMockRecorder) Send(packet interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockClient)(nil).Send), packet)
}
// SetLocalAddr mocks base method.
func (m *MockClient) SetLocalAddr(ip string, port int) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SetLocalAddr", ip, port)
ret0, _ := ret[0].(error)
return ret0
}
// SetLocalAddr indicates an expected call of SetLocalAddr.
func (mr *MockClientMockRecorder) SetLocalAddr(ip, port interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLocalAddr", reflect.TypeOf((*MockClient)(nil).SetLocalAddr), ip, port)
}

View File

@ -25,13 +25,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type Machine struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"`
Reissue bool `protobuf:"varint,3,opt,name=reissue,proto3" json:"reissue,omitempty"`
Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"`
Precision uint64 `protobuf:"varint,5,opt,name=precision,proto3" json:"precision,omitempty"`
IssuerPlanetmint string `protobuf:"bytes,6,opt,name=issuerPlanetmint,proto3" json:"issuerPlanetmint,omitempty"`
IssuerLiquid string `protobuf:"bytes,7,opt,name=issuerLiquid,proto3" json:"issuerLiquid,omitempty"`
MachineId string `protobuf:"bytes,8,opt,name=machineId,proto3" json:"machineId,omitempty"`
Metadata *Metadata `protobuf:"bytes,9,opt,name=metadata,proto3" json:"metadata,omitempty"`
Domain string `protobuf:"bytes,3,opt,name=domain,proto3" json:"domain,omitempty"`
Reissue bool `protobuf:"varint,4,opt,name=reissue,proto3" json:"reissue,omitempty"`
Amount uint64 `protobuf:"varint,5,opt,name=amount,proto3" json:"amount,omitempty"`
Precision uint64 `protobuf:"varint,6,opt,name=precision,proto3" json:"precision,omitempty"`
IssuerPlanetmint string `protobuf:"bytes,7,opt,name=issuerPlanetmint,proto3" json:"issuerPlanetmint,omitempty"`
IssuerLiquid string `protobuf:"bytes,8,opt,name=issuerLiquid,proto3" json:"issuerLiquid,omitempty"`
MachineId string `protobuf:"bytes,9,opt,name=machineId,proto3" json:"machineId,omitempty"`
Metadata *Metadata `protobuf:"bytes,10,opt,name=metadata,proto3" json:"metadata,omitempty"`
}
func (m *Machine) Reset() { *m = Machine{} }
@ -81,6 +82,13 @@ func (m *Machine) GetTicker() string {
return ""
}
func (m *Machine) GetDomain() string {
if m != nil {
return m.Domain
}
return ""
}
func (m *Machine) GetReissue() bool {
if m != nil {
return m.Reissue
@ -269,31 +277,32 @@ func init() {
}
var fileDescriptor_1bb279745bef7c4b = []byte{
// 378 bytes of a gzipped FileDescriptorProto
// 385 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x4a, 0xeb, 0x40,
0x14, 0xc6, 0x3b, 0x4d, 0x6f, 0x9b, 0x9c, 0x5b, 0xb8, 0xbd, 0xc3, 0xe5, 0x32, 0x0b, 0x0d, 0x21,
0x14, 0x87, 0x3b, 0x6d, 0x6f, 0x9b, 0x9c, 0x5b, 0xb8, 0xbd, 0xc3, 0xe5, 0x32, 0x0b, 0x0d, 0x21,
0xab, 0x20, 0x9a, 0x82, 0x2e, 0x04, 0x97, 0xda, 0x4d, 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x51, 0x04, 0x58, 0x89, 0x2c, 0x3a, 0xea,
0xc2, 0x1f, 0x9e, 0x65, 0xa8, 0xfa, 0x78, 0x2b, 0xa4, 0x50, 0xb9, 0x84, 0xc2, 0xe8, 0x26, 0xa6,
0x87, 0xf0, 0x97, 0x87, 0xa1, 0xae, 0xf9, 0xb8, 0xcf, 0x15, 0xbf, 0x18, 0xf4, 0xb5, 0x64, 0xd3,
0xdf, 0x1e, 0x38, 0xcf, 0xd0, 0x29, 0xbf, 0xeb, 0x40, 0x86, 0x38, 0x5d, 0x5f, 0x9c, 0x6c, 0x2e,
0xbe, 0x4b, 0x73, 0xfd, 0x87, 0x9a, 0x1b, 0xdb, 0x9a, 0xcf, 0x4f, 0xdf, 0xe7, 0x16, 0x99, 0xcd,
0x2d, 0xf2, 0x39, 0xb7, 0xc8, 0xeb, 0xc2, 0xaa, 0xcd, 0x16, 0x56, 0xed, 0x63, 0x61, 0xd5, 0xae,
0xf7, 0x57, 0x3e, 0x8f, 0x46, 0x71, 0x6f, 0xba, 0x7c, 0xad, 0xea, 0x29, 0xc1, 0xec, 0xa6, 0xa5,
0x1f, 0xeb, 0xc9, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x61, 0x27, 0xb2, 0x55, 0xd2, 0x02, 0x00,
0x00,
}
func (m *Machine) Marshal() (dAtA []byte, err error) {
@ -326,38 +335,38 @@ func (m *Machine) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i = encodeVarintMachine(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x4a
dAtA[i] = 0x52
}
if len(m.MachineId) > 0 {
i -= len(m.MachineId)
copy(dAtA[i:], m.MachineId)
i = encodeVarintMachine(dAtA, i, uint64(len(m.MachineId)))
i--
dAtA[i] = 0x42
dAtA[i] = 0x4a
}
if len(m.IssuerLiquid) > 0 {
i -= len(m.IssuerLiquid)
copy(dAtA[i:], m.IssuerLiquid)
i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerLiquid)))
i--
dAtA[i] = 0x3a
dAtA[i] = 0x42
}
if len(m.IssuerPlanetmint) > 0 {
i -= len(m.IssuerPlanetmint)
copy(dAtA[i:], m.IssuerPlanetmint)
i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerPlanetmint)))
i--
dAtA[i] = 0x32
dAtA[i] = 0x3a
}
if m.Precision != 0 {
i = encodeVarintMachine(dAtA, i, uint64(m.Precision))
i--
dAtA[i] = 0x28
dAtA[i] = 0x30
}
if m.Amount != 0 {
i = encodeVarintMachine(dAtA, i, uint64(m.Amount))
i--
dAtA[i] = 0x20
dAtA[i] = 0x28
}
if m.Reissue {
i--
@ -367,7 +376,14 @@ func (m *Machine) MarshalToSizedBuffer(dAtA []byte) (int, error) {
dAtA[i] = 0
}
i--
dAtA[i] = 0x18
dAtA[i] = 0x20
}
if len(m.Domain) > 0 {
i -= len(m.Domain)
copy(dAtA[i:], m.Domain)
i = encodeVarintMachine(dAtA, i, uint64(len(m.Domain)))
i--
dAtA[i] = 0x1a
}
if len(m.Ticker) > 0 {
i -= len(m.Ticker)
@ -506,6 +522,10 @@ func (m *Machine) Size() (n int) {
if l > 0 {
n += 1 + l + sovMachine(uint64(l))
}
l = len(m.Domain)
if l > 0 {
n += 1 + l + sovMachine(uint64(l))
}
if m.Reissue {
n += 2
}
@ -680,6 +700,38 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
m.Ticker = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Domain", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
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 ErrInvalidLengthMachine
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthMachine
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Domain = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Reissue", wireType)
}
@ -699,7 +751,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
}
}
m.Reissue = bool(v != 0)
case 4:
case 5:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
}
@ -718,7 +770,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
break
}
}
case 5:
case 6:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Precision", wireType)
}
@ -737,7 +789,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
break
}
}
case 6:
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IssuerPlanetmint", wireType)
}
@ -769,7 +821,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
}
m.IssuerPlanetmint = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 7:
case 8:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IssuerLiquid", wireType)
}
@ -801,7 +853,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
}
m.IssuerLiquid = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 8:
case 9:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field MachineId", wireType)
}
@ -833,7 +885,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
}
m.MachineId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 9:
case 10:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
}