-
Notifications
You must be signed in to change notification settings - Fork 15
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
Refactor StarknetProvider
and StarknetRequest
#217
Conversation
@@ -16,7 +16,7 @@ public class StarknetAccount: StarknetAccountProtocol { | |||
public let chainId: StarknetChainId | |||
|
|||
private let signer: StarknetSignerProtocol | |||
private let provider: StarknetProviderProtocol | |||
public let provider: StarknetProviderProtocol |
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.
note: provider
needs to be changed to public, because it's added in StarknetAccountProtocol
here.
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.
Hmmm, I understand that it's used in the extensions, but I wonder if provider
should be included in the account protocol, as it's making the protocol reliant on component that is more implementation-specific (rpc communication), therefore making the account protocol less abstract
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.
as it's making the protocol reliant on component that is more implementation-specific (rpc communication), therefore making the account protocol less abstract
I agree 👍 Just one remark - not adding provider
in StarknetAccountProtocol
enforces to add extra provider
param in estimateFeeV1
and estimateFeeV3
. Hope this one is not too cumbersome while using these methods.
Wdyt guys @DelevoXDG @mluisbrown?
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 would only need to pass in the provider
in the estimate
methods that don't take nonce
param, right? That seems ok to me.
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 would keep the provider
property in StarknetAccount
though, right? It doesn't need to be in the protocol
but it needs to be a public property in StarknetAccount
.
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.
Ofc, we will keep it in StarknetAccount
. I added provider
param to estimateFeeV1/3
which don't have nonce
param 👍 .
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.
Can't we just make the methods abstract and define them in StarknetAccount
instead?
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.
note: Deleting as it's not used anymore.
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.
note: As discussed with Argent team - now we want RPC calls to be static methods.
Sources/Starknet/Providers/StarknetProvider/StarknetProvider.swift
Outdated
Show resolved
Hide resolved
Sources/Starknet/Providers/StarknetProvider/JsonRpcParams.swift
Outdated
Show resolved
Hide resolved
Sources/Starknet/Providers/StarknetProvider/JsonRpcMethod.swift
Outdated
Show resolved
Hide resolved
@DelevoXDG please also take a look |
Sources/Starknet/Providers/StarknetProvider/JsonRpcMethod.swift
Outdated
Show resolved
Hide resolved
Sources/Starknet/Providers/StarknetProvider/StarknetProvider.swift
Outdated
Show resolved
Hide resolved
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.
Please see my comment about having the static request methods in an extension of the generic StarknetRequest
type, which makes using them more cumbersome than necessary.
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.
All looks great now. Integrated into Argent and also ran our tests against it and all good.
Nice job 👍
Describe your changes
This PR focuses on refactoring
StarknetProvider
,StarknetRequest
and related structs/protocols for sending RPC calls.Introduced changes:
StarknetProvider
toStarknetRequest
which is now just a container for a RPC call.send
method fromStarknetRequest
.send
method toStarknetProvider
responsible for sending single/multiple RPC calls.Linked issues
Closes #215
Breaking changes
StarknetProvider
toStarknetRequest
.send
method fromStarknetRequest
- use addedsend
inStarknetProvider
to send RPC callsprovider
param inestimateFeeV1
andestimateFeeV3
inStarknetAccountProtocol
; Update following methods inStarknetAccount