@algorandfoundation/algokit-utils 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +38 -0
  2. package/account.d.ts +11 -10
  3. package/account.d.ts.map +1 -1
  4. package/account.js +13 -12
  5. package/account.js.map +1 -1
  6. package/amount.d.ts +15 -3
  7. package/amount.d.ts.map +1 -1
  8. package/amount.js +15 -3
  9. package/amount.js.map +1 -1
  10. package/app-client.d.ts +14 -0
  11. package/app-client.d.ts.map +1 -0
  12. package/app-client.js +19 -0
  13. package/app-client.js.map +1 -0
  14. package/{deploy-app.d.ts → app-deploy.d.ts} +16 -14
  15. package/app-deploy.d.ts.map +1 -0
  16. package/{deploy-app.js → app-deploy.js} +47 -28
  17. package/app-deploy.js.map +1 -0
  18. package/app.d.ts +53 -8
  19. package/app.d.ts.map +1 -1
  20. package/app.js +305 -146
  21. package/app.js.map +1 -1
  22. package/index.d.ts +2 -2
  23. package/index.d.ts.map +1 -1
  24. package/index.js +2 -2
  25. package/index.js.map +1 -1
  26. package/indexer-lookup.d.ts +11 -4
  27. package/indexer-lookup.d.ts.map +1 -1
  28. package/indexer-lookup.js +19 -9
  29. package/indexer-lookup.js.map +1 -1
  30. package/localnet.d.ts +7 -7
  31. package/localnet.js +7 -7
  32. package/network-client.d.ts +4 -4
  33. package/network-client.js +5 -5
  34. package/network-client.js.map +1 -1
  35. package/package.json +1 -1
  36. package/testing/account.d.ts +2 -2
  37. package/testing/account.js +2 -2
  38. package/testing/fixtures/algorand-fixture.d.ts +6 -2
  39. package/testing/fixtures/algorand-fixture.d.ts.map +1 -1
  40. package/testing/fixtures/algorand-fixture.js +19 -8
  41. package/testing/fixtures/algorand-fixture.js.map +1 -1
  42. package/testing/indexer.d.ts.map +1 -1
  43. package/testing/indexer.js +1 -0
  44. package/testing/indexer.js.map +1 -1
  45. package/testing/test-logger.d.ts +3 -1
  46. package/testing/test-logger.d.ts.map +1 -1
  47. package/testing/test-logger.js +4 -2
  48. package/testing/test-logger.js.map +1 -1
  49. package/testing/transaction-logger.d.ts +4 -4
  50. package/testing/transaction-logger.d.ts.map +1 -1
  51. package/testing/transaction-logger.js +4 -4
  52. package/testing/transaction-logger.js.map +1 -1
  53. package/transaction.d.ts +54 -13
  54. package/transaction.d.ts.map +1 -1
  55. package/transaction.js +201 -93
  56. package/transaction.js.map +1 -1
  57. package/transfer.d.ts +4 -3
  58. package/transfer.d.ts.map +1 -1
  59. package/transfer.js +10 -8
  60. package/transfer.js.map +1 -1
  61. package/types/account.d.ts +6 -3
  62. package/types/account.d.ts.map +1 -1
  63. package/types/account.js +7 -2
  64. package/types/account.js.map +1 -1
  65. package/types/algo-http-client-with-retry.js +1 -1
  66. package/types/algo-http-client-with-retry.js.map +1 -1
  67. package/types/algod.d.ts +6 -6
  68. package/types/algod.d.ts.map +1 -1
  69. package/types/amount.d.ts +6 -2
  70. package/types/amount.d.ts.map +1 -1
  71. package/types/amount.js +6 -2
  72. package/types/amount.js.map +1 -1
  73. package/types/{application-client.d.ts → app-client.d.ts} +75 -22
  74. package/types/app-client.d.ts.map +1 -0
  75. package/types/{application-client.js → app-client.js} +115 -56
  76. package/types/app-client.js.map +1 -0
  77. package/types/app-spec.d.ts +141 -0
  78. package/types/app-spec.d.ts.map +1 -0
  79. package/types/{appspec.js → app-spec.js} +5 -7
  80. package/types/app-spec.js.map +1 -0
  81. package/types/app.d.ts +23 -17
  82. package/types/app.d.ts.map +1 -1
  83. package/types/app.js.map +1 -1
  84. package/types/config.d.ts +19 -2
  85. package/types/config.d.ts.map +1 -1
  86. package/types/config.js +28 -2
  87. package/types/config.js.map +1 -1
  88. package/types/indexer.d.ts +360 -49
  89. package/types/indexer.d.ts.map +1 -1
  90. package/types/indexer.js +9 -0
  91. package/types/indexer.js.map +1 -1
  92. package/types/logic-error.d.ts +5 -1
  93. package/types/logic-error.d.ts.map +1 -1
  94. package/types/logic-error.js +6 -2
  95. package/types/logic-error.js.map +1 -1
  96. package/types/testing.d.ts +9 -9
  97. package/types/testing.d.ts.map +1 -1
  98. package/types/transaction.d.ts +54 -9
  99. package/types/transaction.d.ts.map +1 -1
  100. package/types/transfer.d.ts +7 -7
  101. package/types/transfer.d.ts.map +1 -1
  102. package/application-client.d.ts +0 -10
  103. package/application-client.d.ts.map +0 -1
  104. package/application-client.js +0 -15
  105. package/application-client.js.map +0 -1
  106. package/deploy-app.d.ts.map +0 -1
  107. package/deploy-app.js.map +0 -1
  108. package/types/application-client.d.ts.map +0 -1
  109. package/types/application-client.js.map +0 -1
  110. package/types/appspec.d.ts +0 -77
  111. package/types/appspec.d.ts.map +0 -1
  112. package/types/appspec.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-logger.js","sourceRoot":"","sources":["../../src/testing/transaction-logger.ts"],"names":[],"mappings":";;;AAAA,qCAAmE;AACnE,yBAA2C;AAE3C;;;GAGG;AACH,MAAa,iBAAiB;IAA9B;QACU,wBAAmB,GAAa,EAAE,CAAA;IA4C5C,CAAC;IA1CC;;OAEG;IACH,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,mBAAmB,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAA;IAC/B,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,kBAA6C;QAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;YACrC,KAAK,MAAM,IAAI,IAAI,kBAAkB,EAAE;gBACrC,MAAM,OAAO,GAAG,IAAA,iCAAuB,EAAC,IAAI,CAAC,CAAA;gBAC7C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;aAClD;SACF;aAAM;YACL,MAAM,OAAO,GAAG,IAAA,iCAAuB,EAAC,kBAAkB,CAAC,CAAA;YAC3D,IAAI,CAAC,mBAAmB,CA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AAE,QAAyB,EAAE,QAAa;QAC3D,IAAI,QAAQ,KAAK,oBAAoB,EAAE;YACrC,OAAO,CAAC,SAAoC,EAAE,EAAE;gBAC9C,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA;gBACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;YACnD,CAAC,CAAA;SACF;QACD,8DAA8D;QAC9D,OAAQ,MAAc,CAAC,QAAQ,CAAC,CAAA;IAClC,CAAC;CACF"}
package/transaction.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import algosdk, { Algodv2, SuggestedParams, Transaction } from 'algosdk';
1
+ import algosdk, { Algodv2, AtomicTransactionComposer, SuggestedParams, Transaction } from 'algosdk';
2
2
  import { PendingTransactionResponse } from './types/algod';
3
3
  import { AlgoAmount } from './types/amount';
4
- import { SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionGroupToSend, TransactionNote } from './types/transaction';
4
+ import { AtomicTransactionComposerToSend, SendAtomicTransactionComposerResults, SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionGroupToSend, TransactionNote } from './types/transaction';
5
5
  /** Encodes a transaction note into a byte array ready to be included in an Algorand transaction.
6
6
  *
7
7
  * @param note The transaction note
@@ -21,21 +21,51 @@ export declare function encodeTransactionNote(note?: TransactionNote): Uint8Arra
21
21
  * @returns The public address
22
22
  */
23
23
  export declare const getSenderAddress: (sender: SendTransactionFrom) => string;
24
- /** Signs and sends the given transaction to the chain
24
+ /**
25
+ * Returns a `TransactionSigner` for the given transaction sender.
26
+ * This function has memoization, so will return the same transaction signer for a given sender.
27
+ * @param sender A transaction sender
28
+ * @returns A transaction signer
29
+ */
30
+ export declare const getSenderTransactionSigner: (val: SendTransactionFrom) => algosdk.TransactionSigner;
31
+ /**
32
+ * Signs a single transaction by the given signer.
33
+ * @param transaction The transaction to sign
34
+ * @param signer The signer to sign
35
+ * @returns The signed transaction as a `Uint8Array`
36
+ */
37
+ export declare const signTransaction: (transaction: Transaction, signer: SendTransactionFrom) => Promise<Uint8Array>;
38
+ /** Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain.
25
39
  *
26
- * @param send The details for the transaction to send, including:
40
+ * @param send The details for the transaction to prepare/send, including:
27
41
  * * `transaction`: The unsigned transaction
28
42
  * * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account
29
43
  * * `config`: The sending configuration for this transaction
30
44
  * @param algod An algod client
31
45
  *
32
- * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
46
+ * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`)
33
47
  */
34
48
  export declare const sendTransaction: (send: {
35
49
  transaction: Transaction;
36
50
  from: SendTransactionFrom;
37
51
  sendParams?: SendTransactionParams;
38
52
  }, algod: Algodv2) => Promise<SendTransactionResult>;
53
+ /**
54
+ * Signs and sends transactions that have been collected by an `AtomicTransactionComposer`.
55
+ * @param atcSend The parameters controlling the send, including:
56
+ * * `atc` The `AtomicTransactionComposer`
57
+ * * `sendParams` The parameters to control the send behaviour
58
+ * @param algod An algod client
59
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
60
+ */
61
+ export declare const sendAtomicTransactionComposer: (atcSend: AtomicTransactionComposerToSend, algod: Algodv2) => Promise<SendAtomicTransactionComposerResults>;
62
+ /**
63
+ * Performs a dry run of the transactions loaded into the given AtomicTransactionComposer`
64
+ * @param atc The AtomicTransactionComposer` with transaction(s) loaded
65
+ * @param algod An Algod client
66
+ * @returns The dryrun result
67
+ */
68
+ export declare function performAtomicTransactionComposerDryrun(atc: AtomicTransactionComposer, algod: Algodv2): Promise<algosdk.DryrunResult>;
39
69
  /**
40
70
  * Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain
41
71
  *
@@ -43,13 +73,9 @@ export declare const sendTransaction: (send: {
43
73
  * * `transactions`: The array of transactions to send along with their signing account
44
74
  * * `sendParams`: The parameters to dictate how the group is sent
45
75
  * @param algod An algod client
46
- * @returns An object with group transaction ID (`groupTransactionId`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
76
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
47
77
  */
48
- export declare const sendGroupOfTransactions: (groupSend: TransactionGroupToSend, algod: Algodv2) => Promise<{
49
- groupId: string;
50
- confirmations: PendingTransactionResponse[] | undefined;
51
- txIds: string[];
52
- }>;
78
+ export declare const sendGroupOfTransactions: (groupSend: TransactionGroupToSend, algod: Algodv2) => Promise<Omit<SendAtomicTransactionComposerResults, "returns">>;
53
79
  /**
54
80
  * Wait until the transaction is confirmed or rejected, or until `timeout`
55
81
  * number of rounds have passed.
@@ -66,10 +92,19 @@ export declare const waitForConfirmation: (transactionId: string, maxRoundsToWai
66
92
  * Limit the acceptable fee to a defined amount of µALGOs.
67
93
  * This also sets the transaction to be flatFee to ensure the transaction only succeeds at
68
94
  * the estimated rate.
69
- * @param transaction The transaction to cap
95
+ * @param transaction The transaction to cap or suggested params object about to be used to create a transaction
70
96
  * @param maxAcceptableFee The maximum acceptable fee to pay
71
97
  */
72
- export declare function capTransactionFee(transaction: algosdk.Transaction, maxAcceptableFee: AlgoAmount): void;
98
+ export declare function capTransactionFee(transaction: algosdk.Transaction | SuggestedParams, maxAcceptableFee: AlgoAmount): void;
99
+ /**
100
+ * Allows for control of fees on a `Transaction` or `SuggestedParams` object
101
+ * @param transaction The transaction or suggested params
102
+ * @param feeControl The fee control parameters
103
+ */
104
+ export declare function controlFees<T extends SuggestedParams | Transaction>(transaction: T, feeControl: {
105
+ fee?: AlgoAmount;
106
+ maxFee?: AlgoAmount;
107
+ }): T;
73
108
  /**
74
109
  * Returns suggested transaction parameters from algod unless some are already provided.
75
110
  * @param params Optionally provide parameters to use
@@ -77,4 +112,10 @@ export declare function capTransactionFee(transaction: algosdk.Transaction, maxA
77
112
  * @returns The suggested transaction parameters
78
113
  */
79
114
  export declare function getTransactionParams(params: SuggestedParams | undefined, algod: Algodv2): Promise<algosdk.SuggestedParams>;
115
+ /**
116
+ * Returns the array of transactions currently present in the given `AtomicTransactionComposer`
117
+ * @param atc The atomic transaction composer
118
+ * @returns The array of transactions with signers
119
+ */
120
+ export declare function getAtomicTransactionComposerTransactions(atc: AtomicTransactionComposer): algosdk.TransactionWithSigner[];
80
121
  //# sourceMappingURL=transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAIxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAE5B;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,SAAS,CAcpF;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAqB,mBAAmB,WAEpE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,SACpB;IACJ,WAAW,EAAE,WAAW,CAAA;IACxB,IAAI,EAAE,mBAAmB,CAAA;IACzB,UAAU,CAAC,EAAE,qBAAqB,CAAA;CACnC,SACM,OAAO,KACb,QAAQ,qBAAqB,CAmC/B,CAAA;AAQD;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,cAA8B,sBAAsB,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BAAqB,CAAA;CACnC,SACM,OAAO,KACb,QAAQ,qBAAqB,CA2B/B,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,YAA4B,+BAA+B,SAAS,OAAO,kDA+EpH,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,sCAAsC,CAAC,GAAG,EAAE,yBAAyB,EAAE,KAAK,EAAE,OAAO,iCAO1G;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,cAA8B,sBAAsB,SAAS,OAAO,mEAgCvG,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,kBACf,MAAM,mBACJ,MAAM,SAChB,OAAO,KACb,QAAQ,0BAA0B,CAkCpC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,GAAG,eAAe,EAAE,gBAAgB,EAAE,UAAU,QAgBjH;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,eAAe,GAAG,WAAW,EACjE,WAAW,EAAE,CAAC,EACd,UAAU,EAAE;IAAE,GAAG,CAAC,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,UAAU,CAAA;CAAE,KAatD;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,oCAE7F;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,GAAG,EAAE,yBAAyB,mCAMtF"}
package/transaction.js CHANGED
@@ -1,10 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTransactionParams = exports.capTransactionFee = exports.waitForConfirmation = exports.sendGroupOfTransactions = exports.sendTransaction = exports.getSenderAddress = exports.encodeTransactionNote = void 0;
7
- const algosdk_1 = __importDefault(require("algosdk"));
26
+ exports.getAtomicTransactionComposerTransactions = exports.getTransactionParams = exports.controlFees = exports.capTransactionFee = exports.waitForConfirmation = exports.sendGroupOfTransactions = exports.performAtomicTransactionComposerDryrun = exports.sendAtomicTransactionComposer = exports.sendTransaction = exports.signTransaction = exports.getSenderTransactionSigner = exports.getSenderAddress = exports.encodeTransactionNote = void 0;
27
+ const algosdk_1 = __importStar(require("algosdk"));
8
28
  const buffer_1 = require("buffer");
9
29
  const _1 = require("./");
10
30
  /** Encodes a transaction note into a byte array ready to be included in an Algorand transaction.
@@ -47,36 +67,65 @@ const getSenderAddress = function (sender) {
47
67
  return 'addr' in sender ? sender.addr : sender.address();
48
68
  };
49
69
  exports.getSenderAddress = getSenderAddress;
50
- /** Signs and sends the given transaction to the chain
70
+ const memoize = (fn) => {
71
+ const cache = new Map();
72
+ const cached = function (val) {
73
+ return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val);
74
+ };
75
+ cached.cache = cache;
76
+ return cached;
77
+ };
78
+ /**
79
+ * Returns a `TransactionSigner` for the given transaction sender.
80
+ * This function has memoization, so will return the same transaction signer for a given sender.
81
+ * @param sender A transaction sender
82
+ * @returns A transaction signer
83
+ */
84
+ exports.getSenderTransactionSigner = memoize(function (sender) {
85
+ return 'signer' in sender
86
+ ? sender.signer
87
+ : 'lsig' in sender
88
+ ? algosdk_1.default.makeLogicSigAccountTransactionSigner(sender)
89
+ : algosdk_1.default.makeBasicAccountTransactionSigner(sender);
90
+ });
91
+ /**
92
+ * Signs a single transaction by the given signer.
93
+ * @param transaction The transaction to sign
94
+ * @param signer The signer to sign
95
+ * @returns The signed transaction as a `Uint8Array`
96
+ */
97
+ const signTransaction = async (transaction, signer) => {
98
+ return 'sk' in signer
99
+ ? transaction.signTxn(signer.sk)
100
+ : 'lsig' in signer
101
+ ? algosdk_1.default.signLogicSigTransactionObject(transaction, signer).blob
102
+ : 'sign' in signer
103
+ ? signer.sign(transaction)
104
+ : (await signer.signer([transaction], [0]))[0];
105
+ };
106
+ exports.signTransaction = signTransaction;
107
+ /** Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain.
51
108
  *
52
- * @param send The details for the transaction to send, including:
109
+ * @param send The details for the transaction to prepare/send, including:
53
110
  * * `transaction`: The unsigned transaction
54
111
  * * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account
55
112
  * * `config`: The sending configuration for this transaction
56
113
  * @param algod An algod client
57
114
  *
58
- * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
115
+ * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`)
59
116
  */
60
117
  const sendTransaction = async function (send, algod) {
61
118
  const { transaction, from, sendParams } = send;
62
- const { skipSending, skipWaiting, fee, maxFee, suppressLog, maxRoundsToWaitForConfirmation } = sendParams ?? {};
63
- if (fee) {
64
- transaction.fee = fee.microAlgos;
65
- transaction.flatFee = true;
66
- }
67
- if (maxFee !== undefined) {
68
- capTransactionFee(transaction, maxFee);
119
+ const { skipSending, skipWaiting, fee, maxFee, suppressLog, maxRoundsToWaitForConfirmation, atc } = sendParams ?? {};
120
+ controlFees(transaction, { fee, maxFee });
121
+ if (atc) {
122
+ atc.addTransaction({ txn: transaction, signer: (0, exports.getSenderTransactionSigner)(from) });
123
+ return { transaction };
69
124
  }
70
125
  if (skipSending) {
71
126
  return { transaction };
72
127
  }
73
- const signedTransaction = 'sk' in from
74
- ? transaction.signTxn(from.sk)
75
- : 'lsig' in from
76
- ? algosdk_1.default.signLogicSigTransactionObject(transaction, from).blob
77
- : 'signer' in from
78
- ? (await from.signer([transaction], [0]))[0]
79
- : from.sign(transaction);
128
+ const signedTransaction = await (0, exports.signTransaction)(transaction, from);
80
129
  await algod.sendRawTransaction(signedTransaction).do();
81
130
  _1.Config.getLogger(suppressLog).info(`Sent transaction ID ${transaction.txID()} ${transaction.type} from ${(0, exports.getSenderAddress)(from)}`);
82
131
  let confirmation = undefined;
@@ -86,12 +135,89 @@ const sendTransaction = async function (send, algod) {
86
135
  return { transaction, confirmation };
87
136
  };
88
137
  exports.sendTransaction = sendTransaction;
89
- const groupBy = (array, predicate) => array.reduce((acc, value, id, array) => {
90
- var _a;
91
- ;
92
- (acc[_a = predicate(value, id, array)] || (acc[_a] = [])).push(value);
93
- return acc;
94
- }, {});
138
+ /**
139
+ * Signs and sends transactions that have been collected by an `AtomicTransactionComposer`.
140
+ * @param atcSend The parameters controlling the send, including:
141
+ * * `atc` The `AtomicTransactionComposer`
142
+ * * `sendParams` The parameters to control the send behaviour
143
+ * @param algod An algod client
144
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
145
+ */
146
+ const sendAtomicTransactionComposer = async function (atcSend, algod) {
147
+ const { atc, sendParams } = atcSend;
148
+ const transactionsWithSigner = atc.buildGroup();
149
+ const transactionsToSend = transactionsWithSigner.map((t) => {
150
+ return t.txn;
151
+ });
152
+ let groupId = undefined;
153
+ if (transactionsToSend.length > 1) {
154
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
155
+ groupId = transactionsToSend[0].group ? buffer_1.Buffer.from(transactionsToSend[0].group).toString('base64') : '';
156
+ _1.Config.getLogger(sendParams?.suppressLog).info(`Sending group of ${transactionsToSend.length} transactions (${groupId})`, {
157
+ transactionsToSend,
158
+ });
159
+ _1.Config.getLogger(sendParams?.suppressLog).debug(`Transaction IDs (${groupId})`, transactionsToSend.map((t) => t.txID()));
160
+ }
161
+ try {
162
+ const result = await atc.execute(algod, sendParams?.maxRoundsToWaitForConfirmation ?? 5);
163
+ if (transactionsToSend.length > 1) {
164
+ _1.Config.getLogger(sendParams?.suppressLog).info(`Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`);
165
+ }
166
+ else {
167
+ _1.Config.getLogger(sendParams?.suppressLog).info(`Sent transaction ID ${transactionsToSend[0].txID()} ${transactionsToSend[0].type} from ${algosdk_1.default.encodeAddress(transactionsToSend[0].from.publicKey)}`);
168
+ }
169
+ let confirmations = undefined;
170
+ if (!sendParams?.skipWaiting) {
171
+ confirmations = await Promise.all(transactionsToSend.map(async (t) => (await algod.pendingTransactionInformation(t.txID()).do())));
172
+ }
173
+ return {
174
+ groupId,
175
+ confirmations,
176
+ txIds: transactionsToSend.map((t) => t.txID()),
177
+ transactions: transactionsToSend,
178
+ returns: result.methodResults.map((r) => ({
179
+ decodeError: r.decodeError,
180
+ returnValue: r.returnValue,
181
+ rawReturnValue: r.rawReturnValue,
182
+ })),
183
+ };
184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
+ }
186
+ catch (e) {
187
+ if (_1.Config.debug && typeof e === 'object') {
188
+ e.traces = [];
189
+ _1.Config.logger.debug('Received error executing Atomic Transaction Composer and debug flag enabled; attempting dry run to get more information');
190
+ const dryrun = await performAtomicTransactionComposerDryrun(atc, algod);
191
+ for (const txn of dryrun.txns) {
192
+ if (txn.appCallRejected()) {
193
+ e.traces.push({
194
+ trace: txn.appTrace(),
195
+ cost: txn.cost,
196
+ logs: txn.logs,
197
+ messages: txn.appCallMessages,
198
+ });
199
+ }
200
+ }
201
+ }
202
+ throw e;
203
+ }
204
+ };
205
+ exports.sendAtomicTransactionComposer = sendAtomicTransactionComposer;
206
+ /**
207
+ * Performs a dry run of the transactions loaded into the given AtomicTransactionComposer`
208
+ * @param atc The AtomicTransactionComposer` with transaction(s) loaded
209
+ * @param algod An Algod client
210
+ * @returns The dryrun result
211
+ */
212
+ async function performAtomicTransactionComposerDryrun(atc, algod) {
213
+ const signedTransactions = await atc.gatherSignatures();
214
+ const txns = signedTransactions.map((t) => {
215
+ return algosdk_1.default.decodeSignedTransaction(t);
216
+ });
217
+ const dryrun = await algosdk_1.default.createDryrun({ client: algod, txns });
218
+ return new algosdk_1.default.DryrunResult(await algod.dryrun(dryrun).do());
219
+ }
220
+ exports.performAtomicTransactionComposerDryrun = performAtomicTransactionComposerDryrun;
95
221
  /**
96
222
  * Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain
97
223
  *
@@ -99,81 +225,32 @@ const groupBy = (array, predicate) => array.reduce((acc, value, id, array) => {
99
225
  * * `transactions`: The array of transactions to send along with their signing account
100
226
  * * `sendParams`: The parameters to dictate how the group is sent
101
227
  * @param algod An algod client
102
- * @returns An object with group transaction ID (`groupTransactionId`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
228
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
103
229
  */
104
230
  const sendGroupOfTransactions = async function (groupSend, algod) {
105
231
  const { transactions, signer, sendParams } = groupSend;
232
+ const defaultTransactionSigner = signer ? (0, exports.getSenderTransactionSigner)(signer) : undefined;
106
233
  const transactionsWithSigner = await Promise.all(transactions.map(async (t) => {
107
234
  if ('signer' in t)
108
- return t;
235
+ return {
236
+ txn: t.transaction,
237
+ signer: (0, exports.getSenderTransactionSigner)(t.signer),
238
+ sender: t.signer,
239
+ };
109
240
  const txn = 'then' in t ? (await t).transaction : t;
110
241
  if (!signer) {
111
- throw new Error(`Attempt to send transaction ${txn.txID()} as part of a group transaction, but no signer was provided.`);
242
+ throw new Error(`Attempt to send transaction ${txn.txID()} as part of a group transaction, but no signer parameter was provided.`);
112
243
  }
113
244
  return {
114
- transaction: txn,
115
- signer: signer,
245
+ txn,
246
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
247
+ signer: defaultTransactionSigner,
248
+ sender: signer,
116
249
  };
117
250
  }));
118
- const transactionsToSend = transactionsWithSigner.map((t) => {
119
- return t.transaction;
120
- });
121
- const group = algosdk_1.default.assignGroupID(transactionsToSend);
122
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
123
- const groupId = buffer_1.Buffer.from(group[0].group).toString('base64');
124
- _1.Config.getLogger(sendParams?.suppressLog).info(`Sending group of transactions (${groupId})`, { transactionsToSend });
125
- // Sign transactions either using TransactionSigners, or not
126
- let signedTransactions;
127
- if (transactionsWithSigner.find((t) => 'signer' in t.signer)) {
128
- // Validate all or nothing for transaction signers
129
- if (transactionsWithSigner.find((t) => !('signer' in t.signer))) {
130
- throw new Error("When issuing a group transaction the signers should either all be TransactionSignerAccount's or all not. " +
131
- 'Received at least one TransactionSignerAccount, but not all of them so failing the send.');
132
- }
133
- // Group transaction signers by signer
134
- const groupedBySigner = groupBy(transactionsWithSigner.map((t, i) => ({
135
- signer: t.signer,
136
- id: i,
137
- })), (t) => t.signer.addr);
138
- // Perform the signature, grouped by signer
139
- const signed = (await Promise.all(Object.values(groupedBySigner).map(async (signature) => {
140
- const indexes = signature.map((s) => s.id);
141
- const signed = await signature[0].signer.signer(group, indexes);
142
- return signed.map((txn, i) => ({
143
- txn,
144
- id: indexes[i],
145
- }));
146
- }))).flatMap((a) => a);
147
- // Extract the signed transactions in order
148
- signedTransactions = signed.sort((s1, s2) => s1.id - s2.id).map((s) => s.txn);
149
- }
150
- else {
151
- signedTransactions = group.map((groupedTransaction, id) => {
152
- const signer = transactionsWithSigner[id].signer;
153
- return 'sk' in signer
154
- ? groupedTransaction.signTxn(signer.sk)
155
- : 'lsig' in signer
156
- ? algosdk_1.default.signLogicSigTransactionObject(groupedTransaction, signer).blob
157
- : 'sign' in signer
158
- ? signer.sign(groupedTransaction)
159
- : // This bit will never happen because above if statement
160
- new Uint8Array();
161
- });
162
- }
163
- _1.Config.getLogger(sendParams?.suppressLog).debug(`Signer IDs (${groupId})`, transactionsWithSigner.map((t) => (0, exports.getSenderAddress)(t.signer)));
164
- _1.Config.getLogger(sendParams?.suppressLog).debug(`Transaction IDs (${groupId})`, transactionsToSend.map((t) => t.txID()));
165
- // https://developer.algorand.org/docs/rest-apis/algod/v2/#post-v2transactions
166
- await algod.sendRawTransaction(signedTransactions).do();
167
- _1.Config.getLogger(sendParams?.suppressLog).info(`Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`);
168
- let confirmations = undefined;
169
- if (!sendParams?.skipWaiting) {
170
- confirmations = await Promise.all(transactionsToSend.map(async (t) => await (0, exports.waitForConfirmation)(t.txID(), sendParams?.maxRoundsToWaitForConfirmation ?? 5, algod)));
171
- }
172
- return {
173
- groupId,
174
- confirmations,
175
- txIds: transactionsToSend.map((t) => t.txID()),
176
- };
251
+ const atc = new algosdk_1.AtomicTransactionComposer();
252
+ transactionsWithSigner.forEach((txn) => atc.addTransaction(txn));
253
+ return (await (0, exports.sendAtomicTransactionComposer)({ atc, sendParams }, algod));
177
254
  };
178
255
  exports.sendGroupOfTransactions = sendGroupOfTransactions;
179
256
  /**
@@ -224,7 +301,7 @@ exports.waitForConfirmation = waitForConfirmation;
224
301
  * Limit the acceptable fee to a defined amount of µALGOs.
225
302
  * This also sets the transaction to be flatFee to ensure the transaction only succeeds at
226
303
  * the estimated rate.
227
- * @param transaction The transaction to cap
304
+ * @param transaction The transaction to cap or suggested params object about to be used to create a transaction
228
305
  * @param maxAcceptableFee The maximum acceptable fee to pay
229
306
  */
230
307
  function capTransactionFee(transaction, maxAcceptableFee) {
@@ -243,6 +320,23 @@ function capTransactionFee(transaction, maxAcceptableFee) {
243
320
  }
244
321
  }
245
322
  exports.capTransactionFee = capTransactionFee;
323
+ /**
324
+ * Allows for control of fees on a `Transaction` or `SuggestedParams` object
325
+ * @param transaction The transaction or suggested params
326
+ * @param feeControl The fee control parameters
327
+ */
328
+ function controlFees(transaction, feeControl) {
329
+ const { fee, maxFee } = feeControl;
330
+ if (fee) {
331
+ transaction.fee = fee.microAlgos;
332
+ transaction.flatFee = true;
333
+ }
334
+ if (maxFee !== undefined) {
335
+ capTransactionFee(transaction, maxFee);
336
+ }
337
+ return transaction;
338
+ }
339
+ exports.controlFees = controlFees;
246
340
  /**
247
341
  * Returns suggested transaction parameters from algod unless some are already provided.
248
342
  * @param params Optionally provide parameters to use
@@ -250,7 +344,21 @@ exports.capTransactionFee = capTransactionFee;
250
344
  * @returns The suggested transaction parameters
251
345
  */
252
346
  async function getTransactionParams(params, algod) {
253
- return params ?? (await algod.getTransactionParams().do());
347
+ return params ? { ...params } : await algod.getTransactionParams().do();
254
348
  }
255
349
  exports.getTransactionParams = getTransactionParams;
350
+ /**
351
+ * Returns the array of transactions currently present in the given `AtomicTransactionComposer`
352
+ * @param atc The atomic transaction composer
353
+ * @returns The array of transactions with signers
354
+ */
355
+ function getAtomicTransactionComposerTransactions(atc) {
356
+ try {
357
+ return atc.clone().buildGroup();
358
+ }
359
+ catch {
360
+ return [];
361
+ }
362
+ }
363
+ exports.getAtomicTransactionComposerTransactions = getAtomicTransactionComposerTransactions;
256
364
  //# sourceMappingURL=transaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwE;AACxE,mCAA+B;AAC/B,yBAA2B;AAY3B;;;;;;;;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 } from 'algosdk';
1
+ import { Algodv2, Kmd } from 'algosdk';
2
2
  import { SendTransactionResult } from './types/transaction';
3
3
  import { AlgoTransferParams, EnsureFundedParams } from './types/transfer';
4
4
  /**
@@ -11,11 +11,12 @@ export declare function transferAlgos(transfer: AlgoTransferParams, algod: Algod
11
11
  /**
12
12
  * Funds a given account using a funding source such that it has a certain amount of algos free to spend (accounting for ALGOs locked in minimum balance requirement).
13
13
  *
14
- * @see https://developer.algorand.org/docs/get-details/accounts/#minimum-balance
14
+ * https://developer.algorand.org/docs/get-details/accounts/#minimum-balance
15
15
  *
16
16
  * @param funding The funding configuration
17
17
  * @param algod An algod client
18
+ * @param kmd An optional kmd client
18
19
  * @returns undefined if nothing was needed or the transaction send result
19
20
  */
20
- export declare function ensureFunded(funding: EnsureFundedParams, algod: Algodv2): Promise<SendTransactionResult | undefined>;
21
+ export declare function ensureFunded(funding: EnsureFundedParams, algod: Algodv2, kmd?: Kmd): Promise<SendTransactionResult | undefined>;
21
22
  //# sourceMappingURL=transfer.d.ts.map
package/transfer.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAG1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAEzE;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBhH;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAgC1H"}
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAG/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAEzE;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBhH;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAiCrI"}
package/transfer.js CHANGED
@@ -17,7 +17,7 @@ async function transferAlgos(transfer, algod) {
17
17
  const { from, to, amount, note, transactionParams, ...sendParams } = transfer;
18
18
  const transaction = algosdk_1.default.makePaymentTxnWithSuggestedParamsFromObject({
19
19
  from: (0, transaction_1.getSenderAddress)(from),
20
- to: to,
20
+ to: typeof to === 'string' ? to : (0, transaction_1.getSenderAddress)(to),
21
21
  amount: amount.microAlgos,
22
22
  note: (0, transaction_1.encodeTransactionNote)(note),
23
23
  suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
@@ -33,25 +33,27 @@ exports.transferAlgos = transferAlgos;
33
33
  /**
34
34
  * Funds a given account using a funding source such that it has a certain amount of algos free to spend (accounting for ALGOs locked in minimum balance requirement).
35
35
  *
36
- * @see https://developer.algorand.org/docs/get-details/accounts/#minimum-balance
36
+ * https://developer.algorand.org/docs/get-details/accounts/#minimum-balance
37
37
  *
38
38
  * @param funding The funding configuration
39
39
  * @param algod An algod client
40
+ * @param kmd An optional kmd client
40
41
  * @returns undefined if nothing was needed or the transaction send result
41
42
  */
42
- async function ensureFunded(funding, algod) {
43
+ async function ensureFunded(funding, algod, kmd) {
43
44
  const { accountToFund, fundingSource, minSpendingBalance, minFundingIncrement, transactionParams, note, ...sendParams } = funding;
44
45
  const addressToFund = typeof accountToFund === 'string' ? accountToFund : (0, transaction_1.getSenderAddress)(accountToFund);
45
46
  const accountInfo = await algod.accountInformation(addressToFund).do();
46
47
  const balance = Number(accountInfo.amount);
47
48
  const minimumBalanceRequirement = (0, _1.microAlgos)(Number(accountInfo['min-balance']));
48
- const currentSpendingBalance = (0, _1.microAlgos)(balance - +minimumBalanceRequirement);
49
+ const currentSpendingBalance = (0, _1.microAlgos)(balance - minimumBalanceRequirement.microAlgos);
49
50
  if (minSpendingBalance > currentSpendingBalance) {
50
- const minFundAmount = (0, _1.microAlgos)(+minSpendingBalance - +currentSpendingBalance);
51
- const fundAmount = (0, _1.microAlgos)(Math.max(+minFundAmount, minFundingIncrement?.microAlgos ?? 0));
52
- _1.Config.getLogger(sendParams.suppressLog).info(`Funding ${addressToFund} ${fundAmount} from ${(0, transaction_1.getSenderAddress)(fundingSource)} to reach minimum spend amount of ${minSpendingBalance} (balance = ${balance}, min_balance_req = ${minimumBalanceRequirement})`);
51
+ const from = fundingSource ?? (await (0, _1.getDispenserAccount)(algod, kmd));
52
+ const minFundAmount = (0, _1.microAlgos)(minSpendingBalance.microAlgos - currentSpendingBalance.microAlgos);
53
+ const fundAmount = (0, _1.microAlgos)(Math.max(minFundAmount.microAlgos, minFundingIncrement?.microAlgos ?? 0));
54
+ _1.Config.getLogger(sendParams.suppressLog).info(`Funding ${addressToFund} ${fundAmount} from ${(0, transaction_1.getSenderAddress)(from)} to reach minimum spend amount of ${minSpendingBalance} (balance = ${balance}, min_balance_req = ${minimumBalanceRequirement})`);
53
55
  return await transferAlgos({
54
- from: fundingSource,
56
+ from,
55
57
  to: addressToFund,
56
58
  note: note ?? 'Funding account to meet minimum requirement',
57
59
  amount: fundAmount,