Skip to content
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

Smart sessions helpers #109

Open
3 tasks
kopy-kat opened this issue Dec 16, 2024 · 9 comments
Open
3 tasks

Smart sessions helpers #109

kopy-kat opened this issue Dec 16, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@kopy-kat
Copy link
Member

kopy-kat commented Dec 16, 2024

Describe the feature you would like

Add:

  • policy state getters
  • toConfigId helper
  • action policy fallback constants (address(1) and bytes4(1))

Additional context

No response

@kopy-kat kopy-kat added the enhancement New feature or request label Dec 16, 2024
@Dhruv-Mishra
Copy link
Contributor

Dhruv-Mishra commented Jan 9, 2025

What does 'policy state' refer to in this context? Does it indicate whether a policy has been enforced in a specific smart session? I'm referring to the Policy section in the ModuleSDK documentation and the ModuleSDK source code to understand policies. Are there additional resources or references I should review?

@kopy-kat
Copy link
Member Author

so the policy state refers to the configuration of the policies, which are held in state/storage. these policies are in this pr

I think the specific helpers that would be useful are

  • getPolicyData from ERC20SpendingLimitPolicy
  • getTimeFrameConfig from TimeFramePolicy
  • actionConfigs from UniActionPolicy
  • usageLimitConfigs from UsageLimitPolicy
  • valueLimitConfigs from ValueLimitPolicy

these should be in the form of getter functions like this one. in terms of structure, these should be in the usage.ts file of the relevant policy in the policies section

lmk if anything else is unclear on this

@Dhruv-Mishra
Copy link
Contributor

Dhruv-Mishra commented Jan 12, 2025

For ERC20SpendingLimitPolicy, should I write the code for the helper based on the current state of the contract as seen here or do you want me to write it based on the state of the contract as it is in the PR that you have mentioned?

@Dhruv-Mishra
Copy link
Contributor

Dhruv-Mishra commented Jan 12, 2025

Also, I noticed that the policy contracts are not deployed on Ethereum mainnet. Are they deployed on any other chain? Where can I test them?
Edit: Found the contract on Eth Sepolia, so will write tests accordingly

@kopy-kat
Copy link
Member Author

based on the prs for all of them - will deploy the remaining ones from the pr to eth sepolia tomorrow

@kopy-kat
Copy link
Member Author

here are the updated contracts on sepolia:

  • erc20 spending limit: 0xbeF80abb8cAEEf28A9B252DcEb7DC508647128f9
  • uni action policy: 0x081C52B15BE96D6A1C729B0a34c8B4bef3da9238

@Dhruv-Mishra
Copy link
Contributor

based on the prs for all of them - will deploy the remaining ones from the pr to eth sepolia tomorrow

Alright, will proceed with that

This was referenced Jan 16, 2025
@Dhruv-Mishra
Copy link
Contributor

Dhruv-Mishra commented Jan 22, 2025

Describe the feature you would like

Add:

[ ]  policy state getters
[ ]  toConfigId helper
[ ]  action policy fallback constants (address(1) and bytes4(1))

Additional context

No response

@kopy-kat can you elaborate on the 2nd(toConfigId helper) and 3rd(action policy fallback constants) requirements here

@kopy-kat
Copy link
Member Author

3 is very easy its just constants for these flags: https://github.com/erc7579/smartsessions/blob/4f8481f91cb30f96a8ee04188415363128eda0fb/contracts/DataTypes.sol#L197-L198

for 2, the policies you integrated take in a configId for the view functions which is different to permissionId. its a bit complicated since depending on the policy type it works a bit differently, see here: https://github.com/erc7579/smartsessions/blob/4f8481f91cb30f96a8ee04188415363128eda0fb/contracts/lib/IdLib.sol#L37-L71. but I think we'd want to have a helper where you pass the permission id and policy type and then it gets you the right config id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants