Skip to content

Commit

Permalink
Merge branch 'master' into aleem/520-metadata-length
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanchristo committed Sep 16, 2021
2 parents 8554f3a + cbc060a commit d0bcc11
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 57 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/tendermint/tendermint v0.34.12
github.com/tendermint/tm-db v0.6.4
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83 // indirect
google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af // indirect
)

replace google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1207,8 +1207,8 @@ google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83 h1:3V2dxSZpz4zozWWUq36vUxXEKnSYitEH2LdsAx+RUmg=
google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af h1:aLMMXFYqw01RA6XJim5uaN+afqNNjc9P8HPAbnpnc5s=
google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
Expand Down
7 changes: 5 additions & 2 deletions proto/regen/ecocredit/v1alpha1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ message EventReceive {
// batch_denom is the unique ID of credit batch.
string batch_denom = 3;

// amount is the decimal number of both tradable and retired credits received.
string amount = 4;
// tradable_amount is the decimal number of tradable credits received.
string tradable_amount = 4;

// retired_amount is the decimal number of retired credits received.
string retired_amount = 5;
}

// EventRetire is an event emitted when credits are retired. When credits are
Expand Down
131 changes: 92 additions & 39 deletions x/ecocredit/events.pb.go

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

21 changes: 9 additions & 12 deletions x/ecocredit/server/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,11 @@ func (s serverImpl) CreateBatch(goCtx context.Context, req *ecocredit.MsgCreateB
}
}

sum, err := tradable.Add(retired)
if err != nil {
return nil, err
}

err = ctx.EventManager().EmitTypedEvent(&ecocredit.EventReceive{
Recipient: recipient,
BatchDenom: string(batchDenom),
Amount: sum.String(),
Recipient: recipient,
BatchDenom: string(batchDenom),
RetiredAmount: tradable.String(),
TradableAmount: retired.String(),
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -306,10 +302,11 @@ func (s serverImpl) Send(goCtx context.Context, req *ecocredit.MsgSend) (*ecocre
}

err = ctx.EventManager().EmitTypedEvent(&ecocredit.EventReceive{
Sender: sender,
Recipient: recipient,
BatchDenom: string(denom),
Amount: sum.String(),
Sender: sender,
Recipient: recipient,
BatchDenom: string(denom),
TradableAmount: tradable.String(),
RetiredAmount: retired.String(),
})
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion x/ecocredit/spec/protobuf.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ transferred will result in a separate EventReceive for easy indexing.
| sender | [string](#string) | | sender is the sender of the credits in the case that this event is the result of a transfer. It will not be set when credits are received at initial issuance. |
| recipient | [string](#string) | | recipient is the recipient of the credits |
| batch_denom | [string](#string) | | batch_denom is the unique ID of credit batch. |
| amount | [string](#string) | | amount is the decimal number of both tradable and retired credits received. |
| tradable_amount | [string](#string) | | tradable_amount is the decimal number of tradable credits received. |
| retired_amount | [string](#string) | | retired_amount is the decimal number of retired credits received. |



Expand Down

0 comments on commit d0bcc11

Please sign in to comment.