starknet-io / starknet.js

JavaScript library for StarkNet
https://www.starknetjs.com
MIT License
1.21k stars 706 forks source link

Problems to use RPCSPEC06 and RPCSPEC07 namespaces #1137

Closed PhilippeR26 closed 1 week ago

PhilippeR26 commented 1 month ago

Describe the bug 2 problems encountered :

1. No Vscode help in RPC spacename

Reading the Starknet.js code, I understand that the paths to use the enums located in src/types/api/rpcspec_0_6/nonspec.ts or in spec 07 are :

import {  types,  RPC } from "starknet";
const lastBlockTag=types.RPC.RPCSPEC06.EBlockTag.LATEST;
const lastBlockTag2=RPC.RPCSPEC06.EBlockTag.LATEST;
const lastBlockTag3=types.RPC.RPCSPEC07.EBlockTag.LATEST;
const lastBlockTag4=RPC.RPCSPEC07.EBlockTag.LATEST;
const lastBlockTag5=types.RPC.EBlockTag.LATEST;
const lastBlockTag6=RPC.EBlockTag.LATEST;

Long and complicated path.... but it works. After typing types., vsCode is helping to reach RPC : image But after selecting RPC, there is no more help from vsCode : image There it becomes complicated. Only digging in a very nested source code can help you.

2. use of RPC types

If you add to the previous code :

const callOpt:types.RPC.RPCSPEC06.SPEC.SIERRA_ENTRY_POINT={selector: "0x123",function_idx:2};

The compilation fails :

TSError: ⨯ Unable to compile TypeScript:
src/tmp/26.testSepolia.ts:38:25 - error TS2694: Namespace 'index$2' has no exported member 'RPC'.

38     const callOpt:types.RPC.RPCSPEC06.SPEC.SIERRA_ENTRY_POINT={selector: "0x123",function_idx:2};
                           ~~~

So, how to use these types?

To Reproduce See above

Expected behavior Good user experience to use RPC enums. Have a way to use types of RPC.

Screenshots See above.

Desktop (please complete the following information):

Additional context

[!WARNING] Currently not open to contributors.

EjembiEmmanuel commented 1 month ago

@PhilippeR26 let me hop on this

tabaktoni commented 1 month ago

@EjembiEmmanuel Feel free to jump onto this one if you can figure it out.

'index$2' do contain RPC on final build so I am not sure what is the issue here. The only workaround until we figure it out is to use starknet-types directly

import { SPEC } from 'starknet-types';

async function main() {

  const a: SPEC.SIERRA_ENTRY_POINT = { selector: '0x123', function_idx: 2 };
github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 6.10.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 5 days ago

:tada: This issue has been resolved in version 7.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: