@decaf-ts/for-fabric 0.0.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 (205) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +647 -0
  3. package/dist/for-fabric.cjs +6223 -0
  4. package/dist/for-fabric.esm.cjs +6180 -0
  5. package/lib/client/FabricClientAdapter.cjs +760 -0
  6. package/lib/client/FabricClientAdapter.d.ts +381 -0
  7. package/lib/client/FabricClientDispatch.cjs +186 -0
  8. package/lib/client/FabricClientDispatch.d.ts +125 -0
  9. package/lib/client/FabricClientRepository.cjs +131 -0
  10. package/lib/client/FabricClientRepository.d.ts +100 -0
  11. package/lib/client/erc20/erc20ClientRepository.cjs +343 -0
  12. package/lib/client/erc20/erc20ClientRepository.d.ts +254 -0
  13. package/lib/client/fabric-fs.cjs +234 -0
  14. package/lib/client/fabric-fs.d.ts +92 -0
  15. package/lib/client/index.cjs +30 -0
  16. package/lib/client/index.d.ts +13 -0
  17. package/lib/client/logging.cjs +102 -0
  18. package/lib/client/logging.d.ts +60 -0
  19. package/lib/client/services/LoggedService.cjs +47 -0
  20. package/lib/client/services/LoggedService.d.ts +42 -0
  21. package/lib/client/services/constants.cjs +3 -0
  22. package/lib/client/services/constants.d.ts +15 -0
  23. package/lib/client/services/enrollementService.cjs +344 -0
  24. package/lib/client/services/enrollementService.d.ts +176 -0
  25. package/lib/client/services/index.cjs +18 -0
  26. package/lib/client/services/index.d.ts +1 -0
  27. package/lib/contracts/ContractAdapter.cjs +730 -0
  28. package/lib/contracts/ContractAdapter.d.ts +296 -0
  29. package/lib/contracts/ContractContext.cjs +85 -0
  30. package/lib/contracts/ContractContext.d.ts +64 -0
  31. package/lib/contracts/ContractPrivateDataAdapter.cjs +281 -0
  32. package/lib/contracts/ContractPrivateDataAdapter.d.ts +74 -0
  33. package/lib/contracts/FabricConstruction.cjs +441 -0
  34. package/lib/contracts/FabricConstruction.d.ts +304 -0
  35. package/lib/contracts/FabricContractRepository.cjs +306 -0
  36. package/lib/contracts/FabricContractRepository.d.ts +162 -0
  37. package/lib/contracts/FabricContractRepositoryObservableHandler.cjs +85 -0
  38. package/lib/contracts/FabricContractRepositoryObservableHandler.d.ts +62 -0
  39. package/lib/contracts/FabricContractSequence.cjs +139 -0
  40. package/lib/contracts/FabricContractSequence.d.ts +61 -0
  41. package/lib/contracts/FabricContractStatement.cjs +119 -0
  42. package/lib/contracts/FabricContractStatement.d.ts +34 -0
  43. package/lib/contracts/PrivateSequence.cjs +36 -0
  44. package/lib/contracts/PrivateSequence.d.ts +15 -0
  45. package/lib/contracts/crud/crud-contract.cjs +257 -0
  46. package/lib/contracts/crud/crud-contract.d.ts +168 -0
  47. package/lib/contracts/crud/index.cjs +19 -0
  48. package/lib/contracts/crud/index.d.ts +2 -0
  49. package/lib/contracts/crud/serialized-crud-contract.cjs +172 -0
  50. package/lib/contracts/crud/serialized-crud-contract.d.ts +37 -0
  51. package/lib/contracts/erc20/erc20contract.cjs +569 -0
  52. package/lib/contracts/erc20/erc20contract.d.ts +151 -0
  53. package/lib/contracts/erc20/index.cjs +21 -0
  54. package/lib/contracts/erc20/index.d.ts +2 -0
  55. package/lib/contracts/erc20/models.cjs +209 -0
  56. package/lib/contracts/erc20/models.d.ts +114 -0
  57. package/lib/contracts/index.cjs +32 -0
  58. package/lib/contracts/index.d.ts +15 -0
  59. package/lib/contracts/logging.cjs +96 -0
  60. package/lib/contracts/logging.d.ts +49 -0
  61. package/lib/contracts/private-data.cjs +121 -0
  62. package/lib/contracts/private-data.d.ts +16 -0
  63. package/lib/contracts/types.cjs +3 -0
  64. package/lib/contracts/types.d.ts +26 -0
  65. package/lib/esm/client/FabricClientAdapter.d.ts +381 -0
  66. package/lib/esm/client/FabricClientAdapter.js +723 -0
  67. package/lib/esm/client/FabricClientDispatch.d.ts +125 -0
  68. package/lib/esm/client/FabricClientDispatch.js +182 -0
  69. package/lib/esm/client/FabricClientRepository.d.ts +100 -0
  70. package/lib/esm/client/FabricClientRepository.js +127 -0
  71. package/lib/esm/client/erc20/erc20ClientRepository.d.ts +254 -0
  72. package/lib/esm/client/erc20/erc20ClientRepository.js +339 -0
  73. package/lib/esm/client/fabric-fs.d.ts +92 -0
  74. package/lib/esm/client/fabric-fs.js +191 -0
  75. package/lib/esm/client/index.d.ts +13 -0
  76. package/lib/esm/client/index.js +14 -0
  77. package/lib/esm/client/logging.d.ts +60 -0
  78. package/lib/esm/client/logging.js +98 -0
  79. package/lib/esm/client/services/LoggedService.d.ts +42 -0
  80. package/lib/esm/client/services/LoggedService.js +43 -0
  81. package/lib/esm/client/services/constants.d.ts +15 -0
  82. package/lib/esm/client/services/constants.js +2 -0
  83. package/lib/esm/client/services/enrollementService.d.ts +176 -0
  84. package/lib/esm/client/services/enrollementService.js +337 -0
  85. package/lib/esm/client/services/index.d.ts +1 -0
  86. package/lib/esm/client/services/index.js +2 -0
  87. package/lib/esm/contracts/ContractAdapter.d.ts +296 -0
  88. package/lib/esm/contracts/ContractAdapter.js +724 -0
  89. package/lib/esm/contracts/ContractContext.d.ts +64 -0
  90. package/lib/esm/contracts/ContractContext.js +81 -0
  91. package/lib/esm/contracts/ContractPrivateDataAdapter.d.ts +74 -0
  92. package/lib/esm/contracts/ContractPrivateDataAdapter.js +277 -0
  93. package/lib/esm/contracts/FabricConstruction.d.ts +304 -0
  94. package/lib/esm/contracts/FabricConstruction.js +433 -0
  95. package/lib/esm/contracts/FabricContractRepository.d.ts +162 -0
  96. package/lib/esm/contracts/FabricContractRepository.js +302 -0
  97. package/lib/esm/contracts/FabricContractRepositoryObservableHandler.d.ts +62 -0
  98. package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js +81 -0
  99. package/lib/esm/contracts/FabricContractSequence.d.ts +61 -0
  100. package/lib/esm/contracts/FabricContractSequence.js +135 -0
  101. package/lib/esm/contracts/FabricContractStatement.d.ts +34 -0
  102. package/lib/esm/contracts/FabricContractStatement.js +115 -0
  103. package/lib/esm/contracts/PrivateSequence.d.ts +15 -0
  104. package/lib/esm/contracts/PrivateSequence.js +33 -0
  105. package/lib/esm/contracts/crud/crud-contract.d.ts +168 -0
  106. package/lib/esm/contracts/crud/crud-contract.js +253 -0
  107. package/lib/esm/contracts/crud/index.d.ts +2 -0
  108. package/lib/esm/contracts/crud/index.js +3 -0
  109. package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +37 -0
  110. package/lib/esm/contracts/crud/serialized-crud-contract.js +168 -0
  111. package/lib/esm/contracts/erc20/erc20contract.d.ts +151 -0
  112. package/lib/esm/contracts/erc20/erc20contract.js +565 -0
  113. package/lib/esm/contracts/erc20/index.d.ts +2 -0
  114. package/lib/esm/contracts/erc20/index.js +4 -0
  115. package/lib/esm/contracts/erc20/models.d.ts +114 -0
  116. package/lib/esm/contracts/erc20/models.js +206 -0
  117. package/lib/esm/contracts/index.d.ts +15 -0
  118. package/lib/esm/contracts/index.js +16 -0
  119. package/lib/esm/contracts/logging.d.ts +49 -0
  120. package/lib/esm/contracts/logging.js +92 -0
  121. package/lib/esm/contracts/private-data.d.ts +16 -0
  122. package/lib/esm/contracts/private-data.js +113 -0
  123. package/lib/esm/contracts/types.d.ts +26 -0
  124. package/lib/esm/contracts/types.js +2 -0
  125. package/lib/esm/index.d.ts +8 -0
  126. package/lib/esm/index.js +9 -0
  127. package/lib/esm/shared/ClientSerializer.d.ts +52 -0
  128. package/lib/esm/shared/ClientSerializer.js +80 -0
  129. package/lib/esm/shared/DeterministicSerializer.d.ts +40 -0
  130. package/lib/esm/shared/DeterministicSerializer.js +50 -0
  131. package/lib/esm/shared/SimpleDeterministicSerializer.d.ts +7 -0
  132. package/lib/esm/shared/SimpleDeterministicSerializer.js +42 -0
  133. package/lib/esm/shared/constants.d.ts +39 -0
  134. package/lib/esm/shared/constants.js +42 -0
  135. package/lib/esm/shared/crypto.d.ts +107 -0
  136. package/lib/esm/shared/crypto.js +331 -0
  137. package/lib/esm/shared/decorators.d.ts +24 -0
  138. package/lib/esm/shared/decorators.js +98 -0
  139. package/lib/esm/shared/erc20/erc20-constants.d.ts +25 -0
  140. package/lib/esm/shared/erc20/erc20-constants.js +27 -0
  141. package/lib/esm/shared/errors.d.ts +116 -0
  142. package/lib/esm/shared/errors.js +132 -0
  143. package/lib/esm/shared/events.d.ts +39 -0
  144. package/lib/esm/shared/events.js +47 -0
  145. package/lib/esm/shared/fabric-types.d.ts +33 -0
  146. package/lib/esm/shared/fabric-types.js +2 -0
  147. package/lib/esm/shared/index.d.ts +13 -0
  148. package/lib/esm/shared/index.js +14 -0
  149. package/lib/esm/shared/interfaces/Checkable.d.ts +21 -0
  150. package/lib/esm/shared/interfaces/Checkable.js +2 -0
  151. package/lib/esm/shared/math.d.ts +34 -0
  152. package/lib/esm/shared/math.js +61 -0
  153. package/lib/esm/shared/model/Identity.d.ts +42 -0
  154. package/lib/esm/shared/model/Identity.js +78 -0
  155. package/lib/esm/shared/model/IdentityCredentials.d.ts +41 -0
  156. package/lib/esm/shared/model/IdentityCredentials.js +74 -0
  157. package/lib/esm/shared/model/index.d.ts +1 -0
  158. package/lib/esm/shared/model/index.js +2 -0
  159. package/lib/esm/shared/model/utils.d.ts +60 -0
  160. package/lib/esm/shared/model/utils.js +108 -0
  161. package/lib/esm/shared/types.d.ts +79 -0
  162. package/lib/esm/shared/types.js +2 -0
  163. package/lib/esm/shared/utils.d.ts +55 -0
  164. package/lib/esm/shared/utils.js +148 -0
  165. package/lib/index.cjs +25 -0
  166. package/lib/index.d.ts +8 -0
  167. package/lib/shared/ClientSerializer.cjs +84 -0
  168. package/lib/shared/ClientSerializer.d.ts +52 -0
  169. package/lib/shared/DeterministicSerializer.cjs +54 -0
  170. package/lib/shared/DeterministicSerializer.d.ts +40 -0
  171. package/lib/shared/SimpleDeterministicSerializer.cjs +46 -0
  172. package/lib/shared/SimpleDeterministicSerializer.d.ts +7 -0
  173. package/lib/shared/constants.cjs +45 -0
  174. package/lib/shared/constants.d.ts +39 -0
  175. package/lib/shared/crypto.cjs +369 -0
  176. package/lib/shared/crypto.d.ts +107 -0
  177. package/lib/shared/decorators.cjs +105 -0
  178. package/lib/shared/decorators.d.ts +24 -0
  179. package/lib/shared/erc20/erc20-constants.cjs +30 -0
  180. package/lib/shared/erc20/erc20-constants.d.ts +25 -0
  181. package/lib/shared/errors.cjs +142 -0
  182. package/lib/shared/errors.d.ts +116 -0
  183. package/lib/shared/events.cjs +51 -0
  184. package/lib/shared/events.d.ts +39 -0
  185. package/lib/shared/fabric-types.cjs +4 -0
  186. package/lib/shared/fabric-types.d.ts +33 -0
  187. package/lib/shared/index.cjs +30 -0
  188. package/lib/shared/index.d.ts +13 -0
  189. package/lib/shared/interfaces/Checkable.cjs +3 -0
  190. package/lib/shared/interfaces/Checkable.d.ts +21 -0
  191. package/lib/shared/math.cjs +66 -0
  192. package/lib/shared/math.d.ts +34 -0
  193. package/lib/shared/model/Identity.cjs +81 -0
  194. package/lib/shared/model/Identity.d.ts +42 -0
  195. package/lib/shared/model/IdentityCredentials.cjs +77 -0
  196. package/lib/shared/model/IdentityCredentials.d.ts +41 -0
  197. package/lib/shared/model/index.cjs +18 -0
  198. package/lib/shared/model/index.d.ts +1 -0
  199. package/lib/shared/model/utils.cjs +114 -0
  200. package/lib/shared/model/utils.d.ts +60 -0
  201. package/lib/shared/types.cjs +3 -0
  202. package/lib/shared/types.d.ts +79 -0
  203. package/lib/shared/utils.cjs +185 -0
  204. package/lib/shared/utils.d.ts +55 -0
  205. package/package.json +166 -0
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FabricERC20ClientRepository = void 0;
4
+ const FabricClientRepository_1 = require("./../FabricClientRepository.cjs");
5
+ const models_1 = require("./../../contracts/erc20/models.cjs");
6
+ const ClientSerializer_1 = require("./../../shared/ClientSerializer.cjs");
7
+ const core_1 = require("@decaf-ts/core");
8
+ const db_decorators_1 = require("@decaf-ts/db-decorators");
9
+ /**
10
+ * Repository for interacting with ERC20 contracts on a Hyperledger Fabric network.
11
+ * Extends the base FabricClientRepository class and utilizes the ClientSerializer for data serialization.
12
+ */
13
+ class FabricERC20ClientRepository extends FabricClientRepository_1.FabricClientRepository {
14
+ static { this.serializer = new ClientSerializer_1.ClientSerializer(); }
15
+ static { this.decoder = new TextDecoder("utf8"); }
16
+ /**
17
+ * @description Notifies all observers of an event.
18
+ * @summary Updates all registered observers with information about a database event.
19
+ * @param {string} table - The table name where the event occurred.
20
+ * @param {OperationKeys|BulkCrudOperationKeys|string} event - The type of event that occurred.
21
+ * @param {EventIds} id - The ID or IDs of the affected records.
22
+ * @param {...any[]} args - Additional arguments.
23
+ * @return {Promise<void>} A promise that resolves when all observers have been notified.
24
+ * @throws {InternalError} If the observer handler is not initialized.
25
+ */
26
+ async updateObservers(table, event, id, ...args) {
27
+ if (!this.observerHandler)
28
+ throw new db_decorators_1.InternalError("ObserverHandler not initialized. Did you register any observables?");
29
+ this.log
30
+ .for(this.updateObservers)
31
+ .verbose(`Updating ${this.observerHandler.count()} observers for ${this}`);
32
+ let parsedId;
33
+ if (id === undefined) {
34
+ parsedId = undefined;
35
+ }
36
+ else if (Array.isArray(id)) {
37
+ parsedId = id.map((i) => core_1.Sequence.parseValue(this.pkProps.type, i));
38
+ }
39
+ else {
40
+ parsedId = core_1.Sequence.parseValue(this.pkProps.type, id);
41
+ }
42
+ await this.observerHandler.updateObservers(this.log, table, event, parsedId, ...args);
43
+ }
44
+ /**
45
+ * Decodes a Uint8Array into a string using the TextDecoder.
46
+ *
47
+ * @param data - The Uint8Array to decode.
48
+ * @returns The decoded string.
49
+ */
50
+ decode(data) {
51
+ return FabricERC20ClientRepository.decoder.decode(data);
52
+ }
53
+ get adapter() {
54
+ return super.adapter;
55
+ }
56
+ constructor(adapter) {
57
+ super(adapter, models_1.ERC20Wallet);
58
+ this.serializer = FabricERC20ClientRepository.serializer;
59
+ }
60
+ /**
61
+ * Retrieves the name of the ERC20 token.
62
+ *
63
+ * @description
64
+ * This function interacts with the blockchain network to fetch the name of the ERC20 token.
65
+ * It calls the "TokenName" transaction on the smart contract and decodes the returned data.
66
+ *
67
+ * @returns {Promise<string>} A promise that resolves with the name of the ERC20 token.
68
+ *
69
+ * @throws {Error} If the transaction fails or the decoding process fails.
70
+ */
71
+ async tokenName() {
72
+ const name = await this.adapter.submitTransaction("TokenName");
73
+ return this.decode(name);
74
+ }
75
+ /**
76
+ * Retrieves the symbol of the ERC20 token.
77
+ *
78
+ * This function interacts with the blockchain network to fetch the symbol of the ERC20 token.
79
+ * It calls the "Symbol" transaction on the smart contract and decodes the returned data.
80
+ *
81
+ * @returns {Promise<string>} A promise that resolves with the symbol of the ERC20 token.
82
+ *
83
+ * @throws {Error} If the transaction fails or the decoding process fails.
84
+ */
85
+ async symbol() {
86
+ const symbol = await this.adapter.submitTransaction("Symbol");
87
+ return this.decode(symbol);
88
+ }
89
+ /**
90
+ * Retrieves the number of decimal places for the ERC20 token.
91
+ *
92
+ * This function interacts with the blockchain network to fetch the number of decimal places for the ERC20 token.
93
+ * It calls the "Decimals" transaction on the smart contract and decodes the returned data.
94
+ *
95
+ * @returns {Promise<number>} A promise that resolves with the number of decimal places for the ERC20 token.
96
+ *
97
+ * @throws {Error} If the transaction fails or the decoding process fails.
98
+ */
99
+ async decimals() {
100
+ const decimals = await this.adapter.submitTransaction("Decimals");
101
+ return Number(this.decode(decimals));
102
+ }
103
+ /**
104
+ * Retrieves the total supply of the ERC20 token.
105
+ *
106
+ * This function interacts with the blockchain network to fetch the total supply of the ERC20 token.
107
+ * It calls the "TotalSupply" transaction on the smart contract and decodes the returned data.
108
+ *
109
+ * @returns {Promise<number>} A promise that resolves with the total supply of the ERC20 token.
110
+ *
111
+ * @throws {Error} If the transaction fails or the decoding process fails.
112
+ */
113
+ async totalSupply() {
114
+ const total = await this.adapter.submitTransaction("TotalSupply");
115
+ return Number(this.decode(total));
116
+ }
117
+ /**
118
+ * Retrieves the balance of the ERC20 token for a specified owner.
119
+ *
120
+ * @description
121
+ * This function interacts with the blockchain network to fetch the balance of the ERC20 token for a given owner.
122
+ * It calls the "BalanceOf" transaction on the smart contract with the provided owner's address as a parameter.
123
+ * The returned data is then decoded and converted to a number.
124
+ *
125
+ * @param owner - The address of the ERC20 token owner.
126
+ *
127
+ * @returns {Promise<number>} A promise that resolves with the balance of the ERC20 token for the specified owner.
128
+ *
129
+ * @throws {Error} If the transaction fails or the decoding process fails.
130
+ */
131
+ async balanceOf(owner) {
132
+ const balance = await this.adapter.submitTransaction("BalanceOf", [owner]);
133
+ return Number(this.decode(balance));
134
+ }
135
+ /**
136
+ * Transfers a specified amount of ERC20 tokens to a recipient.
137
+ *
138
+ * @description
139
+ * This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens to a recipient.
140
+ * It calls the "Transfer" transaction on the smart contract with the recipient's address and the transfer amount as parameters.
141
+ * The returned data is then decoded and checked to determine if the transfer was successful.
142
+ *
143
+ * @param to - The address of the recipient.
144
+ * @param value - The amount of ERC20 tokens to transfer.
145
+ *
146
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the transfer was successful, and `false` otherwise.
147
+ *
148
+ * @throws {Error} If the transaction fails or the decoding process fails.
149
+ */
150
+ async transfer(to, value) {
151
+ const transferred = await this.adapter.submitTransaction("Transfer", [
152
+ to,
153
+ value.toString(),
154
+ ]);
155
+ return this.decode(transferred) === "true" ? true : false;
156
+ }
157
+ /**
158
+ * Transfers a specified amount of ERC20 tokens from one account to another.
159
+ *
160
+ * @description
161
+ * This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens from one account to another.
162
+ * For this transfer to work the spender ( account that will trigger this function ) need to have the value approved as an allowance by the sender.
163
+ * It calls the "TransferFrom" transaction on the smart contract with the sender's address, recipient's address, and the transfer amount as parameters.
164
+ * The returned data is then decoded and checked to determine if the transfer was successful.
165
+ *
166
+ * @param from - The address of the sender.
167
+ * @param to - The address of the recipient.
168
+ * @param value - The amount of ERC20 tokens to transfer.
169
+ *
170
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the transfer was successful, and `false` otherwise.
171
+ *
172
+ * @throws {Error} If the transaction fails or the decoding process fails.
173
+ */
174
+ async transferFrom(from, to, value) {
175
+ const transferred = await this.adapter.submitTransaction("TransferFrom", [
176
+ from,
177
+ to,
178
+ value.toString(),
179
+ ]);
180
+ return this.decode(transferred) === "true" ? true : false;
181
+ }
182
+ /**
183
+ * Approves a specified amount of ERC20 tokens to be spent by a specified spender.
184
+ *
185
+ * This function interacts with the blockchain network to approve a specified amount of ERC20 tokens to be spent by a specified spender.
186
+ * It calls the "Approve" transaction on the smart contract with the spender's address and the approval amount as parameters.
187
+ * The returned data is then decoded and checked to determine if the approval was successful.
188
+ *
189
+ * @param spender - The address of the spender.
190
+ * @param value - The amount of ERC20 tokens to approve for the spender.
191
+ *
192
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the approval was successful, and `false` otherwise.
193
+ *
194
+ * @throws {Error} If the transaction fails or the decoding process fails.
195
+ */
196
+ async approve(spender, value) {
197
+ const approved = await this.adapter.submitTransaction("Approve", [
198
+ spender,
199
+ value.toString(),
200
+ ]);
201
+ return this.decode(approved) === "true" ? true : false;
202
+ }
203
+ /**
204
+ * Retrieves the allowance of ERC20 tokens that the specified owner has approved for a spender.
205
+ *
206
+ * @description
207
+ * This function interacts with the blockchain network to fetch the allowance of ERC20 tokens that the specified owner has approved for a spender.
208
+ * It calls the "Allowance" transaction on the smart contract with the owner's address and the spender's address as parameters.
209
+ * The returned data is then decoded and converted to a number.
210
+ *
211
+ * @param owner - The address of the ERC20 token owner.
212
+ * @param spender - The address of the spender.
213
+ *
214
+ * @returns {Promise<number>} A promise that resolves with the allowance of ERC20 tokens that the specified owner has approved for the spender.
215
+ *
216
+ * @throws {Error} If the transaction fails or the decoding process fails.
217
+ */
218
+ async allowance(owner, spender) {
219
+ const allowance = await this.adapter.submitTransaction("Allowance", [
220
+ owner,
221
+ spender,
222
+ ]);
223
+ return Number(this.decode(allowance));
224
+ }
225
+ /**
226
+ * Initializes the ERC20 contract with the provided token information.
227
+ *
228
+ * @description
229
+ * This function interacts with the blockchain network to initialize the ERC20 contract with the given token information.
230
+ * It calls the "Initialize" transaction on the smart contract with the serialized token data as a parameter.
231
+ * The returned data is then decoded and checked to determine if the initialization was successful.
232
+ *
233
+ * @param token - The ERC20 token information to initialize the contract with.
234
+ *
235
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the initialization was successful, and `false` otherwise.
236
+ *
237
+ * @throws {Error} If the transaction fails or the decoding process fails.
238
+ */
239
+ async initialize(token) {
240
+ const initiliazed = await this.adapter.submitTransaction("Initialize", [
241
+ FabricERC20ClientRepository.serializer.serialize(token),
242
+ ]);
243
+ return this.decode(initiliazed) === "true" ? true : false;
244
+ }
245
+ /**
246
+ * Checks if the ERC20 contract has been initialized.
247
+ *
248
+ * This function interacts with the blockchain network to verify if the ERC20 contract has been initialized.
249
+ * It calls the "CheckInitialized" transaction on the smart contract, which does not require any parameters.
250
+ *
251
+ * @returns {Promise<void>} A promise that resolves when the initialization check is completed.
252
+ *
253
+ * @throws {Error} If the transaction fails.
254
+ */
255
+ async checkInitialized() {
256
+ await this.adapter.submitTransaction("CheckInitialized");
257
+ }
258
+ /**
259
+ * Mints a specified amount of ERC20 tokens.
260
+ *
261
+ * @description
262
+ * This function interacts with the blockchain network to mint a specified amount of ERC20 tokens.
263
+ * It calls the "Mint" transaction on the smart contract with the minting amount as a parameter.
264
+ * The function does not return any value, but it updates the minter's number of tokens.
265
+ *
266
+ * @param amount - The amount of ERC20 tokens to mint.
267
+ *
268
+ * @returns {Promise<void>} A promise that resolves when the minting process is completed.
269
+ *
270
+ * @throws {Error} If the transaction fails.
271
+ */
272
+ async mint(amount) {
273
+ await this.adapter.submitTransaction("Mint", [amount.toString()]);
274
+ }
275
+ /**
276
+ * Burns a specified amount of ERC20 tokens from the minter's account.
277
+ *
278
+ * This function interacts with the blockchain network to burn a specified amount of ERC20 tokens.
279
+ * It calls the "Burn" transaction on the smart contract with the burning amount as a parameter.
280
+ * The function does not return any value, but it decreases the minter's number of tokens.
281
+ *
282
+ * @param amount - The amount of ERC20 tokens to burn.
283
+ *
284
+ * @returns {Promise<void>} A promise that resolves when the burning process is completed.
285
+ *
286
+ * @throws {Error} If the transaction fails.
287
+ */
288
+ async burn(amount) {
289
+ await this.adapter.submitTransaction("Burn", [amount.toString()]);
290
+ }
291
+ /**
292
+ * Burns a specified amount of ERC20 tokens from a specified account.
293
+ *
294
+ * This function interacts with the blockchain network to burn a specified amount of ERC20 tokens from a given account.
295
+ * It calls the "BurnFrom" transaction on the smart contract with the account's address and the burning amount as parameters.
296
+ * The function does not return any value, but it decreases the specified account's number of tokens.
297
+ *
298
+ * @param account - The address of the account from which to burn the ERC20 tokens.
299
+ * @param amount - The amount of ERC20 tokens to burn.
300
+ *
301
+ * @returns {Promise<void>} A promise that resolves when the burning process is completed.
302
+ *
303
+ * @throws {Error} If the transaction fails.
304
+ */
305
+ async burnFrom(account, amount) {
306
+ await this.adapter.submitTransaction("BurnFrom", [
307
+ account,
308
+ amount.toString(),
309
+ ]);
310
+ }
311
+ /**
312
+ * Retrieves the balance of ERC20 tokens associated with the client's account.
313
+ *
314
+ * This function interacts with the blockchain network to fetch the balance of ERC20 tokens associated with the client's account.
315
+ * It calls the "ClientAccountBalance" transaction on the smart contract, which does not require any parameters.
316
+ * The returned data is then decoded and converted to a number.
317
+ *
318
+ * @returns {Promise<number>} A promise that resolves with the balance of ERC20 tokens associated with the client's account.
319
+ *
320
+ * @throws {Error} If the transaction fails or the decoding process fails.
321
+ */
322
+ async clientAccountBalance() {
323
+ const serializedAccountBalance = await this.adapter.submitTransaction("ClientAccountBalance");
324
+ return Number(this.decode(serializedAccountBalance));
325
+ }
326
+ /**
327
+ * Retrieves the client's account ID from the blockchain network.
328
+ *
329
+ * This function interacts with the blockchain network to fetch the client's account ID.
330
+ * It calls the "ClientAccountID" transaction on the smart contract, which does not require any parameters.
331
+ * The returned data is then decoded and returned as a string.
332
+ *
333
+ * @returns {Promise<string>} A promise that resolves with the client's account ID.
334
+ *
335
+ * @throws {Error} If the transaction fails or the decoding process fails.
336
+ */
337
+ async clientAccountID() {
338
+ const clientAccountID = await this.adapter.submitTransaction("ClientAccountID");
339
+ return this.decode(clientAccountID);
340
+ }
341
+ }
342
+ exports.FabricERC20ClientRepository = FabricERC20ClientRepository;
343
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJjMjBDbGllbnRSZXBvc2l0b3J5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaWVudC9lcmMyMC9lcmMyMENsaWVudFJlcG9zaXRvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNEVBQW1FO0FBQ25FLCtEQUF1RTtBQUd2RSwwRUFBaUU7QUFDakUseUNBQW9EO0FBQ3BELDJEQUlpQztBQUNqQzs7O0dBR0c7QUFDSCxNQUFhLDJCQUE0QixTQUFRLCtDQUFtQzthQUNuRSxlQUFVLEdBQUcsSUFBSSxtQ0FBZ0IsRUFBRSxBQUF6QixDQUEwQjthQUtwQyxZQUFPLEdBQUcsSUFBSSxXQUFXLENBQUMsTUFBTSxDQUFDLEFBQTFCLENBQTJCO0lBRWpEOzs7Ozs7Ozs7T0FTRztJQUNNLEtBQUssQ0FBQyxlQUFlLENBQzVCLEtBQWEsRUFDYixLQUFxRCxFQUNyRCxFQUFZLEVBQ1osR0FBRyxJQUFXO1FBRWQsSUFBSSxDQUFDLElBQUksQ0FBQyxlQUFlO1lBQ3ZCLE1BQU0sSUFBSSw2QkFBYSxDQUNyQixvRUFBb0UsQ0FDckUsQ0FBQztRQUNKLElBQUksQ0FBQyxHQUFHO2FBQ0wsR0FBRyxDQUFDLElBQUksQ0FBQyxlQUFlLENBQUM7YUFDekIsT0FBTyxDQUNOLFlBQVksSUFBSSxDQUFDLGVBQWUsQ0FBQyxLQUFLLEVBQUUsa0JBQWtCLElBQUksRUFBRS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sYW5jZSkpO1xuICB9XG5cbiAgLyoqXG4gICAqIFJldHJpZXZlcyB0aGUgY2xpZW50J3MgYWNjb3VudCBJRCBmcm9tIHRoZSBibG9ja2NoYWluIG5ldHdvcmsuXG4gICAqXG4gICAqIFRoaXMgZnVuY3Rpb24gaW50ZXJhY3RzIHdpdGggdGhlIGJsb2NrY2hhaW4gbmV0d29yayB0byBmZXRjaCB0aGUgY2xpZW50J3MgYWNjb3VudCBJRC5cbiAgICogSXQgY2FsbHMgdGhlIFwiQ2xpZW50QWNjb3VudElEXCIgdHJhbnNhY3Rpb24gb24gdGhlIHNtYXJ0IGNvbnRyYWN0LCB3aGljaCBkb2VzIG5vdCByZXF1aXJlIGFueSBwYXJhbWV0ZXJzLlxuICAgKiBUaGUgcmV0dXJuZWQgZGF0YSBpcyB0aGVuIGRlY29kZWQgYW5kIHJldHVybmVkIGFzIGEgc3RyaW5nLlxuICAgKlxuICAgKiBAcmV0dXJucyB7UHJvbWlzZTxzdHJpbmc+fSBBIHByb21pc2UgdGhhdCByZXNvbHZlcyB3aXRoIHRoZSBjbGllbnQncyBhY2NvdW50IElELlxuICAgKlxuICAgKiBAdGhyb3dzIHtFcnJvcn0gSWYgdGhlIHRyYW5zYWN0aW9uIGZhaWxzIG9yIHRoZSBkZWNvZGluZyBwcm9jZXNzIGZhaWxzLlxuICAgKi9cbiAgYXN5bmMgY2xpZW50QWNjb3VudElEKCk6IFByb21pc2U8c3RyaW5nPiB7XG4gICAgY29uc3QgY2xpZW50QWNjb3VudElEID1cbiAgICAgIGF3YWl0IHRoaXMuYWRhcHRlci5zdWJtaXRUcmFuc2FjdGlvbihcIkNsaWVudEFjY291bnRJRFwiKTtcblxuICAgIHJldHVybiB0aGlzLmRlY29kZShjbGllbnRBY2NvdW50SUQpO1xuICB9XG59XG4iXX0=
@@ -0,0 +1,254 @@
1
+ import { FabricClientRepository } from "../FabricClientRepository";
2
+ import { ERC20Token, ERC20Wallet } from "../../contracts/erc20/models";
3
+ import { Serializer } from "@decaf-ts/decorator-validation";
4
+ import { FabricClientAdapter } from "../FabricClientAdapter";
5
+ import { EventIds } from "@decaf-ts/core";
6
+ import { BulkCrudOperationKeys, OperationKeys } from "@decaf-ts/db-decorators";
7
+ /**
8
+ * Repository for interacting with ERC20 contracts on a Hyperledger Fabric network.
9
+ * Extends the base FabricClientRepository class and utilizes the ClientSerializer for data serialization.
10
+ */
11
+ export declare class FabricERC20ClientRepository extends FabricClientRepository<ERC20Wallet> {
12
+ private static serializer;
13
+ protected readonly serializer: Serializer<any>;
14
+ private static decoder;
15
+ /**
16
+ * @description Notifies all observers of an event.
17
+ * @summary Updates all registered observers with information about a database event.
18
+ * @param {string} table - The table name where the event occurred.
19
+ * @param {OperationKeys|BulkCrudOperationKeys|string} event - The type of event that occurred.
20
+ * @param {EventIds} id - The ID or IDs of the affected records.
21
+ * @param {...any[]} args - Additional arguments.
22
+ * @return {Promise<void>} A promise that resolves when all observers have been notified.
23
+ * @throws {InternalError} If the observer handler is not initialized.
24
+ */
25
+ updateObservers(table: string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: any[]): Promise<void>;
26
+ /**
27
+ * Decodes a Uint8Array into a string using the TextDecoder.
28
+ *
29
+ * @param data - The Uint8Array to decode.
30
+ * @returns The decoded string.
31
+ */
32
+ decode(data: Uint8Array): string;
33
+ protected get adapter(): FabricClientAdapter;
34
+ constructor(adapter?: FabricClientAdapter);
35
+ /**
36
+ * Retrieves the name of the ERC20 token.
37
+ *
38
+ * @description
39
+ * This function interacts with the blockchain network to fetch the name of the ERC20 token.
40
+ * It calls the "TokenName" transaction on the smart contract and decodes the returned data.
41
+ *
42
+ * @returns {Promise<string>} A promise that resolves with the name of the ERC20 token.
43
+ *
44
+ * @throws {Error} If the transaction fails or the decoding process fails.
45
+ */
46
+ tokenName(): Promise<string>;
47
+ /**
48
+ * Retrieves the symbol of the ERC20 token.
49
+ *
50
+ * This function interacts with the blockchain network to fetch the symbol of the ERC20 token.
51
+ * It calls the "Symbol" transaction on the smart contract and decodes the returned data.
52
+ *
53
+ * @returns {Promise<string>} A promise that resolves with the symbol of the ERC20 token.
54
+ *
55
+ * @throws {Error} If the transaction fails or the decoding process fails.
56
+ */
57
+ symbol(): Promise<string>;
58
+ /**
59
+ * Retrieves the number of decimal places for the ERC20 token.
60
+ *
61
+ * This function interacts with the blockchain network to fetch the number of decimal places for the ERC20 token.
62
+ * It calls the "Decimals" transaction on the smart contract and decodes the returned data.
63
+ *
64
+ * @returns {Promise<number>} A promise that resolves with the number of decimal places for the ERC20 token.
65
+ *
66
+ * @throws {Error} If the transaction fails or the decoding process fails.
67
+ */
68
+ decimals(): Promise<number>;
69
+ /**
70
+ * Retrieves the total supply of the ERC20 token.
71
+ *
72
+ * This function interacts with the blockchain network to fetch the total supply of the ERC20 token.
73
+ * It calls the "TotalSupply" transaction on the smart contract and decodes the returned data.
74
+ *
75
+ * @returns {Promise<number>} A promise that resolves with the total supply of the ERC20 token.
76
+ *
77
+ * @throws {Error} If the transaction fails or the decoding process fails.
78
+ */
79
+ totalSupply(): Promise<number>;
80
+ /**
81
+ * Retrieves the balance of the ERC20 token for a specified owner.
82
+ *
83
+ * @description
84
+ * This function interacts with the blockchain network to fetch the balance of the ERC20 token for a given owner.
85
+ * It calls the "BalanceOf" transaction on the smart contract with the provided owner's address as a parameter.
86
+ * The returned data is then decoded and converted to a number.
87
+ *
88
+ * @param owner - The address of the ERC20 token owner.
89
+ *
90
+ * @returns {Promise<number>} A promise that resolves with the balance of the ERC20 token for the specified owner.
91
+ *
92
+ * @throws {Error} If the transaction fails or the decoding process fails.
93
+ */
94
+ balanceOf(owner: string): Promise<number>;
95
+ /**
96
+ * Transfers a specified amount of ERC20 tokens to a recipient.
97
+ *
98
+ * @description
99
+ * This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens to a recipient.
100
+ * It calls the "Transfer" transaction on the smart contract with the recipient's address and the transfer amount as parameters.
101
+ * The returned data is then decoded and checked to determine if the transfer was successful.
102
+ *
103
+ * @param to - The address of the recipient.
104
+ * @param value - The amount of ERC20 tokens to transfer.
105
+ *
106
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the transfer was successful, and `false` otherwise.
107
+ *
108
+ * @throws {Error} If the transaction fails or the decoding process fails.
109
+ */
110
+ transfer(to: string, value: number): Promise<boolean>;
111
+ /**
112
+ * Transfers a specified amount of ERC20 tokens from one account to another.
113
+ *
114
+ * @description
115
+ * This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens from one account to another.
116
+ * For this transfer to work the spender ( account that will trigger this function ) need to have the value approved as an allowance by the sender.
117
+ * It calls the "TransferFrom" transaction on the smart contract with the sender's address, recipient's address, and the transfer amount as parameters.
118
+ * The returned data is then decoded and checked to determine if the transfer was successful.
119
+ *
120
+ * @param from - The address of the sender.
121
+ * @param to - The address of the recipient.
122
+ * @param value - The amount of ERC20 tokens to transfer.
123
+ *
124
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the transfer was successful, and `false` otherwise.
125
+ *
126
+ * @throws {Error} If the transaction fails or the decoding process fails.
127
+ */
128
+ transferFrom(from: string, to: string, value: number): Promise<boolean>;
129
+ /**
130
+ * Approves a specified amount of ERC20 tokens to be spent by a specified spender.
131
+ *
132
+ * This function interacts with the blockchain network to approve a specified amount of ERC20 tokens to be spent by a specified spender.
133
+ * It calls the "Approve" transaction on the smart contract with the spender's address and the approval amount as parameters.
134
+ * The returned data is then decoded and checked to determine if the approval was successful.
135
+ *
136
+ * @param spender - The address of the spender.
137
+ * @param value - The amount of ERC20 tokens to approve for the spender.
138
+ *
139
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the approval was successful, and `false` otherwise.
140
+ *
141
+ * @throws {Error} If the transaction fails or the decoding process fails.
142
+ */
143
+ approve(spender: string, value: number): Promise<boolean>;
144
+ /**
145
+ * Retrieves the allowance of ERC20 tokens that the specified owner has approved for a spender.
146
+ *
147
+ * @description
148
+ * This function interacts with the blockchain network to fetch the allowance of ERC20 tokens that the specified owner has approved for a spender.
149
+ * It calls the "Allowance" transaction on the smart contract with the owner's address and the spender's address as parameters.
150
+ * The returned data is then decoded and converted to a number.
151
+ *
152
+ * @param owner - The address of the ERC20 token owner.
153
+ * @param spender - The address of the spender.
154
+ *
155
+ * @returns {Promise<number>} A promise that resolves with the allowance of ERC20 tokens that the specified owner has approved for the spender.
156
+ *
157
+ * @throws {Error} If the transaction fails or the decoding process fails.
158
+ */
159
+ allowance(owner: string, spender: string): Promise<number>;
160
+ /**
161
+ * Initializes the ERC20 contract with the provided token information.
162
+ *
163
+ * @description
164
+ * This function interacts with the blockchain network to initialize the ERC20 contract with the given token information.
165
+ * It calls the "Initialize" transaction on the smart contract with the serialized token data as a parameter.
166
+ * The returned data is then decoded and checked to determine if the initialization was successful.
167
+ *
168
+ * @param token - The ERC20 token information to initialize the contract with.
169
+ *
170
+ * @returns {Promise<boolean>} A promise that resolves with `true` if the initialization was successful, and `false` otherwise.
171
+ *
172
+ * @throws {Error} If the transaction fails or the decoding process fails.
173
+ */
174
+ initialize(token: ERC20Token): Promise<boolean>;
175
+ /**
176
+ * Checks if the ERC20 contract has been initialized.
177
+ *
178
+ * This function interacts with the blockchain network to verify if the ERC20 contract has been initialized.
179
+ * It calls the "CheckInitialized" transaction on the smart contract, which does not require any parameters.
180
+ *
181
+ * @returns {Promise<void>} A promise that resolves when the initialization check is completed.
182
+ *
183
+ * @throws {Error} If the transaction fails.
184
+ */
185
+ checkInitialized(): Promise<void>;
186
+ /**
187
+ * Mints a specified amount of ERC20 tokens.
188
+ *
189
+ * @description
190
+ * This function interacts with the blockchain network to mint a specified amount of ERC20 tokens.
191
+ * It calls the "Mint" transaction on the smart contract with the minting amount as a parameter.
192
+ * The function does not return any value, but it updates the minter's number of tokens.
193
+ *
194
+ * @param amount - The amount of ERC20 tokens to mint.
195
+ *
196
+ * @returns {Promise<void>} A promise that resolves when the minting process is completed.
197
+ *
198
+ * @throws {Error} If the transaction fails.
199
+ */
200
+ mint(amount: number): Promise<void>;
201
+ /**
202
+ * Burns a specified amount of ERC20 tokens from the minter's account.
203
+ *
204
+ * This function interacts with the blockchain network to burn a specified amount of ERC20 tokens.
205
+ * It calls the "Burn" transaction on the smart contract with the burning amount as a parameter.
206
+ * The function does not return any value, but it decreases the minter's number of tokens.
207
+ *
208
+ * @param amount - The amount of ERC20 tokens to burn.
209
+ *
210
+ * @returns {Promise<void>} A promise that resolves when the burning process is completed.
211
+ *
212
+ * @throws {Error} If the transaction fails.
213
+ */
214
+ burn(amount: number): Promise<void>;
215
+ /**
216
+ * Burns a specified amount of ERC20 tokens from a specified account.
217
+ *
218
+ * This function interacts with the blockchain network to burn a specified amount of ERC20 tokens from a given account.
219
+ * It calls the "BurnFrom" transaction on the smart contract with the account's address and the burning amount as parameters.
220
+ * The function does not return any value, but it decreases the specified account's number of tokens.
221
+ *
222
+ * @param account - The address of the account from which to burn the ERC20 tokens.
223
+ * @param amount - The amount of ERC20 tokens to burn.
224
+ *
225
+ * @returns {Promise<void>} A promise that resolves when the burning process is completed.
226
+ *
227
+ * @throws {Error} If the transaction fails.
228
+ */
229
+ burnFrom(account: string, amount: number): Promise<void>;
230
+ /**
231
+ * Retrieves the balance of ERC20 tokens associated with the client's account.
232
+ *
233
+ * This function interacts with the blockchain network to fetch the balance of ERC20 tokens associated with the client's account.
234
+ * It calls the "ClientAccountBalance" transaction on the smart contract, which does not require any parameters.
235
+ * The returned data is then decoded and converted to a number.
236
+ *
237
+ * @returns {Promise<number>} A promise that resolves with the balance of ERC20 tokens associated with the client's account.
238
+ *
239
+ * @throws {Error} If the transaction fails or the decoding process fails.
240
+ */
241
+ clientAccountBalance(): Promise<number>;
242
+ /**
243
+ * Retrieves the client's account ID from the blockchain network.
244
+ *
245
+ * This function interacts with the blockchain network to fetch the client's account ID.
246
+ * It calls the "ClientAccountID" transaction on the smart contract, which does not require any parameters.
247
+ * The returned data is then decoded and returned as a string.
248
+ *
249
+ * @returns {Promise<string>} A promise that resolves with the client's account ID.
250
+ *
251
+ * @throws {Error} If the transaction fails or the decoding process fails.
252
+ */
253
+ clientAccountID(): Promise<string>;
254
+ }