NethermindEth / rpc-request-builder

https://rpc-request-builder.voyager.online/
5 stars 16 forks source link

Implement `starknet.go` support for call endpoints #12

Open jelilat opened 7 months ago

jelilat commented 7 months ago

Implement autogenerated starknet.go code for the following RPC endpoints

Additional Context:

AryanGodara commented 7 months ago

I'd like to start with this issue, and make my way up from here :) Please assign this to me @jelilat 😁

jelilat commented 7 months ago

I'd like to start with this issue, and make my way up from here :) Please assign this to me @jelilat 😁

Done

AryanGodara commented 6 months ago

I see a common problem where,

image

this is the output (also seen in other PRs)

This is the code

 name: "starknet_call",
    params: {
      context,
      request: functionCall,
      block_id,
    },
    starknetJs: ``,
    starknetGo: `package main
    import (
      "context"
      "fmt"
      "log"
      "github.com/NethermindEth/starknet.go/rpc"
    )

    func main() {
      rpcUrl := "https://free-rpc.nethermind.io/mainnet-juno/"
      client, err := rpc.NewClient(rpcUrl)
      if err != nil {
        log.Fatal(err)
      }
      provider := rpc.NewProvider(client)
      feltVar := fp.NewElement(1)
      var one uint64 = 1
      blockId := rpc.BlockID{Number: &one, Hash: felt.NewFelt(&feltVar)}

      res, err := provider.Call(
        context.Background(),
        rpc.FunctionCall{
          Calldata:           ,
          ContractAddress:    ${contract_address},
          EntryPointSelector: ${entry_point_selector},
        },
        ${block_id},
      )
      if err != nil {
        log.Fatal(err)
      }

      fmt.Println(res)
    }`,

It looks like the UI auto renders after detecting the function, this'll need to be updated, at least for golang, where each function takes in a context.Context; and parameters aren't passed in as a simple ring 🤔 . I'm going to work to figure this out, if a different implementation will be needed for go examples.