From 9c3d96d1dbba7e5b395d1f743822514645de2864 Mon Sep 17 00:00:00 2001 From: jerryfan01234 <44346807+jerryfan01234@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:28:44 -0400 Subject: [PATCH 01/12] [OTE-760] implement comlink affiliate metadata endpoint (#2243) --- .../api/v4/affiliates-controller.test.ts | 127 +++++++++++++++++- indexer/services/comlink/src/config.ts | 3 + .../api/v4/affiliates-controller.ts | 61 ++++++++- 3 files changed, 180 insertions(+), 11 deletions(-) diff --git a/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts b/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts index 1f86ebf54e..465865020d 100644 --- a/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts +++ b/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts @@ -1,23 +1,140 @@ +import { + dbHelpers, + testConstants, + testMocks, + SubaccountUsernamesTable, + WalletTable, + AffiliateReferredUsersTable, +} from '@dydxprotocol-indexer/postgres'; import { AffiliateSnapshotRequest, RequestMethod } from '../../../../src/types'; import request from 'supertest'; import { sendRequest } from '../../../helpers/helpers'; +import { defaultWallet, defaultWallet2 } from '@dydxprotocol-indexer/postgres/build/__tests__/helpers/constants'; describe('affiliates-controller#V4', () => { + beforeAll(async () => { + await dbHelpers.migrate(); + }); + + afterAll(async () => { + await dbHelpers.teardown(); + }); + describe('GET /metadata', () => { - it('should return referral code for a valid address string', async () => { - const address = 'some_address'; + beforeEach(async () => { + await testMocks.seedData(); + await SubaccountUsernamesTable.create(testConstants.defaultSubaccountUsername); + }); + + afterEach(async () => { + await dbHelpers.clearData(); + }); + + it('should return referral code for address with username', async () => { const response: request.Response = await sendRequest({ type: RequestMethod.GET, - path: `/v4/affiliates/metadata?address=${address}`, + path: `/v4/affiliates/metadata?address=${testConstants.defaultWallet.address}`, + expectedStatus: 200, // helper performs expect on status }); - expect(response.status).toBe(200); expect(response.body).toEqual({ - referralCode: 'TempCode123', + // username is the referral code + referralCode: testConstants.defaultSubaccountUsername.username, + isVolumeEligible: false, + isAffiliate: false, + }); + }); + + it('should fail if address does not exist', async () => { + const nonExistentAddress = 'adgsakhasgt'; + await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/metadata?address=${nonExistentAddress}`, + expectedStatus: 404, // helper performs expect on status + }); + }); + + it('should classify not volume eligible', async () => { + await WalletTable.update( + { + address: testConstants.defaultWallet.address, + totalVolume: '0', + totalTradingRewards: '0', + }, + ); + const response: request.Response = await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/metadata?address=${testConstants.defaultWallet.address}`, + expectedStatus: 200, // helper performs expect on status + }); + expect(response.body).toEqual({ + referralCode: testConstants.defaultSubaccountUsername.username, + isVolumeEligible: false, + isAffiliate: false, + }); + }); + + it('should classify volume eligible', async () => { + await WalletTable.update( + { + address: testConstants.defaultWallet.address, + totalVolume: '100000', + totalTradingRewards: '0', + }, + ); + const response: request.Response = await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/metadata?address=${testConstants.defaultWallet.address}`, + expectedStatus: 200, // helper performs expect on status + }); + expect(response.body).toEqual({ + referralCode: testConstants.defaultSubaccountUsername.username, isVolumeEligible: true, isAffiliate: false, }); }); + + it('should classify is not affiliate', async () => { + // AffiliateReferredUsersTable is empty + const response: request.Response = await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/metadata?address=${testConstants.defaultWallet.address}`, + expectedStatus: 200, // helper performs expect on status + }); + expect(response.body).toEqual({ + referralCode: testConstants.defaultSubaccountUsername.username, + isVolumeEligible: false, + isAffiliate: false, + }); + }); + + it('should classify is affiliate', async () => { + await AffiliateReferredUsersTable.create({ + affiliateAddress: defaultWallet.address, + refereeAddress: defaultWallet2.address, + referredAtBlock: '1', + }); + const response: request.Response = await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/metadata?address=${testConstants.defaultWallet.address}`, + expectedStatus: 200, // helper performs expect on status + }); + expect(response.body).toEqual({ + referralCode: testConstants.defaultSubaccountUsername.username, + isVolumeEligible: false, + isAffiliate: true, + }); + }); + + it('should fail if subaccount username not found', async () => { + // create defaultWallet2 without subaccount username + await WalletTable.create(testConstants.defaultWallet2); + await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/metadata?address=${testConstants.defaultWallet2.address}`, + expectedStatus: 500, // helper performs expect on status + }); + }); }); describe('GET /address', () => { diff --git a/indexer/services/comlink/src/config.ts b/indexer/services/comlink/src/config.ts index eb3713bc14..e2c85ade2f 100644 --- a/indexer/services/comlink/src/config.ts +++ b/indexer/services/comlink/src/config.ts @@ -60,6 +60,9 @@ export const configSchema = { // vaults table is added. EXPERIMENT_VAULTS: parseString({ default: '' }), EXPERIMENT_VAULT_MARKETS: parseString({ default: '' }), + + // Affiliates config + VOLUME_ELIGIBILITY_THRESHOLD: parseInteger({ default: 10_000 }), }; //////////////////////////////////////////////////////////////////////////////// diff --git a/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts b/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts index 9156fb339e..278b988422 100644 --- a/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts @@ -1,4 +1,10 @@ import { stats } from '@dydxprotocol-indexer/base'; +import { + WalletTable, + AffiliateReferredUsersTable, + SubaccountTable, + SubaccountUsernamesTable, +} from '@dydxprotocol-indexer/postgres'; import express from 'express'; import { checkSchema, matchedData } from 'express-validator'; import { @@ -7,6 +13,7 @@ import { import { getReqRateLimiter } from '../../../caches/rate-limiters'; import config from '../../../config'; +import { NotFoundError, UnexpectedServerError } from '../../../lib/errors'; import { handleControllerError } from '../../../lib/helpers'; import { rateLimiterMiddleware } from '../../../lib/rate-limit'; import { handleValidationErrors } from '../../../request-helpers/error-handler'; @@ -31,14 +38,56 @@ const controllerName: string = 'affiliates-controller'; class AffiliatesController extends Controller { @Get('/metadata') async getMetadata( - @Query() address: string, // eslint-disable-line @typescript-eslint/no-unused-vars + @Query() address: string, ): Promise<AffiliateMetadataResponse> { - // simulate a delay - await new Promise((resolve) => setTimeout(resolve, 100)); + const [walletRow, referredUserRows, subaccountRows] = await Promise.all([ + WalletTable.findById(address), + AffiliateReferredUsersTable.findByAffiliateAddress(address), + SubaccountTable.findAll( + { + address, + subaccountNumber: 0, + }, + [], + ), + ]); + + // Check that the address exists + if (!walletRow) { + throw new NotFoundError(`Wallet with address ${address} not found`); + } + + // Check if the address is an affiliate (has referred users) + const isVolumeEligible = Number(walletRow.totalVolume) >= config.VOLUME_ELIGIBILITY_THRESHOLD; + const isAffiliate = referredUserRows !== undefined ? referredUserRows.length > 0 : false; + + // No need to check subaccountRows.length > 1 as subaccountNumber is unique for an address + if (subaccountRows.length === 0) { + // error logging will be performed by handleInternalServerError + throw new UnexpectedServerError(`Subaccount 0 not found for address ${address}`); + } + const subaccountId = subaccountRows[0].id; + + // Get subaccount0 username, which is the referral code + const usernameRows = await SubaccountUsernamesTable.findAll( + { + subaccountId: [subaccountId], + }, + [], + ); + // No need to check usernameRows.length > 1 as subAccountId is unique (foreign key constraint) + // This error can happen if a user calls this endpoint before subaccount-username-generator + // has generated the username + if (usernameRows.length === 0) { + stats.increment(`${config.SERVICE_NAME}.${controllerName}.get_metadata.subaccount_username_not_found`); + throw new UnexpectedServerError(`Username not found for subaccount ${subaccountId}`); + } + const referralCode = usernameRows[0].username; + return { - referralCode: 'TempCode123', - isVolumeEligible: true, - isAffiliate: false, + referralCode, + isVolumeEligible, + isAffiliate, }; } From 052e47d50de1254b45cb2e8548b6a27d5b8614d2 Mon Sep 17 00:00:00 2001 From: Mohammed Affan <affan@dydx.exchange> Date: Fri, 13 Sep 2024 14:07:16 -0400 Subject: [PATCH 02/12] fix lint for affiliates (#2255) --- protocol/x/revshare/keeper/revshare_test.go | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/protocol/x/revshare/keeper/revshare_test.go b/protocol/x/revshare/keeper/revshare_test.go index ddffb9abd8..fae19e4f07 100644 --- a/protocol/x/revshare/keeper/revshare_test.go +++ b/protocol/x/revshare/keeper/revshare_test.go @@ -335,7 +335,8 @@ func TestKeeper_GetAllRevShares_Valid(t *testing.T) { }, }) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + err = affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) @@ -401,7 +402,8 @@ func TestKeeper_GetAllRevShares_Valid(t *testing.T) { }, }) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + err = affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) @@ -459,7 +461,8 @@ func TestKeeper_GetAllRevShares_Valid(t *testing.T) { }, }) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + err = affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) @@ -500,7 +503,8 @@ func TestKeeper_GetAllRevShares_Valid(t *testing.T) { }) require.NoError(t, err) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + err = affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) @@ -542,8 +546,9 @@ func TestKeeper_GetAllRevShares_Valid(t *testing.T) { }, }, }) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) - err := affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), + err := affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) + err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) }, @@ -622,7 +627,8 @@ func TestKeeper_GetAllRevShares_Invalid(t *testing.T) { }, }, }) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + err = affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) @@ -643,7 +649,8 @@ func TestKeeper_GetAllRevShares_Invalid(t *testing.T) { }) require.NoError(t, err) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + err = affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) @@ -666,8 +673,9 @@ func TestKeeper_GetAllRevShares_Invalid(t *testing.T) { }, }) - affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) - err := affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) + err := affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) + require.NoError(t, err) + err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) require.NoError(t, err) }, }, From 0aa8383b7e0176bfaab83f2ac166d0fd408c102d Mon Sep 17 00:00:00 2001 From: jerryfan01234 <44346807+jerryfan01234@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:12:49 -0400 Subject: [PATCH 03/12] [OTE-761] Affiliates comlink total volume and address (#2254) --- .../api/v4/affiliates-controller.test.ts | 59 ++++++++++++++++--- .../api/v4/affiliates-controller.ts | 32 +++++++--- 2 files changed, 74 insertions(+), 17 deletions(-) diff --git a/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts b/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts index 465865020d..56565269ed 100644 --- a/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts +++ b/indexer/services/comlink/__tests__/controllers/api/v4/affiliates-controller.test.ts @@ -138,16 +138,34 @@ describe('affiliates-controller#V4', () => { }); describe('GET /address', () => { - it('should return address for a valid referral code string', async () => { - const referralCode = 'TempCode123'; + beforeEach(async () => { + await testMocks.seedData(); + await SubaccountUsernamesTable.create(testConstants.defaultSubaccountUsername); + }); + + afterEach(async () => { + await dbHelpers.clearData(); + }); + + it('should return address for a valid referral code', async () => { + const referralCode = testConstants.defaultSubaccountUsername.username; const response: request.Response = await sendRequest({ type: RequestMethod.GET, path: `/v4/affiliates/address?referralCode=${referralCode}`, + expectedStatus: 200, // helper performs expect on status }); - expect(response.status).toBe(200); expect(response.body).toEqual({ - address: 'some_address', + address: testConstants.defaultWallet.address, + }); + }); + + it('should fail when referral code not found', async () => { + const nonExistentReferralCode = 'BadCode123'; + await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/address?referralCode=${nonExistentReferralCode}`, + expectedStatus: 404, // helper performs expect on status }); }); }); @@ -184,16 +202,39 @@ describe('affiliates-controller#V4', () => { }); describe('GET /total_volume', () => { - it('should return total_volume for a valid address', async () => { - const address = 'some_address'; + beforeEach(async () => { + await testMocks.seedData(); + await WalletTable.update( + { + address: testConstants.defaultWallet.address, + totalVolume: '100000', + totalTradingRewards: '0', + }, + ); + }); + + afterEach(async () => { + await dbHelpers.clearData(); + }); + + it('should return total volume for a valid address', async () => { const response: request.Response = await sendRequest({ type: RequestMethod.GET, - path: `/v4/affiliates/total_volume?address=${address}`, + path: `/v4/affiliates/total_volume?address=${testConstants.defaultWallet.address}`, + expectedStatus: 200, // helper performs expect on status }); - expect(response.status).toBe(200); expect(response.body).toEqual({ - totalVolume: 111.1, + totalVolume: 100000, + }); + }); + + it('should fail if address does not exist', async () => { + const nonExistentAddress = 'adgsakhasgt'; + await sendRequest({ + type: RequestMethod.GET, + path: `/v4/affiliates/metadata?address=${nonExistentAddress}`, + expectedStatus: 404, // helper performs expect on status }); }); }); diff --git a/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts b/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts index 278b988422..841d37c300 100644 --- a/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts +++ b/indexer/services/comlink/src/controllers/api/v4/affiliates-controller.ts @@ -93,12 +93,24 @@ class AffiliatesController extends Controller { @Get('/address') async getAddress( - @Query() referralCode: string, // eslint-disable-line @typescript-eslint/no-unused-vars + @Query() referralCode: string, ): Promise<AffiliateAddressResponse> { - // simulate a delay - await new Promise((resolve) => setTimeout(resolve, 100)); + const usernameRow = await SubaccountUsernamesTable.findByUsername(referralCode); + if (!usernameRow) { + throw new NotFoundError(`Referral code ${referralCode} does not exist`); + } + const subAccountId = usernameRow.subaccountId; + + const subaccountRow = await SubaccountTable.findById(subAccountId); + // subaccountRow should never be undefined because of foreign key constraint between subaccounts + // and subaccount_usernames tables + if (!subaccountRow) { + throw new UnexpectedServerError(`Subaccount ${subAccountId} not found`); + } + const address = subaccountRow.address; + return { - address: 'some_address', + address, }; } @@ -143,12 +155,16 @@ class AffiliatesController extends Controller { @Get('/total_volume') public async getTotalVolume( - @Query() address: string, // eslint-disable-line @typescript-eslint/no-unused-vars + @Query() address: string, ): Promise<AffiliateTotalVolumeResponse> { - // simulate a delay - await new Promise((resolve) => setTimeout(resolve, 100)); + // Check that the address exists + const walletRow = await WalletTable.findById(address); + if (!walletRow) { + throw new NotFoundError(`Wallet with address ${address} not found`); + } + return { - totalVolume: 111.1, + totalVolume: Number(walletRow.totalVolume), }; } } From 8cc37b2b49e8907e11a2636f304d84e3336b03c7 Mon Sep 17 00:00:00 2001 From: vincentwschau <99756290+vincentwschau@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:46:17 -0400 Subject: [PATCH 04/12] [TRA-571] Add query to get intervaled PnL ticks. (#2247) --- .../__tests__/stores/pnl-ticks-table.test.ts | 162 ++++++++++++++++++ .../postgres/src/stores/pnl-ticks-table.ts | 57 ++++++ .../postgres/src/types/pnl-ticks-types.ts | 5 + 3 files changed, 224 insertions(+) diff --git a/indexer/packages/postgres/__tests__/stores/pnl-ticks-table.test.ts b/indexer/packages/postgres/__tests__/stores/pnl-ticks-table.test.ts index cf382cdd47..2fb699acbf 100644 --- a/indexer/packages/postgres/__tests__/stores/pnl-ticks-table.test.ts +++ b/indexer/packages/postgres/__tests__/stores/pnl-ticks-table.test.ts @@ -2,8 +2,10 @@ import { IsoString, LeaderboardPnlCreateObject, Ordering, + PnlTickInterval, PnlTicksColumns, PnlTicksCreateObject, + PnlTicksFromDatabase, } from '../../src/types'; import * as PnlTicksTable from '../../src/stores/pnl-ticks-table'; import * as BlockTable from '../../src/stores/block-table'; @@ -439,6 +441,51 @@ describe('PnlTicks store', () => { expect(leaderboardRankedData.length).toEqual(2); }); + it.each([ + { + description: 'Get hourly pnl ticks', + interval: PnlTickInterval.hour, + }, + { + description: 'Get daily pnl ticks', + interval: PnlTickInterval.day, + }, + ])('$description', async ({ + interval, + }: { + interval: PnlTickInterval, + }) => { + const createdTicks: PnlTicksFromDatabase[] = await setupIntervalPnlTicks(); + const pnlTicks: PnlTicksFromDatabase[] = await PnlTicksTable.getPnlTicksAtIntervals( + interval, + 7 * 24 * 60 * 60, // 1 week + [defaultSubaccountId, defaultSubaccountIdWithAlternateAddress], + ); + // See setup function for created ticks. + // Should exclude tick that is within the same hour except the first. + const expectedHourlyTicks: PnlTicksFromDatabase[] = [ + createdTicks[8], + createdTicks[7], + createdTicks[5], + createdTicks[3], + createdTicks[2], + createdTicks[0], + ]; + // Should exclude ticks that is within the same day except for the first. + const expectedDailyTicks: PnlTicksFromDatabase[] = [ + createdTicks[8], + createdTicks[7], + createdTicks[3], + createdTicks[2], + ]; + + if (interval === PnlTickInterval.day) { + expect(pnlTicks).toEqual(expectedDailyTicks); + } else if (interval === PnlTickInterval.hour) { + expect(pnlTicks).toEqual(expectedHourlyTicks); + } + }); + }); async function setupRankedPnlTicksData() { @@ -544,3 +591,118 @@ async function setupRankedPnlTicksData() { }, ]); } + +async function setupIntervalPnlTicks(): Promise<PnlTicksFromDatabase[]> { + const currentTime: DateTime = DateTime.utc().startOf('day'); + const tenMinAgo: string = currentTime.minus({ minute: 10 }).toISO(); + const almostTenMinAgo: string = currentTime.minus({ second: 603 }).toISO(); + const twoHoursAgo: string = currentTime.minus({ hour: 2 }).toISO(); + const twoDaysAgo: string = currentTime.minus({ day: 2 }).toISO(); + const monthAgo: string = currentTime.minus({ day: 30 }).toISO(); + await Promise.all([ + BlockTable.create({ + blockHeight: '3', + time: monthAgo, + }), + BlockTable.create({ + blockHeight: '4', + time: twoDaysAgo, + }), + BlockTable.create({ + blockHeight: '6', + time: twoHoursAgo, + }), + BlockTable.create({ + blockHeight: '8', + time: almostTenMinAgo, + }), + BlockTable.create({ + blockHeight: '10', + time: tenMinAgo, + }), + ]); + const createdTicks: PnlTicksFromDatabase[] = await PnlTicksTable.createMany([ + { + subaccountId: defaultSubaccountId, + equity: '1100', + createdAt: almostTenMinAgo, + totalPnl: '1200', + netTransfers: '50', + blockHeight: '10', + blockTime: almostTenMinAgo, + }, + { + subaccountId: defaultSubaccountId, + equity: '1090', + createdAt: tenMinAgo, + totalPnl: '1190', + netTransfers: '50', + blockHeight: '8', + blockTime: tenMinAgo, + }, + { + subaccountId: defaultSubaccountId, + equity: '1080', + createdAt: twoHoursAgo, + totalPnl: '1180', + netTransfers: '50', + blockHeight: '6', + blockTime: twoHoursAgo, + }, + { + subaccountId: defaultSubaccountId, + equity: '1070', + createdAt: twoDaysAgo, + totalPnl: '1170', + netTransfers: '50', + blockHeight: '4', + blockTime: twoDaysAgo, + }, + { + subaccountId: defaultSubaccountId, + equity: '1200', + createdAt: monthAgo, + totalPnl: '1170', + netTransfers: '50', + blockHeight: '3', + blockTime: monthAgo, + }, + { + subaccountId: defaultSubaccountIdWithAlternateAddress, + equity: '200', + createdAt: almostTenMinAgo, + totalPnl: '300', + netTransfers: '50', + blockHeight: '10', + blockTime: almostTenMinAgo, + }, + { + subaccountId: defaultSubaccountIdWithAlternateAddress, + equity: '210', + createdAt: tenMinAgo, + totalPnl: '310', + netTransfers: '50', + blockHeight: '8', + blockTime: tenMinAgo, + }, + { + subaccountId: defaultSubaccountIdWithAlternateAddress, + equity: '220', + createdAt: twoHoursAgo, + totalPnl: '320', + netTransfers: '50', + blockHeight: '6', + blockTime: twoHoursAgo, + }, + { + subaccountId: defaultSubaccountIdWithAlternateAddress, + equity: '230', + createdAt: twoDaysAgo, + totalPnl: '330', + netTransfers: '50', + blockHeight: '4', + blockTime: twoDaysAgo, + }, + ]); + return createdTicks; +} diff --git a/indexer/packages/postgres/src/stores/pnl-ticks-table.ts b/indexer/packages/postgres/src/stores/pnl-ticks-table.ts index f3cc9ffc1c..64ef22587a 100644 --- a/indexer/packages/postgres/src/stores/pnl-ticks-table.ts +++ b/indexer/packages/postgres/src/stores/pnl-ticks-table.ts @@ -22,6 +22,7 @@ import { PaginationFromDatabase, LeaderboardPnlCreateObject, LeaderboardPnlTimeSpan, + PnlTickInterval, } from '../types'; export function uuid( @@ -448,3 +449,59 @@ async function getAllTimeRankedPnlTicks(): Promise<LeaderboardPnlCreateObject[]> return result.rows; } + +/** + * Constructs a query to get pnl ticks at a specific interval for a set of subaccounts + * within a time range. + * Uses a windowing function in the raw query to get the first row of each window of the specific + * interval time. + * Currently only supports hourly / daily as the interval. + * @param interval 'day' or 'hour'. + * @param timeWindowSeconds Window of time to get pnl ticks for at the specified interval. + * @param subaccountIds Set of subaccounts to get pnl ticks for. + * @returns + */ +export async function getPnlTicksAtIntervals( + interval: PnlTickInterval, + timeWindowSeconds: number, + subaccountIds: string[], +): Promise <PnlTicksFromDatabase[]> { + const result: { + rows: PnlTicksFromDatabase[], + } = await knexReadReplica.getConnection().raw( + ` + SELECT + "id", + "subaccountId", + "equity", + "totalPnl", + "netTransfers", + "createdAt", + "blockHeight", + "blockTime" + FROM ( + SELECT + pnl_ticks.*, + ROW_NUMBER() OVER ( + PARTITION BY + "subaccountId", + DATE_TRUNC( + '${interval}', + "blockTime" + ) ORDER BY "blockTime" + ) AS r + FROM pnl_ticks + WHERE + "subaccountId" IN (${subaccountIds.map((id: string) => { return `'${id}'`; }).join(',')}) AND + "blockTime" > NOW() - INTERVAL '${timeWindowSeconds} second' + ) AS pnl_intervals + WHERE + r = 1 + ORDER BY "subaccountId"; + `, + ) as unknown as { + rows: PnlTicksFromDatabase[], + }; + + return result.rows; +} diff --git a/indexer/packages/postgres/src/types/pnl-ticks-types.ts b/indexer/packages/postgres/src/types/pnl-ticks-types.ts index 2e73eddedd..87c206b890 100644 --- a/indexer/packages/postgres/src/types/pnl-ticks-types.ts +++ b/indexer/packages/postgres/src/types/pnl-ticks-types.ts @@ -22,3 +22,8 @@ export enum PnlTicksColumns { blockHeight = 'blockHeight', blockTime = 'blockTime', } + +export enum PnlTickInterval { + hour = 'hour', + day = 'day', +} From cbd23b1a012dbbc8b741a3fe0ce7db9f8bb65be1 Mon Sep 17 00:00:00 2001 From: jayy04 <103467857+jayy04@users.noreply.github.com> Date: Mon, 16 Sep 2024 04:58:02 +0900 Subject: [PATCH 05/12] [CT-1160] add relevant protos to dydxprotocol (#2162) --- .../dydxprotocol/accountplus/genesis.ts | 147 +- .../dydxprotocol/accountplus/models.ts | 117 ++ .../dydxprotocol/accountplus/params.ts | 67 + .../dydxprotocol/accountplus/query.lcd.ts | 38 + .../accountplus/query.rpc.Query.ts | 63 + .../codegen/dydxprotocol/accountplus/query.ts | 335 ++++ .../dydxprotocol/accountplus/tx.rpc.msg.ts | 47 + .../codegen/dydxprotocol/accountplus/tx.ts | 468 +++++ .../src/codegen/dydxprotocol/bundle.ts | 590 +++--- .../v4-protos/src/codegen/dydxprotocol/lcd.ts | 3 + .../src/codegen/dydxprotocol/rpc.query.ts | 1 + .../src/codegen/dydxprotocol/rpc.tx.ts | 1 + .../v4-protos/src/codegen/gogoproto/bundle.ts | 4 +- .../v4-protos/src/codegen/google/bundle.ts | 24 +- proto/dydxprotocol/accountplus/genesis.proto | 26 + proto/dydxprotocol/accountplus/models.proto | 23 + proto/dydxprotocol/accountplus/params.proto | 15 + proto/dydxprotocol/accountplus/query.proto | 59 + proto/dydxprotocol/accountplus/tx.proto | 68 + .../app/testdata/default_genesis_state.json | 7 +- .../scripts/genesis/sample_pregenesis.json | 7 +- protocol/x/accountplus/types/genesis.pb.go | 432 ++++- protocol/x/accountplus/types/models.pb.go | 418 ++++ protocol/x/accountplus/types/params.pb.go | 315 +++ protocol/x/accountplus/types/query.pb.go | 1365 +++++++++++++ protocol/x/accountplus/types/query.pb.gw.go | 377 ++++ protocol/x/accountplus/types/tx.pb.go | 1702 +++++++++++++++++ 27 files changed, 6398 insertions(+), 321 deletions(-) create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/models.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/params.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.lcd.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.rpc.Query.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.rpc.msg.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.ts create mode 100644 proto/dydxprotocol/accountplus/models.proto create mode 100644 proto/dydxprotocol/accountplus/params.proto create mode 100644 proto/dydxprotocol/accountplus/query.proto create mode 100644 proto/dydxprotocol/accountplus/tx.proto create mode 100644 protocol/x/accountplus/types/models.pb.go create mode 100644 protocol/x/accountplus/types/params.pb.go create mode 100644 protocol/x/accountplus/types/query.pb.go create mode 100644 protocol/x/accountplus/types/query.pb.gw.go create mode 100644 protocol/x/accountplus/types/tx.pb.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts index 00311a9921..5ffc5a7edf 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/genesis.ts @@ -1,20 +1,136 @@ +import { AccountAuthenticator, AccountAuthenticatorSDKType } from "./models"; import { AccountState, AccountStateSDKType } from "./accountplus"; +import { Params, ParamsSDKType } from "./params"; import * as _m0 from "protobufjs/minimal"; -import { DeepPartial } from "../../helpers"; +import { DeepPartial, Long } from "../../helpers"; +/** + * AuthenticatorData represents a genesis exported account with Authenticators. + * The address is used as the key, and the account authenticators are stored in + * the authenticators field. + */ + +export interface AuthenticatorData { + /** address is an account address, one address can have many authenticators */ + address: string; + /** + * authenticators are the account's authenticators, these can be multiple + * types including SignatureVerification, AllOfs, CosmWasmAuthenticators, etc + */ + + authenticators: AccountAuthenticator[]; +} +/** + * AuthenticatorData represents a genesis exported account with Authenticators. + * The address is used as the key, and the account authenticators are stored in + * the authenticators field. + */ + +export interface AuthenticatorDataSDKType { + /** address is an account address, one address can have many authenticators */ + address: string; + /** + * authenticators are the account's authenticators, these can be multiple + * types including SignatureVerification, AllOfs, CosmWasmAuthenticators, etc + */ + + authenticators: AccountAuthenticatorSDKType[]; +} /** Module genesis state */ export interface GenesisState { accounts: AccountState[]; + /** params define the parameters for the authenticator module. */ + + params?: Params; + /** next_authenticator_id is the next available authenticator ID. */ + + nextAuthenticatorId: Long; + /** + * authenticator_data contains the data for multiple accounts, each with their + * authenticators. + */ + + authenticatorData: AuthenticatorData[]; } /** Module genesis state */ export interface GenesisStateSDKType { accounts: AccountStateSDKType[]; + /** params define the parameters for the authenticator module. */ + + params?: ParamsSDKType; + /** next_authenticator_id is the next available authenticator ID. */ + + next_authenticator_id: Long; + /** + * authenticator_data contains the data for multiple accounts, each with their + * authenticators. + */ + + authenticator_data: AuthenticatorDataSDKType[]; +} + +function createBaseAuthenticatorData(): AuthenticatorData { + return { + address: "", + authenticators: [] + }; } +export const AuthenticatorData = { + encode(message: AuthenticatorData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + + for (const v of message.authenticators) { + AccountAuthenticator.encode(v!, writer.uint32(18).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): AuthenticatorData { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAuthenticatorData(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + + case 2: + message.authenticators.push(AccountAuthenticator.decode(reader, reader.uint32())); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<AuthenticatorData>): AuthenticatorData { + const message = createBaseAuthenticatorData(); + message.address = object.address ?? ""; + message.authenticators = object.authenticators?.map(e => AccountAuthenticator.fromPartial(e)) || []; + return message; + } + +}; + function createBaseGenesisState(): GenesisState { return { - accounts: [] + accounts: [], + params: undefined, + nextAuthenticatorId: Long.UZERO, + authenticatorData: [] }; } @@ -24,6 +140,18 @@ export const GenesisState = { AccountState.encode(v!, writer.uint32(10).fork()).ldelim(); } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + + if (!message.nextAuthenticatorId.isZero()) { + writer.uint32(24).uint64(message.nextAuthenticatorId); + } + + for (const v of message.authenticatorData) { + AuthenticatorData.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; }, @@ -40,6 +168,18 @@ export const GenesisState = { message.accounts.push(AccountState.decode(reader, reader.uint32())); break; + case 2: + message.params = Params.decode(reader, reader.uint32()); + break; + + case 3: + message.nextAuthenticatorId = (reader.uint64() as Long); + break; + + case 4: + message.authenticatorData.push(AuthenticatorData.decode(reader, reader.uint32())); + break; + default: reader.skipType(tag & 7); break; @@ -52,6 +192,9 @@ export const GenesisState = { fromPartial(object: DeepPartial<GenesisState>): GenesisState { const message = createBaseGenesisState(); message.accounts = object.accounts?.map(e => AccountState.fromPartial(e)) || []; + message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined; + message.nextAuthenticatorId = object.nextAuthenticatorId !== undefined && object.nextAuthenticatorId !== null ? Long.fromValue(object.nextAuthenticatorId) : Long.UZERO; + message.authenticatorData = object.authenticatorData?.map(e => AuthenticatorData.fromPartial(e)) || []; return message; } diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/models.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/models.ts new file mode 100644 index 0000000000..2e7ce339aa --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/models.ts @@ -0,0 +1,117 @@ +import * as _m0 from "protobufjs/minimal"; +import { Long, DeepPartial } from "../../helpers"; +/** + * AccountAuthenticator represents a foundational model for all authenticators. + * It provides extensibility by allowing concrete types to interpret and + * validate transactions based on the encapsulated data. + */ + +export interface AccountAuthenticator { + /** ID uniquely identifies the authenticator instance. */ + id: Long; + /** + * Type specifies the category of the AccountAuthenticator. + * This type information is essential for differentiating authenticators + * and ensuring precise data retrieval from the storage layer. + */ + + type: string; + /** + * Config is a versatile field used in conjunction with the specific type of + * account authenticator to facilitate complex authentication processes. + * The interpretation of this field is overloaded, enabling multiple + * authenticators to utilize it for their respective purposes. + */ + + config: Uint8Array; +} +/** + * AccountAuthenticator represents a foundational model for all authenticators. + * It provides extensibility by allowing concrete types to interpret and + * validate transactions based on the encapsulated data. + */ + +export interface AccountAuthenticatorSDKType { + /** ID uniquely identifies the authenticator instance. */ + id: Long; + /** + * Type specifies the category of the AccountAuthenticator. + * This type information is essential for differentiating authenticators + * and ensuring precise data retrieval from the storage layer. + */ + + type: string; + /** + * Config is a versatile field used in conjunction with the specific type of + * account authenticator to facilitate complex authentication processes. + * The interpretation of this field is overloaded, enabling multiple + * authenticators to utilize it for their respective purposes. + */ + + config: Uint8Array; +} + +function createBaseAccountAuthenticator(): AccountAuthenticator { + return { + id: Long.UZERO, + type: "", + config: new Uint8Array() + }; +} + +export const AccountAuthenticator = { + encode(message: AccountAuthenticator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (!message.id.isZero()) { + writer.uint32(8).uint64(message.id); + } + + if (message.type !== "") { + writer.uint32(18).string(message.type); + } + + if (message.config.length !== 0) { + writer.uint32(26).bytes(message.config); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): AccountAuthenticator { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseAccountAuthenticator(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.id = (reader.uint64() as Long); + break; + + case 2: + message.type = reader.string(); + break; + + case 3: + message.config = reader.bytes(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<AccountAuthenticator>): AccountAuthenticator { + const message = createBaseAccountAuthenticator(); + message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + message.type = object.type ?? ""; + message.config = object.config ?? new Uint8Array(); + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/params.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/params.ts new file mode 100644 index 0000000000..e0c5fb5adb --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/params.ts @@ -0,0 +1,67 @@ +import * as _m0 from "protobufjs/minimal"; +import { DeepPartial } from "../../helpers"; +/** Params defines the parameters for the module. */ + +export interface Params { + /** + * IsSmartAccountActive defines the state of the authenticator. + * If set to false, the authenticator module will not be used + * and the classic cosmos sdk authentication will be used instead. + */ + isSmartAccountActive: boolean; +} +/** Params defines the parameters for the module. */ + +export interface ParamsSDKType { + /** + * IsSmartAccountActive defines the state of the authenticator. + * If set to false, the authenticator module will not be used + * and the classic cosmos sdk authentication will be used instead. + */ + is_smart_account_active: boolean; +} + +function createBaseParams(): Params { + return { + isSmartAccountActive: false + }; +} + +export const Params = { + encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.isSmartAccountActive === true) { + writer.uint32(8).bool(message.isSmartAccountActive); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Params { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseParams(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.isSmartAccountActive = reader.bool(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<Params>): Params { + const message = createBaseParams(); + message.isSmartAccountActive = object.isSmartAccountActive ?? false; + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.lcd.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.lcd.ts new file mode 100644 index 0000000000..6331bc8560 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.lcd.ts @@ -0,0 +1,38 @@ +import { LCDClient } from "@osmonauts/lcd"; +import { QueryParamsRequest, QueryParamsResponseSDKType, GetAuthenticatorRequest, GetAuthenticatorResponseSDKType, GetAuthenticatorsRequest, GetAuthenticatorsResponseSDKType } from "./query"; +export class LCDQueryClient { + req: LCDClient; + + constructor({ + requestClient + }: { + requestClient: LCDClient; + }) { + this.req = requestClient; + this.params = this.params.bind(this); + this.getAuthenticator = this.getAuthenticator.bind(this); + this.getAuthenticators = this.getAuthenticators.bind(this); + } + /* Parameters queries the parameters of the module. */ + + + async params(_params: QueryParamsRequest = {}): Promise<QueryParamsResponseSDKType> { + const endpoint = `dydxprotocol/accountplus/params`; + return await this.req.get<QueryParamsResponseSDKType>(endpoint); + } + /* Queries a single authenticator by account and authenticator ID. */ + + + async getAuthenticator(params: GetAuthenticatorRequest): Promise<GetAuthenticatorResponseSDKType> { + const endpoint = `dydxprotocol/accountplus/authenticator/${params.account}/${params.authenticatorId}`; + return await this.req.get<GetAuthenticatorResponseSDKType>(endpoint); + } + /* Queries all authenticators for a given account. */ + + + async getAuthenticators(params: GetAuthenticatorsRequest): Promise<GetAuthenticatorsResponseSDKType> { + const endpoint = `dydxprotocol/accountplus/authenticators/${params.account}`; + return await this.req.get<GetAuthenticatorsResponseSDKType>(endpoint); + } + +} \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.rpc.Query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.rpc.Query.ts new file mode 100644 index 0000000000..ab66285450 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.rpc.Query.ts @@ -0,0 +1,63 @@ +import { Rpc } from "../../helpers"; +import * as _m0 from "protobufjs/minimal"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +import { QueryParamsRequest, QueryParamsResponse, GetAuthenticatorRequest, GetAuthenticatorResponse, GetAuthenticatorsRequest, GetAuthenticatorsResponse } from "./query"; +/** Query defines the gRPC querier service. */ + +export interface Query { + /** Parameters queries the parameters of the module. */ + params(request?: QueryParamsRequest): Promise<QueryParamsResponse>; + /** Queries a single authenticator by account and authenticator ID. */ + + getAuthenticator(request: GetAuthenticatorRequest): Promise<GetAuthenticatorResponse>; + /** Queries all authenticators for a given account. */ + + getAuthenticators(request: GetAuthenticatorsRequest): Promise<GetAuthenticatorsResponse>; +} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + + constructor(rpc: Rpc) { + this.rpc = rpc; + this.params = this.params.bind(this); + this.getAuthenticator = this.getAuthenticator.bind(this); + this.getAuthenticators = this.getAuthenticators.bind(this); + } + + params(request: QueryParamsRequest = {}): Promise<QueryParamsResponse> { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.accountplus.Query", "Params", data); + return promise.then(data => QueryParamsResponse.decode(new _m0.Reader(data))); + } + + getAuthenticator(request: GetAuthenticatorRequest): Promise<GetAuthenticatorResponse> { + const data = GetAuthenticatorRequest.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.accountplus.Query", "GetAuthenticator", data); + return promise.then(data => GetAuthenticatorResponse.decode(new _m0.Reader(data))); + } + + getAuthenticators(request: GetAuthenticatorsRequest): Promise<GetAuthenticatorsResponse> { + const data = GetAuthenticatorsRequest.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.accountplus.Query", "GetAuthenticators", data); + return promise.then(data => GetAuthenticatorsResponse.decode(new _m0.Reader(data))); + } + +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return { + params(request?: QueryParamsRequest): Promise<QueryParamsResponse> { + return queryService.params(request); + }, + + getAuthenticator(request: GetAuthenticatorRequest): Promise<GetAuthenticatorResponse> { + return queryService.getAuthenticator(request); + }, + + getAuthenticators(request: GetAuthenticatorsRequest): Promise<GetAuthenticatorsResponse> { + return queryService.getAuthenticators(request); + } + + }; +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.ts new file mode 100644 index 0000000000..432a383d59 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/query.ts @@ -0,0 +1,335 @@ +import { Params, ParamsSDKType } from "./params"; +import { AccountAuthenticator, AccountAuthenticatorSDKType } from "./models"; +import * as _m0 from "protobufjs/minimal"; +import { DeepPartial, Long } from "../../helpers"; +/** QueryParamsRequest is request type for the Query/Params RPC method. */ + +export interface QueryParamsRequest {} +/** QueryParamsRequest is request type for the Query/Params RPC method. */ + +export interface QueryParamsRequestSDKType {} +/** QueryParamsResponse is response type for the Query/Params RPC method. */ + +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: Params; +} +/** QueryParamsResponse is response type for the Query/Params RPC method. */ + +export interface QueryParamsResponseSDKType { + /** params holds all the parameters of this module. */ + params?: ParamsSDKType; +} +/** MsgGetAuthenticatorsRequest defines the Msg/GetAuthenticators request type. */ + +export interface GetAuthenticatorsRequest { + /** MsgGetAuthenticatorsRequest defines the Msg/GetAuthenticators request type. */ + account: string; +} +/** MsgGetAuthenticatorsRequest defines the Msg/GetAuthenticators request type. */ + +export interface GetAuthenticatorsRequestSDKType { + /** MsgGetAuthenticatorsRequest defines the Msg/GetAuthenticators request type. */ + account: string; +} +/** MsgGetAuthenticatorsResponse defines the Msg/GetAuthenticators response type. */ + +export interface GetAuthenticatorsResponse { + accountAuthenticators: AccountAuthenticator[]; +} +/** MsgGetAuthenticatorsResponse defines the Msg/GetAuthenticators response type. */ + +export interface GetAuthenticatorsResponseSDKType { + account_authenticators: AccountAuthenticatorSDKType[]; +} +/** MsgGetAuthenticatorRequest defines the Msg/GetAuthenticator request type. */ + +export interface GetAuthenticatorRequest { + account: string; + authenticatorId: Long; +} +/** MsgGetAuthenticatorRequest defines the Msg/GetAuthenticator request type. */ + +export interface GetAuthenticatorRequestSDKType { + account: string; + authenticator_id: Long; +} +/** MsgGetAuthenticatorResponse defines the Msg/GetAuthenticator response type. */ + +export interface GetAuthenticatorResponse { + accountAuthenticator?: AccountAuthenticator; +} +/** MsgGetAuthenticatorResponse defines the Msg/GetAuthenticator response type. */ + +export interface GetAuthenticatorResponseSDKType { + account_authenticator?: AccountAuthenticatorSDKType; +} + +function createBaseQueryParamsRequest(): QueryParamsRequest { + return {}; +} + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsRequest(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(_: DeepPartial<QueryParamsRequest>): QueryParamsRequest { + const message = createBaseQueryParamsRequest(); + return message; + } + +}; + +function createBaseQueryParamsResponse(): QueryParamsResponse { + return { + params: undefined + }; +} + +export const QueryParamsResponse = { + encode(message: QueryParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseQueryParamsResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<QueryParamsResponse>): QueryParamsResponse { + const message = createBaseQueryParamsResponse(); + message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined; + return message; + } + +}; + +function createBaseGetAuthenticatorsRequest(): GetAuthenticatorsRequest { + return { + account: "" + }; +} + +export const GetAuthenticatorsRequest = { + encode(message: GetAuthenticatorsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.account !== "") { + writer.uint32(10).string(message.account); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetAuthenticatorsRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetAuthenticatorsRequest(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.account = reader.string(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<GetAuthenticatorsRequest>): GetAuthenticatorsRequest { + const message = createBaseGetAuthenticatorsRequest(); + message.account = object.account ?? ""; + return message; + } + +}; + +function createBaseGetAuthenticatorsResponse(): GetAuthenticatorsResponse { + return { + accountAuthenticators: [] + }; +} + +export const GetAuthenticatorsResponse = { + encode(message: GetAuthenticatorsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.accountAuthenticators) { + AccountAuthenticator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetAuthenticatorsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetAuthenticatorsResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.accountAuthenticators.push(AccountAuthenticator.decode(reader, reader.uint32())); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<GetAuthenticatorsResponse>): GetAuthenticatorsResponse { + const message = createBaseGetAuthenticatorsResponse(); + message.accountAuthenticators = object.accountAuthenticators?.map(e => AccountAuthenticator.fromPartial(e)) || []; + return message; + } + +}; + +function createBaseGetAuthenticatorRequest(): GetAuthenticatorRequest { + return { + account: "", + authenticatorId: Long.UZERO + }; +} + +export const GetAuthenticatorRequest = { + encode(message: GetAuthenticatorRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.account !== "") { + writer.uint32(10).string(message.account); + } + + if (!message.authenticatorId.isZero()) { + writer.uint32(16).uint64(message.authenticatorId); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetAuthenticatorRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetAuthenticatorRequest(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.account = reader.string(); + break; + + case 2: + message.authenticatorId = (reader.uint64() as Long); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<GetAuthenticatorRequest>): GetAuthenticatorRequest { + const message = createBaseGetAuthenticatorRequest(); + message.account = object.account ?? ""; + message.authenticatorId = object.authenticatorId !== undefined && object.authenticatorId !== null ? Long.fromValue(object.authenticatorId) : Long.UZERO; + return message; + } + +}; + +function createBaseGetAuthenticatorResponse(): GetAuthenticatorResponse { + return { + accountAuthenticator: undefined + }; +} + +export const GetAuthenticatorResponse = { + encode(message: GetAuthenticatorResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.accountAuthenticator !== undefined) { + AccountAuthenticator.encode(message.accountAuthenticator, writer.uint32(10).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetAuthenticatorResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetAuthenticatorResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.accountAuthenticator = AccountAuthenticator.decode(reader, reader.uint32()); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<GetAuthenticatorResponse>): GetAuthenticatorResponse { + const message = createBaseGetAuthenticatorResponse(); + message.accountAuthenticator = object.accountAuthenticator !== undefined && object.accountAuthenticator !== null ? AccountAuthenticator.fromPartial(object.accountAuthenticator) : undefined; + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.rpc.msg.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.rpc.msg.ts new file mode 100644 index 0000000000..9582fd403d --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.rpc.msg.ts @@ -0,0 +1,47 @@ +import { Rpc } from "../../helpers"; +import * as _m0 from "protobufjs/minimal"; +import { MsgAddAuthenticator, MsgAddAuthenticatorResponse, MsgRemoveAuthenticator, MsgRemoveAuthenticatorResponse, MsgSetActiveState, MsgSetActiveStateResponse } from "./tx"; +/** Msg defines the Msg service. */ + +export interface Msg { + /** AddAuthenticator adds an authenticator to an account. */ + addAuthenticator(request: MsgAddAuthenticator): Promise<MsgAddAuthenticatorResponse>; + /** RemoveAuthenticator removes an authenticator from an account. */ + + removeAuthenticator(request: MsgRemoveAuthenticator): Promise<MsgRemoveAuthenticatorResponse>; + /** + * SetActiveState sets the active state of the authenticator. + * Primarily used for circuit breaking. + */ + + setActiveState(request: MsgSetActiveState): Promise<MsgSetActiveStateResponse>; +} +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + + constructor(rpc: Rpc) { + this.rpc = rpc; + this.addAuthenticator = this.addAuthenticator.bind(this); + this.removeAuthenticator = this.removeAuthenticator.bind(this); + this.setActiveState = this.setActiveState.bind(this); + } + + addAuthenticator(request: MsgAddAuthenticator): Promise<MsgAddAuthenticatorResponse> { + const data = MsgAddAuthenticator.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.accountplus.Msg", "AddAuthenticator", data); + return promise.then(data => MsgAddAuthenticatorResponse.decode(new _m0.Reader(data))); + } + + removeAuthenticator(request: MsgRemoveAuthenticator): Promise<MsgRemoveAuthenticatorResponse> { + const data = MsgRemoveAuthenticator.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.accountplus.Msg", "RemoveAuthenticator", data); + return promise.then(data => MsgRemoveAuthenticatorResponse.decode(new _m0.Reader(data))); + } + + setActiveState(request: MsgSetActiveState): Promise<MsgSetActiveStateResponse> { + const data = MsgSetActiveState.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.accountplus.Msg", "SetActiveState", data); + return promise.then(data => MsgSetActiveStateResponse.decode(new _m0.Reader(data))); + } + +} \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.ts new file mode 100644 index 0000000000..bf7b78452a --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/accountplus/tx.ts @@ -0,0 +1,468 @@ +import * as _m0 from "protobufjs/minimal"; +import { DeepPartial, Long } from "../../helpers"; +/** MsgAddAuthenticatorRequest defines the Msg/AddAuthenticator request type. */ + +export interface MsgAddAuthenticator { + sender: string; + authenticatorType: string; + data: Uint8Array; +} +/** MsgAddAuthenticatorRequest defines the Msg/AddAuthenticator request type. */ + +export interface MsgAddAuthenticatorSDKType { + sender: string; + authenticator_type: string; + data: Uint8Array; +} +/** MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. */ + +export interface MsgAddAuthenticatorResponse { + /** MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. */ + success: boolean; +} +/** MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. */ + +export interface MsgAddAuthenticatorResponseSDKType { + /** MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. */ + success: boolean; +} +/** + * MsgRemoveAuthenticatorRequest defines the Msg/RemoveAuthenticator request + * type. + */ + +export interface MsgRemoveAuthenticator { + sender: string; + id: Long; +} +/** + * MsgRemoveAuthenticatorRequest defines the Msg/RemoveAuthenticator request + * type. + */ + +export interface MsgRemoveAuthenticatorSDKType { + sender: string; + id: Long; +} +/** + * MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response + * type. + */ + +export interface MsgRemoveAuthenticatorResponse { + /** + * MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response + * type. + */ + success: boolean; +} +/** + * MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response + * type. + */ + +export interface MsgRemoveAuthenticatorResponseSDKType { + /** + * MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response + * type. + */ + success: boolean; +} +/** MsgSetActiveState sets the active state of the module. */ + +export interface MsgSetActiveState { + sender: string; + active: boolean; +} +/** MsgSetActiveState sets the active state of the module. */ + +export interface MsgSetActiveStateSDKType { + sender: string; + active: boolean; +} +/** MsgSetActiveStateResponse defines the Msg/SetActiveState response type. */ + +export interface MsgSetActiveStateResponse {} +/** MsgSetActiveStateResponse defines the Msg/SetActiveState response type. */ + +export interface MsgSetActiveStateResponseSDKType {} +/** + * TxExtension allows for additional authenticator-specific data in + * transactions. + */ + +export interface TxExtension { + /** + * selected_authenticators holds the authenticator_id for the chosen + * authenticator per message. + */ + selectedAuthenticators: Long[]; +} +/** + * TxExtension allows for additional authenticator-specific data in + * transactions. + */ + +export interface TxExtensionSDKType { + /** + * selected_authenticators holds the authenticator_id for the chosen + * authenticator per message. + */ + selected_authenticators: Long[]; +} + +function createBaseMsgAddAuthenticator(): MsgAddAuthenticator { + return { + sender: "", + authenticatorType: "", + data: new Uint8Array() + }; +} + +export const MsgAddAuthenticator = { + encode(message: MsgAddAuthenticator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + + if (message.authenticatorType !== "") { + writer.uint32(18).string(message.authenticatorType); + } + + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgAddAuthenticator { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAddAuthenticator(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + + case 2: + message.authenticatorType = reader.string(); + break; + + case 3: + message.data = reader.bytes(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<MsgAddAuthenticator>): MsgAddAuthenticator { + const message = createBaseMsgAddAuthenticator(); + message.sender = object.sender ?? ""; + message.authenticatorType = object.authenticatorType ?? ""; + message.data = object.data ?? new Uint8Array(); + return message; + } + +}; + +function createBaseMsgAddAuthenticatorResponse(): MsgAddAuthenticatorResponse { + return { + success: false + }; +} + +export const MsgAddAuthenticatorResponse = { + encode(message: MsgAddAuthenticatorResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.success === true) { + writer.uint32(8).bool(message.success); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgAddAuthenticatorResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgAddAuthenticatorResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.success = reader.bool(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<MsgAddAuthenticatorResponse>): MsgAddAuthenticatorResponse { + const message = createBaseMsgAddAuthenticatorResponse(); + message.success = object.success ?? false; + return message; + } + +}; + +function createBaseMsgRemoveAuthenticator(): MsgRemoveAuthenticator { + return { + sender: "", + id: Long.UZERO + }; +} + +export const MsgRemoveAuthenticator = { + encode(message: MsgRemoveAuthenticator, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + + if (!message.id.isZero()) { + writer.uint32(16).uint64(message.id); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRemoveAuthenticator { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRemoveAuthenticator(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + + case 2: + message.id = (reader.uint64() as Long); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<MsgRemoveAuthenticator>): MsgRemoveAuthenticator { + const message = createBaseMsgRemoveAuthenticator(); + message.sender = object.sender ?? ""; + message.id = object.id !== undefined && object.id !== null ? Long.fromValue(object.id) : Long.UZERO; + return message; + } + +}; + +function createBaseMsgRemoveAuthenticatorResponse(): MsgRemoveAuthenticatorResponse { + return { + success: false + }; +} + +export const MsgRemoveAuthenticatorResponse = { + encode(message: MsgRemoveAuthenticatorResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.success === true) { + writer.uint32(8).bool(message.success); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgRemoveAuthenticatorResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgRemoveAuthenticatorResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.success = reader.bool(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<MsgRemoveAuthenticatorResponse>): MsgRemoveAuthenticatorResponse { + const message = createBaseMsgRemoveAuthenticatorResponse(); + message.success = object.success ?? false; + return message; + } + +}; + +function createBaseMsgSetActiveState(): MsgSetActiveState { + return { + sender: "", + active: false + }; +} + +export const MsgSetActiveState = { + encode(message: MsgSetActiveState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + + if (message.active === true) { + writer.uint32(16).bool(message.active); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetActiveState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetActiveState(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + + case 2: + message.active = reader.bool(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<MsgSetActiveState>): MsgSetActiveState { + const message = createBaseMsgSetActiveState(); + message.sender = object.sender ?? ""; + message.active = object.active ?? false; + return message; + } + +}; + +function createBaseMsgSetActiveStateResponse(): MsgSetActiveStateResponse { + return {}; +} + +export const MsgSetActiveStateResponse = { + encode(_: MsgSetActiveStateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSetActiveStateResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgSetActiveStateResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(_: DeepPartial<MsgSetActiveStateResponse>): MsgSetActiveStateResponse { + const message = createBaseMsgSetActiveStateResponse(); + return message; + } + +}; + +function createBaseTxExtension(): TxExtension { + return { + selectedAuthenticators: [] + }; +} + +export const TxExtension = { + encode(message: TxExtension, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + writer.uint32(10).fork(); + + for (const v of message.selectedAuthenticators) { + writer.uint64(v); + } + + writer.ldelim(); + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): TxExtension { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTxExtension(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + + while (reader.pos < end2) { + message.selectedAuthenticators.push((reader.uint64() as Long)); + } + } else { + message.selectedAuthenticators.push((reader.uint64() as Long)); + } + + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<TxExtension>): TxExtension { + const message = createBaseTxExtension(); + message.selectedAuthenticators = object.selectedAuthenticators?.map(e => Long.fromValue(e)) || []; + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts index 8357d1849d..ea45d3f68c 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts @@ -1,219 +1,229 @@ import * as _5 from "./accountplus/accountplus"; import * as _6 from "./accountplus/genesis"; -import * as _7 from "./affiliates/affiliates"; -import * as _8 from "./affiliates/genesis"; -import * as _9 from "./affiliates/query"; -import * as _10 from "./affiliates/tx"; -import * as _11 from "./assets/asset"; -import * as _12 from "./assets/genesis"; -import * as _13 from "./assets/query"; -import * as _14 from "./assets/tx"; -import * as _15 from "./blocktime/blocktime"; -import * as _16 from "./blocktime/genesis"; -import * as _17 from "./blocktime/params"; -import * as _18 from "./blocktime/query"; -import * as _19 from "./blocktime/tx"; -import * as _20 from "./bridge/bridge_event_info"; -import * as _21 from "./bridge/bridge_event"; -import * as _22 from "./bridge/genesis"; -import * as _23 from "./bridge/params"; -import * as _24 from "./bridge/query"; -import * as _25 from "./bridge/tx"; -import * as _26 from "./clob/block_rate_limit_config"; -import * as _27 from "./clob/clob_pair"; -import * as _28 from "./clob/equity_tier_limit_config"; -import * as _29 from "./clob/genesis"; -import * as _30 from "./clob/liquidations_config"; -import * as _31 from "./clob/liquidations"; -import * as _32 from "./clob/matches"; -import * as _33 from "./clob/mev"; -import * as _34 from "./clob/operation"; -import * as _35 from "./clob/order_removals"; -import * as _36 from "./clob/order"; -import * as _37 from "./clob/process_proposer_matches_events"; -import * as _38 from "./clob/query"; -import * as _39 from "./clob/tx"; -import * as _40 from "./daemons/bridge/bridge"; -import * as _41 from "./daemons/liquidation/liquidation"; -import * as _42 from "./daemons/pricefeed/price_feed"; -import * as _43 from "./delaymsg/block_message_ids"; -import * as _44 from "./delaymsg/delayed_message"; -import * as _45 from "./delaymsg/genesis"; -import * as _46 from "./delaymsg/query"; -import * as _47 from "./delaymsg/tx"; -import * as _48 from "./epochs/epoch_info"; -import * as _49 from "./epochs/genesis"; -import * as _50 from "./epochs/query"; -import * as _51 from "./feetiers/genesis"; -import * as _52 from "./feetiers/params"; -import * as _53 from "./feetiers/query"; -import * as _54 from "./feetiers/tx"; -import * as _55 from "./govplus/genesis"; -import * as _56 from "./govplus/query"; -import * as _57 from "./govplus/tx"; -import * as _58 from "./indexer/events/events"; -import * as _59 from "./indexer/indexer_manager/event"; -import * as _60 from "./indexer/off_chain_updates/off_chain_updates"; -import * as _61 from "./indexer/protocol/v1/clob"; -import * as _62 from "./indexer/protocol/v1/perpetual"; -import * as _63 from "./indexer/protocol/v1/subaccount"; -import * as _64 from "./indexer/redis/redis_order"; -import * as _65 from "./indexer/shared/removal_reason"; -import * as _66 from "./indexer/socks/messages"; -import * as _67 from "./listing/genesis"; -import * as _68 from "./listing/params"; -import * as _69 from "./listing/query"; -import * as _70 from "./listing/tx"; -import * as _71 from "./perpetuals/genesis"; -import * as _72 from "./perpetuals/params"; -import * as _73 from "./perpetuals/perpetual"; -import * as _74 from "./perpetuals/query"; -import * as _75 from "./perpetuals/tx"; -import * as _76 from "./prices/genesis"; -import * as _77 from "./prices/market_param"; -import * as _78 from "./prices/market_price"; -import * as _79 from "./prices/query"; -import * as _80 from "./prices/tx"; -import * as _81 from "./ratelimit/capacity"; -import * as _82 from "./ratelimit/genesis"; -import * as _83 from "./ratelimit/limit_params"; -import * as _84 from "./ratelimit/pending_send_packet"; -import * as _85 from "./ratelimit/query"; -import * as _86 from "./ratelimit/tx"; -import * as _87 from "./revshare/genesis"; -import * as _88 from "./revshare/params"; -import * as _89 from "./revshare/query"; -import * as _90 from "./revshare/revshare"; -import * as _91 from "./revshare/tx"; -import * as _92 from "./rewards/genesis"; -import * as _93 from "./rewards/params"; -import * as _94 from "./rewards/query"; -import * as _95 from "./rewards/reward_share"; -import * as _96 from "./rewards/tx"; -import * as _97 from "./sending/genesis"; -import * as _98 from "./sending/query"; -import * as _99 from "./sending/transfer"; -import * as _100 from "./sending/tx"; -import * as _101 from "./stats/genesis"; -import * as _102 from "./stats/params"; -import * as _103 from "./stats/query"; -import * as _104 from "./stats/stats"; -import * as _105 from "./stats/tx"; -import * as _106 from "./subaccounts/asset_position"; -import * as _107 from "./subaccounts/genesis"; -import * as _108 from "./subaccounts/perpetual_position"; -import * as _109 from "./subaccounts/query"; -import * as _110 from "./subaccounts/streaming"; -import * as _111 from "./subaccounts/subaccount"; -import * as _112 from "./vault/genesis"; -import * as _113 from "./vault/params"; -import * as _114 from "./vault/query"; -import * as _115 from "./vault/share"; -import * as _116 from "./vault/tx"; -import * as _117 from "./vault/vault"; -import * as _118 from "./vest/genesis"; -import * as _119 from "./vest/query"; -import * as _120 from "./vest/tx"; -import * as _121 from "./vest/vest_entry"; -import * as _129 from "./assets/query.lcd"; -import * as _130 from "./blocktime/query.lcd"; -import * as _131 from "./bridge/query.lcd"; -import * as _132 from "./clob/query.lcd"; -import * as _133 from "./delaymsg/query.lcd"; -import * as _134 from "./epochs/query.lcd"; -import * as _135 from "./feetiers/query.lcd"; -import * as _136 from "./listing/query.lcd"; -import * as _137 from "./perpetuals/query.lcd"; -import * as _138 from "./prices/query.lcd"; -import * as _139 from "./ratelimit/query.lcd"; -import * as _140 from "./revshare/query.lcd"; -import * as _141 from "./rewards/query.lcd"; -import * as _142 from "./stats/query.lcd"; -import * as _143 from "./subaccounts/query.lcd"; -import * as _144 from "./vault/query.lcd"; -import * as _145 from "./vest/query.lcd"; -import * as _146 from "./affiliates/query.rpc.Query"; -import * as _147 from "./assets/query.rpc.Query"; -import * as _148 from "./blocktime/query.rpc.Query"; -import * as _149 from "./bridge/query.rpc.Query"; -import * as _150 from "./clob/query.rpc.Query"; -import * as _151 from "./delaymsg/query.rpc.Query"; -import * as _152 from "./epochs/query.rpc.Query"; -import * as _153 from "./feetiers/query.rpc.Query"; -import * as _154 from "./govplus/query.rpc.Query"; -import * as _155 from "./listing/query.rpc.Query"; -import * as _156 from "./perpetuals/query.rpc.Query"; -import * as _157 from "./prices/query.rpc.Query"; -import * as _158 from "./ratelimit/query.rpc.Query"; -import * as _159 from "./revshare/query.rpc.Query"; -import * as _160 from "./rewards/query.rpc.Query"; -import * as _161 from "./sending/query.rpc.Query"; -import * as _162 from "./stats/query.rpc.Query"; -import * as _163 from "./subaccounts/query.rpc.Query"; -import * as _164 from "./vault/query.rpc.Query"; -import * as _165 from "./vest/query.rpc.Query"; -import * as _166 from "./affiliates/tx.rpc.msg"; -import * as _167 from "./blocktime/tx.rpc.msg"; -import * as _168 from "./bridge/tx.rpc.msg"; -import * as _169 from "./clob/tx.rpc.msg"; -import * as _170 from "./delaymsg/tx.rpc.msg"; -import * as _171 from "./feetiers/tx.rpc.msg"; -import * as _172 from "./govplus/tx.rpc.msg"; -import * as _173 from "./listing/tx.rpc.msg"; -import * as _174 from "./perpetuals/tx.rpc.msg"; -import * as _175 from "./prices/tx.rpc.msg"; -import * as _176 from "./ratelimit/tx.rpc.msg"; -import * as _177 from "./revshare/tx.rpc.msg"; -import * as _178 from "./rewards/tx.rpc.msg"; -import * as _179 from "./sending/tx.rpc.msg"; -import * as _180 from "./stats/tx.rpc.msg"; -import * as _181 from "./vault/tx.rpc.msg"; -import * as _182 from "./vest/tx.rpc.msg"; -import * as _183 from "./lcd"; -import * as _184 from "./rpc.query"; -import * as _185 from "./rpc.tx"; +import * as _7 from "./accountplus/models"; +import * as _8 from "./accountplus/params"; +import * as _9 from "./accountplus/query"; +import * as _10 from "./accountplus/tx"; +import * as _11 from "./affiliates/affiliates"; +import * as _12 from "./affiliates/genesis"; +import * as _13 from "./affiliates/query"; +import * as _14 from "./affiliates/tx"; +import * as _15 from "./assets/asset"; +import * as _16 from "./assets/genesis"; +import * as _17 from "./assets/query"; +import * as _18 from "./assets/tx"; +import * as _19 from "./blocktime/blocktime"; +import * as _20 from "./blocktime/genesis"; +import * as _21 from "./blocktime/params"; +import * as _22 from "./blocktime/query"; +import * as _23 from "./blocktime/tx"; +import * as _24 from "./bridge/bridge_event_info"; +import * as _25 from "./bridge/bridge_event"; +import * as _26 from "./bridge/genesis"; +import * as _27 from "./bridge/params"; +import * as _28 from "./bridge/query"; +import * as _29 from "./bridge/tx"; +import * as _30 from "./clob/block_rate_limit_config"; +import * as _31 from "./clob/clob_pair"; +import * as _32 from "./clob/equity_tier_limit_config"; +import * as _33 from "./clob/genesis"; +import * as _34 from "./clob/liquidations_config"; +import * as _35 from "./clob/liquidations"; +import * as _36 from "./clob/matches"; +import * as _37 from "./clob/mev"; +import * as _38 from "./clob/operation"; +import * as _39 from "./clob/order_removals"; +import * as _40 from "./clob/order"; +import * as _41 from "./clob/process_proposer_matches_events"; +import * as _42 from "./clob/query"; +import * as _43 from "./clob/tx"; +import * as _44 from "./daemons/bridge/bridge"; +import * as _45 from "./daemons/liquidation/liquidation"; +import * as _46 from "./daemons/pricefeed/price_feed"; +import * as _47 from "./delaymsg/block_message_ids"; +import * as _48 from "./delaymsg/delayed_message"; +import * as _49 from "./delaymsg/genesis"; +import * as _50 from "./delaymsg/query"; +import * as _51 from "./delaymsg/tx"; +import * as _52 from "./epochs/epoch_info"; +import * as _53 from "./epochs/genesis"; +import * as _54 from "./epochs/query"; +import * as _55 from "./feetiers/genesis"; +import * as _56 from "./feetiers/params"; +import * as _57 from "./feetiers/query"; +import * as _58 from "./feetiers/tx"; +import * as _59 from "./govplus/genesis"; +import * as _60 from "./govplus/query"; +import * as _61 from "./govplus/tx"; +import * as _62 from "./indexer/events/events"; +import * as _63 from "./indexer/indexer_manager/event"; +import * as _64 from "./indexer/off_chain_updates/off_chain_updates"; +import * as _65 from "./indexer/protocol/v1/clob"; +import * as _66 from "./indexer/protocol/v1/perpetual"; +import * as _67 from "./indexer/protocol/v1/subaccount"; +import * as _68 from "./indexer/redis/redis_order"; +import * as _69 from "./indexer/shared/removal_reason"; +import * as _70 from "./indexer/socks/messages"; +import * as _71 from "./listing/genesis"; +import * as _72 from "./listing/params"; +import * as _73 from "./listing/query"; +import * as _74 from "./listing/tx"; +import * as _75 from "./perpetuals/genesis"; +import * as _76 from "./perpetuals/params"; +import * as _77 from "./perpetuals/perpetual"; +import * as _78 from "./perpetuals/query"; +import * as _79 from "./perpetuals/tx"; +import * as _80 from "./prices/genesis"; +import * as _81 from "./prices/market_param"; +import * as _82 from "./prices/market_price"; +import * as _83 from "./prices/query"; +import * as _84 from "./prices/tx"; +import * as _85 from "./ratelimit/capacity"; +import * as _86 from "./ratelimit/genesis"; +import * as _87 from "./ratelimit/limit_params"; +import * as _88 from "./ratelimit/pending_send_packet"; +import * as _89 from "./ratelimit/query"; +import * as _90 from "./ratelimit/tx"; +import * as _91 from "./revshare/genesis"; +import * as _92 from "./revshare/params"; +import * as _93 from "./revshare/query"; +import * as _94 from "./revshare/revshare"; +import * as _95 from "./revshare/tx"; +import * as _96 from "./rewards/genesis"; +import * as _97 from "./rewards/params"; +import * as _98 from "./rewards/query"; +import * as _99 from "./rewards/reward_share"; +import * as _100 from "./rewards/tx"; +import * as _101 from "./sending/genesis"; +import * as _102 from "./sending/query"; +import * as _103 from "./sending/transfer"; +import * as _104 from "./sending/tx"; +import * as _105 from "./stats/genesis"; +import * as _106 from "./stats/params"; +import * as _107 from "./stats/query"; +import * as _108 from "./stats/stats"; +import * as _109 from "./stats/tx"; +import * as _110 from "./subaccounts/asset_position"; +import * as _111 from "./subaccounts/genesis"; +import * as _112 from "./subaccounts/perpetual_position"; +import * as _113 from "./subaccounts/query"; +import * as _114 from "./subaccounts/streaming"; +import * as _115 from "./subaccounts/subaccount"; +import * as _116 from "./vault/genesis"; +import * as _117 from "./vault/params"; +import * as _118 from "./vault/query"; +import * as _119 from "./vault/share"; +import * as _120 from "./vault/tx"; +import * as _121 from "./vault/vault"; +import * as _122 from "./vest/genesis"; +import * as _123 from "./vest/query"; +import * as _124 from "./vest/tx"; +import * as _125 from "./vest/vest_entry"; +import * as _133 from "./accountplus/query.lcd"; +import * as _134 from "./assets/query.lcd"; +import * as _135 from "./blocktime/query.lcd"; +import * as _136 from "./bridge/query.lcd"; +import * as _137 from "./clob/query.lcd"; +import * as _138 from "./delaymsg/query.lcd"; +import * as _139 from "./epochs/query.lcd"; +import * as _140 from "./feetiers/query.lcd"; +import * as _141 from "./listing/query.lcd"; +import * as _142 from "./perpetuals/query.lcd"; +import * as _143 from "./prices/query.lcd"; +import * as _144 from "./ratelimit/query.lcd"; +import * as _145 from "./revshare/query.lcd"; +import * as _146 from "./rewards/query.lcd"; +import * as _147 from "./stats/query.lcd"; +import * as _148 from "./subaccounts/query.lcd"; +import * as _149 from "./vault/query.lcd"; +import * as _150 from "./vest/query.lcd"; +import * as _151 from "./accountplus/query.rpc.Query"; +import * as _152 from "./affiliates/query.rpc.Query"; +import * as _153 from "./assets/query.rpc.Query"; +import * as _154 from "./blocktime/query.rpc.Query"; +import * as _155 from "./bridge/query.rpc.Query"; +import * as _156 from "./clob/query.rpc.Query"; +import * as _157 from "./delaymsg/query.rpc.Query"; +import * as _158 from "./epochs/query.rpc.Query"; +import * as _159 from "./feetiers/query.rpc.Query"; +import * as _160 from "./govplus/query.rpc.Query"; +import * as _161 from "./listing/query.rpc.Query"; +import * as _162 from "./perpetuals/query.rpc.Query"; +import * as _163 from "./prices/query.rpc.Query"; +import * as _164 from "./ratelimit/query.rpc.Query"; +import * as _165 from "./revshare/query.rpc.Query"; +import * as _166 from "./rewards/query.rpc.Query"; +import * as _167 from "./sending/query.rpc.Query"; +import * as _168 from "./stats/query.rpc.Query"; +import * as _169 from "./subaccounts/query.rpc.Query"; +import * as _170 from "./vault/query.rpc.Query"; +import * as _171 from "./vest/query.rpc.Query"; +import * as _172 from "./accountplus/tx.rpc.msg"; +import * as _173 from "./affiliates/tx.rpc.msg"; +import * as _174 from "./blocktime/tx.rpc.msg"; +import * as _175 from "./bridge/tx.rpc.msg"; +import * as _176 from "./clob/tx.rpc.msg"; +import * as _177 from "./delaymsg/tx.rpc.msg"; +import * as _178 from "./feetiers/tx.rpc.msg"; +import * as _179 from "./govplus/tx.rpc.msg"; +import * as _180 from "./listing/tx.rpc.msg"; +import * as _181 from "./perpetuals/tx.rpc.msg"; +import * as _182 from "./prices/tx.rpc.msg"; +import * as _183 from "./ratelimit/tx.rpc.msg"; +import * as _184 from "./revshare/tx.rpc.msg"; +import * as _185 from "./rewards/tx.rpc.msg"; +import * as _186 from "./sending/tx.rpc.msg"; +import * as _187 from "./stats/tx.rpc.msg"; +import * as _188 from "./vault/tx.rpc.msg"; +import * as _189 from "./vest/tx.rpc.msg"; +import * as _190 from "./lcd"; +import * as _191 from "./rpc.query"; +import * as _192 from "./rpc.tx"; export namespace dydxprotocol { export const accountplus = { ..._5, - ..._6 - }; - export const affiliates = { ..._7, + ..._6, + ..._7, ..._8, ..._9, ..._10, - ..._146, - ..._166 + ..._133, + ..._151, + ..._172 }; - export const assets = { ..._11, + export const affiliates = { ..._11, ..._12, ..._13, ..._14, - ..._129, - ..._147 + ..._152, + ..._173 }; - export const blocktime = { ..._15, + export const assets = { ..._15, ..._16, ..._17, ..._18, - ..._19, - ..._130, - ..._148, - ..._167 + ..._134, + ..._153 }; - export const bridge = { ..._20, + export const blocktime = { ..._19, + ..._20, ..._21, ..._22, ..._23, - ..._24, - ..._25, - ..._131, - ..._149, - ..._168 + ..._135, + ..._154, + ..._174 }; - export const clob = { ..._26, + export const bridge = { ..._24, + ..._25, + ..._26, ..._27, ..._28, ..._29, - ..._30, + ..._136, + ..._155, + ..._175 + }; + export const clob = { ..._30, ..._31, ..._32, ..._33, @@ -223,166 +233,170 @@ export namespace dydxprotocol { ..._37, ..._38, ..._39, - ..._132, - ..._150, - ..._169 + ..._40, + ..._41, + ..._42, + ..._43, + ..._137, + ..._156, + ..._176 }; export namespace daemons { - export const bridge = { ..._40 + export const bridge = { ..._44 }; - export const liquidation = { ..._41 + export const liquidation = { ..._45 }; - export const pricefeed = { ..._42 + export const pricefeed = { ..._46 }; } - export const delaymsg = { ..._43, - ..._44, - ..._45, - ..._46, - ..._47, - ..._133, - ..._151, - ..._170 - }; - export const epochs = { ..._48, + export const delaymsg = { ..._47, + ..._48, ..._49, ..._50, - ..._134, - ..._152 + ..._51, + ..._138, + ..._157, + ..._177 }; - export const feetiers = { ..._51, - ..._52, + export const epochs = { ..._52, ..._53, ..._54, - ..._135, - ..._153, - ..._171 + ..._139, + ..._158 }; - export const govplus = { ..._55, + export const feetiers = { ..._55, ..._56, ..._57, - ..._154, - ..._172 + ..._58, + ..._140, + ..._159, + ..._178 + }; + export const govplus = { ..._59, + ..._60, + ..._61, + ..._160, + ..._179 }; export namespace indexer { - export const events = { ..._58 + export const events = { ..._62 }; - export const indexer_manager = { ..._59 + export const indexer_manager = { ..._63 }; - export const off_chain_updates = { ..._60 + export const off_chain_updates = { ..._64 }; export namespace protocol { - export const v1 = { ..._61, - ..._62, - ..._63 + export const v1 = { ..._65, + ..._66, + ..._67 }; } - export const redis = { ..._64 + export const redis = { ..._68 }; - export const shared = { ..._65 + export const shared = { ..._69 }; - export const socks = { ..._66 + export const socks = { ..._70 }; } - export const listing = { ..._67, - ..._68, - ..._69, - ..._70, - ..._136, - ..._155, - ..._173 - }; - export const perpetuals = { ..._71, + export const listing = { ..._71, ..._72, ..._73, ..._74, - ..._75, - ..._137, - ..._156, - ..._174 + ..._141, + ..._161, + ..._180 }; - export const prices = { ..._76, + export const perpetuals = { ..._75, + ..._76, ..._77, ..._78, ..._79, - ..._80, - ..._138, - ..._157, - ..._175 + ..._142, + ..._162, + ..._181 }; - export const ratelimit = { ..._81, + export const prices = { ..._80, + ..._81, ..._82, ..._83, ..._84, - ..._85, - ..._86, - ..._139, - ..._158, - ..._176 + ..._143, + ..._163, + ..._182 }; - export const revshare = { ..._87, + export const ratelimit = { ..._85, + ..._86, + ..._87, ..._88, ..._89, ..._90, - ..._91, - ..._140, - ..._159, - ..._177 + ..._144, + ..._164, + ..._183 }; - export const rewards = { ..._92, + export const revshare = { ..._91, + ..._92, ..._93, ..._94, ..._95, - ..._96, - ..._141, - ..._160, - ..._178 + ..._145, + ..._165, + ..._184 }; - export const sending = { ..._97, + export const rewards = { ..._96, + ..._97, ..._98, ..._99, ..._100, - ..._161, - ..._179 + ..._146, + ..._166, + ..._185 }; - export const stats = { ..._101, + export const sending = { ..._101, ..._102, ..._103, ..._104, - ..._105, - ..._142, - ..._162, - ..._180 + ..._167, + ..._186 }; - export const subaccounts = { ..._106, + export const stats = { ..._105, + ..._106, ..._107, ..._108, ..._109, - ..._110, - ..._111, - ..._143, - ..._163 + ..._147, + ..._168, + ..._187 }; - export const vault = { ..._112, + export const subaccounts = { ..._110, + ..._111, + ..._112, ..._113, ..._114, ..._115, - ..._116, - ..._117, - ..._144, - ..._164, - ..._181 + ..._148, + ..._169 }; - export const vest = { ..._118, + export const vault = { ..._116, + ..._117, + ..._118, ..._119, ..._120, ..._121, - ..._145, - ..._165, - ..._182 + ..._149, + ..._170, + ..._188 }; - export const ClientFactory = { ..._183, - ..._184, - ..._185 + export const vest = { ..._122, + ..._123, + ..._124, + ..._125, + ..._150, + ..._171, + ..._189 + }; + export const ClientFactory = { ..._190, + ..._191, + ..._192 }; } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts index 790d937a2e..dd77cee074 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/lcd.ts @@ -9,6 +9,9 @@ export const createLCDClient = async ({ }); return { dydxprotocol: { + accountplus: new (await import("./accountplus/query.lcd")).LCDQueryClient({ + requestClient + }), assets: new (await import("./assets/query.lcd")).LCDQueryClient({ requestClient }), diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts index 73541397db..dd9037fad1 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts @@ -9,6 +9,7 @@ export const createRPCQueryClient = async ({ const client = new QueryClient(tmClient); return { dydxprotocol: { + accountplus: (await import("./accountplus/query.rpc.Query")).createRpcQueryExtension(client), affiliates: (await import("./affiliates/query.rpc.Query")).createRpcQueryExtension(client), assets: (await import("./assets/query.rpc.Query")).createRpcQueryExtension(client), blocktime: (await import("./blocktime/query.rpc.Query")).createRpcQueryExtension(client), diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts index 1c3eedfabc..cfddfb350c 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.tx.ts @@ -5,6 +5,7 @@ export const createRPCMsgClient = async ({ rpc: Rpc; }) => ({ dydxprotocol: { + accountplus: new (await import("./accountplus/tx.rpc.msg")).MsgClientImpl(rpc), affiliates: new (await import("./affiliates/tx.rpc.msg")).MsgClientImpl(rpc), blocktime: new (await import("./blocktime/tx.rpc.msg")).MsgClientImpl(rpc), bridge: new (await import("./bridge/tx.rpc.msg")).MsgClientImpl(rpc), diff --git a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts index 790ad9003a..795d06bc47 100644 --- a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts @@ -1,3 +1,3 @@ -import * as _122 from "./gogo"; -export const gogoproto = { ..._122 +import * as _126 from "./gogo"; +export const gogoproto = { ..._126 }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/google/bundle.ts b/indexer/packages/v4-protos/src/codegen/google/bundle.ts index 1ed0c78141..6c02be50fc 100644 --- a/indexer/packages/v4-protos/src/codegen/google/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/google/bundle.ts @@ -1,16 +1,16 @@ -import * as _123 from "./api/annotations"; -import * as _124 from "./api/http"; -import * as _125 from "./protobuf/descriptor"; -import * as _126 from "./protobuf/duration"; -import * as _127 from "./protobuf/timestamp"; -import * as _128 from "./protobuf/any"; +import * as _127 from "./api/annotations"; +import * as _128 from "./api/http"; +import * as _129 from "./protobuf/descriptor"; +import * as _130 from "./protobuf/duration"; +import * as _131 from "./protobuf/timestamp"; +import * as _132 from "./protobuf/any"; export namespace google { - export const api = { ..._123, - ..._124 - }; - export const protobuf = { ..._125, - ..._126, - ..._127, + export const api = { ..._127, ..._128 }; + export const protobuf = { ..._129, + ..._130, + ..._131, + ..._132 + }; } \ No newline at end of file diff --git a/proto/dydxprotocol/accountplus/genesis.proto b/proto/dydxprotocol/accountplus/genesis.proto index 9358dca161..723893b855 100644 --- a/proto/dydxprotocol/accountplus/genesis.proto +++ b/proto/dydxprotocol/accountplus/genesis.proto @@ -3,10 +3,36 @@ package dydxprotocol.accountplus; import "gogoproto/gogo.proto"; import "dydxprotocol/accountplus/accountplus.proto"; +import "dydxprotocol/accountplus/models.proto"; +import "dydxprotocol/accountplus/params.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types"; +// AuthenticatorData represents a genesis exported account with Authenticators. +// The address is used as the key, and the account authenticators are stored in +// the authenticators field. +message AuthenticatorData { + // address is an account address, one address can have many authenticators + string address = 1; + + // authenticators are the account's authenticators, these can be multiple + // types including SignatureVerification, AllOfs, CosmWasmAuthenticators, etc + repeated AccountAuthenticator authenticators = 2 + [ (gogoproto.nullable) = false ]; +} + // Module genesis state message GenesisState { repeated AccountState accounts = 1 [ (gogoproto.nullable) = false ]; + + // params define the parameters for the authenticator module. + Params params = 2 [ (gogoproto.nullable) = false ]; + + // next_authenticator_id is the next available authenticator ID. + uint64 next_authenticator_id = 3; + + // authenticator_data contains the data for multiple accounts, each with their + // authenticators. + repeated AuthenticatorData authenticator_data = 4 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/dydxprotocol/accountplus/models.proto b/proto/dydxprotocol/accountplus/models.proto new file mode 100644 index 0000000000..50ff3732b7 --- /dev/null +++ b/proto/dydxprotocol/accountplus/models.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package dydxprotocol.accountplus; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types"; + +// AccountAuthenticator represents a foundational model for all authenticators. +// It provides extensibility by allowing concrete types to interpret and +// validate transactions based on the encapsulated data. +message AccountAuthenticator { + // ID uniquely identifies the authenticator instance. + uint64 id = 1; + + // Type specifies the category of the AccountAuthenticator. + // This type information is essential for differentiating authenticators + // and ensuring precise data retrieval from the storage layer. + string type = 2; + + // Config is a versatile field used in conjunction with the specific type of + // account authenticator to facilitate complex authentication processes. + // The interpretation of this field is overloaded, enabling multiple + // authenticators to utilize it for their respective purposes. + bytes config = 3; +} diff --git a/proto/dydxprotocol/accountplus/params.proto b/proto/dydxprotocol/accountplus/params.proto new file mode 100644 index 0000000000..673b71d6fd --- /dev/null +++ b/proto/dydxprotocol/accountplus/params.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package dydxprotocol.accountplus; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types"; + +// Params defines the parameters for the module. +message Params { + // IsSmartAccountActive defines the state of the authenticator. + // If set to false, the authenticator module will not be used + // and the classic cosmos sdk authentication will be used instead. + bool is_smart_account_active = 1 + [ (gogoproto.moretags) = "yaml:\"is_smart_account_active\"" ]; +} diff --git a/proto/dydxprotocol/accountplus/query.proto b/proto/dydxprotocol/accountplus/query.proto new file mode 100644 index 0000000000..5314055957 --- /dev/null +++ b/proto/dydxprotocol/accountplus/query.proto @@ -0,0 +1,59 @@ +syntax = "proto3"; +package dydxprotocol.accountplus; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "dydxprotocol/accountplus/models.proto"; +import "dydxprotocol/accountplus/params.proto"; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/dydxprotocol/accountplus/params"; + } + + // Queries a single authenticator by account and authenticator ID. + rpc GetAuthenticator(GetAuthenticatorRequest) + returns (GetAuthenticatorResponse) { + option (google.api.http).get = + "/dydxprotocol/accountplus/authenticator/{account}/{authenticator_id}"; + } + + // Queries all authenticators for a given account. + rpc GetAuthenticators(GetAuthenticatorsRequest) + returns (GetAuthenticatorsResponse) { + option (google.api.http).get = + "/dydxprotocol/accountplus/authenticators/{account}"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// MsgGetAuthenticatorsRequest defines the Msg/GetAuthenticators request type. +message GetAuthenticatorsRequest { string account = 1; } + +// MsgGetAuthenticatorsResponse defines the Msg/GetAuthenticators response type. +message GetAuthenticatorsResponse { + repeated AccountAuthenticator account_authenticators = 1; +} + +// MsgGetAuthenticatorRequest defines the Msg/GetAuthenticator request type. +message GetAuthenticatorRequest { + string account = 1; + uint64 authenticator_id = 2; +} + +// MsgGetAuthenticatorResponse defines the Msg/GetAuthenticator response type. +message GetAuthenticatorResponse { + AccountAuthenticator account_authenticator = 1; +} diff --git a/proto/dydxprotocol/accountplus/tx.proto b/proto/dydxprotocol/accountplus/tx.proto new file mode 100644 index 0000000000..9f901688d2 --- /dev/null +++ b/proto/dydxprotocol/accountplus/tx.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package dydxprotocol.accountplus; + +import "cosmos/msg/v1/msg.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/accountplus/types"; + +// Msg defines the Msg service. +service Msg { + // AddAuthenticator adds an authenticator to an account. + rpc AddAuthenticator(MsgAddAuthenticator) + returns (MsgAddAuthenticatorResponse); + // RemoveAuthenticator removes an authenticator from an account. + rpc RemoveAuthenticator(MsgRemoveAuthenticator) + returns (MsgRemoveAuthenticatorResponse); + + // SetActiveState sets the active state of the authenticator. + // Primarily used for circuit breaking. + rpc SetActiveState(MsgSetActiveState) returns (MsgSetActiveStateResponse); +} + +// MsgAddAuthenticatorRequest defines the Msg/AddAuthenticator request type. +message MsgAddAuthenticator { + option (amino.name) = "dydxprotocol/accountplus/add-authenticator"; + option (cosmos.msg.v1.signer) = "sender"; + + string sender = 1; + string authenticator_type = 2; + bytes data = 3; +} + +// MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. +message MsgAddAuthenticatorResponse { bool success = 1; } + +// MsgRemoveAuthenticatorRequest defines the Msg/RemoveAuthenticator request +// type. +message MsgRemoveAuthenticator { + option (amino.name) = "dydxprotocol/accountplus/remove-authenticator"; + option (cosmos.msg.v1.signer) = "sender"; + + string sender = 1; + uint64 id = 2; +} + +// MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response +// type. +message MsgRemoveAuthenticatorResponse { bool success = 1; } + +// MsgSetActiveState sets the active state of the module. +message MsgSetActiveState { + option (amino.name) = "osmosis/smartaccount/set-active-state"; + option (cosmos.msg.v1.signer) = "sender"; + + string sender = 1; + bool active = 2; +} + +// MsgSetActiveStateResponse defines the Msg/SetActiveState response type. +message MsgSetActiveStateResponse {} + +// TxExtension allows for additional authenticator-specific data in +// transactions. +message TxExtension { + // selected_authenticators holds the authenticator_id for the chosen + // authenticator per message. + repeated uint64 selected_authenticators = 1; +} diff --git a/protocol/app/testdata/default_genesis_state.json b/protocol/app/testdata/default_genesis_state.json index bc6e831c7b..970ae13312 100644 --- a/protocol/app/testdata/default_genesis_state.json +++ b/protocol/app/testdata/default_genesis_state.json @@ -129,7 +129,12 @@ "validator_slash_events": [] }, "dydxaccountplus": { - "accounts": [] + "accounts": [], + "params": { + "is_smart_account_active": false + }, + "next_authenticator_id": "0", + "authenticator_data": [] }, "epochs": { "epoch_info_list": [ diff --git a/protocol/scripts/genesis/sample_pregenesis.json b/protocol/scripts/genesis/sample_pregenesis.json index 1ddea18c1a..5925ef792a 100644 --- a/protocol/scripts/genesis/sample_pregenesis.json +++ b/protocol/scripts/genesis/sample_pregenesis.json @@ -638,7 +638,12 @@ "validator_slash_events": [] }, "dydxaccountplus": { - "accounts": [] + "accounts": [], + "authenticator_data": [], + "next_authenticator_id": "0", + "params": { + "is_smart_account_active": false + } }, "epochs": { "epoch_info_list": [ diff --git a/protocol/x/accountplus/types/genesis.pb.go b/protocol/x/accountplus/types/genesis.pb.go index 13a13d224e..476dd31f5e 100644 --- a/protocol/x/accountplus/types/genesis.pb.go +++ b/protocol/x/accountplus/types/genesis.pb.go @@ -23,16 +23,81 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// AuthenticatorData represents a genesis exported account with Authenticators. +// The address is used as the key, and the account authenticators are stored in +// the authenticators field. +type AuthenticatorData struct { + // address is an account address, one address can have many authenticators + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // authenticators are the account's authenticators, these can be multiple + // types including SignatureVerification, AllOfs, CosmWasmAuthenticators, etc + Authenticators []AccountAuthenticator `protobuf:"bytes,2,rep,name=authenticators,proto3" json:"authenticators"` +} + +func (m *AuthenticatorData) Reset() { *m = AuthenticatorData{} } +func (m *AuthenticatorData) String() string { return proto.CompactTextString(m) } +func (*AuthenticatorData) ProtoMessage() {} +func (*AuthenticatorData) Descriptor() ([]byte, []int) { + return fileDescriptor_03516b8fa43b3a59, []int{0} +} +func (m *AuthenticatorData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AuthenticatorData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AuthenticatorData.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AuthenticatorData) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthenticatorData.Merge(m, src) +} +func (m *AuthenticatorData) XXX_Size() int { + return m.Size() +} +func (m *AuthenticatorData) XXX_DiscardUnknown() { + xxx_messageInfo_AuthenticatorData.DiscardUnknown(m) +} + +var xxx_messageInfo_AuthenticatorData proto.InternalMessageInfo + +func (m *AuthenticatorData) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *AuthenticatorData) GetAuthenticators() []AccountAuthenticator { + if m != nil { + return m.Authenticators + } + return nil +} + // Module genesis state type GenesisState struct { Accounts []AccountState `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts"` + // params define the parameters for the authenticator module. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` + // next_authenticator_id is the next available authenticator ID. + NextAuthenticatorId uint64 `protobuf:"varint,3,opt,name=next_authenticator_id,json=nextAuthenticatorId,proto3" json:"next_authenticator_id,omitempty"` + // authenticator_data contains the data for multiple accounts, each with their + // authenticators. + AuthenticatorData []AuthenticatorData `protobuf:"bytes,4,rep,name=authenticator_data,json=authenticatorData,proto3" json:"authenticator_data"` } func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_03516b8fa43b3a59, []int{0} + return fileDescriptor_03516b8fa43b3a59, []int{1} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -68,7 +133,29 @@ func (m *GenesisState) GetAccounts() []AccountState { return nil } +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetNextAuthenticatorId() uint64 { + if m != nil { + return m.NextAuthenticatorId + } + return 0 +} + +func (m *GenesisState) GetAuthenticatorData() []AuthenticatorData { + if m != nil { + return m.AuthenticatorData + } + return nil +} + func init() { + proto.RegisterType((*AuthenticatorData)(nil), "dydxprotocol.accountplus.AuthenticatorData") proto.RegisterType((*GenesisState)(nil), "dydxprotocol.accountplus.GenesisState") } @@ -77,20 +164,74 @@ func init() { } var fileDescriptor_03516b8fa43b3a59 = []byte{ - // 202 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4b, 0xa9, 0x4c, 0xa9, - 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, - 0x29, 0xc8, 0x29, 0x2d, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x03, 0x4b, 0x0a, - 0x49, 0x20, 0xab, 0xd3, 0x43, 0x52, 0x27, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd1, 0x07, - 0xb1, 0x20, 0xea, 0xa5, 0xb4, 0x70, 0x9a, 0x8b, 0xc4, 0x86, 0xa8, 0x55, 0x8a, 0xe0, 0xe2, 0x71, - 0x87, 0x58, 0x16, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0xe4, 0xc1, 0xc5, 0x01, 0x55, 0x54, 0x2c, 0xc1, - 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, 0xa6, 0x87, 0xcb, 0x7a, 0x3d, 0x47, 0x08, 0x1b, 0xac, 0xd3, - 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xb8, 0x6e, 0xa7, 0xf0, 0x13, 0x8f, 0xe4, 0x18, 0x2f, - 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, - 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xb2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, - 0xd5, 0x47, 0x71, 0x6a, 0x99, 0x89, 0x6e, 0x72, 0x46, 0x62, 0x66, 0x9e, 0x3e, 0x5c, 0xa4, 0x02, - 0xc5, 0xf9, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x59, 0x63, 0x40, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xfa, 0x84, 0x6b, 0x24, 0x3f, 0x01, 0x00, 0x00, + // 362 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x4a, 0xf3, 0x40, + 0x14, 0x85, 0x33, 0x6d, 0xe9, 0xff, 0x3b, 0x15, 0xa1, 0xa3, 0xc2, 0xd0, 0x45, 0x0c, 0x05, 0x4b, + 0x50, 0x4c, 0xa0, 0xba, 0x55, 0xa8, 0x08, 0xea, 0x4e, 0xea, 0x42, 0x10, 0xa1, 0x4e, 0x33, 0x43, + 0x1a, 0x68, 0x33, 0x21, 0x33, 0x91, 0xf6, 0x19, 0xdc, 0xf8, 0x24, 0x3e, 0x47, 0x97, 0x5d, 0xba, + 0x12, 0x69, 0x5e, 0x44, 0x92, 0x8c, 0x25, 0xa9, 0xc4, 0xee, 0x6e, 0x72, 0xbe, 0x7b, 0xee, 0x3d, + 0xc9, 0x85, 0x1d, 0x3a, 0xa3, 0xd3, 0x20, 0xe4, 0x92, 0x3b, 0x7c, 0x6c, 0x13, 0xc7, 0xe1, 0x91, + 0x2f, 0x83, 0x71, 0x24, 0x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x71, 0xfc, 0x47, 0x8e, 0xf5, + 0xff, 0xa1, 0x56, 0x69, 0x92, 0x5f, 0xc2, 0xc3, 0x7c, 0xa9, 0x83, 0xc5, 0x52, 0x07, 0x5f, 0x4b, + 0x1d, 0xbc, 0xc5, 0xba, 0xb6, 0x88, 0x75, 0xed, 0x23, 0xd6, 0xb5, 0xc7, 0x73, 0xd7, 0x93, 0xa3, + 0x68, 0x68, 0x39, 0x7c, 0x62, 0x17, 0x4e, 0xe1, 0xe5, 0xec, 0xc4, 0x19, 0x11, 0xcf, 0xb7, 0x57, + 0x6f, 0xa6, 0x85, 0xf3, 0x90, 0xb3, 0x80, 0x89, 0x61, 0x3d, 0x55, 0x4f, 0xbf, 0x03, 0x00, 0x00, + 0xff, 0xff, 0xda, 0x60, 0x35, 0x04, 0xf2, 0x02, 0x00, 0x00, +} + +func (m *AuthenticatorData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AuthenticatorData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthenticatorData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Authenticators) > 0 { + for iNdEx := len(m.Authenticators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Authenticators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -113,6 +254,35 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AuthenticatorData) > 0 { + for iNdEx := len(m.AuthenticatorData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AuthenticatorData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.NextAuthenticatorId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NextAuthenticatorId)) + i-- + dAtA[i] = 0x18 + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if len(m.Accounts) > 0 { for iNdEx := len(m.Accounts) - 1; iNdEx >= 0; iNdEx-- { { @@ -141,6 +311,25 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *AuthenticatorData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Authenticators) > 0 { + for _, e := range m.Authenticators { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -153,6 +342,17 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if m.NextAuthenticatorId != 0 { + n += 1 + sovGenesis(uint64(m.NextAuthenticatorId)) + } + if len(m.AuthenticatorData) > 0 { + for _, e := range m.AuthenticatorData { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -162,6 +362,122 @@ func sovGenesis(x uint64) (n int) { func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *AuthenticatorData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AuthenticatorData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AuthenticatorData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authenticators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authenticators = append(m.Authenticators, AccountAuthenticator{}) + if err := m.Authenticators[len(m.Authenticators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -225,6 +541,92 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextAuthenticatorId", wireType) + } + m.NextAuthenticatorId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NextAuthenticatorId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthenticatorData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthenticatorData = append(m.AuthenticatorData, AuthenticatorData{}) + if err := m.AuthenticatorData[len(m.AuthenticatorData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/protocol/x/accountplus/types/models.pb.go b/protocol/x/accountplus/types/models.pb.go new file mode 100644 index 0000000000..86a51934d9 --- /dev/null +++ b/protocol/x/accountplus/types/models.pb.go @@ -0,0 +1,418 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/accountplus/models.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// AccountAuthenticator represents a foundational model for all authenticators. +// It provides extensibility by allowing concrete types to interpret and +// validate transactions based on the encapsulated data. +type AccountAuthenticator struct { + // ID uniquely identifies the authenticator instance. + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // Type specifies the category of the AccountAuthenticator. + // This type information is essential for differentiating authenticators + // and ensuring precise data retrieval from the storage layer. + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + // Config is a versatile field used in conjunction with the specific type of + // account authenticator to facilitate complex authentication processes. + // The interpretation of this field is overloaded, enabling multiple + // authenticators to utilize it for their respective purposes. + Config []byte `protobuf:"bytes,3,opt,name=config,proto3" json:"config,omitempty"` +} + +func (m *AccountAuthenticator) Reset() { *m = AccountAuthenticator{} } +func (m *AccountAuthenticator) String() string { return proto.CompactTextString(m) } +func (*AccountAuthenticator) ProtoMessage() {} +func (*AccountAuthenticator) Descriptor() ([]byte, []int) { + return fileDescriptor_14404dbe8eb22d3f, []int{0} +} +func (m *AccountAuthenticator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AccountAuthenticator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AccountAuthenticator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AccountAuthenticator) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccountAuthenticator.Merge(m, src) +} +func (m *AccountAuthenticator) XXX_Size() int { + return m.Size() +} +func (m *AccountAuthenticator) XXX_DiscardUnknown() { + xxx_messageInfo_AccountAuthenticator.DiscardUnknown(m) +} + +var xxx_messageInfo_AccountAuthenticator proto.InternalMessageInfo + +func (m *AccountAuthenticator) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *AccountAuthenticator) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *AccountAuthenticator) GetConfig() []byte { + if m != nil { + return m.Config + } + return nil +} + +func init() { + proto.RegisterType((*AccountAuthenticator)(nil), "dydxprotocol.accountplus.AccountAuthenticator") +} + +func init() { + proto.RegisterFile("dydxprotocol/accountplus/models.proto", fileDescriptor_14404dbe8eb22d3f) +} + +var fileDescriptor_14404dbe8eb22d3f = []byte{ + // 204 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xa9, 0x4c, 0xa9, + 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, + 0x29, 0xc8, 0x29, 0x2d, 0xd6, 0xcf, 0xcd, 0x4f, 0x49, 0xcd, 0x29, 0xd6, 0x03, 0xcb, 0x09, 0x49, + 0x20, 0x2b, 0xd3, 0x43, 0x52, 0xa6, 0x14, 0xc4, 0x25, 0xe2, 0x08, 0xe1, 0x3a, 0x96, 0x96, 0x64, + 0xa4, 0xe6, 0x95, 0x64, 0x26, 0x27, 0x96, 0xe4, 0x17, 0x09, 0xf1, 0x71, 0x31, 0x65, 0xa6, 0x48, + 0x30, 0x2a, 0x30, 0x6a, 0xb0, 0x04, 0x31, 0x65, 0xa6, 0x08, 0x09, 0x71, 0xb1, 0x94, 0x54, 0x16, + 0xa4, 0x4a, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x06, 0x81, 0xd9, 0x42, 0x62, 0x5c, 0x6c, 0xc9, 0xf9, + 0x79, 0x69, 0x99, 0xe9, 0x12, 0xcc, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x50, 0x9e, 0x53, 0xf8, 0x89, + 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, + 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xd9, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, + 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xa3, 0xb8, 0xbc, 0xcc, 0x44, 0x37, 0x39, 0x23, 0x31, 0x33, 0x4f, + 0x1f, 0x2e, 0x52, 0x81, 0xe2, 0x1b, 0x90, 0x7d, 0xc5, 0x49, 0x6c, 0x60, 0x59, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xa0, 0x32, 0xd3, 0x28, 0xf6, 0x00, 0x00, 0x00, +} + +func (m *AccountAuthenticator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AccountAuthenticator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AccountAuthenticator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Config) > 0 { + i -= len(m.Config) + copy(dAtA[i:], m.Config) + i = encodeVarintModels(dAtA, i, uint64(len(m.Config))) + i-- + dAtA[i] = 0x1a + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintModels(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x12 + } + if m.Id != 0 { + i = encodeVarintModels(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintModels(dAtA []byte, offset int, v uint64) int { + offset -= sovModels(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AccountAuthenticator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovModels(uint64(m.Id)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + l = len(m.Config) + if l > 0 { + n += 1 + l + sovModels(uint64(l)) + } + return n +} + +func sovModels(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozModels(x uint64) (n int) { + return sovModels(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AccountAuthenticator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AccountAuthenticator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AccountAuthenticator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowModels + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthModels + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthModels + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Config = append(m.Config[:0], dAtA[iNdEx:postIndex]...) + if m.Config == nil { + m.Config = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipModels(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthModels + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipModels(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModels + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModels + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowModels + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthModels + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupModels + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthModels + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthModels = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowModels = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupModels = fmt.Errorf("proto: unexpected end of group") +) diff --git a/protocol/x/accountplus/types/params.pb.go b/protocol/x/accountplus/types/params.pb.go new file mode 100644 index 0000000000..18da286443 --- /dev/null +++ b/protocol/x/accountplus/types/params.pb.go @@ -0,0 +1,315 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/accountplus/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + // IsSmartAccountActive defines the state of the authenticator. + // If set to false, the authenticator module will not be used + // and the classic cosmos sdk authentication will be used instead. + IsSmartAccountActive bool `protobuf:"varint,1,opt,name=is_smart_account_active,json=isSmartAccountActive,proto3" json:"is_smart_account_active,omitempty" yaml:"is_smart_account_active"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_7db9dd150a39c6af, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetIsSmartAccountActive() bool { + if m != nil { + return m.IsSmartAccountActive + } + return false +} + +func init() { + proto.RegisterType((*Params)(nil), "dydxprotocol.accountplus.Params") +} + +func init() { + proto.RegisterFile("dydxprotocol/accountplus/params.proto", fileDescriptor_7db9dd150a39c6af) +} + +var fileDescriptor_7db9dd150a39c6af = []byte{ + // 210 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xa9, 0x4c, 0xa9, + 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, + 0x29, 0xc8, 0x29, 0x2d, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x03, 0xcb, 0x09, 0x49, + 0x20, 0x2b, 0xd3, 0x43, 0x52, 0x26, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x96, 0xd1, 0x07, 0xb1, + 0x20, 0xea, 0x95, 0x92, 0xb9, 0xd8, 0x02, 0xc0, 0xfa, 0x85, 0x22, 0xb9, 0xc4, 0x33, 0x8b, 0xe3, + 0x8b, 0x73, 0x13, 0x8b, 0x4a, 0xe2, 0xa1, 0xfa, 0xe2, 0x13, 0x93, 0x4b, 0x32, 0xcb, 0x52, 0x25, + 0x18, 0x15, 0x18, 0x35, 0x38, 0x9c, 0x94, 0x3e, 0xdd, 0x93, 0x97, 0xab, 0x4c, 0xcc, 0xcd, 0xb1, + 0x52, 0xc2, 0xa1, 0x50, 0x29, 0x48, 0x24, 0xb3, 0x38, 0x18, 0x24, 0xe1, 0x08, 0x11, 0x77, 0x04, + 0x0b, 0x3b, 0x85, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, + 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x6d, 0x7a, + 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x8a, 0x07, 0xcb, 0x4c, 0x74, 0x93, + 0x33, 0x12, 0x33, 0xf3, 0xf4, 0xe1, 0x22, 0x15, 0x28, 0x9e, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, + 0x62, 0x03, 0xcb, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x37, 0xad, 0x40, 0x1a, 0x1d, 0x01, + 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsSmartAccountActive { + i-- + if m.IsSmartAccountActive { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IsSmartAccountActive { + n += 2 + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSmartAccountActive", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSmartAccountActive = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/protocol/x/accountplus/types/query.pb.go b/protocol/x/accountplus/types/query.pb.go new file mode 100644 index 0000000000..f850e057f1 --- /dev/null +++ b/protocol/x/accountplus/types/query.pb.go @@ -0,0 +1,1365 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/accountplus/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3beaace7ec4b0b78, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3beaace7ec4b0b78, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgGetAuthenticatorsRequest defines the Msg/GetAuthenticators request type. +type GetAuthenticatorsRequest struct { + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (m *GetAuthenticatorsRequest) Reset() { *m = GetAuthenticatorsRequest{} } +func (m *GetAuthenticatorsRequest) String() string { return proto.CompactTextString(m) } +func (*GetAuthenticatorsRequest) ProtoMessage() {} +func (*GetAuthenticatorsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3beaace7ec4b0b78, []int{2} +} +func (m *GetAuthenticatorsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetAuthenticatorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetAuthenticatorsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetAuthenticatorsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetAuthenticatorsRequest.Merge(m, src) +} +func (m *GetAuthenticatorsRequest) XXX_Size() int { + return m.Size() +} +func (m *GetAuthenticatorsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetAuthenticatorsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetAuthenticatorsRequest proto.InternalMessageInfo + +func (m *GetAuthenticatorsRequest) GetAccount() string { + if m != nil { + return m.Account + } + return "" +} + +// MsgGetAuthenticatorsResponse defines the Msg/GetAuthenticators response type. +type GetAuthenticatorsResponse struct { + AccountAuthenticators []*AccountAuthenticator `protobuf:"bytes,1,rep,name=account_authenticators,json=accountAuthenticators,proto3" json:"account_authenticators,omitempty"` +} + +func (m *GetAuthenticatorsResponse) Reset() { *m = GetAuthenticatorsResponse{} } +func (m *GetAuthenticatorsResponse) String() string { return proto.CompactTextString(m) } +func (*GetAuthenticatorsResponse) ProtoMessage() {} +func (*GetAuthenticatorsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3beaace7ec4b0b78, []int{3} +} +func (m *GetAuthenticatorsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetAuthenticatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetAuthenticatorsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetAuthenticatorsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetAuthenticatorsResponse.Merge(m, src) +} +func (m *GetAuthenticatorsResponse) XXX_Size() int { + return m.Size() +} +func (m *GetAuthenticatorsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetAuthenticatorsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetAuthenticatorsResponse proto.InternalMessageInfo + +func (m *GetAuthenticatorsResponse) GetAccountAuthenticators() []*AccountAuthenticator { + if m != nil { + return m.AccountAuthenticators + } + return nil +} + +// MsgGetAuthenticatorRequest defines the Msg/GetAuthenticator request type. +type GetAuthenticatorRequest struct { + Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + AuthenticatorId uint64 `protobuf:"varint,2,opt,name=authenticator_id,json=authenticatorId,proto3" json:"authenticator_id,omitempty"` +} + +func (m *GetAuthenticatorRequest) Reset() { *m = GetAuthenticatorRequest{} } +func (m *GetAuthenticatorRequest) String() string { return proto.CompactTextString(m) } +func (*GetAuthenticatorRequest) ProtoMessage() {} +func (*GetAuthenticatorRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_3beaace7ec4b0b78, []int{4} +} +func (m *GetAuthenticatorRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetAuthenticatorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetAuthenticatorRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetAuthenticatorRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetAuthenticatorRequest.Merge(m, src) +} +func (m *GetAuthenticatorRequest) XXX_Size() int { + return m.Size() +} +func (m *GetAuthenticatorRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetAuthenticatorRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetAuthenticatorRequest proto.InternalMessageInfo + +func (m *GetAuthenticatorRequest) GetAccount() string { + if m != nil { + return m.Account + } + return "" +} + +func (m *GetAuthenticatorRequest) GetAuthenticatorId() uint64 { + if m != nil { + return m.AuthenticatorId + } + return 0 +} + +// MsgGetAuthenticatorResponse defines the Msg/GetAuthenticator response type. +type GetAuthenticatorResponse struct { + AccountAuthenticator *AccountAuthenticator `protobuf:"bytes,1,opt,name=account_authenticator,json=accountAuthenticator,proto3" json:"account_authenticator,omitempty"` +} + +func (m *GetAuthenticatorResponse) Reset() { *m = GetAuthenticatorResponse{} } +func (m *GetAuthenticatorResponse) String() string { return proto.CompactTextString(m) } +func (*GetAuthenticatorResponse) ProtoMessage() {} +func (*GetAuthenticatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3beaace7ec4b0b78, []int{5} +} +func (m *GetAuthenticatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetAuthenticatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetAuthenticatorResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetAuthenticatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetAuthenticatorResponse.Merge(m, src) +} +func (m *GetAuthenticatorResponse) XXX_Size() int { + return m.Size() +} +func (m *GetAuthenticatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetAuthenticatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetAuthenticatorResponse proto.InternalMessageInfo + +func (m *GetAuthenticatorResponse) GetAccountAuthenticator() *AccountAuthenticator { + if m != nil { + return m.AccountAuthenticator + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "dydxprotocol.accountplus.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "dydxprotocol.accountplus.QueryParamsResponse") + proto.RegisterType((*GetAuthenticatorsRequest)(nil), "dydxprotocol.accountplus.GetAuthenticatorsRequest") + proto.RegisterType((*GetAuthenticatorsResponse)(nil), "dydxprotocol.accountplus.GetAuthenticatorsResponse") + proto.RegisterType((*GetAuthenticatorRequest)(nil), "dydxprotocol.accountplus.GetAuthenticatorRequest") + proto.RegisterType((*GetAuthenticatorResponse)(nil), "dydxprotocol.accountplus.GetAuthenticatorResponse") +} + +func init() { + proto.RegisterFile("dydxprotocol/accountplus/query.proto", fileDescriptor_3beaace7ec4b0b78) +} + +var fileDescriptor_3beaace7ec4b0b78 = []byte{ + // 486 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x41, 0x6b, 0xd4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f, 0xd2, 0x08, 0x85, 0x1c, 0xe8, + 0xd6, 0x21, 0x39, 0x98, 0x0f, 0xff, 0x10, 0x7d, 0x07, 0xf0, 0xfa, 0xc2, 0x2d, 0xa3, 0x06, 0xba, + 0x66, 0x8f, 0xbd, 0xd9, 0x88, 0xa3, 0xcd, 0x3c, 0x56, 0x66, 0x06, 0xc8, 0xbb, 0xa0, 0x19, 0xf1, + 0xdf, 0xcd, 0xf6, 0xbb, 0xe3, 0x89, 0x0d, 0x4e, 0x26, 0x36, 0xf8, 0x33, 0xb1, 0xc1, 0x97, 0xa9, + 0xdd, 0x3a, 0x99, 0xda, 0xad, 0x5f, 0x53, 0xbb, 0xf5, 0xfe, 0x49, 0x14, 0xcb, 0x61, 0xb1, 0xeb, + 0x06, 0x7c, 0x64, 0xce, 0xfd, 0x38, 0xd8, 0x08, 0x86, 0x34, 0x4e, 0xc9, 0xac, 0xb2, 0x6f, 0xec, + 0x92, 0xe3, 0x8c, 0x89, 0xdd, 0x8e, 0xea, 0x6e, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x3e, + 0x4f, 0x88, 0x4d, 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a single authenticator by account and authenticator ID. + GetAuthenticator(ctx context.Context, in *GetAuthenticatorRequest, opts ...grpc.CallOption) (*GetAuthenticatorResponse, error) + // Queries all authenticators for a given account. + GetAuthenticators(ctx context.Context, in *GetAuthenticatorsRequest, opts ...grpc.CallOption) (*GetAuthenticatorsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.accountplus.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetAuthenticator(ctx context.Context, in *GetAuthenticatorRequest, opts ...grpc.CallOption) (*GetAuthenticatorResponse, error) { + out := new(GetAuthenticatorResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.accountplus.Query/GetAuthenticator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetAuthenticators(ctx context.Context, in *GetAuthenticatorsRequest, opts ...grpc.CallOption) (*GetAuthenticatorsResponse, error) { + out := new(GetAuthenticatorsResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.accountplus.Query/GetAuthenticators", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a single authenticator by account and authenticator ID. + GetAuthenticator(context.Context, *GetAuthenticatorRequest) (*GetAuthenticatorResponse, error) + // Queries all authenticators for a given account. + GetAuthenticators(context.Context, *GetAuthenticatorsRequest) (*GetAuthenticatorsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) GetAuthenticator(ctx context.Context, req *GetAuthenticatorRequest) (*GetAuthenticatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAuthenticator not implemented") +} +func (*UnimplementedQueryServer) GetAuthenticators(ctx context.Context, req *GetAuthenticatorsRequest) (*GetAuthenticatorsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAuthenticators not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.accountplus.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetAuthenticator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAuthenticatorRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetAuthenticator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.accountplus.Query/GetAuthenticator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetAuthenticator(ctx, req.(*GetAuthenticatorRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetAuthenticators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetAuthenticatorsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetAuthenticators(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.accountplus.Query/GetAuthenticators", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetAuthenticators(ctx, req.(*GetAuthenticatorsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dydxprotocol.accountplus.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "GetAuthenticator", + Handler: _Query_GetAuthenticator_Handler, + }, + { + MethodName: "GetAuthenticators", + Handler: _Query_GetAuthenticators_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dydxprotocol/accountplus/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *GetAuthenticatorsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetAuthenticatorsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetAuthenticatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetAuthenticatorsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetAuthenticatorsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetAuthenticatorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AccountAuthenticators) > 0 { + for iNdEx := len(m.AccountAuthenticators) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AccountAuthenticators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *GetAuthenticatorRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetAuthenticatorRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetAuthenticatorRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AuthenticatorId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.AuthenticatorId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Account) > 0 { + i -= len(m.Account) + copy(dAtA[i:], m.Account) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Account))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetAuthenticatorResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetAuthenticatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetAuthenticatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AccountAuthenticator != nil { + { + size, err := m.AccountAuthenticator.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *GetAuthenticatorsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Account) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *GetAuthenticatorsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AccountAuthenticators) > 0 { + for _, e := range m.AccountAuthenticators { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *GetAuthenticatorRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Account) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.AuthenticatorId != 0 { + n += 1 + sovQuery(uint64(m.AuthenticatorId)) + } + return n +} + +func (m *GetAuthenticatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AccountAuthenticator != nil { + l = m.AccountAuthenticator.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetAuthenticatorsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetAuthenticatorsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetAuthenticatorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetAuthenticatorsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetAuthenticatorsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetAuthenticatorsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountAuthenticators", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccountAuthenticators = append(m.AccountAuthenticators, &AccountAuthenticator{}) + if err := m.AccountAuthenticators[len(m.AccountAuthenticators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetAuthenticatorRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetAuthenticatorRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetAuthenticatorRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Account = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthenticatorId", wireType) + } + m.AuthenticatorId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuthenticatorId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetAuthenticatorResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetAuthenticatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetAuthenticatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountAuthenticator", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AccountAuthenticator == nil { + m.AccountAuthenticator = &AccountAuthenticator{} + } + if err := m.AccountAuthenticator.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/protocol/x/accountplus/types/query.pb.gw.go b/protocol/x/accountplus/types/query.pb.gw.go new file mode 100644 index 0000000000..490d4e2343 --- /dev/null +++ b/protocol/x/accountplus/types/query.pb.gw.go @@ -0,0 +1,377 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: dydxprotocol/accountplus/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetAuthenticator_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAuthenticatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account") + } + + protoReq.Account, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account", err) + } + + val, ok = pathParams["authenticator_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "authenticator_id") + } + + protoReq.AuthenticatorId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "authenticator_id", err) + } + + msg, err := client.GetAuthenticator(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetAuthenticator_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAuthenticatorRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account") + } + + protoReq.Account, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account", err) + } + + val, ok = pathParams["authenticator_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "authenticator_id") + } + + protoReq.AuthenticatorId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "authenticator_id", err) + } + + msg, err := server.GetAuthenticator(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetAuthenticators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAuthenticatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account") + } + + protoReq.Account, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account", err) + } + + msg, err := client.GetAuthenticators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetAuthenticators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetAuthenticatorsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account") + } + + protoReq.Account, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account", err) + } + + msg, err := server.GetAuthenticators(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetAuthenticator_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetAuthenticator_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAuthenticator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetAuthenticators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetAuthenticators_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAuthenticators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetAuthenticator_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetAuthenticator_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAuthenticator_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetAuthenticators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetAuthenticators_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetAuthenticators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"dydxprotocol", "accountplus", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetAuthenticator_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"dydxprotocol", "accountplus", "authenticator", "account", "authenticator_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GetAuthenticators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"dydxprotocol", "accountplus", "authenticators", "account"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_GetAuthenticator_0 = runtime.ForwardResponseMessage + + forward_Query_GetAuthenticators_0 = runtime.ForwardResponseMessage +) diff --git a/protocol/x/accountplus/types/tx.pb.go b/protocol/x/accountplus/types/tx.pb.go new file mode 100644 index 0000000000..7f908acf0f --- /dev/null +++ b/protocol/x/accountplus/types/tx.pb.go @@ -0,0 +1,1702 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/accountplus/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgAddAuthenticatorRequest defines the Msg/AddAuthenticator request type. +type MsgAddAuthenticator struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + AuthenticatorType string `protobuf:"bytes,2,opt,name=authenticator_type,json=authenticatorType,proto3" json:"authenticator_type,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *MsgAddAuthenticator) Reset() { *m = MsgAddAuthenticator{} } +func (m *MsgAddAuthenticator) String() string { return proto.CompactTextString(m) } +func (*MsgAddAuthenticator) ProtoMessage() {} +func (*MsgAddAuthenticator) Descriptor() ([]byte, []int) { + return fileDescriptor_2d1c240983fd17d6, []int{0} +} +func (m *MsgAddAuthenticator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddAuthenticator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddAuthenticator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgAddAuthenticator) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddAuthenticator.Merge(m, src) +} +func (m *MsgAddAuthenticator) XXX_Size() int { + return m.Size() +} +func (m *MsgAddAuthenticator) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddAuthenticator.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddAuthenticator proto.InternalMessageInfo + +func (m *MsgAddAuthenticator) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgAddAuthenticator) GetAuthenticatorType() string { + if m != nil { + return m.AuthenticatorType + } + return "" +} + +func (m *MsgAddAuthenticator) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +// MsgAddAuthenticatorResponse defines the Msg/AddAuthenticator response type. +type MsgAddAuthenticatorResponse struct { + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` +} + +func (m *MsgAddAuthenticatorResponse) Reset() { *m = MsgAddAuthenticatorResponse{} } +func (m *MsgAddAuthenticatorResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddAuthenticatorResponse) ProtoMessage() {} +func (*MsgAddAuthenticatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2d1c240983fd17d6, []int{1} +} +func (m *MsgAddAuthenticatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddAuthenticatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddAuthenticatorResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgAddAuthenticatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddAuthenticatorResponse.Merge(m, src) +} +func (m *MsgAddAuthenticatorResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddAuthenticatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddAuthenticatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddAuthenticatorResponse proto.InternalMessageInfo + +func (m *MsgAddAuthenticatorResponse) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +// MsgRemoveAuthenticatorRequest defines the Msg/RemoveAuthenticator request +// type. +type MsgRemoveAuthenticator struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *MsgRemoveAuthenticator) Reset() { *m = MsgRemoveAuthenticator{} } +func (m *MsgRemoveAuthenticator) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveAuthenticator) ProtoMessage() {} +func (*MsgRemoveAuthenticator) Descriptor() ([]byte, []int) { + return fileDescriptor_2d1c240983fd17d6, []int{2} +} +func (m *MsgRemoveAuthenticator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveAuthenticator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveAuthenticator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRemoveAuthenticator) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveAuthenticator.Merge(m, src) +} +func (m *MsgRemoveAuthenticator) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveAuthenticator) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveAuthenticator.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveAuthenticator proto.InternalMessageInfo + +func (m *MsgRemoveAuthenticator) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgRemoveAuthenticator) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +// MsgRemoveAuthenticatorResponse defines the Msg/RemoveAuthenticator response +// type. +type MsgRemoveAuthenticatorResponse struct { + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` +} + +func (m *MsgRemoveAuthenticatorResponse) Reset() { *m = MsgRemoveAuthenticatorResponse{} } +func (m *MsgRemoveAuthenticatorResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveAuthenticatorResponse) ProtoMessage() {} +func (*MsgRemoveAuthenticatorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2d1c240983fd17d6, []int{3} +} +func (m *MsgRemoveAuthenticatorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveAuthenticatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveAuthenticatorResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRemoveAuthenticatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveAuthenticatorResponse.Merge(m, src) +} +func (m *MsgRemoveAuthenticatorResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveAuthenticatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveAuthenticatorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveAuthenticatorResponse proto.InternalMessageInfo + +func (m *MsgRemoveAuthenticatorResponse) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +// MsgSetActiveState sets the active state of the module. +type MsgSetActiveState struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Active bool `protobuf:"varint,2,opt,name=active,proto3" json:"active,omitempty"` +} + +func (m *MsgSetActiveState) Reset() { *m = MsgSetActiveState{} } +func (m *MsgSetActiveState) String() string { return proto.CompactTextString(m) } +func (*MsgSetActiveState) ProtoMessage() {} +func (*MsgSetActiveState) Descriptor() ([]byte, []int) { + return fileDescriptor_2d1c240983fd17d6, []int{4} +} +func (m *MsgSetActiveState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetActiveState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetActiveState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetActiveState) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetActiveState.Merge(m, src) +} +func (m *MsgSetActiveState) XXX_Size() int { + return m.Size() +} +func (m *MsgSetActiveState) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetActiveState.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetActiveState proto.InternalMessageInfo + +func (m *MsgSetActiveState) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSetActiveState) GetActive() bool { + if m != nil { + return m.Active + } + return false +} + +// MsgSetActiveStateResponse defines the Msg/SetActiveState response type. +type MsgSetActiveStateResponse struct { +} + +func (m *MsgSetActiveStateResponse) Reset() { *m = MsgSetActiveStateResponse{} } +func (m *MsgSetActiveStateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetActiveStateResponse) ProtoMessage() {} +func (*MsgSetActiveStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2d1c240983fd17d6, []int{5} +} +func (m *MsgSetActiveStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetActiveStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetActiveStateResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetActiveStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetActiveStateResponse.Merge(m, src) +} +func (m *MsgSetActiveStateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetActiveStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetActiveStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetActiveStateResponse proto.InternalMessageInfo + +// TxExtension allows for additional authenticator-specific data in +// transactions. +type TxExtension struct { + // selected_authenticators holds the authenticator_id for the chosen + // authenticator per message. + SelectedAuthenticators []uint64 `protobuf:"varint,1,rep,packed,name=selected_authenticators,json=selectedAuthenticators,proto3" json:"selected_authenticators,omitempty"` +} + +func (m *TxExtension) Reset() { *m = TxExtension{} } +func (m *TxExtension) String() string { return proto.CompactTextString(m) } +func (*TxExtension) ProtoMessage() {} +func (*TxExtension) Descriptor() ([]byte, []int) { + return fileDescriptor_2d1c240983fd17d6, []int{6} +} +func (m *TxExtension) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxExtension) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxExtension.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TxExtension) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxExtension.Merge(m, src) +} +func (m *TxExtension) XXX_Size() int { + return m.Size() +} +func (m *TxExtension) XXX_DiscardUnknown() { + xxx_messageInfo_TxExtension.DiscardUnknown(m) +} + +var xxx_messageInfo_TxExtension proto.InternalMessageInfo + +func (m *TxExtension) GetSelectedAuthenticators() []uint64 { + if m != nil { + return m.SelectedAuthenticators + } + return nil +} + +func init() { + proto.RegisterType((*MsgAddAuthenticator)(nil), "dydxprotocol.accountplus.MsgAddAuthenticator") + proto.RegisterType((*MsgAddAuthenticatorResponse)(nil), "dydxprotocol.accountplus.MsgAddAuthenticatorResponse") + proto.RegisterType((*MsgRemoveAuthenticator)(nil), "dydxprotocol.accountplus.MsgRemoveAuthenticator") + proto.RegisterType((*MsgRemoveAuthenticatorResponse)(nil), "dydxprotocol.accountplus.MsgRemoveAuthenticatorResponse") + proto.RegisterType((*MsgSetActiveState)(nil), "dydxprotocol.accountplus.MsgSetActiveState") + proto.RegisterType((*MsgSetActiveStateResponse)(nil), "dydxprotocol.accountplus.MsgSetActiveStateResponse") + proto.RegisterType((*TxExtension)(nil), "dydxprotocol.accountplus.TxExtension") +} + +func init() { proto.RegisterFile("dydxprotocol/accountplus/tx.proto", fileDescriptor_2d1c240983fd17d6) } + +var fileDescriptor_2d1c240983fd17d6 = []byte{ + // 511 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6a, 0xdb, 0x40, + 0x10, 0xc6, 0x2d, 0xdb, 0xb8, 0xe9, 0xb6, 0x84, 0x5a, 0x01, 0xc7, 0x75, 0x40, 0xa4, 0x82, 0x82, + 0x71, 0x91, 0xd4, 0x36, 0x0d, 0x29, 0x82, 0x1c, 0x5c, 0x68, 0x6f, 0xbe, 0x28, 0x81, 0x42, 0x2f, + 0x61, 0xb3, 0x3b, 0xc8, 0x02, 0x4b, 0x2b, 0x34, 0x2b, 0x23, 0xf7, 0x52, 0xda, 0x63, 0x4f, 0x7d, + 0x90, 0x1e, 0xf2, 0x18, 0x3d, 0xe6, 0xd8, 0x63, 0xb1, 0x0f, 0x79, 0x84, 0x5e, 0x83, 0xd7, 0x7f, + 0xb0, 0x1c, 0x39, 0xc4, 0x17, 0x5b, 0x3b, 0xf3, 0xcd, 0xcc, 0x6f, 0x56, 0x1f, 0x22, 0x2f, 0xf8, + 0x88, 0x67, 0x71, 0x22, 0xa4, 0x60, 0x62, 0xe0, 0x50, 0xc6, 0x44, 0x1a, 0xc9, 0x78, 0x90, 0xa2, + 0x23, 0x33, 0x5b, 0xc5, 0xf5, 0xe6, 0xaa, 0xc4, 0x5e, 0x91, 0xb4, 0xf6, 0x99, 0xc0, 0x50, 0xa0, + 0x13, 0xa2, 0xef, 0x0c, 0xdf, 0x4c, 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, 0x00, 0xff, 0xff, 0x6f, 0xd1, 0xf0, 0xf4, 0xca, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // AddAuthenticator adds an authenticator to an account. + AddAuthenticator(ctx context.Context, in *MsgAddAuthenticator, opts ...grpc.CallOption) (*MsgAddAuthenticatorResponse, error) + // RemoveAuthenticator removes an authenticator from an account. + RemoveAuthenticator(ctx context.Context, in *MsgRemoveAuthenticator, opts ...grpc.CallOption) (*MsgRemoveAuthenticatorResponse, error) + // SetActiveState sets the active state of the authenticator. + // Primarily used for circuit breaking. + SetActiveState(ctx context.Context, in *MsgSetActiveState, opts ...grpc.CallOption) (*MsgSetActiveStateResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) AddAuthenticator(ctx context.Context, in *MsgAddAuthenticator, opts ...grpc.CallOption) (*MsgAddAuthenticatorResponse, error) { + out := new(MsgAddAuthenticatorResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.accountplus.Msg/AddAuthenticator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RemoveAuthenticator(ctx context.Context, in *MsgRemoveAuthenticator, opts ...grpc.CallOption) (*MsgRemoveAuthenticatorResponse, error) { + out := new(MsgRemoveAuthenticatorResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.accountplus.Msg/RemoveAuthenticator", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SetActiveState(ctx context.Context, in *MsgSetActiveState, opts ...grpc.CallOption) (*MsgSetActiveStateResponse, error) { + out := new(MsgSetActiveStateResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.accountplus.Msg/SetActiveState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // AddAuthenticator adds an authenticator to an account. + AddAuthenticator(context.Context, *MsgAddAuthenticator) (*MsgAddAuthenticatorResponse, error) + // RemoveAuthenticator removes an authenticator from an account. + RemoveAuthenticator(context.Context, *MsgRemoveAuthenticator) (*MsgRemoveAuthenticatorResponse, error) + // SetActiveState sets the active state of the authenticator. + // Primarily used for circuit breaking. + SetActiveState(context.Context, *MsgSetActiveState) (*MsgSetActiveStateResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) AddAuthenticator(ctx context.Context, req *MsgAddAuthenticator) (*MsgAddAuthenticatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddAuthenticator not implemented") +} +func (*UnimplementedMsgServer) RemoveAuthenticator(ctx context.Context, req *MsgRemoveAuthenticator) (*MsgRemoveAuthenticatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveAuthenticator not implemented") +} +func (*UnimplementedMsgServer) SetActiveState(ctx context.Context, req *MsgSetActiveState) (*MsgSetActiveStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetActiveState not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_AddAuthenticator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddAuthenticator) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddAuthenticator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.accountplus.Msg/AddAuthenticator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddAuthenticator(ctx, req.(*MsgAddAuthenticator)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RemoveAuthenticator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveAuthenticator) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveAuthenticator(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.accountplus.Msg/RemoveAuthenticator", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveAuthenticator(ctx, req.(*MsgRemoveAuthenticator)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SetActiveState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetActiveState) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetActiveState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.accountplus.Msg/SetActiveState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetActiveState(ctx, req.(*MsgSetActiveState)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dydxprotocol.accountplus.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddAuthenticator", + Handler: _Msg_AddAuthenticator_Handler, + }, + { + MethodName: "RemoveAuthenticator", + Handler: _Msg_RemoveAuthenticator_Handler, + }, + { + MethodName: "SetActiveState", + Handler: _Msg_SetActiveState_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dydxprotocol/accountplus/tx.proto", +} + +func (m *MsgAddAuthenticator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddAuthenticator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddAuthenticator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if len(m.AuthenticatorType) > 0 { + i -= len(m.AuthenticatorType) + copy(dAtA[i:], m.AuthenticatorType) + i = encodeVarintTx(dAtA, i, uint64(len(m.AuthenticatorType))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddAuthenticatorResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddAuthenticatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddAuthenticatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Success { + i-- + if m.Success { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveAuthenticator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRemoveAuthenticator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveAuthenticator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Id != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveAuthenticatorResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRemoveAuthenticatorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveAuthenticatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Success { + i-- + if m.Success { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgSetActiveState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetActiveState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetActiveState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Active { + i-- + if m.Active { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetActiveStateResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetActiveStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetActiveStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *TxExtension) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TxExtension) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SelectedAuthenticators) > 0 { + dAtA2 := make([]byte, len(m.SelectedAuthenticators)*10) + var j1 int + for _, num := range m.SelectedAuthenticators { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintTx(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgAddAuthenticator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.AuthenticatorType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAddAuthenticatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Success { + n += 2 + } + return n +} + +func (m *MsgRemoveAuthenticator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Id != 0 { + n += 1 + sovTx(uint64(m.Id)) + } + return n +} + +func (m *MsgRemoveAuthenticatorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Success { + n += 2 + } + return n +} + +func (m *MsgSetActiveState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Active { + n += 2 + } + return n +} + +func (m *MsgSetActiveStateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *TxExtension) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SelectedAuthenticators) > 0 { + l = 0 + for _, e := range m.SelectedAuthenticators { + l += sovTx(uint64(e)) + } + n += 1 + sovTx(uint64(l)) + l + } + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgAddAuthenticator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgAddAuthenticator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddAuthenticator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthenticatorType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthenticatorType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAddAuthenticatorResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgAddAuthenticatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddAuthenticatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Success = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveAuthenticator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveAuthenticator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveAuthenticator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveAuthenticatorResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveAuthenticatorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveAuthenticatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Success = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetActiveState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetActiveState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetActiveState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Active", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Active = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetActiveStateResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetActiveStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetActiveStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxExtension) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TxExtension: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxExtension: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SelectedAuthenticators = append(m.SelectedAuthenticators, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.SelectedAuthenticators) == 0 { + m.SelectedAuthenticators = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SelectedAuthenticators = append(m.SelectedAuthenticators, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field SelectedAuthenticators", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 1c7884e729fabf9fc44a6ef669109828f2aea182 Mon Sep 17 00:00:00 2001 From: vincentwschau <99756290+vincentwschau@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:38:31 -0400 Subject: [PATCH 06/12] [TRA-572] Add upsert vault event. (#2250) --- .../src/codegen/dydxprotocol/bundle.ts | 410 ++++++------- .../dydxprotocol/indexer/events/events.ts | 90 +++ .../dydxprotocol/indexer/protocol/v1/vault.ts | 87 +++ .../v4-protos/src/codegen/gogoproto/bundle.ts | 4 +- .../v4-protos/src/codegen/google/bundle.ts | 22 +- .../dydxprotocol/indexer/events/events.proto | 13 + .../indexer/protocol/v1/vault.proto | 27 + protocol/indexer/events/events.pb.go | 543 +++++++++++++----- protocol/indexer/events/upsert_vault.go | 21 + protocol/indexer/events/upsert_vault_test.go | 26 + .../indexer/protocol/v1/types/vault.pb.go | 89 +++ protocol/indexer/protocol/v1/v1_mappers.go | 5 + .../indexer/protocol/v1/v1_mappers_test.go | 31 + 13 files changed, 1003 insertions(+), 365 deletions(-) create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/protocol/v1/vault.ts create mode 100644 proto/dydxprotocol/indexer/protocol/v1/vault.proto create mode 100644 protocol/indexer/events/upsert_vault.go create mode 100644 protocol/indexer/events/upsert_vault_test.go create mode 100644 protocol/indexer/protocol/v1/types/vault.pb.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts index ea45d3f68c..8a5e295af1 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts @@ -61,124 +61,125 @@ import * as _64 from "./indexer/off_chain_updates/off_chain_updates"; import * as _65 from "./indexer/protocol/v1/clob"; import * as _66 from "./indexer/protocol/v1/perpetual"; import * as _67 from "./indexer/protocol/v1/subaccount"; -import * as _68 from "./indexer/redis/redis_order"; -import * as _69 from "./indexer/shared/removal_reason"; -import * as _70 from "./indexer/socks/messages"; -import * as _71 from "./listing/genesis"; -import * as _72 from "./listing/params"; -import * as _73 from "./listing/query"; -import * as _74 from "./listing/tx"; -import * as _75 from "./perpetuals/genesis"; -import * as _76 from "./perpetuals/params"; -import * as _77 from "./perpetuals/perpetual"; -import * as _78 from "./perpetuals/query"; -import * as _79 from "./perpetuals/tx"; -import * as _80 from "./prices/genesis"; -import * as _81 from "./prices/market_param"; -import * as _82 from "./prices/market_price"; -import * as _83 from "./prices/query"; -import * as _84 from "./prices/tx"; -import * as _85 from "./ratelimit/capacity"; -import * as _86 from "./ratelimit/genesis"; -import * as _87 from "./ratelimit/limit_params"; -import * as _88 from "./ratelimit/pending_send_packet"; -import * as _89 from "./ratelimit/query"; -import * as _90 from "./ratelimit/tx"; -import * as _91 from "./revshare/genesis"; -import * as _92 from "./revshare/params"; -import * as _93 from "./revshare/query"; -import * as _94 from "./revshare/revshare"; -import * as _95 from "./revshare/tx"; -import * as _96 from "./rewards/genesis"; -import * as _97 from "./rewards/params"; -import * as _98 from "./rewards/query"; -import * as _99 from "./rewards/reward_share"; -import * as _100 from "./rewards/tx"; -import * as _101 from "./sending/genesis"; -import * as _102 from "./sending/query"; -import * as _103 from "./sending/transfer"; -import * as _104 from "./sending/tx"; -import * as _105 from "./stats/genesis"; -import * as _106 from "./stats/params"; -import * as _107 from "./stats/query"; -import * as _108 from "./stats/stats"; -import * as _109 from "./stats/tx"; -import * as _110 from "./subaccounts/asset_position"; -import * as _111 from "./subaccounts/genesis"; -import * as _112 from "./subaccounts/perpetual_position"; -import * as _113 from "./subaccounts/query"; -import * as _114 from "./subaccounts/streaming"; -import * as _115 from "./subaccounts/subaccount"; -import * as _116 from "./vault/genesis"; -import * as _117 from "./vault/params"; -import * as _118 from "./vault/query"; -import * as _119 from "./vault/share"; -import * as _120 from "./vault/tx"; -import * as _121 from "./vault/vault"; -import * as _122 from "./vest/genesis"; -import * as _123 from "./vest/query"; -import * as _124 from "./vest/tx"; -import * as _125 from "./vest/vest_entry"; -import * as _133 from "./accountplus/query.lcd"; -import * as _134 from "./assets/query.lcd"; -import * as _135 from "./blocktime/query.lcd"; -import * as _136 from "./bridge/query.lcd"; -import * as _137 from "./clob/query.lcd"; -import * as _138 from "./delaymsg/query.lcd"; -import * as _139 from "./epochs/query.lcd"; -import * as _140 from "./feetiers/query.lcd"; -import * as _141 from "./listing/query.lcd"; -import * as _142 from "./perpetuals/query.lcd"; -import * as _143 from "./prices/query.lcd"; -import * as _144 from "./ratelimit/query.lcd"; -import * as _145 from "./revshare/query.lcd"; -import * as _146 from "./rewards/query.lcd"; -import * as _147 from "./stats/query.lcd"; -import * as _148 from "./subaccounts/query.lcd"; -import * as _149 from "./vault/query.lcd"; -import * as _150 from "./vest/query.lcd"; -import * as _151 from "./accountplus/query.rpc.Query"; -import * as _152 from "./affiliates/query.rpc.Query"; -import * as _153 from "./assets/query.rpc.Query"; -import * as _154 from "./blocktime/query.rpc.Query"; -import * as _155 from "./bridge/query.rpc.Query"; -import * as _156 from "./clob/query.rpc.Query"; -import * as _157 from "./delaymsg/query.rpc.Query"; -import * as _158 from "./epochs/query.rpc.Query"; -import * as _159 from "./feetiers/query.rpc.Query"; -import * as _160 from "./govplus/query.rpc.Query"; -import * as _161 from "./listing/query.rpc.Query"; -import * as _162 from "./perpetuals/query.rpc.Query"; -import * as _163 from "./prices/query.rpc.Query"; -import * as _164 from "./ratelimit/query.rpc.Query"; -import * as _165 from "./revshare/query.rpc.Query"; -import * as _166 from "./rewards/query.rpc.Query"; -import * as _167 from "./sending/query.rpc.Query"; -import * as _168 from "./stats/query.rpc.Query"; -import * as _169 from "./subaccounts/query.rpc.Query"; -import * as _170 from "./vault/query.rpc.Query"; -import * as _171 from "./vest/query.rpc.Query"; -import * as _172 from "./accountplus/tx.rpc.msg"; -import * as _173 from "./affiliates/tx.rpc.msg"; -import * as _174 from "./blocktime/tx.rpc.msg"; -import * as _175 from "./bridge/tx.rpc.msg"; -import * as _176 from "./clob/tx.rpc.msg"; -import * as _177 from "./delaymsg/tx.rpc.msg"; -import * as _178 from "./feetiers/tx.rpc.msg"; -import * as _179 from "./govplus/tx.rpc.msg"; -import * as _180 from "./listing/tx.rpc.msg"; -import * as _181 from "./perpetuals/tx.rpc.msg"; -import * as _182 from "./prices/tx.rpc.msg"; -import * as _183 from "./ratelimit/tx.rpc.msg"; -import * as _184 from "./revshare/tx.rpc.msg"; -import * as _185 from "./rewards/tx.rpc.msg"; -import * as _186 from "./sending/tx.rpc.msg"; -import * as _187 from "./stats/tx.rpc.msg"; -import * as _188 from "./vault/tx.rpc.msg"; -import * as _189 from "./vest/tx.rpc.msg"; -import * as _190 from "./lcd"; -import * as _191 from "./rpc.query"; -import * as _192 from "./rpc.tx"; +import * as _68 from "./indexer/protocol/v1/vault"; +import * as _69 from "./indexer/redis/redis_order"; +import * as _70 from "./indexer/shared/removal_reason"; +import * as _71 from "./indexer/socks/messages"; +import * as _72 from "./listing/genesis"; +import * as _73 from "./listing/params"; +import * as _74 from "./listing/query"; +import * as _75 from "./listing/tx"; +import * as _76 from "./perpetuals/genesis"; +import * as _77 from "./perpetuals/params"; +import * as _78 from "./perpetuals/perpetual"; +import * as _79 from "./perpetuals/query"; +import * as _80 from "./perpetuals/tx"; +import * as _81 from "./prices/genesis"; +import * as _82 from "./prices/market_param"; +import * as _83 from "./prices/market_price"; +import * as _84 from "./prices/query"; +import * as _85 from "./prices/tx"; +import * as _86 from "./ratelimit/capacity"; +import * as _87 from "./ratelimit/genesis"; +import * as _88 from "./ratelimit/limit_params"; +import * as _89 from "./ratelimit/pending_send_packet"; +import * as _90 from "./ratelimit/query"; +import * as _91 from "./ratelimit/tx"; +import * as _92 from "./revshare/genesis"; +import * as _93 from "./revshare/params"; +import * as _94 from "./revshare/query"; +import * as _95 from "./revshare/revshare"; +import * as _96 from "./revshare/tx"; +import * as _97 from "./rewards/genesis"; +import * as _98 from "./rewards/params"; +import * as _99 from "./rewards/query"; +import * as _100 from "./rewards/reward_share"; +import * as _101 from "./rewards/tx"; +import * as _102 from "./sending/genesis"; +import * as _103 from "./sending/query"; +import * as _104 from "./sending/transfer"; +import * as _105 from "./sending/tx"; +import * as _106 from "./stats/genesis"; +import * as _107 from "./stats/params"; +import * as _108 from "./stats/query"; +import * as _109 from "./stats/stats"; +import * as _110 from "./stats/tx"; +import * as _111 from "./subaccounts/asset_position"; +import * as _112 from "./subaccounts/genesis"; +import * as _113 from "./subaccounts/perpetual_position"; +import * as _114 from "./subaccounts/query"; +import * as _115 from "./subaccounts/streaming"; +import * as _116 from "./subaccounts/subaccount"; +import * as _117 from "./vault/genesis"; +import * as _118 from "./vault/params"; +import * as _119 from "./vault/query"; +import * as _120 from "./vault/share"; +import * as _121 from "./vault/tx"; +import * as _122 from "./vault/vault"; +import * as _123 from "./vest/genesis"; +import * as _124 from "./vest/query"; +import * as _125 from "./vest/tx"; +import * as _126 from "./vest/vest_entry"; +import * as _134 from "./accountplus/query.lcd"; +import * as _135 from "./assets/query.lcd"; +import * as _136 from "./blocktime/query.lcd"; +import * as _137 from "./bridge/query.lcd"; +import * as _138 from "./clob/query.lcd"; +import * as _139 from "./delaymsg/query.lcd"; +import * as _140 from "./epochs/query.lcd"; +import * as _141 from "./feetiers/query.lcd"; +import * as _142 from "./listing/query.lcd"; +import * as _143 from "./perpetuals/query.lcd"; +import * as _144 from "./prices/query.lcd"; +import * as _145 from "./ratelimit/query.lcd"; +import * as _146 from "./revshare/query.lcd"; +import * as _147 from "./rewards/query.lcd"; +import * as _148 from "./stats/query.lcd"; +import * as _149 from "./subaccounts/query.lcd"; +import * as _150 from "./vault/query.lcd"; +import * as _151 from "./vest/query.lcd"; +import * as _152 from "./accountplus/query.rpc.Query"; +import * as _153 from "./affiliates/query.rpc.Query"; +import * as _154 from "./assets/query.rpc.Query"; +import * as _155 from "./blocktime/query.rpc.Query"; +import * as _156 from "./bridge/query.rpc.Query"; +import * as _157 from "./clob/query.rpc.Query"; +import * as _158 from "./delaymsg/query.rpc.Query"; +import * as _159 from "./epochs/query.rpc.Query"; +import * as _160 from "./feetiers/query.rpc.Query"; +import * as _161 from "./govplus/query.rpc.Query"; +import * as _162 from "./listing/query.rpc.Query"; +import * as _163 from "./perpetuals/query.rpc.Query"; +import * as _164 from "./prices/query.rpc.Query"; +import * as _165 from "./ratelimit/query.rpc.Query"; +import * as _166 from "./revshare/query.rpc.Query"; +import * as _167 from "./rewards/query.rpc.Query"; +import * as _168 from "./sending/query.rpc.Query"; +import * as _169 from "./stats/query.rpc.Query"; +import * as _170 from "./subaccounts/query.rpc.Query"; +import * as _171 from "./vault/query.rpc.Query"; +import * as _172 from "./vest/query.rpc.Query"; +import * as _173 from "./accountplus/tx.rpc.msg"; +import * as _174 from "./affiliates/tx.rpc.msg"; +import * as _175 from "./blocktime/tx.rpc.msg"; +import * as _176 from "./bridge/tx.rpc.msg"; +import * as _177 from "./clob/tx.rpc.msg"; +import * as _178 from "./delaymsg/tx.rpc.msg"; +import * as _179 from "./feetiers/tx.rpc.msg"; +import * as _180 from "./govplus/tx.rpc.msg"; +import * as _181 from "./listing/tx.rpc.msg"; +import * as _182 from "./perpetuals/tx.rpc.msg"; +import * as _183 from "./prices/tx.rpc.msg"; +import * as _184 from "./ratelimit/tx.rpc.msg"; +import * as _185 from "./revshare/tx.rpc.msg"; +import * as _186 from "./rewards/tx.rpc.msg"; +import * as _187 from "./sending/tx.rpc.msg"; +import * as _188 from "./stats/tx.rpc.msg"; +import * as _189 from "./vault/tx.rpc.msg"; +import * as _190 from "./vest/tx.rpc.msg"; +import * as _191 from "./lcd"; +import * as _192 from "./rpc.query"; +import * as _193 from "./rpc.tx"; export namespace dydxprotocol { export const accountplus = { ..._5, ..._6, @@ -186,32 +187,32 @@ export namespace dydxprotocol { ..._8, ..._9, ..._10, - ..._133, - ..._151, - ..._172 + ..._134, + ..._152, + ..._173 }; export const affiliates = { ..._11, ..._12, ..._13, ..._14, - ..._152, - ..._173 + ..._153, + ..._174 }; export const assets = { ..._15, ..._16, ..._17, ..._18, - ..._134, - ..._153 + ..._135, + ..._154 }; export const blocktime = { ..._19, ..._20, ..._21, ..._22, ..._23, - ..._135, - ..._154, - ..._174 + ..._136, + ..._155, + ..._175 }; export const bridge = { ..._24, ..._25, @@ -219,9 +220,9 @@ export namespace dydxprotocol { ..._27, ..._28, ..._29, - ..._136, - ..._155, - ..._175 + ..._137, + ..._156, + ..._176 }; export const clob = { ..._30, ..._31, @@ -237,9 +238,9 @@ export namespace dydxprotocol { ..._41, ..._42, ..._43, - ..._137, - ..._156, - ..._176 + ..._138, + ..._157, + ..._177 }; export namespace daemons { export const bridge = { ..._44 @@ -254,29 +255,29 @@ export namespace dydxprotocol { ..._49, ..._50, ..._51, - ..._138, - ..._157, - ..._177 + ..._139, + ..._158, + ..._178 }; export const epochs = { ..._52, ..._53, ..._54, - ..._139, - ..._158 + ..._140, + ..._159 }; export const feetiers = { ..._55, ..._56, ..._57, ..._58, - ..._140, - ..._159, - ..._178 + ..._141, + ..._160, + ..._179 }; export const govplus = { ..._59, ..._60, ..._61, - ..._160, - ..._179 + ..._161, + ..._180 }; export namespace indexer { export const events = { ..._62 @@ -288,115 +289,116 @@ export namespace dydxprotocol { export namespace protocol { export const v1 = { ..._65, ..._66, - ..._67 + ..._67, + ..._68 }; } - export const redis = { ..._68 + export const redis = { ..._69 }; - export const shared = { ..._69 + export const shared = { ..._70 }; - export const socks = { ..._70 + export const socks = { ..._71 }; } - export const listing = { ..._71, - ..._72, + export const listing = { ..._72, ..._73, ..._74, - ..._141, - ..._161, - ..._180 + ..._75, + ..._142, + ..._162, + ..._181 }; - export const perpetuals = { ..._75, - ..._76, + export const perpetuals = { ..._76, ..._77, ..._78, ..._79, - ..._142, - ..._162, - ..._181 + ..._80, + ..._143, + ..._163, + ..._182 }; - export const prices = { ..._80, - ..._81, + export const prices = { ..._81, ..._82, ..._83, ..._84, - ..._143, - ..._163, - ..._182 + ..._85, + ..._144, + ..._164, + ..._183 }; - export const ratelimit = { ..._85, - ..._86, + export const ratelimit = { ..._86, ..._87, ..._88, ..._89, ..._90, - ..._144, - ..._164, - ..._183 + ..._91, + ..._145, + ..._165, + ..._184 }; - export const revshare = { ..._91, - ..._92, + export const revshare = { ..._92, ..._93, ..._94, ..._95, - ..._145, - ..._165, - ..._184 + ..._96, + ..._146, + ..._166, + ..._185 }; - export const rewards = { ..._96, - ..._97, + export const rewards = { ..._97, ..._98, ..._99, ..._100, - ..._146, - ..._166, - ..._185 + ..._101, + ..._147, + ..._167, + ..._186 }; - export const sending = { ..._101, - ..._102, + export const sending = { ..._102, ..._103, ..._104, - ..._167, - ..._186 + ..._105, + ..._168, + ..._187 }; - export const stats = { ..._105, - ..._106, + export const stats = { ..._106, ..._107, ..._108, ..._109, - ..._147, - ..._168, - ..._187 + ..._110, + ..._148, + ..._169, + ..._188 }; - export const subaccounts = { ..._110, - ..._111, + export const subaccounts = { ..._111, ..._112, ..._113, ..._114, ..._115, - ..._148, - ..._169 + ..._116, + ..._149, + ..._170 }; - export const vault = { ..._116, - ..._117, + export const vault = { ..._117, ..._118, ..._119, ..._120, ..._121, - ..._149, - ..._170, - ..._188 - }; - export const vest = { ..._122, - ..._123, - ..._124, - ..._125, + ..._122, ..._150, ..._171, ..._189 }; - export const ClientFactory = { ..._190, - ..._191, - ..._192 + export const vest = { ..._123, + ..._124, + ..._125, + ..._126, + ..._151, + ..._172, + ..._190 + }; + export const ClientFactory = { ..._191, + ..._192, + ..._193 }; } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts index fbfa1b572f..6b968da426 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/events/events.ts @@ -2,6 +2,7 @@ import { IndexerSubaccountId, IndexerSubaccountIdSDKType, IndexerPerpetualPositi import { IndexerOrder, IndexerOrderSDKType, IndexerOrderId, IndexerOrderIdSDKType, ClobPairStatus, ClobPairStatusSDKType } from "../protocol/v1/clob"; import { OrderRemovalReason, OrderRemovalReasonSDKType } from "../shared/removal_reason"; import { PerpetualMarketType, PerpetualMarketTypeSDKType } from "../protocol/v1/perpetual"; +import { VaultStatus, VaultStatusSDKType } from "../protocol/v1/vault"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial, Long } from "../../../helpers"; /** Type is the type for funding values. */ @@ -1503,6 +1504,30 @@ export interface RegisterAffiliateEventV1SDKType { affiliate: string; } +/** Event emitted when a vault is created / updated. */ + +export interface UpsertVaultEventV1 { + /** Address of the vault. */ + address: string; + /** Clob pair Id associated with the vault. */ + + clobPairId: number; + /** Status of the vault. */ + + status: VaultStatus; +} +/** Event emitted when a vault is created / updated. */ + +export interface UpsertVaultEventV1SDKType { + /** Address of the vault. */ + address: string; + /** Clob pair Id associated with the vault. */ + + clob_pair_id: number; + /** Status of the vault. */ + + status: VaultStatusSDKType; +} function createBaseFundingUpdateV1(): FundingUpdateV1 { return { @@ -3802,4 +3827,69 @@ export const RegisterAffiliateEventV1 = { return message; } +}; + +function createBaseUpsertVaultEventV1(): UpsertVaultEventV1 { + return { + address: "", + clobPairId: 0, + status: 0 + }; +} + +export const UpsertVaultEventV1 = { + encode(message: UpsertVaultEventV1, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + + if (message.clobPairId !== 0) { + writer.uint32(16).uint32(message.clobPairId); + } + + if (message.status !== 0) { + writer.uint32(24).int32(message.status); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): UpsertVaultEventV1 { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUpsertVaultEventV1(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + + case 2: + message.clobPairId = reader.uint32(); + break; + + case 3: + message.status = (reader.int32() as any); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<UpsertVaultEventV1>): UpsertVaultEventV1 { + const message = createBaseUpsertVaultEventV1(); + message.address = object.address ?? ""; + message.clobPairId = object.clobPairId ?? 0; + message.status = object.status ?? 0; + return message; + } + }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/protocol/v1/vault.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/protocol/v1/vault.ts new file mode 100644 index 0000000000..93b1f9b2fd --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/indexer/protocol/v1/vault.ts @@ -0,0 +1,87 @@ +/** VaultStatus represents the status of a vault. */ +export enum VaultStatus { + /** VAULT_STATUS_UNSPECIFIED - Default value, invalid and unused. */ + VAULT_STATUS_UNSPECIFIED = 0, + + /** VAULT_STATUS_DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */ + VAULT_STATUS_DEACTIVATED = 1, + + /** VAULT_STATUS_STAND_BY - Don’t place orders. Does count towards global vault balances. */ + VAULT_STATUS_STAND_BY = 2, + + /** VAULT_STATUS_QUOTING - Places orders on both sides of the book. */ + VAULT_STATUS_QUOTING = 3, + + /** VAULT_STATUS_CLOSE_ONLY - Only place orders that close the position. */ + VAULT_STATUS_CLOSE_ONLY = 4, + UNRECOGNIZED = -1, +} +/** VaultStatus represents the status of a vault. */ + +export enum VaultStatusSDKType { + /** VAULT_STATUS_UNSPECIFIED - Default value, invalid and unused. */ + VAULT_STATUS_UNSPECIFIED = 0, + + /** VAULT_STATUS_DEACTIVATED - Don’t place orders. Does not count toward global vault balances. */ + VAULT_STATUS_DEACTIVATED = 1, + + /** VAULT_STATUS_STAND_BY - Don’t place orders. Does count towards global vault balances. */ + VAULT_STATUS_STAND_BY = 2, + + /** VAULT_STATUS_QUOTING - Places orders on both sides of the book. */ + VAULT_STATUS_QUOTING = 3, + + /** VAULT_STATUS_CLOSE_ONLY - Only place orders that close the position. */ + VAULT_STATUS_CLOSE_ONLY = 4, + UNRECOGNIZED = -1, +} +export function vaultStatusFromJSON(object: any): VaultStatus { + switch (object) { + case 0: + case "VAULT_STATUS_UNSPECIFIED": + return VaultStatus.VAULT_STATUS_UNSPECIFIED; + + case 1: + case "VAULT_STATUS_DEACTIVATED": + return VaultStatus.VAULT_STATUS_DEACTIVATED; + + case 2: + case "VAULT_STATUS_STAND_BY": + return VaultStatus.VAULT_STATUS_STAND_BY; + + case 3: + case "VAULT_STATUS_QUOTING": + return VaultStatus.VAULT_STATUS_QUOTING; + + case 4: + case "VAULT_STATUS_CLOSE_ONLY": + return VaultStatus.VAULT_STATUS_CLOSE_ONLY; + + case -1: + case "UNRECOGNIZED": + default: + return VaultStatus.UNRECOGNIZED; + } +} +export function vaultStatusToJSON(object: VaultStatus): string { + switch (object) { + case VaultStatus.VAULT_STATUS_UNSPECIFIED: + return "VAULT_STATUS_UNSPECIFIED"; + + case VaultStatus.VAULT_STATUS_DEACTIVATED: + return "VAULT_STATUS_DEACTIVATED"; + + case VaultStatus.VAULT_STATUS_STAND_BY: + return "VAULT_STATUS_STAND_BY"; + + case VaultStatus.VAULT_STATUS_QUOTING: + return "VAULT_STATUS_QUOTING"; + + case VaultStatus.VAULT_STATUS_CLOSE_ONLY: + return "VAULT_STATUS_CLOSE_ONLY"; + + case VaultStatus.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts index 795d06bc47..52cc244930 100644 --- a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts @@ -1,3 +1,3 @@ -import * as _126 from "./gogo"; -export const gogoproto = { ..._126 +import * as _127 from "./gogo"; +export const gogoproto = { ..._127 }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/google/bundle.ts b/indexer/packages/v4-protos/src/codegen/google/bundle.ts index 6c02be50fc..fd95177ed2 100644 --- a/indexer/packages/v4-protos/src/codegen/google/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/google/bundle.ts @@ -1,16 +1,16 @@ -import * as _127 from "./api/annotations"; -import * as _128 from "./api/http"; -import * as _129 from "./protobuf/descriptor"; -import * as _130 from "./protobuf/duration"; -import * as _131 from "./protobuf/timestamp"; -import * as _132 from "./protobuf/any"; +import * as _128 from "./api/annotations"; +import * as _129 from "./api/http"; +import * as _130 from "./protobuf/descriptor"; +import * as _131 from "./protobuf/duration"; +import * as _132 from "./protobuf/timestamp"; +import * as _133 from "./protobuf/any"; export namespace google { - export const api = { ..._127, - ..._128 + export const api = { ..._128, + ..._129 }; - export const protobuf = { ..._129, - ..._130, + export const protobuf = { ..._130, ..._131, - ..._132 + ..._132, + ..._133 }; } \ No newline at end of file diff --git a/proto/dydxprotocol/indexer/events/events.proto b/proto/dydxprotocol/indexer/events/events.proto index 3a548ec735..b152dcd82f 100644 --- a/proto/dydxprotocol/indexer/events/events.proto +++ b/proto/dydxprotocol/indexer/events/events.proto @@ -7,6 +7,7 @@ import "dydxprotocol/indexer/shared/removal_reason.proto"; import "dydxprotocol/indexer/protocol/v1/clob.proto"; import "dydxprotocol/indexer/protocol/v1/perpetual.proto"; import "dydxprotocol/indexer/protocol/v1/subaccount.proto"; +import "dydxprotocol/indexer/protocol/v1/vault.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/events"; @@ -590,3 +591,15 @@ message RegisterAffiliateEventV1 { // Address of the affiliate associated with the referee. string affiliate = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } + +// Event emitted when a vault is created / updated. +message UpsertVaultEventV1 { + // Address of the vault. + string address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Clob pair Id associated with the vault. + uint32 clob_pair_id = 2; + + // Status of the vault. + dydxprotocol.indexer.protocol.v1.VaultStatus status = 3; +} diff --git a/proto/dydxprotocol/indexer/protocol/v1/vault.proto b/proto/dydxprotocol/indexer/protocol/v1/vault.proto new file mode 100644 index 0000000000..1a7ebc6d19 --- /dev/null +++ b/proto/dydxprotocol/indexer/protocol/v1/vault.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +package dydxprotocol.indexer.protocol.v1; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types"; + +// Initial copy of protos from dYdX chain application state protos for the +// vault module for use to send Indexer specific messages. Do not make any +// breaking changes to these protos, a new version should be created if a +// breaking change is needed. + +// VaultStatus represents the status of a vault. +enum VaultStatus { + // Default value, invalid and unused. + VAULT_STATUS_UNSPECIFIED = 0; + + // Don’t place orders. Does not count toward global vault balances. + VAULT_STATUS_DEACTIVATED = 1; + + // Don’t place orders. Does count towards global vault balances. + VAULT_STATUS_STAND_BY = 2; + + // Places orders on both sides of the book. + VAULT_STATUS_QUOTING = 3; + + // Only place orders that close the position. + VAULT_STATUS_CLOSE_ONLY = 4; +} diff --git a/protocol/indexer/events/events.pb.go b/protocol/indexer/events/events.pb.go index 9a02a645dc..45c17665b9 100644 --- a/protocol/indexer/events/events.pb.go +++ b/protocol/indexer/events/events.pb.go @@ -2600,6 +2600,70 @@ func (m *RegisterAffiliateEventV1) GetAffiliate() string { return "" } +// Event emitted when a vault is created / updated. +type UpsertVaultEventV1 struct { + // Address of the vault. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // Clob pair Id associated with the vault. + ClobPairId uint32 `protobuf:"varint,2,opt,name=clob_pair_id,json=clobPairId,proto3" json:"clob_pair_id,omitempty"` + // Status of the vault. + Status types.VaultStatus `protobuf:"varint,3,opt,name=status,proto3,enum=dydxprotocol.indexer.protocol.v1.VaultStatus" json:"status,omitempty"` +} + +func (m *UpsertVaultEventV1) Reset() { *m = UpsertVaultEventV1{} } +func (m *UpsertVaultEventV1) String() string { return proto.CompactTextString(m) } +func (*UpsertVaultEventV1) ProtoMessage() {} +func (*UpsertVaultEventV1) Descriptor() ([]byte, []int) { + return fileDescriptor_6331dfb59c6fd2bb, []int{26} +} +func (m *UpsertVaultEventV1) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UpsertVaultEventV1) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UpsertVaultEventV1.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UpsertVaultEventV1) XXX_Merge(src proto.Message) { + xxx_messageInfo_UpsertVaultEventV1.Merge(m, src) +} +func (m *UpsertVaultEventV1) XXX_Size() int { + return m.Size() +} +func (m *UpsertVaultEventV1) XXX_DiscardUnknown() { + xxx_messageInfo_UpsertVaultEventV1.DiscardUnknown(m) +} + +var xxx_messageInfo_UpsertVaultEventV1 proto.InternalMessageInfo + +func (m *UpsertVaultEventV1) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *UpsertVaultEventV1) GetClobPairId() uint32 { + if m != nil { + return m.ClobPairId + } + return 0 +} + +func (m *UpsertVaultEventV1) GetStatus() types.VaultStatus { + if m != nil { + return m.Status + } + return types.VaultStatus_VAULT_STATUS_UNSPECIFIED +} + func init() { proto.RegisterEnum("dydxprotocol.indexer.events.FundingEventV1_Type", FundingEventV1_Type_name, FundingEventV1_Type_value) proto.RegisterType((*FundingUpdateV1)(nil), "dydxprotocol.indexer.events.FundingUpdateV1") @@ -2634,6 +2698,7 @@ func init() { proto.RegisterType((*OpenInterestUpdate)(nil), "dydxprotocol.indexer.events.OpenInterestUpdate") proto.RegisterType((*LiquidityTierUpsertEventV2)(nil), "dydxprotocol.indexer.events.LiquidityTierUpsertEventV2") proto.RegisterType((*RegisterAffiliateEventV1)(nil), "dydxprotocol.indexer.events.RegisterAffiliateEventV1") + proto.RegisterType((*UpsertVaultEventV1)(nil), "dydxprotocol.indexer.events.UpsertVaultEventV1") } func init() { @@ -2641,157 +2706,160 @@ func init() { } var fileDescriptor_6331dfb59c6fd2bb = []byte{ - // 2392 bytes of a gzipped FileDescriptorProto + // 2439 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x5a, 0xcd, 0x6f, 0x23, 0x49, - 0x15, 0x4f, 0xdb, 0x8e, 0xe3, 0x3c, 0xc7, 0x19, 0xbb, 0xc6, 0xc9, 0x38, 0x09, 0x64, 0x86, 0x96, - 0x90, 0x46, 0xfb, 0xe1, 0x4c, 0xc2, 0xee, 0x6a, 0xb5, 0x07, 0x44, 0x9c, 0x8f, 0x8d, 0xa3, 0x24, - 0xe3, 0xad, 0x24, 0xb3, 0xbb, 0x03, 0xda, 0xa6, 0xd3, 0x5d, 0x76, 0x4a, 0xe9,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4, 0x37, 0x85, - 0xf3, 0x41, 0x87, 0x8a, 0xde, 0x85, 0x82, 0x52, 0x6c, 0x85, 0x84, 0x83, 0xa7, 0x05, 0xf8, 0x83, - 0x09, 0xc0, 0xb7, 0x84, 0x40, 0x07, 0x77, 0xce, 0xed, 0x22, 0x77, 0x01, 0xbb, 0xbe, 0x4d, 0x9b, - 0x57, 0x95, 0xcc, 0xc4, 0xc0, 0x87, 0x42, 0x60, 0x00, 0x58, 0x92, 0x6b, 0x33, 0x30, 0x2d, 0x66, - 0xeb, 0xfb, 0x50, 0x19, 0xb5, 0x4a, 0x54, 0x85, 0xdb, 0xd2, 0x65, 0x4f, 0x69, 0x74, 0x6e, 0x90, - 0x0f, 0x03, 0xdf, 0x23, 0x5e, 0x24, 0x3c, 0x9b, 0xc1, 0x25, 0xc1, 0x7a, 0x97, 0x46, 0xe7, 0x3b, - 0x8a, 0xa1, 0xbf, 0x07, 0x25, 0x89, 0x55, 0x33, 0x59, 0x02, 0x82, 0x20, 0x13, 0x98, 0x34, 0x14, - 0x52, 0xb3, 0x58, 0xfc, 0x46, 0x6b, 0x50, 0x76, 0xa9, 0x67, 0x48, 0x70, 0xeb, 0xdc, 0xf4, 0x5a, - 0x9d, 0xed, 0x56, 0xc0, 0x25, 0x97, 0x7a, 0xc2, 0x9a, 0x2d, 0xc1, 0x69, 0x04, 0xae, 0xde, 0x86, - 0xdb, 0x43, 0xdc, 0x85, 0x6a, 0x90, 0x39, 0x33, 0x19, 0x11, 0xd8, 0xf9, 0x8d, 0xea, 0x04, 0x5e, - 0xe9, 0xb2, 0x0c, 0x0b, 0x59, 0xb4, 0x0c, 0xb9, 0x64, 0x65, 0x5c, 0x7f, 0x09, 0x27, 0x63, 0xfd, - 0xfd, 0x58, 0x6d, 0x8f, 0x33, 0x6f, 0x42, 0xad, 0xfe, 0x3b, 0x0d, 0x0a, 0xc7, 0x7e, 0x3b, 0xb4, - 0xc8, 0xc3, 0x26, 0xdf, 0x52, 0x0c, 0x7d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x34, 0x7c, - 0xce, 0x19, 0x9f, 0xbc, 0x43, 0x1c, 0x27, 0xf0, 0xd4, 0xc5, 0x01, 0x02, 0x48, 0x50, 0xd0, 0x2e, - 0x4c, 0x4b, 0xc0, 0xd4, 0x17, 0x01, 0xdc, 0x9b, 0xc2, 0x52, 0x1c, 0x7d, 0x00, 0x25, 0x87, 0x3e, - 0x69, 0x53, 0xdb, 0x8c, 0xa8, 0xef, 0x29, 0x23, 0xe5, 0x71, 0xb7, 0x36, 0xd6, 0x0b, 0x07, 0x1d, - 0x29, 0x01, 0x29, 0x4e, 0xbb, 0xa2, 0xd3, 0x47, 0x45, 0x77, 0x21, 0xdf, 0xa4, 0x8e, 0x63, 0xa8, - 0xf0, 0xa5, 0x45, 0xf8, 0x80, 0x93, 0x36, 0x65, 0x08, 0xc5, 0xed, 0xc1, 0xfd, 0xd3, 0x24, 0x44, - 0x44, 0x11, 0xf1, 0xdb, 0xe3, 0x82, 0x84, 0xbb, 0x84, 0x70, 0x66, 0x94, 0x30, 0xb3, 0x92, 0x19, - 0xc5, 0xcc, 0x57, 0x00, 0x45, 0x7e, 0x64, 0x3a, 0x06, 0x47, 0x23, 0xb6, 0x21, 0xa4, 0x2a, 0x33, - 0x42, 0x43, 0x51, 0x70, 0x76, 0x05, 0xe3, 0x90, 0xd3, 0x07, 0x66, 0x0b, 0x98, 0x4a, 0x6e, 0x60, - 0xf6, 0x89, 0x98, 0x5d, 0x85, 0xdb, 0x66, 0xb3, 0x49, 0x1d, 0x6a, 0x46, 0xc4, 0x08, 0xc9, 0xa5, - 0x21, 0x8a, 0xb1, 0xca, 0xac, 0x3c, 0x83, 0x13, 0x16, 0x26, 0x97, 0xc7, 0x9c, 0x51, 0x2b, 0x40, - 0x3e, 0xea, 0x44, 0x59, 0xff, 0x71, 0x1a, 0x6e, 0x6f, 0x13, 0x87, 0x5c, 0x92, 0xd0, 0x6c, 0x75, - 0xd5, 0x0f, 0xdf, 0x06, 0x88, 0x3d, 0x44, 0xae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, 0x47, 0x8a, 0xbf, 0x9f, 0xc9, 0x65, 0x8b, 0x33, - 0xfb, 0x99, 0xdc, 0x4c, 0x31, 0x87, 0xef, 0xf8, 0x01, 0xf1, 0x0c, 0xae, 0x20, 0x24, 0x2c, 0x32, - 0x1c, 0xff, 0x29, 0x09, 0x0d, 0xcb, 0x0c, 0xfa, 0x19, 0xed, 0x20, 0x90, 0x0c, 0xfd, 0x97, 0x29, - 0x58, 0x90, 0x8f, 0xac, 0x38, 0x13, 0x63, 0xef, 0xf4, 0xef, 0x11, 0x6d, 0x60, 0x8f, 0x74, 0xd2, - 0x3d, 0xf5, 0xe5, 0xa6, 0x7b, 0xfa, 0x79, 0xe9, 0x3e, 0x34, 0x83, 0x33, 0x2f, 0x92, 0xc1, 0xd3, - 0xc3, 0x33, 0x58, 0xff, 0xbd, 0x06, 0x8b, 0xd2, 0x3f, 0x49, 0xb2, 0x8d, 0xb9, 0xca, 0xd4, 0x91, - 0x91, 0x1a, 0x7d, 0x64, 0xa4, 0x27, 0xb9, 0xab, 0x32, 0x23, 0x36, 0xea, 0xe0, 0x76, 0x9a, 0x1e, - 0xb2, 0x9d, 0x74, 0x06, 0x0b, 0x27, 0xa1, 0x69, 0x53, 0xaf, 0x85, 0xc9, 0x53, 0x33, 0xb4, 0x59, - 0xe7, 0xfd, 0x7c, 0x2b, 0x92, 0x0c, 0x23, 0x94, 0x1c, 0xf5, 0x95, 0x68, 0x7d, 0x6c, 0x11, 0xad, - 0xda, 0xc0, 0x3d, 0x98, 0x78, 0x3e, 0xea, 0x51, 0xa1, 0xff, 0x42, 0x83, 0xf2, 0xb0, 0x89, 0xa8, - 0x0c, 0xd3, 0xfe, 0x53, 0x8f, 0xc4, 0x9d, 0x7e, 0x39, 0x40, 0x17, 0x30, 0x67, 0x13, 0xcf, 0x77, - 0xe3, 0x66, 0x4c, 0xea, 0x86, 0xbf, 0x94, 0xe5, 0x05, 0xba, 0xec, 0xeb, 0xe8, 0x3f, 0xd0, 0x60, - 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, 0x97, + 0x21, 0x14, 0xb7, 0x07, 0xf7, 0x4f, 0x93, 0x10, 0x11, 0x45, 0xc4, 0x6f, 0x8f, 0x73, 0x12, 0x6e, + 0x13, 0xc2, 0x99, 0x51, 0xc2, 0xcc, 0x4a, 0x66, 0x14, 0x33, 0x5f, 0x01, 0x14, 0xf9, 0x11, 0x76, + 0x4c, 0x8e, 0x46, 0x6c, 0x53, 0x48, 0x55, 0x66, 0x84, 0x86, 0xa2, 0xe0, 0x6c, 0x0b, 0xc6, 0x3e, + 0xa7, 0x0f, 0xcc, 0x16, 0x30, 0x95, 0xdc, 0xc0, 0xec, 0x23, 0x31, 0xbb, 0x0a, 0xb7, 0x71, 0xb3, + 0x49, 0x1d, 0x8a, 0x23, 0x62, 0x86, 0xe4, 0xc2, 0x14, 0xa5, 0x5b, 0x65, 0x56, 0x9e, 0xc1, 0x09, + 0xcb, 0x20, 0x17, 0x87, 0x9c, 0x51, 0x2b, 0x40, 0x3e, 0xea, 0x44, 0x59, 0xff, 0x71, 0x1a, 0x6e, + 0x6f, 0x12, 0x87, 0x5c, 0x90, 0x10, 0xb7, 0xba, 0xea, 0x87, 0x6f, 0x03, 0xc4, 0x1e, 0x22, 0xd7, + 0xdb, 0xb0, 0x71, 0x4a, 0x74, 0xe0, 0x38, 0xb8, 0xdf, 0x6c, 0x32, 0x12, 0x45, 0xd4, 0x6b, 0x5d, + 0x6b, 0x87, 0xc6, 0xe0, 0x1d, 0xb8, 0x81, 0x52, 0x2e, 0x3d, 0x58, 0xca, 0xf5, 0x85, 0x3a, 0x33, + 0x10, 0xea, 0x87, 0x50, 0x96, 0x21, 0x78, 0xda, 0xf6, 0x23, 0x62, 0x3e, 0x6d, 0x63, 0x2f, 0x6a, + 0xbb, 0x4c, 0x44, 0x3d, 0x63, 0xc8, 0xf0, 0xbc, 0xc3, 0x59, 0xef, 0x28, 0x0e, 0x5a, 0x80, 0x2c, + 0x65, 0xe6, 0x69, 0xfb, 0x52, 0x04, 0x3f, 0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x12, 0xe6, 0x3b, 0x6d, 0x9e, 0x31, 0xe2, + 0x40, 0x2f, 0x19, 0x45, 0xc9, 0x30, 0x12, 0xba, 0xfe, 0xe7, 0x34, 0x7c, 0x25, 0xb9, 0x92, 0x87, + 0x35, 0x13, 0xfa, 0x2d, 0xbe, 0xba, 0x6e, 0x5a, 0x84, 0x2c, 0xaf, 0x65, 0x48, 0x28, 0xec, 0x9e, + 0x35, 0xd4, 0x68, 0xbc, 0xd1, 0x3b, 0x90, 0x65, 0x11, 0x8e, 0xda, 0xb2, 0xda, 0x9c, 0x9f, 0x24, + 0xb0, 0x1b, 0x4a, 0xe5, 0xa1, 0x90, 0x33, 0x94, 0x3c, 0xfa, 0x26, 0xac, 0xa8, 0xca, 0xd5, 0xb4, + 0x7c, 0xef, 0x82, 0x84, 0x8c, 0x3f, 0x9c, 0x92, 0x66, 0x46, 0x56, 0x38, 0x62, 0x49, 0x4d, 0xd9, + 0x48, 0x66, 0xc4, 0xed, 0x9a, 0xe1, 0xee, 0x9b, 0x19, 0xee, 0x3e, 0xf4, 0x12, 0x94, 0xe2, 0xd2, + 0x8d, 0xd7, 0x4d, 0x26, 0xff, 0x25, 0x4e, 0xe6, 0x82, 0x71, 0x2b, 0x66, 0x34, 0x48, 0x78, 0x44, + 0xad, 0x73, 0xfe, 0xc2, 0x61, 0x11, 0x09, 0xcc, 0x53, 0xcc, 0xba, 0x8a, 0x6b, 0xf9, 0x64, 0x29, + 0x72, 0x4e, 0x0d, 0xb3, 0x4e, 0x69, 0xfd, 0x75, 0x98, 0x97, 0xd5, 0x2a, 0x8d, 0x2e, 0xcd, 0x88, + 0x92, 0xb0, 0x02, 0x02, 0xb6, 0x90, 0x50, 0x8f, 0x28, 0x09, 0xdf, 0x4a, 0x55, 0x34, 0xfd, 0xe7, + 0x99, 0xb1, 0x31, 0x5c, 0xfb, 0x7f, 0x0c, 0xff, 0xab, 0x63, 0x88, 0x4e, 0x20, 0xaf, 0x9c, 0x2a, + 0xda, 0xc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1b, + 0x38, 0x18, 0x14, 0x4b, 0xce, 0x51, 0xd5, 0xd5, 0x2d, 0xf7, 0x86, 0x3e, 0x10, 0x62, 0xfa, 0x0f, + 0x35, 0xa8, 0x18, 0xa4, 0x45, 0x59, 0x44, 0xc2, 0xf5, 0xb8, 0x33, 0x1b, 0x67, 0xdf, 0x1a, 0xcc, + 0x84, 0xa4, 0x49, 0x42, 0x22, 0x1b, 0x2d, 0x63, 0x3e, 0xc0, 0x18, 0xf1, 0x44, 0xf4, 0x06, 0xcc, + 0x26, 0x1d, 0xde, 0xab, 0x3e, 0xdb, 0x18, 0x9d, 0xa9, 0xfc, 0x30, 0x43, 0x32, 0x9c, 0x27, 0xb8, + 0xed, 0x44, 0x5d, 0x26, 0xc4, 0xdf, 0x80, 0xae, 0x34, 0x41, 0x4d, 0x9c, 0xa0, 0x82, 0xda, 0x4a, + 0x6e, 0x87, 0xb4, 0xb8, 0x1d, 0x5e, 0xbd, 0xfa, 0x76, 0x10, 0x56, 0xf5, 0x5e, 0x0d, 0x35, 0xe3, + 0xe3, 0xcf, 0xee, 0x6a, 0x9f, 0x7c, 0x76, 0x57, 0xfb, 0xd7, 0x67, 0x77, 0xb5, 0x9f, 0x7e, 0x7e, + 0x77, 0xea, 0x93, 0xcf, 0xef, 0x4e, 0xfd, 0xfd, 0xf3, 0xbb, 0x53, 0x4f, 0xde, 0x9c, 0x3c, 0xf3, + 0x7b, 0xff, 0xaf, 0xe2, 0x34, 0x2b, 0x18, 0xdf, 0xf8, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xac, + 0xfe, 0xc7, 0x4a, 0x7d, 0x21, 0x00, 0x00, } func (m *FundingUpdateV1) Marshal() (dAtA []byte, err error) { @@ -4575,6 +4643,46 @@ func (m *RegisterAffiliateEventV1) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *UpsertVaultEventV1) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UpsertVaultEventV1) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UpsertVaultEventV1) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if m.ClobPairId != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.ClobPairId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -5387,6 +5495,25 @@ func (m *RegisterAffiliateEventV1) Size() (n int) { return n } +func (m *UpsertVaultEventV1) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.ClobPairId != 0 { + n += 1 + sovEvents(uint64(m.ClobPairId)) + } + if m.Status != 0 { + n += 1 + sovEvents(uint64(m.Status)) + } + return n +} + func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -10005,6 +10132,126 @@ func (m *RegisterAffiliateEventV1) Unmarshal(dAtA []byte) error { } return nil } +func (m *UpsertVaultEventV1) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UpsertVaultEventV1: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UpsertVaultEventV1: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ClobPairId", wireType) + } + m.ClobPairId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ClobPairId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= types.VaultStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/protocol/indexer/events/upsert_vault.go b/protocol/indexer/events/upsert_vault.go new file mode 100644 index 0000000000..b0e7ac8756 --- /dev/null +++ b/protocol/indexer/events/upsert_vault.go @@ -0,0 +1,21 @@ +package events + +import ( + v1 "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1" + clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +// NewUpsertVaultEvent creates a UpsertVaultEventV1 +// representing an create / update of a vault. +func NewUpsertVaultEvent( + vaultAddress string, + clobPairId clobtypes.ClobPairId, + status types.VaultStatus, +) *UpsertVaultEventV1 { + return &UpsertVaultEventV1{ + Address: vaultAddress, + ClobPairId: uint32(clobPairId), + Status: v1.VaultStatusToIndexerVaultStatus(status), + } +} diff --git a/protocol/indexer/events/upsert_vault_test.go b/protocol/indexer/events/upsert_vault_test.go new file mode 100644 index 0000000000..fb05b4a78d --- /dev/null +++ b/protocol/indexer/events/upsert_vault_test.go @@ -0,0 +1,26 @@ +package events_test + +import ( + "testing" + + "github.com/dydxprotocol/v4-chain/protocol/indexer/events" + v1types "github.com/dydxprotocol/v4-chain/protocol/indexer/protocol/v1/types" + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" + + "github.com/stretchr/testify/require" +) + +func TestNewUpsertVaultEvent_Success(t *testing.T) { + upsertVaultEvent := events.NewUpsertVaultEvent( + constants.Alice_Num0.Owner, + 0, + vaulttypes.VaultStatus_VAULT_STATUS_QUOTING, + ) + expectedUpsertVaultEventProto := &events.UpsertVaultEventV1{ + Address: constants.Alice_Num0.Owner, + ClobPairId: 0, + Status: v1types.VaultStatus_VAULT_STATUS_QUOTING, + } + require.Equal(t, expectedUpsertVaultEventProto, upsertVaultEvent) +} diff --git a/protocol/indexer/protocol/v1/types/vault.pb.go b/protocol/indexer/protocol/v1/types/vault.pb.go new file mode 100644 index 0000000000..b6876aeaa2 --- /dev/null +++ b/protocol/indexer/protocol/v1/types/vault.pb.go @@ -0,0 +1,89 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/indexer/protocol/v1/vault.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// VaultStatus represents the status of a vault. +type VaultStatus int32 + +const ( + // Default value, invalid and unused. + VaultStatus_VAULT_STATUS_UNSPECIFIED VaultStatus = 0 + // Don’t place orders. Does not count toward global vault balances. + VaultStatus_VAULT_STATUS_DEACTIVATED VaultStatus = 1 + // Don’t place orders. Does count towards global vault balances. + VaultStatus_VAULT_STATUS_STAND_BY VaultStatus = 2 + // Places orders on both sides of the book. + VaultStatus_VAULT_STATUS_QUOTING VaultStatus = 3 + // Only place orders that close the position. + VaultStatus_VAULT_STATUS_CLOSE_ONLY VaultStatus = 4 +) + +var VaultStatus_name = map[int32]string{ + 0: "VAULT_STATUS_UNSPECIFIED", + 1: "VAULT_STATUS_DEACTIVATED", + 2: "VAULT_STATUS_STAND_BY", + 3: "VAULT_STATUS_QUOTING", + 4: "VAULT_STATUS_CLOSE_ONLY", +} + +var VaultStatus_value = map[string]int32{ + "VAULT_STATUS_UNSPECIFIED": 0, + "VAULT_STATUS_DEACTIVATED": 1, + "VAULT_STATUS_STAND_BY": 2, + "VAULT_STATUS_QUOTING": 3, + "VAULT_STATUS_CLOSE_ONLY": 4, +} + +func (x VaultStatus) String() string { + return proto.EnumName(VaultStatus_name, int32(x)) +} + +func (VaultStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_05be1c6a873a495b, []int{0} +} + +func init() { + proto.RegisterEnum("dydxprotocol.indexer.protocol.v1.VaultStatus", VaultStatus_name, VaultStatus_value) +} + +func init() { + proto.RegisterFile("dydxprotocol/indexer/protocol/v1/vault.proto", fileDescriptor_05be1c6a873a495b) +} + +var fileDescriptor_05be1c6a873a495b = []byte{ + // 244 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x49, 0xa9, 0x4c, 0xa9, + 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0xcf, 0xcc, 0x4b, 0x49, 0xad, 0x48, 0x2d, + 0xd2, 0x87, 0x0b, 0x94, 0x19, 0xea, 0x97, 0x25, 0x96, 0xe6, 0x94, 0xe8, 0x81, 0x45, 0x84, 0x14, + 0x90, 0x55, 0xeb, 0x41, 0x55, 0xeb, 0xc1, 0x05, 0xca, 0x0c, 0xb5, 0x66, 0x33, 0x72, 0x71, 0x87, + 0x81, 0x74, 0x04, 0x97, 0x24, 0x96, 0x94, 0x16, 0x0b, 0xc9, 0x70, 0x49, 0x84, 0x39, 0x86, 0xfa, + 0x84, 0xc4, 0x07, 0x87, 0x38, 0x86, 0x84, 0x06, 0xc7, 0x87, 0xfa, 0x05, 0x07, 0xb8, 0x3a, 0x7b, + 0xba, 0x79, 0xba, 0xba, 0x08, 0x30, 0x60, 0xc8, 0xba, 0xb8, 0x3a, 0x3a, 0x87, 0x78, 0x86, 0x39, + 0x86, 0xb8, 0xba, 0x08, 0x30, 0x0a, 0x49, 0x72, 0x89, 0xa2, 0xc8, 0x06, 0x87, 0x38, 0xfa, 0xb9, + 0xc4, 0x3b, 0x45, 0x0a, 0x30, 0x09, 0x49, 0x70, 0x89, 0xa0, 0x48, 0x05, 0x86, 0xfa, 0x87, 0x78, + 0xfa, 0xb9, 0x0b, 0x30, 0x0b, 0x49, 0x73, 0x89, 0xa3, 0xc8, 0x38, 0xfb, 0xf8, 0x07, 0xbb, 0xc6, + 0xfb, 0xfb, 0xf9, 0x44, 0x0a, 0xb0, 0x38, 0xc5, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, + 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, + 0x1c, 0x43, 0x94, 0x73, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0x4a, + 0x90, 0x94, 0x99, 0xe8, 0x26, 0x67, 0x24, 0x66, 0xe6, 0xe9, 0xe3, 0x0d, 0xa4, 0x92, 0xca, 0x82, + 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x90, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xe8, 0x67, 0x74, 0x34, + 0x55, 0x01, 0x00, 0x00, +} diff --git a/protocol/indexer/protocol/v1/v1_mappers.go b/protocol/indexer/protocol/v1/v1_mappers.go index 917ed71b89..f9a3264f48 100644 --- a/protocol/indexer/protocol/v1/v1_mappers.go +++ b/protocol/indexer/protocol/v1/v1_mappers.go @@ -8,6 +8,7 @@ import ( clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" ) func SubaccountIdToIndexerSubaccountId( @@ -205,3 +206,7 @@ func ConvertToPerpetualMarketType(marketType perptypes.PerpetualMarketType) v1ty ) } } + +func VaultStatusToIndexerVaultStatus(vaultStatus vaulttypes.VaultStatus) v1types.VaultStatus { + return v1types.VaultStatus(vaultStatus) +} diff --git a/protocol/indexer/protocol/v1/v1_mappers_test.go b/protocol/indexer/protocol/v1/v1_mappers_test.go index 26e8312b61..f5825c2d95 100644 --- a/protocol/indexer/protocol/v1/v1_mappers_test.go +++ b/protocol/indexer/protocol/v1/v1_mappers_test.go @@ -11,6 +11,7 @@ import ( clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + vaulttypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" "github.com/stretchr/testify/require" ) @@ -473,3 +474,33 @@ func TestConvertToPerpetualMarketType(t *testing.T) { }) } } + +func TestVaultStatusToIndexerVaultStatus(t *testing.T) { + tests := map[string]struct { + // Input + vaultStatus vaulttypes.VaultStatus + + // Expectations + expectedVaultStatus v1types.VaultStatus + }{} + // Iterate through all the values for VaultStatus to create test cases. + for name, value := range vaulttypes.VaultStatus_value { + testName := fmt.Sprintf("Converts VaultStatus %s to IndexerVaultStatus", name) + tests[testName] = struct { + vaultStatus vaulttypes.VaultStatus + expectedVaultStatus v1types.VaultStatus + }{ + vaultStatus: vaulttypes.VaultStatus(value), + expectedVaultStatus: v1types.VaultStatus(v1types.VaultStatus_value[name]), + } + } + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + require.Equal( + t, + tc.expectedVaultStatus, + v1.VaultStatusToIndexerVaultStatus(tc.vaultStatus), + ) + }) + } +} From d964f26e8079d4329a15814791b0f138dc712131 Mon Sep 17 00:00:00 2001 From: Mohammed Affan <affan@dydx.exchange> Date: Mon, 16 Sep 2024 11:08:02 -0400 Subject: [PATCH 07/12] [OTE-695] Aggregate referred volume in endblocker (#2218) --- protocol/x/affiliates/abci.go | 19 +++ protocol/x/affiliates/keeper/keeper.go | 33 +++++ protocol/x/affiliates/keeper/keeper_test.go | 118 ++++++++++++++++++ protocol/x/affiliates/module.go | 8 ++ .../x/affiliates/types/expected_keepers.go | 2 + 5 files changed, 180 insertions(+) create mode 100644 protocol/x/affiliates/abci.go diff --git a/protocol/x/affiliates/abci.go b/protocol/x/affiliates/abci.go new file mode 100644 index 0000000000..ccffe2ff8e --- /dev/null +++ b/protocol/x/affiliates/abci.go @@ -0,0 +1,19 @@ +package affiliates + +import ( + "runtime/debug" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dydxprotocol/v4-chain/protocol/lib/log" + "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/keeper" +) + +func EndBlocker( + ctx sdk.Context, + keeper *keeper.Keeper, +) { + if err := keeper.AggregateAffiliateReferredVolumeForFills(ctx); err != nil { + log.ErrorLog(ctx, "error aggregating affiliate volume for fills", "error", + err, "stack", string(debug.Stack())) + } +} diff --git a/protocol/x/affiliates/keeper/keeper.go b/protocol/x/affiliates/keeper/keeper.go index 6193fdc194..e76d6d938e 100644 --- a/protocol/x/affiliates/keeper/keeper.go +++ b/protocol/x/affiliates/keeper/keeper.go @@ -258,3 +258,36 @@ func (k *Keeper) SetRevShareKeeper(revShareKeeper types.RevShareKeeper) { func (k Keeper) GetIndexerEventManager() indexer_manager.IndexerEventManager { return k.indexerEventManager } + +func (k Keeper) AggregateAffiliateReferredVolumeForFills( + ctx sdk.Context, +) error { + blockStats := k.statsKeeper.GetBlockStats(ctx) + referredByCache := make(map[string]string) + for _, fill := range blockStats.Fills { + // Add taker's referred volume to the cache + if _, ok := referredByCache[fill.Taker]; !ok { + referredByAddrTaker, found := k.GetReferredBy(ctx, fill.Taker) + if !found { + continue + } + referredByCache[fill.Taker] = referredByAddrTaker + } + if err := k.AddReferredVolume(ctx, referredByCache[fill.Taker], lib.BigU(fill.Notional)); err != nil { + return err + } + + // Add maker's referred volume to the cache + if _, ok := referredByCache[fill.Maker]; !ok { + referredByAddrMaker, found := k.GetReferredBy(ctx, fill.Maker) + if !found { + continue + } + referredByCache[fill.Maker] = referredByAddrMaker + } + if err := k.AddReferredVolume(ctx, referredByCache[fill.Maker], lib.BigU(fill.Notional)); err != nil { + return err + } + } + return nil +} diff --git a/protocol/x/affiliates/keeper/keeper_test.go b/protocol/x/affiliates/keeper/keeper_test.go index 358dcfc68b..0488c538a6 100644 --- a/protocol/x/affiliates/keeper/keeper_test.go +++ b/protocol/x/affiliates/keeper/keeper_test.go @@ -16,6 +16,7 @@ import ( keepertest "github.com/dydxprotocol/v4-chain/protocol/testutil/keeper" "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/keeper" "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types" + statskeeper "github.com/dydxprotocol/v4-chain/protocol/x/stats/keeper" statstypes "github.com/dydxprotocol/v4-chain/protocol/x/stats/types" "github.com/stretchr/testify/require" ) @@ -392,3 +393,120 @@ func TestRegisterAffiliateEmitEvent(t *testing.T) { require.Equal(t, 1, len(events)) require.Equal(t, expectedEvent, events[0]) } + +func TestAggregateAffiliateReferredVolumeForFills(t *testing.T) { + affiliate := constants.AliceAccAddress.String() + referee1 := constants.BobAccAddress.String() + referee2 := constants.DaveAccAddress.String() + maker := constants.CarlAccAddress.String() + testCases := []struct { + name string + referrals int + expectedVolume *big.Int + setup func(t *testing.T, ctx sdk.Context, k *keeper.Keeper, statsKeeper *statskeeper.Keeper) + }{ + { + name: "0 referrals", + expectedVolume: big.NewInt(0), + setup: func(t *testing.T, ctx sdk.Context, k *keeper.Keeper, statsKeeper *statskeeper.Keeper) { + statsKeeper.SetBlockStats(ctx, &statstypes.BlockStats{ + Fills: []*statstypes.BlockStats_Fill{ + { + Taker: referee1, + Maker: maker, + Notional: 100_000_000_000, + }, + }, + }) + }, + }, + { + name: "1 referral", + referrals: 1, + expectedVolume: big.NewInt(100_000_000_000), + setup: func(t *testing.T, ctx sdk.Context, k *keeper.Keeper, statsKeeper *statskeeper.Keeper) { + err := k.RegisterAffiliate(ctx, referee1, affiliate) + require.NoError(t, err) + statsKeeper.SetBlockStats(ctx, &statstypes.BlockStats{ + Fills: []*statstypes.BlockStats_Fill{ + { + Taker: referee1, + Maker: maker, + Notional: 100_000_000_000, + }, + }, + }) + }, + }, + { + name: "2 referrals", + referrals: 2, + expectedVolume: big.NewInt(300_000_000_000), + setup: func(t *testing.T, ctx sdk.Context, k *keeper.Keeper, statsKeeper *statskeeper.Keeper) { + err := k.RegisterAffiliate(ctx, referee1, affiliate) + require.NoError(t, err) + err = k.RegisterAffiliate(ctx, referee2, affiliate) + require.NoError(t, err) + statsKeeper.SetBlockStats(ctx, &statstypes.BlockStats{ + Fills: []*statstypes.BlockStats_Fill{ + { + Taker: referee1, + Maker: maker, + Notional: 100_000_000_000, + }, + { + Taker: referee2, + Maker: maker, + Notional: 200_000_000_000, + }, + }, + }) + }, + }, + { + name: "2 referrals, maker also referred", + referrals: 2, + expectedVolume: big.NewInt(600_000_000_000), + setup: func(t *testing.T, ctx sdk.Context, k *keeper.Keeper, statsKeeper *statskeeper.Keeper) { + err := k.RegisterAffiliate(ctx, referee1, affiliate) + require.NoError(t, err) + err = k.RegisterAffiliate(ctx, referee2, affiliate) + require.NoError(t, err) + err = k.RegisterAffiliate(ctx, maker, affiliate) + require.NoError(t, err) + statsKeeper.SetBlockStats(ctx, &statstypes.BlockStats{ + Fills: []*statstypes.BlockStats_Fill{ + { + Taker: referee1, + Maker: maker, + Notional: 100_000_000_000, + }, + { + Taker: referee2, + Maker: maker, + Notional: 200_000_000_000, + }, + }, + }) + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.AffiliatesKeeper + statsKeeper := tApp.App.StatsKeeper + + tc.setup(t, ctx, &k, &statsKeeper) + + err := k.AggregateAffiliateReferredVolumeForFills(ctx) + require.NoError(t, err) + + referredVolume, err := k.GetReferredVolume(ctx, affiliate) + require.NoError(t, err) + require.Equal(t, tc.expectedVolume, referredVolume) + }) + } +} diff --git a/protocol/x/affiliates/module.go b/protocol/x/affiliates/module.go index 08681594a6..946dcd2857 100644 --- a/protocol/x/affiliates/module.go +++ b/protocol/x/affiliates/module.go @@ -14,6 +14,7 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/dydxprotocol/v4-chain/protocol/lib" "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/client/cli" "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/keeper" "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types" @@ -141,3 +142,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should // be set to 1. func (AppModule) ConsensusVersion() uint64 { return 1 } + +func (am AppModule) EndBlock(ctx sdk.Context) { + EndBlocker( + lib.UnwrapSDKContext(ctx, types.ModuleName), + &am.keeper, + ) +} diff --git a/protocol/x/affiliates/types/expected_keepers.go b/protocol/x/affiliates/types/expected_keepers.go index 2708603f4a..1a60b73dfc 100644 --- a/protocol/x/affiliates/types/expected_keepers.go +++ b/protocol/x/affiliates/types/expected_keepers.go @@ -5,10 +5,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" revsharetypes "github.com/dydxprotocol/v4-chain/protocol/x/revshare/types" + stattypes "github.com/dydxprotocol/v4-chain/protocol/x/stats/types" ) type StatsKeeper interface { GetStakedAmount(ctx sdk.Context, delegatorAddr string) *big.Int + GetBlockStats(ctx sdk.Context) *stattypes.BlockStats } type RevShareKeeper interface { From 85222463a9dc5da76e2ee4b6c54fade81f060812 Mon Sep 17 00:00:00 2001 From: jayy04 <103467857+jayy04@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:15:46 -0400 Subject: [PATCH 08/12] =?UTF-8?q?[CT-1179]=20add=20licensing=20info=20for?= =?UTF-8?q?=20x/accountplus=20and=20attributions=20to=20Os=E2=80=A6=20(#21?= =?UTF-8?q?82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocol/x/accountplus/LICENSE | 178 +++++++++++++++++++++++++++++++ protocol/x/accountplus/README.md | 13 +++ 2 files changed, 191 insertions(+) create mode 100644 protocol/x/accountplus/LICENSE create mode 100644 protocol/x/accountplus/README.md diff --git a/protocol/x/accountplus/LICENSE b/protocol/x/accountplus/LICENSE new file mode 100644 index 0000000000..fa885749ed --- /dev/null +++ b/protocol/x/accountplus/LICENSE @@ -0,0 +1,178 @@ +This module incorporates code from the x/smart-account module from Osmosis Foundation Ltd, which is subject to the following license: + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/protocol/x/accountplus/README.md b/protocol/x/accountplus/README.md new file mode 100644 index 0000000000..be06ece285 --- /dev/null +++ b/protocol/x/accountplus/README.md @@ -0,0 +1,13 @@ +<ins>**Attribution; Modification**.</ins> + +This module incorporates code from [Osmosis](https://github.com/osmosis-labs/osmosis)'s `x/smart-account` [module](https://github.com/osmosis-labs/osmosis/tree/main/x/smart-account), which is subject to [this License](https://github.com/osmosis-labs/osmosis?tab=Apache-2.0-1-ov-file) and has been modified by us. + +Copyright for smart account attributed to 2021 Osmosis Foundation Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. From 03454e4b2213189712a61b30df1091eaff829343 Mon Sep 17 00:00:00 2001 From: Mohammed Affan <affan@dydx.exchange> Date: Mon, 16 Sep 2024 11:58:47 -0400 Subject: [PATCH 09/12] [OTE-780] Add client code for affiliates (#2252) --- .../dydxprotocol/affiliates/genesis.ts | 28 +++++-- proto/dydxprotocol/affiliates/genesis.proto | 7 +- .../app/testdata/default_genesis_state.json | 6 +- .../scripts/genesis/sample_pregenesis.json | 8 +- protocol/x/affiliates/client/cli/query.go | 72 ++++++++++++++++++ .../x/affiliates/client/cli/query_test.go | 74 +++++++++++++++++++ protocol/x/affiliates/client/cli/tx.go | 24 ++++++ protocol/x/affiliates/genesis.go | 13 +++- protocol/x/affiliates/keeper/grpc_query.go | 6 +- .../x/affiliates/keeper/grpc_query_test.go | 4 +- protocol/x/affiliates/types/genesis.go | 6 +- protocol/x/affiliates/types/genesis.pb.go | 74 +++++++++++++++++-- protocol/x/revshare/keeper/revshare_test.go | 3 +- 13 files changed, 298 insertions(+), 27 deletions(-) create mode 100644 protocol/x/affiliates/client/cli/query_test.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/genesis.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/genesis.ts index 75fa8edfa3..17ec53fdf6 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/genesis.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/affiliates/genesis.ts @@ -1,18 +1,31 @@ +import { AffiliateTiers, AffiliateTiersSDKType } from "./affiliates"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial } from "../../helpers"; /** GenesisState defines generis state of `x/affiliates` */ -export interface GenesisState {} +export interface GenesisState { + /** The list of affiliate tiers */ + affiliateTiers?: AffiliateTiers; +} /** GenesisState defines generis state of `x/affiliates` */ -export interface GenesisStateSDKType {} +export interface GenesisStateSDKType { + /** The list of affiliate tiers */ + affiliate_tiers?: AffiliateTiersSDKType; +} function createBaseGenesisState(): GenesisState { - return {}; + return { + affiliateTiers: undefined + }; } export const GenesisState = { - encode(_: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.affiliateTiers !== undefined) { + AffiliateTiers.encode(message.affiliateTiers, writer.uint32(10).fork()).ldelim(); + } + return writer; }, @@ -25,6 +38,10 @@ export const GenesisState = { const tag = reader.uint32(); switch (tag >>> 3) { + case 1: + message.affiliateTiers = AffiliateTiers.decode(reader, reader.uint32()); + break; + default: reader.skipType(tag & 7); break; @@ -34,8 +51,9 @@ export const GenesisState = { return message; }, - fromPartial(_: DeepPartial<GenesisState>): GenesisState { + fromPartial(object: DeepPartial<GenesisState>): GenesisState { const message = createBaseGenesisState(); + message.affiliateTiers = object.affiliateTiers !== undefined && object.affiliateTiers !== null ? AffiliateTiers.fromPartial(object.affiliateTiers) : undefined; return message; } diff --git a/proto/dydxprotocol/affiliates/genesis.proto b/proto/dydxprotocol/affiliates/genesis.proto index 62315d2c44..4dd0dd2291 100644 --- a/proto/dydxprotocol/affiliates/genesis.proto +++ b/proto/dydxprotocol/affiliates/genesis.proto @@ -1,7 +1,12 @@ syntax = "proto3"; package dydxprotocol.affiliates; +import "gogoproto/gogo.proto"; +import "dydxprotocol/affiliates/affiliates.proto"; option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types"; // GenesisState defines generis state of `x/affiliates` -message GenesisState {} \ No newline at end of file +message GenesisState { + // The list of affiliate tiers + AffiliateTiers affiliate_tiers = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/protocol/app/testdata/default_genesis_state.json b/protocol/app/testdata/default_genesis_state.json index 970ae13312..a73a85e96b 100644 --- a/protocol/app/testdata/default_genesis_state.json +++ b/protocol/app/testdata/default_genesis_state.json @@ -13,7 +13,11 @@ } ] }, - "affiliates": {}, + "affiliates": { + "affiliate_tiers": { + "tiers": [] + } + }, "auth": { "params": { "max_memo_characters": "256", diff --git a/protocol/scripts/genesis/sample_pregenesis.json b/protocol/scripts/genesis/sample_pregenesis.json index 5925ef792a..f242459218 100644 --- a/protocol/scripts/genesis/sample_pregenesis.json +++ b/protocol/scripts/genesis/sample_pregenesis.json @@ -2,7 +2,11 @@ "app_hash": null, "app_name": "dydxprotocold", "app_state": { - "affiliates": {}, + "affiliates": { + "affiliate_tiers": { + "tiers": [] + } + }, "assets": { "assets": [ { @@ -3973,7 +3977,7 @@ ] } }, - "app_version": "5.2.1-19-g04197f43", + "app_version": "5.2.1-103-g5c95dd72", "chain_id": "dydx-sample-1", "consensus": { "params": { diff --git a/protocol/x/affiliates/client/cli/query.go b/protocol/x/affiliates/client/cli/query.go index f5145a6c05..872ba5443b 100644 --- a/protocol/x/affiliates/client/cli/query.go +++ b/protocol/x/affiliates/client/cli/query.go @@ -1,6 +1,7 @@ package cli import ( + "context" "fmt" "github.com/spf13/cobra" @@ -20,5 +21,76 @@ func GetQueryCmd(queryRoute string) *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand( + GetCmdQueryAffiliateTiers(), + GetCmdQueryAffiliateInfo(), + GetCmdQueryReferredBy(), + ) + return cmd +} + +func GetCmdQueryAffiliateTiers() *cobra.Command { + cmd := &cobra.Command{ + Use: "affiliate-tiers", + Short: "Query affiliate tiers", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.AllAffiliateTiers(context.Background(), &types.AllAffiliateTiersRequest{}) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} + +func GetCmdQueryAffiliateInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "affiliate-info [affiliate-address]", + Short: "Query affiliate info", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.AffiliateInfo(context.Background(), &types.AffiliateInfoRequest{ + Address: args[0], + }) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + return cmd +} + +func GetCmdQueryReferredBy() *cobra.Command { + cmd := &cobra.Command{ + Use: "referred-by [address]", + Short: "Query the referee that referred the given addresss", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.ReferredBy(context.Background(), &types.ReferredByRequest{ + Address: args[0], + }) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } return cmd } diff --git a/protocol/x/affiliates/client/cli/query_test.go b/protocol/x/affiliates/client/cli/query_test.go new file mode 100644 index 0000000000..036e64a404 --- /dev/null +++ b/protocol/x/affiliates/client/cli/query_test.go @@ -0,0 +1,74 @@ +package cli_test + +import ( + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + "github.com/dydxprotocol/v4-chain/protocol/testutil/network" + "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/client/cli" + "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func setupNetwork(t *testing.T) (*network.Network, client.Context) { + t.Helper() + cfg := network.DefaultConfig(nil) + + // Init state. + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + // Modify default genesis state + state = *types.DefaultGenesis() + + // Add test affiliate tiers + state.AffiliateTiers = types.DefaultAffiliateTiers + + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + net := network.New(t, cfg) + ctx := net.Validators[0].ClientCtx + + return net, ctx +} + +func TestQueryAffiliateTiers(t *testing.T) { + net, ctx := setupNetwork(t) + + out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdQueryAffiliateTiers(), []string{}) + require.NoError(t, err) + + var resp types.AllAffiliateTiersResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, types.DefaultAffiliateTiers, resp.Tiers) +} + +func TestQueryAffiliateInfo(t *testing.T) { + net, ctx := setupNetwork(t) + + testAddress := constants.AliceAccAddress.String() + out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdQueryAffiliateInfo(), []string{testAddress}) + require.NoError(t, err) + + var resp types.AffiliateInfoResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +} + +func TestQueryReferredBy(t *testing.T) { + net, ctx := setupNetwork(t) + + testAddress := constants.AliceAccAddress.String() + out, err := clitestutil.ExecTestCLICmd(ctx, cli.GetCmdQueryReferredBy(), []string{testAddress}) + require.NoError(t, err) + + var resp types.ReferredByResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) +} diff --git a/protocol/x/affiliates/client/cli/tx.go b/protocol/x/affiliates/client/cli/tx.go index fab8d4a046..1deb7a0897 100644 --- a/protocol/x/affiliates/client/cli/tx.go +++ b/protocol/x/affiliates/client/cli/tx.go @@ -6,6 +6,8 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" "github.com/dydxprotocol/v4-chain/protocol/x/affiliates/types" ) @@ -18,5 +20,27 @@ func GetTxCmd() *cobra.Command { SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } + cmd.AddCommand(CmdRegisterAffiliate()) + return cmd +} + +func CmdRegisterAffiliate() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-affiliate [affiliate] [referee]", + Short: "Register an affiliate", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + msg := types.MsgRegisterAffiliate{ + Affiliate: args[0], + Referee: args[1], + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + flags.AddTxFlagsToCmd(cmd) return cmd } diff --git a/protocol/x/affiliates/genesis.go b/protocol/x/affiliates/genesis.go index 4767af4794..fd6c3d4ec7 100644 --- a/protocol/x/affiliates/genesis.go +++ b/protocol/x/affiliates/genesis.go @@ -8,9 +8,20 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + err := k.UpdateAffiliateTiers(ctx, genState.AffiliateTiers) + if err != nil { + panic(err) + } } // ExportGenesis returns the module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - return &types.GenesisState{} + affiliateTiers, err := k.GetAllAffiliateTiers(ctx) + if err != nil { + panic(err) + } + + return &types.GenesisState{ + AffiliateTiers: affiliateTiers, + } } diff --git a/protocol/x/affiliates/keeper/grpc_query.go b/protocol/x/affiliates/keeper/grpc_query.go index fff1a96295..a4a992b271 100644 --- a/protocol/x/affiliates/keeper/grpc_query.go +++ b/protocol/x/affiliates/keeper/grpc_query.go @@ -49,11 +49,7 @@ func (k Keeper) ReferredBy(ctx context.Context, affiliateAddr, exists := k.GetReferredBy(sdkCtx, req.GetAddress()) if !exists { - return &types.ReferredByResponse{}, errorsmod.Wrapf( - types.ErrAffiliateNotFound, - "affiliate not found for address: %s", - req.GetAddress(), - ) + return &types.ReferredByResponse{}, nil } return &types.ReferredByResponse{ diff --git a/protocol/x/affiliates/keeper/grpc_query_test.go b/protocol/x/affiliates/keeper/grpc_query_test.go index 8c4ea7618b..dce8e7c35e 100644 --- a/protocol/x/affiliates/keeper/grpc_query_test.go +++ b/protocol/x/affiliates/keeper/grpc_query_test.go @@ -142,13 +142,13 @@ func TestReferredBy(t *testing.T) { AffiliateAddress: constants.BobAccAddress.String(), }, }, - "Affiliate not found": { + "Affiliate not registered": { req: &types.ReferredByRequest{ Address: constants.DaveAccAddress.String(), }, setup: func(ctx sdk.Context, k keeper.Keeper) {}, expected: nil, - expectError: types.ErrAffiliateNotFound, + expectError: nil, }, } diff --git a/protocol/x/affiliates/types/genesis.go b/protocol/x/affiliates/types/genesis.go index 09583a5f2e..68668b98df 100644 --- a/protocol/x/affiliates/types/genesis.go +++ b/protocol/x/affiliates/types/genesis.go @@ -2,7 +2,11 @@ package types // DefaultGenesis returns the default stats genesis state. func DefaultGenesis() *GenesisState { - return &GenesisState{} + return &GenesisState{ + AffiliateTiers: AffiliateTiers{ + Tiers: []AffiliateTiers_Tier{}, + }, + } } // Validate performs basic genesis state validation returning an error upon any diff --git a/protocol/x/affiliates/types/genesis.pb.go b/protocol/x/affiliates/types/genesis.pb.go index 98728d902f..890eab489a 100644 --- a/protocol/x/affiliates/types/genesis.pb.go +++ b/protocol/x/affiliates/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -24,6 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines generis state of `x/affiliates` type GenesisState struct { + // The list of affiliate tiers + AffiliateTiers AffiliateTiers `protobuf:"bytes,1,opt,name=affiliate_tiers,json=affiliateTiers,proto3" json:"affiliate_tiers"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -59,6 +62,13 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetAffiliateTiers() AffiliateTiers { + if m != nil { + return m.AffiliateTiers + } + return AffiliateTiers{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "dydxprotocol.affiliates.GenesisState") } @@ -68,17 +78,20 @@ func init() { } var fileDescriptor_7d3ffc50e877971b = []byte{ - // 146 bytes of a gzipped FileDescriptorProto + // 207 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xa9, 0x4c, 0xa9, 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x4f, 0x4c, 0x4b, 0xcb, 0xcc, 0xc9, 0x4c, 0x2c, 0x49, 0x2d, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x03, 0xcb, 0x09, 0x89, - 0x23, 0x2b, 0xd3, 0x43, 0x28, 0x53, 0xe2, 0xe3, 0xe2, 0x71, 0x87, 0xa8, 0x0c, 0x2e, 0x49, 0x2c, - 0x49, 0x75, 0x0a, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, - 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x9b, 0xf4, - 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x14, 0x4b, 0xcb, 0x4c, 0x74, 0x93, - 0x33, 0x12, 0x33, 0xf3, 0xf4, 0xe1, 0x22, 0x15, 0xc8, 0x0e, 0x29, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, - 0x62, 0x03, 0x4b, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x52, 0x0f, 0x30, 0xb0, 0x00, - 0x00, 0x00, + 0x23, 0x2b, 0xd3, 0x43, 0x28, 0x93, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x4b, 0xe8, 0x83, 0x58, + 0x10, 0xe5, 0x52, 0x1a, 0xb8, 0x4c, 0x45, 0x30, 0x21, 0x2a, 0x95, 0xd2, 0xb8, 0x78, 0xdc, 0x21, + 0x36, 0x05, 0x97, 0x24, 0x96, 0xa4, 0x0a, 0x85, 0x71, 0xf1, 0xc3, 0xd5, 0xc4, 0x97, 0x64, 0xa6, + 0x16, 0x15, 0x4b, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0xa9, 0xeb, 0xe1, 0x70, 0x82, 0x9e, 0x23, + 0x8c, 0x19, 0x02, 0x52, 0xee, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x5f, 0x22, 0xaa, 0x68, + 0xd8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, + 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xd9, 0xa4, 0x67, 0x96, 0x64, + 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xa3, 0x38, 0xbb, 0xcc, 0x44, 0x37, 0x39, 0x23, 0x31, + 0x33, 0x4f, 0x1f, 0x2e, 0x52, 0x81, 0xec, 0x95, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, + 0xa4, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xb3, 0x6a, 0x5a, 0x48, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -101,6 +114,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.AffiliateTiers.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -121,6 +144,8 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + l = m.AffiliateTiers.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -159,6 +184,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AffiliateTiers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AffiliateTiers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/protocol/x/revshare/keeper/revshare_test.go b/protocol/x/revshare/keeper/revshare_test.go index fae19e4f07..dcf12fbcf1 100644 --- a/protocol/x/revshare/keeper/revshare_test.go +++ b/protocol/x/revshare/keeper/revshare_test.go @@ -675,7 +675,8 @@ func TestKeeper_GetAllRevShares_Invalid(t *testing.T) { err := affiliatesKeeper.UpdateAffiliateTiers(ctx, affiliatetypes.DefaultAffiliateTiers) require.NoError(t, err) - err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), constants.BobAccAddress.String()) + err = affiliatesKeeper.RegisterAffiliate(ctx, constants.AliceAccAddress.String(), + constants.BobAccAddress.String()) require.NoError(t, err) }, }, From 025cc8589d5604c1ba16320ba4499ea17dc54875 Mon Sep 17 00:00:00 2001 From: Teddy Ding <teddy@dydx.exchange> Date: Mon, 16 Sep 2024 12:41:19 -0400 Subject: [PATCH 10/12] [OTE-456] FNS x OE: stage `FinalizeBlock` events and emit in `Precommit` (#2253) --- .../src/codegen/dydxprotocol/bundle.ts | 494 +++++++++--------- .../codegen/dydxprotocol/clob/streaming.ts | 71 +++ .../v4-protos/src/codegen/gogoproto/bundle.ts | 4 +- .../v4-protos/src/codegen/google/bundle.ts | 22 +- proto/dydxprotocol/clob/streaming.proto | 16 + protocol/app/app.go | 4 + protocol/lib/metrics/constants.go | 1 + protocol/lib/metrics/metric_keys.go | 29 +- protocol/streaming/constants.go | 13 + .../streaming/full_node_streaming_manager.go | 167 ++++++ protocol/streaming/noop_streaming_manager.go | 25 + protocol/streaming/types/interface.go | 16 + protocol/x/clob/abci.go | 11 + .../clob/keeper/grpc_stream_finalize_block.go | 50 ++ protocol/x/clob/keeper/process_operations.go | 34 +- protocol/x/clob/types/streaming.pb.go | 473 +++++++++++++++++ protocol/x/subaccounts/keeper/subaccount.go | 6 +- 17 files changed, 1132 insertions(+), 304 deletions(-) create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/streaming.ts create mode 100644 proto/dydxprotocol/clob/streaming.proto create mode 100644 protocol/streaming/constants.go create mode 100644 protocol/x/clob/keeper/grpc_stream_finalize_block.go create mode 100644 protocol/x/clob/types/streaming.pb.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts index 8a5e295af1..3324f5cd90 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts @@ -36,150 +36,151 @@ import * as _39 from "./clob/order_removals"; import * as _40 from "./clob/order"; import * as _41 from "./clob/process_proposer_matches_events"; import * as _42 from "./clob/query"; -import * as _43 from "./clob/tx"; -import * as _44 from "./daemons/bridge/bridge"; -import * as _45 from "./daemons/liquidation/liquidation"; -import * as _46 from "./daemons/pricefeed/price_feed"; -import * as _47 from "./delaymsg/block_message_ids"; -import * as _48 from "./delaymsg/delayed_message"; -import * as _49 from "./delaymsg/genesis"; -import * as _50 from "./delaymsg/query"; -import * as _51 from "./delaymsg/tx"; -import * as _52 from "./epochs/epoch_info"; -import * as _53 from "./epochs/genesis"; -import * as _54 from "./epochs/query"; -import * as _55 from "./feetiers/genesis"; -import * as _56 from "./feetiers/params"; -import * as _57 from "./feetiers/query"; -import * as _58 from "./feetiers/tx"; -import * as _59 from "./govplus/genesis"; -import * as _60 from "./govplus/query"; -import * as _61 from "./govplus/tx"; -import * as _62 from "./indexer/events/events"; -import * as _63 from "./indexer/indexer_manager/event"; -import * as _64 from "./indexer/off_chain_updates/off_chain_updates"; -import * as _65 from "./indexer/protocol/v1/clob"; -import * as _66 from "./indexer/protocol/v1/perpetual"; -import * as _67 from "./indexer/protocol/v1/subaccount"; -import * as _68 from "./indexer/protocol/v1/vault"; -import * as _69 from "./indexer/redis/redis_order"; -import * as _70 from "./indexer/shared/removal_reason"; -import * as _71 from "./indexer/socks/messages"; -import * as _72 from "./listing/genesis"; -import * as _73 from "./listing/params"; -import * as _74 from "./listing/query"; -import * as _75 from "./listing/tx"; -import * as _76 from "./perpetuals/genesis"; -import * as _77 from "./perpetuals/params"; -import * as _78 from "./perpetuals/perpetual"; -import * as _79 from "./perpetuals/query"; -import * as _80 from "./perpetuals/tx"; -import * as _81 from "./prices/genesis"; -import * as _82 from "./prices/market_param"; -import * as _83 from "./prices/market_price"; -import * as _84 from "./prices/query"; -import * as _85 from "./prices/tx"; -import * as _86 from "./ratelimit/capacity"; -import * as _87 from "./ratelimit/genesis"; -import * as _88 from "./ratelimit/limit_params"; -import * as _89 from "./ratelimit/pending_send_packet"; -import * as _90 from "./ratelimit/query"; -import * as _91 from "./ratelimit/tx"; -import * as _92 from "./revshare/genesis"; -import * as _93 from "./revshare/params"; -import * as _94 from "./revshare/query"; -import * as _95 from "./revshare/revshare"; -import * as _96 from "./revshare/tx"; -import * as _97 from "./rewards/genesis"; -import * as _98 from "./rewards/params"; -import * as _99 from "./rewards/query"; -import * as _100 from "./rewards/reward_share"; -import * as _101 from "./rewards/tx"; -import * as _102 from "./sending/genesis"; -import * as _103 from "./sending/query"; -import * as _104 from "./sending/transfer"; -import * as _105 from "./sending/tx"; -import * as _106 from "./stats/genesis"; -import * as _107 from "./stats/params"; -import * as _108 from "./stats/query"; -import * as _109 from "./stats/stats"; -import * as _110 from "./stats/tx"; -import * as _111 from "./subaccounts/asset_position"; -import * as _112 from "./subaccounts/genesis"; -import * as _113 from "./subaccounts/perpetual_position"; -import * as _114 from "./subaccounts/query"; -import * as _115 from "./subaccounts/streaming"; -import * as _116 from "./subaccounts/subaccount"; -import * as _117 from "./vault/genesis"; -import * as _118 from "./vault/params"; -import * as _119 from "./vault/query"; -import * as _120 from "./vault/share"; -import * as _121 from "./vault/tx"; -import * as _122 from "./vault/vault"; -import * as _123 from "./vest/genesis"; -import * as _124 from "./vest/query"; -import * as _125 from "./vest/tx"; -import * as _126 from "./vest/vest_entry"; -import * as _134 from "./accountplus/query.lcd"; -import * as _135 from "./assets/query.lcd"; -import * as _136 from "./blocktime/query.lcd"; -import * as _137 from "./bridge/query.lcd"; -import * as _138 from "./clob/query.lcd"; -import * as _139 from "./delaymsg/query.lcd"; -import * as _140 from "./epochs/query.lcd"; -import * as _141 from "./feetiers/query.lcd"; -import * as _142 from "./listing/query.lcd"; -import * as _143 from "./perpetuals/query.lcd"; -import * as _144 from "./prices/query.lcd"; -import * as _145 from "./ratelimit/query.lcd"; -import * as _146 from "./revshare/query.lcd"; -import * as _147 from "./rewards/query.lcd"; -import * as _148 from "./stats/query.lcd"; -import * as _149 from "./subaccounts/query.lcd"; -import * as _150 from "./vault/query.lcd"; -import * as _151 from "./vest/query.lcd"; -import * as _152 from "./accountplus/query.rpc.Query"; -import * as _153 from "./affiliates/query.rpc.Query"; -import * as _154 from "./assets/query.rpc.Query"; -import * as _155 from "./blocktime/query.rpc.Query"; -import * as _156 from "./bridge/query.rpc.Query"; -import * as _157 from "./clob/query.rpc.Query"; -import * as _158 from "./delaymsg/query.rpc.Query"; -import * as _159 from "./epochs/query.rpc.Query"; -import * as _160 from "./feetiers/query.rpc.Query"; -import * as _161 from "./govplus/query.rpc.Query"; -import * as _162 from "./listing/query.rpc.Query"; -import * as _163 from "./perpetuals/query.rpc.Query"; -import * as _164 from "./prices/query.rpc.Query"; -import * as _165 from "./ratelimit/query.rpc.Query"; -import * as _166 from "./revshare/query.rpc.Query"; -import * as _167 from "./rewards/query.rpc.Query"; -import * as _168 from "./sending/query.rpc.Query"; -import * as _169 from "./stats/query.rpc.Query"; -import * as _170 from "./subaccounts/query.rpc.Query"; -import * as _171 from "./vault/query.rpc.Query"; -import * as _172 from "./vest/query.rpc.Query"; -import * as _173 from "./accountplus/tx.rpc.msg"; -import * as _174 from "./affiliates/tx.rpc.msg"; -import * as _175 from "./blocktime/tx.rpc.msg"; -import * as _176 from "./bridge/tx.rpc.msg"; -import * as _177 from "./clob/tx.rpc.msg"; -import * as _178 from "./delaymsg/tx.rpc.msg"; -import * as _179 from "./feetiers/tx.rpc.msg"; -import * as _180 from "./govplus/tx.rpc.msg"; -import * as _181 from "./listing/tx.rpc.msg"; -import * as _182 from "./perpetuals/tx.rpc.msg"; -import * as _183 from "./prices/tx.rpc.msg"; -import * as _184 from "./ratelimit/tx.rpc.msg"; -import * as _185 from "./revshare/tx.rpc.msg"; -import * as _186 from "./rewards/tx.rpc.msg"; -import * as _187 from "./sending/tx.rpc.msg"; -import * as _188 from "./stats/tx.rpc.msg"; -import * as _189 from "./vault/tx.rpc.msg"; -import * as _190 from "./vest/tx.rpc.msg"; -import * as _191 from "./lcd"; -import * as _192 from "./rpc.query"; -import * as _193 from "./rpc.tx"; +import * as _43 from "./clob/streaming"; +import * as _44 from "./clob/tx"; +import * as _45 from "./daemons/bridge/bridge"; +import * as _46 from "./daemons/liquidation/liquidation"; +import * as _47 from "./daemons/pricefeed/price_feed"; +import * as _48 from "./delaymsg/block_message_ids"; +import * as _49 from "./delaymsg/delayed_message"; +import * as _50 from "./delaymsg/genesis"; +import * as _51 from "./delaymsg/query"; +import * as _52 from "./delaymsg/tx"; +import * as _53 from "./epochs/epoch_info"; +import * as _54 from "./epochs/genesis"; +import * as _55 from "./epochs/query"; +import * as _56 from "./feetiers/genesis"; +import * as _57 from "./feetiers/params"; +import * as _58 from "./feetiers/query"; +import * as _59 from "./feetiers/tx"; +import * as _60 from "./govplus/genesis"; +import * as _61 from "./govplus/query"; +import * as _62 from "./govplus/tx"; +import * as _63 from "./indexer/events/events"; +import * as _64 from "./indexer/indexer_manager/event"; +import * as _65 from "./indexer/off_chain_updates/off_chain_updates"; +import * as _66 from "./indexer/protocol/v1/clob"; +import * as _67 from "./indexer/protocol/v1/perpetual"; +import * as _68 from "./indexer/protocol/v1/subaccount"; +import * as _69 from "./indexer/protocol/v1/vault"; +import * as _70 from "./indexer/redis/redis_order"; +import * as _71 from "./indexer/shared/removal_reason"; +import * as _72 from "./indexer/socks/messages"; +import * as _73 from "./listing/genesis"; +import * as _74 from "./listing/params"; +import * as _75 from "./listing/query"; +import * as _76 from "./listing/tx"; +import * as _77 from "./perpetuals/genesis"; +import * as _78 from "./perpetuals/params"; +import * as _79 from "./perpetuals/perpetual"; +import * as _80 from "./perpetuals/query"; +import * as _81 from "./perpetuals/tx"; +import * as _82 from "./prices/genesis"; +import * as _83 from "./prices/market_param"; +import * as _84 from "./prices/market_price"; +import * as _85 from "./prices/query"; +import * as _86 from "./prices/tx"; +import * as _87 from "./ratelimit/capacity"; +import * as _88 from "./ratelimit/genesis"; +import * as _89 from "./ratelimit/limit_params"; +import * as _90 from "./ratelimit/pending_send_packet"; +import * as _91 from "./ratelimit/query"; +import * as _92 from "./ratelimit/tx"; +import * as _93 from "./revshare/genesis"; +import * as _94 from "./revshare/params"; +import * as _95 from "./revshare/query"; +import * as _96 from "./revshare/revshare"; +import * as _97 from "./revshare/tx"; +import * as _98 from "./rewards/genesis"; +import * as _99 from "./rewards/params"; +import * as _100 from "./rewards/query"; +import * as _101 from "./rewards/reward_share"; +import * as _102 from "./rewards/tx"; +import * as _103 from "./sending/genesis"; +import * as _104 from "./sending/query"; +import * as _105 from "./sending/transfer"; +import * as _106 from "./sending/tx"; +import * as _107 from "./stats/genesis"; +import * as _108 from "./stats/params"; +import * as _109 from "./stats/query"; +import * as _110 from "./stats/stats"; +import * as _111 from "./stats/tx"; +import * as _112 from "./subaccounts/asset_position"; +import * as _113 from "./subaccounts/genesis"; +import * as _114 from "./subaccounts/perpetual_position"; +import * as _115 from "./subaccounts/query"; +import * as _116 from "./subaccounts/streaming"; +import * as _117 from "./subaccounts/subaccount"; +import * as _118 from "./vault/genesis"; +import * as _119 from "./vault/params"; +import * as _120 from "./vault/query"; +import * as _121 from "./vault/share"; +import * as _122 from "./vault/tx"; +import * as _123 from "./vault/vault"; +import * as _124 from "./vest/genesis"; +import * as _125 from "./vest/query"; +import * as _126 from "./vest/tx"; +import * as _127 from "./vest/vest_entry"; +import * as _135 from "./accountplus/query.lcd"; +import * as _136 from "./assets/query.lcd"; +import * as _137 from "./blocktime/query.lcd"; +import * as _138 from "./bridge/query.lcd"; +import * as _139 from "./clob/query.lcd"; +import * as _140 from "./delaymsg/query.lcd"; +import * as _141 from "./epochs/query.lcd"; +import * as _142 from "./feetiers/query.lcd"; +import * as _143 from "./listing/query.lcd"; +import * as _144 from "./perpetuals/query.lcd"; +import * as _145 from "./prices/query.lcd"; +import * as _146 from "./ratelimit/query.lcd"; +import * as _147 from "./revshare/query.lcd"; +import * as _148 from "./rewards/query.lcd"; +import * as _149 from "./stats/query.lcd"; +import * as _150 from "./subaccounts/query.lcd"; +import * as _151 from "./vault/query.lcd"; +import * as _152 from "./vest/query.lcd"; +import * as _153 from "./accountplus/query.rpc.Query"; +import * as _154 from "./affiliates/query.rpc.Query"; +import * as _155 from "./assets/query.rpc.Query"; +import * as _156 from "./blocktime/query.rpc.Query"; +import * as _157 from "./bridge/query.rpc.Query"; +import * as _158 from "./clob/query.rpc.Query"; +import * as _159 from "./delaymsg/query.rpc.Query"; +import * as _160 from "./epochs/query.rpc.Query"; +import * as _161 from "./feetiers/query.rpc.Query"; +import * as _162 from "./govplus/query.rpc.Query"; +import * as _163 from "./listing/query.rpc.Query"; +import * as _164 from "./perpetuals/query.rpc.Query"; +import * as _165 from "./prices/query.rpc.Query"; +import * as _166 from "./ratelimit/query.rpc.Query"; +import * as _167 from "./revshare/query.rpc.Query"; +import * as _168 from "./rewards/query.rpc.Query"; +import * as _169 from "./sending/query.rpc.Query"; +import * as _170 from "./stats/query.rpc.Query"; +import * as _171 from "./subaccounts/query.rpc.Query"; +import * as _172 from "./vault/query.rpc.Query"; +import * as _173 from "./vest/query.rpc.Query"; +import * as _174 from "./accountplus/tx.rpc.msg"; +import * as _175 from "./affiliates/tx.rpc.msg"; +import * as _176 from "./blocktime/tx.rpc.msg"; +import * as _177 from "./bridge/tx.rpc.msg"; +import * as _178 from "./clob/tx.rpc.msg"; +import * as _179 from "./delaymsg/tx.rpc.msg"; +import * as _180 from "./feetiers/tx.rpc.msg"; +import * as _181 from "./govplus/tx.rpc.msg"; +import * as _182 from "./listing/tx.rpc.msg"; +import * as _183 from "./perpetuals/tx.rpc.msg"; +import * as _184 from "./prices/tx.rpc.msg"; +import * as _185 from "./ratelimit/tx.rpc.msg"; +import * as _186 from "./revshare/tx.rpc.msg"; +import * as _187 from "./rewards/tx.rpc.msg"; +import * as _188 from "./sending/tx.rpc.msg"; +import * as _189 from "./stats/tx.rpc.msg"; +import * as _190 from "./vault/tx.rpc.msg"; +import * as _191 from "./vest/tx.rpc.msg"; +import * as _192 from "./lcd"; +import * as _193 from "./rpc.query"; +import * as _194 from "./rpc.tx"; export namespace dydxprotocol { export const accountplus = { ..._5, ..._6, @@ -187,32 +188,32 @@ export namespace dydxprotocol { ..._8, ..._9, ..._10, - ..._134, - ..._152, - ..._173 + ..._135, + ..._153, + ..._174 }; export const affiliates = { ..._11, ..._12, ..._13, ..._14, - ..._153, - ..._174 + ..._154, + ..._175 }; export const assets = { ..._15, ..._16, ..._17, ..._18, - ..._135, - ..._154 + ..._136, + ..._155 }; export const blocktime = { ..._19, ..._20, ..._21, ..._22, ..._23, - ..._136, - ..._155, - ..._175 + ..._137, + ..._156, + ..._176 }; export const bridge = { ..._24, ..._25, @@ -220,9 +221,9 @@ export namespace dydxprotocol { ..._27, ..._28, ..._29, - ..._137, - ..._156, - ..._176 + ..._138, + ..._157, + ..._177 }; export const clob = { ..._30, ..._31, @@ -238,167 +239,168 @@ export namespace dydxprotocol { ..._41, ..._42, ..._43, - ..._138, - ..._157, - ..._177 + ..._44, + ..._139, + ..._158, + ..._178 }; export namespace daemons { - export const bridge = { ..._44 + export const bridge = { ..._45 }; - export const liquidation = { ..._45 + export const liquidation = { ..._46 }; - export const pricefeed = { ..._46 + export const pricefeed = { ..._47 }; } - export const delaymsg = { ..._47, - ..._48, + export const delaymsg = { ..._48, ..._49, ..._50, ..._51, - ..._139, - ..._158, - ..._178 + ..._52, + ..._140, + ..._159, + ..._179 }; - export const epochs = { ..._52, - ..._53, + export const epochs = { ..._53, ..._54, - ..._140, - ..._159 + ..._55, + ..._141, + ..._160 }; - export const feetiers = { ..._55, - ..._56, + export const feetiers = { ..._56, ..._57, ..._58, - ..._141, - ..._160, - ..._179 - }; - export const govplus = { ..._59, - ..._60, - ..._61, + ..._59, + ..._142, ..._161, ..._180 }; + export const govplus = { ..._60, + ..._61, + ..._62, + ..._162, + ..._181 + }; export namespace indexer { - export const events = { ..._62 + export const events = { ..._63 }; - export const indexer_manager = { ..._63 + export const indexer_manager = { ..._64 }; - export const off_chain_updates = { ..._64 + export const off_chain_updates = { ..._65 }; export namespace protocol { - export const v1 = { ..._65, - ..._66, + export const v1 = { ..._66, ..._67, - ..._68 + ..._68, + ..._69 }; } - export const redis = { ..._69 + export const redis = { ..._70 }; - export const shared = { ..._70 + export const shared = { ..._71 }; - export const socks = { ..._71 + export const socks = { ..._72 }; } - export const listing = { ..._72, - ..._73, + export const listing = { ..._73, ..._74, ..._75, - ..._142, - ..._162, - ..._181 + ..._76, + ..._143, + ..._163, + ..._182 }; - export const perpetuals = { ..._76, - ..._77, + export const perpetuals = { ..._77, ..._78, ..._79, ..._80, - ..._143, - ..._163, - ..._182 + ..._81, + ..._144, + ..._164, + ..._183 }; - export const prices = { ..._81, - ..._82, + export const prices = { ..._82, ..._83, ..._84, ..._85, - ..._144, - ..._164, - ..._183 + ..._86, + ..._145, + ..._165, + ..._184 }; - export const ratelimit = { ..._86, - ..._87, + export const ratelimit = { ..._87, ..._88, ..._89, ..._90, ..._91, - ..._145, - ..._165, - ..._184 + ..._92, + ..._146, + ..._166, + ..._185 }; - export const revshare = { ..._92, - ..._93, + export const revshare = { ..._93, ..._94, ..._95, ..._96, - ..._146, - ..._166, - ..._185 + ..._97, + ..._147, + ..._167, + ..._186 }; - export const rewards = { ..._97, - ..._98, + export const rewards = { ..._98, ..._99, ..._100, ..._101, - ..._147, - ..._167, - ..._186 + ..._102, + ..._148, + ..._168, + ..._187 }; - export const sending = { ..._102, - ..._103, + export const sending = { ..._103, ..._104, ..._105, - ..._168, - ..._187 + ..._106, + ..._169, + ..._188 }; - export const stats = { ..._106, - ..._107, + export const stats = { ..._107, ..._108, ..._109, ..._110, - ..._148, - ..._169, - ..._188 + ..._111, + ..._149, + ..._170, + ..._189 }; - export const subaccounts = { ..._111, - ..._112, + export const subaccounts = { ..._112, ..._113, ..._114, ..._115, ..._116, - ..._149, - ..._170 + ..._117, + ..._150, + ..._171 }; - export const vault = { ..._117, - ..._118, + export const vault = { ..._118, ..._119, ..._120, ..._121, ..._122, - ..._150, - ..._171, - ..._189 - }; - export const vest = { ..._123, - ..._124, - ..._125, - ..._126, + ..._123, ..._151, ..._172, ..._190 }; - export const ClientFactory = { ..._191, - ..._192, - ..._193 + export const vest = { ..._124, + ..._125, + ..._126, + ..._127, + ..._152, + ..._173, + ..._191 + }; + export const ClientFactory = { ..._192, + ..._193, + ..._194 }; } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/streaming.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/streaming.ts new file mode 100644 index 0000000000..dab8f1e122 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/clob/streaming.ts @@ -0,0 +1,71 @@ +import { StreamOrderbookFill, StreamOrderbookFillSDKType } from "./query"; +import { StreamSubaccountUpdate, StreamSubaccountUpdateSDKType } from "../subaccounts/streaming"; +import * as _m0 from "protobufjs/minimal"; +import { DeepPartial } from "../../helpers"; +/** StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. */ + +export interface StagedFinalizeBlockEvent { + orderFill?: StreamOrderbookFill; + subaccountUpdate?: StreamSubaccountUpdate; +} +/** StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. */ + +export interface StagedFinalizeBlockEventSDKType { + order_fill?: StreamOrderbookFillSDKType; + subaccount_update?: StreamSubaccountUpdateSDKType; +} + +function createBaseStagedFinalizeBlockEvent(): StagedFinalizeBlockEvent { + return { + orderFill: undefined, + subaccountUpdate: undefined + }; +} + +export const StagedFinalizeBlockEvent = { + encode(message: StagedFinalizeBlockEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.orderFill !== undefined) { + StreamOrderbookFill.encode(message.orderFill, writer.uint32(10).fork()).ldelim(); + } + + if (message.subaccountUpdate !== undefined) { + StreamSubaccountUpdate.encode(message.subaccountUpdate, writer.uint32(18).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): StagedFinalizeBlockEvent { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseStagedFinalizeBlockEvent(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.orderFill = StreamOrderbookFill.decode(reader, reader.uint32()); + break; + + case 2: + message.subaccountUpdate = StreamSubaccountUpdate.decode(reader, reader.uint32()); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<StagedFinalizeBlockEvent>): StagedFinalizeBlockEvent { + const message = createBaseStagedFinalizeBlockEvent(); + message.orderFill = object.orderFill !== undefined && object.orderFill !== null ? StreamOrderbookFill.fromPartial(object.orderFill) : undefined; + message.subaccountUpdate = object.subaccountUpdate !== undefined && object.subaccountUpdate !== null ? StreamSubaccountUpdate.fromPartial(object.subaccountUpdate) : undefined; + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts index 52cc244930..00375897ff 100644 --- a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts @@ -1,3 +1,3 @@ -import * as _127 from "./gogo"; -export const gogoproto = { ..._127 +import * as _128 from "./gogo"; +export const gogoproto = { ..._128 }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/google/bundle.ts b/indexer/packages/v4-protos/src/codegen/google/bundle.ts index fd95177ed2..b2f572879c 100644 --- a/indexer/packages/v4-protos/src/codegen/google/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/google/bundle.ts @@ -1,16 +1,16 @@ -import * as _128 from "./api/annotations"; -import * as _129 from "./api/http"; -import * as _130 from "./protobuf/descriptor"; -import * as _131 from "./protobuf/duration"; -import * as _132 from "./protobuf/timestamp"; -import * as _133 from "./protobuf/any"; +import * as _129 from "./api/annotations"; +import * as _130 from "./api/http"; +import * as _131 from "./protobuf/descriptor"; +import * as _132 from "./protobuf/duration"; +import * as _133 from "./protobuf/timestamp"; +import * as _134 from "./protobuf/any"; export namespace google { - export const api = { ..._128, - ..._129 + export const api = { ..._129, + ..._130 }; - export const protobuf = { ..._130, - ..._131, + export const protobuf = { ..._131, ..._132, - ..._133 + ..._133, + ..._134 }; } \ No newline at end of file diff --git a/proto/dydxprotocol/clob/streaming.proto b/proto/dydxprotocol/clob/streaming.proto new file mode 100644 index 0000000000..06c74ffbe1 --- /dev/null +++ b/proto/dydxprotocol/clob/streaming.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package dydxprotocol.clob; + +import "dydxprotocol/subaccounts/streaming.proto"; +import "dydxprotocol/clob/query.proto"; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/clob/types"; + +// StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. +message StagedFinalizeBlockEvent { + // Contains one of StreamOrderbookFill, StreamSubaccountUpdate. + oneof event { + StreamOrderbookFill order_fill = 1; + dydxprotocol.subaccounts.StreamSubaccountUpdate subaccount_update = 2; + } +} diff --git a/protocol/app/app.go b/protocol/app/app.go index fbb8db6bd0..a8f2cec91e 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -469,6 +469,7 @@ func New( statsmoduletypes.TransientStoreKey, rewardsmoduletypes.TransientStoreKey, indexer_manager.TransientStoreKey, + streaming.StreamingManagerTransientStoreKey, perpetualsmoduletypes.TransientStoreKey, ) memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, clobmoduletypes.MemStoreKey) @@ -764,6 +765,7 @@ func New( appFlags, appCodec, logger, + tkeys[streaming.StreamingManagerTransientStoreKey], ) timeProvider := &timelib.TimeProviderImpl{} @@ -2059,6 +2061,7 @@ func getFullNodeStreamingManagerFromOptions( appFlags flags.Flags, cdc codec.Codec, logger log.Logger, + streamingManagerTransientStoreKey storetypes.StoreKey, ) (manager streamingtypes.FullNodeStreamingManager, wsServer *ws.WebsocketServer) { logger = logger.With(log.ModuleKey, "full-node-streaming") if appFlags.GrpcStreamingEnabled { @@ -2072,6 +2075,7 @@ func getFullNodeStreamingManagerFromOptions( appFlags.GrpcStreamingMaxBatchSize, appFlags.GrpcStreamingMaxChannelBufferSize, appFlags.FullNodeStreamingSnapshotInterval, + streamingManagerTransientStoreKey, ) // Start websocket server. diff --git a/protocol/lib/metrics/constants.go b/protocol/lib/metrics/constants.go index 0ac766bf5b..a0f851eb58 100644 --- a/protocol/lib/metrics/constants.go +++ b/protocol/lib/metrics/constants.go @@ -202,6 +202,7 @@ const ( UpdateType = "update_type" ValidateMatches = "validate_matches" ValidateOrder = "validate_order" + StreamBatchUpdatesAfterFinalizeBlock = "stream_batch_updates_after_finalize_block" // MemCLOB. AddedToOrderBook = "added_to_orderbook" diff --git a/protocol/lib/metrics/metric_keys.go b/protocol/lib/metrics/metric_keys.go index f980275d7f..c7c42b4c44 100644 --- a/protocol/lib/metrics/metric_keys.go +++ b/protocol/lib/metrics/metric_keys.go @@ -70,19 +70,22 @@ const ( GateWithdrawalsIfNegativeTncSubaccountSeenLatency = "gate_withdrawals_if_negative_tnc_subaccount_seen_latency" // Full node grpc - FullNodeGrpc = "full_node_grpc" - GrpcSendOrderbookUpdatesLatency = "grpc_send_orderbook_updates_latency" - GrpcSendOrderbookSnapshotLatency = "grpc_send_orderbook_snapshot_latency" - GrpcSendSubaccountSnapshotLatency = "grpc_send_subaccount_snapshot_latency" - GrpcSendOrderbookFillsLatency = "grpc_send_orderbook_fills_latency" - GrpcSendFinalizedSubaccountUpdatesLatency = "grpc_send_finalized_subaccount_updates_latency" - GrpcAddUpdateToBufferCount = "grpc_add_update_to_buffer_count" - GrpcAddToSubscriptionChannelCount = "grpc_add_to_subscription_channel_count" - GrpcSendResponseToSubscriberCount = "grpc_send_response_to_subscriber_count" - GrpcStreamSubscriberCount = "grpc_stream_subscriber_count" - GrpcStreamNumUpdatesBuffered = "grpc_stream_num_updates_buffered" - GrpcFlushUpdatesLatency = "grpc_flush_updates_latency" - GrpcSubscriptionChannelLength = "grpc_subscription_channel_length" + FullNodeGrpc = "full_node_grpc" + GrpcSendOrderbookUpdatesLatency = "grpc_send_orderbook_updates_latency" + GrpcSendOrderbookSnapshotLatency = "grpc_send_orderbook_snapshot_latency" + GrpcSendSubaccountSnapshotLatency = "grpc_send_subaccount_snapshot_latency" + GrpcSendOrderbookFillsLatency = "grpc_send_orderbook_fills_latency" + GrpcSendFinalizedSubaccountUpdatesLatency = "grpc_send_finalized_subaccount_updates_latency" + GrpcAddUpdateToBufferCount = "grpc_add_update_to_buffer_count" + GrpcAddToSubscriptionChannelCount = "grpc_add_to_subscription_channel_count" + GrpcSendResponseToSubscriberCount = "grpc_send_response_to_subscriber_count" + GrpcStreamSubscriberCount = "grpc_stream_subscriber_count" + GrpcStreamNumUpdatesBuffered = "grpc_stream_num_updates_buffered" + GrpcFlushUpdatesLatency = "grpc_flush_updates_latency" + GrpcSubscriptionChannelLength = "grpc_subscription_channel_length" + GrpcStagedAllFinalizeBlockUpdatesCount = "grpc_staged_all_finalize_block_updates_count" + GrpcStagedFillFinalizeBlockUpdatesCount = "grpc_staged_finalize_block_fill_updates_count" + GrpcStagedSubaccountFinalizeBlockUpdatesCount = "grpc_staged_finalize_block_subaccount_updates_count" EndBlocker = "end_blocker" EndBlockerLag = "end_blocker_lag" diff --git a/protocol/streaming/constants.go b/protocol/streaming/constants.go new file mode 100644 index 0000000000..3e3a3a6676 --- /dev/null +++ b/protocol/streaming/constants.go @@ -0,0 +1,13 @@ +package streaming + +// Constants for FullNodeStreamingManager. +const ( + // Transient store key for storing staged events. + StreamingManagerTransientStoreKey = "tmp_streaming" + + // Key for storing the count of staged events. + StagedEventsCountKey = "EvtCnt" + + // Key prefix for staged events. + StagedEventsKeyPrefix = "Evt:" +) diff --git a/protocol/streaming/full_node_streaming_manager.go b/protocol/streaming/full_node_streaming_manager.go index a6fe37c512..34b7eaaf36 100644 --- a/protocol/streaming/full_node_streaming_manager.go +++ b/protocol/streaming/full_node_streaming_manager.go @@ -1,15 +1,20 @@ package streaming import ( + "encoding/binary" "fmt" "sync" "sync/atomic" "time" + "github.com/dydxprotocol/v4-chain/protocol/lib" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" "cosmossdk.io/log" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + ante_types "github.com/dydxprotocol/v4-chain/protocol/app/ante/types" "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" "github.com/dydxprotocol/v4-chain/protocol/streaming/types" streaming_util "github.com/dydxprotocol/v4-chain/protocol/streaming/util" @@ -50,6 +55,9 @@ type FullNodeStreamingManagerImpl struct { // Block interval in which snapshot info should be sent out in. // Defaults to 0, which means only one snapshot will be sent out. snapshotBlockInterval uint32 + + // stores the staged FinalizeBlock events for full node streaming. + streamingManagerTransientStoreKey storetypes.StoreKey } // OrderbookSubscription represents a active subscription to the orderbook updates stream. @@ -86,6 +94,7 @@ func NewFullNodeStreamingManager( maxUpdatesInCache uint32, maxSubscriptionChannelSize uint32, snapshotBlockInterval uint32, + streamingManagerTransientStoreKey storetypes.StoreKey, ) *FullNodeStreamingManagerImpl { fullNodeStreamingManager := &FullNodeStreamingManagerImpl{ logger: logger, @@ -102,6 +111,8 @@ func NewFullNodeStreamingManager( maxUpdatesInCache: maxUpdatesInCache, maxSubscriptionChannelSize: maxSubscriptionChannelSize, snapshotBlockInterval: snapshotBlockInterval, + + streamingManagerTransientStoreKey: streamingManagerTransientStoreKey, } // Start the goroutine for pushing order updates through. @@ -367,6 +378,88 @@ func (sm *FullNodeStreamingManagerImpl) sendStreamUpdates( } } +func getStagedEventsCount(store storetypes.KVStore) uint32 { + countsBytes := store.Get([]byte(StagedEventsCountKey)) + if countsBytes == nil { + return 0 + } + return binary.BigEndian.Uint32(countsBytes) +} + +// Stage a subaccount update event in transient store, during `FinalizeBlock`. +func (sm *FullNodeStreamingManagerImpl) StageFinalizeBlockSubaccountUpdate( + ctx sdk.Context, + subaccountUpdate satypes.StreamSubaccountUpdate, +) { + stagedEvent := clobtypes.StagedFinalizeBlockEvent{ + Event: &clobtypes.StagedFinalizeBlockEvent_SubaccountUpdate{ + SubaccountUpdate: &subaccountUpdate, + }, + } + sm.stageFinalizeBlockEvent( + ctx, + clobtypes.Amino.MustMarshal(stagedEvent), + ) +} + +// Stage a fill event in transient store, during `FinalizeBlock`. +// Since `FinalizeBlock` code block can be called more than once with optimistic +// execution (once optimistically and optionally once on the canonical block), +// we need to stage the events in transient store and later emit them +// during `Precommit`. +func (sm *FullNodeStreamingManagerImpl) StageFinalizeBlockFill( + ctx sdk.Context, + fill clobtypes.StreamOrderbookFill, +) { + stagedEvent := clobtypes.StagedFinalizeBlockEvent{ + Event: &clobtypes.StagedFinalizeBlockEvent_OrderFill{ + OrderFill: &fill, + }, + } + sm.stageFinalizeBlockEvent( + ctx, + clobtypes.Amino.MustMarshal(stagedEvent), + ) +} + +func getStagedFinalizeBlockEvents(store storetypes.KVStore) []clobtypes.StagedFinalizeBlockEvent { + count := getStagedEventsCount(store) + events := make([]clobtypes.StagedFinalizeBlockEvent, count) + store = prefix.NewStore(store, []byte(StagedEventsKeyPrefix)) + for i := uint32(0); i < count; i++ { + var event clobtypes.StagedFinalizeBlockEvent + bytes := store.Get(lib.Uint32ToKey(i)) + clobtypes.Amino.MustUnmarshal(bytes, &event) + events[i] = event + } + return events +} + +// Retrieve all events staged during `FinalizeBlock`. +func (sm *FullNodeStreamingManagerImpl) GetStagedFinalizeBlockEvents( + ctx sdk.Context, +) []clobtypes.StagedFinalizeBlockEvent { + noGasCtx := ctx.WithGasMeter(ante_types.NewFreeInfiniteGasMeter()) + store := noGasCtx.TransientStore(sm.streamingManagerTransientStoreKey) + return getStagedFinalizeBlockEvents(store) +} + +func (sm *FullNodeStreamingManagerImpl) stageFinalizeBlockEvent( + ctx sdk.Context, + eventBytes []byte, +) { + noGasCtx := ctx.WithGasMeter(ante_types.NewFreeInfiniteGasMeter()) + store := noGasCtx.TransientStore(sm.streamingManagerTransientStoreKey) + + // Increment events count. + count := getStagedEventsCount(store) + store.Set([]byte(StagedEventsCountKey), lib.Uint32ToKey(count+1)) + + // Store events keyed by index. + store = prefix.NewStore(store, []byte(StagedEventsKeyPrefix)) + store.Set(lib.Uint32ToKey(count), eventBytes) +} + // SendCombinedSnapshot sends messages to a particular subscriber without buffering. // Note this method requires the lock and assumes that the lock has already been // acquired by the caller. @@ -703,6 +796,80 @@ func (sm *FullNodeStreamingManagerImpl) GetSubaccountSnapshotsForInitStreams( return ret } +// Grpc Streaming logic after consensus agrees on a block. +// - Stream all events staged during `FinalizeBlock`. +// - Stream orderbook updates to sync fills in local ops queue. +func (sm *FullNodeStreamingManagerImpl) StreamBatchUpdatesAfterFinalizeBlock( + ctx sdk.Context, + orderBookUpdatesToSyncLocalOpsQueue *clobtypes.OffchainUpdates, + perpetualIdToClobPairId map[uint32][]clobtypes.ClobPairId, +) { + // Flush all pending updates, since we want the onchain updates to arrive in a batch. + sm.FlushStreamUpdates() + + finalizedFills, finalizedSubaccountUpdates := sm.getStagedEventsFromFinalizeBlock(ctx) + + // TODO(CT-1190): Stream below in a single batch. + // Send orderbook updates to sync optimistic orderbook onchain state after FinalizeBlock. + sm.SendOrderbookUpdates( + orderBookUpdatesToSyncLocalOpsQueue, + uint32(ctx.BlockHeight()), + ctx.ExecMode(), + ) + + // Send finalized fills from FinalizeBlock. + sm.SendOrderbookFillUpdates( + finalizedFills, + uint32(ctx.BlockHeight()), + ctx.ExecMode(), + perpetualIdToClobPairId, + ) + + // Send finalized subaccount updates from FinalizeBlock. + sm.SendFinalizedSubaccountUpdates( + finalizedSubaccountUpdates, + uint32(ctx.BlockHeight()), + ctx.ExecMode(), + ) +} + +// getStagedEventsFromFinalizeBlock returns staged events from `FinalizeBlock`. +// It should be called after the consensus agrees on a block (e.g. Precommitter). +func (sm *FullNodeStreamingManagerImpl) getStagedEventsFromFinalizeBlock( + ctx sdk.Context, +) ( + finalizedFills []clobtypes.StreamOrderbookFill, + finalizedSubaccountUpdates []satypes.StreamSubaccountUpdate, +) { + // Get onchain stream events stored in transient store. + stagedEvents := sm.GetStagedFinalizeBlockEvents(ctx) + + metrics.SetGauge( + metrics.GrpcStagedAllFinalizeBlockUpdatesCount, + float32(len(stagedEvents)), + ) + + for _, stagedEvent := range stagedEvents { + switch event := stagedEvent.Event.(type) { + case *clobtypes.StagedFinalizeBlockEvent_OrderFill: + finalizedFills = append(finalizedFills, *event.OrderFill) + case *clobtypes.StagedFinalizeBlockEvent_SubaccountUpdate: + finalizedSubaccountUpdates = append(finalizedSubaccountUpdates, *event.SubaccountUpdate) + } + } + + metrics.SetGauge( + metrics.GrpcStagedSubaccountFinalizeBlockUpdatesCount, + float32(len(finalizedSubaccountUpdates)), + ) + metrics.SetGauge( + metrics.GrpcStagedFillFinalizeBlockUpdatesCount, + float32(len(finalizedFills)), + ) + + return finalizedFills, finalizedSubaccountUpdates +} + func (sm *FullNodeStreamingManagerImpl) InitializeNewStreams( getOrderbookSnapshot func(clobPairId clobtypes.ClobPairId) *clobtypes.OffchainUpdates, subaccountSnapshots map[satypes.SubaccountId]*satypes.StreamSubaccountUpdate, diff --git a/protocol/streaming/noop_streaming_manager.go b/protocol/streaming/noop_streaming_manager.go index 6e9c00895d..4df60bc427 100644 --- a/protocol/streaming/noop_streaming_manager.go +++ b/protocol/streaming/noop_streaming_manager.go @@ -78,3 +78,28 @@ func (sm *NoopGrpcStreamingManager) InitializeNewStreams( func (sm *NoopGrpcStreamingManager) Stop() { } + +func (sm *NoopGrpcStreamingManager) StageFinalizeBlockFill( + ctx sdk.Context, + fill clobtypes.StreamOrderbookFill, +) { +} + +func (sm *NoopGrpcStreamingManager) GetStagedFinalizeBlockEvents( + ctx sdk.Context, +) []clobtypes.StagedFinalizeBlockEvent { + return nil +} + +func (sm *NoopGrpcStreamingManager) StageFinalizeBlockSubaccountUpdate( + ctx sdk.Context, + subaccountUpdate satypes.StreamSubaccountUpdate, +) { +} + +func (sm *NoopGrpcStreamingManager) StreamBatchUpdatesAfterFinalizeBlock( + ctx sdk.Context, + orderBookUpdatesToSyncLocalOpsQueue *clobtypes.OffchainUpdates, + perpetualIdToClobPairId map[uint32][]clobtypes.ClobPairId, +) { +} diff --git a/protocol/streaming/types/interface.go b/protocol/streaming/types/interface.go index e3dff9d94b..0f097d3e75 100644 --- a/protocol/streaming/types/interface.go +++ b/protocol/streaming/types/interface.go @@ -50,7 +50,23 @@ type FullNodeStreamingManager interface { blockHeight uint32, execMode sdk.ExecMode, ) + StageFinalizeBlockFill( + ctx sdk.Context, + fill clobtypes.StreamOrderbookFill, + ) + StageFinalizeBlockSubaccountUpdate( + ctx sdk.Context, + subaccountUpdate satypes.StreamSubaccountUpdate, + ) + GetStagedFinalizeBlockEvents( + ctx sdk.Context, + ) []clobtypes.StagedFinalizeBlockEvent TracksSubaccountId(id satypes.SubaccountId) bool + StreamBatchUpdatesAfterFinalizeBlock( + ctx sdk.Context, + orderBookUpdatesToSyncLocalOpsQueue *clobtypes.OffchainUpdates, + perpetualIdToClobPairId map[uint32][]clobtypes.ClobPairId, + ) } type OutgoingMessageSender interface { diff --git a/protocol/x/clob/abci.go b/protocol/x/clob/abci.go index 96bacb2cc5..9fd5f4a0b5 100644 --- a/protocol/x/clob/abci.go +++ b/protocol/x/clob/abci.go @@ -46,6 +46,17 @@ func BeginBlocker( keeper.ResetAllDeliveredOrderIds(ctx) } +// Precommit executes all ABCI Precommit logic respective to the clob module. +func Precommit( + ctx sdk.Context, + keeper keeper.Keeper, +) { + if streamingManager := keeper.GetFullNodeStreamingManager(); !streamingManager.Enabled() { + return + } + keeper.StreamBatchUpdatesAfterFinalizeBlock(ctx) +} + // EndBlocker executes all ABCI EndBlock logic respective to the clob module. func EndBlocker( ctx sdk.Context, diff --git a/protocol/x/clob/keeper/grpc_stream_finalize_block.go b/protocol/x/clob/keeper/grpc_stream_finalize_block.go new file mode 100644 index 0000000000..1bc23e46c6 --- /dev/null +++ b/protocol/x/clob/keeper/grpc_stream_finalize_block.go @@ -0,0 +1,50 @@ +package keeper + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dydxprotocol/v4-chain/protocol/lib/metrics" + "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" +) + +// Returns the order updates needed to update the fill amount for the orders +// from local ops queue, according to the latest onchain state (after FinalizeBlock). +// Effectively reverts the optimistic fill amounts removed from the CheckTx to DeliverTx state transition. +func (k Keeper) getUpdatesToSyncLocalOpsQueue( + ctx sdk.Context, +) *types.OffchainUpdates { + localValidatorOperationsQueue, _ := k.MemClob.GetOperationsToReplay(ctx) + fetchOrdersInvolvedInOpQueue(localValidatorOperationsQueue) + orderIdsFromLocal := fetchOrdersInvolvedInOpQueue( + localValidatorOperationsQueue, + ) + allUpdates := types.NewOffchainUpdates() + for orderId := range orderIdsFromLocal { + orderbookUpdate := k.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId) + allUpdates.Append(orderbookUpdate) + } + return allUpdates +} + +// Grpc Streaming logic after consensus agrees on a block. +// - Stream all events staged during `FinalizeBlock`. +// - Stream orderbook updates to sync fills in local ops queue. +func (k Keeper) StreamBatchUpdatesAfterFinalizeBlock( + ctx sdk.Context, +) { + defer telemetry.MeasureSince( + time.Now(), + types.ModuleName, + metrics.StreamBatchUpdatesAfterFinalizeBlock, + metrics.Latency, + ) + orderBookUpdatesToSyncLocalOpsQueue := k.getUpdatesToSyncLocalOpsQueue(ctx) + + k.GetFullNodeStreamingManager().StreamBatchUpdatesAfterFinalizeBlock( + ctx, + orderBookUpdatesToSyncLocalOpsQueue, + k.PerpetualIdToClobPairId, + ) +} diff --git a/protocol/x/clob/keeper/process_operations.go b/protocol/x/clob/keeper/process_operations.go index d202c2a270..cddb5fb68b 100644 --- a/protocol/x/clob/keeper/process_operations.go +++ b/protocol/x/clob/keeper/process_operations.go @@ -57,26 +57,6 @@ func (k Keeper) ProcessProposerOperations( return errorsmod.Wrapf(types.ErrInvalidMsgProposedOperations, "Error: %+v", err) } - // If grpc streams are on, send absolute fill amounts from local + proposed opqueue to the grpc stream. - // This effetively reverts the optimitic orderbook updates during CheckTx. - if streamingManager := k.GetFullNodeStreamingManager(); streamingManager.Enabled() { - localValidatorOperationsQueue, _ := k.MemClob.GetOperationsToReplay(ctx) - orderIdsFromProposed := fetchOrdersInvolvedInOpQueue( - operations, - ) - orderIdsFromLocal := fetchOrdersInvolvedInOpQueue( - localValidatorOperationsQueue, - ) - orderIdSetToUpdate := lib.MergeMaps(orderIdsFromLocal, orderIdsFromProposed) - - allUpdates := types.NewOffchainUpdates() - for orderId := range orderIdSetToUpdate { - orderbookUpdate := k.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId) - allUpdates.Append(orderbookUpdate) - } - k.SendOrderbookUpdates(ctx, allUpdates) - } - log.DebugLog(ctx, "Processing operations queue", log.OperationsQueue, types.GetInternalOperationsQueueTextString(operations)) @@ -550,6 +530,7 @@ func (k Keeper) PersistMatchOrdersToState( // if GRPC streaming is on, emit a generated clob match to stream. if streamingManager := k.GetFullNodeStreamingManager(); streamingManager.Enabled() { + // Note: GenerateStreamOrderbookFill doesn't rely on MemClob state. streamOrderbookFill := k.MemClob.GenerateStreamOrderbookFill( ctx, types.ClobMatch{ @@ -560,11 +541,10 @@ func (k Keeper) PersistMatchOrdersToState( &takerOrder, makerOrders, ) - k.SendOrderbookFillUpdates( + + k.GetFullNodeStreamingManager().StageFinalizeBlockFill( ctx, - []types.StreamOrderbookFill{ - streamOrderbookFill, - }, + streamOrderbookFill, ) } @@ -669,11 +649,9 @@ func (k Keeper) PersistMatchLiquidationToState( takerOrder, makerOrders, ) - k.SendOrderbookFillUpdates( + k.GetFullNodeStreamingManager().StageFinalizeBlockFill( ctx, - []types.StreamOrderbookFill{ - streamOrderbookFill, - }, + streamOrderbookFill, ) } return nil diff --git a/protocol/x/clob/types/streaming.pb.go b/protocol/x/clob/types/streaming.pb.go new file mode 100644 index 0000000000..83b8db719a --- /dev/null +++ b/protocol/x/clob/types/streaming.pb.go @@ -0,0 +1,473 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/clob/streaming.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + types "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// StagedFinalizeBlockEvent is an event staged during `FinalizeBlock`. +type StagedFinalizeBlockEvent struct { + // Contains one of StreamOrderbookFill, StreamSubaccountUpdate. + // + // Types that are valid to be assigned to Event: + // *StagedFinalizeBlockEvent_OrderFill + // *StagedFinalizeBlockEvent_SubaccountUpdate + Event isStagedFinalizeBlockEvent_Event `protobuf_oneof:"event"` +} + +func (m *StagedFinalizeBlockEvent) Reset() { *m = StagedFinalizeBlockEvent{} } +func (m *StagedFinalizeBlockEvent) String() string { return proto.CompactTextString(m) } +func (*StagedFinalizeBlockEvent) ProtoMessage() {} +func (*StagedFinalizeBlockEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_cecf6ffcf2554dee, []int{0} +} +func (m *StagedFinalizeBlockEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StagedFinalizeBlockEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StagedFinalizeBlockEvent.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StagedFinalizeBlockEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StagedFinalizeBlockEvent.Merge(m, src) +} +func (m *StagedFinalizeBlockEvent) XXX_Size() int { + return m.Size() +} +func (m *StagedFinalizeBlockEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StagedFinalizeBlockEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StagedFinalizeBlockEvent proto.InternalMessageInfo + +type isStagedFinalizeBlockEvent_Event interface { + isStagedFinalizeBlockEvent_Event() + MarshalTo([]byte) (int, error) + Size() int +} + +type StagedFinalizeBlockEvent_OrderFill struct { + OrderFill *StreamOrderbookFill `protobuf:"bytes,1,opt,name=order_fill,json=orderFill,proto3,oneof" json:"order_fill,omitempty"` +} +type StagedFinalizeBlockEvent_SubaccountUpdate struct { + SubaccountUpdate *types.StreamSubaccountUpdate `protobuf:"bytes,2,opt,name=subaccount_update,json=subaccountUpdate,proto3,oneof" json:"subaccount_update,omitempty"` +} + +func (*StagedFinalizeBlockEvent_OrderFill) isStagedFinalizeBlockEvent_Event() {} +func (*StagedFinalizeBlockEvent_SubaccountUpdate) isStagedFinalizeBlockEvent_Event() {} + +func (m *StagedFinalizeBlockEvent) GetEvent() isStagedFinalizeBlockEvent_Event { + if m != nil { + return m.Event + } + return nil +} + +func (m *StagedFinalizeBlockEvent) GetOrderFill() *StreamOrderbookFill { + if x, ok := m.GetEvent().(*StagedFinalizeBlockEvent_OrderFill); ok { + return x.OrderFill + } + return nil +} + +func (m *StagedFinalizeBlockEvent) GetSubaccountUpdate() *types.StreamSubaccountUpdate { + if x, ok := m.GetEvent().(*StagedFinalizeBlockEvent_SubaccountUpdate); ok { + return x.SubaccountUpdate + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*StagedFinalizeBlockEvent) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*StagedFinalizeBlockEvent_OrderFill)(nil), + (*StagedFinalizeBlockEvent_SubaccountUpdate)(nil), + } +} + +func init() { + proto.RegisterType((*StagedFinalizeBlockEvent)(nil), "dydxprotocol.clob.StagedFinalizeBlockEvent") +} + +func init() { proto.RegisterFile("dydxprotocol/clob/streaming.proto", fileDescriptor_cecf6ffcf2554dee) } + +var fileDescriptor_cecf6ffcf2554dee = []byte{ + // 281 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0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x3c, 0x18, 0x82, 0x04, 0x8a, 0xd1, + 0xc4, 0x9c, 0xd8, 0xb9, 0x58, 0x53, 0x41, 0x4e, 0x76, 0x0a, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, + 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, + 0xc6, 0x63, 0x39, 0x86, 0x28, 0xb3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, + 0x7d, 0x94, 0x30, 0x29, 0x33, 0xd1, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x87, 0x8b, 0x54, 0x40, + 0xc2, 0xa9, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x2c, 0x6c, 0x0c, 0x08, 0x00, 0x00, 0xff, + 0xff, 0x65, 0x71, 0xd8, 0xa8, 0xa9, 0x01, 0x00, 0x00, +} + +func (m *StagedFinalizeBlockEvent) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StagedFinalizeBlockEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StagedFinalizeBlockEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Event != nil { + { + size := m.Event.Size() + i -= size + if _, err := m.Event.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *StagedFinalizeBlockEvent_OrderFill) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StagedFinalizeBlockEvent_OrderFill) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.OrderFill != nil { + { + size, err := m.OrderFill.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStreaming(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *StagedFinalizeBlockEvent_SubaccountUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StagedFinalizeBlockEvent_SubaccountUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.SubaccountUpdate != nil { + { + size, err := m.SubaccountUpdate.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStreaming(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func encodeVarintStreaming(dAtA []byte, offset int, v uint64) int { + offset -= sovStreaming(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *StagedFinalizeBlockEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Event != nil { + n += m.Event.Size() + } + return n +} + +func (m *StagedFinalizeBlockEvent_OrderFill) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.OrderFill != nil { + l = m.OrderFill.Size() + n += 1 + l + sovStreaming(uint64(l)) + } + return n +} +func (m *StagedFinalizeBlockEvent_SubaccountUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SubaccountUpdate != nil { + l = m.SubaccountUpdate.Size() + n += 1 + l + sovStreaming(uint64(l)) + } + return n +} + +func sovStreaming(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozStreaming(x uint64) (n int) { + return sovStreaming(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *StagedFinalizeBlockEvent) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStreaming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StagedFinalizeBlockEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StagedFinalizeBlockEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OrderFill", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStreaming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStreaming + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStreaming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &StreamOrderbookFill{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Event = &StagedFinalizeBlockEvent_OrderFill{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubaccountUpdate", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStreaming + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStreaming + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStreaming + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types.StreamSubaccountUpdate{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Event = &StagedFinalizeBlockEvent_SubaccountUpdate{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStreaming(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStreaming + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipStreaming(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStreaming + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStreaming + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowStreaming + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthStreaming + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupStreaming + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthStreaming + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthStreaming = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStreaming = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStreaming = fmt.Errorf("proto: unexpected end of group") +) diff --git a/protocol/x/subaccounts/keeper/subaccount.go b/protocol/x/subaccounts/keeper/subaccount.go index 8b40d382b1..8ee77a9d13 100644 --- a/protocol/x/subaccounts/keeper/subaccount.go +++ b/protocol/x/subaccounts/keeper/subaccount.go @@ -445,11 +445,9 @@ func (k Keeper) UpdateSubaccounts( if lib.IsDeliverTxMode(ctx) && k.GetFullNodeStreamingManager().Enabled() { if k.GetFullNodeStreamingManager().TracksSubaccountId(*u.SettledSubaccount.Id) { subaccountUpdate := GenerateStreamSubaccountUpdate(u, fundingPayments) - k.SendFinalizedSubaccountUpdates( + k.GetFullNodeStreamingManager().StageFinalizeBlockSubaccountUpdate( ctx, - []types.StreamSubaccountUpdate{ - subaccountUpdate, - }, + subaccountUpdate, ) } } From 521ed1b2b864be37e522a9f09e2ecb1bded0efff Mon Sep 17 00:00:00 2001 From: Tian <tian@dydx.exchange> Date: Tue, 17 Sep 2024 02:29:19 +0900 Subject: [PATCH 11/12] add megavault operator params and update message (#2259) --- .../src/codegen/dydxprotocol/vault/genesis.ts | 20 +- .../src/codegen/dydxprotocol/vault/params.ts | 55 ++ .../codegen/dydxprotocol/vault/tx.rpc.msg.ts | 12 +- .../src/codegen/dydxprotocol/vault/tx.ts | 113 ++++- proto/dydxprotocol/vault/genesis.proto | 2 + proto/dydxprotocol/vault/params.proto | 6 + proto/dydxprotocol/vault/tx.proto | 17 + protocol/app/msgs/all_msgs.go | 2 + protocol/app/msgs/internal_msgs.go | 2 + protocol/app/msgs/internal_msgs_test.go | 2 + .../app/testdata/default_genesis_state.json | 3 + protocol/lib/ante/internal_msg.go | 1 + .../scripts/genesis/sample_pregenesis.json | 3 + protocol/testing/genesis.sh | 2 + protocol/testutil/constants/genesis.go | 3 + protocol/x/vault/genesis.go | 6 + .../msg_server_update_operator_params.go | 32 ++ .../msg_server_update_operator_params_test.go | 75 +++ protocol/x/vault/keeper/params.go | 29 ++ protocol/x/vault/keeper/params_test.go | 32 ++ protocol/x/vault/types/errors.go | 5 + protocol/x/vault/types/genesis.go | 1 + protocol/x/vault/types/genesis.pb.go | 159 ++++-- protocol/x/vault/types/keys.go | 3 + protocol/x/vault/types/keys_test.go | 1 + protocol/x/vault/types/params.go | 18 + protocol/x/vault/types/params.pb.go | 239 +++++++-- protocol/x/vault/types/params_test.go | 35 ++ protocol/x/vault/types/tx.pb.go | 480 ++++++++++++++++-- 29 files changed, 1223 insertions(+), 135 deletions(-) create mode 100644 protocol/x/vault/keeper/msg_server_update_operator_params.go create mode 100644 protocol/x/vault/keeper/msg_server_update_operator_params_test.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts index b3d055a1fc..7275203711 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts @@ -1,5 +1,5 @@ import { NumShares, NumSharesSDKType, OwnerShare, OwnerShareSDKType, OwnerShareUnlocks, OwnerShareUnlocksSDKType } from "./share"; -import { QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType } from "./params"; +import { QuotingParams, QuotingParamsSDKType, OperatorParams, OperatorParamsSDKType, VaultParams, VaultParamsSDKType } from "./params"; import { VaultId, VaultIdSDKType } from "./vault"; import * as _m0 from "protobufjs/minimal"; import { DeepPartial } from "../../helpers"; @@ -20,6 +20,9 @@ export interface GenesisState { /** All owner share unlocks. */ allOwnerShareUnlocks: OwnerShareUnlocks[]; + /** The parameters regarding megavault operator. */ + + operatorParams?: OperatorParams; } /** GenesisState defines `x/vault`'s genesis state. */ @@ -38,6 +41,9 @@ export interface GenesisStateSDKType { /** All owner share unlocks. */ all_owner_share_unlocks: OwnerShareUnlocksSDKType[]; + /** The parameters regarding megavault operator. */ + + operator_params?: OperatorParamsSDKType; } /** Vault defines the state of a vault. */ @@ -136,7 +142,8 @@ function createBaseGenesisState(): GenesisState { ownerShares: [], vaults: [], defaultQuotingParams: undefined, - allOwnerShareUnlocks: [] + allOwnerShareUnlocks: [], + operatorParams: undefined }; } @@ -162,6 +169,10 @@ export const GenesisState = { OwnerShareUnlocks.encode(v!, writer.uint32(42).fork()).ldelim(); } + if (message.operatorParams !== undefined) { + OperatorParams.encode(message.operatorParams, writer.uint32(50).fork()).ldelim(); + } + return writer; }, @@ -194,6 +205,10 @@ export const GenesisState = { message.allOwnerShareUnlocks.push(OwnerShareUnlocks.decode(reader, reader.uint32())); break; + case 6: + message.operatorParams = OperatorParams.decode(reader, reader.uint32()); + break; + default: reader.skipType(tag & 7); break; @@ -210,6 +225,7 @@ export const GenesisState = { message.vaults = object.vaults?.map(e => Vault.fromPartial(e)) || []; message.defaultQuotingParams = object.defaultQuotingParams !== undefined && object.defaultQuotingParams !== null ? QuotingParams.fromPartial(object.defaultQuotingParams) : undefined; message.allOwnerShareUnlocks = object.allOwnerShareUnlocks?.map(e => OwnerShareUnlocks.fromPartial(e)) || []; + message.operatorParams = object.operatorParams !== undefined && object.operatorParams !== null ? OperatorParams.fromPartial(object.operatorParams) : undefined; return message; } diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts index 0dd3919cda..85118c1e48 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/params.ts @@ -91,6 +91,16 @@ export interface VaultParamsSDKType { quoting_params?: QuotingParamsSDKType; } +/** OperatorParams stores parameters regarding megavault operator. */ + +export interface OperatorParams { + operator: string; +} +/** OperatorParams stores parameters regarding megavault operator. */ + +export interface OperatorParamsSDKType { + operator: string; +} /** * Deprecated: Params stores `x/vault` parameters. * Deprecated since v6.x as is replaced by QuotingParams. @@ -330,6 +340,51 @@ export const VaultParams = { }; +function createBaseOperatorParams(): OperatorParams { + return { + operator: "" + }; +} + +export const OperatorParams = { + encode(message: OperatorParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.operator !== "") { + writer.uint32(10).string(message.operator); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OperatorParams { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOperatorParams(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.operator = reader.string(); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<OperatorParams>): OperatorParams { + const message = createBaseOperatorParams(); + message.operator = object.operator ?? ""; + return message; + } + +}; + function createBaseParams(): Params { return { layers: 0, diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts index bae3116ba7..88d0a2ebcd 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.rpc.msg.ts @@ -1,6 +1,6 @@ import { Rpc } from "../../helpers"; import * as _m0 from "protobufjs/minimal"; -import { MsgDepositToMegavault, MsgDepositToMegavaultResponse, MsgUpdateDefaultQuotingParams, MsgUpdateDefaultQuotingParamsResponse, MsgSetVaultParams, MsgSetVaultParamsResponse, MsgUnlockShares, MsgUnlockSharesResponse } from "./tx"; +import { MsgDepositToMegavault, MsgDepositToMegavaultResponse, MsgUpdateDefaultQuotingParams, MsgUpdateDefaultQuotingParamsResponse, MsgUpdateOperatorParams, MsgUpdateOperatorParamsResponse, MsgSetVaultParams, MsgSetVaultParamsResponse, MsgUnlockShares, MsgUnlockSharesResponse } from "./tx"; /** Msg defines the Msg service. */ export interface Msg { @@ -9,6 +9,9 @@ export interface Msg { /** UpdateDefaultQuotingParams updates the default quoting params in state. */ updateDefaultQuotingParams(request: MsgUpdateDefaultQuotingParams): Promise<MsgUpdateDefaultQuotingParamsResponse>; + /** UpdateOperatorParams sets the parameters regarding megavault operator. */ + + updateOperatorParams(request: MsgUpdateOperatorParams): Promise<MsgUpdateOperatorParamsResponse>; /** SetVaultParams sets the parameters of a specific vault. */ setVaultParams(request: MsgSetVaultParams): Promise<MsgSetVaultParamsResponse>; @@ -26,6 +29,7 @@ export class MsgClientImpl implements Msg { this.rpc = rpc; this.depositToMegavault = this.depositToMegavault.bind(this); this.updateDefaultQuotingParams = this.updateDefaultQuotingParams.bind(this); + this.updateOperatorParams = this.updateOperatorParams.bind(this); this.setVaultParams = this.setVaultParams.bind(this); this.unlockShares = this.unlockShares.bind(this); } @@ -42,6 +46,12 @@ export class MsgClientImpl implements Msg { return promise.then(data => MsgUpdateDefaultQuotingParamsResponse.decode(new _m0.Reader(data))); } + updateOperatorParams(request: MsgUpdateOperatorParams): Promise<MsgUpdateOperatorParamsResponse> { + const data = MsgUpdateOperatorParams.encode(request).finish(); + const promise = this.rpc.request("dydxprotocol.vault.Msg", "UpdateOperatorParams", data); + return promise.then(data => MsgUpdateOperatorParamsResponse.decode(new _m0.Reader(data))); + } + setVaultParams(request: MsgSetVaultParams): Promise<MsgSetVaultParamsResponse> { const data = MsgSetVaultParams.encode(request).finish(); const promise = this.rpc.request("dydxprotocol.vault.Msg", "SetVaultParams", data); diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts index dfb80e764c..0d802ca4f4 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts @@ -1,5 +1,5 @@ import { SubaccountId, SubaccountIdSDKType } from "../subaccounts/subaccount"; -import { QuotingParams, QuotingParamsSDKType, VaultParams, VaultParamsSDKType, Params, ParamsSDKType } from "./params"; +import { QuotingParams, QuotingParamsSDKType, OperatorParams, OperatorParamsSDKType, VaultParams, VaultParamsSDKType, Params, ParamsSDKType } from "./params"; import { VaultId, VaultIdSDKType } from "./vault"; import { NumShares, NumSharesSDKType } from "./share"; import * as _m0 from "protobufjs/minimal"; @@ -156,6 +156,28 @@ export interface MsgUpdateParamsSDKType { params?: ParamsSDKType; } +/** MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type. */ + +export interface MsgUpdateOperatorParams { + authority: string; + /** Operator parameters to set. */ + + params?: OperatorParams; +} +/** MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type. */ + +export interface MsgUpdateOperatorParamsSDKType { + authority: string; + /** Operator parameters to set. */ + + params?: OperatorParamsSDKType; +} +/** MsgUpdateVaultParamsResponse is the Msg/UpdateOperatorParams response type. */ + +export interface MsgUpdateOperatorParamsResponse {} +/** MsgUpdateVaultParamsResponse is the Msg/UpdateOperatorParams response type. */ + +export interface MsgUpdateOperatorParamsResponseSDKType {} function createBaseMsgDepositToMegavault(): MsgDepositToMegavault { return { @@ -598,4 +620,93 @@ export const MsgUpdateParams = { return message; } +}; + +function createBaseMsgUpdateOperatorParams(): MsgUpdateOperatorParams { + return { + authority: "", + params: undefined + }; +} + +export const MsgUpdateOperatorParams = { + encode(message: MsgUpdateOperatorParams, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.authority !== "") { + writer.uint32(10).string(message.authority); + } + + if (message.params !== undefined) { + OperatorParams.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateOperatorParams { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateOperatorParams(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + case 1: + message.authority = reader.string(); + break; + + case 2: + message.params = OperatorParams.decode(reader, reader.uint32()); + break; + + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(object: DeepPartial<MsgUpdateOperatorParams>): MsgUpdateOperatorParams { + const message = createBaseMsgUpdateOperatorParams(); + message.authority = object.authority ?? ""; + message.params = object.params !== undefined && object.params !== null ? OperatorParams.fromPartial(object.params) : undefined; + return message; + } + +}; + +function createBaseMsgUpdateOperatorParamsResponse(): MsgUpdateOperatorParamsResponse { + return {}; +} + +export const MsgUpdateOperatorParamsResponse = { + encode(_: MsgUpdateOperatorParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpdateOperatorParamsResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseMsgUpdateOperatorParamsResponse(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(_: DeepPartial<MsgUpdateOperatorParamsResponse>): MsgUpdateOperatorParamsResponse { + const message = createBaseMsgUpdateOperatorParamsResponse(); + return message; + } + }; \ No newline at end of file diff --git a/proto/dydxprotocol/vault/genesis.proto b/proto/dydxprotocol/vault/genesis.proto index c295f016dc..9697b40b94 100644 --- a/proto/dydxprotocol/vault/genesis.proto +++ b/proto/dydxprotocol/vault/genesis.proto @@ -21,6 +21,8 @@ message GenesisState { // All owner share unlocks. repeated OwnerShareUnlocks all_owner_share_unlocks = 5 [ (gogoproto.nullable) = false ]; + // The parameters regarding megavault operator. + OperatorParams operator_params = 6 [ (gogoproto.nullable) = false ]; } // Vault defines the state of a vault. diff --git a/proto/dydxprotocol/vault/params.proto b/proto/dydxprotocol/vault/params.proto index 73f5c52880..f0f16fb714 100644 --- a/proto/dydxprotocol/vault/params.proto +++ b/proto/dydxprotocol/vault/params.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package dydxprotocol.vault; +import "cosmos_proto/cosmos.proto"; import "dydxprotocol/vault/vault.proto"; import "gogoproto/gogo.proto"; @@ -48,6 +49,11 @@ message VaultParams { QuotingParams quoting_params = 2; } +// OperatorParams stores parameters regarding megavault operator. +message OperatorParams { + string operator = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} + // Deprecated: Params stores `x/vault` parameters. // Deprecated since v6.x as is replaced by QuotingParams. message Params { diff --git a/proto/dydxprotocol/vault/tx.proto b/proto/dydxprotocol/vault/tx.proto index c1db0c8f4a..4c52fa179f 100644 --- a/proto/dydxprotocol/vault/tx.proto +++ b/proto/dydxprotocol/vault/tx.proto @@ -21,6 +21,10 @@ service Msg { rpc UpdateDefaultQuotingParams(MsgUpdateDefaultQuotingParams) returns (MsgUpdateDefaultQuotingParamsResponse); + // UpdateOperatorParams sets the parameters regarding megavault operator. + rpc UpdateOperatorParams(MsgUpdateOperatorParams) + returns (MsgUpdateOperatorParamsResponse); + // SetVaultParams sets the parameters of a specific vault. rpc SetVaultParams(MsgSetVaultParams) returns (MsgSetVaultParamsResponse); @@ -112,3 +116,16 @@ message MsgUpdateParams { // The parameters to update. Each field must be set. Params params = 2 [ (gogoproto.nullable) = false ]; } + +// MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type. +message MsgUpdateOperatorParams { + // Authority is the address that controls the module. + option (cosmos.msg.v1.signer) = "authority"; + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // Operator parameters to set. + OperatorParams params = 2 [ (gogoproto.nullable) = false ]; +} + +// MsgUpdateVaultParamsResponse is the Msg/UpdateOperatorParams response type. +message MsgUpdateOperatorParamsResponse {} diff --git a/protocol/app/msgs/all_msgs.go b/protocol/app/msgs/all_msgs.go index 18eb2b5280..b864918dcd 100644 --- a/protocol/app/msgs/all_msgs.go +++ b/protocol/app/msgs/all_msgs.go @@ -257,6 +257,8 @@ var ( "/dydxprotocol.vault.MsgUnlockSharesResponse": {}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": {}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": {}, + "/dydxprotocol.vault.MsgUpdateOperatorParams": {}, + "/dydxprotocol.vault.MsgUpdateOperatorParamsResponse": {}, "/dydxprotocol.vault.MsgUpdateParams": {}, // vest diff --git a/protocol/app/msgs/internal_msgs.go b/protocol/app/msgs/internal_msgs.go index 778311d8a5..1403318f96 100644 --- a/protocol/app/msgs/internal_msgs.go +++ b/protocol/app/msgs/internal_msgs.go @@ -202,6 +202,8 @@ var ( "/dydxprotocol.vault.MsgUnlockSharesResponse": nil, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams": &vault.MsgUpdateDefaultQuotingParams{}, "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse": nil, + "/dydxprotocol.vault.MsgUpdateOperatorParams": &vault.MsgUpdateOperatorParams{}, + "/dydxprotocol.vault.MsgUpdateOperatorParamsResponse": nil, // vest "/dydxprotocol.vest.MsgSetVestEntry": &vest.MsgSetVestEntry{}, diff --git a/protocol/app/msgs/internal_msgs_test.go b/protocol/app/msgs/internal_msgs_test.go index 2d3d5828bf..0b183c962e 100644 --- a/protocol/app/msgs/internal_msgs_test.go +++ b/protocol/app/msgs/internal_msgs_test.go @@ -158,6 +158,8 @@ func TestInternalMsgSamples_Gov_Key(t *testing.T) { "/dydxprotocol.vault.MsgUnlockSharesResponse", "/dydxprotocol.vault.MsgUpdateDefaultQuotingParams", "/dydxprotocol.vault.MsgUpdateDefaultQuotingParamsResponse", + "/dydxprotocol.vault.MsgUpdateOperatorParams", + "/dydxprotocol.vault.MsgUpdateOperatorParamsResponse", // vest "/dydxprotocol.vest.MsgDeleteVestEntry", diff --git a/protocol/app/testdata/default_genesis_state.json b/protocol/app/testdata/default_genesis_state.json index a73a85e96b..e8fd038a30 100644 --- a/protocol/app/testdata/default_genesis_state.json +++ b/protocol/app/testdata/default_genesis_state.json @@ -501,6 +501,9 @@ "order_expiration_seconds": 60, "activation_threshold_quote_quantums": "1000000000" }, + "operator_params": { + "operator": "dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky" + }, "owner_shares": [], "total_shares": { "num_shares": "0" diff --git a/protocol/lib/ante/internal_msg.go b/protocol/lib/ante/internal_msg.go index ae315e5871..e58e43d43b 100644 --- a/protocol/lib/ante/internal_msg.go +++ b/protocol/lib/ante/internal_msg.go @@ -132,6 +132,7 @@ func IsInternalMsg(msg sdk.Msg) bool { *vault.MsgSetVaultParams, *vault.MsgUnlockShares, *vault.MsgUpdateDefaultQuotingParams, + *vault.MsgUpdateOperatorParams, // vest *vest.MsgDeleteVestEntry, diff --git a/protocol/scripts/genesis/sample_pregenesis.json b/protocol/scripts/genesis/sample_pregenesis.json index f242459218..bcb8311a75 100644 --- a/protocol/scripts/genesis/sample_pregenesis.json +++ b/protocol/scripts/genesis/sample_pregenesis.json @@ -3945,6 +3945,9 @@ "spread_buffer_ppm": 1500, "spread_min_ppm": 3000 }, + "operator_params": { + "operator": "dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky" + }, "owner_shares": [ { "owner": "dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4", diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index a5e69c584b..a355d413d9 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -2255,6 +2255,8 @@ function edit_genesis() { # Vaults # Set default quoting params. dasel put -t int -f "$GENESIS" ".app_state.vault.default_quoting_params.spread_min_ppm" -v '3000' + # Set operator params. + dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.operator" -v 'dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky' # Set total shares and owner shares. if [ -z "${INPUT_TEST_ACCOUNTS[0]}" ]; then vault_owner_address='dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4' # alice as default vault owner diff --git a/protocol/testutil/constants/genesis.go b/protocol/testutil/constants/genesis.go index a47b0fae81..a33db9f187 100644 --- a/protocol/testutil/constants/genesis.go +++ b/protocol/testutil/constants/genesis.go @@ -4580,6 +4580,9 @@ const GenesisState = `{ "order_expiration_seconds": 60, "activation_threshold_quote_quantums": "1000000000" }, + "operator_params": { + "operator": "dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky" + }, "owner_shares": [], "total_shares": { "num_shares": "0" diff --git a/protocol/x/vault/genesis.go b/protocol/x/vault/genesis.go index 3d8f84461a..1da55abcdb 100644 --- a/protocol/x/vault/genesis.go +++ b/protocol/x/vault/genesis.go @@ -40,6 +40,11 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetMostRecentClientIds(ctx, vault.VaultId, vault.MostRecentClientIds) k.AddVaultToAddressStore(ctx, vault.VaultId) } + + // Set operator params. + if err := k.SetOperatorParams(ctx, genState.OperatorParams); err != nil { + panic(err) + } } // ExportGenesis returns the module's exported genesis. @@ -53,6 +58,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { // Export params. genesis.DefaultQuotingParams = k.GetDefaultQuotingParams(ctx) + genesis.OperatorParams = k.GetOperatorParams(ctx) // Export vaults. genesis.Vaults = k.GetAllVaults(ctx) diff --git a/protocol/x/vault/keeper/msg_server_update_operator_params.go b/protocol/x/vault/keeper/msg_server_update_operator_params.go new file mode 100644 index 0000000000..6091e1bdc5 --- /dev/null +++ b/protocol/x/vault/keeper/msg_server_update_operator_params.go @@ -0,0 +1,32 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/dydxprotocol/v4-chain/protocol/lib" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +// UpdateOperatorParams updates the operator parameters of megavault. +func (k msgServer) UpdateOperatorParams( + goCtx context.Context, + msg *types.MsgUpdateOperatorParams, +) (*types.MsgUpdateOperatorParamsResponse, error) { + if !k.HasAuthority(msg.Authority) { + return nil, errorsmod.Wrapf( + govtypes.ErrInvalidSigner, + "invalid authority %s", + msg.Authority, + ) + } + + ctx := lib.UnwrapSDKContext(goCtx, types.ModuleName) + if err := k.SetOperatorParams(ctx, msg.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateOperatorParamsResponse{}, nil +} diff --git a/protocol/x/vault/keeper/msg_server_update_operator_params_test.go b/protocol/x/vault/keeper/msg_server_update_operator_params_test.go new file mode 100644 index 0000000000..e51ba5a997 --- /dev/null +++ b/protocol/x/vault/keeper/msg_server_update_operator_params_test.go @@ -0,0 +1,75 @@ +package keeper_test + +import ( + "testing" + + "github.com/dydxprotocol/v4-chain/protocol/lib" + + testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" + "github.com/dydxprotocol/v4-chain/protocol/testutil/constants" + + "github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" + "github.com/stretchr/testify/require" +) + +func TestMsgUpdateOperatorParams(t *testing.T) { + tests := map[string]struct { + // Msg. + msg *types.MsgUpdateOperatorParams + // Expected error + expectedErr string + }{ + "Success. Update to gov module account": { + msg: &types.MsgUpdateOperatorParams{ + Authority: lib.GovModuleAddress.String(), + Params: types.OperatorParams{ + Operator: constants.GovAuthority, + }, + }, + }, + "Success. Update to Alice": { + msg: &types.MsgUpdateOperatorParams{ + Authority: lib.GovModuleAddress.String(), + Params: types.OperatorParams{ + Operator: constants.AliceAccAddress.String(), + }, + }, + }, + "Failure - Invalid Authority": { + msg: &types.MsgUpdateOperatorParams{ + Authority: constants.AliceAccAddress.String(), + Params: types.OperatorParams{ + Operator: constants.GovAuthority, + }, + }, + expectedErr: "invalid authority", + }, + "Failure - Invalid Params": { + msg: &types.MsgUpdateOperatorParams{ + Authority: lib.GovModuleAddress.String(), + Params: types.OperatorParams{ + Operator: "", + }, + }, + expectedErr: types.ErrEmptyOperator.Error(), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.VaultKeeper + ms := keeper.NewMsgServerImpl(k) + + _, err := ms.UpdateOperatorParams(ctx, tc.msg) + if tc.expectedErr != "" { + require.ErrorContains(t, err, tc.expectedErr) + } else { + require.NoError(t, err) + require.Equal(t, tc.msg.Params, k.GetOperatorParams(ctx)) + } + }) + } +} diff --git a/protocol/x/vault/keeper/params.go b/protocol/x/vault/keeper/params.go index 5620daa722..4bd7783945 100644 --- a/protocol/x/vault/keeper/params.go +++ b/protocol/x/vault/keeper/params.go @@ -122,3 +122,32 @@ func (k Keeper) UnsafeDeleteParams( store := ctx.KVStore(k.storeKey) store.Delete([]byte("Params")) } + +// GetOperatorParams returns `OperatorParams` in state. +func (k Keeper) GetOperatorParams( + ctx sdk.Context, +) ( + params types.OperatorParams, +) { + store := ctx.KVStore(k.storeKey) + b := store.Get([]byte(types.OperatorParamsKey)) + k.cdc.MustUnmarshal(b, ¶ms) + return params +} + +// SetOperatorParams sets `OperatorParams` in state. +// Returns an error if validation fails. +func (k Keeper) SetOperatorParams( + ctx sdk.Context, + params types.OperatorParams, +) error { + if err := params.Validate(); err != nil { + return err + } + + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(¶ms) + store.Set([]byte(types.OperatorParamsKey), b) + + return nil +} diff --git a/protocol/x/vault/keeper/params_test.go b/protocol/x/vault/keeper/params_test.go index cb7f410f47..3d4e8a5c0f 100644 --- a/protocol/x/vault/keeper/params_test.go +++ b/protocol/x/vault/keeper/params_test.go @@ -165,3 +165,35 @@ func TestGetVaultQuotingParams(t *testing.T) { }) } } + +func TestGetSetOperatorParams(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.VaultKeeper + + // At genesis, operator defaults to gov module account. + params := k.GetOperatorParams(ctx) + require.Equal( + t, + types.OperatorParams{ + Operator: constants.GovAuthority, + }, + params, + ) + + // Set operator to Alice. + newParams := types.OperatorParams{ + Operator: constants.AliceAccAddress.String(), + } + err := k.SetOperatorParams(ctx, newParams) + require.NoError(t, err) + require.Equal(t, newParams, k.GetOperatorParams(ctx)) + + // Set invalid operator and get. + invalidParams := types.OperatorParams{ + Operator: "", + } + err = k.SetOperatorParams(ctx, invalidParams) + require.Error(t, err) + require.Equal(t, newParams, k.GetOperatorParams(ctx)) +} diff --git a/protocol/x/vault/types/errors.go b/protocol/x/vault/types/errors.go index ec534653b8..45f0f5cee7 100644 --- a/protocol/x/vault/types/errors.go +++ b/protocol/x/vault/types/errors.go @@ -121,4 +121,9 @@ var ( 23, "Locked shares exceeds owner shares", ) + ErrEmptyOperator = errorsmod.Register( + ModuleName, + 24, + "Empty operator address", + ) ) diff --git a/protocol/x/vault/types/genesis.go b/protocol/x/vault/types/genesis.go index 88bed0f395..90cc1b2209 100644 --- a/protocol/x/vault/types/genesis.go +++ b/protocol/x/vault/types/genesis.go @@ -4,6 +4,7 @@ package types func DefaultGenesis() *GenesisState { return &GenesisState{ DefaultQuotingParams: DefaultQuotingParams(), + OperatorParams: DefaultOperatorParams(), } } diff --git a/protocol/x/vault/types/genesis.pb.go b/protocol/x/vault/types/genesis.pb.go index c8d11e7887..6acb34440a 100644 --- a/protocol/x/vault/types/genesis.pb.go +++ b/protocol/x/vault/types/genesis.pb.go @@ -35,6 +35,8 @@ type GenesisState struct { DefaultQuotingParams QuotingParams `protobuf:"bytes,4,opt,name=default_quoting_params,json=defaultQuotingParams,proto3" json:"default_quoting_params"` // All owner share unlocks. AllOwnerShareUnlocks []OwnerShareUnlocks `protobuf:"bytes,5,rep,name=all_owner_share_unlocks,json=allOwnerShareUnlocks,proto3" json:"all_owner_share_unlocks"` + // The parameters regarding megavault operator. + OperatorParams OperatorParams `protobuf:"bytes,6,opt,name=operator_params,json=operatorParams,proto3" json:"operator_params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -105,6 +107,13 @@ func (m *GenesisState) GetAllOwnerShareUnlocks() []OwnerShareUnlocks { return nil } +func (m *GenesisState) GetOperatorParams() OperatorParams { + if m != nil { + return m.OperatorParams + } + return OperatorParams{} +} + // Vault defines the state of a vault. type Vault struct { // The ID of the vault. @@ -318,40 +327,41 @@ func init() { func init() { proto.RegisterFile("dydxprotocol/vault/genesis.proto", fileDescriptor_4be4a747b209e41c) } var fileDescriptor_4be4a747b209e41c = []byte{ - // 519 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0x63, 0x3b, 0x69, 0xab, 0x4d, 0x40, 0x68, 0xa9, 0x4a, 0x08, 0xc2, 0x09, 0x91, 0x90, - 0x7a, 0xc1, 0x16, 0x2d, 0x4a, 0x2f, 0x1c, 0xa0, 0x48, 0x94, 0x72, 0x00, 0x9a, 0x8a, 0x1c, 0x90, - 0x90, 0xe5, 0xd8, 0x8b, 0x63, 0xb1, 0xf1, 0x06, 0xef, 0x3a, 0xb4, 0x6f, 0xc1, 0x9d, 0x17, 0xe0, - 0x41, 0x40, 0xea, 0xb1, 0x47, 0x4e, 0x08, 0x25, 0x2f, 0x82, 0x3c, 0xbb, 0x49, 0xe3, 0xd4, 0x09, - 0x41, 0xa2, 0x17, 0xc7, 0x99, 0xf9, 0xe7, 0xf3, 0xce, 0xfc, 0x1e, 0xa3, 0x86, 0x7f, 0xea, 0x9f, - 0x0c, 0x62, 0x26, 0x98, 0xc7, 0xa8, 0x3d, 0x74, 0x13, 0x2a, 0xec, 0x80, 0x44, 0x84, 0x87, 0xdc, - 0x82, 0x30, 0xc6, 0xb3, 0x0a, 0x0b, 0x14, 0xb5, 0xcd, 0x80, 0x05, 0x0c, 0x62, 0x76, 0x7a, 0x27, - 0x95, 0xb5, 0x7a, 0x0e, 0x6b, 0xe0, 0xc6, 0x6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, 0x08, 0xef, 0xae, 0x41, 0x7c, 0xf7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe4, - 0x95, 0x50, 0xc5, 0x60, 0x05, 0x00, 0x00, + // 542 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0x9d, 0x47, 0xab, 0x49, 0x28, 0x68, 0xa8, 0x4a, 0x08, 0xc2, 0x09, 0x91, 0x90, 0xba, + 0xc1, 0x16, 0x2d, 0x4a, 0x37, 0x2c, 0xa0, 0x48, 0x94, 0xb2, 0x00, 0x92, 0x8a, 0x2c, 0x90, 0x90, + 0x35, 0xb1, 0x07, 0xc7, 0xc2, 0xf1, 0x04, 0xcf, 0x38, 0xb4, 0x7f, 0xc1, 0x67, 0xf0, 0x21, 0x20, + 0x75, 0xd9, 0x25, 0x2b, 0x84, 0x92, 0x3d, 0xdf, 0x80, 0x7c, 0x67, 0x92, 0xc6, 0xa9, 0x53, 0x82, + 0x44, 0x37, 0x8e, 0x73, 0xee, 0xb9, 0xc7, 0x67, 0xee, 0x63, 0x50, 0xc3, 0x3d, 0x71, 0x8f, 0x87, + 0x11, 0x13, 0xcc, 0x61, 0x81, 0x35, 0x22, 0x71, 0x20, 0x2c, 0x8f, 0x86, 0x94, 0xfb, 0xdc, 0x04, + 0x18, 0xe3, 0x79, 0x86, 0x09, 0x8c, 0xda, 0xa6, 0xc7, 0x3c, 0x06, 0x98, 0x95, 0xbc, 0x49, 0x66, + 0xad, 0x9e, 0xa1, 0x35, 0x24, 0x11, 0x19, 0x28, 0xa9, 0x9a, 0x91, 0x41, 0xe0, 0x7d, 0x12, 0xd1, + 0x4b, 0xe2, 0xf0, 0x94, 0xf1, 0xe6, 0xef, 0x3c, 0xaa, 0x1c, 0x48, 0x73, 0x47, 0x82, 0x08, 0x8a, + 0x9f, 0xa3, 0x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x7b, 0x25, 0xc0, 0x77, + 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xf9, 0x2f, 0x34, 0xb3, 0x05, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -374,6 +384,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.OperatorParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 if len(m.AllOwnerShareUnlocks) > 0 { for iNdEx := len(m.AllOwnerShareUnlocks) - 1; iNdEx >= 0; iNdEx-- { { @@ -460,20 +480,20 @@ func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.MostRecentClientIds) > 0 { - dAtA4 := make([]byte, len(m.MostRecentClientIds)*10) - var j3 int + dAtA5 := make([]byte, len(m.MostRecentClientIds)*10) + var j4 int for _, num := range m.MostRecentClientIds { for num >= 1<<7 { - dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + dAtA5[j4] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j3++ + j4++ } - dAtA4[j3] = uint8(num) - j3++ + dAtA5[j4] = uint8(num) + j4++ } - i -= j3 - copy(dAtA[i:], dAtA4[:j3]) - i = encodeVarintGenesis(dAtA, i, uint64(j3)) + i -= j4 + copy(dAtA[i:], dAtA5[:j4]) + i = encodeVarintGenesis(dAtA, i, uint64(j4)) i-- dAtA[i] = 0x1a } @@ -568,20 +588,20 @@ func (m *VaultV6) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if len(m.MostRecentClientIds) > 0 { - dAtA9 := make([]byte, len(m.MostRecentClientIds)*10) - var j8 int + dAtA10 := make([]byte, len(m.MostRecentClientIds)*10) + var j9 int for _, num := range m.MostRecentClientIds { for num >= 1<<7 { - dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j8++ + j9++ } - dAtA9[j8] = uint8(num) - j8++ + dAtA10[j9] = uint8(num) + j9++ } - i -= j8 - copy(dAtA[i:], dAtA9[:j8]) - i = encodeVarintGenesis(dAtA, i, uint64(j8)) + i -= j9 + copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintGenesis(dAtA, i, uint64(j9)) i-- dAtA[i] = 0x2a } @@ -675,6 +695,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.OperatorParams.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -950,6 +972,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OperatorParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/protocol/x/vault/types/keys.go b/protocol/x/vault/types/keys.go index adeac27735..fcf5f0d429 100644 --- a/protocol/x/vault/types/keys.go +++ b/protocol/x/vault/types/keys.go @@ -36,6 +36,9 @@ const ( // MostRecentClientIdsKeyPrefix is the prefix to retrieve all most recent client IDs. // MostRecentClientIdsStore: vaultId VaultId -> clientIds []uint32 MostRecentClientIdsKeyPrefix = "MostRecentClientIds:" + + // OperatorParamsKey is the key to retrieve OperatorParams. + OperatorParamsKey = "OperatorParams" ) // Module accounts diff --git a/protocol/x/vault/types/keys_test.go b/protocol/x/vault/types/keys_test.go index eff8bea720..42d6a87c51 100644 --- a/protocol/x/vault/types/keys_test.go +++ b/protocol/x/vault/types/keys_test.go @@ -20,6 +20,7 @@ func TestStateKeys(t *testing.T) { require.Equal(t, "VaultAddress:", types.VaultAddressKeyPrefix) require.Equal(t, "MostRecentClientIds:", types.MostRecentClientIdsKeyPrefix) require.Equal(t, "OwnerShareUnlocks:", types.OwnerShareUnlocksKeyPrefix) + require.Equal(t, "OperatorParams", types.OperatorParamsKey) } func TestModuleAccountKeys(t *testing.T) { diff --git a/protocol/x/vault/types/params.go b/protocol/x/vault/types/params.go index d339114ee0..4236d981d1 100644 --- a/protocol/x/vault/types/params.go +++ b/protocol/x/vault/types/params.go @@ -4,6 +4,7 @@ import ( "math" "github.com/dydxprotocol/v4-chain/protocol/dtypes" + "github.com/dydxprotocol/v4-chain/protocol/lib" ) // DefaultQuotingParams returns a default set of `x/vault` parameters. @@ -60,3 +61,20 @@ func (v VaultParams) Validate() error { return nil } + +// Validate validates OperatorParams. +func (o OperatorParams) Validate() error { + // Validate that operator is non-empty. + if o.Operator == "" { + return ErrEmptyOperator + } + + return nil +} + +// DefaultOperatorParams returns a default set of `x/vault` operator parameters. +func DefaultOperatorParams() OperatorParams { + return OperatorParams{ + Operator: lib.GovModuleAddress.String(), + } +} diff --git a/protocol/x/vault/types/params.pb.go b/protocol/x/vault/types/params.pb.go index b136d9d840..3c2908369c 100644 --- a/protocol/x/vault/types/params.pb.go +++ b/protocol/x/vault/types/params.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" github_com_dydxprotocol_v4_chain_protocol_dtypes "github.com/dydxprotocol/v4-chain/protocol/dtypes" @@ -178,6 +179,51 @@ func (m *VaultParams) GetQuotingParams() *QuotingParams { return nil } +// OperatorParams stores parameters regarding megavault operator. +type OperatorParams struct { + Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` +} + +func (m *OperatorParams) Reset() { *m = OperatorParams{} } +func (m *OperatorParams) String() string { return proto.CompactTextString(m) } +func (*OperatorParams) ProtoMessage() {} +func (*OperatorParams) Descriptor() ([]byte, []int) { + return fileDescriptor_6043e0b8bfdbca9f, []int{2} +} +func (m *OperatorParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OperatorParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OperatorParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OperatorParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_OperatorParams.Merge(m, src) +} +func (m *OperatorParams) XXX_Size() int { + return m.Size() +} +func (m *OperatorParams) XXX_DiscardUnknown() { + xxx_messageInfo_OperatorParams.DiscardUnknown(m) +} + +var xxx_messageInfo_OperatorParams proto.InternalMessageInfo + +func (m *OperatorParams) GetOperator() string { + if m != nil { + return m.Operator + } + return "" +} + // Deprecated: Params stores `x/vault` parameters. // Deprecated since v6.x as is replaced by QuotingParams. type Params struct { @@ -207,7 +253,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_6043e0b8bfdbca9f, []int{2} + return fileDescriptor_6043e0b8bfdbca9f, []int{3} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -281,43 +327,47 @@ func (m *Params) GetOrderExpirationSeconds() uint32 { func init() { proto.RegisterType((*QuotingParams)(nil), "dydxprotocol.vault.QuotingParams") proto.RegisterType((*VaultParams)(nil), "dydxprotocol.vault.VaultParams") + proto.RegisterType((*OperatorParams)(nil), "dydxprotocol.vault.OperatorParams") proto.RegisterType((*Params)(nil), "dydxprotocol.vault.Params") } func init() { proto.RegisterFile("dydxprotocol/vault/params.proto", fileDescriptor_6043e0b8bfdbca9f) } var fileDescriptor_6043e0b8bfdbca9f = []byte{ - // 475 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0x4f, 0x6b, 0x13, 0x41, - 0x18, 0xc6, 0xb3, 0x46, 0x57, 0x98, 0x36, 0x29, 0x2e, 0x52, 0x96, 0x1e, 0x36, 0x31, 0x8a, 0x14, - 0xc5, 0x5d, 0xa8, 0x42, 0x3d, 0x4a, 0x40, 0xa9, 0x07, 0x21, 0x7f, 0xc4, 0x83, 0x97, 0x61, 0xb2, - 0x3b, 0x49, 0x06, 0x77, 0x77, 0x66, 0x67, 0xde, 0xad, 0x49, 0x3e, 0x45, 0x6f, 0x1e, 0xbc, 0xf9, - 0x69, 0x7a, 0xec, 0x51, 0x3c, 0x14, 0x49, 0xbe, 0x88, 0xec, 0x3b, 0x6b, 0x6d, 0xb1, 0x07, 0x8f, - 0x1e, 0x7a, 0x09, 0x33, 0xcf, 0xf3, 0x7b, 0xe7, 0x0d, 0x3c, 0x0f, 0x4b, 0x3a, 0xc9, 0x32, 0x59, - 0x28, 0x2d, 0x41, 0xc6, 0x32, 0x8d, 0x8e, 0x59, 0x99, 0x42, 0xa4, 0x98, 0x66, 0x99, 0x09, 0x51, - 0xf5, 0xbc, 0xcb, 0x40, 0x88, 0xc0, 0x5e, 0x70, 0xcd, 0x10, 0xfe, 0xda, 0x99, 0xbd, 0xfb, 0x33, - 0x39, 0x93, 0x78, 0x8c, 0xaa, 0x93, 0x55, 0x7b, 0xdf, 0x9a, 0xa4, 0x35, 0x2c, 0x25, 0x88, 0x7c, - 0x36, 0xc0, 0x0d, 0xde, 0x2e, 0x71, 0x53, 0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, 0x4a, 0x02, 0x4b, - 0xc5, 0x4d, 0x38, 0xe6, 0x5a, 0xb0, 0x54, 0xac, 0xd8, 0x24, 0xe5, 0x6f, 0x73, 0x18, 0x75, 0xff, - 0x2c, 0x7d, 0xff, 0x7b, 0x67, 0x15, 0x09, 0x1f, 0xd6, 0x1b, 0x7b, 0x27, 0x0e, 0xd9, 0xfa, 0x50, - 0x45, 0x59, 0x47, 0x74, 0x48, 0x5c, 0x03, 0x0c, 0x4a, 0x1b, 0x51, 0xfb, 0xa0, 0x13, 0xfe, 0xdd, - 0x87, 0x10, 0x07, 0xc6, 0x88, 0x8d, 0x6a, 0xdc, 0x3b, 0x22, 0xed, 0xc2, 0x86, 0x4d, 0x6d, 0x9f, - 0x30, 0xc3, 0xad, 0x83, 0x07, 0xd7, 0x3d, 0x70, 0xa5, 0x16, 0xa3, 0x56, 0x71, 0xf9, 0xda, 0xfb, - 0xda, 0x24, 0xee, 0x4d, 0x61, 0xfe, 0xd3, 0xc2, 0xf4, 0x87, 0xa7, 0xeb, 0xc0, 0x39, 0x5b, 0x07, - 0xce, 0xcf, 0x75, 0xe0, 0x9c, 0x6c, 0x82, 0xc6, 0xd9, 0x26, 0x68, 0x7c, 0xdf, 0x04, 0x8d, 0x8f, - 0x87, 0xff, 0xbe, 0x7d, 0x51, 0x7f, 0x44, 0xf0, 0x4f, 0x4c, 0x5c, 0xd4, 0x9f, 0xff, 0x0a, 0x00, - 0x00, 0xff, 0xff, 0x9a, 0x4f, 0xa0, 0xd4, 0x9c, 0x04, 0x00, 0x00, + // 527 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x94, 0xb1, 0x6e, 0xd3, 0x40, + 0x1c, 0xc6, 0x63, 0x02, 0x01, 0xae, 0x4d, 0x2a, 0xac, 0xaa, 0x32, 0x1d, 0x9c, 0x10, 0x10, 0xaa, + 0x40, 0xb5, 0xa5, 0x52, 0xa9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0b, 0x2a, 0xdc, 0x3e, 0x42, 0xad, 0x89, 0x09, 0x1b, 0x9b, 0xaa, 0x41, 0x86, 0x6b, + 0x7b, 0xf7, 0xae, 0xba, 0xe0, 0x52, 0x2d, 0x82, 0xe6, 0xe4, 0xe2, 0xb1, 0x7b, 0x88, 0x5a, 0xaf, + 0x05, 0x95, 0xa4, 0x8c, 0xc8, 0x3c, 0x6a, 0x1f, 0xdd, 0xe2, 0x95, 0x02, 0xcf, 0xba, 0xdd, 0x73, + 0xbe, 0x7e, 0xd9, 0xdd, 0xac, 0x3a, 0xfa, 0x3c, 0x8e, 0x25, 0x55, 0x2a, 0xd4, 0x92, 0xe5, 0x49, + 0xb0, 0x22, 0xbb, 0x9f, 0xea, 0xa8, 0xf1, 0xbf, 0x78, 0xff, 0x68, 0xf1, 0x7a, 0x83, 0xd3, 0x85, + 0x6b, 0x9d, 0x2d, 0x5c, 0xeb, 0xc7, 0xc2, 0xb5, 0x4e, 0x96, 0x6e, 0xed, 0x6c, 0xe9, 0xd6, 0xbe, + 0x2d, 0xdd, 0xda, 0xbb, 0x83, 0xbf, 0xdf, 0x3e, 0xad, 0x3e, 0x46, 0xf0, 0x88, 0x61, 0x03, 0xf4, + 0x27, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x00, 0x8f, 0x94, 0x49, 0xff, 0x04, 0x00, 0x00, } func (m *QuotingParams) Marshal() (dAtA []byte, err error) { @@ -423,6 +473,36 @@ func (m *VaultParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *OperatorParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperatorParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OperatorParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Operator) > 0 { + i -= len(m.Operator) + copy(dAtA[i:], m.Operator) + i = encodeVarintParams(dAtA, i, uint64(len(m.Operator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -542,6 +622,19 @@ func (m *VaultParams) Size() (n int) { return n } +func (m *OperatorParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Operator) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + func (m *Params) Size() (n int) { if m == nil { return 0 @@ -879,6 +972,88 @@ func (m *VaultParams) Unmarshal(dAtA []byte) error { } return nil } +func (m *OperatorParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OperatorParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperatorParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/protocol/x/vault/types/params_test.go b/protocol/x/vault/types/params_test.go index fe6f053942..9705241f61 100644 --- a/protocol/x/vault/types/params_test.go +++ b/protocol/x/vault/types/params_test.go @@ -132,3 +132,38 @@ func TestValidateVaultParams(t *testing.T) { }) } } + +func TestValidateOperatorParams(t *testing.T) { + tests := map[string]struct { + // Params to validate. + params types.OperatorParams + // Expected error + expectedErr error + }{ + "Success: Alice as operator": { + params: types.OperatorParams{ + Operator: constants.AliceAccAddress.String(), + }, + expectedErr: nil, + }, + "Success: Gov module account as operator": { + params: types.OperatorParams{ + Operator: constants.GovAuthority, + }, + expectedErr: nil, + }, + "Failure - empty operator": { + params: types.OperatorParams{ + Operator: "", + }, + expectedErr: types.ErrEmptyOperator, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + err := tc.params.Validate() + require.Equal(t, tc.expectedErr, err) + }) + } +} diff --git a/protocol/x/vault/types/tx.pb.go b/protocol/x/vault/types/tx.pb.go index 6d7e84c3bf..785488e2ad 100644 --- a/protocol/x/vault/types/tx.pb.go +++ b/protocol/x/vault/types/tx.pb.go @@ -477,6 +477,97 @@ func (m *MsgUpdateParams) GetParams() Params { return Params{} } +// MsgUpdateOperatorParams is the Msg/UpdateOperatorParams request type. +type MsgUpdateOperatorParams struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // Operator parameters to set. + Params OperatorParams `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateOperatorParams) Reset() { *m = MsgUpdateOperatorParams{} } +func (m *MsgUpdateOperatorParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateOperatorParams) ProtoMessage() {} +func (*MsgUpdateOperatorParams) Descriptor() ([]byte, []int) { + return fileDescriptor_ced574c6017ce006, []int{9} +} +func (m *MsgUpdateOperatorParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateOperatorParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateOperatorParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateOperatorParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateOperatorParams.Merge(m, src) +} +func (m *MsgUpdateOperatorParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateOperatorParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateOperatorParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateOperatorParams proto.InternalMessageInfo + +func (m *MsgUpdateOperatorParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateOperatorParams) GetParams() OperatorParams { + if m != nil { + return m.Params + } + return OperatorParams{} +} + +// MsgUpdateVaultParamsResponse is the Msg/UpdateOperatorParams response type. +type MsgUpdateOperatorParamsResponse struct { +} + +func (m *MsgUpdateOperatorParamsResponse) Reset() { *m = MsgUpdateOperatorParamsResponse{} } +func (m *MsgUpdateOperatorParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateOperatorParamsResponse) ProtoMessage() {} +func (*MsgUpdateOperatorParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ced574c6017ce006, []int{10} +} +func (m *MsgUpdateOperatorParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateOperatorParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateOperatorParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateOperatorParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateOperatorParamsResponse.Merge(m, src) +} +func (m *MsgUpdateOperatorParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateOperatorParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateOperatorParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateOperatorParamsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgDepositToMegavault)(nil), "dydxprotocol.vault.MsgDepositToMegavault") proto.RegisterType((*MsgDepositToMegavaultResponse)(nil), "dydxprotocol.vault.MsgDepositToMegavaultResponse") @@ -487,58 +578,63 @@ func init() { proto.RegisterType((*MsgUnlockShares)(nil), "dydxprotocol.vault.MsgUnlockShares") proto.RegisterType((*MsgUnlockSharesResponse)(nil), "dydxprotocol.vault.MsgUnlockSharesResponse") proto.RegisterType((*MsgUpdateParams)(nil), "dydxprotocol.vault.MsgUpdateParams") + proto.RegisterType((*MsgUpdateOperatorParams)(nil), "dydxprotocol.vault.MsgUpdateOperatorParams") + proto.RegisterType((*MsgUpdateOperatorParamsResponse)(nil), "dydxprotocol.vault.MsgUpdateOperatorParamsResponse") } func init() { proto.RegisterFile("dydxprotocol/vault/tx.proto", fileDescriptor_ced574c6017ce006) } var fileDescriptor_ced574c6017ce006 = []byte{ - // 723 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x3d, 0x6f, 0xd3, 0x4e, - 0x1c, 0x8e, 0xff, 0xfd, 0xab, 0xd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, 0x77, 0x72, 0x85, 0xbb, 0x3f, 0x4b, 0x9c, 0x29, 0x73, 0xc5, - 0x19, 0x4f, 0xfa, 0x2e, 0x18, 0x4d, 0xf8, 0x57, 0x49, 0x1b, 0x28, 0x71, 0x40, 0x02, 0xbf, 0x76, - 0x21, 0x49, 0xbf, 0x20, 0xad, 0x1e, 0x8c, 0x80, 0x91, 0x0a, 0xb1, 0xe5, 0x00, 0xc8, 0x29, 0x1f, - 0xb4, 0xa5, 0xb4, 0xca, 0xa9, 0x1f, 0x04, 0x65, 0x65, 0x68, 0x68, 0xac, 0xf0, 0x47, 0x09, 0x28, - 0x27, 0xbc, 0xee, 0x83, 0x2a, 0x0e, 0x4e, 0x51, 0xee, 0xfd, 0x73, 0x4a, 0x3c, 0xcc, 0x36, 0xc8, - 0x1f, 0x7b, 0x11, 0x17, 0x06, 0x14, 0x4b, 0xc2, 0x94, 0xe5, 0xa1, 0x60, 0x71, 0x9f, 0xd7, 0x20, - 0x9b, 0xb0, 0xfb, 0xfc, 0xa0, 0x91, 0x7b, 0x40, 0xca, 0x8d, 0x21, 0x40, 0x9d, 0x0e, 0xe5, 0xad, - 0xfd, 0x23, 0x55, 0x3a, 0x38, 0x52, 0xa5, 0x5f, 0x47, 0xaa, 0xf4, 0xa9, 0xad, 0x66, 0x0e, 0xda, - 0x6a, 0xe6, 0x47, 0x5b, 0xcd, 0xbc, 0xbc, 0x33, 0xfc, 0x95, 0xb1, 0xdb, 0xb9, 0xdf, 0xa3, 0x9b, - 0xa3, 0x3e, 0xca, 0xe2, 0x37, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x36, 0x3b, 0xb2, 0x02, - 0x08, 0x00, 0x00, + // 781 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x4f, 0x13, 0x4d, + 0x18, 0xef, 0xbe, 0x10, 0xde, 0x97, 0xa1,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f3, + 0x5b, 0xc3, 0x7f, 0x75, 0x1b, 0xad, 0x9f, 0x48, 0xde, 0xc7, 0xb7, 0x32, 0xc6, 0xe2, 0x1b, 0x7f, + 0x03, 0x00, 0x00, 0xff, 0xff, 0xb0, 0xc1, 0x28, 0xab, 0x45, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -557,6 +653,8 @@ type MsgClient interface { DepositToMegavault(ctx context.Context, in *MsgDepositToMegavault, opts ...grpc.CallOption) (*MsgDepositToMegavaultResponse, error) // UpdateDefaultQuotingParams updates the default quoting params in state. UpdateDefaultQuotingParams(ctx context.Context, in *MsgUpdateDefaultQuotingParams, opts ...grpc.CallOption) (*MsgUpdateDefaultQuotingParamsResponse, error) + // UpdateOperatorParams sets the parameters regarding megavault operator. + UpdateOperatorParams(ctx context.Context, in *MsgUpdateOperatorParams, opts ...grpc.CallOption) (*MsgUpdateOperatorParamsResponse, error) // SetVaultParams sets the parameters of a specific vault. SetVaultParams(ctx context.Context, in *MsgSetVaultParams, opts ...grpc.CallOption) (*MsgSetVaultParamsResponse, error) // UnlockShares unlocks an owner's shares that are due to unlock by the block @@ -590,6 +688,15 @@ func (c *msgClient) UpdateDefaultQuotingParams(ctx context.Context, in *MsgUpdat return out, nil } +func (c *msgClient) UpdateOperatorParams(ctx context.Context, in *MsgUpdateOperatorParams, opts ...grpc.CallOption) (*MsgUpdateOperatorParamsResponse, error) { + out := new(MsgUpdateOperatorParamsResponse) + err := c.cc.Invoke(ctx, "/dydxprotocol.vault.Msg/UpdateOperatorParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) SetVaultParams(ctx context.Context, in *MsgSetVaultParams, opts ...grpc.CallOption) (*MsgSetVaultParamsResponse, error) { out := new(MsgSetVaultParamsResponse) err := c.cc.Invoke(ctx, "/dydxprotocol.vault.Msg/SetVaultParams", in, out, opts...) @@ -614,6 +721,8 @@ type MsgServer interface { DepositToMegavault(context.Context, *MsgDepositToMegavault) (*MsgDepositToMegavaultResponse, error) // UpdateDefaultQuotingParams updates the default quoting params in state. UpdateDefaultQuotingParams(context.Context, *MsgUpdateDefaultQuotingParams) (*MsgUpdateDefaultQuotingParamsResponse, error) + // UpdateOperatorParams sets the parameters regarding megavault operator. + UpdateOperatorParams(context.Context, *MsgUpdateOperatorParams) (*MsgUpdateOperatorParamsResponse, error) // SetVaultParams sets the parameters of a specific vault. SetVaultParams(context.Context, *MsgSetVaultParams) (*MsgSetVaultParamsResponse, error) // UnlockShares unlocks an owner's shares that are due to unlock by the block @@ -631,6 +740,9 @@ func (*UnimplementedMsgServer) DepositToMegavault(ctx context.Context, req *MsgD func (*UnimplementedMsgServer) UpdateDefaultQuotingParams(ctx context.Context, req *MsgUpdateDefaultQuotingParams) (*MsgUpdateDefaultQuotingParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateDefaultQuotingParams not implemented") } +func (*UnimplementedMsgServer) UpdateOperatorParams(ctx context.Context, req *MsgUpdateOperatorParams) (*MsgUpdateOperatorParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateOperatorParams not implemented") +} func (*UnimplementedMsgServer) SetVaultParams(ctx context.Context, req *MsgSetVaultParams) (*MsgSetVaultParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetVaultParams not implemented") } @@ -678,6 +790,24 @@ func _Msg_UpdateDefaultQuotingParams_Handler(srv interface{}, ctx context.Contex return interceptor(ctx, in, info, handler) } +func _Msg_UpdateOperatorParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateOperatorParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateOperatorParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/dydxprotocol.vault.Msg/UpdateOperatorParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateOperatorParams(ctx, req.(*MsgUpdateOperatorParams)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_SetVaultParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSetVaultParams) if err := dec(in); err != nil { @@ -726,6 +856,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateDefaultQuotingParams", Handler: _Msg_UpdateDefaultQuotingParams_Handler, }, + { + MethodName: "UpdateOperatorParams", + Handler: _Msg_UpdateOperatorParams_Handler, + }, { MethodName: "SetVaultParams", Handler: _Msg_SetVaultParams_Handler, @@ -1063,6 +1197,69 @@ func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateOperatorParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateOperatorParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateOperatorParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateOperatorParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateOperatorParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateOperatorParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1193,6 +1390,30 @@ func (m *MsgUpdateParams) Size() (n int) { return n } +func (m *MsgUpdateOperatorParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateOperatorParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2076,6 +2297,171 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateOperatorParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateOperatorParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateOperatorParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateOperatorParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateOperatorParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateOperatorParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 288227185f54755214ec68fbdd0c362721988240 Mon Sep 17 00:00:00 2001 From: Chenyao Yu <4844716+chenyaoy@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:48:15 -0400 Subject: [PATCH 12/12] [TRA-599] Set market pair for telemetry in Slinky Daemon (#2239) --- protocol/daemons/slinky/client/market_pair_fetcher.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocol/daemons/slinky/client/market_pair_fetcher.go b/protocol/daemons/slinky/client/market_pair_fetcher.go index e618231ee0..bfcc42e311 100644 --- a/protocol/daemons/slinky/client/market_pair_fetcher.go +++ b/protocol/daemons/slinky/client/market_pair_fetcher.go @@ -9,6 +9,7 @@ import ( "google.golang.org/grpc" appflags "github.com/dydxprotocol/v4-chain/protocol/app/flags" + pricefeedmetrics "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/metrics" daemonlib "github.com/dydxprotocol/v4-chain/protocol/daemons/shared" daemontypes "github.com/dydxprotocol/v4-chain/protocol/daemons/types" "github.com/dydxprotocol/v4-chain/protocol/lib/slinky" @@ -101,6 +102,7 @@ func (m *MarketPairFetcherImpl) FetchIdMappings(ctx context.Context) error { } m.Logger.Debug("Mapped market to pair", "market id", mp.Id, "currency pair", cp.String()) compatMappings[cp] = mp.Id + pricefeedmetrics.SetMarketPairForTelemetry(mp.Id, mp.Pair) } m.compatMu.Lock() defer m.compatMu.Unlock()