@algorandfoundation/algokit-utils 6.2.1 → 7.0.0-alpha.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/LICENSE +21 -0
- package/README.md +22 -26
- package/account/account.d.ts +21 -11
- package/account/get-account-config-from-environment.d.ts +0 -1
- package/account/get-account.d.ts +6 -7
- package/account/get-dispenser-account.d.ts +2 -3
- package/account/index.d.ts +0 -1
- package/account/mnemonic-account.d.ts +1 -2
- package/amount.d.ts +41 -9
- package/app-client.d.ts +19 -5
- package/app-deploy.d.ts +18 -2
- package/app.d.ts +39 -3
- package/asset.d.ts +10 -1
- package/config.d.ts +0 -1
- package/debugging/debugging.d.ts +3 -5
- package/debugging/index.d.ts +0 -2
- package/dispenser-client.d.ts +1 -2
- package/index.d.ts +8 -6
- package/index.js +61 -48
- package/index.js.map +1 -1
- package/index.mjs +27 -24
- package/index.mjs.map +1 -1
- package/indexer-lookup.d.ts +10 -9
- package/localnet/get-kmd-wallet-account.d.ts +1 -2
- package/localnet/get-localnet-dispenser-account.d.ts +1 -2
- package/localnet/get-or-create-kmd-wallet-account.d.ts +2 -3
- package/localnet/index.d.ts +0 -1
- package/localnet/is-localnet.d.ts +1 -2
- package/network-client.d.ts +3 -10
- package/package.json +5 -5
- package/{account → src/account}/account.js +38 -15
- package/src/account/account.js.map +1 -0
- package/{account → src/account}/account.mjs +39 -16
- package/src/account/account.mjs.map +1 -0
- package/src/account/get-account-config-from-environment.js.map +1 -0
- package/src/account/get-account-config-from-environment.mjs.map +1 -0
- package/{account → src/account}/get-account.js +5 -5
- package/src/account/get-account.js.map +1 -0
- package/{account → src/account}/get-account.mjs +5 -5
- package/src/account/get-account.mjs.map +1 -0
- package/{account → src/account}/get-dispenser-account.js +3 -3
- package/src/account/get-dispenser-account.js.map +1 -0
- package/{account → src/account}/get-dispenser-account.mjs +3 -3
- package/src/account/get-dispenser-account.mjs.map +1 -0
- package/{account → src/account}/mnemonic-account.js +1 -1
- package/src/account/mnemonic-account.js.map +1 -0
- package/{account → src/account}/mnemonic-account.mjs +1 -1
- package/src/account/mnemonic-account.mjs.map +1 -0
- package/src/amount.js +61 -0
- package/src/amount.js.map +1 -0
- package/src/amount.mjs +54 -0
- package/src/amount.mjs.map +1 -0
- package/{app-client.js → src/app-client.js} +20 -5
- package/src/app-client.js.map +1 -0
- package/{app-client.mjs → src/app-client.mjs} +20 -5
- package/src/app-client.mjs.map +1 -0
- package/src/app-deploy.js +285 -0
- package/src/app-deploy.js.map +1 -0
- package/src/app-deploy.mjs +276 -0
- package/src/app-deploy.mjs.map +1 -0
- package/src/app.js +349 -0
- package/src/app.js.map +1 -0
- package/src/app.mjs +329 -0
- package/src/app.mjs.map +1 -0
- package/src/asset.js +142 -0
- package/src/asset.js.map +1 -0
- package/src/asset.mjs +136 -0
- package/src/asset.mjs.map +1 -0
- package/{config.js → src/config.js} +1 -1
- package/src/config.js.map +1 -0
- package/{config.mjs → src/config.mjs} +1 -1
- package/src/config.mjs.map +1 -0
- package/src/debugging/debugging.js +15 -0
- package/src/debugging/debugging.js.map +1 -0
- package/src/debugging/debugging.mjs +13 -0
- package/src/debugging/debugging.mjs.map +1 -0
- package/{dispenser-client.js → src/dispenser-client.js} +3 -3
- package/src/dispenser-client.js.map +1 -0
- package/{dispenser-client.mjs → src/dispenser-client.mjs} +3 -3
- package/src/dispenser-client.mjs.map +1 -0
- package/{indexer-lookup.js → src/indexer-lookup.js} +14 -10
- package/src/indexer-lookup.js.map +1 -0
- package/{indexer-lookup.mjs → src/indexer-lookup.mjs} +14 -10
- package/src/indexer-lookup.mjs.map +1 -0
- package/{localnet → src/localnet}/get-kmd-wallet-account.js +3 -3
- package/src/localnet/get-kmd-wallet-account.js.map +1 -0
- package/{localnet → src/localnet}/get-kmd-wallet-account.mjs +3 -3
- package/src/localnet/get-kmd-wallet-account.mjs.map +1 -0
- package/{localnet → src/localnet}/get-localnet-dispenser-account.js +3 -3
- package/src/localnet/get-localnet-dispenser-account.js.map +1 -0
- package/{localnet → src/localnet}/get-localnet-dispenser-account.mjs +3 -3
- package/src/localnet/get-localnet-dispenser-account.mjs.map +1 -0
- package/{localnet → src/localnet}/get-or-create-kmd-wallet-account.js +4 -4
- package/src/localnet/get-or-create-kmd-wallet-account.js.map +1 -0
- package/{localnet → src/localnet}/get-or-create-kmd-wallet-account.mjs +4 -4
- package/src/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -0
- package/{localnet → src/localnet}/is-localnet.js +2 -2
- package/src/localnet/is-localnet.js.map +1 -0
- package/{localnet → src/localnet}/is-localnet.mjs +2 -2
- package/src/localnet/is-localnet.mjs.map +1 -0
- package/{network-client.js → src/network-client.js} +5 -12
- package/src/network-client.js.map +1 -0
- package/{network-client.mjs → src/network-client.mjs} +5 -12
- package/src/network-client.mjs.map +1 -0
- package/{testing → src/testing}/account.js +16 -4
- package/src/testing/account.js.map +1 -0
- package/{testing → src/testing}/account.mjs +17 -5
- package/src/testing/account.mjs.map +1 -0
- package/src/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/src/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -0
- package/{testing → src/testing}/fixtures/algorand-fixture.js +18 -14
- package/src/testing/fixtures/algorand-fixture.js.map +1 -0
- package/{testing → src/testing}/fixtures/algorand-fixture.mjs +18 -14
- package/src/testing/fixtures/algorand-fixture.mjs.map +1 -0
- package/src/testing/indexer.js.map +1 -0
- package/src/testing/indexer.mjs.map +1 -0
- package/{testing → src/testing}/test-logger.js +7 -3
- package/src/testing/test-logger.js.map +1 -0
- package/{testing → src/testing}/test-logger.mjs +7 -3
- package/src/testing/test-logger.mjs.map +1 -0
- package/src/testing/transaction-logger.js.map +1 -0
- package/src/testing/transaction-logger.mjs.map +1 -0
- package/src/transaction/legacy-bridge.js +129 -0
- package/src/transaction/legacy-bridge.js.map +1 -0
- package/src/transaction/legacy-bridge.mjs +124 -0
- package/src/transaction/legacy-bridge.mjs.map +1 -0
- package/{transaction → src/transaction}/perform-atomic-transaction-composer-simulate.js +14 -9
- package/src/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -0
- package/{transaction → src/transaction}/perform-atomic-transaction-composer-simulate.mjs +15 -10
- package/src/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -0
- package/{transaction → src/transaction}/transaction.js +221 -141
- package/src/transaction/transaction.js.map +1 -0
- package/{transaction → src/transaction}/transaction.mjs +222 -142
- package/src/transaction/transaction.mjs.map +1 -0
- package/src/transfer/transfer-algos.js +31 -0
- package/src/transfer/transfer-algos.js.map +1 -0
- package/src/transfer/transfer-algos.mjs +29 -0
- package/src/transfer/transfer-algos.mjs.map +1 -0
- package/src/transfer/transfer.js +112 -0
- package/src/transfer/transfer.js.map +1 -0
- package/src/transfer/transfer.mjs +108 -0
- package/src/transfer/transfer.mjs.map +1 -0
- package/{util.js → src/util.js} +33 -7
- package/src/util.js.map +1 -0
- package/{util.mjs → src/util.mjs} +31 -7
- package/src/util.mjs.map +1 -0
- package/testing/_asset.d.ts +3 -5
- package/testing/account.d.ts +4 -4
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +0 -1
- package/testing/fixtures/algorand-fixture.d.ts +1 -2
- package/testing/fixtures/index.d.ts +0 -1
- package/testing/index.d.ts +0 -1
- package/testing/index.js +6 -6
- package/testing/index.mjs +6 -6
- package/testing/indexer.d.ts +0 -1
- package/testing/test-logger.d.ts +0 -1
- package/testing/transaction-logger.d.ts +0 -1
- package/transaction/index.d.ts +0 -1
- package/transaction/legacy-bridge.d.ts +35 -0
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -2
- package/transaction/transaction.d.ts +39 -20
- package/transfer/index.d.ts +0 -1
- package/transfer/transfer-algos.d.ts +4 -3
- package/transfer/transfer.d.ts +8 -2
- package/types/account-manager.d.ts +165 -40
- package/types/account-manager.js +255 -59
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +255 -59
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +137 -14
- package/types/account.js +2 -2
- package/types/account.js.map +1 -1
- package/types/account.mjs +3 -3
- package/types/account.mjs.map +1 -1
- package/types/algo-http-client-with-retry.d.ts +1 -3
- package/types/algo-http-client-with-retry.js +34 -4
- package/types/algo-http-client-with-retry.js.map +1 -1
- package/types/algo-http-client-with-retry.mjs +33 -3
- package/types/algo-http-client-with-retry.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +28 -0
- package/types/algorand-client-interface.js +3 -0
- package/types/algorand-client-interface.js.map +1 -0
- package/types/algorand-client-interface.mjs +2 -0
- package/types/algorand-client-interface.mjs.map +1 -0
- package/types/algorand-client-transaction-creator.d.ts +718 -0
- package/types/algorand-client-transaction-creator.js +683 -0
- package/types/algorand-client-transaction-creator.js.map +1 -0
- package/types/algorand-client-transaction-creator.mjs +681 -0
- package/types/algorand-client-transaction-creator.mjs.map +1 -0
- package/types/algorand-client-transaction-sender.d.ts +1158 -0
- package/types/algorand-client-transaction-sender.js +852 -0
- package/types/algorand-client-transaction-sender.js.map +1 -0
- package/types/algorand-client-transaction-sender.mjs +850 -0
- package/types/algorand-client-transaction-sender.mjs.map +1 -0
- package/types/algorand-client.d.ts +48 -91
- package/types/algorand-client.js +53 -132
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +55 -131
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +23 -12
- package/types/amount.js +33 -10
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +33 -10
- package/types/amount.mjs.map +1 -1
- package/types/app-arc56.d.ts +359 -0
- package/types/app-arc56.js +184 -0
- package/types/app-arc56.js.map +1 -0
- package/types/app-arc56.mjs +175 -0
- package/types/app-arc56.mjs.map +1 -0
- package/types/app-client.d.ts +1511 -15
- package/types/app-client.js +1029 -43
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +1030 -45
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +126 -0
- package/types/app-deployer.js +353 -0
- package/types/app-deployer.js.map +1 -0
- package/types/app-deployer.mjs +351 -0
- package/types/app-deployer.mjs.map +1 -0
- package/types/app-factory.d.ts +846 -0
- package/types/app-factory.js +410 -0
- package/types/app-factory.js.map +1 -0
- package/types/app-factory.mjs +408 -0
- package/types/app-factory.mjs.map +1 -0
- package/types/app-manager.d.ts +244 -0
- package/types/app-manager.js +423 -0
- package/types/app-manager.js.map +1 -0
- package/types/app-manager.mjs +421 -0
- package/types/app-manager.mjs.map +1 -0
- package/types/app-spec.d.ts +2 -1
- package/types/app-spec.js +127 -0
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +126 -0
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +57 -18
- package/types/app.js +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs +1 -1
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +205 -0
- package/types/asset-manager.js +176 -0
- package/types/asset-manager.js.map +1 -0
- package/types/asset-manager.mjs +174 -0
- package/types/asset-manager.mjs.map +1 -0
- package/types/asset.d.ts +4 -5
- package/types/async-event-emitter.d.ts +14 -0
- package/types/async-event-emitter.js +50 -0
- package/types/async-event-emitter.js.map +1 -0
- package/types/async-event-emitter.mjs +48 -0
- package/types/async-event-emitter.mjs.map +1 -0
- package/types/client-manager.d.ts +171 -58
- package/types/client-manager.js +198 -43
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +199 -44
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +474 -132
- package/types/composer.js +461 -167
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +461 -168
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +3 -6
- package/types/config.js +5 -44
- package/types/config.js.map +1 -1
- package/types/config.mjs +5 -27
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +29 -101
- package/types/debugging.js +16 -109
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -107
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +14 -6
- package/types/dispenser-client.js +19 -14
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +19 -14
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +7 -0
- package/types/expand.js +3 -0
- package/types/expand.js.map +1 -0
- package/types/expand.mjs +2 -0
- package/types/expand.mjs.map +1 -0
- package/types/indexer.d.ts +74 -756
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +5 -6
- package/types/kmd-account-manager.js +9 -9
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +10 -10
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +10 -0
- package/types/lifecycle-events.js +8 -0
- package/types/lifecycle-events.js.map +1 -0
- package/types/lifecycle-events.mjs +8 -0
- package/types/lifecycle-events.mjs.map +1 -0
- package/types/logging.d.ts +0 -1
- package/types/logging.js.map +1 -1
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +2 -4
- package/types/logic-error.js +3 -3
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +3 -3
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +21 -3
- package/types/network-client.js +10 -0
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +9 -0
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +9 -11
- package/types/transaction.d.ts +17 -4
- package/types/transfer.d.ts +8 -8
- package/util.d.ts +15 -2
- package/account/account.d.ts.map +0 -1
- package/account/account.js.map +0 -1
- package/account/account.mjs.map +0 -1
- package/account/get-account-config-from-environment.d.ts.map +0 -1
- package/account/get-account-config-from-environment.js.map +0 -1
- package/account/get-account-config-from-environment.mjs.map +0 -1
- package/account/get-account.d.ts.map +0 -1
- package/account/get-account.js.map +0 -1
- package/account/get-account.mjs.map +0 -1
- package/account/get-dispenser-account.d.ts.map +0 -1
- package/account/get-dispenser-account.js.map +0 -1
- package/account/get-dispenser-account.mjs.map +0 -1
- package/account/index.d.ts.map +0 -1
- package/account/mnemonic-account.d.ts.map +0 -1
- package/account/mnemonic-account.js.map +0 -1
- package/account/mnemonic-account.mjs.map +0 -1
- package/amount.d.ts.map +0 -1
- package/amount.js +0 -34
- package/amount.js.map +0 -1
- package/amount.mjs +0 -30
- package/amount.mjs.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-client.js.map +0 -1
- package/app-client.mjs.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app-deploy.js +0 -468
- package/app-deploy.js.map +0 -1
- package/app-deploy.mjs +0 -459
- package/app-deploy.mjs.map +0 -1
- package/app.d.ts.map +0 -1
- package/app.js +0 -599
- package/app.js.map +0 -1
- package/app.mjs +0 -579
- package/app.mjs.map +0 -1
- package/asset.d.ts.map +0 -1
- package/asset.js +0 -272
- package/asset.js.map +0 -1
- package/asset.mjs +0 -266
- package/asset.mjs.map +0 -1
- package/config.d.ts.map +0 -1
- package/config.js.map +0 -1
- package/config.mjs.map +0 -1
- package/debugging/debugging.d.ts.map +0 -1
- package/debugging/debugging.js +0 -139
- package/debugging/debugging.js.map +0 -1
- package/debugging/debugging.mjs +0 -118
- package/debugging/debugging.mjs.map +0 -1
- package/debugging/index.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.d.ts +0 -20
- package/debugging/simulate-and-persist-response.d.ts.map +0 -1
- package/debugging/simulate-and-persist-response.js +0 -108
- package/debugging/simulate-and-persist-response.js.map +0 -1
- package/debugging/simulate-and-persist-response.mjs +0 -89
- package/debugging/simulate-and-persist-response.mjs.map +0 -1
- package/dispenser-client.d.ts.map +0 -1
- package/dispenser-client.js.map +0 -1
- package/dispenser-client.mjs.map +0 -1
- package/index.d.ts.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/indexer-lookup.js.map +0 -1
- package/indexer-lookup.mjs.map +0 -1
- package/localnet/get-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/get-kmd-wallet-account.js.map +0 -1
- package/localnet/get-kmd-wallet-account.mjs.map +0 -1
- package/localnet/get-localnet-dispenser-account.d.ts.map +0 -1
- package/localnet/get-localnet-dispenser-account.js.map +0 -1
- package/localnet/get-localnet-dispenser-account.mjs.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.js.map +0 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +0 -1
- package/localnet/index.d.ts.map +0 -1
- package/localnet/is-localnet.d.ts.map +0 -1
- package/localnet/is-localnet.js.map +0 -1
- package/localnet/is-localnet.mjs.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/network-client.js.map +0 -1
- package/network-client.mjs.map +0 -1
- package/testing/_asset.d.ts.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/account.js.map +0 -1
- package/testing/account.mjs.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.js.map +0 -1
- package/testing/fixtures/algorand-fixture.mjs.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/indexer.js.map +0 -1
- package/testing/indexer.mjs.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/test-logger.js.map +0 -1
- package/testing/test-logger.mjs.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/testing/transaction-logger.js.map +0 -1
- package/testing/transaction-logger.mjs.map +0 -1
- package/transaction/index.d.ts.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.d.ts.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.js.map +0 -1
- package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +0 -1
- package/transaction/transaction.d.ts.map +0 -1
- package/transaction/transaction.js.map +0 -1
- package/transaction/transaction.mjs.map +0 -1
- package/transfer/index.d.ts.map +0 -1
- package/transfer/transfer-algos.d.ts.map +0 -1
- package/transfer/transfer-algos.js +0 -40
- package/transfer/transfer-algos.js.map +0 -1
- package/transfer/transfer-algos.mjs +0 -38
- package/transfer/transfer-algos.mjs.map +0 -1
- package/transfer/transfer.d.ts.map +0 -1
- package/transfer/transfer.js +0 -147
- package/transfer/transfer.js.map +0 -1
- package/transfer/transfer.mjs +0 -143
- package/transfer/transfer.mjs.map +0 -1
- package/types/account-manager.d.ts.map +0 -1
- package/types/account.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algorand-client.d.ts.map +0 -1
- package/types/amount.d.ts.map +0 -1
- package/types/app-client.d.ts.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.d.ts.map +0 -1
- package/types/asset.d.ts.map +0 -1
- package/types/client-manager.d.ts.map +0 -1
- package/types/composer.d.ts.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/debugging.d.ts.map +0 -1
- package/types/dispenser-client.d.ts.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/kmd-account-manager.d.ts.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/network-client.d.ts.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/transaction.d.ts.map +0 -1
- package/types/transfer.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts +0 -41
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.js +0 -153
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/types/urlTokenBaseHTTPClient.mjs +0 -151
- package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
- package/util.d.ts.map +0 -1
- package/util.js.map +0 -1
- package/util.mjs.map +0 -1
- /package/{account → src/account}/get-account-config-from-environment.js +0 -0
- /package/{account → src/account}/get-account-config-from-environment.mjs +0 -0
- /package/{testing → src/testing}/fixtures/algokit-log-capture-fixture.js +0 -0
- /package/{testing → src/testing}/fixtures/algokit-log-capture-fixture.mjs +0 -0
- /package/{testing → src/testing}/indexer.js +0 -0
- /package/{testing → src/testing}/indexer.mjs +0 -0
- /package/{testing → src/testing}/transaction-logger.js +0 -0
- /package/{testing → src/testing}/transaction-logger.mjs +0 -0
package/types/app-client.js
CHANGED
|
@@ -2,21 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
var algosdk = require('algosdk');
|
|
4
4
|
var buffer = require('buffer');
|
|
5
|
-
var app = require('../app.js');
|
|
6
|
-
var appDeploy = require('../app-deploy.js');
|
|
7
|
-
var config = require('../config.js');
|
|
8
|
-
var
|
|
9
|
-
var transaction = require('../transaction/transaction.js');
|
|
10
|
-
var
|
|
5
|
+
var app = require('../src/app.js');
|
|
6
|
+
var appDeploy = require('../src/app-deploy.js');
|
|
7
|
+
var config = require('../src/config.js');
|
|
8
|
+
var legacyBridge = require('../src/transaction/legacy-bridge.js');
|
|
9
|
+
var transaction = require('../src/transaction/transaction.js');
|
|
10
|
+
var util = require('../src/util.js');
|
|
11
11
|
var types_app = require('./app.js');
|
|
12
|
-
var
|
|
12
|
+
var types_appArc56 = require('./app-arc56.js');
|
|
13
|
+
var types_appSpec = require('./app-spec.js');
|
|
14
|
+
var types_lifecycleEvents = require('./lifecycle-events.js');
|
|
13
15
|
var types_logicError = require('./logic-error.js');
|
|
14
16
|
|
|
15
17
|
var ABIMethod = algosdk.ABIMethod;
|
|
16
18
|
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
17
19
|
var getApplicationAddress = algosdk.getApplicationAddress;
|
|
18
20
|
var Indexer = algosdk.Indexer;
|
|
19
|
-
var
|
|
21
|
+
var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
22
|
+
var SourceMap = algosdk.ProgramSourceMap;
|
|
20
23
|
/**
|
|
21
24
|
* Determines deploy time control (UPDATABLE, DELETABLE) value by inspecting application specification
|
|
22
25
|
* @param approval TEAL Approval program, not the base64 version found on the appSpec
|
|
@@ -39,13 +42,972 @@ function getDeployTimeControl(approval, appSpec, templateVariableName, callConfi
|
|
|
39
42
|
return !!abiCallConfig && abiCallConfig !== 'NEVER';
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
const BYTE_CBLOCK = 38;
|
|
46
|
+
const INT_CBLOCK = 32;
|
|
47
|
+
/**
|
|
48
|
+
* Get the offset of the last constant block at the beginning of the program
|
|
49
|
+
* This value is used to calculate the program counter for an ARC56 program that has a pcOffsetMethod of "cblocks"
|
|
50
|
+
*
|
|
51
|
+
* @param program The program to parse
|
|
52
|
+
* @returns The PC value of the opcode after the last constant block
|
|
53
|
+
*/
|
|
54
|
+
function getConstantBlockOffset(program) {
|
|
55
|
+
const bytes = [...program];
|
|
56
|
+
const programSize = bytes.length;
|
|
57
|
+
bytes.shift(); // remove version
|
|
58
|
+
/** The PC of the opcode after the bytecblock */
|
|
59
|
+
let bytecblockOffset;
|
|
60
|
+
/** The PC of the opcode after the intcblock */
|
|
61
|
+
let intcblockOffset;
|
|
62
|
+
while (bytes.length > 0) {
|
|
63
|
+
/** The current byte from the beginning of the byte array */
|
|
64
|
+
const byte = bytes.shift();
|
|
65
|
+
// If the byte is a constant block...
|
|
66
|
+
if (byte === BYTE_CBLOCK || byte === INT_CBLOCK) {
|
|
67
|
+
const isBytecblock = byte === BYTE_CBLOCK;
|
|
68
|
+
/** The byte following the opcode is the number of values in the constant block */
|
|
69
|
+
const valuesRemaining = bytes.shift();
|
|
70
|
+
// Iterate over all the values in the constant block
|
|
71
|
+
for (let i = 0; i < valuesRemaining; i++) {
|
|
72
|
+
if (isBytecblock) {
|
|
73
|
+
/** The byte following the opcode is the length of the next element */
|
|
74
|
+
const length = bytes.shift();
|
|
75
|
+
bytes.splice(0, length);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// intcblock is a uvarint, so we need to keep reading until we find the end (MSB is not set)
|
|
79
|
+
while ((bytes.shift() & 0x80) !== 0) {
|
|
80
|
+
// Do nothing...
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (isBytecblock)
|
|
85
|
+
bytecblockOffset = programSize - bytes.length - 1;
|
|
86
|
+
else
|
|
87
|
+
intcblockOffset = programSize - bytes.length - 1;
|
|
88
|
+
if (bytes[0] !== BYTE_CBLOCK && bytes[0] !== INT_CBLOCK) {
|
|
89
|
+
// if the next opcode isn't a constant block, we're done
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return Math.max(bytecblockOffset ?? 0, intcblockOffset ?? 0);
|
|
95
|
+
}
|
|
96
|
+
/** ARC-56/ARC-32 application client that allows you to manage calls and
|
|
97
|
+
* state for a specific deployed instance of an app (with a known app ID). */
|
|
98
|
+
class AppClient {
|
|
99
|
+
constructor(params) {
|
|
100
|
+
this._appId = params.appId;
|
|
101
|
+
this._appAddress = algosdk.getApplicationAddress(this._appId);
|
|
102
|
+
this._appSpec = AppClient.normaliseAppSpec(params.appSpec);
|
|
103
|
+
this._appName = params.appName ?? this._appSpec.name;
|
|
104
|
+
this._algorand = params.algorand;
|
|
105
|
+
this._defaultSender = typeof params.defaultSender === 'string' ? algosdk.Address.fromString(params.defaultSender) : params.defaultSender;
|
|
106
|
+
this._defaultSigner = params.defaultSigner;
|
|
107
|
+
this._approvalSourceMap = params.approvalSourceMap;
|
|
108
|
+
this._clearSourceMap = params.clearSourceMap;
|
|
109
|
+
this._localStateMethods = (address) => this.getStateMethods(() => this.getLocalState(address), () => this._appSpec.state.keys.local, () => this._appSpec.state.maps.local);
|
|
110
|
+
this._globalStateMethods = this.getStateMethods(() => this.getGlobalState(), () => this._appSpec.state.keys.global, () => this._appSpec.state.maps.global);
|
|
111
|
+
this._boxStateMethods = this.getBoxMethods();
|
|
112
|
+
this._paramsMethods = {
|
|
113
|
+
...this.getMethodCallParamsMethods(),
|
|
114
|
+
/** Get parameters to define bare (raw) transactions to the current app */
|
|
115
|
+
bare: this.getBareParamsMethods(),
|
|
116
|
+
};
|
|
117
|
+
this._createTransactionsMethods = {
|
|
118
|
+
...this.getMethodCallCreateTransactionMethods(),
|
|
119
|
+
/** Get transactions for bare (raw) calls to the current app */
|
|
120
|
+
bare: this.getBareCreateTransactionMethods(),
|
|
121
|
+
};
|
|
122
|
+
this._sendMethods = {
|
|
123
|
+
...this.getMethodCallSendMethods(),
|
|
124
|
+
/** Send bare (raw) transactions to the current app */
|
|
125
|
+
bare: this.getBareSendMethods(),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Clone this app client with different params
|
|
130
|
+
*
|
|
131
|
+
* @param params The params to use for the the cloned app client. Omit a param to keep the original value. Set a param to override the original value. Setting to undefined will clear the original value.
|
|
132
|
+
* @returns A new app client with the altered params
|
|
133
|
+
*/
|
|
134
|
+
clone(params) {
|
|
135
|
+
return new AppClient({
|
|
136
|
+
appId: this._appId,
|
|
137
|
+
appSpec: this._appSpec,
|
|
138
|
+
algorand: this._algorand,
|
|
139
|
+
appName: this._appName,
|
|
140
|
+
defaultSender: this._defaultSender,
|
|
141
|
+
defaultSigner: this._defaultSigner,
|
|
142
|
+
approvalSourceMap: this._approvalSourceMap,
|
|
143
|
+
clearSourceMap: this._clearSourceMap,
|
|
144
|
+
...params,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns a new `AppClient` client, resolving the app by creator address and name
|
|
149
|
+
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
150
|
+
* @param params The parameters to create the app client
|
|
151
|
+
*/
|
|
152
|
+
static async fromCreatorAndName(params) {
|
|
153
|
+
const appSpec = AppClient.normaliseAppSpec(params.appSpec);
|
|
154
|
+
const appLookup = params.appLookupCache ?? (await params.algorand.appDeployer.getCreatorAppsByName(params.creatorAddress, params.ignoreCache));
|
|
155
|
+
const appMetadata = appLookup.apps[params.appName ?? appSpec.name];
|
|
156
|
+
if (!appMetadata) {
|
|
157
|
+
throw new Error(`App not found for creator ${params.creatorAddress} and name ${params.appName ?? appSpec.name}`);
|
|
158
|
+
}
|
|
159
|
+
return new AppClient({
|
|
160
|
+
...params,
|
|
161
|
+
algorand: params.algorand,
|
|
162
|
+
appId: appMetadata.appId,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns an `AppClient` instance for the current network based on
|
|
167
|
+
* pre-determined network-specific app IDs specified in the ARC-56 app spec.
|
|
168
|
+
*
|
|
169
|
+
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
170
|
+
* @param params The parameters to create the app client
|
|
171
|
+
*/
|
|
172
|
+
static async fromNetwork(params) {
|
|
173
|
+
const network = await params.algorand.client.network();
|
|
174
|
+
const appSpec = AppClient.normaliseAppSpec(params.appSpec);
|
|
175
|
+
const networkNames = [network.genesisHash];
|
|
176
|
+
if (network.isLocalNet)
|
|
177
|
+
networkNames.push('localnet');
|
|
178
|
+
if (network.isTestNet)
|
|
179
|
+
networkNames.push('testnet');
|
|
180
|
+
if (network.isMainNet)
|
|
181
|
+
networkNames.push('mainnet');
|
|
182
|
+
const availableAppSpecNetworks = Object.keys(appSpec.networks ?? {});
|
|
183
|
+
const networkIndex = availableAppSpecNetworks.findIndex((n) => networkNames.includes(n));
|
|
184
|
+
if (networkIndex === -1) {
|
|
185
|
+
throw new Error(`No app ID found for network ${JSON.stringify(networkNames)} in the app spec`);
|
|
186
|
+
}
|
|
187
|
+
const appId = BigInt(appSpec.networks[networkIndex].appID);
|
|
188
|
+
return new AppClient({ ...params, appId, appSpec });
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Takes a string or parsed JSON object that could be ARC-32 or ARC-56 format and
|
|
192
|
+
* normalises it into a parsed ARC-56 contract object.
|
|
193
|
+
* @param spec The spec to normalise
|
|
194
|
+
* @returns The normalised ARC-56 contract object
|
|
195
|
+
*/
|
|
196
|
+
static normaliseAppSpec(spec) {
|
|
197
|
+
const parsedSpec = typeof spec === 'string' ? JSON.parse(spec) : spec;
|
|
198
|
+
const appSpec = 'hints' in parsedSpec ? types_appSpec.arc32ToArc56(parsedSpec) : parsedSpec;
|
|
199
|
+
return appSpec;
|
|
200
|
+
}
|
|
201
|
+
/** The ID of the app instance this client is linked to. */
|
|
202
|
+
get appId() {
|
|
203
|
+
return this._appId;
|
|
204
|
+
}
|
|
205
|
+
/** The app address of the app instance this client is linked to. */
|
|
206
|
+
get appAddress() {
|
|
207
|
+
return this._appAddress;
|
|
208
|
+
}
|
|
209
|
+
/** The name of the app (from the ARC-32 / ARC-56 app spec or override). */
|
|
210
|
+
get appName() {
|
|
211
|
+
return this._appName;
|
|
212
|
+
}
|
|
213
|
+
/** The ARC-56 app spec being used */
|
|
214
|
+
get appSpec() {
|
|
215
|
+
return this._appSpec;
|
|
216
|
+
}
|
|
217
|
+
/** A reference to the underlying `AlgorandClient` this app client is using. */
|
|
218
|
+
get algorand() {
|
|
219
|
+
return this._algorand;
|
|
220
|
+
}
|
|
221
|
+
/** Get parameters to create transactions for the current app.
|
|
222
|
+
*
|
|
223
|
+
* A good mental model for this is that these parameters represent a deferred transaction creation.
|
|
224
|
+
* @example Create a transaction in the future using Algorand Client
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
|
|
227
|
+
* // ...
|
|
228
|
+
* await algorand.send.AppMethodCall(myMethodCall)
|
|
229
|
+
* ```
|
|
230
|
+
* @example Define a nested transaction as an ABI argument
|
|
231
|
+
* ```typescript
|
|
232
|
+
* const myMethodCall = appClient.params.call({method: 'my_method', args: [123, 'hello']})
|
|
233
|
+
* await appClient.send.call({method: 'my_method2', args: [myMethodCall]})
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
get params() {
|
|
237
|
+
return this._paramsMethods;
|
|
238
|
+
}
|
|
239
|
+
/** Create transactions for the current app */
|
|
240
|
+
get createTransaction() {
|
|
241
|
+
return this._createTransactionsMethods;
|
|
242
|
+
}
|
|
243
|
+
/** Send transactions to the current app */
|
|
244
|
+
get send() {
|
|
245
|
+
return this._sendMethods;
|
|
246
|
+
}
|
|
247
|
+
/** Get state (local, global, box) from the current app */
|
|
248
|
+
get state() {
|
|
249
|
+
return {
|
|
250
|
+
/**
|
|
251
|
+
* Methods to access local state for the current app
|
|
252
|
+
* @param address The address of the account to get the local state for
|
|
253
|
+
*/
|
|
254
|
+
local: this._localStateMethods,
|
|
255
|
+
/**
|
|
256
|
+
* Methods to access global state for the current app
|
|
257
|
+
*/
|
|
258
|
+
global: this._globalStateMethods,
|
|
259
|
+
/**
|
|
260
|
+
* Methods to access box storage for the current app
|
|
261
|
+
*/
|
|
262
|
+
box: this._boxStateMethods,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Funds Algo into the app account for this app.
|
|
267
|
+
*
|
|
268
|
+
* An alias for `appClient.send.fundAppAccount(params)`.
|
|
269
|
+
* @param params The parameters for the funding transaction
|
|
270
|
+
* @returns The result of the funding
|
|
271
|
+
*/
|
|
272
|
+
async fundAppAccount(params) {
|
|
273
|
+
return this.send.fundAppAccount(params);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Returns raw global state for the current app.
|
|
277
|
+
* @returns The global state
|
|
278
|
+
*/
|
|
279
|
+
async getGlobalState() {
|
|
280
|
+
return await this._algorand.app.getGlobalState(this.appId);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Returns raw local state for the given account address.
|
|
284
|
+
* @param address The address of the account to get the local state for
|
|
285
|
+
* @returns The local state
|
|
286
|
+
*/
|
|
287
|
+
async getLocalState(address) {
|
|
288
|
+
return await this._algorand.app.getLocalState(this.appId, address);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Returns the names of all current boxes for the current app.
|
|
292
|
+
* @returns The names of the boxes
|
|
293
|
+
*/
|
|
294
|
+
async getBoxNames() {
|
|
295
|
+
return await this._algorand.app.getBoxNames(this.appId);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Returns the value of the given box for the current app.
|
|
299
|
+
* @param name The identifier of the box to return
|
|
300
|
+
* @returns The current box value as a byte array
|
|
301
|
+
*/
|
|
302
|
+
async getBoxValue(name) {
|
|
303
|
+
return await this._algorand.app.getBoxValue(this.appId, name);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Returns the value of the given box for the current app.
|
|
307
|
+
* @param name The identifier of the box to return
|
|
308
|
+
* @param type
|
|
309
|
+
* @returns The current box value as a byte array
|
|
310
|
+
*/
|
|
311
|
+
async getBoxValueFromABIType(name, type) {
|
|
312
|
+
return await this._algorand.app.getBoxValueFromABIType({
|
|
313
|
+
appId: this.appId,
|
|
314
|
+
boxName: name,
|
|
315
|
+
type,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Returns the values of all current boxes for the current app.
|
|
320
|
+
* Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.
|
|
321
|
+
* @param filter Optional filter to filter which boxes' values are returned
|
|
322
|
+
* @returns The (name, value) pair of the boxes with values as raw byte arrays
|
|
323
|
+
*/
|
|
324
|
+
async getBoxValues(filter) {
|
|
325
|
+
const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
|
|
326
|
+
const values = await this._algorand.app.getBoxValues(this.appId, names.map((name) => name.nameRaw));
|
|
327
|
+
return names.map((name, i) => ({ name, value: values[i] }));
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Returns the values of all current boxes for the current app decoded using an ABI Type.
|
|
331
|
+
* Note: This will issue multiple HTTP requests (one per box) and it's not an atomic operation so values may be out of sync.
|
|
332
|
+
* @param type The ABI type to decode the values with
|
|
333
|
+
* @param filter Optional filter to filter which boxes' values are returned
|
|
334
|
+
* @returns The (name, value) pair of the boxes with values as the ABI Value
|
|
335
|
+
*/
|
|
336
|
+
async getBoxValuesFromABIType(type, filter) {
|
|
337
|
+
const names = (await this.getBoxNames()).filter(filter ?? ((_) => true));
|
|
338
|
+
const values = await this._algorand.app.getBoxValuesFromABIType({
|
|
339
|
+
appId: this.appId,
|
|
340
|
+
boxNames: names.map((name) => name.nameRaw),
|
|
341
|
+
type,
|
|
342
|
+
});
|
|
343
|
+
return names.map((name, i) => ({ name, value: values[i] }));
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Takes an error that may include a logic error from a call to the current app and re-exposes the
|
|
347
|
+
* error to include source code information via the source map and ARC-56 spec.
|
|
348
|
+
* @param e The error to parse
|
|
349
|
+
* @param isClearStateProgram Whether or not the code was running the clear state program (defaults to approval program)
|
|
350
|
+
* @returns The new error, or if there was no logic error or source map then the wrapped error with source details
|
|
351
|
+
*/
|
|
352
|
+
async exposeLogicError(e, isClearStateProgram) {
|
|
353
|
+
const pcOffsetMethod = this._appSpec.sourceInfo?.[isClearStateProgram ? 'clear' : 'approval']?.pcOffsetMethod;
|
|
354
|
+
let program;
|
|
355
|
+
if (pcOffsetMethod === 'cblocks') {
|
|
356
|
+
// TODO: Cache this if we deploy the app and it's not updateable
|
|
357
|
+
const appInfo = await this._algorand.app.getById(this.appId);
|
|
358
|
+
program = isClearStateProgram ? appInfo.clearStateProgram : appInfo.approvalProgram;
|
|
359
|
+
}
|
|
360
|
+
return AppClient.exposeLogicError(e, this._appSpec, {
|
|
361
|
+
isClearStateProgram,
|
|
362
|
+
approvalSourceMap: this._approvalSourceMap,
|
|
363
|
+
clearSourceMap: this._clearSourceMap,
|
|
364
|
+
program,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Export the current source maps for the app.
|
|
369
|
+
* @returns The source maps
|
|
370
|
+
*/
|
|
371
|
+
exportSourceMaps() {
|
|
372
|
+
if (!this._approvalSourceMap || !this._clearSourceMap) {
|
|
373
|
+
throw new Error("Unable to export source maps; they haven't been loaded into this client - you need to call create, update, or deploy first");
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
approvalSourceMap: this._approvalSourceMap,
|
|
377
|
+
clearSourceMap: this._clearSourceMap,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Import source maps for the app.
|
|
382
|
+
* @param sourceMaps The source maps to import
|
|
383
|
+
*/
|
|
384
|
+
importSourceMaps(sourceMaps) {
|
|
385
|
+
this._approvalSourceMap = new SourceMap(sourceMaps.approvalSourceMap);
|
|
386
|
+
this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Returns the ABI Method spec for the given method string for the app represented by this application client instance
|
|
390
|
+
* @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
|
|
391
|
+
* e.g. `my_method` or `my_method(unit64,string)bytes`
|
|
392
|
+
* @returns A tuple with: [ARC-56 `Method`, algosdk `ABIMethod`]
|
|
393
|
+
*/
|
|
394
|
+
getABIMethod(methodNameOrSignature) {
|
|
395
|
+
return types_appArc56.getArc56Method(methodNameOrSignature, this._appSpec);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Checks for decode errors on the SendAppTransactionResult and maps the return value to the specified type
|
|
399
|
+
* on the ARC-56 method, replacing the `return` property with the decoded type.
|
|
400
|
+
*
|
|
401
|
+
* If the return type is an ARC-56 struct then the struct will be returned.
|
|
402
|
+
*
|
|
403
|
+
* @param result The SendAppTransactionResult to be mapped
|
|
404
|
+
* @param method The method that was called
|
|
405
|
+
* @returns The smart contract response with an updated return value
|
|
406
|
+
*/
|
|
407
|
+
async processMethodCallReturn(result, method) {
|
|
408
|
+
const resultValue = await result;
|
|
409
|
+
return { ...resultValue, return: types_appArc56.getArc56ReturnValue(resultValue.return, method, this._appSpec.structs) };
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Compiles the approval and clear state programs (if TEAL templates provided),
|
|
413
|
+
* performing any provided deploy-time parameter replacement and stores
|
|
414
|
+
* the source maps.
|
|
415
|
+
*
|
|
416
|
+
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
417
|
+
*
|
|
418
|
+
* Will store any generated source maps for later use in debugging.
|
|
419
|
+
*/
|
|
420
|
+
async compile(compilation) {
|
|
421
|
+
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
422
|
+
if (result.compiledApproval) {
|
|
423
|
+
this._approvalSourceMap = result.compiledApproval.sourceMap;
|
|
424
|
+
}
|
|
425
|
+
if (result.compiledClear) {
|
|
426
|
+
this._clearSourceMap = result.compiledClear.sourceMap;
|
|
427
|
+
}
|
|
428
|
+
return result;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Takes an error that may include a logic error from a call to the current app and re-exposes the
|
|
432
|
+
* error to include source code information via the source map and ARC-56 spec.
|
|
433
|
+
* @param e The error to parse
|
|
434
|
+
* @param appSpec The app spec for the app
|
|
435
|
+
* @param details Additional information to inform the error
|
|
436
|
+
* @returns The new error, or if there was no logic error or source map then the wrapped error with source details
|
|
437
|
+
*/
|
|
438
|
+
static exposeLogicError(e, appSpec, details) {
|
|
439
|
+
const { isClearStateProgram, approvalSourceMap, clearSourceMap, program } = details;
|
|
440
|
+
const sourceMap = isClearStateProgram ? clearSourceMap : approvalSourceMap;
|
|
441
|
+
const errorDetails = types_logicError.LogicError.parseLogicError(e);
|
|
442
|
+
// Return the error if we don't have a PC
|
|
443
|
+
if (errorDetails === undefined || errorDetails?.pc === undefined)
|
|
444
|
+
return e;
|
|
445
|
+
/** The PC value to find in the ARC56 SourceInfo */
|
|
446
|
+
let arc56Pc = errorDetails?.pc;
|
|
447
|
+
const programSourceInfo = isClearStateProgram ? appSpec.sourceInfo?.clear : appSpec.sourceInfo?.approval;
|
|
448
|
+
/** The offset to apply to the PC if using the cblocks pc offset method */
|
|
449
|
+
let cblocksOffset = 0;
|
|
450
|
+
// If the program uses cblocks offset, then we need to adjust the PC accordingly
|
|
451
|
+
if (programSourceInfo?.pcOffsetMethod === 'cblocks') {
|
|
452
|
+
if (program === undefined)
|
|
453
|
+
throw new Error('Program bytes are required to calculate the ARC56 cblocks PC offset');
|
|
454
|
+
cblocksOffset = getConstantBlockOffset(program);
|
|
455
|
+
arc56Pc = errorDetails.pc - cblocksOffset;
|
|
456
|
+
}
|
|
457
|
+
// Find the source info for this PC and get the error message
|
|
458
|
+
const sourceInfo = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(arc56Pc));
|
|
459
|
+
const errorMessage = sourceInfo?.errorMessage;
|
|
460
|
+
// If we have the source we can display the TEAL in the error message
|
|
461
|
+
if (appSpec.source) {
|
|
462
|
+
let getLineForPc = (inputPc) => sourceMap?.getLocationForPc?.(inputPc)?.line;
|
|
463
|
+
// If the SourceMap is not defined, we need to provide our own function for going from a PC to TEAL based on ARC56 SourceInfo[]
|
|
464
|
+
if (sourceMap === undefined) {
|
|
465
|
+
getLineForPc = (inputPc) => {
|
|
466
|
+
const teal = programSourceInfo?.sourceInfo.find((s) => s.pc.includes(inputPc - cblocksOffset))?.teal;
|
|
467
|
+
if (teal === undefined)
|
|
468
|
+
return undefined;
|
|
469
|
+
return teal - 1;
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
e = new types_logicError.LogicError(errorDetails, buffer.Buffer.from(isClearStateProgram ? appSpec.source.clear : appSpec.source.approval, 'base64')
|
|
473
|
+
.toString()
|
|
474
|
+
.split('\n'),
|
|
475
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
476
|
+
getLineForPc);
|
|
477
|
+
}
|
|
478
|
+
if (errorMessage) {
|
|
479
|
+
const appId = JSON.stringify(e).match(/(?<=app=)\d+/)?.[0] || '';
|
|
480
|
+
const txId = JSON.stringify(e).match(/(?<=transaction )\S+(?=:)/)?.[0];
|
|
481
|
+
const error = new Error(`Runtime error when executing ${appSpec.name} (appId: ${appId}) in transaction ${txId}: ${errorMessage}`);
|
|
482
|
+
error.cause = e;
|
|
483
|
+
return error;
|
|
484
|
+
}
|
|
485
|
+
return e;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Compiles the approval and clear state programs (if TEAL templates provided),
|
|
489
|
+
* performing any provided deploy-time parameter replacement and returns
|
|
490
|
+
* the compiled code and any compilation results (including source maps).
|
|
491
|
+
*
|
|
492
|
+
* If no TEAL templates provided it will use any byte code provided in the app spec.
|
|
493
|
+
*
|
|
494
|
+
* Will store any generated source maps for later use in debugging.
|
|
495
|
+
* @param appSpec The app spec for the app
|
|
496
|
+
* @param compilation Any compilation parameters to use
|
|
497
|
+
*/
|
|
498
|
+
static async compile(appSpec, appManager, compilation) {
|
|
499
|
+
const { deployTimeParams, updatable, deletable } = compilation ?? {};
|
|
500
|
+
if (!appSpec.source) {
|
|
501
|
+
if (!appSpec.byteCode?.approval || !appSpec.byteCode?.clear) {
|
|
502
|
+
throw new Error(`Attempt to compile app ${appSpec.name} without source or byteCode`);
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
approvalProgram: buffer.Buffer.from(appSpec.byteCode.approval, 'base64'),
|
|
506
|
+
clearStateProgram: buffer.Buffer.from(appSpec.byteCode.clear, 'base64'),
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
const approvalTemplate = buffer.Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
|
|
510
|
+
const compiledApproval = await appManager.compileTealTemplate(approvalTemplate, deployTimeParams, {
|
|
511
|
+
updatable,
|
|
512
|
+
deletable,
|
|
513
|
+
});
|
|
514
|
+
const clearTemplate = buffer.Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
|
|
515
|
+
const compiledClear = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
|
|
516
|
+
if (config.Config.debug) {
|
|
517
|
+
await config.Config.events.emitAsync(types_lifecycleEvents.EventType.AppCompiled, {
|
|
518
|
+
sources: [
|
|
519
|
+
{ compiledTeal: compiledApproval, appName: appSpec.name, fileName: 'approval' },
|
|
520
|
+
{ compiledTeal: compiledClear, appName: appSpec.name, fileName: 'clear' },
|
|
521
|
+
],
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
return {
|
|
525
|
+
approvalProgram: compiledApproval.compiledBase64ToBytes,
|
|
526
|
+
compiledApproval,
|
|
527
|
+
clearStateProgram: compiledClear.compiledBase64ToBytes,
|
|
528
|
+
compiledClear,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Returns ABI method arguments ready for a method call params object with default values populated
|
|
533
|
+
* and structs replaced with tuples.
|
|
534
|
+
*
|
|
535
|
+
* It does this by replacing any `undefined` values with the equivalent default value from the given ARC-56 app spec.
|
|
536
|
+
* @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.
|
|
537
|
+
* e.g. `my_method` or `my_method(unit64,string)bytes`
|
|
538
|
+
* @param args The arguments to the method with `undefined` for any that should be populated with a default value
|
|
539
|
+
*/
|
|
540
|
+
async getABIArgsWithDefaultValues(methodNameOrSignature, args, sender) {
|
|
541
|
+
const m = types_appArc56.getArc56Method(methodNameOrSignature, this._appSpec);
|
|
542
|
+
return await Promise.all(args?.map(async (a, i) => {
|
|
543
|
+
const arg = m.args[i];
|
|
544
|
+
if (a !== undefined) {
|
|
545
|
+
// If a struct then convert to tuple for the underlying call
|
|
546
|
+
return arg.struct && typeof a === 'object' && !Array.isArray(a)
|
|
547
|
+
? types_appArc56.getABITupleFromABIStruct(a, this._appSpec.structs[arg.struct], this._appSpec.structs)
|
|
548
|
+
: a;
|
|
549
|
+
}
|
|
550
|
+
const defaultValue = arg.defaultValue;
|
|
551
|
+
if (defaultValue) {
|
|
552
|
+
switch (defaultValue.source) {
|
|
553
|
+
case 'literal':
|
|
554
|
+
return types_appArc56.getABIDecodedValue(buffer.Buffer.from(defaultValue.data, 'base64'), m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
|
|
555
|
+
case 'method': {
|
|
556
|
+
const method = this.getABIMethod(defaultValue.data);
|
|
557
|
+
const result = await this.send.call({
|
|
558
|
+
method: defaultValue.data,
|
|
559
|
+
args: method.args.map(() => undefined),
|
|
560
|
+
sender,
|
|
561
|
+
});
|
|
562
|
+
if (result.return === undefined) {
|
|
563
|
+
throw new Error('Default value method call did not return a value');
|
|
564
|
+
}
|
|
565
|
+
if (typeof result.return === 'object' && !(result.return instanceof Uint8Array) && !Array.isArray(result.return)) {
|
|
566
|
+
return types_appArc56.getABITupleFromABIStruct(result.return, this._appSpec.structs[method.returns.struct], this._appSpec.structs);
|
|
567
|
+
}
|
|
568
|
+
return result.return;
|
|
569
|
+
}
|
|
570
|
+
case 'local':
|
|
571
|
+
case 'global': {
|
|
572
|
+
const state = defaultValue.source === 'global' ? await this.getGlobalState() : await this.getLocalState(sender);
|
|
573
|
+
const value = Object.values(state).find((s) => s.keyBase64 === defaultValue.data);
|
|
574
|
+
if (!value) {
|
|
575
|
+
throw new Error(`Preparing default value for argument ${arg.name ?? `arg${i + 1}`} resulted in the failure: The key '${defaultValue.data}' could not be found in ${defaultValue.source} storage`);
|
|
576
|
+
}
|
|
577
|
+
return 'valueRaw' in value
|
|
578
|
+
? types_appArc56.getABIDecodedValue(value.valueRaw, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs)
|
|
579
|
+
: value.value;
|
|
580
|
+
}
|
|
581
|
+
case 'box': {
|
|
582
|
+
const value = await this.getBoxValue(buffer.Buffer.from(defaultValue.data, 'base64'));
|
|
583
|
+
return types_appArc56.getABIDecodedValue(value, m.method.args[i].defaultValue?.type ?? m.method.args[i].type, this._appSpec.structs);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (!algosdk.abiTypeIsTransaction(arg.type)) {
|
|
588
|
+
throw new Error(`No value provided for required argument ${arg.name ?? `arg${i + 1}`} in call to method ${m.name}`);
|
|
589
|
+
}
|
|
590
|
+
}) ?? []);
|
|
591
|
+
}
|
|
592
|
+
getBareParamsMethods() {
|
|
593
|
+
return {
|
|
594
|
+
/** Return params for an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
595
|
+
update: async (params) => {
|
|
596
|
+
return this.getBareParams({
|
|
597
|
+
...params,
|
|
598
|
+
...(await this.compile(params)),
|
|
599
|
+
}, OnApplicationComplete.UpdateApplicationOC);
|
|
600
|
+
},
|
|
601
|
+
/** Return params for an opt-in call */
|
|
602
|
+
optIn: (params) => {
|
|
603
|
+
return this.getBareParams(params, OnApplicationComplete.OptInOC);
|
|
604
|
+
},
|
|
605
|
+
/** Return params for a delete call */
|
|
606
|
+
delete: (params) => {
|
|
607
|
+
return this.getBareParams(params, OnApplicationComplete.DeleteApplicationOC);
|
|
608
|
+
},
|
|
609
|
+
/** Return params for a clear state call */
|
|
610
|
+
clearState: (params) => {
|
|
611
|
+
return this.getBareParams(params, OnApplicationComplete.ClearStateOC);
|
|
612
|
+
},
|
|
613
|
+
/** Return params for a close out call */
|
|
614
|
+
closeOut: (params) => {
|
|
615
|
+
return this.getBareParams(params, OnApplicationComplete.CloseOutOC);
|
|
616
|
+
},
|
|
617
|
+
/** Return params for a call (defaults to no-op) */
|
|
618
|
+
call: (params) => {
|
|
619
|
+
return this.getBareParams(params, params?.onComplete ?? OnApplicationComplete.NoOpOC);
|
|
620
|
+
},
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
getBareCreateTransactionMethods() {
|
|
624
|
+
return {
|
|
625
|
+
/** Returns a transaction for an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
626
|
+
update: async (params) => {
|
|
627
|
+
return this._algorand.createTransaction.appUpdate(await this.params.bare.update(params));
|
|
628
|
+
},
|
|
629
|
+
/** Returns a transaction for an opt-in call */
|
|
630
|
+
optIn: (params) => {
|
|
631
|
+
return this._algorand.createTransaction.appCall(this.params.bare.optIn(params));
|
|
632
|
+
},
|
|
633
|
+
/** Returns a transaction for a delete call */
|
|
634
|
+
delete: (params) => {
|
|
635
|
+
return this._algorand.createTransaction.appDelete(this.params.bare.delete(params));
|
|
636
|
+
},
|
|
637
|
+
/** Returns a transaction for a clear state call */
|
|
638
|
+
clearState: (params) => {
|
|
639
|
+
return this._algorand.createTransaction.appCall(this.params.bare.clearState(params));
|
|
640
|
+
},
|
|
641
|
+
/** Returns a transaction for a close out call */
|
|
642
|
+
closeOut: (params) => {
|
|
643
|
+
return this._algorand.createTransaction.appCall(this.params.bare.closeOut(params));
|
|
644
|
+
},
|
|
645
|
+
/** Returns a transaction for a call (defaults to no-op) */
|
|
646
|
+
call: (params) => {
|
|
647
|
+
return this._algorand.createTransaction.appCall(this.params.bare.call(params));
|
|
648
|
+
},
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
getBareSendMethods() {
|
|
652
|
+
return {
|
|
653
|
+
/** Signs and sends an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
654
|
+
update: async (params) => {
|
|
655
|
+
const compiled = await this.compile(params);
|
|
656
|
+
return {
|
|
657
|
+
...(await this.handleCallErrors(async () => this._algorand.send.appUpdate(await this.params.bare.update(params)))),
|
|
658
|
+
...compiled,
|
|
659
|
+
};
|
|
660
|
+
},
|
|
661
|
+
/** Signs and sends an opt-in call */
|
|
662
|
+
optIn: (params) => {
|
|
663
|
+
return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.optIn(params)));
|
|
664
|
+
},
|
|
665
|
+
/** Signs and sends a delete call */
|
|
666
|
+
delete: (params) => {
|
|
667
|
+
return this.handleCallErrors(() => this._algorand.send.appDelete(this.params.bare.delete(params)));
|
|
668
|
+
},
|
|
669
|
+
/** Signs and sends a clear state call */
|
|
670
|
+
clearState: (params) => {
|
|
671
|
+
return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.clearState(params)));
|
|
672
|
+
},
|
|
673
|
+
/** Signs and sends a close out call */
|
|
674
|
+
closeOut: (params) => {
|
|
675
|
+
return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.closeOut(params)));
|
|
676
|
+
},
|
|
677
|
+
/** Signs and sends a call (defaults to no-op) */
|
|
678
|
+
call: (params) => {
|
|
679
|
+
return this.handleCallErrors(() => this._algorand.send.appCall(this.params.bare.call(params)));
|
|
680
|
+
},
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
getMethodCallParamsMethods() {
|
|
684
|
+
return {
|
|
685
|
+
/** Return params for a payment transaction to fund the app account */
|
|
686
|
+
fundAppAccount: (params) => {
|
|
687
|
+
return {
|
|
688
|
+
...params,
|
|
689
|
+
sender: this.getSender(params.sender),
|
|
690
|
+
signer: this.getSigner(params.sender, params.signer),
|
|
691
|
+
receiver: this.appAddress,
|
|
692
|
+
};
|
|
693
|
+
},
|
|
694
|
+
/** Return params for an update ABI call, including deploy-time TEAL template replacements and compilation if provided */
|
|
695
|
+
update: async (params) => {
|
|
696
|
+
return (await this.getABIParams({
|
|
697
|
+
...params,
|
|
698
|
+
...(await this.compile(params)),
|
|
699
|
+
}, OnApplicationComplete.UpdateApplicationOC));
|
|
700
|
+
},
|
|
701
|
+
/** Return params for an opt-in ABI call */
|
|
702
|
+
optIn: async (params) => {
|
|
703
|
+
return (await this.getABIParams(params, OnApplicationComplete.OptInOC));
|
|
704
|
+
},
|
|
705
|
+
/** Return params for an delete ABI call */
|
|
706
|
+
delete: async (params) => {
|
|
707
|
+
return (await this.getABIParams(params, OnApplicationComplete.DeleteApplicationOC));
|
|
708
|
+
},
|
|
709
|
+
/** Return params for an close out ABI call */
|
|
710
|
+
closeOut: async (params) => {
|
|
711
|
+
return (await this.getABIParams(params, OnApplicationComplete.CloseOutOC));
|
|
712
|
+
},
|
|
713
|
+
/** Return params for an ABI call */
|
|
714
|
+
call: async (params) => {
|
|
715
|
+
return (await this.getABIParams(params, params.onComplete ?? OnApplicationComplete.NoOpOC));
|
|
716
|
+
},
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
getMethodCallSendMethods() {
|
|
720
|
+
return {
|
|
721
|
+
/** Sign and send transactions for a payment transaction to fund the app account */
|
|
722
|
+
fundAppAccount: (params) => {
|
|
723
|
+
return this._algorand.send.payment(this.params.fundAppAccount(params));
|
|
724
|
+
},
|
|
725
|
+
/**
|
|
726
|
+
* Sign and send transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
|
|
727
|
+
*/
|
|
728
|
+
update: async (params) => {
|
|
729
|
+
const compiled = await this.compile(params);
|
|
730
|
+
return {
|
|
731
|
+
...(await this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), types_appArc56.getArc56Method(params.method, this._appSpec)))),
|
|
732
|
+
...compiled,
|
|
733
|
+
};
|
|
734
|
+
},
|
|
735
|
+
/**
|
|
736
|
+
* Sign and send transactions for an opt-in ABI call
|
|
737
|
+
*/
|
|
738
|
+
optIn: (params) => {
|
|
739
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.optIn(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
740
|
+
},
|
|
741
|
+
/**
|
|
742
|
+
* Sign and send transactions for a delete ABI call
|
|
743
|
+
*/
|
|
744
|
+
delete: (params) => {
|
|
745
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appDeleteMethodCall(await this.params.delete(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
746
|
+
},
|
|
747
|
+
/**
|
|
748
|
+
* Sign and send transactions for a close out ABI call
|
|
749
|
+
*/
|
|
750
|
+
closeOut: (params) => {
|
|
751
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.closeOut(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
752
|
+
},
|
|
753
|
+
/**
|
|
754
|
+
* Sign and send transactions for a call (defaults to no-op)
|
|
755
|
+
*/
|
|
756
|
+
call: async (params) => {
|
|
757
|
+
// Read-only call - do it via simulate
|
|
758
|
+
if ((params.onComplete === OnApplicationComplete.NoOpOC || !params.onComplete) &&
|
|
759
|
+
types_appArc56.getArc56Method(params.method, this._appSpec).method.readonly) {
|
|
760
|
+
const result = await this._algorand
|
|
761
|
+
.newGroup()
|
|
762
|
+
.addAppCallMethodCall(await this.params.call(params))
|
|
763
|
+
.simulate({
|
|
764
|
+
allowUnnamedResources: params.populateAppCallResources ?? true,
|
|
765
|
+
// Simulate calls for a readonly method shouldn't invoke signing
|
|
766
|
+
skipSignatures: true,
|
|
767
|
+
});
|
|
768
|
+
return this.processMethodCallReturn({
|
|
769
|
+
...result,
|
|
770
|
+
transaction: result.transactions.at(-1),
|
|
771
|
+
confirmation: result.confirmations.at(-1),
|
|
772
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
773
|
+
return: (result.returns?.length ?? 0 > 0) ? result.returns?.at(-1) : undefined,
|
|
774
|
+
}, types_appArc56.getArc56Method(params.method, this._appSpec));
|
|
775
|
+
}
|
|
776
|
+
return this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appCallMethodCall(await this.params.call(params)), types_appArc56.getArc56Method(params.method, this._appSpec)));
|
|
777
|
+
},
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
getMethodCallCreateTransactionMethods() {
|
|
781
|
+
return {
|
|
782
|
+
/** Return transaction for a payment transaction to fund the app account */
|
|
783
|
+
fundAppAccount: (params) => {
|
|
784
|
+
return this._algorand.createTransaction.payment(this.params.fundAppAccount(params));
|
|
785
|
+
},
|
|
786
|
+
/**
|
|
787
|
+
* Return transactions for an update ABI call, including deploy-time TEAL template replacements and compilation if provided
|
|
788
|
+
*/
|
|
789
|
+
update: async (params) => {
|
|
790
|
+
return this._algorand.createTransaction.appUpdateMethodCall(await this.params.update(params));
|
|
791
|
+
},
|
|
792
|
+
/**
|
|
793
|
+
* Return transactions for an opt-in ABI call
|
|
794
|
+
*/
|
|
795
|
+
optIn: async (params) => {
|
|
796
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.optIn(params));
|
|
797
|
+
},
|
|
798
|
+
/**
|
|
799
|
+
* Return transactions for a delete ABI call
|
|
800
|
+
*/
|
|
801
|
+
delete: async (params) => {
|
|
802
|
+
return this._algorand.createTransaction.appDeleteMethodCall(await this.params.delete(params));
|
|
803
|
+
},
|
|
804
|
+
/**
|
|
805
|
+
* Return transactions for a close out ABI call
|
|
806
|
+
*/
|
|
807
|
+
closeOut: async (params) => {
|
|
808
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.closeOut(params));
|
|
809
|
+
},
|
|
810
|
+
/**
|
|
811
|
+
* Return transactions for an ABI call (defaults to no-op)
|
|
812
|
+
*/
|
|
813
|
+
call: async (params) => {
|
|
814
|
+
return this._algorand.createTransaction.appCallMethodCall(await this.params.call(params));
|
|
815
|
+
},
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
/** Returns the sender for a call, using the provided sender or using the `defaultSender`
|
|
819
|
+
* if none provided and throws an error if neither provided */
|
|
820
|
+
getSender(sender) {
|
|
821
|
+
if (!sender && !this._defaultSender) {
|
|
822
|
+
throw new Error(`No sender provided and no default sender present in app client for call to app ${this._appName}`);
|
|
823
|
+
}
|
|
824
|
+
return typeof sender === 'string' ? algosdk.Address.fromString(sender) : (sender ?? this._defaultSender);
|
|
825
|
+
}
|
|
826
|
+
/** Returns the signer for a call, using the provided signer or the `defaultSigner`
|
|
827
|
+
* if no signer was provided and the call will use default sender
|
|
828
|
+
* or `undefined` otherwise (so the signer is resolved from `AlgorandClient`) */
|
|
829
|
+
getSigner(sender, signer) {
|
|
830
|
+
return signer ?? (!sender ? this._defaultSigner : undefined);
|
|
831
|
+
}
|
|
832
|
+
getBareParams(params, onComplete) {
|
|
833
|
+
return {
|
|
834
|
+
...params,
|
|
835
|
+
appId: this._appId,
|
|
836
|
+
sender: this.getSender(params?.sender),
|
|
837
|
+
signer: this.getSigner(params?.sender, params?.signer),
|
|
838
|
+
onComplete,
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
async getABIParams(params, onComplete) {
|
|
842
|
+
const sender = this.getSender(params.sender);
|
|
843
|
+
const method = types_appArc56.getArc56Method(params.method, this._appSpec);
|
|
844
|
+
const args = await this.getABIArgsWithDefaultValues(params.method, params.args, sender);
|
|
845
|
+
return {
|
|
846
|
+
...params,
|
|
847
|
+
appId: this._appId,
|
|
848
|
+
sender: sender,
|
|
849
|
+
signer: this.getSigner(params.sender, params.signer),
|
|
850
|
+
method,
|
|
851
|
+
onComplete,
|
|
852
|
+
args,
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
/** Make the given call and catch any errors, augmenting with debugging information before re-throwing. */
|
|
856
|
+
async handleCallErrors(call) {
|
|
857
|
+
try {
|
|
858
|
+
return await call();
|
|
859
|
+
}
|
|
860
|
+
catch (e) {
|
|
861
|
+
throw await this.exposeLogicError(e);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
getBoxMethods() {
|
|
865
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
866
|
+
const that = this;
|
|
867
|
+
const stateMethods = {
|
|
868
|
+
/**
|
|
869
|
+
* Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.
|
|
870
|
+
*/
|
|
871
|
+
getAll: async () => {
|
|
872
|
+
return Object.fromEntries(await Promise.all(Object.keys(that._appSpec.state.keys.box).map(async (key) => [key, await stateMethods.getValue(key)])));
|
|
873
|
+
},
|
|
874
|
+
/**
|
|
875
|
+
* Returns a single state value for the current app with the value a decoded ABI value.
|
|
876
|
+
* @param name The name of the state value to retrieve the value for
|
|
877
|
+
* @returns
|
|
878
|
+
*/
|
|
879
|
+
getValue: async (name) => {
|
|
880
|
+
const metadata = that._appSpec.state.keys.box[name];
|
|
881
|
+
const value = await that.getBoxValue(buffer.Buffer.from(metadata.key, 'base64'));
|
|
882
|
+
return types_appArc56.getABIDecodedValue(value, metadata.valueType, that._appSpec.structs);
|
|
883
|
+
},
|
|
884
|
+
/**
|
|
885
|
+
*
|
|
886
|
+
* @param mapName The name of the map to read from
|
|
887
|
+
* @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value
|
|
888
|
+
* that will be converted to bytes by encoding it using the specified ABI key type
|
|
889
|
+
* in the ARC-56 spec
|
|
890
|
+
*/
|
|
891
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
892
|
+
getMapValue: async (mapName, key) => {
|
|
893
|
+
const metadata = that._appSpec.state.maps.box[mapName];
|
|
894
|
+
const prefix = buffer.Buffer.from(metadata.prefix ?? '', 'base64');
|
|
895
|
+
const encodedKey = buffer.Buffer.concat([prefix, types_appArc56.getABIEncodedValue(key, metadata.keyType, that._appSpec.structs)]);
|
|
896
|
+
const base64Key = buffer.Buffer.from(encodedKey).toString('base64');
|
|
897
|
+
const value = await that.getBoxValue(buffer.Buffer.from(base64Key, 'base64'));
|
|
898
|
+
return types_appArc56.getABIDecodedValue(value, metadata.valueType, that._appSpec.structs);
|
|
899
|
+
},
|
|
900
|
+
/**
|
|
901
|
+
*
|
|
902
|
+
* @param mapName The name of the map to read from
|
|
903
|
+
* @param key The key within the map as either a Buffer with the bytes or a value
|
|
904
|
+
* that will be converted to bytes by encoding it using the specified ABI key type
|
|
905
|
+
* in the ARC-56 spec
|
|
906
|
+
* @param appState
|
|
907
|
+
*/
|
|
908
|
+
getMap: async (mapName) => {
|
|
909
|
+
const metadata = that._appSpec.state.maps.box[mapName];
|
|
910
|
+
const prefix = buffer.Buffer.from(metadata.prefix ?? '', 'base64');
|
|
911
|
+
const boxNames = await that.getBoxNames();
|
|
912
|
+
return new Map(await Promise.all(boxNames
|
|
913
|
+
.filter((b) => util.binaryStartsWith(b.nameRaw, prefix))
|
|
914
|
+
.map(async (b) => {
|
|
915
|
+
const encodedKey = buffer.Buffer.concat([prefix, b.nameRaw]);
|
|
916
|
+
const base64Key = buffer.Buffer.from(encodedKey).toString('base64');
|
|
917
|
+
return [
|
|
918
|
+
types_appArc56.getABIDecodedValue(b.nameRaw.slice(prefix.length), metadata.keyType, that._appSpec.structs),
|
|
919
|
+
types_appArc56.getABIDecodedValue(await that.getBoxValue(buffer.Buffer.from(base64Key, 'base64')), metadata.valueType, that._appSpec.structs),
|
|
920
|
+
];
|
|
921
|
+
})));
|
|
922
|
+
},
|
|
923
|
+
};
|
|
924
|
+
return stateMethods;
|
|
925
|
+
}
|
|
926
|
+
getStateMethods(stateGetter, keyGetter, mapGetter) {
|
|
927
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
928
|
+
const that = this;
|
|
929
|
+
const stateMethods = {
|
|
930
|
+
/**
|
|
931
|
+
* Returns all single-key state values in a record keyed by the key name and the value a decoded ABI value.
|
|
932
|
+
*/
|
|
933
|
+
getAll: async () => {
|
|
934
|
+
const appState = await stateGetter();
|
|
935
|
+
return Object.fromEntries(await Promise.all(Object.keys(keyGetter()).map(async (key) => [key, await stateMethods.getValue(key, appState)])));
|
|
936
|
+
},
|
|
937
|
+
/**
|
|
938
|
+
* Returns a single state value for the current app with the value a decoded ABI value.
|
|
939
|
+
* @param name The name of the state value to retrieve the value for
|
|
940
|
+
* @param appState Optional cached value of the current state
|
|
941
|
+
* @returns
|
|
942
|
+
*/
|
|
943
|
+
getValue: async (name, appState) => {
|
|
944
|
+
const state = Object.values(appState ?? (await stateGetter()));
|
|
945
|
+
const metadata = keyGetter()[name];
|
|
946
|
+
const value = state.find((s) => s.keyBase64 === metadata.key);
|
|
947
|
+
if (value && 'valueRaw' in value) {
|
|
948
|
+
return types_appArc56.getABIDecodedValue(value.valueRaw, metadata.valueType, that._appSpec.structs);
|
|
949
|
+
}
|
|
950
|
+
return value?.value;
|
|
951
|
+
},
|
|
952
|
+
/**
|
|
953
|
+
* Returns a single value from the given map for the current app with the value a decoded ABI value.
|
|
954
|
+
* @param mapName The name of the map to read from
|
|
955
|
+
* @param key The key within the map (without any map prefix) as either a Buffer with the bytes or a value
|
|
956
|
+
* that will be converted to bytes by encoding it using the specified ABI key type
|
|
957
|
+
* in the ARC-56 spec
|
|
958
|
+
* @param appState Optional cached value of the current state
|
|
959
|
+
*/
|
|
960
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
961
|
+
getMapValue: async (mapName, key, appState) => {
|
|
962
|
+
const state = Object.values(appState ?? (await stateGetter()));
|
|
963
|
+
const metadata = mapGetter()[mapName];
|
|
964
|
+
const prefix = buffer.Buffer.from(metadata.prefix ?? '', 'base64');
|
|
965
|
+
const encodedKey = buffer.Buffer.concat([prefix, types_appArc56.getABIEncodedValue(key, metadata.keyType, that._appSpec.structs)]);
|
|
966
|
+
const base64Key = buffer.Buffer.from(encodedKey).toString('base64');
|
|
967
|
+
const value = state.find((s) => s.keyBase64 === base64Key);
|
|
968
|
+
if (value && 'valueRaw' in value) {
|
|
969
|
+
return types_appArc56.getABIDecodedValue(value.valueRaw, metadata.valueType, that._appSpec.structs);
|
|
970
|
+
}
|
|
971
|
+
return value?.value;
|
|
972
|
+
},
|
|
973
|
+
/**
|
|
974
|
+
* Returns all map values for the given map.
|
|
975
|
+
* @param mapName The name of the map to read from
|
|
976
|
+
* @param appState Optional cached value of the current state
|
|
977
|
+
* @returns A map of all key-value pairs in the map as a `Record<string, ABIValue>`
|
|
978
|
+
*/
|
|
979
|
+
getMap: async (mapName) => {
|
|
980
|
+
const state = Object.values(await stateGetter());
|
|
981
|
+
const metadata = mapGetter()[mapName];
|
|
982
|
+
const prefix = buffer.Buffer.from(metadata.prefix ?? '', 'base64');
|
|
983
|
+
return new Map(state
|
|
984
|
+
.filter((s) => util.binaryStartsWith(s.keyRaw, prefix))
|
|
985
|
+
.map((s) => {
|
|
986
|
+
const key = s.keyRaw.slice(prefix.length);
|
|
987
|
+
return [
|
|
988
|
+
types_appArc56.getABIDecodedValue(key, metadata.keyType, this._appSpec.structs),
|
|
989
|
+
types_appArc56.getABIDecodedValue('valueRaw' in s ? s.valueRaw : s.value, metadata.valueType, this._appSpec.structs),
|
|
990
|
+
];
|
|
991
|
+
}));
|
|
992
|
+
},
|
|
993
|
+
};
|
|
994
|
+
return stateMethods;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientById` or
|
|
999
|
+
* `algorand.client.getAppClientByCreatorAndName`.
|
|
1000
|
+
* If you want to `create` or `deploy` then use `AppFactory` e.g. via `algorand.client.getAppFactory`,
|
|
1001
|
+
* which will in turn give you an `AppClient` instance against the created/deployed app to make other calls.
|
|
1002
|
+
*
|
|
1003
|
+
* Application client - a class that wraps an ARC-0032 app spec and provides high productivity methods to deploy and call the app */
|
|
43
1004
|
class ApplicationClient {
|
|
44
|
-
// todo: process ABI args as needed to make them nicer to deal with like beaker-ts
|
|
45
|
-
// todo: support readonly, noop method calls
|
|
46
|
-
// todo: find create, update, delete, etc. methods from app spec and call them by default
|
|
47
|
-
// todo: intelligent version management when deploying
|
|
48
1005
|
/**
|
|
1006
|
+
* @deprecated Use `AppClient` instead e.g. via `algorand.client.getAppClientById` or
|
|
1007
|
+
* `algorand.client.getAppClientByCreatorAndName`.
|
|
1008
|
+
* If you want to `create` or `deploy` then use `AppFactory` e.g. via `algorand.client.getAppFactory`,
|
|
1009
|
+
* which will in turn give you an `AppClient` instance against the created/deployed app to make other calls.
|
|
1010
|
+
*
|
|
49
1011
|
* Create a new ApplicationClient instance
|
|
50
1012
|
* @param appDetails The details of the app
|
|
51
1013
|
* @param algod An algod instance
|
|
@@ -64,7 +1026,7 @@ class ApplicationClient {
|
|
|
64
1026
|
}
|
|
65
1027
|
else {
|
|
66
1028
|
this._appId = 0;
|
|
67
|
-
this._creator = appIdentifier.creatorAddress;
|
|
1029
|
+
this._creator = appIdentifier.creatorAddress?.toString();
|
|
68
1030
|
if (appIdentifier.findExistingUsing instanceof Indexer) {
|
|
69
1031
|
this.indexer = appIdentifier.findExistingUsing;
|
|
70
1032
|
}
|
|
@@ -75,14 +1037,16 @@ class ApplicationClient {
|
|
|
75
1037
|
this.existingDeployments = appIdentifier.findExistingUsing;
|
|
76
1038
|
}
|
|
77
1039
|
}
|
|
78
|
-
this._appAddress = algosdk.getApplicationAddress(this._appId);
|
|
1040
|
+
this._appAddress = algosdk.getApplicationAddress(this._appId).toString();
|
|
79
1041
|
this.sender = sender;
|
|
80
1042
|
this.params = params;
|
|
81
1043
|
}
|
|
82
1044
|
/**
|
|
83
|
-
*
|
|
1045
|
+
* @deprecated Use `AppClient.compile()` instead.
|
|
1046
|
+
*
|
|
1047
|
+
* Compiles the approval and clear state programs and sets up the source map.
|
|
84
1048
|
* @param compilation The deploy-time parameters for the compilation
|
|
85
|
-
* @returns The compiled approval and clear programs
|
|
1049
|
+
* @returns The compiled approval and clear state programs
|
|
86
1050
|
*/
|
|
87
1051
|
async compile(compilation) {
|
|
88
1052
|
const { deployTimeParams, updatable, deletable } = compilation ?? {};
|
|
@@ -97,15 +1061,12 @@ class ApplicationClient {
|
|
|
97
1061
|
const clear = appDeploy.performTemplateSubstitution(clearTemplate, deployTimeParams ?? this.deployTimeParams);
|
|
98
1062
|
const clearCompiled = await app.compileTeal(clear, this.algod);
|
|
99
1063
|
this._clearSourceMap = clearCompiled?.sourceMap;
|
|
100
|
-
if (config.Config.debug
|
|
101
|
-
|
|
1064
|
+
if (config.Config.debug) {
|
|
1065
|
+
await config.Config.events.emitAsync(types_lifecycleEvents.EventType.AppCompiled, {
|
|
102
1066
|
sources: [
|
|
103
|
-
|
|
104
|
-
|
|
1067
|
+
{ compiledTeal: approvalCompiled, appName: this._appName, fileName: 'approval' },
|
|
1068
|
+
{ compiledTeal: clearCompiled, appName: this._appName, fileName: 'clear' },
|
|
105
1069
|
],
|
|
106
|
-
projectRoot: config.Config.projectRoot,
|
|
107
|
-
client: this.algod,
|
|
108
|
-
withSources: true,
|
|
109
1070
|
});
|
|
110
1071
|
}
|
|
111
1072
|
return { approvalCompiled, clearCompiled };
|
|
@@ -132,6 +1093,8 @@ class ApplicationClient {
|
|
|
132
1093
|
this._clearSourceMap = new SourceMap(sourceMaps.clearSourceMap);
|
|
133
1094
|
}
|
|
134
1095
|
/**
|
|
1096
|
+
* @deprecated Use `deploy` from an `AppFactory` instance instead.
|
|
1097
|
+
*
|
|
135
1098
|
* Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
|
|
136
1099
|
*
|
|
137
1100
|
* To understand the architecture decisions behind this functionality please see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md
|
|
@@ -217,6 +1180,8 @@ class ApplicationClient {
|
|
|
217
1180
|
}
|
|
218
1181
|
}
|
|
219
1182
|
/**
|
|
1183
|
+
* @deprecated Use `create` from an `AppFactory` instance instead.
|
|
1184
|
+
*
|
|
220
1185
|
* Creates a smart contract app, returns the details of the created app.
|
|
221
1186
|
* @param create The parameters to create the app with
|
|
222
1187
|
* @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
|
|
@@ -252,15 +1217,17 @@ class ApplicationClient {
|
|
|
252
1217
|
if (result.confirmation) {
|
|
253
1218
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
254
1219
|
this._appId = result.confirmation.applicationIndex;
|
|
255
|
-
this._appAddress = getApplicationAddress(this._appId);
|
|
1220
|
+
this._appAddress = getApplicationAddress(this._appId).toString();
|
|
256
1221
|
}
|
|
257
1222
|
return { ...result, ...{ compiledApproval: approvalCompiled, compiledClear: clearCompiled } };
|
|
258
1223
|
}
|
|
259
1224
|
catch (e) {
|
|
260
|
-
throw this.exposeLogicError(e);
|
|
1225
|
+
throw await this.exposeLogicError(e);
|
|
261
1226
|
}
|
|
262
1227
|
}
|
|
263
1228
|
/**
|
|
1229
|
+
* @deprecated Use `appClient.send.update` or `appClient.createTransaction.update` from an `AppClient` instance instead.
|
|
1230
|
+
*
|
|
264
1231
|
* Updates the smart contract app.
|
|
265
1232
|
* @param update The parameters to update the app with
|
|
266
1233
|
* @returns The transaction send result and the compilation result
|
|
@@ -289,10 +1256,12 @@ class ApplicationClient {
|
|
|
289
1256
|
return { ...result, ...{ compiledApproval: approvalCompiled, compiledClear: clearCompiled } };
|
|
290
1257
|
}
|
|
291
1258
|
catch (e) {
|
|
292
|
-
throw this.exposeLogicError(e);
|
|
1259
|
+
throw await this.exposeLogicError(e);
|
|
293
1260
|
}
|
|
294
1261
|
}
|
|
295
1262
|
/**
|
|
1263
|
+
* @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
|
|
1264
|
+
*
|
|
296
1265
|
* Issues a no_op (normal) call to the app.
|
|
297
1266
|
* @param call The call details.
|
|
298
1267
|
* @returns The result of the call
|
|
@@ -307,7 +1276,7 @@ class ApplicationClient {
|
|
|
307
1276
|
!call.sendParams?.atc &&
|
|
308
1277
|
// The method is readonly
|
|
309
1278
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
310
|
-
this.appSpec.hints[
|
|
1279
|
+
this.appSpec.hints[this.getABIMethodSignature(this.getABIMethod(call.method))].read_only) {
|
|
311
1280
|
const atc = new AtomicTransactionComposer();
|
|
312
1281
|
await this.callOfType({ ...call, sendParams: { ...call.sendParams, atc } }, 'no_op');
|
|
313
1282
|
const result = await atc.simulate(this.algod);
|
|
@@ -326,6 +1295,8 @@ class ApplicationClient {
|
|
|
326
1295
|
return await this.callOfType(call, 'no_op');
|
|
327
1296
|
}
|
|
328
1297
|
/**
|
|
1298
|
+
* @deprecated Use `appClient.send.optIn` or `appClient.createTransaction.optIn` from an `AppClient` instance instead.
|
|
1299
|
+
*
|
|
329
1300
|
* Issues a opt_in call to the app.
|
|
330
1301
|
* @param call The call details.
|
|
331
1302
|
* @returns The result of the call
|
|
@@ -334,6 +1305,8 @@ class ApplicationClient {
|
|
|
334
1305
|
return await this.callOfType(call, 'opt_in');
|
|
335
1306
|
}
|
|
336
1307
|
/**
|
|
1308
|
+
* @deprecated Use `appClient.send.closeOut` or `appClient.createTransaction.closeOut` from an `AppClient` instance instead.
|
|
1309
|
+
*
|
|
337
1310
|
* Issues a close_out call to the app.
|
|
338
1311
|
* @param call The call details.
|
|
339
1312
|
* @returns The result of the call
|
|
@@ -342,6 +1315,8 @@ class ApplicationClient {
|
|
|
342
1315
|
return await this.callOfType(call, 'close_out');
|
|
343
1316
|
}
|
|
344
1317
|
/**
|
|
1318
|
+
* @deprecated Use `appClient.send.clearState` or `appClient.createTransaction.clearState` from an `AppClient` instance instead.
|
|
1319
|
+
*
|
|
345
1320
|
* Issues a clear_state call to the app.
|
|
346
1321
|
* @param call The call details.
|
|
347
1322
|
* @returns The result of the call
|
|
@@ -350,6 +1325,8 @@ class ApplicationClient {
|
|
|
350
1325
|
return await this.callOfType(call, 'clear_state');
|
|
351
1326
|
}
|
|
352
1327
|
/**
|
|
1328
|
+
* @deprecated Use `appClient.send.delete` or `appClient.createTransaction.delete` from an `AppClient` instance instead.
|
|
1329
|
+
*
|
|
353
1330
|
* Issues a delete_application call to the app.
|
|
354
1331
|
* @param call The call details.
|
|
355
1332
|
* @returns The result of the call
|
|
@@ -358,6 +1335,8 @@ class ApplicationClient {
|
|
|
358
1335
|
return await this.callOfType(call, 'delete_application');
|
|
359
1336
|
}
|
|
360
1337
|
/**
|
|
1338
|
+
* @deprecated Use `appClient.send.call` or `appClient.createTransaction.call` from an `AppClient` instance instead.
|
|
1339
|
+
*
|
|
361
1340
|
* Issues a call to the app with the given call type.
|
|
362
1341
|
* @param call The call details.
|
|
363
1342
|
* @param callType The call type
|
|
@@ -390,7 +1369,7 @@ class ApplicationClient {
|
|
|
390
1369
|
}
|
|
391
1370
|
}
|
|
392
1371
|
/**
|
|
393
|
-
* Funds
|
|
1372
|
+
* Funds Algo into the app account for this app.
|
|
394
1373
|
* @param fund The parameters for the funding or the funding amount
|
|
395
1374
|
* @returns The result of the funding
|
|
396
1375
|
*/
|
|
@@ -400,15 +1379,12 @@ class ApplicationClient {
|
|
|
400
1379
|
throw new Error('No sender provided, unable to call app');
|
|
401
1380
|
}
|
|
402
1381
|
const ref = await this.getAppReference();
|
|
403
|
-
return
|
|
404
|
-
|
|
1382
|
+
return legacyBridge.legacySendTransactionBridge(this.algod, sender ?? this.sender, sendParams ?? {}, {
|
|
1383
|
+
receiver: ref.appAddress,
|
|
1384
|
+
sender: transaction.getSenderAddress(sender ?? this.sender),
|
|
405
1385
|
amount: amount,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
note: note,
|
|
409
|
-
transactionParams: this.params,
|
|
410
|
-
...(sendParams ?? {}),
|
|
411
|
-
}, this.algod);
|
|
1386
|
+
note: transaction.encodeTransactionNote(note),
|
|
1387
|
+
}, (c) => c.payment, (c) => c.payment, this.params);
|
|
412
1388
|
}
|
|
413
1389
|
/**
|
|
414
1390
|
* Returns global state for the current app.
|
|
@@ -503,6 +1479,8 @@ class ApplicationClient {
|
|
|
503
1479
|
})));
|
|
504
1480
|
}
|
|
505
1481
|
/**
|
|
1482
|
+
* @deprecated Use `appClient.params.*` from an `AppClient` instance instead.
|
|
1483
|
+
*
|
|
506
1484
|
* Returns the arguments for an app call for the given ABI method or raw method specification.
|
|
507
1485
|
* @param args The call args specific to this application client
|
|
508
1486
|
* @param sender The sender of this call. Will be used to fetch any default argument values if applicable
|
|
@@ -517,7 +1495,7 @@ class ApplicationClient {
|
|
|
517
1495
|
if (!abiMethod) {
|
|
518
1496
|
throw new Error(`Attempt to call ABI method ${args.method}, but it wasn't found`);
|
|
519
1497
|
}
|
|
520
|
-
const methodSignature =
|
|
1498
|
+
const methodSignature = this.getABIMethodSignature(abiMethod);
|
|
521
1499
|
return {
|
|
522
1500
|
...args,
|
|
523
1501
|
method: abiMethod,
|
|
@@ -534,7 +1512,7 @@ class ApplicationClient {
|
|
|
534
1512
|
case 'abi-method': {
|
|
535
1513
|
const method = defaultValueStrategy.data;
|
|
536
1514
|
const result = await this.callOfType({
|
|
537
|
-
method:
|
|
1515
|
+
method: this.getABIMethodSignature(method),
|
|
538
1516
|
methodArgs: method.args.map(() => undefined),
|
|
539
1517
|
sender,
|
|
540
1518
|
}, 'no_op');
|
|
@@ -560,6 +1538,8 @@ class ApplicationClient {
|
|
|
560
1538
|
}
|
|
561
1539
|
}
|
|
562
1540
|
/**
|
|
1541
|
+
* @deprecated Use `appClient.getABIMethod` instead.
|
|
1542
|
+
*
|
|
563
1543
|
* Returns the ABI Method parameters for the given method name string for the app represented by this application client instance
|
|
564
1544
|
* @param method Either the name of the method or the ABI method spec definition string
|
|
565
1545
|
* @returns The ABI method params for the given method
|
|
@@ -569,12 +1549,12 @@ class ApplicationClient {
|
|
|
569
1549
|
const methods = this.appSpec.contract.methods.filter((m) => m.name === method);
|
|
570
1550
|
if (methods.length > 1) {
|
|
571
1551
|
throw new Error(`Received a call to method ${method} in contract ${this._appName}, but this resolved to multiple methods; please pass in an ABI signature instead: ${methods
|
|
572
|
-
.map(
|
|
1552
|
+
.map(this.getABIMethodSignature)
|
|
573
1553
|
.join(', ')}`);
|
|
574
1554
|
}
|
|
575
1555
|
return methods[0];
|
|
576
1556
|
}
|
|
577
|
-
return this.appSpec.contract.methods.find((m) =>
|
|
1557
|
+
return this.appSpec.contract.methods.find((m) => this.getABIMethodSignature(m) === method);
|
|
578
1558
|
}
|
|
579
1559
|
/**
|
|
580
1560
|
* Returns the ABI Method for the given method name string for the app represented by this application client instance
|
|
@@ -586,6 +1566,8 @@ class ApplicationClient {
|
|
|
586
1566
|
return methodParams ? new ABIMethod(methodParams) : undefined;
|
|
587
1567
|
}
|
|
588
1568
|
/**
|
|
1569
|
+
* @deprecated Use `appClient.appId` and `appClient.appAddress` from an `AppClient` instance instead.
|
|
1570
|
+
*
|
|
589
1571
|
* Gets the reference information for the current application instance.
|
|
590
1572
|
* `appId` will be 0 if it can't find an app.
|
|
591
1573
|
* @returns The app reference, or if deployed using the `deploy` method, the app metadata too
|
|
@@ -600,7 +1582,7 @@ class ApplicationClient {
|
|
|
600
1582
|
if (!app) {
|
|
601
1583
|
return {
|
|
602
1584
|
appId: 0,
|
|
603
|
-
appAddress: getApplicationAddress(0),
|
|
1585
|
+
appAddress: getApplicationAddress(0).toString(),
|
|
604
1586
|
};
|
|
605
1587
|
}
|
|
606
1588
|
return app;
|
|
@@ -627,11 +1609,15 @@ class ApplicationClient {
|
|
|
627
1609
|
.toString()
|
|
628
1610
|
.split('\n'),
|
|
629
1611
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
630
|
-
isClear ? this._clearSourceMap : this._approvalSourceMap);
|
|
1612
|
+
(pc) => (isClear ? this._clearSourceMap : this._approvalSourceMap)?.getLocationForPc(pc)?.line);
|
|
631
1613
|
else
|
|
632
1614
|
return e;
|
|
633
1615
|
}
|
|
1616
|
+
getABIMethodSignature(method) {
|
|
1617
|
+
return 'getSignature' in method ? method.getSignature() : new ABIMethod(method).getSignature();
|
|
1618
|
+
}
|
|
634
1619
|
}
|
|
635
1620
|
|
|
1621
|
+
exports.AppClient = AppClient;
|
|
636
1622
|
exports.ApplicationClient = ApplicationClient;
|
|
637
1623
|
//# sourceMappingURL=app-client.js.map
|