-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add metadata to megavault operator params #2509
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -94,12 +94,38 @@ export interface VaultParamsSDKType { | |||||||||
/** OperatorParams stores parameters regarding megavault operator. */ | ||||||||||
|
||||||||||
export interface OperatorParams { | ||||||||||
/** Address of the operator. */ | ||||||||||
operator: string; | ||||||||||
/** Metadata of the operator. */ | ||||||||||
|
||||||||||
metadata?: OperatorMetadata; | ||||||||||
} | ||||||||||
/** OperatorParams stores parameters regarding megavault operator. */ | ||||||||||
|
||||||||||
export interface OperatorParamsSDKType { | ||||||||||
/** Address of the operator. */ | ||||||||||
operator: string; | ||||||||||
/** Metadata of the operator. */ | ||||||||||
|
||||||||||
metadata?: OperatorMetadataSDKType; | ||||||||||
} | ||||||||||
/** OperatorMetadata stores metadata regarding megavault operator. */ | ||||||||||
|
||||||||||
export interface OperatorMetadata { | ||||||||||
/** Name of the operator. */ | ||||||||||
name: string; | ||||||||||
/** Description of the operator. */ | ||||||||||
|
||||||||||
description: string; | ||||||||||
} | ||||||||||
/** OperatorMetadata stores metadata regarding megavault operator. */ | ||||||||||
|
||||||||||
export interface OperatorMetadataSDKType { | ||||||||||
/** Name of the operator. */ | ||||||||||
name: string; | ||||||||||
/** Description of the operator. */ | ||||||||||
|
||||||||||
description: string; | ||||||||||
} | ||||||||||
/** | ||||||||||
* Deprecated: Params stores `x/vault` parameters. | ||||||||||
|
@@ -342,7 +368,8 @@ export const VaultParams = { | |||||||||
|
||||||||||
function createBaseOperatorParams(): OperatorParams { | ||||||||||
return { | ||||||||||
operator: "" | ||||||||||
operator: "", | ||||||||||
metadata: undefined | ||||||||||
Comment on lines
+371
to
+372
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Initialize 'metadata' with a Default Value In the Apply this diff: function createBaseOperatorParams(): OperatorParams {
return {
operator: "",
- metadata: undefined
+ metadata: createBaseOperatorMetadata()
};
} This ensures that 📝 Committable suggestion
Suggested change
|
||||||||||
}; | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -352,6 +379,10 @@ export const OperatorParams = { | |||||||||
writer.uint32(10).string(message.operator); | ||||||||||
} | ||||||||||
|
||||||||||
if (message.metadata !== undefined) { | ||||||||||
OperatorMetadata.encode(message.metadata, writer.uint32(18).fork()).ldelim(); | ||||||||||
} | ||||||||||
|
||||||||||
return writer; | ||||||||||
}, | ||||||||||
|
||||||||||
|
@@ -368,6 +399,10 @@ export const OperatorParams = { | |||||||||
message.operator = reader.string(); | ||||||||||
break; | ||||||||||
|
||||||||||
case 2: | ||||||||||
message.metadata = OperatorMetadata.decode(reader, reader.uint32()); | ||||||||||
break; | ||||||||||
|
||||||||||
Comment on lines
+402
to
+405
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle Optional 'metadata' Field in Decoding Logic In the Consider checking if the next tag corresponds to |
||||||||||
default: | ||||||||||
reader.skipType(tag & 7); | ||||||||||
break; | ||||||||||
|
@@ -380,6 +415,62 @@ export const OperatorParams = { | |||||||||
fromPartial(object: DeepPartial<OperatorParams>): OperatorParams { | ||||||||||
const message = createBaseOperatorParams(); | ||||||||||
message.operator = object.operator ?? ""; | ||||||||||
message.metadata = object.metadata !== undefined && object.metadata !== null ? OperatorMetadata.fromPartial(object.metadata) : undefined; | ||||||||||
return message; | ||||||||||
} | ||||||||||
|
||||||||||
}; | ||||||||||
|
||||||||||
function createBaseOperatorMetadata(): OperatorMetadata { | ||||||||||
return { | ||||||||||
name: "", | ||||||||||
description: "" | ||||||||||
}; | ||||||||||
} | ||||||||||
|
||||||||||
export const OperatorMetadata = { | ||||||||||
encode(message: OperatorMetadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||||||||||
if (message.name !== "") { | ||||||||||
writer.uint32(10).string(message.name); | ||||||||||
} | ||||||||||
|
||||||||||
if (message.description !== "") { | ||||||||||
writer.uint32(18).string(message.description); | ||||||||||
} | ||||||||||
|
||||||||||
return writer; | ||||||||||
}, | ||||||||||
|
||||||||||
decode(input: _m0.Reader | Uint8Array, length?: number): OperatorMetadata { | ||||||||||
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||||||||||
let end = length === undefined ? reader.len : reader.pos + length; | ||||||||||
const message = createBaseOperatorMetadata(); | ||||||||||
|
||||||||||
while (reader.pos < end) { | ||||||||||
const tag = reader.uint32(); | ||||||||||
|
||||||||||
switch (tag >>> 3) { | ||||||||||
case 1: | ||||||||||
message.name = reader.string(); | ||||||||||
break; | ||||||||||
|
||||||||||
case 2: | ||||||||||
message.description = reader.string(); | ||||||||||
break; | ||||||||||
|
||||||||||
default: | ||||||||||
reader.skipType(tag & 7); | ||||||||||
break; | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
return message; | ||||||||||
}, | ||||||||||
|
||||||||||
fromPartial(object: DeepPartial<OperatorMetadata>): OperatorMetadata { | ||||||||||
const message = createBaseOperatorMetadata(); | ||||||||||
message.name = object.name ?? ""; | ||||||||||
message.description = object.description ?? ""; | ||||||||||
return message; | ||||||||||
} | ||||||||||
|
||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2273,6 +2273,8 @@ function edit_genesis() { | |
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' | ||
dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.metadata.name" -v 'Governance' | ||
dasel put -t string -f "$GENESIS" ".app_state.vault.operator_params.metadata.description" -v 'Governance Module Account' | ||
Comment on lines
+2276
to
+2277
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification 'metadata' field not found in 'OperatorParams' The
🔗 Analysis chainVerify the inclusion of 'metadata' fields in 'operator_params'. The code adds Run the following script to check if 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that 'metadata' is a recognized field within 'operator_params'.
# Search for the definition of 'OperatorParams' and check for 'metadata' field.
ast-grep --lang proto --pattern $'message OperatorParams {
$$$
OperatorMetadata metadata = $_;
$$$
}'
# Search for usages of 'operator_params.metadata' in the codebase.
rg --type shell --type go '\operator_params\.metadata' -A 5 -B 5
Length of output: 379 Script: #!/bin/bash
# Description: Verify that 'metadata' is a recognized field within 'OperatorParams'.
# Search for the definition of 'OperatorParams' and check for 'metadata' field in .proto files.
rg 'message OperatorParams\s*\{[^}]*OperatorMetadata\s+metadata\s+=' --type proto
# Search for usages of 'operator_params.metadata' in shell and Go files.
rg 'operator_params\.metadata' --type sh --type go -A 5 -B 5
Length of output: 1264 Script: #!/bin/bash
# Description: Verify that 'metadata' is a recognized field within 'OperatorParams'.
# Define the 'proto' file type for rg
rg --type-add 'proto:*.proto' --type proto 'message OperatorParams\s*\{[^}]*OperatorMetadata\s+metadata\s+='
# Search for usages of 'operator_params.metadata' in shell and Go files with corrected regex
rg 'operator_params\\.metadata' --type sh --type go -A 5 -B 5
Length of output: 174 |
||
# Set total shares and owner shares. | ||
if [ -z "${INPUT_TEST_ACCOUNTS[0]}" ]; then | ||
vault_owner_address='dydx199tqg4wdlnu4qjlxchpd7seg454937hjrknju4' # alice as default vault owner | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure Consistent Initialization of Optional Fields
The
metadata
field inOperatorParams
andOperatorParamsSDKType
is declared as optional. In thecreateBaseOperatorParams()
function, it is initialized toundefined
. To maintain consistency and avoid potential runtime errors when accessingmetadata
, consider initializing it with a default value.Apply this diff to initialize
metadata
with a defaultOperatorMetadata
object:This change ensures that
metadata
is always an object, simplifying usage throughout the codebase.Also applies to: 106-110