@kyve/contract-lib
Advanced tools
Comparing version 0.1.0-alpha.8 to 0.1.0-alpha.9
@@ -1,28 +0,1 @@ | ||
import { StateInterface } from "@kyve/contract/dist/faces"; | ||
import Arweave from "arweave"; | ||
import { JWKInterface } from "arweave/web/lib/wallet"; | ||
export { Pool } from "./pool"; | ||
declare type Keyfile = JWKInterface | "use_wallet" | undefined; | ||
declare class Contract { | ||
arweave: Arweave; | ||
keyfile: Keyfile; | ||
ID: string; | ||
constructor(arweave: Arweave, keyfile?: Keyfile); | ||
getState: () => Promise<StateInterface>; | ||
write: (input: any) => Promise<string>; | ||
register: (poolID: number) => Promise<string>; | ||
unregister: (poolID: number) => Promise<string>; | ||
lock: (poolID: number, qty: number) => Promise<string>; | ||
lockGlobal: (qty: number) => Promise<string>; | ||
unlock: (poolID: number) => Promise<string>; | ||
deny: (poolID: number) => Promise<string>; | ||
createPool: (poolName: string, architecture: string, config: Object) => Promise<string>; | ||
fundPool: (poolID: number, quantity: number) => Promise<string>; | ||
updatePool: (poolID: number, pool: any) => Promise<string>; | ||
vote: (voteID: number, cast: "yay" | "nay") => Promise<string>; | ||
finalize: (voteID: number) => Promise<string>; | ||
transfer: (target: string, quantity: number) => Promise<string>; | ||
dispense: () => Promise<string>; | ||
payout: (poolID: number) => Promise<string>; | ||
} | ||
export default Contract; |
@@ -9,275 +9,5 @@ "use strict"; | ||
})); | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
exports.__esModule = true; | ||
exports.Pool = void 0; | ||
var smartweave_1 = require("smartweave"); | ||
var pool_1 = require("./pool"); | ||
__createBinding(exports, pool_1, "Pool"); | ||
var Contract = /** @class */ (function () { | ||
function Contract(arweave, keyfile) { | ||
var _this = this; | ||
// Todo import from @kyve/contract | ||
this.ID = "-NpR1D0UzGTNuLzG4XN4ZfKKnVOceHMpiDvtHBJ3MXo"; | ||
this.getState = function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, smartweave_1.readContract(this.arweave, this.ID)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.write = function (input) { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, smartweave_1.interactWrite(this.arweave, this.keyfile, this.ID, input)]; | ||
case 1: | ||
//@ts-ignore | ||
return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.register = function (poolID) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "register", | ||
id: poolID | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.unregister = function (poolID) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "unregister", | ||
id: poolID | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.lock = function (poolID, qty) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "lock", | ||
id: poolID, | ||
qty: qty | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.lockGlobal = function (qty) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "lock", | ||
qty: qty | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.unlock = function (poolID) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "unlock", | ||
id: poolID | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.deny = function (poolID) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "deny", | ||
id: poolID | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.createPool = function (poolName, architecture, config) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "createPool", | ||
name: poolName, | ||
architecture: architecture, | ||
config: config | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.fundPool = function (poolID, quantity) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "fund", | ||
id: poolID, | ||
qty: quantity | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
// todo add pool type | ||
this.updatePool = function (poolID, pool) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "propose", | ||
type: "updatePool", | ||
id: poolID, | ||
pool: pool | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.vote = function (voteID, cast) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "vote", | ||
id: voteID, | ||
cast: cast | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.finalize = function (voteID) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "finalize", | ||
id: voteID | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.transfer = function (target, quantity) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "transfer", | ||
target: target, | ||
qty: quantity | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.dispense = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "dispense" | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.payout = function (poolID) { return __awaiter(_this, void 0, void 0, function () { | ||
var input; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
input = { | ||
"function": "payout", | ||
id: poolID | ||
}; | ||
return [4 /*yield*/, this.write(input)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); }; | ||
this.arweave = arweave; | ||
this.keyfile = keyfile; | ||
} | ||
return Contract; | ||
}()); | ||
exports["default"] = Contract; |
@@ -54,5 +54,5 @@ "use strict"; | ||
function Pool(arweave, wallet, id) { | ||
this.src = "-GRxcV2BZT14lnUmoPyRE24KLU-ugN5afVUa-HUhgas"; | ||
this.governance = "cpXtKvM0e6cqAgjv-BCfanWQmYGupECt1MxRk1N9Mjk"; | ||
this.treasury = "shwdmXTFCaMq8WaCGg79oCF5GCj0bpb5tNA62cluEQY"; | ||
this.src = "MjrjR6qCFcld0VO83tt3NcpZs2FIuLscvo7ya64afbY"; | ||
this.governance = "C_1uo08qRuQAeDi9Y1I8fkaWYUC9IWkOrKDNe9EphJo"; | ||
this.treasury = "RCH2pVk8m-IAuwg36mwxUt8Em_CnpWjSLpiAcCvZJMA"; | ||
this.client = arweave; | ||
@@ -59,0 +59,0 @@ this.wallet = wallet; |
{ | ||
"name": "@kyve/contract-lib", | ||
"version": "0.1.0-alpha.8", | ||
"version": "0.1.0-alpha.9", | ||
"main": "dist/index", | ||
@@ -19,7 +19,7 @@ "types": "dist/index", | ||
"dependencies": { | ||
"@kyve/contract": "0.1.0-alpha.4", | ||
"@kyve/contract-pool": "1.0.0-alpha.1", | ||
"arweave": "^1.10.13", | ||
"smartweave": "KYVENetwork/SmartWeave#release" | ||
}, | ||
"gitHead": "f08917fa4d4489dae0082cb16ba8d519b604d665" | ||
"gitHead": "664898ef6aa5003996af02c00cea38d57359e53a" | ||
} |
10453
226
+ Added@kyve/contract-pool@1.0.0-alpha.1(transitive)
+ Addedarweave-bundles@1.0.3(transitive)
+ Addedprando@6.0.1(transitive)
- Removed@kyve/contract@0.1.0-alpha.4
- Removed@kyve/contract@0.1.0-alpha.4(transitive)