docknetwork / sdk

A JavaScript SDK built ontop of PolkadotJS for interaction with Dock's Substrate node and compatible chains
https://www.dock.io
89 stars 20 forks source link

run yarn dock-did-example, error "TypeError: this.module.newOnchain is not a function" #346

Open kangkang333 opened 1 year ago

kangkang333 commented 1 year ago

step1. docker run -p 9944:9944 -p 30333:30333 docknetwork/dock-substrate:mainnet --chain ./cspec/knox_raw.json --ws-external --enable-offchain-indexing=true

step2. run yarn dock-did-example

Creating DID resolvers... Building DIDs list... Error occurred somewhere, it was caught! TypeError: this.module.newOnchain is not a function at DIDModule.createNewOnchainTx (/Users/xxxxx/Downloads/sdk-master/src/modules/did/did.js:143:24) at DIDModule.new (/Users/xxxxx/Downloads/sdk-master/src/modules/did/did.js:167:12) at registerNewDIDUsingPair (/Users/xxxxx/Downloads/sdk-master/tests/integration/helpers.js:25:25) at createDockDID (/Users/xxxxx/Downloads/sdk-master/example/resolver.js:55:32) at main (/Users/xxxxx/Downloads/sdk-master/example/resolver.js:78:25) at processTicksAndRejections (node:internal/process/task_queues:96:5) error Command failed with exit code 1.

lovesh commented 1 year ago

Can you share your docker image id and SDK version because this.module.newOnchain is not a function suggests an old docker image?

Creating DID resolvers... Building DIDs list

The output logs suggest you're running yarn did-resolver-example and not yarn dock-did-example. Secondly using the mainnet tagged docker images to run examples and tests isn't a good idea as it will cost you real tokens.

kangkang333 commented 1 year ago

SDK version: master dock-substrate: version 0.22.0

And I run the following command :

docker run -p 9944:9944 -p 30333:30333 docknetwork/dock-substrate:mainnet --chain ./cspec/knox_raw.json --ws-external --enable-offchain-indexing=true

2023-04-10 08:07:06 Dock Node 2023-04-10 08:07:06 ✌️ version 0.22.0 2023-04-10 08:07:06 ❤️ by Dock.io, 2017-2023 2023-04-10 08:07:06 📋 Chain specification: Dock PoS Mainnet 2023-04-10 08:07:06 🏷 Node name: imported-learning-5413 2023-04-10 08:07:06 👤 Role: FULL

lovesh commented 1 year ago

Can you share the most recent block on your node? The TypeError might be because your local node doesn't have the recent blocks (last few months) and as per your local state, newOnchain is not an extrinsic as it was only introduced a few months ago.

GinMu commented 7 months ago

i also have this problem on mainnet, docker image log is:

Screenshot 2024-03-29 at 13 41 37

then i run connect command:

docker run -p 9944:9944 -p 30333:30333 docknetwork/dock-substrate:mainnet --chain ./cspec/knox_raw.json --ws-external --enable-offchain-indexing=true

then run yarn dock-did-example that throws this.module.newOnchain is not a function error. But not throw this error on testnet.