Skip to content

Conversation

@livingrockrises
Copy link
Contributor

@livingrockrises livingrockrises commented Sep 24, 2024

can confirm current util wasn't working. my added fix works

make uni policy types export as well.

const parsedRef = parseReferenceValue(rule.ref);
return {
condition: rule.condition,
offset: BigInt(rule.offset) * BigInt(32), // Ensure correct offset calculation
Copy link
Contributor

@joepegler joepegler Sep 24, 2024

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

@livingrockrises livingrockrises Sep 24, 2024

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

@livingrockrises livingrockrises marked this pull request as draft October 4, 2024 09:25
@livingrockrises
Copy link
Contributor Author

I need to redo this PR with proper description. as there are new changes that updates the types and improves devx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants