dharmaprotocol / dharma.js

DEPRECATED: Javascript Developer library for interacting with Dharma Protocol
https://dharma.io
MIT License
57 stars 24 forks source link

TypeError this.provider.sendAsync #334

Open wilbarnes opened 5 years ago

wilbarnes commented 5 years ago

Hello,

I was working through the tutorial https://developer.dharma.io/tutorials/create

dharma-chain running on 8545

const { Dharma, Web3 } = require("@dharmaprotocol/dharma.js");
const BigNumber = require("bignumber.js");

const host = "http://localhost:8545";
const dharma = new Dharma(host);

async function loanreq() {

    const { LoanRequest } = Dharma.Types;

    const loanRequest = await LoanRequest.create(dharma, {
        principalAmount: new BigNumber(1),
        principalToken: "WETH",
        collateralAmount: new BigNumber(20),
        collateralToken: "REP",
        interestRate: new BigNumber(3),
        termDuration: new BigNumber(3),
        termUnit: "months",
        expiresInDuration: new BigNumber(1),
        expiresInUnit: "weeks"
    });
    console.log(loanRequest);
}

loanreq()

Output

(node:8362) UnhandledPromiseRejectionWarning: TypeError: this.provider.sendAsync is not a function
    at RequestManager.sendAsync (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:88601:19)
    at Object.send (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:14677:42)
    at /xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:5610:10
    at new Promise (<anonymous>)
    at new F (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:36181:28)
    at /xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:5592:12
    at BlockchainAPI.<anonymous> (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301244:72)
    at step (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301081:23)
    at Object.next (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301062:53)
    at /xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301056:71
(node:8362) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:8362) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled wil terminate the Node.js process with a non-zero exit code.

Was simply trying to print the loanRequest

jahosh commented 5 years ago

@wilbarnes I'm experiencing this as well when using the dharma-chain - I believe it may be related to the fact that the version of web3 dharma.js is using ("web3": "~0.20.7") expects a Web3.Provider instead of a "string" as the tutorial suggests. https://github.com/ethereum/web3.js/tree/master#usage