Skip to content

Commit

Permalink
[OTE-790]Implement affiliates whitelist logic (#2258)
Browse files Browse the repository at this point in the history
  • Loading branch information
affanv14 authored Sep 19, 2024
1 parent 25dbec5 commit 728d53a
Show file tree
Hide file tree
Showing 38 changed files with 1,321 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { MsgRegisterAffiliate, MsgRegisterAffiliateResponse, MsgUpdateAffiliateTiers, MsgUpdateAffiliateTiersResponse } from "./tx";
import { MsgRegisterAffiliate, MsgRegisterAffiliateResponse, MsgUpdateAffiliateTiers, MsgUpdateAffiliateTiersResponse, MsgUpdateAffiliateWhitelist, MsgUpdateAffiliateWhitelistResponse } from "./tx";
/** Msg defines the Msg service. */

export interface Msg {
Expand All @@ -9,6 +9,9 @@ export interface Msg {
/** UpdateAffiliateTiers updates affiliate tiers */

updateAffiliateTiers(request: MsgUpdateAffiliateTiers): Promise<MsgUpdateAffiliateTiersResponse>;
/** UpdateAffiliateWhitelist updates affiliate whitelist */

updateAffiliateWhitelist(request: MsgUpdateAffiliateWhitelist): Promise<MsgUpdateAffiliateWhitelistResponse>;
}
export class MsgClientImpl implements Msg {
private readonly rpc: Rpc;
Expand All @@ -17,6 +20,7 @@ export class MsgClientImpl implements Msg {
this.rpc = rpc;
this.registerAffiliate = this.registerAffiliate.bind(this);
this.updateAffiliateTiers = this.updateAffiliateTiers.bind(this);
this.updateAffiliateWhitelist = this.updateAffiliateWhitelist.bind(this);
}

registerAffiliate(request: MsgRegisterAffiliate): Promise<MsgRegisterAffiliateResponse> {
Expand All @@ -31,4 +35,10 @@ export class MsgClientImpl implements Msg {
return promise.then(data => MsgUpdateAffiliateTiersResponse.decode(new _m0.Reader(data)));
}

updateAffiliateWhitelist(request: MsgUpdateAffiliateWhitelist): Promise<MsgUpdateAffiliateWhitelistResponse> {
const data = MsgUpdateAffiliateWhitelist.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.affiliates.Msg", "UpdateAffiliateWhitelist", data);
return promise.then(data => MsgUpdateAffiliateWhitelistResponse.decode(new _m0.Reader(data)));
}

}
115 changes: 114 additions & 1 deletion indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/tx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AffiliateTiers, AffiliateTiersSDKType } from "./affiliates";
import { AffiliateTiers, AffiliateTiersSDKType, AffiliateWhitelist, AffiliateWhitelistSDKType } from "./affiliates";
import * as _m0 from "protobufjs/minimal";
import { DeepPartial } from "../../helpers";
/** Message to register a referee-affiliate relationship */
Expand Down Expand Up @@ -49,6 +49,30 @@ export interface MsgUpdateAffiliateTiersResponse {}
/** Response to MsgUpdateAffiliateTiers */

export interface MsgUpdateAffiliateTiersResponseSDKType {}
/** Message to update affiliate whitelist */

export interface MsgUpdateAffiliateWhitelist {
/** Authority sending this message. Will be sent by gov */
authority: string;
/** Updated affiliate whitelist information */

whitelist?: AffiliateWhitelist;
}
/** Message to update affiliate whitelist */

export interface MsgUpdateAffiliateWhitelistSDKType {
/** Authority sending this message. Will be sent by gov */
authority: string;
/** Updated affiliate whitelist information */

whitelist?: AffiliateWhitelistSDKType;
}
/** Response to MsgUpdateAffiliateWhitelist */

export interface MsgUpdateAffiliateWhitelistResponse {}
/** Response to MsgUpdateAffiliateWhitelist */

export interface MsgUpdateAffiliateWhitelistResponseSDKType {}

function createBaseMsgRegisterAffiliate(): MsgRegisterAffiliate {
return {
Expand Down Expand Up @@ -226,4 +250,93 @@ export const MsgUpdateAffiliateTiersResponse = {
return message;
}

};

function createBaseMsgUpdateAffiliateWhitelist(): MsgUpdateAffiliateWhitelist {
return {
authority: "",
whitelist: undefined
};
}

export const MsgUpdateAffiliateWhitelist = {
encode(message: MsgUpdateAffiliateWhitelist, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.authority !== "") {
writer.uint32(10).string(message.authority);
}

if (message.whitelist !== undefined) {
AffiliateWhitelist.encode(message.whitelist, writer.uint32(18).fork()).ldelim();
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateAffiliateWhitelist {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgUpdateAffiliateWhitelist();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.authority = reader.string();
break;

case 2:
message.whitelist = AffiliateWhitelist.decode(reader, reader.uint32());
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<MsgUpdateAffiliateWhitelist>): MsgUpdateAffiliateWhitelist {
const message = createBaseMsgUpdateAffiliateWhitelist();
message.authority = object.authority ?? "";
message.whitelist = object.whitelist !== undefined && object.whitelist !== null ? AffiliateWhitelist.fromPartial(object.whitelist) : undefined;
return message;
}

};

function createBaseMsgUpdateAffiliateWhitelistResponse(): MsgUpdateAffiliateWhitelistResponse {
return {};
}

export const MsgUpdateAffiliateWhitelistResponse = {
encode(_: MsgUpdateAffiliateWhitelistResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateAffiliateWhitelistResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgUpdateAffiliateWhitelistResponse();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(_: DeepPartial<MsgUpdateAffiliateWhitelistResponse>): MsgUpdateAffiliateWhitelistResponse {
const message = createBaseMsgUpdateAffiliateWhitelistResponse();
return message;
}

};
17 changes: 16 additions & 1 deletion proto/dydxprotocol/affiliates/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ service Msg {
// UpdateAffiliateTiers updates affiliate tiers
rpc UpdateAffiliateTiers(MsgUpdateAffiliateTiers)
returns (MsgUpdateAffiliateTiersResponse);
// UpdateAffiliateWhitelist updates affiliate whitelist
rpc UpdateAffiliateWhitelist(MsgUpdateAffiliateWhitelist)
returns (MsgUpdateAffiliateWhitelistResponse);
}

// Message to register a referee-affiliate relationship
Expand Down Expand Up @@ -43,4 +46,16 @@ message MsgUpdateAffiliateTiers {
}

// Response to MsgUpdateAffiliateTiers
message MsgUpdateAffiliateTiersResponse {}
message MsgUpdateAffiliateTiersResponse {}

// Message to update affiliate whitelist
message MsgUpdateAffiliateWhitelist {
option (cosmos.msg.v1.signer) = "authority";
// Authority sending this message. Will be sent by gov
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
// Updated affiliate whitelist information
AffiliateWhitelist whitelist = 2 [ (gogoproto.nullable) = false ];
}

// Response to MsgUpdateAffiliateWhitelist
message MsgUpdateAffiliateWhitelistResponse {}
1 change: 1 addition & 0 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ func New(
app.PricesKeeper,
app.StatsKeeper,
app.RewardsKeeper,
app.AffiliatesKeeper,
app.IndexerEventManager,
app.FullNodeStreamingManager,
txConfig.TxDecoder(),
Expand Down
11 changes: 6 additions & 5 deletions protocol/app/msgs/all_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ var (
"/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal": {},

// affiliates
"/dydxprotocol.affiliates.MsgRegisterAffiliate": {},
"/dydxprotocol.affiliates.MsgRegisterAffiliateResponse": {},
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiers": {},
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiersResponse": {},

"/dydxprotocol.affiliates.MsgRegisterAffiliate": {},
"/dydxprotocol.affiliates.MsgRegisterAffiliateResponse": {},
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiers": {},
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiersResponse": {},
"/dydxprotocol.affiliates.MsgUpdateAffiliateWhitelist": {},
"/dydxprotocol.affiliates.MsgUpdateAffiliateWhitelistResponse": {},
// blocktime
"/dydxprotocol.blocktime.MsgUpdateDowntimeParams": {},
"/dydxprotocol.blocktime.MsgUpdateDowntimeParamsResponse": {},
Expand Down
6 changes: 4 additions & 2 deletions protocol/app/msgs/internal_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ var (
InternalMsgSamplesDydxCustom = map[string]sdk.Msg{

// affiliates
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiers": &affiliates.MsgUpdateAffiliateTiers{},
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiersResponse": nil,
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiers": &affiliates.MsgUpdateAffiliateTiers{},
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiersResponse": nil,
"/dydxprotocol.affiliates.MsgUpdateAffiliateWhitelist": &affiliates.MsgUpdateAffiliateWhitelist{},
"/dydxprotocol.affiliates.MsgUpdateAffiliateWhitelistResponse": nil,

// blocktime
"/dydxprotocol.blocktime.MsgUpdateDowntimeParams": &blocktime.MsgUpdateDowntimeParams{},
Expand Down
2 changes: 2 additions & 0 deletions protocol/app/msgs/internal_msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func TestInternalMsgSamples_Gov_Key(t *testing.T) {
// affiliates
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiers",
"/dydxprotocol.affiliates.MsgUpdateAffiliateTiersResponse",
"/dydxprotocol.affiliates.MsgUpdateAffiliateWhitelist",
"/dydxprotocol.affiliates.MsgUpdateAffiliateWhitelistResponse",

// blocktime
"/dydxprotocol.blocktime.MsgUpdateDowntimeParams",
Expand Down
3 changes: 2 additions & 1 deletion protocol/lib/ante/internal_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ func IsInternalMsg(msg sdk.Msg) bool {
*ibcconn.MsgUpdateParams,

// affiliates
*affiliates.MsgUpdateAffiliateTiers:
*affiliates.MsgUpdateAffiliateTiers,
*affiliates.MsgUpdateAffiliateWhitelist:

return true

Expand Down
30 changes: 15 additions & 15 deletions protocol/mocks/ClobKeeper.go

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

30 changes: 15 additions & 15 deletions protocol/mocks/MemClobKeeper.go

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

Loading

0 comments on commit 728d53a

Please sign in to comment.