-
Notifications
You must be signed in to change notification settings - Fork 756
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
feat: isClassDeclared createBulkInvocations, fix cairo0 test #1211
Conversation
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.
Two minor nitpicks, in general lgtm
src/provider/rpc.ts
Outdated
* 2. Order declarations first | ||
* @param invocations | ||
*/ | ||
public async createBulkInvocations(invocations: Invocations) { |
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 would suggest renaming the method, I feel like users might make a mistake and think it's similar to accountInvocationsFactory()
. Admittedly I haven't come up with a surefire alternative, maybe something like sanitizeInvocations()
.
src/provider/rpc.ts
Outdated
const result = await this.getClass(classHash, blockIdentifier); | ||
return result instanceof Object; | ||
} catch (error) { | ||
return false; |
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.
Could be filtered for instances of LibraryError
and re-throw otherwise.
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.
Just little naming concerns.
/** | ||
* DeclareContractPayload with classHash or contract defined | ||
*/ | ||
export type ContractClassIdentifier = DeclareContractPayload | { classHash: string }; |
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.
Why an object containing the classHash? Seems complicated.
I think that the easiest way for the user is something like this :
export type ContractClassIdentifier = DeclareContractPayload | BigNumberish;
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.
Because it would be ambiguous.
Class can be identified by classHash or by contract, in case of BigNumberish it can be both and non-specific.
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.
For me, a class is only identified by its hash, and nothing else.
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.
And if you have the address of an instance of a class, you have already the answer of the
question is classDeclared
.
It's more than weird to ask if a parent is existing if you have already one of its children....
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.
And if you have the address of an instance of a class, you have already the answer of the question
is classDeclared
. It's more than weird to ask if a parent is existing if you have already one of its children....
Agree, and this does not contain an address. What address are you referring to?
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.
It does not deal with Contract instance nor addresses, just with Contract Class aka. definition classHash
ContractClassIdentifier is
{
contract: CompiledContract | string;
classHash?: string;
casm?: CompiledSierraCasm;
compiledClassHash?: string;
};
In this case it covers cases for:
- identifying class from its source code by computing classHash from contract
- optional zero computing and classHash is already provided
- less computing by providing optional params for classHash
or
{ classHash: string }
This case cover providing non-optional classHash
So that in the end, you can get classHash which is in essence ContractClassIdentifier.
Changing it to
export type ContractClassIdentifier = DeclareContractPayload | BigNumberish;
In this case, BigNumberish represents classHash but in the source, we used mixed cases sometimes string sometimes BigNumberish.
Solutions:
1.
Another case is that we set | { classHash: BigNumberish }
.
This case is less ambiguous and I think we can do it.
2. create type ClassHashIdentifier: BigNumberish
and than do:
export type ContractClassIdentifier = DeclareContractPayload | ClassHashIdentifier;
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.
For me, a class is only identified by its hash, and nothing else.
Yes but you can provide that classHash or you can provide source code and we can compute classHash from it.
So both source code and classHash are identifiers
src/provider/rpc.ts
Outdated
* 2. Order declarations first | ||
* @param invocations | ||
*/ | ||
public async createBulkInvocations(invocations: Invocations) { |
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 agree with @penovicp ; all these public functions with bulk
in their names are not understood by the users.
Such names are OK for internal functions, but are problematic for basic users usage.
We have already this problem with getEstimateFeeBulk
& parseFeeEstimateBulkResponse
.
My proposal : buildInvocations
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.
prepareBulkInvocations ?
prepareInvocations ?
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.
OK for me.
# [6.14.0](v6.13.1...v6.14.0) (2024-09-04) ### Features * isClassDeclared prepareInvocations, fix cairo0 test ([#1211](#1211)) ([9fdf54f](9fdf54f))
🎉 This issue has been resolved in version 6.14.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Motivation and Resolution
Fix #1209
Usage related changes
New
Test if class is already declared from
ContractClassIdentifier
Build bulk invocations with auto-detect declared class and declare order sort
provider.createBulkInvocations(invocations: Invocations)Checklist: