@massalabs/wallet-provider 1.2.1-dev.20230801093549 → 1.2.1-dev.20230803141012

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 (227) hide show
  1. package/bundle.js +5662 -5204
  2. package/bundle.min.js +3 -0
  3. package/dist/cmd/account/Account.d.ts +103 -0
  4. package/dist/cmd/account/Account.d.ts.map +1 -0
  5. package/dist/cmd/account/Account.js +179 -0
  6. package/dist/cmd/account/Account.js.map +1 -0
  7. package/dist/cmd/account/AccountBalance.d.ts +14 -0
  8. package/dist/cmd/account/AccountBalance.d.ts.map +1 -0
  9. package/dist/cmd/account/AccountBalance.js +3 -0
  10. package/dist/cmd/account/AccountBalance.js.map +1 -0
  11. package/dist/cmd/account/AccountSign.d.ts +16 -0
  12. package/dist/cmd/account/AccountSign.d.ts.map +1 -0
  13. package/dist/cmd/account/AccountSign.js +3 -0
  14. package/dist/cmd/account/AccountSign.js.map +1 -0
  15. package/dist/cmd/account/IAccount.d.ts +20 -0
  16. package/dist/cmd/account/IAccount.d.ts.map +1 -0
  17. package/dist/cmd/account/IAccount.js +3 -0
  18. package/dist/cmd/account/IAccount.js.map +1 -0
  19. package/dist/cmd/account/IAccountCallSCRequest.d.ts +25 -0
  20. package/dist/cmd/account/IAccountCallSCRequest.d.ts.map +1 -0
  21. package/dist/cmd/account/IAccountCallSCRequest.js +3 -0
  22. package/dist/cmd/account/IAccountCallSCRequest.js.map +1 -0
  23. package/dist/cmd/account/IAccountDetails.d.ts +8 -0
  24. package/dist/cmd/account/IAccountDetails.d.ts.map +1 -0
  25. package/dist/cmd/account/IAccountDetails.js +3 -0
  26. package/dist/cmd/account/IAccountDetails.js.map +1 -0
  27. package/dist/cmd/account/IAccountRolls.d.ts +8 -0
  28. package/dist/cmd/account/IAccountRolls.d.ts.map +1 -0
  29. package/dist/cmd/account/IAccountRolls.js +3 -0
  30. package/dist/cmd/account/IAccountRolls.js.map +1 -0
  31. package/dist/cmd/account/IAccountSendTransaction.d.ts +9 -0
  32. package/dist/cmd/account/IAccountSendTransaction.d.ts.map +1 -0
  33. package/dist/cmd/account/IAccountSendTransaction.js +3 -0
  34. package/dist/cmd/account/IAccountSendTransaction.js.map +1 -0
  35. package/dist/cmd/account/index.d.ts +9 -0
  36. package/dist/cmd/account/index.d.ts.map +1 -0
  37. package/dist/cmd/account/index.js +6 -0
  38. package/dist/cmd/account/index.js.map +1 -0
  39. package/dist/cmd/connector/Connector.d.ts +87 -0
  40. package/dist/cmd/connector/Connector.d.ts.map +1 -0
  41. package/dist/cmd/connector/Connector.js +173 -0
  42. package/dist/cmd/connector/Connector.js.map +1 -0
  43. package/dist/cmd/connector/ICustomEventMessageRequest.d.ts +10 -0
  44. package/dist/cmd/connector/ICustomEventMessageRequest.d.ts.map +1 -0
  45. package/dist/cmd/connector/ICustomEventMessageRequest.js +3 -0
  46. package/dist/cmd/connector/ICustomEventMessageRequest.js.map +1 -0
  47. package/dist/cmd/connector/ICustomEventMessageResponse.d.ts +11 -0
  48. package/dist/cmd/connector/ICustomEventMessageResponse.d.ts.map +1 -0
  49. package/dist/cmd/connector/ICustomEventMessageResponse.js +3 -0
  50. package/dist/cmd/connector/ICustomEventMessageResponse.js.map +1 -0
  51. package/dist/cmd/connector/IRegisterEvent.d.ts +8 -0
  52. package/dist/cmd/connector/IRegisterEvent.d.ts.map +1 -0
  53. package/dist/cmd/connector/IRegisterEvent.js +3 -0
  54. package/dist/cmd/connector/IRegisterEvent.js.map +1 -0
  55. package/dist/cmd/connector/index.d.ts +5 -0
  56. package/dist/cmd/connector/index.d.ts.map +1 -0
  57. package/dist/cmd/connector/index.js +7 -0
  58. package/dist/cmd/connector/index.js.map +1 -0
  59. package/dist/cmd/index.d.ts +48 -0
  60. package/dist/cmd/index.d.ts.map +1 -0
  61. package/dist/cmd/index.js +89 -0
  62. package/dist/cmd/index.js.map +1 -0
  63. package/dist/cmd/massaStation/MassaStationAccount.d.ts +103 -0
  64. package/dist/cmd/massaStation/MassaStationAccount.d.ts.map +1 -0
  65. package/dist/cmd/massaStation/MassaStationAccount.js +312 -0
  66. package/dist/cmd/massaStation/MassaStationAccount.js.map +1 -0
  67. package/dist/cmd/massaStation/MassaStationDiscovery.d.ts +57 -0
  68. package/dist/cmd/massaStation/MassaStationDiscovery.d.ts.map +1 -0
  69. package/dist/cmd/massaStation/MassaStationDiscovery.js +80 -0
  70. package/dist/cmd/massaStation/MassaStationDiscovery.js.map +1 -0
  71. package/dist/cmd/massaStation/MassaStationProvider.d.ts +91 -0
  72. package/dist/cmd/massaStation/MassaStationProvider.d.ts.map +1 -0
  73. package/dist/cmd/massaStation/MassaStationProvider.js +193 -0
  74. package/dist/cmd/massaStation/MassaStationProvider.js.map +1 -0
  75. package/dist/cmd/massaStation/RequestHandler.d.ts +47 -0
  76. package/dist/cmd/massaStation/RequestHandler.d.ts.map +1 -0
  77. package/dist/cmd/massaStation/RequestHandler.js +133 -0
  78. package/dist/cmd/massaStation/RequestHandler.js.map +1 -0
  79. package/dist/cmd/provider/AccountDeletion.d.ts +24 -0
  80. package/dist/cmd/provider/AccountDeletion.d.ts.map +1 -0
  81. package/dist/cmd/provider/AccountDeletion.js +14 -0
  82. package/dist/cmd/provider/AccountDeletion.js.map +1 -0
  83. package/dist/cmd/provider/AccountImport.d.ts +26 -0
  84. package/dist/cmd/provider/AccountImport.d.ts.map +1 -0
  85. package/dist/cmd/provider/AccountImport.js +14 -0
  86. package/dist/cmd/provider/AccountImport.js.map +1 -0
  87. package/dist/cmd/provider/AccoutGeneration.d.ts +8 -0
  88. package/dist/cmd/provider/AccoutGeneration.d.ts.map +1 -0
  89. package/dist/cmd/provider/AccoutGeneration.js +3 -0
  90. package/dist/cmd/provider/AccoutGeneration.js.map +1 -0
  91. package/dist/cmd/provider/IProvider.d.ts +16 -0
  92. package/dist/cmd/provider/IProvider.d.ts.map +1 -0
  93. package/dist/cmd/provider/IProvider.js +3 -0
  94. package/dist/cmd/provider/IProvider.js.map +1 -0
  95. package/dist/cmd/provider/Provider.d.ts +68 -0
  96. package/dist/cmd/provider/Provider.d.ts.map +1 -0
  97. package/dist/cmd/provider/Provider.js +126 -0
  98. package/dist/cmd/provider/Provider.js.map +1 -0
  99. package/dist/cmd/provider/index.d.ts +5 -0
  100. package/dist/cmd/provider/index.d.ts.map +1 -0
  101. package/dist/cmd/provider/index.js +10 -0
  102. package/dist/cmd/provider/index.js.map +1 -0
  103. package/dist/cmd/utils/argsToBase64.d.ts +16 -0
  104. package/dist/cmd/utils/argsToBase64.d.ts.map +1 -0
  105. package/dist/cmd/utils/argsToBase64.js +25 -0
  106. package/dist/cmd/utils/argsToBase64.js.map +1 -0
  107. package/dist/cmd/utils/time.d.ts +77 -0
  108. package/dist/cmd/utils/time.d.ts.map +1 -0
  109. package/dist/cmd/utils/time.js +120 -0
  110. package/dist/cmd/utils/time.js.map +1 -0
  111. package/dist/connector/Connector.d.ts +2 -0
  112. package/dist/connector/Connector.d.ts.map +1 -1
  113. package/dist/connector/Connector.js +13 -9
  114. package/dist/esm/account/Account.d.ts +103 -0
  115. package/dist/esm/account/Account.d.ts.map +1 -0
  116. package/dist/esm/account/Account.js +178 -0
  117. package/dist/esm/account/Account.js.map +1 -0
  118. package/dist/esm/account/AccountBalance.d.ts +14 -0
  119. package/dist/esm/account/AccountBalance.d.ts.map +1 -0
  120. package/dist/esm/account/AccountBalance.js +2 -0
  121. package/dist/esm/account/AccountBalance.js.map +1 -0
  122. package/dist/esm/account/AccountSign.d.ts +16 -0
  123. package/dist/esm/account/AccountSign.d.ts.map +1 -0
  124. package/dist/esm/account/AccountSign.js +2 -0
  125. package/dist/esm/account/AccountSign.js.map +1 -0
  126. package/dist/esm/account/IAccount.d.ts +20 -0
  127. package/dist/esm/account/IAccount.d.ts.map +1 -0
  128. package/dist/esm/account/IAccount.js +2 -0
  129. package/dist/esm/account/IAccount.js.map +1 -0
  130. package/dist/esm/account/IAccountCallSCRequest.d.ts +25 -0
  131. package/dist/esm/account/IAccountCallSCRequest.d.ts.map +1 -0
  132. package/dist/esm/account/IAccountCallSCRequest.js +2 -0
  133. package/dist/esm/account/IAccountCallSCRequest.js.map +1 -0
  134. package/dist/esm/account/IAccountDetails.d.ts +8 -0
  135. package/dist/esm/account/IAccountDetails.d.ts.map +1 -0
  136. package/dist/esm/account/IAccountDetails.js +2 -0
  137. package/dist/esm/account/IAccountDetails.js.map +1 -0
  138. package/dist/esm/account/IAccountRolls.d.ts +8 -0
  139. package/dist/esm/account/IAccountRolls.d.ts.map +1 -0
  140. package/dist/esm/account/IAccountRolls.js +2 -0
  141. package/dist/esm/account/IAccountRolls.js.map +1 -0
  142. package/dist/esm/account/IAccountSendTransaction.d.ts +9 -0
  143. package/dist/esm/account/IAccountSendTransaction.d.ts.map +1 -0
  144. package/dist/esm/account/IAccountSendTransaction.js +2 -0
  145. package/dist/esm/account/IAccountSendTransaction.js.map +1 -0
  146. package/dist/esm/account/index.d.ts +9 -0
  147. package/dist/esm/account/index.d.ts.map +1 -0
  148. package/dist/esm/account/index.js +2 -0
  149. package/dist/esm/account/index.js.map +1 -0
  150. package/dist/esm/connector/Connector.d.ts +87 -0
  151. package/dist/esm/connector/Connector.d.ts.map +1 -0
  152. package/dist/esm/connector/Connector.js +172 -0
  153. package/dist/esm/connector/Connector.js.map +1 -0
  154. package/dist/esm/connector/ICustomEventMessageRequest.d.ts +10 -0
  155. package/dist/esm/connector/ICustomEventMessageRequest.d.ts.map +1 -0
  156. package/dist/esm/connector/ICustomEventMessageRequest.js +2 -0
  157. package/dist/esm/connector/ICustomEventMessageRequest.js.map +1 -0
  158. package/dist/esm/connector/ICustomEventMessageResponse.d.ts +11 -0
  159. package/dist/esm/connector/ICustomEventMessageResponse.d.ts.map +1 -0
  160. package/dist/esm/connector/ICustomEventMessageResponse.js +2 -0
  161. package/dist/esm/connector/ICustomEventMessageResponse.js.map +1 -0
  162. package/dist/esm/connector/IRegisterEvent.d.ts +8 -0
  163. package/dist/esm/connector/IRegisterEvent.d.ts.map +1 -0
  164. package/dist/esm/connector/IRegisterEvent.js +2 -0
  165. package/dist/esm/connector/IRegisterEvent.js.map +1 -0
  166. package/dist/esm/connector/index.d.ts +5 -0
  167. package/dist/esm/connector/index.d.ts.map +1 -0
  168. package/dist/esm/connector/index.js +2 -0
  169. package/dist/esm/connector/index.js.map +1 -0
  170. package/dist/esm/index.d.ts +48 -0
  171. package/dist/esm/index.d.ts.map +1 -0
  172. package/dist/esm/index.js +79 -0
  173. package/dist/esm/index.js.map +1 -0
  174. package/dist/esm/massaStation/MassaStationAccount.d.ts +103 -0
  175. package/dist/esm/massaStation/MassaStationAccount.d.ts.map +1 -0
  176. package/dist/esm/massaStation/MassaStationAccount.js +311 -0
  177. package/dist/esm/massaStation/MassaStationAccount.js.map +1 -0
  178. package/dist/esm/massaStation/MassaStationDiscovery.d.ts +57 -0
  179. package/dist/esm/massaStation/MassaStationDiscovery.d.ts.map +1 -0
  180. package/dist/esm/massaStation/MassaStationDiscovery.js +76 -0
  181. package/dist/esm/massaStation/MassaStationDiscovery.js.map +1 -0
  182. package/dist/esm/massaStation/MassaStationProvider.d.ts +91 -0
  183. package/dist/esm/massaStation/MassaStationProvider.d.ts.map +1 -0
  184. package/dist/esm/massaStation/MassaStationProvider.js +190 -0
  185. package/dist/esm/massaStation/MassaStationProvider.js.map +1 -0
  186. package/dist/esm/massaStation/RequestHandler.d.ts +47 -0
  187. package/dist/esm/massaStation/RequestHandler.d.ts.map +1 -0
  188. package/dist/esm/massaStation/RequestHandler.js +126 -0
  189. package/dist/esm/massaStation/RequestHandler.js.map +1 -0
  190. package/dist/esm/provider/AccountDeletion.d.ts +24 -0
  191. package/dist/esm/provider/AccountDeletion.d.ts.map +1 -0
  192. package/dist/esm/provider/AccountDeletion.js +11 -0
  193. package/dist/esm/provider/AccountDeletion.js.map +1 -0
  194. package/dist/esm/provider/AccountImport.d.ts +26 -0
  195. package/dist/esm/provider/AccountImport.d.ts.map +1 -0
  196. package/dist/esm/provider/AccountImport.js +11 -0
  197. package/dist/esm/provider/AccountImport.js.map +1 -0
  198. package/dist/esm/provider/AccoutGeneration.d.ts +8 -0
  199. package/dist/esm/provider/AccoutGeneration.d.ts.map +1 -0
  200. package/dist/esm/provider/AccoutGeneration.js +2 -0
  201. package/dist/esm/provider/AccoutGeneration.js.map +1 -0
  202. package/dist/esm/provider/IProvider.d.ts +16 -0
  203. package/dist/esm/provider/IProvider.d.ts.map +1 -0
  204. package/dist/esm/provider/IProvider.js +2 -0
  205. package/dist/esm/provider/IProvider.js.map +1 -0
  206. package/dist/esm/provider/Provider.d.ts +68 -0
  207. package/dist/esm/provider/Provider.d.ts.map +1 -0
  208. package/dist/esm/provider/Provider.js +123 -0
  209. package/dist/esm/provider/Provider.js.map +1 -0
  210. package/dist/esm/provider/index.d.ts +5 -0
  211. package/dist/esm/provider/index.d.ts.map +1 -0
  212. package/dist/esm/provider/index.js +4 -0
  213. package/dist/esm/provider/index.js.map +1 -0
  214. package/dist/esm/utils/argsToBase64.d.ts +16 -0
  215. package/dist/esm/utils/argsToBase64.d.ts.map +1 -0
  216. package/dist/esm/utils/argsToBase64.js +20 -0
  217. package/dist/esm/utils/argsToBase64.js.map +1 -0
  218. package/dist/esm/utils/time.d.ts +77 -0
  219. package/dist/esm/utils/time.d.ts.map +1 -0
  220. package/dist/esm/utils/time.js +119 -0
  221. package/dist/esm/utils/time.js.map +1 -0
  222. package/dist/index.d.ts.map +1 -1
  223. package/dist/index.js +1 -0
  224. package/dist/massaStation/MassaStationDiscovery.d.ts +2 -16
  225. package/dist/massaStation/MassaStationDiscovery.d.ts.map +1 -1
  226. package/dist/massaStation/MassaStationDiscovery.js +4 -30
  227. package/package.json +11 -8
@@ -0,0 +1,87 @@
1
+ import { AvailableCommands, IAccountBalanceRequest, IAccountBalanceResponse, IAccountDeletionRequest, IAccountDeletionResponse, IAccountImportRequest, IAccountImportResponse, IAccountSignRequest, IAccountSignResponse } from '..';
2
+ import { IAccount } from '../account/IAccount';
3
+ /**
4
+ * A constant string that is used to identify the HTML element that is used for
5
+ * communication between the web page script and the content script.
6
+ */
7
+ export declare const MASSA_WINDOW_OBJECT = "massaWalletProvider";
8
+ type CallbackFunction = (result: AllowedResponses, error: Error | null) => unknown;
9
+ export type AllowedRequests = object | IAccountBalanceRequest | IAccountSignRequest | IAccountImportRequest | IAccountDeletionRequest;
10
+ export type AllowedResponses = object | IAccountBalanceResponse | IAccountSignResponse | IAccountImportResponse | IAccountDeletionResponse | IAccount[] | string;
11
+ /**
12
+ * This class enables communication with the content script by sending and receiving messages.
13
+ * @remarks
14
+ * - This class is used to send messages to the content script and to receive messages from the content script.
15
+ * - It is used to send messages to the content script and to receive messages from the content script.
16
+ *
17
+ */
18
+ declare class Connector {
19
+ private registeredProviders;
20
+ private pendingRequests;
21
+ private massaStationListener;
22
+ /**
23
+ * Connector constructor
24
+ *
25
+ * @remarks
26
+ * - The Connector constructor takes no arguments.
27
+ * - It creates a Map object that is used to store pending requests.
28
+ * - It creates an HTML element that is used to communicate with the content script.
29
+ * - It adds an event listener to the HTML element that is used to communicate with the content script.
30
+ *
31
+ * @returns An instance of the Connector class.
32
+ *
33
+ */
34
+ constructor();
35
+ /**
36
+ * This method adds a register listener in the web page.
37
+ * It listens to the 'register' event.
38
+ *
39
+ * @returns void
40
+ *
41
+ * @remarks
42
+ * - It is used to register a new provider.
43
+ * - This method creates a new HTML element and a listener that listens to the register event.
44
+ *
45
+ */
46
+ private register;
47
+ private initMassaStationListener;
48
+ startMassaStationDiscovery(): Promise<void>;
49
+ /**
50
+ * This method sends a message from the webpage script to the content script.
51
+ *
52
+ * @remarks
53
+ * Sends a message to the content script using the specified provider name, command, and parameters,
54
+ *
55
+ * @privateRemarks
56
+ * This method registers the response callback with a unique ID.
57
+ *
58
+ * @param providerName - The name of the provider.
59
+ * @param command - The command that is sent to the content script (among the {@link AvailableCommands}).
60
+ * @param params - The parameters that are sent to the content script.
61
+ * @param responseCallback - The callback function that is called when the content script sends a response.
62
+ * @returns void
63
+ *
64
+ */
65
+ sendMessageToContentScript(providerName: string, command: AvailableCommands, params: AllowedRequests, responseCallback: CallbackFunction): void;
66
+ /**
67
+ * This method returns the registered providers.
68
+ *
69
+ * @returns The registered provider associated with its unique key.
70
+ *
71
+ */
72
+ getWalletProviders(): {
73
+ [key: string]: string;
74
+ };
75
+ /**
76
+ * This method handles the response from the content script by
77
+ * calling the response callback with the response and error objects.
78
+ *
79
+ * @param event - The event that is sent from the content script.
80
+ * @returns void
81
+ *
82
+ */
83
+ private handleResponseFromContentScript;
84
+ }
85
+ export declare const connector: Connector;
86
+ export {};
87
+ //# sourceMappingURL=Connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/connector/Connector.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,IAAI,CAAC;AAOZ,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,KAAK,gBAAgB,GAAG,CACtB,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,KAAK,GAAG,IAAI,KAChB,OAAO,CAAC;AAEb,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,sBAAsB,GACtB,mBAAmB,GACnB,qBAAqB,GACrB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,uBAAuB,GACvB,oBAAoB,GACpB,sBAAsB,GACtB,wBAAwB,GACxB,QAAQ,EAAE,GACV,MAAM,CAAC;AAEX;;;;;;GAMG;AACH,cAAM,SAAS;IACb,OAAO,CAAC,mBAAmB,CAAiC;IAC5D,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,oBAAoB,CAAwB;IAEpD;;;;;;;;;;;OAWG;;IAgBH;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;IAqBhB,OAAO,CAAC,wBAAwB;IAWnB,0BAA0B;IAQvC;;;;;;;;;;;;;;;OAeG;IAEI,0BAA0B,CAC/B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,eAAe,EACvB,gBAAgB,EAAE,gBAAgB;IAgCpC;;;;;OAKG;IACI,kBAAkB,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAItD;;;;;;;OAOG;IACH,OAAO,CAAC,+BAA+B;CAuBxC;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * This file defines a TypeScript module named connector.
3
+ * It is the tool that allows the 'provider' and 'account' objects to communicate with the web page script.
4
+ *
5
+ * @remarks
6
+ * - If you are only looking to use our library, the connector object will not be useful to you.
7
+ * - If you want to work on this repo, you will probably be interested in this object
8
+ *
9
+ */
10
+ import { uid } from 'uid';
11
+ import { AvailableCommands, } from '..';
12
+ import { ON_MASSA_STATION_DISCOVERED, ON_MASSA_STATION_DISCONNECTED, MassaStationDiscovery, } from '../massaStation/MassaStationDiscovery';
13
+ import { MASSA_STATION_PROVIDER_NAME } from '../massaStation/MassaStationProvider';
14
+ /**
15
+ * A constant string that is used to identify the HTML element that is used for
16
+ * communication between the web page script and the content script.
17
+ */
18
+ export const MASSA_WINDOW_OBJECT = 'massaWalletProvider';
19
+ /**
20
+ * This class enables communication with the content script by sending and receiving messages.
21
+ * @remarks
22
+ * - This class is used to send messages to the content script and to receive messages from the content script.
23
+ * - It is used to send messages to the content script and to receive messages from the content script.
24
+ *
25
+ */
26
+ class Connector {
27
+ registeredProviders = {};
28
+ pendingRequests;
29
+ massaStationListener;
30
+ /**
31
+ * Connector constructor
32
+ *
33
+ * @remarks
34
+ * - The Connector constructor takes no arguments.
35
+ * - It creates a Map object that is used to store pending requests.
36
+ * - It creates an HTML element that is used to communicate with the content script.
37
+ * - It adds an event listener to the HTML element that is used to communicate with the content script.
38
+ *
39
+ * @returns An instance of the Connector class.
40
+ *
41
+ */
42
+ constructor() {
43
+ this.pendingRequests = new Map();
44
+ this.massaStationListener = new MassaStationDiscovery();
45
+ this.initMassaStationListener();
46
+ this.register();
47
+ // start listening to messages from content script
48
+ document
49
+ .getElementById(MASSA_WINDOW_OBJECT)
50
+ .addEventListener('message', this.handleResponseFromContentScript.bind(this));
51
+ }
52
+ /**
53
+ * This method adds a register listener in the web page.
54
+ * It listens to the 'register' event.
55
+ *
56
+ * @returns void
57
+ *
58
+ * @remarks
59
+ * - It is used to register a new provider.
60
+ * - This method creates a new HTML element and a listener that listens to the register event.
61
+ *
62
+ */
63
+ register() {
64
+ // global event target to use for all wallet provider
65
+ if (!document.getElementById(MASSA_WINDOW_OBJECT)) {
66
+ const inv = document.createElement('p');
67
+ inv.id = MASSA_WINDOW_OBJECT;
68
+ inv.setAttribute('style', 'display:none');
69
+ document.body.appendChild(inv);
70
+ }
71
+ // add an invisible HTML element and set a listener to it like the following
72
+ // hook up register handler
73
+ document
74
+ .getElementById(MASSA_WINDOW_OBJECT)
75
+ .addEventListener('register', (evt) => {
76
+ const payload = evt.detail;
77
+ const providerEventTargetName = `${MASSA_WINDOW_OBJECT}_${payload.providerName}`;
78
+ this.registeredProviders[payload.providerName] =
79
+ providerEventTargetName;
80
+ });
81
+ }
82
+ initMassaStationListener() {
83
+ this.massaStationListener.on(ON_MASSA_STATION_DISCOVERED, () => {
84
+ this.registeredProviders[MASSA_STATION_PROVIDER_NAME] = `${MASSA_WINDOW_OBJECT}_${MASSA_STATION_PROVIDER_NAME}`;
85
+ });
86
+ this.massaStationListener.on(ON_MASSA_STATION_DISCONNECTED, () => {
87
+ delete this.registeredProviders[MASSA_STATION_PROVIDER_NAME];
88
+ });
89
+ }
90
+ async startMassaStationDiscovery() {
91
+ try {
92
+ await this.massaStationListener.startListening();
93
+ }
94
+ catch (e) {
95
+ console.log('MassaStation is not detected');
96
+ }
97
+ }
98
+ /**
99
+ * This method sends a message from the webpage script to the content script.
100
+ *
101
+ * @remarks
102
+ * Sends a message to the content script using the specified provider name, command, and parameters,
103
+ *
104
+ * @privateRemarks
105
+ * This method registers the response callback with a unique ID.
106
+ *
107
+ * @param providerName - The name of the provider.
108
+ * @param command - The command that is sent to the content script (among the {@link AvailableCommands}).
109
+ * @param params - The parameters that are sent to the content script.
110
+ * @param responseCallback - The callback function that is called when the content script sends a response.
111
+ * @returns void
112
+ *
113
+ */
114
+ sendMessageToContentScript(providerName, command, params, responseCallback) {
115
+ if (!Object.values(AvailableCommands).includes(command)) {
116
+ throw new Error(`Unknown command ${command}`);
117
+ }
118
+ const requestId = uid();
119
+ const eventMessageRequest = {
120
+ params,
121
+ requestId,
122
+ };
123
+ this.pendingRequests.set(requestId, responseCallback);
124
+ // dispatch an event to the specific provider event target
125
+ const specificProviderEventTarget = document.getElementById(`${this.registeredProviders[providerName]}`);
126
+ if (!specificProviderEventTarget) {
127
+ throw new Error(`Registered provider with name ${providerName} does not exist`);
128
+ }
129
+ const isDispatched = specificProviderEventTarget.dispatchEvent(new CustomEvent(command, { detail: eventMessageRequest }));
130
+ if (!isDispatched) {
131
+ throw new Error(`Could not dispatch a message to ${this.registeredProviders[providerName]}`);
132
+ }
133
+ }
134
+ /**
135
+ * This method returns the registered providers.
136
+ *
137
+ * @returns The registered provider associated with its unique key.
138
+ *
139
+ */
140
+ getWalletProviders() {
141
+ return this.registeredProviders;
142
+ }
143
+ /**
144
+ * This method handles the response from the content script by
145
+ * calling the response callback with the response and error objects.
146
+ *
147
+ * @param event - The event that is sent from the content script.
148
+ * @returns void
149
+ *
150
+ */
151
+ handleResponseFromContentScript(event) {
152
+ const { result, error, requestId } = event.detail;
153
+ const responseCallback = this.pendingRequests.get(requestId);
154
+ if (responseCallback) {
155
+ if (error) {
156
+ responseCallback(null, new Error(error.message));
157
+ }
158
+ else {
159
+ responseCallback(result, null);
160
+ }
161
+ const deleted = this.pendingRequests.delete(requestId);
162
+ if (!deleted) {
163
+ console.error(`Error deleting a pending request with id ${requestId}`);
164
+ }
165
+ }
166
+ else {
167
+ console.error(`Request Id ${requestId} not found in response callback map`);
168
+ }
169
+ }
170
+ }
171
+ export const connector = new Connector();
172
+ //# sourceMappingURL=Connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connector.js","sourceRoot":"","sources":["../../../src/connector/Connector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAI1B,OAAO,EACL,iBAAiB,GASlB,MAAM,IAAI,CAAC;AACZ,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAGnF;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAuBzD;;;;;;GAMG;AACH,MAAM,SAAS;IACL,mBAAmB,GAA8B,EAAE,CAAC;IACpD,eAAe,CAAgC;IAC/C,oBAAoB,CAAwB;IAEpD;;;;;;;;;;;OAWG;IACH;QACE,IAAI,CAAC,eAAe,GAAG,IAAI,GAAG,EAA4B,CAAC;QAC3D,IAAI,CAAC,oBAAoB,GAAG,IAAI,qBAAqB,EAAE,CAAC;QACxD,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEhB,kDAAkD;QAClD,QAAQ;aACL,cAAc,CAAC,mBAAmB,CAAC;aACnC,gBAAgB,CACf,SAAS,EACT,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,CAChD,CAAC;IACN,CAAC;IAED;;;;;;;;;;OAUG;IACK,QAAQ;QACd,qDAAqD;QACrD,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC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;YACpB,IAAI,KAAK,EAAE;gBACT,gBAAgB,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;aAClD;iBAAM;gBACL,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAChC;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YACvD,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,CAAC,KAAK,CAAC,4CAA4C,SAAS,EAAE,CAAC,CAAC;aACxE;SACF;aAAM;YACL,OAAO,CAAC,KAAK,CACX,cAAc,SAAS,qCAAqC,CAC7D,CAAC;SACH;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC","sourcesContent":["/**\n * This file defines a TypeScript module named connector.\n * It is the tool that allows the 'provider' and 'account' objects to communicate with the web page script.\n *\n * @remarks\n * - If you are only looking to use our library, the connector object will not be useful to you.\n * - If you want to work on this repo, you will probably be interested in this object\n *\n */\nimport { uid } from 'uid';\nimport { ICustomEventMessageResponse } from './ICustomEventMessageResponse';\nimport { ICustomEventMessageRequest } from './ICustomEventMessageRequest';\nimport { IRegisterEvent } from './IRegisterEvent';\nimport {\n AvailableCommands,\n IAccountBalanceRequest,\n IAccountBalanceResponse,\n IAccountDeletionRequest,\n IAccountDeletionResponse,\n IAccountImportRequest,\n IAccountImportResponse,\n IAccountSignRequest,\n IAccountSignResponse,\n} from '..';\nimport {\n ON_MASSA_STATION_DISCOVERED,\n ON_MASSA_STATION_DISCONNECTED,\n MassaStationDiscovery,\n} from '../massaStation/MassaStationDiscovery';\nimport { MASSA_STATION_PROVIDER_NAME } from '../massaStation/MassaStationProvider';\nimport { IAccount } from '../account/IAccount';\n\n/**\n * A constant string that is used to identify the HTML element that is used for\n * communication between the web page script and the content script.\n */\nexport const MASSA_WINDOW_OBJECT = 'massaWalletProvider';\n\ntype CallbackFunction = (\n result: AllowedResponses,\n error: Error | null,\n) => unknown;\n\nexport type AllowedRequests =\n | object\n | IAccountBalanceRequest\n | IAccountSignRequest\n | IAccountImportRequest\n | IAccountDeletionRequest;\n\nexport type AllowedResponses =\n | object\n | IAccountBalanceResponse\n | IAccountSignResponse\n | IAccountImportResponse\n | IAccountDeletionResponse\n | IAccount[]\n | string;\n\n/**\n * This class enables communication with the content script by sending and receiving messages.\n * @remarks\n * - This class is used to send messages to the content script and to receive messages from the content script.\n * - It is used to send messages to the content script and to receive messages from the content script.\n *\n */\nclass Connector {\n private registeredProviders: { [key: string]: string } = {};\n private pendingRequests: Map<string, CallbackFunction>;\n private massaStationListener: MassaStationDiscovery;\n\n /**\n * Connector constructor\n *\n * @remarks\n * - The Connector constructor takes no arguments.\n * - It creates a Map object that is used to store pending requests.\n * - It creates an HTML element that is used to communicate with the content script.\n * - It adds an event listener to the HTML element that is used to communicate with the content script.\n *\n * @returns An instance of the Connector class.\n *\n */\n public constructor() {\n this.pendingRequests = new Map<string, CallbackFunction>();\n this.massaStationListener = new MassaStationDiscovery();\n this.initMassaStationListener();\n this.register();\n\n // start listening to messages from content script\n document\n .getElementById(MASSA_WINDOW_OBJECT)\n .addEventListener(\n 'message',\n this.handleResponseFromContentScript.bind(this),\n );\n }\n\n /**\n * This method adds a register listener in the web page.\n * It listens to the 'register' event.\n *\n * @returns void\n *\n * @remarks\n * - It is used to register a new provider.\n * - This method creates a new HTML element and a listener that listens to the register event.\n *\n */\n private register() {\n // global event target to use for all wallet provider\n if (!document.getElementById(MASSA_WINDOW_OBJECT)) {\n const inv = document.createElement('p');\n inv.id = MASSA_WINDOW_OBJECT;\n inv.setAttribute('style', 'display:none');\n document.body.appendChild(inv);\n }\n\n // add an invisible HTML element and set a listener to it like the following\n // hook up register handler\n document\n .getElementById(MASSA_WINDOW_OBJECT)\n .addEventListener('register', (evt: CustomEvent) => {\n const payload: IRegisterEvent = evt.detail;\n const providerEventTargetName = `${MASSA_WINDOW_OBJECT}_${payload.providerName}`;\n this.registeredProviders[payload.providerName] =\n providerEventTargetName;\n });\n }\n\n private initMassaStationListener() {\n this.massaStationListener.on(ON_MASSA_STATION_DISCOVERED, () => {\n this.registeredProviders[\n MASSA_STATION_PROVIDER_NAME\n ] = `${MASSA_WINDOW_OBJECT}_${MASSA_STATION_PROVIDER_NAME}`;\n });\n this.massaStationListener.on(ON_MASSA_STATION_DISCONNECTED, () => {\n delete this.registeredProviders[MASSA_STATION_PROVIDER_NAME];\n });\n }\n\n public async startMassaStationDiscovery() {\n try {\n await this.massaStationListener.startListening();\n } catch (e) {\n console.log('MassaStation is not detected');\n }\n }\n\n /**\n * This method sends a message from the webpage script to the content script.\n *\n * @remarks\n * Sends a message to the content script using the specified provider name, command, and parameters,\n *\n * @privateRemarks\n * This method registers the response callback with a unique ID.\n *\n * @param providerName - The name of the provider.\n * @param command - The command that is sent to the content script (among the {@link AvailableCommands}).\n * @param params - The parameters that are sent to the content script.\n * @param responseCallback - The callback function that is called when the content script sends a response.\n * @returns void\n *\n */\n\n public sendMessageToContentScript(\n providerName: string,\n command: AvailableCommands,\n params: AllowedRequests,\n responseCallback: CallbackFunction,\n ) {\n if (!Object.values(AvailableCommands).includes(command)) {\n throw new Error(`Unknown command ${command}`);\n }\n\n const requestId = uid();\n const eventMessageRequest: ICustomEventMessageRequest = {\n params,\n requestId,\n };\n this.pendingRequests.set(requestId, responseCallback);\n\n // dispatch an event to the specific provider event target\n const specificProviderEventTarget = document.getElementById(\n `${this.registeredProviders[providerName]}`,\n ) as EventTarget;\n if (!specificProviderEventTarget) {\n throw new Error(\n `Registered provider with name ${providerName} does not exist`,\n );\n }\n const isDispatched = specificProviderEventTarget.dispatchEvent(\n new CustomEvent(command, { detail: eventMessageRequest }),\n );\n if (!isDispatched) {\n throw new Error(\n `Could not dispatch a message to ${this.registeredProviders[providerName]}`,\n );\n }\n }\n\n /**\n * This method returns the registered providers.\n *\n * @returns The registered provider associated with its unique key.\n *\n */\n public getWalletProviders(): { [key: string]: string } {\n return this.registeredProviders;\n }\n\n /**\n * This method handles the response from the content script by\n * calling the response callback with the response and error objects.\n *\n * @param event - The event that is sent from the content script.\n * @returns void\n *\n */\n private handleResponseFromContentScript(event: CustomEvent) {\n const { result, error, requestId }: ICustomEventMessageResponse =\n event.detail;\n\n const responseCallback: CallbackFunction =\n this.pendingRequests.get(requestId);\n\n if (responseCallback) {\n if (error) {\n responseCallback(null, new Error(error.message));\n } else {\n responseCallback(result, null);\n }\n const deleted = this.pendingRequests.delete(requestId);\n if (!deleted) {\n console.error(`Error deleting a pending request with id ${requestId}`);\n }\n } else {\n console.error(\n `Request Id ${requestId} not found in response callback map`,\n );\n }\n }\n}\n\nexport const connector = new Connector();\n"]}
@@ -0,0 +1,10 @@
1
+ import { AllowedRequests } from './Connector';
2
+ /**
3
+ * This interface represents the request done by the web page script to the content script
4
+ * in order to setup a custom event.
5
+ */
6
+ export interface ICustomEventMessageRequest {
7
+ params: AllowedRequests;
8
+ requestId: string;
9
+ }
10
+ //# sourceMappingURL=ICustomEventMessageRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICustomEventMessageRequest.d.ts","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ICustomEventMessageRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICustomEventMessageRequest.js","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageRequest.ts"],"names":[],"mappings":"","sourcesContent":["import { AllowedRequests } from './Connector';\n\n/**\n * This interface represents the request done by the web page script to the content script\n * in order to setup a custom event.\n */\nexport interface ICustomEventMessageRequest {\n params: AllowedRequests;\n requestId: string;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { AllowedResponses } from './Connector';
2
+ /**
3
+ * This interface represents the response from the content script to the web page script
4
+ * for an ICustomEventMessageRequest.
5
+ */
6
+ export interface ICustomEventMessageResponse {
7
+ result?: AllowedResponses;
8
+ error?: Error;
9
+ requestId: string;
10
+ }
11
+ //# sourceMappingURL=ICustomEventMessageResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICustomEventMessageResponse.d.ts","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ICustomEventMessageResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICustomEventMessageResponse.js","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageResponse.ts"],"names":[],"mappings":"","sourcesContent":["import { AllowedResponses } from './Connector';\n\n/**\n * This interface represents the response from the content script to the web page script\n * for an ICustomEventMessageRequest.\n */\nexport interface ICustomEventMessageResponse {\n result?: AllowedResponses;\n error?: Error;\n requestId: string;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This interface represents the object that is used to register an event.
3
+ */
4
+ export interface IRegisterEvent {
5
+ providerName: string;
6
+ eventTarget: string;
7
+ }
8
+ //# sourceMappingURL=IRegisterEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRegisterEvent.d.ts","sourceRoot":"","sources":["../../../src/connector/IRegisterEvent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IRegisterEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRegisterEvent.js","sourceRoot":"","sources":["../../../src/connector/IRegisterEvent.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the object that is used to register an event.\n */\nexport interface IRegisterEvent {\n providerName: string;\n eventTarget: string;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export { connector, AllowedRequests, AllowedResponses, MASSA_WINDOW_OBJECT, } from './Connector';
2
+ export { ICustomEventMessageRequest } from './ICustomEventMessageRequest';
3
+ export { ICustomEventMessageResponse } from './ICustomEventMessageResponse';
4
+ export { IRegisterEvent } from './IRegisterEvent';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { connector, MASSA_WINDOW_OBJECT, } from './Connector';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAGT,mBAAmB,GACpB,MAAM,aAAa,CAAC","sourcesContent":["export {\n connector,\n AllowedRequests,\n AllowedResponses,\n MASSA_WINDOW_OBJECT,\n} from './Connector';\nexport { ICustomEventMessageRequest } from './ICustomEventMessageRequest';\nexport { ICustomEventMessageResponse } from './ICustomEventMessageResponse';\nexport { IRegisterEvent } from './IRegisterEvent';\n"]}
@@ -0,0 +1,48 @@
1
+ /// <reference types="node" />
2
+ /** Polyfills */
3
+ import { Buffer } from 'buffer';
4
+ declare global {
5
+ interface Window {
6
+ Buffer: typeof Buffer;
7
+ }
8
+ }
9
+ import { IProvider } from './provider/IProvider';
10
+ export declare enum AvailableCommands {
11
+ ProviderListAccounts = "LIST_ACCOUNTS",
12
+ ProviderDeleteAccount = "DELETE_ACCOUNT",
13
+ ProviderImportAccount = "IMPORT_ACCOUNT",
14
+ ProviderGetNodesUrls = "GET_NODES_URLS",
15
+ AccountBalance = "ACCOUNT_BALANCE",
16
+ AccountSign = "ACCOUNT_SIGN",
17
+ ProviderGenerateNewAccount = "GENERATE_NEW_ACCOUNT",
18
+ AccountSellRolls = "ACCOUNT_SELL_ROLLS",
19
+ AccountBuyRolls = "ACCOUNT_BUY_ROLLS",
20
+ AccountSendTransaction = "ACCOUNT_SEND_TRANSACTION",
21
+ AccountCallSC = "ACCOUNT_CALL_SC"
22
+ }
23
+ export interface ITransactionDetails {
24
+ operationId: string;
25
+ }
26
+ /**
27
+ * Get the list of providers that are available to interact with.
28
+ *
29
+ * @param retry - If true, will retry to get the list of providers if none are available.
30
+ * @param pollInterval - The timeout in milliseconds to wait between retries. default is 2000ms.
31
+ * @param timeout - The timeout in milliseconds to wait before giving up. default is 3000ms.
32
+ *
33
+ * @returns An array of providers.
34
+ */
35
+ export declare function providers(retry?: boolean, timeout?: number, pollInterval?: number): Promise<IProvider[]>;
36
+ /**
37
+ * Manually register a provider to interact with.
38
+ *
39
+ * @param name - The name of the provider.
40
+ * @param id - The id of the HTML element that is used to communicate with the provider.
41
+ */
42
+ export declare function registerProvider(name: string, id?: string): void;
43
+ export { AllowedRequests, AllowedResponses } from './connector';
44
+ export { IAccountDetails, IAccountBalanceRequest, IAccountBalanceResponse, IAccountSignRequest, IAccountSignResponse, IAccount, Account, IAccountRollsRequest, IAccountSendTransactionRequest, IAccountCallSCRequest, } from './account';
45
+ export { EAccountDeletionResponse, EAccountImportResponse, IAccountDeletionRequest, IAccountDeletionResponse, IAccountImportRequest, IAccountImportResponse, IProvider, Provider, } from './provider';
46
+ export { IMassaStationWallet } from './massaStation/MassaStationProvider';
47
+ export { MassaStationAccount } from './massaStation/MassaStationAccount';
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,gBAAgB;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,OAAO,MAAM,CAAC;KACvB;CACF;AAQD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAOjD,oBAAY,iBAAiB;IAC3B,oBAAoB,kBAAkB;IACtC,qBAAqB,mBAAmB;IACxC,qBAAqB,mBAAmB;IACxC,oBAAoB,mBAAmB;IACvC,cAAc,oBAAoB;IAClC,WAAW,iBAAiB;IAC5B,0BAA0B,yBAAyB;IACnD,gBAAgB,uBAAuB;IACvC,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,aAAa,oBAAoB;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,KAAK,UAAO,EACZ,OAAO,SAAO,EACd,YAAY,SAAM,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CA6BtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAsB,GAAG,IAAI,CAQ7E;AAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -0,0 +1,79 @@
1
+ /** Polyfills */
2
+ import { Buffer } from 'buffer';
3
+ // Check if we are on browser
4
+ if (typeof window !== 'undefined') {
5
+ window.Buffer = Buffer;
6
+ }
7
+ import { MASSA_WINDOW_OBJECT, connector } from './connector/Connector';
8
+ import { Provider } from './provider/Provider';
9
+ import { MASSA_STATION_PROVIDER_NAME, MassaStationProvider, } from './massaStation/MassaStationProvider';
10
+ export var AvailableCommands;
11
+ (function (AvailableCommands) {
12
+ AvailableCommands["ProviderListAccounts"] = "LIST_ACCOUNTS";
13
+ AvailableCommands["ProviderDeleteAccount"] = "DELETE_ACCOUNT";
14
+ AvailableCommands["ProviderImportAccount"] = "IMPORT_ACCOUNT";
15
+ AvailableCommands["ProviderGetNodesUrls"] = "GET_NODES_URLS";
16
+ AvailableCommands["AccountBalance"] = "ACCOUNT_BALANCE";
17
+ AvailableCommands["AccountSign"] = "ACCOUNT_SIGN";
18
+ AvailableCommands["ProviderGenerateNewAccount"] = "GENERATE_NEW_ACCOUNT";
19
+ AvailableCommands["AccountSellRolls"] = "ACCOUNT_SELL_ROLLS";
20
+ AvailableCommands["AccountBuyRolls"] = "ACCOUNT_BUY_ROLLS";
21
+ AvailableCommands["AccountSendTransaction"] = "ACCOUNT_SEND_TRANSACTION";
22
+ AvailableCommands["AccountCallSC"] = "ACCOUNT_CALL_SC";
23
+ })(AvailableCommands || (AvailableCommands = {}));
24
+ /**
25
+ * Get the list of providers that are available to interact with.
26
+ *
27
+ * @param retry - If true, will retry to get the list of providers if none are available.
28
+ * @param pollInterval - The timeout in milliseconds to wait between retries. default is 2000ms.
29
+ * @param timeout - The timeout in milliseconds to wait before giving up. default is 3000ms.
30
+ *
31
+ * @returns An array of providers.
32
+ */
33
+ export async function providers(retry = true, timeout = 3000, pollInterval = 500) {
34
+ if (timeout <= 0) {
35
+ return [];
36
+ }
37
+ await connector.startMassaStationDiscovery();
38
+ return new Promise((resolve) => {
39
+ let provider = [];
40
+ for (const providerName of Object.keys(connector.getWalletProviders())) {
41
+ if (providerName === MASSA_STATION_PROVIDER_NAME) {
42
+ const p = new MassaStationProvider();
43
+ provider.push(p);
44
+ }
45
+ else {
46
+ const p = new Provider(providerName);
47
+ provider.push(p);
48
+ }
49
+ }
50
+ // If no providers are available, wait and try again
51
+ if (retry && provider.length === 0) {
52
+ setTimeout(() => {
53
+ providers(retry, timeout - pollInterval, pollInterval).then(resolve);
54
+ }, pollInterval);
55
+ }
56
+ else {
57
+ resolve(provider);
58
+ }
59
+ });
60
+ }
61
+ /**
62
+ * Manually register a provider to interact with.
63
+ *
64
+ * @param name - The name of the provider.
65
+ * @param id - The id of the HTML element that is used to communicate with the provider.
66
+ */
67
+ export function registerProvider(name, id = MASSA_WINDOW_OBJECT) {
68
+ const registerEvent = new CustomEvent('register', {
69
+ detail: { providerName: name },
70
+ });
71
+ const element = document.getElementById(id);
72
+ if (element) {
73
+ element.dispatchEvent(registerEvent);
74
+ }
75
+ }
76
+ export { Account, } from './account';
77
+ export { EAccountDeletionResponse, EAccountImportResponse, Provider, } from './provider';
78
+ export { MassaStationAccount } from './massaStation/MassaStationAccount';
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQhC,6BAA6B;AAC7B,IAAI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C;gBACrC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aAClB;SACF;QAED,oDAAoD;QACpD,IAAI,KAAK,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,UAAU,CAAC,GAAG,EAAE;gBACd,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvE,CAAC,EAAE,YAAY,CAAC,CAAC;SAClB;aAAM;YACL,OAAO,CAAC,QAAQ,CAAC,CAAC;SACnB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,EAAE,GAAG,mBAAmB;IACrE,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,UAAU,EAAE;QAChD,MAAM,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;KAC/B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC5C,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;KACtC;AACH,CAAC;AAID,OAAO,EAOL,OAAO,GAIR,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EAMtB,QAAQ,GACT,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC","sourcesContent":["/** Polyfills */\nimport { Buffer } from 'buffer';\n\ndeclare global {\n interface Window {\n Buffer: typeof Buffer;\n }\n}\n\n// Check if we are on browser\nif (typeof window !== 'undefined') {\n window.Buffer = Buffer;\n}\n\nimport { MASSA_WINDOW_OBJECT, connector } from './connector/Connector';\nimport { IProvider } from './provider/IProvider';\nimport { Provider } from './provider/Provider';\nimport {\n MASSA_STATION_PROVIDER_NAME,\n MassaStationProvider,\n} from './massaStation/MassaStationProvider';\n\nexport enum AvailableCommands {\n ProviderListAccounts = 'LIST_ACCOUNTS',\n ProviderDeleteAccount = 'DELETE_ACCOUNT',\n ProviderImportAccount = 'IMPORT_ACCOUNT',\n ProviderGetNodesUrls = 'GET_NODES_URLS',\n AccountBalance = 'ACCOUNT_BALANCE',\n AccountSign = 'ACCOUNT_SIGN',\n ProviderGenerateNewAccount = 'GENERATE_NEW_ACCOUNT',\n AccountSellRolls = 'ACCOUNT_SELL_ROLLS',\n AccountBuyRolls = 'ACCOUNT_BUY_ROLLS',\n AccountSendTransaction = 'ACCOUNT_SEND_TRANSACTION',\n AccountCallSC = 'ACCOUNT_CALL_SC',\n}\n\nexport interface ITransactionDetails {\n operationId: string;\n}\n\n/**\n * Get the list of providers that are available to interact with.\n *\n * @param retry - If true, will retry to get the list of providers if none are available.\n * @param pollInterval - The timeout in milliseconds to wait between retries. default is 2000ms.\n * @param timeout - The timeout in milliseconds to wait before giving up. default is 3000ms.\n *\n * @returns An array of providers.\n */\nexport async function providers(\n retry = true,\n timeout = 3000,\n pollInterval = 500,\n): Promise<IProvider[]> {\n if (timeout <= 0) {\n return [];\n }\n\n await connector.startMassaStationDiscovery();\n\n return new Promise((resolve) => {\n let provider: IProvider[] = [];\n\n for (const providerName of Object.keys(connector.getWalletProviders())) {\n if (providerName === MASSA_STATION_PROVIDER_NAME) {\n const p = new MassaStationProvider();\n provider.push(p);\n } else {\n const p = new Provider(providerName);\n provider.push(p);\n }\n }\n\n // If no providers are available, wait and try again\n if (retry && provider.length === 0) {\n setTimeout(() => {\n providers(retry, timeout - pollInterval, pollInterval).then(resolve);\n }, pollInterval);\n } else {\n resolve(provider);\n }\n });\n}\n\n/**\n * Manually register a provider to interact with.\n *\n * @param name - The name of the provider.\n * @param id - The id of the HTML element that is used to communicate with the provider.\n */\nexport function registerProvider(name: string, id = MASSA_WINDOW_OBJECT): void {\n const registerEvent = new CustomEvent('register', {\n detail: { providerName: name },\n });\n const element = document.getElementById(id);\n if (element) {\n element.dispatchEvent(registerEvent);\n }\n}\n\nexport { AllowedRequests, AllowedResponses } from './connector';\n\nexport {\n IAccountDetails,\n IAccountBalanceRequest,\n IAccountBalanceResponse,\n IAccountSignRequest,\n IAccountSignResponse,\n IAccount,\n Account,\n IAccountRollsRequest,\n IAccountSendTransactionRequest,\n IAccountCallSCRequest,\n} from './account';\n\nexport {\n EAccountDeletionResponse,\n EAccountImportResponse,\n IAccountDeletionRequest,\n IAccountDeletionResponse,\n IAccountImportRequest,\n IAccountImportResponse,\n IProvider,\n Provider,\n} from './provider';\n\nexport { IMassaStationWallet } from './massaStation/MassaStationProvider';\n\nexport { MassaStationAccount } from './massaStation/MassaStationAccount';\n"]}
@@ -0,0 +1,103 @@
1
+ import { IAccountBalanceResponse, IAccountDetails, IAccountSignResponse, ITransactionDetails } from '..';
2
+ import { IAccount } from '../account/IAccount';
3
+ import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
4
+ /**
5
+ * This module contains the MassaStationAccount class. It is responsible for representing an account in
6
+ * the MassaStation wallet.
7
+ *
8
+ * @remarks
9
+ * This class provides methods to interact with MassaStation account's {@link balance} and to {@link sign} messages.
10
+ *
11
+ */
12
+ export declare class MassaStationAccount implements IAccount {
13
+ private _providerName;
14
+ private _address;
15
+ private _name;
16
+ /**
17
+ * This constructor takes an object of type IAccountDetails and a providerName string as its arguments.
18
+ *
19
+ * @param address - The address of the account.
20
+ * @param name - The name of the account.
21
+ * @param providerName - The name of the provider.
22
+ * @returns An instance of the Account class.
23
+ *
24
+ * @remarks
25
+ * - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.
26
+ * - The IAccountDetails object contains the account's address and name.
27
+ * - The providerName string identifies the provider that is used to interact with the blockchain.
28
+ */
29
+ constructor({ address, name }: IAccountDetails, providerName: string);
30
+ /**
31
+ * @returns The address of the account.
32
+ */
33
+ address(): string;
34
+ /**
35
+ * @returns The name of the account.
36
+ */
37
+ name(): string;
38
+ /**
39
+ * @returns The name of the provider.
40
+ */
41
+ providerName(): string;
42
+ /**
43
+ * This method aims to retrieve the account's balance.
44
+ *
45
+ * @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.
46
+ */
47
+ balance(): Promise<IAccountBalanceResponse>;
48
+ /**
49
+ * This method aims to sign a message.
50
+ *
51
+ * @param data - The message to be signed.
52
+ * @returns An IAccountSignResponse object. It contains the signature of the message.
53
+ */
54
+ sign(data: Uint8Array | string): Promise<IAccountSignResponse>;
55
+ /**
56
+ * This method aims to buy rolls on behalf of the sender.
57
+ *
58
+ * @param amount - The amount of rolls to be bought.
59
+ * @param fee - The fee to be paid for the transaction execution by the node.
60
+ * @returns An ITransactionDetails object. It contains the operationId on the network.
61
+ */
62
+ buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
63
+ /**
64
+ * This method aims to sell rolls on behalf of the sender.
65
+ *
66
+ * @param amount - The amount of rolls to be sold.
67
+ * @param fee - The fee to be paid for the transaction execution by the node.
68
+ * @returns An ITransactionDetails object. It contains the operationId on the network.
69
+ */
70
+ sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
71
+ /**
72
+ * This method aims to transfer MAS on behalf of the sender to a recipient.
73
+ *
74
+ * @param amount - The amount of MAS (in the smallest unit) to be transferred.
75
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
76
+ * @returns An ITransactionDetails object. It contains the operationId on the network.
77
+ */
78
+ sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
79
+ /**
80
+ * This method aims to interact with a smart contract deployed on the MASSA blockchain.
81
+ *
82
+ * @remarks
83
+ * If dryRun.dryRun is true, the method will dry run the smart contract call and return an
84
+ * IContractReadOperationResponse object which contains all the information about the dry run
85
+ * (state changes, gas used, etc.)
86
+ *
87
+ * @param contractAddress - The address of the smart contract.
88
+ * @param functionName - The name of the function to be called.
89
+ * @param parameter - The parameters as an Args object to be passed to the function.
90
+ * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
91
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
92
+ * @param maxGas - The maximum amount of gas to be used for the transaction execution.
93
+ * @param nonPersistentExecution - The dryRun object to be passed to the function.
94
+ *
95
+ * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
96
+ * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
97
+ *
98
+ */
99
+ callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint, nonPersistentExecution?: boolean): Promise<ITransactionDetails | IContractReadOperationResponse>;
100
+ getNodeUrlFromMassaStation(): Promise<string>;
101
+ nonPersistentCallSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint): Promise<IContractReadOperationResponse>;
102
+ }
103
+ //# sourceMappingURL=MassaStationAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MassaStationAccount.d.ts","sourceRoot":"","sources":["../../../src/massaStation/MassaStationAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM/C,OAAO,EACL,IAAI,EAEJ,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAoC/B;;;;;;;GAOG;AACH,qBAAa,mBAAoB,YAAW,QAAQ;IAClD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IAEtB;;;;;;;;;;;;OAYG;gBACgB,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM;IAM3E;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACI,IAAI,IAAI,MAAM;IAIrB;;OAEG;IACI,YAAY,IAAI,MAAM;IAI7B;;;;OAIG;IACU,OAAO,IAAI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