Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

beaker-ts

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beaker-ts - npm Package Compare versions

Comparing version 0.0.36 to 0.0.37

lib/application_client/index.d.ts

7

examples/hello/index.ts

@@ -1,11 +0,10 @@

import * as bkr from "../../src";
import {sandbox} from "../../src";
import {HelloBeaker} from "./hellobeaker_client";
(async function () {
const acct = (await bkr.sandbox.getAccounts()).pop();
const acct = (await sandbox.getAccounts()).pop();
if (acct === undefined) return
const appClient = new HelloBeaker({
client: bkr.sandbox.getAlgodClient(),
client: sandbox.getAlgodClient(),
signer: acct.signer,

@@ -12,0 +11,0 @@ sender: acct.addr,

import algosdk, { AtomicTransactionComposer } from 'algosdk';
import { Schema } from '../';
import { Schema } from '../generate';
import { ApplicationState, AccountState } from './state';

@@ -4,0 +4,0 @@ export declare type MethodArg = algosdk.ABIArgument | algosdk.Transaction | object | MethodArg[];

@@ -1,79 +0,6 @@

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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 };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplicationClient = exports.ABIResult = exports.decodeNamedTuple = void 0;
var algosdk_1 = __importStar(require("algosdk"));
var __1 = require("../");
var logic_error_1 = require("./logic_error");
var state_1 = require("./state");
function decodeNamedTuple(v, keys) {
import algosdk, { ABIReferenceType } from 'algosdk';
import { getStateSchema } from '../generate';
import { parseLogicError, LogicError } from './logic_error';
import { decodeState } from './state';
export function decodeNamedTuple(v, keys) {
if (v === undefined)

@@ -85,9 +12,16 @@ return {};

throw Error('Different key length than value length');
return Object.fromEntries(keys.map(function (key, idx) {
return Object.fromEntries(keys.map((key, idx) => {
return [key, v[idx]];
}));
}
exports.decodeNamedTuple = decodeNamedTuple;
var ABIResult = /** @class */ (function () {
function ABIResult(result, value) {
export class ABIResult {
txID;
rawReturnValue;
method;
txInfo;
returnValue;
decodeError;
value;
inners;
constructor(result, value) {
this.txID = result.txID;

@@ -100,14 +34,14 @@ this.rawReturnValue = result.rawReturnValue;

this.inners = [];
if ((result === null || result === void 0 ? void 0 : result.txInfo) !== undefined && 'inner-txns' in result.txInfo) {
if (result?.txInfo !== undefined && 'inner-txns' in result.txInfo) {
// TODO: this only parses 1 level deep
var outer_1 = result.txInfo['txn']['txn'];
const outer = result.txInfo['txn']['txn'];
// eslint-disable-next-line
this.inners = result.txInfo['inner-txns'].map(function (itxn) {
var et = itxn['txn']['txn'];
et.gen = outer_1.gen;
et.gh = outer_1.gh;
this.inners = result.txInfo['inner-txns'].map((itxn) => {
const et = itxn['txn']['txn'];
et.gen = outer.gen;
et.gh = outer.gh;
return {
createdAsset: itxn['asset-index'],
createdApp: itxn['application-index'],
txn: algosdk_1.default.Transaction.from_obj_for_encoding(itxn['txn']['txn']),
txn: algosdk.Transaction.from_obj_for_encoding(itxn['txn']['txn']),
};

@@ -118,11 +52,23 @@ });

}
return ABIResult;
}());
exports.ABIResult = ABIResult;
var ApplicationClient = /** @class */ (function () {
function ApplicationClient(opts) {
}
export class ApplicationClient {
client;
appId;
appAddress;
signer;
sender;
methods;
approvalProgram;
clearProgram;
approvalProgramBinary;
clearProgramBinary;
approvalProgramMap;
clearProgramMap;
appSchema;
acctSchema;
constructor(opts) {
this.client = opts.client;
if (opts.appId !== undefined) {
this.appId = opts.appId;
this.appAddress = algosdk_1.default.getApplicationAddress(opts.appId);
this.appAddress = algosdk.getApplicationAddress(opts.appId);
}

@@ -136,429 +82,305 @@ else {

}
ApplicationClient.prototype.compile = function (program) {
return __awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.client.compile(program).sourcemap(true).do()];
case 1:
result = _a.sent();
return [2 /*return*/, [
new Uint8Array(Buffer.from(result['result'], 'base64')),
new algosdk_1.default.SourceMap(result['sourcemap']),
]];
}
});
async compile(program) {
const result = await this.client.compile(program).sourcemap(true).do();
return [
new Uint8Array(Buffer.from(result['result'], 'base64')),
new algosdk.SourceMap(result['sourcemap']),
];
}
async ensurePrograms() {
if (this.approvalProgram === undefined || this.clearProgram === undefined)
throw Error('no approval or clear program defined');
if (this.approvalProgramBinary === undefined) {
const [appBin, appMap] = await this.compile(Buffer.from(this.approvalProgram, 'base64').toString());
this.approvalProgramBinary = appBin;
this.approvalProgramMap = appMap;
}
if (this.clearProgramBinary === undefined) {
const [clearBin, clearMap] = await this.compile(Buffer.from(this.clearProgram, 'base64').toString());
this.clearProgramBinary = clearBin;
this.clearProgramMap = clearMap;
}
}
async create(txParams) {
await this.ensurePrograms();
if (this.approvalProgramBinary === undefined ||
this.clearProgramBinary === undefined)
throw Error('no approval or clear program binaries defined');
if (this.signer === undefined)
throw Error('no signer defined');
const sp = await this.getSuggestedParams(txParams);
const atc = new algosdk.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk.makeApplicationCreateTxnFromObject({
from: this.getSender(),
suggestedParams: sp,
onComplete: algosdk.OnApplicationComplete.NoOpOC,
approvalProgram: this.approvalProgramBinary,
clearProgram: this.clearProgramBinary,
...this.getGlobalSchema(),
...this.getLocalSchema(),
...txParams,
}),
signer: this.signer,
});
};
ApplicationClient.prototype.ensurePrograms = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, appBin, appMap, _b, clearBin, clearMap;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (this.approvalProgram === undefined || this.clearProgram === undefined)
throw Error('no approval or clear program defined');
if (!(this.approvalProgramBinary === undefined)) return [3 /*break*/, 2];
return [4 /*yield*/, this.compile(Buffer.from(this.approvalProgram, 'base64').toString())];
case 1:
_a = _c.sent(), appBin = _a[0], appMap = _a[1];
this.approvalProgramBinary = appBin;
this.approvalProgramMap = appMap;
_c.label = 2;
case 2:
if (!(this.clearProgramBinary === undefined)) return [3 /*break*/, 4];
return [4 /*yield*/, this.compile(Buffer.from(this.clearProgram, 'base64').toString())];
case 3:
_b = _c.sent(), clearBin = _b[0], clearMap = _b[1];
this.clearProgramBinary = clearBin;
this.clearProgramMap = clearMap;
_c.label = 4;
case 4: return [2 /*return*/];
}
});
try {
const result = await atc.execute(this.client, 4);
const txid = result.txIDs[0];
if (txid === undefined)
throw new Error('No transaction id returned from execute');
const txinfo = await this.client.pendingTransactionInformation(txid).do();
this.appId = txinfo['application-index'];
this.appAddress = algosdk.getApplicationAddress(this.appId);
return [this.appId, this.appAddress, txid];
}
catch (e) {
throw this.wrapLogicError(e);
}
}
async delete(txParams) {
if (this.signer === undefined)
throw Error('no signer defined');
const sp = await this.getSuggestedParams(txParams);
const atc = new algosdk.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk.makeApplicationCallTxnFromObject({
from: this.getSender(),
suggestedParams: sp,
onComplete: algosdk.OnApplicationComplete.DeleteApplicationOC,
appIndex: this.appId,
...txParams,
}),
signer: this.signer,
});
};
ApplicationClient.prototype.create = function (txParams) {
return __awaiter(this, void 0, void 0, function () {
var sp, atc, result, txid, txinfo, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ensurePrograms()];
case 1:
_a.sent();
if (this.approvalProgramBinary === undefined ||
this.clearProgramBinary === undefined)
throw Error('no approval or clear program binaries defined');
if (this.signer === undefined)
throw Error('no signer defined');
return [4 /*yield*/, this.getSuggestedParams(txParams)];
case 2:
sp = _a.sent();
atc = new algosdk_1.default.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk_1.default.makeApplicationCreateTxnFromObject(__assign(__assign(__assign({ from: this.getSender(), suggestedParams: sp, onComplete: algosdk_1.default.OnApplicationComplete.NoOpOC, approvalProgram: this.approvalProgramBinary, clearProgram: this.clearProgramBinary }, this.getGlobalSchema()), this.getLocalSchema()), txParams)),
signer: this.signer,
});
_a.label = 3;
case 3:
_a.trys.push([3, 6, , 7]);
return [4 /*yield*/, atc.execute(this.client, 4)];
case 4:
result = _a.sent();
txid = result.txIDs[0];
if (txid === undefined)
throw new Error('No transaction id returned from execute');
return [4 /*yield*/, this.client.pendingTransactionInformation(txid).do()];
case 5:
txinfo = _a.sent();
this.appId = txinfo['application-index'];
this.appAddress = algosdk_1.default.getApplicationAddress(this.appId);
return [2 /*return*/, [this.appId, this.appAddress, txid]];
case 6:
e_1 = _a.sent();
throw this.wrapLogicError(e_1);
case 7: return [2 /*return*/];
}
});
try {
return atc.execute(this.client, 4);
}
catch (e) {
throw this.wrapLogicError(e);
}
}
async update(txParams) {
await this.ensurePrograms();
if (this.approvalProgramBinary === undefined ||
this.clearProgramBinary === undefined)
throw Error('no approval or clear program binaries defined');
if (this.signer === undefined)
throw Error('no signer defined');
const sp = await this.getSuggestedParams(txParams);
const atc = new algosdk.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk.makeApplicationUpdateTxnFromObject({
from: this.getSender(),
suggestedParams: sp,
approvalProgram: this.approvalProgramBinary,
clearProgram: this.clearProgramBinary,
appIndex: this.appId,
...txParams,
}),
signer: this.signer,
});
};
ApplicationClient.prototype.delete = function (txParams) {
return __awaiter(this, void 0, void 0, function () {
var sp, atc;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.signer === undefined)
throw Error('no signer defined');
return [4 /*yield*/, this.getSuggestedParams(txParams)];
case 1:
sp = _a.sent();
atc = new algosdk_1.default.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk_1.default.makeApplicationCallTxnFromObject(__assign({ from: this.getSender(), suggestedParams: sp, onComplete: algosdk_1.default.OnApplicationComplete.DeleteApplicationOC, appIndex: this.appId }, txParams)),
signer: this.signer,
});
try {
return [2 /*return*/, atc.execute(this.client, 4)];
}
catch (e) {
throw this.wrapLogicError(e);
}
return [2 /*return*/];
}
});
try {
return await atc.execute(this.client, 4);
}
catch (e) {
throw this.wrapLogicError(e);
}
}
async optIn(txParams) {
if (this.signer === undefined)
throw Error('no signer defined');
const sp = await this.getSuggestedParams(txParams);
const atc = new algosdk.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk.makeApplicationOptInTxnFromObject({
from: this.getSender(),
suggestedParams: sp,
appIndex: this.appId,
...txParams,
}),
signer: this.signer,
});
};
ApplicationClient.prototype.update = function (txParams) {
return __awaiter(this, void 0, void 0, function () {
var sp, atc, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.ensurePrograms()];
case 1:
_a.sent();
if (this.approvalProgramBinary === undefined ||
this.clearProgramBinary === undefined)
throw Error('no approval or clear program binaries defined');
if (this.signer === undefined)
throw Error('no signer defined');
return [4 /*yield*/, this.getSuggestedParams(txParams)];
case 2:
sp = _a.sent();
atc = new algosdk_1.default.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk_1.default.makeApplicationUpdateTxnFromObject(__assign({ from: this.getSender(), suggestedParams: sp, approvalProgram: this.approvalProgramBinary, clearProgram: this.clearProgramBinary, appIndex: this.appId }, txParams)),
signer: this.signer,
});
_a.label = 3;
case 3:
_a.trys.push([3, 5, , 6]);
return [4 /*yield*/, atc.execute(this.client, 4)];
case 4: return [2 /*return*/, _a.sent()];
case 5:
e_2 = _a.sent();
throw this.wrapLogicError(e_2);
case 6: return [2 /*return*/];
}
});
try {
return await atc.execute(this.client, 4);
}
catch (e) {
throw this.wrapLogicError(e);
}
}
async closeOut(txParams) {
if (this.signer === undefined)
throw Error('no signer defined');
const sp = await this.getSuggestedParams(txParams);
const atc = new algosdk.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk.makeApplicationCloseOutTxnFromObject({
from: this.getSender(),
suggestedParams: sp,
appIndex: this.appId,
...txParams,
}),
signer: this.signer,
});
};
ApplicationClient.prototype.optIn = function (txParams) {
return __awaiter(this, void 0, void 0, function () {
var sp, atc, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.signer === undefined)
throw Error('no signer defined');
return [4 /*yield*/, this.getSuggestedParams(txParams)];
case 1:
sp = _a.sent();
atc = new algosdk_1.default.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk_1.default.makeApplicationOptInTxnFromObject(__assign({ from: this.getSender(), suggestedParams: sp, appIndex: this.appId }, txParams)),
signer: this.signer,
});
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, atc.execute(this.client, 4)];
case 3: return [2 /*return*/, _a.sent()];
case 4:
e_3 = _a.sent();
throw this.wrapLogicError(e_3);
case 5: return [2 /*return*/];
}
});
try {
return await atc.execute(this.client, 4);
}
catch (e) {
throw this.wrapLogicError(e);
}
}
async clearState(txParams) {
if (this.signer === undefined)
throw Error('no signer defined');
const sp = await this.getSuggestedParams(txParams);
const atc = new algosdk.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk.makeApplicationClearStateTxnFromObject({
from: this.getSender(),
suggestedParams: sp,
appIndex: this.appId,
}),
signer: this.signer,
});
};
ApplicationClient.prototype.closeOut = function (txParams) {
return __awaiter(this, void 0, void 0, function () {
var sp, atc, e_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.signer === undefined)
throw Error('no signer defined');
return [4 /*yield*/, this.getSuggestedParams(txParams)];
case 1:
sp = _a.sent();
atc = new algosdk_1.default.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk_1.default.makeApplicationCloseOutTxnFromObject(__assign({ from: this.getSender(), suggestedParams: sp, appIndex: this.appId }, txParams)),
signer: this.signer,
});
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, atc.execute(this.client, 4)];
case 3: return [2 /*return*/, _a.sent()];
case 4:
e_4 = _a.sent();
throw this.wrapLogicError(e_4);
case 5: return [2 /*return*/];
try {
return await atc.execute(this.client, 4);
}
catch (e) {
throw this.wrapLogicError(e);
}
}
async execute(atc) {
try {
const result = await atc.execute(this.client, 4);
return result.methodResults[0]
? result.methodResults[0]
: {};
}
catch (e) {
throw this.wrapLogicError(e);
}
}
async addMethodCall(method, args, txParams, atc) {
if (atc === undefined) {
atc = new algosdk.AtomicTransactionComposer();
}
if (this.signer === undefined)
throw new Error('no signer defined');
const sp = await this.getSuggestedParams(txParams);
const processedArgs = [];
for (const expected_arg of method.args) {
if (args === undefined)
throw new Error(`No args passed, expected ${method.args}`);
if (expected_arg.name === undefined || !(expected_arg.name in args)) {
// Error! (or check hints)
throw new Error(`Cant find required argument: ${expected_arg.name}`);
}
let arg = args[expected_arg.name];
if (arg instanceof algosdk.Transaction) {
arg = {
txn: arg,
signer: this.signer,
};
}
else if (arg instanceof Uint8Array) {
// TODO: other types?
if (expected_arg.type instanceof algosdk.ABIAddressType ||
expected_arg.type == ABIReferenceType.account) {
arg = algosdk.encodeAddress(arg);
}
});
}
else if (arg instanceof Object &&
!algosdk.isTransactionWithSigner(arg)) {
arg = Object.values(arg);
}
processedArgs.push(arg);
}
atc.addMethodCall({
appID: this.appId,
method: method,
methodArgs: processedArgs,
sender: this.getSender(),
suggestedParams: sp,
signer: this.signer,
...txParams,
});
};
ApplicationClient.prototype.clearState = function (txParams) {
return __awaiter(this, void 0, void 0, function () {
var sp, atc, e_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.signer === undefined)
throw Error('no signer defined');
return [4 /*yield*/, this.getSuggestedParams(txParams)];
case 1:
sp = _a.sent();
atc = new algosdk_1.default.AtomicTransactionComposer();
atc.addTransaction({
txn: algosdk_1.default.makeApplicationClearStateTxnFromObject({
from: this.getSender(),
suggestedParams: sp,
appIndex: this.appId,
}),
signer: this.signer,
});
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, atc.execute(this.client, 4)];
case 3: return [2 /*return*/, _a.sent()];
case 4:
e_5 = _a.sent();
throw this.wrapLogicError(e_5);
case 5: return [2 /*return*/];
}
});
});
};
ApplicationClient.prototype.execute = function (atc) {
return __awaiter(this, void 0, void 0, function () {
var result, e_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, atc.execute(this.client, 4)];
case 1:
result = _a.sent();
return [2 /*return*/, result.methodResults[0]
? result.methodResults[0]
: {}];
case 2:
e_6 = _a.sent();
throw this.wrapLogicError(e_6);
case 3: return [2 /*return*/];
}
});
});
};
ApplicationClient.prototype.addMethodCall = function (method, args, txParams, atc) {
return __awaiter(this, void 0, void 0, function () {
var sp, processedArgs, _i, _a, expected_arg, arg;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (atc === undefined) {
atc = new algosdk_1.default.AtomicTransactionComposer();
}
if (this.signer === undefined)
throw new Error('no signer defined');
return [4 /*yield*/, this.getSuggestedParams(txParams)];
case 1:
sp = _b.sent();
processedArgs = [];
for (_i = 0, _a = method.args; _i < _a.length; _i++) {
expected_arg = _a[_i];
if (args === undefined)
throw new Error("No args passed, expected ".concat(method.args));
if (expected_arg.name === undefined || !(expected_arg.name in args)) {
// Error! (or check hints)
throw new Error("Cant find required argument: ".concat(expected_arg.name));
}
arg = args[expected_arg.name];
if (arg instanceof algosdk_1.default.Transaction) {
arg = {
txn: arg,
signer: this.signer,
};
}
else if (arg instanceof Uint8Array) {
// TODO: other types?
if (expected_arg.type instanceof algosdk_1.default.ABIAddressType ||
expected_arg.type == algosdk_1.ABIReferenceType.account) {
arg = algosdk_1.default.encodeAddress(arg);
}
}
else if (arg instanceof Object &&
!algosdk_1.default.isTransactionWithSigner(arg)) {
arg = Object.values(arg);
}
processedArgs.push(arg);
}
atc.addMethodCall(__assign({ appID: this.appId, method: method, methodArgs: processedArgs, sender: this.getSender(), suggestedParams: sp, signer: this.signer }, txParams));
return [2 /*return*/, atc];
}
});
});
};
ApplicationClient.prototype.wrapLogicError = function (e) {
return atc;
}
wrapLogicError(e) {
if (this.approvalProgram === undefined ||
this.approvalProgramMap == undefined)
return e;
var led = (0, logic_error_1.parseLogicError)(e.message);
const led = parseLogicError(e.message);
if (led.msg !== undefined)
return new logic_error_1.LogicError(led, Buffer.from(this.approvalProgram, 'base64').toString().split('\n'), this.approvalProgramMap);
return new LogicError(led, Buffer.from(this.approvalProgram, 'base64').toString().split('\n'), this.approvalProgramMap);
else
return e;
};
ApplicationClient.prototype.resolve = function (source, data) {
return __awaiter(this, void 0, void 0, function () {
var val, _a, appState, key, acctState, meth, _b;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
_a = source;
switch (_a) {
case 'global-state': return [3 /*break*/, 1];
case 'local-state': return [3 /*break*/, 3];
case 'abi-method': return [3 /*break*/, 5];
}
return [3 /*break*/, 7];
case 1: return [4 /*yield*/, this.getApplicationState(true)];
case 2:
appState = _c.sent();
key = Buffer.from(data).toString('hex');
val = appState[key];
if (val === undefined)
throw new Error("no global state value: ".concat(data));
return [2 /*return*/, val];
case 3: return [4 /*yield*/, this.getAccountState()];
case 4:
acctState = _c.sent();
val = acctState[data];
if (val === undefined)
throw new Error("no global state value: ".concat(data));
return [2 /*return*/, val];
case 5:
// TODO: args?
if (this.methods === undefined)
throw new Error('no methods defined, cannot resolve hint');
meth = algosdk_1.default.getMethodByName(this.methods, data);
_b = this.execute;
return [4 /*yield*/, this.addMethodCall(meth, undefined)];
case 6: return [2 /*return*/, _b.apply(this, [_c.sent()])];
case 7: return [2 /*return*/, data];
}
});
});
};
ApplicationClient.prototype.getSuggestedParams = function (txParams) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (txParams !== undefined && txParams.suggestedParams !== undefined)
return [2 /*return*/, txParams.suggestedParams];
return [4 /*yield*/, this.client.getTransactionParams().do()];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
ApplicationClient.prototype.getApplicationState = function (raw) {
return __awaiter(this, void 0, void 0, function () {
var appInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.client.getApplicationByID(this.appId).do()];
case 1:
appInfo = _a.sent();
if (!('params' in appInfo) || !('global-state' in appInfo['params']))
throw new Error('No global state found');
return [2 /*return*/, (0, state_1.decodeState)(appInfo['params']['global-state'], raw)];
}
});
});
};
ApplicationClient.prototype.getAccountState = function (address, raw) {
return __awaiter(this, void 0, void 0, function () {
var acctInfo;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (address === undefined)
address = this.getSender();
return [4 /*yield*/, this.client
.accountApplicationInformation(address, this.appId)
.do()];
case 1:
acctInfo = _a.sent();
if (!('app-local-state' in acctInfo) ||
!('key-value' in acctInfo['app-local-state']))
return [2 /*return*/, {}];
return [2 /*return*/, (0, state_1.decodeState)(acctInfo['app-local-state']['key-value'], raw)];
}
});
});
};
ApplicationClient.prototype.getSender = function () {
}
async resolve(source, data) {
let val;
switch (source) {
case 'global-state':
// Use the raw return value, so encode the key as hex since
// that is what we get back from the call to getAppState
const appState = await this.getApplicationState(true);
const key = Buffer.from(data).toString('hex');
val = appState[key];
if (val === undefined)
throw new Error(`no global state value: ${data}`);
return val;
case 'local-state':
// TODO: how do we pass in which account to resolve against ?
// This assumes the current client sender
const acctState = await this.getAccountState();
val = acctState[data];
if (val === undefined)
throw new Error(`no global state value: ${data}`);
return val;
case 'abi-method':
// TODO: args?
if (this.methods === undefined)
throw new Error('no methods defined, cannot resolve hint');
const meth = algosdk.getMethodByName(this.methods, data);
return this.execute(await this.addMethodCall(meth, undefined));
default:
return data;
}
}
async getSuggestedParams(txParams) {
if (txParams !== undefined && txParams.suggestedParams !== undefined)
return txParams.suggestedParams;
return await this.client.getTransactionParams().do();
}
async getApplicationState(raw) {
const appInfo = await this.client.getApplicationByID(this.appId).do();
if (!('params' in appInfo) || !('global-state' in appInfo['params']))
throw new Error('No global state found');
return decodeState(appInfo['params']['global-state'], raw);
}
async getAccountState(address, raw) {
if (address === undefined)
address = this.getSender();
const acctInfo = await this.client
.accountApplicationInformation(address, this.appId)
.do();
if (!('app-local-state' in acctInfo) ||
!('key-value' in acctInfo['app-local-state']))
return {};
return decodeState(acctInfo['app-local-state']['key-value'], raw);
}
getSender() {
return this.sender;
};
ApplicationClient.prototype.getLocalSchema = function () {
}
getLocalSchema() {
if (this.acctSchema === undefined)
throw new Error('No account schema defined');
var s = (0, __1.getStateSchema)(this.acctSchema);
const s = getStateSchema(this.acctSchema);
return { numLocalInts: s.uints, numLocalByteSlices: s.bytes };
};
ApplicationClient.prototype.getGlobalSchema = function () {
}
getGlobalSchema() {
if (this.appSchema === undefined)
throw new Error('No app schema defined');
var s = (0, __1.getStateSchema)(this.appSchema);
const s = getStateSchema(this.appSchema);
return { numGlobalInts: s.uints, numGlobalByteSlices: s.bytes };
};
return ApplicationClient;
}());
exports.ApplicationClient = ApplicationClient;
}
}
//# sourceMappingURL=application_client.js.map

@@ -1,22 +0,4 @@

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogicError = exports.parseLogicError = void 0;
var LOGIC_ERROR = /TransactionPool.Remember: transaction ([A-Z0-9]+): logic eval error: (.*). Details: pc=([0-9]+), opcodes=.*/;
function parseLogicError(errMsg) {
var res = LOGIC_ERROR.exec(errMsg);
const LOGIC_ERROR = /TransactionPool.Remember: transaction ([A-Z0-9]+): logic eval error: (.*). Details: pc=([0-9]+), opcodes=.*/;
export function parseLogicError(errMsg) {
const res = LOGIC_ERROR.exec(errMsg);
if (res === null || res.length <= 3)

@@ -30,27 +12,26 @@ return {};

}
exports.parseLogicError = parseLogicError;
var LogicError = /** @class */ (function (_super) {
__extends(LogicError, _super);
function LogicError(led, program, map) {
var _this = _super.call(this) || this;
_this.lines = 5;
_this.teal_line = 0;
_this.led = led;
_this.program = program;
var line = map.getLineForPc(led.pc);
_this.teal_line = line === undefined ? 0 : line;
_this.message = "".concat(_this.led.msg.slice(0, 20), "... at:").concat(line);
if (_this.teal_line > 0) {
var start = _this.teal_line > _this.lines ? _this.teal_line - _this.lines : 0;
var stop_1 = program.length > _this.teal_line + _this.lines
? _this.teal_line + _this.lines
export class LogicError extends Error {
led;
program;
lines = 5;
teal_line = 0;
stack;
constructor(led, program, map) {
super();
this.led = led;
this.program = program;
const line = map.getLineForPc(led.pc);
this.teal_line = line === undefined ? 0 : line;
this.message = `${this.led.msg.slice(0, 20)}... at:${line}`;
if (this.teal_line > 0) {
const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0;
const stop = program.length > this.teal_line + this.lines
? this.teal_line + this.lines
: program.length;
var stack_lines = program.slice(start, stop_1);
const stack_lines = program.slice(start, stop);
stack_lines[stack_lines.length / 2] += ' <--- Error';
_this.stack = stack_lines.join('\n');
this.stack = stack_lines.join('\n');
}
return _this;
}
return LogicError;
}(Error));
exports.LogicError = LogicError;
}
//# sourceMappingURL=logic_error.js.map

@@ -1,4 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeState = void 0;
function strOrHex(v) {

@@ -14,15 +11,14 @@ try {

// friendly generic object
function decodeState(state, raw) {
var obj = {};
export function decodeState(state, raw) {
const obj = {};
// Start with empty set
for (var _i = 0, state_1 = state; _i < state_1.length; _i++) {
var stateVal = state_1[_i];
var keyBuff = Buffer.from(stateVal.key, 'base64');
var key = raw ? keyBuff.toString('hex') : strOrHex(keyBuff);
var value = stateVal.value;
for (const stateVal of state) {
const keyBuff = Buffer.from(stateVal.key, 'base64');
const key = raw ? keyBuff.toString('hex') : strOrHex(keyBuff);
const value = stateVal.value;
// In both global-state and state deltas, 1 is bytes and 2 is int
var dataTypeFlag = value.action ? value.action : value.type;
const dataTypeFlag = value.action ? value.action : value.type;
switch (dataTypeFlag) {
case 1:
var valBuff = Buffer.from(value.bytes, 'base64');
const valBuff = Buffer.from(value.bytes, 'base64');
obj[key] = raw ? new Uint8Array(valBuff) : strOrHex(valBuff);

@@ -38,2 +34,2 @@ break;

}
exports.decodeState = decodeState;
//# sourceMappingURL=state.js.map

@@ -1,2 +0,1 @@

#!/usr/bin/env node
export {};

@@ -1,37 +0,11 @@

#!/usr/bin/env node
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var commander_1 = require("commander");
var _1 = require(".");
var fs = __importStar(require("fs"));
var path = __importStar(require("path"));
var pjson = require('../package.json'); // eslint-disable-line
var program = new commander_1.Command();
import { Command } from 'commander';
import { generateApplicationClient } from './index.js';
import * as fs from 'fs';
import * as path from 'path';
//const pjson = ../package.json'); // eslint-disable-line
const program = new Command();
program
.name('beaker')
.description('Utilities for working with beaker applications')
.version(pjson['version']);
.version('0.0.35');
program

@@ -42,4 +16,3 @@ .command('generate')

.option('-l, --local', 'whether or not to use local import')
.action(function (specPath, srcPath, options) {
var importPath = options.local ? '../../src/' : undefined;
.action((specPath, srcPath, options) => {
if (srcPath.slice(-1) !== path.sep)

@@ -53,9 +26,13 @@ srcPath += path.sep;

}
console.log("Writing client to: ".concat(srcPath));
var jsonObj = JSON.parse(fs.readFileSync(specPath).toString());
let jsonObj = JSON.parse(fs.readFileSync(specPath).toString());
if (!('contract' in jsonObj)) {
jsonObj = { hints: {}, source: {}, schema: {}, contract: jsonObj };
}
(0, _1.generateApplicationClient)(jsonObj, srcPath, importPath);
const outputFile = generateApplicationClient(jsonObj, options.local ? '../../src/' : undefined);
const name = jsonObj.contract.name;
const file_name = `${name.toLowerCase()}_client.ts`;
fs.writeFileSync(srcPath + file_name, outputFile);
console.log(`Wrote client to: ${srcPath + file_name}`);
});
program.parse();
//# sourceMappingURL=beaker.js.map

@@ -1,14 +0,10 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getStateSchema = exports.AVMType = void 0;
var AVMType;
export var AVMType;
(function (AVMType) {
AVMType[AVMType["uint64"] = 0] = "uint64";
AVMType[AVMType["bytes"] = 1] = "bytes";
})(AVMType = exports.AVMType || (exports.AVMType = {}));
function getStateSchema(s) {
var uints = 0;
var bytes = 0;
for (var _i = 0, _a = Object.entries(s.declared); _i < _a.length; _i++) {
var item = _a[_i];
})(AVMType || (AVMType = {}));
export function getStateSchema(s) {
let uints = 0;
let bytes = 0;
for (const item of Object.entries(s.declared)) {
if (item[1].type == AVMType.bytes)

@@ -19,4 +15,3 @@ bytes += 1;

}
for (var _b = 0, _c = Object.entries(s.dynamic); _b < _c.length; _b++) {
var item = _c[_b];
for (const item of Object.entries(s.dynamic)) {
if (item[1].type == AVMType.bytes)

@@ -29,2 +24,2 @@ bytes += item[1].max_keys;

}
exports.getStateSchema = getStateSchema;
//# sourceMappingURL=appspec.js.map
import type { AppSpec } from './appspec';
export declare function generateApplicationClient(appSpec: AppSpec, path: string, beakerPath?: string): void;
export declare function generateApplicationClient(appSpec: AppSpec, beakerPath?: string): string;

@@ -1,52 +0,14 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateApplicationClient = void 0;
var algosdk_1 = __importDefault(require("algosdk"));
var typescript_1 = __importStar(require("typescript"));
var fs_1 = require("fs");
import algosdk from 'algosdk';
import ts from 'typescript';
const { factory } = ts;
// AMAZING resource:
// https://ts-ast-viewer.com/#
var CLIENT_NAME = 'bkr.ApplicationClient';
const CLIENT_NAME = 'bkr.ApplicationClient';
// TODO: only import if we _need_ them
var CLIENT_IMPORTS = "* as bkr";
var CLIENT_PATH = 'beaker-ts';
var ALGOSDK_IMPORTS = 'algosdk';
var ALGOSDK_PATH = 'algosdk';
var REF_TYPES = ['account', 'application', 'asset'];
var TXN_TYPES = [
const CLIENT_IMPORTS = `* as bkr`;
const CLIENT_PATH = 'beaker-ts';
const ALGOSDK_IMPORTS = 'algosdk';
const ALGOSDK_PATH = 'algosdk';
const REF_TYPES = ['account', 'application', 'asset'];
const TXN_TYPES = [
'txn',

@@ -61,92 +23,89 @@ 'pay',

// native types
var UINT8_ARRAY_IDENT = typescript_1.factory.createIdentifier('Uint8Array');
var UINT8_ARRAY_TYPE = typescript_1.factory.createTypeReferenceNode(UINT8_ARRAY_IDENT);
const UINT8_ARRAY_IDENT = factory.createIdentifier('Uint8Array');
const UINT8_ARRAY_TYPE = factory.createTypeReferenceNode(UINT8_ARRAY_IDENT);
// sdk types
var ABI_METHOD_IDENT = typescript_1.factory.createIdentifier('algosdk.ABIMethod');
var ABI_METHOD_TYPE = typescript_1.factory.createTypeReferenceNode(ABI_METHOD_IDENT);
var ATC_IDENT = typescript_1.factory.createIdentifier('algosdk.AtomicTransactionComposer');
var ATC_TYPE = typescript_1.factory.createTypeReferenceNode(ATC_IDENT);
const ABI_METHOD_IDENT = factory.createIdentifier('algosdk.ABIMethod');
const ABI_METHOD_TYPE = factory.createTypeReferenceNode(ABI_METHOD_IDENT);
const ATC_IDENT = factory.createIdentifier('algosdk.AtomicTransactionComposer');
const ATC_TYPE = factory.createTypeReferenceNode(ATC_IDENT);
// bkr types
var ABI_RESULT_IDENT = typescript_1.factory.createIdentifier('bkr.ABIResult');
var DECODE_NAMED_TUPLE_IDENT = typescript_1.factory.createIdentifier('bkr.decodeNamedTuple');
var SCHEMA_TYPE = typescript_1.factory.createTypeReferenceNode('bkr.Schema');
var TRANSACTION_OVERRIDES_TYPE = typescript_1.factory.createTypeReferenceNode('bkr.TransactionOverrides');
const ABI_RESULT_IDENT = factory.createIdentifier('bkr.ABIResult');
const DECODE_NAMED_TUPLE_IDENT = factory.createIdentifier('bkr.decodeNamedTuple');
const SCHEMA_TYPE = factory.createTypeReferenceNode('bkr.Schema');
const TRANSACTION_OVERRIDES_TYPE = factory.createTypeReferenceNode('bkr.TransactionOverrides');
function tsTypeFromAbiType(argType) {
if (typeof argType === 'string') {
if (TXN_TYPES.includes(argType))
return typescript_1.factory.createUnionTypeNode([
typescript_1.factory.createTypeReferenceNode('algosdk.TransactionWithSigner'),
typescript_1.factory.createTypeReferenceNode('algosdk.Transaction'),
return factory.createUnionTypeNode([
factory.createTypeReferenceNode('algosdk.TransactionWithSigner'),
factory.createTypeReferenceNode('algosdk.Transaction'),
]);
if (REF_TYPES.includes(argType)) {
if (['application', 'asset'].includes(argType))
return typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.BigIntKeyword);
return typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.StringKeyword);
return factory.createKeywordTypeNode(ts.SyntaxKind.BigIntKeyword);
return factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);
}
}
var abiType = typeof argType === 'string' ? algosdk_1.default.ABIType.from(argType) : argType;
const abiType = typeof argType === 'string' ? algosdk.ABIType.from(argType) : argType;
switch (abiType.constructor) {
case algosdk_1.default.ABIByteType:
return typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.NumberKeyword);
case algosdk_1.default.ABIUintType:
case algosdk_1.default.ABIUfixedType:
return typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.BigIntKeyword);
case algosdk_1.default.ABIAddressType:
case algosdk_1.default.ABIStringType:
return typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.StringKeyword);
case algosdk_1.default.ABIBoolType:
return typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.BooleanKeyword);
case algosdk_1.default.ABIArrayStaticType:
var asStaticArr = abiType;
case algosdk.ABIByteType:
return factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
case algosdk.ABIUintType:
case algosdk.ABIUfixedType:
return factory.createKeywordTypeNode(ts.SyntaxKind.BigIntKeyword);
case algosdk.ABIAddressType:
case algosdk.ABIStringType:
return factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword);
case algosdk.ABIBoolType:
return factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword);
case algosdk.ABIArrayStaticType:
const asStaticArr = abiType;
switch (asStaticArr.childType.constructor) {
// If its bytes, make it a uint8array
case algosdk_1.default.ABIByteType:
case algosdk.ABIByteType:
return UINT8_ARRAY_TYPE;
}
return typescript_1.factory.createArrayTypeNode(tsTypeFromAbiType(asStaticArr.childType));
case algosdk_1.default.ABIArrayDynamicType:
var asArr = abiType;
return factory.createArrayTypeNode(tsTypeFromAbiType(asStaticArr.childType));
case algosdk.ABIArrayDynamicType:
const asArr = abiType;
switch (asArr.childType.constructor) {
// If its bytes, make it a uint8array
case algosdk_1.default.ABIByteType:
case algosdk.ABIByteType:
return UINT8_ARRAY_TYPE;
}
return typescript_1.factory.createArrayTypeNode(tsTypeFromAbiType(asArr.childType));
case algosdk_1.default.ABITupleType:
var asTuple = abiType;
return typescript_1.factory.createTupleTypeNode(asTuple.childTypes.map(function (elem) {
return factory.createArrayTypeNode(tsTypeFromAbiType(asArr.childType));
case algosdk.ABITupleType:
const asTuple = abiType;
return factory.createTupleTypeNode(asTuple.childTypes.map((elem) => {
return tsTypeFromAbiType(elem);
}));
}
return typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.AnyKeyword);
return factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
}
function defaultValueFromTsType(t) {
switch (t.kind) {
case typescript_1.default.SyntaxKind.StringKeyword:
return typescript_1.factory.createStringLiteral('');
case typescript_1.default.SyntaxKind.NumberKeyword:
return typescript_1.factory.createNumericLiteral(0);
case typescript_1.default.SyntaxKind.BigIntKeyword:
return typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('BigInt'), undefined, [typescript_1.factory.createNumericLiteral('0')]);
case typescript_1.default.SyntaxKind.BooleanKeyword:
return typescript_1.factory.createIdentifier('false');
case typescript_1.default.SyntaxKind.TypeReference:
return typescript_1.factory.createNewExpression(UINT8_ARRAY_IDENT, undefined, []);
case ts.SyntaxKind.StringKeyword:
return factory.createStringLiteral('');
case ts.SyntaxKind.NumberKeyword:
return factory.createNumericLiteral(0);
case ts.SyntaxKind.BigIntKeyword:
return factory.createCallExpression(factory.createIdentifier('BigInt'), undefined, [factory.createNumericLiteral('0')]);
case ts.SyntaxKind.BooleanKeyword:
return factory.createIdentifier('false');
case ts.SyntaxKind.TypeReference:
return factory.createNewExpression(UINT8_ARRAY_IDENT, undefined, []);
}
return typescript_1.factory.createIdentifier('undefined');
return factory.createIdentifier('undefined');
}
function generateApplicationClient(appSpec, path, beakerPath) {
var name = appSpec.contract.name;
var nodes = generateImports(beakerPath);
var structNodes = generateStructTypes(appSpec);
nodes.push.apply(nodes, structNodes);
var classNode = generateClass(appSpec);
export function generateApplicationClient(appSpec, beakerPath) {
const name = appSpec.contract.name;
const nodes = generateImports(beakerPath);
const structNodes = generateStructTypes(appSpec);
nodes.push(...structNodes);
const classNode = generateClass(appSpec);
nodes.push(classNode);
var outputFile = typescript_1.default
return ts
.createPrinter()
.printList(typescript_1.default.ListFormat.MultiLine, typescript_1.factory.createNodeArray(nodes), typescript_1.default.createSourceFile(name, '', typescript_1.default.ScriptTarget.ESNext, true, typescript_1.default.ScriptKind.TS));
var file_name = "".concat(name.toLowerCase(), "_client.ts");
(0, fs_1.writeFileSync)(path + file_name, outputFile);
.printList(ts.ListFormat.MultiLine, factory.createNodeArray(nodes), ts.createSourceFile(name, '', ts.ScriptTarget.ESNext, true, ts.ScriptKind.TS));
}
exports.generateApplicationClient = generateApplicationClient;
// create the imports for the generated client

@@ -156,23 +115,23 @@ function generateImports(beakerPath) {

// Import algosdk
typescript_1.factory.createImportDeclaration(undefined, undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier(ALGOSDK_IMPORTS), undefined), typescript_1.factory.createStringLiteral(ALGOSDK_PATH), undefined),
factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, factory.createIdentifier(ALGOSDK_IMPORTS), undefined), factory.createStringLiteral(ALGOSDK_PATH), undefined),
// Import generic client
typescript_1.factory.createImportDeclaration(undefined, undefined, typescript_1.factory.createImportClause(false, typescript_1.factory.createIdentifier(CLIENT_IMPORTS), undefined), typescript_1.factory.createStringLiteral(beakerPath ? beakerPath : CLIENT_PATH), undefined),
factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, factory.createIdentifier(CLIENT_IMPORTS), undefined), factory.createStringLiteral(beakerPath ? beakerPath : CLIENT_PATH), undefined),
];
}
function generateClass(appSpec) {
return typescript_1.factory.createClassDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.ExportKeyword)], typescript_1.factory.createIdentifier(appSpec.contract.name), undefined, [
typescript_1.factory.createHeritageClause(typescript_1.default.SyntaxKind.ExtendsKeyword, [
typescript_1.factory.createExpressionWithTypeArguments(typescript_1.factory.createIdentifier(CLIENT_NAME), undefined),
return factory.createClassDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier(appSpec.contract.name), undefined, [
factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [
factory.createExpressionWithTypeArguments(factory.createIdentifier(CLIENT_NAME), undefined),
]),
], __spreadArray(__spreadArray(__spreadArray([], generateContractProperties(appSpec), true), appSpec.contract.methods.map(function (meth) {
return generateMethodImpl(meth, appSpec);
}), true), [
], [
...generateContractProperties(appSpec),
...appSpec.contract.methods.map((meth) => generateMethodImpl(meth, appSpec)),
generateComposeMethods(appSpec),
], false));
]);
}
function generateComposeMethods(spec) {
// create desc property
return typescript_1.factory.createPropertyDeclaration(undefined, undefined, typescript_1.factory.createIdentifier('compose'), undefined, undefined, typescript_1.factory.createObjectLiteralExpression(spec.contract.methods.map(function (meth) {
var _a = generateComposeMethodImpl(meth, spec), key = _a[0], value = _a[1];
return typescript_1.factory.createPropertyAssignment(key, value);
return factory.createPropertyDeclaration(undefined, undefined, factory.createIdentifier('compose'), undefined, undefined, factory.createObjectLiteralExpression(spec.contract.methods.map((meth) => {
const [key, value] = generateComposeMethodImpl(meth, spec);
return factory.createPropertyAssignment(key, value);
}), true));

@@ -182,57 +141,56 @@ }

function generateMethodImpl(method, spec) {
var params = [];
var abiMethodArgs = [];
var argParams = [];
var hint = method.name in spec.hints ? spec.hints[method.name] : {};
for (var _i = 0, _a = method.args; _i < _a.length; _i++) {
var arg = _a[_i];
const params = [];
const abiMethodArgs = [];
const argParams = [];
const hint = method.name in spec.hints ? spec.hints[method.name] : {};
for (const arg of method.args) {
if (arg.name === undefined)
continue;
var argName = typescript_1.factory.createIdentifier(arg.name);
var argType = tsTypeFromAbiType(arg.type.toString());
const argName = factory.createIdentifier(arg.name);
let argType = tsTypeFromAbiType(arg.type.toString());
if (hint !== undefined &&
hint.structs !== undefined &&
arg.name in hint.structs) {
var structHint = hint.structs[arg.name];
const structHint = hint.structs[arg.name];
if (structHint !== undefined)
argType = typescript_1.factory.createTypeReferenceNode(structHint.name);
argType = factory.createTypeReferenceNode(structHint.name);
}
var defaultArg = (hint === null || hint === void 0 ? void 0 : hint.default_arguments) !== undefined &&
const defaultArg = hint?.default_arguments !== undefined &&
arg.name in hint.default_arguments
? hint.default_arguments[arg.name]
: undefined;
var argVal = typescript_1.factory.createIdentifier("args.".concat(arg.name));
let argVal = factory.createIdentifier(`args.${arg.name}`);
if (defaultArg !== undefined) {
var data = void 0;
let data;
if (typeof defaultArg.data == 'string') {
data = typescript_1.factory.createStringLiteral(defaultArg.data);
data = factory.createStringLiteral(defaultArg.data);
}
else if (typeof defaultArg.data == 'bigint') {
data = typescript_1.factory.createBigIntLiteral(defaultArg.data.toString());
data = factory.createBigIntLiteral(defaultArg.data.toString());
}
else if (typeof defaultArg.data == 'number') {
data = typescript_1.factory.createNumericLiteral(defaultArg.data);
data = factory.createNumericLiteral(defaultArg.data);
}
else {
data = typescript_1.factory.createIdentifier('undefined');
data = factory.createIdentifier('undefined');
}
argVal = typescript_1.factory.createConditionalExpression(typescript_1.factory.createBinaryExpression(argVal, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.EqualsEqualsEqualsToken), typescript_1.factory.createIdentifier('undefined')), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), typescript_1.factory.createAsExpression(typescript_1.factory.createAwaitExpression(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('this.resolve'), undefined, [typescript_1.factory.createStringLiteral(defaultArg.source), data])), argType), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.ColonToken), argVal);
argVal = factory.createConditionalExpression(factory.createBinaryExpression(argVal, factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken), factory.createIdentifier('undefined')), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createAsExpression(factory.createAwaitExpression(factory.createCallExpression(factory.createIdentifier('this.resolve'), undefined, [factory.createStringLiteral(defaultArg.source), data])), argType), factory.createToken(ts.SyntaxKind.ColonToken), argVal);
}
abiMethodArgs.push(typescript_1.factory.createPropertyAssignment(argName, argVal));
var optional = defaultArg !== undefined
? typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken)
abiMethodArgs.push(factory.createPropertyAssignment(argName, argVal));
const optional = defaultArg !== undefined
? factory.createToken(ts.SyntaxKind.QuestionToken)
: undefined;
//factory.createPropertyDeclaration
argParams.push(typescript_1.factory.createPropertySignature(undefined, arg.name, optional, argType));
argParams.push(factory.createPropertySignature(undefined, arg.name, optional, argType));
}
// Expect args
if (argParams.length > 0) {
params.push(typescript_1.factory.createParameterDeclaration(undefined, undefined, undefined, typescript_1.factory.createIdentifier('args'), undefined, typescript_1.factory.createTypeLiteralNode(argParams)));
params.push(factory.createParameterDeclaration(undefined, undefined, undefined, factory.createIdentifier('args'), undefined, factory.createTypeLiteralNode(argParams)));
}
// Any tx overrides
var txnParams = typescript_1.factory.createIdentifier('txnParams');
params.push(typescript_1.factory.createParameterDeclaration(undefined, undefined, undefined, txnParams, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), TRANSACTION_OVERRIDES_TYPE));
const txnParams = factory.createIdentifier('txnParams');
params.push(factory.createParameterDeclaration(undefined, undefined, undefined, txnParams, factory.createToken(ts.SyntaxKind.QuestionToken), TRANSACTION_OVERRIDES_TYPE));
// Set up return type
var abiRetType = typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.VoidKeyword);
var resultArgs = [typescript_1.factory.createIdentifier('result')];
let abiRetType = factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword);
const resultArgs = [factory.createIdentifier('result')];
if (method.returns.type.toString() !== 'void') {

@@ -243,9 +201,9 @@ abiRetType = tsTypeFromAbiType(method.returns.type.toString());

if (hint !== undefined &&
(hint === null || hint === void 0 ? void 0 : hint.structs) !== undefined &&
hint?.structs !== undefined &&
'output' in hint.structs) {
var outputHint = hint.structs['output'];
const outputHint = hint.structs['output'];
if (outputHint !== undefined) {
abiRetType = typescript_1.factory.createTypeReferenceNode(outputHint === null || outputHint === void 0 ? void 0 : outputHint.name);
resultArgs.push(typescript_1.factory.createCallExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier(outputHint.name), typescript_1.factory.createIdentifier('decodeResult')), undefined, [
typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('result'), typescript_1.factory.createIdentifier('returnValue')),
abiRetType = factory.createTypeReferenceNode(outputHint?.name);
resultArgs.push(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier(outputHint.name), factory.createIdentifier('decodeResult')), undefined, [
factory.createPropertyAccessExpression(factory.createIdentifier('result'), factory.createIdentifier('returnValue')),
]));

@@ -255,19 +213,19 @@ }

else {
resultArgs.push(typescript_1.factory.createAsExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('result'), typescript_1.factory.createIdentifier('returnValue')), abiRetType));
resultArgs.push(factory.createAsExpression(factory.createPropertyAccessExpression(factory.createIdentifier('result'), factory.createIdentifier('returnValue')), abiRetType));
}
}
var composeArgs = [];
const composeArgs = [];
if (argParams.length > 0) {
composeArgs.push(typescript_1.factory.createObjectLiteralExpression(abiMethodArgs));
composeArgs.push(factory.createObjectLiteralExpression(abiMethodArgs));
}
composeArgs.push(txnParams);
var composeExpr = typescript_1.factory.createAwaitExpression(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('this.compose.' + method.name), undefined, composeArgs));
var body = typescript_1.factory.createBlock([
typescript_1.factory.createVariableStatement(undefined, typescript_1.factory.createVariableDeclarationList([
typescript_1.factory.createVariableDeclaration(typescript_1.factory.createIdentifier('result'), undefined, undefined, typescript_1.factory.createAwaitExpression(typescript_1.factory.createCallExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createThis(), typescript_1.factory.createIdentifier('execute')), undefined, [composeExpr]))),
], typescript_1.default.NodeFlags.Const)),
typescript_1.factory.createReturnStatement(typescript_1.factory.createNewExpression(ABI_RESULT_IDENT, [abiRetType], resultArgs)),
const composeExpr = factory.createAwaitExpression(factory.createCallExpression(factory.createIdentifier('this.compose.' + method.name), undefined, composeArgs));
const body = factory.createBlock([
factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
factory.createVariableDeclaration(factory.createIdentifier('result'), undefined, undefined, factory.createAwaitExpression(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier('execute')), undefined, [composeExpr]))),
], ts.NodeFlags.Const)),
factory.createReturnStatement(factory.createNewExpression(ABI_RESULT_IDENT, [abiRetType], resultArgs)),
], true);
var retType = typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier('Promise'), [typescript_1.factory.createTypeReferenceNode(ABI_RESULT_IDENT, [abiRetType])]);
var methodSpec = typescript_1.factory.createMethodDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.AsyncKeyword)], undefined, method.name, undefined, undefined, params, retType, body);
const retType = factory.createTypeReferenceNode(factory.createIdentifier('Promise'), [factory.createTypeReferenceNode(ABI_RESULT_IDENT, [abiRetType])]);
const methodSpec = factory.createMethodDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.AsyncKeyword)], undefined, method.name, undefined, undefined, params, retType, body);
return methodSpec;

@@ -278,102 +236,100 @@ }

function generateComposeMethodImpl(method, spec) {
var params = [];
var callArgs = [];
var abiMethodArgs = [];
var argParams = [];
var hint = method.name in spec.hints ? spec.hints[method.name] : {};
callArgs.push(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('algosdk.getMethodByName'), undefined, [
typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createThis(), typescript_1.factory.createIdentifier('methods')),
typescript_1.factory.createStringLiteral(method.name),
const params = [];
const callArgs = [];
const abiMethodArgs = [];
const argParams = [];
const hint = method.name in spec.hints ? spec.hints[method.name] : {};
callArgs.push(factory.createCallExpression(factory.createIdentifier('algosdk.getMethodByName'), undefined, [
factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier('methods')),
factory.createStringLiteral(method.name),
]));
for (var _i = 0, _a = method.args; _i < _a.length; _i++) {
var arg = _a[_i];
for (const arg of method.args) {
if (arg.name === undefined) {
continue;
}
var argName = typescript_1.factory.createIdentifier(arg.name);
var argType = tsTypeFromAbiType(arg.type.toString());
const argName = factory.createIdentifier(arg.name);
let argType = tsTypeFromAbiType(arg.type.toString());
if (hint !== undefined &&
hint.structs !== undefined &&
arg.name in hint.structs) {
var structHint = hint.structs[arg.name];
const structHint = hint.structs[arg.name];
if (structHint !== undefined)
argType = typescript_1.factory.createTypeReferenceNode(structHint.name);
argType = factory.createTypeReferenceNode(structHint.name);
}
var defaultArg = (hint === null || hint === void 0 ? void 0 : hint.default_arguments) !== undefined &&
const defaultArg = hint?.default_arguments !== undefined &&
arg.name in hint.default_arguments
? hint.default_arguments[arg.name]
: undefined;
var argVal = typescript_1.factory.createIdentifier("args.".concat(arg.name));
let argVal = factory.createIdentifier(`args.${arg.name}`);
if (defaultArg !== undefined) {
var data = void 0;
let data;
if (typeof defaultArg.data == 'string') {
data = typescript_1.factory.createStringLiteral(defaultArg.data);
data = factory.createStringLiteral(defaultArg.data);
}
else if (typeof defaultArg.data == 'bigint') {
data = typescript_1.factory.createBigIntLiteral(defaultArg.data.toString());
data = factory.createBigIntLiteral(defaultArg.data.toString());
}
else if (typeof defaultArg.data == 'number') {
data = typescript_1.factory.createNumericLiteral(defaultArg.data);
data = factory.createNumericLiteral(defaultArg.data);
}
else {
data = typescript_1.factory.createIdentifier('undefined');
data = factory.createIdentifier('undefined');
}
argVal = typescript_1.factory.createConditionalExpression(typescript_1.factory.createBinaryExpression(argVal, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.EqualsEqualsEqualsToken), typescript_1.factory.createIdentifier('undefined')), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), typescript_1.factory.createAwaitExpression(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('this.resolve'), undefined, [typescript_1.factory.createStringLiteral(defaultArg.source), data])), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.ColonToken), argVal);
argVal = factory.createConditionalExpression(factory.createBinaryExpression(argVal, factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken), factory.createIdentifier('undefined')), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createAwaitExpression(factory.createCallExpression(factory.createIdentifier('this.resolve'), undefined, [factory.createStringLiteral(defaultArg.source), data])), factory.createToken(ts.SyntaxKind.ColonToken), argVal);
}
abiMethodArgs.push(typescript_1.factory.createPropertyAssignment(argName, argVal));
var optional = defaultArg !== undefined
? typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken)
abiMethodArgs.push(factory.createPropertyAssignment(argName, argVal));
const optional = defaultArg !== undefined
? factory.createToken(ts.SyntaxKind.QuestionToken)
: undefined;
argParams.push(typescript_1.factory.createPropertySignature(undefined, arg.name, optional, argType));
argParams.push(factory.createPropertySignature(undefined, arg.name, optional, argType));
}
// Expect args
if (argParams.length > 0) {
params.push(typescript_1.factory.createParameterDeclaration(undefined, undefined, undefined, typescript_1.factory.createIdentifier('args'), undefined, typescript_1.factory.createTypeLiteralNode(argParams)));
params.push(factory.createParameterDeclaration(undefined, undefined, undefined, factory.createIdentifier('args'), undefined, factory.createTypeLiteralNode(argParams)));
}
var txnParams = typescript_1.factory.createIdentifier('txnParams');
params.push(typescript_1.factory.createParameterDeclaration(undefined, undefined, undefined, txnParams, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), TRANSACTION_OVERRIDES_TYPE));
var atcParam = typescript_1.factory.createIdentifier('atc');
params.push(typescript_1.factory.createParameterDeclaration(undefined, undefined, undefined, atcParam, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), ATC_TYPE));
var body = typescript_1.factory.createBlock([
typescript_1.factory.createReturnStatement(typescript_1.factory.createCallExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createThis(), typescript_1.factory.createIdentifier('addMethodCall')), undefined, __spreadArray(__spreadArray([], callArgs, true), [
typescript_1.factory.createObjectLiteralExpression(abiMethodArgs),
const txnParams = factory.createIdentifier('txnParams');
params.push(factory.createParameterDeclaration(undefined, undefined, undefined, txnParams, factory.createToken(ts.SyntaxKind.QuestionToken), TRANSACTION_OVERRIDES_TYPE));
const atcParam = factory.createIdentifier('atc');
params.push(factory.createParameterDeclaration(undefined, undefined, undefined, atcParam, factory.createToken(ts.SyntaxKind.QuestionToken), ATC_TYPE));
const body = factory.createBlock([
factory.createReturnStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier('addMethodCall')), undefined, [
...callArgs,
factory.createObjectLiteralExpression(abiMethodArgs),
txnParams,
atcParam,
], false))),
])),
], true);
var retType = typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier('Promise'), [typescript_1.factory.createTypeReferenceNode(ATC_IDENT)]);
var fncSpec = typescript_1.factory.createArrowFunction([typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.AsyncKeyword)], undefined, params, retType, undefined, body);
const retType = factory.createTypeReferenceNode(factory.createIdentifier('Promise'), [factory.createTypeReferenceNode(ATC_IDENT)]);
const fncSpec = factory.createArrowFunction([factory.createModifier(ts.SyntaxKind.AsyncKeyword)], undefined, params, retType, undefined, body);
return [method.name, fncSpec];
}
function copySchemaObject(so) {
var declaredAppSchemaProps = Object.entries(so.declared).map(function (sv) {
return typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier(sv[0]), typescript_1.factory.createObjectLiteralExpression([
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('type'), typescript_1.factory.createIdentifier("bkr.AVMType.".concat(sv[1].type))),
const declaredAppSchemaProps = Object.entries(so.declared).map((sv) => {
return factory.createPropertyAssignment(factory.createIdentifier(sv[0]), factory.createObjectLiteralExpression([
factory.createPropertyAssignment(factory.createIdentifier('type'), factory.createIdentifier(`bkr.AVMType.${sv[1].type}`)),
objStrProperty('key', sv[1].key),
objStrProperty('desc', sv[1].desc),
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('static'), sv[1].static ? typescript_1.factory.createTrue() : typescript_1.factory.createFalse()),
factory.createPropertyAssignment(factory.createIdentifier('static'), sv[1].static ? factory.createTrue() : factory.createFalse()),
]));
});
var dynamicAppSchemaProps = Object.entries(so.dynamic).map(function (sv) {
return typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier(sv[0]), typescript_1.factory.createObjectLiteralExpression([
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('type'), typescript_1.factory.createIdentifier("bkr.AVMType.".concat(sv[1].type.toString()))),
const dynamicAppSchemaProps = Object.entries(so.dynamic).map((sv) => {
return factory.createPropertyAssignment(factory.createIdentifier(sv[0]), factory.createObjectLiteralExpression([
factory.createPropertyAssignment(factory.createIdentifier('type'), factory.createIdentifier(`bkr.AVMType.${sv[1].type.toString()}`)),
objStrProperty('desc', sv[1].desc),
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('max_keys'), typescript_1.factory.createNumericLiteral(sv[1].max_keys ? sv[1].max_keys : 0)),
factory.createPropertyAssignment(factory.createIdentifier('max_keys'), factory.createNumericLiteral(sv[1].max_keys ? sv[1].max_keys : 0)),
]));
});
return typescript_1.factory.createObjectLiteralExpression([
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('declared'), typescript_1.factory.createObjectLiteralExpression(declaredAppSchemaProps)),
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('dynamic'), typescript_1.factory.createObjectLiteralExpression(dynamicAppSchemaProps)),
return factory.createObjectLiteralExpression([
factory.createPropertyAssignment(factory.createIdentifier('declared'), factory.createObjectLiteralExpression(declaredAppSchemaProps)),
factory.createPropertyAssignment(factory.createIdentifier('dynamic'), factory.createObjectLiteralExpression(dynamicAppSchemaProps)),
]);
}
function generateStructTypes(spec) {
var hints = spec.hints;
var structs = {};
for (var _i = 0, _a = Object.keys(hints); _i < _a.length; _i++) {
var k = _a[_i];
var hint = hints[k];
const hints = spec.hints;
const structs = {};
for (const k of Object.keys(hints)) {
const hint = hints[k];
if (hint !== undefined && hint.structs !== undefined) {
for (var _b = 0, _c = Object.keys(hint.structs); _b < _c.length; _b++) {
var sk = _c[_b];
var struct = hint.structs[sk];
for (const sk of Object.keys(hint.structs)) {
const struct = hint.structs[sk];
if (struct !== undefined && !(struct.name in struct)) {

@@ -388,72 +344,70 @@ structs[struct.name] = generateStruct(struct);

function generateStruct(s) {
var members = [];
var tupleTypes = [];
var tupleNames = [];
for (var _i = 0, _a = s.elements; _i < _a.length; _i++) {
var elem = _a[_i];
const members = [];
const tupleTypes = [];
const tupleNames = [];
for (const elem of s.elements) {
tupleNames.push(elem[0]);
tupleTypes.push(elem[1]);
var tsType = tsTypeFromAbiType(elem[1]);
members.push(typescript_1.factory.createPropertyDeclaration(undefined, undefined, typescript_1.factory.createIdentifier(elem[0]), undefined, tsType, defaultValueFromTsType(tsType)));
const tsType = tsTypeFromAbiType(elem[1]);
members.push(factory.createPropertyDeclaration(undefined, undefined, factory.createIdentifier(elem[0]), undefined, tsType, defaultValueFromTsType(tsType)));
}
members.push(typescript_1.factory.createPropertyDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.StaticKeyword)], typescript_1.factory.createIdentifier('codec'), undefined, typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createQualifiedName(typescript_1.factory.createIdentifier('algosdk'), typescript_1.factory.createIdentifier('ABIType')), undefined), typescript_1.factory.createCallExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier('algosdk'), typescript_1.factory.createIdentifier('ABIType')), typescript_1.factory.createIdentifier('from')), undefined, [typescript_1.factory.createStringLiteral("(".concat(tupleTypes.join(','), ")"))])));
members.push(typescript_1.factory.createPropertyDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.StaticKeyword)], typescript_1.factory.createIdentifier('fields'), undefined, typescript_1.factory.createTypeReferenceNode('string[]'), typescript_1.factory.createArrayLiteralExpression(tupleNames.map(function (name) {
return typescript_1.factory.createStringLiteral(name);
members.push(factory.createPropertyDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.StaticKeyword)], factory.createIdentifier('codec'), undefined, factory.createTypeReferenceNode(factory.createQualifiedName(factory.createIdentifier('algosdk'), factory.createIdentifier('ABIType')), undefined), factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('algosdk'), factory.createIdentifier('ABIType')), factory.createIdentifier('from')), undefined, [factory.createStringLiteral(`(${tupleTypes.join(',')})`)])));
members.push(factory.createPropertyDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.StaticKeyword)], factory.createIdentifier('fields'), undefined, factory.createTypeReferenceNode('string[]'), factory.createArrayLiteralExpression(tupleNames.map((name) => {
return factory.createStringLiteral(name);
}))));
members.push(
// Add static `decodeResult(val: ABIValue): <T>` method
typescript_1.factory.createMethodDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.StaticKeyword)], undefined, typescript_1.factory.createIdentifier('decodeResult'), undefined, undefined, [
typescript_1.factory.createParameterDeclaration(undefined, undefined, undefined, typescript_1.factory.createIdentifier('val'), undefined, typescript_1.factory.createUnionTypeNode([
typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createQualifiedName(typescript_1.factory.createIdentifier('algosdk'), typescript_1.factory.createIdentifier('ABIValue')), undefined),
typescript_1.factory.createTypeReferenceNode('undefined'),
factory.createMethodDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.StaticKeyword)], undefined, factory.createIdentifier('decodeResult'), undefined, undefined, [
factory.createParameterDeclaration(undefined, undefined, undefined, factory.createIdentifier('val'), undefined, factory.createUnionTypeNode([
factory.createTypeReferenceNode(factory.createQualifiedName(factory.createIdentifier('algosdk'), factory.createIdentifier('ABIValue')), undefined),
factory.createTypeReferenceNode('undefined'),
]), undefined),
], typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier(s.name), undefined), typescript_1.factory.createBlock([
typescript_1.factory.createReturnStatement(typescript_1.factory.createAsExpression(typescript_1.factory.createCallExpression(DECODE_NAMED_TUPLE_IDENT, undefined, [
typescript_1.factory.createIdentifier('val'),
typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier(s.name), typescript_1.factory.createIdentifier('fields')),
]), typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier(s.name), undefined))),
], factory.createTypeReferenceNode(factory.createIdentifier(s.name), undefined), factory.createBlock([
factory.createReturnStatement(factory.createAsExpression(factory.createCallExpression(DECODE_NAMED_TUPLE_IDENT, undefined, [
factory.createIdentifier('val'),
factory.createPropertyAccessExpression(factory.createIdentifier(s.name), factory.createIdentifier('fields')),
]), factory.createTypeReferenceNode(factory.createIdentifier(s.name), undefined))),
], true)));
members.push(typescript_1.factory.createMethodDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.StaticKeyword)], undefined, typescript_1.factory.createIdentifier('decodeBytes'), undefined, undefined, [
typescript_1.factory.createParameterDeclaration(undefined, undefined, undefined, typescript_1.factory.createIdentifier('val'), undefined, UINT8_ARRAY_TYPE, undefined),
], typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier(s.name), undefined), typescript_1.factory.createBlock([
typescript_1.factory.createReturnStatement(typescript_1.factory.createAsExpression(typescript_1.factory.createCallExpression(DECODE_NAMED_TUPLE_IDENT, undefined, [
typescript_1.factory.createCallExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier(s.name), typescript_1.factory.createIdentifier('codec')), typescript_1.factory.createIdentifier('decode')), undefined, [typescript_1.factory.createIdentifier('val')]),
typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier(s.name), typescript_1.factory.createIdentifier('fields')),
]), typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier(s.name), undefined))),
members.push(factory.createMethodDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.StaticKeyword)], undefined, factory.createIdentifier('decodeBytes'), undefined, undefined, [
factory.createParameterDeclaration(undefined, undefined, undefined, factory.createIdentifier('val'), undefined, UINT8_ARRAY_TYPE, undefined),
], factory.createTypeReferenceNode(factory.createIdentifier(s.name), undefined), factory.createBlock([
factory.createReturnStatement(factory.createAsExpression(factory.createCallExpression(DECODE_NAMED_TUPLE_IDENT, undefined, [
factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier(s.name), factory.createIdentifier('codec')), factory.createIdentifier('decode')), undefined, [factory.createIdentifier('val')]),
factory.createPropertyAccessExpression(factory.createIdentifier(s.name), factory.createIdentifier('fields')),
]), factory.createTypeReferenceNode(factory.createIdentifier(s.name), undefined))),
], true)));
return typescript_1.factory.createClassDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.ExportKeyword)], typescript_1.factory.createIdentifier(s.name), undefined, undefined, members);
return factory.createClassDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier(s.name), undefined, undefined, members);
}
function generateContractProperties(spec) {
var descr = spec.contract.description;
var methods = spec.contract.methods;
var source = spec.source;
var schema = spec.schema;
const descr = spec.contract.description;
const methods = spec.contract.methods;
const source = spec.source;
const schema = spec.schema;
// create desc property
var descrProp = typescript_1.factory.createPropertyDeclaration(undefined, undefined, typescript_1.factory.createIdentifier('desc'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.StringKeyword), typescript_1.factory.createStringLiteral(descr ? descr : ''));
const descrProp = factory.createPropertyDeclaration(undefined, undefined, factory.createIdentifier('desc'), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), factory.createStringLiteral(descr ? descr : ''));
// Create approval program property
var approvalProp;
let approvalProp;
if (source.approval !== undefined) {
approvalProp = typescript_1.factory.createPropertyDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.OverrideKeyword)], typescript_1.factory.createIdentifier('approvalProgram'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.StringKeyword), typescript_1.factory.createStringLiteral(source.approval));
approvalProp = factory.createPropertyDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.OverrideKeyword)], factory.createIdentifier('approvalProgram'), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), factory.createStringLiteral(source.approval));
}
// Create clear program property
var clearProp;
let clearProp;
if (source.clear !== undefined) {
clearProp = typescript_1.factory.createPropertyDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.OverrideKeyword)], typescript_1.factory.createIdentifier('clearProgram'), undefined, typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.StringKeyword), typescript_1.factory.createStringLiteral(source.clear));
clearProp = factory.createPropertyDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.OverrideKeyword)], factory.createIdentifier('clearProgram'), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), factory.createStringLiteral(source.clear));
}
// Create App Schema Property
var appSchemaProp;
let appSchemaProp;
if (schema.global !== undefined) {
appSchemaProp = typescript_1.factory.createPropertyDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.OverrideKeyword)], typescript_1.factory.createIdentifier('appSchema'), undefined, SCHEMA_TYPE, copySchemaObject(schema.global));
appSchemaProp = factory.createPropertyDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.OverrideKeyword)], factory.createIdentifier('appSchema'), undefined, SCHEMA_TYPE, copySchemaObject(schema.global));
}
// Create Acct schema property
var acctSchemaProp;
let acctSchemaProp;
if (schema.local !== undefined) {
acctSchemaProp = typescript_1.factory.createPropertyDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.OverrideKeyword)], typescript_1.factory.createIdentifier('acctSchema'), undefined, SCHEMA_TYPE, copySchemaObject(schema.local));
acctSchemaProp = factory.createPropertyDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.OverrideKeyword)], factory.createIdentifier('acctSchema'), undefined, SCHEMA_TYPE, copySchemaObject(schema.local));
}
// Add methods
var methodAssignments = [];
for (var _i = 0, methods_1 = methods; _i < methods_1.length; _i++) {
var meth = methods_1[_i];
var argObjs = meth.args.map(function (arg) {
return typescript_1.factory.createObjectLiteralExpression([
const methodAssignments = [];
for (const meth of methods) {
const argObjs = meth.args.map((arg) => {
return factory.createObjectLiteralExpression([
objStrProperty('type', arg.type.toString()),

@@ -464,3 +418,3 @@ objStrProperty('name', arg.name),

});
var returnObj = typescript_1.factory.createObjectLiteralExpression([
const returnObj = factory.createObjectLiteralExpression([
objStrProperty('type', meth.returns.type.toString()),

@@ -470,8 +424,8 @@ objStrProperty('desc', meth.returns.description),

// Create ABIMethod object
methodAssignments.push(typescript_1.factory.createNewExpression(ABI_METHOD_IDENT, undefined, [
typescript_1.factory.createObjectLiteralExpression([
methodAssignments.push(factory.createNewExpression(ABI_METHOD_IDENT, undefined, [
factory.createObjectLiteralExpression([
objStrProperty('name', meth.name),
objStrProperty('desc', meth.description),
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('args'), typescript_1.factory.createArrayLiteralExpression(argObjs)),
typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('returns'), returnObj),
factory.createPropertyAssignment(factory.createIdentifier('args'), factory.createArrayLiteralExpression(argObjs)),
factory.createPropertyAssignment(factory.createIdentifier('returns'), returnObj),
]),

@@ -481,4 +435,4 @@ ]));

// create methods property
var methodProps = typescript_1.factory.createPropertyDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.default.SyntaxKind.OverrideKeyword)], typescript_1.factory.createIdentifier('methods'), undefined, typescript_1.factory.createArrayTypeNode(ABI_METHOD_TYPE), typescript_1.factory.createArrayLiteralExpression(methodAssignments, true));
var props = [descrProp];
const methodProps = factory.createPropertyDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.OverrideKeyword)], factory.createIdentifier('methods'), undefined, factory.createArrayTypeNode(ABI_METHOD_TYPE), factory.createArrayLiteralExpression(methodAssignments, true));
const props = [descrProp];
if (appSchemaProp !== undefined)

@@ -496,4 +450,5 @@ props.push(appSchemaProp);

function objStrProperty(k, v) {
var val = v === undefined ? '' : v;
return typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier(k), typescript_1.factory.createStringLiteral(val));
const val = v === undefined ? '' : v;
return factory.createPropertyAssignment(factory.createIdentifier(k), factory.createStringLiteral(val));
}
//# sourceMappingURL=generate.js.map

@@ -1,5 +0,4 @@

export { ApplicationClient, ABIResult, MethodArg, MethodArgs, decodeNamedTuple, TransactionOverrides, } from './application_client/application_client';
export { LogicError, parseLogicError } from './application_client/logic_error';
export { generateApplicationClient } from './generate/generate';
export { HintSpec, DeclaredSchemaValueSpec, DynamicSchemaValueSpec, Schema, StateSchema, SchemaSpec, AppSources, AppSpec, AVMType, getStateSchema, } from './generate/appspec';
export * from './application_client';
export * from './generate';
export * as web from './web';
export * as sandbox from './sandbox';

@@ -1,39 +0,5 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sandbox = exports.getStateSchema = exports.AVMType = exports.generateApplicationClient = exports.parseLogicError = exports.LogicError = exports.decodeNamedTuple = exports.ABIResult = exports.ApplicationClient = void 0;
var application_client_1 = require("./application_client/application_client");
Object.defineProperty(exports, "ApplicationClient", { enumerable: true, get: function () { return application_client_1.ApplicationClient; } });
Object.defineProperty(exports, "ABIResult", { enumerable: true, get: function () { return application_client_1.ABIResult; } });
Object.defineProperty(exports, "decodeNamedTuple", { enumerable: true, get: function () { return application_client_1.decodeNamedTuple; } });
var logic_error_1 = require("./application_client/logic_error");
Object.defineProperty(exports, "LogicError", { enumerable: true, get: function () { return logic_error_1.LogicError; } });
Object.defineProperty(exports, "parseLogicError", { enumerable: true, get: function () { return logic_error_1.parseLogicError; } });
var generate_1 = require("./generate/generate");
Object.defineProperty(exports, "generateApplicationClient", { enumerable: true, get: function () { return generate_1.generateApplicationClient; } });
var appspec_1 = require("./generate/appspec");
Object.defineProperty(exports, "AVMType", { enumerable: true, get: function () { return appspec_1.AVMType; } });
Object.defineProperty(exports, "getStateSchema", { enumerable: true, get: function () { return appspec_1.getStateSchema; } });
exports.sandbox = __importStar(require("./sandbox"));
export * from './application_client';
export * from './generate';
export * as web from './web';
export * as sandbox from './sandbox';
//# sourceMappingURL=index.js.map

@@ -8,2 +8,10 @@ /// <reference types="node" />

};
export declare function getAccounts(): Promise<SandboxAccount[]>;
export declare type KMDConfig = {
host: string;
port: string;
token: string;
wallet: string;
password: string;
};
export declare const DefaultKMDConfig: KMDConfig;
export declare function getAccounts(config?: KMDConfig): Promise<SandboxAccount[]>;

@@ -1,97 +0,45 @@

"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());
});
import algosdk from 'algosdk';
const kmd_token = 'a'.repeat(64);
const kmd_host = 'http://localhost';
const kmd_port = '4002';
const kmd_wallet = 'unencrypted-default-wallet';
const kmd_password = '';
export const DefaultKMDConfig = {
host: kmd_host,
token: kmd_token,
port: kmd_port,
wallet: kmd_wallet,
password: kmd_password,
};
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 };
export async function getAccounts(config = DefaultKMDConfig) {
const kmdClient = new algosdk.Kmd(config.token, config.host, config.port);
const wallets = await kmdClient.listWallets();
let walletId;
for (const wallet of wallets['wallets']) {
if (wallet['name'] === config.wallet)
walletId = wallet['id'];
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccounts = void 0;
var algosdk_1 = __importDefault(require("algosdk"));
var kmd_token = 'a'.repeat(64);
var kmd_host = 'http://localhost';
var kmd_port = '4002';
var kmd_wallet = 'unencrypted-default-wallet';
var kmd_password = '';
function getAccounts() {
return __awaiter(this, void 0, void 0, function () {
var kmdClient, wallets, walletId, _i, _a, wallet, handleResp, handle, addresses, acctPromises, _b, _c, addr, keys;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
kmdClient = new algosdk_1.default.Kmd(kmd_token, kmd_host, kmd_port);
return [4 /*yield*/, kmdClient.listWallets()];
case 1:
wallets = _d.sent();
for (_i = 0, _a = wallets['wallets']; _i < _a.length; _i++) {
wallet = _a[_i];
if (wallet['name'] === kmd_wallet)
walletId = wallet['id'];
}
if (walletId === undefined)
throw Error('No wallet named: ' + kmd_wallet);
return [4 /*yield*/, kmdClient.initWalletHandle(walletId, kmd_password)];
case 2:
handleResp = _d.sent();
handle = handleResp['wallet_handle_token'];
return [4 /*yield*/, kmdClient.listKeys(handle)];
case 3:
addresses = _d.sent();
acctPromises = [];
for (_b = 0, _c = addresses['addresses']; _b < _c.length; _b++) {
addr = _c[_b];
acctPromises.push(kmdClient.exportKey(handle, kmd_password, addr));
}
return [4 /*yield*/, Promise.all(acctPromises)];
case 4:
keys = _d.sent();
// Don't need to wait for it
kmdClient.releaseWalletHandle(handle);
return [2 /*return*/, keys.map(function (k) {
var addr = algosdk_1.default.encodeAddress(k.private_key.slice(32));
var acct = { sk: k.private_key, addr: addr };
var signer = algosdk_1.default.makeBasicAccountTransactionSigner(acct);
return {
addr: acct.addr,
privateKey: acct.sk,
signer: signer,
};
})];
}
});
if (walletId === undefined)
throw Error('No wallet named: ' + config.wallet);
const handleResp = await kmdClient.initWalletHandle(walletId, config.password);
const handle = handleResp['wallet_handle_token'];
const addresses = await kmdClient.listKeys(handle);
const acctPromises = [];
for (const addr of addresses['addresses']) {
acctPromises.push(kmdClient.exportKey(handle, config.password, addr));
}
const keys = await Promise.all(acctPromises);
// Don't need to wait for it
kmdClient.releaseWalletHandle(handle);
return keys.map((k) => {
const addr = algosdk.encodeAddress(k.private_key.slice(32));
const acct = { sk: k.private_key, addr: addr };
const signer = algosdk.makeBasicAccountTransactionSigner(acct);
return {
addr: acct.addr,
privateKey: acct.sk,
signer: signer,
};
});
}
exports.getAccounts = getAccounts;
//# sourceMappingURL=accounts.js.map

@@ -1,15 +0,8 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIndexerClient = exports.getAlgodClient = void 0;
var algosdk_1 = __importDefault(require("algosdk"));
function getAlgodClient() {
return new algosdk_1.default.Algodv2('a'.repeat(64), 'http://localhost', 4001);
import algosdk from 'algosdk';
export function getAlgodClient() {
return new algosdk.Algodv2('a'.repeat(64), 'http://localhost', 4001);
}
exports.getAlgodClient = getAlgodClient;
function getIndexerClient() {
return new algosdk_1.default.Indexer('a'.repeat(64), 'http://localhost', 8980);
export function getIndexerClient() {
return new algosdk.Indexer('a'.repeat(64), 'http://localhost', 8980);
}
exports.getIndexerClient = getIndexerClient;
//# sourceMappingURL=clients.js.map

@@ -1,8 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccounts = exports.getIndexerClient = exports.getAlgodClient = void 0;
var clients_1 = require("./clients");
Object.defineProperty(exports, "getAlgodClient", { enumerable: true, get: function () { return clients_1.getAlgodClient; } });
Object.defineProperty(exports, "getIndexerClient", { enumerable: true, get: function () { return clients_1.getIndexerClient; } });
var accounts_1 = require("./accounts");
Object.defineProperty(exports, "getAccounts", { enumerable: true, get: function () { return accounts_1.getAccounts; } });
export { getAlgodClient, getIndexerClient } from './clients';
export { getAccounts } from './accounts';
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

export { Wallet, SignedTxn } from './wallets/wallet';
export { Wallet } from './wallets/wallet';
export { SessionWallet, ImplementedWallets } from './session_wallet';

@@ -1,9 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImplementedWallets = exports.SessionWallet = exports.Wallet = void 0;
var wallet_1 = require("./wallets/wallet");
Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return wallet_1.Wallet; } });
var session_wallet_1 = require("./session_wallet");
Object.defineProperty(exports, "SessionWallet", { enumerable: true, get: function () { return session_wallet_1.SessionWallet; } });
Object.defineProperty(exports, "ImplementedWallets", { enumerable: true, get: function () { return session_wallet_1.ImplementedWallets; } });
export { Wallet } from './wallets/wallet';
export { SessionWallet, ImplementedWallets } from './session_wallet';
//# sourceMappingURL=index.js.map

@@ -1,28 +0,13 @@

"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());
});
import AlgoSignerWallet from './wallets/algosigner';
import MyAlgoConnectWallet from './wallets/myalgoconnect';
import InsecureWallet from './wallets/insecure';
import WC from './wallets/walletconnect';
import { KMDWallet } from './wallets/kmd';
export const ImplementedWallets = {
'wallet-connect': WC,
'algo-signer': AlgoSignerWallet,
'my-algo-connect': MyAlgoConnectWallet,
'insecure-wallet': InsecureWallet,
'kmd-wallet': KMDWallet,
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionWallet = exports.ImplementedWallets = void 0;
const algosigner_1 = __importDefault(require("./wallets/algosigner"));
const myalgoconnect_1 = __importDefault(require("./wallets/myalgoconnect"));
const insecure_1 = __importDefault(require("./wallets/insecure"));
const walletconnect_1 = __importDefault(require("./wallets/walletconnect"));
const kmd_1 = require("./wallets/kmd");
exports.ImplementedWallets = {
'wallet-connect': walletconnect_1.default,
'algo-signer': algosigner_1.default,
'my-algo-connect': myalgoconnect_1.default,
'insecure-wallet': insecure_1.default,
'kmd-wallet': kmd_1.KMDWallet,
};
const walletPreferenceKey = 'wallet-preference';

@@ -32,7 +17,10 @@ const acctListKey = 'acct-list';

const mnemonicKey = 'mnemonic';
class SessionWallet {
export class SessionWallet {
wallet;
wname;
network;
constructor(network, wname) {
this.wname = wname;
this.network = network;
const wtype = exports.ImplementedWallets[wname];
const wtype = ImplementedWallets[wname];
if (wtype === undefined)

@@ -45,39 +33,37 @@ throw new Error(`Unrecognized wallet option: ${wname}`);

}
connect() {
return __awaiter(this, void 0, void 0, function* () {
if (this.wallet === undefined)
return false;
switch (this.wname) {
case 'insecure-wallet':
const storedMnemonic = this.mnemonic();
const mnemonic = storedMnemonic
? storedMnemonic
: prompt('Paste your mnemonic space delimited (DO NOT USE WITH MAINNET ACCOUNTS)');
if (!mnemonic)
return false;
if (yield this.wallet.connect(mnemonic)) {
this.setMnemonic(mnemonic);
this.setAccountList(this.wallet.accounts);
this.wallet.defaultAccount = this.accountIndex();
return true;
}
break;
case 'wallet-connect':
yield this.wallet.connect((acctList) => {
this.setAccountList(acctList);
this.wallet.defaultAccount = this.accountIndex();
});
async connect() {
if (this.wallet === undefined)
return false;
switch (this.wname) {
case 'insecure-wallet':
const storedMnemonic = this.mnemonic();
const mnemonic = storedMnemonic
? storedMnemonic
: prompt('Paste your mnemonic space delimited (DO NOT USE WITH MAINNET ACCOUNTS)');
if (!mnemonic)
return false;
if (await this.wallet.connect(mnemonic)) {
this.setMnemonic(mnemonic);
this.setAccountList(this.wallet.accounts);
this.wallet.defaultAccount = this.accountIndex();
return true;
default:
if (yield this.wallet.connect()) {
this.setAccountList(this.wallet.accounts);
this.wallet.defaultAccount = this.accountIndex();
return true;
}
break;
}
// Fail
this.disconnect();
return false;
});
}
break;
case 'wallet-connect':
await this.wallet.connect((acctList) => {
this.setAccountList(acctList);
this.wallet.defaultAccount = this.accountIndex();
});
return true;
default:
if (await this.wallet.connect()) {
this.setAccountList(this.wallet.accounts);
this.wallet.defaultAccount = this.accountIndex();
return true;
}
break;
}
// Fail
this.disconnect();
return false;
}

@@ -141,11 +127,8 @@ connected() {

}
signTxn(txns) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.connected() && !(yield this.connect()))
return [];
return this.wallet.signTxns(txns);
});
async signTxn(txns) {
if (!this.connected() && !(await this.connect()))
return [];
return this.wallet.signTxns(txns);
}
}
exports.SessionWallet = SessionWallet;
//# sourceMappingURL=session_wallet.js.map

@@ -1,20 +0,6 @@

"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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const algosdk_1 = __importDefault(require("algosdk"));
const wallet_1 = require("./wallet");
import algosdk from 'algosdk';
import { Wallet } from './wallet';
const logoInverted = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAO4AAADuCAYAAAA+7jsiAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABB1SURBVHgB7d1/chNXtsDx091qZhw7Qaq897/CCpwdiBUEVjCeeiH/5rECzAoCf7yqV8AUygoCK4h2EG9gjObvUNUebDDBVt/p25aILLek/nG61er+fv4BG/BMKI7vPefee44IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5OQI0THDQ73ZuuT8akX0xpus4ztFlGL7uvRiPpCEIXDTK2YM7P05EniT9Wv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m960ZXF1ZTTfRXXVJUp1v5QN3npTaFkV9bAZXVzrIVl01JKnOt/KB6yMpRe22Og81XZJU51iTFZek8oP59PmPKDGf9FOBkySWe/FMb/fDfwsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADA+j9qvbJJRJoJawAAAABJRU5ErkJggg==';
class AlgoSignerWallet extends wallet_1.Wallet {
class AlgoSignerWallet extends Wallet {
constructor(network) {

@@ -35,61 +21,55 @@ super(network);

}
connect() {
return __awaiter(this, void 0, void 0, function* () {
if (this.isConnected())
async connect() {
if (this.isConnected())
return true;
const loaded = await this.waitForLoaded();
if (!loaded) {
return false;
}
try {
await AlgoSigner.connect();
}
catch (err) {
return false;
}
const accts = await AlgoSigner.accounts({ ledger: this.network });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.accounts = accts.map((a) => {
return a.address;
});
return true;
}
async waitForLoaded() {
for (let x = 0; x < 3; x++) {
if (typeof AlgoSigner !== 'undefined') {
return true;
const loaded = yield this.waitForLoaded();
if (!loaded) {
return false;
}
try {
yield AlgoSigner.connect();
}
catch (err) {
return false;
}
const accts = yield AlgoSigner.accounts({ ledger: this.network });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.accounts = accts.map((a) => {
return a.address;
await new Promise((r) => {
setTimeout(r, 1000);
});
return true;
});
}
return false;
}
waitForLoaded() {
return __awaiter(this, void 0, void 0, function* () {
for (let x = 0; x < 3; x++) {
if (typeof AlgoSigner !== 'undefined') {
return true;
}
yield new Promise((r) => {
setTimeout(r, 1000);
});
}
return false;
async signTxn(txns) {
const defaultAcct = this.getDefaultAccount();
const encodedTxns = txns.map((tx) => {
const t = {
txn: AlgoSigner.encoding.msgpackToBase64(tx.toByte()),
};
if (algosdk.encodeAddress(tx.from.publicKey) !== defaultAcct)
t.signers = [];
return t;
});
}
signTxn(txns) {
return __awaiter(this, void 0, void 0, function* () {
const defaultAcct = this.getDefaultAccount();
const encodedTxns = txns.map((tx) => {
const t = {
txn: AlgoSigner.encoding.msgpackToBase64(tx.toByte()),
const signed = await AlgoSigner.signTxn(encodedTxns);
return signed.map((signedTx) => {
if (signedTx)
return {
txID: signedTx.txID,
blob: AlgoSigner.encoding.base64ToMsgpack(signedTx.blob),
};
if (algosdk_1.default.encodeAddress(tx.from.publicKey) !== defaultAcct)
t.signers = [];
return t;
});
const signed = yield AlgoSigner.signTxn(encodedTxns);
return signed.map((signedTx) => {
if (signedTx)
return {
txID: signedTx.txID,
blob: AlgoSigner.encoding.base64ToMsgpack(signedTx.blob),
};
return {};
});
return {};
});
}
}
exports.default = AlgoSignerWallet;
export default AlgoSignerWallet;
//# sourceMappingURL=algosigner.js.map

@@ -1,19 +0,6 @@

"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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const wallet_1 = require("./wallet");
const algosdk_1 = __importDefault(require("algosdk"));
import { Wallet } from './wallet';
import algosdk from 'algosdk';
const logo = 'data:image/jpg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhITExMVFRUTFRUWGBcVEhcVFRgVIBUXGBUXFxcYHSggGBolHRcVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGxAQGjAmICYtMDAvLzMyLSswLy01LTU3LSstLS8tLS0vLTI3Ly8tMTUtLS8tLjAtLS0vLS0rLS8tL//AABEIAJkBSAMB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dqOCgG06qPyQ/wBnbr3TkGnZKP2t+iAxeK5cyYZcMOFBzaP/ALWg4zksjD7Ptjyo/D8l1Eh00FKNocMndaGVs2jI4yWj7198TYqyZ18FyOFcSDggg9iMFGtdrO0H2SAR2IB/qqTyaBwBMYvsS3+hVNZsCxfgmn58Pqbcc+P+SOR1pa10n/w0Of0T/wBTvzWWOTQNBIjFdyXf1KxLYOR1lH1+hJ51fc/v5nINJJwASewGSthwfJZHn2vYHnZ+H5rpIGgeyAAOwAH9FdI0NGRut+jYNceNstfDkvr+xhnnSf4VoYnC8uZCMtGXGi51n/0spntb9OyUZ1UU5PZ26q7rrhXHdgtEaUpOT1bBx00Pmm1uqyiMat1GR2k4CmRBzy2h0UhEDfdNjARk7qt0hFDogH4x2pTMQF9kxEOyqbITXdAMSE0eqk5mmwm9gAyNwoMcScHZANrtVH30h/s7de6cg02Eo/a36IAaNW/TshztND5okOnZONuoZKAGs1WVEyEUOiHvIOBsptjBGT1QAIQb7oVZlKSAvcwY2VDHEkAlWKIQE5GgDIpQiOTdqRSagHNW1JQ3nNochqAUpwapTiaCMm1FyYQFb3EEgK9rBgUqipBAVB57q97AAThVqRQEI3EkAqyUYFUohNyAjCc72nNWMUhqHIBwjIu1CU4OBSm1JyAnG0EAlUueQTasCiUBboHZUNeSRasUQgLJGgAkKqI5ODamUmoBzDAqkobzm03JNQCmONqU4hkXai5NqAhI4gkBWsYCAcKBTCAqLz3WQ5gwaVSkUBWxxJAKtlaAMilAKRQEYjk3ac1YxSGocgHDe9qMpwapNqHICUbQRk2qnuIJAKsCiUBa1gxskopoD//Z';
class InsecureWallet extends wallet_1.Wallet {
class InsecureWallet extends Wallet {
pkToSk;
constructor(network) {

@@ -23,10 +10,8 @@ super(network);

}
connect(mnemonic) {
return __awaiter(this, void 0, void 0, function* () {
const sk = algosdk_1.default.mnemonicToSecretKey(mnemonic);
this.accounts = [sk.addr];
this.pkToSk = { [sk.addr]: sk };
this.defaultAccount = 0;
return true;
});
async connect(mnemonic) {
const sk = algosdk.mnemonicToSecretKey(mnemonic);
this.accounts = [sk.addr];
this.pkToSk = { [sk.addr]: sk };
this.defaultAccount = 0;
return true;
}

@@ -55,24 +40,22 @@ static displayName() {

}
signTxns(txns) {
return __awaiter(this, void 0, void 0, function* () {
const signed = [];
const defaultAddr = this.getDefaultAccount();
for (const txidx in txns) {
const txn = txns[txidx];
if (txn === undefined)
continue;
const addr = algosdk_1.default.encodeAddress(txn.from.publicKey);
const acct = this.pkToSk[addr];
if (acct !== undefined && addr === defaultAddr) {
signed.push({ txID: txn.txID(), blob: txn.signTxn(acct.sk) });
}
else {
signed.push({ txID: '', blob: new Uint8Array() });
}
async signTxns(txns) {
const signed = [];
const defaultAddr = this.getDefaultAccount();
for (const txidx in txns) {
const txn = txns[txidx];
if (txn === undefined)
continue;
const addr = algosdk.encodeAddress(txn.from.publicKey);
const acct = this.pkToSk[addr];
if (acct !== undefined && addr === defaultAddr) {
signed.push({ txID: txn.txID(), blob: txn.signTxn(acct.sk) });
}
return signed;
});
else {
signed.push({ txID: '', blob: new Uint8Array() });
}
}
return signed;
}
}
exports.default = InsecureWallet;
export default InsecureWallet;
//# sourceMappingURL=insecure.js.map

@@ -1,20 +0,6 @@

"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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.KMDWallet = void 0;
const algosdk_1 = __importDefault(require("algosdk"));
const wallet_1 = require("./wallet");
const __1 = require("../..");
class KMDWallet extends wallet_1.Wallet {
import algosdk from 'algosdk';
import { Wallet } from './wallet';
import { sandbox } from '../..';
export class KMDWallet extends Wallet {
pkToSk;
constructor(network) {

@@ -24,14 +10,13 @@ super(network);

}
connect(config) {
return __awaiter(this, void 0, void 0, function* () {
const accts = yield __1.sandbox.getAccounts(config);
for (const sba of accts) {
this.pkToSk[sba.addr] = {
sk: sba.privateKey,
addr: sba.addr,
};
this.accounts.push(sba.addr);
}
return true;
});
async connect(config) {
this.accounts = [];
const accts = await sandbox.getAccounts(config);
for (const sba of accts) {
this.pkToSk[sba.addr] = {
sk: sba.privateKey,
addr: sba.addr,
};
this.accounts.push(sba.addr);
}
return true;
}

@@ -51,24 +36,21 @@ static displayName() {

}
signTxns(txns) {
return __awaiter(this, void 0, void 0, function* () {
const signed = [];
const defaultAddr = this.getDefaultAccount();
for (const txidx in txns) {
const txn = txns[txidx];
if (txn === undefined)
continue;
const addr = algosdk_1.default.encodeAddress(txn.from.publicKey);
const acct = this.pkToSk[addr];
if (acct !== undefined && addr === defaultAddr) {
signed.push({ txID: txn.txID(), blob: txn.signTxn(acct.sk) });
}
else {
signed.push({ txID: '', blob: new Uint8Array() });
}
async signTxns(txns) {
const signed = [];
const defaultAddr = this.getDefaultAccount();
for (const txidx in txns) {
const txn = txns[txidx];
if (txn === undefined)
continue;
const addr = algosdk.encodeAddress(txn.from.publicKey);
const acct = this.pkToSk[addr];
if (acct !== undefined && addr === defaultAddr) {
signed.push({ txID: txn.txID(), blob: txn.signTxn(acct.sk) });
}
return signed;
});
else {
signed.push({ txID: '', blob: new Uint8Array() });
}
}
return signed;
}
}
exports.KMDWallet = KMDWallet;
//# sourceMappingURL=kmd.js.map

@@ -1,18 +0,4 @@

"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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const algosdk_1 = __importDefault(require("algosdk"));
const wallet_1 = require("./wallet");
const myalgo_connect_1 = __importDefault(require("@randlabs/myalgo-connect"));
import algosdk from 'algosdk';
import { Wallet } from './wallet';
import MyAlgo from '@randlabs/myalgo-connect';
const logoInverted = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQEAAAEGCAYAAABl6SBFAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAEHpJREFUeNrsnf9RGzsXhhUm/3++FVxTQUgFLBUAFcRUEKiAUIGhAkwFMRWwVBCngriDOBXwrYycyxACllZaSec8z4yHuXcCLPrx7nuOjqR3Dw8PBgD0skMTACACAIAIAAAiAACIAAAgAgCACAAAIgAAiAAAIAIAgAgAACIAAIgAACACAIAIAAAiAACIAAAgAgCACAAAIgAAiAAAIAIAgAgAACIAANXyPtcvfvfuHa0/IA8PD3vdl1FAP7W03qD9pEcEIMkEb9z/2ndfgyb+K4NyIwiL7vPLfV12QrGgF+rlXa5ryHACwZOycZP7g/u6V8ijrQWh+3x3YrHo+nhFj5XvBBCBsgfE5u2+7yZ7U9mfsHCfeysMXZ8v6VVEABHYztrbyX5Y4aTfRhSsS7gl14AIIAJ/TvxP3eeo+4yV/Nk2VJg7QZgzChABjZ1tJ/tnZRP/LUG40e4QEAEdMf6Rm/x7Bl7C5g1uus9MYw4BEZD91j93AjBinm+NdQdXmtwBIiCvQxs3+Rvmcy8WTgxmiAAiwOQnVLiQLAaIAJMflIsBIsDkB+VigAjU12Hj7svUPCb8IB+tE4MWEUAEhuoom+E/NY9LfWT7y8E6gr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45FS8bIfPiGSSQPIK+QAZJxv0MzZBANjTIYNTG71JYS3EgAWRA4wckkL0M/hAmEENxMd89n/FXGj8S0D5ncN5V5Esq8skCPZTZijE/EiipVzvMZB/OL6By39P+pHwACRTf0x3GuFafbNvL/XmPv5OU0sChInk0AveZ3H3qu8/Lu8+8+7rUHt9J773wCDYSgAdC2Mr9+xNnR1Kolf9dLvncdP/S0yMBOJFd9zk8CXeQwvPuv2cZD3XcdX+i0SMBiCOFY5wUpt3nrBtCzEZs7Puuse+6xk68RwKQoNf9GccyOEjiwN9++Pox4Xz+4ev9E78TlPLbly9fKAUAw7BECIAEAAAJAAASAAAkAABIAACQAAAgAQBAAgCABAAACQAAEgAAJAAASAAAkAAAIAEAQAIAgAQAAAkAABIAACQAAEgAAJAAACABAEACAIAEAAAJAAASAAAkAABIAACQAAAgAQBAAgCABAAACQAAEgAAJAAAGfJ/AQYAHdQzxPOOxTAAAAAASUVORK5CYII=';

*/
class MyAlgoConnectWallet extends wallet_1.Wallet {
class MyAlgoConnectWallet extends Wallet {
walletConn;
constructor(network) {
super(network);
this.walletConn = new myalgo_connect_1.default();
this.walletConn = new MyAlgo();
}

@@ -44,64 +31,58 @@ static displayName() {

}
connect() {
return __awaiter(this, void 0, void 0, function* () {
if (this.isConnected())
return true;
try {
const accounts = yield this.walletConn.connect();
this.accounts = accounts.map((account) => account.address);
}
catch (err) {
return false;
}
async connect() {
if (this.isConnected())
return true;
});
try {
const accounts = await this.walletConn.connect();
this.accounts = accounts.map((account) => account.address);
}
catch (err) {
return false;
}
return true;
}
doSign(defaultAcct, txns) {
return __awaiter(this, void 0, void 0, function* () {
const unsigned = [];
const signedTxns = [];
const toSignTxns = [];
for (let tidx = 0; tidx < txns.length; tidx++) {
const txn = txns[tidx];
if (txn === undefined)
continue;
signedTxns.push({ txID: '', blob: new Uint8Array() });
if (algosdk_1.default.encodeAddress(txn.from.publicKey) === defaultAcct) {
toSignTxns.push(tidx);
unsigned.push(txn.toByte());
}
async doSign(defaultAcct, txns) {
const unsigned = [];
const signedTxns = [];
const toSignTxns = [];
for (let tidx = 0; tidx < txns.length; tidx++) {
const txn = txns[tidx];
if (txn === undefined)
continue;
signedTxns.push({ txID: '', blob: new Uint8Array() });
if (algosdk.encodeAddress(txn.from.publicKey) === defaultAcct) {
toSignTxns.push(tidx);
unsigned.push(txn.toByte());
}
const s = yield this.walletConn.signTransaction(unsigned);
for (const sidx in s) {
const signedIdx = toSignTxns[sidx];
if (signedIdx === undefined)
continue;
const stxn = s[sidx];
if (stxn === undefined)
continue;
signedTxns[signedIdx] = stxn;
}
return signedTxns;
});
}
const s = await this.walletConn.signTransaction(unsigned);
for (const sidx in s) {
const signedIdx = toSignTxns[sidx];
if (signedIdx === undefined)
continue;
const stxn = s[sidx];
if (stxn === undefined)
continue;
signedTxns[signedIdx] = stxn;
}
return signedTxns;
}
signTxn(txns) {
return __awaiter(this, void 0, void 0, function* () {
const defaultAcct = this.getDefaultAccount();
if (defaultAcct === undefined)
return [];
//if (this.permissionCallback) {
// return await this.permissionCallback.request({
// approved: async (): Promise<SignedTxn[]> => {
// return await this.doSign(defaultAcct, txns);
// },
// declined: async (): Promise<SignedTxn[]> => {
// return [];
// },
// });
//}
return yield this.doSign(defaultAcct, txns);
});
async signTxn(txns) {
const defaultAcct = this.getDefaultAccount();
if (defaultAcct === undefined)
return [];
//if (this.permissionCallback) {
// return await this.permissionCallback.request({
// approved: async (): Promise<SignedTxn[]> => {
// return await this.doSign(defaultAcct, txns);
// },
// declined: async (): Promise<SignedTxn[]> => {
// return [];
// },
// });
//}
return await this.doSign(defaultAcct, txns);
}
}
exports.default = MyAlgoConnectWallet;
export default MyAlgoConnectWallet;
//# sourceMappingURL=myalgoconnect.js.map

@@ -1,14 +0,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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Wallet = void 0;
class Wallet {
export class Wallet {
accounts;
defaultAccount;
network;
constructor(network) {

@@ -27,7 +18,5 @@ this.accounts = [];

// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
connect(_settings) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(() => {
false;
});
async connect(_settings) {
return new Promise(() => {
false;
});

@@ -56,3 +45,2 @@ }

}
exports.Wallet = Wallet;
//# sourceMappingURL=wallet.js.map

@@ -1,74 +0,57 @@

"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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const algosdk_1 = __importDefault(require("algosdk"));
const wallet_1 = require("./wallet");
const client_1 = __importDefault(require("@walletconnect/client"));
const algorand_walletconnect_qrcode_modal_1 = __importDefault(require("algorand-walletconnect-qrcode-modal"));
const utils_1 = require("@json-rpc-tools/utils");
import algosdk from 'algosdk';
import { Wallet } from './wallet';
import WalletConnect from '@walletconnect/client';
import WalletConnectQRCodeModal from 'algorand-walletconnect-qrcode-modal';
import { formatJsonRpcRequest } from '@json-rpc-tools/utils';
const logo = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTIwIDIwSDE3LjUwNDdMMTUuODY5MyAxMy45NkwxMi4zNjI1IDIwSDkuNTYzNzVMMTQuOTc1OCAxMC42NDU2TDE0LjA5OTEgNy4zODE3TDYuNzk4NzQgMjBINEwxMy4yNTYxIDRIMTUuNzE3NkwxNi43Nzk4IDcuOTg3MzhIMTkuMzA4N0wxNy41ODkgMTAuOTgyMUwyMCAyMFoiIGZpbGw9IiMyQjJCMkYiLz4KPC9zdmc+Cg==';
class WC extends wallet_1.Wallet {
class WC extends Wallet {
connector;
constructor(network) {
super(network);
const bridge = 'https://bridge.walletconnect.org';
this.connector = new client_1.default({
this.connector = new WalletConnect({
bridge,
qrcodeModal: algorand_walletconnect_qrcode_modal_1.default,
qrcodeModal: WalletConnectQRCodeModal,
});
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
connect(cb) {
return __awaiter(this, void 0, void 0, function* () {
// Check if connection is already established
if (this.connector.connected)
return true;
this.connector.createSession();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.connector.on('connect', (error, payload) => {
if (error) {
throw error;
}
const { accounts } = payload.params[0];
cb(accounts);
this.accounts = accounts;
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.connector.on('session_update', (error, payload) => {
if (error) {
throw error;
}
const { accounts } = payload.params[0];
cb(accounts);
this.accounts = accounts;
});
this.connector.on('disconnect', (error) => {
if (error)
throw error;
});
return yield this.waitForConnected();
async connect(cb) {
// Check if connection is already established
if (this.connector.connected)
return true;
this.connector.createSession();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.connector.on('connect', (error, payload) => {
if (error) {
throw error;
}
const { accounts } = payload.params[0];
cb(accounts);
this.accounts = accounts;
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.connector.on('session_update', (error, payload) => {
if (error) {
throw error;
}
const { accounts } = payload.params[0];
cb(accounts);
this.accounts = accounts;
});
this.connector.on('disconnect', (error) => {
if (error)
throw error;
});
return await this.waitForConnected();
}
waitForConnected() {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => {
const reconn = setInterval(() => {
if (this.connector.connected) {
clearInterval(reconn);
resolve(true);
return;
}
this.connector.connect();
}, 100);
});
async waitForConnected() {
return new Promise((resolve) => {
const reconn = setInterval(() => {
if (this.connector.connected) {
clearInterval(reconn);
resolve(true);
return;
}
this.connector.connect();
}, 100);
});

@@ -95,31 +78,29 @@ }

}
signTxn(txns) {
return __awaiter(this, void 0, void 0, function* () {
const defaultAddress = this.getDefaultAccount();
const txnsToSign = txns.map((txn) => {
const encodedTxn = Buffer.from(algosdk_1.default.encodeUnsignedTransaction(txn)).toString('base64');
if (algosdk_1.default.encodeAddress(txn.from.publicKey) !== defaultAddress)
return { txn: encodedTxn, signers: [] };
return { txn: encodedTxn };
});
const request = (0, utils_1.formatJsonRpcRequest)('algo_signTxn', [txnsToSign]);
const result = yield this.connector.sendCustomRequest(request);
return result.map((element, idx) => {
const txn = txns[idx];
if (txn === undefined)
return { txID: '', blob: new Uint8Array() };
return element
? {
txID: txn.txID(),
blob: new Uint8Array(Buffer.from(element, 'base64')),
}
: {
txID: txn.txID(),
blob: new Uint8Array(),
};
});
async signTxn(txns) {
const defaultAddress = this.getDefaultAccount();
const txnsToSign = txns.map((txn) => {
const encodedTxn = Buffer.from(algosdk.encodeUnsignedTransaction(txn)).toString('base64');
if (algosdk.encodeAddress(txn.from.publicKey) !== defaultAddress)
return { txn: encodedTxn, signers: [] };
return { txn: encodedTxn };
});
const request = formatJsonRpcRequest('algo_signTxn', [txnsToSign]);
const result = await this.connector.sendCustomRequest(request);
return result.map((element, idx) => {
const txn = txns[idx];
if (txn === undefined)
return { txID: '', blob: new Uint8Array() };
return element
? {
txID: txn.txID(),
blob: new Uint8Array(Buffer.from(element, 'base64')),
}
: {
txID: txn.txID(),
blob: new Uint8Array(),
};
});
}
}
exports.default = WC;
export default WC;
//# sourceMappingURL=walletconnect.js.map
{
"name": "beaker-ts",
"version": "0.0.36",
"version": "0.0.37",
"description": "",
"main": "./lib/index.js",
"scripts": {
"build": "tsc -p .",
"beaker": "npx ts-node src/beaker.ts",
"build": "npx tsc -p .",
"beaker": "npx tsx src/beaker.ts",
"genhello": "npm run beaker -- generate --local examples/hello/hello.json examples/hello/",
"hello": "npx ts-node examples/hello/index.ts",
"hello": "npx tsx examples/hello/index.ts",
"genstructer": "npm run beaker -- generate --local examples/struct/structer.json examples/struct/",
"structer": "npx ts-node examples/struct/index.ts",
"structer": "npx tsx examples/struct/index.ts",
"genopup": "npm run beaker -- generate --local examples/opup/opup.json examples/opup/",
"opup": "npx ts-node examples/opup/index.ts",
"opup": "npx tsx examples/opup/index.ts",
"genamm": "npm run beaker -- generate --local examples/amm/amm.json examples/amm/",
"amm": "npx ts-node examples/amm/index.ts",
"amm": "npx tsx examples/amm/index.ts",
"genavm7": "npm run beaker -- generate --local examples/demo_avm7/demo_avm7.json examples/demo_avm7/",
"avm7": "npx ts-node examples/demo_avm7/index.ts",
"avm7": "npx tsx examples/demo_avm7/index.ts",
"regen": "npm run genhello && npm run genstructer && npm run genopup && npm run genavm7 && npm run genamm",

@@ -40,10 +40,16 @@ "lint": "eslint \"src/**/*.ts\"",

"eslint-plugin-react-hooks": "^4.3.0",
"prettier": "^2.7.1"
"prettier": "^2.7.1",
"tsx": "^3.9.0"
},
"dependencies": {
"algosdk": "^1.19.0",
"@json-rpc-tools/utils": "^1.7.6",
"@randlabs/myalgo-connect": "^1.1.0",
"@walletconnect/client": "^1.6.5",
"@walletconnect/qrcode-modal": "^1.6.5",
"algorand-walletconnect-qrcode-modal": "^1.6.1",
"algosdk": "^1.21.0",
"buffer": "^6.0.3",
"commander": "^9.4.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
}
}

@@ -55,3 +55,3 @@ # Beaker Typescript Client Generator

The client can now be imported and used to create or call the app!
The client can now be imported and used to create or call the app methods by name and with expected types.

@@ -58,0 +58,0 @@ ```ts

import algosdk, { ABIReferenceType, AtomicTransactionComposer } from 'algosdk';
import { getStateSchema, Schema } from '../';
import { getStateSchema, Schema } from '../generate';
import { parseLogicError, LogicError } from './logic_error';

@@ -5,0 +5,0 @@ import { ApplicationState, AccountState, decodeState } from './state';

@@ -1,5 +0,3 @@

#!/usr/bin/env node
import { Command } from 'commander';
import { generateApplicationClient } from '.';
import { generateApplicationClient } from './index.js';

@@ -9,3 +7,3 @@ import * as fs from 'fs';

const pjson = require('../package.json'); // eslint-disable-line
//const pjson = ../package.json'); // eslint-disable-line
const program = new Command();

@@ -16,3 +14,3 @@

.description('Utilities for working with beaker applications')
.version(pjson['version']);
.version('0.0.35');

@@ -25,4 +23,2 @@ program

.action((specPath, srcPath, options) => {
const importPath = options.local ? '../../src/' : undefined;
if (srcPath.slice(-1) !== path.sep) srcPath += path.sep;

@@ -38,4 +34,2 @@

console.log(`Writing client to: ${srcPath}`);
let jsonObj = JSON.parse(fs.readFileSync(specPath).toString());

@@ -46,5 +40,14 @@ if (!('contract' in jsonObj)) {

generateApplicationClient(jsonObj, srcPath, importPath);
const outputFile = generateApplicationClient(
jsonObj,
options.local ? '../../src/' : undefined,
);
const name: string = jsonObj.contract.name;
const file_name = `${name.toLowerCase()}_client.ts`;
fs.writeFileSync(srcPath + file_name, outputFile);
console.log(`Wrote client to: ${srcPath + file_name}`);
});
program.parse();

@@ -11,4 +11,4 @@ import type {

import algosdk from 'algosdk';
import ts, { factory } from 'typescript';
import { writeFileSync } from 'fs';
import ts from 'typescript';
const { factory } = ts;

@@ -144,5 +144,4 @@ // AMAZING resource:

appSpec: AppSpec,
path: string,
beakerPath?: string,
): void {
): string {
const name = appSpec.contract.name;

@@ -158,3 +157,3 @@

const outputFile = ts
return ts
.createPrinter()

@@ -172,5 +171,2 @@ .printList(

);
const file_name = `${name.toLowerCase()}_client.ts`;
writeFileSync(path + file_name, outputFile);
}

@@ -177,0 +173,0 @@

@@ -1,25 +0,4 @@

export {
ApplicationClient,
ABIResult,
MethodArg,
MethodArgs,
decodeNamedTuple,
TransactionOverrides,
} from './application_client/application_client';
export { LogicError, parseLogicError } from './application_client/logic_error';
export { generateApplicationClient } from './generate/generate';
export {
HintSpec,
DeclaredSchemaValueSpec,
DynamicSchemaValueSpec,
Schema,
StateSchema,
SchemaSpec,
AppSources,
AppSpec,
AVMType,
getStateSchema,
} from './generate/appspec';
export * from './application_client';
export * from './generate';
export * as web from './web';
export * as sandbox from './sandbox';

@@ -15,5 +15,23 @@ import algosdk from 'algosdk';

export async function getAccounts(): Promise<SandboxAccount[]> {
const kmdClient = new algosdk.Kmd(kmd_token, kmd_host, kmd_port);
export type KMDConfig = {
host: string;
port: string;
token: string;
wallet: string;
password: string;
};
export const DefaultKMDConfig = {
host: kmd_host,
token: kmd_token,
port: kmd_port,
wallet: kmd_wallet,
password: kmd_password,
} as KMDConfig;
export async function getAccounts(
config: KMDConfig = DefaultKMDConfig,
): Promise<SandboxAccount[]> {
const kmdClient = new algosdk.Kmd(config.token, config.host, config.port);
const wallets = await kmdClient.listWallets();

@@ -23,8 +41,11 @@

for (const wallet of wallets['wallets']) {
if (wallet['name'] === kmd_wallet) walletId = wallet['id'];
if (wallet['name'] === config.wallet) walletId = wallet['id'];
}
if (walletId === undefined) throw Error('No wallet named: ' + kmd_wallet);
if (walletId === undefined) throw Error('No wallet named: ' + config.wallet);
const handleResp = await kmdClient.initWalletHandle(walletId, kmd_password);
const handleResp = await kmdClient.initWalletHandle(
walletId,
config.password,
);
const handle = handleResp['wallet_handle_token'];

@@ -35,3 +56,3 @@

for (const addr of addresses['addresses']) {
acctPromises.push(kmdClient.exportKey(handle, kmd_password, addr));
acctPromises.push(kmdClient.exportKey(handle, config.password, addr));
}

@@ -38,0 +59,0 @@ const keys = await Promise.all(acctPromises);

{
"extends": "@tsconfig/node16-strictest/tsconfig.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"target": "ESNext",
"module": "ESNext",
"lib": ["es6", "es2015", "dom"],
"allowJs": true,
"sourceMap": true,
"declaration": true,

@@ -13,2 +15,3 @@ "outDir": "lib",

"resolveJsonModule": true,
"moduleResolution": "Node",
"strict":true

@@ -15,0 +18,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc