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