feature/did swt ante (#22)

* feat: add support for vault allocation

* feat(dwn): Add IPFS client

* refactor: move GetDefaultBypassFeeMessages to ibc/module.go

* refactor(did): clean up genesis state definition

* feat: remove global integrity proof requirement

* feat: remove gas consumption for tx size

* feat: add registration route

* refactor: centralize response handling in the  package

* feat(types): add account and pubkey types

* refactor: simplify dockerfile process-compose.yaml copy
This commit is contained in:
Prad Nukala
2024-09-24 17:54:33 -04:00
committed by GitHub
parent 750559ff19
commit 97b3f9836a
184 changed files with 4020 additions and 18495 deletions
+1
View File
@@ -0,0 +1 @@
package types
-634
View File
@@ -1,634 +0,0 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: did/v1/accounts.proto
package types
import (
fmt "fmt"
proto "github.com/cosmos/gogoproto/proto"
io "io"
math "math"
math_bits "math/bits"
math "math"
)
// 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 BtcAccount struct {
}
func (m *BtcAccount) Reset() { *m = BtcAccount{} }
func (m *BtcAccount) String() string { return proto.CompactTextString(m) }
func (*BtcAccount) ProtoMessage() {}
func (*BtcAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_2125a09fb14c3bc3, []int{0}
}
func (m *BtcAccount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *BtcAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_BtcAccount.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 *BtcAccount) XXX_Merge(src proto.Message) {
xxx_messageInfo_BtcAccount.Merge(m, src)
}
func (m *BtcAccount) XXX_Size() int {
return m.Size()
}
func (m *BtcAccount) XXX_DiscardUnknown() {
xxx_messageInfo_BtcAccount.DiscardUnknown(m)
}
var xxx_messageInfo_BtcAccount proto.InternalMessageInfo
type EthAccount struct {
}
func (m *EthAccount) Reset() { *m = EthAccount{} }
func (m *EthAccount) String() string { return proto.CompactTextString(m) }
func (*EthAccount) ProtoMessage() {}
func (*EthAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_2125a09fb14c3bc3, []int{1}
}
func (m *EthAccount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *EthAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_EthAccount.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 *EthAccount) XXX_Merge(src proto.Message) {
xxx_messageInfo_EthAccount.Merge(m, src)
}
func (m *EthAccount) XXX_Size() int {
return m.Size()
}
func (m *EthAccount) XXX_DiscardUnknown() {
xxx_messageInfo_EthAccount.DiscardUnknown(m)
}
var xxx_messageInfo_EthAccount proto.InternalMessageInfo
type IBCAccount struct {
}
func (m *IBCAccount) Reset() { *m = IBCAccount{} }
func (m *IBCAccount) String() string { return proto.CompactTextString(m) }
func (*IBCAccount) ProtoMessage() {}
func (*IBCAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_2125a09fb14c3bc3, []int{2}
}
func (m *IBCAccount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *IBCAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_IBCAccount.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 *IBCAccount) XXX_Merge(src proto.Message) {
xxx_messageInfo_IBCAccount.Merge(m, src)
}
func (m *IBCAccount) XXX_Size() int {
return m.Size()
}
func (m *IBCAccount) XXX_DiscardUnknown() {
xxx_messageInfo_IBCAccount.DiscardUnknown(m)
}
var xxx_messageInfo_IBCAccount proto.InternalMessageInfo
type SnrAccount struct {
}
func (m *SnrAccount) Reset() { *m = SnrAccount{} }
func (m *SnrAccount) String() string { return proto.CompactTextString(m) }
func (*SnrAccount) ProtoMessage() {}
func (*SnrAccount) Descriptor() ([]byte, []int) {
return fileDescriptor_2125a09fb14c3bc3, []int{3}
}
func (m *SnrAccount) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SnrAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SnrAccount.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 *SnrAccount) XXX_Merge(src proto.Message) {
xxx_messageInfo_SnrAccount.Merge(m, src)
}
func (m *SnrAccount) XXX_Size() int {
return m.Size()
}
func (m *SnrAccount) XXX_DiscardUnknown() {
xxx_messageInfo_SnrAccount.DiscardUnknown(m)
}
var xxx_messageInfo_SnrAccount proto.InternalMessageInfo
func init() {
proto.RegisterType((*BtcAccount)(nil), "did.v1.BtcAccount")
proto.RegisterType((*EthAccount)(nil), "did.v1.EthAccount")
proto.RegisterType((*IBCAccount)(nil), "did.v1.IBCAccount")
proto.RegisterType((*SnrAccount)(nil), "did.v1.SnrAccount")
}
func init() { proto.RegisterFile("did/v1/accounts.proto", fileDescriptor_2125a09fb14c3bc3) }
var fileDescriptor_2125a09fb14c3bc3 = []byte{
// 145 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0xc9, 0x4c, 0xd1,
0x2f, 0x33, 0xd4, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f,
0xc9, 0x17, 0x62, 0x4b, 0xc9, 0x4c, 0xd1, 0x2b, 0x33, 0x54, 0xe2, 0xe1, 0xe2, 0x72, 0x2a, 0x49,
0x76, 0x84, 0x48, 0x82, 0x78, 0xae, 0x25, 0x19, 0x48, 0x3c, 0x4f, 0x27, 0x67, 0x24, 0x5e, 0x70,
0x5e, 0x11, 0x94, 0xe7, 0x64, 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e,
0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51,
0x4a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xf9, 0x79, 0xc5, 0xf9,
0x79, 0x45, 0xfa, 0x60, 0xa2, 0x42, 0x1f, 0xe4, 0x92, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36,
0xb0, 0x23, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x82, 0x7e, 0x89, 0x0a, 0x9d, 0x00, 0x00,
0x00,
}
func (m *BtcAccount) 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 *BtcAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *BtcAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *EthAccount) 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 *EthAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *IBCAccount) 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 *IBCAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *IBCAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func (m *SnrAccount) 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 *SnrAccount) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *SnrAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func encodeVarintAccounts(dAtA []byte, offset int, v uint64) int {
offset -= sovAccounts(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *BtcAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func (m *EthAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func (m *IBCAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func (m *SnrAccount) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func sovAccounts(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozAccounts(x uint64) (n int) {
return sovAccounts(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *BtcAccount) 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 ErrIntOverflowAccounts
}
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: BtcAccount: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: BtcAccount: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipAccounts(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthAccounts
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *EthAccount) 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 ErrIntOverflowAccounts
}
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: EthAccount: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: EthAccount: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipAccounts(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthAccounts
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *IBCAccount) 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 ErrIntOverflowAccounts
}
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: IBCAccount: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: IBCAccount: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipAccounts(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthAccounts
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SnrAccount) 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 ErrIntOverflowAccounts
}
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: SnrAccount: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SnrAccount: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipAccounts(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthAccounts
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipAccounts(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, ErrIntOverflowAccounts
}
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, ErrIntOverflowAccounts
}
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, ErrIntOverflowAccounts
}
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, ErrInvalidLengthAccounts
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupAccounts
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthAccounts
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthAccounts = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowAccounts = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupAccounts = fmt.Errorf("proto: unexpected end of group")
)
func init() { proto.RegisterFile("did/v1/accounts.proto", fileDescriptor_2125a09fb14c3bc3) }
var fileDescriptor_2125a09fb14c3bc3 = []byte{
// 122 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0xc9, 0x4c, 0xd1,
0x2f, 0x33, 0xd4, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f,
0xc9, 0x17, 0x62, 0x4b, 0xc9, 0x4c, 0xd1, 0x2b, 0x33, 0x74, 0xb2, 0x39, 0xf1, 0x48, 0x8e, 0xf1,
0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e,
0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xa5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc,
0x5c, 0xfd, 0xfc, 0xbc, 0xe2, 0xfc, 0xbc, 0x22, 0xfd, 0x8c, 0xf2, 0xc4, 0x4a, 0xfd, 0x0a, 0x7d,
0x90, 0x89, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xc3, 0x8c, 0x01, 0x01, 0x00, 0x00,
0xff, 0xff, 0x28, 0xd1, 0x54, 0x54, 0x65, 0x00, 0x00, 0x00,
}
-2
View File
@@ -13,8 +13,6 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/mr-tron/base58/base58"
"github.com/onsonr/crypto"
// this line is used by starport scaffolding # 1
)
-31
View File
@@ -1,31 +0,0 @@
package types
// Coin represents a cryptocurrency
type Coin interface {
// FormatAddress formats a public key into an address
FormatAddress(pubKey []byte) (string, error)
// GetIndex returns the coin type index
GetIndex() int64
// GetPath returns the coin component path
GetPath() uint32
// GetSymbol returns the coin symbol
GetSymbol() string
// GetMethod returns the coin DID method
GetMethod() string
// GetName returns the coin name
GetName() string
}
// CoinBTCType is the coin type for BTC
const CoinBTCType = int64(0)
// CoinETHType is the coin type for ETH
const CoinETHType = int64(60)
// CoinSNRType is the coin type for SNR
const CoinSNRType = int64(703)
+2 -5
View File
@@ -41,8 +41,7 @@ const DefaultIndex uint64 = 1
func DefaultGenesis() *GenesisState {
return &GenesisState{
// this line is used by starport scaffolding # genesis/types/default
GlobalIntegrity: DefaultGlobalIntegrity(),
Params: DefaultParams(),
Params: DefaultParams(),
}
}
@@ -50,9 +49,7 @@ func DefaultGenesis() *GenesisState {
// failure.
func (gs GenesisState) Validate() error {
// this line is used by starport scaffolding # genesis/types/validate
if gs.GlobalIntegrity == nil {
return fmt.Errorf("global integrity proof is nil")
}
return gs.Params.Validate()
}
+1 -372
View File
@@ -28,8 +28,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type GenesisState struct {
// Params defines all the parameters of the module.
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
// GlobalIntegrity defines a zkp integrity proof for the entire DID namespace
GlobalIntegrity *GlobalIntegrity `protobuf:"bytes,2,opt,name=global_integrity,json=globalIntegrity,proto3" json:"global_integrity,omitempty"`
}
func (m *GenesisState) Reset() { *m = GenesisState{} }
@@ -72,82 +70,6 @@ func (m *GenesisState) GetParams() Params {
return Params{}
}
func (m *GenesisState) GetGlobalIntegrity() *GlobalIntegrity {
if m != nil {
return m.GlobalIntegrity
}
return nil
}
// GlobalIntegrity defines a zkp integrity proof for the entire DID namespace
type GlobalIntegrity struct {
Controller string `protobuf:"bytes,1,opt,name=controller,proto3" json:"controller,omitempty"`
Seed string `protobuf:"bytes,2,opt,name=seed,proto3" json:"seed,omitempty"`
Accumulator []byte `protobuf:"bytes,3,opt,name=accumulator,proto3" json:"accumulator,omitempty"`
Count uint64 `protobuf:"varint,4,opt,name=count,proto3" json:"count,omitempty"`
}
func (m *GlobalIntegrity) Reset() { *m = GlobalIntegrity{} }
func (m *GlobalIntegrity) String() string { return proto.CompactTextString(m) }
func (*GlobalIntegrity) ProtoMessage() {}
func (*GlobalIntegrity) Descriptor() ([]byte, []int) {
return fileDescriptor_fda181cae44f7c00, []int{1}
}
func (m *GlobalIntegrity) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *GlobalIntegrity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_GlobalIntegrity.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 *GlobalIntegrity) XXX_Merge(src proto.Message) {
xxx_messageInfo_GlobalIntegrity.Merge(m, src)
}
func (m *GlobalIntegrity) XXX_Size() int {
return m.Size()
}
func (m *GlobalIntegrity) XXX_DiscardUnknown() {
xxx_messageInfo_GlobalIntegrity.DiscardUnknown(m)
}
var xxx_messageInfo_GlobalIntegrity proto.InternalMessageInfo
func (m *GlobalIntegrity) GetController() string {
if m != nil {
return m.Controller
}
return ""
}
func (m *GlobalIntegrity) GetSeed() string {
if m != nil {
return m.Seed
}
return ""
}
func (m *GlobalIntegrity) GetAccumulator() []byte {
if m != nil {
return m.Accumulator
}
return nil
}
func (m *GlobalIntegrity) GetCount() uint64 {
if m != nil {
return m.Count
}
return 0
}
// Params defines the set of module parameters.
type Params struct {
// Whitelisted Assets
@@ -167,7 +89,7 @@ type Params struct {
func (m *Params) Reset() { *m = Params{} }
func (*Params) ProtoMessage() {}
func (*Params) Descriptor() ([]byte, []int) {
return fileDescriptor_fda181cae44f7c00, []int{2}
return fileDescriptor_fda181cae44f7c00, []int{1}
}
func (m *Params) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@@ -772,7 +694,6 @@ func (m *Service) GetPermissions() map[string]string {
func init() {
proto.RegisterType((*GenesisState)(nil), "did.v1.GenesisState")
proto.RegisterType((*GlobalIntegrity)(nil), "did.v1.GlobalIntegrity")
proto.RegisterType((*Params)(nil), "did.v1.Params")
proto.RegisterMapType((map[string]*KeyInfo)(nil), "did.v1.Params.AllowedPublicKeysEntry")
proto.RegisterType((*AssetInfo)(nil), "did.v1.AssetInfo")
@@ -927,18 +848,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.GlobalIntegrity != nil {
{
size, err := m.GlobalIntegrity.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintGenesis(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
{
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
@@ -952,55 +861,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *GlobalIntegrity) 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 *GlobalIntegrity) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *GlobalIntegrity) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.Count != 0 {
i = encodeVarintGenesis(dAtA, i, uint64(m.Count))
i--
dAtA[i] = 0x20
}
if len(m.Accumulator) > 0 {
i -= len(m.Accumulator)
copy(dAtA[i:], m.Accumulator)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Accumulator)))
i--
dAtA[i] = 0x1a
}
if len(m.Seed) > 0 {
i -= len(m.Seed)
copy(dAtA[i:], m.Seed)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Seed)))
i--
dAtA[i] = 0x12
}
if len(m.Controller) > 0 {
i -= len(m.Controller)
copy(dAtA[i:], m.Controller)
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Controller)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *Params) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@@ -1560,34 +1420,6 @@ func (m *GenesisState) Size() (n int) {
_ = l
l = m.Params.Size()
n += 1 + l + sovGenesis(uint64(l))
if m.GlobalIntegrity != nil {
l = m.GlobalIntegrity.Size()
n += 1 + l + sovGenesis(uint64(l))
}
return n
}
func (m *GlobalIntegrity) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Controller)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
l = len(m.Seed)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
l = len(m.Accumulator)
if l > 0 {
n += 1 + l + sovGenesis(uint64(l))
}
if m.Count != 0 {
n += 1 + sovGenesis(uint64(m.Count))
}
return n
}
@@ -1926,209 +1758,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field GlobalIntegrity", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.GlobalIntegrity == nil {
m.GlobalIntegrity = &GlobalIntegrity{}
}
if err := m.GlobalIntegrity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthGenesis
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *GlobalIntegrity) 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 ErrIntOverflowGenesis
}
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: GlobalIntegrity: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: GlobalIntegrity: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
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 ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Controller = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Seed", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
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 ErrInvalidLengthGenesis
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Seed = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Accumulator", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthGenesis
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthGenesis
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Accumulator = append(m.Accumulator[:0], dAtA[iNdEx:postIndex]...)
if m.Accumulator == nil {
m.Accumulator = []byte{}
}
iNdEx = postIndex
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType)
}
m.Count = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenesis
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Count |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipGenesis(dAtA[iNdEx:])
-27
View File
@@ -1,27 +0,0 @@
package types
import "lukechampine.com/blake3"
func (g *GlobalIntegrity) Update(address string) bool {
return true
}
func (g *GlobalIntegrity) getProof() (*Proof, error) {
if g.Accumulator == nil {
return NewProof(g.Controller, g.proofProperty(), g.seedKdf())
}
return &Proof{
Issuer: g.Controller,
Property: g.proofProperty(),
Accumulator: g.Accumulator,
}, nil
}
func (g *GlobalIntegrity) proofProperty() string {
return "did:sonr:integrity"
}
func (g *GlobalIntegrity) seedKdf() []byte {
res := blake3.Sum256([]byte(g.Seed))
return res[:]
}
File diff suppressed because it is too large Load Diff
-102
View File
@@ -1,102 +0,0 @@
package types
import (
"cosmossdk.io/x/nft"
)
func (n DIDNamespace) ID() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "did:dwn:0"
case DIDNamespace_DID_NAMESPACE_SONR:
return "did:sonr:0"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "did:btc:0"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "did:eth:0"
case DIDNamespace_DID_NAMESPACE_IBC:
return "did:ibc:0"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "did:authn:0"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "did:web:0"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "did:ipfs:0"
}
return ""
}
func (n DIDNamespace) Name() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "DecentralizedWebNode"
case DIDNamespace_DID_NAMESPACE_SONR:
return "SonrNetwork"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "BitcoinNetwork"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "EthereumNetwork"
case DIDNamespace_DID_NAMESPACE_IBC:
return "IBCNetwork"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "WebAuthentication"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "DecentrlizedService"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "IPFSStorage"
}
return ""
}
func (n DIDNamespace) Symbol() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "DWN"
case DIDNamespace_DID_NAMESPACE_SONR:
return "SONR"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "BTC"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "ETH"
case DIDNamespace_DID_NAMESPACE_IBC:
return "IBC"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "WEBAUTHN"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "SERVICE"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "IPFS"
}
return ""
}
func (n DIDNamespace) Description() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "DWN Service Provider"
case DIDNamespace_DID_NAMESPACE_SONR:
return "Sonr Network Gateway"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "Bitcoin Network Gateway"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "Ethereum Network Gateway"
case DIDNamespace_DID_NAMESPACE_IBC:
return "IBC Network Gateway"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "Web Authentication Key"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "Decentrlized Service"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "Data Storage on IPFS"
}
return ""
}
func (n DIDNamespace) GetNFTClass() *nft.Class {
return &nft.Class{
Id: n.ID(),
Name: n.Name(),
Symbol: n.Symbol(),
Description: n.Description(),
}
}
-34
View File
@@ -1,34 +0,0 @@
// Code generated from Pkl module `oidc`. DO NOT EDIT.
package oidc
type DiscoveryDocument struct {
Issuer string `pkl:"issuer" json:"issuer,omitempty" param:"issuer"`
AuthorizationEndpoint string `pkl:"authorization_endpoint" json:"authorization_endpoint,omitempty" param:"authorization_endpoint"`
TokenEndpoint string `pkl:"token_endpoint" json:"token_endpoint,omitempty" param:"token_endpoint"`
UserinfoEndpoint string `pkl:"userinfo_endpoint" json:"userinfo_endpoint,omitempty" param:"userinfo_endpoint"`
JwksUri string `pkl:"jwks_uri" json:"jwks_uri,omitempty" param:"jwks_uri"`
RegistrationEndpoint string `pkl:"registration_endpoint" json:"registration_endpoint,omitempty" param:"registration_endpoint"`
ScopesSupported []string `pkl:"scopes_supported" json:"scopes_supported,omitempty" param:"scopes_supported"`
ResponseTypesSupported []string `pkl:"response_types_supported" json:"response_types_supported,omitempty" param:"response_types_supported"`
ResponseModesSupported []string `pkl:"response_modes_supported" json:"response_modes_supported,omitempty" param:"response_modes_supported"`
SubjectTypesSupported []string `pkl:"subject_types_supported" json:"subject_types_supported,omitempty" param:"subject_types_supported"`
IdTokenSigningAlgValuesSupported []string `pkl:"id_token_signing_alg_values_supported" json:"id_token_signing_alg_values_supported,omitempty" param:"id_token_signing_alg_values_supported"`
ClaimsSupported []string `pkl:"claims_supported" json:"claims_supported,omitempty" param:"claims_supported"`
GrantTypesSupported []string `pkl:"grant_types_supported" json:"grant_types_supported,omitempty" param:"grant_types_supported"`
AcrValuesSupported []string `pkl:"acr_values_supported" json:"acr_values_supported,omitempty" param:"acr_values_supported"`
TokenEndpointAuthMethodsSupported []string `pkl:"token_endpoint_auth_methods_supported" json:"token_endpoint_auth_methods_supported,omitempty" param:"token_endpoint_auth_methods_supported"`
}
-36
View File
@@ -1,36 +0,0 @@
// Code generated from Pkl module `oidc`. DO NOT EDIT.
package oidc
import (
"context"
"github.com/apple/pkl-go/pkl"
)
type Oidc struct {
}
// LoadFromPath loads the pkl module at the given path and evaluates it into a Oidc
func LoadFromPath(ctx context.Context, path string) (ret *Oidc, err error) {
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
if err != nil {
return nil, err
}
defer func() {
cerr := evaluator.Close()
if err == nil {
err = cerr
}
}()
ret, err = Load(ctx, evaluator, pkl.FileSource(path))
return ret, err
}
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Oidc
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Oidc, error) {
var ret Oidc
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
return nil, err
}
return &ret, nil
}
-9
View File
@@ -1,9 +0,0 @@
// Code generated from Pkl module `oidc`. DO NOT EDIT.
package oidc
import "github.com/apple/pkl-go/pkl"
func init() {
pkl.RegisterMapping("oidc", Oidc{})
pkl.RegisterMapping("oidc#DiscoveryDocument", DiscoveryDocument{})
}
-152
View File
@@ -1,153 +1 @@
package types
import (
"crypto/ecdsa"
"encoding/hex"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/mr-tron/base58/base58"
"github.com/onsonr/crypto"
"github.com/onsonr/crypto/macaroon"
)
var WalletKeyInfo = &KeyInfo{
Role: KeyRole_KEY_ROLE_DELEGATION,
Curve: KeyCurve_KEY_CURVE_SECP256K1,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_BIP32,
}
var EthKeyInfo = &KeyInfo{
Role: KeyRole_KEY_ROLE_DELEGATION,
Curve: KeyCurve_KEY_CURVE_KECCAK256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_BIP32,
}
var SonrKeyInfo = &KeyInfo{
Role: KeyRole_KEY_ROLE_INVOCATION,
Curve: KeyCurve_KEY_CURVE_P256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_MPC,
}
var ChainCodeKeyInfos = map[ChainCode]*KeyInfo{
ChainCodeBTC: WalletKeyInfo,
ChainCodeETH: EthKeyInfo,
ChainCodeSNR: SonrKeyInfo,
ChainCodeIBC: WalletKeyInfo,
}
// NewEthPublicKey returns a new ethereum public key
func NewPublicKey(data []byte, keyInfo *KeyInfo) (*PubKey, error) {
encKey, err := keyInfo.Encoding.EncodeRaw(data)
if err != nil {
return nil, err
}
return &PubKey{
Raw: encKey,
Role: keyInfo.Role,
Encoding: keyInfo.Encoding,
Algorithm: keyInfo.Algorithm,
Curve: keyInfo.Curve,
KeyType: keyInfo.Type,
}, nil
}
// Address returns the address of the public key
func (k *PubKey) Address() cryptotypes.Address {
return nil
}
// Bytes returns the raw bytes of the public key
func (k *PubKey) Bytes() []byte {
bz, _ := k.GetEncoding().DecodeRaw(k.GetRaw())
return bz
}
// Clone returns a copy of the public key
func (k *PubKey) Clone() cryptotypes.PubKey {
return &PubKey{
Raw: k.GetRaw(),
Role: k.GetRole(),
Encoding: k.GetEncoding(),
Algorithm: k.GetAlgorithm(),
Curve: k.GetCurve(),
KeyType: k.GetKeyType(),
}
}
// IssueMacaroon returns a macaroon for the public key with the given id and location
func (pk *PubKey) IssueMacaroon(subject string, origin string) (*macaroon.Macaroon, error) {
return macaroon.New(pk.Bytes(), []byte(subject), origin, macaroon.LatestVersion)
}
// ECDSA returns the ECDSA public key
func (k *PubKey) ECDSA() (*ecdsa.PublicKey, error) {
return crypto.ComputeEcdsaPublicKey(k.Bytes())
}
// VerifySignature verifies a signature over the given message
func (k *PubKey) VerifySignature(msg []byte, sig []byte) bool {
pk, err := crypto.ComputeEcdsaPublicKey(k.Bytes())
sigMpc, err := crypto.DeserializeMPCSignature(sig)
if err != nil {
return false
}
return crypto.VerifyMPCSignature(sigMpc, msg, pk)
}
// Equals returns true if two public keys are equal
func (k *PubKey) Equals(k2 cryptotypes.PubKey) bool {
if k == nil && k2 == nil {
return true
}
return false
}
// Type returns the type of the public key
func (k *PubKey) Type() string {
return k.KeyType.String()
}
// DecodePublicKey extracts the public key from the given data
func (k *KeyInfo) DecodePublicKey(data interface{}) ([]byte, error) {
var bz []byte
switch v := data.(type) {
case string:
bz = []byte(v)
case []byte:
bz = v
default:
return nil, ErrUnsupportedKeyEncoding
}
if k.Encoding == KeyEncoding_KEY_ENCODING_RAW {
return bz, nil
}
if k.Encoding == KeyEncoding_KEY_ENCODING_HEX {
return hex.DecodeString(string(bz))
}
if k.Encoding == KeyEncoding_KEY_ENCODING_MULTIBASE {
return base58.Decode(string(bz))
}
return nil, ErrUnsupportedKeyEncoding
}
// EncodePublicKey encodes the public key according to the KeyInfo's encoding
func (k *KeyInfo) EncodePublicKey(data []byte) (string, error) {
if k.Encoding == KeyEncoding_KEY_ENCODING_RAW {
return string(data), nil
}
if k.Encoding == KeyEncoding_KEY_ENCODING_HEX {
return hex.EncodeToString(data), nil
}
if k.Encoding == KeyEncoding_KEY_ENCODING_MULTIBASE {
return base58.Encode(data), nil
}
return "", ErrUnsupportedKeyEncoding
}
-53
View File
@@ -1,53 +0,0 @@
package types
import "gopkg.in/macaroon-bakery.v2/bakery/checkers"
var (
PermissionScopeStrings = [...]string{
"profile.name",
"identifiers.email",
"identifiers.phone",
"transactions.read",
"transactions.write",
"wallets.read",
"wallets.create",
"wallets.subscribe",
"wallets.update",
"transactions.verify",
"transactions.broadcast",
"admin.user",
"admin.validator",
}
StringToPermissionScope = map[string]PermissionScope{
"PERMISSION_SCOPE_UNSPECIFIED": PermissionScope_PERMISSION_SCOPE_UNSPECIFIED,
"PERMISSION_SCOPE_BASIC_INFO": PermissionScope_PERMISSION_SCOPE_BASIC_INFO,
"PERMISSION_SCOPE_IDENTIFIERS_EMAIL": PermissionScope_PERMISSION_SCOPE_PERMISSIONS_READ,
"PERMISSION_SCOPE_IDENTIFIERS_PHONE": PermissionScope_PERMISSION_SCOPE_PERMISSIONS_WRITE,
"PERMISSION_SCOPE_TRANSACTIONS_READ": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_READ,
"PERMISSION_SCOPE_TRANSACTIONS_WRITE": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_WRITE,
"PERMISSION_SCOPE_WALLETS_READ": PermissionScope_PERMISSION_SCOPE_WALLETS_READ,
"PERMISSION_SCOPE_WALLETS_CREATE": PermissionScope_PERMISSION_SCOPE_WALLETS_CREATE,
"PERMISSION_SCOPE_WALLETS_SUBSCRIBE": PermissionScope_PERMISSION_SCOPE_WALLETS_SUBSCRIBE,
"PERMISSION_SCOPE_WALLETS_UPDATE": PermissionScope_PERMISSION_SCOPE_WALLETS_UPDATE,
"PERMISSION_SCOPE_TRANSACTIONS_VERIFY": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_VERIFY,
"PERMISSION_SCOPE_TRANSACTIONS_BROADCAST": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_BROADCAST,
"PERMISSION_SCOPE_ADMIN_USER": PermissionScope_PERMISSION_SCOPE_ADMIN_USER,
"PERMISSION_SCOPE_ADMIN_VALIDATOR": PermissionScope_PERMISSION_SCOPE_ADMIN_VALIDATOR,
}
)
func ResolvePermissionScope(scope string) (PermissionScope, bool) {
uriToPrefix := make(map[string]string)
for _, scope := range PermissionScopeStrings {
uriToPrefix["https://example.com/auth/"+scope] = scope
}
PermissionNamespace := checkers.NewNamespace(uriToPrefix)
prefix, ok := PermissionNamespace.Resolve("https://example.com/auth/" + scope)
if !ok {
return 0, false
}
permScope, ok := StringToPermissionScope[prefix]
return permScope, ok
}
+2 -2
View File
@@ -345,11 +345,11 @@ var fileDescriptor_f44bb702879c34b4 = []byte{
0xb7, 0x97, 0xed, 0x3f, 0x03, 0x79, 0x06, 0xfb, 0xb3, 0x52, 0xff, 0x03, 0x35, 0x9f, 0x32, 0x17,
0x4c, 0x50, 0x3e, 0x78, 0x37, 0x9f, 0xb2, 0xfe, 0xd4, 0x18, 0x7c, 0xb5, 0x59, 0x58, 0xdb, 0x4d,
0xd7, 0x69, 0x1b, 0x8b, 0x3b, 0xf0, 0x70, 0x33, 0x5e, 0x77, 0x33, 0x5b, 0xd7, 0x72, 0x8d, 0xe7,
0xc7, 0xd0, 0xbe, 0x23, 0xba, 0xba, 0x64, 0xc5, 0xf3, 0x09, 0x22, 0xd5, 0xd7, 0xaf, 0x7e, 0x2c,
0xc7, 0xd0, 0xbe, 0x23, 0xba, 0xba, 0x64, 0xc5, 0xf3, 0x09, 0x22, 0x95, 0xd7, 0xaf, 0x7e, 0x2c,
0x42, 0x74, 0xb3, 0x08, 0xd1, 0x9f, 0x45, 0x88, 0xbe, 0x2e, 0xc3, 0x9d, 0x9b, 0x65, 0xb8, 0xf3,
0x6b, 0x19, 0xee, 0x7c, 0xe8, 0x0c, 0xb9, 0x1a, 0x15, 0x49, 0x2f, 0x15, 0x93, 0x48, 0x64, 0x3a,
0xe9, 0xc8, 0x7c, 0x3e, 0x47, 0xfa, 0xd9, 0xea, 0x1b, 0x65, 0x52, 0x33, 0x4f, 0xf6, 0xe5, 0xbf,
0x00, 0x00, 0x00, 0xff, 0xff, 0x58, 0x8d, 0xb9, 0xaa, 0xff, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x53, 0x80, 0x70, 0xff, 0x03, 0x00, 0x00,
}
func (m *Alias) Marshal() (dAtA []byte, err error) {
+1071 -493
View File
File diff suppressed because it is too large Load Diff
-6
View File
@@ -1,6 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
type Msg interface {
GetTypeUrl() string
}
@@ -1,44 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgDidAllocateVault interface {
Msg
GetAuthority() string
GetSubject() string
GetToken() *pkl.Object
}
var _ MsgDidAllocateVault = (*MsgDidAllocateVaultImpl)(nil)
type MsgDidAllocateVaultImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Authority string `pkl:"authority"`
Subject string `pkl:"subject"`
Token *pkl.Object `pkl:"token"`
}
// The type URL for the message
func (rcv *MsgDidAllocateVaultImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgDidAllocateVaultImpl) GetAuthority() string {
return rcv.Authority
}
func (rcv *MsgDidAllocateVaultImpl) GetSubject() string {
return rcv.Subject
}
func (rcv *MsgDidAllocateVaultImpl) GetToken() *pkl.Object {
return rcv.Token
}
-60
View File
@@ -1,60 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgDidAuthorize interface {
Msg
GetAuthority() string
GetController() string
GetAddress() string
GetOrigin() string
GetToken() *pkl.Object
}
var _ MsgDidAuthorize = (*MsgDidAuthorizeImpl)(nil)
type MsgDidAuthorizeImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Authority string `pkl:"authority"`
Controller string `pkl:"controller"`
Address string `pkl:"address"`
Origin string `pkl:"origin"`
Token *pkl.Object `pkl:"token"`
}
// The type URL for the message
func (rcv *MsgDidAuthorizeImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgDidAuthorizeImpl) GetAuthority() string {
return rcv.Authority
}
func (rcv *MsgDidAuthorizeImpl) GetController() string {
return rcv.Controller
}
func (rcv *MsgDidAuthorizeImpl) GetAddress() string {
return rcv.Address
}
func (rcv *MsgDidAuthorizeImpl) GetOrigin() string {
return rcv.Origin
}
func (rcv *MsgDidAuthorizeImpl) GetToken() *pkl.Object {
return rcv.Token
}
@@ -1,52 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgDidProveWitness interface {
Msg
GetAuthority() string
GetProperty() string
GetWitness() []int
GetToken() *pkl.Object
}
var _ MsgDidProveWitness = (*MsgDidProveWitnessImpl)(nil)
type MsgDidProveWitnessImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Authority string `pkl:"authority"`
Property string `pkl:"property"`
Witness []int `pkl:"witness"`
Token *pkl.Object `pkl:"token"`
}
// The type URL for the message
func (rcv *MsgDidProveWitnessImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgDidProveWitnessImpl) GetAuthority() string {
return rcv.Authority
}
func (rcv *MsgDidProveWitnessImpl) GetProperty() string {
return rcv.Property
}
func (rcv *MsgDidProveWitnessImpl) GetWitness() []int {
return rcv.Witness
}
func (rcv *MsgDidProveWitnessImpl) GetToken() *pkl.Object {
return rcv.Token
}
@@ -1,60 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgDidRegisterController interface {
Msg
GetAuthority() string
GetCid() string
GetOrigin() string
GetAuthentication() []*pkl.Object
GetToken() *pkl.Object
}
var _ MsgDidRegisterController = (*MsgDidRegisterControllerImpl)(nil)
type MsgDidRegisterControllerImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Authority string `pkl:"authority"`
Cid string `pkl:"cid"`
Origin string `pkl:"origin"`
Authentication []*pkl.Object `pkl:"authentication"`
Token *pkl.Object `pkl:"token"`
}
// The type URL for the message
func (rcv *MsgDidRegisterControllerImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgDidRegisterControllerImpl) GetAuthority() string {
return rcv.Authority
}
func (rcv *MsgDidRegisterControllerImpl) GetCid() string {
return rcv.Cid
}
func (rcv *MsgDidRegisterControllerImpl) GetOrigin() string {
return rcv.Origin
}
func (rcv *MsgDidRegisterControllerImpl) GetAuthentication() []*pkl.Object {
return rcv.Authentication
}
func (rcv *MsgDidRegisterControllerImpl) GetToken() *pkl.Object {
return rcv.Token
}
@@ -1,76 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgDidRegisterService interface {
Msg
GetController() string
GetOriginUri() string
GetScopes() *pkl.Object
GetDescription() string
GetServiceEndpoints() map[string]string
GetMetadata() *pkl.Object
GetToken() *pkl.Object
}
var _ MsgDidRegisterService = (*MsgDidRegisterServiceImpl)(nil)
type MsgDidRegisterServiceImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Controller string `pkl:"controller"`
OriginUri string `pkl:"originUri"`
Scopes *pkl.Object `pkl:"scopes"`
Description string `pkl:"description"`
ServiceEndpoints map[string]string `pkl:"serviceEndpoints"`
Metadata *pkl.Object `pkl:"metadata"`
Token *pkl.Object `pkl:"token"`
}
// The type URL for the message
func (rcv *MsgDidRegisterServiceImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgDidRegisterServiceImpl) GetController() string {
return rcv.Controller
}
func (rcv *MsgDidRegisterServiceImpl) GetOriginUri() string {
return rcv.OriginUri
}
func (rcv *MsgDidRegisterServiceImpl) GetScopes() *pkl.Object {
return rcv.Scopes
}
func (rcv *MsgDidRegisterServiceImpl) GetDescription() string {
return rcv.Description
}
func (rcv *MsgDidRegisterServiceImpl) GetServiceEndpoints() map[string]string {
return rcv.ServiceEndpoints
}
func (rcv *MsgDidRegisterServiceImpl) GetMetadata() *pkl.Object {
return rcv.Metadata
}
func (rcv *MsgDidRegisterServiceImpl) GetToken() *pkl.Object {
return rcv.Token
}
-36
View File
@@ -1,36 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgDidSyncVault interface {
Msg
GetController() string
GetToken() *pkl.Object
}
var _ MsgDidSyncVault = (*MsgDidSyncVaultImpl)(nil)
type MsgDidSyncVaultImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Controller string `pkl:"controller"`
Token *pkl.Object `pkl:"token"`
}
// The type URL for the message
func (rcv *MsgDidSyncVaultImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgDidSyncVaultImpl) GetController() string {
return rcv.Controller
}
func (rcv *MsgDidSyncVaultImpl) GetToken() *pkl.Object {
return rcv.Token
}
@@ -1,44 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgDidUpdateParams interface {
Msg
GetAuthority() string
GetParams() *pkl.Object
GetToken() *pkl.Object
}
var _ MsgDidUpdateParams = (*MsgDidUpdateParamsImpl)(nil)
type MsgDidUpdateParamsImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Authority string `pkl:"authority"`
Params *pkl.Object `pkl:"params"`
Token *pkl.Object `pkl:"token"`
}
// The type URL for the message
func (rcv *MsgDidUpdateParamsImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgDidUpdateParamsImpl) GetAuthority() string {
return rcv.Authority
}
func (rcv *MsgDidUpdateParamsImpl) GetParams() *pkl.Object {
return rcv.Params
}
func (rcv *MsgDidUpdateParamsImpl) GetToken() *pkl.Object {
return rcv.Token
}
-44
View File
@@ -1,44 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgGovDeposit interface {
Msg
GetProposalId() int
GetDepositor() string
GetAmount() []*pkl.Object
}
var _ MsgGovDeposit = (*MsgGovDepositImpl)(nil)
type MsgGovDepositImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
ProposalId int `pkl:"proposalId"`
Depositor string `pkl:"depositor"`
Amount []*pkl.Object `pkl:"amount"`
}
// The type URL for the message
func (rcv *MsgGovDepositImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgGovDepositImpl) GetProposalId() int {
return rcv.ProposalId
}
func (rcv *MsgGovDepositImpl) GetDepositor() string {
return rcv.Depositor
}
func (rcv *MsgGovDepositImpl) GetAmount() []*pkl.Object {
return rcv.Amount
}
@@ -1,45 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgGovSubmitProposal interface {
Msg
GetContent() *Proposal
GetInitialDeposit() []*pkl.Object
GetProposer() string
}
var _ MsgGovSubmitProposal = (*MsgGovSubmitProposalImpl)(nil)
// Gov module messages
type MsgGovSubmitProposalImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Content *Proposal `pkl:"content"`
InitialDeposit []*pkl.Object `pkl:"initialDeposit"`
Proposer string `pkl:"proposer"`
}
// The type URL for the message
func (rcv *MsgGovSubmitProposalImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgGovSubmitProposalImpl) GetContent() *Proposal {
return rcv.Content
}
func (rcv *MsgGovSubmitProposalImpl) GetInitialDeposit() []*pkl.Object {
return rcv.InitialDeposit
}
func (rcv *MsgGovSubmitProposalImpl) GetProposer() string {
return rcv.Proposer
}
-42
View File
@@ -1,42 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
type MsgGovVote interface {
Msg
GetProposalId() int
GetVoter() string
GetOption() int
}
var _ MsgGovVote = (*MsgGovVoteImpl)(nil)
type MsgGovVoteImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
ProposalId int `pkl:"proposalId"`
Voter string `pkl:"voter"`
Option int `pkl:"option"`
}
// The type URL for the message
func (rcv *MsgGovVoteImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgGovVoteImpl) GetProposalId() int {
return rcv.ProposalId
}
func (rcv *MsgGovVoteImpl) GetVoter() string {
return rcv.Voter
}
func (rcv *MsgGovVoteImpl) GetOption() int {
return rcv.Option
}
@@ -1,45 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgGroupCreateGroup interface {
Msg
GetAdmin() string
GetMembers() []*pkl.Object
GetMetadata() string
}
var _ MsgGroupCreateGroup = (*MsgGroupCreateGroupImpl)(nil)
// Group module messages
type MsgGroupCreateGroupImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Admin string `pkl:"admin"`
Members []*pkl.Object `pkl:"members"`
Metadata string `pkl:"metadata"`
}
// The type URL for the message
func (rcv *MsgGroupCreateGroupImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgGroupCreateGroupImpl) GetAdmin() string {
return rcv.Admin
}
func (rcv *MsgGroupCreateGroupImpl) GetMembers() []*pkl.Object {
return rcv.Members
}
func (rcv *MsgGroupCreateGroupImpl) GetMetadata() string {
return rcv.Metadata
}
@@ -1,60 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgGroupSubmitProposal interface {
Msg
GetGroupPolicyAddress() string
GetProposers() []string
GetMetadata() string
GetMessages() []*pkl.Object
GetExec() int
}
var _ MsgGroupSubmitProposal = (*MsgGroupSubmitProposalImpl)(nil)
type MsgGroupSubmitProposalImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
GroupPolicyAddress string `pkl:"groupPolicyAddress"`
Proposers []string `pkl:"proposers"`
Metadata string `pkl:"metadata"`
Messages []*pkl.Object `pkl:"messages"`
Exec int `pkl:"exec"`
}
// The type URL for the message
func (rcv *MsgGroupSubmitProposalImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgGroupSubmitProposalImpl) GetGroupPolicyAddress() string {
return rcv.GroupPolicyAddress
}
func (rcv *MsgGroupSubmitProposalImpl) GetProposers() []string {
return rcv.Proposers
}
func (rcv *MsgGroupSubmitProposalImpl) GetMetadata() string {
return rcv.Metadata
}
func (rcv *MsgGroupSubmitProposalImpl) GetMessages() []*pkl.Object {
return rcv.Messages
}
func (rcv *MsgGroupSubmitProposalImpl) GetExec() int {
return rcv.Exec
}
-58
View File
@@ -1,58 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
type MsgGroupVote interface {
Msg
GetProposalId() int
GetVoter() string
GetOption() int
GetMetadata() string
GetExec() int
}
var _ MsgGroupVote = (*MsgGroupVoteImpl)(nil)
type MsgGroupVoteImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
ProposalId int `pkl:"proposalId"`
Voter string `pkl:"voter"`
Option int `pkl:"option"`
Metadata string `pkl:"metadata"`
Exec int `pkl:"exec"`
}
// The type URL for the message
func (rcv *MsgGroupVoteImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgGroupVoteImpl) GetProposalId() int {
return rcv.ProposalId
}
func (rcv *MsgGroupVoteImpl) GetVoter() string {
return rcv.Voter
}
func (rcv *MsgGroupVoteImpl) GetOption() int {
return rcv.Option
}
func (rcv *MsgGroupVoteImpl) GetMetadata() string {
return rcv.Metadata
}
func (rcv *MsgGroupVoteImpl) GetExec() int {
return rcv.Exec
}
@@ -1,52 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgStakingBeginRedelegate interface {
Msg
GetDelegatorAddress() string
GetValidatorSrcAddress() string
GetValidatorDstAddress() string
GetAmount() *pkl.Object
}
var _ MsgStakingBeginRedelegate = (*MsgStakingBeginRedelegateImpl)(nil)
type MsgStakingBeginRedelegateImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
DelegatorAddress string `pkl:"delegatorAddress"`
ValidatorSrcAddress string `pkl:"validatorSrcAddress"`
ValidatorDstAddress string `pkl:"validatorDstAddress"`
Amount *pkl.Object `pkl:"amount"`
}
// The type URL for the message
func (rcv *MsgStakingBeginRedelegateImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgStakingBeginRedelegateImpl) GetDelegatorAddress() string {
return rcv.DelegatorAddress
}
func (rcv *MsgStakingBeginRedelegateImpl) GetValidatorSrcAddress() string {
return rcv.ValidatorSrcAddress
}
func (rcv *MsgStakingBeginRedelegateImpl) GetValidatorDstAddress() string {
return rcv.ValidatorDstAddress
}
func (rcv *MsgStakingBeginRedelegateImpl) GetAmount() *pkl.Object {
return rcv.Amount
}
@@ -1,77 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgStakingCreateValidator interface {
Msg
GetDescription() *pkl.Object
GetCommission() *pkl.Object
GetMinSelfDelegation() string
GetDelegatorAddress() string
GetValidatorAddress() string
GetPubkey() *pkl.Object
GetValue() *pkl.Object
}
var _ MsgStakingCreateValidator = (*MsgStakingCreateValidatorImpl)(nil)
// Staking module messages
type MsgStakingCreateValidatorImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
Description *pkl.Object `pkl:"description"`
Commission *pkl.Object `pkl:"commission"`
MinSelfDelegation string `pkl:"minSelfDelegation"`
DelegatorAddress string `pkl:"delegatorAddress"`
ValidatorAddress string `pkl:"validatorAddress"`
Pubkey *pkl.Object `pkl:"pubkey"`
Value *pkl.Object `pkl:"value"`
}
// The type URL for the message
func (rcv *MsgStakingCreateValidatorImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgStakingCreateValidatorImpl) GetDescription() *pkl.Object {
return rcv.Description
}
func (rcv *MsgStakingCreateValidatorImpl) GetCommission() *pkl.Object {
return rcv.Commission
}
func (rcv *MsgStakingCreateValidatorImpl) GetMinSelfDelegation() string {
return rcv.MinSelfDelegation
}
func (rcv *MsgStakingCreateValidatorImpl) GetDelegatorAddress() string {
return rcv.DelegatorAddress
}
func (rcv *MsgStakingCreateValidatorImpl) GetValidatorAddress() string {
return rcv.ValidatorAddress
}
func (rcv *MsgStakingCreateValidatorImpl) GetPubkey() *pkl.Object {
return rcv.Pubkey
}
func (rcv *MsgStakingCreateValidatorImpl) GetValue() *pkl.Object {
return rcv.Value
}
@@ -1,44 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgStakingDelegate interface {
Msg
GetDelegatorAddress() string
GetValidatorAddress() string
GetAmount() *pkl.Object
}
var _ MsgStakingDelegate = (*MsgStakingDelegateImpl)(nil)
type MsgStakingDelegateImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
DelegatorAddress string `pkl:"delegatorAddress"`
ValidatorAddress string `pkl:"validatorAddress"`
Amount *pkl.Object `pkl:"amount"`
}
// The type URL for the message
func (rcv *MsgStakingDelegateImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgStakingDelegateImpl) GetDelegatorAddress() string {
return rcv.DelegatorAddress
}
func (rcv *MsgStakingDelegateImpl) GetValidatorAddress() string {
return rcv.ValidatorAddress
}
func (rcv *MsgStakingDelegateImpl) GetAmount() *pkl.Object {
return rcv.Amount
}
@@ -1,44 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
type MsgStakingUndelegate interface {
Msg
GetDelegatorAddress() string
GetValidatorAddress() string
GetAmount() *pkl.Object
}
var _ MsgStakingUndelegate = (*MsgStakingUndelegateImpl)(nil)
type MsgStakingUndelegateImpl struct {
// The type URL for the message
TypeUrl string `pkl:"typeUrl"`
DelegatorAddress string `pkl:"delegatorAddress"`
ValidatorAddress string `pkl:"validatorAddress"`
Amount *pkl.Object `pkl:"amount"`
}
// The type URL for the message
func (rcv *MsgStakingUndelegateImpl) GetTypeUrl() string {
return rcv.TypeUrl
}
func (rcv *MsgStakingUndelegateImpl) GetDelegatorAddress() string {
return rcv.DelegatorAddress
}
func (rcv *MsgStakingUndelegateImpl) GetValidatorAddress() string {
return rcv.ValidatorAddress
}
func (rcv *MsgStakingUndelegateImpl) GetAmount() *pkl.Object {
return rcv.Amount
}
-11
View File
@@ -1,11 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
// Base class for all proposals
type Proposal struct {
// The title of the proposal
Title string `pkl:"title"`
// The description of the proposal
Description string `pkl:"description"`
}
-17
View File
@@ -1,17 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
// Represents a transaction body
type TxBody struct {
Messages []Msg `pkl:"messages"`
Memo *string `pkl:"memo"`
TimeoutHeight *int `pkl:"timeoutHeight"`
ExtensionOptions *[]*pkl.Object `pkl:"extensionOptions"`
NonCriticalExtensionOptions *[]*pkl.Object `pkl:"nonCriticalExtensionOptions"`
}
-36
View File
@@ -1,36 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import (
"context"
"github.com/apple/pkl-go/pkl"
)
type Txns struct {
}
// LoadFromPath loads the pkl module at the given path and evaluates it into a Txns
func LoadFromPath(ctx context.Context, path string) (ret *Txns, err error) {
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
if err != nil {
return nil, err
}
defer func() {
cerr := evaluator.Close()
if err == nil {
err = cerr
}
}()
ret, err = Load(ctx, evaluator, pkl.FileSource(path))
return ret, err
}
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Txns
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Txns, error) {
var ret Txns
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
return nil, err
}
return &ret, nil
}
-27
View File
@@ -1,27 +0,0 @@
// Code generated from Pkl module `txns`. DO NOT EDIT.
package txns
import "github.com/apple/pkl-go/pkl"
func init() {
pkl.RegisterMapping("txns", Txns{})
pkl.RegisterMapping("txns#Proposal", Proposal{})
pkl.RegisterMapping("txns#MsgGovSubmitProposal", MsgGovSubmitProposalImpl{})
pkl.RegisterMapping("txns#MsgGovVote", MsgGovVoteImpl{})
pkl.RegisterMapping("txns#MsgGovDeposit", MsgGovDepositImpl{})
pkl.RegisterMapping("txns#MsgGroupCreateGroup", MsgGroupCreateGroupImpl{})
pkl.RegisterMapping("txns#MsgGroupSubmitProposal", MsgGroupSubmitProposalImpl{})
pkl.RegisterMapping("txns#MsgGroupVote", MsgGroupVoteImpl{})
pkl.RegisterMapping("txns#MsgStakingCreateValidator", MsgStakingCreateValidatorImpl{})
pkl.RegisterMapping("txns#MsgStakingDelegate", MsgStakingDelegateImpl{})
pkl.RegisterMapping("txns#MsgStakingUndelegate", MsgStakingUndelegateImpl{})
pkl.RegisterMapping("txns#MsgStakingBeginRedelegate", MsgStakingBeginRedelegateImpl{})
pkl.RegisterMapping("txns#MsgDidUpdateParams", MsgDidUpdateParamsImpl{})
pkl.RegisterMapping("txns#MsgDidAllocateVault", MsgDidAllocateVaultImpl{})
pkl.RegisterMapping("txns#MsgDidProveWitness", MsgDidProveWitnessImpl{})
pkl.RegisterMapping("txns#MsgDidSyncVault", MsgDidSyncVaultImpl{})
pkl.RegisterMapping("txns#MsgDidRegisterController", MsgDidRegisterControllerImpl{})
pkl.RegisterMapping("txns#MsgDidAuthorize", MsgDidAuthorizeImpl{})
pkl.RegisterMapping("txns#MsgDidRegisterService", MsgDidRegisterServiceImpl{})
pkl.RegisterMapping("txns#TxBody", TxBody{})
}
-155
View File
@@ -1,155 +0,0 @@
package types
import (
"fmt"
"github.com/onsonr/crypto/accumulator"
"github.com/onsonr/crypto/core/curves"
)
// Accumulator is the accumulator for the ZKP
type Accumulator []byte
// Element is the element for the BLS scheme
type Element = accumulator.Element
// Witness is the witness for the ZKP
type Witness []byte
// NewProof creates a new Proof which is used for ZKP
func NewProof(issuer, property string, pubKey []byte) (*Proof, error) {
input := append(pubKey, []byte(property)...)
hash := []byte(input)
curve := curves.BLS12381(&curves.PointBls12381G1{})
key, err := new(accumulator.SecretKey).New(curve, hash[:])
if err != nil {
return nil, fmt.Errorf("failed to create secret key: %w", err)
}
keyBytes, err := key.MarshalBinary()
if err != nil {
return nil, fmt.Errorf("failed to marshal secret key: %w", err)
}
return &Proof{
Issuer: issuer,
Property: property,
Accumulator: keyBytes,
}, nil
}
// CreateAccumulator creates a new accumulator for a Proof
func CreateAccumulator(proof *Proof, values ...string) error {
curve := curves.BLS12381(&curves.PointBls12381G1{})
acc, err := new(accumulator.Accumulator).New(curve)
if err != nil {
return err
}
secretKey := new(accumulator.SecretKey)
if err := secretKey.UnmarshalBinary(proof.Accumulator); err != nil {
return err
}
fin, _, err := acc.Update(secretKey, ConvertValuesToZeroKnowledgeElements(values), nil)
if err != nil {
return err
}
accBytes, err := fin.MarshalBinary()
if err != nil {
return fmt.Errorf("failed to marshal accumulator: %w", err)
}
proof.Accumulator = accBytes
return nil
}
// CreateWitness creates a witness for the accumulator in a Proof for a given value
func CreateWitness(proof *Proof, value string) ([]byte, error) {
curve := curves.BLS12381(&curves.PointBls12381G1{})
element := curve.Scalar.Hash([]byte(value))
secretKey := new(accumulator.SecretKey)
if err := secretKey.UnmarshalBinary(proof.Accumulator); err != nil {
return nil, err
}
accObj := new(accumulator.Accumulator)
if err := accObj.UnmarshalBinary(proof.Accumulator); err != nil {
return nil, fmt.Errorf("failed to unmarshal accumulator: %w", err)
}
mw, err := new(accumulator.MembershipWitness).New(element, accObj, secretKey)
if err != nil {
return nil, err
}
witnessBytes, err := mw.MarshalBinary()
if err != nil {
return nil, fmt.Errorf("failed to marshal witness: %w", err)
}
return witnessBytes, nil
}
// VerifyWitness proves that a value is a member of the accumulator
func VerifyWitness(proof *Proof, acc Accumulator, witness Witness) error {
secretKey := new(accumulator.SecretKey)
if err := secretKey.UnmarshalBinary([]byte(proof.Id)); err != nil {
return err
}
curve := curves.BLS12381(&curves.PointBls12381G1{})
publicKey, err := secretKey.GetPublicKey(curve)
if err != nil {
return err
}
accObj := new(accumulator.Accumulator)
if err := accObj.UnmarshalBinary(proof.Accumulator); err != nil {
return fmt.Errorf("failed to unmarshal accumulator: %w", err)
}
witnessObj := new(accumulator.MembershipWitness)
if err := witnessObj.UnmarshalBinary(witness); err != nil {
return fmt.Errorf("failed to unmarshal witness: %w", err)
}
return witnessObj.Verify(publicKey, accObj)
}
// UpdateAccumulator updates the accumulator in a Proof with new values
func UpdateAccumulator(proof *Proof, addValues []string, removeValues []string) error {
secretKey := new(accumulator.SecretKey)
if err := secretKey.UnmarshalBinary(proof.Accumulator); err != nil {
return err
}
accObj := new(accumulator.Accumulator)
if err := accObj.UnmarshalBinary(proof.Accumulator); err != nil {
return fmt.Errorf("failed to unmarshal accumulator: %w", err)
}
updatedAcc, _, err := accObj.Update(secretKey, ConvertValuesToZeroKnowledgeElements(addValues), ConvertValuesToZeroKnowledgeElements(removeValues))
if err != nil {
return err
}
updatedAccBytes, err := updatedAcc.MarshalBinary()
if err != nil {
return fmt.Errorf("failed to marshal updated accumulator: %w", err)
}
proof.Accumulator = updatedAccBytes
return nil
}
// ConvertValuesToZeroKnowledgeElements converts a slice of strings to a slice of accumulator elements
func ConvertValuesToZeroKnowledgeElements(values []string) []Element {
curve := curves.BLS12381(&curves.PointBls12381G1{})
elements := make([]accumulator.Element, len(values))
for i, value := range values {
elements[i] = curve.Scalar.Hash([]byte(value))
}
return elements
}