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

[VIP] V6 saitama #908

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open

[VIP] V6 saitama #908

wants to merge 16 commits into from

Conversation

tabaktoni
Copy link
Collaborator

Motivation and Resolution

We have this structure in the project:

Starknet | <-> 1. Channel -> 2. Provider -> 3.Account -> 4.Contract

We have this type of structure:
RPC (namespace: types.RPC and RPC) (none in top namespace)
Provider (all in top namespace) (some inherited from RPC)
Account (all in top namespace)
Contract (all in top namespace)

Every level has a specific diff from prev one. inheriting prev. structure + diff
The channel will change with every RPC Release
Provider needs to stay in the same structure until the next major release.
Account and Contract are based on Provider so it will also stay + extend in the same structure until next major.

So it is clear that stability needs to be lined on Provider as so RPC types res and response used by provider need to be re-exported on the top level as "Provider types"
and so to the top.

This is a vertical structure, on the other hand, we have a horizontal structure like in Account - Signer -Hashing
An account provides loose types so that UX can be flexible on the other hand as you go deeper into signer it transforms it into strict union discriminatory types and at the bottom Hashing works only with the strictly defined types.

As I see it, I will need to export RPC Enums to the top level as Provider Enums, and req/res types as provider types. This would be the first step.
The second step will be to check horizontal types and polish them as we can.

The second issue is that we have floating definitions of classes and some types in lib and some other files that are floating around at the moment, they were historically union between sequencer and RPC in some unstructured mess. This would need to be checked and aligned with now only SSOT that is RPC Spec in such a way that it can be extended from 2 RPC Specs as we could potentially have in the future when changes are not in addition like v5 v6 but also restructured.

RPC version (if applicable)

...

Usage related changes

  • Change 1.
  • ...

Development related changes

  • Change 1.
  • ...

Checklist:

  • Performed a self-review of the code
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Linked the issues which this PR resolves
  • Documented the changes in code (API docs will be generated automatically)
  • Updated the tests
  • All tests are passing

Copy link

netlify bot commented Dec 22, 2023

Deploy Preview for starknetjs ready!

Name Link
🔨 Latest commit 24941b3
🔍 Latest deploy log https://app.netlify.com/sites/starknetjs/deploys/6585a2edd0e5650008d367d8
😎 Deploy Preview https://deploy-preview-908--starknetjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tabaktoni tabaktoni changed the base branch from develop to beta December 22, 2023 14:53
@tabaktoni tabaktoni changed the base branch from beta to develop February 8, 2024 10:02
@tabaktoni tabaktoni changed the title [VIP] V6/beta/final [VIP] V6 saitama Feb 13, 2024
@tabaktoni tabaktoni marked this pull request as ready for review February 24, 2024 16:37
Copy link
Collaborator

@penovicp penovicp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bunch of smaller nitpicks. In general lgtm.

__tests__/accountInstance.test.ts Outdated Show resolved Hide resolved
transactionVersion:
| ETransactionVersion.V2
| ETransactionVersion.V3 = DEFAULT_TRANSACTION_VERSION,
instance?: boolean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This instance parameter and the new AccountInstance class feels like it could be confusing to users. I suggest evaluating if a different term might be a better fit, maybe something like inheritable or inheritableProvider.

Adding @ivpavici since he's had success with naming things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that the user create Acc from the instance and not class.
Is there a better name to fit I'm fine with it, I am not supper happy with this name also, but it was only one logical to me.

}
this.retries = retries || defaultOptions.retries;
this.headers = { ...defaultOptions.headers, ...headers };
this.blockIdentifier = blockIdentifier || defaultOptions.blockIdentifier;
this.chainId = chainId;
this.waitMode = waitMode || false;
this.requestId = 0;
this.speckVersion = speckVersion;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

speckVersion should be renamed to specVersion.

@@ -34,7 +34,7 @@ import type {
} from '../types';

export abstract class ProviderInterface {
public abstract channel: RpcChannel;
public abstract channel: RpcChannel | undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't seem necessary because of the @ts-expect-error in src/provider/rpc.ts on line 44.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure will ti effect external implementations

Comment on lines 43 to 45
// stop ts complains
// @ts-expect-error
this.channel = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be done with a cast.

Suggested change
// stop ts complains
// @ts-expect-error
this.channel = null;
this.channel = null as any;

src/types/index.ts Outdated Show resolved Hide resolved
@@ -155,52 +161,54 @@ export enum TransactionType {
INVOKE = 'INVOKE_FUNCTION',
}

// TODO: All this should be removed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented blocks?

@@ -70,7 +71,7 @@ export type Storage = RPC.Felt;

export type Nonce = string;

export type SimulationFlags = RPC.SimulationFlags;
// export type SimulationFlags = RPC.SimulationFlags;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Straggler?

tabaktoni and others added 2 commits March 1, 2024 16:38
Co-authored-by: Petar Penović <pp@spaceshard.io>
@tabaktoni
Copy link
Collaborator Author

TODO: Will close this one once extracted important parts.

@tabaktoni tabaktoni added the pending need update label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending need update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants