Skip to content

Commit

Permalink
feat: add support for offline key registration
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell committed Nov 22, 2024
1 parent c9127c9 commit fd98a1d
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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`\>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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`[] }\>
Expand Down
69 changes: 47 additions & 22 deletions docs/code/classes/types_composer.TransactionComposer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

___
Expand Down Expand Up @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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
Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand Down Expand Up @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)

___

Expand All @@ -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)
15 changes: 14 additions & 1 deletion docs/code/modules/types_composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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` }
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/types/algorand-client-transaction-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
5 changes: 5 additions & 0 deletions src/types/algorand-client-transaction-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`,
})
}
Loading

0 comments on commit fd98a1d

Please sign in to comment.