starknet.js icon indicating copy to clipboard operation
starknet.js copied to clipboard

Problems to use RPCSPEC06 and RPCSPEC07 namespaces

Open PhilippeR26 opened this issue 1 year ago • 4 comments

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):

  • Browser & version [e.g. chrome, safari, webworker] : any
  • Node version [e.g. 16.0.1] ts-node": "^10.9.2
  • Starknet.js version : v6.9.0
  • Network [devnet, testnet] : any

Additional context

[!WARNING] Currently not open to contributors.

PhilippeR26 avatar May 28 '24 11:05 PhilippeR26

@PhilippeR26 let me hop on this

EjembiEmmanuel avatar May 28 '24 12:05 EjembiEmmanuel

@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 };

tabaktoni avatar May 30 '24 14:05 tabaktoni

: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] avatar Jun 28 '24 13:06 github-actions[bot]

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

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jul 03 '24 10:07 github-actions[bot]