v0.4.84
Some checks failed
CI / build (push) Has been cancelled

This commit is contained in:
ppe
2022-05-09 23:47:19 +02:00
parent ecf780de25
commit 9125b5a109
2 changed files with 8 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "redstone-smartweave",
"version": "0.4.83",
"version": "0.4.84",
"description": "An implementation of the SmartWeave smart contract protocol.",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",

View File

@@ -1,7 +1,7 @@
/* eslint-disable */
import Arweave from 'arweave';
import { GQLNodeInterface, GQLTagInterface } from './gqlResult';
import {EvaluationOptions} from "@smartweave/core";
import { EvaluationOptions } from '@smartweave/core';
/**
*
@@ -64,22 +64,24 @@ export class SmartWeaveGlobal {
};
this.arweave.wallets.getBalance = async (address: string): Promise<string> => {
if (!this._activeTx) {
throw new Error("Cannot read balance - active tx is not set.");
throw new Error('Cannot read balance - active tx is not set.');
}
if (!this.block.height) {
throw new Error("Cannot read balance - block height not set.")
throw new Error('Cannot read balance - block height not set.');
}
console.log(`${evaluationOptions.walletBalanceUrl}block/height/${this.block.height}/wallet/${address}/balance`);
// http://nyc-1.dev.arweave.net:1984/block/height/914387/wallet/M-mpNeJbg9h7mZ-uHaNsa5jwFFRAq0PsTkNWXJ-ojwI/balance
return await fetch(`${evaluationOptions.walletBalanceUrl}block/height/${this.block.height}/wallet/${address}/balance`)
return await fetch(
`${evaluationOptions.walletBalanceUrl}block/height/${this.block.height}/wallet/${address}/balance`
)
.then((res) => {
return res.ok ? res.text() : Promise.reject(res);
})
.catch((error) => {
throw new Error(`Unable to read wallet balance. ${error.status}. ${error.body?.message}`);
});
}
};
this.contract = contract;
this.transaction = new Transaction(this);
this.block = new Block(this);