thetatoken / theta-protocol-ledger

Reference implementation of the Theta Blockchain Ledger Protocol
https://docs.thetatoken.org/
GNU General Public License v3.0
364 stars 85 forks source link

Unable to use Wallet in thetajs #180

Open the-xperimentalist opened 2 years ago

the-xperimentalist commented 2 years ago

Hello, posting here since couldn't find theta js repository. I am following the Get Started tutorials of theta js. And am unable to import all the objects, as required. The following is the initial code:

import './style.css'
import * as THETA from "@thetalabs/theta-js";

console.log(THETA)

const provider = new THETA.providers.HttpProvider()

const privateKey = "0x0000000000000000000000000000000000000000000000000000000000000000"
const wallet = new THETA.Wallet(privateKey)

console.log(wallet)

Here, I am getting the following error in the line where the wallet is created:

Uncaught TypeError: can't access property "fromRed", this.x is null
    getX thetajs.umd.js:37573
    _encode thetajs.umd.js:37078
    encode thetajs.umd.js:37087
    getPublic thetajs.umd.js:38496
    SigningKey thetajs.umd.js:39004
    Wallet thetajs.umd.js:56009
    <anonymous> script.js:9
    <anonymous> bundle.bc5303e438ec3245.js:70102
    <anonymous> bundle.bc5303e438ec3245.js:70104
thetajs.umd.js:37573
    getX thetajs.umd.js:37573
    _encode thetajs.umd.js:37078
    encode thetajs.umd.js:37087
    getPublic thetajs.umd.js:38496
    SigningKey thetajs.umd.js:39004
    Wallet thetajs.umd.js:56009
    <anonymous> script.js:9
    <anonymous> bundle.bc5303e438ec3245.js:70102
    <anonymous> bundle.bc5303e438ec3245.js:70104

My package json dependencies are:

    "dependencies": {
        "@babel/core": "^7.15.8",
        "@babel/preset-env": "^7.15.8",
        "@thetalabs/theta-js": "^0.0.67",
        "babel-loader": "^8.2.3",
        "clean-webpack-plugin": "^4.0.0",
        "copy-webpack-plugin": "^9.0.1",
        "css-loader": "^6.5.0",
        "file-loader": "^6.2.0",
        "html-loader": "^3.0.0",
        "html-webpack-plugin": "^5.5.0",
        "mini-css-extract-plugin": "^2.4.3",
        "portfinder-sync": "0.0.2",
        "raw-loader": "^4.0.2",
        "style-loader": "^3.3.1",
        "webpack": "^5.60.0",
        "webpack-cli": "^4.9.1",
        "webpack-dev-server": "^4.4.0",
        "webpack-merge": "^5.8.0"
    }

I am using webpack for working on the page right now. Don't think that should cause an issue. Please let me know