-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OTE-689] add protos for affiliates (#2112)
- Loading branch information
Showing
33 changed files
with
4,801 additions
and
467 deletions.
There are no files selected for viewing
164 changes: 164 additions & 0 deletions
164
indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/affiliates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
import * as _m0 from "protobufjs/minimal"; | ||
import { DeepPartial, Long } from "../../helpers"; | ||
/** AffiliateTiers defines the affiliate tiers. */ | ||
|
||
export interface AffiliateTiers { | ||
/** All affiliate tiers */ | ||
tiers: AffiliateTiers_Tier[]; | ||
} | ||
/** AffiliateTiers defines the affiliate tiers. */ | ||
|
||
export interface AffiliateTiersSDKType { | ||
/** All affiliate tiers */ | ||
tiers: AffiliateTiers_TierSDKType[]; | ||
} | ||
/** Tier defines an affiliate tier. */ | ||
|
||
export interface AffiliateTiers_Tier { | ||
/** Level of the tier */ | ||
level: number; | ||
/** Required all-time referred volume in quote quantums. */ | ||
|
||
reqReferredVolume: Long; | ||
/** Required currently staked native tokens (in whole coins). */ | ||
|
||
reqStakedWholeCoins: number; | ||
/** Taker fee share in parts-per-million. */ | ||
|
||
takerFeeSharePpm: number; | ||
} | ||
/** Tier defines an affiliate tier. */ | ||
|
||
export interface AffiliateTiers_TierSDKType { | ||
/** Level of the tier */ | ||
level: number; | ||
/** Required all-time referred volume in quote quantums. */ | ||
|
||
req_referred_volume: Long; | ||
/** Required currently staked native tokens (in whole coins). */ | ||
|
||
req_staked_whole_coins: number; | ||
/** Taker fee share in parts-per-million. */ | ||
|
||
taker_fee_share_ppm: number; | ||
} | ||
|
||
function createBaseAffiliateTiers(): AffiliateTiers { | ||
return { | ||
tiers: [] | ||
}; | ||
} | ||
|
||
export const AffiliateTiers = { | ||
encode(message: AffiliateTiers, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
for (const v of message.tiers) { | ||
AffiliateTiers_Tier.encode(v!, writer.uint32(10).fork()).ldelim(); | ||
} | ||
|
||
return writer; | ||
}, | ||
|
||
decode(input: _m0.Reader | Uint8Array, length?: number): AffiliateTiers { | ||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
let end = length === undefined ? reader.len : reader.pos + length; | ||
const message = createBaseAffiliateTiers(); | ||
|
||
while (reader.pos < end) { | ||
const tag = reader.uint32(); | ||
|
||
switch (tag >>> 3) { | ||
case 1: | ||
message.tiers.push(AffiliateTiers_Tier.decode(reader, reader.uint32())); | ||
break; | ||
|
||
default: | ||
reader.skipType(tag & 7); | ||
break; | ||
} | ||
} | ||
|
||
return message; | ||
}, | ||
|
||
fromPartial(object: DeepPartial<AffiliateTiers>): AffiliateTiers { | ||
const message = createBaseAffiliateTiers(); | ||
message.tiers = object.tiers?.map(e => AffiliateTiers_Tier.fromPartial(e)) || []; | ||
return message; | ||
} | ||
|
||
}; | ||
|
||
function createBaseAffiliateTiers_Tier(): AffiliateTiers_Tier { | ||
return { | ||
level: 0, | ||
reqReferredVolume: Long.UZERO, | ||
reqStakedWholeCoins: 0, | ||
takerFeeSharePpm: 0 | ||
}; | ||
} | ||
|
||
export const AffiliateTiers_Tier = { | ||
encode(message: AffiliateTiers_Tier, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
if (message.level !== 0) { | ||
writer.uint32(8).uint32(message.level); | ||
} | ||
|
||
if (!message.reqReferredVolume.isZero()) { | ||
writer.uint32(16).uint64(message.reqReferredVolume); | ||
} | ||
|
||
if (message.reqStakedWholeCoins !== 0) { | ||
writer.uint32(24).uint32(message.reqStakedWholeCoins); | ||
} | ||
|
||
if (message.takerFeeSharePpm !== 0) { | ||
writer.uint32(32).uint32(message.takerFeeSharePpm); | ||
} | ||
|
||
return writer; | ||
}, | ||
|
||
decode(input: _m0.Reader | Uint8Array, length?: number): AffiliateTiers_Tier { | ||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
let end = length === undefined ? reader.len : reader.pos + length; | ||
const message = createBaseAffiliateTiers_Tier(); | ||
|
||
while (reader.pos < end) { | ||
const tag = reader.uint32(); | ||
|
||
switch (tag >>> 3) { | ||
case 1: | ||
message.level = reader.uint32(); | ||
break; | ||
|
||
case 2: | ||
message.reqReferredVolume = (reader.uint64() as Long); | ||
break; | ||
|
||
case 3: | ||
message.reqStakedWholeCoins = reader.uint32(); | ||
break; | ||
|
||
case 4: | ||
message.takerFeeSharePpm = reader.uint32(); | ||
break; | ||
|
||
default: | ||
reader.skipType(tag & 7); | ||
break; | ||
} | ||
} | ||
|
||
return message; | ||
}, | ||
|
||
fromPartial(object: DeepPartial<AffiliateTiers_Tier>): AffiliateTiers_Tier { | ||
const message = createBaseAffiliateTiers_Tier(); | ||
message.level = object.level ?? 0; | ||
message.reqReferredVolume = object.reqReferredVolume !== undefined && object.reqReferredVolume !== null ? Long.fromValue(object.reqReferredVolume) : Long.UZERO; | ||
message.reqStakedWholeCoins = object.reqStakedWholeCoins ?? 0; | ||
message.takerFeeSharePpm = object.takerFeeSharePpm ?? 0; | ||
return message; | ||
} | ||
|
||
}; |
49 changes: 47 additions & 2 deletions
49
indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/query.rpc.Query.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,63 @@ | ||
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"; | ||
/** Query defines the gRPC querier service. */ | ||
|
||
export interface Query {} | ||
export interface Query { | ||
/** Query AffiliateInfo returns the affiliate info for a given address. */ | ||
affiliateInfo(request: AffiliateInfoRequest): Promise<AffiliateInfoResponse>; | ||
/** Query ReferredBy returns the affiliate that referred a given address. */ | ||
|
||
referredBy(request: ReferredByRequest): Promise<ReferredByResponse>; | ||
/** Query AllAffiliateTiers returns all affiliate tiers. */ | ||
|
||
allAffiliateTiers(request?: AllAffiliateTiersRequest): Promise<AllAffiliateTiersResponse>; | ||
} | ||
export class QueryClientImpl implements Query { | ||
private readonly rpc: Rpc; | ||
|
||
constructor(rpc: Rpc) { | ||
this.rpc = rpc; | ||
this.affiliateInfo = this.affiliateInfo.bind(this); | ||
this.referredBy = this.referredBy.bind(this); | ||
this.allAffiliateTiers = this.allAffiliateTiers.bind(this); | ||
} | ||
|
||
affiliateInfo(request: AffiliateInfoRequest): Promise<AffiliateInfoResponse> { | ||
const data = AffiliateInfoRequest.encode(request).finish(); | ||
const promise = this.rpc.request("dydxprotocol.affiliates.Query", "AffiliateInfo", data); | ||
return promise.then(data => AffiliateInfoResponse.decode(new _m0.Reader(data))); | ||
} | ||
|
||
referredBy(request: ReferredByRequest): Promise<ReferredByResponse> { | ||
const data = ReferredByRequest.encode(request).finish(); | ||
const promise = this.rpc.request("dydxprotocol.affiliates.Query", "ReferredBy", data); | ||
return promise.then(data => ReferredByResponse.decode(new _m0.Reader(data))); | ||
} | ||
|
||
allAffiliateTiers(request: AllAffiliateTiersRequest = {}): Promise<AllAffiliateTiersResponse> { | ||
const data = AllAffiliateTiersRequest.encode(request).finish(); | ||
const promise = this.rpc.request("dydxprotocol.affiliates.Query", "AllAffiliateTiers", data); | ||
return promise.then(data => AllAffiliateTiersResponse.decode(new _m0.Reader(data))); | ||
} | ||
|
||
} | ||
export const createRpcQueryExtension = (base: QueryClient) => { | ||
const rpc = createProtobufRpcClient(base); | ||
const queryService = new QueryClientImpl(rpc); | ||
return {}; | ||
return { | ||
affiliateInfo(request: AffiliateInfoRequest): Promise<AffiliateInfoResponse> { | ||
return queryService.affiliateInfo(request); | ||
}, | ||
|
||
referredBy(request: ReferredByRequest): Promise<ReferredByResponse> { | ||
return queryService.referredBy(request); | ||
}, | ||
|
||
allAffiliateTiers(request?: AllAffiliateTiersRequest): Promise<AllAffiliateTiersResponse> { | ||
return queryService.allAffiliateTiers(request); | ||
} | ||
|
||
}; | ||
}; |
Oops, something went wrong.