diff --git a/docs/capabilities/account.md b/docs/capabilities/account.md index f106eb2b..11fbd9f4 100644 --- a/docs/capabilities/account.md +++ b/docs/capabilities/account.md @@ -97,11 +97,11 @@ await algorand.account.rekeyAccount({ note: 'note', firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), maxRoundsToWaitForConfirmation: 5, suppressLog: true, }) @@ -147,7 +147,7 @@ const defaultDispenserAccount = await kmdAccountManager.getWalletAccount( const localNetDispenserAccount = await kmdAccountManager.getLocalNetDispenserAccount() // Idempotently get (if exists) or create (if it doesn't exist yet) an account by name using KMD // if creating it then fund it with 2 ALGO from the default dispenser account -const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algos()) +const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algo()) // This will return the same account as above since the name matches const existingAccount = await kmdAccountManager.getOrCreateWalletAccount('account1') ``` @@ -160,5 +160,5 @@ const localNetDispenser = await algorand.account.localNetDispenser() // Get and register a dispenser by environment variable, or if not set then LocalNet dispenser via KMD const dispenser = await algorand.account.dispenserFromEnvironment() // Get / create and register account from KMD idempotently by name -const account1 = await algorand.account.fromKmd('account1', (2).algos()) +const account1 = await algorand.account.fromKmd('account1', (2).algo()) ``` diff --git a/docs/capabilities/algorand-client.md b/docs/capabilities/algorand-client.md index 8489abcf..2cf1d320 100644 --- a/docs/capabilities/algorand-client.md +++ b/docs/capabilities/algorand-client.md @@ -94,7 +94,7 @@ You can compose a group of transactions for execution by using the `newGroup()` ```typescript const result = algorand .newGroup() - .addPayment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', amount: (1).microAlgos() }) + .addPayment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', amount: (1).microAlgo() }) .addAssetOptIn({ sender: 'SENDERADDRESS', assetId: 12345n }) .execute() ``` diff --git a/docs/capabilities/amount.md b/docs/capabilities/amount.md index cfbcefb2..fa9508ca 100644 --- a/docs/capabilities/amount.md +++ b/docs/capabilities/amount.md @@ -23,15 +23,15 @@ You may not need to import this type to use it though since there are also speci There are a few ways to create an `AlgoAmount`: - Algo - - Constructor: `new AlgoAmount({algos: 10})` - - Static helper: `AlgoAmount.algos(10)` - - AlgoKit Helper: `algokit.algos(10)` - - Number coersion: `(10).algos()` (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) + - Constructor: `new AlgoAmount({algo: 10})` + - Static helper: `AlgoAmount.algo(10)` + - AlgoKit Helper: `algokit.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.algos(10)` - - AlgoKit Helper: `algokit.microAlgos(10_000)` - - Number coersion: `(10_000).microAlgos()` (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) + - Static helper: `AlgoAmount.algo(10)` + - AlgoKit Helper: `algokit.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: @@ -41,10 +41,10 @@ import { AlgoAmount } from '@algorandfoundation/algokit-utils/types/amount' ### Extracting a value from `AlgoAmount` -The `AlgoAmount` class has methods to return Algo and microAlgo: +The `AlgoAmount` class has properties to return Algo and microAlgo: -- `amount.algos()` - Returns the value in Algo -- `amount.microAlgos()` - Returns the value in microAlgo +- `amount.algo` - Returns the value in Algo +- `amount.microAlgo` - Returns the value in microAlgo `AlgoAmount` will coerce to a `number` automatically (in microAlgo), which is not recommended to be used outside of allowing you to use `AlgoAmount` objects in comparison operations such as `<` and `>=` etc. diff --git a/docs/capabilities/app-client.md b/docs/capabilities/app-client.md index 543b8fff..277f536f 100644 --- a/docs/capabilities/app-client.md +++ b/docs/capabilities/app-client.md @@ -153,7 +153,7 @@ const result = await appClient.call({ methodArgs: { args: [ appClient.fundAppAccount({ - amount: algokit.microAlgos(200_000), + amount: algokit.microAlgo(200_000), sendParams: { skipSending: true }, }), ], diff --git a/docs/capabilities/asset.md b/docs/capabilities/asset.md index a5fd8aa0..5df19607 100644 --- a/docs/capabilities/asset.md +++ b/docs/capabilities/asset.md @@ -60,11 +60,11 @@ await algorand.send.assetCreate({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -112,11 +112,11 @@ await algorand.send.assetConfig({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -162,11 +162,11 @@ await algorand.send.assetTransfer({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -209,11 +209,11 @@ await algorand.send.assetOptIn({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -260,11 +260,11 @@ await algorand.send.assetOptOut({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -286,7 +286,7 @@ algorand.asset.bulkOptIn('ACCOUNTADDRESS', [12345n, 67890n]) // Advanced example algorand.asset.bulkOptIn('ACCOUNTADDRESS', [12345n, 67890n], { - maxFee: (1000).microAlgos(), + maxFee: (1000).microAlgo(), suppressLog: true, }) ``` @@ -304,7 +304,7 @@ algorand.asset.bulkOptOut('ACCOUNTADDRESS', [12345n, 67890n]) algorand.asset.bulkOptOut('ACCOUNTADDRESS', [12345n, 67890n], { ensureZeroBalance: true, - maxFee: (1000).microAlgos(), + maxFee: (1000).microAlgo(), suppressLog: true, }) ``` diff --git a/docs/capabilities/transfer.md b/docs/capabilities/transfer.md index b8a2bc85..9d6685f5 100644 --- a/docs/capabilities/transfer.md +++ b/docs/capabilities/transfer.md @@ -19,14 +19,14 @@ The base type for specifying a payment transaction is [`PaymentParams`](../code/ const result = await algorand.send.payment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', - amount: (4).algos(), + amount: (4).algo(), }) // Advanced example const result2 = await algorand.send.payment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', - amount: (4).algos(), + amount: (4).algo(), closeRemainderTo: 'CLOSEREMAINDERTOADDRESS', lease: 'lease', note: 'note', @@ -35,11 +35,11 @@ const result2 = await algorand.send.payment({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -81,22 +81,22 @@ The general structure of these calls is similar, they all take: // From account // Basic example -await algorand.account.ensureFunded('ACCOUNTADDRESS', 'DISPENSERADDRESS', algokit.algos(1)) +await algorand.account.ensureFunded('ACCOUNTADDRESS', 'DISPENSERADDRESS', algokit.algo(1)) // With configuration -await algorand.account.ensureFunded('ACCOUNTADDRESS', 'DISPENSERADDRESS', algokit.algos(1), { - minFundingIncrement: algokit.algos(2), - fee: (1000).microAlgos(), +await algorand.account.ensureFunded('ACCOUNTADDRESS', 'DISPENSERADDRESS', algokit.algo(1), { + minFundingIncrement: algokit.algo(2), + fee: (1000).microAlgo(), suppressLog: true, }) // From environment // Basic example -await algorand.account.ensureFundedFromEnvironment('ACCOUNTADDRESS', algokit.algos(1)) +await algorand.account.ensureFundedFromEnvironment('ACCOUNTADDRESS', algokit.algo(1)) // With configuration -await algorand.account.ensureFundedFromEnvironment('ACCOUNTADDRESS', algokit.algos(1), { - minFundingIncrement: algokit.algos(2), - fee: (1000).microAlgos(), +await algorand.account.ensureFundedFromEnvironment('ACCOUNTADDRESS', algokit.algo(1), { + minFundingIncrement: algokit.algo(2), + fee: (1000).microAlgo(), suppressLog: true, }) @@ -106,14 +106,14 @@ await algorand.account.ensureFundedFromEnvironment('ACCOUNTADDRESS', algokit.alg await algorand.account.ensureFundedUsingDispenserAPI( 'ACCOUNTADDRESS', algorand.client.getTestNetDispenserFromEnvironment(), - algokit.algos(1), + algokit.algo(1), ) // With configuration await algorand.account.ensureFundedUsingDispenserAPI( 'ACCOUNTADDRESS', algorand.client.getTestNetDispenserFromEnvironment(), - algokit.algos(1), - { minFundingIncrement: algokit.algos(2) }, + algokit.algo(1), + { minFundingIncrement: algokit.algo(2) }, ) ``` diff --git a/docs/capabilities/typed-app-clients.md b/docs/capabilities/typed-app-clients.md index 1dbc2180..a2c8b73e 100644 --- a/docs/capabilities/typed-app-clients.md +++ b/docs/capabilities/typed-app-clients.md @@ -81,7 +81,7 @@ import { AlgorandClient } from '@algorandfoundation/algokit-utils' // These require environment variables to be present, or it will retrieve from default LocalNet const algorand = AlgorandClient.fromEnvironment() -const deployer = algorand.account.fromEnvironment('DEPLOYER', (1).algos()) +const deployer = algorand.account.fromEnvironment('DEPLOYER', (1).algo()) // Create the typed app client const appClient = algorand.client.getTypedAppClientByCreatorAndName(HelloWorldAppClient, { diff --git a/docs/code/classes/types_account_manager.AccountManager.md b/docs/code/classes/types_account_manager.AccountManager.md index d4a115a9..a3e09a0c 100644 --- a/docs/code/classes/types_account_manager.AccountManager.md +++ b/docs/code/classes/types_account_manager.AccountManager.md @@ -240,10 +240,10 @@ https://developer.algorand.org/docs/get-details/accounts/#minimum-balance ```typescript // Basic example -await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algos(1)) +await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algo(1)) // With configuration -await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algos(1), - { minFundingIncrement: algokit.algos(2), fee: (1000).microAlgos(), suppressLog: true } +await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algo(1), + { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true } ) ``` @@ -289,10 +289,10 @@ https://developer.algorand.org/docs/get-details/accounts/#minimum-balance ```typescript // Basic example -await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algos(1)) +await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algo(1)) // With configuration -await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algos(1), - { minFundingIncrement: algokit.algos(2), fee: (1000).microAlgos(), suppressLog: true } +await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algo(1), + { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true } ) ``` @@ -333,10 +333,10 @@ https://developer.algorand.org/docs/get-details/accounts/#minimum-balance ```typescript // Basic example -await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algos(1)) +await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1)) // With configuration -await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algos(1), - { minFundingIncrement: algokit.algos(2) } +await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1), + { minFundingIncrement: algokit.algo(2) } ) ``` @@ -713,11 +713,11 @@ await algorand.account.rekeyAccount({ note: 'note', firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), maxRoundsToWaitForConfirmation: 5, suppressLog: true, }) diff --git a/docs/code/classes/types_algorand_client_sender.AlgorandClientSender.md b/docs/code/classes/types_algorand_client_sender.AlgorandClientSender.md index 5891c570..6b4a23d9 100644 --- a/docs/code/classes/types_algorand_client_sender.AlgorandClientSender.md +++ b/docs/code/classes/types_algorand_client_sender.AlgorandClientSender.md @@ -144,11 +144,11 @@ await algorand.send.assetConfig({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -205,11 +205,11 @@ await algorand.send.assetDestroy({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -264,11 +264,11 @@ await algorand.send.assetFreeze({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -321,11 +321,11 @@ await algorand.send.assetOptIn({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -383,11 +383,11 @@ await algorand.send.assetTransfer({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -483,7 +483,7 @@ Send a payment transaction to transfer Algo between accounts. const result = await algorandClient.send.payment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', - amount: (4).algos(), + amount: (4).algo(), }) ``` @@ -491,7 +491,7 @@ const result = await algorandClient.send.payment({ ```typescript const result = await algorandClient.send.payment({ - amount: (4).algos(), + amount: (4).algo(), receiver: 'RECEIVERADDRESS', sender: 'SENDERADDRESS', closeRemainderTo: 'CLOSEREMAINDERTOADDRESS', @@ -502,11 +502,11 @@ const result = await algorandClient.send.payment({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -625,11 +625,11 @@ await algorand.send.assetCreate({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in @@ -692,11 +692,11 @@ await algorand.send.assetOptOut({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), // Signer only needed if you want to provide one, // generally you'd register it with AlgorandClient // against the sender and not need to pass it in 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 acb64b28..a71fa3eb 100644 --- a/docs/code/classes/types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md +++ b/docs/code/classes/types_algorand_client_transaction_creator.AlgorandClientTransactionCreator.md @@ -130,11 +130,11 @@ await algorand.transaction.assetConfig({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` @@ -194,11 +194,11 @@ await algorand.transaction.assetCreate({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` @@ -249,11 +249,11 @@ await algorand.transaction.assetDestroy({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` @@ -302,11 +302,11 @@ await algorand.transaction.assetFreeze({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` @@ -353,11 +353,11 @@ await algorand.transaction.assetOptIn({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` @@ -409,11 +409,11 @@ await algorand.transaction.assetOptIn({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` @@ -465,11 +465,11 @@ await algorand.transaction.assetTransfer({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` @@ -531,7 +531,7 @@ Create a payment transaction to transfer Algo between accounts. const result = await algorandClient.send.payment({ sender: 'SENDERADDRESS', receiver: 'RECEIVERADDRESS', - amount: (4).algos(), + amount: (4).algo(), }) ``` @@ -539,7 +539,7 @@ const result = await algorandClient.send.payment({ ```typescript const result = await algorandClient.send.payment({ - amount: (4).algos(), + amount: (4).algo(), receiver: 'RECEIVERADDRESS', sender: 'SENDERADDRESS', closeRemainderTo: 'CLOSEREMAINDERTOADDRESS', @@ -550,11 +550,11 @@ const result = await algorandClient.send.payment({ // You wouldn't normally set this field firstValidRound: 1000n, validityWindow: 10, - extraFee: (1000).microAlgos(), - staticFee: (1000).microAlgos(), + extraFee: (1000).microAlgo(), + staticFee: (1000).microAlgo(), // Max fee doesn't make sense with extraFee AND staticFee // already specified, but here for completeness - maxFee: (3000).microAlgos(), + maxFee: (3000).microAlgo(), }) ``` diff --git a/docs/code/classes/types_amount.AlgoAmount.md b/docs/code/classes/types_amount.AlgoAmount.md index 64f9edca..4b19a435 100644 --- a/docs/code/classes/types_amount.AlgoAmount.md +++ b/docs/code/classes/types_amount.AlgoAmount.md @@ -14,18 +14,22 @@ Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbe ### Properties -- [amountInMicroAlgos](types_amount.AlgoAmount.md#amountinmicroalgos) +- [amountInMicroAlgo](types_amount.AlgoAmount.md#amountinmicroalgo) ### Accessors +- [algo](types_amount.AlgoAmount.md#algo) - [algos](types_amount.AlgoAmount.md#algos) +- [microAlgo](types_amount.AlgoAmount.md#microalgo) - [microAlgos](types_amount.AlgoAmount.md#microalgos) ### Methods - [toString](types_amount.AlgoAmount.md#tostring) - [valueOf](types_amount.AlgoAmount.md#valueof) +- [Algo](types_amount.AlgoAmount.md#algo-1) - [Algos](types_amount.AlgoAmount.md#algos-1) +- [MicroAlgo](types_amount.AlgoAmount.md#microalgo-1) - [MicroAlgos](types_amount.AlgoAmount.md#microalgos-1) ## Constructors @@ -38,7 +42,7 @@ Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbe | Name | Type | | :------ | :------ | -| `amount` | \{ `algos`: `number` } \| \{ `microAlgos`: `number` } | +| `amount` | \{ `algos`: `number` } \| \{ `algo`: `number` } \| \{ `microAlgos`: `number` } \| \{ `microAlgo`: `number` } | #### Returns @@ -46,13 +50,13 @@ Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbe #### Defined in -[src/types/amount.ts:17](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L17) +[src/types/amount.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L27) ## Properties -### amountInMicroAlgos +### amountInMicroAlgo -• `Private` **amountInMicroAlgos**: `number` +• `Private` **amountInMicroAlgo**: `number` #### Defined in @@ -60,6 +64,22 @@ Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbe ## Accessors +### algo + +• `get` **algo**(): `number` + +Return the amount as a number in Algo + +#### Returns + +`number` + +#### Defined in + +[src/types/amount.ts:23](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L23) + +___ + ### algos • `get` **algos**(): `number` @@ -72,6 +92,22 @@ Return the amount as a number in Algo #### Defined in +[src/types/amount.ts:18](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L18) + +___ + +### microAlgo + +• `get` **microAlgo**(): `number` + +Return the amount as a number in µAlgo + +#### Returns + +`number` + +#### Defined in + [src/types/amount.ts:13](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L13) ___ @@ -102,7 +138,7 @@ Return the amount as a number in µAlgo #### Defined in -[src/types/amount.ts:21](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L21) +[src/types/amount.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L38) ___ @@ -120,7 +156,29 @@ the algos or microAlgos properties #### Defined in -[src/types/amount.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L29) +[src/types/amount.ts:46](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L46) + +___ + +### Algo + +▸ **Algo**(`amount`): [`AlgoAmount`](types_amount.AlgoAmount.md) + +Create a `AlgoAmount` object representing the given number of Algo + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `amount` | `number` | + +#### Returns + +[`AlgoAmount`](types_amount.AlgoAmount.md) + +#### Defined in + +[src/types/amount.ts:56](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L56) ___ @@ -142,7 +200,29 @@ Create a `AlgoAmount` object representing the given number of Algo #### Defined in -[src/types/amount.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L34) +[src/types/amount.ts:51](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L51) + +___ + +### MicroAlgo + +▸ **MicroAlgo**(`amount`): [`AlgoAmount`](types_amount.AlgoAmount.md) + +Create a `AlgoAmount` object representing the given number of µAlgo + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `amount` | `number` | + +#### Returns + +[`AlgoAmount`](types_amount.AlgoAmount.md) + +#### Defined in + +[src/types/amount.ts:66](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L66) ___ @@ -164,4 +244,4 @@ Create a `AlgoAmount` object representing the given number of µAlgo #### Defined in -[src/types/amount.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L39) +[src/types/amount.ts:61](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L61) diff --git a/docs/code/classes/types_asset_manager.AssetManager.md b/docs/code/classes/types_asset_manager.AssetManager.md index 71b697a0..7a2a062a 100644 --- a/docs/code/classes/types_asset_manager.AssetManager.md +++ b/docs/code/classes/types_asset_manager.AssetManager.md @@ -111,7 +111,7 @@ An array of records matching asset ID to transaction ID of the opt in // Basic example algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n]) // With configuration -algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgos(), suppressLog: true }) +algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true }) ``` #### Defined in @@ -148,7 +148,7 @@ An array of records matching asset ID to transaction ID of the opt in // Basic example algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n]) // With configuration -algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgos(), suppressLog: true }) +algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true }) ``` #### Defined in diff --git a/docs/code/classes/types_kmd_account_manager.KmdAccountManager.md b/docs/code/classes/types_kmd_account_manager.KmdAccountManager.md index a0aae270..62d92eda 100644 --- a/docs/code/classes/types_kmd_account_manager.KmdAccountManager.md +++ b/docs/code/classes/types_kmd_account_manager.KmdAccountManager.md @@ -123,7 +123,7 @@ An Algorand account with private key loaded - either one that already existed in ```typescript // Idempotently get (if exists) or crate (if it doesn't exist yet) an account by name using KMD // if creating it then fund it with 2 ALGO from the default dispenser account -const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algos()) +const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algo()) // This will return the same account as above since the name matches const existingAccount = await kmdAccountManager.getOrCreateWalletAccount('account1') ``` diff --git a/docs/code/modules/index.md b/docs/code/modules/index.md index f8c32d86..9e6b6aae 100644 --- a/docs/code/modules/index.md +++ b/docs/code/modules/index.md @@ -31,6 +31,7 @@ ### Functions +- [algo](index.md#algo) - [algos](index.md#algos) - [assetBulkOptIn](index.md#assetbulkoptin) - [assetBulkOptOut](index.md#assetbulkoptout) @@ -94,6 +95,7 @@ - [isMainNet](index.md#ismainnet) - [isSchemaIsBroken](index.md#isschemaisbroken) - [isTestNet](index.md#istestnet) +- [microAlgo](index.md#microalgo) - [microAlgos](index.md#microalgos) - [mnemonicAccount](index.md#mnemonicaccount) - [mnemonicAccountFromEnvironment](index.md#mnemonicaccountfromenvironment) @@ -221,6 +223,28 @@ ___ ## Functions +### algo + +▸ **algo**(`algos`): [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) + +Returns an amount of Algo using AlgoAmount + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `algos` | `number` | The amount of Algo | + +#### Returns + +[`AlgoAmount`](../classes/types_amount.AlgoAmount.md) + +#### Defined in + +[src/amount.ts:51](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L51) + +___ + ### algos ▸ **algos**(`algos`): [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) @@ -239,7 +263,7 @@ Returns an amount of Algo using AlgoAmount #### Defined in -[src/amount.ts:22](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L22) +[src/amount.ts:44](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L44) ___ @@ -2185,6 +2209,28 @@ Use `await algorandClient.client.isTestNet()` or `await new ClientManager({ algo ___ +### microAlgo + +▸ **microAlgo**(`microAlgos`): [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) + +Returns an amount of µAlgo using AlgoAmount + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `microAlgos` | `number` | The amount of µAlgo | + +#### Returns + +[`AlgoAmount`](../classes/types_amount.AlgoAmount.md) + +#### Defined in + +[src/amount.ts:65](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L65) + +___ + ### microAlgos ▸ **microAlgos**(`microAlgos`): [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) @@ -2203,7 +2249,7 @@ Returns an amount of µAlgo using AlgoAmount #### Defined in -[src/amount.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L29) +[src/amount.ts:58](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L58) ___ @@ -2774,7 +2820,7 @@ Returns an amount of µAlgo to cover standard fees for the given number of trans #### Defined in -[src/amount.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L36) +[src/amount.ts:72](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/amount.ts#L72) ___ @@ -2833,7 +2879,7 @@ Transfer Algo between two accounts. **`Example`** ```typescript -await algokit.transferAlgos({ from, to, amount: algokit.algos(1) }, algod) +await algokit.transferAlgos({ from, to, amount: algokit.algo(1) }, algod) ``` #### Defined in diff --git a/src/amount.ts b/src/amount.ts index a631499f..924914b2 100644 --- a/src/amount.ts +++ b/src/amount.ts @@ -3,36 +3,72 @@ import { AlgoAmount } from './types/amount' declare global { interface Number { + /** + * Returns an `AlgoAmount` using this number of microAlgo. + */ microAlgos(this: number): AlgoAmount + /** + * Returns an `AlgoAmount` using this number of Algo. + */ algos(this: number): AlgoAmount + /** + * Returns an `AlgoAmount` using this number of microAlgo. + */ + microAlgo(this: number): AlgoAmount + /** + * Returns an `AlgoAmount` using this number of Algo. + */ + algo(this: number): AlgoAmount } } Number.prototype.microAlgos = function () { - return AlgoAmount.MicroAlgos(this) + return AlgoAmount.MicroAlgo(this) } Number.prototype.algos = function () { - return AlgoAmount.Algos(this) + return AlgoAmount.Algo(this) +} + +Number.prototype.microAlgo = function () { + return AlgoAmount.MicroAlgo(this) +} + +Number.prototype.algo = function () { + return AlgoAmount.Algo(this) } /** Returns an amount of Algo using AlgoAmount * @param algos The amount of Algo */ export const algos = (algos: number) => { - return AlgoAmount.Algos(algos) + return AlgoAmount.Algo(algos) +} + +/** Returns an amount of Algo using AlgoAmount + * @param algos The amount of Algo + */ +export const algo = (algos: number) => { + return AlgoAmount.Algo(algos) } /** Returns an amount of µAlgo using AlgoAmount * @param microAlgos The amount of µAlgo */ export const microAlgos = (microAlgos: number) => { - return AlgoAmount.MicroAlgos(microAlgos) + return AlgoAmount.MicroAlgo(microAlgos) +} + +/** Returns an amount of µAlgo using AlgoAmount + * @param microAlgos The amount of µAlgo + */ +export const microAlgo = (microAlgos: number) => { + return AlgoAmount.MicroAlgo(microAlgos) } /** Returns an amount of µAlgo to cover standard fees for the given number of transactions using AlgoAmount * @param numberOfTransactions The of standard transaction fees to return the amount of Algo */ export const transactionFees = (numberOfTransactions: number) => { - return AlgoAmount.MicroAlgos(numberOfTransactions * algosdk.ALGORAND_MIN_TX_FEE) + return AlgoAmount.MicroAlgo(numberOfTransactions * algosdk.ALGORAND_MIN_TX_FEE) } diff --git a/src/app.spec.ts b/src/app.spec.ts index 312d4b0e..25810ecc 100644 --- a/src/app.spec.ts +++ b/src/app.spec.ts @@ -53,7 +53,7 @@ describe('app', () => { const rekeyedAccount = algorand.account.rekeyed(testAccount.addr, rekeyTo) await algokit.transferAlgos( { - amount: (0).algos(), + amount: (0).algo(), from: rekeyedAccount, to: testAccount, }, diff --git a/src/indexer-lookup.spec.ts b/src/indexer-lookup.spec.ts index 90091cc7..26b6b6f7 100644 --- a/src/indexer-lookup.spec.ts +++ b/src/indexer-lookup.spec.ts @@ -12,7 +12,7 @@ describe('indexer-lookup', () => { return await localnet.context.algorand.send.payment({ sender: from ?? localnet.context.testAccount.addr, receiver: localnet.context.testAccount.addr, - amount: amount ?? (1).microAlgos(), + amount: amount ?? (1).microAlgo(), }) } @@ -39,12 +39,12 @@ describe('indexer-lookup', () => { test('Transactions are searched with pagination', async () => { const { algorand, testAccount, generateAccount, waitForIndexer } = localnet.context const secondAccount = await generateAccount({ - initialFunds: (1).algos(), + initialFunds: (1).algo(), suppressLog: true, }) - const { transaction: transaction1 } = await sendTestTransaction((1).microAlgos()) - const { transaction: transaction2 } = await sendTestTransaction((2).microAlgos()) - await sendTestTransaction((1).microAlgos(), secondAccount.addr) + const { transaction: transaction1 } = await sendTestTransaction((1).microAlgo()) + const { transaction: transaction2 } = await sendTestTransaction((2).microAlgo()) + await sendTestTransaction((1).microAlgo(), secondAccount.addr) await waitForIndexer() const transactions = await indexer.searchTransactions( @@ -60,7 +60,7 @@ describe('indexer-lookup', () => { test('Application create transactions are found by creator with pagination', async () => { const { algorand, testAccount, generateAccount, waitForIndexer } = localnet.context const secondAccount = await generateAccount({ - initialFunds: (1).algos(), + initialFunds: (1).algo(), suppressLog: true, }) diff --git a/src/testing/account.ts b/src/testing/account.ts index d9568e16..8f0cb0da 100644 --- a/src/testing/account.ts +++ b/src/testing/account.ts @@ -59,7 +59,7 @@ export async function getTestAccount( const accountInfo = await algorand.account.getInformation(account.addr) - Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgos) + Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgo) return account } diff --git a/src/transaction/transaction.spec.ts b/src/transaction/transaction.spec.ts index b49dd11b..717ef6b1 100644 --- a/src/transaction/transaction.spec.ts +++ b/src/transaction/transaction.spec.ts @@ -41,7 +41,7 @@ describe('transaction', () => { transaction: txn, from: testAccount, sendParams: { - maxFee: algokit.microAlgos(1), + maxFee: algokit.microAlgo(1), }, }, algod, @@ -62,7 +62,7 @@ describe('transaction', () => { transaction: txn, from: testAccount, sendParams: { - maxFee: algokit.microAlgos(1), + maxFee: algokit.microAlgo(1), }, }, algod, @@ -77,7 +77,7 @@ describe('transaction', () => { transaction: txn, from: testAccount, sendParams: { - maxFee: algokit.microAlgos(1000_000), + maxFee: algokit.microAlgo(1000_000), }, }, algod, @@ -89,7 +89,7 @@ describe('transaction', () => { test('Transaction fee is overridable', async () => { const { algod, testAccount } = localnet.context const txn = await getTestTransaction() - const fee = algokit.algos(1) + const fee = algokit.algo(1) const result = await algokit.sendTransaction( { transaction: txn, @@ -102,7 +102,7 @@ describe('transaction', () => { ) invariant(result.confirmation) - expect(result.confirmation.txn.txn.fee).toBe(fee.microAlgos) + expect(result.confirmation.txn.txn.fee).toBe(fee.microAlgo) }) test('Transaction group is sent', async () => { @@ -143,7 +143,7 @@ describe('transaction', () => { const txn1 = await getTestTransaction(1) const txn2Promise = algokit.transferAlgos( { - amount: algokit.microAlgos(2), + amount: algokit.microAlgo(2), from: testAccount, to: testAccount.addr, skipSending: true, @@ -168,7 +168,7 @@ describe('transaction', () => { test('Transaction group is sent using transaction signers', async () => { const { algod, testAccount, generateAccount } = localnet.context - const account2 = await generateAccount({ suppressLog: true, initialFunds: algokit.algos(10) }) + const account2 = await generateAccount({ suppressLog: true, initialFunds: algokit.algo(10) }) const txn1 = await getTestTransaction(1) const txn2 = await getTestTransaction(2, account2.addr) const txn3 = await getTestTransaction(3) @@ -233,7 +233,7 @@ describe('transaction', () => { { from: testAccount, to: multisig.addr, - amount: algokit.algos(1), + amount: algokit.algo(1), }, algod, ) @@ -243,7 +243,7 @@ describe('transaction', () => { { from: multisig, to: testAccount.addr, - amount: algokit.microAlgos(500), + amount: algokit.microAlgo(500), }, algod, ) @@ -252,7 +252,7 @@ describe('transaction', () => { test('Multisig double account', async () => { const { algod, testAccount, generateAccount } = localnet.context const account2 = await generateAccount({ - initialFunds: algokit.algos(10), + initialFunds: algokit.algo(10), suppressLog: true, }) @@ -271,7 +271,7 @@ describe('transaction', () => { { from: testAccount, to: multisig.addr, - amount: algokit.algos(1), + amount: algokit.algo(1), }, algod, ) @@ -281,7 +281,7 @@ describe('transaction', () => { { from: multisig, to: testAccount.addr, - amount: algokit.microAlgos(500), + amount: algokit.microAlgo(500), }, algod, ) @@ -416,9 +416,9 @@ const tests = (version: 8 | 9) => () => { await appClient.create({ method: 'createApplication', methodArgs: [] }) - await appClient.fundAppAccount(algokit.microAlgos(2334300)) + await appClient.fundAppAccount(algokit.microAlgo(2334300)) - await appClient.call({ method: 'bootstrap', methodArgs: [], sendParams: { fee: algokit.microAlgos(3_000) } }) + await appClient.call({ method: 'bootstrap', methodArgs: [], sendParams: { fee: algokit.microAlgo(3_000) } }) externalClient = new ApplicationClient( { @@ -474,7 +474,7 @@ const tests = (version: 8 | 9) => () => { appClient.call({ method: 'externalAppCall', methodArgs: [], - sendParams: { populateAppCallResources: false, fee: algokit.microAlgos(2_000) }, + sendParams: { populateAppCallResources: false, fee: algokit.microAlgo(2_000) }, }), ).rejects.toThrow('unavailable App') }) @@ -483,7 +483,7 @@ const tests = (version: 8 | 9) => () => { await appClient.call({ method: 'externalAppCall', methodArgs: [], - sendParams: { fee: algokit.microAlgos(2_000) }, + sendParams: { fee: algokit.microAlgo(2_000) }, }) }) }) @@ -684,8 +684,8 @@ describe('Resource Packer: Mixed', () => { test('app account', async () => { const { algod, testAccount } = fixture.context - await v8Client.fundAppAccount(algokit.microAlgos(328500)) - await v8Client.call({ method: 'bootstrap', methodArgs: [], sendParams: { fee: algokit.microAlgos(3_000) } }) + await v8Client.fundAppAccount(algokit.microAlgo(328500)) + await v8Client.call({ method: 'bootstrap', methodArgs: [], sendParams: { fee: algokit.microAlgo(3_000) } }) const externalAppID = (await v8Client.getGlobalState()).externalAppID!.value as bigint @@ -766,18 +766,18 @@ describe('Resource Packer: meta', () => { amount: 0, }) - await externalClient.fundAppAccount(algokit.microAlgos(106100)) + await externalClient.fundAppAccount(algokit.microAlgo(106100)) await externalClient.call({ method: 'boxWithPayment', methodArgs: [{ transaction: payment, signer: testAccount }] }) }) test('sender asset holding', async () => { - await externalClient.fundAppAccount(algokit.microAlgos(200_000)) + await externalClient.fundAppAccount(algokit.microAlgo(200_000)) await externalClient.call({ method: 'createAsset', methodArgs: [], - sendParams: { fee: algokit.microAlgos(2_000) }, + sendParams: { fee: algokit.microAlgo(2_000) }, }) const res = await externalClient.call({ method: 'senderAssetBalance', methodArgs: [] }) @@ -792,12 +792,12 @@ describe('Resource Packer: meta', () => { await algorand.account.rekeyAccount(testAccount.addr, authAddr.addr) - await externalClient.fundAppAccount(algokit.microAlgos(200_000)) + await externalClient.fundAppAccount(algokit.microAlgo(200_000)) await externalClient.call({ method: 'createAsset', methodArgs: [], - sendParams: { fee: algokit.microAlgos(2_000) }, + sendParams: { fee: algokit.microAlgo(2_000) }, sender: { addr: testAccount.addr, signer: algosdk.makeBasicAccountTransactionSigner(authAddr) }, }) const res = await externalClient.call({ diff --git a/src/transaction/transaction.ts b/src/transaction/transaction.ts index a811eebb..925a4874 100644 --- a/src/transaction/transaction.ts +++ b/src/transaction/transaction.ts @@ -818,9 +818,9 @@ export function capTransactionFee(transaction: algosdk.Transaction | SuggestedPa if (!transaction.flatFee) { // Once a transaction has been constructed by algosdk, transaction.fee indicates what the total transaction fee // Will be based on the current suggested fee-per-byte value. - if (transaction.fee > maxAcceptableFee.microAlgos) { + if (transaction.fee > maxAcceptableFee.microAlgo) { throw new Error( - `Cancelled transaction due to high network congestion fees. Algorand suggested fees would cause this transaction to cost ${transaction.fee} µALGO. Cap for this transaction is ${maxAcceptableFee.microAlgos} µALGO.`, + `Cancelled transaction due to high network congestion fees. Algorand suggested fees would cause this transaction to cost ${transaction.fee} µALGO. Cap for this transaction is ${maxAcceptableFee.microAlgo} µALGO.`, ) } else if (transaction.fee > algosdk.ALGORAND_MIN_TX_FEE) { Config.logger.warn(`Algorand network congestion fees are in effect. This transaction will incur a fee of ${transaction.fee} µALGO.`) @@ -842,7 +842,7 @@ export function controlFees( ) { const { fee, maxFee } = feeControl if (fee) { - transaction.fee = fee.microAlgos + transaction.fee = fee.microAlgo transaction.flatFee = true } diff --git a/src/transfer/transfer-algos.ts b/src/transfer/transfer-algos.ts index e0b6864f..356d04a9 100644 --- a/src/transfer/transfer-algos.ts +++ b/src/transfer/transfer-algos.ts @@ -16,7 +16,7 @@ import Algodv2 = algosdk.Algodv2 * * @example Usage example * ```typescript - * await algokit.transferAlgos({ from, to, amount: algokit.algos(1) }, algod) + * await algokit.transferAlgos({ from, to, amount: algokit.algo(1) }, algod) * ``` */ export async function transferAlgos(transfer: AlgoTransferParams, algod: Algodv2): Promise { diff --git a/src/transfer/transfer.ts b/src/transfer/transfer.ts index f9715d6e..00729bd8 100644 --- a/src/transfer/transfer.ts +++ b/src/transfer/transfer.ts @@ -41,7 +41,7 @@ export async function ensureFunded( ) if (!result) return undefined return { - amount: result.amountFunded.microAlgos, + amount: result.amountFunded.microAlgo, transactionId: result.transactionId, } } else { @@ -65,7 +65,7 @@ export async function ensureFunded( return result ? { - amount: result.amountFunded.microAlgos, + amount: result.amountFunded.microAlgo, transactionId: result.txIds[0], } : undefined @@ -128,7 +128,7 @@ export async function rekeyAccount(rekey: AlgoRekeyParams, algod: Algodv2): Prom { sender: getSenderAddress(rekey.from), receiver: getSenderAddress(rekey.from), - amount: (0).microAlgos(), + amount: (0).microAlgo(), rekeyTo: typeof rekey.rekeyTo === 'string' ? rekey.rekeyTo : getSenderAddress(rekey.rekeyTo), note: encodeTransactionNote(rekey.note), lease: rekey.lease, diff --git a/src/types/account-manager.spec.ts b/src/types/account-manager.spec.ts index dd6f2a6c..159f64b2 100644 --- a/src/types/account-manager.spec.ts +++ b/src/types/account-manager.spec.ts @@ -14,7 +14,7 @@ describe('AccountManager', () => { const account = await algorand.account.fromEnvironment(uuid()) const accountInfo = await algorand.account.getInformation(account.addr) - expect(accountInfo.balance.microAlgos).toBeGreaterThan(0) + expect(accountInfo.balance.microAlgo).toBeGreaterThan(0) }, 10e6) test('Same account is subsequently retrieved', async () => { diff --git a/src/types/account-manager.ts b/src/types/account-manager.ts index 017cd016..21be433e 100644 --- a/src/types/account-manager.ts +++ b/src/types/account-manager.ts @@ -205,11 +205,11 @@ export class AccountManager { return { ...account, // None of these can practically overflow 2^53 - balance: AlgoAmount.MicroAlgos(Number(account.amount)), - amountWithoutPendingRewards: AlgoAmount.MicroAlgos(Number(account.amountWithoutPendingRewards)), - minBalance: AlgoAmount.MicroAlgos(Number(account.minBalance)), - pendingRewards: AlgoAmount.MicroAlgos(Number(account.pendingRewards)), - rewards: AlgoAmount.MicroAlgos(Number(account.rewards)), + balance: AlgoAmount.MicroAlgo(Number(account.amount)), + amountWithoutPendingRewards: AlgoAmount.MicroAlgo(Number(account.amountWithoutPendingRewards)), + minBalance: AlgoAmount.MicroAlgo(Number(account.minBalance)), + pendingRewards: AlgoAmount.MicroAlgo(Number(account.pendingRewards)), + rewards: AlgoAmount.MicroAlgo(Number(account.rewards)), validAsOfRound: BigInt(account.round), totalAppsOptedIn: Number(account.totalAppsOptedIn), totalAssetsOptedIn: Number(account.totalAssetsOptedIn), @@ -441,11 +441,11 @@ export class AccountManager { * note: 'note', * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * maxRoundsToWaitForConfirmation: 5, * suppressLog: true, * }) @@ -462,7 +462,7 @@ export class AccountManager { ...options, sender: typeof account === 'string' ? account : account.addr, receiver: typeof account === 'string' ? account : account.addr, - amount: AlgoAmount.MicroAlgos(0), + amount: AlgoAmount.MicroAlgo(0), rekeyTo: typeof rekeyTo === 'string' ? rekeyTo : rekeyTo.addr, }) .execute(options) @@ -479,11 +479,11 @@ export class AccountManager { private async _getEnsureFundedAmount(sender: string, minSpendingBalance: AlgoAmount, minFundingIncrement?: AlgoAmount) { const accountInfo = await this.getInformation(sender) - const currentSpendingBalance = accountInfo.balance.microAlgos - accountInfo.minBalance.microAlgos + const currentSpendingBalance = accountInfo.balance.microAlgo - accountInfo.minBalance.microAlgo - const amountFunded = calculateFundAmount(minSpendingBalance.microAlgos, currentSpendingBalance, minFundingIncrement?.microAlgos ?? 0) + const amountFunded = calculateFundAmount(minSpendingBalance.microAlgo, currentSpendingBalance, minFundingIncrement?.microAlgo ?? 0) - return amountFunded === null ? undefined : AlgoAmount.MicroAlgos(amountFunded) + return amountFunded === null ? undefined : AlgoAmount.MicroAlgo(amountFunded) } /** @@ -500,10 +500,10 @@ export class AccountManager { * @example Example using AlgorandClient * ```typescript * // Basic example - * await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algos(1)) + * await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algo(1)) * // With configuration - * await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algos(1), - * { minFundingIncrement: algokit.algos(2), fee: (1000).microAlgos(), suppressLog: true } + * await algorand.account.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algo(1), + * { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true } * ) * ``` * @returns @@ -562,10 +562,10 @@ export class AccountManager { * @example Example using AlgorandClient * ```typescript * // Basic example - * await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algos(1)) + * await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algo(1)) * // With configuration - * await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algos(1), - * { minFundingIncrement: algokit.algos(2), fee: (1000).microAlgos(), suppressLog: true } + * await algorand.account.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algo(1), + * { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true } * ) * ``` * @returns @@ -618,10 +618,10 @@ export class AccountManager { * @example Example using AlgorandClient * ```typescript * // Basic example - * await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algos(1)) + * await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1)) * // With configuration - * await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algos(1), - * { minFundingIncrement: algokit.algos(2) } + * await algorand.account.ensureFundedUsingDispenserAPI("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1), + * { minFundingIncrement: algokit.algo(2) } * ) * ``` * @returns @@ -645,9 +645,9 @@ export class AccountManager { const amountFunded = await this._getEnsureFundedAmount(addressToFund, minSpendingBalance, options?.minFundingIncrement) if (!amountFunded) return undefined - const result = await dispenserClient.fund(addressToFund, amountFunded.microAlgos) + const result = await dispenserClient.fund(addressToFund, amountFunded.microAlgo) return { - amountFunded: AlgoAmount.MicroAlgos(result.amount), + amountFunded: AlgoAmount.MicroAlgo(result.amount), transactionId: result.txId, } } diff --git a/src/types/algorand-client-sender.ts b/src/types/algorand-client-sender.ts index a6fc7c5c..7e806459 100644 --- a/src/types/algorand-client-sender.ts +++ b/src/types/algorand-client-sender.ts @@ -67,13 +67,13 @@ export class AlgorandClientSender { * const result = await algorandClient.send.payment({ * sender: 'SENDERADDRESS', * receiver: 'RECEIVERADDRESS', - * amount: (4).algos(), + * amount: (4).algo(), * }) * ``` * @example Advanced example * ```typescript * const result = await algorandClient.send.payment({ - * amount: (4).algos(), + * amount: (4).algo(), * receiver: 'RECEIVERADDRESS', * sender: 'SENDERADDRESS', * closeRemainderTo: 'CLOSEREMAINDERTOADDRESS', @@ -84,11 +84,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in @@ -102,7 +102,7 @@ export class AlgorandClientSender { */ payment = this._send((c) => c.addPayment, { preLog: (params, transaction) => - `Sending ${params.amount.microAlgos} µALGO from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}`, + `Sending ${params.amount.microAlgo} µALGO from ${params.sender} to ${params.receiver} via transaction ${transaction.txID()}`, }) /** * Create a new Algorand Standard Asset. @@ -136,11 +136,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in @@ -185,11 +185,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in @@ -224,11 +224,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in @@ -265,11 +265,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in @@ -307,11 +307,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in @@ -345,11 +345,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in @@ -392,11 +392,11 @@ export class AlgorandClientSender { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * // Signer only needed if you want to provide one, * // generally you'd register it with AlgorandClient * // against the sender and not need to pass it in diff --git a/src/types/algorand-client-transaction-creator.ts b/src/types/algorand-client-transaction-creator.ts index 4a4a7bac..cf834d1c 100644 --- a/src/types/algorand-client-transaction-creator.ts +++ b/src/types/algorand-client-transaction-creator.ts @@ -31,13 +31,13 @@ export class AlgorandClientTransactionCreator { * const result = await algorandClient.send.payment({ * sender: 'SENDERADDRESS', * receiver: 'RECEIVERADDRESS', - * amount: (4).algos(), + * amount: (4).algo(), * }) * ``` * @example Advanced example * ```typescript * const result = await algorandClient.send.payment({ - * amount: (4).algos(), + * amount: (4).algo(), * receiver: 'RECEIVERADDRESS', * sender: 'SENDERADDRESS', * closeRemainderTo: 'CLOSEREMAINDERTOADDRESS', @@ -48,11 +48,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @@ -90,11 +90,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @returns The asset create transaction @@ -126,11 +126,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @returns The asset config transaction @@ -156,11 +156,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @returns The asset freeze transaction @@ -188,11 +188,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @returns The asset destroy transaction @@ -221,11 +221,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @returns The result of the asset transfer transaction @@ -249,11 +249,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @returns The asset opt-in transaction @@ -282,11 +282,11 @@ export class AlgorandClientTransactionCreator { * // You wouldn't normally set this field * firstValidRound: 1000n, * validityWindow: 10, - * extraFee: (1000).microAlgos(), - * staticFee: (1000).microAlgos(), + * extraFee: (1000).microAlgo(), + * staticFee: (1000).microAlgo(), * // Max fee doesn't make sense with extraFee AND staticFee * // already specified, but here for completeness - * maxFee: (3000).microAlgos(), + * maxFee: (3000).microAlgo(), * }) * ``` * @returns The asset opt-out transaction diff --git a/src/types/algorand-client.asset.spec.ts b/src/types/algorand-client.asset.spec.ts index 5bb777c1..813a4324 100644 --- a/src/types/algorand-client.asset.spec.ts +++ b/src/types/algorand-client.asset.spec.ts @@ -45,7 +45,7 @@ describe('Asset capability', () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 1) const dummyAssetIds = [dummyAssetId] - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) const secondAccountInfo = await algorand.account.getInformation(secondAccount.addr) expect(secondAccountInfo.totalAssetsOptedIn).toBe(0) @@ -59,7 +59,7 @@ describe('Asset capability', () => { test('OptIn two batches of asset to an account succeed', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetIds: bigint[] = [] - const secondAccount = await generateAccount({ initialFunds: (3).algos() }) + const secondAccount = await generateAccount({ initialFunds: (3).algo() }) for (let i = 0; i < 20; i++) { const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 0) dummyAssetIds.push(dummyAssetId) @@ -74,7 +74,7 @@ describe('Asset capability', () => { const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 0) const dummyAssetId2 = await generateTestAsset(algorand, testAccount.addr, 0) const dummyAssetIds = [dummyAssetId, dummyAssetId2] - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.asset.bulkOptIn(secondAccount, dummyAssetIds, { validityWindow: 100 }) @@ -91,7 +91,7 @@ describe('Asset capability', () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 0) const dummyAssetIds = [dummyAssetId, 1234567n, -132n] - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.asset.bulkOptIn(secondAccount, [dummyAssetId], { validityWindow: 100 }) @@ -111,7 +111,7 @@ describe('Asset capability', () => { const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 0) const dummyAssetId2 = await generateTestAsset(algorand, testAccount.addr, 0) const dummyAssetIds = [dummyAssetId, dummyAssetId2] - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.asset.bulkOptIn(secondAccount, dummyAssetIds, { validityWindow: 100 }) @@ -137,7 +137,7 @@ describe('Asset capability', () => { test('OptIn and OptOut of a single asset ', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 0) - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.send.assetOptIn({ sender: secondAccount.addr, assetId: dummyAssetId }) @@ -158,7 +158,7 @@ describe('Asset capability', () => { test('OptOut of non-zero balance single asset to an account fails by default', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 0) - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.send.assetOptIn({ sender: secondAccount.addr, assetId: dummyAssetId }) @@ -181,7 +181,7 @@ describe('Asset capability', () => { test('OptOut of two batches of asset to an account succeed', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetIds: bigint[] = [] - const secondAccount = await generateAccount({ initialFunds: (3).algos() }) + const secondAccount = await generateAccount({ initialFunds: (3).algo() }) for (let i = 0; i < 20; i++) { const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 0) dummyAssetIds.push(dummyAssetId) diff --git a/src/types/algorand-client.spec.ts b/src/types/algorand-client.spec.ts index 194e9449..00883cca 100644 --- a/src/types/algorand-client.spec.ts +++ b/src/types/algorand-client.spec.ts @@ -27,7 +27,7 @@ describe('AlgorandClient', () => { await fixture.beforeEach() alice = fixture.context.testAccount - bob = await fixture.context.generateAccount({ initialFunds: AlgoAmount.MicroAlgos(100_000) }) + bob = await fixture.context.generateAccount({ initialFunds: AlgoAmount.MicroAlgo(100_000) }) algorand = fixture.algorand appClient = algorand.client.getTypedAppClientById(TestContractClient, { @@ -42,12 +42,12 @@ describe('AlgorandClient', () => { test('sendPayment', async () => { const alicePreBalance = (await algorand.account.getInformation(alice)).balance const bobPreBalance = (await algorand.account.getInformation(bob)).balance - await algorand.send.payment({ sender: alice.addr, receiver: bob.addr, amount: AlgoAmount.MicroAlgos(1) }) + await algorand.send.payment({ sender: alice.addr, receiver: bob.addr, amount: AlgoAmount.MicroAlgo(1) }) const alicePostBalance = (await algorand.account.getInformation(alice)).balance const bobPostBalance = (await algorand.account.getInformation(bob)).balance - expect(alicePostBalance.microAlgos).toBe(alicePreBalance.microAlgos - 1001) - expect(bobPostBalance.microAlgos).toBe(bobPreBalance.microAlgos + 1) + expect(alicePostBalance.microAlgo).toBe(alicePreBalance.microAlgo - 1001) + expect(bobPostBalance.microAlgo).toBe(bobPreBalance.microAlgo + 1) }) test('sendAssetCreate', async () => { @@ -63,15 +63,15 @@ describe('AlgorandClient', () => { const doMathAtc = await appClient.compose().doMath({ a: 1, b: 2, operation: 'sum' }).atc() const result = await algorand .newGroup() - .addPayment({ sender: alice.addr, receiver: bob.addr, amount: AlgoAmount.MicroAlgos(1) }) + .addPayment({ sender: alice.addr, receiver: bob.addr, amount: AlgoAmount.MicroAlgo(1) }) .addAtc(doMathAtc) .execute() const alicePostBalance = (await algorand.account.getInformation(alice)).balance const bobPostBalance = (await algorand.account.getInformation(bob)).balance - expect(alicePostBalance.microAlgos).toBe(alicePreBalance.microAlgos - 2001) - expect(bobPostBalance.microAlgos).toBe(bobPreBalance.microAlgos + 1) + expect(alicePostBalance.microAlgo).toBe(alicePreBalance.microAlgo - 2001) + expect(bobPostBalance.microAlgo).toBe(bobPreBalance.microAlgo + 1) expect(result.returns?.[0].returnValue?.valueOf()).toBe(3n) }) @@ -82,7 +82,7 @@ describe('AlgorandClient', () => { const methodRes = await algorand .newGroup() - .addPayment({ sender: alice.addr, receiver: bob.addr, amount: AlgoAmount.MicroAlgos(1), note: new Uint8Array([1]) }) + .addPayment({ sender: alice.addr, receiver: bob.addr, amount: AlgoAmount.MicroAlgo(1), note: new Uint8Array([1]) }) .addMethodCall({ sender: alice.addr, appId: appId, @@ -94,8 +94,8 @@ describe('AlgorandClient', () => { const alicePostBalance = (await algorand.account.getInformation(alice)).balance const bobPostBalance = (await algorand.account.getInformation(bob)).balance - expect(alicePostBalance.microAlgos).toBe(alicePreBalance.microAlgos - 2001) - expect(bobPostBalance.microAlgos).toBe(bobPreBalance.microAlgos + 1) + expect(alicePostBalance.microAlgo).toBe(alicePreBalance.microAlgo - 2001) + expect(bobPostBalance.microAlgo).toBe(bobPreBalance.microAlgo + 1) expect(methodRes.returns?.[0].returnValue?.valueOf()).toBe(3n) }) @@ -105,12 +105,12 @@ describe('AlgorandClient', () => { sender: alice.addr, appId: appId, method: appClient.appClient.getABIMethod('txnArg')!, - args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgos(0) })], + args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgo(0) })], } const txnRes = await algorand .newGroup() - .addPayment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgos(0), note: new Uint8Array([1]) }) + .addPayment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgo(0), note: new Uint8Array([1]) }) .addMethodCall(txnArgParams) .execute() @@ -143,7 +143,7 @@ describe('AlgorandClient', () => { sender: alice.addr, appId: appId, method: appClient.appClient.getABIMethod('txnArg')!, - args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgos(0) })], + args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgo(0) })], } satisfies MethodCallParams const nestedTxnArgRes = await algorand @@ -165,14 +165,14 @@ describe('AlgorandClient', () => { sender: alice.addr, appId: appId, method: appClient.appClient.getABIMethod('txnArg')!, - args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgos(0) })], + args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgo(0) })], } satisfies MethodCallParams const secondTxnCall = { sender: alice.addr, appId: appId, method: appClient.appClient.getABIMethod('txnArg')!, - args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgos(1) })], + args: [algorand.transactions.payment({ sender: alice.addr, receiver: alice.addr, amount: AlgoAmount.MicroAlgo(1) })], note: new Uint8Array([1]), } satisfies MethodCallParams @@ -223,12 +223,12 @@ describe('AlgorandClient', () => { await algorand.send.payment({ sender: (await algorand.account.localNetDispenser()).addr, receiver: alice.addr, - amount: (2).algos(), + amount: (2).algo(), }) // Default validity window is 10 for (let i = 0; i < 10; i++) { - await algorand.send.payment({ sender: alice.addr, receiver: alice.addr, amount: i.microAlgos() }) + await algorand.send.payment({ sender: alice.addr, receiver: alice.addr, amount: i.microAlgo() }) } }) }) diff --git a/src/types/algorand-client.transfer.spec.ts b/src/types/algorand-client.transfer.spec.ts index 00797f13..c3a79aff 100644 --- a/src/types/algorand-client.transfer.spec.ts +++ b/src/types/algorand-client.transfer.spec.ts @@ -28,7 +28,7 @@ describe('Transfer capability', () => { const result = await algorand.send.payment({ sender: testAccount.addr, receiver: secondAccount.addr, - amount: (5).algos(), + amount: (5).algo(), note: 'Transfer 5 Algos', }) @@ -45,7 +45,7 @@ describe('Transfer capability', () => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion expect(algosdk.encodeAddress(result.confirmation.txn.txn.snd)).toBe(testAccount.addr) - expect(accountInfo.balance.microAlgos).toBe(5_000_000) + expect(accountInfo.balance.microAlgo).toBe(5_000_000) }) test('Transfer Algo respects string lease', async () => { @@ -55,7 +55,7 @@ describe('Transfer capability', () => { await algorand.send.payment({ sender: testAccount.addr, receiver: secondAccount.addr, - amount: (1).algos(), + amount: (1).algo(), lease: 'test', }) @@ -63,7 +63,7 @@ describe('Transfer capability', () => { algorand.send.payment({ sender: testAccount.addr, receiver: secondAccount.addr, - amount: (2).algos(), + amount: (2).algo(), lease: 'test', }), ).rejects.toThrow(/overlapping lease/) @@ -76,7 +76,7 @@ describe('Transfer capability', () => { await algorand.send.payment({ sender: testAccount.addr, receiver: secondAccount.addr, - amount: (1).algos(), + amount: (1).algo(), lease: new Uint8Array([1, 2, 3, 4]), }) @@ -84,7 +84,7 @@ describe('Transfer capability', () => { algorand.send.payment({ sender: testAccount.addr, receiver: secondAccount.addr, - amount: (2).algos(), + amount: (2).algo(), lease: new Uint8Array([1, 2, 3, 4]), }), ).rejects.toThrow(/overlapping lease/) @@ -93,7 +93,7 @@ describe('Transfer capability', () => { test('Transfer ASA, respects lease', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 100) - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.send.assetOptIn({ sender: secondAccount.addr, assetId: dummyAssetId }) await algorand.send.assetTransfer({ @@ -137,7 +137,7 @@ describe('Transfer capability', () => { test('Transfer ASA, sender is not opted in', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 100) - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.send.assetOptIn({ sender: secondAccount.addr, assetId: dummyAssetId }) @@ -157,7 +157,7 @@ describe('Transfer capability', () => { test('Transfer ASA, asset doesnt exist', async () => { const { algorand, testAccount, generateAccount } = localnet.context - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) try { await algorand.send.assetTransfer({ @@ -176,7 +176,7 @@ describe('Transfer capability', () => { // @deprecated test - remove when removing transferAsset test('Transfer ASA, without sending', async () => { const { algod, testAccount, generateAccount } = localnet.context - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) const response = await transferAsset( { @@ -197,7 +197,7 @@ describe('Transfer capability', () => { test('Transfer ASA, asset is transfered to another account', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 100) - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.send.assetOptIn({ sender: secondAccount.addr, assetId: dummyAssetId }) @@ -219,8 +219,8 @@ describe('Transfer capability', () => { test('Transfer ASA, asset is transfered to another account from revocationTarget', async () => { const { algorand, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algorand, testAccount.addr, 100) - const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - const clawbackAccount = await generateAccount({ initialFunds: (1).algos() }) + const secondAccount = await generateAccount({ initialFunds: (1).algo() }) + const clawbackAccount = await generateAccount({ initialFunds: (1).algo() }) await algorand.send.assetOptIn({ sender: secondAccount.addr, assetId: dummyAssetId }) @@ -260,27 +260,27 @@ describe('Transfer capability', () => { const { algorand, testAccount } = localnet.context const secondAccount = algorand.account.random() - const result = await algorand.account.ensureFunded(secondAccount, testAccount, (1).microAlgos()) + const result = await algorand.account.ensureFunded(secondAccount, testAccount, (1).microAlgo()) const accountInfo = await algorand.account.getInformation(secondAccount.addr) invariant(result) expect(result.transactionId).toBe(result.transaction.txID()) - expect(result.amountFunded.microAlgos).toBe(100_001) - expect(accountInfo.balance.microAlgos).toBe(100_001) + expect(result.amountFunded.microAlgo).toBe(100_001) + expect(accountInfo.balance.microAlgo).toBe(100_001) }) test('ensureFunded respects minimum funding increment', async () => { const { algorand, testAccount, generateAccount } = localnet.context - const secondAccount = await generateAccount({ initialFunds: (100_000).microAlgos() }) + const secondAccount = await generateAccount({ initialFunds: (100_000).microAlgo() }) - const result = await algorand.account.ensureFunded(secondAccount, testAccount, (1).microAlgos(), { - minFundingIncrement: (1).algos(), + const result = await algorand.account.ensureFunded(secondAccount, testAccount, (1).microAlgo(), { + minFundingIncrement: (1).algo(), }) invariant(result) - expect(result.amountFunded.algos).toBe(1) + expect(result.amountFunded.algo).toBe(1) const accountInfo = await algorand.account.getInformation(secondAccount.addr) - expect(accountInfo.balance.microAlgos).toBe(1_100_000) + expect(accountInfo.balance.microAlgo).toBe(1_100_000) }) test('ensureFunded uses dispenser account by default', async () => { @@ -288,15 +288,15 @@ describe('Transfer capability', () => { const secondAccount = algorand.account.random() const dispenser = await algorand.account.dispenserFromEnvironment() - const result = await algorand.account.ensureFundedFromEnvironment(secondAccount, (1).microAlgos(), { - minFundingIncrement: (1).algos(), + const result = await algorand.account.ensureFundedFromEnvironment(secondAccount, (1).microAlgo(), { + minFundingIncrement: (1).algo(), }) invariant(result) const resultReceiver = algosdk.encodeAddress(result.confirmation.txn.txn.snd) expect(resultReceiver).toBe(dispenser.addr) const accountInfo = await algorand.account.getInformation(secondAccount.addr) - expect(accountInfo.balance.algos).toBe(1) + expect(accountInfo.balance.algo).toBe(1) }) test('ensureFunded uses dispenser api with access token successfully', async () => { @@ -313,13 +313,13 @@ describe('Transfer capability', () => { const accountToFund = algorand.account.random() - const result = await algorand.account.ensureFundedFromTestNetDispenserApi(accountToFund, dispenserClient, (100).algos(), { - minFundingIncrement: (0.1).algos(), + const result = await algorand.account.ensureFundedFromTestNetDispenserApi(accountToFund, dispenserClient, (100).algo(), { + minFundingIncrement: (0.1).algo(), }) invariant(result) expect(result.transactionId).toBeDefined() - expect(result.amountFunded.algos).toBe(0.2) + expect(result.amountFunded.algo).toBe(0.2) }) test('ensureFunded uses dispenser api and fails with rejected response', async () => { @@ -336,8 +336,8 @@ describe('Transfer capability', () => { const accountToFund = algorand.account.random() await expect( - algorand.account.ensureFundedFromTestNetDispenserApi(accountToFund, dispenserClient, (100).algos(), { - minFundingIncrement: (1).algos(), + algorand.account.ensureFundedFromTestNetDispenserApi(accountToFund, dispenserClient, (100).algo(), { + minFundingIncrement: (1).algo(), }), ).rejects.toThrowErrorMatchingInlineSnapshot('"dummy_error"') }) @@ -369,7 +369,7 @@ describe('rekey', () => { await algorand.send.payment({ sender: testAccount.addr, receiver: testAccount.addr, - amount: (1).microAlgos(), + amount: (1).microAlgo(), signer: secondAccount.signer, }) }) diff --git a/src/types/amount.spec.ts b/src/types/amount.spec.ts index a17371d4..cd044b12 100644 --- a/src/types/amount.spec.ts +++ b/src/types/amount.spec.ts @@ -10,32 +10,32 @@ describe('amount', () => { expect(`${algos(100)}`).toBe(`100,000,000 µALGO`) }) test('microalgos to microalgos', () => { - expect(microAlgos(100).microAlgos).toBe(100) + expect(microAlgos(100).microAlgo).toBe(100) }) test('algos to microalgos', () => { - expect(algos(100).microAlgos).toBe(100_000_000) + expect(algos(100).microAlgo).toBe(100_000_000) }) test('algos to algos', () => { - expect(algos(100).algos).toBe(100) + expect(algos(100).algo).toBe(100) }) test('small microalgos to algos', () => { - expect(microAlgos(1000).algos).toBe(0.001) + expect(microAlgos(1000).algo).toBe(0.001) }) test('large microalgos to algos', () => { - expect(microAlgos(100_000_000).algos).toBe(100) + expect(microAlgos(100_000_000).algo).toBe(100) }) test('single transaction fee', () => { - expect(transactionFees(1).microAlgos).toBe(1_000) + expect(transactionFees(1).microAlgo).toBe(1_000) }) test('multiple transaction fees', () => { - expect(transactionFees(10).microAlgos).toBe(10_000) + expect(transactionFees(10).microAlgo).toBe(10_000) }) test('algos via Number.prototype', () => { - expect((100).algos()).toBeInstanceOf(AlgoAmount) - expect((100).algos().algos).toBe(100) + expect((100).algo()).toBeInstanceOf(AlgoAmount) + expect((100).algo().algo).toBe(100) }) test('microAlgos via Number.prototype', () => { - expect((100).microAlgos()).toBeInstanceOf(AlgoAmount) - expect((100).microAlgos().microAlgos).toBe(100) + expect((100).microAlgo()).toBeInstanceOf(AlgoAmount) + expect((100).microAlgo().microAlgo).toBe(100) }) }) diff --git a/src/types/amount.ts b/src/types/amount.ts index 2d2c720c..72ca54c3 100644 --- a/src/types/amount.ts +++ b/src/types/amount.ts @@ -2,24 +2,41 @@ import algosdk from 'algosdk' /** Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers */ export class AlgoAmount { - private amountInMicroAlgos + private amountInMicroAlgo /** Return the amount as a number in µAlgo */ get microAlgos() { - return this.amountInMicroAlgos + return this.amountInMicroAlgo + } + + /** Return the amount as a number in µAlgo */ + get microAlgo() { + return this.amountInMicroAlgo } /** Return the amount as a number in Algo */ get algos() { - return algosdk.microalgosToAlgos(this.amountInMicroAlgos) + return algosdk.microalgosToAlgos(this.amountInMicroAlgo) } - constructor(amount: { algos: number } | { microAlgos: number }) { - this.amountInMicroAlgos = 'microAlgos' in amount ? amount.microAlgos : algosdk.algosToMicroalgos(amount.algos) + /** Return the amount as a number in Algo */ + get algo() { + return algosdk.microalgosToAlgos(this.amountInMicroAlgo) + } + + constructor(amount: { algos: number } | { algo: number } | { microAlgos: number } | { microAlgo: number }) { + this.amountInMicroAlgo = + 'microAlgos' in amount + ? amount.microAlgos + : 'microAlgo' in amount + ? amount.microAlgo + : 'algos' in amount + ? algosdk.algosToMicroalgos(amount.algos) + : algosdk.algosToMicroalgos(amount.algo) } toString(): string { - return `${this.microAlgos.toLocaleString('en-US')} µALGO` + return `${this.microAlgo.toLocaleString('en-US')} µALGO` } /** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc., @@ -27,7 +44,7 @@ export class AlgoAmount { * the algos or microAlgos properties */ valueOf(): number { - return this.microAlgos + return this.microAlgo } /** Create a `AlgoAmount` object representing the given number of Algo */ @@ -35,8 +52,18 @@ export class AlgoAmount { return new AlgoAmount({ algos: amount }) } + /** Create a `AlgoAmount` object representing the given number of Algo */ + static Algo(amount: number) { + return new AlgoAmount({ algos: amount }) + } + /** Create a `AlgoAmount` object representing the given number of µAlgo */ static MicroAlgos(amount: number) { return new AlgoAmount({ microAlgos: amount }) } + + /** Create a `AlgoAmount` object representing the given number of µAlgo */ + static MicroAlgo(amount: number) { + return new AlgoAmount({ microAlgos: amount }) + } } diff --git a/src/types/app-client.spec.ts b/src/types/app-client.spec.ts index 358fb4ca..3ea84360 100644 --- a/src/types/app-client.spec.ts +++ b/src/types/app-client.spec.ts @@ -430,7 +430,7 @@ describe('application-client', () => { const rekeyedAccount = algorand.account.rekeyed(testAccount.addr, rekeyTo) await algokit.transferAlgos( { - amount: (0).algos(), + amount: (0).algo(), from: rekeyedAccount, to: testAccount, }, @@ -547,7 +547,7 @@ describe('application-client', () => { { from: testAccount, to: testAccount.addr, - amount: algokit.microAlgos(Math.ceil(Math.random() * 10000)), + amount: algokit.microAlgo(Math.ceil(Math.random() * 10000)), skipSending: true, }, algod, @@ -573,7 +573,7 @@ describe('application-client', () => { { from: testAccount, to: testAccount.addr, - amount: algokit.microAlgos(Math.ceil(Math.random() * 10000)), + amount: algokit.microAlgo(Math.ceil(Math.random() * 10000)), skipSending: true, }, algod, @@ -597,13 +597,13 @@ describe('application-client', () => { test('Sign transaction in group with different signer if provided', async () => { const { algod, indexer, testAccount, generateAccount } = localnet.context - const signer = await generateAccount({ initialFunds: (1).algos() }) + const signer = await generateAccount({ initialFunds: (1).algo() }) const transaction = ( await algokit.transferAlgos( { from: signer, to: signer.addr, - amount: algokit.microAlgos(Math.ceil(Math.random() * 10000)), + amount: algokit.microAlgo(Math.ceil(Math.random() * 10000)), skipSending: true, }, algod, @@ -746,14 +746,14 @@ describe('application-client', () => { test('Fund app account', async () => { const { algod, indexer, testAccount } = localnet.context - const fundAmount = algokit.microAlgos(200_000) + const fundAmount = algokit.microAlgo(200_000) const { client, app } = await deploy(testAccount, algod, indexer) const result = await client.fundAppAccount({ amount: fundAmount, }) - expect(result.transaction.amount).toBe(fundAmount.microAlgos) + expect(result.transaction.amount).toBe(fundAmount.microAlgo) expect(result.transaction.type).toBe(TransactionType.pay) expect(algosdk.encodeAddress(result.transaction.to.publicKey)).toBe(app.appAddress) expect(algosdk.encodeAddress(result.transaction.from.publicKey)).toBe(testAccount.addr) @@ -798,7 +798,7 @@ describe('application-client', () => { const boxName1Base64 = Buffer.from(boxName1).toString('base64') const boxName2 = new Uint8Array([0, 0, 0, 2]) const boxName2Base64 = Buffer.from(boxName2).toString('base64') - await client.fundAppAccount(algokit.algos(1)) + await client.fundAppAccount(algokit.algo(1)) await client.call({ method: 'set_box', methodArgs: [boxName1, 'value1'], diff --git a/src/types/asset-manager.ts b/src/types/asset-manager.ts index a14279c4..44f0f17c 100644 --- a/src/types/asset-manager.ts +++ b/src/types/asset-manager.ts @@ -226,7 +226,7 @@ export class AssetManager { * // Basic example * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n]) * // With configuration - * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgos(), suppressLog: true }) + * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true }) * ``` * @returns An array of records matching asset ID to transaction ID of the opt in */ @@ -276,7 +276,7 @@ export class AssetManager { * // Basic example * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n]) * // With configuration - * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgos(), suppressLog: true }) + * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true }) * ``` * @returns An array of records matching asset ID to transaction ID of the opt in */ diff --git a/src/types/composer.ts b/src/types/composer.ts index 49017c41..0c5ea70c 100644 --- a/src/types/composer.ts +++ b/src/types/composer.ts @@ -610,14 +610,14 @@ export default class AlgoKitComposer { } if (params.staticFee !== undefined) { - txn.fee = params.staticFee.microAlgos + txn.fee = params.staticFee.microAlgo } else { txn.fee = txn.estimateSize() * suggestedParams.fee || algosdk.ALGORAND_MIN_TX_FEE - if (params.extraFee) txn.fee += params.extraFee.microAlgos + if (params.extraFee) txn.fee += params.extraFee.microAlgo } txn.flatFee = true - if (params.maxFee !== undefined && txn.fee > params.maxFee.microAlgos) { + if (params.maxFee !== undefined && txn.fee > params.maxFee.microAlgo) { throw Error(`Transaction fee ${txn.fee} is greater than maxFee ${params.maxFee}`) } @@ -705,7 +705,7 @@ export default class AlgoKitComposer { const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ from: params.sender, to: params.receiver, - amount: params.amount.microAlgos, + amount: params.amount.microAlgo, closeRemainderTo: params.closeRemainderTo, suggestedParams, }) diff --git a/src/types/kmd-account-manager.ts b/src/types/kmd-account-manager.ts index 7cc876d3..9c5d0068 100644 --- a/src/types/kmd-account-manager.ts +++ b/src/types/kmd-account-manager.ts @@ -125,7 +125,7 @@ export class KmdAccountManager { * ```typescript * // Idempotently get (if exists) or crate (if it doesn't exist yet) an account by name using KMD * // if creating it then fund it with 2 ALGO from the default dispenser account - * const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algos()) + * const newAccount = await kmdAccountManager.getOrCreateWalletAccount('account1', (2).algo()) * // This will return the same account as above since the name matches * const existingAccount = await kmdAccountManager.getOrCreateWalletAccount('account1') * ``` @@ -155,7 +155,7 @@ export class KmdAccountManager { Config.logger.info( `LocalNet account '${name}' doesn't yet exist; created account ${account.addr} with keys stored in KMD and funding with ${ - fundWith?.algos ?? 1000 + fundWith?.algo ?? 1000 } ALGO`, ) @@ -167,7 +167,7 @@ export class KmdAccountManager { getSuggestedParams: () => this._clientManager.algod.getTransactionParams().do(), }) .addPayment({ - amount: fundWith ?? AlgoAmount.Algos(1000), + amount: fundWith ?? AlgoAmount.Algo(1000), receiver: account.addr, sender: dispenser.addr, })