Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script from README is not working with #21

Open
punishell opened this issue Aug 21, 2023 · 0 comments
Open

Script from README is not working with #21

punishell opened this issue Aug 21, 2023 · 0 comments

Comments

@punishell
Copy link

package.json

{
  "name": "kujira-fin-demo",
  "version": "1.0.0",
  "main": "index.js",
  "type": "module",
  "license": "MIT",
  "dependencies": {
    "@cosmjs/cosmwasm-stargate": "^0.28.9",
    "@cosmjs/proto-signing": "^0.28.9",
    "@cosmjs/stargate": "^0.28.9",
    "kujira.js": "Team-Kujira/kujira.js.git"
  }
}

index.js

import { tx, registry } from "kujira.js";

import { GasPrice, SigningStargateClient } from "@cosmjs/stargate";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";

const RPC_ENDPOINT = "https://kujira-testnet-rpc.polkachu.com";


const MNEMONIC = "REDACTED";



const signer = await DirectSecp256k1HdWallet.fromMnemonic(MNEMONIC);

const client = await SigningStargateClient.connectWithSigner(
  RPC_ENDPOINT,
  signer,
  {
    registry,
    gasPrice: GasPrice.fromString("0.00125ukuji"),
  }
);


const FIN_KUJI_DEMO =
  "kujira1suhgf5svhu4usrurvxzlgn54ksxmn8gljarjtxqnapv8kjnp4nrsqq4jjh";

const [account] = await signer.getAccounts();

const msg = tx.wasm.msgExecuteContract({
  sender: account.address,
  contract: FIN_KUJI_DEMO,
  msg: Buffer.from(JSON.stringify({ submit_order: { price: "210.5" } })),
  funds: coins(1000000, "ukuji"),
});

await client.signAndBroadcast(account.address, [msg], "auto");
import { tx, registry } from "kujira.js";
         ^^
SyntaxError: Named export 'tx' not found. The requested module 'kujira.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'kujira.js';
const { tx, registry } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant