scale-it / algo-builder Goto Github PK
View Code? Open in Web Editor NEWFramework to automate development of Algorand Assets and Smart Contracts.
Home Page: https://algobuilder.dev
License: Apache License 2.0
Framework to automate development of Algorand Assets and Smart Contracts.
Home Page: https://algobuilder.dev
License: Apache License 2.0
As discussed on the discord channel, it would be very useful if there was an option to output the stack after the execution of each opcode.
Currently if I have a failing test I have to try and isolate the problem by modifying the PyTeal or go through the long process of setting up the execution environment and using the teal debugger tool.
Getting the following error when running yarn run algob deploy scripts/0-gold.js
:
Error ABLDR602: Error while executing script 'scripts/0-gold.js:Line:29,Position:67': Cannot read properties of undefined (reading 'addr')
This is because on line 21 goldOwner = deployer.accountsByName.get('alice')
is defined but alice
has not been defined in algob.config.js
. (See step 4 which omits alice
's account)
Provide alice's
account information
yarn run algob deploy scripts/0-gold.js
as suggested in step 5Algo Builder test environment doesn't support account rekeying.
Update the RuntimeAccount type and functionality (eg by adding class methods) to support account rekeying and verification.
A complete solution will require tests.
The config only allows string type for token and number type for port, while AlgodClient accepts also an object (i.e., AlgodTokenHeader and CustomTokenHeader) for the token and string type for port.
App.localGetEx
does not found local state. Have not tested for App.globalGetEx
.
stateful.py
from pyteal import *
def contract():
update_local_state = Seq([
App.localPut(Int(0), Bytes('test'), Int(3)),
Int(1)
])
state = App.localGetEx(Int(1), Int(0), Bytes('test'))
check_local_state = Seq([
state,
state.hasValue()
])
return Cond(
[Txn.on_completion() == OnComplete.OptIn, Int(1)],
[Txn.application_id() == Int(0), Int(1)],
[Txn.application_args[0] == Bytes('u'), update_local_state],
[Txn.application_args[0] == Bytes('c'), check_local_state],
)
if __name__ == "__main__":
print(compileTeal(contract(), Mode.Application, version=3))
test.ts
import { getProgram } from '@algo-builder/algob';
import { AccountStore, Runtime, stringToBytes, types } from '@algo-builder/runtime';
import { assert } from 'chai';
import { StateUtil } from './utils/auxiliaryUtils';
import { getAddDispenserTxGroup, getAddEscrowTxGroup, updateDispenserTxGroup } from './utils/newTxGroups/ffTxnCreator';
import { setupDispenser, setupEscrowContract } from './utils/contractUtil';
import { encodeAddress, encodeUint64, LogicSig } from 'algosdk';
import { ExecParams } from '@algo-builder/runtime/build/types';
const approvalProg = getProgram('stateful.py');
const clearProg = getProgram('main_clear_state.py');
describe('Test', function () {
const master = new AccountStore(10e6);
const account = new AccountStore(10e6);
const runtime = new Runtime([master, account]);
let creationArgs, creationFlags: any;
let appId: number;
this.beforeAll(() => {
creationArgs = [];
creationFlags = {
sender: master.account,
localInts: 1,
localBytes: 0,
globalInts: 0,
globalBytes: 0,
appArgs: [],
};
appId = runtime.addApp(creationFlags, {}, approvalProg, clearProg);
});
it('test', () => {
runtime.optInToApp(account.address, appId, {}, {});
runtime.executeTx({
type: types.TransactionType.CallNoOpSSC,
sign: types.SignType.SecretKey,
fromAccount: account.account,
appID: appId,
appArgs: [stringToBytes('u')],
payFlags: { totalFee: 1000 }
});
const local = runtime.getLocalState(appId, account.address, 'test')
assert.equal(local, BigInt(3));
runtime.executeTx({
type: types.TransactionType.CallNoOpSSC,
sign: types.SignType.SecretKey,
fromAccount: master.account,
appID: appId,
appArgs: [stringToBytes('c')],
accounts: [account.address],
payFlags: { totalFee: 1000 }
}, 3);
});
});
The test fails of the last transaction being executed. It returns 0
0
on the stack when fetching the local state of account
.
both need the $ removed from the environment variables. The existing environment values will never be found with these $ names.
An asset clawback transaction with a closeRemainderTo
payFlag should throw an error (which is the behaviour of algorand network). Clawbacks cannot close assets from an address - only the actual owner can.
Hi, I got this error when trying to run yarn add algob
yarn add v1.22.4
[1/4] ๐ Resolving packages...
error An unexpected error occurred: "https://raw.githubusercontent.com/algorand/js-algorand-sdk/3999aa43fc3d945b38419339c593bb5fd72e49c6/package.json: connect ECONNREFUSED 0.0.0.0:443".
info If you think this is a bug, please open a bug report with the information provided in "/Users/haichaozhu/code/algob-project/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
I figured this might be a connection problem of my network. (I'm in China and I'm using a local mirror site for all yarn and npm packages).
However I don't have problems installing algorand js SDK alone.
Not an expert in js coding. So could be a silly question.
Only one test fails:
1) argumentTypes
Input file type
Should throw if the file isn't readable:
AssertionError: BuilderError number 302 expected, but no Error was thrown
at Object.expectBuilderError (test/helpers/errors.ts:65:9)
at Context.<anonymous> (test/internal/core/params/argument-types.ts:242:7)
I am trying to create a DAO on the testnet. On the Create Application part of the deploy.js file I recieve a TypeError because the first argument is null. I debugged my code and any argument retuns me null.
async function run (runtimeEnv, deployer) {
const { creator, proposer, voterA, voterB } = accounts(deployer);
// fund accounts
await fundAccount(deployer, [creator, proposer, voterA, voterB]);
// Create DAO Gov Token
const govToken = await deployer.deployASA('test-token', { creator: creator });
// DAO App initialization parameters
const deposit = 15; // deposit required to make a proposal
const minSupport = 5; // minimum number of yes power votes to validate proposal
const minDuration = 1 * 60; // 1min (minimum voting time in number of seconds)
const maxDuration = 5 * 60; // 5min (maximum voting time in number of seconds)
const url = 'www.my-url.com';
const appArgs = [
`int:${deposit}`,
`int:${minSupport}`,
`int:${minDuration}`,
`int:${maxDuration}`,
`str:${url}`
];
const templateParam = { ARG_GOV_TOKEN: govToken.assetIndex };
// Create Application
const daoAppInfo = await deployer.deployApp(
'dao-app-approval.py',
'dao-app-clear.py', {
sender: creator,
localInts: 9,
localBytes: 7,
globalInts: 4,
globalBytes: 2,
appArgs: appArgs
}, {}, templateParam);
...
Error output:
PyTEAL template parameters: { ARG_GOV_TOKEN: 62330360 }
TEAL replacement parameters: {}
TypeError: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received null
at new NodeError (node:internal/errors:371:5)
at from (node:buffer:322:9)
at Object.MurmurHashV3 [as default] (C:\Users\isica\AppData\Local\Yarn\Data\global\node_modules\murmurhash\murmurhash.js:74:38)
at CompileOp.ensureCompiled (C:\Users\isica\AppData\Local\Yarn\Data\global\node_modules\@algo-builder\algob\src\lib\compile.ts:51:44)
at AlgoOperatorImpl.ensureCompiled (C:\Users\isica\AppData\Local\Yarn\Data\global\node_modules\@algo-builder\algob\src\lib\algo-operator.ts:503:33)
at AlgoOperatorImpl.deployApp (C:\Users\isica\AppData\Local\Yarn\Data\global\node_modules\@algo-builder\algob\src\lib\algo-operator.ts:317:28)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at DeployerDeployMode.deployApp (C:\Users\isica\AppData\Local\Yarn\Data\global\node_modules\@algo-builder\algob\src\internal\deployer.ts:672:17)
at Object.run [as default] (C:\Kernel\projects\my_new_project\dao\scripts\deploy.js:34:22)
at runScript (C:\Users\isica\AppData\Local\Yarn\Data\global\node_modules\@algo-builder\algob\src\internal\util\scripts-runner.ts:75:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
Error ABLDR602: Error while executing script 'scripts/deploy.js': The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Receieceived null
Yarn build command fails at the @algo-builder/algob process. It looks like you changed some dependencies and did not update the build process. Here is the error message: `node_modules/@algo-builder/runtime/build/logicsig.d.ts:3:34 - error TS2305: Module '"algosdk"' has no exported member 'MultiSigAccount'.
3 import { LogicSigBase, MultiSig, MultiSigAccount } from "algosdk";
~~~~~~~~~~~~~~~
src/lib/algo-operator.ts:310:36 - error TS2339: Property 'DeploySSC' does not exist on type 'typeof TransactionType'.
310 type: rtypes.TransactionType.DeploySSC,
~~~~~~~~~
src/lib/algo-operator.ts:313:7 - error TS2322: Type '{ type: any; sign: rtypes.SignType.SecretKey; fromAccount: algosdk.Account; approvalProgram: string; clearProgram: string; approvalProg: Uint8Array; clearProg: Uint8Array; ... 10 more ...; lease: Uint8Array | undefined; }' is not assignable to type 'ExecParams'.
Object literal may only specify known properties, and 'approvalProgram' does not exist in type 'ExecParams'.
313 approvalProgram: approvalProgram,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib/algo-operator.ts:366:36 - error TS2339: Property 'OptInSSC' does not exist on type 'typeof TransactionType'.
366 type: rtypes.TransactionType.OptInSSC,
~~~~~~~~` @robert-zaremba @Invertisment @sebastiangula @amityadav0 @as04
I am just learning about LogicSignatures and was following along this tutorial for the algob console using the asa-example. I found that the README was a bit misleading as its sentence suggested there would be one stateless contract that had ALL the listed features. Also the naming of the files was misleading, as one file suggests its related to the gold-asset (3-gold-delegated-asc.teal), where it really allows only transfering of Algos.
I think it would have been more helpful if the test was something like this:
this example also includes stateless smart contracts that showcase the two different modes of operation (contract & signature delegation):
Overall, I really like the examples in this repo. Thats why I wanted to contribute to making it a tiny bit better.. Keep up the good work!
When I execute/test group transactions integrating more than 1 smart contract, I got some errors, but it only show the line in the teal file.
I don't know exactly smart contracts have errors, like below:
RUNTIME_ERR1000: Length of the stack is less than min length required for current op at line 33.
I think we should show more information like appID or source of the smart contract. It will help developers easier debug and fix problems. Maybe like that:
RUNTIME_ERR1000: Length of the stack is less than min length required for current op at line 33 in "Main.teal"
.
Thank for checking this issue! โค๏ธ
In packages/runtime/src/interpreter/opcode-list.ts,
AppLocalGetEx
and AppGlobalGetEx
ops execution results in pushing BIGINT0
to the stack in case the key doesn't have a corresponding value in app's state.
The actual behaviour should be pushing BIGINT0
twice: one for the did_exist flag and one for the value.
This could result in an unwanted behaviour since the stack length is not as expected.
I've tested the above scenario with a simple TEAL script before posting this issue just to make sure but please validate as well.
While working on a ts application I realized that the accepted params for the smart contracts when loading python logic where only string but I think they could also be integer or something else since they are just params for python
In order to help organise one's smart contracts and asa-defs, it would be helpful if they did not have to be directly in the assets folder.
A for going through an array returns an error in runtime
@Subroutine(TealType.none)
def update_state():
i = ScratchVar(TealType.uint64)
init = i.store(Int(1))
cond = i.load() < Txn.application_args.length()
step = i.store(i.load() + Int(2))
return Seq(
[
For(init, cond, step).Do(
App.globalPut(
Txn.application_args[i.load()],
Btoi(Txn.application_args[i.load() + Int(1)]),
),
),
Int(1),
]
)
This is the code(Txn.application_args as length of 3)
It should go throw the array normally
It gives on Txn.application_args[i.load()]
the error pyteal.TealInputError: Invalid array index: (Load slot#256)
This doesn't seem to be a problem when using one stateful contract and one stateless contract although further investigation may be needed.
When executing a grouped transaction where there is a stateful contract call in position 0 and a stateful contract call in postion x (where x > 0) then at both positions txn
seems to be referencing txn
at postion 0. This contradicts the documentation https://developer.algorand.org/docs/reference/teal/opcodes/#txn-f which suggests txn
refers to the current transaction.
I believe this problem impacts all scenarios where txn
is accessed whether implicitly or explicity eg. asset_params_get
and txn accounts
.
To recreate:
# test1.py
from pyteal import *
def contract():
program = Cond(
[Txn.application_id() == Int(0), Int(1)], # on creation
[Txn.on_completion() == OnComplete.DeleteApplication, Int(0)],
[Txn.on_completion() == OnComplete.UpdateApplication, Int(0)],
[Txn.on_completion() == OnComplete.CloseOut, Int(0)],
[Txn.on_completion() == OnComplete.OptIn, Int(0)],
[Txn.on_completion() == OnComplete.NoOp, Txn.group_index() == Int(0)]
)
return program
if __name__ == "__main__":
print(compileTeal(contract(), Mode.Application))
# test2.py
from pyteal import *
def contract():
program = Cond(
[Txn.application_id() == Int(0), Int(1)], # on creation
[Txn.on_completion() == OnComplete.DeleteApplication, Int(0)],
[Txn.on_completion() == OnComplete.UpdateApplication, Int(0)],
[Txn.on_completion() == OnComplete.CloseOut, Int(0)],
[Txn.on_completion() == OnComplete.OptIn, Int(0)],
[Txn.on_completion() == OnComplete.NoOp, Txn.group_index() == Int(1)]
)
return program
if __name__ == "__main__":
print(compileTeal(contract(), Mode.Application))
# test file
it('test', () => {
const test1 = getProgram('test1.py');
const test2 = getProgram('test2.py');
const appId1 = runtime.addApp(
{
sender: master.account,
localInts: 0,
localBytes: 0,
globalInts: 0,
globalBytes: 0,
appArgs: []
},
{},
test1,
clearProgram
);
const appId2 = runtime.addApp(
{
sender: master.account,
localInts: 0,
localBytes: 0,
globalInts: 0,
globalBytes: 0,
appArgs: []
},
{},
test2,
clearProgram
);
runtime.executeTx([
{
type: types.TransactionType.CallNoOpSSC,
sign: types.SignType.SecretKey,
fromAccount: master.account,
appId: appId1,
payFlags: {},
},
{
type: types.TransactionType.CallNoOpSSC,
sign: types.SignType.SecretKey,
fromAccount: master.account,
appId: appId2,
payFlags: {},
}
]);
});
This fails on the Txn.group_index() == Int(1)
check and passes if that is changed to Txn.group_index() == Int(0)
asset close to parameter for TransferAsset transaction
In runtime
getLogicSig
, the address should be the compiled TEAL program and not a randomly generated address. Use case: have hardcoded escrow account address into contract.
In runtime, I've to opt in a couple of accounts in ASA. I do that directly in Assets/asa.yaml
with optInAccNames: ["alice", "bob"]
. when I run the test, an error returns to me as below.
doing yarn algob-deploy
fails.
in 0-gold/tesla-asa.js
the script is misspelling Account:
deployer.optInAcountToASA -> deployer.optInAccountToASA
I am trying to test the DAO example and all scripts seems to work correctly. But when I use the execute.js script using this command line.
yarn run algob run scripts/run/execute.js
I receive a Transaction Failed Error with the status code 400.
Transaction Failed Error: cannot POST /ps2/v2/transactions (400)
at Response.toError (/home/isaac/Downloads/my_new_project/dao/node_modules/superagent/src/node/response.js:95:15)
at Response._setStatusProperties (/home/isaac/Downloads/my_new_project/dao/node_modules/superagent/src/response-base.js:126:48)
at new Response (/home/isaac/Downloads/my_new_project/dao/node_modules/superagent/src/node/response.js:41:8)
at Request._emitResponse (/home/isaac/Downloads/my_new_project/dao/node_modules/superagent/src/node/index.js:928:20)
at fn (/home/isaac/Downloads/my_new_project/dao/node_modules/superagent/src/node/index.js:1130:38)
at IncomingMessage.<anonymous> (/home/isaac/Downloads/my_new_project/dao/node_modules/superagent/src/node/parsers/image.js:8:5)
at IncomingMessage.emit (node:events:402:35)
at IncomingMessage.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
status: 400,
text: undefined,
method: 'POST',
path: '/ps2/v2/transactions'
}
I follow all the commands from https://github.com/scale-it/algo-builder/tree/master/examples/dao in the same order.
Thank you!
A small note: I am using develop
which I shouldn't.
I get this error while trying to use Txn.application_args
inside of a For
It should support txnas
It throws, saying the opcode does not exist
Full StackTrace:
at opcodeFromSentence (algo-builder/packages/runtime/build/parser/parser.js:326:15)
at parser (algo-builder/packages/runtime/build/parser/parser.js:414:29)
at Interpreter.executeWithResult (algo-builder/packages/runtime/build/interpreter/interpreter.js:384:49)
at Interpreter.execute (algo-builder/packages/runtime/build/interpreter/interpreter.js:365:29)
at Runtime.run (algo-builder/packages/runtime/build/runtime.js:553:21)
at Ctx.addApp (algo-builder/packages/runtime/build/ctx.js:206:22)
at Runtime.addApp (algo-builder/packages/runtime/build/runtime.js:381:18)
It would be nice to support the Tmpl
expression in pyteal and have a parseArgs
function that can replace these variables. Each time I want to export a smart contract to a different project I need to manuallly edit all my smart contracts after testing to use the Tmpl
expression.
When I try to create a DAO I use the command
yarn run algob deploy
The Token is created correctly and added to the master wallet. But then I recieve the next error:
[Error: ENOENT: no such file or directory, open 'C:\Kernel\projects\my_new_project\dao\artifacts\cache\dao-app-approval.py.yaml'] {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Kernel\\projects\\my_new_project\\dao\\artifacts\\cache\\dao-app-approval.py.yaml'
}
And the folder dao/artifacts/cache is empty
Hello,
I'm using typescript for create a script, and if I'm going to declare an array of parameters for an Atomic Transaction, so composed by heterogeneous types I need to specify any as type for the array, if I don't specify anything, it returns the following error.
Should works without any type assigned
Error is Error: RUNTIME_ERR1000: Length of stack is less than min length required for current op at line 21
during Runtime test, during normal deploy the error in the transaction is TEAL runtime encountered err opcode
and the code I'm testing is
#pragma version 2
txn ApplicationID
int 0
==
bnz l0
txn OnCompletion
int CloseOut
==
bnz l1
txn OnCompletion
int OptIn
==
bnz l2
err
l0:
int 1
txna ApplicationArgs 1
btoi
asset_holding_get AssetBalance
store 0
store 1
txn NumAppArgs
int 2
==
load 0
&&
bnz l6
err
l6:
byte "dispenser_holding"
load 1
app_global_put
b l5
l1:
int 1
b l5
l2:
int 0
byte "balance"
int 0
app_local_put
int 1
b l5
l5:
The code was tested in goal and it works properly, it seems to drop on the
store 0
store 1
I was trying to use algob from outside my project and after linking it, I used to work on projects in the same environment of algob(my project was in a cloned algob) and now as I'm trying to use algob with
yarn link
yarn link @algo-builder/algob
I get these errors during the build of my project, I also tried to install the same algosdk version in my project but nothing changed
2 import { AssetDef } from "algosdk";
~~~~~~~~
../algo-builder/packages/runtime/build/interpreter/interpreter.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/runtime/build/lib/constants.d.ts:2:10 - error TS2614: Module '"algosdk"' has no exported member 'AssetDefEnc'. Did you mean to use 'import AssetDefEnc from "algosdk"' instead?
2 import { AssetDefEnc, StateSchemaEnc, TxnEncodedObj } from "algosdk";
~~~~~~~~~~~
../algo-builder/packages/runtime/build/lib/constants.d.ts:2:23 - error TS2614: Module '"algosdk"' has no exported member 'StateSchemaEnc'. Did you mean to use 'import StateSchemaEnc from "algosdk"' instead?
2 import { AssetDefEnc, StateSchemaEnc, TxnEncodedObj } from "algosdk";
~~~~~~~~~~~~~~
../algo-builder/packages/runtime/build/lib/constants.d.ts:2:39 - error TS2614: Module '"algosdk"' has no exported member 'TxnEncodedObj'. Did you mean to use 'import TxnEncodedObj from "algosdk"' instead?
2 import { AssetDefEnc, StateSchemaEnc, TxnEncodedObj } from "algosdk";
~~~~~~~~~~~~~
../algo-builder/packages/runtime/build/lib/constants.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/runtime/build/types.d.ts:2:33 - error TS2614: Module '"algosdk"' has no exported member 'AssetDef'. Did you mean to use 'import AssetDef from "algosdk"' instead?
2 import { Account as AccountSDK, AssetDef, LogicSig, LogicSigArgs, SSCSchemaConfig, TxnEncodedObj } from "algosdk";
~~~~~~~~
../algo-builder/packages/runtime/build/types.d.ts:2:43 - error TS2614: Module '"algosdk"' has no exported member 'LogicSig'. Did you mean to use 'import LogicSig from "algosdk"' instead?
2 import { Account as AccountSDK, AssetDef, LogicSig, LogicSigArgs, SSCSchemaConfig, TxnEncodedObj } from "algosdk";
~~~~~~~~
../algo-builder/packages/runtime/build/types.d.ts:2:53 - error TS2614: Module '"algosdk"' has no exported member 'LogicSigArgs'. Did you mean to use 'import LogicSigArgs from "algosdk"' instead?
2 import { Account as AccountSDK, AssetDef, LogicSig, LogicSigArgs, SSCSchemaConfig, TxnEncodedObj } from "algosdk";
~~~~~~~~~~~~
../algo-builder/packages/runtime/build/types.d.ts:2:67 - error TS2614: Module '"algosdk"' has no exported member 'SSCSchemaConfig'. Did you mean to use 'import SSCSchemaConfig from "algosdk"' instead?
2 import { Account as AccountSDK, AssetDef, LogicSig, LogicSigArgs, SSCSchemaConfig, TxnEncodedObj } from "algosdk";
~~~~~~~~~~~~~~~
../algo-builder/packages/runtime/build/types.d.ts:2:84 - error TS2614: Module '"algosdk"' has no exported member 'TxnEncodedObj'. Did you mean to use 'import TxnEncodedObj from "algosdk"' instead?
2 import { Account as AccountSDK, AssetDef, LogicSig, LogicSigArgs, SSCSchemaConfig, TxnEncodedObj } from "algosdk";
~~~~~~~~~~~~~
../algo-builder/packages/runtime/build/types.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/runtime/build/account.d.ts:2:24 - error TS2614: Module '"algosdk"' has no exported member 'AssetDef'. Did you mean to use 'import AssetDef from "algosdk"' instead?
2 import type { Account, AssetDef, SSCSchemaConfig } from "algosdk";
~~~~~~~~
../algo-builder/packages/runtime/build/account.d.ts:2:34 - error TS2614: Module '"algosdk"' has no exported member 'SSCSchemaConfig'. Did you mean to use 'import SSCSchemaConfig from "algosdk"' instead?
2 import type { Account, AssetDef, SSCSchemaConfig } from "algosdk";
~~~~~~~~~~~~~~~
../algo-builder/packages/runtime/build/account.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/runtime/build/lib/asa.d.ts:2:15 - error TS2614: Module '"algosdk"' has no exported member 'AssetDef'. Did you mean to use 'import AssetDef from "algosdk"' instead?
2 import type { AssetDef } from "algosdk";
~~~~~~~~
../algo-builder/packages/runtime/build/lib/asa.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/runtime/build/lib/txn.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/runtime/build/logicsig.d.ts:3:10 - error TS2614: Module '"algosdk"' has no exported member 'LogicSigBase'. Did you mean to use 'import LogicSigBase from "algosdk"' instead?
3 import { LogicSigBase, MultiSig, MultisigMetadata } from "algosdk";
~~~~~~~~~~~~
../algo-builder/packages/runtime/build/logicsig.d.ts:3:24 - error TS2614: Module '"algosdk"' has no exported member 'MultiSig'. Did you mean to use 'import MultiSig from "algosdk"' instead?
3 import { LogicSigBase, MultiSig, MultisigMetadata } from "algosdk";
~~~~~~~~
../algo-builder/packages/runtime/build/logicsig.d.ts:3:34 - error TS2614: Module '"algosdk"' has no exported member 'MultisigMetadata'. Did you mean to use 'import MultisigMetadata from "algosdk"' instead?
3 import { LogicSigBase, MultiSig, MultisigMetadata } from "algosdk";
~~~~~~~~~~~~~~~~
../algo-builder/packages/runtime/build/logicsig.d.ts:2:23 - error TS2688: Cannot find type definition file for 'types'.
2 /// <reference types="types" />
~~~~~
../algo-builder/packages/runtime/build/runtime.d.ts:2:10 - error TS2614: Module '"algosdk"' has no exported member 'AssetDef'. Did you mean to use 'import AssetDef from "algosdk"' instead?
2 import { AssetDef } from "algosdk";
~~~~~~~~
../algo-builder/packages/runtime/build/runtime.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/algob/build/types.d.ts:4:15 - error TS2614: Module '"algosdk"' has no exported member 'LogicSig'. Did you mean to use 'import LogicSig from "algosdk"' instead?
4 import type { LogicSig } from "algosdk";
~~~~~~~~
../algo-builder/packages/algob/build/types.d.ts:317:54 - error TS2694: Namespace '"/home/lumene/algo-builder/node_modules/algosdk/dist/types/index"' has no exported member 'ConfirmedTxInfo'.
317 logTx: (message: string, txConfirmation: algosdk.ConfirmedTxInfo) => void;
~~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/types.d.ts:322:74 - error TS2694: Namespace '"/home/lumene/algo-builder/node_modules/algosdk/dist/types/index"' has no exported member 'ConfirmedTxInfo'.
322 sendAndWait: (rawTxns: Uint8Array | Uint8Array[]) => Promise<algosdk.ConfirmedTxInfo>;
~~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/types.d.ts:368:60 - error TS2694: Namespace '"/home/lumene/algo-builder/node_modules/algosdk/dist/types/index"' has no exported member 'ConfirmedTxInfo'.
368 waitForConfirmation: (txId: string) => Promise<algosdk.ConfirmedTxInfo>;
~~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/types.d.ts:371:68 - error TS2694: Namespace '"/home/lumene/algo-builder/node_modules/algosdk/dist/types/index"' has no exported member 'AssetInfo'.
371 getAssetByID: (assetIndex: number | bigint) => Promise<algosdk.AssetInfo>;
~~~~~~~~~
../algo-builder/packages/algob/build/types.d.ts:2:23 - error TS2688: Cannot find type definition file for 'types'.
2 /// <reference types="types" />
~~~~~
../algo-builder/packages/algob/build/lib/account.d.ts:3:15 - error TS2614: Module '"algosdk"' has no exported member 'MultisigMetadata'. Did you mean to use 'import MultisigMetadata from "algosdk"' instead?
3 import { Kmd, MultisigMetadata } from "algosdk";
~~~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/lib/account.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/algob/build/lib/constants.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/algob/build/lib/lsig.d.ts:3:15 - error TS2614: Module '"algosdk"' has no exported member 'LogicSig'. Did you mean to use 'import LogicSig from "algosdk"' instead?
3 import type { LogicSig, MultisigMetadata } from "algosdk";
~~~~~~~~
../algo-builder/packages/algob/build/lib/lsig.d.ts:3:25 - error TS2614: Module '"algosdk"' has no exported member 'MultisigMetadata'. Did you mean to use 'import MultisigMetadata from "algosdk"' instead?
3 import type { LogicSig, MultisigMetadata } from "algosdk";
~~~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/lib/lsig.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/algob/build/lib/msig.d.ts:2:24 - error TS2614: Module '"algosdk"' has no exported member 'LogicSig'. Did you mean to use 'import LogicSig from "algosdk"' instead?
2 import type { Account, LogicSig, MultiSig, TxSig } from "algosdk";
~~~~~~~~
../algo-builder/packages/algob/build/lib/msig.d.ts:2:34 - error TS2614: Module '"algosdk"' has no exported member 'MultiSig'. Did you mean to use 'import MultiSig from "algosdk"' instead?
2 import type { Account, LogicSig, MultiSig, TxSig } from "algosdk";
~~~~~~~~
../algo-builder/packages/algob/build/lib/msig.d.ts:2:44 - error TS2614: Module '"algosdk"' has no exported member 'TxSig'. Did you mean to use 'import TxSig from "algosdk"' instead?
2 import type { Account, LogicSig, MultiSig, TxSig } from "algosdk";
~~~~~
../algo-builder/packages/algob/build/lib/msig.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/algob/build/lib/status.d.ts:2:15 - error TS2614: Module '"algosdk"' has no exported member 'AssetHolding'. Did you mean to use 'import AssetHolding from "algosdk"' instead?
2 import type { AssetHolding, SSCStateSchema } from "algosdk";
~~~~~~~~~~~~
../algo-builder/packages/algob/build/lib/status.d.ts:2:29 - error TS2614: Module '"algosdk"' has no exported member 'SSCStateSchema'. Did you mean to use 'import SSCStateSchema from "algosdk"' instead?
2 import type { AssetHolding, SSCStateSchema } from "algosdk";
~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/lib/status.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
../algo-builder/packages/algob/build/lib/tx.d.ts:38:134 - error TS2694: Namespace '"/home/lumene/algo-builder/node_modules/algosdk/dist/types/src/main"' has no exported member 'ConfirmedTxInfo'.
38 export declare function executeTransaction(deployer: Deployer, execParams: rtypes.ExecParams | rtypes.ExecParams[]): Promise<algosdk.ConfirmedTxInfo>;
~~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/lib/tx.d.ts:47:105 - error TS2694: Namespace '"/home/lumene/algo-builder/node_modules/algosdk/dist/types/src/main"' has no exported member 'ConfirmedTxInfo'.
47 export declare function executeSignedTxnFromFile(deployer: Deployer, fileName: string): Promise<algosdk.ConfirmedTxInfo>;
~~~~~~~~~~~~~~~
../algo-builder/packages/algob/build/lib/tx.d.ts:1:23 - error TS2688: Cannot find type definition file for 'types'.
1 /// <reference types="types" />
~~~~~
This happens usually when I try to create a network:
$ make create-private-net
https://github.com/algorandfoundation/specs/tree/3a83c4c743f8b17adfd73944b4319c25722a6782 100000
Error creating private network: invalid API token
make: *** [Makefile:6: create-private-net] Error 1
When the creation manage to works I also usually get:
$ make start-private-net
goal network start -r ./node_data
Error starting deployed network: node exited with an error code, check node.log for more details : exit status 1
make: *** [Makefile:15: start-private-net] Error 1
I didn't manage to find the node.log.
Also after the 2 commands were working I had some trouble with setup-master-account:
$ make setup-master-account
ERRO[0000] [Stack] goroutine 1 [running]:
runtime/debug.Stack(0xc0000c81c0, 0xc0000104a8, 0xc0003b5730)
runtime/debug/stack.go:24 +0x9f
github.com/algorand/go-algorand/logging.logger.Errorf(0xc0000c81c0, 0xc0000104a8, 0x11956d0, 0x42, 0xc0003ed890, 0x3, 0x3)
github.com/algorand/go-algorand/logging/log.go:229 +0x4a
github.com/algorand/go-algorand/nodecontrol.(*KMDController).StartKMD(0xc0002ad2b0, 0x3c, 0x0, 0xc0004e6960, 0xc0004adb70)
github.com/algorand/go-algorand/nodecontrol/kmdControl.go:204 +0xc96
github.com/algorand/go-algorand/libgoal.(*Client).getKMDClient(0xc0002ad250, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/algorand/go-algorand/libgoal/libgoal.go:240 +0x77
github.com/algorand/go-algorand/libgoal.(*Client).ensureKmdClient(...)
github.com/algorand/go-algorand/libgoal/libgoal.go:185
github.com/algorand/go-algorand/libgoal.(*Client).init(0xc0002ad250, 0x7fffe1d03ccc, 0x48, 0xc0004e6660, 0x51, 0xc0004e6780, 0x53, 0xc0000360b0, 0x8, 0x1, ...)
github.com/algorand/go-algorand/libgoal/libgoal.go:163 +0x286
github.com/algorand/go-algorand/libgoal.MakeClientFromConfig(0x7fffe1d03ccc, 0x48, 0xc0004e6660, 0x51, 0xc0004e6780, 0x53, 0xc0000360b0, 0x8, 0x1, 0xc0004adb50, ...)
github.com/algorand/go-algorand/libgoal/libgoal.go:128 +0x9f
main.ensureGoalClient(0x7fffe1d03ccc, 0x48, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/algorand/go-algorand/cmd/goal/commands.go:380 +0x16e
main.ensureKmdClient(...)
github.com/algorand/go-algorand/cmd/goal/commands.go:363
main.getWalletHandleMaybePassword(0x7fffe1d03ccc, 0x48, 0x0, 0x0, 0xc000264600, 0xc0002ad900, 0xea8d21, 0xc0004c0000, 0x14a, 0x34a, ...)
github.com/algorand/go-algorand/cmd/goal/commands.go:407 +0xe9
main.ensureWalletHandleMaybePassword(0x7fffe1d03ccc, 0x48, 0x0, 0x0, 0xc000118400, 0x0, 0x1, 0x1712280, 0xc0003bd6ea, 0xc0002ada1f, ...)
github.com/algorand/go-algorand/cmd/goal/commands.go:394 +0x75
main.ensureWalletHandle(...)
github.com/algorand/go-algorand/cmd/goal/commands.go:389
main.glob..func9(0x20707c0, 0xc0003e8280, 0x0, 0x2)
github.com/algorand/go-algorand/cmd/goal/account.go:460 +0xfa
github.com/spf13/cobra.(*Command).execute(0x20707c0, 0xc0003e8220, 0x2, 0x2, 0x20707c0, 0xc0003e8220)
github.com/spf13/[email protected]/command.go:766 +0x29f
github.com/spf13/cobra.(*Command).ExecuteC(0x2066180, 0x0, 0x119df1f, 0xc3)
github.com/spf13/[email protected]/command.go:852 +0x2ec
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:800
main.main()
github.com/algorand/go-algorand/cmd/goal/commands.go:155 +0x98 file=kmdControl.go function="github.com/algorand/go-algorand/nodecontrol.(*KMDController).StartKMD" line=204
ERRO[0000] /mnt/c/Users/LucaM/algolend/backend/infrastructure/node_data/PrimaryNode/kmd-v0.5: kmd data dir exists but is too permissive (777), change to (700) file=kmdControl.go function="github.com/algorand/go-algorand/nodecontrol.(*KMDController).StartKMD" line=204
Cannot contact Algorand node: kmd data dir not secure
goal account import -m "enforce drive foster uniform cradle tired win arrow wasp melt cattle chronic sport dinosaur announce shell correct shed amused dismiss mother jazz task above hospital" -d `pwd`/node_data/PrimaryNode
ERRO[0000] [Stack] goroutine 1 [running]:
runtime/debug.Stack(0xc0002e4690, 0xc00028a0a0, 0xc0003d11f0)
runtime/debug/stack.go:24 +0x9f
github.com/algorand/go-algorand/logging.logger.Errorf(0xc0002e4690, 0xc00028a0a0, 0x11956d0, 0x42, 0xc0004d2300, 0x3, 0x3)
github.com/algorand/go-algorand/logging/log.go:229 +0x4a
github.com/algorand/go-algorand/nodecontrol.(*KMDController).StartKMD(0xc00039f760, 0x3c, 0x0, 0xc0002c3f80, 0xc000483ed0)
github.com/algorand/go-algorand/nodecontrol/kmdControl.go:204 +0xc96
github.com/algorand/go-algorand/libgoal.(*Client).getKMDClient(0xc00039f700, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/algorand/go-algorand/libgoal/libgoal.go:240 +0x77
github.com/algorand/go-algorand/libgoal.(*Client).ensureKmdClient(...)
github.com/algorand/go-algorand/libgoal/libgoal.go:185
github.com/algorand/go-algorand/libgoal.(*Client).init(0xc00039f700, 0x7ffff8c17498, 0x48, 0xc0002c3c80, 0x51, 0xc0002c3da0, 0x53, 0xc000132010, 0x8, 0x1, ...)
github.com/algorand/go-algorand/libgoal/libgoal.go:163 +0x286
github.com/algorand/go-algorand/libgoal.MakeClientFromConfig(0x7ffff8c17498, 0x48, 0xc0002c3c80, 0x51, 0xc0002c3da0, 0x53, 0xc000132010, 0x8, 0x1, 0xc000483eb0, ...)
github.com/algorand/go-algorand/libgoal/libgoal.go:128 +0x9f
main.ensureGoalClient(0x7ffff8c17498, 0x48, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
github.com/algorand/go-algorand/cmd/goal/commands.go:380 +0x16e
main.ensureKmdClient(...)
github.com/algorand/go-algorand/cmd/goal/commands.go:363
main.glob..func20(0x206f260, 0xc0002833c0, 0x0, 0x4)
github.com/algorand/go-algorand/cmd/goal/account.go:1088 +0x1af
github.com/spf13/cobra.(*Command).execute(0x206f260, 0xc000283340, 0x4, 0x4, 0x206f260, 0xc000283340)
github.com/spf13/[email protected]/command.go:766 +0x29f
github.com/spf13/cobra.(*Command).ExecuteC(0x2066180, 0x0, 0x119df1f, 0xc3)
github.com/spf13/[email protected]/command.go:852 +0x2ec
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:800
main.main()
github.com/algorand/go-algorand/cmd/goal/commands.go:155 +0x98 file=kmdControl.go function="github.com/algorand/go-algorand/nodecontrol.(*KMDController).StartKMD" line=204
ERRO[0000] /mnt/c/Users/LucaM/algolend/backend/infrastructure/node_data/PrimaryNode/kmd-v0.5: kmd data dir exists but is too permissive (777), change to (700) file=kmdControl.go function="github.com/algorand/go-algorand/nodecontrol.(*KMDController).StartKMD" line=204
Cannot contact Algorand node: kmd data dir not secure
And another error about the wrong api key in after the same command(make setup-master-account) but I can't manage to simulate it again
@algo-builder/runtime installed from npm is missing a module "zod".
I expected to be able to include the module in my Node.js JavaScript project without incurring an error.
Attempting to require @algo-builder/runtime throws the following error:
Error: Cannot find module 'zod'
Possibly need to include the appropriate version of zod
in package.json
.
npm init -y
npm install @algo-builder/runtime
index.js
and add const runtime = require("@algo-builder/runtime")
node index.js
You should see the following error:
> node index.js
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'zod'
I tried installing "zod" like this npm install zod
, but that results in a different error when running node index.js
:
> node index.js
internal/modules/cjs/loader.js:438
throw e;
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/src/ZodError' is not defined by "exports" in ...\algo-builder-test\node_modules\zod\package.json
Currently, when loading a smart-contract template (lsig or app) we need to repeat the template parameters.
Context: https://discord.com/channels/491256308461207573/806180598703587358/902125991734939719
In the typescript example, after doing yarn build
:
yarn run algob deploy
yarn run algob run scripts/withdraw/htlc-withdraw.js
return errors because there is no script in scripts(only ts files)
The solution should be to change the algob scripts folder to build/scripts
Great framework unmatched by itโs look! Here you go!
The ideas behind it are hopefully obvious to you guys. Feel free to use it and contact if you like also the vector files.
Fees have been updated in algorand where there is now pooled transaction fees https://developer.algorand.org/articles/introducing-algorand-virtual-machine-avm-09-release/. This applies to all TEAL versions - not just TEAL4.
If for example you want to buy an asset from an escrow; you group together a payment to the escrow (tx0) and the asset transfer from the escrow (tx1). You should be able to have tx0 fee 2000 and tx1 fee 0.
When you try and use a fee less than 1000 then it is automically switched to 1000.
Algob is still relying on PyTeal w/ TEAL4 support, limiting developers access to new TEAL versions. PyTeal added support for the TEAL 5 release a few weeks ago
Update algob dependencies and runtime to support upstream PyTeal
This is not a major issue, but when you have multiple files in the root of scripts/ and one doesn't have an export default(probably if it's the first identified by algob during the deploy, ex. in my case common.js was choosen before deploy.js) the command will fail. Obviously, you can still do yarn algob deploy scripts/deploy.js
but it's just to clarify that. Solution would be to check scripts files for an export default or simply suggest the user to specify the deploy script, temporary solution is to have the deploy in the root of scripts and leave the others in a subfolder.
Hello, I have been trying to run tests on my smart contracts using algo-builder. I have looked through your examples and docs to figure out how to deploy a stateful smart contract (I need it to be deployed as an atomic transaction). I came up with the following code based on the documentation:
describe('Stateful Contract Deployment', function () {
let master;
let runtime;
const approvalProgram = getProgram('winner_approval.teal');
const clearStateProgram = getProgram('participant_clear_state.teal');
this.beforeEach(async function () {
master = new AccountStore(masterBalance);
runtime = new Runtime([master]);
});
it('Should not fail if app is deployed as an atomic transaction', () => {
const validTxFee = 1000;
transactionGroup = [
{
type: types.TransactionType.DeploySSC,
sender: master.account,
approvalProgram: approvalProgram,
clearProgram: clearStateProgram,
globalBytes: 5,
globalInts: 4,
localBytes: 0,
localInts: 0,
appArgs: [
"int:0",
"int:25412621"
],
payFlags: { totalFee: validTxFee }
}
]
runtime.executeTx(transactionGroup);
});
});
I have removed some snippets of my tests to highlight the problematic transaction which is the DeploySSC transaction. When I try to execute my test, the code crashes and produces the following error:
Error: address seems to be malformed
at Object.<anonymous> (/home/paul/Desktop/test-algob/node_modules/algosdk/src/encoding/address.js:13:33)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/paul/Desktop/test-algob/node_modules/algosdk/src/main.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/paul/Desktop/test-algob/node_modules/algosdk/index.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/paul/Desktop/test-algob/node_modules/@algo-builder/runtime/build/account.js:4:19)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/paul/Desktop/test-algob/node_modules/@algo-builder/runtime/build/index.js:23:19)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/paul/Desktop/test-algob/node_modules/@algo-builder/algob/build/index.js:23:19)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (test/sample-test.js:1:24)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
at async Loader.import (internal/modules/esm/loader.js:177:24)
I have searched for answers to see if it's something that I'm doing wrong but there are no resources that show deploying a stateful smart contract as an atomic transaction. However, I would expect what I've done to be correct based on the documentation but it produces errors.
In runtime test the function Console.log() doesn't print anything within the "it" sections.
Got error when using substring3
opcode. But work well with the Algorand goal
command line.
Run substring3 successful
Return error when running substring3
Error
Error: RUNTIME_ERR1003: Type of data is incorrect. Expected byte[] but got bigint at line 14
This contract uses teal version 5.
Filename: string.teal.
#pragma version 5
int 0
txn ApplicationID
==
bnz on_creation
byte "result"
byte "this_is_not_bug"
int 0
int 1
substring3
app_global_put
int 1
return
on_creation:
int 1
return
const { getProgram } = require('@algo-builder/algob');
const { Runtime, AccountStore } = require('@algo-builder/runtime');
const { types } = require('@algo-builder/web');
const { assert } = require('chai');
const { convert } = require('@algo-builder/algob');
const minBalance = BigInt(1e6);
const masterBalance = BigInt(10e6);
const amount = BigInt(1e6);
describe("Test String", function () {
let testAccount;
let runtime;
let executorProgram;
let appID;
this.beforeEach(async () => {
// prepare smart contract
testAccount = new AccountStore(masterBalance);
runtime = new Runtime([testAccount]);
executorProgram = getProgram("string.teal");
// deploy application
appID = runtime.addApp({
sender: testAccount.account,
globalBytes: 32,
globalInts: 32,
localBytes: 8,
localInts: 8
}, {}, executorProgram);
});
function syncAccounts() {
testAccount = runtime.getAccount(testAccount.address);
}
it("Test", () => {
const fee = 4000;
const txnParams = {
type: types.TransactionType.CallApp,
sign: types.SignType.SecretKey,
fromAccount: testAccount.account,
appID: appID,
payFlags: { totalFee: fee }
};
runtime.executeTx(txnParams);
const result = runtime.getGlobalState(txnParams.appID, 'result');
console.log(result);
})
})
Thanks for your support! โค๏ธ
We are observing an error which seems to be stemming from algob runtime. It is not observed when goal is used directly. Below is the description:
Consider the following PyTEAL contract:
from pyteal import *
def approval_program():
on_create = Seq([
App.globalPut(Concat(Txn.application_args[0], Bytes("test_")), Btoi(Txn.application_args[0])),
Int(1),
])
on_closeout = Int(1)
on_opt_in = Int(1)
on_test = App.globalGet(Concat(Itob(Txn.xfer_asset()), Bytes("test_")))
program = Cond(
[Txn.application_id() == Int(0), on_create],
[Txn.on_completion() == OnComplete.CloseOut, on_closeout],
[Txn.on_completion() == OnComplete.OptIn, on_opt_in],
[Txn.type_enum() == TxnType.AssetTransfer, on_test],
)
return program
Steps:
This is when we are using the Runtime in algob to execute the transactions.
The app args array for the creation call is: [
int:${assetID}]
The creation call is:
{
type: types.TransactionType.CallNoOpSSC,
sign: types.SignType.SecretKey,
fromAccountAddr: fromAccount,
appId: applicationId,
appArgs: [`int:${assetID}`],
payFlags: { totalFee: systemFee }
}
The asset transfer call to call on_test is:
{
type: types.TransactionType.TransferAsset,
sign: types.SignType.SecretKey,
fromAccountAddr: fromAccount ,
toAccountAddr: toAccount,
amount: amount,
assetID: assetID,
payFlags: { totalFee: systemFee }
};
We get the below error from runtime: "type of data is incorrect. Expected object but got bigint at line 325"
Could you please help with the same?
The error is not obtained when steps 1 to 4 are done using goal.
Hi, I have been trying to run test cases that involve Atomic Transfers. However, when I try to add an application using TransactionType.DeploySSC it executes but the app is not added/deployed to the store.
<ref *1> Runtime {
store: {
accounts: Map(1) {
'6JHI7HVPHRALW3JO5NMFAKUNJVLLV7NTNC3D645MLYNJ7EJWVDVRCUIQO4' => [AccountStore]
},
globalApps: Map(0) {},
assetDefs: Map(0) {}
},
When I try to add the same Stateful Smart Contract using the runtime.addApp function, it works properly resulting in this:
<ref *1> Runtime {
store: {
accounts: Map(1) {
'XDKZ6KLRFR7WD4LAKAAKZ6FUOOUHEFOZ6SANFQ2CHTE4HI437HLQRPTX3Q' => [AccountStore]
},
globalApps: Map(1) {
1 => 'XDKZ6KLRFR7WD4LAKAAKZ6FUOOUHEFOZ6SANFQ2CHTE4HI437HLQRPTX3Q'
},
assetDefs: Map(0) {}
},
This is the code I have written in order to deploy an app, I'm quite sure it's correct but I may be wrong once again:
runtime.executeTx(
{
type: types.TransactionType.DeploySSC,
sign: types.SignType.SecretKey,
fromAccount: master.account,
approvalProgram: approvalProgram,
globalBytes: 5,
globalInts: 4,
localBytes: 0,
localInts: 0,
appArgs: [
"int:0",
"int:25412621"
],
payFlags: { totalFee: 1000 }
}
)
You cannot opt into an asset using asset transfer transaction.
Should be able to opt into an asset with asset transfer transaction.
Error: RUNTIME_ERR1404: Account ENBABX5NX4CCBETS2MJWYFIGTXA6TVTML7FBDLNR4NIPMYEKT2VHM7JWEQ doesn't hold asset index 1
from this line https://github.com/scale-it/algo-builder/blob/master/packages/runtime/src/ctx.ts#L277
You should catch the error thrown and check for this https://github.com/scale-it/algo-builder/blob/master/packages/runtime/src/ctx.ts#L281 and then only throw the error if you are not opting into asset.
Create runtime asset transfer transaction with 0 amount and same sender and asset receiver.
I have tried to install in an Ubuntu docker container and on my Pop-OS desktop machine.
When I try to install using npm, it gives an error 'no such file or directory' ... 'This is related to npm not being able to find a file.'.
When I try to install using yarn, it installs but on usage gives: 'Error: Cannot find module '@nodelib/fs.walk''
I expect the package to install without stating that a file or module is missing.
On npm install -g @algo-builder/algob
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /usr/local/lib/node_modules/@algo-builder/algob/node_modules/@algo-builder/runtime/build/algod.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/@algo-builder/algob/node_modules/@algo-builder/runtime/build/algod.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mark/.npm/_logs/2021-08-01T05_08_22_306Z-debug.log
On yarn global add @algo-builder/algob
, and then algob
:
Error: Cannot find module '@nodelib/fs.walk'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/lib/files.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/lib/asa.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/account.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/index.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/algob/build/errors/errors.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/algob/build/internal/cli/cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/src/lib/files.ts:1:1)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
Yarn installs it properly in my docker container. However, there appears to be a missing module error during usage as shown above.
Yarn isn't configured properly on my Pop-OS desktop machine, and not sure how to fix - so I haven't tried with yarn.
TBA.
Install via npm:
docker run -it ubuntu
apt update -y
apt install wget -y
# Install node 14 with nvm
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install 14
# Install algo-builder
npm install -g @algo-builder/algob -y
Result:
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /root/.nvm/versions/node/v14.17.4/lib/node_modules/@algo-builder/algob/node_modules/@algo-builder/runtime/build/algod.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/root/.nvm/versions/node/v14.17.4/lib/node_modules/@algo-builder/algob/node_modules/@algo-builder/runtime/build/algod.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-08-01T05_31_41_660Z-debug.log
Install via yarn:
# ...
npm install -g yarn
yarn global add @algo-builder/algob
algob
Result:
Error: Cannot find module '@nodelib/fs.walk'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/lib/files.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/lib/asa.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/account.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/build/index.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/algob/build/errors/errors.js
- /usr/local/share/.config/yarn/global/node_modules/@algo-builder/algob/build/internal/cli/cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/@algo-builder/runtime/src/lib/files.ts:1:1)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
I've attempted to execute an atomic transaction within a script but get the following error:
TypeError: deployer.getSSCfromCPKey is not a function
at Object.registerCheckpoints (/home/paul/Desktop/algo_proj/algo-builder/packages/algob/src/lib/script-checkpoints.ts:235:32)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at executeTransaction (/home/paul/Desktop/algo_proj/algo-builder/packages/algob/src/lib/tx.ts:243:5)
at Object.run [as default] (/home/paul/Desktop/algo_proj/project_files/scripts/0-sampleScript.js:51:16)
at Object.runScript (/home/paul/.config/yarn/global/node_modules/@algo-builder/algob/src/internal/util/scripts-runner.ts:75:5)
at runSortedScripts (/home/paul/.config/yarn/global/node_modules/@algo-builder/algob/src/builtin-tasks/run.ts:108:5)
at Object.runMultipleScripts (/home/paul/.config/yarn/global/node_modules/@algo-builder/algob/src/builtin-tasks/run.ts:66:5)
at executeDeployTask (/home/paul/.config/yarn/global/node_modules/@algo-builder/algob/src/builtin-tasks/deploy.ts:85:10)
at Environment._runTaskDefinition (/home/paul/.config/yarn/global/node_modules/@algo-builder/algob/src/internal/core/runtime-environment.ts:173:14)
at Environment.run (/home/paul/.config/yarn/global/node_modules/@algo-builder/algob/src/internal/core/runtime-environment.ts:99:12)
Here is the code I'm running (I have written tests to execute this same transaction using runtime.execute()
and it works for the tests but not here):
const {
executeTransaction,
} = require('@algo-builder/algob');
const { types } = require('@algo-builder/runtime');
async function run (_, deployer) {
const contractOwnerAccount = deployer.accountsByName.get('contract_owner_1');
const developerAccount = deployer.accountsByName.get('developer_1');
const escrowAccount = await deployer.loadLogic('escrow_contract.teal');
// const donorAccount = deployer.accountsByName.get('john');
approvalProgram = 'winner_approval.teal';
clearProgram = 'participant_clear_state.teal';
const submissionBegin = 0;
const submissionEnd = 15797462;
const globalBytes = 5;
const globalInts = 4;
const validTxFee = 1000;
const CONTRACT_FUNDS = 202000;
let response;
const algoTxnParams = [{
type: types.TransactionType.DeploySSC,
sign: types.SignType.SecretKey,
fromAccount: contractOwnerAccount,
approvalProgram,
clearProgram,
localInts: 0,
localBytes: 0,
globalInts,
globalBytes,
appArgs: [
`int:${submissionBegin}`,
`int:${submissionEnd}`
],
payFlags: { totalFee: validTxFee }
},
{
type: types.TransactionType.TransferAlgo,
sign: types.SignType.SecretKey,
fromAccount: contractOwnerAccount,
toAccountAddr: escrowAccount.address(),
amountMicroAlgos: CONTRACT_FUNDS,
payFlags: { totalFee: validTxFee }
}]
try {
response = await executeTransaction(deployer, algoTxnParams)
} catch (error){
console.log(error);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.