paritytech / capi

[WIP] A framework for crafting interactions with Substrate chains
https://docs.capi.dev
Apache License 2.0
104 stars 9 forks source link

`capi serve --target dev` invalid transactions #1199

Closed kratico closed 1 year ago

kratico commented 1 year ago

capi serve --target dev switches the RPC endpoint but it doesn't switch the dev package. As a result, transactions are sent using the non-dev package metadata. For example, with the following nets.ts, transactions send to the polkadotDev endpoint use version 9420 (which is the version on wss://rpc.polkadot.io/) but the version should be 9380 (which is the dev binary version)

import { bins, net } from "capi/nets"

const bin = bins({ polkadot: ["polkadot", "v0.9.38"] })

export const polkadotDev = net.dev({
  bin: bin.polkadot,
  chain: "polkadot-dev",
})

export const polkadot = net.ws({
  url: "wss://rpc.polkadot.io/",
  targets: { dev: polkadotDev },
})

The same thing could happen if there is a miss alignment in some constants, for example the SS58Prefix.

The solution could be to validate that both networks share the same metadata (or the same constants).

ryanleecode commented 1 year ago

Is this the same as https://github.com/paritytech/capi/issues/1173 or different?

kratico commented 1 year ago

@ryanleecode yes, it's the same as #1173