Skip to content

Commit 52104e3

Browse files
authored
Revert "feat: Add Authenticator flow for Permissioned Keys (#317)"
This reverts commit bdbab8c.
1 parent b64a37b commit 52104e3

File tree

13 files changed

+38
-372
lines changed

13 files changed

+38
-372
lines changed

v4-client-js/examples/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export const DYDX_LOCAL_ADDRESS = 'dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4';
1515
export const DYDX_LOCAL_MNEMONIC =
1616
'merge panther lobster crazy road hollow amused security before critic about cliff exhibit cause coyote talent happy where lion river tobacco option coconut small';
1717

18-
export const DYDX_TEST_MNEMONIC_2 = 'movie yard still copper exile wear brisk chest ride dizzy novel future menu finish radar lunar claim hub middle force turtle mouse frequent embark';
19-
2018
export const MARKET_BTC_USD: string = 'BTC-USD';
2119
export const PERPETUAL_PAIR_BTC_USD: number = 0;
2220

v4-client-js/examples/permissioned_keys_example.ts

Lines changed: 0 additions & 110 deletions
This file was deleted.

v4-client-js/package-lock.json

Lines changed: 13 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v4-client-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"@cosmjs/stargate": "^0.32.1",
3939
"@cosmjs/tendermint-rpc": "^0.32.1",
4040
"@cosmjs/utils": "^0.32.1",
41-
"@dydxprotocol/v4-proto": "8.0.0",
4241
"@osmonauts/lcd": "^0.6.0",
42+
"@dydxprotocol/v4-proto": "7.0.0-dev.0",
4343
"@scure/bip32": "^1.1.5",
4444
"@scure/bip39": "^1.1.1",
4545
"axios": "1.1.3",

v4-client-js/src/clients/composite-client.ts

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
BroadcastTxAsyncResponse,
66
BroadcastTxSyncResponse,
77
} from '@cosmjs/tendermint-rpc/build/tendermint37';
8-
import { GetAuthenticatorsResponse } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/accountplus/query';
98
import {
109
Order_ConditionType,
1110
Order_TimeInForce,
@@ -18,7 +17,6 @@ import { bigIntToBytes } from '../lib/helpers';
1817
import { isStatefulOrder, verifyOrderFlags } from '../lib/validation';
1918
import { GovAddNewMarketParams, OrderFlags } from '../types';
2019
import {
21-
AuthenticatorType,
2220
Network,
2321
OrderExecution,
2422
OrderSide,
@@ -68,11 +66,6 @@ export interface OrderBatchWithMarketId {
6866
clientIds: number[];
6967
}
7068

71-
export interface PermissionedKeysAccountAuth {
72-
authenticators: Long[];
73-
accountForOrder: SubaccountInfo;
74-
}
75-
7669
export class CompositeClient {
7770
public readonly network: Network;
7871
public gasDenom: SelectedGasDenom = SelectedGasDenom.USDC;
@@ -158,7 +151,6 @@ export class CompositeClient {
158151
memo?: string,
159152
broadcastMode?: BroadcastMode,
160153
account?: () => Promise<Account>,
161-
authenticators?: Long[],
162154
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
163155
return this.validatorClient.post.send(
164156
wallet,
@@ -168,8 +160,6 @@ export class CompositeClient {
168160
memo,
169161
broadcastMode,
170162
account,
171-
undefined,
172-
authenticators,
173163
);
174164
}
175165

@@ -307,15 +297,10 @@ export class CompositeClient {
307297
timeInForce: Order_TimeInForce,
308298
reduceOnly: boolean,
309299
memo?: string,
310-
permissionedKeysAccountAuth?: PermissionedKeysAccountAuth,
311300
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
312-
// For permissioned orders, use the permissioning account details instead of the subaccount
313-
// This allows placing orders on behalf of another account when using permissioned keys
314-
const accountForOrder = permissionedKeysAccountAuth ? permissionedKeysAccountAuth.accountForOrder : subaccount;
315301
const msgs: Promise<EncodeObject[]> = new Promise((resolve, reject) => {
316-
317302
const msg = this.placeShortTermOrderMessage(
318-
accountForOrder,
303+
subaccount,
319304
marketId,
320305
side,
321306
price,
@@ -326,16 +311,14 @@ export class CompositeClient {
326311
reduceOnly,
327312
);
328313
msg
329-
.then((it) => {
330-
resolve([it]);
331-
})
314+
.then((it) => resolve([it]))
332315
.catch((err) => {
333316
console.log(err);
334317
reject(err);
335318
});
336319
});
337320
const account: Promise<Account> = this.validatorClient.post.account(
338-
accountForOrder.address,
321+
subaccount.address,
339322
undefined,
340323
);
341324
return this.send(
@@ -346,7 +329,6 @@ export class CompositeClient {
346329
memo,
347330
undefined,
348331
() => account,
349-
permissionedKeysAccountAuth?.authenticators,
350332
);
351333
}
352334

@@ -1235,23 +1217,4 @@ export class CompositeClient {
12351217
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
12361218
return this.validatorClient.post.createMarketPermissionless(ticker, subaccount, broadcastMode, gasAdjustment, memo);
12371219
}
1238-
1239-
async addAuthenticator(
1240-
subaccount: SubaccountInfo,
1241-
authenticatorType: AuthenticatorType,
1242-
data: Uint8Array,
1243-
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
1244-
return this.validatorClient.post.addAuthenticator(subaccount, authenticatorType, data)
1245-
}
1246-
1247-
async removeAuthenticator(
1248-
subaccount: SubaccountInfo,
1249-
id: Long,
1250-
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
1251-
return this.validatorClient.post.removeAuthenticator(subaccount, id)
1252-
}
1253-
1254-
async getAuthenticators(address: string): Promise<GetAuthenticatorsResponse>{
1255-
return this.validatorClient.get.getAuthenticators(address);
1256-
}
12571220
}

v4-client-js/src/clients/constants.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ export const TYPE_URL_MSG_UNDELEGATE = '/cosmos.staking.v1beta1.MsgUndelegate';
116116
export const TYPE_URL_MSG_WITHDRAW_DELEGATOR_REWARD =
117117
'/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward';
118118

119-
// x/accountplus
120-
export const TYPE_URL_MSG_ADD_AUTHENTICATOR = '/dydxprotocol.accountplus.MsgAddAuthenticator'
121-
export const TYPE_URL_MSG_REMOVE_AUTHENTICATOR = '/dydxprotocol.accountplus.MsgRemoveAuthenticator'
122-
123119
// ------------ Chain Constants ------------
124120
// The following are same across different networks / deployments.
125121
export const GOV_MODULE_ADDRESS = 'dydx10d07y265gmmuvt4z0w9aw880jnsr700jnmapky';
@@ -200,17 +196,6 @@ export enum PnlTickInterval {
200196
day = 'day',
201197
}
202198

203-
// ----------- Authenticators -------------
204-
205-
export enum AuthenticatorType {
206-
ALL_OF = 'AllOf',
207-
ANY_OF = 'AnyOf',
208-
SIGNATURE_VERIFICATION = 'SignatureVerification',
209-
MESSAGE_FILTER = 'MessageFilter',
210-
CLOB_PAIR_ID_FILTER = 'ClobPairIdFilter',
211-
SUBACCOUNT_FILTER = 'SubaccountFilter',
212-
}
213-
214199
export enum TradingRewardAggregationPeriod {
215200
DAILY = 'DAILY',
216201
WEEKLY = 'WEEKLY',
@@ -300,7 +285,7 @@ export class Network {
300285
const indexerConfig = new IndexerConfig(IndexerApiHost.STAGING, IndexerWSHost.STAGING);
301286
const validatorConfig = new ValidatorConfig(
302287
ValidatorApiHost.STAGING,
303-
STAGING_CHAIN_ID,
288+
TESTNET_CHAIN_ID,
304289
{
305290
CHAINTOKEN_DENOM: 'adv4tnt',
306291
USDC_DENOM: 'ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5',

v4-client-js/src/clients/lib/registry.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { GeneratedType, Registry } from '@cosmjs/proto-signing';
22
import { defaultRegistryTypes } from '@cosmjs/stargate';
3-
import { MsgAddAuthenticator, MsgRemoveAuthenticator } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/accountplus/tx';
43
import { MsgRegisterAffiliate } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/affiliates/tx';
54
import {
65
MsgPlaceOrder,
@@ -39,8 +38,6 @@ import {
3938
TYPE_URL_MSG_WITHDRAW_FROM_MEGAVAULT,
4039
TYPE_URL_MSG_REGISTER_AFFILIATE,
4140
TYPE_URL_MSG_CREATE_MARKET_PERMISSIONLESS,
42-
TYPE_URL_MSG_ADD_AUTHENTICATOR,
43-
TYPE_URL_MSG_REMOVE_AUTHENTICATOR,
4441
} from '../constants';
4542

4643
export const registry: ReadonlyArray<[string, GeneratedType]> = [];
@@ -77,11 +74,6 @@ export function generateRegistry(): Registry {
7774
// affiliates
7875
[TYPE_URL_MSG_REGISTER_AFFILIATE, MsgRegisterAffiliate as GeneratedType],
7976

80-
81-
// authentication
82-
[TYPE_URL_MSG_ADD_AUTHENTICATOR, MsgAddAuthenticator as GeneratedType],
83-
[TYPE_URL_MSG_REMOVE_AUTHENTICATOR, MsgRemoveAuthenticator as GeneratedType],
84-
8577
// default types
8678
...defaultRegistryTypes,
8779
]);

0 commit comments

Comments
 (0)