diff --git a/docs/code/classes/types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md b/docs/code/classes/types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md index 5a0688bd..67bf7490 100644 --- a/docs/code/classes/types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md +++ b/docs/code/classes/types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md @@ -30,6 +30,7 @@ Orchestrates creating transactions for `AlgorandClient`. - [assetOptIn](types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md#assetoptin) - [assetOptOut](types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md#assetoptout) - [assetTransfer](types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md#assettransfer) +- [offlineKeyRegistration](types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md#offlinekeyregistration) - [onlineKeyRegistration](types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md#onlinekeyregistration) - [payment](types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md#payment) @@ -1103,6 +1104,32 @@ await algorand.createTransaction.assetTransfer({ ___ +### offlineKeyRegistration + +• **offlineKeyRegistration**: (`params`: [`OfflineKeyRegistrationParams`](../modules/types_composer.md#offlinekeyregistrationparams)) => `Promise`\<`Transaction`\> + +Create an offline key registration transaction. + +#### Type declaration + +▸ (`params`): `Promise`\<`Transaction`\> + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `params` | [`OfflineKeyRegistrationParams`](../modules/types_composer.md#offlinekeyregistrationparams) | + +##### Returns + +`Promise`\<`Transaction`\> + +#### Defined in + +[src/types/algorand-client-transaction-creator.ts:692](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/algorand-client-transaction-creator.ts#L692) + +___ + ### onlineKeyRegistration • **onlineKeyRegistration**: (`params`: [`OnlineKeyRegistrationParams`](../modules/types_composer.md#onlinekeyregistrationparams)) => `Promise`\<`Transaction`\> diff --git a/docs/code/classes/types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md b/docs/code/classes/types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md index eb2e52c5..2983ebf7 100644 --- a/docs/code/classes/types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md +++ b/docs/code/classes/types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md @@ -30,6 +30,7 @@ Orchestrates sending transactions for `AlgorandClient`. - [assetFreeze](types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md#assetfreeze) - [assetOptIn](types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md#assetoptin) - [assetTransfer](types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md#assettransfer) +- [offlineKeyRegistration](types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md#offlinekeyregistration) - [onlineKeyRegistration](types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md#onlinekeyregistration) - [payment](types_algorand_client_transaction_sender.AlgorandClientTransactionSender.md#payment) @@ -995,6 +996,32 @@ await algorand.send.assetTransfer({ ___ +### offlineKeyRegistration + +• **offlineKeyRegistration**: (`params`: [`CommonTransactionParams`](../modules/types_composer.md#commontransactionparams) & \{ `preventAccountFromEverParticipatingAgain?`: `boolean` } & [`SendParams`](../interfaces/types_transaction.SendParams.md)) => `Promise`\<\{ `confirmation`: `PendingTransactionResponse` ; `confirmations`: `PendingTransactionResponse`[] ; `groupId`: `string` ; `returns?`: [`ABIReturn`](../modules/types_app.md#abireturn)[] ; `transaction`: `Transaction` ; `transactions`: `Transaction`[] ; `txIds`: `string`[] }\> + +Register an offline key. + +#### Type declaration + +▸ (`params`): `Promise`\<\{ `confirmation`: `PendingTransactionResponse` ; `confirmations`: `PendingTransactionResponse`[] ; `groupId`: `string` ; `returns?`: [`ABIReturn`](../modules/types_app.md#abireturn)[] ; `transaction`: `Transaction` ; `transactions`: `Transaction`[] ; `txIds`: `string`[] }\> + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `params` | [`CommonTransactionParams`](../modules/types_composer.md#commontransactionparams) & \{ `preventAccountFromEverParticipatingAgain?`: `boolean` } & [`SendParams`](../interfaces/types_transaction.SendParams.md) | + +##### Returns + +`Promise`\<\{ `confirmation`: `PendingTransactionResponse` ; `confirmations`: `PendingTransactionResponse`[] ; `groupId`: `string` ; `returns?`: [`ABIReturn`](../modules/types_app.md#abireturn)[] ; `transaction`: `Transaction` ; `transactions`: `Transaction`[] ; `txIds`: `string`[] }\> + +#### Defined in + +[src/types/algorand-client-transaction-sender.ts:955](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/algorand-client-transaction-sender.ts#L955) + +___ + ### onlineKeyRegistration • **onlineKeyRegistration**: (`params`: [`CommonTransactionParams`](../modules/types_composer.md#commontransactionparams) & \{ `selectionKey`: `Uint8Array` ; `stateProofKey?`: `Uint8Array` ; `voteFirst`: `bigint` ; `voteKey`: `Uint8Array` ; `voteKeyDilution`: `bigint` ; `voteLast`: `bigint` } & [`SendParams`](../interfaces/types_transaction.SendParams.md)) => `Promise`\<\{ `confirmation`: `PendingTransactionResponse` ; `confirmations`: `PendingTransactionResponse`[] ; `groupId`: `string` ; `returns?`: [`ABIReturn`](../modules/types_app.md#abireturn)[] ; `transaction`: `Transaction` ; `transactions`: `Transaction`[] ; `txIds`: `string`[] }\> diff --git a/docs/code/classes/types_composer.TransactionComposer.md b/docs/code/classes/types_composer.TransactionComposer.md index 61672c59..f40505a7 100644 --- a/docs/code/classes/types_composer.TransactionComposer.md +++ b/docs/code/classes/types_composer.TransactionComposer.md @@ -43,6 +43,7 @@ TransactionComposer helps you compose and execute transactions as a transaction - [addAssetOptOut](types_composer.TransactionComposer.md#addassetoptout) - [addAssetTransfer](types_composer.TransactionComposer.md#addassettransfer) - [addAtc](types_composer.TransactionComposer.md#addatc) +- [addOfflineKeyRegistration](types_composer.TransactionComposer.md#addofflinekeyregistration) - [addOnlineKeyRegistration](types_composer.TransactionComposer.md#addonlinekeyregistration) - [addPayment](types_composer.TransactionComposer.md#addpayment) - [addTransaction](types_composer.TransactionComposer.md#addtransaction) @@ -675,6 +676,30 @@ The composer so you can chain method calls #### Defined in +[src/types/composer.ts:770](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L770) + +___ + +### addOfflineKeyRegistration + +▸ **addOfflineKeyRegistration**(`params`): [`TransactionComposer`](types_composer.TransactionComposer.md) + +Add an offline key registration transaction to the transaction group. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `params` | [`OfflineKeyRegistrationParams`](../modules/types_composer.md#offlinekeyregistrationparams) | The offline key registration transaction parameters | + +#### Returns + +[`TransactionComposer`](types_composer.TransactionComposer.md) + +The composer so you can chain method calls + +#### Defined in + [src/types/composer.ts:759](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L759) ___ @@ -771,7 +796,7 @@ The built atomic transaction composer and the transactions #### Defined in -[src/types/composer.ts:1220](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1220) +[src/types/composer.ts:1241](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1241) ___ @@ -792,7 +817,7 @@ ___ #### Defined in -[src/types/composer.ts:1038](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1038) +[src/types/composer.ts:1049](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1049) ___ @@ -813,7 +838,7 @@ ___ #### Defined in -[src/types/composer.ts:987](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L987) +[src/types/composer.ts:998](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L998) ___ @@ -834,7 +859,7 @@ ___ #### Defined in -[src/types/composer.ts:967](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L967) +[src/types/composer.ts:978](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L978) ___ @@ -855,7 +880,7 @@ ___ #### Defined in -[src/types/composer.ts:1002](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1002) +[src/types/composer.ts:1013](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1013) ___ @@ -876,7 +901,7 @@ ___ #### Defined in -[src/types/composer.ts:1012](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1012) +[src/types/composer.ts:1023](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1023) ___ @@ -897,7 +922,7 @@ ___ #### Defined in -[src/types/composer.ts:1024](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1024) +[src/types/composer.ts:1035](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1035) ___ @@ -920,7 +945,7 @@ Build an ATC and return transactions ready to be incorporated into a broader set #### Defined in -[src/types/composer.ts:765](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L765) +[src/types/composer.ts:776](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L776) ___ @@ -932,7 +957,7 @@ ___ | Name | Type | | :------ | :------ | -| `params` | [`OnlineKeyRegistrationParams`](../modules/types_composer.md#onlinekeyregistrationparams) | +| `params` | [`OnlineKeyRegistrationParams`](../modules/types_composer.md#onlinekeyregistrationparams) \| [`OfflineKeyRegistrationParams`](../modules/types_composer.md#offlinekeyregistrationparams) | | `suggestedParams` | `SuggestedParams` | #### Returns @@ -941,7 +966,7 @@ ___ #### Defined in -[src/types/composer.ts:1093](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1093) +[src/types/composer.ts:1104](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1104) ___ @@ -965,7 +990,7 @@ Builds an ABI method call transaction and any other associated transactions repr #### Defined in -[src/types/composer.ts:831](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L831) +[src/types/composer.ts:842](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L842) ___ @@ -986,7 +1011,7 @@ ___ #### Defined in -[src/types/composer.ts:955](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L955) +[src/types/composer.ts:966](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L966) ___ @@ -1004,7 +1029,7 @@ The array of built transactions and any corresponding method calls #### Defined in -[src/types/composer.ts:1167](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1167) +[src/types/composer.ts:1188](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1188) ___ @@ -1027,7 +1052,7 @@ Builds all transaction types apart from `txnWithSigner`, `atc` and `methodCall` #### Defined in -[src/types/composer.ts:1117](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1117) +[src/types/composer.ts:1138](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1138) ___ @@ -1048,7 +1073,7 @@ ___ #### Defined in -[src/types/composer.ts:1144](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1144) +[src/types/composer.ts:1165](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1165) ___ @@ -1070,7 +1095,7 @@ ___ #### Defined in -[src/types/composer.ts:786](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L786) +[src/types/composer.ts:797](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L797) ___ @@ -1086,7 +1111,7 @@ Get the number of transactions currently added to this composer. #### Defined in -[src/types/composer.ts:1207](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1207) +[src/types/composer.ts:1228](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1228) ___ @@ -1116,7 +1141,7 @@ An alias for `composer.send(params)`. #### Defined in -[src/types/composer.ts:1289](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1289) +[src/types/composer.ts:1310](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1310) ___ @@ -1135,7 +1160,7 @@ The newly built atomic transaction composer and the transactions #### Defined in -[src/types/composer.ts:1249](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1249) +[src/types/composer.ts:1270](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1270) ___ @@ -1159,7 +1184,7 @@ The execution result #### Defined in -[src/types/composer.ts:1259](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1259) +[src/types/composer.ts:1280](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1280) ___ @@ -1183,7 +1208,7 @@ The simulation result #### Defined in -[src/types/composer.ts:1297](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1297) +[src/types/composer.ts:1318](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1318) ___ @@ -1209,4 +1234,4 @@ The binary encoded transaction note #### Defined in -[src/types/composer.ts:1372](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1372) +[src/types/composer.ts:1393](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L1393) diff --git a/docs/code/modules/types_composer.md b/docs/code/modules/types_composer.md index 67347ea4..ca36f088 100644 --- a/docs/code/modules/types_composer.md +++ b/docs/code/modules/types_composer.md @@ -34,6 +34,7 @@ - [AssetTransferParams](types_composer.md#assettransferparams) - [CommonAppCallParams](types_composer.md#commonappcallparams) - [CommonTransactionParams](types_composer.md#commontransactionparams) +- [OfflineKeyRegistrationParams](types_composer.md#offlinekeyregistrationparams) - [OnlineKeyRegistrationParams](types_composer.md#onlinekeyregistrationparams) - [PaymentParams](types_composer.md#paymentparams) - [SimulateOptions](types_composer.md#simulateoptions) @@ -316,6 +317,18 @@ Common parameters for defining a transaction. ___ +### OfflineKeyRegistrationParams + +Ƭ **OfflineKeyRegistrationParams**: [`CommonTransactionParams`](types_composer.md#commontransactionparams) & \{ `preventAccountFromEverParticipatingAgain?`: `boolean` } + +Parameters to define an offline key registration transaction. + +#### Defined in + +[src/types/composer.ts:322](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/composer.ts#L322) + +___ + ### OnlineKeyRegistrationParams Ƭ **OnlineKeyRegistrationParams**: [`CommonTransactionParams`](types_composer.md#commontransactionparams) & \{ `selectionKey`: `Uint8Array` ; `stateProofKey?`: `Uint8Array` ; `voteFirst`: `bigint` ; `voteKey`: `Uint8Array` ; `voteKeyDilution`: `bigint` ; `voteLast`: `bigint` } @@ -376,7 +389,7 @@ ___ ### Txn -Ƭ **Txn**: [`PaymentParams`](types_composer.md#paymentparams) & \{ `type`: ``"pay"`` } \| [`AssetCreateParams`](types_composer.md#assetcreateparams) & \{ `type`: ``"assetCreate"`` } \| [`AssetConfigParams`](types_composer.md#assetconfigparams) & \{ `type`: ``"assetConfig"`` } \| [`AssetFreezeParams`](types_composer.md#assetfreezeparams) & \{ `type`: ``"assetFreeze"`` } \| [`AssetDestroyParams`](types_composer.md#assetdestroyparams) & \{ `type`: ``"assetDestroy"`` } \| [`AssetTransferParams`](types_composer.md#assettransferparams) & \{ `type`: ``"assetTransfer"`` } \| [`AssetOptInParams`](types_composer.md#assetoptinparams) & \{ `type`: ``"assetOptIn"`` } \| [`AssetOptOutParams`](types_composer.md#assetoptoutparams) & \{ `type`: ``"assetOptOut"`` } \| [`AppCallParams`](types_composer.md#appcallparams) \| [`AppCreateParams`](types_composer.md#appcreateparams) \| [`AppUpdateParams`](types_composer.md#appupdateparams) & \{ `type`: ``"appCall"`` } \| [`OnlineKeyRegistrationParams`](types_composer.md#onlinekeyregistrationparams) & \{ `type`: ``"keyReg"`` } \| `algosdk.TransactionWithSigner` & \{ `type`: ``"txnWithSigner"`` } \| \{ `atc`: `algosdk.AtomicTransactionComposer` ; `type`: ``"atc"`` } \| [`AppCallMethodCall`](types_composer.md#appcallmethodcall) \| [`AppCreateMethodCall`](types_composer.md#appcreatemethodcall) \| [`AppUpdateMethodCall`](types_composer.md#appupdatemethodcall) & \{ `type`: ``"methodCall"`` } +Ƭ **Txn**: [`PaymentParams`](types_composer.md#paymentparams) & \{ `type`: ``"pay"`` } \| [`AssetCreateParams`](types_composer.md#assetcreateparams) & \{ `type`: ``"assetCreate"`` } \| [`AssetConfigParams`](types_composer.md#assetconfigparams) & \{ `type`: ``"assetConfig"`` } \| [`AssetFreezeParams`](types_composer.md#assetfreezeparams) & \{ `type`: ``"assetFreeze"`` } \| [`AssetDestroyParams`](types_composer.md#assetdestroyparams) & \{ `type`: ``"assetDestroy"`` } \| [`AssetTransferParams`](types_composer.md#assettransferparams) & \{ `type`: ``"assetTransfer"`` } \| [`AssetOptInParams`](types_composer.md#assetoptinparams) & \{ `type`: ``"assetOptIn"`` } \| [`AssetOptOutParams`](types_composer.md#assetoptoutparams) & \{ `type`: ``"assetOptOut"`` } \| [`AppCallParams`](types_composer.md#appcallparams) \| [`AppCreateParams`](types_composer.md#appcreateparams) \| [`AppUpdateParams`](types_composer.md#appupdateparams) & \{ `type`: ``"appCall"`` } \| [`OnlineKeyRegistrationParams`](types_composer.md#onlinekeyregistrationparams) \| [`OfflineKeyRegistrationParams`](types_composer.md#offlinekeyregistrationparams) & \{ `type`: ``"keyReg"`` } \| `algosdk.TransactionWithSigner` & \{ `type`: ``"txnWithSigner"`` } \| \{ `atc`: `algosdk.AtomicTransactionComposer` ; `type`: ``"atc"`` } \| [`AppCallMethodCall`](types_composer.md#appcallmethodcall) \| [`AppCreateMethodCall`](types_composer.md#appcreatemethodcall) \| [`AppUpdateMethodCall`](types_composer.md#appupdatemethodcall) & \{ `type`: ``"methodCall"`` } #### Defined in diff --git a/src/types/algorand-client-transaction-creator.ts b/src/types/algorand-client-transaction-creator.ts index d92f685d..107ecbc6 100644 --- a/src/types/algorand-client-transaction-creator.ts +++ b/src/types/algorand-client-transaction-creator.ts @@ -688,4 +688,6 @@ export class AlgorandClientTransactionCreator { appCallMethodCall = this._transactions((c) => c.addAppCallMethodCall) /** Create an online key registration transaction. */ onlineKeyRegistration = this._transaction((c) => c.addOnlineKeyRegistration) + /** Create an offline key registration transaction. */ + offlineKeyRegistration = this._transaction((c) => c.addOfflineKeyRegistration) } diff --git a/src/types/algorand-client-transaction-sender.ts b/src/types/algorand-client-transaction-sender.ts index d2408f8a..1d8bcf2d 100644 --- a/src/types/algorand-client-transaction-sender.ts +++ b/src/types/algorand-client-transaction-sender.ts @@ -950,4 +950,9 @@ export class AlgorandClientTransactionSender { onlineKeyRegistration = this._send((c) => c.addOnlineKeyRegistration, { preLog: (params, transaction) => `Registering online key for ${params.sender} via transaction ${transaction.txID()}`, }) + + /** Register an offline key. */ + offlineKeyRegistration = this._send((c) => c.addOfflineKeyRegistration, { + preLog: (params, transaction) => `Registering offline key for ${params.sender} via transaction ${transaction.txID()}`, + }) } diff --git a/src/types/composer.ts b/src/types/composer.ts index 2a2f8999..69349889 100644 --- a/src/types/composer.ts +++ b/src/types/composer.ts @@ -318,11 +318,11 @@ export type OnlineKeyRegistrationParams = CommonTransactionParams & { stateProofKey?: Uint8Array } -// Not yet exposed because of bug in algosdk -// export type OfflineKeyRegistrationParams = CommonTransactionParams & { -// /** Prevent this account from ever participating again. On network with rewards enabled, also disable rewards for this account */ -// preventAddressFromEverParticipatingAgain?: boolean -// } +/** Parameters to define an offline key registration transaction. */ +export type OfflineKeyRegistrationParams = CommonTransactionParams & { + /** Prevent this account from ever participating again. The account will also no longer earn rewards */ + preventAccountFromEverParticipatingAgain?: boolean +} /** Common parameters for defining an application call transaction. */ export type CommonAppCallParams = CommonTransactionParams & { @@ -455,7 +455,7 @@ export type Txn = | (AssetOptInParams & { type: 'assetOptIn' }) | (AssetOptOutParams & { type: 'assetOptOut' }) | ((AppCallParams | AppCreateParams | AppUpdateParams) & { type: 'appCall' }) - | (OnlineKeyRegistrationParams & { type: 'keyReg' }) + | ((OnlineKeyRegistrationParams | OfflineKeyRegistrationParams) & { type: 'keyReg' }) | (algosdk.TransactionWithSigner & { type: 'txnWithSigner' }) | { atc: algosdk.AtomicTransactionComposer; type: 'atc' } | ((AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall) & { type: 'methodCall' }) @@ -751,6 +751,17 @@ export class TransactionComposer { return this } + /** + * Add an offline key registration transaction to the transaction group. + * @param params The offline key registration transaction parameters + * @returns The composer so you can chain method calls + */ + addOfflineKeyRegistration(params: OfflineKeyRegistrationParams): TransactionComposer { + this.txns.push({ ...params, type: 'keyReg' }) + + return this + } + /** * Add the transactions within an `AtomicTransactionComposer` to the transaction group. * @param atc The `AtomicTransactionComposer` to build transactions from and add to the group @@ -1090,24 +1101,34 @@ export class TransactionComposer { return this.commonTxnBuildStep(params, txn, suggestedParams) } - private buildKeyReg(params: OnlineKeyRegistrationParams, suggestedParams: algosdk.SuggestedParams) { - // algosdk throws when voteFirst is 0, so we need to set it to 1, then switch back to 1 after creating the transaction - const voteFirst = params.voteFirst === 0n ? 1n : params.voteFirst + private buildKeyReg(params: OnlineKeyRegistrationParams | OfflineKeyRegistrationParams, suggestedParams: algosdk.SuggestedParams) { + let txn: algosdk.Transaction - const txn = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({ - from: params.sender, - voteKey: params.voteKey, - selectionKey: params.selectionKey, - voteFirst: Number(voteFirst), - voteLast: Number(params.voteLast), - voteKeyDilution: Number(params.voteKeyDilution), - suggestedParams, - nonParticipation: false, - stateProofKey: params.stateProofKey as string | Uint8Array, - }) + if ('voteKey' in params) { + // algosdk throws when voteFirst is 0, so we need to set it to 1, then switch back to 1 after creating the transaction + const voteFirst = params.voteFirst === 0n ? 1n : params.voteFirst + + txn = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({ + from: params.sender, + voteKey: params.voteKey, + selectionKey: params.selectionKey, + voteFirst: Number(voteFirst), + voteLast: Number(params.voteLast), + voteKeyDilution: Number(params.voteKeyDilution), + suggestedParams, + nonParticipation: false, + stateProofKey: params.stateProofKey as string | Uint8Array, + }) - if (params.voteFirst === 0n) { - txn.voteFirst = 0 + if (params.voteFirst === 0n) { + txn.voteFirst = 0 + } + } else { + txn = algosdk.makeKeyRegistrationTxnWithSuggestedParamsFromObject({ + from: params.sender, + suggestedParams, + nonParticipation: params.preventAccountFromEverParticipatingAgain, + }) } return this.commonTxnBuildStep(params, txn, suggestedParams)