Skip to content

Commit

Permalink
feat: Deprecated methods in transaction module
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `ExecuteParams` has been moved from `types/composer` to `types/transaction`
  • Loading branch information
robdmoore committed Sep 4, 2024
1 parent 41d8df1 commit d2c9f55
Show file tree
Hide file tree
Showing 48 changed files with 566 additions and 551 deletions.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ To turn on debug mode you can use the following:
Config.configure({ debug: true })
```
To retrieve the current debug state you can use [`algokit.Config.debug`](./code/interfaces/types_config.Config.md).
To retrieve the current debug state you can use [`Config.debug`](./code/interfaces/types_config.Config.md).
This will turn on things like automatic tracing, more verbose logging and [advanced debugging](./capabilities/debugging.md). It's likely this option will result in extra HTTP calls to algod so worth being careful when it's turned on.
If you want to temporarily turn it on you can use the [`withDebug`](./code/classes/types_config.UpdatableConfig.md#withdebug) function:
```typescript
Config.withDebug(() => {
// Do stuff with algokit.Config.debug set to true
// Do stuff with Config.debug set to true
})
```
Expand All @@ -159,7 +159,7 @@ The library helps you interact with and develop against the Algorand blockchain
- [**Client management**](./capabilities/client.md) - Creation of (auto-retry) algod, indexer and kmd clients against various networks resolved from environment or specified configuration, and creation of other API clients (e.g. TestNet Dispenser API and app clients)
- [**Account management**](./capabilities/account.md) - Creation, use, and management of accounts including mnemonic, rekeyed, multisig, transaction signer ([useWallet](https://github.com/TxnLab/use-wallet) for dApps and Atomic Transaction Composer compatible signers), idempotent KMD accounts and environment variable injected
- [**Algo amount handling**](./capabilities/amount.md) - Reliable, explicit, and terse specification of microAlgo and Algo amounts and safe conversion between them
- [**Transaction management**](./capabilities/transaction.md) - Ability to construct and send single and atomically grouped transactions with consistent and highly configurable semantics, including configurable control of transaction notes, logging, fees, validity, signing, and sending behaviour
- [**Transaction management**](./capabilities/transaction.md) - Ability to construct, simulate and send transactions with consistent and highly configurable semantics, including configurable control of transaction notes, logging, fees, validity, signing, and sending behaviour
- **Higher-order use cases**
- [**Asset management**](./capabilities/asset.md) - Creation, transfer, destroying, opting in and out and managing Algorand Standard Assets
- [**Typed application clients**](./capabilities/typed-app-clients.md) - Type-safe application clients that are [generated](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/generate.md#1-typed-clients) from ARC-0032 application spec files and allow you to intuitively and productively interact with a deployed app, which is the recommended way of interacting with apps and builds on top of the following capabilities:
Expand Down
32 changes: 10 additions & 22 deletions docs/capabilities/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,7 @@ const accountManager = new AccountManager(clientManager)

The core internal type that holds information about a signer/sender pair for a transaction is [`TransactionSignerAccount`](../code/interfaces/types_account.TransactionSignerAccount.md), which represents an `algosdk.TransactionSigner` (`signer`) along with a sender address (`addr`) as the encoded string address.

Many methods in `AccountManager` expose a `TransactionSignerAccount`.

### `SendTransactionFrom`

> [!NOTE]
> The [legacy functions](../README.md#usage) within AlgoKit Utils make use of a [`SendTransactionFrom`](../code/modules/types_transaction.md#sendtransactionfrom) union type that is slowly being phased out in favour of the simpler `TransactionSignerAccount`. This `SendTransactionFrom` type is still prevalent within the legacy functions though.
`SendTransactionFrom` is a union of the following types that each represent an account that can both sign a transaction and represent a sender address:

- `Account` - An in-built algosdk `Account` object
- [`SigningAccount`](../code/classes/types_account.SigningAccount.md) - An abstraction around `algosdk.Account` that supports rekeyed accounts
- `LogicSigAccount` - An in-built algosdk `algosdk.LogicSigAccount` object
- [`MultisigAccount`](../code/classes/types_account.MultisigAccount.md) - An abstraction around `algosdk.MultisigMetadata`, `algosdk.makeMultiSigAccountTransactionSigner`, `algosdk.multisigAddress`, `algosdk.signMultisigTransaction` and `algosdk.appendSignMultisigTransaction` that supports multisig accounts with one or more signers present
- [`TransactionSignerAccount`](../code/interfaces/types_account.TransactionSignerAccount.md) - An interface that provides a sender address alongside a transaction signer (e.g. for use with `AtomicTransactionComposer` or [useWallet](https://github.com/TxnLab/use-wallet))

The use of in-built algosdk types like `Account`, `LogicSigAccount` and `TransactionSigner` is aligned to the [Modularity](../README.md#core-principles) principle. Allowing you to co-exist non AlgoKit Utils code with AlgoKit Utils functions.

AlgoKit Utils provides a few helper methods to take one of these `SendTransactionFrom` objects (that to reiterate uses the [legacy imports](../README.md#usage) to access):

- [`algokit.getSenderAddress`](../code/modules/index.md#getsenderaddress) - Returns the public address of the sender the account represents
- [`algokit.getSenderTransactionSigner`](../code/modules/index.md#getsendertransactionsigner) - Returns a `TransactionSigner` to represent the signer of the account' note: this is memoized so multiple calls to this for the same account will safely return the same `TransactionSigner` instance; this works nicely with `AtomicTransactionComposer`
- [`algokit.signTransaction`](../code/modules/index.md#signtransaction) - Signs a single `algosdk.Transaction` object with the given account
Many methods in `AccountManager` expose a `TransactionSignerAccount`. `TransactionSignerAccount` can be used with `AtomicTransactionComposer`, [`AlgoKitComposer`](./algokit-composer.md) and [useWallet](https://github.com/TxnLab/use-wallet).

## Accounts

Expand All @@ -55,6 +34,15 @@ In order to get/register accounts for signing operations you can use the followi
- [`algorand.account.fromKmd()`](../code/classes/types_account_manager.AccountManager.md#fromkmd) - Returns an account with private key loaded from the given KMD wallet (identified by name)
- [`algorand.account.logicsig(program, args?)`](../code/classes/types_account_manager.AccountManager.md#logicsig) - Returns an account that represents a logic signature

### Underlying account classes

While `TransactionSignerAccount` is the main class used to represent an account that can sign, there are underlying account classes that can underpin the signer withing the transaction signer account.

- `Account` - An in-built `algosdk.Account` object that has an address and private signing key, this can be created
- [`SigningAccount`](../code/classes/types_account.SigningAccount.md) - An abstraction around `algosdk.Account` that supports rekeyed accounts
- `LogicSigAccount` - An in-built algosdk `algosdk.LogicSigAccount` object
- [`MultisigAccount`](../code/classes/types_account.MultisigAccount.md) - An abstraction around `algosdk.MultisigMetadata`, `algosdk.makeMultiSigAccountTransactionSigner`, `algosdk.multisigAddress`, `algosdk.signMultisigTransaction` and `algosdk.appendSignMultisigTransaction` that supports multisig accounts with one or more signers present

### Dispenser

- [`algorand.account.dispenserFromEnvironment()`](../code/classes/types_account_manager.AccountManager.md#dispenserfromenvironment) - Returns an account (with private key loaded) that can act as a dispenser from environment variables, or against default LocalNet if no environment variables present
Expand Down
4 changes: 2 additions & 2 deletions docs/capabilities/algorand-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The signature for the calls to send a single transaction usually look like:
- To get intellisense on the params, open an object parenthesis (`{`) and use your IDE's intellisense keyboard shortcut (e.g. ctrl+space).
- `{ComposerTransactionTypeParams}` will be the parameters that are specific to that transaction type e.g. `PaymentParams`, [see the full list](../code/modules/types_composer.md#type-aliases)
- [`CommonTransactionParams`](../code/modules/types_composer.md#commontransactionparams) are the [common transaction parameters](#transaction-parameters) that can be specified for every single transaction
- [`ExecuteParams`](../code/interfaces/types_composer.ExecuteParams.md) are the [parameters](#transaction-parameters) that control execution semantics when sending transactions to the network
- [`ExecuteParams`](../code/interfaces/types_transaction.ExecuteParams.md) are the [parameters](#transaction-parameters) that control execution semantics when sending transactions to the network
- [`SendSingleTransactionResult`](../code/modules/types_algorand_client.md#sendsingletransactionresult) is all of the information that is relevant when [sending a single transaction to the network](./transaction.md#sending-a-transaction)

Generally, the functions to immediately send a single transaction will emit log messages before and/or after sending the transaction. You can opt-out of this by sending `suppressLog: true`.
Expand Down Expand Up @@ -121,7 +121,7 @@ There are two common base interfaces that get reused:
- `validityWindow?: number` - How many rounds the transaction should be valid for, if not specified then the registered default validity window will be used.
- `firstValidRound?: bigint` - Set the first round this transaction is valid. If left undefined, the value from algod will be used. We recommend you only set this when you intentionally want this to be some time in the future.
- `lastValidRound?: bigint` - The last round this transaction is valid. It is recommended to use `validityWindow` instead.
- [`ExecuteParams`](../code/interfaces/types_composer.ExecuteParams.md)
- [`ExecuteParams`](../code/interfaces/types_transaction.ExecuteParams.md)
- `maxRoundsToWaitForConfirmation?: number` - The number of rounds to wait for confirmation. By default until the latest lastValid has past.
- `suppressLog?: boolean` - Whether to suppress log messages from transaction send, default: do not suppress.

Expand Down
6 changes: 3 additions & 3 deletions docs/capabilities/amount.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ To import the AlgoAmount class you can access it via:
import { AlgoAmount } from '@algorandfoundation/algokit-utils/types/amount'
```

You may not need to import this type to use it though since there are also special methods that are exposed from `algokit.` and extend the `number` protoype per below.
You may not need to import this type to use it though since there are also special methods that are exposed from the root AlgoKit Utils export and also others that extend the `number` protoype per below.

### Creating an `AlgoAmount`

Expand All @@ -25,12 +25,12 @@ There are a few ways to create an `AlgoAmount`:
- Algo
- Constructor: `new AlgoAmount({algo: 10})`
- Static helper: `AlgoAmount.algo(10)`
- AlgoKit Helper: `algokit.algo(10)`
- AlgoKit Helper: `algo(10)`
- Number coersion: `(10).algo()` (note: you have to wrap the number in brackets or have it in a variable or function return, a raw number value can't have a method called on it)
- microAlgo
- Constructor: `new AlgoAmount({microAlgos: 10_000})`
- Static helper: `AlgoAmount.algo(10)`
- AlgoKit Helper: `algokit.microAlgo(10_000)`
- AlgoKit Helper: `microAlgo(10_000)`
- Number coersion: `(10_000).microAlgo()` (note: you have to wrap the number in brackets or have it in a variable or function return, a raw number value can't have a method called on it)

Note: per above, to use any of the versions that reference `AlgoAmount` type itself you need to import it:
Expand Down
18 changes: 9 additions & 9 deletions docs/capabilities/app-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const result = await appClient.call({
methodArgs: {
args: [
appClient.fundAppAccount({
amount: algokit.microAlgo(200_000),
amount: microAlgo(200_000),
sendParams: { skipSending: true },
}),
],
Expand All @@ -169,13 +169,13 @@ const result = await appClient.call({
There are various methods defined that let you read state from the smart contract app:

- `getGlobalState()` - Gets the current global state using [`algokit.getAppGlobalState](./app.md#global-state)
- `getLocalState(account: string | SendTransactionFrom)` - Gets the current local state for the given account address using [`algokit.getAppLocalState](./app.md#local-state).
- `getBoxNames()` - Gets the current box names using [`algokit.getAppBoxNames`](./app.md#boxes)
- `getBoxValue(name)` - Gets the current value of the given box using [`algokit.getAppBoxValue](./app.md#boxes)
- `getBoxValueFromABIType(name)` - Gets the current value of the given box from an ABI type using [`algokit.getAppBoxValueFromABIType](./app.md#boxes)
- `getBoxValues(filter)` - Gets the current values of the boxes using [`algokit.getAppBoxValues](./app.md#boxes)
- `getBoxValuesFromABIType(type, filter)` - Gets the current values of the boxes from an ABI type using [`algokit.getAppBoxValuesFromABIType](./app.md#boxes)
- `getGlobalState()` - Gets the current global state using [`algorand.app.getById(appId).globalState](./app.md#global-state)
- `getLocalState(account: string | SendTransactionFrom)` - Gets the current local state for the given account address using [`algorand.app.getLocalState](./app.md#local-state).
- `getBoxNames()` - Gets the current box names using [`algorand.app.getBoxNames`](./app.md#boxes)
- `getBoxValue(name)` - Gets the current value of the given box using [`algorand.app.getBoxValue](./app.md#boxes)
- `getBoxValueFromABIType(name)` - Gets the current value of the given box from an ABI type using [`algorand.app.getBoxValueFromABIType](./app.md#boxes)
- `getBoxValues(filter)` - Gets the current values of the boxes using [`algorand.app.getBoxValues](./app.md#boxes)
- `getBoxValuesFromABIType(type, filter)` - Gets the current values of the boxes from an ABI type using [`algorand.app.getBoxValuesFromABIType](./app.md#boxes)

These calls will only work if the Application Client knows the ID of the app, which will occur if:

Expand Down Expand Up @@ -214,7 +214,7 @@ Note: This information will only show if the Application Client has a source map
If you want to go a step further and automatically issue a [simulated transaction](https://algorand.github.io/js-algorand-sdk/classes/modelsv2.SimulateTransactionResult.html) and get trace information when there is an error when an ABI method is called you can turn on debug mode:

```typescript
algokit.Config.configure({ debug: true })
Config.configure({ debug: true })
```

If you do that then the exception will have the `traces` property within the underlying exception will have key information from the simulation within it and this will get populated into the `led.traces` property of the thrown error.
Expand Down
Loading

0 comments on commit d2c9f55

Please sign in to comment.