@algorandfoundation/algokit-utils 10.0.0-alpha.13 → 10.0.0-alpha.15
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/package.json +1 -1
- package/packages/algod_client/src/models/block.d.ts +1 -1
- package/packages/algod_client/src/models/block.js.map +1 -1
- package/packages/algod_client/src/models/block.mjs.map +1 -1
- package/packages/transact/src/transactions/app-call.d.ts +1 -6
- package/packages/transact/src/transactions/asset-config.d.ts +1 -6
- package/packages/transact/src/transactions/asset-config.js.map +1 -1
- package/packages/transact/src/transactions/asset-config.mjs.map +1 -1
- package/packages/transact/src/transactions/asset-freeze.d.ts +1 -6
- package/packages/transact/src/transactions/asset-transfer.d.ts +1 -6
- package/packages/transact/src/transactions/key-registration.d.ts +1 -8
- package/packages/transact/src/transactions/signed-transaction.d.ts +5 -1
- package/packages/transact/src/transactions/signed-transaction.js +1 -1
- package/packages/transact/src/transactions/signed-transaction.js.map +1 -1
- package/packages/transact/src/transactions/signed-transaction.mjs +1 -2
- package/packages/transact/src/transactions/signed-transaction.mjs.map +1 -1
- package/packages/transact/src/transactions/transaction.d.ts +5 -1
- package/packages/transact/src/transactions/transaction.js +0 -1
- package/packages/transact/src/transactions/transaction.js.map +1 -1
- package/packages/transact/src/transactions/transaction.mjs +0 -1
- package/packages/transact/src/transactions/transaction.mjs.map +1 -1
- package/transact/index.d.ts +9 -9
- package/transact/index.js +3 -10
- package/transact/index.mjs +5 -9
- package/transactions/key-registration.d.ts +1 -1
- package/transactions/key-registration.js.map +1 -1
- package/transactions/key-registration.mjs.map +1 -1
- package/types/account-manager.js +1 -1
- package/types/account-manager.mjs +1 -1
- package/types/algorand-client-transaction-creator.d.ts +27 -27
- package/types/algorand-client-transaction-sender.d.ts +28 -28
- package/types/app-client.d.ts +93 -93
- package/types/app-factory.d.ts +43 -43
- package/types/composer.js +9 -2
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +11 -4
- package/types/composer.mjs.map +1 -1
- package/packages/transact/src/transactions/common.d.ts +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.js","names":["hash","base32","TRANSACTION_ID_LENGTH","Codec","TransactionType","Address","transactionParamsCodec","concatArrays","TRANSACTION_DOMAIN_SEPARATOR","validateAssetTransferTransaction","validateAssetConfigTransaction","validateAppCallTransaction","validateKeyRegistrationTransaction","validateAssetFreezeTransaction","getValidationErrorMessage","encodeMsgpack","decodeMsgpack","SIGNATURE_ENCODING_INCR","MAX_TRANSACTION_GROUP_SIZE","TRANSACTION_GROUP_DOMAIN_SEPARATOR"],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n validateTransaction(transaction)\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,OAAO,IAAI,+BAA+B;;;;AAmIpE,IAAa,cAAb,MAAsD;;CAEpD,CAAC;;;;CAKD;;;;;;CAOA;;;;;;CAOA;;;;CAKA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;;;CASA;;;;;;;;;CAUA;;;;;;CAOA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;CAEA,YAAY,QAA2B;AACrC,OAAK,cAAc;AACnB,OAAK,OAAO,OAAO;AACnB,OAAK,SAAS,OAAO;AACrB,OAAK,MAAM,OAAO;AAClB,OAAK,aAAa,OAAO;AACzB,OAAK,YAAY,OAAO;AACxB,OAAK,cAAc,OAAO;AAC1B,OAAK,YAAY,OAAO;AACxB,OAAK,OAAO,OAAO;AACnB,OAAK,UAAU,OAAO;AACtB,OAAK,QAAQ,OAAO;AACpB,OAAK,QAAQ,OAAO;AACpB,OAAK,UAAU,OAAO;AACtB,OAAK,gBAAgB,OAAO;AAC5B,OAAK,cAAc,OAAO;AAC1B,OAAK,UAAU,OAAO;AACtB,OAAK,kBAAkB,OAAO;AAC9B,OAAK,cAAc,OAAO;AAC1B,OAAK,YAAY,OAAO;AACxB,OAAK,aAAa,OAAO;;CAG3B,AAAQ,UAAsB;AAC5B,MAAI,KAAK,gBAAgB,OACvB,OAAM,IAAI,MAAM,qDAAqD;AAIvE,SAAOA,oBADc,kBAAkB,KAAK,CACnB;;;;;CAM3B,OAAe;EACb,MAAM,UAAU,KAAK,SAAS;AAE9B,SAAOC,kBAAO,OAAO,QAAQ,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AAQ,SAASC,0CAAwB;;;;;AAMzD,SAAgB,kBAAkB,cAA4C;CAC5E,MAAM,QAAQ,aAAa,aAAa;AACxC,QAAO,aAAa,KACjB,OACC,IAAI,YAAY;EACd,GAAG;EACH;EACD,CAAC,CACL;;AAGH,SAAgB,UAAU,aAA0B,WAAmC;CACrF,MAAM,MAAM,aAAa,aAAa,UAAU;AAChD,QAAO,IAAI,YAAY;EACrB,GAAG;EACH;EACD,CAAC;;AAGJ,SAAS,aAAa,cAAyC;AAC7D,KAAI,aAAa,WAAW,EAC1B,OAAM,IAAI,MAAM,qCAAqC;AAGvD,KAAI,aAAa,SAASC,6CACxB,OAAM,IAAI,MAAM,mDAAmDA,+CAA6B;CAGlG,MAAM,WAAW,aAAa,KAAK,OAAO;AACxC,MAAI,GAAG,MACL,OAAM,IAAI,MAAM,2CAA2C;AAI7D,SAAOlB,oBADc,kBAAkB,GAAG,CACjB;GACzB;AAQF,QAAOA,oBADeO,2BALF,IAAI,aAAa,CAAC,OAAOY,qDAAmC,EAC3DJ,8BAAc,EACjC,QAAQ,UACT,CAAC,CAE2D,CACnC;;AAG5B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
|
|
1
|
+
{"version":3,"file":"transaction.js","names":["hash","base32","TRANSACTION_ID_LENGTH","Codec","TransactionType","Address","transactionParamsCodec","concatArrays","TRANSACTION_DOMAIN_SEPARATOR","validateAssetTransferTransaction","validateAssetConfigTransaction","validateAppCallTransaction","validateKeyRegistrationTransaction","validateAssetFreezeTransaction","getValidationErrorMessage","encodeMsgpack","decodeMsgpack","SIGNATURE_ENCODING_INCR","MAX_TRANSACTION_GROUP_SIZE","TRANSACTION_GROUP_DOMAIN_SEPARATOR"],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,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AG;EACH;EACD,CAAC;;AAGJ,SAAS,aAAa,cAAyC;AAC7D,KAAI,aAAa,WAAW,EAC1B,OAAM,IAAI,MAAM,qCAAqC;AAGvD,KAAI,aAAa,SAASC,6CACxB,OAAM,IAAI,MAAM,mDAAmDA,+CAA6B;CAGlG,MAAM,WAAW,aAAa,KAAK,OAAO;AACxC,MAAI,GAAG,MACL,OAAM,IAAI,MAAM,2CAA2C;AAI7D,SAAOlB,oBADc,kBAAkB,GAAG,CACjB;GACzB;AAQF,QAAOA,oBADeO,2BALF,IAAI,aAAa,CAAC,OAAOY,qDAAmC,EAC3DJ,8BAAc,EACjC,QAAQ,UACT,CAAC,CAE2D,CACnC;;AAG5B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
|
|
@@ -251,7 +251,6 @@ function validateTransaction(transaction) {
|
|
|
251
251
|
* This is useful for encoding the transaction for signing with tools that automatically add "TX" prefix to the transaction bytes.
|
|
252
252
|
*/
|
|
253
253
|
function encodeTransactionRaw(transaction) {
|
|
254
|
-
validateTransaction(transaction);
|
|
255
254
|
return encodeMsgpack(transactionCodec.encode(transaction, "msgpack"));
|
|
256
255
|
}
|
|
257
256
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n validateTransaction(transaction)\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,OAAO,IAAI,+BAA+B;;;;AAmIpE,IAAa,cAAb,MAAsD;;CAEpD,CAAC;;;;CAKD;;;;;;CAOA;;;;;;CAOA;;;;CAKA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;;;CASA;;;;;;;;;CAUA;;;;;;CAOA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;C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I7D,SAAO,KADc,kBAAkB,GAAG,CACjB;GACzB;AAQF,QAAO,KADe,aALF,IAAI,aAAa,CAAC,OAAO,mCAAmC,EAC3D,cAAc,EACjC,QAAQ,UACT,CAAC,CAE2D,CACnC;;AAG5B,SAAgB,aAAa,aAA0B,WAA8B;CACnF,IAAI,gBAAgB;AAEpB,KAAI,UAAU,aAAa,IAAI;EAC7B,MAAM,gBAAgB,wBAAwB,YAAY;AAC1D,kBAAgB,UAAU,aAAa,OAAO,cAAc;;AAG9D,KAAI,gBAAgB,UAAU,OAC5B,iBAAgB,UAAU;AAG5B,KAAI,UAAU,SACZ,kBAAiB,UAAU;AAG7B,KAAI,UAAU,UAAU,gBAAgB,UAAU,OAChD,OAAM,IAAI,MAAM,mBAAmB,cAAc,gCAAgC,UAAU,OAAO,QAAQ;AAG5G,QAAO"}
|
|
1
|
+
{"version":3,"file":"transaction.mjs","names":[],"sources":["../../../../../packages/transact/src/transactions/transaction.ts"],"sourcesContent":["import type { EncodingFormat, WireObject } from '@algorandfoundation/algokit-common'\nimport {\n Address,\n Codec,\n MAX_TRANSACTION_GROUP_SIZE,\n SIGNATURE_ENCODING_INCR,\n TRANSACTION_DOMAIN_SEPARATOR,\n TRANSACTION_GROUP_DOMAIN_SEPARATOR,\n TRANSACTION_ID_LENGTH,\n concatArrays,\n decodeMsgpack,\n encodeMsgpack,\n hash,\n} from '@algorandfoundation/algokit-common'\nimport base32 from 'hi-base32'\nimport { AppCallTransactionFields, validateAppCallTransaction } from './app-call'\nimport { AssetConfigTransactionFields, validateAssetConfigTransaction } from './asset-config'\nimport { AssetFreezeTransactionFields, validateAssetFreezeTransaction } from './asset-freeze'\nimport { AssetTransferTransactionFields, validateAssetTransferTransaction } from './asset-transfer'\nimport { TransactionValidationError, getValidationErrorMessage } from './common'\nimport { HeartbeatTransactionFields } from './heartbeat'\nimport { KeyRegistrationTransactionFields, validateKeyRegistrationTransaction } from './key-registration'\nimport { PaymentTransactionFields } from './payment'\nimport { StateProofTransactionFields } from './state-proof'\nimport { transactionParamsCodec } from './transaction-meta'\nimport { TransactionType } from './transaction-type'\n\n/** Symbol used for instanceof checks across packages (CJS/ESM) */\nexport const TXN_SYMBOL = Symbol.for('algokit_transact:Transaction')\n\n/**\n * Represents the parameters for a complete Algorand transaction.\n *\n * This structure contains the fields that are present in every transaction,\n * regardless of transaction type, plus transaction-type-specific fields.\n */\nexport type TransactionParams = {\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n}\n\n/**\n * Represents a complete Algorand transaction.\n */\nexport class Transaction implements TransactionParams {\n /** @internal */\n [TXN_SYMBOL]: boolean\n\n /**\n * The type of transaction\n */\n type: TransactionType\n\n /**\n * The account that authorized the transaction.\n *\n * Fees are deducted from this account.\n */\n sender: Address\n\n /**\n * Optional transaction fee in microALGO.\n *\n * When not set, the fee will be interpreted as 0 by the network.\n */\n fee?: bigint\n\n /**\n * First round for when the transaction is valid.\n */\n firstValid: bigint\n\n /**\n * Last round for when the transaction is valid.\n *\n * After this round, the transaction will be expired.\n */\n lastValid: bigint\n\n /**\n * Hash of the genesis block of the network.\n *\n * Used to identify which network the transaction is for.\n */\n genesisHash?: Uint8Array\n\n /**\n * Genesis ID of the network.\n *\n * A human-readable string used alongside genesis hash to identify the network.\n */\n genesisId?: string\n\n /**\n * Optional user-defined note field.\n *\n * Can contain arbitrary data up to 1KB in size.\n */\n note?: Uint8Array\n\n /**\n * Optional authorized account for future transactions.\n *\n * If set, only this account will be used for transaction authorization going forward.\n * Reverting back control to the original address must be done by setting this field to\n * the original address.\n */\n rekeyTo?: Address\n\n /**\n * Optional lease value to enforce mutual transaction exclusion.\n *\n * When a transaction with a non-empty lease field is confirmed, the lease is acquired.\n * A lease X is acquired by the sender, generating the (sender, X) lease.\n * The lease is kept active until the last_valid round of the transaction has elapsed.\n * No other transaction sent by the same sender can be confirmed until the lease expires.\n */\n lease?: Uint8Array\n\n /**\n * Optional group ID for atomic transaction grouping.\n *\n * Transactions with the same group ID must execute together or not at all.\n */\n group?: Uint8Array\n\n /**\n * Payment specific fields\n */\n payment?: PaymentTransactionFields\n\n /**\n * Asset transfer specific fields\n */\n assetTransfer?: AssetTransferTransactionFields\n\n /**\n * Asset config specific fields\n */\n assetConfig?: AssetConfigTransactionFields\n\n /**\n * App call specific fields\n */\n appCall?: AppCallTransactionFields\n\n /**\n * Key registration specific fields\n */\n keyRegistration?: KeyRegistrationTransactionFields\n\n /**\n * Asset freeze specific fields\n */\n assetFreeze?: AssetFreezeTransactionFields\n\n /**\n * Heartbeat specific fields\n */\n heartbeat?: HeartbeatTransactionFields\n\n /**\n * State proof specific fields\n */\n stateProof?: StateProofTransactionFields\n\n constructor(params: TransactionParams) {\n this[TXN_SYMBOL] = true\n this.type = params.type\n this.sender = params.sender\n this.fee = params.fee\n this.firstValid = params.firstValid\n this.lastValid = params.lastValid\n this.genesisHash = params.genesisHash\n this.genesisId = params.genesisId\n this.note = params.note\n this.rekeyTo = params.rekeyTo\n this.lease = params.lease\n this.group = params.group\n this.payment = params.payment\n this.assetTransfer = params.assetTransfer\n this.assetConfig = params.assetConfig\n this.appCall = params.appCall\n this.keyRegistration = params.keyRegistration\n this.assetFreeze = params.assetFreeze\n this.heartbeat = params.heartbeat\n this.stateProof = params.stateProof\n }\n\n private rawTxId(): Uint8Array {\n if (this.genesisHash === undefined) {\n throw new Error('Cannot compute transaction id without genesis hash')\n }\n\n const encodedBytes = encodeTransaction(this)\n return hash(encodedBytes)\n }\n\n /**\n * Get the transaction ID as a base32-encoded string.\n */\n txId(): string {\n const rawTxId = this.rawTxId()\n\n return base32.encode(rawTxId).slice(0, TRANSACTION_ID_LENGTH)\n }\n\n static [Symbol.hasInstance](obj: unknown) {\n return Boolean(obj && typeof obj === 'object' && TXN_SYMBOL in obj && obj[TXN_SYMBOL as keyof typeof obj])\n }\n}\n\n/**\n * Codec for Transaction class.\n * Handles encoding/decoding between Transaction class instances and wire format.\n */\nclass TransactionCodec extends Codec<Transaction, Record<string, unknown>, WireObject> {\n public defaultValue(): Transaction {\n return new Transaction({\n type: TransactionType.Unknown,\n sender: Address.zeroAddress(),\n firstValid: 0n,\n lastValid: 0n,\n })\n }\n\n protected toEncoded(value: Transaction, format: EncodingFormat): Record<string, unknown> {\n return transactionParamsCodec.encode({ ...value }, format)\n }\n\n protected fromEncoded(value: WireObject, format: EncodingFormat): Transaction {\n const params = transactionParamsCodec.decode(value, format)\n return new Transaction(params)\n }\n\n public isDefaultValue(_: Transaction): boolean {\n return false\n }\n}\n\nexport const transactionCodec = new TransactionCodec()\n\nexport type FeeParams = {\n feePerByte: bigint\n minFee: bigint\n extraFee?: bigint\n maxFee?: bigint\n}\n\n/**\n * Get the transaction type from the encoded transaction.\n * This is particularly useful when decoding a transaction that has an unknown type\n */\nexport function getEncodedTransactionType(encoded_transaction: Uint8Array): TransactionType {\n const decoded = decodeTransaction(encoded_transaction)\n return decoded.type\n}\n\n/**\n * Encode the transaction with the domain separation (e.g. \"TX\") prefix\n *\n * @param transaction - The transaction to encode\n * @returns The MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransaction(transaction: Transaction): Uint8Array {\n const rawBytes = encodeTransactionRaw(transaction)\n\n // Add domain separation prefix\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n return concatArrays(prefixBytes, rawBytes)\n}\n\n/**\n * Encode transactions with the domain separation (e.g. \"TX\") prefix\n *\n * @param transactions - A collection of transactions to encode\n * @returns A collection of MsgPack encoded bytes or an error if encoding fails.\n */\nexport function encodeTransactions(transactions: Transaction[]): Uint8Array[] {\n return transactions.map((tx) => encodeTransaction(tx))\n}\n\n/**\n * Validate a transaction\n */\nexport function validateTransaction(transaction: Transaction): void {\n // Validate that only one transaction type specific field is set\n const typeFields = [\n transaction.payment,\n transaction.assetTransfer,\n transaction.assetConfig,\n transaction.appCall,\n transaction.keyRegistration,\n transaction.assetFreeze,\n transaction.heartbeat,\n transaction.stateProof,\n ]\n\n const setFieldsCount = typeFields.filter((field) => field !== undefined).length\n\n if (setFieldsCount > 1) {\n throw new Error('Multiple transaction type specific fields set')\n }\n\n // Perform type-specific validation where applicable\n let typeName = 'Transaction'\n const errors = new Array<TransactionValidationError>()\n if (transaction.assetTransfer) {\n typeName = 'Asset transfer'\n errors.push(...validateAssetTransferTransaction(transaction.assetTransfer))\n } else if (transaction.assetConfig) {\n typeName = 'Asset config'\n errors.push(...validateAssetConfigTransaction(transaction.assetConfig))\n } else if (transaction.appCall) {\n typeName = 'App call'\n errors.push(...validateAppCallTransaction(transaction.appCall))\n } else if (transaction.keyRegistration) {\n typeName = 'Key registration'\n errors.push(...validateKeyRegistrationTransaction(transaction.keyRegistration))\n } else if (transaction.assetFreeze) {\n typeName = 'Asset freeze'\n errors.push(...validateAssetFreezeTransaction(transaction.assetFreeze))\n }\n\n if (errors.length > 0) {\n const errorMessages = errors.map((e) => getValidationErrorMessage(e))\n throw new Error(`${typeName} validation failed: ${errorMessages.join('\\n')}`)\n }\n}\n\n/**\n * Encode the transaction without the domain separation (e.g. \"TX\") prefix\n * This is useful for encoding the transaction for signing with tools that automatically add \"TX\" prefix to the transaction bytes.\n */\nexport function encodeTransactionRaw(transaction: Transaction): Uint8Array {\n const encodingData = transactionCodec.encode(transaction, 'msgpack')\n return encodeMsgpack(encodingData)\n}\n\n/**\n * Decodes MsgPack bytes into a transaction.\n *\n * # Parameters\n * * `encoded_transaction` - MsgPack encoded bytes representing a transaction.\n *\n * # Returns\n * A decoded transaction or an error if decoding fails.\n */\nexport function decodeTransaction(encoded_transaction: Uint8Array): Transaction {\n if (encoded_transaction.length === 0) {\n throw new Error('attempted to decode 0 bytes')\n }\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_DOMAIN_SEPARATOR)\n // Check if the transaction has the domain separation prefix\n let hasPrefix = true\n if (encoded_transaction.length < prefixBytes.length) {\n hasPrefix = false\n } else {\n for (let i = 0; i < prefixBytes.length; i++) {\n if (encoded_transaction[i] !== prefixBytes[i]) {\n hasPrefix = false\n break\n }\n }\n }\n\n const decodedData = decodeMsgpack(hasPrefix ? encoded_transaction.slice(prefixBytes.length) : encoded_transaction)\n return transactionCodec.decode(decodedData, 'msgpack')\n}\n\n/**\n * Decodes a collection of MsgPack bytes into a transaction collection.\n *\n * # Parameters\n * * `encoded_transaction` - A collection of MsgPack encoded bytes, each representing a transaction.\n *\n * # Returns\n * A collection of decoded transactions or an error if decoding fails.\n */\nexport function decodeTransactions(encoded_transactions: Uint8Array[]): Transaction[] {\n return encoded_transactions.map((et) => decodeTransaction(et))\n}\n\n/**\n * Return the size of the transaction in bytes as if it was already signed and encoded.\n * This is useful for estimating the fee for the transaction.\n */\nexport function estimateTransactionSize(transaction: Transaction): bigint {\n const encoded = encodeTransactionRaw(transaction)\n return BigInt(encoded.length + SIGNATURE_ENCODING_INCR)\n}\n\n/**\n * Groups a collection of transactions by calculating and assigning the group to each transaction.\n */\nexport function groupTransactions(transactions: Transaction[]): Transaction[] {\n const group = computeGroup(transactions)\n return transactions.map(\n (tx) =>\n new Transaction({\n ...tx,\n group,\n }),\n )\n}\n\nexport function assignFee(transaction: Transaction, feeParams: FeeParams): Transaction {\n const fee = calculateFee(transaction, feeParams)\n return new Transaction({\n ...transaction,\n fee,\n })\n}\n\nfunction computeGroup(transactions: Transaction[]): Uint8Array {\n if (transactions.length === 0) {\n throw new Error('Transaction group size cannot be 0')\n }\n\n if (transactions.length > MAX_TRANSACTION_GROUP_SIZE) {\n throw new Error(`Transaction group size exceeds the max limit of ${MAX_TRANSACTION_GROUP_SIZE}`)\n }\n\n const txHashes = transactions.map((tx) => {\n if (tx.group) {\n throw new Error('Transactions must not already be grouped')\n }\n\n const encodedBytes = encodeTransaction(tx)\n return hash(encodedBytes)\n })\n\n const prefixBytes = new TextEncoder().encode(TRANSACTION_GROUP_DOMAIN_SEPARATOR)\n const encodedBytes = encodeMsgpack({\n txlist: txHashes,\n })\n\n const prefixedBytes = concatArrays(prefixBytes, encodedBytes)\n return hash(prefixedBytes)\n}\n\nexport function calculateFee(transaction: Transaction, feeParams: FeeParams): bigint {\n let calculatedFee = 0n\n\n if (feeParams.feePerByte > 0n) {\n const estimatedSize = estimateTransactionSize(transaction)\n calculatedFee = feeParams.feePerByte * BigInt(estimatedSize)\n }\n\n if (calculatedFee < feeParams.minFee) {\n calculatedFee = feeParams.minFee\n }\n\n if (feeParams.extraFee) {\n calculatedFee += feeParams.extraFee\n }\n\n if (feeParams.maxFee && calculatedFee > feeParams.maxFee) {\n throw new Error(`Transaction fee ${calculatedFee} µALGO is greater than maxFee ${feeParams.maxFee} µALGO`)\n }\n\n return calculatedFee\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAa,aAAa,OAAO,IAAI,+BAA+B;;;;AAmIpE,IAAa,cAAb,MAAsD;;CAEpD,CAAC;;;;CAKD;;;;;;CAOA;;;;;;CAOA;;;;CAKA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;CAOA;;;;;;;;CASA;;;;;;;;;CAUA;;;;;;CAOA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;;;;CAKA;CAEA,YAAY,QAA2B;AACrC,OAAK,cAAc;AACnB,OAAK,OAAO,OAAO;AACnB,OAAK,SAAS,OAAO;AACrB,OAAK,MAAM,OAAO;AAClB,OAAK,aAAa,OAAO;AACzB,OAAK,YAAY,OAAO;AACxB,OAAK,cAAc,OAAO;AAC1B,OAAK,YAAY,OAAO;AACxB,OAAK,OAAO,OAAO;AACnB,OAAK,UAAU,OAAO;AACtB,OAAK,QAAQ,OAAO;AACpB,OAAK,QAAQ,OAAO;AACpB,OAAK,UAAU,OAAO;AACtB,OAAK,gBAAgB,OAAO;AAC5B,OAAK,cAAc,OAAO;AAC1B,OAAK,UAAU,OAAO;AACtB,OAAK,kBAAkB,OAAO;AAC9B,OAAK,cAAc,OAAO;AAC1B,OAAK,YAAY,OAAO;AACxB,OAAK,aAAa,OAAO;;CAG3B,AAAQ,UAAsB;AAC5B,MAAI,KAAK,g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ields, BoxReference, HoldingReference, LocalsReference, OnApplicationComplete, ResourceReference, StateSchema
|
|
2
|
-
import { AssetConfigTransactionFields
|
|
3
|
-
import { AssetFreezeTransactionFields
|
|
4
|
-
import { AssetTransferTransactionFields
|
|
1
|
+
import { AppCallTransactionFields, BoxReference, HoldingReference, LocalsReference, OnApplicationComplete, ResourceReference, StateSchema } from "../packages/transact/src/transactions/app-call.js";
|
|
2
|
+
import { AssetConfigTransactionFields } from "../packages/transact/src/transactions/asset-config.js";
|
|
3
|
+
import { AssetFreezeTransactionFields } from "../packages/transact/src/transactions/asset-freeze.js";
|
|
4
|
+
import { AssetTransferTransactionFields } from "../packages/transact/src/transactions/asset-transfer.js";
|
|
5
5
|
import { HeartbeatProof, HeartbeatTransactionFields } from "../packages/transact/src/transactions/heartbeat.js";
|
|
6
|
-
import { KeyRegistrationTransactionFields
|
|
6
|
+
import { KeyRegistrationTransactionFields } from "../packages/transact/src/transactions/key-registration.js";
|
|
7
7
|
import { PaymentTransactionFields } from "../packages/transact/src/transactions/payment.js";
|
|
8
8
|
import { FalconSignatureStruct, FalconVerifier, HashFactory, MerkleArrayProof, MerkleSignatureVerifier, Participant, Reveal, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields } from "../packages/transact/src/transactions/state-proof.js";
|
|
9
9
|
import { TransactionType } from "../packages/transact/src/transactions/transaction-type.js";
|
|
10
|
-
import { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec } from "../packages/transact/src/transactions/transaction.js";
|
|
11
|
-
import { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions } from "../packages/transact/src/transactions/signed-transaction.js";
|
|
12
|
-
import { SignedTransactionMeta } from "../packages/transact/src/transactions/signed-transaction-meta.js";
|
|
10
|
+
import { Transaction, TransactionParams, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec, validateTransaction } from "../packages/transact/src/transactions/transaction.js";
|
|
11
|
+
import { LogicSignature, MultisigSignature, MultisigSubsignature, SignedTransaction, decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions, validateSignedTransaction } from "../packages/transact/src/transactions/signed-transaction.js";
|
|
13
12
|
import { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from "../packages/transact/src/transactions/reference-types-meta.js";
|
|
13
|
+
import { SignedTransactionMeta } from "../packages/transact/src/transactions/signed-transaction-meta.js";
|
|
14
14
|
import { TransactionParamsMeta, transactionParamsCodec } from "../packages/transact/src/transactions/transaction-meta.js";
|
|
15
15
|
import { MultisigAccount, MultisigMetadata } from "../packages/transact/src/multisig.js";
|
|
16
16
|
import { DelegatedLsigSigner, LogicSigAccount, ProgramDataSigner } from "../packages/transact/src/logicsig.js";
|
|
17
17
|
import { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, MxBytesSigner, SendingAddress, TransactionSigner, generateAddressWithSigners, makeEmptyTransactionSigner } from "../packages/transact/src/signer.js";
|
|
18
|
-
export { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, AppCallTransactionFields, AssetConfigTransactionFields, AssetFreezeTransactionFields, AssetTransferTransactionFields, BoxReference, BoxReferenceMeta, DelegatedLsigSigner, FalconSignatureStruct, FalconVerifier, HashFactory, HeartbeatProof, HeartbeatTransactionFields, HoldingReference, HoldingReferenceMeta, KeyRegistrationTransactionFields, LocalsReference, LocalsReferenceMeta, LogicSigAccount, LogicSignature, MerkleArrayProof, MerkleSignatureVerifier, MultisigAccount, MultisigMetadata, MultisigSignature, MultisigSubsignature, MxBytesSigner, OnApplicationComplete, Participant, PaymentTransactionFields, ProgramDataSigner, ResourceReference, Reveal, SendingAddress, SignedTransaction, SignedTransactionMeta, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields, StateSchema, Transaction, TransactionParams, TransactionParamsMeta, TransactionSigner, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec,
|
|
18
|
+
export { AddressWithDelegatedLsigSigner, AddressWithMxBytesSigner, AddressWithProgramDataSigner, AddressWithSigners, AddressWithTransactionSigner, AppCallTransactionFields, AssetConfigTransactionFields, AssetFreezeTransactionFields, AssetTransferTransactionFields, BoxReference, BoxReferenceMeta, DelegatedLsigSigner, FalconSignatureStruct, FalconVerifier, HashFactory, HeartbeatProof, HeartbeatTransactionFields, HoldingReference, HoldingReferenceMeta, KeyRegistrationTransactionFields, LocalsReference, LocalsReferenceMeta, LogicSigAccount, LogicSignature, MerkleArrayProof, MerkleSignatureVerifier, MultisigAccount, MultisigMetadata, MultisigSignature, MultisigSubsignature, MxBytesSigner, OnApplicationComplete, Participant, PaymentTransactionFields, ProgramDataSigner, ResourceReference, Reveal, SendingAddress, SignedTransaction, SignedTransactionMeta, SigslotCommit, StateProof, StateProofMessage, StateProofTransactionFields, StateSchema, Transaction, TransactionParams, TransactionParamsMeta, TransactionSigner, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec, validateSignedTransaction, validateTransaction };
|
package/transact/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
const require_app_call = require('../packages/transact/src/transactions/app-call.js');
|
|
2
|
-
const require_asset_config = require('../packages/transact/src/transactions/asset-config.js');
|
|
3
|
-
const require_asset_freeze = require('../packages/transact/src/transactions/asset-freeze.js');
|
|
4
|
-
const require_asset_transfer = require('../packages/transact/src/transactions/asset-transfer.js');
|
|
5
|
-
const require_key_registration = require('../packages/transact/src/transactions/key-registration.js');
|
|
6
2
|
const require_transaction_type = require('../packages/transact/src/transactions/transaction-type.js');
|
|
7
3
|
const require_transaction_meta = require('../packages/transact/src/transactions/transaction-meta.js');
|
|
8
4
|
const require_transaction = require('../packages/transact/src/transactions/transaction.js');
|
|
@@ -10,8 +6,8 @@ const require_signed_transaction_meta = require('../packages/transact/src/transa
|
|
|
10
6
|
const require_signed_transaction = require('../packages/transact/src/transactions/signed-transaction.js');
|
|
11
7
|
const require_reference_types_meta = require('../packages/transact/src/transactions/reference-types-meta.js');
|
|
12
8
|
const require_signer = require('../packages/transact/src/signer.js');
|
|
13
|
-
const require_multisig = require('../packages/transact/src/multisig.js');
|
|
14
9
|
const require_logicsig = require('../packages/transact/src/logicsig.js');
|
|
10
|
+
const require_multisig = require('../packages/transact/src/multisig.js');
|
|
15
11
|
|
|
16
12
|
exports.BoxReferenceMeta = require_reference_types_meta.BoxReferenceMeta;
|
|
17
13
|
exports.HoldingReferenceMeta = require_reference_types_meta.HoldingReferenceMeta;
|
|
@@ -41,8 +37,5 @@ exports.groupTransactions = require_transaction.groupTransactions;
|
|
|
41
37
|
exports.makeEmptyTransactionSigner = require_signer.makeEmptyTransactionSigner;
|
|
42
38
|
exports.transactionCodec = require_transaction.transactionCodec;
|
|
43
39
|
exports.transactionParamsCodec = require_transaction_meta.transactionParamsCodec;
|
|
44
|
-
exports.
|
|
45
|
-
exports.
|
|
46
|
-
exports.validateAssetFreezeTransaction = require_asset_freeze.validateAssetFreezeTransaction;
|
|
47
|
-
exports.validateAssetTransferTransaction = require_asset_transfer.validateAssetTransferTransaction;
|
|
48
|
-
exports.validateKeyRegistrationTransaction = require_key_registration.validateKeyRegistrationTransaction;
|
|
40
|
+
exports.validateSignedTransaction = require_signed_transaction.validateSignedTransaction;
|
|
41
|
+
exports.validateTransaction = require_transaction.validateTransaction;
|
package/transact/index.mjs
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { OnApplicationComplete
|
|
2
|
-
import { validateAssetConfigTransaction } from "../packages/transact/src/transactions/asset-config.mjs";
|
|
3
|
-
import { validateAssetFreezeTransaction } from "../packages/transact/src/transactions/asset-freeze.mjs";
|
|
4
|
-
import { validateAssetTransferTransaction } from "../packages/transact/src/transactions/asset-transfer.mjs";
|
|
5
|
-
import { validateKeyRegistrationTransaction } from "../packages/transact/src/transactions/key-registration.mjs";
|
|
1
|
+
import { OnApplicationComplete } from "../packages/transact/src/transactions/app-call.mjs";
|
|
6
2
|
import { TransactionType } from "../packages/transact/src/transactions/transaction-type.mjs";
|
|
7
3
|
import { TransactionParamsMeta, transactionParamsCodec } from "../packages/transact/src/transactions/transaction-meta.mjs";
|
|
8
|
-
import { Transaction, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec } from "../packages/transact/src/transactions/transaction.mjs";
|
|
4
|
+
import { Transaction, assignFee, calculateFee, decodeTransaction, decodeTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, getEncodedTransactionType, groupTransactions, transactionCodec, validateTransaction } from "../packages/transact/src/transactions/transaction.mjs";
|
|
9
5
|
import { SignedTransactionMeta } from "../packages/transact/src/transactions/signed-transaction-meta.mjs";
|
|
10
|
-
import { decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions } from "../packages/transact/src/transactions/signed-transaction.mjs";
|
|
6
|
+
import { decodeSignedTransaction, decodeSignedTransactions, encodeSignedTransaction, encodeSignedTransactions, validateSignedTransaction } from "../packages/transact/src/transactions/signed-transaction.mjs";
|
|
11
7
|
import { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta } from "../packages/transact/src/transactions/reference-types-meta.mjs";
|
|
12
8
|
import { generateAddressWithSigners, makeEmptyTransactionSigner } from "../packages/transact/src/signer.mjs";
|
|
13
|
-
import { MultisigAccount } from "../packages/transact/src/multisig.mjs";
|
|
14
9
|
import { LogicSigAccount } from "../packages/transact/src/logicsig.mjs";
|
|
10
|
+
import { MultisigAccount } from "../packages/transact/src/multisig.mjs";
|
|
15
11
|
|
|
16
|
-
export { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta, LogicSigAccount, MultisigAccount, OnApplicationComplete, SignedTransactionMeta, Transaction, TransactionParamsMeta, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec,
|
|
12
|
+
export { BoxReferenceMeta, HoldingReferenceMeta, LocalsReferenceMeta, LogicSigAccount, MultisigAccount, OnApplicationComplete, SignedTransactionMeta, Transaction, TransactionParamsMeta, TransactionType, assignFee, calculateFee, decodeSignedTransaction, decodeSignedTransactions, decodeTransaction, decodeTransactions, encodeSignedTransaction, encodeSignedTransactions, encodeTransaction, encodeTransactionRaw, encodeTransactions, estimateTransactionSize, generateAddressWithSigners, getEncodedTransactionType, groupTransactions, makeEmptyTransactionSigner, transactionCodec, transactionParamsCodec, validateSignedTransaction, validateTransaction };
|
|
@@ -15,7 +15,7 @@ type OnlineKeyRegistrationParams = CommonTransactionParams & {
|
|
|
15
15
|
/** This is the dilution for the 2-level participation key. It determines the interval (number of rounds) for generating new ephemeral keys */
|
|
16
16
|
voteKeyDilution: bigint;
|
|
17
17
|
/** The 64 byte state proof public key commitment */
|
|
18
|
-
stateProofKey
|
|
18
|
+
stateProofKey: Uint8Array;
|
|
19
19
|
};
|
|
20
20
|
/** Parameters to define an offline key registration transaction. */
|
|
21
21
|
type OfflineKeyRegistrationParams = CommonTransactionParams & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-registration.js","names":["buildTransactionCommonData","Transaction","TransactionType"],"sources":["../../src/transactions/key-registration.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Parameters to define an online key registration transaction. */\nexport type OnlineKeyRegistrationParams = CommonTransactionParams & {\n /** The root participation public key */\n voteKey: Uint8Array\n /** The VRF public key */\n selectionKey: Uint8Array\n /** The first round that the participation key is valid. Not to be confused with the `firstValid` round of the keyreg transaction */\n voteFirst: bigint\n /** The last round that the participation key is valid. Not to be confused with the `lastValid` round of the keyreg transaction */\n voteLast: bigint\n /** This is the dilution for the 2-level participation key. It determines the interval (number of rounds) for generating new ephemeral keys */\n voteKeyDilution: bigint\n /** The 64 byte state proof public key commitment */\n stateProofKey
|
|
1
|
+
{"version":3,"file":"key-registration.js","names":["buildTransactionCommonData","Transaction","TransactionType"],"sources":["../../src/transactions/key-registration.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Parameters to define an online key registration transaction. */\nexport type OnlineKeyRegistrationParams = CommonTransactionParams & {\n /** The root participation public key */\n voteKey: Uint8Array\n /** The VRF public key */\n selectionKey: Uint8Array\n /** The first round that the participation key is valid. Not to be confused with the `firstValid` round of the keyreg transaction */\n voteFirst: bigint\n /** The last round that the participation key is valid. Not to be confused with the `lastValid` round of the keyreg transaction */\n voteLast: bigint\n /** This is the dilution for the 2-level participation key. It determines the interval (number of rounds) for generating new ephemeral keys */\n voteKeyDilution: bigint\n /** The 64 byte state proof public key commitment */\n stateProofKey: Uint8Array\n}\n\n/** Parameters to define an offline key registration transaction. */\nexport type OfflineKeyRegistrationParams = CommonTransactionParams & {\n /** Prevent this account from ever participating again. The account will also no longer earn rewards */\n preventAccountFromEverParticipatingAgain?: boolean\n}\n\nexport const buildKeyReg = (\n params: OnlineKeyRegistrationParams | OfflineKeyRegistrationParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n if ('voteKey' in params) {\n return new Transaction({\n ...commonData,\n type: TransactionType.KeyRegistration,\n keyRegistration: {\n voteKey: params.voteKey,\n selectionKey: params.selectionKey,\n voteFirst: params.voteFirst,\n voteLast: params.voteLast,\n voteKeyDilution: params.voteKeyDilution,\n nonParticipation: false,\n stateProofKey: params.stateProofKey,\n },\n })\n } else {\n return new Transaction({\n ...commonData,\n type: TransactionType.KeyRegistration,\n keyRegistration: {\n nonParticipation: params.preventAccountFromEverParticipatingAgain,\n },\n })\n }\n}\n"],"mappings":";;;;;AA0BA,MAAa,eACX,QACA,iBACA,0BACgB;CAChB,MAAM,aAAaA,0CAA2B,QAAQ,iBAAiB,sBAAsB;AAC7F,KAAI,aAAa,OACf,QAAO,IAAIC,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,iBAAiB;GACf,SAAS,OAAO;GAChB,cAAc,OAAO;GACrB,WAAW,OAAO;GAClB,UAAU,OAAO;GACjB,iBAAiB,OAAO;GACxB,kBAAkB;GAClB,eAAe,OAAO;GACvB;EACF,CAAC;KAEF,QAAO,IAAID,gCAAY;EACrB,GAAG;EACH,MAAMC,yCAAgB;EACtB,iBAAiB,EACf,kBAAkB,OAAO,0CAC1B;EACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-registration.mjs","names":[],"sources":["../../src/transactions/key-registration.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Parameters to define an online key registration transaction. */\nexport type OnlineKeyRegistrationParams = CommonTransactionParams & {\n /** The root participation public key */\n voteKey: Uint8Array\n /** The VRF public key */\n selectionKey: Uint8Array\n /** The first round that the participation key is valid. Not to be confused with the `firstValid` round of the keyreg transaction */\n voteFirst: bigint\n /** The last round that the participation key is valid. Not to be confused with the `lastValid` round of the keyreg transaction */\n voteLast: bigint\n /** This is the dilution for the 2-level participation key. It determines the interval (number of rounds) for generating new ephemeral keys */\n voteKeyDilution: bigint\n /** The 64 byte state proof public key commitment */\n stateProofKey
|
|
1
|
+
{"version":3,"file":"key-registration.mjs","names":[],"sources":["../../src/transactions/key-registration.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Parameters to define an online key registration transaction. */\nexport type OnlineKeyRegistrationParams = CommonTransactionParams & {\n /** The root participation public key */\n voteKey: Uint8Array\n /** The VRF public key */\n selectionKey: Uint8Array\n /** The first round that the participation key is valid. Not to be confused with the `firstValid` round of the keyreg transaction */\n voteFirst: bigint\n /** The last round that the participation key is valid. Not to be confused with the `lastValid` round of the keyreg transaction */\n voteLast: bigint\n /** This is the dilution for the 2-level participation key. It determines the interval (number of rounds) for generating new ephemeral keys */\n voteKeyDilution: bigint\n /** The 64 byte state proof public key commitment */\n stateProofKey: Uint8Array\n}\n\n/** Parameters to define an offline key registration transaction. */\nexport type OfflineKeyRegistrationParams = CommonTransactionParams & {\n /** Prevent this account from ever participating again. The account will also no longer earn rewards */\n preventAccountFromEverParticipatingAgain?: boolean\n}\n\nexport const buildKeyReg = (\n params: OnlineKeyRegistrationParams | OfflineKeyRegistrationParams,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n if ('voteKey' in params) {\n return new Transaction({\n ...commonData,\n type: TransactionType.KeyRegistration,\n keyRegistration: {\n voteKey: params.voteKey,\n selectionKey: params.selectionKey,\n voteFirst: params.voteFirst,\n voteLast: params.voteLast,\n voteKeyDilution: params.voteKeyDilution,\n nonParticipation: false,\n stateProofKey: params.stateProofKey,\n },\n })\n } else {\n return new Transaction({\n ...commonData,\n type: TransactionType.KeyRegistration,\n keyRegistration: {\n nonParticipation: params.preventAccountFromEverParticipatingAgain,\n },\n })\n }\n}\n"],"mappings":";;;;;AA0BA,MAAa,eACX,QACA,iBACA,0BACgB;CAChB,MAAM,aAAa,2BAA2B,QAAQ,iBAAiB,sBAAsB;AAC7F,KAAI,aAAa,OACf,QAAO,IAAI,YAAY;EACrB,GAAG;EACH,MAAM,gBAAgB;EACtB,iBAAiB;GACf,SAAS,OAAO;GAChB,cAAc,OAAO;GACrB,WAAW,OAAO;GAClB,UAAU,OAAO;GACjB,iBAAiB,OAAO;GACxB,kBAAkB;GAClB,eAAe,OAAO;GACvB;EACF,CAAC;KAEF,QAAO,IAAI,YAAY;EACrB,GAAG;EACH,MAAM,gBAAgB;EACtB,iBAAiB,EACf,kBAAkB,OAAO,0CAC1B;EACF,CAAC"}
|
package/types/account-manager.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
2
|
const require_address = require('../packages/common/src/address.js');
|
|
3
3
|
const require_signer = require('../packages/transact/src/signer.js');
|
|
4
|
-
const require_multisig = require('../packages/transact/src/multisig.js');
|
|
5
4
|
const require_logicsig = require('../packages/transact/src/logicsig.js');
|
|
5
|
+
const require_multisig = require('../packages/transact/src/multisig.js');
|
|
6
6
|
const require_amount = require('./amount.js');
|
|
7
7
|
const require_config = require('../config.js');
|
|
8
8
|
const require_util = require('../util.js');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Address, getAddress, getOptionalAddress } from "../packages/common/src/address.mjs";
|
|
2
2
|
import { generateAddressWithSigners } from "../packages/transact/src/signer.mjs";
|
|
3
|
-
import { MultisigAccount } from "../packages/transact/src/multisig.mjs";
|
|
4
3
|
import { LogicSigAccount } from "../packages/transact/src/logicsig.mjs";
|
|
4
|
+
import { MultisigAccount } from "../packages/transact/src/multisig.mjs";
|
|
5
5
|
import { AlgoAmount } from "./amount.mjs";
|
|
6
6
|
import { Config } from "../config.mjs";
|
|
7
7
|
import { calculateFundAmount, memoize } from "../util.mjs";
|
|
@@ -348,8 +348,9 @@ declare class AlgorandClientTransactionCreator {
|
|
|
348
348
|
* @returns The application create transaction
|
|
349
349
|
*/
|
|
350
350
|
appCreate: (params: {
|
|
351
|
+
args?: Uint8Array[] | undefined;
|
|
351
352
|
sender: SendingAddress;
|
|
352
|
-
signer?:
|
|
353
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
353
354
|
rekeyTo?: ReadableAddress | undefined;
|
|
354
355
|
note?: string | Uint8Array | undefined;
|
|
355
356
|
lease?: string | Uint8Array | undefined;
|
|
@@ -360,7 +361,6 @@ declare class AlgorandClientTransactionCreator {
|
|
|
360
361
|
firstValidRound?: bigint | undefined;
|
|
361
362
|
lastValidRound?: bigint | undefined;
|
|
362
363
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
|
|
363
|
-
args?: Uint8Array[] | undefined;
|
|
364
364
|
accountReferences?: ReadableAddress[] | undefined;
|
|
365
365
|
appReferences?: bigint[] | undefined;
|
|
366
366
|
assetReferences?: bigint[] | undefined;
|
|
@@ -417,7 +417,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
417
417
|
*/
|
|
418
418
|
appUpdate: (params: {
|
|
419
419
|
sender: SendingAddress;
|
|
420
|
-
signer?:
|
|
420
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
421
421
|
rekeyTo?: ReadableAddress | undefined;
|
|
422
422
|
note?: string | Uint8Array | undefined;
|
|
423
423
|
lease?: string | Uint8Array | undefined;
|
|
@@ -570,7 +570,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
570
570
|
appCreateMethodCall: (params: {
|
|
571
571
|
appId?: 0 | undefined;
|
|
572
572
|
sender: SendingAddress;
|
|
573
|
-
signer?:
|
|
573
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
574
574
|
rekeyTo?: ReadableAddress | undefined;
|
|
575
575
|
note?: string | Uint8Array | undefined;
|
|
576
576
|
lease?: string | Uint8Array | undefined;
|
|
@@ -597,9 +597,10 @@ declare class AlgorandClientTransactionCreator {
|
|
|
597
597
|
} | undefined;
|
|
598
598
|
extraProgramPages?: number | undefined;
|
|
599
599
|
method: ABIMethod;
|
|
600
|
-
args?: (Transaction |
|
|
600
|
+
args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
601
|
+
args?: Uint8Array[] | undefined;
|
|
601
602
|
sender: SendingAddress;
|
|
602
|
-
signer?:
|
|
603
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
603
604
|
rekeyTo?: ReadableAddress | undefined;
|
|
604
605
|
note?: string | Uint8Array | undefined;
|
|
605
606
|
lease?: string | Uint8Array | undefined;
|
|
@@ -610,7 +611,6 @@ declare class AlgorandClientTransactionCreator {
|
|
|
610
611
|
firstValidRound?: bigint | undefined;
|
|
611
612
|
lastValidRound?: bigint | undefined;
|
|
612
613
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
|
|
613
|
-
args?: Uint8Array[] | undefined;
|
|
614
614
|
accountReferences?: ReadableAddress[] | undefined;
|
|
615
615
|
appReferences?: bigint[] | undefined;
|
|
616
616
|
assetReferences?: bigint[] | undefined;
|
|
@@ -629,7 +629,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
629
629
|
extraProgramPages?: number | undefined;
|
|
630
630
|
}> | AppMethodCall<{
|
|
631
631
|
sender: SendingAddress;
|
|
632
|
-
signer?:
|
|
632
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
633
633
|
rekeyTo?: ReadableAddress | undefined;
|
|
634
634
|
note?: string | Uint8Array | undefined;
|
|
635
635
|
lease?: string | Uint8Array | undefined;
|
|
@@ -650,7 +650,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
650
650
|
rejectVersion?: number | undefined;
|
|
651
651
|
approvalProgram: string | Uint8Array;
|
|
652
652
|
clearStateProgram: string | Uint8Array;
|
|
653
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
653
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
654
654
|
}) => Promise<Expand<BuiltTransactions>>;
|
|
655
655
|
/** Create an application update call with ABI method call transaction.
|
|
656
656
|
*
|
|
@@ -704,7 +704,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
704
704
|
appUpdateMethodCall: (params: {
|
|
705
705
|
appId: bigint;
|
|
706
706
|
sender: SendingAddress;
|
|
707
|
-
signer?:
|
|
707
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
708
708
|
rekeyTo?: ReadableAddress | undefined;
|
|
709
709
|
note?: string | Uint8Array | undefined;
|
|
710
710
|
lease?: string | Uint8Array | undefined;
|
|
@@ -724,9 +724,10 @@ declare class AlgorandClientTransactionCreator {
|
|
|
724
724
|
approvalProgram: string | Uint8Array;
|
|
725
725
|
clearStateProgram: string | Uint8Array;
|
|
726
726
|
method: ABIMethod;
|
|
727
|
-
args?: (Transaction |
|
|
727
|
+
args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
728
|
+
args?: Uint8Array[] | undefined;
|
|
728
729
|
sender: SendingAddress;
|
|
729
|
-
signer?:
|
|
730
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
730
731
|
rekeyTo?: ReadableAddress | undefined;
|
|
731
732
|
note?: string | Uint8Array | undefined;
|
|
732
733
|
lease?: string | Uint8Array | undefined;
|
|
@@ -737,7 +738,6 @@ declare class AlgorandClientTransactionCreator {
|
|
|
737
738
|
firstValidRound?: bigint | undefined;
|
|
738
739
|
lastValidRound?: bigint | undefined;
|
|
739
740
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
|
|
740
|
-
args?: Uint8Array[] | undefined;
|
|
741
741
|
accountReferences?: ReadableAddress[] | undefined;
|
|
742
742
|
appReferences?: bigint[] | undefined;
|
|
743
743
|
assetReferences?: bigint[] | undefined;
|
|
@@ -756,7 +756,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
756
756
|
extraProgramPages?: number | undefined;
|
|
757
757
|
}> | AppMethodCall<{
|
|
758
758
|
sender: SendingAddress;
|
|
759
|
-
signer?:
|
|
759
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
760
760
|
rekeyTo?: ReadableAddress | undefined;
|
|
761
761
|
note?: string | Uint8Array | undefined;
|
|
762
762
|
lease?: string | Uint8Array | undefined;
|
|
@@ -777,7 +777,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
777
777
|
rejectVersion?: number | undefined;
|
|
778
778
|
approvalProgram: string | Uint8Array;
|
|
779
779
|
clearStateProgram: string | Uint8Array;
|
|
780
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
780
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
781
781
|
}) => Promise<Expand<BuiltTransactions>>;
|
|
782
782
|
/** Create an application delete call with ABI method call transaction.
|
|
783
783
|
*
|
|
@@ -829,7 +829,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
829
829
|
appDeleteMethodCall: (params: {
|
|
830
830
|
appId: bigint;
|
|
831
831
|
sender: SendingAddress;
|
|
832
|
-
signer?:
|
|
832
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
833
833
|
rekeyTo?: ReadableAddress | undefined;
|
|
834
834
|
note?: string | Uint8Array | undefined;
|
|
835
835
|
lease?: string | Uint8Array | undefined;
|
|
@@ -847,9 +847,10 @@ declare class AlgorandClientTransactionCreator {
|
|
|
847
847
|
accessReferences?: ResourceReference[] | undefined;
|
|
848
848
|
rejectVersion?: number | undefined;
|
|
849
849
|
method: ABIMethod;
|
|
850
|
-
args?: (Transaction |
|
|
850
|
+
args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
851
|
+
args?: Uint8Array[] | undefined;
|
|
851
852
|
sender: SendingAddress;
|
|
852
|
-
signer?:
|
|
853
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
853
854
|
rekeyTo?: ReadableAddress | undefined;
|
|
854
855
|
note?: string | Uint8Array | undefined;
|
|
855
856
|
lease?: string | Uint8Array | undefined;
|
|
@@ -860,7 +861,6 @@ declare class AlgorandClientTransactionCreator {
|
|
|
860
861
|
firstValidRound?: bigint | undefined;
|
|
861
862
|
lastValidRound?: bigint | undefined;
|
|
862
863
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
|
|
863
|
-
args?: Uint8Array[] | undefined;
|
|
864
864
|
accountReferences?: ReadableAddress[] | undefined;
|
|
865
865
|
appReferences?: bigint[] | undefined;
|
|
866
866
|
assetReferences?: bigint[] | undefined;
|
|
@@ -879,7 +879,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
879
879
|
extraProgramPages?: number | undefined;
|
|
880
880
|
}> | AppMethodCall<{
|
|
881
881
|
sender: SendingAddress;
|
|
882
|
-
signer?:
|
|
882
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
883
883
|
rekeyTo?: ReadableAddress | undefined;
|
|
884
884
|
note?: string | Uint8Array | undefined;
|
|
885
885
|
lease?: string | Uint8Array | undefined;
|
|
@@ -900,7 +900,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
900
900
|
rejectVersion?: number | undefined;
|
|
901
901
|
approvalProgram: string | Uint8Array;
|
|
902
902
|
clearStateProgram: string | Uint8Array;
|
|
903
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
903
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
904
904
|
}) => Promise<Expand<BuiltTransactions>>;
|
|
905
905
|
/** Create an application call with ABI method call transaction.
|
|
906
906
|
*
|
|
@@ -952,7 +952,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
952
952
|
appCallMethodCall: (params: {
|
|
953
953
|
appId: bigint;
|
|
954
954
|
sender: SendingAddress;
|
|
955
|
-
signer?:
|
|
955
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
956
956
|
rekeyTo?: ReadableAddress | undefined;
|
|
957
957
|
note?: string | Uint8Array | undefined;
|
|
958
958
|
lease?: string | Uint8Array | undefined;
|
|
@@ -970,9 +970,10 @@ declare class AlgorandClientTransactionCreator {
|
|
|
970
970
|
accessReferences?: ResourceReference[] | undefined;
|
|
971
971
|
rejectVersion?: number | undefined;
|
|
972
972
|
method: ABIMethod;
|
|
973
|
-
args?: (Transaction |
|
|
973
|
+
args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
|
|
974
|
+
args?: Uint8Array[] | undefined;
|
|
974
975
|
sender: SendingAddress;
|
|
975
|
-
signer?:
|
|
976
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
976
977
|
rekeyTo?: ReadableAddress | undefined;
|
|
977
978
|
note?: string | Uint8Array | undefined;
|
|
978
979
|
lease?: string | Uint8Array | undefined;
|
|
@@ -983,7 +984,6 @@ declare class AlgorandClientTransactionCreator {
|
|
|
983
984
|
firstValidRound?: bigint | undefined;
|
|
984
985
|
lastValidRound?: bigint | undefined;
|
|
985
986
|
onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
|
|
986
|
-
args?: Uint8Array[] | undefined;
|
|
987
987
|
accountReferences?: ReadableAddress[] | undefined;
|
|
988
988
|
appReferences?: bigint[] | undefined;
|
|
989
989
|
assetReferences?: bigint[] | undefined;
|
|
@@ -1002,7 +1002,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
1002
1002
|
extraProgramPages?: number | undefined;
|
|
1003
1003
|
}> | AppMethodCall<{
|
|
1004
1004
|
sender: SendingAddress;
|
|
1005
|
-
signer?:
|
|
1005
|
+
signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
|
|
1006
1006
|
rekeyTo?: ReadableAddress | undefined;
|
|
1007
1007
|
note?: string | Uint8Array | undefined;
|
|
1008
1008
|
lease?: string | Uint8Array | undefined;
|
|
@@ -1023,7 +1023,7 @@ declare class AlgorandClientTransactionCreator {
|
|
|
1023
1023
|
rejectVersion?: number | undefined;
|
|
1024
1024
|
approvalProgram: string | Uint8Array;
|
|
1025
1025
|
clearStateProgram: string | Uint8Array;
|
|
1026
|
-
}> | AppMethodCall<AppMethodCallParams> | undefined)[] | undefined;
|
|
1026
|
+
}> | AppMethodCall<AppMethodCallParams> | Promise<Transaction> | undefined)[] | undefined;
|
|
1027
1027
|
}) => Promise<Expand<BuiltTransactions>>;
|
|
1028
1028
|
/**
|
|
1029
1029
|
* Create an online key registration transaction.
|