Skip to content

Commit

Permalink
[CT-1160] add relevant protos to dydxprotocol (#2162)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayy04 authored Sep 15, 2024
1 parent 8cc37b2 commit cbd23b1
Show file tree
Hide file tree
Showing 27 changed files with 6,398 additions and 321 deletions.
Original file line number Diff line number Diff line change
@@ -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: []
};
}

Expand All @@ -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;
},

Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

};
Original file line number Diff line number Diff line change
@@ -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;
}

};
Loading

0 comments on commit cbd23b1

Please sign in to comment.