Skip to content

Commit

Permalink
feat: finish implementing blocklist
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey committed Apr 26, 2024
1 parent f4529fb commit 619b260
Show file tree
Hide file tree
Showing 16 changed files with 8,548 additions and 45 deletions.
1,716 changes: 1,716 additions & 0 deletions api/ondo/usdy/blocklist/v1/events.pulsar.go

Large diffs are not rendered by default.

3,960 changes: 3,936 additions & 24 deletions api/ondo/usdy/blocklist/v1/tx.pulsar.go

Large diffs are not rendered by default.

161 changes: 157 additions & 4 deletions api/ondo/usdy/blocklist/v1/tx_grpc.pb.go

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

25 changes: 25 additions & 0 deletions proto/ondo/usdy/blocklist/v1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

package ondo.usdy.blocklist.v1;

option go_package = "github.com/noble-assets/ondo/x/usdy/types/blocklist";

// OwnershipTransferStarted is emitted whenever an ownership transfer is started.
message OwnershipTransferStarted {
// old_owner is the address of the old owner account.
string old_owner = 1;
// new_owner is the address of the new owner account.
string new_owner = 2;
}

// BlockedAddressesAdded is emitted whenever addresses are added to the blocklist.
message BlockedAddressesAdded {
// accounts is the list of addresses that were added to the blocklist.
repeated string accounts = 1;
}

// BlockedAddressesRemoved is emitted whenever addresses are removed from the blocklist.
message BlockedAddressesRemoved {
// accounts is the list of addresses that were removed from the blocklist.
repeated string accounts = 1;
}
70 changes: 70 additions & 0 deletions proto/ondo/usdy/blocklist/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,80 @@ syntax = "proto3";

package ondo.usdy.blocklist.v1;

import "amino/amino.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/noble-assets/ondo/x/usdy/types/blocklist";

service Msg {
option (cosmos.msg.v1.service) = true;

rpc TransferOwnership(MsgTransferOwnership) returns (MsgTransferOwnershipResponse);
rpc AcceptOwnership(MsgAcceptOwnership) returns (MsgAcceptOwnershipResponse);

rpc AddToBlocklist(MsgAddToBlocklist) returns (MsgAddToBlocklistResponse);
rpc RemoveFromBlocklist(MsgRemoveFromBlocklist) returns (MsgRemoveFromBlocklistResponse);
}

//

// MsgTransferOwnership implements the transferOwnership (0xf2fde38b) method.
message MsgTransferOwnership {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "ondo/usdy/blocklist/TransferOwnership";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string new_owner = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgTransferOwnershipResponse is the response of the TransferOwnership action.
message MsgTransferOwnershipResponse {}

// MsgAcceptOwnership implements the acceptOwnership (0x79ba5097) method.
message MsgAcceptOwnership {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "ondo/usdy/blocklist/AcceptOwnership";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgAcceptOwnershipResponse is the response of the AcceptOwnership action.
message MsgAcceptOwnershipResponse {}

// MsgAddToBlocklist implements the addToBlocklist (0xf71a55f8) method.
message MsgAddToBlocklist {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "ondo/usdy/blocklist/AddToBlocklist";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated string accounts = 2;
}

// MsgAddToBlocklistResponse is the response of the AddToBlocklist action.
message MsgAddToBlocklistResponse {}

// MsgRemoveFromBlocklist implements the removeFromBlocklist (0xab63e69c) method.
message MsgRemoveFromBlocklist {
option (cosmos.msg.v1.signer) = "signer";
option (amino.name) = "ondo/usdy/blocklist/RemoveFromBlocklist";

option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated string accounts = 2;
}

// MsgRemoveFromBlocklistResponse is the response of the RemoveFromBlocklist action.
message MsgRemoveFromBlocklistResponse {}
15 changes: 15 additions & 0 deletions utils/mocks/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package mocks

import (
"cosmossdk.io/core/address"
"github.com/cosmos/cosmos-sdk/x/auth/codec"
"github.com/noble-assets/ondo/x/usdy/types"
)

var _ types.AccountKeeper = AccountKeeper{}

type AccountKeeper struct{}

func (AccountKeeper) AddressCodec() address.Codec {
return codec.NewBech32Codec("noble")
}
1 change: 1 addition & 0 deletions utils/mocks/usdy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ func USDYKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
runtime.NewKVStoreService(key),
runtime.ProvideEventService(),
"ausdy",
AccountKeeper{},
), wrapper.Ctx
}
6 changes: 5 additions & 1 deletion x/usdy/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type Keeper struct {
Owner collections.Item[string]
PendingOwner collections.Item[string]
BlockedAddresses collections.Map[[]byte, bool]

accountKeeper types.AccountKeeper
}

func NewKeeper(
Expand All @@ -38,6 +40,7 @@ func NewKeeper(
storeService store.KVStoreService,
eventService event.Service,
denom string,
accountKeeper types.AccountKeeper,
) *Keeper {
builder := collections.NewSchemaBuilder(storeService)

Expand All @@ -47,7 +50,8 @@ func NewKeeper(
storeService: storeService,
eventService: eventService,

Denom: denom,
Denom: denom,
accountKeeper: accountKeeper,

Paused: collections.NewItem(builder, types.PausedKey, "paused", collections.BoolValue),
Pauser: collections.NewItem(builder, types.PauserKey, "pauser", collections.StringValue),
Expand Down
Loading

0 comments on commit 619b260

Please sign in to comment.