algosdk 1.11.0 → 1.13.0-beta.2

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 (138) hide show
  1. package/README.md +17 -6
  2. package/dist/browser/algosdk.min.js +1 -1
  3. package/dist/browser/algosdk.min.js.map +1 -1
  4. package/dist/cjs/src/abi/abi_type.js +693 -0
  5. package/dist/cjs/src/abi/abi_type.js.map +1 -0
  6. package/dist/cjs/src/abi/contract.js +27 -0
  7. package/dist/cjs/src/abi/contract.js.map +1 -0
  8. package/dist/cjs/src/abi/index.js +19 -0
  9. package/dist/cjs/src/abi/index.js.map +1 -0
  10. package/dist/cjs/src/abi/interface.js +23 -0
  11. package/dist/cjs/src/abi/interface.js.map +1 -0
  12. package/dist/cjs/src/abi/method.js +114 -0
  13. package/dist/cjs/src/abi/method.js.map +1 -0
  14. package/dist/cjs/src/abi/reference.js +25 -0
  15. package/dist/cjs/src/abi/reference.js.map +1 -0
  16. package/dist/cjs/src/abi/transaction.js +52 -0
  17. package/dist/cjs/src/abi/transaction.js.map +1 -0
  18. package/dist/cjs/src/client/baseHTTPClient.js +3 -0
  19. package/dist/cjs/src/client/baseHTTPClient.js.map +1 -0
  20. package/dist/cjs/src/client/client.js +165 -104
  21. package/dist/cjs/src/client/client.js.map +1 -1
  22. package/dist/cjs/src/client/urlTokenBaseHTTPClient.js +138 -0
  23. package/dist/cjs/src/client/urlTokenBaseHTTPClient.js.map +1 -0
  24. package/dist/cjs/src/client/v2/algod/algod.js +7 -2
  25. package/dist/cjs/src/client/v2/algod/algod.js.map +1 -1
  26. package/dist/cjs/src/client/v2/algod/models/types.js +18 -12
  27. package/dist/cjs/src/client/v2/algod/models/types.js.map +1 -1
  28. package/dist/cjs/src/client/v2/indexer/indexer.js +15 -2
  29. package/dist/cjs/src/client/v2/indexer/indexer.js.map +1 -1
  30. package/dist/cjs/src/client/v2/indexer/lookupApplicationLogs.js +48 -0
  31. package/dist/cjs/src/client/v2/indexer/lookupApplicationLogs.js.map +1 -0
  32. package/dist/cjs/src/client/v2/serviceClient.js +17 -8
  33. package/dist/cjs/src/client/v2/serviceClient.js.map +1 -1
  34. package/dist/cjs/src/composer.js +439 -0
  35. package/dist/cjs/src/composer.js.map +1 -0
  36. package/dist/cjs/src/encoding/address.js +14 -1
  37. package/dist/cjs/src/encoding/address.js.map +1 -1
  38. package/dist/cjs/src/encoding/bigint.js +38 -0
  39. package/dist/cjs/src/encoding/bigint.js.map +1 -0
  40. package/dist/cjs/src/logic/langspec.json +392 -77
  41. package/dist/cjs/src/logicsig.js +2 -2
  42. package/dist/cjs/src/logicsig.js.map +1 -1
  43. package/dist/cjs/src/main.js +17 -91
  44. package/dist/cjs/src/main.js.map +1 -1
  45. package/dist/cjs/src/makeTxn.js +29 -1
  46. package/dist/cjs/src/makeTxn.js.map +1 -1
  47. package/dist/cjs/src/multisig.js +77 -2
  48. package/dist/cjs/src/multisig.js.map +1 -1
  49. package/dist/cjs/src/signer.js +66 -0
  50. package/dist/cjs/src/signer.js.map +1 -0
  51. package/dist/cjs/src/transaction.js +53 -10
  52. package/dist/cjs/src/transaction.js.map +1 -1
  53. package/dist/cjs/src/types/intDecoding.js +0 -2
  54. package/dist/cjs/src/types/intDecoding.js.map +1 -1
  55. package/dist/cjs/src/types/transactions/base.js +0 -1
  56. package/dist/cjs/src/types/transactions/base.js.map +1 -1
  57. package/dist/cjs/src/wait.js +53 -0
  58. package/dist/cjs/src/wait.js.map +1 -0
  59. package/dist/esm/src/abi/abi_type.js +680 -0
  60. package/dist/esm/src/abi/abi_type.js.map +1 -0
  61. package/dist/esm/src/abi/contract.js +23 -0
  62. package/dist/esm/src/abi/contract.js.map +1 -0
  63. package/dist/esm/src/abi/index.js +7 -0
  64. package/dist/esm/src/abi/index.js.map +1 -0
  65. package/dist/esm/src/abi/interface.js +19 -0
  66. package/dist/esm/src/abi/interface.js.map +1 -0
  67. package/dist/esm/src/abi/method.js +110 -0
  68. package/dist/esm/src/abi/method.js.map +1 -0
  69. package/dist/esm/src/abi/reference.js +21 -0
  70. package/dist/esm/src/abi/reference.js.map +1 -0
  71. package/dist/esm/src/abi/transaction.js +47 -0
  72. package/dist/esm/src/abi/transaction.js.map +1 -0
  73. package/dist/esm/src/client/baseHTTPClient.js +2 -0
  74. package/dist/esm/src/client/baseHTTPClient.js.map +1 -0
  75. package/dist/esm/src/client/client.js +165 -101
  76. package/dist/esm/src/client/client.js.map +1 -1
  77. package/dist/esm/src/client/urlTokenBaseHTTPClient.js +112 -0
  78. package/dist/esm/src/client/urlTokenBaseHTTPClient.js.map +1 -0
  79. package/dist/esm/src/client/v2/algod/algod.js +7 -2
  80. package/dist/esm/src/client/v2/algod/algod.js.map +1 -1
  81. package/dist/esm/src/client/v2/algod/models/types.js +18 -12
  82. package/dist/esm/src/client/v2/algod/models/types.js.map +1 -1
  83. package/dist/esm/src/client/v2/indexer/indexer.js +15 -2
  84. package/dist/esm/src/client/v2/indexer/indexer.js.map +1 -1
  85. package/dist/esm/src/client/v2/indexer/lookupApplicationLogs.js +42 -0
  86. package/dist/esm/src/client/v2/indexer/lookupApplicationLogs.js.map +1 -0
  87. package/dist/esm/src/client/v2/serviceClient.js +17 -8
  88. package/dist/esm/src/client/v2/serviceClient.js.map +1 -1
  89. package/dist/esm/src/composer.js +435 -0
  90. package/dist/esm/src/composer.js.map +1 -0
  91. package/dist/esm/src/encoding/address.js +12 -0
  92. package/dist/esm/src/encoding/address.js.map +1 -1
  93. package/dist/esm/src/encoding/bigint.js +33 -0
  94. package/dist/esm/src/encoding/bigint.js.map +1 -0
  95. package/dist/esm/src/logic/langspec.json +392 -77
  96. package/dist/esm/src/logicsig.js +2 -2
  97. package/dist/esm/src/logicsig.js.map +1 -1
  98. package/dist/esm/src/main.js +7 -85
  99. package/dist/esm/src/main.js.map +1 -1
  100. package/dist/esm/src/makeTxn.js +27 -0
  101. package/dist/esm/src/makeTxn.js.map +1 -1
  102. package/dist/esm/src/multisig.js +73 -1
  103. package/dist/esm/src/multisig.js.map +1 -1
  104. package/dist/esm/src/signer.js +59 -0
  105. package/dist/esm/src/signer.js.map +1 -0
  106. package/dist/esm/src/transaction.js +53 -10
  107. package/dist/esm/src/transaction.js.map +1 -1
  108. package/dist/esm/src/types/intDecoding.js +0 -2
  109. package/dist/esm/src/types/intDecoding.js.map +1 -1
  110. package/dist/esm/src/types/transactions/base.js +0 -1
  111. package/dist/esm/src/types/transactions/base.js.map +1 -1
  112. package/dist/esm/src/wait.js +49 -0
  113. package/dist/esm/src/wait.js.map +1 -0
  114. package/dist/types/src/abi/abi_type.d.ts +102 -0
  115. package/dist/types/src/abi/contract.d.ts +21 -0
  116. package/dist/types/src/abi/index.d.ts +6 -0
  117. package/dist/types/src/abi/interface.d.ts +13 -0
  118. package/dist/types/src/abi/method.d.ts +39 -0
  119. package/dist/types/src/abi/reference.d.ts +15 -0
  120. package/dist/types/src/abi/transaction.d.ts +33 -0
  121. package/dist/types/src/client/baseHTTPClient.d.ts +41 -0
  122. package/dist/types/src/client/client.d.ts +67 -31
  123. package/dist/types/src/client/kmd.d.ts +1 -1
  124. package/dist/types/src/client/urlTokenBaseHTTPClient.d.ts +44 -0
  125. package/dist/types/src/client/v2/algod/algod.d.ts +8 -2
  126. package/dist/types/src/client/v2/algod/models/types.d.ts +29 -14
  127. package/dist/types/src/client/v2/indexer/indexer.d.ts +14 -2
  128. package/dist/types/src/client/v2/indexer/lookupApplicationLogs.d.ts +20 -0
  129. package/dist/types/src/client/v2/serviceClient.d.ts +4 -2
  130. package/dist/types/src/composer.d.ts +160 -0
  131. package/dist/types/src/encoding/address.d.ts +6 -0
  132. package/dist/types/src/encoding/bigint.d.ts +14 -0
  133. package/dist/types/src/main.d.ts +8 -48
  134. package/dist/types/src/makeTxn.d.ts +18 -1
  135. package/dist/types/src/multisig.d.ts +39 -1
  136. package/dist/types/src/signer.d.ts +40 -0
  137. package/dist/types/src/wait.d.ts +11 -0
  138. package/package.json +6 -4
@@ -0,0 +1,44 @@
1
+ import { BaseHTTPClient, BaseHTTPClientResponse, Query } from './baseHTTPClient';
2
+ export interface AlgodTokenHeader {
3
+ 'X-Algo-API-Token': string;
4
+ }
5
+ export interface IndexerTokenHeader {
6
+ 'X-Indexer-API-Token': string;
7
+ }
8
+ export interface KMDTokenHeader {
9
+ 'X-KMD-API-Token': string;
10
+ }
11
+ export interface CustomTokenHeader {
12
+ [headerName: string]: string;
13
+ }
14
+ export declare type TokenHeader = AlgodTokenHeader | IndexerTokenHeader | KMDTokenHeader | CustomTokenHeader;
15
+ /**
16
+ * Implementation of BaseHTTPClient that uses a URL and a token
17
+ * and make the REST queries using superagent.
18
+ * This is the default implementation of BaseHTTPClient.
19
+ */
20
+ export declare class URLTokenBaseHTTPClient implements BaseHTTPClient {
21
+ private defaultHeaders;
22
+ private readonly baseURL;
23
+ private readonly tokenHeader;
24
+ constructor(tokenHeader: TokenHeader, baseServer: string, port?: string | number, defaultHeaders?: Record<string, any>);
25
+ /**
26
+ * Compute the URL for a path relative to the instance's address
27
+ * @param relativePath - A path string
28
+ * @returns A URL string
29
+ */
30
+ private addressWithPath;
31
+ /**
32
+ * Convert a superagent response to a valid BaseHTTPClientResponse
33
+ * Modify the superagent response
34
+ * @private
35
+ */
36
+ private static superagentToHTTPClientResponse;
37
+ /**
38
+ * Make a superagent error more readable. For more info, see https://github.com/visionmedia/superagent/issues/1074
39
+ */
40
+ private static formatSuperagentError;
41
+ get(relativePath: string, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
42
+ post(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
43
+ delete(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
44
+ }
@@ -1,5 +1,4 @@
1
1
  import ServiceClient from '../serviceClient';
2
- import { AlgodTokenHeader, CustomTokenHeader } from '../../client';
3
2
  import * as modelsv2 from './models/types';
4
3
  import AccountInformation from './accountInformation';
5
4
  import Block from './block';
@@ -19,8 +18,15 @@ import Supply from './supply';
19
18
  import Versions from './versions';
20
19
  import Genesis from './genesis';
21
20
  import Proof from './proof';
21
+ import { BaseHTTPClient } from '../../baseHTTPClient';
22
+ import { AlgodTokenHeader, CustomTokenHeader } from '../../urlTokenBaseHTTPClient';
22
23
  export default class AlgodClient extends ServiceClient {
23
- constructor(token: string | AlgodTokenHeader | CustomTokenHeader, baseServer?: string, port?: string | number, headers?: {});
24
+ /**
25
+ * Create an AlgodClient from
26
+ * * either a token, baseServer, port, and optional headers
27
+ * * or a base client server for interoperability with external dApp wallets
28
+ */
29
+ constructor(tokenOrBaseClient: string | AlgodTokenHeader | CustomTokenHeader | BaseHTTPClient, baseServer?: string, port?: string | number, headers?: Record<string, string>);
24
30
  healthCheck(): HealthCheck;
25
31
  versionsCheck(): Versions;
26
32
  sendRawTransaction(stxOrStxs: Uint8Array | Uint8Array[]): SendRawTransaction;
@@ -286,7 +286,7 @@ export declare class ApplicationParams extends BaseModel {
286
286
  */
287
287
  globalState?: TealKeyValue[];
288
288
  /**
289
- * [\lsch) global schema
289
+ * [\gsch) global schema
290
290
  */
291
291
  globalStateSchema?: ApplicationStateSchema;
292
292
  /**
@@ -301,7 +301,7 @@ export declare class ApplicationParams extends BaseModel {
301
301
  * parameters and global state for this application can be found.
302
302
  * @param extraProgramPages - (epp) the amount of extra program pages available to this app.
303
303
  * @param globalState - [\gs) global schema
304
- * @param globalStateSchema - [\lsch) global schema
304
+ * @param globalStateSchema - [\gsch) global schema
305
305
  * @param localStateSchema - [\lsch) local schema
306
306
  */
307
307
  constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, }: {
@@ -746,6 +746,10 @@ export declare class DryrunTxnResult extends BaseModel {
746
746
  disassembly: string[];
747
747
  appCallMessages?: string[];
748
748
  appCallTrace?: DryrunState[];
749
+ /**
750
+ * Execution cost of app call transaction
751
+ */
752
+ cost?: number | bigint;
749
753
  /**
750
754
  * Application state delta.
751
755
  */
@@ -753,24 +757,29 @@ export declare class DryrunTxnResult extends BaseModel {
753
757
  localDeltas?: AccountStateDelta[];
754
758
  logicSigMessages?: string[];
755
759
  logicSigTrace?: DryrunState[];
760
+ logs?: Uint8Array[];
756
761
  /**
757
762
  * Creates a new `DryrunTxnResult` object.
758
763
  * @param disassembly - Disassembled program line by line.
759
764
  * @param appCallMessages -
760
765
  * @param appCallTrace -
766
+ * @param cost - Execution cost of app call transaction
761
767
  * @param globalDelta - Application state delta.
762
768
  * @param localDeltas -
763
769
  * @param logicSigMessages -
764
770
  * @param logicSigTrace -
771
+ * @param logs -
765
772
  */
766
- constructor({ disassembly, appCallMessages, appCallTrace, globalDelta, localDeltas, logicSigMessages, logicSigTrace, }: {
773
+ constructor({ disassembly, appCallMessages, appCallTrace, cost, globalDelta, localDeltas, logicSigMessages, logicSigTrace, logs, }: {
767
774
  disassembly: string[];
768
775
  appCallMessages?: string[];
769
776
  appCallTrace?: DryrunState[];
777
+ cost?: number | bigint;
770
778
  globalDelta?: EvalDeltaKeyValue[];
771
779
  localDeltas?: AccountStateDelta[];
772
780
  logicSigMessages?: string[];
773
781
  logicSigTrace?: DryrunState[];
782
+ logs?: Uint8Array[];
774
783
  });
775
784
  }
776
785
  /**
@@ -939,14 +948,8 @@ export declare class NodeStatusResponse extends BaseModel {
939
948
  });
940
949
  }
941
950
  /**
942
- * Given a transaction id of a recently submitted transaction, it returns
943
- * information about it. There are several cases when this might succeed:
944
- * - transaction committed (committed round > 0)
945
- * - transaction still in the pool (committed round = 0, pool error = "")
946
- * - transaction removed from pool due to error (committed round = 0, pool error !=
947
- * "")
948
- * Or the transaction may have happened sufficiently long ago that the node no
949
- * longer remembers it, and this will return an error.
951
+ * Details about a pending transaction. If the transaction was recently confirmed,
952
+ * includes confirmation details like the round and reward details.
950
953
  */
951
954
  export declare class PendingTransactionResponse extends BaseModel {
952
955
  /**
@@ -989,11 +992,19 @@ export declare class PendingTransactionResponse extends BaseModel {
989
992
  * transaction.
990
993
  */
991
994
  globalStateDelta?: EvalDeltaKeyValue[];
995
+ /**
996
+ * Inner transactions produced by application execution.
997
+ */
998
+ innerTxns?: PendingTransactionResponse[];
992
999
  /**
993
1000
  * (ld) Local state key/value changes for the application being executed by this
994
1001
  * transaction.
995
1002
  */
996
1003
  localStateDelta?: AccountStateDelta[];
1004
+ /**
1005
+ * (lg) Logs for the application being executed by this transaction.
1006
+ */
1007
+ logs?: Uint8Array[];
997
1008
  /**
998
1009
  * Rewards in microalgos applied to the receiver account.
999
1010
  */
@@ -1017,12 +1028,14 @@ export declare class PendingTransactionResponse extends BaseModel {
1017
1028
  * @param confirmedRound - The round where this transaction was confirmed, if present.
1018
1029
  * @param globalStateDelta - (gd) Global state key/value changes for the application being executed by this
1019
1030
  * transaction.
1031
+ * @param innerTxns - Inner transactions produced by application execution.
1020
1032
  * @param localStateDelta - (ld) Local state key/value changes for the application being executed by this
1021
1033
  * transaction.
1034
+ * @param logs - (lg) Logs for the application being executed by this transaction.
1022
1035
  * @param receiverRewards - Rewards in microalgos applied to the receiver account.
1023
1036
  * @param senderRewards - Rewards in microalgos applied to the sender account.
1024
1037
  */
1025
- constructor({ poolError, txn, applicationIndex, assetClosingAmount, assetIndex, closeRewards, closingAmount, confirmedRound, globalStateDelta, localStateDelta, receiverRewards, senderRewards, }: {
1038
+ constructor({ poolError, txn, applicationIndex, assetClosingAmount, assetIndex, closeRewards, closingAmount, confirmedRound, globalStateDelta, innerTxns, localStateDelta, logs, receiverRewards, senderRewards, }: {
1026
1039
  poolError: string;
1027
1040
  txn: EncodedSignedTransaction;
1028
1041
  applicationIndex?: number | bigint;
@@ -1032,7 +1045,9 @@ export declare class PendingTransactionResponse extends BaseModel {
1032
1045
  closingAmount?: number | bigint;
1033
1046
  confirmedRound?: number | bigint;
1034
1047
  globalStateDelta?: EvalDeltaKeyValue[];
1048
+ innerTxns?: PendingTransactionResponse[];
1035
1049
  localStateDelta?: AccountStateDelta[];
1050
+ logs?: Uint8Array[];
1036
1051
  receiverRewards?: number | bigint;
1037
1052
  senderRewards?: number | bigint;
1038
1053
  });
@@ -1141,7 +1156,7 @@ export declare class TealKeyValue extends BaseModel {
1141
1156
  */
1142
1157
  export declare class TealValue extends BaseModel {
1143
1158
  /**
1144
- * (tt) value type.
1159
+ * (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint**
1145
1160
  */
1146
1161
  type: number | bigint;
1147
1162
  /**
@@ -1154,7 +1169,7 @@ export declare class TealValue extends BaseModel {
1154
1169
  uint: number | bigint;
1155
1170
  /**
1156
1171
  * Creates a new `TealValue` object.
1157
- * @param type - (tt) value type.
1172
+ * @param type - (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint**
1158
1173
  * @param bytes - (tb) bytes value.
1159
1174
  * @param uint - (ui) uint value.
1160
1175
  */
@@ -1,5 +1,4 @@
1
1
  import ServiceClient from '../serviceClient';
2
- import { CustomTokenHeader, IndexerTokenHeader } from '../../client';
3
2
  import MakeHealthCheck from './makeHealthCheck';
4
3
  import LookupAssetBalances from './lookupAssetBalances';
5
4
  import LookupAssetTransactions from './lookupAssetTransactions';
@@ -9,12 +8,20 @@ import LookupTransactionByID from './lookupTransactionByID';
9
8
  import LookupAccountByID from './lookupAccountByID';
10
9
  import LookupAssetByID from './lookupAssetByID';
11
10
  import LookupApplications from './lookupApplications';
11
+ import LookupApplicationLogs from './lookupApplicationLogs';
12
12
  import SearchAccounts from './searchAccounts';
13
13
  import SearchForTransactions from './searchForTransactions';
14
14
  import SearchForAssets from './searchForAssets';
15
15
  import SearchForApplications from './searchForApplications';
16
+ import { BaseHTTPClient } from '../../baseHTTPClient';
17
+ import { CustomTokenHeader, IndexerTokenHeader } from '../../urlTokenBaseHTTPClient';
16
18
  export default class IndexerClient extends ServiceClient {
17
- constructor(token: string | IndexerTokenHeader | CustomTokenHeader, baseServer?: string, port?: string | number, headers?: {});
19
+ /**
20
+ * Create an IndexerClient from
21
+ * * either a token, baseServer, port, and optional headers
22
+ * * or a base client server for interoperability with external dApp wallets
23
+ */
24
+ constructor(tokenOrBaseClient: string | IndexerTokenHeader | CustomTokenHeader | BaseHTTPClient, baseServer?: string, port?: string | number, headers?: Record<string, string>);
18
25
  /**
19
26
  * Returns the health object for the service.
20
27
  */
@@ -59,6 +66,11 @@ export default class IndexerClient extends ServiceClient {
59
66
  * @param index - The ID of the application to look up.
60
67
  */
61
68
  lookupApplications(index: number): LookupApplications;
69
+ /**
70
+ * Returns log messages generated by the passed in application.
71
+ * @param appID - The ID of the application which generated the logs.
72
+ */
73
+ lookupApplicationLogs(appID: number): LookupApplicationLogs;
62
74
  /**
63
75
  * Returns information about indexed accounts.
64
76
  */
@@ -0,0 +1,20 @@
1
+ import JSONRequest from '../jsonrequest';
2
+ import HTTPClient from '../../client';
3
+ import IntDecoding from '../../../types/intDecoding';
4
+ export default class LookupApplicationLogs extends JSONRequest {
5
+ private appID;
6
+ constructor(c: HTTPClient, intDecoding: IntDecoding, appID: number);
7
+ path(): string;
8
+ /** limit for filter, as int */
9
+ limit(limit: number): this;
10
+ /** min round to filter with, as int */
11
+ minRound(round: number): this;
12
+ /** max round to filter with, as int */
13
+ maxRound(round: number): this;
14
+ /** used for pagination */
15
+ nextToken(nextToken: string): this;
16
+ /** only include transactions with this sender address */
17
+ sender(senderAddress: string): this;
18
+ /** txid to filter with, as string */
19
+ txid(txid: string): this;
20
+ }
@@ -1,5 +1,7 @@
1
- import HTTPClient, { TokenHeader } from '../client';
1
+ import HTTPClient from '../client';
2
2
  import IntDecoding from '../../types/intDecoding';
3
+ import { BaseHTTPClient } from '../baseHTTPClient';
4
+ import { TokenHeader } from '../urlTokenBaseHTTPClient';
3
5
  export declare type TokenHeaderIdentifier = 'X-Indexer-API-Token' | 'X-KMD-API-Token' | 'X-Algo-API-Token' | string;
4
6
  /**
5
7
  * Abstract service client to encapsulate shared AlgodClient and IndexerClient logic
@@ -7,7 +9,7 @@ export declare type TokenHeaderIdentifier = 'X-Indexer-API-Token' | 'X-KMD-API-T
7
9
  export default abstract class ServiceClient {
8
10
  c: HTTPClient;
9
11
  intDecoding: IntDecoding;
10
- constructor(tokenHeaderIdentifier: TokenHeaderIdentifier, tokenHeaderOrStr: string | TokenHeader, baseServer: string, port?: string | number, defaultHeaders?: Record<string, any>);
12
+ constructor(tokenHeaderIdentifier: TokenHeaderIdentifier, tokenHeaderOrStrOrBaseClient: string | TokenHeader | BaseHTTPClient, baseServer: string, port?: string | number, defaultHeaders?: Record<string, any>);
11
13
  /**
12
14
  * Set the default int decoding method for all JSON requests this client creates.
13
15
  * @param method - \{"default" | "safe" | "mixed" | "bigint"\} method The method to use when parsing the
@@ -0,0 +1,160 @@
1
+ import { ABIValue, ABIMethod } from './abi';
2
+ import Algodv2 from './client/v2/algod/algod';
3
+ import { TransactionSigner, TransactionWithSigner } from './signer';
4
+ import { OnApplicationComplete, SuggestedParams } from './types/transactions/base';
5
+ export declare type ABIArgument = ABIValue | TransactionWithSigner;
6
+ /** Represents the output from a successful ABI method call. */
7
+ export interface ABIResult {
8
+ /** The TxID of the transaction that invoked the ABI method call. */
9
+ txID: string;
10
+ /**
11
+ * The raw bytes of the return value from the ABI method call. This will be empty if the method
12
+ * does not return a value (return type "void").
13
+ */
14
+ rawReturnValue: Uint8Array;
15
+ /**
16
+ * The return value from the ABI method call. This will be undefined if the method does not return
17
+ * a value (return type "void"), or if the SDK was unable to decode the returned value.
18
+ */
19
+ returnValue?: ABIValue;
20
+ /** If the SDK was unable to decode a return value, the error will be here. */
21
+ decodeError?: Error;
22
+ }
23
+ export declare enum AtomicTransactionComposerStatus {
24
+ /** The atomic group is still under construction. */
25
+ BUILDING = 0,
26
+ /** The atomic group has been finalized, but not yet signed. */
27
+ BUILT = 1,
28
+ /** The atomic group has been finalized and signed, but not yet submitted to the network. */
29
+ SIGNED = 2,
30
+ /** The atomic group has been finalized, signed, and submitted to the network. */
31
+ SUBMITTED = 3,
32
+ /** The atomic group has been finalized, signed, submitted, and successfully committed to a block. */
33
+ COMMITTED = 4
34
+ }
35
+ /** A class used to construct and execute atomic transaction groups */
36
+ export declare class AtomicTransactionComposer {
37
+ /** The maximum size of an atomic transaction group. */
38
+ static MAX_GROUP_SIZE: number;
39
+ private status;
40
+ private transactions;
41
+ private methodCalls;
42
+ private signedTxns;
43
+ private txIDs;
44
+ /**
45
+ * Get the status of this composer's transaction group.
46
+ */
47
+ getStatus(): AtomicTransactionComposerStatus;
48
+ /**
49
+ * Get the number of transactions currently in this atomic group.
50
+ */
51
+ count(): number;
52
+ /**
53
+ * Create a new composer with the same underlying transactions. The new composer's status will be
54
+ * BUILDING, so additional transactions may be added to it.
55
+ */
56
+ clone(): AtomicTransactionComposer;
57
+ /**
58
+ * Add a transaction to this atomic group.
59
+ *
60
+ * An error will be thrown if the transaction has a nonzero group ID, the composer's status is
61
+ * not BUILDING, or if adding this transaction causes the current group to exceed MAX_GROUP_SIZE.
62
+ */
63
+ addTransaction(txnAndSigner: TransactionWithSigner): void;
64
+ /**
65
+ * Add a smart contract method call to this atomic group.
66
+ *
67
+ * An error will be thrown if the composer's status is not BUILDING, if adding this transaction
68
+ * causes the current group to exceed MAX_GROUP_SIZE, or if the provided arguments are invalid
69
+ * for the given method.
70
+ */
71
+ addMethodCall({ appID, method, methodArgs, sender, suggestedParams, onComplete, approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages, note, lease, rekeyTo, signer, }: {
72
+ /** The ID of the smart contract to call. Set this to 0 to indicate an application creation call. */
73
+ appID: number;
74
+ /** The method to call on the smart contract */
75
+ method: ABIMethod;
76
+ /** The arguments to include in the method call. If omitted, no arguments will be passed to the method. */
77
+ methodArgs?: ABIArgument[];
78
+ /** The address of the sender of this application call */
79
+ sender: string;
80
+ /** Transactions params to use for this application call */
81
+ suggestedParams: SuggestedParams;
82
+ /** The OnComplete action to take for this application call. If omitted, OnApplicationComplete.NoOpOC will be used. */
83
+ onComplete?: OnApplicationComplete;
84
+ /** The approval program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC */
85
+ approvalProgram?: Uint8Array;
86
+ /** The clear program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC */
87
+ clearProgram?: Uint8Array;
88
+ /** The global integer schema size. Only set this if this is an application creation call. */
89
+ numGlobalInts?: number;
90
+ /** The global byte slice schema size. Only set this if this is an application creation call. */
91
+ numGlobalByteSlices?: number;
92
+ /** The local integer schema size. Only set this if this is an application creation call. */
93
+ numLocalInts?: number;
94
+ /** The local byte slice schema size. Only set this if this is an application creation call. */
95
+ numLocalByteSlices?: number;
96
+ /** The number of extra pages to allocate for the application's programs. Only set this if this is an application creation call. If omitted, defaults to 0. */
97
+ extraPages?: number;
98
+ /** The note value for this application call */
99
+ note?: Uint8Array;
100
+ /** The lease value for this application call */
101
+ lease?: Uint8Array;
102
+ /** If provided, the address that the sender will be rekeyed to at the conclusion of this application call */
103
+ rekeyTo?: string;
104
+ /** A transaction signer that can authorize this application call from sender */
105
+ signer: TransactionSigner;
106
+ }): void;
107
+ /**
108
+ * Finalize the transaction group and returned the finalized transactions.
109
+ *
110
+ * The composer's status will be at least BUILT after executing this method.
111
+ */
112
+ buildGroup(): TransactionWithSigner[];
113
+ /**
114
+ * Obtain signatures for each transaction in this group. If signatures have already been obtained,
115
+ * this method will return cached versions of the signatures.
116
+ *
117
+ * The composer's status will be at least SIGNED after executing this method.
118
+ *
119
+ * An error will be thrown if signing any of the transactions fails.
120
+ *
121
+ * @returns A promise that resolves to an array of signed transactions.
122
+ */
123
+ gatherSignatures(): Promise<Uint8Array[]>;
124
+ /**
125
+ * Send the transaction group to the network, but don't wait for it to be committed to a block. An
126
+ * error will be thrown if submission fails.
127
+ *
128
+ * The composer's status must be SUBMITTED or lower before calling this method. If submission is
129
+ * successful, this composer's status will update to SUBMITTED.
130
+ *
131
+ * Note: a group can only be submitted again if it fails.
132
+ *
133
+ * @param client - An Algodv2 client
134
+ *
135
+ * @returns A promise that, upon success, resolves to a list of TxIDs of the submitted transactions.
136
+ */
137
+ submit(client: Algodv2): Promise<string[]>;
138
+ /**
139
+ * Send the transaction group to the network and wait until it's committed to a block. An error
140
+ * will be thrown if submission or execution fails.
141
+ *
142
+ * The composer's status must be SUBMITTED or lower before calling this method, since execution is
143
+ * only allowed once. If submission is successful, this composer's status will update to SUBMITTED.
144
+ * If the execution is also successful, this composer's status will update to COMMITTED.
145
+ *
146
+ * Note: a group can only be submitted again if it fails.
147
+ *
148
+ * @param client - An Algodv2 client
149
+ * @param waitRounds - The maximum number of rounds to wait for transaction confirmation
150
+ *
151
+ * @returns A promise that, upon success, resolves to an object containing the confirmed round for
152
+ * this transaction, the txIDs of the submitted transactions, and an array of results containing
153
+ * one element for each method call transaction in this group.
154
+ */
155
+ execute(client: Algodv2, waitRounds: number): Promise<{
156
+ confirmedRound: number;
157
+ txIDs: string[];
158
+ methodResults: ABIResult[];
159
+ }>;
160
+ }
@@ -49,3 +49,9 @@ export declare function fromMultisigPreImgAddrs({ version, threshold, addrs, }:
49
49
  threshold: number;
50
50
  addrs: string[];
51
51
  }): string;
52
+ /**
53
+ * Get the escrow address of an application.
54
+ * @param appID - The ID of the application.
55
+ * @returns The address corresponding to that application's escrow account.
56
+ */
57
+ export declare function getApplicationAddress(appID: number | bigint): string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * bigIntToBytes converts a BigInt to a big-endian Uint8Array for encoding.
3
+ * @param bi - The bigint to convert.
4
+ * @param size - The size of the resulting byte array.
5
+ * @returns A byte array containing the big-endian encoding of the input bigint
6
+ */
7
+ export declare function bigIntToBytes(bi: bigint | number, size: number): Uint8Array;
8
+ /**
9
+ * bytesToBigInt produces a bigint from a binary representation.
10
+ *
11
+ * @param bytes - The Uint8Array to convert.
12
+ * @returns The bigint that was encoded in the input data.
13
+ */
14
+ export declare function bytesToBigInt(bytes: Uint8Array): bigint;
@@ -1,6 +1,5 @@
1
1
  import * as txnBuilder from './transaction';
2
2
  import { BidOptions } from './bid';
3
- import { MultisigMetadata } from './types/multisig';
4
3
  export declare const MULTISIG_BAD_SENDER_ERROR_MSG = "The transaction sender address and multisig preimage do not match.";
5
4
  /**
6
5
  * signTransaction takes an object with either payment or key registration fields and
@@ -46,50 +45,6 @@ export declare function signBytes(bytes: Uint8Array, sk: Uint8Array): Uint8Array
46
45
  * @returns bool
47
46
  */
48
47
  export declare function verifyBytes(bytes: Uint8Array, signature: Uint8Array, addr: string): boolean;
49
- /**
50
- * signMultisigTransaction takes a raw transaction (see signTransaction), a multisig preimage, a secret key, and returns
51
- * a multisig transaction, which is a blob representing a transaction and multisignature account preimage. The returned
52
- * multisig txn can accumulate additional signatures through mergeMultisigTransactions or appendMultisigTransaction.
53
- * @param txn - object with either payment or key registration fields
54
- * @param version - multisig version
55
- * @param threshold - multisig threshold
56
- * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important.
57
- * @param sk - Algorand secret key. The corresponding pk should be in the pre image.
58
- * @returns object containing txID, and blob of partially signed multisig transaction (with multisig preimage information)
59
- * If the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum.
60
- */
61
- export declare function signMultisigTransaction(txn: txnBuilder.TransactionLike, { version, threshold, addrs }: MultisigMetadata, sk: Uint8Array): {
62
- txID: string;
63
- blob: Uint8Array;
64
- };
65
- /**
66
- * mergeMultisigTransactions takes a list of multisig transaction blobs, and merges them.
67
- * @param multisigTxnBlobs - a list of blobs representing encoded multisig txns
68
- * @returns blob representing encoded multisig txn
69
- */
70
- export declare function mergeMultisigTransactions(multisigTxnBlobs: Uint8Array[]): Uint8Array;
71
- /**
72
- * appendSignMultisigTransaction takes a multisig transaction blob, and appends our signature to it.
73
- * While we could derive public key preimagery from the partially-signed multisig transaction,
74
- * we ask the caller to pass it back in, to ensure they know what they are signing.
75
- * @param multisigTxnBlob - an encoded multisig txn. Supports non-payment txn types.
76
- * @param version - multisig version
77
- * @param threshold - multisig threshold
78
- * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important.
79
- * @param sk - Algorand secret key
80
- * @returns object containing txID, and blob representing encoded multisig txn
81
- */
82
- export declare function appendSignMultisigTransaction(multisigTxnBlob: Uint8Array, { version, threshold, addrs }: MultisigMetadata, sk: Uint8Array): {
83
- txID: string;
84
- blob: Uint8Array;
85
- };
86
- /**
87
- * multisigAddress takes multisig metadata (preimage) and returns the corresponding human readable Algorand address.
88
- * @param version - mutlisig version
89
- * @param threshold - multisig threshold
90
- * @param addrs - list of Algorand addresses
91
- */
92
- export declare function multisigAddress({ version, threshold, addrs, }: MultisigMetadata): string;
93
48
  /**
94
49
  * encodeObj takes a javascript object and returns its msgpack encoding
95
50
  * Note that the encoding sorts the fields alphabetically
@@ -111,16 +66,21 @@ export { default as Kmd } from './client/kmd';
111
66
  export { default as IntDecoding } from './types/intDecoding';
112
67
  export { default as Account } from './types/account';
113
68
  export { default as Indexer } from './client/v2/indexer/indexer';
114
- export { isValidAddress, encodeAddress, decodeAddress, } from './encoding/address';
69
+ export { BaseHTTPClient, BaseHTTPClientResponse, BaseHTTPClientError, } from './client/baseHTTPClient';
70
+ export { waitForConfirmation } from './wait';
71
+ export { isValidAddress, encodeAddress, decodeAddress, getApplicationAddress, } from './encoding/address';
115
72
  export { encodeUint64, decodeUint64 } from './encoding/uint64';
116
73
  export { default as generateAccount } from './account';
117
- export { secretKeyToMnemonic, mnemonicToSecretKey } from './mnemonic/mnemonic';
118
74
  export * as modelsv2 from './client/v2/algod/models/types';
119
- export { mnemonicToMasterDerivationKey, masterDerivationKeyToMnemonic, } from './mnemonic/mnemonic';
75
+ export { mnemonicToMasterDerivationKey, masterDerivationKeyToMnemonic, secretKeyToMnemonic, mnemonicToSecretKey, seedFromMnemonic, mnemonicFromSeed, } from './mnemonic/mnemonic';
120
76
  export { microalgosToAlgos, algosToMicroalgos, INVALID_MICROALGOS_ERROR_MSG, } from './convert';
121
77
  export { computeGroupID, assignGroupID } from './group';
122
78
  export { LogicSigAccount, makeLogicSig, signLogicSigTransaction, signLogicSigTransactionObject, logicSigFromByte, tealSign, tealSignFromProgram, } from './logicsig';
79
+ export { signMultisigTransaction, mergeMultisigTransactions, appendSignMultisigTransaction, multisigAddress, } from './multisig';
123
80
  export declare const LogicTemplates: any;
124
81
  export * from './makeTxn';
125
82
  export * from './transaction';
83
+ export * from './signer';
84
+ export * from './composer';
126
85
  export * from './types';
86
+ export * from './abi';
@@ -455,7 +455,7 @@ export declare function makeApplicationDeleteTxnFromObject(o: Pick<RenamePropert
455
455
  * @param lease - Lease a transaction
456
456
  * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions
457
457
  */
458
- export declare function makeApplicationOptInTxn(from: AppOptInTxn['from'], suggestedParams: MustHaveSuggestedParams<AppOptInTxn>['suggestedParams'], appIndex: AppOptInTxn['appIndex'], appArgs?: AppOptInTxn['appArgs'], accounts?: AppOptInTxn['appAccounts'], foreignApps?: AppOptInTxn['appForeignApps'], foreignAssets?: AppOptInTxn['appForeignApps'], note?: AppOptInTxn['note'], lease?: AppOptInTxn['lease'], rekeyTo?: AppOptInTxn['reKeyTo']): txnBuilder.Transaction;
458
+ export declare function makeApplicationOptInTxn(from: AppOptInTxn['from'], suggestedParams: MustHaveSuggestedParams<AppOptInTxn>['suggestedParams'], appIndex: AppOptInTxn['appIndex'], appArgs?: AppOptInTxn['appArgs'], accounts?: AppOptInTxn['appAccounts'], foreignApps?: AppOptInTxn['appForeignApps'], foreignAssets?: AppOptInTxn['appForeignAssets'], note?: AppOptInTxn['note'], lease?: AppOptInTxn['lease'], rekeyTo?: AppOptInTxn['reKeyTo']): txnBuilder.Transaction;
459
459
  export declare function makeApplicationOptInTxnFromObject(o: Pick<RenameProperties<MustHaveSuggestedParams<AppOptInTxn>, {
460
460
  appAccounts: 'accounts';
461
461
  appForeignApps: 'foreignApps';
@@ -544,3 +544,20 @@ export declare function makeApplicationNoOpTxnFromObject(o: Pick<RenamePropertie
544
544
  reKeyTo: 'rekeyTo';
545
545
  }>, 'from' | 'suggestedParams' | 'appIndex' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'note' | 'lease' | 'rekeyTo'>): txnBuilder.Transaction;
546
546
  export { OnApplicationComplete } from './types/transactions/base';
547
+ /**
548
+ * Generic function for creating any application call transaction.
549
+ */
550
+ export declare function makeApplicationCallTxnFromObject(options: Pick<RenameProperties<MustHaveSuggestedParams<AppCreateTxn>, {
551
+ appOnComplete: 'onComplete';
552
+ appAccounts: 'accounts';
553
+ appForeignApps: 'foreignApps';
554
+ appForeignAssets: 'foreignAssets';
555
+ reKeyTo: 'rekeyTo';
556
+ }>, 'from' | 'suggestedParams' | 'appIndex' | 'onComplete' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'note' | 'lease' | 'rekeyTo' | 'extraPages'> & Partial<Pick<RenameProperties<MustHaveSuggestedParams<AppCreateTxn>, {
557
+ appApprovalProgram: 'approvalProgram';
558
+ appClearProgram: 'clearProgram';
559
+ appLocalInts: 'numLocalInts';
560
+ appLocalByteSlices: 'numLocalByteSlices';
561
+ appGlobalInts: 'numGlobalInts';
562
+ appGlobalByteSlices: 'numGlobalByteSlices';
563
+ }>, 'approvalProgram' | 'clearProgram' | 'numLocalInts' | 'numLocalByteSlices' | 'numGlobalInts' | 'numGlobalByteSlices'>>): txnBuilder.Transaction;
@@ -50,4 +50,42 @@ export declare class MultisigTransaction extends txnBuilder.Transaction {
50
50
  */
51
51
  export declare function mergeMultisigTransactions(multisigTxnBlobs: Uint8Array[]): Uint8Array;
52
52
  export declare function verifyMultisig(toBeVerified: Uint8Array, msig: EncodedMultisig, publicKey: Uint8Array): boolean;
53
- export default MultisigTransaction;
53
+ /**
54
+ * signMultisigTransaction takes a raw transaction (see signTransaction), a multisig preimage, a secret key, and returns
55
+ * a multisig transaction, which is a blob representing a transaction and multisignature account preimage. The returned
56
+ * multisig txn can accumulate additional signatures through mergeMultisigTransactions or appendMultisigTransaction.
57
+ * @param txn - object with either payment or key registration fields
58
+ * @param version - multisig version
59
+ * @param threshold - multisig threshold
60
+ * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important.
61
+ * @param sk - Algorand secret key. The corresponding pk should be in the pre image.
62
+ * @returns object containing txID, and blob of partially signed multisig transaction (with multisig preimage information)
63
+ * If the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum.
64
+ */
65
+ export declare function signMultisigTransaction(txn: txnBuilder.TransactionLike, { version, threshold, addrs }: MultisigMetadata, sk: Uint8Array): {
66
+ txID: string;
67
+ blob: Uint8Array;
68
+ };
69
+ /**
70
+ * appendSignMultisigTransaction takes a multisig transaction blob, and appends our signature to it.
71
+ * While we could derive public key preimagery from the partially-signed multisig transaction,
72
+ * we ask the caller to pass it back in, to ensure they know what they are signing.
73
+ * @param multisigTxnBlob - an encoded multisig txn. Supports non-payment txn types.
74
+ * @param version - multisig version
75
+ * @param threshold - multisig threshold
76
+ * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important.
77
+ * @param sk - Algorand secret key
78
+ * @returns object containing txID, and blob representing encoded multisig txn
79
+ */
80
+ export declare function appendSignMultisigTransaction(multisigTxnBlob: Uint8Array, { version, threshold, addrs }: MultisigMetadata, sk: Uint8Array): {
81
+ txID: string;
82
+ blob: Uint8Array;
83
+ };
84
+ /**
85
+ * multisigAddress takes multisig metadata (preimage) and returns the corresponding human readable Algorand address.
86
+ * @param version - mutlisig version
87
+ * @param threshold - multisig threshold
88
+ * @param addrs - list of Algorand addresses
89
+ */
90
+ export declare function multisigAddress({ version, threshold, addrs, }: MultisigMetadata): string;
91
+ export {};