Skip to content

fix: make the provider create method generic to enable it when mixins are applied #1370

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

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

penovicp
Copy link
Collaborator

@penovicp penovicp commented Apr 3, 2025

Motivation and Resolution

Ensures that RpcProvider.create(...) generates the chosen class with the appropriate TypeScript type for both the base class and extended classes after mixins are added. Also disables it for the Account class inheritance chain.

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
Collaborator

@PhilippeR26 PhilippeR26 left a comment

Choose a reason for hiding this comment

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

Nice:
image

We should take the opportunity when solving this type problem, to also solve this known problem:
image

@penovicp
Copy link
Collaborator Author

penovicp commented Apr 8, 2025

Nice: image

We should take the opportunity when solving this type problem, to also solve this known problem: image

SupportedRpcVersion from the second image is an object literal emulation of a TypeScript enum. The error prompt shown is a side-effect of reproducing the enum behaviour.

enum

@PhilippeR26
Copy link
Collaborator

PhilippeR26 commented Apr 8, 2025

So, how a user can use SupportedRpcVersion.xxx as a constant value?
(I suppose that if it's located in constants namespace, it's to be used as constant by users...)
I would like to have something similar to ETransactionVersion.V3

@penovicp
Copy link
Collaborator Author

penovicp commented Apr 8, 2025

@PhilippeR26 After your last message I remembered that what you were actually referencing was that SupportedRpcVersion has an issue with the underlying object literal not being visible to TS in the published build. I believe I found an approach that resolves the issue, it's in the #1375 draft PR.

@tabaktoni
Copy link
Member

LPTM!

@penovicp penovicp merged commit 1f48dc6 into develop Apr 9, 2025
@penovicp penovicp deleted the fix/provider-create branch April 9, 2025 19:34
github-actions bot pushed a commit that referenced this pull request Apr 14, 2025
# [7.1.0](v7.0.1...v7.1.0) (2025-04-14)

### Bug Fixes

* ensure enum replacement objects are reachable for type resolution ([#1375](#1375)) ([eb8b10d](eb8b10d))
* make the provider create method generic to enable it when mixins are applied ([#1370](#1370)) ([1f48dc6](1f48dc6))

### Features

* update to rpc 0.8.1 ([83e17b8](83e17b8))
Copy link

🎉 This PR is included in version 7.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

PhilippeR26 added a commit to PhilippeR26/starknet.js that referenced this pull request May 5, 2025
docs: update guide

build: ledger app v2.3.0

chore: upgrade name to 2.3.1 and polish doc

docs: update guide

chore: upgrade name to 2.3.1 and polish doc

feat: prune deprecated functionalities

BREAKING CHANGE: Removed multiple functionalities that have been marked as deprecated

chore(release): 7.0.0-beta.4 [skip ci]

* repair snip-12 enum type nested dependency ([starknet-io#1289](starknet-io#1289)) ([1cd4219](starknet-io@1cd4219))

* drop fetch-cookie dependency ([9a57daf](starknet-io@9a57daf))
* drop isomorphic-fetch dependency ([9da0083](starknet-io@9da0083))
* prune deprecated functionalities ([cbd18f5](starknet-io@cbd18f5))

* Removed multiple functionalities that have been marked as deprecated

chore(release): 7.0.0 [skip ci]

* Implement RPC 0.8 and V3 transactions ([starknet-io#1328](starknet-io#1328)) ([316ae27](starknet-io@316ae27))

* contract withOptions Fix/1252 ([starknet-io#1255](starknet-io#1255)) ([b59952e](starknet-io@b59952e))
* update ws impl, add TEST_WS_URL, update token constants ([411eeec](starknet-io@411eeec))

* drop fetch-cookie dependency ([9a57daf](starknet-io@9a57daf))
* drop isomorphic-fetch dependency ([9da0083](starknet-io@9da0083))
* prune deprecated functionalities ([cbd18f5](starknet-io@cbd18f5))
* the WebSockets ([starknet-io#1251](starknet-io#1251)) ([fabca27](starknet-io@fabca27)), closes [starknet-io#1272](starknet-io#1272)
* Update Beta to latest Develop ([starknet-io#1312](starknet-io#1312)) ([2958051](starknet-io@2958051)), closes [starknet-io#949](starknet-io#949) [starknet-io#970](starknet-io#970)
* v7 fee, new methods, tests ([starknet-io#1337](starknet-io#1337)) ([00743de](starknet-io@00743de))

* Removed multiple functionalities that have been marked as deprecated
* Library defaults to RPC 0.8 with the corresponding API changes, dropped RPC 0.6 support

fix: preserve value for numeric arguments within address padding utility

chore(release): 7.0.1 [skip ci]

* preserve value for numeric arguments within address padding utility ([abc7958](starknet-io@abc7958))

docs: generate documentation version

docs: expand v7 migration guide (starknet-io#1368)

---------
Co-authored-by: Petar Penovic <[email protected]>

fix: make the provider create method generic to enable it when mixins are applied (starknet-io#1370)

fix: ensure enum replacement objects are reachable for type resolution (starknet-io#1375)

docs: update guides for v7 (starknet-io#1376)

---------
Co-authored-by: Petar Penovic <[email protected]>

feat: update to rpc 0.8.1

chore(release): 7.1.0 [skip ci]

* ensure enum replacement objects are reachable for type resolution ([starknet-io#1375](starknet-io#1375)) ([eb8b10d](starknet-io@eb8b10d))
* make the provider create method generic to enable it when mixins are applied ([starknet-io#1370](starknet-io#1370)) ([1f48dc6](starknet-io@1f48dc6))

* update to rpc 0.8.1 ([83e17b8](starknet-io@83e17b8))

style: remove comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants