Skip to content

Commit

Permalink
feat: correct encoding for new policies
Browse files Browse the repository at this point in the history
  • Loading branch information
kopy-kat committed Oct 29, 2024
1 parent 4e1aa37 commit d0ff131
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TIME_FRAME_POLICY_ADDRESS } from './constants'
import { Policy } from '../types'
import { encodeAbiParameters } from 'viem'
import { encodePacked } from 'viem'

type Params = {
validUntil: number
Expand All @@ -11,9 +11,9 @@ export const getTimeFramePolicy = (param: Params): Policy => {
return {
policy: TIME_FRAME_POLICY_ADDRESS,
address: TIME_FRAME_POLICY_ADDRESS,
initData: encodeAbiParameters(
[{ type: 'uint48' }, { type: 'uint48' }],
[param.validAfter, param.validUntil],
initData: encodePacked(
['uint128', 'uint128'],
[BigInt(param.validUntil), BigInt(param.validAfter)],
),
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { USAGE_LIMIT_POLICY_ADDRESS } from './constants'
import { Policy } from '../types'
import { encodeAbiParameters } from 'viem'
import { encodePacked } from 'viem'

type Params = {
limit: bigint
Expand All @@ -10,6 +10,6 @@ export const getUsageLimitPolicy = (params: Params): Policy => {
return {
policy: USAGE_LIMIT_POLICY_ADDRESS,
address: USAGE_LIMIT_POLICY_ADDRESS,
initData: encodeAbiParameters([{ type: 'uint128' }], [params.limit]),
initData: encodePacked(['uint128'], [params.limit]),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { Policy } from '../types'
import { encodeAbiParameters } from 'viem'

type Params = {
valueLimit: bigint,
valueLimit: bigint
limitUsed: bigint
}

export const getValueLimitPolicy = (params: Params): Policy => {
return {
policy: VALUE_LIMIT_POLICY_ADDRESS,
address: VALUE_LIMIT_POLICY_ADDRESS,
initData: encodeAbiParameters([{ type: 'uint256' }, {type: 'uint256'}], [params.valueLimit, params.limitUsed]),
initData: encodeAbiParameters([{ type: 'uint256' }], [params.valueLimit]),
}
}

0 comments on commit d0ff131

Please sign in to comment.