@kyve/contract-lib
Advanced tools
Comparing version 0.1.0-alpha.15 to 0.1.0-alpha.16
@@ -16,2 +16,3 @@ import { StateInterface } from "@kyve/contract-pool/dist/faces"; | ||
getState(useCache?: boolean): Promise<StateInterface>; | ||
getUnhandledTxs(address: string, useCache?: boolean): Promise<string[]>; | ||
processOutbox(): Promise<string>; | ||
@@ -18,0 +19,0 @@ deposit(qty: number): Promise<string>; |
@@ -112,2 +112,37 @@ "use strict"; | ||
}; | ||
Pool.prototype.getUnhandledTxs = function (address, useCache) { | ||
if (useCache === void 0) { useCache = true; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var txs, response, state, unhandledTxs; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!this.id) | ||
throw new Error("No pool ID specified."); | ||
if (!useCache) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, cross_fetch_1.fetch("https://kyve.network/api/pool?id=" + this.id + "&type=unhandledTxs")]; | ||
case 1: | ||
response = _a.sent(); | ||
if (!response.ok) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
txs = _a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: throw new Error("Couldn't read unhandled txs for " + this.id + " from cache."); | ||
case 4: return [3 /*break*/, 7]; | ||
case 5: return [4 /*yield*/, smartweave_1.readContract(this.client, this.id)]; | ||
case 6: | ||
state = _a.sent(); | ||
txs = state.txs; | ||
_a.label = 7; | ||
case 7: | ||
unhandledTxs = Object.entries(txs).filter(function (_a) { | ||
var key = _a[0], value = _a[1]; | ||
return value.status === "pending" && !value.voters.includes(address); | ||
}); | ||
return [2 /*return*/, unhandledTxs.map(function (tx) { return tx[0]; })]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Pool.prototype.processOutbox = function () { | ||
@@ -114,0 +149,0 @@ return __awaiter(this, void 0, void 0, function () { |
{ | ||
"name": "@kyve/contract-lib", | ||
"version": "0.1.0-alpha.15", | ||
"version": "0.1.0-alpha.16", | ||
"main": "dist/index", | ||
@@ -19,3 +19,3 @@ "types": "dist/index", | ||
"dependencies": { | ||
"@kyve/contract-pool": "^1.0.0-alpha.1", | ||
"@kyve/contract-pool": "1.0.0-alpha.2", | ||
"arweave": "^1.10.15", | ||
@@ -25,3 +25,3 @@ "cross-fetch": "^3.1.4", | ||
}, | ||
"gitHead": "9bdea84e61561f20101df1ca38a5fc38223f405e" | ||
"gitHead": "ec20828602ad1cd3f816640f4993a29d9d3ada86" | ||
} |
21089
439
+ Added@kyve/contract-pool@1.0.0-alpha.2(transitive)
- Removed@kyve/contract-pool@1.0.0-alpha.5(transitive)