Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into aleem/ecocredit-genesis-migration
  • Loading branch information
aleem1314 committed Apr 13, 2022
2 parents c3e3d17 + 470f881 commit a583f4e
Show file tree
Hide file tree
Showing 24 changed files with 4,208 additions and 1,371 deletions.
2,506 changes: 2,284 additions & 222 deletions api/regen/ecocredit/v1/tx.pulsar.go

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions api/regen/ecocredit/v1/tx_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 42 additions & 1 deletion proto/regen/ecocredit/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ service Msg {
// UpdateClassMetadata updates the credit class metadata
rpc UpdateClassMetadata(MsgUpdateClassMetadata)
returns (MsgUpdateClassMetadataResponse);

// UpdateProjectAdmin updates the project admin address
rpc UpdateProjectAdmin(MsgUpdateProjectAdmin)
returns (MsgUpdateProjectAdminResponse);

// UpdateProjectMetadata updates the project metadata
rpc UpdateProjectMetadata(MsgUpdateProjectMetadata)
returns (MsgUpdateProjectMetadataResponse);
}

// MsgCreateClass is the Msg/CreateClass request type.
Expand Down Expand Up @@ -380,5 +388,38 @@ message MsgUpdateClassMetadata {
string metadata = 3;
}

// MsgUpdateClassMetadataResponse is the MsgUpdateClassMetadata response type.
// MsgUpdateClassMetadataResponse is the Msg/UpdateClassMetadata response type.
message MsgUpdateClassMetadataResponse {}

// MsgUpdateProjectAdmin is the Msg/UpdateProjectAdmin request type.
message MsgUpdateProjectAdmin {

// admin is the project's current admin address.
string admin = 1;

// new_admin is the address of the new admin of the project.
string new_admin = 2;

// project_id is the id of the project. (e.g. VERRA)
string project_id = 3;
}

// MsgUpdateProjectAdmin is the Msg/UpdateProjectAdmin response type.
message MsgUpdateProjectAdminResponse {}

// MsgUpdateProjectMetadata is the Msg/UpdateProjectMetadata request type.
message MsgUpdateProjectMetadata {

// admin is project admin address.
string admin = 1;

// new_metadata is the metadata to update the project with.
string new_metadata = 2;

// project_id is the id of the project. (e.g. VERRA)
string project_id = 3;
}

// MsgUpdateProjectMetadataResponse is the Msg/UpdateProjectMetadataResponse
// response type.
message MsgUpdateProjectMetadataResponse {}
13 changes: 13 additions & 0 deletions types/timestamp.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package types

import (
"fmt"
"time"

gogotypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
Expand Down Expand Up @@ -38,3 +42,12 @@ func GogoToProtobufDuration(d *gogotypes.Duration) *durationpb.Duration {
Nanos: d.Nanos,
}
}

// ParseDate parses a date using the format yyyy-mm-dd.
func ParseDate(field string, date string) (time.Time, error) {
t, err := time.Parse("2006-01-02", date)
if err != nil {
return t, errors.New(fmt.Sprintf("%s must have format yyyy-mm-dd, but received %v", field, date))
}
return t, nil
}
29 changes: 28 additions & 1 deletion types/timestamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package types_test
import (
"reflect"
"testing"
"time"

gogotypes "github.com/gogo/protobuf/types"
"github.com/regen-network/regen-ledger/types"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/regen-network/regen-ledger/types"
)

func TestGogoToProtobufDuration(t *testing.T) {
Expand Down Expand Up @@ -96,3 +99,27 @@ func TestProtobufToGogoTimestamp(t *testing.T) {
})
}
}

func TestParseDate(t *testing.T) {
tcs := []struct {
name string
date string
hasErr bool
}{
{"good", "2022-01-20", false},
{"bad", "01-2021-20", true},
}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
require := require.New(t)
tm, err := types.ParseDate(tc.date, tc.date)
if tc.hasErr {
require.Error(err)
require.Equal(time.Time{}, tm)
} else {
require.NoError(err)
require.NotNil(tm)
}
})
}
}
8 changes: 5 additions & 3 deletions x/ecocredit/basket/msg_put_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package basket

import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/regen-network/regen-ledger/x/ecocredit"
"github.com/stretchr/testify/require"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/stretchr/testify/require"

"github.com/regen-network/regen-ledger/x/ecocredit"
)

func TestMsgPut_ValidateBasic(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions x/ecocredit/basket/msg_take.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"

"github.com/regen-network/regen-ledger/x/ecocredit"
)

Expand Down
Loading

0 comments on commit a583f4e

Please sign in to comment.