algosdk 2.8.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 +5 -3
- package/dist/cjs/abi/contract.js.map +1 -1
- package/dist/cjs/{types/transactions/asset.js → abi/event.js} +1 -1
- package/dist/cjs/abi/event.js.map +1 -0
- 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 +14 -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 +3712 -1824
- 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 +320 -554
- 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 +3 -1
- package/dist/esm/abi/contract.js.map +1 -1
- package/dist/esm/abi/event.js +2 -0
- package/dist/esm/abi/event.js.map +1 -0
- 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 +8 -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 +3712 -1821
- 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 +314 -513
- 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 +5 -1
- package/dist/types/abi/event.d.ts +16 -0
- 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 +12 -5
- 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 +629 -318
- 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 +129 -388
- 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 +7 -1
- package/src/abi/event.ts +16 -0
- package/src/abi/index.ts +6 -6
- package/src/abi/interface.ts +1 -1
- package/src/abi/method.ts +22 -8
- 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 +4729 -2254
- 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 +670 -1320
- 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.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/dist/cjs/transaction.js
CHANGED
|
@@ -26,917 +26,572 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const buffer_1 = require("buffer");
|
|
29
|
+
exports.decodeUnsignedTransaction = exports.encodeUnsignedTransaction = exports.Transaction = void 0;
|
|
31
30
|
const hi_base32_1 = __importDefault(require("hi-base32"));
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
31
|
+
const boxStorage_js_1 = require("./boxStorage.js");
|
|
32
|
+
const address_js_1 = require("./encoding/address.js");
|
|
33
|
+
const encoding = __importStar(require("./encoding/encoding.js"));
|
|
34
|
+
const index_js_1 = require("./encoding/schema/index.js");
|
|
35
|
+
const nacl = __importStar(require("./nacl/naclWrappers.js"));
|
|
36
|
+
const base_js_1 = require("./types/transactions/base.js");
|
|
37
|
+
const stateproof_js_1 = require("./stateproof.js");
|
|
38
|
+
const utils = __importStar(require("./utils/utils.js"));
|
|
38
39
|
const ALGORAND_TRANSACTION_LENGTH = 52;
|
|
39
|
-
exports.ALGORAND_MIN_TX_FEE = 1000; // version v5
|
|
40
40
|
const ALGORAND_TRANSACTION_LEASE_LENGTH = 32;
|
|
41
|
-
const ALGORAND_MAX_ASSET_DECIMALS = 19;
|
|
42
41
|
const NUM_ADDL_BYTES_AFTER_SIGNING = 75; // NUM_ADDL_BYTES_AFTER_SIGNING is the number of bytes added to a txn after signing it
|
|
43
|
-
const ALGORAND_TRANSACTION_LEASE_LABEL_LENGTH = 5;
|
|
44
|
-
const ALGORAND_TRANSACTION_ADDRESS_LENGTH = 32;
|
|
45
|
-
const ALGORAND_TRANSACTION_REKEY_LABEL_LENGTH = 5;
|
|
46
42
|
const ASSET_METADATA_HASH_LENGTH = 32;
|
|
47
43
|
const KEYREG_VOTE_KEY_LENGTH = 32;
|
|
48
44
|
const KEYREG_SELECTION_KEY_LENGTH = 32;
|
|
49
45
|
const KEYREG_STATE_PROOF_KEY_LENGTH = 64;
|
|
46
|
+
const ALGORAND_TRANSACTION_GROUP_LENGTH = 32;
|
|
47
|
+
function uint8ArrayIsEmpty(input) {
|
|
48
|
+
return input.every((value) => value === 0);
|
|
49
|
+
}
|
|
50
50
|
function getKeyregKey(input, inputName, length) {
|
|
51
51
|
if (input == null) {
|
|
52
52
|
return undefined;
|
|
53
53
|
}
|
|
54
|
-
let
|
|
54
|
+
let inputBytes;
|
|
55
|
+
if (input instanceof Uint8Array) {
|
|
56
|
+
inputBytes = input;
|
|
57
|
+
}
|
|
58
|
+
if (inputBytes == null || inputBytes.byteLength !== length) {
|
|
59
|
+
throw Error(`${inputName} must be a ${length} byte Uint8Array`);
|
|
60
|
+
}
|
|
61
|
+
return inputBytes;
|
|
62
|
+
}
|
|
63
|
+
function ensureAddress(input) {
|
|
64
|
+
if (input == null) {
|
|
65
|
+
throw new Error('Address must not be null or undefined');
|
|
66
|
+
}
|
|
55
67
|
if (typeof input === 'string') {
|
|
56
|
-
|
|
68
|
+
return address_js_1.Address.fromString(input);
|
|
69
|
+
}
|
|
70
|
+
if (input instanceof address_js_1.Address) {
|
|
71
|
+
return input;
|
|
72
|
+
}
|
|
73
|
+
throw new Error(`Not an address: ${input}`);
|
|
74
|
+
}
|
|
75
|
+
function optionalAddress(input) {
|
|
76
|
+
if (input == null) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
let addr;
|
|
80
|
+
if (input instanceof address_js_1.Address) {
|
|
81
|
+
addr = input;
|
|
82
|
+
}
|
|
83
|
+
else if (typeof input === 'string') {
|
|
84
|
+
addr = address_js_1.Address.fromString(input);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new Error(`Not an address: ${input}`);
|
|
88
|
+
}
|
|
89
|
+
if (uint8ArrayIsEmpty(addr.publicKey)) {
|
|
90
|
+
// If it's the zero address, throw an error so that the user won't be surprised that this gets dropped
|
|
91
|
+
throw new Error('Invalid use of the zero address. To omit this value, pass in undefined');
|
|
92
|
+
}
|
|
93
|
+
return addr;
|
|
94
|
+
}
|
|
95
|
+
function optionalUint8Array(input) {
|
|
96
|
+
if (typeof input === 'undefined') {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
if (input instanceof Uint8Array) {
|
|
100
|
+
return input;
|
|
101
|
+
}
|
|
102
|
+
throw new Error(`Not a Uint8Array: ${input}`);
|
|
103
|
+
}
|
|
104
|
+
function ensureUint8Array(input) {
|
|
105
|
+
if (input instanceof Uint8Array) {
|
|
106
|
+
return input;
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`Not a Uint8Array: ${input}`);
|
|
109
|
+
}
|
|
110
|
+
function optionalUint64(input) {
|
|
111
|
+
if (typeof input === 'undefined') {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
return utils.ensureUint64(input);
|
|
115
|
+
}
|
|
116
|
+
function ensureBoolean(input) {
|
|
117
|
+
if (input === true || input === false) {
|
|
118
|
+
return input;
|
|
119
|
+
}
|
|
120
|
+
throw new Error(`Not a boolean: ${input}`);
|
|
121
|
+
}
|
|
122
|
+
function ensureArray(input) {
|
|
123
|
+
if (Array.isArray(input)) {
|
|
124
|
+
return input.slice();
|
|
125
|
+
}
|
|
126
|
+
throw new Error(`Not an array: ${input}`);
|
|
127
|
+
}
|
|
128
|
+
function optionalFixedLengthByteArray(input, length, name) {
|
|
129
|
+
const bytes = optionalUint8Array(input);
|
|
130
|
+
if (typeof bytes === 'undefined') {
|
|
131
|
+
return undefined;
|
|
57
132
|
}
|
|
58
|
-
|
|
59
|
-
|
|
133
|
+
if (bytes.byteLength !== length) {
|
|
134
|
+
throw new Error(`${name} must be ${length} bytes long, was ${bytes.byteLength}`);
|
|
60
135
|
}
|
|
61
|
-
|
|
62
|
-
|
|
136
|
+
if (uint8ArrayIsEmpty(bytes)) {
|
|
137
|
+
// if contains all 0s, omit it
|
|
138
|
+
return undefined;
|
|
63
139
|
}
|
|
64
|
-
|
|
65
|
-
|
|
140
|
+
return bytes;
|
|
141
|
+
}
|
|
142
|
+
function ensureBoxReference(input) {
|
|
143
|
+
if (input != null && typeof input === 'object') {
|
|
144
|
+
const { appIndex, name } = input;
|
|
145
|
+
return {
|
|
146
|
+
appIndex: utils.ensureUint64(appIndex),
|
|
147
|
+
name: ensureUint8Array(name),
|
|
148
|
+
};
|
|
66
149
|
}
|
|
67
|
-
|
|
150
|
+
throw new Error(`Not a box reference: ${input}`);
|
|
68
151
|
}
|
|
152
|
+
const TX_TAG = new TextEncoder().encode('TX');
|
|
69
153
|
/**
|
|
70
154
|
* Transaction enables construction of Algorand transactions
|
|
71
155
|
* */
|
|
72
156
|
class Transaction {
|
|
73
|
-
constructor(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
if (typeof transaction.type === 'undefined') {
|
|
85
|
-
transaction.type = defaults.type;
|
|
86
|
-
}
|
|
87
|
-
// Default flatFee
|
|
88
|
-
if (typeof transaction.flatFee ===
|
|
89
|
-
'undefined') {
|
|
90
|
-
transaction.flatFee =
|
|
91
|
-
defaults.flatFee;
|
|
92
|
-
}
|
|
93
|
-
// Default nonParticipation
|
|
94
|
-
if (transaction.type === base_1.TransactionType.keyreg &&
|
|
95
|
-
typeof transaction.voteKey !== 'undefined' &&
|
|
96
|
-
typeof transaction.nonParticipation === 'undefined') {
|
|
97
|
-
transaction.nonParticipation = defaults.nonParticipation;
|
|
98
|
-
}
|
|
99
|
-
/* eslint-enable no-param-reassign */
|
|
100
|
-
// Move suggested parameters from its object to inline
|
|
101
|
-
if (transaction.suggestedParams !== undefined) {
|
|
102
|
-
// Create a temporary reference to the transaction object that has params inline and also as a suggested params object
|
|
103
|
-
// - Helpful for moving params from named object to inline
|
|
104
|
-
const reference = transaction;
|
|
105
|
-
reference.genesisHash = reference.suggestedParams.genesisHash;
|
|
106
|
-
reference.fee = reference.suggestedParams.fee;
|
|
107
|
-
if (reference.suggestedParams.flatFee !== undefined)
|
|
108
|
-
reference.flatFee = reference.suggestedParams.flatFee;
|
|
109
|
-
reference.firstRound = reference.suggestedParams.firstRound;
|
|
110
|
-
reference.lastRound = reference.suggestedParams.lastRound;
|
|
111
|
-
reference.genesisID = reference.suggestedParams.genesisID;
|
|
112
|
-
}
|
|
113
|
-
// At this point all suggestedParams have been moved to be inline, so we can reassign the transaction object type
|
|
114
|
-
// to one which is more useful as we prepare properties for storing
|
|
115
|
-
const txn = transaction;
|
|
116
|
-
txn.from = address.decodeAddress(txn.from);
|
|
117
|
-
if (txn.to !== undefined)
|
|
118
|
-
txn.to = address.decodeAddress(txn.to);
|
|
119
|
-
if (txn.closeRemainderTo !== undefined)
|
|
120
|
-
txn.closeRemainderTo = address.decodeAddress(txn.closeRemainderTo);
|
|
121
|
-
if (txn.assetManager !== undefined)
|
|
122
|
-
txn.assetManager = address.decodeAddress(txn.assetManager);
|
|
123
|
-
if (txn.assetReserve !== undefined)
|
|
124
|
-
txn.assetReserve = address.decodeAddress(txn.assetReserve);
|
|
125
|
-
if (txn.assetFreeze !== undefined)
|
|
126
|
-
txn.assetFreeze = address.decodeAddress(txn.assetFreeze);
|
|
127
|
-
if (txn.assetClawback !== undefined)
|
|
128
|
-
txn.assetClawback = address.decodeAddress(txn.assetClawback);
|
|
129
|
-
if (txn.assetRevocationTarget !== undefined)
|
|
130
|
-
txn.assetRevocationTarget = address.decodeAddress(txn.assetRevocationTarget);
|
|
131
|
-
if (txn.freezeAccount !== undefined)
|
|
132
|
-
txn.freezeAccount = address.decodeAddress(txn.freezeAccount);
|
|
133
|
-
if (txn.reKeyTo !== undefined)
|
|
134
|
-
txn.reKeyTo = address.decodeAddress(txn.reKeyTo);
|
|
135
|
-
if (txn.genesisHash === undefined)
|
|
136
|
-
throw Error('genesis hash must be specified and in a base64 string.');
|
|
137
|
-
txn.genesisHash = buffer_1.Buffer.from(txn.genesisHash, 'base64');
|
|
138
|
-
if (txn.amount !== undefined &&
|
|
139
|
-
(!(Number.isSafeInteger(txn.amount) ||
|
|
140
|
-
(typeof txn.amount === 'bigint' &&
|
|
141
|
-
txn.amount <= BigInt('0xffffffffffffffff'))) ||
|
|
142
|
-
txn.amount < 0))
|
|
143
|
-
throw Error('Amount must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.');
|
|
144
|
-
if (!Number.isSafeInteger(txn.fee) || txn.fee < 0)
|
|
145
|
-
throw Error('fee must be a positive number and smaller than 2^53-1');
|
|
146
|
-
if (!Number.isSafeInteger(txn.firstRound) || txn.firstRound < 0)
|
|
147
|
-
throw Error('firstRound must be a positive number');
|
|
148
|
-
if (!Number.isSafeInteger(txn.lastRound) || txn.lastRound < 0)
|
|
149
|
-
throw Error('lastRound must be a positive number');
|
|
150
|
-
if (txn.extraPages !== undefined &&
|
|
151
|
-
(!Number.isInteger(txn.extraPages) ||
|
|
152
|
-
txn.extraPages < 0 ||
|
|
153
|
-
txn.extraPages > 3))
|
|
154
|
-
throw Error('extraPages must be an Integer between and including 0 to 3');
|
|
155
|
-
if (txn.assetTotal !== undefined &&
|
|
156
|
-
(!(Number.isSafeInteger(txn.assetTotal) ||
|
|
157
|
-
(typeof txn.assetTotal === 'bigint' &&
|
|
158
|
-
txn.assetTotal <= BigInt('0xffffffffffffffff'))) ||
|
|
159
|
-
txn.assetTotal < 0))
|
|
160
|
-
throw Error('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.');
|
|
161
|
-
if (txn.assetDecimals !== undefined &&
|
|
162
|
-
(!Number.isSafeInteger(txn.assetDecimals) ||
|
|
163
|
-
txn.assetDecimals < 0 ||
|
|
164
|
-
txn.assetDecimals > ALGORAND_MAX_ASSET_DECIMALS))
|
|
165
|
-
throw Error(`assetDecimals must be a positive number and smaller than ${ALGORAND_MAX_ASSET_DECIMALS.toString()}`);
|
|
166
|
-
if (txn.assetIndex !== undefined &&
|
|
167
|
-
(!Number.isSafeInteger(txn.assetIndex) || txn.assetIndex < 0))
|
|
168
|
-
throw Error('Asset index must be a positive number and smaller than 2^53-1');
|
|
169
|
-
if (txn.appIndex !== undefined &&
|
|
170
|
-
(!Number.isSafeInteger(txn.appIndex) || txn.appIndex < 0))
|
|
171
|
-
throw Error('Application index must be a positive number and smaller than 2^53-1');
|
|
172
|
-
if (txn.appLocalInts !== undefined &&
|
|
173
|
-
(!Number.isSafeInteger(txn.appLocalInts) || txn.appLocalInts < 0))
|
|
174
|
-
throw Error('Application local ints count must be a positive number and smaller than 2^53-1');
|
|
175
|
-
if (txn.appLocalByteSlices !== undefined &&
|
|
176
|
-
(!Number.isSafeInteger(txn.appLocalByteSlices) ||
|
|
177
|
-
txn.appLocalByteSlices < 0))
|
|
178
|
-
throw Error('Application local byte slices count must be a positive number and smaller than 2^53-1');
|
|
179
|
-
if (txn.appGlobalInts !== undefined &&
|
|
180
|
-
(!Number.isSafeInteger(txn.appGlobalInts) || txn.appGlobalInts < 0))
|
|
181
|
-
throw Error('Application global ints count must be a positive number and smaller than 2^53-1');
|
|
182
|
-
if (txn.appGlobalByteSlices !== undefined &&
|
|
183
|
-
(!Number.isSafeInteger(txn.appGlobalByteSlices) ||
|
|
184
|
-
txn.appGlobalByteSlices < 0))
|
|
185
|
-
throw Error('Application global byte slices count must be a positive number and smaller than 2^53-1');
|
|
186
|
-
if (txn.appApprovalProgram !== undefined) {
|
|
187
|
-
if (txn.appApprovalProgram.constructor !== Uint8Array)
|
|
188
|
-
throw Error('appApprovalProgram must be a Uint8Array.');
|
|
189
|
-
}
|
|
190
|
-
if (txn.appClearProgram !== undefined) {
|
|
191
|
-
if (txn.appClearProgram.constructor !== Uint8Array)
|
|
192
|
-
throw Error('appClearProgram must be a Uint8Array.');
|
|
193
|
-
}
|
|
194
|
-
if (txn.appArgs !== undefined) {
|
|
195
|
-
if (!Array.isArray(txn.appArgs))
|
|
196
|
-
throw Error('appArgs must be an Array of Uint8Array.');
|
|
197
|
-
txn.appArgs = txn.appArgs.slice();
|
|
198
|
-
txn.appArgs.forEach((arg) => {
|
|
199
|
-
if (arg.constructor !== Uint8Array)
|
|
200
|
-
throw Error('each element of AppArgs must be a Uint8Array.');
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
txn.appArgs = [];
|
|
205
|
-
}
|
|
206
|
-
if (txn.appAccounts !== undefined) {
|
|
207
|
-
if (!Array.isArray(txn.appAccounts))
|
|
208
|
-
throw Error('appAccounts must be an Array of addresses.');
|
|
209
|
-
txn.appAccounts = txn.appAccounts.map((addressAsString) => address.decodeAddress(addressAsString));
|
|
210
|
-
}
|
|
211
|
-
if (txn.appForeignApps !== undefined) {
|
|
212
|
-
if (!Array.isArray(txn.appForeignApps))
|
|
213
|
-
throw Error('appForeignApps must be an Array of integers.');
|
|
214
|
-
txn.appForeignApps = txn.appForeignApps.slice();
|
|
215
|
-
txn.appForeignApps.forEach((foreignAppIndex) => {
|
|
216
|
-
if (!Number.isSafeInteger(foreignAppIndex) || foreignAppIndex < 0)
|
|
217
|
-
throw Error('each foreign application index must be a positive number and smaller than 2^53-1');
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
if (txn.appForeignAssets !== undefined) {
|
|
221
|
-
if (!Array.isArray(txn.appForeignAssets))
|
|
222
|
-
throw Error('appForeignAssets must be an Array of integers.');
|
|
223
|
-
txn.appForeignAssets = txn.appForeignAssets.slice();
|
|
224
|
-
txn.appForeignAssets.forEach((foreignAssetIndex) => {
|
|
225
|
-
if (!Number.isSafeInteger(foreignAssetIndex) || foreignAssetIndex < 0)
|
|
226
|
-
throw Error('each foreign asset index must be a positive number and smaller than 2^53-1');
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
if (txn.boxes !== undefined) {
|
|
230
|
-
if (!Array.isArray(txn.boxes))
|
|
231
|
-
throw Error('boxes must be an Array of BoxReference.');
|
|
232
|
-
txn.boxes = txn.boxes.slice();
|
|
233
|
-
txn.boxes.forEach((box) => {
|
|
234
|
-
if (!Number.isSafeInteger(box.appIndex) ||
|
|
235
|
-
box.name.constructor !== Uint8Array)
|
|
236
|
-
throw Error('box app index must be a number and name must be an Uint8Array.');
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
if (txn.assetMetadataHash !== undefined &&
|
|
240
|
-
txn.assetMetadataHash.length !== 0) {
|
|
241
|
-
if (typeof txn.assetMetadataHash === 'string') {
|
|
242
|
-
txn.assetMetadataHash = new Uint8Array(buffer_1.Buffer.from(txn.assetMetadataHash));
|
|
243
|
-
}
|
|
244
|
-
if (txn.assetMetadataHash.constructor !== Uint8Array ||
|
|
245
|
-
txn.assetMetadataHash.byteLength !== ASSET_METADATA_HASH_LENGTH) {
|
|
246
|
-
throw Error(`assetMetadataHash must be a ${ASSET_METADATA_HASH_LENGTH} byte Uint8Array or string.`);
|
|
247
|
-
}
|
|
248
|
-
if (txn.assetMetadataHash.every((value) => value === 0)) {
|
|
249
|
-
// if hash contains all 0s, omit it
|
|
250
|
-
txn.assetMetadataHash = undefined;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
txn.assetMetadataHash = undefined;
|
|
255
|
-
}
|
|
256
|
-
if (txn.note !== undefined) {
|
|
257
|
-
if (txn.note.constructor !== Uint8Array)
|
|
258
|
-
throw Error('note must be a Uint8Array.');
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
txn.note = new Uint8Array(0);
|
|
262
|
-
}
|
|
263
|
-
if (txn.lease !== undefined) {
|
|
264
|
-
if (txn.lease.constructor !== Uint8Array)
|
|
265
|
-
throw Error('lease must be a Uint8Array.');
|
|
266
|
-
if (txn.lease.length !== ALGORAND_TRANSACTION_LEASE_LENGTH)
|
|
267
|
-
throw Error(`lease must be of length ${ALGORAND_TRANSACTION_LEASE_LENGTH.toString()}.`);
|
|
268
|
-
if (txn.lease.every((value) => value === 0)) {
|
|
269
|
-
// if lease contains all 0s, omit it
|
|
270
|
-
txn.lease = new Uint8Array(0);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
txn.lease = new Uint8Array(0);
|
|
275
|
-
}
|
|
276
|
-
txn.voteKey = getKeyregKey(txn.voteKey, 'voteKey', KEYREG_VOTE_KEY_LENGTH);
|
|
277
|
-
txn.selectionKey = getKeyregKey(txn.selectionKey, 'selectionKey', KEYREG_SELECTION_KEY_LENGTH);
|
|
278
|
-
txn.stateProofKey = getKeyregKey(txn.stateProofKey, 'stateProofKey', KEYREG_STATE_PROOF_KEY_LENGTH);
|
|
279
|
-
// Checking non-participation key registration
|
|
280
|
-
if (txn.nonParticipation &&
|
|
281
|
-
(txn.voteKey ||
|
|
282
|
-
txn.selectionKey ||
|
|
283
|
-
txn.voteFirst ||
|
|
284
|
-
txn.stateProofKey ||
|
|
285
|
-
txn.voteLast ||
|
|
286
|
-
txn.voteKeyDilution)) {
|
|
287
|
-
throw new Error('nonParticipation is true but participation params are present.');
|
|
288
|
-
}
|
|
289
|
-
// Checking online key registration
|
|
290
|
-
if (!txn.nonParticipation &&
|
|
291
|
-
(txn.voteKey ||
|
|
292
|
-
txn.selectionKey ||
|
|
293
|
-
txn.stateProofKey ||
|
|
294
|
-
txn.voteFirst ||
|
|
295
|
-
txn.voteLast ||
|
|
296
|
-
txn.voteKeyDilution) &&
|
|
297
|
-
!(txn.voteKey &&
|
|
298
|
-
txn.selectionKey &&
|
|
299
|
-
txn.voteFirst &&
|
|
300
|
-
txn.voteLast &&
|
|
301
|
-
txn.voteKeyDilution)
|
|
302
|
-
// stateProofKey not included here for backwards compatibility
|
|
303
|
-
) {
|
|
304
|
-
throw new Error('online key registration missing at least one of the following fields: ' +
|
|
305
|
-
'voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution');
|
|
306
|
-
}
|
|
307
|
-
// The last option is an offline key registration where all the fields
|
|
308
|
-
// nonParticipation, voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution
|
|
309
|
-
// are all undefined/false
|
|
310
|
-
// Remove unwanted properties and store transaction on instance
|
|
311
|
-
delete txn.suggestedParams;
|
|
312
|
-
Object.assign(this, utils.removeUndefinedProperties(txn));
|
|
313
|
-
// Modify Fee
|
|
314
|
-
if (!txn.flatFee) {
|
|
315
|
-
this.fee *= this.estimateSize();
|
|
316
|
-
// If suggested fee too small and will be rejected, set to min tx fee
|
|
317
|
-
if (this.fee < exports.ALGORAND_MIN_TX_FEE) {
|
|
318
|
-
this.fee = exports.ALGORAND_MIN_TX_FEE;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
// say we are aware of groups
|
|
157
|
+
constructor(params) {
|
|
158
|
+
if (!(0, base_js_1.isTransactionType)(params.type)) {
|
|
159
|
+
throw new Error(`Invalid transaction type: ${params.type}`);
|
|
160
|
+
}
|
|
161
|
+
// Common fields
|
|
162
|
+
this.type = params.type; // verified above
|
|
163
|
+
this.sender = ensureAddress(params.sender);
|
|
164
|
+
this.note = ensureUint8Array(params.note ?? new Uint8Array());
|
|
165
|
+
this.lease = optionalFixedLengthByteArray(params.lease, ALGORAND_TRANSACTION_LEASE_LENGTH, 'lease');
|
|
166
|
+
this.rekeyTo = optionalAddress(params.rekeyTo);
|
|
167
|
+
// Group
|
|
322
168
|
this.group = undefined;
|
|
323
|
-
//
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
169
|
+
// Suggested params fields
|
|
170
|
+
this.firstValid = utils.ensureUint64(params.suggestedParams.firstValid);
|
|
171
|
+
this.lastValid = utils.ensureUint64(params.suggestedParams.lastValid);
|
|
172
|
+
if (params.suggestedParams.genesisID) {
|
|
173
|
+
if (typeof params.suggestedParams.genesisID !== 'string') {
|
|
174
|
+
throw new Error('Genesis ID must be a string if present');
|
|
175
|
+
}
|
|
176
|
+
this.genesisID = params.suggestedParams.genesisID;
|
|
177
|
+
}
|
|
178
|
+
this.genesisHash = optionalUint8Array(params.suggestedParams.genesisHash);
|
|
179
|
+
// Fee is handled at the end
|
|
180
|
+
const fieldsPresent = [];
|
|
181
|
+
if (params.paymentParams)
|
|
182
|
+
fieldsPresent.push(base_js_1.TransactionType.pay);
|
|
183
|
+
if (params.keyregParams)
|
|
184
|
+
fieldsPresent.push(base_js_1.TransactionType.keyreg);
|
|
185
|
+
if (params.assetConfigParams)
|
|
186
|
+
fieldsPresent.push(base_js_1.TransactionType.acfg);
|
|
187
|
+
if (params.assetTransferParams)
|
|
188
|
+
fieldsPresent.push(base_js_1.TransactionType.axfer);
|
|
189
|
+
if (params.assetFreezeParams)
|
|
190
|
+
fieldsPresent.push(base_js_1.TransactionType.afrz);
|
|
191
|
+
if (params.appCallParams)
|
|
192
|
+
fieldsPresent.push(base_js_1.TransactionType.appl);
|
|
193
|
+
if (params.stateProofParams)
|
|
194
|
+
fieldsPresent.push(base_js_1.TransactionType.stpf);
|
|
195
|
+
if (fieldsPresent.length !== 1) {
|
|
196
|
+
throw new Error(`Transaction has wrong number of type fields present (${fieldsPresent.length}): ${fieldsPresent}`);
|
|
197
|
+
}
|
|
198
|
+
if (this.type !== fieldsPresent[0]) {
|
|
199
|
+
throw new Error(`Transaction has type ${this.type} but fields present for ${fieldsPresent[0]}`);
|
|
200
|
+
}
|
|
201
|
+
if (params.paymentParams) {
|
|
202
|
+
this.payment = {
|
|
203
|
+
receiver: ensureAddress(params.paymentParams.receiver),
|
|
204
|
+
amount: utils.ensureUint64(params.paymentParams.amount),
|
|
205
|
+
closeRemainderTo: optionalAddress(params.paymentParams.closeRemainderTo),
|
|
357
206
|
};
|
|
358
|
-
// parse close address
|
|
359
|
-
if (this.closeRemainderTo !== undefined &&
|
|
360
|
-
address.encodeAddress(this.closeRemainderTo.publicKey) !==
|
|
361
|
-
address.ALGORAND_ZERO_ADDRESS_STRING) {
|
|
362
|
-
txn.close = buffer_1.Buffer.from(this.closeRemainderTo.publicKey);
|
|
363
|
-
}
|
|
364
|
-
if (this.reKeyTo !== undefined) {
|
|
365
|
-
txn.rekey = buffer_1.Buffer.from(this.reKeyTo.publicKey);
|
|
366
|
-
}
|
|
367
|
-
// allowed zero values
|
|
368
|
-
if (this.to !== undefined)
|
|
369
|
-
txn.rcv = buffer_1.Buffer.from(this.to.publicKey);
|
|
370
|
-
if (!txn.note.length)
|
|
371
|
-
delete txn.note;
|
|
372
|
-
if (!txn.amt)
|
|
373
|
-
delete txn.amt;
|
|
374
|
-
if (!txn.fee)
|
|
375
|
-
delete txn.fee;
|
|
376
|
-
if (!txn.fv)
|
|
377
|
-
delete txn.fv;
|
|
378
|
-
if (!txn.gen)
|
|
379
|
-
delete txn.gen;
|
|
380
|
-
if (txn.grp === undefined)
|
|
381
|
-
delete txn.grp;
|
|
382
|
-
if (!txn.lx.length)
|
|
383
|
-
delete txn.lx;
|
|
384
|
-
if (!txn.rekey)
|
|
385
|
-
delete txn.rekey;
|
|
386
|
-
return txn;
|
|
387
207
|
}
|
|
388
|
-
if (
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
gh: this.genesisHash,
|
|
398
|
-
lx: buffer_1.Buffer.from(this.lease),
|
|
399
|
-
grp: this.group,
|
|
400
|
-
votekey: this.voteKey,
|
|
401
|
-
selkey: this.selectionKey,
|
|
402
|
-
sprfkey: this.stateProofKey,
|
|
403
|
-
votefst: this.voteFirst,
|
|
404
|
-
votelst: this.voteLast,
|
|
405
|
-
votekd: this.voteKeyDilution,
|
|
208
|
+
if (params.keyregParams) {
|
|
209
|
+
this.keyreg = {
|
|
210
|
+
voteKey: getKeyregKey(params.keyregParams.voteKey, 'voteKey', KEYREG_VOTE_KEY_LENGTH),
|
|
211
|
+
selectionKey: getKeyregKey(params.keyregParams.selectionKey, 'selectionKey', KEYREG_SELECTION_KEY_LENGTH),
|
|
212
|
+
stateProofKey: getKeyregKey(params.keyregParams.stateProofKey, 'stateProofKey', KEYREG_STATE_PROOF_KEY_LENGTH),
|
|
213
|
+
voteFirst: optionalUint64(params.keyregParams.voteFirst),
|
|
214
|
+
voteLast: optionalUint64(params.keyregParams.voteLast),
|
|
215
|
+
voteKeyDilution: optionalUint64(params.keyregParams.voteKeyDilution),
|
|
216
|
+
nonParticipation: ensureBoolean(params.keyregParams.nonParticipation ?? false),
|
|
406
217
|
};
|
|
407
|
-
//
|
|
408
|
-
if (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
t: this.assetTotal,
|
|
456
|
-
df: this.assetDefaultFrozen,
|
|
457
|
-
dc: this.assetDecimals,
|
|
458
|
-
},
|
|
218
|
+
// Checking non-participation key registration
|
|
219
|
+
if (this.keyreg.nonParticipation &&
|
|
220
|
+
(this.keyreg.voteKey ||
|
|
221
|
+
this.keyreg.selectionKey ||
|
|
222
|
+
this.keyreg.stateProofKey ||
|
|
223
|
+
typeof this.keyreg.voteFirst !== 'undefined' ||
|
|
224
|
+
typeof this.keyreg.voteLast !== 'undefined' ||
|
|
225
|
+
typeof this.keyreg.voteKeyDilution !== 'undefined')) {
|
|
226
|
+
throw new Error('nonParticipation is true but participation params are present.');
|
|
227
|
+
}
|
|
228
|
+
// Checking online key registration
|
|
229
|
+
if (
|
|
230
|
+
// If we are participating
|
|
231
|
+
!this.keyreg.nonParticipation &&
|
|
232
|
+
// And *ANY* participating fields are present
|
|
233
|
+
(this.keyreg.voteKey ||
|
|
234
|
+
this.keyreg.selectionKey ||
|
|
235
|
+
this.keyreg.stateProofKey ||
|
|
236
|
+
typeof this.keyreg.voteFirst !== 'undefined' ||
|
|
237
|
+
typeof this.keyreg.voteLast !== 'undefined' ||
|
|
238
|
+
typeof this.keyreg.voteKeyDilution !== 'undefined') &&
|
|
239
|
+
// Then *ALL* participating fields must be present (with an exception for stateProofKey,
|
|
240
|
+
// which was introduced later so for backwards compatibility we don't require it)
|
|
241
|
+
!(this.keyreg.voteKey &&
|
|
242
|
+
this.keyreg.selectionKey &&
|
|
243
|
+
typeof this.keyreg.voteFirst !== 'undefined' &&
|
|
244
|
+
typeof this.keyreg.voteLast !== 'undefined' &&
|
|
245
|
+
typeof this.keyreg.voteKeyDilution !== 'undefined')) {
|
|
246
|
+
throw new Error(`Online key registration missing at least one of the following fields: voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution`);
|
|
247
|
+
}
|
|
248
|
+
// The last option is an offline key registration where all the fields
|
|
249
|
+
// nonParticipation, voteKey, selectionKey, stateProofKey, voteFirst, voteLast, voteKeyDilution
|
|
250
|
+
// are all undefined
|
|
251
|
+
}
|
|
252
|
+
if (params.assetConfigParams) {
|
|
253
|
+
this.assetConfig = {
|
|
254
|
+
assetIndex: utils.ensureUint64(params.assetConfigParams.assetIndex ?? 0),
|
|
255
|
+
total: utils.ensureUint64(params.assetConfigParams.total ?? 0),
|
|
256
|
+
decimals: utils.ensureSafeUnsignedInteger(params.assetConfigParams.decimals ?? 0),
|
|
257
|
+
defaultFrozen: ensureBoolean(params.assetConfigParams.defaultFrozen ?? false),
|
|
258
|
+
manager: optionalAddress(params.assetConfigParams.manager),
|
|
259
|
+
reserve: optionalAddress(params.assetConfigParams.reserve),
|
|
260
|
+
freeze: optionalAddress(params.assetConfigParams.freeze),
|
|
261
|
+
clawback: optionalAddress(params.assetConfigParams.clawback),
|
|
262
|
+
unitName: params.assetConfigParams.unitName,
|
|
263
|
+
assetName: params.assetConfigParams.assetName,
|
|
264
|
+
assetURL: params.assetConfigParams.assetURL,
|
|
265
|
+
assetMetadataHash: optionalFixedLengthByteArray(params.assetConfigParams.assetMetadataHash, ASSET_METADATA_HASH_LENGTH, 'assetMetadataHash'),
|
|
459
266
|
};
|
|
460
|
-
if (this.assetManager !== undefined)
|
|
461
|
-
txn.apar.m = buffer_1.Buffer.from(this.assetManager.publicKey);
|
|
462
|
-
if (this.assetReserve !== undefined)
|
|
463
|
-
txn.apar.r = buffer_1.Buffer.from(this.assetReserve.publicKey);
|
|
464
|
-
if (this.assetFreeze !== undefined)
|
|
465
|
-
txn.apar.f = buffer_1.Buffer.from(this.assetFreeze.publicKey);
|
|
466
|
-
if (this.assetClawback !== undefined)
|
|
467
|
-
txn.apar.c = buffer_1.Buffer.from(this.assetClawback.publicKey);
|
|
468
|
-
if (this.assetName !== undefined)
|
|
469
|
-
txn.apar.an = this.assetName;
|
|
470
|
-
if (this.assetUnitName !== undefined)
|
|
471
|
-
txn.apar.un = this.assetUnitName;
|
|
472
|
-
if (this.assetURL !== undefined)
|
|
473
|
-
txn.apar.au = this.assetURL;
|
|
474
|
-
if (this.assetMetadataHash !== undefined)
|
|
475
|
-
txn.apar.am = buffer_1.Buffer.from(this.assetMetadataHash);
|
|
476
|
-
// allowed zero values
|
|
477
|
-
if (!txn.note.length)
|
|
478
|
-
delete txn.note;
|
|
479
|
-
if (!txn.lx.length)
|
|
480
|
-
delete txn.lx;
|
|
481
|
-
if (!txn.amt)
|
|
482
|
-
delete txn.amt;
|
|
483
|
-
if (!txn.fee)
|
|
484
|
-
delete txn.fee;
|
|
485
|
-
if (!txn.fv)
|
|
486
|
-
delete txn.fv;
|
|
487
|
-
if (!txn.gen)
|
|
488
|
-
delete txn.gen;
|
|
489
|
-
if (this.reKeyTo !== undefined) {
|
|
490
|
-
txn.rekey = buffer_1.Buffer.from(this.reKeyTo.publicKey);
|
|
491
|
-
}
|
|
492
|
-
if (!txn.caid)
|
|
493
|
-
delete txn.caid;
|
|
494
|
-
if (!txn.apar.t &&
|
|
495
|
-
!txn.apar.un &&
|
|
496
|
-
!txn.apar.an &&
|
|
497
|
-
!txn.apar.df &&
|
|
498
|
-
!txn.apar.m &&
|
|
499
|
-
!txn.apar.r &&
|
|
500
|
-
!txn.apar.f &&
|
|
501
|
-
!txn.apar.c &&
|
|
502
|
-
!txn.apar.au &&
|
|
503
|
-
!txn.apar.am &&
|
|
504
|
-
!txn.apar.dc) {
|
|
505
|
-
delete txn.apar;
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
if (!txn.apar.t)
|
|
509
|
-
delete txn.apar.t;
|
|
510
|
-
if (!txn.apar.dc)
|
|
511
|
-
delete txn.apar.dc;
|
|
512
|
-
if (!txn.apar.un)
|
|
513
|
-
delete txn.apar.un;
|
|
514
|
-
if (!txn.apar.an)
|
|
515
|
-
delete txn.apar.an;
|
|
516
|
-
if (!txn.apar.df)
|
|
517
|
-
delete txn.apar.df;
|
|
518
|
-
if (!txn.apar.m)
|
|
519
|
-
delete txn.apar.m;
|
|
520
|
-
if (!txn.apar.r)
|
|
521
|
-
delete txn.apar.r;
|
|
522
|
-
if (!txn.apar.f)
|
|
523
|
-
delete txn.apar.f;
|
|
524
|
-
if (!txn.apar.c)
|
|
525
|
-
delete txn.apar.c;
|
|
526
|
-
if (!txn.apar.au)
|
|
527
|
-
delete txn.apar.au;
|
|
528
|
-
if (!txn.apar.am)
|
|
529
|
-
delete txn.apar.am;
|
|
530
|
-
}
|
|
531
|
-
if (txn.grp === undefined)
|
|
532
|
-
delete txn.grp;
|
|
533
|
-
return txn;
|
|
534
267
|
}
|
|
535
|
-
if (
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
note: buffer_1.Buffer.from(this.note),
|
|
543
|
-
snd: buffer_1.Buffer.from(this.from.publicKey),
|
|
544
|
-
arcv: buffer_1.Buffer.from(this.to.publicKey),
|
|
545
|
-
type: this.type,
|
|
546
|
-
gen: this.genesisID,
|
|
547
|
-
gh: this.genesisHash,
|
|
548
|
-
lx: buffer_1.Buffer.from(this.lease),
|
|
549
|
-
grp: this.group,
|
|
550
|
-
xaid: this.assetIndex,
|
|
268
|
+
if (params.assetTransferParams) {
|
|
269
|
+
this.assetTransfer = {
|
|
270
|
+
assetIndex: utils.ensureUint64(params.assetTransferParams.assetIndex),
|
|
271
|
+
amount: utils.ensureUint64(params.assetTransferParams.amount),
|
|
272
|
+
assetSender: optionalAddress(params.assetTransferParams.assetSender),
|
|
273
|
+
receiver: ensureAddress(params.assetTransferParams.receiver),
|
|
274
|
+
closeRemainderTo: optionalAddress(params.assetTransferParams.closeRemainderTo),
|
|
551
275
|
};
|
|
552
|
-
if (this.closeRemainderTo !== undefined)
|
|
553
|
-
txn.aclose = buffer_1.Buffer.from(this.closeRemainderTo.publicKey);
|
|
554
|
-
if (this.assetRevocationTarget !== undefined)
|
|
555
|
-
txn.asnd = buffer_1.Buffer.from(this.assetRevocationTarget.publicKey);
|
|
556
|
-
// allowed zero values
|
|
557
|
-
if (!txn.note.length)
|
|
558
|
-
delete txn.note;
|
|
559
|
-
if (!txn.lx.length)
|
|
560
|
-
delete txn.lx;
|
|
561
|
-
if (!txn.aamt)
|
|
562
|
-
delete txn.aamt;
|
|
563
|
-
if (!txn.amt)
|
|
564
|
-
delete txn.amt;
|
|
565
|
-
if (!txn.fee)
|
|
566
|
-
delete txn.fee;
|
|
567
|
-
if (!txn.fv)
|
|
568
|
-
delete txn.fv;
|
|
569
|
-
if (!txn.gen)
|
|
570
|
-
delete txn.gen;
|
|
571
|
-
if (txn.grp === undefined)
|
|
572
|
-
delete txn.grp;
|
|
573
|
-
if (!txn.aclose)
|
|
574
|
-
delete txn.aclose;
|
|
575
|
-
if (!txn.asnd)
|
|
576
|
-
delete txn.asnd;
|
|
577
|
-
if (!txn.rekey)
|
|
578
|
-
delete txn.rekey;
|
|
579
|
-
if (this.reKeyTo !== undefined) {
|
|
580
|
-
txn.rekey = buffer_1.Buffer.from(this.reKeyTo.publicKey);
|
|
581
|
-
}
|
|
582
|
-
return txn;
|
|
583
276
|
}
|
|
584
|
-
if (
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
lv: this.lastRound,
|
|
590
|
-
note: buffer_1.Buffer.from(this.note),
|
|
591
|
-
snd: buffer_1.Buffer.from(this.from.publicKey),
|
|
592
|
-
type: this.type,
|
|
593
|
-
gen: this.genesisID,
|
|
594
|
-
gh: this.genesisHash,
|
|
595
|
-
lx: buffer_1.Buffer.from(this.lease),
|
|
596
|
-
grp: this.group,
|
|
597
|
-
faid: this.assetIndex,
|
|
598
|
-
afrz: this.freezeState,
|
|
277
|
+
if (params.assetFreezeParams) {
|
|
278
|
+
this.assetFreeze = {
|
|
279
|
+
assetIndex: utils.ensureUint64(params.assetFreezeParams.assetIndex),
|
|
280
|
+
freezeAccount: ensureAddress(params.assetFreezeParams.freezeTarget),
|
|
281
|
+
frozen: ensureBoolean(params.assetFreezeParams.frozen),
|
|
599
282
|
};
|
|
600
|
-
if (this.freezeAccount !== undefined)
|
|
601
|
-
txn.fadd = buffer_1.Buffer.from(this.freezeAccount.publicKey);
|
|
602
|
-
// allowed zero values
|
|
603
|
-
if (!txn.note.length)
|
|
604
|
-
delete txn.note;
|
|
605
|
-
if (!txn.lx.length)
|
|
606
|
-
delete txn.lx;
|
|
607
|
-
if (!txn.amt)
|
|
608
|
-
delete txn.amt;
|
|
609
|
-
if (!txn.fee)
|
|
610
|
-
delete txn.fee;
|
|
611
|
-
if (!txn.fv)
|
|
612
|
-
delete txn.fv;
|
|
613
|
-
if (!txn.gen)
|
|
614
|
-
delete txn.gen;
|
|
615
|
-
if (!txn.afrz)
|
|
616
|
-
delete txn.afrz;
|
|
617
|
-
if (txn.grp === undefined)
|
|
618
|
-
delete txn.grp;
|
|
619
|
-
if (this.reKeyTo !== undefined) {
|
|
620
|
-
txn.rekey = buffer_1.Buffer.from(this.reKeyTo.publicKey);
|
|
621
|
-
}
|
|
622
|
-
return txn;
|
|
623
283
|
}
|
|
624
|
-
if (
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
nui: this.appGlobalInts,
|
|
645
|
-
nbs: this.appGlobalByteSlices,
|
|
646
|
-
},
|
|
647
|
-
apfa: this.appForeignApps,
|
|
648
|
-
apas: this.appForeignAssets,
|
|
649
|
-
apep: this.extraPages,
|
|
650
|
-
apbx: (0, boxStorage_1.translateBoxReferences)(this.boxes, this.appForeignApps, this.appIndex),
|
|
284
|
+
if (params.appCallParams) {
|
|
285
|
+
const { onComplete } = params.appCallParams;
|
|
286
|
+
if (!(0, base_js_1.isOnApplicationComplete)(onComplete)) {
|
|
287
|
+
throw new Error(`Invalid onCompletion value: ${onComplete}`);
|
|
288
|
+
}
|
|
289
|
+
this.applicationCall = {
|
|
290
|
+
appIndex: utils.ensureUint64(params.appCallParams.appIndex),
|
|
291
|
+
onComplete,
|
|
292
|
+
numLocalInts: utils.ensureSafeUnsignedInteger(params.appCallParams.numLocalInts ?? 0),
|
|
293
|
+
numLocalByteSlices: utils.ensureSafeUnsignedInteger(params.appCallParams.numLocalByteSlices ?? 0),
|
|
294
|
+
numGlobalInts: utils.ensureSafeUnsignedInteger(params.appCallParams.numGlobalInts ?? 0),
|
|
295
|
+
numGlobalByteSlices: utils.ensureSafeUnsignedInteger(params.appCallParams.numGlobalByteSlices ?? 0),
|
|
296
|
+
extraPages: utils.ensureSafeUnsignedInteger(params.appCallParams.extraPages ?? 0),
|
|
297
|
+
approvalProgram: ensureUint8Array(params.appCallParams.approvalProgram ?? new Uint8Array()),
|
|
298
|
+
clearProgram: ensureUint8Array(params.appCallParams.clearProgram ?? new Uint8Array()),
|
|
299
|
+
appArgs: ensureArray(params.appCallParams.appArgs ?? []).map(ensureUint8Array),
|
|
300
|
+
accounts: ensureArray(params.appCallParams.accounts ?? []).map(ensureAddress),
|
|
301
|
+
foreignApps: ensureArray(params.appCallParams.foreignApps ?? []).map(utils.ensureUint64),
|
|
302
|
+
foreignAssets: ensureArray(params.appCallParams.foreignAssets ?? []).map(utils.ensureUint64),
|
|
303
|
+
boxes: ensureArray(params.appCallParams.boxes ?? []).map(ensureBoxReference),
|
|
651
304
|
};
|
|
652
|
-
if (this.reKeyTo !== undefined) {
|
|
653
|
-
txn.rekey = buffer_1.Buffer.from(this.reKeyTo.publicKey);
|
|
654
|
-
}
|
|
655
|
-
if (this.appApprovalProgram !== undefined) {
|
|
656
|
-
txn.apap = buffer_1.Buffer.from(this.appApprovalProgram);
|
|
657
|
-
}
|
|
658
|
-
if (this.appClearProgram !== undefined) {
|
|
659
|
-
txn.apsu = buffer_1.Buffer.from(this.appClearProgram);
|
|
660
|
-
}
|
|
661
|
-
if (this.appArgs !== undefined) {
|
|
662
|
-
txn.apaa = this.appArgs.map((arg) => buffer_1.Buffer.from(arg));
|
|
663
|
-
}
|
|
664
|
-
if (this.appAccounts !== undefined) {
|
|
665
|
-
txn.apat = this.appAccounts.map((decodedAddress) => buffer_1.Buffer.from(decodedAddress.publicKey));
|
|
666
|
-
}
|
|
667
|
-
// allowed zero values
|
|
668
|
-
if (!txn.note.length)
|
|
669
|
-
delete txn.note;
|
|
670
|
-
if (!txn.lx.length)
|
|
671
|
-
delete txn.lx;
|
|
672
|
-
if (!txn.amt)
|
|
673
|
-
delete txn.amt;
|
|
674
|
-
if (!txn.fee)
|
|
675
|
-
delete txn.fee;
|
|
676
|
-
if (!txn.fv)
|
|
677
|
-
delete txn.fv;
|
|
678
|
-
if (!txn.gen)
|
|
679
|
-
delete txn.gen;
|
|
680
|
-
if (!txn.apid)
|
|
681
|
-
delete txn.apid;
|
|
682
|
-
if (!txn.apls.nui)
|
|
683
|
-
delete txn.apls.nui;
|
|
684
|
-
if (!txn.apls.nbs)
|
|
685
|
-
delete txn.apls.nbs;
|
|
686
|
-
if (!txn.apls.nui && !txn.apls.nbs)
|
|
687
|
-
delete txn.apls;
|
|
688
|
-
if (!txn.apgs.nui)
|
|
689
|
-
delete txn.apgs.nui;
|
|
690
|
-
if (!txn.apgs.nbs)
|
|
691
|
-
delete txn.apgs.nbs;
|
|
692
|
-
if (!txn.apaa || !txn.apaa.length)
|
|
693
|
-
delete txn.apaa;
|
|
694
|
-
if (!txn.apgs.nui && !txn.apgs.nbs)
|
|
695
|
-
delete txn.apgs;
|
|
696
|
-
if (!txn.apap)
|
|
697
|
-
delete txn.apap;
|
|
698
|
-
if (!txn.apsu)
|
|
699
|
-
delete txn.apsu;
|
|
700
|
-
if (!txn.apan)
|
|
701
|
-
delete txn.apan;
|
|
702
|
-
if (!txn.apfa || !txn.apfa.length)
|
|
703
|
-
delete txn.apfa;
|
|
704
|
-
if (!txn.apas || !txn.apas.length)
|
|
705
|
-
delete txn.apas;
|
|
706
|
-
for (const box of txn.apbx) {
|
|
707
|
-
if (!box.i)
|
|
708
|
-
delete box.i;
|
|
709
|
-
if (!box.n || !box.n.length)
|
|
710
|
-
delete box.n;
|
|
711
|
-
}
|
|
712
|
-
if (!txn.apbx || !txn.apbx.length)
|
|
713
|
-
delete txn.apbx;
|
|
714
|
-
if (!txn.apat || !txn.apat.length)
|
|
715
|
-
delete txn.apat;
|
|
716
|
-
if (!txn.apep)
|
|
717
|
-
delete txn.apep;
|
|
718
|
-
if (txn.grp === undefined)
|
|
719
|
-
delete txn.grp;
|
|
720
|
-
return txn;
|
|
721
305
|
}
|
|
722
|
-
if (
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
lv: this.lastRound,
|
|
728
|
-
note: buffer_1.Buffer.from(this.note),
|
|
729
|
-
snd: buffer_1.Buffer.from(this.from.publicKey),
|
|
730
|
-
type: this.type,
|
|
731
|
-
gen: this.genesisID,
|
|
732
|
-
gh: this.genesisHash,
|
|
733
|
-
lx: buffer_1.Buffer.from(this.lease),
|
|
734
|
-
sptype: this.stateProofType,
|
|
735
|
-
spmsg: buffer_1.Buffer.from(this.stateProofMessage),
|
|
736
|
-
sp: buffer_1.Buffer.from(this.stateProof),
|
|
306
|
+
if (params.stateProofParams) {
|
|
307
|
+
this.stateProof = {
|
|
308
|
+
stateProofType: utils.ensureSafeUnsignedInteger(params.stateProofParams.stateProofType ?? 0),
|
|
309
|
+
stateProof: params.stateProofParams.stateProof,
|
|
310
|
+
message: params.stateProofParams.message,
|
|
737
311
|
};
|
|
738
|
-
// allowed zero values
|
|
739
|
-
if (!txn.sptype)
|
|
740
|
-
delete txn.sptype;
|
|
741
|
-
if (!txn.note.length)
|
|
742
|
-
delete txn.note;
|
|
743
|
-
if (!txn.lx.length)
|
|
744
|
-
delete txn.lx;
|
|
745
|
-
if (!txn.amt)
|
|
746
|
-
delete txn.amt;
|
|
747
|
-
if (!txn.fee)
|
|
748
|
-
delete txn.fee;
|
|
749
|
-
if (!txn.fv)
|
|
750
|
-
delete txn.fv;
|
|
751
|
-
if (!txn.gen)
|
|
752
|
-
delete txn.gen;
|
|
753
|
-
if (!txn.apid)
|
|
754
|
-
delete txn.apid;
|
|
755
|
-
if (!txn.apaa || !txn.apaa.length)
|
|
756
|
-
delete txn.apaa;
|
|
757
|
-
if (!txn.apap)
|
|
758
|
-
delete txn.apap;
|
|
759
|
-
if (!txn.apsu)
|
|
760
|
-
delete txn.apsu;
|
|
761
|
-
if (!txn.apan)
|
|
762
|
-
delete txn.apan;
|
|
763
|
-
if (!txn.apfa || !txn.apfa.length)
|
|
764
|
-
delete txn.apfa;
|
|
765
|
-
if (!txn.apas || !txn.apas.length)
|
|
766
|
-
delete txn.apas;
|
|
767
|
-
if (!txn.apat || !txn.apat.length)
|
|
768
|
-
delete txn.apat;
|
|
769
|
-
if (!txn.apep)
|
|
770
|
-
delete txn.apep;
|
|
771
|
-
if (txn.grp === undefined)
|
|
772
|
-
delete txn.grp;
|
|
773
|
-
return txn;
|
|
774
312
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
if (!(0, base_1.isTransactionType)(txnForEnc.type)) {
|
|
785
|
-
throw new Error(`Unrecognized transaction type: ${txnForEnc.type}`);
|
|
786
|
-
}
|
|
787
|
-
txn.type = txnForEnc.type;
|
|
788
|
-
txn.fee = txnForEnc.fee;
|
|
789
|
-
txn.firstRound = txnForEnc.fv;
|
|
790
|
-
txn.lastRound = txnForEnc.lv;
|
|
791
|
-
txn.note = new Uint8Array(txnForEnc.note);
|
|
792
|
-
txn.lease = new Uint8Array(txnForEnc.lx);
|
|
793
|
-
txn.from = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.snd)));
|
|
794
|
-
if (txnForEnc.grp !== undefined)
|
|
795
|
-
txn.group = buffer_1.Buffer.from(txnForEnc.grp);
|
|
796
|
-
if (txnForEnc.rekey !== undefined)
|
|
797
|
-
txn.reKeyTo = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.rekey)));
|
|
798
|
-
if (txnForEnc.type === 'pay') {
|
|
799
|
-
txn.amount = txnForEnc.amt;
|
|
800
|
-
txn.to = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.rcv)));
|
|
801
|
-
if (txnForEnc.close !== undefined)
|
|
802
|
-
txn.closeRemainderTo = address.decodeAddress(address.encodeAddress(txnForEnc.close));
|
|
803
|
-
}
|
|
804
|
-
else if (txnForEnc.type === 'keyreg') {
|
|
805
|
-
if (txnForEnc.votekey !== undefined) {
|
|
806
|
-
txn.voteKey = buffer_1.Buffer.from(txnForEnc.votekey);
|
|
807
|
-
}
|
|
808
|
-
if (txnForEnc.selkey !== undefined) {
|
|
809
|
-
txn.selectionKey = buffer_1.Buffer.from(txnForEnc.selkey);
|
|
810
|
-
}
|
|
811
|
-
if (txnForEnc.sprfkey !== undefined) {
|
|
812
|
-
txn.stateProofKey = buffer_1.Buffer.from(txnForEnc.sprfkey);
|
|
813
|
-
}
|
|
814
|
-
if (txnForEnc.votekd !== undefined) {
|
|
815
|
-
txn.voteKeyDilution = txnForEnc.votekd;
|
|
816
|
-
}
|
|
817
|
-
if (txnForEnc.votefst !== undefined) {
|
|
818
|
-
txn.voteFirst = txnForEnc.votefst;
|
|
819
|
-
}
|
|
820
|
-
if (txnForEnc.votelst !== undefined) {
|
|
821
|
-
txn.voteLast = txnForEnc.votelst;
|
|
822
|
-
}
|
|
823
|
-
if (txnForEnc.nonpart !== undefined) {
|
|
824
|
-
txn.nonParticipation = txnForEnc.nonpart;
|
|
313
|
+
// Determine fee
|
|
314
|
+
this.fee = utils.ensureUint64(params.suggestedParams.fee);
|
|
315
|
+
const feeDependsOnSize = !ensureBoolean(params.suggestedParams.flatFee ?? false);
|
|
316
|
+
if (feeDependsOnSize) {
|
|
317
|
+
const minFee = utils.ensureUint64(params.suggestedParams.minFee);
|
|
318
|
+
this.fee *= BigInt(this.estimateSize());
|
|
319
|
+
// If suggested fee too small and will be rejected, set to min tx fee
|
|
320
|
+
if (this.fee < minFee) {
|
|
321
|
+
this.fee = minFee;
|
|
825
322
|
}
|
|
826
323
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
324
|
+
}
|
|
325
|
+
// eslint-disable-next-line class-methods-use-this
|
|
326
|
+
getEncodingSchema() {
|
|
327
|
+
return Transaction.encodingSchema;
|
|
328
|
+
}
|
|
329
|
+
toEncodingData() {
|
|
330
|
+
const data = new Map([
|
|
331
|
+
['type', this.type],
|
|
332
|
+
['fv', this.firstValid],
|
|
333
|
+
['lv', this.lastValid],
|
|
334
|
+
['snd', this.sender],
|
|
335
|
+
['gen', this.genesisID],
|
|
336
|
+
['gh', this.genesisHash],
|
|
337
|
+
['fee', this.fee],
|
|
338
|
+
['note', this.note],
|
|
339
|
+
['lx', this.lease],
|
|
340
|
+
['rekey', this.rekeyTo],
|
|
341
|
+
['grp', this.group],
|
|
342
|
+
]);
|
|
343
|
+
if (this.payment) {
|
|
344
|
+
data.set('amt', this.payment.amount);
|
|
345
|
+
data.set('rcv', this.payment.receiver);
|
|
346
|
+
data.set('close', this.payment.closeRemainderTo);
|
|
347
|
+
return data;
|
|
348
|
+
}
|
|
349
|
+
if (this.keyreg) {
|
|
350
|
+
data.set('votekey', this.keyreg.voteKey);
|
|
351
|
+
data.set('selkey', this.keyreg.selectionKey);
|
|
352
|
+
data.set('sprfkey', this.keyreg.stateProofKey);
|
|
353
|
+
data.set('votefst', this.keyreg.voteFirst);
|
|
354
|
+
data.set('votelst', this.keyreg.voteLast);
|
|
355
|
+
data.set('votekd', this.keyreg.voteKeyDilution);
|
|
356
|
+
data.set('nonpart', this.keyreg.nonParticipation);
|
|
357
|
+
return data;
|
|
358
|
+
}
|
|
359
|
+
if (this.assetConfig) {
|
|
360
|
+
data.set('caid', this.assetConfig.assetIndex);
|
|
361
|
+
const assetParams = new Map([
|
|
362
|
+
['t', this.assetConfig.total],
|
|
363
|
+
['dc', this.assetConfig.decimals],
|
|
364
|
+
['df', this.assetConfig.defaultFrozen],
|
|
365
|
+
['m', this.assetConfig.manager],
|
|
366
|
+
['r', this.assetConfig.reserve],
|
|
367
|
+
['f', this.assetConfig.freeze],
|
|
368
|
+
['c', this.assetConfig.clawback],
|
|
369
|
+
['un', this.assetConfig.unitName],
|
|
370
|
+
['an', this.assetConfig.assetName],
|
|
371
|
+
['au', this.assetConfig.assetURL],
|
|
372
|
+
['am', this.assetConfig.assetMetadataHash],
|
|
373
|
+
]);
|
|
374
|
+
data.set('apar', assetParams);
|
|
375
|
+
return data;
|
|
376
|
+
}
|
|
377
|
+
if (this.assetTransfer) {
|
|
378
|
+
data.set('xaid', this.assetTransfer.assetIndex);
|
|
379
|
+
data.set('aamt', this.assetTransfer.amount);
|
|
380
|
+
data.set('arcv', this.assetTransfer.receiver);
|
|
381
|
+
data.set('aclose', this.assetTransfer.closeRemainderTo);
|
|
382
|
+
data.set('asnd', this.assetTransfer.assetSender);
|
|
383
|
+
return data;
|
|
384
|
+
}
|
|
385
|
+
if (this.assetFreeze) {
|
|
386
|
+
data.set('faid', this.assetFreeze.assetIndex);
|
|
387
|
+
data.set('afrz', this.assetFreeze.frozen);
|
|
388
|
+
data.set('fadd', this.assetFreeze.freezeAccount);
|
|
389
|
+
return data;
|
|
390
|
+
}
|
|
391
|
+
if (this.applicationCall) {
|
|
392
|
+
data.set('apid', this.applicationCall.appIndex);
|
|
393
|
+
data.set('apan', this.applicationCall.onComplete);
|
|
394
|
+
data.set('apaa', this.applicationCall.appArgs);
|
|
395
|
+
data.set('apat', this.applicationCall.accounts);
|
|
396
|
+
data.set('apas', this.applicationCall.foreignAssets);
|
|
397
|
+
data.set('apfa', this.applicationCall.foreignApps);
|
|
398
|
+
data.set('apbx', (0, boxStorage_js_1.boxReferencesToEncodingData)(this.applicationCall.boxes, this.applicationCall.foreignApps, this.applicationCall.appIndex));
|
|
399
|
+
data.set('apap', this.applicationCall.approvalProgram);
|
|
400
|
+
data.set('apsu', this.applicationCall.clearProgram);
|
|
401
|
+
data.set('apls', new Map([
|
|
402
|
+
['nui', this.applicationCall.numLocalInts],
|
|
403
|
+
['nbs', this.applicationCall.numLocalByteSlices],
|
|
404
|
+
]));
|
|
405
|
+
data.set('apgs', new Map([
|
|
406
|
+
['nui', this.applicationCall.numGlobalInts],
|
|
407
|
+
['nbs', this.applicationCall.numGlobalByteSlices],
|
|
408
|
+
]));
|
|
409
|
+
data.set('apep', this.applicationCall.extraPages);
|
|
410
|
+
return data;
|
|
411
|
+
}
|
|
412
|
+
if (this.stateProof) {
|
|
413
|
+
data.set('sptype', this.stateProof.stateProofType);
|
|
414
|
+
data.set('sp', this.stateProof.stateProof
|
|
415
|
+
? this.stateProof.stateProof.toEncodingData()
|
|
416
|
+
: undefined);
|
|
417
|
+
data.set('spmsg', this.stateProof.message
|
|
418
|
+
? this.stateProof.message.toEncodingData()
|
|
419
|
+
: undefined);
|
|
420
|
+
return data;
|
|
421
|
+
}
|
|
422
|
+
throw new Error(`Unexpected transaction type: ${this.type}`);
|
|
423
|
+
}
|
|
424
|
+
static fromEncodingData(data) {
|
|
425
|
+
if (!(data instanceof Map)) {
|
|
426
|
+
throw new Error(`Invalid decoded logic sig account: ${data}`);
|
|
427
|
+
}
|
|
428
|
+
const suggestedParams = {
|
|
429
|
+
minFee: BigInt(0),
|
|
430
|
+
flatFee: true,
|
|
431
|
+
fee: data.get('fee') ?? 0,
|
|
432
|
+
firstValid: data.get('fv') ?? 0,
|
|
433
|
+
lastValid: data.get('lv') ?? 0,
|
|
434
|
+
genesisHash: data.get('gh'),
|
|
435
|
+
genesisID: data.get('gen'),
|
|
436
|
+
};
|
|
437
|
+
const txnType = data.get('type');
|
|
438
|
+
if (!(0, base_js_1.isTransactionType)(txnType)) {
|
|
439
|
+
throw new Error(`Unrecognized transaction type: ${txnType}`);
|
|
440
|
+
}
|
|
441
|
+
const params = {
|
|
442
|
+
type: txnType,
|
|
443
|
+
sender: data.get('snd') ?? address_js_1.Address.zeroAddress(),
|
|
444
|
+
note: data.get('note'),
|
|
445
|
+
lease: data.get('lx'),
|
|
446
|
+
suggestedParams,
|
|
447
|
+
};
|
|
448
|
+
if (data.get('rekey')) {
|
|
449
|
+
params.rekeyTo = data.get('rekey');
|
|
854
450
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
if (
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
451
|
+
if (params.type === base_js_1.TransactionType.pay) {
|
|
452
|
+
const paymentParams = {
|
|
453
|
+
amount: data.get('amt') ?? 0,
|
|
454
|
+
receiver: data.get('rcv') ?? address_js_1.Address.zeroAddress(),
|
|
455
|
+
};
|
|
456
|
+
if (data.get('close')) {
|
|
457
|
+
paymentParams.closeRemainderTo = data.get('close');
|
|
458
|
+
}
|
|
459
|
+
params.paymentParams = paymentParams;
|
|
460
|
+
}
|
|
461
|
+
else if (params.type === base_js_1.TransactionType.keyreg) {
|
|
462
|
+
const keyregParams = {
|
|
463
|
+
voteKey: data.get('votekey'),
|
|
464
|
+
selectionKey: data.get('selkey'),
|
|
465
|
+
stateProofKey: data.get('sprfkey'),
|
|
466
|
+
voteFirst: data.get('votefst'),
|
|
467
|
+
voteLast: data.get('votelst'),
|
|
468
|
+
voteKeyDilution: data.get('votekd'),
|
|
469
|
+
nonParticipation: data.get('nonpart'),
|
|
470
|
+
};
|
|
471
|
+
params.keyregParams = keyregParams;
|
|
869
472
|
}
|
|
870
|
-
else if (
|
|
871
|
-
|
|
872
|
-
|
|
473
|
+
else if (params.type === base_js_1.TransactionType.acfg) {
|
|
474
|
+
const assetConfigParams = {
|
|
475
|
+
assetIndex: data.get('caid'),
|
|
476
|
+
};
|
|
477
|
+
if (data.get('apar')) {
|
|
478
|
+
const assetParams = data.get('apar');
|
|
479
|
+
assetConfigParams.total = assetParams.get('t');
|
|
480
|
+
assetConfigParams.decimals = assetParams.get('dc');
|
|
481
|
+
assetConfigParams.defaultFrozen = assetParams.get('df');
|
|
482
|
+
assetConfigParams.unitName = assetParams.get('un');
|
|
483
|
+
assetConfigParams.assetName = assetParams.get('an');
|
|
484
|
+
assetConfigParams.assetURL = assetParams.get('au');
|
|
485
|
+
assetConfigParams.assetMetadataHash = assetParams.get('am');
|
|
486
|
+
if (assetParams.get('m')) {
|
|
487
|
+
assetConfigParams.manager = assetParams.get('m');
|
|
488
|
+
}
|
|
489
|
+
if (assetParams.get('r')) {
|
|
490
|
+
assetConfigParams.reserve = assetParams.get('r');
|
|
491
|
+
}
|
|
492
|
+
if (assetParams.get('f')) {
|
|
493
|
+
assetConfigParams.freeze = assetParams.get('f');
|
|
494
|
+
}
|
|
495
|
+
if (assetParams.get('c')) {
|
|
496
|
+
assetConfigParams.clawback = assetParams.get('c');
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
params.assetConfigParams = assetConfigParams;
|
|
500
|
+
}
|
|
501
|
+
else if (params.type === base_js_1.TransactionType.axfer) {
|
|
502
|
+
const assetTransferParams = {
|
|
503
|
+
assetIndex: data.get('xaid') ?? 0,
|
|
504
|
+
amount: data.get('aamt') ?? 0,
|
|
505
|
+
receiver: data.get('arcv') ?? address_js_1.Address.zeroAddress(),
|
|
506
|
+
};
|
|
507
|
+
if (data.get('aclose')) {
|
|
508
|
+
assetTransferParams.closeRemainderTo = data.get('aclose');
|
|
873
509
|
}
|
|
874
|
-
if (
|
|
875
|
-
|
|
510
|
+
if (data.get('asnd')) {
|
|
511
|
+
assetTransferParams.assetSender = data.get('asnd');
|
|
876
512
|
}
|
|
877
|
-
|
|
513
|
+
params.assetTransferParams = assetTransferParams;
|
|
878
514
|
}
|
|
879
|
-
else if (
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
if (
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
515
|
+
else if (params.type === base_js_1.TransactionType.afrz) {
|
|
516
|
+
const assetFreezeParams = {
|
|
517
|
+
assetIndex: data.get('faid') ?? 0,
|
|
518
|
+
freezeTarget: data.get('fadd') ?? address_js_1.Address.zeroAddress(),
|
|
519
|
+
frozen: data.get('afrz') ?? false,
|
|
520
|
+
};
|
|
521
|
+
params.assetFreezeParams = assetFreezeParams;
|
|
522
|
+
}
|
|
523
|
+
else if (params.type === base_js_1.TransactionType.appl) {
|
|
524
|
+
const appCallParams = {
|
|
525
|
+
appIndex: data.get('apid') ?? 0,
|
|
526
|
+
onComplete: utils.ensureSafeUnsignedInteger(data.get('apan') ?? 0),
|
|
527
|
+
appArgs: data.get('apaa'),
|
|
528
|
+
accounts: data.get('apat'),
|
|
529
|
+
foreignAssets: data.get('apas'),
|
|
530
|
+
foreignApps: data.get('apfa'),
|
|
531
|
+
approvalProgram: data.get('apap'),
|
|
532
|
+
clearProgram: data.get('apsu'),
|
|
533
|
+
extraPages: data.get('apep'),
|
|
534
|
+
};
|
|
535
|
+
const localSchema = data.get('apls');
|
|
536
|
+
if (localSchema) {
|
|
537
|
+
appCallParams.numLocalInts = localSchema.get('nui');
|
|
538
|
+
appCallParams.numLocalByteSlices = localSchema.get('nbs');
|
|
539
|
+
}
|
|
540
|
+
const globalSchema = data.get('apgs');
|
|
541
|
+
if (globalSchema) {
|
|
542
|
+
appCallParams.numGlobalInts = globalSchema.get('nui');
|
|
543
|
+
appCallParams.numGlobalByteSlices = globalSchema.get('nbs');
|
|
544
|
+
}
|
|
545
|
+
const boxes = data.get('apbx');
|
|
546
|
+
if (boxes) {
|
|
547
|
+
appCallParams.boxes = boxes.map((box) => {
|
|
548
|
+
const index = utils.ensureSafeUnsignedInteger(box.get('i') ?? 0);
|
|
549
|
+
const name = ensureUint8Array(box.get('n') ?? new Uint8Array());
|
|
550
|
+
if (index === 0) {
|
|
551
|
+
// We return 0 for the app ID so that it's guaranteed translateBoxReferences will
|
|
552
|
+
// translate the app index back to 0. If we instead returned the called app ID,
|
|
553
|
+
// translateBoxReferences would translate the app index to a nonzero value if the called
|
|
554
|
+
// app is also in the foreign app array.
|
|
555
|
+
return {
|
|
556
|
+
appIndex: 0,
|
|
557
|
+
name,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (!appCallParams.foreignApps ||
|
|
561
|
+
index > appCallParams.foreignApps.length) {
|
|
562
|
+
throw new Error(`Cannot find foreign app index ${index} in ${appCallParams.foreignApps}`);
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
appIndex: appCallParams.foreignApps[index - 1],
|
|
566
|
+
name,
|
|
567
|
+
};
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
params.appCallParams = appCallParams;
|
|
571
|
+
}
|
|
572
|
+
else if (params.type === base_js_1.TransactionType.stpf) {
|
|
573
|
+
const stateProofParams = {
|
|
574
|
+
stateProofType: data.get('sptype'),
|
|
575
|
+
stateProof: data.get('sp')
|
|
576
|
+
? stateproof_js_1.StateProof.fromEncodingData(data.get('sp'))
|
|
577
|
+
: undefined,
|
|
578
|
+
message: data.get('spmsg')
|
|
579
|
+
? stateproof_js_1.StateProofMessage.fromEncodingData(data.get('spmsg'))
|
|
580
|
+
: undefined,
|
|
581
|
+
};
|
|
582
|
+
params.stateProofParams = stateProofParams;
|
|
929
583
|
}
|
|
930
|
-
else
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
if (
|
|
938
|
-
|
|
584
|
+
else {
|
|
585
|
+
const exhaustiveCheck = params.type;
|
|
586
|
+
throw new Error(`Unexpected transaction type: ${exhaustiveCheck}`);
|
|
587
|
+
}
|
|
588
|
+
const txn = new Transaction(params);
|
|
589
|
+
if (data.get('grp')) {
|
|
590
|
+
const group = ensureUint8Array(data.get('grp'));
|
|
591
|
+
if (group.byteLength !== ALGORAND_TRANSACTION_GROUP_LENGTH) {
|
|
592
|
+
throw new Error(`Invalid group length: ${group.byteLength}`);
|
|
939
593
|
}
|
|
594
|
+
txn.group = group;
|
|
940
595
|
}
|
|
941
596
|
return txn;
|
|
942
597
|
}
|
|
@@ -945,187 +600,247 @@ class Transaction {
|
|
|
945
600
|
}
|
|
946
601
|
bytesToSign() {
|
|
947
602
|
const encodedMsg = this.toByte();
|
|
948
|
-
return
|
|
603
|
+
return utils.concatArrays(TX_TAG, encodedMsg);
|
|
949
604
|
}
|
|
950
605
|
toByte() {
|
|
951
|
-
return encoding.
|
|
606
|
+
return encoding.encodeMsgpack(this);
|
|
952
607
|
}
|
|
953
608
|
// returns the raw signature
|
|
954
609
|
rawSignTxn(sk) {
|
|
955
610
|
const toBeSigned = this.bytesToSign();
|
|
956
611
|
const sig = nacl.sign(toBeSigned, sk);
|
|
957
|
-
return
|
|
612
|
+
return sig;
|
|
958
613
|
}
|
|
959
614
|
signTxn(sk) {
|
|
960
|
-
//
|
|
961
|
-
const sTxn = {
|
|
962
|
-
sig: this.rawSignTxn(sk),
|
|
963
|
-
txn: this.get_obj_for_encoding(),
|
|
964
|
-
};
|
|
965
|
-
// add AuthAddr if signing with a different key than From indicates
|
|
615
|
+
// TODO: deprecate in favor of SignedTransaction class
|
|
966
616
|
const keypair = nacl.keyPairFromSecretKey(sk);
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
sTxn.sgnr = buffer_1.Buffer.from(pubKeyFromSk);
|
|
971
|
-
}
|
|
972
|
-
return new Uint8Array(encoding.encode(sTxn));
|
|
617
|
+
const signerAddr = new address_js_1.Address(keypair.publicKey);
|
|
618
|
+
const sig = this.rawSignTxn(sk);
|
|
619
|
+
return this.attachSignature(signerAddr, sig);
|
|
973
620
|
}
|
|
974
621
|
attachSignature(signerAddr, signature) {
|
|
622
|
+
// TODO: deprecate in favor of SignedTransaction class
|
|
975
623
|
if (!nacl.isValidSignatureLength(signature.length)) {
|
|
976
624
|
throw new Error('Invalid signature length');
|
|
977
625
|
}
|
|
978
|
-
const sTxn =
|
|
979
|
-
sig
|
|
980
|
-
txn
|
|
981
|
-
|
|
626
|
+
const sTxn = new Map([
|
|
627
|
+
['sig', signature],
|
|
628
|
+
['txn', this.toEncodingData()],
|
|
629
|
+
]);
|
|
630
|
+
const signerAddrObj = ensureAddress(signerAddr);
|
|
982
631
|
// add AuthAddr if signing with a different key than From indicates
|
|
983
|
-
if (
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
632
|
+
if (!this.sender.equals(signerAddrObj)) {
|
|
633
|
+
sTxn.set('sgnr', signerAddrObj);
|
|
634
|
+
}
|
|
635
|
+
// This is a hack to avoid a circular reference with the SignedTransaction class
|
|
636
|
+
const stxnSchema = new index_js_1.NamedMapSchema((0, index_js_1.allOmitEmpty)([
|
|
637
|
+
{
|
|
638
|
+
key: 'txn',
|
|
639
|
+
valueSchema: Transaction.encodingSchema,
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
key: 'sig',
|
|
643
|
+
valueSchema: new index_js_1.FixedLengthByteArraySchema(64),
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
key: 'sgnr',
|
|
647
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()),
|
|
648
|
+
},
|
|
649
|
+
]));
|
|
650
|
+
return encoding.msgpackRawEncode(stxnSchema.prepareMsgpack(sTxn));
|
|
988
651
|
}
|
|
989
652
|
rawTxID() {
|
|
990
653
|
const enMsg = this.toByte();
|
|
991
|
-
const gh =
|
|
992
|
-
return
|
|
654
|
+
const gh = utils.concatArrays(TX_TAG, enMsg);
|
|
655
|
+
return Uint8Array.from(nacl.genericHash(gh));
|
|
993
656
|
}
|
|
994
657
|
txID() {
|
|
995
658
|
const hash = this.rawTxID();
|
|
996
659
|
return hi_base32_1.default.encode(hash).slice(0, ALGORAND_TRANSACTION_LENGTH);
|
|
997
660
|
}
|
|
998
|
-
// add a lease to a transaction not yet having
|
|
999
|
-
// supply feePerByte to increment fee accordingly
|
|
1000
|
-
addLease(lease, feePerByte = 0) {
|
|
1001
|
-
let mutableLease;
|
|
1002
|
-
if (lease !== undefined) {
|
|
1003
|
-
if (lease.constructor !== Uint8Array)
|
|
1004
|
-
throw Error('lease must be a Uint8Array.');
|
|
1005
|
-
if (lease.length !== ALGORAND_TRANSACTION_LEASE_LENGTH)
|
|
1006
|
-
throw Error(`lease must be of length ${ALGORAND_TRANSACTION_LEASE_LENGTH.toString()}.`);
|
|
1007
|
-
mutableLease = new Uint8Array(lease);
|
|
1008
|
-
}
|
|
1009
|
-
else {
|
|
1010
|
-
mutableLease = new Uint8Array(0);
|
|
1011
|
-
}
|
|
1012
|
-
this.lease = mutableLease;
|
|
1013
|
-
if (feePerByte !== 0) {
|
|
1014
|
-
this.fee +=
|
|
1015
|
-
(ALGORAND_TRANSACTION_LEASE_LABEL_LENGTH +
|
|
1016
|
-
ALGORAND_TRANSACTION_LEASE_LENGTH) *
|
|
1017
|
-
feePerByte;
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
// add the rekey-to field to a transaction not yet having it
|
|
1021
|
-
// supply feePerByte to increment fee accordingly
|
|
1022
|
-
addRekey(reKeyTo, feePerByte = 0) {
|
|
1023
|
-
if (reKeyTo !== undefined) {
|
|
1024
|
-
this.reKeyTo = address.decodeAddress(reKeyTo);
|
|
1025
|
-
}
|
|
1026
|
-
if (feePerByte !== 0) {
|
|
1027
|
-
this.fee +=
|
|
1028
|
-
(ALGORAND_TRANSACTION_REKEY_LABEL_LENGTH +
|
|
1029
|
-
ALGORAND_TRANSACTION_ADDRESS_LENGTH) *
|
|
1030
|
-
feePerByte;
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
// build display dict for prettyPrint and toString
|
|
1034
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1035
|
-
_getDictForDisplay() {
|
|
1036
|
-
const forPrinting = {
|
|
1037
|
-
...this,
|
|
1038
|
-
};
|
|
1039
|
-
forPrinting.tag = forPrinting.tag.toString();
|
|
1040
|
-
forPrinting.from = address.encodeAddress(forPrinting.from.publicKey);
|
|
1041
|
-
if (forPrinting.to !== undefined)
|
|
1042
|
-
forPrinting.to = address.encodeAddress(forPrinting.to.publicKey);
|
|
1043
|
-
// things that need fixing:
|
|
1044
|
-
if (forPrinting.freezeAccount !== undefined)
|
|
1045
|
-
forPrinting.freezeAccount = address.encodeAddress(forPrinting.freezeAccount.publicKey);
|
|
1046
|
-
if (forPrinting.closeRemainderTo !== undefined)
|
|
1047
|
-
forPrinting.closeRemainderTo = address.encodeAddress(forPrinting.closeRemainderTo.publicKey);
|
|
1048
|
-
if (forPrinting.assetManager !== undefined)
|
|
1049
|
-
forPrinting.assetManager = address.encodeAddress(forPrinting.assetManager.publicKey);
|
|
1050
|
-
if (forPrinting.assetReserve !== undefined)
|
|
1051
|
-
forPrinting.assetReserve = address.encodeAddress(forPrinting.assetReserve.publicKey);
|
|
1052
|
-
if (forPrinting.assetFreeze !== undefined)
|
|
1053
|
-
forPrinting.assetFreeze = address.encodeAddress(forPrinting.assetFreeze.publicKey);
|
|
1054
|
-
if (forPrinting.assetClawback !== undefined)
|
|
1055
|
-
forPrinting.assetClawback = address.encodeAddress(forPrinting.assetClawback.publicKey);
|
|
1056
|
-
if (forPrinting.assetRevocationTarget !== undefined)
|
|
1057
|
-
forPrinting.assetRevocationTarget = address.encodeAddress(forPrinting.assetRevocationTarget.publicKey);
|
|
1058
|
-
if (forPrinting.reKeyTo !== undefined)
|
|
1059
|
-
forPrinting.reKeyTo = address.encodeAddress(forPrinting.reKeyTo.publicKey);
|
|
1060
|
-
forPrinting.genesisHash = forPrinting.genesisHash.toString('base64');
|
|
1061
|
-
return forPrinting;
|
|
1062
|
-
}
|
|
1063
|
-
// pretty print the transaction to console
|
|
1064
|
-
prettyPrint() {
|
|
1065
|
-
// eslint-disable-next-line no-underscore-dangle,no-console
|
|
1066
|
-
console.log(this._getDictForDisplay());
|
|
1067
|
-
}
|
|
1068
|
-
// get string representation
|
|
1069
|
-
toString() {
|
|
1070
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
1071
|
-
return JSON.stringify(this._getDictForDisplay());
|
|
1072
|
-
}
|
|
1073
661
|
}
|
|
1074
662
|
exports.Transaction = Transaction;
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
663
|
+
Transaction.encodingSchema = new index_js_1.NamedMapSchema((0, index_js_1.allOmitEmpty)([
|
|
664
|
+
// Common
|
|
665
|
+
{ key: 'type', valueSchema: new index_js_1.StringSchema() },
|
|
666
|
+
{ key: 'snd', valueSchema: new index_js_1.AddressSchema() },
|
|
667
|
+
{ key: 'lv', valueSchema: new index_js_1.Uint64Schema() },
|
|
668
|
+
{ key: 'gen', valueSchema: new index_js_1.OptionalSchema(new index_js_1.StringSchema()) },
|
|
669
|
+
{
|
|
670
|
+
key: 'gh',
|
|
671
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.FixedLengthByteArraySchema(32)),
|
|
672
|
+
},
|
|
673
|
+
{ key: 'fee', valueSchema: new index_js_1.Uint64Schema() },
|
|
674
|
+
{ key: 'fv', valueSchema: new index_js_1.Uint64Schema() },
|
|
675
|
+
{ key: 'note', valueSchema: new index_js_1.ByteArraySchema() },
|
|
676
|
+
{
|
|
677
|
+
key: 'lx',
|
|
678
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.FixedLengthByteArraySchema(32)),
|
|
679
|
+
},
|
|
680
|
+
{ key: 'rekey', valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()) },
|
|
681
|
+
{
|
|
682
|
+
key: 'grp',
|
|
683
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.FixedLengthByteArraySchema(32)),
|
|
684
|
+
},
|
|
685
|
+
// We mark all top-level type-specific fields optional because they will not be present when
|
|
686
|
+
// the transaction is not that type.
|
|
687
|
+
// Payment
|
|
688
|
+
{ key: 'amt', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
689
|
+
{ key: 'rcv', valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()) },
|
|
690
|
+
{ key: 'close', valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()) },
|
|
691
|
+
// Keyreg
|
|
692
|
+
{
|
|
693
|
+
key: 'votekey',
|
|
694
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.FixedLengthByteArraySchema(32)),
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
key: 'selkey',
|
|
698
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.FixedLengthByteArraySchema(32)),
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
key: 'sprfkey',
|
|
702
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.FixedLengthByteArraySchema(64)),
|
|
703
|
+
},
|
|
704
|
+
{ key: 'votefst', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
705
|
+
{ key: 'votelst', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
706
|
+
{ key: 'votekd', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
707
|
+
{ key: 'nonpart', valueSchema: new index_js_1.OptionalSchema(new index_js_1.BooleanSchema()) },
|
|
708
|
+
// AssetConfig
|
|
709
|
+
{ key: 'caid', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
710
|
+
{
|
|
711
|
+
key: 'apar',
|
|
712
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.NamedMapSchema((0, index_js_1.allOmitEmpty)([
|
|
713
|
+
{ key: 't', valueSchema: new index_js_1.Uint64Schema() },
|
|
714
|
+
{ key: 'dc', valueSchema: new index_js_1.Uint64Schema() },
|
|
715
|
+
{ key: 'df', valueSchema: new index_js_1.BooleanSchema() },
|
|
716
|
+
{
|
|
717
|
+
key: 'm',
|
|
718
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()),
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
key: 'r',
|
|
722
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()),
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
key: 'f',
|
|
726
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()),
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
key: 'c',
|
|
730
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()),
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
key: 'un',
|
|
734
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.StringSchema()),
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
key: 'an',
|
|
738
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.StringSchema()),
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
key: 'au',
|
|
742
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.StringSchema()),
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
key: 'am',
|
|
746
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.FixedLengthByteArraySchema(32)),
|
|
747
|
+
},
|
|
748
|
+
]))),
|
|
749
|
+
},
|
|
750
|
+
// AssetTransfer
|
|
751
|
+
{ key: 'xaid', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
752
|
+
{ key: 'aamt', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
753
|
+
{ key: 'arcv', valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()) },
|
|
754
|
+
{ key: 'aclose', valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()) },
|
|
755
|
+
{ key: 'asnd', valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()) },
|
|
756
|
+
// AssetFreeze
|
|
757
|
+
{ key: 'faid', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
758
|
+
{ key: 'afrz', valueSchema: new index_js_1.OptionalSchema(new index_js_1.BooleanSchema()) },
|
|
759
|
+
{ key: 'fadd', valueSchema: new index_js_1.OptionalSchema(new index_js_1.AddressSchema()) },
|
|
760
|
+
// Application
|
|
761
|
+
{ key: 'apid', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
762
|
+
{ key: 'apan', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
763
|
+
{
|
|
764
|
+
key: 'apaa',
|
|
765
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.ArraySchema(new index_js_1.ByteArraySchema())),
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
key: 'apat',
|
|
769
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.ArraySchema(new index_js_1.AddressSchema())),
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
key: 'apas',
|
|
773
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.ArraySchema(new index_js_1.Uint64Schema())),
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
key: 'apfa',
|
|
777
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.ArraySchema(new index_js_1.Uint64Schema())),
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
key: 'apbx',
|
|
781
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.ArraySchema(new index_js_1.NamedMapSchema((0, index_js_1.allOmitEmpty)([
|
|
782
|
+
{
|
|
783
|
+
key: 'i',
|
|
784
|
+
valueSchema: new index_js_1.Uint64Schema(),
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
key: 'n',
|
|
788
|
+
valueSchema: new index_js_1.ByteArraySchema(),
|
|
789
|
+
},
|
|
790
|
+
])))),
|
|
791
|
+
},
|
|
792
|
+
{ key: 'apap', valueSchema: new index_js_1.OptionalSchema(new index_js_1.ByteArraySchema()) },
|
|
793
|
+
{ key: 'apsu', valueSchema: new index_js_1.OptionalSchema(new index_js_1.ByteArraySchema()) },
|
|
794
|
+
{
|
|
795
|
+
key: 'apls',
|
|
796
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.NamedMapSchema((0, index_js_1.allOmitEmpty)([
|
|
797
|
+
{
|
|
798
|
+
key: 'nui',
|
|
799
|
+
valueSchema: new index_js_1.Uint64Schema(),
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
key: 'nbs',
|
|
803
|
+
valueSchema: new index_js_1.Uint64Schema(),
|
|
804
|
+
},
|
|
805
|
+
]))),
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
key: 'apgs',
|
|
809
|
+
valueSchema: new index_js_1.OptionalSchema(new index_js_1.NamedMapSchema((0, index_js_1.allOmitEmpty)([
|
|
810
|
+
{
|
|
811
|
+
key: 'nui',
|
|
812
|
+
valueSchema: new index_js_1.Uint64Schema(),
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
key: 'nbs',
|
|
816
|
+
valueSchema: new index_js_1.Uint64Schema(),
|
|
817
|
+
},
|
|
818
|
+
]))),
|
|
819
|
+
},
|
|
820
|
+
{ key: 'apep', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
821
|
+
// StateProof
|
|
822
|
+
{ key: 'sptype', valueSchema: new index_js_1.OptionalSchema(new index_js_1.Uint64Schema()) },
|
|
823
|
+
{ key: 'sp', valueSchema: new index_js_1.OptionalSchema(stateproof_js_1.StateProof.encodingSchema) },
|
|
824
|
+
{
|
|
825
|
+
key: 'spmsg',
|
|
826
|
+
valueSchema: new index_js_1.OptionalSchema(stateproof_js_1.StateProofMessage.encodingSchema),
|
|
827
|
+
},
|
|
828
|
+
]));
|
|
1090
829
|
/**
|
|
1091
830
|
* encodeUnsignedTransaction takes a completed txnBuilder.Transaction object, such as from the makeFoo
|
|
1092
831
|
* family of transactions, and converts it to a Buffer
|
|
1093
832
|
* @param transactionObject - the completed Transaction object
|
|
1094
833
|
*/
|
|
1095
834
|
function encodeUnsignedTransaction(transactionObject) {
|
|
1096
|
-
|
|
1097
|
-
return encoding.encode(objToEncode);
|
|
835
|
+
return encoding.encodeMsgpack(transactionObject);
|
|
1098
836
|
}
|
|
1099
837
|
exports.encodeUnsignedTransaction = encodeUnsignedTransaction;
|
|
1100
838
|
/**
|
|
1101
|
-
* decodeUnsignedTransaction takes a
|
|
839
|
+
* decodeUnsignedTransaction takes a Uint8Array (as if from encodeUnsignedTransaction) and converts it to a txnBuilder.Transaction object
|
|
1102
840
|
* @param transactionBuffer - the Uint8Array containing a transaction
|
|
1103
841
|
*/
|
|
1104
842
|
function decodeUnsignedTransaction(transactionBuffer) {
|
|
1105
|
-
|
|
1106
|
-
return Transaction.from_obj_for_encoding(partlyDecodedObject);
|
|
843
|
+
return encoding.decodeMsgpack(transactionBuffer, Transaction);
|
|
1107
844
|
}
|
|
1108
845
|
exports.decodeUnsignedTransaction = decodeUnsignedTransaction;
|
|
1109
|
-
/**
|
|
1110
|
-
* decodeSignedTransaction takes a Buffer (from transaction.signTxn) and converts it to an object
|
|
1111
|
-
* containing the Transaction (txn), the signature (sig), and the auth-addr field if applicable (sgnr)
|
|
1112
|
-
* @param transactionBuffer - the Uint8Array containing a transaction
|
|
1113
|
-
* @returns containing a Transaction, the signature, and possibly an auth-addr field
|
|
1114
|
-
*/
|
|
1115
|
-
function decodeSignedTransaction(transactionBuffer) {
|
|
1116
|
-
const stxnDecoded = encoding.decode(transactionBuffer);
|
|
1117
|
-
const stxn = {
|
|
1118
|
-
...stxnDecoded,
|
|
1119
|
-
txn: Transaction.from_obj_for_encoding(stxnDecoded.txn),
|
|
1120
|
-
};
|
|
1121
|
-
return stxn;
|
|
1122
|
-
}
|
|
1123
|
-
exports.decodeSignedTransaction = decodeSignedTransaction;
|
|
1124
|
-
function instantiateTxnIfNeeded(transactionLike) {
|
|
1125
|
-
return transactionLike instanceof Transaction
|
|
1126
|
-
? transactionLike
|
|
1127
|
-
: new Transaction(transactionLike);
|
|
1128
|
-
}
|
|
1129
|
-
exports.instantiateTxnIfNeeded = instantiateTxnIfNeeded;
|
|
1130
|
-
exports.default = Transaction;
|
|
1131
846
|
//# sourceMappingURL=transaction.js.map
|