ava-labs / avalanchejs

The Avalanche Platform JavaScript Library
Other
321 stars 164 forks source link

Export C-to-X example does not work #837

Closed lacombar closed 7 months ago

lacombar commented 7 months ago
$ yarn
$ C_CHAIN_ADDRESS=... PRIVATE_KEY=... X_CHAIN_ADDRESS=... AVAX_PUBLIC_URL=https://ava-testnet.public.blastapi.io/ npm run example

pm verb cli /usr/bin/node /bin/npm
npm info using npm@10.2.4
npm info using node@v20.11.1
npm verb title npm run example
npm verb argv "run" "example"
npm verb logfile logs-max:10 dir:/data/src/.npm/_logs/2024-03-13T03_36_44_344Z-
npm verb logfile /data/src/.npm/_logs/2024-03-13T03_36_44_344Z-debug-0.log

> @avalabs/avalanchejs@4.0.4 example
> NODE_OPTIONS='--loader ts-node/esm' ts-node examples/c-chain/export.ts

(node:2652212) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
file:///data/misc/avalanchejs/src/vms/common/rpc.ts:28
  constructor(private readonly url: string) {}
                  ^
Error: Method not found
    at JrpcProvider.callMethod (file:///data/misc/avalanchejs/src/vms/common/rpc.ts:28:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Info.getTxFee (file:///data/misc/avalanchejs/src/info/info.ts:34:22)
    at async getContextFromURI (file:///data/misc/avalanchejs/src/vms/context/context.ts:8:225)
    at async main (file:///data/misc/avalanchejs/examples/c-chain/export.ts:15:21)
npm verb exit 1
npm verb code 1
bferenc commented 7 months ago

According to their docs Blast does not support the Info API, which is internally used by the example script. Can you please give it a try using AVAX_PUBLIC_URL=https://api.avax-test.network?

lacombar commented 7 months ago

How can you use v4 API with Blast if getContextFromURI() is not supported there ?

bferenc commented 7 months ago

You can use your own, custom logic to construct the Context object which may use Blast for the X/P/C chain APIs and the aforementioned Info API for grabbing the required transaction fee details.