Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OTE-791] Add proto for affiliate whitelist #2232

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,44 @@ export interface AffiliateTiers_TierSDKType {

taker_fee_share_ppm: number;
}
/**
* AffiliateWhitelist specifies the whitelisted affiliates.
* If an address is in the whitelist, then the affiliate fee share in
* this object will override fee share from the regular affiliate tiers above.
*/

export interface AffiliateWhitelist {
/** All affiliate whitelist tiers. */
tiers: AffiliateWhitelist_Tier[];
}
/**
* AffiliateWhitelist specifies the whitelisted affiliates.
* If an address is in the whitelist, then the affiliate fee share in
* this object will override fee share from the regular affiliate tiers above.
*/

export interface AffiliateWhitelistSDKType {
/** All affiliate whitelist tiers. */
tiers: AffiliateWhitelist_TierSDKType[];
}
/** Tier defines an affiliate whitelist tier. */

export interface AffiliateWhitelist_Tier {
/** List of unique whitelisted addresses. */
addresses: string[];
/** Taker fee share in parts-per-million. */

takerFeeSharePpm: number;
}
/** Tier defines an affiliate whitelist tier. */

export interface AffiliateWhitelist_TierSDKType {
/** List of unique whitelisted addresses. */
addresses: string[];
/** Taker fee share in parts-per-million. */

taker_fee_share_ppm: number;
}

function createBaseAffiliateTiers(): AffiliateTiers {
return {
Expand Down Expand Up @@ -145,4 +183,104 @@ export const AffiliateTiers_Tier = {
return message;
}

};

function createBaseAffiliateWhitelist(): AffiliateWhitelist {
return {
tiers: []
};
}

export const AffiliateWhitelist = {
encode(message: AffiliateWhitelist, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.tiers) {
AffiliateWhitelist_Tier.encode(v!, writer.uint32(10).fork()).ldelim();
}

return writer;
},

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

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

switch (tag >>> 3) {
case 1:
message.tiers.push(AffiliateWhitelist_Tier.decode(reader, reader.uint32()));
break;

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

return message;
},

fromPartial(object: DeepPartial<AffiliateWhitelist>): AffiliateWhitelist {
const message = createBaseAffiliateWhitelist();
message.tiers = object.tiers?.map(e => AffiliateWhitelist_Tier.fromPartial(e)) || [];
return message;
}

};

function createBaseAffiliateWhitelist_Tier(): AffiliateWhitelist_Tier {
return {
addresses: [],
takerFeeSharePpm: 0
};
}

export const AffiliateWhitelist_Tier = {
encode(message: AffiliateWhitelist_Tier, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.addresses) {
writer.uint32(10).string(v!);
}

if (message.takerFeeSharePpm !== 0) {
writer.uint32(16).uint32(message.takerFeeSharePpm);
}

return writer;
},

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

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

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

case 2:
message.takerFeeSharePpm = reader.uint32();
break;

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

return message;
},

fromPartial(object: DeepPartial<AffiliateWhitelist_Tier>): AffiliateWhitelist_Tier {
const message = createBaseAffiliateWhitelist_Tier();
message.addresses = object.addresses?.map(e => e) || [];
message.takerFeeSharePpm = object.takerFeeSharePpm ?? 0;
return message;
}

};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate";
import { AffiliateInfoRequest, AffiliateInfoResponse, ReferredByRequest, ReferredByResponse, AllAffiliateTiersRequest, AllAffiliateTiersResponse } from "./query";
import { AffiliateInfoRequest, AffiliateInfoResponse, ReferredByRequest, ReferredByResponse, AllAffiliateTiersRequest, AllAffiliateTiersResponse, AffiliateWhitelistRequest, AffiliateWhitelistResponse } from "./query";
/** Query defines the gRPC querier service. */

export interface Query {
Expand All @@ -13,6 +13,9 @@ export interface Query {
/** Query AllAffiliateTiers returns all affiliate tiers. */

allAffiliateTiers(request?: AllAffiliateTiersRequest): Promise<AllAffiliateTiersResponse>;
/** Query AffiliateWhitelist returns the affiliate whitelist. */

affiliateWhitelist(request?: AffiliateWhitelistRequest): Promise<AffiliateWhitelistResponse>;
}
export class QueryClientImpl implements Query {
private readonly rpc: Rpc;
Expand All @@ -22,6 +25,7 @@ export class QueryClientImpl implements Query {
this.affiliateInfo = this.affiliateInfo.bind(this);
this.referredBy = this.referredBy.bind(this);
this.allAffiliateTiers = this.allAffiliateTiers.bind(this);
this.affiliateWhitelist = this.affiliateWhitelist.bind(this);
}

affiliateInfo(request: AffiliateInfoRequest): Promise<AffiliateInfoResponse> {
Expand All @@ -42,6 +46,12 @@ export class QueryClientImpl implements Query {
return promise.then(data => AllAffiliateTiersResponse.decode(new _m0.Reader(data)));
}

affiliateWhitelist(request: AffiliateWhitelistRequest = {}): Promise<AffiliateWhitelistResponse> {
const data = AffiliateWhitelistRequest.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.affiliates.Query", "AffiliateWhitelist", data);
return promise.then(data => AffiliateWhitelistResponse.decode(new _m0.Reader(data)));
}

}
export const createRpcQueryExtension = (base: QueryClient) => {
const rpc = createProtobufRpcClient(base);
Expand All @@ -57,6 +67,10 @@ export const createRpcQueryExtension = (base: QueryClient) => {

allAffiliateTiers(request?: AllAffiliateTiersRequest): Promise<AllAffiliateTiersResponse> {
return queryService.allAffiliateTiers(request);
},

affiliateWhitelist(request?: AffiliateWhitelistRequest): Promise<AffiliateWhitelistResponse> {
return queryService.affiliateWhitelist(request);
}

};
Expand Down
Loading
Loading