algosdk 2.9.0 → 3.0.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/README.md +8 -4
- package/dist/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.LICENSE.txt +0 -9
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/abi/abi_type.js +34 -27
- package/dist/cjs/abi/abi_type.js.map +1 -1
- package/dist/cjs/abi/contract.js +3 -3
- package/dist/cjs/abi/contract.js.map +1 -1
- package/dist/cjs/abi/index.js +6 -6
- package/dist/cjs/abi/index.js.map +1 -1
- package/dist/cjs/abi/interface.js +3 -3
- package/dist/cjs/abi/interface.js.map +1 -1
- package/dist/cjs/abi/method.js +10 -10
- package/dist/cjs/abi/method.js.map +1 -1
- package/dist/cjs/abi/reference.js +1 -1
- package/dist/cjs/abi/reference.js.map +1 -1
- package/dist/cjs/abi/transaction.js +2 -2
- package/dist/cjs/abi/transaction.js.map +1 -1
- package/dist/cjs/account.js +4 -4
- package/dist/cjs/account.js.map +1 -1
- package/dist/cjs/boxStorage.js +17 -17
- package/dist/cjs/boxStorage.js.map +1 -1
- package/dist/cjs/client/client.js +77 -41
- package/dist/cjs/client/client.js.map +1 -1
- package/dist/cjs/client/index.js +29 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/client/kmd.js +69 -86
- package/dist/cjs/client/kmd.js.map +1 -1
- package/dist/cjs/client/urlTokenBaseHTTPClient.js +16 -11
- package/dist/cjs/client/urlTokenBaseHTTPClient.js.map +1 -1
- package/dist/cjs/client/v2/algod/accountApplicationInformation.js +11 -7
- package/dist/cjs/client/v2/algod/accountApplicationInformation.js.map +1 -1
- package/dist/cjs/client/v2/algod/accountAssetInformation.js +11 -7
- package/dist/cjs/client/v2/algod/accountAssetInformation.js.map +1 -1
- package/dist/cjs/client/v2/algod/accountInformation.js +11 -6
- package/dist/cjs/client/v2/algod/accountInformation.js.map +1 -1
- package/dist/cjs/client/v2/algod/algod.js +85 -83
- package/dist/cjs/client/v2/algod/algod.js.map +1 -1
- package/dist/cjs/client/v2/algod/block.js +6 -33
- package/dist/cjs/client/v2/algod/block.js.map +1 -1
- package/dist/cjs/client/v2/algod/compile.js +17 -11
- package/dist/cjs/client/v2/algod/compile.js.map +1 -1
- package/dist/cjs/client/v2/algod/disassemble.js +17 -11
- package/dist/cjs/client/v2/algod/disassemble.js.map +1 -1
- package/dist/cjs/client/v2/algod/dryrun.js +18 -37
- package/dist/cjs/client/v2/algod/dryrun.js.map +1 -1
- package/dist/cjs/client/v2/algod/genesis.js +6 -2
- package/dist/cjs/client/v2/algod/genesis.js.map +1 -1
- package/dist/cjs/client/v2/algod/getApplicationBoxByName.js +10 -10
- package/dist/cjs/client/v2/algod/getApplicationBoxByName.js.map +1 -1
- package/dist/cjs/client/v2/algod/getApplicationBoxes.js +8 -8
- package/dist/cjs/client/v2/algod/getApplicationBoxes.js.map +1 -1
- package/dist/cjs/client/v2/algod/getApplicationByID.js +10 -5
- package/dist/cjs/client/v2/algod/getApplicationByID.js.map +1 -1
- package/dist/cjs/client/v2/algod/getAssetByID.js +10 -5
- package/dist/cjs/client/v2/algod/getAssetByID.js.map +1 -1
- package/dist/cjs/client/v2/algod/getBlockHash.js +10 -6
- package/dist/cjs/client/v2/algod/getBlockHash.js.map +1 -1
- package/dist/cjs/client/v2/algod/getBlockOffsetTimestamp.js +6 -5
- package/dist/cjs/client/v2/algod/getBlockOffsetTimestamp.js.map +1 -1
- package/dist/cjs/client/v2/algod/getBlockTxids.js +10 -4
- package/dist/cjs/client/v2/algod/getBlockTxids.js.map +1 -1
- package/dist/cjs/client/v2/algod/getLedgerStateDelta.js +11 -6
- package/dist/cjs/client/v2/algod/getLedgerStateDelta.js.map +1 -1
- package/dist/cjs/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js +11 -6
- package/dist/cjs/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js.map +1 -1
- package/dist/cjs/client/v2/algod/getSyncRound.js +6 -5
- package/dist/cjs/client/v2/algod/getSyncRound.js.map +1 -1
- package/dist/cjs/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js +9 -9
- package/dist/cjs/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js.map +1 -1
- package/dist/cjs/client/v2/algod/getTransactionProof.js +10 -6
- package/dist/cjs/client/v2/algod/getTransactionProof.js.map +1 -1
- package/dist/cjs/client/v2/algod/healthCheck.js +4 -9
- package/dist/cjs/client/v2/algod/healthCheck.js.map +1 -1
- package/dist/cjs/{types → client/v2/algod}/index.js +5 -3
- package/dist/cjs/client/v2/algod/index.js.map +1 -0
- package/dist/cjs/client/v2/algod/lightBlockHeaderProof.js +10 -5
- package/dist/cjs/client/v2/algod/lightBlockHeaderProof.js.map +1 -1
- package/dist/cjs/client/v2/algod/models/types.js +3701 -1828
- package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
- package/dist/cjs/client/v2/algod/pendingTransactionInformation.js +6 -32
- package/dist/cjs/client/v2/algod/pendingTransactionInformation.js.map +1 -1
- package/dist/cjs/client/v2/algod/pendingTransactions.js +6 -31
- package/dist/cjs/client/v2/algod/pendingTransactions.js.map +1 -1
- package/dist/cjs/client/v2/algod/pendingTransactionsByAddress.js +7 -33
- package/dist/cjs/client/v2/algod/pendingTransactionsByAddress.js.map +1 -1
- package/dist/cjs/client/v2/algod/ready.js +4 -2
- package/dist/cjs/client/v2/algod/ready.js.map +1 -1
- package/dist/cjs/client/v2/algod/sendRawTransaction.js +17 -8
- package/dist/cjs/client/v2/algod/sendRawTransaction.js.map +1 -1
- package/dist/cjs/client/v2/algod/setBlockOffsetTimestamp.js +13 -8
- package/dist/cjs/client/v2/algod/setBlockOffsetTimestamp.js.map +1 -1
- package/dist/cjs/client/v2/algod/setSyncRound.js +13 -8
- package/dist/cjs/client/v2/algod/setSyncRound.js.map +1 -1
- package/dist/cjs/client/v2/algod/simulateTransaction.js +15 -35
- package/dist/cjs/client/v2/algod/simulateTransaction.js.map +1 -1
- package/dist/cjs/client/v2/algod/stateproof.js +10 -5
- package/dist/cjs/client/v2/algod/stateproof.js.map +1 -1
- package/dist/cjs/client/v2/algod/status.js +8 -2
- package/dist/cjs/client/v2/algod/status.js.map +1 -1
- package/dist/cjs/client/v2/algod/statusAfterBlock.js +10 -5
- package/dist/cjs/client/v2/algod/statusAfterBlock.js.map +1 -1
- package/dist/cjs/client/v2/algod/suggestedParams.js +13 -9
- package/dist/cjs/client/v2/algod/suggestedParams.js.map +1 -1
- package/dist/cjs/client/v2/algod/supply.js +8 -2
- package/dist/cjs/client/v2/algod/supply.js.map +1 -1
- package/dist/cjs/client/v2/algod/unsetSyncRound.js +11 -5
- package/dist/cjs/client/v2/algod/unsetSyncRound.js.map +1 -1
- package/dist/cjs/client/v2/algod/versions.js +8 -2
- package/dist/cjs/client/v2/algod/versions.js.map +1 -1
- package/dist/cjs/client/v2/indexer/index.js +22 -0
- package/dist/cjs/client/v2/indexer/index.js.map +1 -0
- package/dist/cjs/client/v2/indexer/indexer.js +44 -43
- package/dist/cjs/client/v2/indexer/indexer.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAccountAppLocalStates.js +11 -6
- package/dist/cjs/client/v2/indexer/lookupAccountAppLocalStates.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAccountAssets.js +11 -6
- package/dist/cjs/client/v2/indexer/lookupAccountAssets.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAccountByID.js +11 -6
- package/dist/cjs/client/v2/indexer/lookupAccountByID.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAccountCreatedApplications.js +11 -6
- package/dist/cjs/client/v2/indexer/lookupAccountCreatedApplications.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAccountCreatedAssets.js +11 -6
- package/dist/cjs/client/v2/indexer/lookupAccountCreatedAssets.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js +19 -12
- package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupApplicationBoxByIDandName.js +10 -10
- package/dist/cjs/client/v2/indexer/lookupApplicationBoxByIDandName.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupApplicationLogs.js +10 -5
- package/dist/cjs/client/v2/indexer/lookupApplicationLogs.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupApplications.js +10 -5
- package/dist/cjs/client/v2/indexer/lookupApplications.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAssetBalances.js +10 -5
- package/dist/cjs/client/v2/indexer/lookupAssetBalances.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAssetByID.js +10 -5
- package/dist/cjs/client/v2/indexer/lookupAssetByID.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js +19 -12
- package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupBlock.js +10 -5
- package/dist/cjs/client/v2/indexer/lookupBlock.js.map +1 -1
- package/dist/cjs/client/v2/indexer/lookupTransactionByID.js +10 -5
- package/dist/cjs/client/v2/indexer/lookupTransactionByID.js.map +1 -1
- package/dist/cjs/client/v2/indexer/makeHealthCheck.js +8 -2
- package/dist/cjs/client/v2/indexer/makeHealthCheck.js.map +1 -1
- package/dist/cjs/client/v2/indexer/models/types.js +3591 -1651
- package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
- package/dist/cjs/client/v2/indexer/searchAccounts.js +9 -3
- package/dist/cjs/client/v2/indexer/searchAccounts.js.map +1 -1
- package/dist/cjs/client/v2/indexer/searchForApplicationBoxes.js +8 -8
- package/dist/cjs/client/v2/indexer/searchForApplicationBoxes.js.map +1 -1
- package/dist/cjs/client/v2/indexer/searchForApplications.js +9 -3
- package/dist/cjs/client/v2/indexer/searchForApplications.js.map +1 -1
- package/dist/cjs/client/v2/indexer/searchForAssets.js +9 -3
- package/dist/cjs/client/v2/indexer/searchForAssets.js.map +1 -1
- package/dist/cjs/client/v2/indexer/searchForTransactions.js +17 -9
- package/dist/cjs/client/v2/indexer/searchForTransactions.js.map +1 -1
- package/dist/cjs/client/v2/jsonrequest.js +22 -54
- package/dist/cjs/client/v2/jsonrequest.js.map +1 -1
- package/dist/cjs/client/v2/serviceClient.js +5 -25
- package/dist/cjs/client/v2/serviceClient.js.map +1 -1
- package/dist/cjs/client/v2/untypedmodel.js +22 -0
- package/dist/cjs/client/v2/untypedmodel.js.map +1 -0
- package/dist/cjs/composer.js +64 -58
- package/dist/cjs/composer.js.map +1 -1
- package/dist/cjs/convert.js.map +1 -1
- package/dist/cjs/dryrun.js +107 -203
- package/dist/cjs/dryrun.js.map +1 -1
- package/dist/cjs/encoding/address.js +88 -104
- package/dist/cjs/encoding/address.js.map +1 -1
- package/dist/cjs/encoding/bigint.js +2 -3
- package/dist/cjs/encoding/bigint.js.map +1 -1
- package/dist/cjs/encoding/binarydata.js +82 -0
- package/dist/cjs/encoding/binarydata.js.map +1 -0
- package/dist/cjs/encoding/encoding.js +353 -38
- package/dist/cjs/encoding/encoding.js.map +1 -1
- package/dist/cjs/encoding/schema/address.js +41 -0
- package/dist/cjs/encoding/schema/address.js.map +1 -0
- package/dist/cjs/encoding/schema/array.js +43 -0
- package/dist/cjs/encoding/schema/array.js.map +1 -0
- package/dist/cjs/encoding/schema/binarystring.js +55 -0
- package/dist/cjs/encoding/schema/binarystring.js.map +1 -0
- package/dist/cjs/encoding/schema/blockhash.js +67 -0
- package/dist/cjs/encoding/schema/blockhash.js.map +1 -0
- package/dist/cjs/encoding/schema/boolean.js +42 -0
- package/dist/cjs/encoding/schema/boolean.js.map +1 -0
- package/dist/cjs/encoding/schema/bytearray.js +98 -0
- package/dist/cjs/encoding/schema/bytearray.js.map +1 -0
- package/dist/cjs/encoding/schema/index.js +34 -0
- package/dist/cjs/encoding/schema/index.js.map +1 -0
- package/dist/cjs/encoding/schema/map.js +528 -0
- package/dist/cjs/encoding/schema/map.js.map +1 -0
- package/dist/cjs/encoding/schema/optional.js +58 -0
- package/dist/cjs/encoding/schema/optional.js.map +1 -0
- package/dist/cjs/encoding/schema/string.js +43 -0
- package/dist/cjs/encoding/schema/string.js.map +1 -0
- package/dist/cjs/encoding/schema/uint64.js +36 -0
- package/dist/cjs/encoding/schema/uint64.js.map +1 -0
- package/dist/cjs/encoding/schema/untyped.js +33 -0
- package/dist/cjs/encoding/schema/untyped.js.map +1 -0
- package/dist/cjs/encoding/uint64.js +2 -2
- package/dist/cjs/encoding/uint64.js.map +1 -1
- package/dist/cjs/group.js +23 -60
- package/dist/cjs/group.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logic/sourcemap.js +56 -25
- package/dist/cjs/logic/sourcemap.js.map +1 -1
- package/dist/cjs/logicsig.js +113 -146
- package/dist/cjs/logicsig.js.map +1 -1
- package/dist/cjs/main.js +113 -122
- package/dist/cjs/main.js.map +1 -1
- package/dist/cjs/makeTxn.js +310 -570
- package/dist/cjs/makeTxn.js.map +1 -1
- package/dist/cjs/mnemonic/mnemonic.js +8 -8
- package/dist/cjs/mnemonic/mnemonic.js.map +1 -1
- package/dist/cjs/multisig.js +60 -312
- package/dist/cjs/multisig.js.map +1 -1
- package/dist/cjs/multisigSigning.js +285 -0
- package/dist/cjs/multisigSigning.js.map +1 -0
- package/dist/cjs/nacl/naclWrappers.js +2 -2
- package/dist/cjs/nacl/naclWrappers.js.map +1 -1
- package/dist/cjs/signedTransaction.js +106 -0
- package/dist/cjs/signedTransaction.js.map +1 -0
- package/dist/cjs/signer.js +7 -7
- package/dist/cjs/signer.js.map +1 -1
- package/dist/cjs/signing.js +105 -0
- package/dist/cjs/signing.js.map +1 -0
- package/dist/cjs/stateproof.js +421 -0
- package/dist/cjs/stateproof.js.map +1 -0
- package/dist/cjs/transaction.js +724 -1009
- package/dist/cjs/transaction.js.map +1 -1
- package/dist/cjs/types/block.js +813 -0
- package/dist/cjs/types/block.js.map +1 -0
- package/dist/cjs/types/intDecoding.js +1 -1
- package/dist/cjs/types/intDecoding.js.map +1 -1
- package/dist/cjs/types/statedelta.js +1155 -0
- package/dist/cjs/types/statedelta.js.map +1 -0
- package/dist/cjs/types/transactions/base.js +22 -5
- package/dist/cjs/types/transactions/base.js.map +1 -1
- package/dist/cjs/types/transactions/encoded.js +67 -0
- package/dist/cjs/types/transactions/encoded.js.map +1 -1
- package/dist/cjs/types/transactions/index.js +2 -5
- package/dist/cjs/types/transactions/index.js.map +1 -1
- package/dist/cjs/utils/utils.js +86 -22
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/cjs/wait.js +4 -4
- package/dist/cjs/wait.js.map +1 -1
- package/dist/esm/abi/abi_type.js +22 -15
- package/dist/esm/abi/abi_type.js.map +1 -1
- package/dist/esm/abi/contract.js +1 -1
- package/dist/esm/abi/contract.js.map +1 -1
- package/dist/esm/abi/index.js +6 -6
- package/dist/esm/abi/index.js.map +1 -1
- package/dist/esm/abi/interface.js +1 -1
- package/dist/esm/abi/interface.js.map +1 -1
- package/dist/esm/abi/method.js +4 -4
- package/dist/esm/abi/method.js.map +1 -1
- package/dist/esm/abi/transaction.js +1 -1
- package/dist/esm/abi/transaction.js.map +1 -1
- package/dist/esm/account.js +4 -4
- package/dist/esm/account.js.map +1 -1
- package/dist/esm/boxStorage.js +15 -15
- package/dist/esm/boxStorage.js.map +1 -1
- package/dist/esm/client/client.js +74 -40
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/client/index.js +7 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/client/kmd.js +67 -62
- package/dist/esm/client/kmd.js.map +1 -1
- package/dist/esm/client/urlTokenBaseHTTPClient.js +16 -11
- package/dist/esm/client/urlTokenBaseHTTPClient.js.map +1 -1
- package/dist/esm/client/v2/algod/accountApplicationInformation.js +10 -6
- package/dist/esm/client/v2/algod/accountApplicationInformation.js.map +1 -1
- package/dist/esm/client/v2/algod/accountAssetInformation.js +10 -6
- package/dist/esm/client/v2/algod/accountAssetInformation.js.map +1 -1
- package/dist/esm/client/v2/algod/accountInformation.js +10 -5
- package/dist/esm/client/v2/algod/accountInformation.js.map +1 -1
- package/dist/esm/client/v2/algod/algod.js +71 -70
- package/dist/esm/client/v2/algod/algod.js.map +1 -1
- package/dist/esm/client/v2/algod/block.js +5 -9
- package/dist/esm/client/v2/algod/block.js.map +1 -1
- package/dist/esm/client/v2/algod/compile.js +16 -10
- package/dist/esm/client/v2/algod/compile.js.map +1 -1
- package/dist/esm/client/v2/algod/disassemble.js +16 -10
- package/dist/esm/client/v2/algod/disassemble.js.map +1 -1
- package/dist/esm/client/v2/algod/dryrun.js +16 -12
- package/dist/esm/client/v2/algod/dryrun.js.map +1 -1
- package/dist/esm/client/v2/algod/genesis.js +5 -1
- package/dist/esm/client/v2/algod/genesis.js.map +1 -1
- package/dist/esm/client/v2/algod/getApplicationBoxByName.js +9 -9
- package/dist/esm/client/v2/algod/getApplicationBoxByName.js.map +1 -1
- package/dist/esm/client/v2/algod/getApplicationBoxes.js +7 -7
- package/dist/esm/client/v2/algod/getApplicationBoxes.js.map +1 -1
- package/dist/esm/client/v2/algod/getApplicationByID.js +9 -4
- package/dist/esm/client/v2/algod/getApplicationByID.js.map +1 -1
- package/dist/esm/client/v2/algod/getAssetByID.js +9 -4
- package/dist/esm/client/v2/algod/getAssetByID.js.map +1 -1
- package/dist/esm/client/v2/algod/getBlockHash.js +9 -5
- package/dist/esm/client/v2/algod/getBlockHash.js.map +1 -1
- package/dist/esm/client/v2/algod/getBlockOffsetTimestamp.js +5 -4
- package/dist/esm/client/v2/algod/getBlockOffsetTimestamp.js.map +1 -1
- package/dist/esm/client/v2/algod/getBlockTxids.js +9 -3
- package/dist/esm/client/v2/algod/getBlockTxids.js.map +1 -1
- package/dist/esm/client/v2/algod/getLedgerStateDelta.js +10 -5
- package/dist/esm/client/v2/algod/getLedgerStateDelta.js.map +1 -1
- package/dist/esm/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js +10 -5
- package/dist/esm/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js.map +1 -1
- package/dist/esm/client/v2/algod/getSyncRound.js +5 -4
- package/dist/esm/client/v2/algod/getSyncRound.js.map +1 -1
- package/dist/esm/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js +8 -8
- package/dist/esm/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js.map +1 -1
- package/dist/esm/client/v2/algod/getTransactionProof.js +9 -5
- package/dist/esm/client/v2/algod/getTransactionProof.js.map +1 -1
- package/dist/esm/client/v2/algod/healthCheck.js +3 -8
- package/dist/esm/client/v2/algod/healthCheck.js.map +1 -1
- package/dist/esm/client/v2/algod/index.js +4 -0
- package/dist/esm/client/v2/algod/index.js.map +1 -0
- package/dist/esm/client/v2/algod/lightBlockHeaderProof.js +9 -4
- package/dist/esm/client/v2/algod/lightBlockHeaderProof.js.map +1 -1
- package/dist/esm/client/v2/algod/models/types.js +3701 -1825
- package/dist/esm/client/v2/algod/models/types.js.map +1 -1
- package/dist/esm/client/v2/algod/pendingTransactionInformation.js +5 -8
- package/dist/esm/client/v2/algod/pendingTransactionInformation.js.map +1 -1
- package/dist/esm/client/v2/algod/pendingTransactions.js +5 -7
- package/dist/esm/client/v2/algod/pendingTransactions.js.map +1 -1
- package/dist/esm/client/v2/algod/pendingTransactionsByAddress.js +6 -9
- package/dist/esm/client/v2/algod/pendingTransactionsByAddress.js.map +1 -1
- package/dist/esm/client/v2/algod/ready.js +3 -1
- package/dist/esm/client/v2/algod/ready.js.map +1 -1
- package/dist/esm/client/v2/algod/sendRawTransaction.js +15 -6
- package/dist/esm/client/v2/algod/sendRawTransaction.js.map +1 -1
- package/dist/esm/client/v2/algod/setBlockOffsetTimestamp.js +12 -7
- package/dist/esm/client/v2/algod/setBlockOffsetTimestamp.js.map +1 -1
- package/dist/esm/client/v2/algod/setSyncRound.js +12 -7
- package/dist/esm/client/v2/algod/setSyncRound.js.map +1 -1
- package/dist/esm/client/v2/algod/simulateTransaction.js +14 -11
- package/dist/esm/client/v2/algod/simulateTransaction.js.map +1 -1
- package/dist/esm/client/v2/algod/stateproof.js +9 -4
- package/dist/esm/client/v2/algod/stateproof.js.map +1 -1
- package/dist/esm/client/v2/algod/status.js +7 -1
- package/dist/esm/client/v2/algod/status.js.map +1 -1
- package/dist/esm/client/v2/algod/statusAfterBlock.js +9 -4
- package/dist/esm/client/v2/algod/statusAfterBlock.js.map +1 -1
- package/dist/esm/client/v2/algod/suggestedParams.js +12 -8
- package/dist/esm/client/v2/algod/suggestedParams.js.map +1 -1
- package/dist/esm/client/v2/algod/supply.js +7 -1
- package/dist/esm/client/v2/algod/supply.js.map +1 -1
- package/dist/esm/client/v2/algod/unsetSyncRound.js +10 -4
- package/dist/esm/client/v2/algod/unsetSyncRound.js.map +1 -1
- package/dist/esm/client/v2/algod/versions.js +7 -1
- package/dist/esm/client/v2/algod/versions.js.map +1 -1
- package/dist/esm/client/v2/indexer/index.js +4 -0
- package/dist/esm/client/v2/indexer/index.js.map +1 -0
- package/dist/esm/client/v2/indexer/indexer.js +42 -42
- package/dist/esm/client/v2/indexer/indexer.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAccountAppLocalStates.js +10 -5
- package/dist/esm/client/v2/indexer/lookupAccountAppLocalStates.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAccountAssets.js +10 -5
- package/dist/esm/client/v2/indexer/lookupAccountAssets.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAccountByID.js +10 -5
- package/dist/esm/client/v2/indexer/lookupAccountByID.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAccountCreatedApplications.js +10 -5
- package/dist/esm/client/v2/indexer/lookupAccountCreatedApplications.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAccountCreatedAssets.js +10 -5
- package/dist/esm/client/v2/indexer/lookupAccountCreatedAssets.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAccountTransactions.js +18 -11
- package/dist/esm/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupApplicationBoxByIDandName.js +9 -9
- package/dist/esm/client/v2/indexer/lookupApplicationBoxByIDandName.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupApplicationLogs.js +9 -4
- package/dist/esm/client/v2/indexer/lookupApplicationLogs.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupApplications.js +9 -4
- package/dist/esm/client/v2/indexer/lookupApplications.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAssetBalances.js +9 -4
- package/dist/esm/client/v2/indexer/lookupAssetBalances.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAssetByID.js +9 -4
- package/dist/esm/client/v2/indexer/lookupAssetByID.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupAssetTransactions.js +17 -10
- package/dist/esm/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupBlock.js +9 -4
- package/dist/esm/client/v2/indexer/lookupBlock.js.map +1 -1
- package/dist/esm/client/v2/indexer/lookupTransactionByID.js +9 -4
- package/dist/esm/client/v2/indexer/lookupTransactionByID.js.map +1 -1
- package/dist/esm/client/v2/indexer/makeHealthCheck.js +7 -1
- package/dist/esm/client/v2/indexer/makeHealthCheck.js.map +1 -1
- package/dist/esm/client/v2/indexer/models/types.js +3591 -1648
- package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
- package/dist/esm/client/v2/indexer/searchAccounts.js +8 -2
- package/dist/esm/client/v2/indexer/searchAccounts.js.map +1 -1
- package/dist/esm/client/v2/indexer/searchForApplicationBoxes.js +7 -7
- package/dist/esm/client/v2/indexer/searchForApplicationBoxes.js.map +1 -1
- package/dist/esm/client/v2/indexer/searchForApplications.js +8 -2
- package/dist/esm/client/v2/indexer/searchForApplications.js.map +1 -1
- package/dist/esm/client/v2/indexer/searchForAssets.js +8 -2
- package/dist/esm/client/v2/indexer/searchForAssets.js.map +1 -1
- package/dist/esm/client/v2/indexer/searchForTransactions.js +15 -7
- package/dist/esm/client/v2/indexer/searchForTransactions.js.map +1 -1
- package/dist/esm/client/v2/jsonrequest.js +22 -51
- package/dist/esm/client/v2/jsonrequest.js.map +1 -1
- package/dist/esm/client/v2/serviceClient.js +3 -20
- package/dist/esm/client/v2/serviceClient.js.map +1 -1
- package/dist/esm/client/v2/untypedmodel.js +18 -0
- package/dist/esm/client/v2/untypedmodel.js.map +1 -0
- package/dist/esm/composer.js +43 -37
- package/dist/esm/composer.js.map +1 -1
- package/dist/esm/convert.js.map +1 -1
- package/dist/esm/dryrun.js +98 -195
- package/dist/esm/dryrun.js.map +1 -1
- package/dist/esm/encoding/address.js +85 -100
- package/dist/esm/encoding/address.js.map +1 -1
- package/dist/esm/encoding/bigint.js +2 -3
- package/dist/esm/encoding/bigint.js.map +1 -1
- package/dist/esm/encoding/binarydata.js +73 -0
- package/dist/esm/encoding/binarydata.js.map +1 -0
- package/dist/esm/encoding/encoding.js +337 -12
- package/dist/esm/encoding/encoding.js.map +1 -1
- package/dist/esm/encoding/schema/address.js +37 -0
- package/dist/esm/encoding/schema/address.js.map +1 -0
- package/dist/esm/encoding/schema/array.js +39 -0
- package/dist/esm/encoding/schema/array.js.map +1 -0
- package/dist/esm/encoding/schema/binarystring.js +51 -0
- package/dist/esm/encoding/schema/binarystring.js.map +1 -0
- package/dist/esm/encoding/schema/blockhash.js +60 -0
- package/dist/esm/encoding/schema/blockhash.js.map +1 -0
- package/dist/esm/encoding/schema/boolean.js +38 -0
- package/dist/esm/encoding/schema/boolean.js.map +1 -0
- package/dist/esm/encoding/schema/bytearray.js +93 -0
- package/dist/esm/encoding/schema/bytearray.js.map +1 -0
- package/dist/esm/encoding/schema/index.js +12 -0
- package/dist/esm/encoding/schema/index.js.map +1 -0
- package/dist/esm/encoding/schema/map.js +517 -0
- package/dist/esm/encoding/schema/map.js.map +1 -0
- package/dist/esm/encoding/schema/optional.js +54 -0
- package/dist/esm/encoding/schema/optional.js.map +1 -0
- package/dist/esm/encoding/schema/string.js +39 -0
- package/dist/esm/encoding/schema/string.js.map +1 -0
- package/dist/esm/encoding/schema/uint64.js +32 -0
- package/dist/esm/encoding/schema/uint64.js.map +1 -0
- package/dist/esm/encoding/schema/untyped.js +29 -0
- package/dist/esm/encoding/schema/untyped.js.map +1 -0
- package/dist/esm/encoding/uint64.js +1 -1
- package/dist/esm/encoding/uint64.js.map +1 -1
- package/dist/esm/group.js +22 -58
- package/dist/esm/group.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logic/sourcemap.js +54 -23
- package/dist/esm/logic/sourcemap.js.map +1 -1
- package/dist/esm/logicsig.js +110 -141
- package/dist/esm/logicsig.js.map +1 -1
- package/dist/esm/main.js +47 -76
- package/dist/esm/main.js.map +1 -1
- package/dist/esm/makeTxn.js +304 -529
- package/dist/esm/makeTxn.js.map +1 -1
- package/dist/esm/mnemonic/mnemonic.js +5 -5
- package/dist/esm/mnemonic/mnemonic.js.map +1 -1
- package/dist/esm/multisig.js +56 -305
- package/dist/esm/multisig.js.map +1 -1
- package/dist/esm/multisigSigning.js +254 -0
- package/dist/esm/multisigSigning.js.map +1 -0
- package/dist/esm/nacl/naclWrappers.js +1 -1
- package/dist/esm/nacl/naclWrappers.js.map +1 -1
- package/dist/esm/package.json +1 -0
- package/dist/esm/signedTransaction.js +100 -0
- package/dist/esm/signedTransaction.js.map +1 -0
- package/dist/esm/signer.js +3 -3
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/signing.js +77 -0
- package/dist/esm/signing.js.map +1 -0
- package/dist/esm/stateproof.js +408 -0
- package/dist/esm/stateproof.js.map +1 -0
- package/dist/esm/transaction.js +723 -1005
- package/dist/esm/transaction.js.map +1 -1
- package/dist/esm/types/block.js +797 -0
- package/dist/esm/types/block.js.map +1 -0
- package/dist/esm/types/intDecoding.js +1 -1
- package/dist/esm/types/intDecoding.js.map +1 -1
- package/dist/esm/types/statedelta.js +1129 -0
- package/dist/esm/types/statedelta.js.map +1 -0
- package/dist/esm/types/transactions/base.js +18 -2
- package/dist/esm/types/transactions/base.js.map +1 -1
- package/dist/esm/types/transactions/encoded.js +62 -1
- package/dist/esm/types/transactions/encoded.js.map +1 -1
- package/dist/esm/types/transactions/index.js +2 -3
- package/dist/esm/types/transactions/index.js.map +1 -1
- package/dist/esm/utils/utils.js +80 -21
- package/dist/esm/utils/utils.js.map +1 -1
- package/dist/esm/wait.js +4 -4
- package/dist/esm/wait.js.map +1 -1
- package/dist/types/abi/abi_type.d.ts +1 -1
- package/dist/types/abi/contract.d.ts +2 -2
- package/dist/types/abi/index.d.ts +6 -6
- package/dist/types/abi/interface.d.ts +1 -1
- package/dist/types/abi/method.d.ts +6 -6
- package/dist/types/abi/transaction.d.ts +1 -1
- package/dist/types/account.d.ts +1 -1
- package/dist/types/boxStorage.d.ts +4 -5
- package/dist/types/client/baseHTTPClient.d.ts +9 -6
- package/dist/types/client/client.d.ts +59 -18
- package/dist/types/client/index.d.ts +5 -0
- package/dist/types/client/kmd.d.ts +12 -10
- package/dist/types/client/urlTokenBaseHTTPClient.d.ts +8 -5
- package/dist/types/client/v2/algod/accountApplicationInformation.d.ts +8 -6
- package/dist/types/client/v2/algod/accountAssetInformation.d.ts +8 -6
- package/dist/types/client/v2/algod/accountInformation.d.ts +7 -5
- package/dist/types/client/v2/algod/algod.d.ts +53 -52
- package/dist/types/client/v2/algod/block.d.ts +5 -4
- package/dist/types/client/v2/algod/compile.d.ts +7 -9
- package/dist/types/client/v2/algod/disassemble.d.ts +7 -9
- package/dist/types/client/v2/algod/dryrun.d.ts +7 -9
- package/dist/types/client/v2/algod/genesis.d.ts +4 -2
- package/dist/types/client/v2/algod/getApplicationBoxByName.d.ts +6 -7
- package/dist/types/client/v2/algod/getApplicationBoxes.d.ts +6 -7
- package/dist/types/client/v2/algod/getApplicationByID.d.ts +6 -5
- package/dist/types/client/v2/algod/getAssetByID.d.ts +6 -5
- package/dist/types/client/v2/algod/getBlockHash.d.ts +7 -6
- package/dist/types/client/v2/algod/getBlockOffsetTimestamp.d.ts +5 -4
- package/dist/types/client/v2/algod/getBlockTxids.d.ts +6 -5
- package/dist/types/client/v2/algod/getLedgerStateDelta.d.ts +6 -5
- package/dist/types/client/v2/algod/getLedgerStateDeltaForTransactionGroup.d.ts +6 -5
- package/dist/types/client/v2/algod/getSyncRound.d.ts +5 -4
- package/dist/types/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.d.ts +6 -7
- package/dist/types/client/v2/algod/getTransactionProof.d.ts +6 -5
- package/dist/types/client/v2/algod/healthCheck.d.ts +4 -3
- package/dist/types/client/v2/algod/index.d.ts +2 -0
- package/dist/types/client/v2/algod/lightBlockHeaderProof.d.ts +6 -5
- package/dist/types/client/v2/algod/models/types.d.ts +604 -317
- package/dist/types/client/v2/algod/pendingTransactionInformation.d.ts +5 -4
- package/dist/types/client/v2/algod/pendingTransactions.d.ts +5 -4
- package/dist/types/client/v2/algod/pendingTransactionsByAddress.d.ts +7 -5
- package/dist/types/client/v2/algod/ready.d.ts +4 -2
- package/dist/types/client/v2/algod/sendRawTransaction.d.ts +7 -5
- package/dist/types/client/v2/algod/setBlockOffsetTimestamp.d.ts +6 -6
- package/dist/types/client/v2/algod/setSyncRound.d.ts +6 -6
- package/dist/types/client/v2/algod/simulateTransaction.d.ts +7 -7
- package/dist/types/client/v2/algod/stateproof.d.ts +6 -5
- package/dist/types/client/v2/algod/status.d.ts +5 -2
- package/dist/types/client/v2/algod/statusAfterBlock.d.ts +6 -5
- package/dist/types/client/v2/algod/suggestedParams.d.ts +25 -4
- package/dist/types/client/v2/algod/supply.d.ts +5 -2
- package/dist/types/client/v2/algod/unsetSyncRound.d.ts +5 -3
- package/dist/types/client/v2/algod/versions.d.ts +5 -2
- package/dist/types/client/v2/indexer/index.d.ts +2 -0
- package/dist/types/client/v2/indexer/indexer.d.ts +31 -30
- package/dist/types/client/v2/indexer/lookupAccountAppLocalStates.d.ts +7 -5
- package/dist/types/client/v2/indexer/lookupAccountAssets.d.ts +7 -5
- package/dist/types/client/v2/indexer/lookupAccountByID.d.ts +7 -5
- package/dist/types/client/v2/indexer/lookupAccountCreatedApplications.d.ts +7 -5
- package/dist/types/client/v2/indexer/lookupAccountCreatedAssets.d.ts +7 -5
- package/dist/types/client/v2/indexer/lookupAccountTransactions.d.ts +11 -9
- package/dist/types/client/v2/indexer/lookupApplicationBoxByIDandName.d.ts +6 -7
- package/dist/types/client/v2/indexer/lookupApplicationLogs.d.ts +6 -5
- package/dist/types/client/v2/indexer/lookupApplications.d.ts +6 -5
- package/dist/types/client/v2/indexer/lookupAssetBalances.d.ts +6 -5
- package/dist/types/client/v2/indexer/lookupAssetByID.d.ts +6 -5
- package/dist/types/client/v2/indexer/lookupAssetTransactions.d.ts +12 -10
- package/dist/types/client/v2/indexer/lookupBlock.d.ts +6 -5
- package/dist/types/client/v2/indexer/lookupTransactionByID.d.ts +6 -5
- package/dist/types/client/v2/indexer/makeHealthCheck.d.ts +5 -2
- package/dist/types/client/v2/indexer/models/types.d.ts +513 -267
- package/dist/types/client/v2/indexer/searchAccounts.d.ts +7 -3
- package/dist/types/client/v2/indexer/searchForApplicationBoxes.d.ts +6 -7
- package/dist/types/client/v2/indexer/searchForApplications.d.ts +7 -3
- package/dist/types/client/v2/indexer/searchForAssets.d.ts +7 -3
- package/dist/types/client/v2/indexer/searchForTransactions.d.ts +11 -7
- package/dist/types/client/v2/jsonrequest.d.ts +20 -33
- package/dist/types/client/v2/serviceClient.d.ts +4 -18
- package/dist/types/client/v2/untypedmodel.d.ts +10 -0
- package/dist/types/composer.d.ts +18 -17
- package/dist/types/dryrun.d.ts +8 -80
- package/dist/types/encoding/address.d.ts +40 -31
- package/dist/types/encoding/binarydata.d.ts +30 -0
- package/dist/types/encoding/encoding.d.ts +219 -7
- package/dist/types/encoding/schema/address.d.ts +10 -0
- package/dist/types/encoding/schema/array.d.ts +11 -0
- package/dist/types/encoding/schema/binarystring.d.ts +18 -0
- package/dist/types/encoding/schema/blockhash.d.ts +16 -0
- package/dist/types/encoding/schema/boolean.d.ts +10 -0
- package/dist/types/encoding/schema/bytearray.d.ts +19 -0
- package/dist/types/encoding/schema/index.d.ts +11 -0
- package/dist/types/encoding/schema/map.d.ts +125 -0
- package/dist/types/encoding/schema/optional.d.ts +24 -0
- package/dist/types/encoding/schema/string.d.ts +9 -0
- package/dist/types/encoding/schema/uint64.d.ts +9 -0
- package/dist/types/encoding/schema/untyped.d.ts +9 -0
- package/dist/types/encoding/uint64.d.ts +1 -0
- package/dist/types/group.d.ts +6 -25
- package/dist/types/index.d.ts +2 -2
- package/dist/types/logic/sourcemap.d.ts +39 -13
- package/dist/types/logicsig.d.ts +27 -57
- package/dist/types/main.d.ts +43 -54
- package/dist/types/makeTxn.d.ts +117 -404
- package/dist/types/mnemonic/mnemonic.d.ts +1 -1
- package/dist/types/multisig.d.ts +28 -99
- package/dist/types/multisigSigning.d.ts +72 -0
- package/dist/types/signedTransaction.d.ts +55 -0
- package/dist/types/signer.d.ts +5 -5
- package/dist/types/signing.d.ts +29 -0
- package/dist/types/stateproof.d.ts +194 -0
- package/dist/types/transaction.d.ts +103 -182
- package/dist/types/types/account.d.ts +2 -1
- package/dist/types/types/block.d.ts +407 -0
- package/dist/types/types/intDecoding.d.ts +1 -1
- package/dist/types/types/statedelta.d.ts +575 -0
- package/dist/types/types/transactions/base.d.ts +206 -118
- package/dist/types/types/transactions/encoded.d.ts +7 -301
- package/dist/types/types/transactions/index.d.ts +2 -15
- package/dist/types/types/utils.d.ts +7 -7
- package/dist/types/utils/utils.d.ts +21 -16
- package/dist/types/wait.d.ts +3 -2
- package/package.json +48 -20
- package/src/abi/abi_type.ts +28 -18
- package/src/abi/contract.ts +2 -2
- package/src/abi/index.ts +6 -6
- package/src/abi/interface.ts +1 -1
- package/src/abi/method.ts +11 -9
- package/src/abi/transaction.ts +2 -2
- package/src/account.ts +5 -5
- package/src/boxStorage.ts +25 -23
- package/src/client/baseHTTPClient.ts +12 -6
- package/src/client/client.ts +147 -75
- package/src/client/index.ts +6 -0
- package/src/client/kmd.ts +79 -72
- package/src/client/urlTokenBaseHTTPClient.ts +25 -14
- package/src/client/v2/algod/accountApplicationInformation.ts +16 -9
- package/src/client/v2/algod/accountAssetInformation.ts +16 -9
- package/src/client/v2/algod/accountInformation.ts +16 -11
- package/src/client/v2/algod/algod.ts +83 -105
- package/src/client/v2/algod/block.ts +7 -11
- package/src/client/v2/algod/compile.ts +27 -19
- package/src/client/v2/algod/disassemble.ts +27 -19
- package/src/client/v2/algod/dryrun.ts +23 -19
- package/src/client/v2/algod/genesis.ts +8 -2
- package/src/client/v2/algod/getApplicationBoxByName.ts +10 -15
- package/src/client/v2/algod/getApplicationBoxes.ts +12 -13
- package/src/client/v2/algod/getApplicationByID.ts +15 -7
- package/src/client/v2/algod/getAssetByID.ts +15 -7
- package/src/client/v2/algod/getBlockHash.ts +13 -9
- package/src/client/v2/algod/getBlockOffsetTimestamp.ts +7 -8
- package/src/client/v2/algod/getBlockTxids.ts +12 -6
- package/src/client/v2/algod/getLedgerStateDelta.ts +16 -8
- package/src/client/v2/algod/getLedgerStateDeltaForTransactionGroup.ts +16 -8
- package/src/client/v2/algod/getSyncRound.ts +7 -8
- package/src/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.ts +15 -15
- package/src/client/v2/algod/getTransactionProof.ts +11 -9
- package/src/client/v2/algod/healthCheck.ts +5 -9
- package/src/client/v2/algod/index.ts +3 -0
- package/src/client/v2/algod/lightBlockHeaderProof.ts +15 -8
- package/src/client/v2/algod/models/types.ts +4699 -2263
- package/src/client/v2/algod/pendingTransactionInformation.ts +11 -11
- package/src/client/v2/algod/pendingTransactions.ts +7 -9
- package/src/client/v2/algod/pendingTransactionsByAddress.ts +12 -11
- package/src/client/v2/algod/ready.ts +6 -2
- package/src/client/v2/algod/sendRawTransaction.ts +24 -13
- package/src/client/v2/algod/setBlockOffsetTimestamp.ts +21 -11
- package/src/client/v2/algod/setSyncRound.ts +21 -11
- package/src/client/v2/algod/simulateTransaction.ts +22 -23
- package/src/client/v2/algod/stateproof.ts +15 -8
- package/src/client/v2/algod/status.ts +10 -2
- package/src/client/v2/algod/statusAfterBlock.ts +15 -7
- package/src/client/v2/algod/suggestedParams.ts +40 -10
- package/src/client/v2/algod/supply.ts +10 -2
- package/src/client/v2/algod/unsetSyncRound.ts +16 -5
- package/src/client/v2/algod/versions.ts +10 -2
- package/src/client/v2/indexer/index.ts +3 -0
- package/src/client/v2/indexer/indexer.ts +51 -59
- package/src/client/v2/indexer/lookupAccountAppLocalStates.ts +16 -11
- package/src/client/v2/indexer/lookupAccountAssets.ts +16 -11
- package/src/client/v2/indexer/lookupAccountByID.ts +16 -11
- package/src/client/v2/indexer/lookupAccountCreatedApplications.ts +16 -11
- package/src/client/v2/indexer/lookupAccountCreatedAssets.ts +16 -11
- package/src/client/v2/indexer/lookupAccountTransactions.ts +26 -19
- package/src/client/v2/indexer/lookupApplicationBoxByIDandName.ts +10 -15
- package/src/client/v2/indexer/lookupApplicationLogs.ts +15 -7
- package/src/client/v2/indexer/lookupApplications.ts +15 -7
- package/src/client/v2/indexer/lookupAssetBalances.ts +15 -7
- package/src/client/v2/indexer/lookupAssetByID.ts +15 -7
- package/src/client/v2/indexer/lookupAssetTransactions.ts +27 -16
- package/src/client/v2/indexer/lookupBlock.ts +15 -7
- package/src/client/v2/indexer/lookupTransactionByID.ts +15 -7
- package/src/client/v2/indexer/makeHealthCheck.ts +10 -2
- package/src/client/v2/indexer/models/types.ts +4454 -1988
- package/src/client/v2/indexer/searchAccounts.ts +13 -4
- package/src/client/v2/indexer/searchForApplicationBoxes.ts +12 -13
- package/src/client/v2/indexer/searchForApplications.ts +13 -4
- package/src/client/v2/indexer/searchForAssets.ts +13 -4
- package/src/client/v2/indexer/searchForTransactions.ts +22 -11
- package/src/client/v2/jsonrequest.ts +39 -57
- package/src/client/v2/serviceClient.ts +9 -31
- package/src/client/v2/untypedmodel.ts +25 -0
- package/src/composer.ts +83 -60
- package/src/dryrun.ts +129 -306
- package/src/encoding/address.ts +134 -146
- package/src/encoding/bigint.ts +2 -4
- package/src/encoding/binarydata.ts +80 -0
- package/src/encoding/encoding.ts +558 -13
- package/src/encoding/schema/address.ts +53 -0
- package/src/encoding/schema/array.ts +66 -0
- package/src/encoding/schema/binarystring.ts +73 -0
- package/src/encoding/schema/blockhash.ts +84 -0
- package/src/encoding/schema/boolean.ts +54 -0
- package/src/encoding/schema/bytearray.ts +127 -0
- package/src/encoding/schema/index.ts +26 -0
- package/src/encoding/schema/map.ts +713 -0
- package/src/encoding/schema/optional.ts +72 -0
- package/src/encoding/schema/string.ts +55 -0
- package/src/encoding/schema/uint64.ts +46 -0
- package/src/encoding/schema/untyped.ts +47 -0
- package/src/encoding/uint64.ts +2 -1
- package/src/group.ts +27 -75
- package/src/index.ts +2 -2
- package/src/logic/sourcemap.ts +94 -29
- package/src/logicsig.ts +154 -202
- package/src/main.ts +91 -94
- package/src/makeTxn.ts +660 -1338
- package/src/mnemonic/mnemonic.ts +14 -14
- package/src/multisig.ts +89 -403
- package/src/multisigSigning.ts +359 -0
- package/src/nacl/naclWrappers.ts +1 -1
- package/src/signedTransaction.ts +163 -0
- package/src/signer.ts +10 -5
- package/src/signing.ts +95 -0
- package/src/stateproof.ts +595 -0
- package/src/transaction.ts +986 -1242
- package/src/types/account.ts +3 -1
- package/src/types/block.ts +1278 -0
- package/src/types/intDecoding.ts +1 -1
- package/src/types/statedelta.ts +1717 -0
- package/src/types/transactions/base.ts +230 -122
- package/src/types/transactions/encoded.ts +81 -371
- package/src/types/transactions/index.ts +2 -72
- package/src/types/utils.ts +3 -3
- package/src/utils/utils.ts +96 -25
- package/src/wait.ts +8 -7
- package/dist/cjs/bid.js +0 -83
- package/dist/cjs/bid.js.map +0 -1
- package/dist/cjs/client/v2/basemodel.js +0 -67
- package/dist/cjs/client/v2/basemodel.js.map +0 -1
- package/dist/cjs/types/address.js +0 -3
- package/dist/cjs/types/address.js.map +0 -1
- package/dist/cjs/types/blockHeader.js +0 -3
- package/dist/cjs/types/blockHeader.js.map +0 -1
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/cjs/types/multisig.js +0 -3
- package/dist/cjs/types/multisig.js.map +0 -1
- package/dist/cjs/types/transactions/application.js +0 -3
- package/dist/cjs/types/transactions/application.js.map +0 -1
- package/dist/cjs/types/transactions/asset.js +0 -3
- package/dist/cjs/types/transactions/asset.js.map +0 -1
- package/dist/cjs/types/transactions/builder.js +0 -3
- package/dist/cjs/types/transactions/builder.js.map +0 -1
- package/dist/cjs/types/transactions/keyreg.js +0 -3
- package/dist/cjs/types/transactions/keyreg.js.map +0 -1
- package/dist/cjs/types/transactions/payment.js +0 -3
- package/dist/cjs/types/transactions/payment.js.map +0 -1
- package/dist/cjs/types/transactions/stateproof.js +0 -3
- package/dist/cjs/types/transactions/stateproof.js.map +0 -1
- package/dist/esm/bid.js +0 -57
- package/dist/esm/bid.js.map +0 -1
- package/dist/esm/client/v2/basemodel.js +0 -64
- package/dist/esm/client/v2/basemodel.js.map +0 -1
- package/dist/esm/types/address.js +0 -2
- package/dist/esm/types/address.js.map +0 -1
- package/dist/esm/types/blockHeader.js +0 -2
- package/dist/esm/types/blockHeader.js.map +0 -1
- package/dist/esm/types/index.js +0 -4
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/multisig.js +0 -2
- package/dist/esm/types/multisig.js.map +0 -1
- package/dist/esm/types/transactions/application.js +0 -2
- package/dist/esm/types/transactions/application.js.map +0 -1
- package/dist/esm/types/transactions/asset.js +0 -2
- package/dist/esm/types/transactions/asset.js.map +0 -1
- package/dist/esm/types/transactions/builder.js +0 -2
- package/dist/esm/types/transactions/builder.js.map +0 -1
- package/dist/esm/types/transactions/keyreg.js +0 -2
- package/dist/esm/types/transactions/keyreg.js.map +0 -1
- package/dist/esm/types/transactions/payment.js +0 -2
- package/dist/esm/types/transactions/payment.js.map +0 -1
- package/dist/esm/types/transactions/stateproof.js +0 -2
- package/dist/esm/types/transactions/stateproof.js.map +0 -1
- package/dist/types/bid.d.ts +0 -38
- package/dist/types/client/v2/basemodel.d.ts +0 -11
- package/dist/types/types/address.d.ts +0 -7
- package/dist/types/types/blockHeader.d.ts +0 -67
- package/dist/types/types/index.d.ts +0 -3
- package/dist/types/types/multisig.d.ts +0 -20
- package/dist/types/types/transactions/application.d.ts +0 -22
- package/dist/types/types/transactions/asset.d.ts +0 -28
- package/dist/types/types/transactions/builder.d.ts +0 -36
- package/dist/types/types/transactions/keyreg.d.ts +0 -8
- package/dist/types/types/transactions/payment.d.ts +0 -8
- package/dist/types/types/transactions/stateproof.d.ts +0 -8
- package/src/bid.ts +0 -96
- package/src/client/v2/basemodel.ts +0 -81
- package/src/types/address.ts +0 -7
- package/src/types/blockHeader.ts +0 -81
- package/src/types/index.ts +0 -3
- package/src/types/multisig.ts +0 -22
- package/src/types/transactions/application.ts +0 -111
- package/src/types/transactions/asset.ts +0 -108
- package/src/types/transactions/builder.ts +0 -69
- package/src/types/transactions/keyreg.ts +0 -23
- package/src/types/transactions/payment.ts +0 -14
- package/src/types/transactions/stateproof.ts +0 -17
package/src/transaction.ts
CHANGED
|
@@ -1,1298 +1,1106 @@
|
|
|
1
|
-
import { Buffer } from 'buffer';
|
|
2
1
|
import base32 from 'hi-base32';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
6
|
-
import * as utils from './utils/utils';
|
|
7
|
-
import { translateBoxReferences } from './boxStorage';
|
|
2
|
+
import { boxReferencesToEncodingData } from './boxStorage.js';
|
|
3
|
+
import { Address } from './encoding/address.js';
|
|
4
|
+
import * as encoding from './encoding/encoding.js';
|
|
8
5
|
import {
|
|
6
|
+
AddressSchema,
|
|
7
|
+
Uint64Schema,
|
|
8
|
+
ByteArraySchema,
|
|
9
|
+
FixedLengthByteArraySchema,
|
|
10
|
+
StringSchema,
|
|
11
|
+
ArraySchema,
|
|
12
|
+
NamedMapSchema,
|
|
13
|
+
BooleanSchema,
|
|
14
|
+
OptionalSchema,
|
|
15
|
+
allOmitEmpty,
|
|
16
|
+
} from './encoding/schema/index.js';
|
|
17
|
+
import * as nacl from './nacl/naclWrappers.js';
|
|
18
|
+
import {
|
|
19
|
+
SuggestedParams,
|
|
20
|
+
BoxReference,
|
|
9
21
|
OnApplicationComplete,
|
|
22
|
+
isOnApplicationComplete,
|
|
10
23
|
TransactionParams,
|
|
11
24
|
TransactionType,
|
|
12
25
|
isTransactionType,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import { Address } from './types/address';
|
|
26
|
+
PaymentTransactionParams,
|
|
27
|
+
AssetConfigurationTransactionParams,
|
|
28
|
+
AssetTransferTransactionParams,
|
|
29
|
+
AssetFreezeTransactionParams,
|
|
30
|
+
KeyRegistrationTransactionParams,
|
|
31
|
+
ApplicationCallTransactionParams,
|
|
32
|
+
StateProofTransactionParams,
|
|
33
|
+
} from './types/transactions/base.js';
|
|
34
|
+
import { StateProof, StateProofMessage } from './stateproof.js';
|
|
35
|
+
import * as utils from './utils/utils.js';
|
|
24
36
|
|
|
25
37
|
const ALGORAND_TRANSACTION_LENGTH = 52;
|
|
26
|
-
export const ALGORAND_MIN_TX_FEE = 1000; // version v5
|
|
27
38
|
const ALGORAND_TRANSACTION_LEASE_LENGTH = 32;
|
|
28
|
-
const ALGORAND_MAX_ASSET_DECIMALS = 19;
|
|
29
39
|
const NUM_ADDL_BYTES_AFTER_SIGNING = 75; // NUM_ADDL_BYTES_AFTER_SIGNING is the number of bytes added to a txn after signing it
|
|
30
|
-
const ALGORAND_TRANSACTION_LEASE_LABEL_LENGTH = 5;
|
|
31
|
-
const ALGORAND_TRANSACTION_ADDRESS_LENGTH = 32;
|
|
32
|
-
const ALGORAND_TRANSACTION_REKEY_LABEL_LENGTH = 5;
|
|
33
40
|
const ASSET_METADATA_HASH_LENGTH = 32;
|
|
34
41
|
const KEYREG_VOTE_KEY_LENGTH = 32;
|
|
35
42
|
const KEYREG_SELECTION_KEY_LENGTH = 32;
|
|
36
43
|
const KEYREG_STATE_PROOF_KEY_LENGTH = 64;
|
|
44
|
+
const ALGORAND_TRANSACTION_GROUP_LENGTH = 32;
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* A modified version of the transaction params. Represents the internal structure that the Transaction class uses
|
|
43
|
-
* to store inputted transaction objects.
|
|
44
|
-
*/
|
|
45
|
-
// Omit allows overwriting properties
|
|
46
|
-
interface TransactionStorageStructure
|
|
47
|
-
extends Omit<
|
|
48
|
-
TransactionParams,
|
|
49
|
-
| 'from'
|
|
50
|
-
| 'to'
|
|
51
|
-
| 'genesisHash'
|
|
52
|
-
| 'closeRemainderTo'
|
|
53
|
-
| 'voteKey'
|
|
54
|
-
| 'selectionKey'
|
|
55
|
-
| 'stateProofKey'
|
|
56
|
-
| 'assetManager'
|
|
57
|
-
| 'assetReserve'
|
|
58
|
-
| 'assetFreeze'
|
|
59
|
-
| 'assetClawback'
|
|
60
|
-
| 'assetRevocationTarget'
|
|
61
|
-
| 'freezeAccount'
|
|
62
|
-
| 'appAccounts'
|
|
63
|
-
| 'suggestedParams'
|
|
64
|
-
| 'reKeyTo'
|
|
65
|
-
> {
|
|
66
|
-
from: string | Address;
|
|
67
|
-
to: string | Address;
|
|
68
|
-
fee: number;
|
|
69
|
-
amount: number | bigint;
|
|
70
|
-
firstRound: number;
|
|
71
|
-
lastRound: number;
|
|
72
|
-
note?: Uint8Array;
|
|
73
|
-
genesisID: string;
|
|
74
|
-
genesisHash: string | Buffer;
|
|
75
|
-
lease?: Uint8Array;
|
|
76
|
-
closeRemainderTo?: string | Address;
|
|
77
|
-
voteKey: string | Buffer;
|
|
78
|
-
selectionKey: string | Buffer;
|
|
79
|
-
stateProofKey: string | Buffer;
|
|
80
|
-
voteFirst: number;
|
|
81
|
-
voteLast: number;
|
|
82
|
-
voteKeyDilution: number;
|
|
83
|
-
assetIndex: number;
|
|
84
|
-
assetTotal: number | bigint;
|
|
85
|
-
assetDecimals: number;
|
|
86
|
-
assetDefaultFrozen: boolean;
|
|
87
|
-
assetManager: string | Address;
|
|
88
|
-
assetReserve: string | Address;
|
|
89
|
-
assetFreeze: string | Address;
|
|
90
|
-
assetClawback: string | Address;
|
|
91
|
-
assetUnitName: string;
|
|
92
|
-
assetName: string;
|
|
93
|
-
assetURL: string;
|
|
94
|
-
assetMetadataHash?: string | Uint8Array;
|
|
95
|
-
freezeAccount: string | Address;
|
|
96
|
-
freezeState: boolean;
|
|
97
|
-
assetRevocationTarget?: string | Address;
|
|
98
|
-
appIndex: number;
|
|
99
|
-
appOnComplete: OnApplicationComplete;
|
|
100
|
-
appLocalInts: number;
|
|
101
|
-
appLocalByteSlices: number;
|
|
102
|
-
appGlobalInts: number;
|
|
103
|
-
appGlobalByteSlices: number;
|
|
104
|
-
appApprovalProgram: Uint8Array;
|
|
105
|
-
appClearProgram: Uint8Array;
|
|
106
|
-
appArgs?: Uint8Array[];
|
|
107
|
-
appAccounts?: string[] | Address[];
|
|
108
|
-
appForeignApps?: number[];
|
|
109
|
-
appForeignAssets?: number[];
|
|
110
|
-
type?: TransactionType;
|
|
111
|
-
flatFee: boolean;
|
|
112
|
-
reKeyTo?: string | Address;
|
|
113
|
-
nonParticipation?: boolean;
|
|
114
|
-
group?: Buffer;
|
|
115
|
-
extraPages?: number;
|
|
116
|
-
boxes?: BoxReference[];
|
|
117
|
-
stateProofType?: number | bigint;
|
|
118
|
-
stateProof?: Uint8Array;
|
|
119
|
-
stateProofMessage?: Uint8Array;
|
|
46
|
+
function uint8ArrayIsEmpty(input: Uint8Array): boolean {
|
|
47
|
+
return input.every((value) => value === 0);
|
|
120
48
|
}
|
|
121
49
|
|
|
122
50
|
function getKeyregKey(
|
|
123
|
-
input: undefined | string | Uint8Array
|
|
51
|
+
input: undefined | string | Uint8Array,
|
|
124
52
|
inputName: string,
|
|
125
53
|
length: number
|
|
126
|
-
):
|
|
54
|
+
): Uint8Array | undefined {
|
|
127
55
|
if (input == null) {
|
|
128
56
|
return undefined;
|
|
129
57
|
}
|
|
130
58
|
|
|
131
|
-
let
|
|
59
|
+
let inputBytes: Uint8Array | undefined;
|
|
60
|
+
|
|
61
|
+
if (input instanceof Uint8Array) {
|
|
62
|
+
inputBytes = input;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (inputBytes == null || inputBytes.byteLength !== length) {
|
|
66
|
+
throw Error(`${inputName} must be a ${length} byte Uint8Array`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return inputBytes;
|
|
70
|
+
}
|
|
132
71
|
|
|
72
|
+
function ensureAddress(input: unknown): Address {
|
|
73
|
+
if (input == null) {
|
|
74
|
+
throw new Error('Address must not be null or undefined');
|
|
75
|
+
}
|
|
133
76
|
if (typeof input === 'string') {
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
inputAsBuffer = input;
|
|
77
|
+
return Address.fromString(input);
|
|
78
|
+
}
|
|
79
|
+
if (input instanceof Address) {
|
|
80
|
+
return input;
|
|
139
81
|
}
|
|
82
|
+
throw new Error(`Not an address: ${input}`);
|
|
83
|
+
}
|
|
140
84
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
85
|
+
function optionalAddress(input: unknown): Address | undefined {
|
|
86
|
+
if (input == null) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
let addr: Address;
|
|
90
|
+
if (input instanceof Address) {
|
|
91
|
+
addr = input;
|
|
92
|
+
} else if (typeof input === 'string') {
|
|
93
|
+
addr = Address.fromString(input);
|
|
94
|
+
} else {
|
|
95
|
+
throw new Error(`Not an address: ${input}`);
|
|
96
|
+
}
|
|
97
|
+
if (uint8ArrayIsEmpty(addr.publicKey)) {
|
|
98
|
+
// If it's the zero address, throw an error so that the user won't be surprised that this gets dropped
|
|
99
|
+
throw new Error(
|
|
100
|
+
'Invalid use of the zero address. To omit this value, pass in undefined'
|
|
144
101
|
);
|
|
145
102
|
}
|
|
103
|
+
return addr;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function optionalUint8Array(input: unknown): Uint8Array | undefined {
|
|
107
|
+
if (typeof input === 'undefined') {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (input instanceof Uint8Array) {
|
|
111
|
+
return input;
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Not a Uint8Array: ${input}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function ensureUint8Array(input: unknown): Uint8Array {
|
|
117
|
+
if (input instanceof Uint8Array) {
|
|
118
|
+
return input;
|
|
119
|
+
}
|
|
120
|
+
throw new Error(`Not a Uint8Array: ${input}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function optionalUint64(input: unknown): bigint | undefined {
|
|
124
|
+
if (typeof input === 'undefined') {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
return utils.ensureUint64(input);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function ensureBoolean(input: unknown): boolean {
|
|
131
|
+
if (input === true || input === false) {
|
|
132
|
+
return input;
|
|
133
|
+
}
|
|
134
|
+
throw new Error(`Not a boolean: ${input}`);
|
|
135
|
+
}
|
|
146
136
|
|
|
147
|
-
|
|
137
|
+
function ensureArray(input: unknown): unknown[] {
|
|
138
|
+
if (Array.isArray(input)) {
|
|
139
|
+
return input.slice();
|
|
140
|
+
}
|
|
141
|
+
throw new Error(`Not an array: ${input}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function optionalFixedLengthByteArray(
|
|
145
|
+
input: unknown,
|
|
146
|
+
length: number,
|
|
147
|
+
name: string
|
|
148
|
+
): Uint8Array | undefined {
|
|
149
|
+
const bytes = optionalUint8Array(input);
|
|
150
|
+
if (typeof bytes === 'undefined') {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
if (bytes.byteLength !== length) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
`${name} must be ${length} bytes long, was ${bytes.byteLength}`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
if (uint8ArrayIsEmpty(bytes)) {
|
|
159
|
+
// if contains all 0s, omit it
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return bytes;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface TransactionBoxReference {
|
|
166
|
+
readonly appIndex: bigint;
|
|
167
|
+
readonly name: Uint8Array;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function ensureBoxReference(input: unknown): TransactionBoxReference {
|
|
171
|
+
if (input != null && typeof input === 'object') {
|
|
172
|
+
const { appIndex, name } = input as BoxReference;
|
|
173
|
+
return {
|
|
174
|
+
appIndex: utils.ensureUint64(appIndex),
|
|
175
|
+
name: ensureUint8Array(name),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
throw new Error(`Not a box reference: ${input}`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const TX_TAG = new TextEncoder().encode('TX');
|
|
182
|
+
|
|
183
|
+
export interface PaymentTransactionFields {
|
|
184
|
+
readonly receiver: Address;
|
|
185
|
+
readonly amount: bigint;
|
|
186
|
+
readonly closeRemainderTo?: Address;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface KeyRegistrationTransactionFields {
|
|
190
|
+
readonly voteKey?: Uint8Array;
|
|
191
|
+
readonly selectionKey?: Uint8Array;
|
|
192
|
+
readonly stateProofKey?: Uint8Array;
|
|
193
|
+
readonly voteFirst?: bigint;
|
|
194
|
+
readonly voteLast?: bigint;
|
|
195
|
+
readonly voteKeyDilution?: bigint;
|
|
196
|
+
readonly nonParticipation: boolean;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface AssetConfigTransactionFields {
|
|
200
|
+
readonly assetIndex: bigint;
|
|
201
|
+
readonly total: bigint;
|
|
202
|
+
readonly decimals: number;
|
|
203
|
+
readonly defaultFrozen: boolean;
|
|
204
|
+
readonly manager?: Address;
|
|
205
|
+
readonly reserve?: Address;
|
|
206
|
+
readonly freeze?: Address;
|
|
207
|
+
readonly clawback?: Address;
|
|
208
|
+
readonly unitName?: string;
|
|
209
|
+
readonly assetName?: string;
|
|
210
|
+
readonly assetURL?: string;
|
|
211
|
+
readonly assetMetadataHash?: Uint8Array;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface AssetTransferTransactionFields {
|
|
215
|
+
readonly assetIndex: bigint;
|
|
216
|
+
readonly amount: bigint;
|
|
217
|
+
readonly assetSender?: Address;
|
|
218
|
+
readonly receiver: Address;
|
|
219
|
+
readonly closeRemainderTo?: Address;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface AssetFreezeTransactionFields {
|
|
223
|
+
readonly assetIndex: bigint;
|
|
224
|
+
readonly freezeAccount: Address;
|
|
225
|
+
readonly frozen: boolean;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface ApplicationTransactionFields {
|
|
229
|
+
readonly appIndex: bigint;
|
|
230
|
+
readonly onComplete: OnApplicationComplete;
|
|
231
|
+
readonly numLocalInts: number;
|
|
232
|
+
readonly numLocalByteSlices: number;
|
|
233
|
+
readonly numGlobalInts: number;
|
|
234
|
+
readonly numGlobalByteSlices: number;
|
|
235
|
+
readonly extraPages: number;
|
|
236
|
+
readonly approvalProgram: Uint8Array;
|
|
237
|
+
readonly clearProgram: Uint8Array;
|
|
238
|
+
readonly appArgs: ReadonlyArray<Uint8Array>;
|
|
239
|
+
readonly accounts: ReadonlyArray<Address>;
|
|
240
|
+
readonly foreignApps: ReadonlyArray<bigint>;
|
|
241
|
+
readonly foreignAssets: ReadonlyArray<bigint>;
|
|
242
|
+
readonly boxes: ReadonlyArray<TransactionBoxReference>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface StateProofTransactionFields {
|
|
246
|
+
readonly stateProofType: number;
|
|
247
|
+
readonly stateProof?: StateProof;
|
|
248
|
+
readonly message?: StateProofMessage;
|
|
148
249
|
}
|
|
149
250
|
|
|
150
251
|
/**
|
|
151
252
|
* Transaction enables construction of Algorand transactions
|
|
152
253
|
* */
|
|
153
|
-
export class Transaction implements
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
254
|
+
export class Transaction implements encoding.Encodable {
|
|
255
|
+
static readonly encodingSchema = new NamedMapSchema(
|
|
256
|
+
allOmitEmpty([
|
|
257
|
+
// Common
|
|
258
|
+
{ key: 'type', valueSchema: new StringSchema() },
|
|
259
|
+
{ key: 'snd', valueSchema: new AddressSchema() },
|
|
260
|
+
{ key: 'lv', valueSchema: new Uint64Schema() },
|
|
261
|
+
{ key: 'gen', valueSchema: new OptionalSchema(new StringSchema()) },
|
|
262
|
+
{
|
|
263
|
+
key: 'gh',
|
|
264
|
+
valueSchema: new OptionalSchema(new FixedLengthByteArraySchema(32)),
|
|
265
|
+
},
|
|
266
|
+
{ key: 'fee', valueSchema: new Uint64Schema() },
|
|
267
|
+
{ key: 'fv', valueSchema: new Uint64Schema() },
|
|
268
|
+
{ key: 'note', valueSchema: new ByteArraySchema() },
|
|
269
|
+
{
|
|
270
|
+
key: 'lx',
|
|
271
|
+
valueSchema: new OptionalSchema(new FixedLengthByteArraySchema(32)),
|
|
272
|
+
},
|
|
273
|
+
{ key: 'rekey', valueSchema: new OptionalSchema(new AddressSchema()) },
|
|
274
|
+
{
|
|
275
|
+
key: 'grp',
|
|
276
|
+
valueSchema: new OptionalSchema(new FixedLengthByteArraySchema(32)),
|
|
277
|
+
},
|
|
278
|
+
// We mark all top-level type-specific fields optional because they will not be present when
|
|
279
|
+
// the transaction is not that type.
|
|
280
|
+
// Payment
|
|
281
|
+
{ key: 'amt', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
282
|
+
{ key: 'rcv', valueSchema: new OptionalSchema(new AddressSchema()) },
|
|
283
|
+
{ key: 'close', valueSchema: new OptionalSchema(new AddressSchema()) },
|
|
284
|
+
// Keyreg
|
|
285
|
+
{
|
|
286
|
+
key: 'votekey',
|
|
287
|
+
valueSchema: new OptionalSchema(new FixedLengthByteArraySchema(32)),
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
key: 'selkey',
|
|
291
|
+
valueSchema: new OptionalSchema(new FixedLengthByteArraySchema(32)),
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
key: 'sprfkey',
|
|
295
|
+
valueSchema: new OptionalSchema(new FixedLengthByteArraySchema(64)),
|
|
296
|
+
},
|
|
297
|
+
{ key: 'votefst', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
298
|
+
{ key: 'votelst', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
299
|
+
{ key: 'votekd', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
300
|
+
{ key: 'nonpart', valueSchema: new OptionalSchema(new BooleanSchema()) },
|
|
301
|
+
// AssetConfig
|
|
302
|
+
{ key: 'caid', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
303
|
+
{
|
|
304
|
+
key: 'apar',
|
|
305
|
+
valueSchema: new OptionalSchema(
|
|
306
|
+
new NamedMapSchema(
|
|
307
|
+
allOmitEmpty([
|
|
308
|
+
{ key: 't', valueSchema: new Uint64Schema() },
|
|
309
|
+
{ key: 'dc', valueSchema: new Uint64Schema() },
|
|
310
|
+
{ key: 'df', valueSchema: new BooleanSchema() },
|
|
311
|
+
{
|
|
312
|
+
key: 'm',
|
|
313
|
+
valueSchema: new OptionalSchema(new AddressSchema()),
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
key: 'r',
|
|
317
|
+
valueSchema: new OptionalSchema(new AddressSchema()),
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
key: 'f',
|
|
321
|
+
valueSchema: new OptionalSchema(new AddressSchema()),
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
key: 'c',
|
|
325
|
+
valueSchema: new OptionalSchema(new AddressSchema()),
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
key: 'un',
|
|
329
|
+
valueSchema: new OptionalSchema(new StringSchema()),
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
key: 'an',
|
|
333
|
+
valueSchema: new OptionalSchema(new StringSchema()),
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
key: 'au',
|
|
337
|
+
valueSchema: new OptionalSchema(new StringSchema()),
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
key: 'am',
|
|
341
|
+
valueSchema: new OptionalSchema(
|
|
342
|
+
new FixedLengthByteArraySchema(32)
|
|
343
|
+
),
|
|
344
|
+
},
|
|
345
|
+
])
|
|
346
|
+
)
|
|
347
|
+
),
|
|
348
|
+
},
|
|
349
|
+
// AssetTransfer
|
|
350
|
+
{ key: 'xaid', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
351
|
+
{ key: 'aamt', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
352
|
+
{ key: 'arcv', valueSchema: new OptionalSchema(new AddressSchema()) },
|
|
353
|
+
{ key: 'aclose', valueSchema: new OptionalSchema(new AddressSchema()) },
|
|
354
|
+
{ key: 'asnd', valueSchema: new OptionalSchema(new AddressSchema()) },
|
|
355
|
+
// AssetFreeze
|
|
356
|
+
{ key: 'faid', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
357
|
+
{ key: 'afrz', valueSchema: new OptionalSchema(new BooleanSchema()) },
|
|
358
|
+
{ key: 'fadd', valueSchema: new OptionalSchema(new AddressSchema()) },
|
|
359
|
+
// Application
|
|
360
|
+
{ key: 'apid', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
361
|
+
{ key: 'apan', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
362
|
+
{
|
|
363
|
+
key: 'apaa',
|
|
364
|
+
valueSchema: new OptionalSchema(new ArraySchema(new ByteArraySchema())),
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
key: 'apat',
|
|
368
|
+
valueSchema: new OptionalSchema(new ArraySchema(new AddressSchema())),
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
key: 'apas',
|
|
372
|
+
valueSchema: new OptionalSchema(new ArraySchema(new Uint64Schema())),
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
key: 'apfa',
|
|
376
|
+
valueSchema: new OptionalSchema(new ArraySchema(new Uint64Schema())),
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
key: 'apbx',
|
|
380
|
+
valueSchema: new OptionalSchema(
|
|
381
|
+
new ArraySchema(
|
|
382
|
+
new NamedMapSchema(
|
|
383
|
+
allOmitEmpty([
|
|
384
|
+
{
|
|
385
|
+
key: 'i',
|
|
386
|
+
valueSchema: new Uint64Schema(),
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
key: 'n',
|
|
390
|
+
valueSchema: new ByteArraySchema(),
|
|
391
|
+
},
|
|
392
|
+
])
|
|
393
|
+
)
|
|
394
|
+
)
|
|
395
|
+
),
|
|
396
|
+
},
|
|
397
|
+
{ key: 'apap', valueSchema: new OptionalSchema(new ByteArraySchema()) },
|
|
398
|
+
{ key: 'apsu', valueSchema: new OptionalSchema(new ByteArraySchema()) },
|
|
399
|
+
{
|
|
400
|
+
key: 'apls',
|
|
401
|
+
valueSchema: new OptionalSchema(
|
|
402
|
+
new NamedMapSchema(
|
|
403
|
+
allOmitEmpty([
|
|
404
|
+
{
|
|
405
|
+
key: 'nui',
|
|
406
|
+
valueSchema: new Uint64Schema(),
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
key: 'nbs',
|
|
410
|
+
valueSchema: new Uint64Schema(),
|
|
411
|
+
},
|
|
412
|
+
])
|
|
413
|
+
)
|
|
414
|
+
),
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
key: 'apgs',
|
|
418
|
+
valueSchema: new OptionalSchema(
|
|
419
|
+
new NamedMapSchema(
|
|
420
|
+
allOmitEmpty([
|
|
421
|
+
{
|
|
422
|
+
key: 'nui',
|
|
423
|
+
valueSchema: new Uint64Schema(),
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
key: 'nbs',
|
|
427
|
+
valueSchema: new Uint64Schema(),
|
|
428
|
+
},
|
|
429
|
+
])
|
|
430
|
+
)
|
|
431
|
+
),
|
|
432
|
+
},
|
|
433
|
+
{ key: 'apep', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
434
|
+
// StateProof
|
|
435
|
+
{ key: 'sptype', valueSchema: new OptionalSchema(new Uint64Schema()) },
|
|
436
|
+
{ key: 'sp', valueSchema: new OptionalSchema(StateProof.encodingSchema) },
|
|
437
|
+
{
|
|
438
|
+
key: 'spmsg',
|
|
439
|
+
valueSchema: new OptionalSchema(StateProofMessage.encodingSchema),
|
|
440
|
+
},
|
|
441
|
+
])
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
/** common */
|
|
445
|
+
public readonly type: TransactionType;
|
|
446
|
+
public readonly sender: Address;
|
|
447
|
+
public readonly note: Uint8Array;
|
|
448
|
+
public readonly lease?: Uint8Array;
|
|
449
|
+
public readonly rekeyTo?: Address;
|
|
450
|
+
|
|
451
|
+
/** group */
|
|
452
|
+
public group?: Uint8Array;
|
|
453
|
+
|
|
454
|
+
/** suggested params */
|
|
455
|
+
public fee: bigint;
|
|
456
|
+
public readonly firstValid: bigint;
|
|
457
|
+
public readonly lastValid: bigint;
|
|
458
|
+
public readonly genesisID?: string;
|
|
459
|
+
public readonly genesisHash?: Uint8Array;
|
|
460
|
+
|
|
461
|
+
/** type-specific fields */
|
|
462
|
+
public readonly payment?: PaymentTransactionFields;
|
|
463
|
+
public readonly keyreg?: KeyRegistrationTransactionFields;
|
|
464
|
+
public readonly assetConfig?: AssetConfigTransactionFields;
|
|
465
|
+
public readonly assetTransfer?: AssetTransferTransactionFields;
|
|
466
|
+
public readonly assetFreeze?: AssetFreezeTransactionFields;
|
|
467
|
+
public readonly applicationCall?: ApplicationTransactionFields;
|
|
468
|
+
public readonly stateProof?: StateProofTransactionFields;
|
|
469
|
+
|
|
470
|
+
constructor(params: TransactionParams) {
|
|
471
|
+
if (!isTransactionType(params.type)) {
|
|
472
|
+
throw new Error(`Invalid transaction type: ${params.type}`);
|
|
240
473
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
474
|
+
|
|
475
|
+
// Common fields
|
|
476
|
+
this.type = params.type; // verified above
|
|
477
|
+
this.sender = ensureAddress(params.sender);
|
|
478
|
+
this.note = ensureUint8Array(params.note ?? new Uint8Array());
|
|
479
|
+
this.lease = optionalFixedLengthByteArray(
|
|
480
|
+
params.lease,
|
|
481
|
+
ALGORAND_TRANSACTION_LEASE_LENGTH,
|
|
482
|
+
'lease'
|
|
483
|
+
);
|
|
484
|
+
this.rekeyTo = optionalAddress(params.rekeyTo);
|
|
485
|
+
|
|
486
|
+
// Group
|
|
487
|
+
this.group = undefined;
|
|
488
|
+
|
|
489
|
+
// Suggested params fields
|
|
490
|
+
this.firstValid = utils.ensureUint64(params.suggestedParams.firstValid);
|
|
491
|
+
this.lastValid = utils.ensureUint64(params.suggestedParams.lastValid);
|
|
492
|
+
if (params.suggestedParams.genesisID) {
|
|
493
|
+
if (typeof params.suggestedParams.genesisID !== 'string') {
|
|
494
|
+
throw new Error('Genesis ID must be a string if present');
|
|
495
|
+
}
|
|
496
|
+
this.genesisID = params.suggestedParams.genesisID;
|
|
258
497
|
}
|
|
498
|
+
this.genesisHash = optionalUint8Array(params.suggestedParams.genesisHash);
|
|
499
|
+
// Fee is handled at the end
|
|
259
500
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
501
|
+
const fieldsPresent: TransactionType[] = [];
|
|
502
|
+
if (params.paymentParams) fieldsPresent.push(TransactionType.pay);
|
|
503
|
+
if (params.keyregParams) fieldsPresent.push(TransactionType.keyreg);
|
|
504
|
+
if (params.assetConfigParams) fieldsPresent.push(TransactionType.acfg);
|
|
505
|
+
if (params.assetTransferParams) fieldsPresent.push(TransactionType.axfer);
|
|
506
|
+
if (params.assetFreezeParams) fieldsPresent.push(TransactionType.afrz);
|
|
507
|
+
if (params.appCallParams) fieldsPresent.push(TransactionType.appl);
|
|
508
|
+
if (params.stateProofParams) fieldsPresent.push(TransactionType.stpf);
|
|
263
509
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
txn.closeRemainderTo = address.decodeAddress(
|
|
268
|
-
txn.closeRemainderTo as string
|
|
269
|
-
);
|
|
270
|
-
if (txn.assetManager !== undefined)
|
|
271
|
-
txn.assetManager = address.decodeAddress(txn.assetManager as string);
|
|
272
|
-
if (txn.assetReserve !== undefined)
|
|
273
|
-
txn.assetReserve = address.decodeAddress(txn.assetReserve as string);
|
|
274
|
-
if (txn.assetFreeze !== undefined)
|
|
275
|
-
txn.assetFreeze = address.decodeAddress(txn.assetFreeze as string);
|
|
276
|
-
if (txn.assetClawback !== undefined)
|
|
277
|
-
txn.assetClawback = address.decodeAddress(txn.assetClawback as string);
|
|
278
|
-
if (txn.assetRevocationTarget !== undefined)
|
|
279
|
-
txn.assetRevocationTarget = address.decodeAddress(
|
|
280
|
-
txn.assetRevocationTarget as string
|
|
281
|
-
);
|
|
282
|
-
if (txn.freezeAccount !== undefined)
|
|
283
|
-
txn.freezeAccount = address.decodeAddress(txn.freezeAccount as string);
|
|
284
|
-
if (txn.reKeyTo !== undefined)
|
|
285
|
-
txn.reKeyTo = address.decodeAddress(txn.reKeyTo as string);
|
|
286
|
-
if (txn.genesisHash === undefined)
|
|
287
|
-
throw Error('genesis hash must be specified and in a base64 string.');
|
|
288
|
-
|
|
289
|
-
txn.genesisHash = Buffer.from(txn.genesisHash as string, 'base64');
|
|
290
|
-
|
|
291
|
-
if (
|
|
292
|
-
txn.amount !== undefined &&
|
|
293
|
-
(!(
|
|
294
|
-
Number.isSafeInteger(txn.amount) ||
|
|
295
|
-
(typeof txn.amount === 'bigint' &&
|
|
296
|
-
txn.amount <= BigInt('0xffffffffffffffff'))
|
|
297
|
-
) ||
|
|
298
|
-
txn.amount < 0)
|
|
299
|
-
)
|
|
300
|
-
throw Error(
|
|
301
|
-
'Amount must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'
|
|
302
|
-
);
|
|
303
|
-
if (!Number.isSafeInteger(txn.fee) || txn.fee < 0)
|
|
304
|
-
throw Error('fee must be a positive number and smaller than 2^53-1');
|
|
305
|
-
if (!Number.isSafeInteger(txn.firstRound) || txn.firstRound < 0)
|
|
306
|
-
throw Error('firstRound must be a positive number');
|
|
307
|
-
if (!Number.isSafeInteger(txn.lastRound) || txn.lastRound < 0)
|
|
308
|
-
throw Error('lastRound must be a positive number');
|
|
309
|
-
if (
|
|
310
|
-
txn.extraPages !== undefined &&
|
|
311
|
-
(!Number.isInteger(txn.extraPages) ||
|
|
312
|
-
txn.extraPages < 0 ||
|
|
313
|
-
txn.extraPages > 3)
|
|
314
|
-
)
|
|
315
|
-
throw Error('extraPages must be an Integer between and including 0 to 3');
|
|
316
|
-
if (
|
|
317
|
-
txn.assetTotal !== undefined &&
|
|
318
|
-
(!(
|
|
319
|
-
Number.isSafeInteger(txn.assetTotal) ||
|
|
320
|
-
(typeof txn.assetTotal === 'bigint' &&
|
|
321
|
-
txn.assetTotal <= BigInt('0xffffffffffffffff'))
|
|
322
|
-
) ||
|
|
323
|
-
txn.assetTotal < 0)
|
|
324
|
-
)
|
|
325
|
-
throw Error(
|
|
326
|
-
'Total asset issuance must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'
|
|
327
|
-
);
|
|
328
|
-
if (
|
|
329
|
-
txn.assetDecimals !== undefined &&
|
|
330
|
-
(!Number.isSafeInteger(txn.assetDecimals) ||
|
|
331
|
-
txn.assetDecimals < 0 ||
|
|
332
|
-
txn.assetDecimals > ALGORAND_MAX_ASSET_DECIMALS)
|
|
333
|
-
)
|
|
334
|
-
throw Error(
|
|
335
|
-
`assetDecimals must be a positive number and smaller than ${ALGORAND_MAX_ASSET_DECIMALS.toString()}`
|
|
336
|
-
);
|
|
337
|
-
if (
|
|
338
|
-
txn.assetIndex !== undefined &&
|
|
339
|
-
(!Number.isSafeInteger(txn.assetIndex) || txn.assetIndex < 0)
|
|
340
|
-
)
|
|
341
|
-
throw Error(
|
|
342
|
-
'Asset index must be a positive number and smaller than 2^53-1'
|
|
343
|
-
);
|
|
344
|
-
if (
|
|
345
|
-
txn.appIndex !== undefined &&
|
|
346
|
-
(!Number.isSafeInteger(txn.appIndex) || txn.appIndex < 0)
|
|
347
|
-
)
|
|
348
|
-
throw Error(
|
|
349
|
-
'Application index must be a positive number and smaller than 2^53-1'
|
|
350
|
-
);
|
|
351
|
-
if (
|
|
352
|
-
txn.appLocalInts !== undefined &&
|
|
353
|
-
(!Number.isSafeInteger(txn.appLocalInts) || txn.appLocalInts < 0)
|
|
354
|
-
)
|
|
355
|
-
throw Error(
|
|
356
|
-
'Application local ints count must be a positive number and smaller than 2^53-1'
|
|
357
|
-
);
|
|
358
|
-
if (
|
|
359
|
-
txn.appLocalByteSlices !== undefined &&
|
|
360
|
-
(!Number.isSafeInteger(txn.appLocalByteSlices) ||
|
|
361
|
-
txn.appLocalByteSlices < 0)
|
|
362
|
-
)
|
|
363
|
-
throw Error(
|
|
364
|
-
'Application local byte slices count must be a positive number and smaller than 2^53-1'
|
|
365
|
-
);
|
|
366
|
-
if (
|
|
367
|
-
txn.appGlobalInts !== undefined &&
|
|
368
|
-
(!Number.isSafeInteger(txn.appGlobalInts) || txn.appGlobalInts < 0)
|
|
369
|
-
)
|
|
370
|
-
throw Error(
|
|
371
|
-
'Application global ints count must be a positive number and smaller than 2^53-1'
|
|
372
|
-
);
|
|
373
|
-
if (
|
|
374
|
-
txn.appGlobalByteSlices !== undefined &&
|
|
375
|
-
(!Number.isSafeInteger(txn.appGlobalByteSlices) ||
|
|
376
|
-
txn.appGlobalByteSlices < 0)
|
|
377
|
-
)
|
|
378
|
-
throw Error(
|
|
379
|
-
'Application global byte slices count must be a positive number and smaller than 2^53-1'
|
|
510
|
+
if (fieldsPresent.length !== 1) {
|
|
511
|
+
throw new Error(
|
|
512
|
+
`Transaction has wrong number of type fields present (${fieldsPresent.length}): ${fieldsPresent}`
|
|
380
513
|
);
|
|
381
|
-
if (txn.appApprovalProgram !== undefined) {
|
|
382
|
-
if (txn.appApprovalProgram.constructor !== Uint8Array)
|
|
383
|
-
throw Error('appApprovalProgram must be a Uint8Array.');
|
|
384
514
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
if (txn.appArgs !== undefined) {
|
|
390
|
-
if (!Array.isArray(txn.appArgs))
|
|
391
|
-
throw Error('appArgs must be an Array of Uint8Array.');
|
|
392
|
-
txn.appArgs = txn.appArgs.slice();
|
|
393
|
-
txn.appArgs.forEach((arg) => {
|
|
394
|
-
if (arg.constructor !== Uint8Array)
|
|
395
|
-
throw Error('each element of AppArgs must be a Uint8Array.');
|
|
396
|
-
});
|
|
397
|
-
} else {
|
|
398
|
-
txn.appArgs = [];
|
|
399
|
-
}
|
|
400
|
-
if (txn.appAccounts !== undefined) {
|
|
401
|
-
if (!Array.isArray(txn.appAccounts))
|
|
402
|
-
throw Error('appAccounts must be an Array of addresses.');
|
|
403
|
-
txn.appAccounts = txn.appAccounts.map((addressAsString) =>
|
|
404
|
-
address.decodeAddress(addressAsString)
|
|
515
|
+
|
|
516
|
+
if (this.type !== fieldsPresent[0]) {
|
|
517
|
+
throw new Error(
|
|
518
|
+
`Transaction has type ${this.type} but fields present for ${fieldsPresent[0]}`
|
|
405
519
|
);
|
|
406
520
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
if (txn.appForeignAssets !== undefined) {
|
|
419
|
-
if (!Array.isArray(txn.appForeignAssets))
|
|
420
|
-
throw Error('appForeignAssets must be an Array of integers.');
|
|
421
|
-
txn.appForeignAssets = txn.appForeignAssets.slice();
|
|
422
|
-
txn.appForeignAssets.forEach((foreignAssetIndex) => {
|
|
423
|
-
if (!Number.isSafeInteger(foreignAssetIndex) || foreignAssetIndex < 0)
|
|
424
|
-
throw Error(
|
|
425
|
-
'each foreign asset index must be a positive number and smaller than 2^53-1'
|
|
426
|
-
);
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
if (txn.boxes !== undefined) {
|
|
430
|
-
if (!Array.isArray(txn.boxes))
|
|
431
|
-
throw Error('boxes must be an Array of BoxReference.');
|
|
432
|
-
txn.boxes = txn.boxes.slice();
|
|
433
|
-
txn.boxes.forEach((box) => {
|
|
434
|
-
if (
|
|
435
|
-
!Number.isSafeInteger(box.appIndex) ||
|
|
436
|
-
box.name.constructor !== Uint8Array
|
|
437
|
-
)
|
|
438
|
-
throw Error(
|
|
439
|
-
'box app index must be a number and name must be an Uint8Array.'
|
|
440
|
-
);
|
|
441
|
-
});
|
|
521
|
+
|
|
522
|
+
if (params.paymentParams) {
|
|
523
|
+
this.payment = {
|
|
524
|
+
receiver: ensureAddress(params.paymentParams.receiver),
|
|
525
|
+
amount: utils.ensureUint64(params.paymentParams.amount),
|
|
526
|
+
closeRemainderTo: optionalAddress(
|
|
527
|
+
params.paymentParams.closeRemainderTo
|
|
528
|
+
),
|
|
529
|
+
};
|
|
442
530
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
531
|
+
|
|
532
|
+
if (params.keyregParams) {
|
|
533
|
+
this.keyreg = {
|
|
534
|
+
voteKey: getKeyregKey(
|
|
535
|
+
params.keyregParams.voteKey,
|
|
536
|
+
'voteKey',
|
|
537
|
+
KEYREG_VOTE_KEY_LENGTH
|
|
538
|
+
)!,
|
|
539
|
+
selectionKey: getKeyregKey(
|
|
540
|
+
params.keyregParams.selectionKey,
|
|
541
|
+
'selectionKey',
|
|
542
|
+
KEYREG_SELECTION_KEY_LENGTH
|
|
543
|
+
)!,
|
|
544
|
+
stateProofKey: getKeyregKey(
|
|
545
|
+
params.keyregParams.stateProofKey,
|
|
546
|
+
'stateProofKey',
|
|
547
|
+
KEYREG_STATE_PROOF_KEY_LENGTH
|
|
548
|
+
)!,
|
|
549
|
+
voteFirst: optionalUint64(params.keyregParams.voteFirst),
|
|
550
|
+
voteLast: optionalUint64(params.keyregParams.voteLast),
|
|
551
|
+
voteKeyDilution: optionalUint64(params.keyregParams.voteKeyDilution),
|
|
552
|
+
nonParticipation: ensureBoolean(
|
|
553
|
+
params.keyregParams.nonParticipation ?? false
|
|
554
|
+
),
|
|
555
|
+
};
|
|
556
|
+
// Checking non-participation key registration
|
|
557
|
+
if (
|
|
558
|
+
this.keyreg.nonParticipation &&
|
|
559
|
+
(this.keyreg.voteKey ||
|
|
560
|
+
this.keyreg.selectionKey ||
|
|
561
|
+
this.keyreg.stateProofKey ||
|
|
562
|
+
typeof this.keyreg.voteFirst !== 'undefined' ||
|
|
563
|
+
typeof this.keyreg.voteLast !== 'undefined' ||
|
|
564
|
+
typeof this.keyreg.voteKeyDilution !== 'undefined')
|
|
565
|
+
) {
|
|
566
|
+
throw new Error(
|
|
567
|
+
'nonParticipation is true but participation params are present.'
|
|
450
568
|
);
|
|
451
569
|
}
|
|
452
|
-
|
|
570
|
+
// Checking online key registration
|
|
453
571
|
if (
|
|
454
|
-
|
|
455
|
-
|
|
572
|
+
// If we are participating
|
|
573
|
+
!this.keyreg.nonParticipation &&
|
|
574
|
+
// And *ANY* participating fields are present
|
|
575
|
+
(this.keyreg.voteKey ||
|
|
576
|
+
this.keyreg.selectionKey ||
|
|
577
|
+
this.keyreg.stateProofKey ||
|
|
578
|
+
typeof this.keyreg.voteFirst !== 'undefined' ||
|
|
579
|
+
typeof this.keyreg.voteLast !== 'undefined' ||
|
|
580
|
+
typeof this.keyreg.voteKeyDilution !== 'undefined') &&
|
|
581
|
+
// Then *ALL* participating fields must be present (with an exception for stateProofKey,
|
|
582
|
+
// which was introduced later so for backwards compatibility we don't require it)
|
|
583
|
+
!(
|
|
584
|
+
this.keyreg.voteKey &&
|
|
585
|
+
this.keyreg.selectionKey &&
|
|
586
|
+
typeof this.keyreg.voteFirst !== 'undefined' &&
|
|
587
|
+
typeof this.keyreg.voteLast !== 'undefined' &&
|
|
588
|
+
typeof this.keyreg.voteKeyDilution !== 'undefined'
|
|
589
|
+
)
|
|
456
590
|
) {
|
|
457
|
-
throw Error(
|
|
458
|
-
`
|
|
591
|
+
throw new Error(
|
|
592
|
+
`Online key registration missing at least one of the following fields: voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution`
|
|
459
593
|
);
|
|
460
594
|
}
|
|
595
|
+
// The last option is an offline key registration where all the fields
|
|
596
|
+
// nonParticipation, voteKey, selectionKey, stateProofKey, voteFirst, voteLast, voteKeyDilution
|
|
597
|
+
// are all undefined
|
|
598
|
+
}
|
|
461
599
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
600
|
+
if (params.assetConfigParams) {
|
|
601
|
+
this.assetConfig = {
|
|
602
|
+
assetIndex: utils.ensureUint64(
|
|
603
|
+
params.assetConfigParams.assetIndex ?? 0
|
|
604
|
+
),
|
|
605
|
+
total: utils.ensureUint64(params.assetConfigParams.total ?? 0),
|
|
606
|
+
decimals: utils.ensureSafeUnsignedInteger(
|
|
607
|
+
params.assetConfigParams.decimals ?? 0
|
|
608
|
+
),
|
|
609
|
+
defaultFrozen: ensureBoolean(
|
|
610
|
+
params.assetConfigParams.defaultFrozen ?? false
|
|
611
|
+
),
|
|
612
|
+
manager: optionalAddress(params.assetConfigParams.manager),
|
|
613
|
+
reserve: optionalAddress(params.assetConfigParams.reserve),
|
|
614
|
+
freeze: optionalAddress(params.assetConfigParams.freeze),
|
|
615
|
+
clawback: optionalAddress(params.assetConfigParams.clawback),
|
|
616
|
+
unitName: params.assetConfigParams.unitName,
|
|
617
|
+
assetName: params.assetConfigParams.assetName,
|
|
618
|
+
assetURL: params.assetConfigParams.assetURL,
|
|
619
|
+
assetMetadataHash: optionalFixedLengthByteArray(
|
|
620
|
+
params.assetConfigParams.assetMetadataHash,
|
|
621
|
+
ASSET_METADATA_HASH_LENGTH,
|
|
622
|
+
'assetMetadataHash'
|
|
623
|
+
),
|
|
624
|
+
};
|
|
468
625
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
626
|
+
|
|
627
|
+
if (params.assetTransferParams) {
|
|
628
|
+
this.assetTransfer = {
|
|
629
|
+
assetIndex: utils.ensureUint64(params.assetTransferParams.assetIndex),
|
|
630
|
+
amount: utils.ensureUint64(params.assetTransferParams.amount),
|
|
631
|
+
assetSender: optionalAddress(params.assetTransferParams.assetSender),
|
|
632
|
+
receiver: ensureAddress(params.assetTransferParams.receiver),
|
|
633
|
+
closeRemainderTo: optionalAddress(
|
|
634
|
+
params.assetTransferParams.closeRemainderTo
|
|
635
|
+
),
|
|
636
|
+
};
|
|
474
637
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if (txn.lease.every((value) => value === 0)) {
|
|
483
|
-
// if lease contains all 0s, omit it
|
|
484
|
-
txn.lease = new Uint8Array(0);
|
|
485
|
-
}
|
|
486
|
-
} else {
|
|
487
|
-
txn.lease = new Uint8Array(0);
|
|
638
|
+
|
|
639
|
+
if (params.assetFreezeParams) {
|
|
640
|
+
this.assetFreeze = {
|
|
641
|
+
assetIndex: utils.ensureUint64(params.assetFreezeParams.assetIndex),
|
|
642
|
+
freezeAccount: ensureAddress(params.assetFreezeParams.freezeTarget),
|
|
643
|
+
frozen: ensureBoolean(params.assetFreezeParams.frozen),
|
|
644
|
+
};
|
|
488
645
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
646
|
+
|
|
647
|
+
if (params.appCallParams) {
|
|
648
|
+
const { onComplete } = params.appCallParams;
|
|
649
|
+
if (!isOnApplicationComplete(onComplete)) {
|
|
650
|
+
throw new Error(`Invalid onCompletion value: ${onComplete}`);
|
|
651
|
+
}
|
|
652
|
+
this.applicationCall = {
|
|
653
|
+
appIndex: utils.ensureUint64(params.appCallParams.appIndex),
|
|
654
|
+
onComplete,
|
|
655
|
+
numLocalInts: utils.ensureSafeUnsignedInteger(
|
|
656
|
+
params.appCallParams.numLocalInts ?? 0
|
|
657
|
+
),
|
|
658
|
+
numLocalByteSlices: utils.ensureSafeUnsignedInteger(
|
|
659
|
+
params.appCallParams.numLocalByteSlices ?? 0
|
|
660
|
+
),
|
|
661
|
+
numGlobalInts: utils.ensureSafeUnsignedInteger(
|
|
662
|
+
params.appCallParams.numGlobalInts ?? 0
|
|
663
|
+
),
|
|
664
|
+
numGlobalByteSlices: utils.ensureSafeUnsignedInteger(
|
|
665
|
+
params.appCallParams.numGlobalByteSlices ?? 0
|
|
666
|
+
),
|
|
667
|
+
extraPages: utils.ensureSafeUnsignedInteger(
|
|
668
|
+
params.appCallParams.extraPages ?? 0
|
|
669
|
+
),
|
|
670
|
+
approvalProgram: ensureUint8Array(
|
|
671
|
+
params.appCallParams.approvalProgram ?? new Uint8Array()
|
|
672
|
+
),
|
|
673
|
+
clearProgram: ensureUint8Array(
|
|
674
|
+
params.appCallParams.clearProgram ?? new Uint8Array()
|
|
675
|
+
),
|
|
676
|
+
appArgs: ensureArray(params.appCallParams.appArgs ?? []).map(
|
|
677
|
+
ensureUint8Array
|
|
678
|
+
),
|
|
679
|
+
accounts: ensureArray(params.appCallParams.accounts ?? []).map(
|
|
680
|
+
ensureAddress
|
|
681
|
+
),
|
|
682
|
+
foreignApps: ensureArray(params.appCallParams.foreignApps ?? []).map(
|
|
683
|
+
utils.ensureUint64
|
|
684
|
+
),
|
|
685
|
+
foreignAssets: ensureArray(
|
|
686
|
+
params.appCallParams.foreignAssets ?? []
|
|
687
|
+
).map(utils.ensureUint64),
|
|
688
|
+
boxes: ensureArray(params.appCallParams.boxes ?? []).map(
|
|
689
|
+
ensureBoxReference
|
|
690
|
+
),
|
|
691
|
+
};
|
|
513
692
|
}
|
|
514
|
-
|
|
515
|
-
if (
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
!(
|
|
524
|
-
txn.voteKey &&
|
|
525
|
-
txn.selectionKey &&
|
|
526
|
-
txn.voteFirst &&
|
|
527
|
-
txn.voteLast &&
|
|
528
|
-
txn.voteKeyDilution
|
|
529
|
-
)
|
|
530
|
-
// stateProofKey not included here for backwards compatibility
|
|
531
|
-
) {
|
|
532
|
-
throw new Error(
|
|
533
|
-
'online key registration missing at least one of the following fields: ' +
|
|
534
|
-
'voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution'
|
|
535
|
-
);
|
|
693
|
+
|
|
694
|
+
if (params.stateProofParams) {
|
|
695
|
+
this.stateProof = {
|
|
696
|
+
stateProofType: utils.ensureSafeUnsignedInteger(
|
|
697
|
+
params.stateProofParams.stateProofType ?? 0
|
|
698
|
+
),
|
|
699
|
+
stateProof: params.stateProofParams.stateProof,
|
|
700
|
+
message: params.stateProofParams.message,
|
|
701
|
+
};
|
|
536
702
|
}
|
|
537
|
-
// The last option is an offline key registration where all the fields
|
|
538
|
-
// nonParticipation, voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution
|
|
539
|
-
// are all undefined/false
|
|
540
703
|
|
|
541
|
-
//
|
|
542
|
-
|
|
543
|
-
Object.assign(this, utils.removeUndefinedProperties(txn));
|
|
704
|
+
// Determine fee
|
|
705
|
+
this.fee = utils.ensureUint64(params.suggestedParams.fee);
|
|
544
706
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
707
|
+
const feeDependsOnSize = !ensureBoolean(
|
|
708
|
+
params.suggestedParams.flatFee ?? false
|
|
709
|
+
);
|
|
710
|
+
if (feeDependsOnSize) {
|
|
711
|
+
const minFee = utils.ensureUint64(params.suggestedParams.minFee);
|
|
712
|
+
this.fee *= BigInt(this.estimateSize());
|
|
548
713
|
// If suggested fee too small and will be rejected, set to min tx fee
|
|
549
|
-
if (this.fee <
|
|
550
|
-
this.fee =
|
|
714
|
+
if (this.fee < minFee) {
|
|
715
|
+
this.fee = minFee;
|
|
551
716
|
}
|
|
552
717
|
}
|
|
718
|
+
}
|
|
553
719
|
|
|
554
|
-
|
|
555
|
-
|
|
720
|
+
// eslint-disable-next-line class-methods-use-this
|
|
721
|
+
getEncodingSchema(): encoding.Schema {
|
|
722
|
+
return Transaction.encodingSchema;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
toEncodingData(): Map<string, unknown> {
|
|
726
|
+
const data = new Map<string, unknown>([
|
|
727
|
+
['type', this.type],
|
|
728
|
+
['fv', this.firstValid],
|
|
729
|
+
['lv', this.lastValid],
|
|
730
|
+
['snd', this.sender],
|
|
731
|
+
['gen', this.genesisID],
|
|
732
|
+
['gh', this.genesisHash],
|
|
733
|
+
['fee', this.fee],
|
|
734
|
+
['note', this.note],
|
|
735
|
+
['lx', this.lease],
|
|
736
|
+
['rekey', this.rekeyTo],
|
|
737
|
+
['grp', this.group],
|
|
738
|
+
]);
|
|
739
|
+
|
|
740
|
+
if (this.payment) {
|
|
741
|
+
data.set('amt', this.payment.amount);
|
|
742
|
+
data.set('rcv', this.payment.receiver);
|
|
743
|
+
data.set('close', this.payment.closeRemainderTo);
|
|
744
|
+
return data;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
if (this.keyreg) {
|
|
748
|
+
data.set('votekey', this.keyreg.voteKey);
|
|
749
|
+
data.set('selkey', this.keyreg.selectionKey);
|
|
750
|
+
data.set('sprfkey', this.keyreg.stateProofKey);
|
|
751
|
+
data.set('votefst', this.keyreg.voteFirst);
|
|
752
|
+
data.set('votelst', this.keyreg.voteLast);
|
|
753
|
+
data.set('votekd', this.keyreg.voteKeyDilution);
|
|
754
|
+
data.set('nonpart', this.keyreg.nonParticipation);
|
|
755
|
+
return data;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
if (this.assetConfig) {
|
|
759
|
+
data.set('caid', this.assetConfig.assetIndex);
|
|
760
|
+
const assetParams = new Map<string, unknown>([
|
|
761
|
+
['t', this.assetConfig.total],
|
|
762
|
+
['dc', this.assetConfig.decimals],
|
|
763
|
+
['df', this.assetConfig.defaultFrozen],
|
|
764
|
+
['m', this.assetConfig.manager],
|
|
765
|
+
['r', this.assetConfig.reserve],
|
|
766
|
+
['f', this.assetConfig.freeze],
|
|
767
|
+
['c', this.assetConfig.clawback],
|
|
768
|
+
['un', this.assetConfig.unitName],
|
|
769
|
+
['an', this.assetConfig.assetName],
|
|
770
|
+
['au', this.assetConfig.assetURL],
|
|
771
|
+
['am', this.assetConfig.assetMetadataHash],
|
|
772
|
+
]);
|
|
773
|
+
data.set('apar', assetParams);
|
|
774
|
+
return data;
|
|
775
|
+
}
|
|
556
776
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
777
|
+
if (this.assetTransfer) {
|
|
778
|
+
data.set('xaid', this.assetTransfer.assetIndex);
|
|
779
|
+
data.set('aamt', this.assetTransfer.amount);
|
|
780
|
+
data.set('arcv', this.assetTransfer.receiver);
|
|
781
|
+
data.set('aclose', this.assetTransfer.closeRemainderTo);
|
|
782
|
+
data.set('asnd', this.assetTransfer.assetSender);
|
|
783
|
+
return data;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
if (this.assetFreeze) {
|
|
787
|
+
data.set('faid', this.assetFreeze.assetIndex);
|
|
788
|
+
data.set('afrz', this.assetFreeze.frozen);
|
|
789
|
+
data.set('fadd', this.assetFreeze.freezeAccount);
|
|
790
|
+
return data;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
if (this.applicationCall) {
|
|
794
|
+
data.set('apid', this.applicationCall.appIndex);
|
|
795
|
+
data.set('apan', this.applicationCall.onComplete);
|
|
796
|
+
data.set('apaa', this.applicationCall.appArgs);
|
|
797
|
+
data.set('apat', this.applicationCall.accounts);
|
|
798
|
+
data.set('apas', this.applicationCall.foreignAssets);
|
|
799
|
+
data.set('apfa', this.applicationCall.foreignApps);
|
|
800
|
+
data.set(
|
|
801
|
+
'apbx',
|
|
802
|
+
boxReferencesToEncodingData(
|
|
803
|
+
this.applicationCall.boxes,
|
|
804
|
+
this.applicationCall.foreignApps,
|
|
805
|
+
this.applicationCall.appIndex
|
|
806
|
+
)
|
|
564
807
|
);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
808
|
+
data.set('apap', this.applicationCall.approvalProgram);
|
|
809
|
+
data.set('apsu', this.applicationCall.clearProgram);
|
|
810
|
+
data.set(
|
|
811
|
+
'apls',
|
|
812
|
+
new Map<string, number>([
|
|
813
|
+
['nui', this.applicationCall.numLocalInts],
|
|
814
|
+
['nbs', this.applicationCall.numLocalByteSlices],
|
|
815
|
+
])
|
|
816
|
+
);
|
|
817
|
+
data.set(
|
|
818
|
+
'apgs',
|
|
819
|
+
new Map<string, number>([
|
|
820
|
+
['nui', this.applicationCall.numGlobalInts],
|
|
821
|
+
['nbs', this.applicationCall.numGlobalByteSlices],
|
|
822
|
+
])
|
|
823
|
+
);
|
|
824
|
+
data.set('apep', this.applicationCall.extraPages);
|
|
825
|
+
return data;
|
|
570
826
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
827
|
+
|
|
828
|
+
if (this.stateProof) {
|
|
829
|
+
data.set('sptype', this.stateProof.stateProofType);
|
|
830
|
+
data.set(
|
|
831
|
+
'sp',
|
|
832
|
+
this.stateProof.stateProof
|
|
833
|
+
? this.stateProof.stateProof.toEncodingData()
|
|
834
|
+
: undefined
|
|
835
|
+
);
|
|
836
|
+
data.set(
|
|
837
|
+
'spmsg',
|
|
838
|
+
this.stateProof.message
|
|
839
|
+
? this.stateProof.message.toEncodingData()
|
|
840
|
+
: undefined
|
|
841
|
+
);
|
|
842
|
+
return data;
|
|
576
843
|
}
|
|
577
|
-
}
|
|
578
844
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
if (this.type === 'pay') {
|
|
582
|
-
const txn: EncodedTransaction = {
|
|
583
|
-
amt: this.amount,
|
|
584
|
-
fee: this.fee,
|
|
585
|
-
fv: this.firstRound,
|
|
586
|
-
lv: this.lastRound,
|
|
587
|
-
note: Buffer.from(this.note),
|
|
588
|
-
snd: Buffer.from(this.from.publicKey),
|
|
589
|
-
type: 'pay',
|
|
590
|
-
gen: this.genesisID,
|
|
591
|
-
gh: this.genesisHash,
|
|
592
|
-
lx: Buffer.from(this.lease),
|
|
593
|
-
grp: this.group,
|
|
594
|
-
};
|
|
845
|
+
throw new Error(`Unexpected transaction type: ${this.type}`);
|
|
846
|
+
}
|
|
595
847
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
address.encodeAddress(this.closeRemainderTo.publicKey) !==
|
|
600
|
-
address.ALGORAND_ZERO_ADDRESS_STRING
|
|
601
|
-
) {
|
|
602
|
-
txn.close = Buffer.from(this.closeRemainderTo.publicKey);
|
|
603
|
-
}
|
|
604
|
-
if (this.reKeyTo !== undefined) {
|
|
605
|
-
txn.rekey = Buffer.from(this.reKeyTo.publicKey);
|
|
606
|
-
}
|
|
607
|
-
// allowed zero values
|
|
608
|
-
if (this.to !== undefined) txn.rcv = Buffer.from(this.to.publicKey);
|
|
609
|
-
if (!txn.note.length) delete txn.note;
|
|
610
|
-
if (!txn.amt) delete txn.amt;
|
|
611
|
-
if (!txn.fee) delete txn.fee;
|
|
612
|
-
if (!txn.fv) delete txn.fv;
|
|
613
|
-
if (!txn.gen) delete txn.gen;
|
|
614
|
-
if (txn.grp === undefined) delete txn.grp;
|
|
615
|
-
if (!txn.lx.length) delete txn.lx;
|
|
616
|
-
if (!txn.rekey) delete txn.rekey;
|
|
617
|
-
return txn;
|
|
848
|
+
static fromEncodingData(data: unknown): Transaction {
|
|
849
|
+
if (!(data instanceof Map)) {
|
|
850
|
+
throw new Error(`Invalid decoded logic sig account: ${data}`);
|
|
618
851
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
selkey: this.selectionKey,
|
|
633
|
-
sprfkey: this.stateProofKey,
|
|
634
|
-
votefst: this.voteFirst,
|
|
635
|
-
votelst: this.voteLast,
|
|
636
|
-
votekd: this.voteKeyDilution,
|
|
637
|
-
};
|
|
638
|
-
// allowed zero values
|
|
639
|
-
if (!txn.note.length) delete txn.note;
|
|
640
|
-
if (!txn.lx.length) delete txn.lx;
|
|
641
|
-
if (!txn.fee) delete txn.fee;
|
|
642
|
-
if (!txn.fv) delete txn.fv;
|
|
643
|
-
if (!txn.gen) delete txn.gen;
|
|
644
|
-
if (txn.grp === undefined) delete txn.grp;
|
|
645
|
-
if (this.reKeyTo !== undefined) {
|
|
646
|
-
txn.rekey = Buffer.from(this.reKeyTo.publicKey);
|
|
647
|
-
}
|
|
648
|
-
if (this.nonParticipation) {
|
|
649
|
-
txn.nonpart = true;
|
|
650
|
-
}
|
|
651
|
-
if (!txn.selkey) delete txn.selkey;
|
|
652
|
-
if (!txn.votekey) delete txn.votekey;
|
|
653
|
-
if (!txn.sprfkey) delete txn.sprfkey;
|
|
654
|
-
if (!txn.votefst) delete txn.votefst;
|
|
655
|
-
if (!txn.votelst) delete txn.votelst;
|
|
656
|
-
if (!txn.votekd) delete txn.votekd;
|
|
657
|
-
return txn;
|
|
852
|
+
const suggestedParams: SuggestedParams = {
|
|
853
|
+
minFee: BigInt(0),
|
|
854
|
+
flatFee: true,
|
|
855
|
+
fee: data.get('fee') ?? 0,
|
|
856
|
+
firstValid: data.get('fv') ?? 0,
|
|
857
|
+
lastValid: data.get('lv') ?? 0,
|
|
858
|
+
genesisHash: data.get('gh'),
|
|
859
|
+
genesisID: data.get('gen'),
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
const txnType = data.get('type');
|
|
863
|
+
if (!isTransactionType(txnType)) {
|
|
864
|
+
throw new Error(`Unrecognized transaction type: ${txnType}`);
|
|
658
865
|
}
|
|
659
|
-
if (this.type === 'acfg') {
|
|
660
|
-
// asset creation, or asset reconfigure, or asset destruction
|
|
661
|
-
const txn: EncodedTransaction = {
|
|
662
|
-
fee: this.fee,
|
|
663
|
-
fv: this.firstRound,
|
|
664
|
-
lv: this.lastRound,
|
|
665
|
-
note: Buffer.from(this.note),
|
|
666
|
-
snd: Buffer.from(this.from.publicKey),
|
|
667
|
-
type: this.type,
|
|
668
|
-
gen: this.genesisID,
|
|
669
|
-
gh: this.genesisHash,
|
|
670
|
-
lx: Buffer.from(this.lease),
|
|
671
|
-
grp: this.group,
|
|
672
|
-
caid: this.assetIndex,
|
|
673
|
-
apar: {
|
|
674
|
-
t: this.assetTotal,
|
|
675
|
-
df: this.assetDefaultFrozen,
|
|
676
|
-
dc: this.assetDecimals,
|
|
677
|
-
},
|
|
678
|
-
};
|
|
679
|
-
if (this.assetManager !== undefined)
|
|
680
|
-
txn.apar.m = Buffer.from(this.assetManager.publicKey);
|
|
681
|
-
if (this.assetReserve !== undefined)
|
|
682
|
-
txn.apar.r = Buffer.from(this.assetReserve.publicKey);
|
|
683
|
-
if (this.assetFreeze !== undefined)
|
|
684
|
-
txn.apar.f = Buffer.from(this.assetFreeze.publicKey);
|
|
685
|
-
if (this.assetClawback !== undefined)
|
|
686
|
-
txn.apar.c = Buffer.from(this.assetClawback.publicKey);
|
|
687
|
-
if (this.assetName !== undefined) txn.apar.an = this.assetName;
|
|
688
|
-
if (this.assetUnitName !== undefined) txn.apar.un = this.assetUnitName;
|
|
689
|
-
if (this.assetURL !== undefined) txn.apar.au = this.assetURL;
|
|
690
|
-
if (this.assetMetadataHash !== undefined)
|
|
691
|
-
txn.apar.am = Buffer.from(this.assetMetadataHash);
|
|
692
|
-
|
|
693
|
-
// allowed zero values
|
|
694
|
-
if (!txn.note.length) delete txn.note;
|
|
695
|
-
if (!txn.lx.length) delete txn.lx;
|
|
696
|
-
if (!txn.amt) delete txn.amt;
|
|
697
|
-
if (!txn.fee) delete txn.fee;
|
|
698
|
-
if (!txn.fv) delete txn.fv;
|
|
699
|
-
if (!txn.gen) delete txn.gen;
|
|
700
|
-
if (this.reKeyTo !== undefined) {
|
|
701
|
-
txn.rekey = Buffer.from(this.reKeyTo.publicKey);
|
|
702
|
-
}
|
|
703
866
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
!txn.apar.r &&
|
|
712
|
-
!txn.apar.f &&
|
|
713
|
-
!txn.apar.c &&
|
|
714
|
-
!txn.apar.au &&
|
|
715
|
-
!txn.apar.am &&
|
|
716
|
-
!txn.apar.dc
|
|
717
|
-
) {
|
|
718
|
-
delete txn.apar;
|
|
719
|
-
} else {
|
|
720
|
-
if (!txn.apar.t) delete txn.apar.t;
|
|
721
|
-
if (!txn.apar.dc) delete txn.apar.dc;
|
|
722
|
-
if (!txn.apar.un) delete txn.apar.un;
|
|
723
|
-
if (!txn.apar.an) delete txn.apar.an;
|
|
724
|
-
if (!txn.apar.df) delete txn.apar.df;
|
|
725
|
-
if (!txn.apar.m) delete txn.apar.m;
|
|
726
|
-
if (!txn.apar.r) delete txn.apar.r;
|
|
727
|
-
if (!txn.apar.f) delete txn.apar.f;
|
|
728
|
-
if (!txn.apar.c) delete txn.apar.c;
|
|
729
|
-
if (!txn.apar.au) delete txn.apar.au;
|
|
730
|
-
if (!txn.apar.am) delete txn.apar.am;
|
|
731
|
-
}
|
|
732
|
-
if (txn.grp === undefined) delete txn.grp;
|
|
867
|
+
const params: TransactionParams = {
|
|
868
|
+
type: txnType,
|
|
869
|
+
sender: data.get('snd') ?? Address.zeroAddress(),
|
|
870
|
+
note: data.get('note'),
|
|
871
|
+
lease: data.get('lx'),
|
|
872
|
+
suggestedParams,
|
|
873
|
+
};
|
|
733
874
|
|
|
734
|
-
|
|
875
|
+
if (data.get('rekey')) {
|
|
876
|
+
params.rekeyTo = data.get('rekey');
|
|
735
877
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
fv: this.firstRound,
|
|
742
|
-
lv: this.lastRound,
|
|
743
|
-
note: Buffer.from(this.note),
|
|
744
|
-
snd: Buffer.from(this.from.publicKey),
|
|
745
|
-
arcv: Buffer.from(this.to.publicKey),
|
|
746
|
-
type: this.type,
|
|
747
|
-
gen: this.genesisID,
|
|
748
|
-
gh: this.genesisHash,
|
|
749
|
-
lx: Buffer.from(this.lease),
|
|
750
|
-
grp: this.group,
|
|
751
|
-
xaid: this.assetIndex,
|
|
878
|
+
|
|
879
|
+
if (params.type === TransactionType.pay) {
|
|
880
|
+
const paymentParams: PaymentTransactionParams = {
|
|
881
|
+
amount: data.get('amt') ?? 0,
|
|
882
|
+
receiver: data.get('rcv') ?? Address.zeroAddress(),
|
|
752
883
|
};
|
|
753
|
-
if (
|
|
754
|
-
|
|
755
|
-
if (this.assetRevocationTarget !== undefined)
|
|
756
|
-
txn.asnd = Buffer.from(this.assetRevocationTarget.publicKey);
|
|
757
|
-
// allowed zero values
|
|
758
|
-
if (!txn.note.length) delete txn.note;
|
|
759
|
-
if (!txn.lx.length) delete txn.lx;
|
|
760
|
-
if (!txn.aamt) delete txn.aamt;
|
|
761
|
-
if (!txn.amt) delete txn.amt;
|
|
762
|
-
if (!txn.fee) delete txn.fee;
|
|
763
|
-
if (!txn.fv) delete txn.fv;
|
|
764
|
-
if (!txn.gen) delete txn.gen;
|
|
765
|
-
if (txn.grp === undefined) delete txn.grp;
|
|
766
|
-
if (!txn.aclose) delete txn.aclose;
|
|
767
|
-
if (!txn.asnd) delete txn.asnd;
|
|
768
|
-
if (!txn.rekey) delete txn.rekey;
|
|
769
|
-
if (this.reKeyTo !== undefined) {
|
|
770
|
-
txn.rekey = Buffer.from(this.reKeyTo.publicKey);
|
|
884
|
+
if (data.get('close')) {
|
|
885
|
+
paymentParams.closeRemainderTo = data.get('close');
|
|
771
886
|
}
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
type: this.type,
|
|
783
|
-
gen: this.genesisID,
|
|
784
|
-
gh: this.genesisHash,
|
|
785
|
-
lx: Buffer.from(this.lease),
|
|
786
|
-
grp: this.group,
|
|
787
|
-
faid: this.assetIndex,
|
|
788
|
-
afrz: this.freezeState,
|
|
887
|
+
params.paymentParams = paymentParams;
|
|
888
|
+
} else if (params.type === TransactionType.keyreg) {
|
|
889
|
+
const keyregParams: KeyRegistrationTransactionParams = {
|
|
890
|
+
voteKey: data.get('votekey'),
|
|
891
|
+
selectionKey: data.get('selkey'),
|
|
892
|
+
stateProofKey: data.get('sprfkey'),
|
|
893
|
+
voteFirst: data.get('votefst'),
|
|
894
|
+
voteLast: data.get('votelst'),
|
|
895
|
+
voteKeyDilution: data.get('votekd'),
|
|
896
|
+
nonParticipation: data.get('nonpart'),
|
|
789
897
|
};
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
if (!txn.lx.length) delete txn.lx;
|
|
795
|
-
if (!txn.amt) delete txn.amt;
|
|
796
|
-
if (!txn.fee) delete txn.fee;
|
|
797
|
-
if (!txn.fv) delete txn.fv;
|
|
798
|
-
if (!txn.gen) delete txn.gen;
|
|
799
|
-
if (!txn.afrz) delete txn.afrz;
|
|
800
|
-
if (txn.grp === undefined) delete txn.grp;
|
|
801
|
-
if (this.reKeyTo !== undefined) {
|
|
802
|
-
txn.rekey = Buffer.from(this.reKeyTo.publicKey);
|
|
803
|
-
}
|
|
804
|
-
return txn;
|
|
805
|
-
}
|
|
806
|
-
if (this.type === 'appl') {
|
|
807
|
-
// application call of some kind
|
|
808
|
-
const txn: EncodedTransaction = {
|
|
809
|
-
fee: this.fee,
|
|
810
|
-
fv: this.firstRound,
|
|
811
|
-
lv: this.lastRound,
|
|
812
|
-
note: Buffer.from(this.note),
|
|
813
|
-
snd: Buffer.from(this.from.publicKey),
|
|
814
|
-
type: this.type,
|
|
815
|
-
gen: this.genesisID,
|
|
816
|
-
gh: this.genesisHash,
|
|
817
|
-
lx: Buffer.from(this.lease),
|
|
818
|
-
grp: this.group,
|
|
819
|
-
apid: this.appIndex,
|
|
820
|
-
apan: this.appOnComplete,
|
|
821
|
-
apls: {
|
|
822
|
-
nui: this.appLocalInts,
|
|
823
|
-
nbs: this.appLocalByteSlices,
|
|
824
|
-
},
|
|
825
|
-
apgs: {
|
|
826
|
-
nui: this.appGlobalInts,
|
|
827
|
-
nbs: this.appGlobalByteSlices,
|
|
828
|
-
},
|
|
829
|
-
apfa: this.appForeignApps,
|
|
830
|
-
apas: this.appForeignAssets,
|
|
831
|
-
apep: this.extraPages,
|
|
832
|
-
apbx: translateBoxReferences(
|
|
833
|
-
this.boxes,
|
|
834
|
-
this.appForeignApps,
|
|
835
|
-
this.appIndex
|
|
836
|
-
),
|
|
898
|
+
params.keyregParams = keyregParams;
|
|
899
|
+
} else if (params.type === TransactionType.acfg) {
|
|
900
|
+
const assetConfigParams: AssetConfigurationTransactionParams = {
|
|
901
|
+
assetIndex: data.get('caid'),
|
|
837
902
|
};
|
|
838
|
-
if (
|
|
839
|
-
|
|
903
|
+
if (data.get('apar')) {
|
|
904
|
+
const assetParams = data.get('apar') as Map<string, any>;
|
|
905
|
+
assetConfigParams.total = assetParams.get('t');
|
|
906
|
+
assetConfigParams.decimals = assetParams.get('dc');
|
|
907
|
+
assetConfigParams.defaultFrozen = assetParams.get('df');
|
|
908
|
+
assetConfigParams.unitName = assetParams.get('un');
|
|
909
|
+
assetConfigParams.assetName = assetParams.get('an');
|
|
910
|
+
assetConfigParams.assetURL = assetParams.get('au');
|
|
911
|
+
assetConfigParams.assetMetadataHash = assetParams.get('am');
|
|
912
|
+
if (assetParams.get('m')) {
|
|
913
|
+
assetConfigParams.manager = assetParams.get('m');
|
|
914
|
+
}
|
|
915
|
+
if (assetParams.get('r')) {
|
|
916
|
+
assetConfigParams.reserve = assetParams.get('r');
|
|
917
|
+
}
|
|
918
|
+
if (assetParams.get('f')) {
|
|
919
|
+
assetConfigParams.freeze = assetParams.get('f');
|
|
920
|
+
}
|
|
921
|
+
if (assetParams.get('c')) {
|
|
922
|
+
assetConfigParams.clawback = assetParams.get('c');
|
|
923
|
+
}
|
|
840
924
|
}
|
|
841
|
-
|
|
842
|
-
|
|
925
|
+
params.assetConfigParams = assetConfigParams;
|
|
926
|
+
} else if (params.type === TransactionType.axfer) {
|
|
927
|
+
const assetTransferParams: AssetTransferTransactionParams = {
|
|
928
|
+
assetIndex: data.get('xaid') ?? 0,
|
|
929
|
+
amount: data.get('aamt') ?? 0,
|
|
930
|
+
receiver: data.get('arcv') ?? Address.zeroAddress(),
|
|
931
|
+
};
|
|
932
|
+
if (data.get('aclose')) {
|
|
933
|
+
assetTransferParams.closeRemainderTo = data.get('aclose');
|
|
843
934
|
}
|
|
844
|
-
if (
|
|
845
|
-
|
|
935
|
+
if (data.get('asnd')) {
|
|
936
|
+
assetTransferParams.assetSender = data.get('asnd');
|
|
846
937
|
}
|
|
847
|
-
|
|
848
|
-
|
|
938
|
+
params.assetTransferParams = assetTransferParams;
|
|
939
|
+
} else if (params.type === TransactionType.afrz) {
|
|
940
|
+
const assetFreezeParams: AssetFreezeTransactionParams = {
|
|
941
|
+
assetIndex: data.get('faid') ?? 0,
|
|
942
|
+
freezeTarget: data.get('fadd') ?? Address.zeroAddress(),
|
|
943
|
+
frozen: data.get('afrz') ?? false,
|
|
944
|
+
};
|
|
945
|
+
params.assetFreezeParams = assetFreezeParams;
|
|
946
|
+
} else if (params.type === TransactionType.appl) {
|
|
947
|
+
const appCallParams: ApplicationCallTransactionParams = {
|
|
948
|
+
appIndex: data.get('apid') ?? 0,
|
|
949
|
+
onComplete: utils.ensureSafeUnsignedInteger(data.get('apan') ?? 0),
|
|
950
|
+
appArgs: data.get('apaa'),
|
|
951
|
+
accounts: data.get('apat'),
|
|
952
|
+
foreignAssets: data.get('apas'),
|
|
953
|
+
foreignApps: data.get('apfa'),
|
|
954
|
+
approvalProgram: data.get('apap'),
|
|
955
|
+
clearProgram: data.get('apsu'),
|
|
956
|
+
extraPages: data.get('apep'),
|
|
957
|
+
};
|
|
958
|
+
const localSchema = data.get('apls') as Map<string, number> | undefined;
|
|
959
|
+
if (localSchema) {
|
|
960
|
+
appCallParams.numLocalInts = localSchema.get('nui');
|
|
961
|
+
appCallParams.numLocalByteSlices = localSchema.get('nbs');
|
|
849
962
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
);
|
|
963
|
+
const globalSchema = data.get('apgs') as Map<string, number> | undefined;
|
|
964
|
+
if (globalSchema) {
|
|
965
|
+
appCallParams.numGlobalInts = globalSchema.get('nui');
|
|
966
|
+
appCallParams.numGlobalByteSlices = globalSchema.get('nbs');
|
|
854
967
|
}
|
|
855
|
-
|
|
856
|
-
if (
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
968
|
+
const boxes = data.get('apbx') as Array<Map<string, unknown>> | undefined;
|
|
969
|
+
if (boxes) {
|
|
970
|
+
appCallParams.boxes = boxes.map((box) => {
|
|
971
|
+
const index = utils.ensureSafeUnsignedInteger(box.get('i') ?? 0);
|
|
972
|
+
const name = ensureUint8Array(box.get('n') ?? new Uint8Array());
|
|
973
|
+
if (index === 0) {
|
|
974
|
+
// We return 0 for the app ID so that it's guaranteed translateBoxReferences will
|
|
975
|
+
// translate the app index back to 0. If we instead returned the called app ID,
|
|
976
|
+
// translateBoxReferences would translate the app index to a nonzero value if the called
|
|
977
|
+
// app is also in the foreign app array.
|
|
978
|
+
return {
|
|
979
|
+
appIndex: 0,
|
|
980
|
+
name,
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
if (
|
|
984
|
+
!appCallParams.foreignApps ||
|
|
985
|
+
index > appCallParams.foreignApps.length
|
|
986
|
+
) {
|
|
987
|
+
throw new Error(
|
|
988
|
+
`Cannot find foreign app index ${index} in ${appCallParams.foreignApps}`
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
return {
|
|
992
|
+
appIndex: appCallParams.foreignApps[index - 1],
|
|
993
|
+
name,
|
|
994
|
+
};
|
|
995
|
+
});
|
|
878
996
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
fv: this.firstRound,
|
|
890
|
-
lv: this.lastRound,
|
|
891
|
-
note: Buffer.from(this.note),
|
|
892
|
-
snd: Buffer.from(this.from.publicKey),
|
|
893
|
-
type: this.type,
|
|
894
|
-
gen: this.genesisID,
|
|
895
|
-
gh: this.genesisHash,
|
|
896
|
-
lx: Buffer.from(this.lease),
|
|
897
|
-
sptype: this.stateProofType,
|
|
898
|
-
spmsg: Buffer.from(this.stateProofMessage),
|
|
899
|
-
sp: Buffer.from(this.stateProof),
|
|
997
|
+
params.appCallParams = appCallParams;
|
|
998
|
+
} else if (params.type === TransactionType.stpf) {
|
|
999
|
+
const stateProofParams: StateProofTransactionParams = {
|
|
1000
|
+
stateProofType: data.get('sptype'),
|
|
1001
|
+
stateProof: data.get('sp')
|
|
1002
|
+
? StateProof.fromEncodingData(data.get('sp'))
|
|
1003
|
+
: undefined,
|
|
1004
|
+
message: data.get('spmsg')
|
|
1005
|
+
? StateProofMessage.fromEncodingData(data.get('spmsg'))
|
|
1006
|
+
: undefined,
|
|
900
1007
|
};
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (!txn.amt) delete txn.amt;
|
|
906
|
-
if (!txn.fee) delete txn.fee;
|
|
907
|
-
if (!txn.fv) delete txn.fv;
|
|
908
|
-
if (!txn.gen) delete txn.gen;
|
|
909
|
-
if (!txn.apid) delete txn.apid;
|
|
910
|
-
if (!txn.apaa || !txn.apaa.length) delete txn.apaa;
|
|
911
|
-
if (!txn.apap) delete txn.apap;
|
|
912
|
-
if (!txn.apsu) delete txn.apsu;
|
|
913
|
-
if (!txn.apan) delete txn.apan;
|
|
914
|
-
if (!txn.apfa || !txn.apfa.length) delete txn.apfa;
|
|
915
|
-
if (!txn.apas || !txn.apas.length) delete txn.apas;
|
|
916
|
-
if (!txn.apat || !txn.apat.length) delete txn.apat;
|
|
917
|
-
if (!txn.apep) delete txn.apep;
|
|
918
|
-
if (txn.grp === undefined) delete txn.grp;
|
|
919
|
-
return txn;
|
|
1008
|
+
params.stateProofParams = stateProofParams;
|
|
1009
|
+
} else {
|
|
1010
|
+
const exhaustiveCheck: never = params.type;
|
|
1011
|
+
throw new Error(`Unexpected transaction type: ${exhaustiveCheck}`);
|
|
920
1012
|
}
|
|
921
1013
|
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
// eslint-disable-next-line camelcase
|
|
926
|
-
static from_obj_for_encoding(txnForEnc: EncodedTransaction): Transaction {
|
|
927
|
-
const txn = Object.create(this.prototype) as Transaction;
|
|
928
|
-
txn.name = 'Transaction';
|
|
929
|
-
txn.tag = Buffer.from('TX');
|
|
1014
|
+
const txn = new Transaction(params);
|
|
930
1015
|
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
936
|
-
txn.type = txnForEnc.type;
|
|
937
|
-
txn.fee = txnForEnc.fee;
|
|
938
|
-
txn.firstRound = txnForEnc.fv;
|
|
939
|
-
txn.lastRound = txnForEnc.lv;
|
|
940
|
-
txn.note = new Uint8Array(txnForEnc.note);
|
|
941
|
-
txn.lease = new Uint8Array(txnForEnc.lx);
|
|
942
|
-
txn.from = address.decodeAddress(
|
|
943
|
-
address.encodeAddress(new Uint8Array(txnForEnc.snd))
|
|
944
|
-
);
|
|
945
|
-
if (txnForEnc.grp !== undefined) txn.group = Buffer.from(txnForEnc.grp);
|
|
946
|
-
if (txnForEnc.rekey !== undefined)
|
|
947
|
-
txn.reKeyTo = address.decodeAddress(
|
|
948
|
-
address.encodeAddress(new Uint8Array(txnForEnc.rekey))
|
|
949
|
-
);
|
|
950
|
-
|
|
951
|
-
if (txnForEnc.type === 'pay') {
|
|
952
|
-
txn.amount = txnForEnc.amt;
|
|
953
|
-
txn.to = address.decodeAddress(
|
|
954
|
-
address.encodeAddress(new Uint8Array(txnForEnc.rcv))
|
|
955
|
-
);
|
|
956
|
-
if (txnForEnc.close !== undefined)
|
|
957
|
-
txn.closeRemainderTo = address.decodeAddress(
|
|
958
|
-
address.encodeAddress(txnForEnc.close)
|
|
959
|
-
);
|
|
960
|
-
} else if (txnForEnc.type === 'keyreg') {
|
|
961
|
-
if (txnForEnc.votekey !== undefined) {
|
|
962
|
-
txn.voteKey = Buffer.from(txnForEnc.votekey);
|
|
963
|
-
}
|
|
964
|
-
if (txnForEnc.selkey !== undefined) {
|
|
965
|
-
txn.selectionKey = Buffer.from(txnForEnc.selkey);
|
|
966
|
-
}
|
|
967
|
-
if (txnForEnc.sprfkey !== undefined) {
|
|
968
|
-
txn.stateProofKey = Buffer.from(txnForEnc.sprfkey);
|
|
969
|
-
}
|
|
970
|
-
if (txnForEnc.votekd !== undefined) {
|
|
971
|
-
txn.voteKeyDilution = txnForEnc.votekd;
|
|
972
|
-
}
|
|
973
|
-
if (txnForEnc.votefst !== undefined) {
|
|
974
|
-
txn.voteFirst = txnForEnc.votefst;
|
|
975
|
-
}
|
|
976
|
-
if (txnForEnc.votelst !== undefined) {
|
|
977
|
-
txn.voteLast = txnForEnc.votelst;
|
|
978
|
-
}
|
|
979
|
-
if (txnForEnc.nonpart !== undefined) {
|
|
980
|
-
txn.nonParticipation = txnForEnc.nonpart;
|
|
981
|
-
}
|
|
982
|
-
} else if (txnForEnc.type === 'acfg') {
|
|
983
|
-
// asset creation, or asset reconfigure, or asset destruction
|
|
984
|
-
if (txnForEnc.caid !== undefined) {
|
|
985
|
-
txn.assetIndex = txnForEnc.caid;
|
|
986
|
-
}
|
|
987
|
-
if (txnForEnc.apar !== undefined) {
|
|
988
|
-
txn.assetTotal = txnForEnc.apar.t;
|
|
989
|
-
txn.assetDefaultFrozen = txnForEnc.apar.df;
|
|
990
|
-
if (txnForEnc.apar.dc !== undefined)
|
|
991
|
-
txn.assetDecimals = txnForEnc.apar.dc;
|
|
992
|
-
if (txnForEnc.apar.m !== undefined)
|
|
993
|
-
txn.assetManager = address.decodeAddress(
|
|
994
|
-
address.encodeAddress(new Uint8Array(txnForEnc.apar.m))
|
|
995
|
-
);
|
|
996
|
-
if (txnForEnc.apar.r !== undefined)
|
|
997
|
-
txn.assetReserve = address.decodeAddress(
|
|
998
|
-
address.encodeAddress(new Uint8Array(txnForEnc.apar.r))
|
|
999
|
-
);
|
|
1000
|
-
if (txnForEnc.apar.f !== undefined)
|
|
1001
|
-
txn.assetFreeze = address.decodeAddress(
|
|
1002
|
-
address.encodeAddress(new Uint8Array(txnForEnc.apar.f))
|
|
1003
|
-
);
|
|
1004
|
-
if (txnForEnc.apar.c !== undefined)
|
|
1005
|
-
txn.assetClawback = address.decodeAddress(
|
|
1006
|
-
address.encodeAddress(new Uint8Array(txnForEnc.apar.c))
|
|
1007
|
-
);
|
|
1008
|
-
if (txnForEnc.apar.un !== undefined)
|
|
1009
|
-
txn.assetUnitName = txnForEnc.apar.un;
|
|
1010
|
-
if (txnForEnc.apar.an !== undefined) txn.assetName = txnForEnc.apar.an;
|
|
1011
|
-
if (txnForEnc.apar.au !== undefined) txn.assetURL = txnForEnc.apar.au;
|
|
1012
|
-
if (txnForEnc.apar.am !== undefined)
|
|
1013
|
-
txn.assetMetadataHash = txnForEnc.apar.am;
|
|
1014
|
-
}
|
|
1015
|
-
} else if (txnForEnc.type === 'axfer') {
|
|
1016
|
-
// asset transfer, acceptance, revocation, mint, or burn
|
|
1017
|
-
if (txnForEnc.xaid !== undefined) {
|
|
1018
|
-
txn.assetIndex = txnForEnc.xaid;
|
|
1019
|
-
}
|
|
1020
|
-
if (txnForEnc.aamt !== undefined) txn.amount = txnForEnc.aamt;
|
|
1021
|
-
if (txnForEnc.aclose !== undefined) {
|
|
1022
|
-
txn.closeRemainderTo = address.decodeAddress(
|
|
1023
|
-
address.encodeAddress(new Uint8Array(txnForEnc.aclose))
|
|
1024
|
-
);
|
|
1025
|
-
}
|
|
1026
|
-
if (txnForEnc.asnd !== undefined) {
|
|
1027
|
-
txn.assetRevocationTarget = address.decodeAddress(
|
|
1028
|
-
address.encodeAddress(new Uint8Array(txnForEnc.asnd))
|
|
1029
|
-
);
|
|
1030
|
-
}
|
|
1031
|
-
txn.to = address.decodeAddress(
|
|
1032
|
-
address.encodeAddress(new Uint8Array(txnForEnc.arcv))
|
|
1033
|
-
);
|
|
1034
|
-
} else if (txnForEnc.type === 'afrz') {
|
|
1035
|
-
if (txnForEnc.afrz !== undefined) {
|
|
1036
|
-
txn.freezeState = txnForEnc.afrz;
|
|
1037
|
-
}
|
|
1038
|
-
if (txnForEnc.faid !== undefined) {
|
|
1039
|
-
txn.assetIndex = txnForEnc.faid;
|
|
1040
|
-
}
|
|
1041
|
-
txn.freezeAccount = address.decodeAddress(
|
|
1042
|
-
address.encodeAddress(new Uint8Array(txnForEnc.fadd))
|
|
1043
|
-
);
|
|
1044
|
-
} else if (txnForEnc.type === 'appl') {
|
|
1045
|
-
if (txnForEnc.apid !== undefined) {
|
|
1046
|
-
txn.appIndex = txnForEnc.apid;
|
|
1047
|
-
}
|
|
1048
|
-
if (txnForEnc.apan !== undefined) {
|
|
1049
|
-
txn.appOnComplete = txnForEnc.apan;
|
|
1050
|
-
}
|
|
1051
|
-
if (txnForEnc.apls !== undefined) {
|
|
1052
|
-
if (txnForEnc.apls.nui !== undefined)
|
|
1053
|
-
txn.appLocalInts = txnForEnc.apls.nui;
|
|
1054
|
-
if (txnForEnc.apls.nbs !== undefined)
|
|
1055
|
-
txn.appLocalByteSlices = txnForEnc.apls.nbs;
|
|
1056
|
-
}
|
|
1057
|
-
if (txnForEnc.apgs !== undefined) {
|
|
1058
|
-
if (txnForEnc.apgs.nui !== undefined)
|
|
1059
|
-
txn.appGlobalInts = txnForEnc.apgs.nui;
|
|
1060
|
-
if (txnForEnc.apgs.nbs !== undefined)
|
|
1061
|
-
txn.appGlobalByteSlices = txnForEnc.apgs.nbs;
|
|
1062
|
-
}
|
|
1063
|
-
if (txnForEnc.apep !== undefined) {
|
|
1064
|
-
txn.extraPages = txnForEnc.apep;
|
|
1065
|
-
}
|
|
1066
|
-
if (txnForEnc.apap !== undefined) {
|
|
1067
|
-
txn.appApprovalProgram = new Uint8Array(txnForEnc.apap);
|
|
1068
|
-
}
|
|
1069
|
-
if (txnForEnc.apsu !== undefined) {
|
|
1070
|
-
txn.appClearProgram = new Uint8Array(txnForEnc.apsu);
|
|
1071
|
-
}
|
|
1072
|
-
if (txnForEnc.apaa !== undefined) {
|
|
1073
|
-
txn.appArgs = txnForEnc.apaa.map((arg) => new Uint8Array(arg));
|
|
1074
|
-
}
|
|
1075
|
-
if (txnForEnc.apat !== undefined) {
|
|
1076
|
-
txn.appAccounts = txnForEnc.apat.map((addressBytes) =>
|
|
1077
|
-
address.decodeAddress(
|
|
1078
|
-
address.encodeAddress(new Uint8Array(addressBytes))
|
|
1079
|
-
)
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
if (txnForEnc.apfa !== undefined) {
|
|
1083
|
-
txn.appForeignApps = txnForEnc.apfa;
|
|
1084
|
-
}
|
|
1085
|
-
if (txnForEnc.apas !== undefined) {
|
|
1086
|
-
txn.appForeignAssets = txnForEnc.apas;
|
|
1087
|
-
}
|
|
1088
|
-
if (txnForEnc.apbx !== undefined) {
|
|
1089
|
-
txn.boxes = txnForEnc.apbx.map((box) => ({
|
|
1090
|
-
// We return 0 for the app ID so that it's guaranteed translateBoxReferences will
|
|
1091
|
-
// translate the app index back to 0. If we instead returned the called app ID,
|
|
1092
|
-
// translateBoxReferences would translate the app index to a nonzero value if the called
|
|
1093
|
-
// app is also in the foreign app array.
|
|
1094
|
-
appIndex: box.i ? txn.appForeignApps[box.i - 1] : 0,
|
|
1095
|
-
name: box.n,
|
|
1096
|
-
}));
|
|
1097
|
-
}
|
|
1098
|
-
} else if (txnForEnc.type === 'stpf') {
|
|
1099
|
-
if (txnForEnc.sptype !== undefined) {
|
|
1100
|
-
txn.stateProofType = txnForEnc.sptype;
|
|
1101
|
-
}
|
|
1102
|
-
if (txnForEnc.sp !== undefined) {
|
|
1103
|
-
txn.stateProof = txnForEnc.sp;
|
|
1104
|
-
}
|
|
1105
|
-
if (txnForEnc.spmsg !== undefined) {
|
|
1106
|
-
txn.stateProofMessage = txnForEnc.spmsg;
|
|
1016
|
+
if (data.get('grp')) {
|
|
1017
|
+
const group = ensureUint8Array(data.get('grp'));
|
|
1018
|
+
if (group.byteLength !== ALGORAND_TRANSACTION_GROUP_LENGTH) {
|
|
1019
|
+
throw new Error(`Invalid group length: ${group.byteLength}`);
|
|
1107
1020
|
}
|
|
1021
|
+
txn.group = group;
|
|
1108
1022
|
}
|
|
1023
|
+
|
|
1109
1024
|
return txn;
|
|
1110
1025
|
}
|
|
1111
1026
|
|
|
1112
|
-
estimateSize() {
|
|
1027
|
+
private estimateSize() {
|
|
1113
1028
|
return this.toByte().length + NUM_ADDL_BYTES_AFTER_SIGNING;
|
|
1114
1029
|
}
|
|
1115
1030
|
|
|
1116
1031
|
bytesToSign() {
|
|
1117
1032
|
const encodedMsg = this.toByte();
|
|
1118
|
-
return
|
|
1033
|
+
return utils.concatArrays(TX_TAG, encodedMsg);
|
|
1119
1034
|
}
|
|
1120
1035
|
|
|
1121
1036
|
toByte() {
|
|
1122
|
-
return encoding.
|
|
1037
|
+
return encoding.encodeMsgpack(this);
|
|
1123
1038
|
}
|
|
1124
1039
|
|
|
1125
1040
|
// returns the raw signature
|
|
1126
|
-
rawSignTxn(sk: Uint8Array) {
|
|
1041
|
+
rawSignTxn(sk: Uint8Array): Uint8Array {
|
|
1127
1042
|
const toBeSigned = this.bytesToSign();
|
|
1128
1043
|
const sig = nacl.sign(toBeSigned, sk);
|
|
1129
|
-
return
|
|
1044
|
+
return sig;
|
|
1130
1045
|
}
|
|
1131
1046
|
|
|
1132
|
-
signTxn(sk: Uint8Array) {
|
|
1133
|
-
//
|
|
1134
|
-
const sTxn: EncodedSignedTransaction = {
|
|
1135
|
-
sig: this.rawSignTxn(sk),
|
|
1136
|
-
txn: this.get_obj_for_encoding(),
|
|
1137
|
-
};
|
|
1138
|
-
// add AuthAddr if signing with a different key than From indicates
|
|
1047
|
+
signTxn(sk: Uint8Array): Uint8Array {
|
|
1048
|
+
// TODO: deprecate in favor of SignedTransaction class
|
|
1139
1049
|
const keypair = nacl.keyPairFromSecretKey(sk);
|
|
1140
|
-
const
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
address.encodeAddress(this.from.publicKey)
|
|
1144
|
-
) {
|
|
1145
|
-
sTxn.sgnr = Buffer.from(pubKeyFromSk);
|
|
1146
|
-
}
|
|
1147
|
-
return new Uint8Array(encoding.encode(sTxn));
|
|
1050
|
+
const signerAddr = new Address(keypair.publicKey);
|
|
1051
|
+
const sig = this.rawSignTxn(sk);
|
|
1052
|
+
return this.attachSignature(signerAddr, sig);
|
|
1148
1053
|
}
|
|
1149
1054
|
|
|
1150
|
-
attachSignature(
|
|
1055
|
+
attachSignature(
|
|
1056
|
+
signerAddr: string | Address,
|
|
1057
|
+
signature: Uint8Array
|
|
1058
|
+
): Uint8Array {
|
|
1059
|
+
// TODO: deprecate in favor of SignedTransaction class
|
|
1151
1060
|
if (!nacl.isValidSignatureLength(signature.length)) {
|
|
1152
1061
|
throw new Error('Invalid signature length');
|
|
1153
1062
|
}
|
|
1154
|
-
const sTxn
|
|
1155
|
-
sig
|
|
1156
|
-
txn
|
|
1157
|
-
|
|
1063
|
+
const sTxn = new Map<string, unknown>([
|
|
1064
|
+
['sig', signature],
|
|
1065
|
+
['txn', this.toEncodingData()],
|
|
1066
|
+
]);
|
|
1067
|
+
const signerAddrObj = ensureAddress(signerAddr);
|
|
1158
1068
|
// add AuthAddr if signing with a different key than From indicates
|
|
1159
|
-
if (
|
|
1160
|
-
|
|
1161
|
-
sTxn.sgnr = Buffer.from(signerPublicKey);
|
|
1069
|
+
if (!this.sender.equals(signerAddrObj)) {
|
|
1070
|
+
sTxn.set('sgnr', signerAddrObj);
|
|
1162
1071
|
}
|
|
1163
|
-
|
|
1072
|
+
|
|
1073
|
+
// This is a hack to avoid a circular reference with the SignedTransaction class
|
|
1074
|
+
const stxnSchema = new NamedMapSchema(
|
|
1075
|
+
allOmitEmpty([
|
|
1076
|
+
{
|
|
1077
|
+
key: 'txn',
|
|
1078
|
+
valueSchema: Transaction.encodingSchema,
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
key: 'sig',
|
|
1082
|
+
valueSchema: new FixedLengthByteArraySchema(64),
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
key: 'sgnr',
|
|
1086
|
+
valueSchema: new OptionalSchema(new AddressSchema()),
|
|
1087
|
+
},
|
|
1088
|
+
])
|
|
1089
|
+
);
|
|
1090
|
+
|
|
1091
|
+
return encoding.msgpackRawEncode(stxnSchema.prepareMsgpack(sTxn));
|
|
1164
1092
|
}
|
|
1165
1093
|
|
|
1166
|
-
rawTxID() {
|
|
1094
|
+
rawTxID(): Uint8Array {
|
|
1167
1095
|
const enMsg = this.toByte();
|
|
1168
|
-
const gh =
|
|
1169
|
-
return
|
|
1096
|
+
const gh = utils.concatArrays(TX_TAG, enMsg);
|
|
1097
|
+
return Uint8Array.from(nacl.genericHash(gh));
|
|
1170
1098
|
}
|
|
1171
1099
|
|
|
1172
|
-
txID() {
|
|
1100
|
+
txID(): string {
|
|
1173
1101
|
const hash = this.rawTxID();
|
|
1174
1102
|
return base32.encode(hash).slice(0, ALGORAND_TRANSACTION_LENGTH);
|
|
1175
1103
|
}
|
|
1176
|
-
|
|
1177
|
-
// add a lease to a transaction not yet having
|
|
1178
|
-
// supply feePerByte to increment fee accordingly
|
|
1179
|
-
addLease(lease: Uint8Array, feePerByte = 0) {
|
|
1180
|
-
let mutableLease: Uint8Array;
|
|
1181
|
-
|
|
1182
|
-
if (lease !== undefined) {
|
|
1183
|
-
if (lease.constructor !== Uint8Array)
|
|
1184
|
-
throw Error('lease must be a Uint8Array.');
|
|
1185
|
-
if (lease.length !== ALGORAND_TRANSACTION_LEASE_LENGTH)
|
|
1186
|
-
throw Error(
|
|
1187
|
-
`lease must be of length ${ALGORAND_TRANSACTION_LEASE_LENGTH.toString()}.`
|
|
1188
|
-
);
|
|
1189
|
-
|
|
1190
|
-
mutableLease = new Uint8Array(lease);
|
|
1191
|
-
} else {
|
|
1192
|
-
mutableLease = new Uint8Array(0);
|
|
1193
|
-
}
|
|
1194
|
-
this.lease = mutableLease;
|
|
1195
|
-
if (feePerByte !== 0) {
|
|
1196
|
-
this.fee +=
|
|
1197
|
-
(ALGORAND_TRANSACTION_LEASE_LABEL_LENGTH +
|
|
1198
|
-
ALGORAND_TRANSACTION_LEASE_LENGTH) *
|
|
1199
|
-
feePerByte;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
// add the rekey-to field to a transaction not yet having it
|
|
1204
|
-
// supply feePerByte to increment fee accordingly
|
|
1205
|
-
addRekey(reKeyTo: string, feePerByte = 0) {
|
|
1206
|
-
if (reKeyTo !== undefined) {
|
|
1207
|
-
this.reKeyTo = address.decodeAddress(reKeyTo);
|
|
1208
|
-
}
|
|
1209
|
-
if (feePerByte !== 0) {
|
|
1210
|
-
this.fee +=
|
|
1211
|
-
(ALGORAND_TRANSACTION_REKEY_LABEL_LENGTH +
|
|
1212
|
-
ALGORAND_TRANSACTION_ADDRESS_LENGTH) *
|
|
1213
|
-
feePerByte;
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
// build display dict for prettyPrint and toString
|
|
1218
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1219
|
-
_getDictForDisplay() {
|
|
1220
|
-
const forPrinting: TransactionStorageStructure & Record<string, any> = {
|
|
1221
|
-
...this,
|
|
1222
|
-
};
|
|
1223
|
-
forPrinting.tag = forPrinting.tag.toString();
|
|
1224
|
-
forPrinting.from = address.encodeAddress(
|
|
1225
|
-
(forPrinting.from as Address).publicKey
|
|
1226
|
-
);
|
|
1227
|
-
if (forPrinting.to !== undefined)
|
|
1228
|
-
forPrinting.to = address.encodeAddress(
|
|
1229
|
-
(forPrinting.to as Address).publicKey
|
|
1230
|
-
);
|
|
1231
|
-
// things that need fixing:
|
|
1232
|
-
if (forPrinting.freezeAccount !== undefined)
|
|
1233
|
-
forPrinting.freezeAccount = address.encodeAddress(
|
|
1234
|
-
(forPrinting.freezeAccount as Address).publicKey
|
|
1235
|
-
);
|
|
1236
|
-
if (forPrinting.closeRemainderTo !== undefined)
|
|
1237
|
-
forPrinting.closeRemainderTo = address.encodeAddress(
|
|
1238
|
-
(forPrinting.closeRemainderTo as Address).publicKey
|
|
1239
|
-
);
|
|
1240
|
-
if (forPrinting.assetManager !== undefined)
|
|
1241
|
-
forPrinting.assetManager = address.encodeAddress(
|
|
1242
|
-
(forPrinting.assetManager as Address).publicKey
|
|
1243
|
-
);
|
|
1244
|
-
if (forPrinting.assetReserve !== undefined)
|
|
1245
|
-
forPrinting.assetReserve = address.encodeAddress(
|
|
1246
|
-
(forPrinting.assetReserve as Address).publicKey
|
|
1247
|
-
);
|
|
1248
|
-
if (forPrinting.assetFreeze !== undefined)
|
|
1249
|
-
forPrinting.assetFreeze = address.encodeAddress(
|
|
1250
|
-
(forPrinting.assetFreeze as Address).publicKey
|
|
1251
|
-
);
|
|
1252
|
-
if (forPrinting.assetClawback !== undefined)
|
|
1253
|
-
forPrinting.assetClawback = address.encodeAddress(
|
|
1254
|
-
(forPrinting.assetClawback as Address).publicKey
|
|
1255
|
-
);
|
|
1256
|
-
if (forPrinting.assetRevocationTarget !== undefined)
|
|
1257
|
-
forPrinting.assetRevocationTarget = address.encodeAddress(
|
|
1258
|
-
(forPrinting.assetRevocationTarget as Address).publicKey
|
|
1259
|
-
);
|
|
1260
|
-
if (forPrinting.reKeyTo !== undefined)
|
|
1261
|
-
forPrinting.reKeyTo = address.encodeAddress(
|
|
1262
|
-
(forPrinting.reKeyTo as Address).publicKey
|
|
1263
|
-
);
|
|
1264
|
-
forPrinting.genesisHash = forPrinting.genesisHash.toString('base64');
|
|
1265
|
-
return forPrinting;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
// pretty print the transaction to console
|
|
1269
|
-
prettyPrint() {
|
|
1270
|
-
// eslint-disable-next-line no-underscore-dangle,no-console
|
|
1271
|
-
console.log(this._getDictForDisplay());
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
// get string representation
|
|
1275
|
-
toString() {
|
|
1276
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1277
|
-
return JSON.stringify(this._getDictForDisplay());
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
/**
|
|
1282
|
-
* encodeUnsignedSimulateTransaction takes a txnBuilder.Transaction object,
|
|
1283
|
-
* converts it into a SignedTransaction-like object, and converts it to a Buffer.
|
|
1284
|
-
*
|
|
1285
|
-
* Note: this function should only be used to simulate unsigned transactions.
|
|
1286
|
-
*
|
|
1287
|
-
* @param transactionObject - Transaction object to simulate.
|
|
1288
|
-
*/
|
|
1289
|
-
export function encodeUnsignedSimulateTransaction(
|
|
1290
|
-
transactionObject: Transaction
|
|
1291
|
-
) {
|
|
1292
|
-
const objToEncode: EncodedSignedTransaction = {
|
|
1293
|
-
txn: transactionObject.get_obj_for_encoding(),
|
|
1294
|
-
};
|
|
1295
|
-
return encoding.encode(objToEncode);
|
|
1296
1104
|
}
|
|
1297
1105
|
|
|
1298
1106
|
/**
|
|
@@ -1300,82 +1108,18 @@ export function encodeUnsignedSimulateTransaction(
|
|
|
1300
1108
|
* family of transactions, and converts it to a Buffer
|
|
1301
1109
|
* @param transactionObject - the completed Transaction object
|
|
1302
1110
|
*/
|
|
1303
|
-
export function encodeUnsignedTransaction(
|
|
1304
|
-
|
|
1305
|
-
|
|
1111
|
+
export function encodeUnsignedTransaction(
|
|
1112
|
+
transactionObject: Transaction
|
|
1113
|
+
): Uint8Array {
|
|
1114
|
+
return encoding.encodeMsgpack(transactionObject);
|
|
1306
1115
|
}
|
|
1307
1116
|
|
|
1308
1117
|
/**
|
|
1309
|
-
* decodeUnsignedTransaction takes a
|
|
1118
|
+
* decodeUnsignedTransaction takes a Uint8Array (as if from encodeUnsignedTransaction) and converts it to a txnBuilder.Transaction object
|
|
1310
1119
|
* @param transactionBuffer - the Uint8Array containing a transaction
|
|
1311
1120
|
*/
|
|
1312
1121
|
export function decodeUnsignedTransaction(
|
|
1313
1122
|
transactionBuffer: ArrayLike<number>
|
|
1314
|
-
) {
|
|
1315
|
-
|
|
1316
|
-
transactionBuffer
|
|
1317
|
-
) as EncodedTransaction;
|
|
1318
|
-
return Transaction.from_obj_for_encoding(partlyDecodedObject);
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
/**
|
|
1322
|
-
* Object representing a transaction with a signature
|
|
1323
|
-
*/
|
|
1324
|
-
export interface SignedTransaction {
|
|
1325
|
-
/**
|
|
1326
|
-
* Transaction signature
|
|
1327
|
-
*/
|
|
1328
|
-
sig?: Buffer;
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
* The transaction that was signed
|
|
1332
|
-
*/
|
|
1333
|
-
txn: Transaction;
|
|
1334
|
-
|
|
1335
|
-
/**
|
|
1336
|
-
* Multisig structure
|
|
1337
|
-
*/
|
|
1338
|
-
msig?: EncodedMultisig;
|
|
1339
|
-
|
|
1340
|
-
/**
|
|
1341
|
-
* Logic signature
|
|
1342
|
-
*/
|
|
1343
|
-
lsig?: EncodedLogicSig;
|
|
1344
|
-
|
|
1345
|
-
/**
|
|
1346
|
-
* The signer, if signing with a different key than the Transaction type `from` property indicates
|
|
1347
|
-
*/
|
|
1348
|
-
sgnr?: Buffer;
|
|
1123
|
+
): Transaction {
|
|
1124
|
+
return encoding.decodeMsgpack(transactionBuffer, Transaction);
|
|
1349
1125
|
}
|
|
1350
|
-
|
|
1351
|
-
/**
|
|
1352
|
-
* decodeSignedTransaction takes a Buffer (from transaction.signTxn) and converts it to an object
|
|
1353
|
-
* containing the Transaction (txn), the signature (sig), and the auth-addr field if applicable (sgnr)
|
|
1354
|
-
* @param transactionBuffer - the Uint8Array containing a transaction
|
|
1355
|
-
* @returns containing a Transaction, the signature, and possibly an auth-addr field
|
|
1356
|
-
*/
|
|
1357
|
-
export function decodeSignedTransaction(
|
|
1358
|
-
transactionBuffer: Uint8Array
|
|
1359
|
-
): SignedTransaction {
|
|
1360
|
-
const stxnDecoded = encoding.decode(
|
|
1361
|
-
transactionBuffer
|
|
1362
|
-
) as EncodedSignedTransaction;
|
|
1363
|
-
const stxn: SignedTransaction = {
|
|
1364
|
-
...stxnDecoded,
|
|
1365
|
-
txn: Transaction.from_obj_for_encoding(stxnDecoded.txn),
|
|
1366
|
-
};
|
|
1367
|
-
return stxn;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
/**
|
|
1371
|
-
* Either a valid transaction object or an instance of the Transaction class
|
|
1372
|
-
*/
|
|
1373
|
-
export type TransactionLike = AnyTransaction | Transaction;
|
|
1374
|
-
|
|
1375
|
-
export function instantiateTxnIfNeeded(transactionLike: TransactionLike) {
|
|
1376
|
-
return transactionLike instanceof Transaction
|
|
1377
|
-
? transactionLike
|
|
1378
|
-
: new Transaction(transactionLike);
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
export default Transaction;
|