-
Notifications
You must be signed in to change notification settings - Fork 17
add toActionConfig helper #65
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
base: main
Are you sure you want to change the base?
add toActionConfig helper #65
Conversation
| const parsedRef = parseReferenceValue(rule.ref); | ||
| return { | ||
| condition: rule.condition, | ||
| offset: BigInt(rule.offset) * BigInt(32), // Ensure correct offset calculation |
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.
offset: BigInt(rule.offsetIndex) * BigInt(32). <- This makes it clearer to the user what's going on.
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.
Maybe rename the relevant field / type to offsetIndex?
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.
offsetIndex var doesn't exist in the contract and it has been removed from module-sdk also.
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.
before there was some types such as
valueLimitPerUse: bigint
paramRules: RawParamRules
}
export type RawParamRules = {
length: bigint
rules: RawParamRule[]
}
export type RawParamRule = {
condition: ParamCondition
offset: bigint
isLimited: boolean
ref: Hex
usage: LimitUsage
}```
over
```export type ActionConfig = {
valueLimitPerUse: bigint
paramRules: {
length: number
rules: Rule[]
}
}
export type Rule = {
/**
* EQUAL = 0,
* GREATER_THAN = 1,
* LESS_THAN = 2,
* GREATER_THAN_OR_EQUAL = 3,
* LESS_THAN_OR_EQUAL = 4,
* NOT_EQUAL = 5
*/
condition: ParamCondition
/**
* The offset in the calldata where the value to be checked is located.
* The offset is in multiples of 32 bytes. (Note: not the offsetIndex)
* The offsetIndex is generally the index of the arg in the method that you wish to target.
* The exception is when the arg is in an array
* In this case, the offsetIndex needs to be figured out using its position in the array
* (See the 'use-of-dynamic-types' example below for how to figure out the offsetIndex for an array)
*
* https://docs.soliditylang.org/en/develop/abi-spec.html#use-of-dynamic-types
*
* */
offsetIndex: bigint
/**
* If the rule is limited, the usage object will contain the limit and the used values.
*/
isLimited: boolean
/**
* The reference value to compare against. You can pass in the raw hex value or a human-friendly value.
* Use the raw hex value if you are sure of the value you are passing in.
*/
ref: AnyReferenceValue
/**
* The usage object will contain the limit and the used values, and is only required if the isLimited property is true.
*/
usage: LimitUsage
}```
and this util toActionConfig converted ActionConfig it into RawActionConfig
|
I need to redo this PR with proper description. as there are new changes that updates the types and improves devx |
can confirm current util wasn't working. my added fix works
make uni policy types export as well.