profile
viewpoint

Ehofas/rocketPuncher-client 0

Rocket puncher client

Ehofas/rocketPuncher-server 0

Table tennis - the new way

eoslithuania/honest-producers-old 0

EOS Block producer webpage analysis

Invertisment/4clj-impl 0

4clojure.com problem implementations. (Only the ones that took longer than others)

Invertisment/algob-asa-deploy-opt-in 0

Algorand builder sample project that deploys ASA and opts in two accounts

Invertisment/Android-WebGrep 0

Service to download a webpage and execute multiple Java regex for content

Invertisment/angular-cli-git 0

Angular CLI in Docker

Invertisment/beehive 0

A flexible event/agent & automation system with lots of bees 🐝

push eventInvertisment/cljs-tetris

Martynas M

commit sha 75551f49eb987355215122be3f49708a2bc02e80

style.css added to git build

view details

push time in 12 days

push eventInvertisment/cljs-tetris

Martynas M

commit sha 60f5d0a1e262719dab6e15631e3f1b2e5a0860b5

New genome

view details

push time in 12 days

startedzwaldeck/mollie

started time in 15 days

issue openedKah0ona/mollie-clj

This one uses v1, whereas there is already v2 API

https://docs.mollie.com/payments/migrating-v1-to-v2

created time in 15 days

startedKah0ona/mollie-clj

started time in 15 days

issue openedAssemblyPayments/android-sdk

PromisePay declares public key but doesn't use it

I'm trying to figure out the API and I've found an unused public key: https://github.com/AssemblyPayments/android-sdk/blob/6b96c511155a802262866dc42c3b672a2efc7993/promisepay/src/main/java/com/github/promisepay/PromisePay.java#L57

I'd suggest to remove the publicKey parameter as it creates a false assumption of security. Also it creates a publicKey dependency in the app and then it's not used. Probably it still requires a full-featured library at the backend (assuming this is an Android front-end library).

created time in 15 days

issue openedAssemblyPayments/android-sdk

Why not Java sdk?

All major languages were supported but Java wasn't. I write my backend in Clojure so I'd benefit from Java version a little.

created time in 15 days

issue commentStudistCorporation/ring-accept-language

Explain usage details in README

Import from here: https://clojars.org/jp.studist/ring-accept-language

Use like this:

(ns my-ns 
  (:require [ring.middleware.accept-language :as accept-language]))

(defn get-best-language-list [req]
  (->> req ;; {:headers {"accept-language" "en-US,en;q=0.5"}}
       (accept-language/accept-language-request)
       :accept-language
       (sort-by second)
       reverse))

If req is the same as in the comment then this is the output: (["en-US" 1.0] ["en" 0.5])

taurauko

comment created time in a month

issue commentscale-it/algorand-builder

Connection Error to the js-algorand-sdk package

If you have a local mirror site you should somehow make sure that it came from our repository and that it's compiled correctly. This is what I have in my yarn.lock after a successful install:

algob@^0.0.3:
  version "0.0.3"
  resolved "https://registry.yarnpkg.com/algob/-/algob-0.0.3.tgz#6ea5f46463ffb183e443b10ccca9c7a7ad79d243"
  integrity sha512-g9uKdoi5SmHh9ujBeNn92ao/wHymibiWc785UvbClp40769aiawBeZHyaUIVzG/m/3mI9K9izLsr8C06Hilvhg==
  dependencies:
    algosdk "github:algorand/js-algorand-sdk#v1.7.0-beta"
...

And if I go to https://registry.yarnpkg.com/algob then I can find a link to our github repository: git+https://github.com/scale-it/algorand-builder.git

I don't know which version is deployed to https://www.npmjs.com/package/algob/v/0.0.3 but it has to be a commit of a master branch.


If none of this suggests a solution then you can compile algob by hand and do yarn link to have it locally. We currently don't have a way to import directly from github because we have a monorepo project (this would be a way to not have a npmjs package this early).

To run a linked package with yarn you can do this (assuming you use unix-like terminal):

git clone https://github.com/scale-it/algorand-builder/
cd algorand-builder/packages/algob
yarn build
yarn link

Then go to your project, and execute yarn link algob

This will add a link in your project (not exactly this way but it works similarly to this): project/node_modules/algob -> ~/.../algorand-builder/packages/algob/build/

Then if you have your local yarn bin/ directory in $PATH you'll be able to even use the CLI tool (as you would regularly): $> algob -h

Mine77

comment created time in 2 months

PR opened scale-it/algorand-builder

Sphinx text-based docs
+177 -1

0 comment

9 changed files

pr created time in 2 months

create barnchscale-it/algorand-builder

branch : sphinx-text-based

created branch time in 2 months

create barnchscale-it/algorand-builder

branch : docs-typedoc

created branch time in 2 months

push eventscale-it/algorand-builder

Invertisment

commit sha 9ef8e9303d569b2b8f43300cc45b612f381011ac

Doc requirements moved to algob/docs

view details

Invertisment

commit sha 23d4b84fff7f0e1bcb00e72d92063972052672e5

Nonworking sphinx

view details

push time in 2 months

push eventscale-it/algorand-builder

Invertisment

commit sha 104657369dd511b6c6508bd8058ce59be2373cf2

readthedocs.io master_doc

view details

push time in 2 months

create barnchscale-it/algorand-builder

branch : auto-docs

created branch time in 2 months

push eventscale-it/algorand-builder

Martynas M

commit sha 310ec529b6f5f471f00fef96305ecc494caff25b

Deployer moved to internal (#79)

view details

push time in 2 months

delete branch scale-it/algorand-builder

delete branch : move-deployer-to-internal

delete time in 2 months

PR merged scale-it/algorand-builder

Move deployer to package `internal`

Depends on #75 being merged.

+10 -10

1 comment

4 changed files

Invertisment

pr closed time in 2 months

push eventscale-it/algorand-builder

Robert Zaremba

commit sha 7be76d0990f93a946029a446ee5d7a2b2caa65ba

cosmetic: TxParams comment update

view details

Martynas M

commit sha f42635c6740082652fb140586450afe167af164f

Asa opt-in with balance check (#75) * Run task optimized to use less file IO * Scripts: ASA always loads only once * Construct Account index before executing scripts * ASA validation includes opt-ins * ASA opt-in from asa.yaml with balance check * Deployer comment on algodClient method * Deployer.optInToASA * asa opt-in takes account as accountName * Example: tesla uses manual ASA opt-in

view details

Invertisment

commit sha dac2d0155c56e35195c56601e9074cff6994a17f

Deployer moved to internal

view details

push time in 2 months

push eventscale-it/algorand-builder

Martynas M

commit sha f42635c6740082652fb140586450afe167af164f

Asa opt-in with balance check (#75) * Run task optimized to use less file IO * Scripts: ASA always loads only once * Construct Account index before executing scripts * ASA validation includes opt-ins * ASA opt-in from asa.yaml with balance check * Deployer comment on algodClient method * Deployer.optInToASA * asa opt-in takes account as accountName * Example: tesla uses manual ASA opt-in

view details

push time in 2 months

delete branch scale-it/algorand-builder

delete branch : asa-opt-in

delete time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 declare module 'algosdk' {    type TxnBytes = Uint8Array +  type Address = string++  interface AccountAssetInfo {+    amount: number,+    'asset-id': number,+    creator: Address,+    'is-frozen': false
 'is-frozen': boolean
Invertisment

comment created time in 2 months

PullRequestReviewEvent

push eventscale-it/algorand-builder

Invertisment

commit sha a2b1d61d3dd658c3b3141589f97963a2c6d1245f

Improvement by Amit

view details

Invertisment

commit sha a1142217e68611c1206a5aa8fa3c12be22cca87f

Example: Ignore artifacts

view details

Invertisment

commit sha bdad1ba51717edaf73d1732a514fd9dbbfad7ca4

Deployer moved to internal

view details

push time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {

It will work but it will be even harder to understand what it does. And it will be faster.

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {+  return getLast(getLast(ts));+}++export function partitionByFn<T> (+  f: (s: T, s1: T) => boolean,

6 7 5 2 3 1 -> [[6 7] [5] [2 3] [1]]

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export async function runMultipleScriptsOneByOne (   allowWrite: boolean,   algoOp: AlgoOperator ): Promise<void> {-  for (const script of scriptNames) {-    await runMultipleScripts(+  const accounts = mkAccountIndex(runtimeEnv.network.config.accounts);+  const asaDefs = loadASAFile(accounts);+  for (const scriptsBatch of batchScriptNames(scriptNames)) {+    await runScriptsBatch(       runtimeEnv,-      [script],+      scriptsBatch,       onSuccessFn,       force,       logDebugTag,-      allowWrite,-      algoOp+      (cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs, accounts)

I alread restored the code to the method with many variables. And for now the DeployerImpl's constructor doesn't have many variables so the type there is not needed.

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export async function runMultipleScriptsOneByOne (   allowWrite: boolean,   algoOp: AlgoOperator ): Promise<void> {-  for (const script of scriptNames) {-    await runMultipleScripts(+  const accounts = mkAccountIndex(runtimeEnv.network.config.accounts);+  const asaDefs = loadASAFile(accounts);+  for (const scriptsBatch of batchScriptNames(scriptNames)) {+    await runScriptsBatch(       runtimeEnv,-      [script],+      scriptsBatch,       onSuccessFn,       force,       logDebugTag,-      allowWrite,-      algoOp+      (cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs, accounts)

You didn't understand what I meant by "know types". There are two functions: Outer one:runMultipleScripts and inner one: runSortedScripts. The outer one does some IO and creates some variables. The inner one does only use CPRepo and has to load it inside. It also needs Deployer to send it to the script method. That's it. It doesn't need to care about any other variables so I encapsulated it in a function.

The function type is simpler than the type which you propose because it takes only CPRepo and produces Deployer. What you propose is to have a type with 4 or more fields that are still visible to the inner function. It could be that this type signals that we have too much logic in Deployer already and we should limit it.

Now what you want is not only to show the variables to the inner function but to create a larger type in a completely different file to solve the issue with first file. If we will end up having 20 variables in DeployerImpl's constructor then it's probably an issue with DeployerImpl class and not with this function.

And the object will still need to be created so my function solution would still have worked in the exact same way. Except instead of having a type with four or more fields I had a type with input and output. And my top-level mkDeployer function has more fields too.

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export async function runMultipleScriptsOneByOne (   allowWrite: boolean,   algoOp: AlgoOperator ): Promise<void> {-  for (const script of scriptNames) {-    await runMultipleScripts(+  const accounts = mkAccountIndex(runtimeEnv.network.config.accounts);+  const asaDefs = loadASAFile(accounts);+  for (const scriptsBatch of batchScriptNames(scriptNames)) {+    await runScriptsBatch(       runtimeEnv,-      [script],+      scriptsBatch,       onSuccessFn,       force,       logDebugTag,-      allowWrite,-      algoOp+      (cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs, accounts)

And even when we'll add an object then either:

  • Deployer.constructor will take it as a parameter (probably even add it to types.ts and make it public to everything)
  • Destructure the object inside of the method but then everything is still visible to the method.
  • Curried function (I used this way to have only one param instead of several)
  • Pass everything -- Equivalent to object but without a type and without showing it to the whole app. These ways are fine depending on the style that you prefer to use.
Invertisment

comment created time in 2 months

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export async function runMultipleScriptsOneByOne (   allowWrite: boolean,   algoOp: AlgoOperator ): Promise<void> {-  for (const script of scriptNames) {-    await runMultipleScripts(+  const accounts = mkAccountIndex(runtimeEnv.network.config.accounts);+  const asaDefs = loadASAFile(accounts);+  for (const scriptsBatch of batchScriptNames(scriptNames)) {+    await runScriptsBatch(       runtimeEnv,-      [script],+      scriptsBatch,       onSuccessFn,       force,       logDebugTag,-      allowWrite,-      algoOp+      (cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs, accounts)

Then we'll need a type and I preferred to use functions so I used them. runSortedScripts doesn't need to know everything about internals of deployer so I prefer to remove what is not needed by it and make runSortedScripts not care instead of having huge objects that can be interacted from every place. It's a viable strategy both ways but I preferred to know less where I don't need to know.

Invertisment

comment created time in 2 months

push eventscale-it/algorand-builder

Amit Yadav

commit sha 4128bce4e716abcbe1bf8c71af2b8fab27efd914

Store output of transaction (#74) * Print output of transaction

view details

Robert Zaremba

commit sha b99ddd525f46c28681021ba65ee24ee7909198da

Milestone review (#76) * TxParams: update the structure * sample-project: fix fee check * README updates * fix checkpoint docs

view details

Invertisment

commit sha d34e060cfd3473aa7ecc80d8ce6c7d0d530a9b2d

Merge remote-tracking branch 'origin/master' into asa-opt-in

view details

Invertisment

commit sha e04d6f072a802031eeff14d296632126eca247c7

Renaming and mkDeployer fn removal

view details

Invertisment

commit sha 50ab093d1950823c612deebb0be4b3ccfdeed8be

Example: Ignore artifacts

view details

Invertisment

commit sha 3760c451216b638699a0167154def1b091f5dd21

Deployer moved to internal

view details

push time in 2 months

push eventscale-it/algorand-builder

Invertisment

commit sha e04d6f072a802031eeff14d296632126eca247c7

Renaming and mkDeployer fn removal

view details

push time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 function loadCheckpointsIntoCPData (cpData: CheckpointRepo, scriptPaths: string[   return checkpointData; } -// TODO: Reduce file IO:-// Function only accepts sorted scripts -- only this way it loads the state correctly.-// Optimization: Split the scripts into sorted array chunks and run those chunks-// This will save some disk reads because sub-arrays will be sorted-export async function runMultipleScriptsOneByOne (+function batchScriptNames (unbatched: string[]): string[][] {+  return partitionByFn(+    (a: string, b: string) => cmpStr(a, b) === 1,+    unbatched);+}

Added this:

/** Partitions an unsorted string list into sorted parts:
    `[1 2 2 3 4 3 4 2 1]` returns `[[1 2 2 3 4] [3 4] [2] [1]]` */
function partitionIntoSorted (unsorted: string[]): string[][] {
  return partitionByFn(
    (a: string, b: string) => cmpStr(a, b) === 1, // split when a > b
    unsorted);
}
Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {+  return getLast(getLast(ts));+}++export function partitionByFn<T> (+  f: (s: T, s1: T) => boolean,

This is then later passed to the CP loading method which loads all preceding checkpoints: For instance I have CPs 1 2 3 4. Then I want to execute scripts 2 3 1 which will produce an order of: [[2 3] [1]] Then [2 3] will: load CPs 1, 2 then execute script 2. Then load 3 and execute 3. The last [1] part will load CP 1 and execute script 1

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export async function runMultipleScriptsOneByOne (   allowWrite: boolean,   algoOp: AlgoOperator ): Promise<void> {-  for (const script of scriptNames) {-    await runMultipleScripts(+  const accounts = mkAccountIndex(runtimeEnv.network.config.accounts);+  const asaDefs = loadASAFile(accounts);+  for (const scriptsBatch of batchScriptNames(scriptNames)) {+    await runScriptsBatch(       runtimeEnv,-      [script],+      scriptsBatch,       onSuccessFn,       force,       logDebugTag,-      allowWrite,-      algoOp+      (cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs, accounts)

Ok. Added 4 parameters to the method to not create a function:

  allowWrite: boolean,
  algoOp: AlgoOperator,
  asaDefs: ASADefs,
  accounts: Accounts

Now the method takes 9 parameters of which 4 is exclusively used for mkDeployer function.

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export class AlgoOperatorImpl implements AlgoOperator {     }   }; +  getTxFee (params: algosdk.SuggestedParams, txSize: number): number {+    if (params.flatFee) {+      return Math.max(ALGORAND_MIN_TX_FEE, params.fee);+    }+    return Math.max(ALGORAND_MIN_TX_FEE, txSize);+  }++  getUsableAccBalance (accoutInfo: algosdk.AccountInfo): number {+    // Extracted from interacting with Algorand node:+    // 7 opted-in assets require to have 800000 micro algos (frozen in account).+    // 11 assets require 1200000.+    return accoutInfo.amount - (accoutInfo.assets.length + 1) * ALGORAND_ASA_OWNERSHIP_COST;+  }++  getOptInTxSize (params: algosdk.SuggestedParams, accounts: Accounts): number {+    const randomAccount = accounts.values().next().value;+    // assetID can't be known before ASA creation+    // it shouldn't be easy to find out the latest asset ID+    // In original source code it's uint64:+    // https://github.com/algorand/go-algorand/blob/1424855ad2b5f6755ff3feba7e419ee06f2493da/data/basics/userBalance.go#L278+    const assetID = Number.MAX_SAFE_INTEGER; // not 64 bits but 55 bits should be enough+    const sampleASAOptInTX = tx.makeASAOptInTx(randomAccount.addr, assetID, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(randomAccount.sk);+    return rawSignedTxn.length;+  }++  async optInToASA (+    asaName: string, assetIndex: number, account: Account, params: algosdk.SuggestedParams+  ): Promise<void> {+    console.log(`ASA ${account.name} opt-in for for ASA ${asaName}`);+    const sampleASAOptInTX = tx.makeASAOptInTx(account.addr, assetIndex, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(account.sk);+    const txInfo = await this.algodClient.sendRawTransaction(rawSignedTxn).do();+    await this.waitForConfirmation(txInfo.txId);+  }++  async optInToASAMultiple (+    asaName: string, assetIndex: number, accounts: Account[], params: algosdk.SuggestedParams+  ): Promise<void> {+    for (const account of accounts) {+      await this.optInToASA(asaName, assetIndex, account, params);+    }+  }++  async checkASAOptInAccountBalances (

checkBalanceForOptInTx

Invertisment

comment created time in 2 months

PullRequestReviewEvent

push eventscale-it/algorand-builder

Amit Yadav

commit sha 4128bce4e716abcbe1bf8c71af2b8fab27efd914

Store output of transaction (#74) * Print output of transaction

view details

Robert Zaremba

commit sha b99ddd525f46c28681021ba65ee24ee7909198da

Milestone review (#76) * TxParams: update the structure * sample-project: fix fee check * README updates * fix checkpoint docs

view details

Invertisment

commit sha d34e060cfd3473aa7ecc80d8ce6c7d0d530a9b2d

Merge remote-tracking branch 'origin/master' into asa-opt-in

view details

push time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export class AlgoOperatorImpl implements AlgoOperator {     }   }; +  getTxFee (params: algosdk.SuggestedParams, txSize: number): number {+    if (params.flatFee) {+      return Math.max(ALGORAND_MIN_TX_FEE, params.fee);+    }+    return Math.max(ALGORAND_MIN_TX_FEE, txSize);+  }++  getUsableAccBalance (accoutInfo: algosdk.AccountInfo): number {+    // Extracted from interacting with Algorand node:+    // 7 opted-in assets require to have 800000 micro algos (frozen in account).+    // 11 assets require 1200000.+    return accoutInfo.amount - (accoutInfo.assets.length + 1) * ALGORAND_ASA_OWNERSHIP_COST;+  }++  getOptInTxSize (params: algosdk.SuggestedParams, accounts: Accounts): number {+    const randomAccount = accounts.values().next().value;+    // assetID can't be known before ASA creation+    // it shouldn't be easy to find out the latest asset ID+    // In original source code it's uint64:+    // https://github.com/algorand/go-algorand/blob/1424855ad2b5f6755ff3feba7e419ee06f2493da/data/basics/userBalance.go#L278+    const assetID = Number.MAX_SAFE_INTEGER; // not 64 bits but 55 bits should be enough+    const sampleASAOptInTX = tx.makeASAOptInTx(randomAccount.addr, assetID, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(randomAccount.sk);+    return rawSignedTxn.length;+  }++  async optInToASA (+    asaName: string, assetIndex: number, account: Account, params: algosdk.SuggestedParams+  ): Promise<void> {+    console.log(`ASA ${account.name} opt-in for for ASA ${asaName}`);+    const sampleASAOptInTX = tx.makeASAOptInTx(account.addr, assetIndex, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(account.sk);+    const txInfo = await this.algodClient.sendRawTransaction(rawSignedTxn).do();+    await this.waitForConfirmation(txInfo.txId);+  }

It looks like I have an old code. DeploymentFlags was the old name of TxParams

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export async function runMultipleScriptsOneByOne (   allowWrite: boolean,   algoOp: AlgoOperator ): Promise<void> {-  for (const script of scriptNames) {-    await runMultipleScripts(+  const accounts = mkAccountIndex(runtimeEnv.network.config.accounts);+  const asaDefs = loadASAFile(accounts);+  for (const scriptsBatch of batchScriptNames(scriptNames)) {+    await runScriptsBatch(       runtimeEnv,-      [script],+      scriptsBatch,       onSuccessFn,       force,       logDebugTag,-      allowWrite,-      algoOp+      (cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs, accounts)

What else would you want to use to preserve loaded runtimeEnv and other arguments when cpData is reloaded inside of runScript?

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 function loadCheckpointsIntoCPData (cpData: CheckpointRepo, scriptPaths: string[   return checkpointData; } -// TODO: Reduce file IO:-// Function only accepts sorted scripts -- only this way it loads the state correctly.-// Optimization: Split the scripts into sorted array chunks and run those chunks-// This will save some disk reads because sub-arrays will be sorted-export async function runMultipleScriptsOneByOne (+function batchScriptNames (unbatched: string[]): string[][] {+  return partitionByFn(+    (a: string, b: string) => cmpStr(a, b) === 1,+    unbatched);+}

Then the function would split when it will encounter not a smaller element but equal one: [1 2 2 3 4 3 2 1] would return [[1 2] [2 3 4 3 2 1]]. And as it runs sequentially from left to right it preserves the order which is important for me. This is not grouping and more of a splitting of a list. There is no sorting so sorted doesn't belong here. The order is not changed.

Invertisment

comment created time in 2 months

PullRequestReviewEvent

create barnchscale-it/algorand-builder

branch : move-deployer-to-internal

created branch time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export class AlgoOperatorImpl implements AlgoOperator {     }   }; +  getTxFee (params: algosdk.SuggestedParams, txSize: number): number {+    if (params.flatFee) {+      return Math.max(ALGORAND_MIN_TX_FEE, params.fee);+    }+    return Math.max(ALGORAND_MIN_TX_FEE, txSize);+  }++  getUsableAccBalance (accoutInfo: algosdk.AccountInfo): number {+    // Extracted from interacting with Algorand node:+    // 7 opted-in assets require to have 800000 micro algos (frozen in account).+    // 11 assets require 1200000.+    return accoutInfo.amount - (accoutInfo.assets.length + 1) * ALGORAND_ASA_OWNERSHIP_COST;+  }++  getOptInTxSize (params: algosdk.SuggestedParams, accounts: Accounts): number {+    const randomAccount = accounts.values().next().value;+    // assetID can't be known before ASA creation+    // it shouldn't be easy to find out the latest asset ID+    // In original source code it's uint64:+    // https://github.com/algorand/go-algorand/blob/1424855ad2b5f6755ff3feba7e419ee06f2493da/data/basics/userBalance.go#L278+    const assetID = Number.MAX_SAFE_INTEGER; // not 64 bits but 55 bits should be enough+    const sampleASAOptInTX = tx.makeASAOptInTx(randomAccount.addr, assetID, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(randomAccount.sk);+    return rawSignedTxn.length;+  }++  async optInToASA (+    asaName: string, assetIndex: number, account: Account, params: algosdk.SuggestedParams+  ): Promise<void> {+    console.log(`ASA ${account.name} opt-in for for ASA ${asaName}`);+    const sampleASAOptInTX = tx.makeASAOptInTx(account.addr, assetIndex, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(account.sk);+    const txInfo = await this.algodClient.sendRawTransaction(rawSignedTxn).do();+    await this.waitForConfirmation(txInfo.txId);+  }

Example updated. tesla will do the manual opt-in.

Invertisment

comment created time in 2 months

PullRequestReviewEvent

push eventscale-it/algorand-builder

Invertisment

commit sha df995bca1407c1a8ed7cb916c78be867a51ba88d

asa opt-in takes account as accountName

view details

Invertisment

commit sha d44851acd34db673a34dbf2e0a6db242c7532e69

Example: tesla uses manual ASA opt-in

view details

push time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export class AlgoOperatorImpl implements AlgoOperator {     }   }; +  getTxFee (params: algosdk.SuggestedParams, txSize: number): number {+    if (params.flatFee) {+      return Math.max(ALGORAND_MIN_TX_FEE, params.fee);+    }+    return Math.max(ALGORAND_MIN_TX_FEE, txSize);+  }++  getUsableAccBalance (accoutInfo: algosdk.AccountInfo): number {+    // Extracted from interacting with Algorand node:+    // 7 opted-in assets require to have 800000 micro algos (frozen in account).+    // 11 assets require 1200000.+    return accoutInfo.amount - (accoutInfo.assets.length + 1) * ALGORAND_ASA_OWNERSHIP_COST;+  }++  getOptInTxSize (params: algosdk.SuggestedParams, accounts: Accounts): number {+    const randomAccount = accounts.values().next().value;+    // assetID can't be known before ASA creation+    // it shouldn't be easy to find out the latest asset ID+    // In original source code it's uint64:+    // https://github.com/algorand/go-algorand/blob/1424855ad2b5f6755ff3feba7e419ee06f2493da/data/basics/userBalance.go#L278+    const assetID = Number.MAX_SAFE_INTEGER; // not 64 bits but 55 bits should be enough+    const sampleASAOptInTX = tx.makeASAOptInTx(randomAccount.addr, assetID, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(randomAccount.sk);+    return rawSignedTxn.length;+  }++  async optInToASA (+    asaName: string, assetIndex: number, account: Account, params: algosdk.SuggestedParams+  ): Promise<void> {+    console.log(`ASA ${account.name} opt-in for for ASA ${asaName}`);+    const sampleASAOptInTX = tx.makeASAOptInTx(account.addr, assetIndex, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(account.sk);+    const txInfo = await this.algodClient.sendRawTransaction(rawSignedTxn).do();+    await this.waitForConfirmation(txInfo.txId);+  }

Deployer's signature changed to optInToASA (name: string, accountName: string, flags: ASADeploymentFlags): Promise<void> accountName is better than Account

Invertisment

comment created time in 2 months

PullRequestReviewEvent

push eventscale-it/algorand-builder

Invertisment

commit sha 7467a722fa53d6a92cc171121ed318924e7c61a3

Deployer.optInToASA

view details

push time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export class AlgoOperatorImpl implements AlgoOperator {     }   }; +  getTxFee (params: algosdk.SuggestedParams, txSize: number): number {+    if (params.flatFee) {+      return Math.max(ALGORAND_MIN_TX_FEE, params.fee);+    }+    return Math.max(ALGORAND_MIN_TX_FEE, txSize);+  }++  getUsableAccBalance (accoutInfo: algosdk.AccountInfo): number {+    // Extracted from interacting with Algorand node:+    // 7 opted-in assets require to have 800000 micro algos (frozen in account).+    // 11 assets require 1200000.+    return accoutInfo.amount - (accoutInfo.assets.length + 1) * ALGORAND_ASA_OWNERSHIP_COST;+  }++  getOptInTxSize (params: algosdk.SuggestedParams, accounts: Accounts): number {+    const randomAccount = accounts.values().next().value;+    // assetID can't be known before ASA creation+    // it shouldn't be easy to find out the latest asset ID+    // In original source code it's uint64:+    // https://github.com/algorand/go-algorand/blob/1424855ad2b5f6755ff3feba7e419ee06f2493da/data/basics/userBalance.go#L278+    const assetID = Number.MAX_SAFE_INTEGER; // not 64 bits but 55 bits should be enough+    const sampleASAOptInTX = tx.makeASAOptInTx(randomAccount.addr, assetID, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(randomAccount.sk);+    return rawSignedTxn.length;+  }++  async optInToASA (+    asaName: string, assetIndex: number, account: Account, params: algosdk.SuggestedParams+  ): Promise<void> {+    console.log(`ASA ${account.name} opt-in for for ASA ${asaName}`);+    const sampleASAOptInTX = tx.makeASAOptInTx(account.addr, assetIndex, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(account.sk);+    const txInfo = await this.algodClient.sendRawTransaction(rawSignedTxn).do();+    await this.waitForConfirmation(txInfo.txId);+  }

I'll use this as a signature for AlgoOperator: optInToASA (asaName: string, assetIndex: number, account: Account, params: DeploymentFlags): Promise<void> And this for Deployer: optInToASA (asaName: string, account: Account, params: DeploymentFlags): Promise<void>

It will also need to check that asaName has been saved in CP

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export class AlgoOperatorImpl implements AlgoOperator {     }   }; +  getTxFee (params: algosdk.SuggestedParams, txSize: number): number {+    if (params.flatFee) {+      return Math.max(ALGORAND_MIN_TX_FEE, params.fee);+    }+    return Math.max(ALGORAND_MIN_TX_FEE, txSize);+  }++  getUsableAccBalance (accoutInfo: algosdk.AccountInfo): number {+    // Extracted from interacting with Algorand node:+    // 7 opted-in assets require to have 800000 micro algos (frozen in account).+    // 11 assets require 1200000.+    return accoutInfo.amount - (accoutInfo.assets.length + 1) * ALGORAND_ASA_OWNERSHIP_COST;+  }++  getOptInTxSize (params: algosdk.SuggestedParams, accounts: Accounts): number {+    const randomAccount = accounts.values().next().value;+    // assetID can't be known before ASA creation+    // it shouldn't be easy to find out the latest asset ID+    // In original source code it's uint64:+    // https://github.com/algorand/go-algorand/blob/1424855ad2b5f6755ff3feba7e419ee06f2493da/data/basics/userBalance.go#L278+    const assetID = Number.MAX_SAFE_INTEGER; // not 64 bits but 55 bits should be enough+    const sampleASAOptInTX = tx.makeASAOptInTx(randomAccount.addr, assetID, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(randomAccount.sk);+    return rawSignedTxn.length;+  }++  async optInToASA (+    asaName: string, assetIndex: number, account: Account, params: algosdk.SuggestedParams+  ): Promise<void> {+    console.log(`ASA ${account.name} opt-in for for ASA ${asaName}`);+    const sampleASAOptInTX = tx.makeASAOptInTx(account.addr, assetIndex, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(account.sk);+    const txInfo = await this.algodClient.sendRawTransaction(rawSignedTxn).do();+    await this.waitForConfirmation(txInfo.txId);+  }

This function also takes assetID which is too verbose as well. I'll make a new function that will prepare the parameters for this one and won't touch this function.

Invertisment

comment created time in 2 months

PullRequestReviewEvent

push eventscale-it/algorand-builder

Invertisment

commit sha eca8451dc22bc2c242f51b1d495bb6b42f9977d3

PR comments

view details

push time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {+  return getLast(getLast(ts));+}++export function partitionByFn<T> (+  f: (s: T, s1: T) => boolean,

This exact function takes two inputs and returns a boolean. And this how it decides to split the list in the function.

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {+  return getLast(getLast(ts));+}++export function partitionByFn<T> (+  f: (s: T, s1: T) => boolean,

Also you can see tests in here: packages/algob/test/internal/util/lists.ts

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 import { BuilderError } from "../internal/core/errors"; import { ERRORS } from "../internal/core/errors-list"; import { ASSETS_DIR } from "../internal/core/project-structure"; import { parseZodError } from "../internal/core/validation-errors";-import { ASADefs } from "../types";+import { Accounts, ASADef, ASADefs } from "../types"; import { ASADefsSchema } from "../types-input"; import { loadFromYamlFileSilentWithMessage } from "./files"; -export function validateASADefs (obj: Object, filename?: string): ASADefs {+function validateSingle (accounts: Accounts, filename: string, asaDef: ASADef): void {+  if (!asaDef.optInAccNames || asaDef.optInAccNames.length === 0) {+    return;+  }+  for (const accName of asaDef.optInAccNames) {+    if (!accounts.get(accName)) {+      throw new BuilderError(+        ERRORS.SCRIPT.ASA_PARAM_ERROR_NO_NAMED_OPT_IN_ACCOUNT, {+          filename: filename,+          optInAccName: accName+        });+    }+  }+}++function validateASADefsOneByOne (accounts: Accounts, asaDefs: ASADefs, filename: string): void {

validateParsedASADefs

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 declare module 'algosdk' {    type TxnBytes = Uint8Array +  type Address = string

removed

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 import { BuilderError } from "../internal/core/errors"; import { ERRORS } from "../internal/core/errors-list"; import { ASSETS_DIR } from "../internal/core/project-structure"; import { parseZodError } from "../internal/core/validation-errors";-import { ASADefs } from "../types";+import { Accounts, ASADef, ASADefs } from "../types"; import { ASADefsSchema } from "../types-input"; import { loadFromYamlFileSilentWithMessage } from "./files"; -export function validateASADefs (obj: Object, filename?: string): ASADefs {+function validateSingle (accounts: Accounts, filename: string, asaDef: ASADef): void {+  if (!asaDef.optInAccNames || asaDef.optInAccNames.length === 0) {+    return;+  }+  for (const accName of asaDef.optInAccNames) {+    if (!accounts.get(accName)) {+      throw new BuilderError(+        ERRORS.SCRIPT.ASA_PARAM_ERROR_NO_NAMED_OPT_IN_ACCOUNT, {+          filename: filename,+          optInAccName: accName+        });+    }+  }+}++function validateASADefsOneByOne (accounts: Accounts, asaDefs: ASADefs, filename: string): void {

Your suggestion is fine and I wanted to use it too but validateASADefs is already defined so I have to find an alternative for one of these. Or move this function body to validateSingle and rename it.

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 import * as tx from "./tx";  const confirmedRound = "confirmed-round"; +// This was not exported in algosdk+const ALGORAND_MIN_TX_FEE = 1000;+// Extracted from interaction with Algorand node+const ALGORAND_ASA_OWNERSHIP_COST = 100000;

Changed to: // Extracted from interaction with Algorand node (100k microAlgos)

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export class AlgoOperatorImpl implements AlgoOperator {     }   }; +  getTxFee (params: algosdk.SuggestedParams, txSize: number): number {+    if (params.flatFee) {+      return Math.max(ALGORAND_MIN_TX_FEE, params.fee);+    }+    return Math.max(ALGORAND_MIN_TX_FEE, txSize);+  }++  getUsableAccBalance (accoutInfo: algosdk.AccountInfo): number {+    // Extracted from interacting with Algorand node:+    // 7 opted-in assets require to have 800000 micro algos (frozen in account).+    // 11 assets require 1200000.+    return accoutInfo.amount - (accoutInfo.assets.length + 1) * ALGORAND_ASA_OWNERSHIP_COST;+  }++  getOptInTxSize (params: algosdk.SuggestedParams, accounts: Accounts): number {+    const randomAccount = accounts.values().next().value;+    // assetID can't be known before ASA creation+    // it shouldn't be easy to find out the latest asset ID+    // In original source code it's uint64:+    // https://github.com/algorand/go-algorand/blob/1424855ad2b5f6755ff3feba7e419ee06f2493da/data/basics/userBalance.go#L278+    const assetID = Number.MAX_SAFE_INTEGER; // not 64 bits but 55 bits should be enough+    const sampleASAOptInTX = tx.makeASAOptInTx(randomAccount.addr, assetID, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(randomAccount.sk);+    return rawSignedTxn.length;+  }++  async optInToASA (+    asaName: string, assetIndex: number, account: Account, params: algosdk.SuggestedParams+  ): Promise<void> {+    console.log(`ASA ${account.name} opt-in for for ASA ${asaName}`);+    const sampleASAOptInTX = tx.makeASAOptInTx(account.addr, assetIndex, params);+    const rawSignedTxn = sampleASAOptInTX.signTxn(account.sk);+    const txInfo = await this.algodClient.sendRawTransaction(rawSignedTxn).do();+    await this.waitForConfirmation(txInfo.txId);+  }++  async optInToASAMultiple (+    asaName: string, assetIndex: number, accounts: Account[], params: algosdk.SuggestedParams+  ): Promise<void> {+    for (const account of accounts) {+      await this.optInToASA(asaName, assetIndex, account, params);+    }+  }++  async checkASAOptInAccountBalances (

checkBalanceForASAOptInTx

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {

Renaming to getLastDeepChild

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {+  return getLast(getLast(ts));+}++export function partitionByFn<T> (+  f: (s: T, s1: T) => boolean,+  input: T[]+): T[][] {+  if (input.length === 0) {+    return [];+  }+  var out = [[input[0]]];+  for (const current of input.slice(1)) {+    const last = getLastSubchild(out);+    if (f(last, current)) {+      out.push([current]);+    } else {+      out[out.length - 1].push(current);+    }+  }+  return out;+}

It has tests in packages/algob/test/internal/util/lists.ts

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 function loadCheckpointsIntoCPData (cpData: CheckpointRepo, scriptPaths: string[   return checkpointData; } -// TODO: Reduce file IO:-// Function only accepts sorted scripts -- only this way it loads the state correctly.-// Optimization: Split the scripts into sorted array chunks and run those chunks-// This will save some disk reads because sub-arrays will be sorted-export async function runMultipleScriptsOneByOne (+function batchScriptNames (unbatched: string[]): string[][] {+  return partitionByFn(+    (a: string, b: string) => cmpStr(a, b) === 1,+    unbatched);+}

Comparator returns 1 when one string is larger than the other. This partitions a random-order list into multiple sorted lists.

partitionIntoSorted and partitionByFn is more correct because group of items is not sorted and partition is defined here as "dividing something into parts": https://www.thefreedictionary.com/partition

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 export async function runMultipleScriptsOneByOne (   allowWrite: boolean,   algoOp: AlgoOperator ): Promise<void> {-  for (const script of scriptNames) {-    await runMultipleScripts(+  const accounts = mkAccountIndex(runtimeEnv.network.config.accounts);+  const asaDefs = loadASAFile(accounts);+  for (const scriptsBatch of batchScriptNames(scriptNames)) {+    await runScriptsBatch(       runtimeEnv,-      [script],+      scriptsBatch,       onSuccessFn,       force,       logDebugTag,-      allowWrite,-      algoOp+      (cpData: CheckpointRepo) => mkDeployer(runtimeEnv, cpData, allowWrite, algoOp, asaDefs, accounts)

True, it's better to have this function as a variable.

I decided not to read files for every script batch run. So I moved more IO into method runMultipleScripts.

I made it that the script executor (runScriptsBatch (probably I'll rename it)) wouldn't need all of the parameters: runtimeEnv, allowWrite, algoOp, asaDefs, accounts. This is why I have this function in this method.

Invertisment

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

 declare module 'algosdk' {    type TxnBytes = Uint8Array +  type Address = string++  interface AccountAssetInfo {+    amount: number,+    'asset-id': number,+    creator: Address,+    'is-frozen': false

Will change this one

Invertisment

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Kmd client(Draft)

 export type AccountDef =   | HDAccount   | Account; +export interface wallet {

Change wallet to Wallet, it's a type

amityadav0

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Kmd client(Draft)

 let accounts = mkAccounts([   } ]); +// KMD credentials+let KMDConfig = {

You call this KMDConfig but add it later as a network. Isn't it that the network uses one port and KMD has it's own?

amityadav0

comment created time in 2 months

Pull request review commentscale-it/algorand-builder

Kmd client(Draft)

 let defaultCfg = { module.exports = {   networks: {     localhost: defaultCfg,-    default: defaultCfg+    default: defaultCfg,+    KMD: KMDConfig

You add KMDConfig as a network but it shouldn't be used as a node that can compile code.

amityadav0

comment created time in 2 months

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentscale-it/algorand-builder

Asa opt-in with balance check

++function getLast<T> (ts: T[]): T {+  return ts[ts.length - 1];+}++function getLastSubchild<T> (ts: T[][]): T {+  return getLast(getLast(ts));+}++export function partitionByFn<T> (+  f: (s: T, s1: T) => boolean,

It takes a list which has some kind of order then it also takes a function that checks whether the list should be split there. If it returns true then it should split. then this: f: > and [c, d, a, b] will return: [[c d], [a b]]

Invertisment

comment created time in 2 months

PullRequestReviewEvent

push eventscale-it/algorand-builder

Invertisment

commit sha 171724c596037a48cdd708f64850f8c9d7ae6e2d

Deployer comment on algodClient method

view details

push time in 2 months

push eventscale-it/algorand-builder

Invertisment

commit sha 771d6d466aaea2a84ac4928c01684d023de5237c

fix

view details

push time in 2 months

PR opened scale-it/algorand-builder

Asa opt-in with balance check
+405 -165

0 comment

18 changed files

pr created time in 2 months

push eventscale-it/algorand-builder

Martynas M

commit sha df8ef3426a4f4bff209cd6e3fe5ce49370cfd399

Scripts: Accounts argument removed (#73) * Scripts: Accounts argument removed * Example: scripts: accounts argument removed

view details

Amit Yadav

commit sha 826b215df974214e0fa89e512b4201169f675834

Add a warning when deployer skips a script (#72)

view details

Robert Zaremba

commit sha 9092e4d8bb51be417a82d6cea54d5f279e41d502

update package.json

view details

Robert Zaremba

commit sha 530ce6d2ad9c7c6b8abeb26ade99923a01acfdd4

Update README and added missing dependencies + added quick start instructions + fixed linter warnings

view details

Robert Zaremba

commit sha b112a88db922ed3904af1ef9e075dc24882ce4f8

example: update README

view details

Invertisment

commit sha 4fc7a998bb5e1b6be7e8ed9da9b72c441ed26f9f

Run task optimized to use less file IO

view details

Invertisment

commit sha 5bc073cd2ca9ab8e5ffee46b51b05d76a8f07668

Scripts: ASA always loads only once

view details

Invertisment

commit sha a296d7f472537f17be4c623b50609886261fe494

Construct Account index before executing scripts

view details

Invertisment

commit sha 02ed64758b1707bdb1de141ad33b0aa388adc418

ASA validation includes opt-ins

view details

Invertisment

commit sha d139b1a833174f180e18304ea8923042af9563ae

ASA opt-in from asa.yaml with balance check

view details

push time in 2 months

issue commentalgorand/js-algorand-sdk

Typescript support

I'm not sure if I want to make a PR right now as our typings are not complete. We add things as we go and it already has some things in there but it's far from complete as we didn't use everything.

You may want to check our code out: https://github.com/scale-it/algorand-builder/blob/master/packages/types-algosdk/index.d.ts

Invertisment

comment created time in 2 months

push eventscale-it/algorand-builder

Martynas M

commit sha df8ef3426a4f4bff209cd6e3fe5ce49370cfd399

Scripts: Accounts argument removed (#73) * Scripts: Accounts argument removed * Example: scripts: accounts argument removed

view details

push time in 2 months

delete branch scale-it/algorand-builder

delete branch : remove-accounts-task-arg

delete time in 2 months

create barnchscale-it/algorand-builder

branch : asa-opt-in

created branch time in 2 months

push eventscale-it/algorand-builder

Invertisment

commit sha 387f85e9b67831c46d5d8371b1ce68e6a5a1ac4c

Example: scripts: accounts argument removed

view details

push time in 2 months

more