Skip to content

Commit

Permalink
Merge pull request #347 from algorandfoundation/v7-fix-factory-signer
Browse files Browse the repository at this point in the history
fix: some signing and simulate issues
  • Loading branch information
neilcampbell authored Dec 6, 2024
2 parents 6b55470 + 59bb86a commit a57122a
Show file tree
Hide file tree
Showing 31 changed files with 396 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Pull Request

on:
pull_request:
branches: [main]
branches: [main, main-v7]

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- release
- 7.x.x
workflow_dispatch:

concurrency: release
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The goal of this library is to provide intuitive, productive utility functions t

Note: If you prefer Python there's an equivalent [Python utility library](https://github.com/algorandfoundation/algokit-utils-py).

[Install](#install) | [Documentation](docs/README.md)
[Install](#install) | [Documentation](./docs/README.md)

## Install

Expand Down
59 changes: 53 additions & 6 deletions docs/capabilities/transaction-composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,57 @@ The [methods to construct a transaction](../code/classes/types_composer.default.
For example:

```typescript
const result = algorand.addPayment({ sender: 'SENDER', receiver: 'RECEIVER', amount: (100).microAlgo() }).addAppCallMethodCall({
sender: 'SENDER',
appId: 123n,
method: abiMethod,
args: [1, 2, 3],
}).
const result = algorand
.newGroup()
.addPayment({ sender: 'SENDER', receiver: 'RECEIVER', amount: (100).microAlgo() })
.addAppCallMethodCall({
sender: 'SENDER',
appId: 123n,
method: abiMethod,
args: [1, 2, 3],
})
```

## Simulating a transaction

Transactions can be simulated using the simulate endpoint in algod, which enables evaluating the transaction on the network without it actually being commited to a block.
This is a powerful feature, which has a number of options which are detailed in the [simulate API docs](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactionssimulate).

For example you can simulate a transaction group like below:

```typescript
const result = await algorand
.newGroup()
.addPayment({ sender: 'SENDER', receiver: 'RECEIVER', amount: (100).microAlgo() })
.addAppCallMethodCall({
sender: 'SENDER',
appId: 123n,
method: abiMethod,
args: [1, 2, 3],
})
.simulate()
```

The above will execute a simulate request asserting that all transactions in the group are correctly signed.

### Simulate without signing

There are situations where you may not be able to (or want to) sign the transactions when executing simulate.
In these instances you should set `skipSignatures: true` which automatically builds empty transaction signers and sets both `fix-signers` and `allow-empty-signatures` to `true` when sending the algod API call.

For example:

```typescript
const result = await algorand
.newGroup()
.addPayment({ sender: 'SENDER', receiver: 'RECEIVER', amount: (100).microAlgo() })
.addAppCallMethodCall({
sender: 'SENDER',
appId: 123n,
method: abiMethod,
args: [1, 2, 3],
})
.simulate({
skipSignatures: true,
})
```
2 changes: 1 addition & 1 deletion docs/code/classes/types_app_client.AppClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ ___
**getSigner**(`sender`, `signer`): `undefined` \| `TransactionSigner` \| [`TransactionSignerAccount`](../interfaces/types_account.TransactionSignerAccount.md)

Returns the signer for a call, using the provided signer or the `defaultSigner`
if no signer was provided and the call will use default sender
if no signer was provided and the sender resolves to the default sender, the call will use default signer
or `undefined` otherwise (so the signer is resolved from `AlgorandClient`)

#### Parameters
Expand Down
146 changes: 86 additions & 60 deletions docs/code/classes/types_app_factory.AppFactory.md

Large diffs are not rendered by default.

Loading

0 comments on commit a57122a

Please sign in to comment.