-
Notifications
You must be signed in to change notification settings - Fork 705
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
Implement SNIP-9 (WiP) #1111
base: next-version
Are you sure you want to change the base?
Implement SNIP-9 (WiP) #1111
Conversation
To explain my choice of hashing algorithms: In the SNIP-9 specification it's stated that SNIP-12 should be used for hashing. There are 2 revisions of |
thanks!! we will take a deep look! |
We should add documentation for OutsideExecution usage |
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.
In general lgtm.
- docs
- e2e account test
|
||
export const OutsideExecutionCallerAny = encodeShortString('ANY_CALLER'); | ||
|
||
export class OutsideExecution { |
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.
We used (because of initial setup) types dir for pure type definitions and utils for implementations.
I think this is fine but it will break existing convenience.
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.
Yeah I will leave the interface inside types
and move the class and implementation into utils
, if it's fine
|
||
expect(abiData).toEqual(expectedResult); | ||
}); | ||
}); |
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.
Is there an Acc implementing this snip so we can test it on Account?
If so I would like to have a full e2e test with ACC using it.
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.
Yep, Argent and Braavos support it at least on Sepolia, I'll write the missing test in a few days, sorry for the delay
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.
I just realized that OZ account contract doesn't support SNIP-9 yet. And both Argent and Braavos are distributed under GPL, so I can't just take their compiled contracts and put them into __mocks__
directory. I can request a feature on OZ but nobody knows how long it will take. If I compile a "dummy" account contract with minimal execute_from_outside
implementation and use it in tests, will it count as a valid test?
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.
Tagging Argent folks, @janek26 @dhruvkelawala hi! for testing purposes, does GPL license allow usage of your Account contract for testing this SNIP? @kfastov I don't think we would have problems with the GPL license, this is a non-profit library in any case :)
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.
@ivpavici all good to use our contracts. double checked it with Sergio.
@kfastov hi! Will you have time to add these couple of things left? 🙏 |
Hello! Sorry for being slow, had to make a forced break in development, but now I am here again. |
Motivation and Resolution
This PR implements the SNIP-9 (outside execution) standard in starknet.js. SNIP-9 enables protocols to submit transactions on behalf of a user account, as long as they have the relevant signatures. This feature provides flexibility for various use cases such as delayed orders and fee subsidies.
The implementation follows the SNIP-9 specification and introduces new types, utilities, and account methods to support off-chain signatures. It includes the OutsideExecution class, which represents an outside transaction to be executed on behalf of the user account. The Account class has been extended with methods to get the supported SNIP-9 version, check nonce validity, and execute an outside execution.
RPC version (if applicable)
N/A
Usage related changes
OutsideExecution
,OutsideCall
, andEOutsideExecutionVersion
.Account
class with methods to support SNIP-9:getSnip9Version
: Retrieves the supported SNIP-9 version of the account.isValidSnip9Nonce
: Checks if a given nonce is valid for the account.executeFromOutside
: Executes an outside execution on behalf of the account.Development related changes
buildExecuteFromOutsideCallData()
andgetSnip9Nonce()
.Checklist:
Things left:
Fixes #948