@algorandfoundation/algokit-utils 5.3.3-beta.2 → 5.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account/account.d.ts +81 -0
- package/account/account.d.ts.map +1 -0
- package/account/account.js +120 -0
- package/account/account.js.map +1 -0
- package/account/account.mjs +112 -0
- package/account/account.mjs.map +1 -0
- package/account/get-account-config-from-environment.d.ts +13 -0
- package/account/get-account-config-from-environment.d.ts.map +1 -0
- package/account/get-account-config-from-environment.js +25 -0
- package/account/get-account-config-from-environment.js.map +1 -0
- package/account/get-account-config-from-environment.mjs +23 -0
- package/account/get-account-config-from-environment.mjs.map +1 -0
- package/account/get-account.d.ts +66 -0
- package/account/get-account.d.ts.map +1 -0
- package/account/get-account.js +83 -0
- package/account/get-account.js.map +1 -0
- package/account/get-account.mjs +81 -0
- package/account/get-account.mjs.map +1 -0
- package/account/get-dispenser-account.d.ts +13 -0
- package/account/get-dispenser-account.d.ts.map +1 -0
- package/account/get-dispenser-account.js +23 -0
- package/account/get-dispenser-account.js.map +1 -0
- package/account/get-dispenser-account.mjs +21 -0
- package/account/get-dispenser-account.mjs.map +1 -0
- package/account/index.d.ts +6 -0
- package/account/index.d.ts.map +1 -0
- package/account/mnemonic-account.d.ts +11 -0
- package/account/mnemonic-account.d.ts.map +1 -0
- package/account/mnemonic-account.js +18 -0
- package/account/mnemonic-account.js.map +1 -0
- package/account/mnemonic-account.mjs +16 -0
- package/account/mnemonic-account.mjs.map +1 -0
- package/amount.d.ts.map +1 -0
- package/amount.js +34 -0
- package/amount.js.map +1 -0
- package/{esm/amount.js → amount.mjs} +8 -5
- package/amount.mjs.map +1 -0
- package/app-client.d.ts.map +1 -0
- package/{cjs/app-client.js → app-client.js} +11 -10
- package/app-client.js.map +1 -0
- package/{esm/app-client.js → app-client.mjs} +8 -5
- package/app-client.mjs.map +1 -0
- package/app-deploy.d.ts.map +1 -0
- package/{cjs/app-deploy.js → app-deploy.js} +67 -69
- package/app-deploy.js.map +1 -0
- package/{esm/app-deploy.js → app-deploy.mjs} +17 -14
- package/app-deploy.mjs.map +1 -0
- package/{cjs/app.d.ts → app.d.ts} +1 -1
- package/app.d.ts.map +1 -0
- package/{cjs/app.js → app.js} +102 -104
- package/app.js.map +1 -0
- package/{esm/app.js → app.mjs} +27 -24
- package/app.mjs.map +1 -0
- package/asset.d.ts.map +1 -0
- package/{cjs/asset.js → asset.js} +41 -42
- package/asset.js.map +1 -0
- package/{esm/asset.js → asset.mjs} +10 -6
- package/asset.mjs.map +1 -0
- package/config.d.ts +4 -0
- package/config.d.ts.map +1 -0
- package/config.js +9 -0
- package/config.js.map +1 -0
- package/config.mjs +7 -0
- package/config.mjs.map +1 -0
- package/debugging/debugging.d.ts +10 -0
- package/debugging/debugging.d.ts.map +1 -0
- package/debugging/debugging.js +139 -0
- package/debugging/debugging.js.map +1 -0
- package/debugging/debugging.mjs +118 -0
- package/debugging/debugging.mjs.map +1 -0
- package/debugging/index.d.ts +3 -0
- package/debugging/index.d.ts.map +1 -0
- package/{cjs/debugging.d.ts → debugging/simulate-and-persist-response.d.ts} +3 -12
- package/debugging/simulate-and-persist-response.d.ts.map +1 -0
- package/debugging/simulate-and-persist-response.js +108 -0
- package/debugging/simulate-and-persist-response.js.map +1 -0
- package/debugging/simulate-and-persist-response.mjs +89 -0
- package/debugging/simulate-and-persist-response.mjs.map +1 -0
- package/dispenser-client.d.ts.map +1 -0
- package/{cjs/dispenser-client.js → dispenser-client.js} +7 -6
- package/dispenser-client.js.map +1 -0
- package/{esm/dispenser-client.js → dispenser-client.mjs} +6 -3
- package/dispenser-client.mjs.map +1 -0
- package/{cjs/index.d.ts → index.d.ts} +1 -3
- package/index.d.ts.map +1 -0
- package/index.js +125 -0
- package/index.js.map +1 -0
- package/index.mjs +25 -0
- package/index.mjs.map +1 -0
- package/indexer-lookup.d.ts.map +1 -0
- package/{cjs/indexer-lookup.js → indexer-lookup.js} +8 -8
- package/indexer-lookup.js.map +1 -0
- package/{esm/indexer-lookup.js → indexer-lookup.mjs} +8 -6
- package/indexer-lookup.mjs.map +1 -0
- package/localnet/get-kmd-wallet-account.d.ts +26 -0
- package/localnet/get-kmd-wallet-account.d.ts.map +1 -0
- package/localnet/get-kmd-wallet-account.js +55 -0
- package/localnet/get-kmd-wallet-account.js.map +1 -0
- package/localnet/get-kmd-wallet-account.mjs +53 -0
- package/localnet/get-kmd-wallet-account.mjs.map +1 -0
- package/localnet/get-localnet-dispenser-account.d.ts +12 -0
- package/localnet/get-localnet-dispenser-account.d.ts.map +1 -0
- package/localnet/get-localnet-dispenser-account.js +21 -0
- package/localnet/get-localnet-dispenser-account.js.map +1 -0
- package/localnet/get-localnet-dispenser-account.mjs +19 -0
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -0
- package/localnet/get-or-create-kmd-wallet-account.d.ts +27 -0
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +1 -0
- package/localnet/get-or-create-kmd-wallet-account.js +52 -0
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -0
- package/localnet/get-or-create-kmd-wallet-account.mjs +50 -0
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -0
- package/localnet/index.d.ts +5 -0
- package/localnet/index.d.ts.map +1 -0
- package/localnet/is-localnet.d.ts +5 -0
- package/localnet/is-localnet.d.ts.map +1 -0
- package/localnet/is-localnet.js +10 -0
- package/localnet/is-localnet.js.map +1 -0
- package/localnet/is-localnet.mjs +8 -0
- package/localnet/is-localnet.mjs.map +1 -0
- package/{cjs/network-client.d.ts → network-client.d.ts} +0 -1
- package/network-client.d.ts.map +1 -0
- package/{cjs/network-client.js → network-client.js} +21 -25
- package/network-client.js.map +1 -0
- package/{esm/network-client.js → network-client.mjs} +15 -13
- package/network-client.mjs.map +1 -0
- package/package.json +15 -36
- package/testing/_asset.d.ts.map +1 -0
- package/testing/account.d.ts.map +1 -0
- package/testing/account.js +29 -0
- package/testing/account.js.map +1 -0
- package/{esm/testing/account.js → testing/account.mjs} +8 -5
- package/testing/account.mjs.map +1 -0
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/{cjs/testing → testing}/fixtures/algokit-log-capture-fixture.js +11 -10
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/{esm/testing/fixtures/algokit-log-capture-fixture.js → testing/fixtures/algokit-log-capture-fixture.mjs} +7 -4
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -0
- package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/testing/fixtures/algorand-fixture.js +64 -0
- package/testing/fixtures/algorand-fixture.js.map +1 -0
- package/{esm/testing/fixtures/algorand-fixture.js → testing/fixtures/algorand-fixture.mjs} +12 -4
- package/testing/fixtures/algorand-fixture.mjs.map +1 -0
- package/testing/fixtures/index.d.ts.map +1 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +18 -0
- package/testing/index.js.map +1 -0
- package/testing/index.mjs +7 -0
- package/testing/index.mjs.map +1 -0
- package/testing/indexer.d.ts.map +1 -0
- package/{cjs/testing → testing}/indexer.js +4 -4
- package/testing/indexer.js.map +1 -0
- package/{esm/testing/indexer.js → testing/indexer.mjs} +4 -2
- package/testing/indexer.mjs.map +1 -0
- package/testing/test-logger.d.ts.map +1 -0
- package/{cjs/testing → testing}/test-logger.js +7 -8
- package/testing/test-logger.js.map +1 -0
- package/{esm/testing/test-logger.js → testing/test-logger.mjs} +6 -5
- package/testing/test-logger.mjs.map +1 -0
- package/testing/transaction-logger.d.ts.map +1 -0
- package/{cjs/testing → testing}/transaction-logger.js +14 -15
- package/testing/transaction-logger.js.map +1 -0
- package/{esm/testing/transaction-logger.js → testing/transaction-logger.mjs} +9 -5
- package/testing/transaction-logger.mjs.map +1 -0
- package/transaction/index.d.ts +3 -0
- package/transaction/index.d.ts.map +1 -0
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +11 -0
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +1 -0
- package/transaction/perform-atomic-transaction-composer-simulate.js +35 -0
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -0
- package/transaction/perform-atomic-transaction-composer-simulate.mjs +33 -0
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -0
- package/{cjs → transaction}/transaction.d.ts +2 -9
- package/transaction/transaction.d.ts.map +1 -0
- package/{cjs → transaction}/transaction.js +88 -113
- package/transaction/transaction.js.map +1 -0
- package/{esm/transaction.js → transaction/transaction.mjs} +27 -50
- package/transaction/transaction.mjs.map +1 -0
- package/transfer/index.d.ts +3 -0
- package/transfer/index.d.ts.map +1 -0
- package/transfer/transfer-algos.d.ts +17 -0
- package/transfer/transfer-algos.d.ts.map +1 -0
- package/transfer/transfer-algos.js +40 -0
- package/transfer/transfer-algos.js.map +1 -0
- package/transfer/transfer-algos.mjs +38 -0
- package/transfer/transfer-algos.mjs.map +1 -0
- package/{cjs → transfer}/transfer.d.ts +2 -14
- package/transfer/transfer.d.ts.map +1 -0
- package/transfer/transfer.js +147 -0
- package/transfer/transfer.js.map +1 -0
- package/{esm/transfer.js → transfer/transfer.mjs} +15 -40
- package/transfer/transfer.mjs.map +1 -0
- package/types/account.d.ts +63 -161
- package/types/account.d.ts.map +1 -1
- package/{cjs/types → types}/account.js +14 -22
- package/types/account.js.map +1 -0
- package/{esm/types/account.js → types/account.mjs} +7 -11
- package/types/account.mjs.map +1 -0
- package/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/{cjs/types → types}/algo-http-client-with-retry.js +25 -24
- package/types/algo-http-client-with-retry.js.map +1 -0
- package/{esm/types/algo-http-client-with-retry.js → types/algo-http-client-with-retry.mjs} +23 -20
- package/types/algo-http-client-with-retry.mjs.map +1 -0
- package/types/amount.d.ts +22 -18
- package/types/amount.d.ts.map +1 -1
- package/{cjs/types → types}/amount.js +8 -11
- package/types/amount.js.map +1 -0
- package/{esm/types/amount.js → types/amount.mjs} +5 -3
- package/types/amount.mjs.map +1 -0
- package/types/app-client.d.ts +413 -69
- package/types/app-client.d.ts.map +1 -1
- package/{cjs/types → types}/app-client.js +58 -73
- package/types/app-client.js.map +1 -0
- package/{esm/types/app-client.js → types/app-client.mjs} +14 -24
- package/types/app-client.mjs.map +1 -0
- package/types/app-spec.d.ts.map +1 -0
- package/types/app.d.ts +300 -146
- package/types/app.d.ts.map +1 -1
- package/{cjs/types → types}/app.js +16 -14
- package/types/app.js.map +1 -0
- package/{esm/types/app.js → types/app.mjs} +9 -9
- package/types/app.mjs.map +1 -0
- package/types/asset.d.ts +40 -47
- package/types/asset.d.ts.map +1 -1
- package/types/config.d.ts.map +1 -0
- package/{cjs/types → types}/config.js +30 -41
- package/types/config.js.map +1 -0
- package/{esm/types/config.js → types/config.mjs} +8 -11
- package/types/config.mjs.map +1 -0
- package/types/debugging.d.ts +105 -22
- package/types/debugging.d.ts.map +1 -1
- package/{cjs/types → types}/debugging.js +6 -13
- package/types/debugging.js.map +1 -0
- package/{esm/types/debugging.js → types/debugging.mjs} +6 -11
- package/types/debugging.mjs.map +1 -0
- package/types/dispenser-client.d.ts +71 -13
- package/types/dispenser-client.d.ts.map +1 -1
- package/{cjs/types → types}/dispenser-client.js +4 -6
- package/types/dispenser-client.js.map +1 -0
- package/{esm/types/dispenser-client.js → types/dispenser-client.mjs} +4 -4
- package/types/dispenser-client.mjs.map +1 -0
- package/types/indexer.d.ts.map +1 -0
- package/types/logging.d.ts.map +1 -0
- package/{cjs/types → types}/logging.js +8 -6
- package/types/logging.js.map +1 -0
- package/{esm/types/logging.js → types/logging.mjs} +5 -3
- package/types/logging.mjs.map +1 -0
- package/types/logic-error.d.ts.map +1 -0
- package/{cjs/types → types}/logic-error.js +6 -9
- package/types/logic-error.js.map +1 -0
- package/{esm/types/logic-error.js → types/logic-error.mjs} +6 -7
- package/types/logic-error.mjs.map +1 -0
- package/types/network-client.d.ts +19 -99
- package/types/network-client.d.ts.map +1 -1
- package/types/testing.d.ts.map +1 -0
- package/types/transaction.d.ts +112 -175
- package/types/transaction.d.ts.map +1 -1
- package/types/transfer.d.ts +74 -56
- package/types/transfer.d.ts.map +1 -1
- package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/{cjs/types → types}/urlTokenBaseHTTPClient.js +7 -10
- package/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/{esm/types/urlTokenBaseHTTPClient.js → types/urlTokenBaseHTTPClient.mjs} +5 -6
- package/types/urlTokenBaseHTTPClient.mjs.map +1 -0
- package/util.d.ts.map +1 -0
- package/{cjs/util.js → util.js} +7 -7
- package/util.js.map +1 -0
- package/{esm/util.js → util.mjs} +7 -5
- package/util.mjs.map +1 -0
- package/cjs/account.d.ts +0 -168
- package/cjs/account.d.ts.map +0 -1
- package/cjs/account.js +0 -238
- package/cjs/account.js.map +0 -1
- package/cjs/amount.d.ts.map +0 -1
- package/cjs/amount.js +0 -36
- package/cjs/amount.js.map +0 -1
- package/cjs/app-client.d.ts.map +0 -1
- package/cjs/app-client.js.map +0 -1
- package/cjs/app-deploy.d.ts.map +0 -1
- package/cjs/app-deploy.js.map +0 -1
- package/cjs/app.d.ts.map +0 -1
- package/cjs/app.js.map +0 -1
- package/cjs/asset.d.ts.map +0 -1
- package/cjs/asset.js.map +0 -1
- package/cjs/debugging.d.ts.map +0 -1
- package/cjs/debugging.js +0 -225
- package/cjs/debugging.js.map +0 -1
- package/cjs/dispenser-client.d.ts.map +0 -1
- package/cjs/dispenser-client.js.map +0 -1
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js +0 -34
- package/cjs/index.js.map +0 -1
- package/cjs/indexer-lookup.d.ts.map +0 -1
- package/cjs/indexer-lookup.js.map +0 -1
- package/cjs/localnet.d.ts +0 -57
- package/cjs/localnet.d.ts.map +0 -1
- package/cjs/localnet.js +0 -121
- package/cjs/localnet.js.map +0 -1
- package/cjs/network-client.d.ts.map +0 -1
- package/cjs/network-client.js.map +0 -1
- package/cjs/testing/_asset.d.ts.map +0 -1
- package/cjs/testing/_asset.js +0 -36
- package/cjs/testing/_asset.js.map +0 -1
- package/cjs/testing/account.d.ts.map +0 -1
- package/cjs/testing/account.js +0 -31
- package/cjs/testing/account.js.map +0 -1
- package/cjs/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/cjs/testing/fixtures/algokit-log-capture-fixture.js.map +0 -1
- package/cjs/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/cjs/testing/fixtures/algorand-fixture.js +0 -58
- package/cjs/testing/fixtures/algorand-fixture.js.map +0 -1
- package/cjs/testing/fixtures/index.d.ts.map +0 -1
- package/cjs/testing/fixtures/index.js +0 -19
- package/cjs/testing/fixtures/index.js.map +0 -1
- package/cjs/testing/index.d.ts.map +0 -1
- package/cjs/testing/index.js +0 -22
- package/cjs/testing/index.js.map +0 -1
- package/cjs/testing/indexer.d.ts.map +0 -1
- package/cjs/testing/indexer.js.map +0 -1
- package/cjs/testing/test-logger.d.ts.map +0 -1
- package/cjs/testing/test-logger.js.map +0 -1
- package/cjs/testing/transaction-logger.d.ts.map +0 -1
- package/cjs/testing/transaction-logger.js.map +0 -1
- package/cjs/transaction.d.ts.map +0 -1
- package/cjs/transaction.js.map +0 -1
- package/cjs/transfer.d.ts.map +0 -1
- package/cjs/transfer.js +0 -178
- package/cjs/transfer.js.map +0 -1
- package/cjs/types/account.d.ts +0 -70
- package/cjs/types/account.d.ts.map +0 -1
- package/cjs/types/account.js.map +0 -1
- package/cjs/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/cjs/types/algo-http-client-with-retry.js.map +0 -1
- package/cjs/types/amount.d.ts +0 -24
- package/cjs/types/amount.d.ts.map +0 -1
- package/cjs/types/amount.js.map +0 -1
- package/cjs/types/app-client.d.ts +0 -416
- package/cjs/types/app-client.d.ts.map +0 -1
- package/cjs/types/app-client.js.map +0 -1
- package/cjs/types/app-spec.d.ts.map +0 -1
- package/cjs/types/app-spec.js +0 -3
- package/cjs/types/app-spec.js.map +0 -1
- package/cjs/types/app.d.ts +0 -323
- package/cjs/types/app.d.ts.map +0 -1
- package/cjs/types/app.js.map +0 -1
- package/cjs/types/asset.d.ts +0 -42
- package/cjs/types/asset.d.ts.map +0 -1
- package/cjs/types/asset.js +0 -3
- package/cjs/types/asset.js.map +0 -1
- package/cjs/types/config.d.ts.map +0 -1
- package/cjs/types/config.js.map +0 -1
- package/cjs/types/debugging.d.ts +0 -112
- package/cjs/types/debugging.d.ts.map +0 -1
- package/cjs/types/debugging.js.map +0 -1
- package/cjs/types/dispenser-client.d.ts +0 -77
- package/cjs/types/dispenser-client.d.ts.map +0 -1
- package/cjs/types/dispenser-client.js.map +0 -1
- package/cjs/types/indexer.d.ts.map +0 -1
- package/cjs/types/indexer.js +0 -34
- package/cjs/types/indexer.js.map +0 -1
- package/cjs/types/logging.d.ts.map +0 -1
- package/cjs/types/logging.js.map +0 -1
- package/cjs/types/logic-error.d.ts.map +0 -1
- package/cjs/types/logic-error.js.map +0 -1
- package/cjs/types/network-client.d.ts +0 -20
- package/cjs/types/network-client.d.ts.map +0 -1
- package/cjs/types/network-client.js +0 -3
- package/cjs/types/network-client.js.map +0 -1
- package/cjs/types/testing.d.ts.map +0 -1
- package/cjs/types/testing.js +0 -3
- package/cjs/types/testing.js.map +0 -1
- package/cjs/types/transaction.d.ts +0 -118
- package/cjs/types/transaction.d.ts.map +0 -1
- package/cjs/types/transaction.js +0 -3
- package/cjs/types/transaction.js.map +0 -1
- package/cjs/types/transfer.d.ts +0 -76
- package/cjs/types/transfer.d.ts.map +0 -1
- package/cjs/types/transfer.js +0 -3
- package/cjs/types/transfer.js.map +0 -1
- package/cjs/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/cjs/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/cjs/util.d.ts.map +0 -1
- package/cjs/util.js.map +0 -1
- package/esm/account.js +0 -221
- package/esm/account.js.map +0 -1
- package/esm/amount.js.map +0 -1
- package/esm/app-client.js.map +0 -1
- package/esm/app-deploy.js.map +0 -1
- package/esm/app.js.map +0 -1
- package/esm/asset.js.map +0 -1
- package/esm/debugging.js +0 -197
- package/esm/debugging.js.map +0 -1
- package/esm/dispenser-client.js.map +0 -1
- package/esm/index.js +0 -17
- package/esm/index.js.map +0 -1
- package/esm/indexer-lookup.js.map +0 -1
- package/esm/localnet.js +0 -111
- package/esm/localnet.js.map +0 -1
- package/esm/network-client.js.map +0 -1
- package/esm/package.json +0 -3
- package/esm/testing/_asset.js +0 -29
- package/esm/testing/_asset.js.map +0 -1
- package/esm/testing/account.js.map +0 -1
- package/esm/testing/fixtures/algokit-log-capture-fixture.js.map +0 -1
- package/esm/testing/fixtures/algorand-fixture.js.map +0 -1
- package/esm/testing/fixtures/index.js +0 -3
- package/esm/testing/fixtures/index.js.map +0 -1
- package/esm/testing/index.js +0 -6
- package/esm/testing/index.js.map +0 -1
- package/esm/testing/indexer.js.map +0 -1
- package/esm/testing/test-logger.js.map +0 -1
- package/esm/testing/transaction-logger.js.map +0 -1
- package/esm/transaction.js.map +0 -1
- package/esm/transfer.js.map +0 -1
- package/esm/types/account.js.map +0 -1
- package/esm/types/algo-http-client-with-retry.js.map +0 -1
- package/esm/types/amount.js.map +0 -1
- package/esm/types/app-client.js.map +0 -1
- package/esm/types/app-spec.js +0 -2
- package/esm/types/app-spec.js.map +0 -1
- package/esm/types/app.js.map +0 -1
- package/esm/types/asset.js +0 -2
- package/esm/types/asset.js.map +0 -1
- package/esm/types/config.js.map +0 -1
- package/esm/types/debugging.js.map +0 -1
- package/esm/types/dispenser-client.js.map +0 -1
- package/esm/types/indexer.js +0 -31
- package/esm/types/indexer.js.map +0 -1
- package/esm/types/logging.js.map +0 -1
- package/esm/types/logic-error.js.map +0 -1
- package/esm/types/network-client.js +0 -2
- package/esm/types/network-client.js.map +0 -1
- package/esm/types/testing.js +0 -2
- package/esm/types/testing.js.map +0 -1
- package/esm/types/transaction.js +0 -2
- package/esm/types/transaction.js.map +0 -1
- package/esm/types/transfer.js +0 -2
- package/esm/types/transfer.js.map +0 -1
- package/esm/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/esm/util.js.map +0 -1
- package/types/app-deploy.d.ts +0 -104
- package/types/app-deploy.d.ts.map +0 -1
- package/types/index.d.ts +0 -17
- package/types/index.d.ts.map +0 -1
- package/types/indexer-lookup.d.ts +0 -39
- package/types/indexer-lookup.d.ts.map +0 -1
- package/types/localnet.d.ts +0 -57
- package/types/localnet.d.ts.map +0 -1
- package/types/testing/_asset.d.ts +0 -5
- package/types/testing/_asset.d.ts.map +0 -1
- package/types/testing/account.d.ts +0 -17
- package/types/testing/account.d.ts.map +0 -1
- package/types/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -20
- package/types/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/types/testing/fixtures/algorand-fixture.d.ts +0 -50
- package/types/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/types/testing/fixtures/index.d.ts +0 -3
- package/types/testing/fixtures/index.d.ts.map +0 -1
- package/types/testing/index.d.ts +0 -6
- package/types/testing/index.d.ts.map +0 -1
- package/types/testing/indexer.d.ts +0 -13
- package/types/testing/indexer.d.ts.map +0 -1
- package/types/testing/test-logger.d.ts +0 -41
- package/types/testing/test-logger.d.ts.map +0 -1
- package/types/testing/transaction-logger.d.ts +0 -31
- package/types/testing/transaction-logger.d.ts.map +0 -1
- package/types/types/account.d.ts +0 -70
- package/types/types/account.d.ts.map +0 -1
- package/types/types/algo-http-client-with-retry.d.ts +0 -14
- package/types/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/types/amount.d.ts +0 -24
- package/types/types/amount.d.ts.map +0 -1
- package/types/types/app-client.d.ts +0 -416
- package/types/types/app-client.d.ts.map +0 -1
- package/types/types/app-spec.d.ts +0 -156
- package/types/types/app-spec.d.ts.map +0 -1
- package/types/types/app.d.ts +0 -323
- package/types/types/app.d.ts.map +0 -1
- package/types/types/asset.d.ts +0 -42
- package/types/types/asset.d.ts.map +0 -1
- package/types/types/config.d.ts +0 -49
- package/types/types/config.d.ts.map +0 -1
- package/types/types/debugging.d.ts +0 -112
- package/types/types/debugging.d.ts.map +0 -1
- package/types/types/dispenser-client.d.ts +0 -77
- package/types/types/dispenser-client.d.ts.map +0 -1
- package/types/types/indexer.d.ts +0 -625
- package/types/types/indexer.d.ts.map +0 -1
- package/types/types/logging.d.ts +0 -13
- package/types/types/logging.d.ts.map +0 -1
- package/types/types/logic-error.d.ts +0 -37
- package/types/types/logic-error.d.ts.map +0 -1
- package/types/types/network-client.d.ts +0 -20
- package/types/types/network-client.d.ts.map +0 -1
- package/types/types/testing.d.ts +0 -95
- package/types/types/testing.d.ts.map +0 -1
- package/types/types/transaction.d.ts +0 -118
- package/types/types/transaction.d.ts.map +0 -1
- package/types/types/transfer.d.ts +0 -76
- package/types/types/transfer.d.ts.map +0 -1
- package/types/types/urlTokenBaseHTTPClient.d.ts +0 -41
- package/types/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/types/util.d.ts +0 -24
- package/types/util.d.ts.map +0 -1
- /package/{cjs/amount.d.ts → amount.d.ts} +0 -0
- /package/{cjs/app-client.d.ts → app-client.d.ts} +0 -0
- /package/{cjs/app-deploy.d.ts → app-deploy.d.ts} +0 -0
- /package/{cjs/asset.d.ts → asset.d.ts} +0 -0
- /package/{cjs/dispenser-client.d.ts → dispenser-client.d.ts} +0 -0
- /package/{cjs/indexer-lookup.d.ts → indexer-lookup.d.ts} +0 -0
- /package/{cjs/testing → testing}/_asset.d.ts +0 -0
- /package/{cjs/testing → testing}/account.d.ts +0 -0
- /package/{cjs/testing → testing}/fixtures/algokit-log-capture-fixture.d.ts +0 -0
- /package/{cjs/testing → testing}/fixtures/algorand-fixture.d.ts +0 -0
- /package/{cjs/testing → testing}/fixtures/index.d.ts +0 -0
- /package/{cjs/testing → testing}/index.d.ts +0 -0
- /package/{cjs/testing → testing}/indexer.d.ts +0 -0
- /package/{cjs/testing → testing}/test-logger.d.ts +0 -0
- /package/{cjs/testing → testing}/transaction-logger.d.ts +0 -0
- /package/{cjs/types → types}/algo-http-client-with-retry.d.ts +0 -0
- /package/{cjs/types → types}/app-spec.d.ts +0 -0
- /package/{cjs/types → types}/config.d.ts +0 -0
- /package/{cjs/types → types}/indexer.d.ts +0 -0
- /package/{cjs/types → types}/logging.d.ts +0 -0
- /package/{cjs/types → types}/logic-error.d.ts +0 -0
- /package/{cjs/types → types}/testing.d.ts +0 -0
- /package/{cjs/types → types}/urlTokenBaseHTTPClient.d.ts +0 -0
- /package/{cjs/util.d.ts → util.d.ts} +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import algosdk from 'algosdk';
|
|
2
|
+
import { MultisigAccount, SigningAccount, TransactionSignerAccount } from '../types/account';
|
|
3
|
+
import { AlgoAmount } from '../types/amount';
|
|
4
|
+
import { SendTransactionFrom } from '../types/transaction';
|
|
5
|
+
import Account = algosdk.Account;
|
|
6
|
+
import Algodv2 = algosdk.Algodv2;
|
|
7
|
+
import Kmd = algosdk.Kmd;
|
|
8
|
+
import MultisigMetadata = algosdk.MultisigMetadata;
|
|
9
|
+
import TransactionSigner = algosdk.TransactionSigner;
|
|
10
|
+
/**
|
|
11
|
+
* Returns an account wrapper that supports partial or full multisig signing.
|
|
12
|
+
* @param multisigParams The parameters that define the multisig account
|
|
13
|
+
* @param signingAccounts The signers that are currently present
|
|
14
|
+
* @returns A multisig account wrapper
|
|
15
|
+
*/
|
|
16
|
+
export declare function multisigAccount(multisigParams: MultisigMetadata, signingAccounts: (Account | SigningAccount)[]): MultisigAccount;
|
|
17
|
+
/**
|
|
18
|
+
* Returns an account wrapper that supports a rekeyed account.
|
|
19
|
+
* @param signer The account, with private key loaded, that is signing
|
|
20
|
+
* @param sender The address of the rekeyed account that will act as a sender
|
|
21
|
+
* @returns The SigningAccount wrapper
|
|
22
|
+
*/
|
|
23
|
+
export declare function rekeyedAccount(signer: Account, sender: string): SigningAccount;
|
|
24
|
+
/**
|
|
25
|
+
* Returns an account wrapper that supports a transaction signer with associated sender address.
|
|
26
|
+
* @param signer The transaction signer
|
|
27
|
+
* @param sender The address of sender account
|
|
28
|
+
* @returns The SigningAccount wrapper
|
|
29
|
+
*/
|
|
30
|
+
export declare function transactionSignerAccount(signer: TransactionSigner, sender: string): TransactionSignerAccount;
|
|
31
|
+
/** Returns a new, random Algorand account with secret key loaded.
|
|
32
|
+
*
|
|
33
|
+
* This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export declare function randomAccount(): Account;
|
|
37
|
+
/**
|
|
38
|
+
* Returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.
|
|
39
|
+
*
|
|
40
|
+
* Note: This function expects to run in a Node.js environment.
|
|
41
|
+
*
|
|
42
|
+
* ## Convention:
|
|
43
|
+
* * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
|
|
44
|
+
* never commit it into source control and ideally load it via a secret storage service rather than the file system.
|
|
45
|
+
* If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
|
|
46
|
+
* * **LocalNet:** will load the account from a KMD wallet called \{NAME\} and if that wallet doesn't exist it will create it and fund the account for you
|
|
47
|
+
*
|
|
48
|
+
* This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).
|
|
49
|
+
*
|
|
50
|
+
* @example Default
|
|
51
|
+
*
|
|
52
|
+
* If you have a mnemonic secret loaded into `process.env.MY_ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const account = await mnemonicAccountFromEnvironment('MY_ACCOUNT', algod)
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* If that code runs against LocalNet then a wallet called `MY_ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
|
|
58
|
+
* If not running against LocalNet then it will use proces.env.MY_ACCOUNT_MNEMONIC as the private key and (if present) process.env.MY_ACCOUNT_SENDER as the sender address.
|
|
59
|
+
*
|
|
60
|
+
* @param account The details of the account to get, either the name identifier (string) or an object with:
|
|
61
|
+
* * `name`: string: The name identifier of the account
|
|
62
|
+
* * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account
|
|
63
|
+
* @param algod An algod client
|
|
64
|
+
* @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables
|
|
65
|
+
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
66
|
+
*/
|
|
67
|
+
export declare function mnemonicAccountFromEnvironment(account: string | {
|
|
68
|
+
name: string;
|
|
69
|
+
fundWith?: AlgoAmount;
|
|
70
|
+
}, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
|
|
71
|
+
/** Returns an account's address as a byte array
|
|
72
|
+
*
|
|
73
|
+
* @param account Either an account (with private key loaded) or the string address of an account
|
|
74
|
+
*/
|
|
75
|
+
export declare function getAccountAddressAsUint8Array(account: SendTransactionFrom | string): Uint8Array;
|
|
76
|
+
/** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
|
|
77
|
+
*
|
|
78
|
+
* @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
|
|
79
|
+
*/
|
|
80
|
+
export declare function getAccountAddressAsString(addressEncodedInB64: string): string;
|
|
81
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/account/account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAK7B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,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require('../localnet/get-or-create-kmd-wallet-account.js');
|
|
6
|
+
var isLocalnet = require('../localnet/is-localnet.js');
|
|
7
|
+
var transaction = require('../transaction/transaction.js');
|
|
8
|
+
var account = require('../types/account.js');
|
|
9
|
+
var getAccountConfigFromEnvironment = require('./get-account-config-from-environment.js');
|
|
10
|
+
var mnemonicAccount = require('./mnemonic-account.js');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns an account wrapper that supports partial or full multisig signing.
|
|
14
|
+
* @param multisigParams The parameters that define the multisig account
|
|
15
|
+
* @param signingAccounts The signers that are currently present
|
|
16
|
+
* @returns A multisig account wrapper
|
|
17
|
+
*/
|
|
18
|
+
function multisigAccount(multisigParams, signingAccounts) {
|
|
19
|
+
return new account.MultisigAccount(multisigParams, signingAccounts);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns an account wrapper that supports a rekeyed account.
|
|
23
|
+
* @param signer The account, with private key loaded, that is signing
|
|
24
|
+
* @param sender The address of the rekeyed account that will act as a sender
|
|
25
|
+
* @returns The SigningAccount wrapper
|
|
26
|
+
*/
|
|
27
|
+
function rekeyedAccount(signer, sender) {
|
|
28
|
+
return new account.SigningAccount(signer, sender);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns an account wrapper that supports a transaction signer with associated sender address.
|
|
32
|
+
* @param signer The transaction signer
|
|
33
|
+
* @param sender The address of sender account
|
|
34
|
+
* @returns The SigningAccount wrapper
|
|
35
|
+
*/
|
|
36
|
+
function transactionSignerAccount(signer, sender) {
|
|
37
|
+
return { addr: sender, signer };
|
|
38
|
+
}
|
|
39
|
+
/** Returns a new, random Algorand account with secret key loaded.
|
|
40
|
+
*
|
|
41
|
+
* This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
function randomAccount() {
|
|
45
|
+
// This method is confusingly named, so this function provides a more dev friendly "wrapper" name
|
|
46
|
+
return algosdk.generateAccount();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.
|
|
50
|
+
*
|
|
51
|
+
* Note: This function expects to run in a Node.js environment.
|
|
52
|
+
*
|
|
53
|
+
* ## Convention:
|
|
54
|
+
* * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
|
|
55
|
+
* never commit it into source control and ideally load it via a secret storage service rather than the file system.
|
|
56
|
+
* If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
|
|
57
|
+
* * **LocalNet:** will load the account from a KMD wallet called \{NAME\} and if that wallet doesn't exist it will create it and fund the account for you
|
|
58
|
+
*
|
|
59
|
+
* This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).
|
|
60
|
+
*
|
|
61
|
+
* @example Default
|
|
62
|
+
*
|
|
63
|
+
* If you have a mnemonic secret loaded into `process.env.MY_ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const account = await mnemonicAccountFromEnvironment('MY_ACCOUNT', algod)
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* If that code runs against LocalNet then a wallet called `MY_ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
|
|
69
|
+
* If not running against LocalNet then it will use proces.env.MY_ACCOUNT_MNEMONIC as the private key and (if present) process.env.MY_ACCOUNT_SENDER as the sender address.
|
|
70
|
+
*
|
|
71
|
+
* @param account The details of the account to get, either the name identifier (string) or an object with:
|
|
72
|
+
* * `name`: string: The name identifier of the account
|
|
73
|
+
* * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account
|
|
74
|
+
* @param algod An algod client
|
|
75
|
+
* @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables
|
|
76
|
+
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
77
|
+
*/
|
|
78
|
+
async function mnemonicAccountFromEnvironment(account$1, algod, kmdClient) {
|
|
79
|
+
const { name, fundWith } = typeof account$1 === 'string' ? { name: account$1, fundWith: undefined } : account$1;
|
|
80
|
+
// todo: When eventually removing this method, inline it here
|
|
81
|
+
const config$1 = getAccountConfigFromEnvironment.getAccountConfigFromEnvironment(name);
|
|
82
|
+
if (config$1.accountMnemonic) {
|
|
83
|
+
const signer = mnemonicAccount.mnemonicAccount(config$1.accountMnemonic);
|
|
84
|
+
const sender = config$1.senderAddress;
|
|
85
|
+
if (sender) {
|
|
86
|
+
config.Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${sender} for ${name} account`);
|
|
87
|
+
return new account.SigningAccount(signer, sender);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return signer;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (await isLocalnet.isLocalNet(algod)) {
|
|
94
|
+
return await getOrCreateKmdWalletAccount.getOrCreateKmdWalletAccount({ name, fundWith }, algod, kmdClient);
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`);
|
|
97
|
+
}
|
|
98
|
+
/** Returns an account's address as a byte array
|
|
99
|
+
*
|
|
100
|
+
* @param account Either an account (with private key loaded) or the string address of an account
|
|
101
|
+
*/
|
|
102
|
+
function getAccountAddressAsUint8Array(account) {
|
|
103
|
+
return algosdk.decodeAddress(typeof account === 'string' ? account : transaction.getSenderAddress(account)).publicKey;
|
|
104
|
+
}
|
|
105
|
+
/** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
|
|
106
|
+
*
|
|
107
|
+
* @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
|
|
108
|
+
*/
|
|
109
|
+
function getAccountAddressAsString(addressEncodedInB64) {
|
|
110
|
+
return algosdk.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.getAccountAddressAsString = getAccountAddressAsString;
|
|
114
|
+
exports.getAccountAddressAsUint8Array = getAccountAddressAsUint8Array;
|
|
115
|
+
exports.mnemonicAccountFromEnvironment = mnemonicAccountFromEnvironment;
|
|
116
|
+
exports.multisigAccount = multisigAccount;
|
|
117
|
+
exports.randomAccount = randomAccount;
|
|
118
|
+
exports.rekeyedAccount = rekeyedAccount;
|
|
119
|
+
exports.transactionSignerAccount = transactionSignerAccount;
|
|
120
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":["MultisigAccount","SigningAccount","account","config","getAccountConfigFromEnvironment","mnemonicAccount","Config","isLocalNet","getOrCreateKmdWalletAccount","getSenderAddress"],"mappings":";;;;;;;;;;;AAgBA;;;;;AAKG;AACa,SAAA,eAAe,CAAC,cAAgC,EAAE,eAA6C,EAAA;AAC7G,IAAA,OAAO,IAAIA,uBAAe,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;AAKG;AACa,SAAA,cAAc,CAAC,MAAe,EAAE,MAAc,EAAA;AAC5D,IAAA,OAAO,IAAIC,sBAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;AAKG;AACa,SAAA,wBAAwB,CAAC,MAAyB,EAAE,MAAc,EAAA;AAChF,IAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACjC,CAAC;AAED;;;;AAIG;SACa,aAAa,GAAA;;AAE3B,IAAA,OAAO,OAAO,CAAC,eAAe,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACI,eAAe,8BAA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A;AAC3G,CAAC;AAED;;;AAGG;AACG,SAAU,yBAAyB,CAAC,mBAA2B,EAAA;AACnE,IAAA,OAAO,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC1E;;;;;;;;;;"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import algosdk from 'algosdk';
|
|
2
|
+
import { Config } from '../config.mjs';
|
|
3
|
+
import { getOrCreateKmdWalletAccount } from '../localnet/get-or-create-kmd-wallet-account.mjs';
|
|
4
|
+
import { isLocalNet } from '../localnet/is-localnet.mjs';
|
|
5
|
+
import { getSenderAddress } from '../transaction/transaction.mjs';
|
|
6
|
+
import { MultisigAccount, SigningAccount } from '../types/account.mjs';
|
|
7
|
+
import { getAccountConfigFromEnvironment } from './get-account-config-from-environment.mjs';
|
|
8
|
+
import { mnemonicAccount } from './mnemonic-account.mjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns an account wrapper that supports partial or full multisig signing.
|
|
12
|
+
* @param multisigParams The parameters that define the multisig account
|
|
13
|
+
* @param signingAccounts The signers that are currently present
|
|
14
|
+
* @returns A multisig account wrapper
|
|
15
|
+
*/
|
|
16
|
+
function multisigAccount(multisigParams, signingAccounts) {
|
|
17
|
+
return new MultisigAccount(multisigParams, signingAccounts);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns an account wrapper that supports a rekeyed account.
|
|
21
|
+
* @param signer The account, with private key loaded, that is signing
|
|
22
|
+
* @param sender The address of the rekeyed account that will act as a sender
|
|
23
|
+
* @returns The SigningAccount wrapper
|
|
24
|
+
*/
|
|
25
|
+
function rekeyedAccount(signer, sender) {
|
|
26
|
+
return new SigningAccount(signer, sender);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns an account wrapper that supports a transaction signer with associated sender address.
|
|
30
|
+
* @param signer The transaction signer
|
|
31
|
+
* @param sender The address of sender account
|
|
32
|
+
* @returns The SigningAccount wrapper
|
|
33
|
+
*/
|
|
34
|
+
function transactionSignerAccount(signer, sender) {
|
|
35
|
+
return { addr: sender, signer };
|
|
36
|
+
}
|
|
37
|
+
/** Returns a new, random Algorand account with secret key loaded.
|
|
38
|
+
*
|
|
39
|
+
* This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
function randomAccount() {
|
|
43
|
+
// This method is confusingly named, so this function provides a more dev friendly "wrapper" name
|
|
44
|
+
return algosdk.generateAccount();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.
|
|
48
|
+
*
|
|
49
|
+
* Note: This function expects to run in a Node.js environment.
|
|
50
|
+
*
|
|
51
|
+
* ## Convention:
|
|
52
|
+
* * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
|
|
53
|
+
* never commit it into source control and ideally load it via a secret storage service rather than the file system.
|
|
54
|
+
* If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
|
|
55
|
+
* * **LocalNet:** will load the account from a KMD wallet called \{NAME\} and if that wallet doesn't exist it will create it and fund the account for you
|
|
56
|
+
*
|
|
57
|
+
* This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).
|
|
58
|
+
*
|
|
59
|
+
* @example Default
|
|
60
|
+
*
|
|
61
|
+
* If you have a mnemonic secret loaded into `process.env.MY_ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const account = await mnemonicAccountFromEnvironment('MY_ACCOUNT', algod)
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* If that code runs against LocalNet then a wallet called `MY_ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
|
|
67
|
+
* If not running against LocalNet then it will use proces.env.MY_ACCOUNT_MNEMONIC as the private key and (if present) process.env.MY_ACCOUNT_SENDER as the sender address.
|
|
68
|
+
*
|
|
69
|
+
* @param account The details of the account to get, either the name identifier (string) or an object with:
|
|
70
|
+
* * `name`: string: The name identifier of the account
|
|
71
|
+
* * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account
|
|
72
|
+
* @param algod An algod client
|
|
73
|
+
* @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables
|
|
74
|
+
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
75
|
+
*/
|
|
76
|
+
async function mnemonicAccountFromEnvironment(account, algod, kmdClient) {
|
|
77
|
+
const { name, fundWith } = typeof account === 'string' ? { name: account, fundWith: undefined } : account;
|
|
78
|
+
// todo: When eventually removing this method, inline it here
|
|
79
|
+
const config = getAccountConfigFromEnvironment(name);
|
|
80
|
+
if (config.accountMnemonic) {
|
|
81
|
+
const signer = mnemonicAccount(config.accountMnemonic);
|
|
82
|
+
const sender = config.senderAddress;
|
|
83
|
+
if (sender) {
|
|
84
|
+
Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${sender} for ${name} account`);
|
|
85
|
+
return new SigningAccount(signer, sender);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return signer;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (await isLocalNet(algod)) {
|
|
92
|
+
return await getOrCreateKmdWalletAccount({ name, fundWith }, algod, kmdClient);
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`);
|
|
95
|
+
}
|
|
96
|
+
/** Returns an account's address as a byte array
|
|
97
|
+
*
|
|
98
|
+
* @param account Either an account (with private key loaded) or the string address of an account
|
|
99
|
+
*/
|
|
100
|
+
function getAccountAddressAsUint8Array(account) {
|
|
101
|
+
return algosdk.decodeAddress(typeof account === 'string' ? account : getSenderAddress(account)).publicKey;
|
|
102
|
+
}
|
|
103
|
+
/** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
|
|
104
|
+
*
|
|
105
|
+
* @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
|
|
106
|
+
*/
|
|
107
|
+
function getAccountAddressAsString(addressEncodedInB64) {
|
|
108
|
+
return algosdk.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { getAccountAddressAsString, getAccountAddressAsUint8Array, mnemonicAccountFromEnvironment, multisigAccount, randomAccount, rekeyedAccount, transactionSignerAccount };
|
|
112
|
+
//# sourceMappingURL=account.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.mjs","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAgBA;;;;;AAKG;AACa,SAAA,eAAe,CAAC,cAAgC,EAAE,eAA6C,EAAA;AAC7G,IAAA,OAAO,IAAI,eAAe,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;AAKG;AACa,SAAA,cAAc,CAAC,MAAe,EAAE,MAAc,EAAA;AAC5D,IAAA,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;AAKG;AACa,SAAA,wBAAwB,CAAC,MAAyB,EAAE,MAAc,EAAA;AAChF,IAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACjC,CAAC;AAED;;;;AAIG;SACa,aAAa,GAAA;;AAE3B,IAAA,OAAO,OAAO,CAAC,eAAe,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACI,eAAe,8BAA8B,CAClD,OAAyD,EACzD,KA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yB,CAAC,mBAA2B,EAAA;AACnE,IAAA,OAAO,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC1E;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AccountConfig } from '../types/account';
|
|
2
|
+
/** @deprecated Use algokit.mnemonicAccountFromEnvironment, which doesn't need this function
|
|
3
|
+
* Returns the Account configuration from environment variables
|
|
4
|
+
*
|
|
5
|
+
* @param accountName account name
|
|
6
|
+
*
|
|
7
|
+
* @example environment variables
|
|
8
|
+
* {accountName}_MNEMONIC
|
|
9
|
+
* {accountName}_SENDER
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare function getAccountConfigFromEnvironment(accountName: string): AccountConfig;
|
|
13
|
+
//# sourceMappingURL=get-account-config-from-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-account-config-from-environment.d.ts","sourceRoot":"","sources":["../../src/account/get-account-config-from-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAUlF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** @deprecated Use algokit.mnemonicAccountFromEnvironment, which doesn't need this function
|
|
4
|
+
* Returns the Account configuration from environment variables
|
|
5
|
+
*
|
|
6
|
+
* @param accountName account name
|
|
7
|
+
*
|
|
8
|
+
* @example environment variables
|
|
9
|
+
* {accountName}_MNEMONIC
|
|
10
|
+
* {accountName}_SENDER
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
function getAccountConfigFromEnvironment(accountName) {
|
|
14
|
+
if (!process || !process.env) {
|
|
15
|
+
throw new Error('Attempt to get account with private key from a non Node.js context; not supported!');
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
accountMnemonic: process.env[`${accountName.toUpperCase()}_MNEMONIC`] || '',
|
|
19
|
+
senderAddress: process.env[`${accountName.toUpperCase()}_SENDER`],
|
|
20
|
+
accountName,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.getAccountConfigFromEnvironment = getAccountConfigFromEnvironment;
|
|
25
|
+
//# sourceMappingURL=get-account-config-from-environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-account-config-from-environment.js","sources":["../../src/account/get-account-config-from-environment.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;;;;;;AASG;AACG,SAAU,+BAA+B,CAAC,WAAmB,EAAA;IACjE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;AAC5B,QAAA,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAA;KACtG;IAED,OAAO;AACL,QAAA,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA,EAAG,WAAW,CAAC,WAAW,EAAE,CAAW,SAAA,CAAA,CAAC,IAAI,EAAE;QAC3E,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,CAAG,EAAA,WAAW,CAAC,WAAW,EAAE,CAAA,OAAA,CAAS,CAAC;QACjE,WAAW;KACZ,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @deprecated Use algokit.mnemonicAccountFromEnvironment, which doesn't need this function
|
|
2
|
+
* Returns the Account configuration from environment variables
|
|
3
|
+
*
|
|
4
|
+
* @param accountName account name
|
|
5
|
+
*
|
|
6
|
+
* @example environment variables
|
|
7
|
+
* {accountName}_MNEMONIC
|
|
8
|
+
* {accountName}_SENDER
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
function getAccountConfigFromEnvironment(accountName) {
|
|
12
|
+
if (!process || !process.env) {
|
|
13
|
+
throw new Error('Attempt to get account with private key from a non Node.js context; not supported!');
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
accountMnemonic: process.env[`${accountName.toUpperCase()}_MNEMONIC`] || '',
|
|
17
|
+
senderAddress: process.env[`${accountName.toUpperCase()}_SENDER`],
|
|
18
|
+
accountName,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { getAccountConfigFromEnvironment };
|
|
23
|
+
//# sourceMappingURL=get-account-config-from-environment.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-account-config-from-environment.mjs","sources":["../../src/account/get-account-config-from-environment.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;;;;;;AASG;AACG,SAAU,+BAA+B,CAAC,WAAmB,EAAA;IACjE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;AAC5B,QAAA,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAA;KACtG;IAED,OAAO;AACL,QAAA,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA,EAAG,WAAW,CAAC,WAAW,EAAE,CAAW,SAAA,CAAA,CAAC,IAAI,EAAE;QAC3E,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,CAAG,EAAA,WAAW,CAAC,WAAW,EAAE,CAAA,OAAA,CAAS,CAAC;QACjE,WAAW;KACZ,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import algosdk from 'algosdk';
|
|
2
|
+
import { AccountConfig, SigningAccount } from '../types/account';
|
|
3
|
+
import { AlgoAmount } from '../types/amount';
|
|
4
|
+
import Account = algosdk.Account;
|
|
5
|
+
import Algodv2 = algosdk.Algodv2;
|
|
6
|
+
import Kmd = algosdk.Kmd;
|
|
7
|
+
/** @deprecated use mnemonicAccountFromEnvironment instead
|
|
8
|
+
*
|
|
9
|
+
* Returns an Algorand account with private key loaded by convention based on the given name identifier.
|
|
10
|
+
*
|
|
11
|
+
* Note: This function expects to run in a Node.js environment.
|
|
12
|
+
*
|
|
13
|
+
* ## Convention:
|
|
14
|
+
* * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
|
|
15
|
+
* never commit it into source control and ideally load it via a secret storage service rather than the file system.
|
|
16
|
+
* If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
|
|
17
|
+
* * **LocalNet:** will load the account from a KMD wallet called \{NAME\} and if that wallet doesn't exist it will create it and fund the account for you
|
|
18
|
+
*
|
|
19
|
+
* This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).
|
|
20
|
+
*
|
|
21
|
+
* @example Default
|
|
22
|
+
*
|
|
23
|
+
* If you have a mnemonic secret loaded into `process.env.ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const account = await getAccount('ACCOUNT', algod)
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* If that code runs against LocalNet then a wallet called `ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
|
|
29
|
+
*
|
|
30
|
+
* @param account The details of the account to get, either the name identifier (string) or an object with:
|
|
31
|
+
* * `name`: The name identifier of the account
|
|
32
|
+
* * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account
|
|
33
|
+
* @param algod An algod client
|
|
34
|
+
* @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables
|
|
35
|
+
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
36
|
+
*/
|
|
37
|
+
export declare function getAccount(account: {
|
|
38
|
+
name: string;
|
|
39
|
+
fundWith?: AlgoAmount;
|
|
40
|
+
} | string, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
|
|
41
|
+
/** @deprecated use mnemonicAccountFromEnvironment instead
|
|
42
|
+
* Returns an Algorand account with private key loaded by convention based on the given name identifier.
|
|
43
|
+
*
|
|
44
|
+
* Note: This function expects to run in a Node.js environment.
|
|
45
|
+
*
|
|
46
|
+
* @example Default
|
|
47
|
+
*
|
|
48
|
+
* If you have a mnemonic secret loaded into `process.env.ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const account = await getAccount({config: getAccountConfigFromEnvironment('ACCOUNT')}, algod)
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* If that code runs against LocalNet then a wallet called `ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
|
|
54
|
+
*
|
|
55
|
+
* @param account The details of the account to get, an object with:
|
|
56
|
+
* * `config`: Account configuration. To get from environment use getAccountConfigFromEnvironment(accountName)
|
|
57
|
+
* * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account
|
|
58
|
+
* @param algod An algod client
|
|
59
|
+
* @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables
|
|
60
|
+
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
61
|
+
*/
|
|
62
|
+
export declare function getAccount(account: {
|
|
63
|
+
config: AccountConfig;
|
|
64
|
+
fundWith?: AlgoAmount;
|
|
65
|
+
}, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
|
|
66
|
+
//# sourceMappingURL=get-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-account.d.ts","sourceRoot":"","sources":["../../src/account/get-account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAChC,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAChC,OAAO,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAA;CAAE,GAAG,MAAM,EACzD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC,CAAA;AAEpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAA;CAAE,EACzD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var algosdk = require('algosdk');
|
|
4
|
+
var config = require('../config.js');
|
|
5
|
+
var getOrCreateKmdWalletAccount = require('../localnet/get-or-create-kmd-wallet-account.js');
|
|
6
|
+
var isLocalnet = require('../localnet/is-localnet.js');
|
|
7
|
+
var account = require('../types/account.js');
|
|
8
|
+
var getAccountConfigFromEnvironment = require('./get-account-config-from-environment.js');
|
|
9
|
+
var mnemonicAccount = require('./mnemonic-account.js');
|
|
10
|
+
|
|
11
|
+
/** @deprecated use mnemonicAccountFromEnvironment instead
|
|
12
|
+
* Returns an Algorand account with private key loaded by convention based on the given name identifier.
|
|
13
|
+
*
|
|
14
|
+
* Note: This function expects to run in a Node.js environment.
|
|
15
|
+
*
|
|
16
|
+
* ## Convention:
|
|
17
|
+
* * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
|
|
18
|
+
* never commit it into source control and ideally load it via a secret storage service rather than the file system.
|
|
19
|
+
* If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
|
|
20
|
+
* * **LocalNet:** will load the account from a KMD wallet called \{NAME\} and if that wallet doesn't exist it will create it and fund the account for you
|
|
21
|
+
*
|
|
22
|
+
* This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).
|
|
23
|
+
*
|
|
24
|
+
* @example Default
|
|
25
|
+
*
|
|
26
|
+
* If you have a mnemonic secret loaded into `process.env.ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const account = await getAccount({config: getAccountConfigFromEnvironment('ACCOUNT')}, algod)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* If that code runs against LocalNet then a wallet called `ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
|
|
32
|
+
*
|
|
33
|
+
* @param account The details of the account to get, either the name identifier (string) or an object with:
|
|
34
|
+
* * `config`: Account configuration. To get from environment use getAccountConfigFromEnvironment(accountName) OR
|
|
35
|
+
* * `name`: string: The name identifier of the account (deprecated)
|
|
36
|
+
* And optionally
|
|
37
|
+
* * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account
|
|
38
|
+
* @param algod An algod client
|
|
39
|
+
* @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables
|
|
40
|
+
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
41
|
+
*/
|
|
42
|
+
async function getAccount(account$1, algod, kmdClient) {
|
|
43
|
+
let name;
|
|
44
|
+
let fundWith = undefined;
|
|
45
|
+
let config$1;
|
|
46
|
+
if (typeof account$1 === 'string') {
|
|
47
|
+
name = account$1;
|
|
48
|
+
config$1 = getAccountConfigFromEnvironment.getAccountConfigFromEnvironment(name);
|
|
49
|
+
}
|
|
50
|
+
else if ('name' in account$1) {
|
|
51
|
+
name = account$1.name;
|
|
52
|
+
config$1 = getAccountConfigFromEnvironment.getAccountConfigFromEnvironment(name);
|
|
53
|
+
fundWith = account$1.fundWith;
|
|
54
|
+
}
|
|
55
|
+
else if ('config' in account$1) {
|
|
56
|
+
config$1 = account$1.config;
|
|
57
|
+
name = config$1.accountName;
|
|
58
|
+
fundWith = account$1.fundWith;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error('Missing name or account config');
|
|
62
|
+
}
|
|
63
|
+
if (config$1.accountMnemonic) {
|
|
64
|
+
const signer = mnemonicAccount.mnemonicAccount(config$1.accountMnemonic);
|
|
65
|
+
const sender = config$1.senderAddress || config$1.senderMnemonic;
|
|
66
|
+
if (sender) {
|
|
67
|
+
config.Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${sender} for ${name} account`);
|
|
68
|
+
return new account.SigningAccount(signer, sender);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return signer;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (await isLocalnet.isLocalNet(algod)) {
|
|
75
|
+
const account = await getOrCreateKmdWalletAccount.getOrCreateKmdWalletAccount({ name, fundWith }, algod, kmdClient);
|
|
76
|
+
config$1.accountMnemonic = algosdk.secretKeyToMnemonic(account.sk);
|
|
77
|
+
return account;
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.getAccount = getAccount;
|
|
83
|
+
//# sourceMappingURL=get-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-account.js","sources":["../../src/account/get-account.ts"],"sourcesContent":[null],"names":["account","config","getAccountConfigFromEnvironment","mnemonicAccount","Config","SigningAccount","isLocalNet","getOrCreateKmdWalletAccount"],"mappings":";;;;;;;;;;AA2EA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,eAAe,UAAU,CAC9BA,SAA4G,EAC5G,KAAc,EACd,SAAe,EAAA;AAEf,IAAA,IAAI,IAAY,CAAA;IAChB,IAAI,QAAQ,GAA2B,SAAS,CAAA;AAChD,IAAA,IAAIC,QAAqB,CAAA;AAEzB,IAAA,IAAI,OAAOD,SAAO,KAAK,QAAQ,EAAE;QAC/B,IAAI,GAAGA,SAAO,CAAA;AACd,QAAAC,QAAM,GAAGC,+DAA+B,CAAC,IAAI,CAAC,CAAA;KAC/C;AAAM,SAAA,IAAI,MAAM,IAAIF,SAAO,EAAE;AAC5B,QAAA,IAAI,GAAGA,SAAO,CAAC,IAAI,CAAA;AACnB,QAAAC,QAAM,GAAGC,+DAA+B,CAAC,IAAI,CAAC,CAAA;AAC9C,QAAA,QAAQ,GAAGF,SAAO,CAAC,QAAQ,CAAA;KAC5B;AAAM,SAAA,IAAI,QAAQ,IAAIA,SAAO,EAAE;AAC9B,QAAAC,QAAM,GAAGD,SAAO,CAAC,MAAM,CAAA;AACvB,QAAA,IAAI,GAAGC,QAAM,CAAC,WAAW,CAAA;AACzB,QAAA,QAAQ,GAAGD,SAAO,CAAC,QAAQ,CAAA;KAC5B;SAAM;AACL,QAAA,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KAClD;AAED,IAAA,IAAIC,QAAM,CAAC,eAAe,EAAE;QAC1B,MAAM,MAAM,GAAGE,+BAAe,CAACF,QAAM,CAAC,eAAe,CAAC,CAAA;QACtD,MAAM,MAAM,GAAGA,QAAM,CAAC,aAAa,IAAIA,QAAM,CAAC,cAAc,CAAA;QAC5D,IAAI,MAAM,EAAE;AACV,YA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