@aeternity/aepp-sdk 12.0.0 → 12.1.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 (283) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -15
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +2 -1
  5. package/dist/aepp-sdk.browser.js.LICENSE.txt +1 -0
  6. package/dist/aepp-sdk.browser.js.map +1 -1
  7. package/dist/aepp-sdk.js +20765 -1
  8. package/dist/aepp-sdk.js.map +1 -1
  9. package/es/AeSdk.d.ts +7 -7
  10. package/es/AeSdk.mjs.map +1 -1
  11. package/es/AeSdkAepp.d.ts +4 -3
  12. package/es/AeSdkAepp.mjs +2 -1
  13. package/es/AeSdkAepp.mjs.map +1 -1
  14. package/es/AeSdkBase.d.ts +22 -21
  15. package/es/AeSdkBase.mjs +25 -21
  16. package/es/AeSdkBase.mjs.map +1 -1
  17. package/es/AeSdkWallet.d.ts +4 -3
  18. package/es/AeSdkWallet.mjs +5 -1
  19. package/es/AeSdkWallet.mjs.map +1 -1
  20. package/es/Node.d.ts +7 -10
  21. package/es/Node.mjs +63 -57
  22. package/es/Node.mjs.map +1 -1
  23. package/es/account/Base.d.ts +7 -4
  24. package/es/account/Base.mjs +3 -3
  25. package/es/account/Base.mjs.map +1 -1
  26. package/es/account/Memory.d.ts +5 -4
  27. package/es/account/Memory.mjs +24 -2
  28. package/es/account/Memory.mjs.map +1 -1
  29. package/es/account/Rpc.d.ts +6 -6
  30. package/es/account/Rpc.mjs +3 -2
  31. package/es/account/Rpc.mjs.map +1 -1
  32. package/es/aens.d.ts +27 -14
  33. package/es/aens.mjs +27 -21
  34. package/es/aens.mjs.map +1 -1
  35. package/es/aepp-wallet-communication/connection/Browser.d.ts +2 -1
  36. package/es/aepp-wallet-communication/connection/Browser.mjs +5 -2
  37. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  38. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +1 -0
  39. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  41. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -0
  42. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +5 -1
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  44. package/es/aepp-wallet-communication/connection-proxy.d.ts +1 -0
  45. package/es/aepp-wallet-communication/connection-proxy.mjs +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  47. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +1 -0
  48. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +5 -5
  49. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/rpc/types.d.ts +8 -8
  51. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  52. package/es/aepp-wallet-communication/schema.d.ts +17 -2
  53. package/es/aepp-wallet-communication/schema.mjs +54 -17
  54. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  55. package/es/aepp-wallet-communication/wallet-detector.d.ts +2 -1
  56. package/es/aepp-wallet-communication/wallet-detector.mjs +2 -3
  57. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  58. package/es/apis/node/models/index.d.ts +6 -2
  59. package/es/apis/node/models/index.mjs.map +1 -1
  60. package/es/apis/node/models/mappers.mjs +4 -2
  61. package/es/apis/node/models/mappers.mjs.map +1 -1
  62. package/es/chain.d.ts +92 -64
  63. package/es/chain.mjs +190 -154
  64. package/es/chain.mjs.map +1 -1
  65. package/es/channel/handlers.d.ts +3 -3
  66. package/es/channel/handlers.mjs +42 -44
  67. package/es/channel/handlers.mjs.map +1 -1
  68. package/es/channel/index.d.ts +43 -52
  69. package/es/channel/index.mjs +46 -49
  70. package/es/channel/index.mjs.map +1 -1
  71. package/es/channel/internal.d.ts +16 -15
  72. package/es/channel/internal.mjs +67 -62
  73. package/es/channel/internal.mjs.map +1 -1
  74. package/es/contract/Compiler.d.ts +1 -0
  75. package/es/contract/Compiler.mjs +5 -4
  76. package/es/contract/Compiler.mjs.map +1 -1
  77. package/es/contract/aci.d.ts +17 -15
  78. package/es/contract/aci.mjs +58 -45
  79. package/es/contract/aci.mjs.map +1 -1
  80. package/es/contract/ga.d.ts +16 -15
  81. package/es/contract/ga.mjs +12 -7
  82. package/es/contract/ga.mjs.map +1 -1
  83. package/es/contract/methods.d.ts +9 -6
  84. package/es/contract/methods.mjs +9 -6
  85. package/es/contract/methods.mjs.map +1 -1
  86. package/es/deprecated/index.d.ts +143 -0
  87. package/es/deprecated/index.mjs +162 -0
  88. package/es/deprecated/index.mjs.map +1 -0
  89. package/es/deprecated/methods.d.ts +18 -0
  90. package/es/deprecated/methods.mjs +26 -0
  91. package/es/deprecated/methods.mjs.map +1 -0
  92. package/es/index.d.ts +4 -1
  93. package/es/index.mjs +4 -1
  94. package/es/index.mjs.map +1 -1
  95. package/es/oracle.d.ts +69 -62
  96. package/es/oracle.mjs +121 -103
  97. package/es/oracle.mjs.map +1 -1
  98. package/es/spend.d.ts +16 -15
  99. package/es/spend.mjs +19 -30
  100. package/es/spend.mjs.map +1 -1
  101. package/es/tx/builder/address.d.ts +25 -0
  102. package/es/tx/builder/address.mjs +45 -0
  103. package/es/tx/builder/address.mjs.map +1 -0
  104. package/es/tx/builder/constants.d.ts +55 -26
  105. package/es/tx/builder/constants.mjs +60 -38
  106. package/es/tx/builder/constants.mjs.map +1 -1
  107. package/es/tx/builder/field-types/coin-amount.d.ts +13 -0
  108. package/es/tx/builder/field-types/coin-amount.mjs +26 -0
  109. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -0
  110. package/es/tx/builder/field-types/deposit.d.ts +15 -0
  111. package/es/tx/builder/field-types/deposit.mjs +19 -0
  112. package/es/tx/builder/field-types/deposit.mjs.map +1 -0
  113. package/es/tx/builder/field-types/fee.d.ts +25 -0
  114. package/es/tx/{min-fee.mjs → builder/field-types/fee.mjs} +62 -60
  115. package/es/tx/builder/field-types/fee.mjs.map +1 -0
  116. package/es/tx/builder/field-types/field.d.ts +6 -0
  117. package/es/tx/builder/field-types/field.mjs +15 -0
  118. package/es/tx/builder/field-types/field.mjs.map +1 -0
  119. package/es/tx/builder/field-types/gas-limit.d.ts +12 -0
  120. package/es/tx/builder/field-types/gas-limit.mjs +33 -0
  121. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -0
  122. package/es/tx/builder/field-types/gas-price.d.ts +8 -0
  123. package/es/tx/builder/field-types/gas-price.mjs +18 -0
  124. package/es/tx/builder/field-types/gas-price.mjs.map +1 -0
  125. package/es/tx/builder/field-types/index.d.ts +70 -0
  126. package/es/tx/builder/field-types/index.mjs +25 -0
  127. package/es/tx/builder/field-types/index.mjs.map +1 -0
  128. package/es/tx/builder/field-types/name-fee.d.ts +20 -0
  129. package/es/tx/builder/field-types/name-fee.mjs +24 -0
  130. package/es/tx/builder/field-types/name-fee.mjs.map +1 -0
  131. package/es/tx/builder/field-types/name-id.d.ts +14 -0
  132. package/es/tx/builder/field-types/name-id.mjs +19 -0
  133. package/es/tx/builder/field-types/name-id.mjs.map +1 -0
  134. package/es/tx/builder/field-types/name.d.ts +13 -0
  135. package/es/tx/builder/field-types/name.mjs +18 -0
  136. package/es/tx/builder/field-types/name.mjs.map +1 -0
  137. package/es/tx/builder/field-types/short-u-int.d.ts +6 -0
  138. package/es/tx/builder/field-types/short-u-int.mjs +12 -0
  139. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -0
  140. package/es/tx/builder/field-types/u-int.d.ts +8 -0
  141. package/es/tx/builder/field-types/u-int.mjs +14 -0
  142. package/es/tx/builder/field-types/u-int.mjs.map +1 -0
  143. package/es/tx/builder/helpers.d.ts +27 -33
  144. package/es/tx/builder/helpers.mjs +41 -47
  145. package/es/tx/builder/helpers.mjs.map +1 -1
  146. package/es/tx/builder/index.d.ts +25 -12
  147. package/es/tx/builder/index.mjs +74 -83
  148. package/es/tx/builder/index.mjs.map +1 -1
  149. package/es/tx/builder/schema.d.ts +995 -144
  150. package/es/tx/builder/schema.mjs +121 -170
  151. package/es/tx/builder/schema.mjs.map +1 -1
  152. package/es/tx/index.d.ts +28 -27
  153. package/es/tx/index.mjs +97 -117
  154. package/es/tx/index.mjs.map +1 -1
  155. package/es/tx/validator.d.ts +4 -3
  156. package/es/tx/validator.mjs +79 -92
  157. package/es/tx/validator.mjs.map +1 -1
  158. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -1
  159. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -1
  160. package/es/typings/bip32-path/index.d.mjs.map +1 -1
  161. package/es/typings/blakejs/index.d.mjs.map +1 -1
  162. package/es/typings/sha-js/index.d.mjs +2 -0
  163. package/es/typings/sha-js/index.d.mjs.map +1 -0
  164. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -1
  165. package/es/utils/amount-formatter.d.ts +9 -9
  166. package/es/utils/amount-formatter.mjs +17 -17
  167. package/es/utils/amount-formatter.mjs.map +1 -1
  168. package/es/utils/autorest.mjs +7 -7
  169. package/es/utils/autorest.mjs.map +1 -1
  170. package/es/utils/bignumber.mjs +2 -1
  171. package/es/utils/bignumber.mjs.map +1 -1
  172. package/es/utils/bytes.mjs +1 -1
  173. package/es/utils/bytes.mjs.map +1 -1
  174. package/es/utils/crypto.d.ts +8 -23
  175. package/es/utils/crypto.mjs +15 -41
  176. package/es/utils/crypto.mjs.map +1 -1
  177. package/es/utils/encoder-types.d.ts +61 -0
  178. package/es/utils/encoder-types.mjs +36 -0
  179. package/es/utils/encoder-types.mjs.map +1 -0
  180. package/es/utils/encoder.d.ts +6 -7
  181. package/es/utils/encoder.mjs +42 -26
  182. package/es/utils/encoder.mjs.map +1 -1
  183. package/es/utils/errors.d.ts +1 -11
  184. package/es/utils/errors.mjs +4 -20
  185. package/es/utils/errors.mjs.map +1 -1
  186. package/es/utils/hd-wallet.d.ts +18 -2
  187. package/es/utils/hd-wallet.mjs +64 -34
  188. package/es/utils/hd-wallet.mjs.map +1 -1
  189. package/es/utils/json-big.mjs +2 -2
  190. package/es/utils/json-big.mjs.map +1 -1
  191. package/es/utils/keystore.mjs +4 -2
  192. package/es/utils/keystore.mjs.map +1 -1
  193. package/es/utils/mptree.d.ts +2 -2
  194. package/es/utils/mptree.mjs +11 -6
  195. package/es/utils/mptree.mjs.map +1 -1
  196. package/es/utils/other.d.ts +8 -2
  197. package/es/utils/other.mjs +15 -3
  198. package/es/utils/other.mjs.map +1 -1
  199. package/es/utils/semver-satisfies.d.ts +1 -1
  200. package/es/utils/semver-satisfies.mjs +2 -2
  201. package/es/utils/semver-satisfies.mjs.map +1 -1
  202. package/es/utils/string.mjs.map +1 -1
  203. package/package.json +36 -34
  204. package/src/AeSdk.ts +30 -27
  205. package/src/AeSdkAepp.ts +93 -84
  206. package/src/AeSdkBase.ts +148 -130
  207. package/src/AeSdkWallet.ts +172 -156
  208. package/src/Node.ts +108 -102
  209. package/src/account/Base.ts +42 -32
  210. package/src/account/Memory.ts +45 -30
  211. package/src/account/Rpc.ts +32 -30
  212. package/src/aens.ts +124 -108
  213. package/src/aepp-wallet-communication/connection/Browser.ts +18 -15
  214. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +22 -21
  215. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +63 -52
  216. package/src/aepp-wallet-communication/connection-proxy.ts +8 -7
  217. package/src/aepp-wallet-communication/rpc/RpcClient.ts +67 -61
  218. package/src/aepp-wallet-communication/rpc/types.ts +32 -32
  219. package/src/aepp-wallet-communication/schema.ts +117 -74
  220. package/src/aepp-wallet-communication/wallet-detector.ts +29 -28
  221. package/src/apis/node/code-model-v4.yaml +54 -20
  222. package/src/apis/node/models/index.ts +6 -2
  223. package/src/apis/node/models/mappers.ts +4 -2
  224. package/src/chain.ts +286 -228
  225. package/src/channel/handlers.ts +424 -372
  226. package/src/channel/index.ts +285 -251
  227. package/src/channel/internal.ts +248 -232
  228. package/src/contract/Compiler.ts +22 -21
  229. package/src/contract/aci.ts +267 -258
  230. package/src/contract/ga.ts +93 -72
  231. package/src/contract/methods.ts +32 -27
  232. package/src/deprecated/index.ts +172 -0
  233. package/src/deprecated/methods.ts +25 -0
  234. package/src/index.ts +37 -32
  235. package/src/oracle.ts +211 -189
  236. package/src/spend.ts +82 -70
  237. package/src/tx/builder/address.ts +50 -0
  238. package/src/tx/builder/constants.ts +82 -52
  239. package/src/tx/builder/field-types/coin-amount.ts +27 -0
  240. package/src/tx/builder/field-types/deposit.ts +21 -0
  241. package/src/tx/builder/field-types/fee.ts +143 -0
  242. package/src/tx/builder/field-types/field.ts +9 -0
  243. package/src/tx/builder/field-types/gas-limit.ts +41 -0
  244. package/src/tx/builder/field-types/gas-price.ts +16 -0
  245. package/src/tx/builder/field-types/index.ts +45 -0
  246. package/src/tx/builder/field-types/name-fee.ts +32 -0
  247. package/src/tx/builder/field-types/name-id.ts +20 -0
  248. package/src/tx/builder/field-types/name.ts +18 -0
  249. package/src/tx/builder/field-types/short-u-int.ts +11 -0
  250. package/src/tx/builder/field-types/u-int.ts +16 -0
  251. package/src/tx/builder/helpers.ts +112 -117
  252. package/src/tx/builder/index.ts +203 -197
  253. package/src/tx/builder/schema.ts +421 -465
  254. package/src/tx/index.ts +128 -135
  255. package/src/tx/validator.ts +165 -161
  256. package/src/typings/@aeternity__argon2-browser/index.d.ts +1 -1
  257. package/src/typings/@aeternity__uuid/index.d.ts +3 -1
  258. package/src/typings/bip32-path/index.d.ts +6 -6
  259. package/src/typings/blakejs/index.d.ts +4 -32
  260. package/src/typings/sha-js/index.d.ts +5 -0
  261. package/src/typings/tweetnacl-auth/index.d.ts +2 -2
  262. package/src/utils/amount-formatter.ts +41 -41
  263. package/src/utils/autorest.ts +57 -54
  264. package/src/utils/bignumber.ts +7 -6
  265. package/src/utils/bytes.ts +19 -19
  266. package/src/utils/crypto.ts +82 -94
  267. package/src/utils/encoder-types.ts +63 -0
  268. package/src/utils/encoder.ts +104 -56
  269. package/src/utils/errors.ts +246 -264
  270. package/src/utils/hd-wallet.ts +114 -82
  271. package/src/utils/json-big.ts +16 -15
  272. package/src/utils/keystore.ts +65 -62
  273. package/src/utils/mptree.ts +59 -56
  274. package/src/utils/other.ts +26 -18
  275. package/src/utils/semver-satisfies.ts +15 -11
  276. package/src/utils/string.ts +10 -10
  277. package/es/tx/builder/field-types.d.ts +0 -62
  278. package/es/tx/builder/field-types.mjs +0 -126
  279. package/es/tx/builder/field-types.mjs.map +0 -1
  280. package/es/tx/min-fee.d.ts +0 -20
  281. package/es/tx/min-fee.mjs.map +0 -1
  282. package/src/tx/builder/field-types.ts +0 -111
  283. package/src/tx/min-fee.ts +0 -136
@@ -1,21 +1,34 @@
1
- import { EncodedData } from '../utils/encoder'
2
- import { BaseError, InternalError } from '../utils/errors'
1
+ // eslint-disable-next-line max-classes-per-file
2
+ import { Encoded } from '../utils/encoder';
3
+ import { BaseError, InternalError } from '../utils/errors';
3
4
 
5
+ /**
6
+ * @category aepp wallet communication
7
+ */
4
8
  export const enum MESSAGE_DIRECTION {
5
9
  to_waellet = 'to_waellet',
6
- to_aepp = 'to_aepp'
10
+ to_aepp = 'to_aepp',
7
11
  }
8
12
 
13
+ /**
14
+ * @category aepp wallet communication
15
+ */
9
16
  export const enum WALLET_TYPE {
10
17
  window = 'window',
11
- extension = 'extension'
18
+ extension = 'extension',
12
19
  }
13
20
 
21
+ /**
22
+ * @category aepp wallet communication
23
+ */
14
24
  export const enum SUBSCRIPTION_TYPES {
15
25
  subscribe = 'subscribe',
16
- unsubscribe = 'unsubscribe'
26
+ unsubscribe = 'unsubscribe',
17
27
  }
18
28
 
29
+ /**
30
+ * @category aepp wallet communication
31
+ */
19
32
  export const enum METHODS {
20
33
  readyToConnect = 'connection.announcePresence',
21
34
  updateAddress = 'address.update',
@@ -25,45 +38,48 @@ export const enum METHODS {
25
38
  signMessage = 'message.sign',
26
39
  subscribeAddress = 'address.subscribe',
27
40
  updateNetwork = 'networkId.update',
28
- closeConnection = 'connection.close'
41
+ closeConnection = 'connection.close',
29
42
  }
30
43
 
44
+ /**
45
+ * @category aepp wallet communication
46
+ */
31
47
  export const enum RPC_STATUS {
32
48
  CONNECTED = 'CONNECTED',
33
49
  DISCONNECTED = 'DISCONNECTED',
34
- WAITING_FOR_CONNECTION_REQUEST = 'WAITING_FOR_CONNECTION_REQUEST'
50
+ WAITING_FOR_CONNECTION_REQUEST = 'WAITING_FOR_CONNECTION_REQUEST',
35
51
  }
36
52
 
37
53
  interface RpcErrorAsJson {
38
- code: number
39
- message: string
40
- data?: any
54
+ code: number;
55
+ message: string;
56
+ data?: any;
41
57
  }
42
58
 
59
+ const rpcErrors: Array<(new (data?: any) => RpcError) & { code: number }> = [];
60
+
43
61
  /**
44
62
  * @category exception
45
63
  */
46
64
  export abstract class RpcError extends BaseError {
47
- static code: number
48
- code: number
49
- data?: any
65
+ static code: number;
66
+
67
+ code: number;
50
68
 
51
- toJSON (): RpcErrorAsJson {
69
+ data?: any;
70
+
71
+ toJSON(): RpcErrorAsJson {
52
72
  return {
53
73
  code: this.code,
54
74
  message: this.message,
55
- data: this.data
56
- }
75
+ data: this.data,
76
+ };
57
77
  }
58
78
 
59
- static deserialize (json: RpcErrorAsJson): RpcError {
60
- const RpcErr = [
61
- RpcInvalidTransactionError, RpcBroadcastError, RpcRejectedByUserError,
62
- RpcUnsupportedProtocolError, RpcConnectionDenyError, RpcNotAuthorizeError,
63
- RpcPermissionDenyError, RpcInternalError
64
- ].find(cl => cl.code === json.code)
65
- if (RpcErr == null) throw new InternalError(`Can't find RpcError with code: ${json.code}`)
66
- return new RpcErr(json.data)
79
+ static deserialize(json: RpcErrorAsJson): RpcError {
80
+ const RpcErr = rpcErrors.find((cl) => cl.code === json.code);
81
+ if (RpcErr == null) throw new InternalError(`Can't find RpcError with code: ${json.code}`);
82
+ return new RpcErr(json.data);
67
83
  }
68
84
  }
69
85
 
@@ -71,111 +87,138 @@ export abstract class RpcError extends BaseError {
71
87
  * @category exception
72
88
  */
73
89
  export class RpcInvalidTransactionError extends RpcError {
74
- static code = 2
75
- code = 2
76
- constructor (data?: any) {
77
- super('Invalid transaction')
78
- this.data = data
79
- this.name = 'RpcInvalidTransactionError'
90
+ static code = 2;
91
+
92
+ code = 2;
93
+
94
+ constructor(data?: any) {
95
+ super('Invalid transaction');
96
+ this.data = data;
97
+ this.name = 'RpcInvalidTransactionError';
80
98
  }
81
99
  }
100
+ rpcErrors.push(RpcInvalidTransactionError);
82
101
 
83
102
  /**
84
103
  * @category exception
85
104
  */
86
105
  export class RpcBroadcastError extends RpcError {
87
- static code = 3
88
- code = 3
89
- constructor (data?: any) {
90
- super('Broadcast failed')
91
- this.data = data
92
- this.name = 'RpcBroadcastError'
106
+ static code = 3;
107
+
108
+ code = 3;
109
+
110
+ constructor(data?: any) {
111
+ super('Broadcast failed');
112
+ this.data = data;
113
+ this.name = 'RpcBroadcastError';
93
114
  }
94
115
  }
116
+ rpcErrors.push(RpcBroadcastError);
95
117
 
96
118
  /**
97
119
  * @category exception
98
120
  */
99
121
  export class RpcRejectedByUserError extends RpcError {
100
- static code = 4
101
- code = 4
102
- constructor (data?: any) {
103
- super('Operation rejected by user')
104
- this.data = data
105
- this.name = 'RpcRejectedByUserError'
122
+ static code = 4;
123
+
124
+ code = 4;
125
+
126
+ constructor(data?: any) {
127
+ super('Operation rejected by user');
128
+ this.data = data;
129
+ this.name = 'RpcRejectedByUserError';
106
130
  }
107
131
  }
132
+ rpcErrors.push(RpcRejectedByUserError);
108
133
 
109
134
  /**
110
135
  * @category exception
111
136
  */
112
137
  export class RpcUnsupportedProtocolError extends RpcError {
113
- static code = 5
114
- code = 5
115
- constructor () {
116
- super('Unsupported Protocol Version')
117
- this.name = 'RpcUnsupportedProtocolError'
138
+ static code = 5;
139
+
140
+ code = 5;
141
+
142
+ constructor() {
143
+ super('Unsupported Protocol Version');
144
+ this.name = 'RpcUnsupportedProtocolError';
118
145
  }
119
146
  }
147
+ rpcErrors.push(RpcUnsupportedProtocolError);
120
148
 
121
149
  /**
122
150
  * @category exception
123
151
  */
124
152
  export class RpcConnectionDenyError extends RpcError {
125
- static code = 9
126
- code = 9
127
- constructor (data?: any) {
128
- super('Wallet deny your connection request')
129
- this.data = data
130
- this.name = 'RpcConnectionDenyError'
153
+ static code = 9;
154
+
155
+ code = 9;
156
+
157
+ constructor(data?: any) {
158
+ super('Wallet deny your connection request');
159
+ this.data = data;
160
+ this.name = 'RpcConnectionDenyError';
131
161
  }
132
162
  }
163
+ rpcErrors.push(RpcConnectionDenyError);
133
164
 
134
165
  /**
135
166
  * @category exception
136
167
  */
137
168
  export class RpcNotAuthorizeError extends RpcError {
138
- static code = 10
139
- code = 10
140
- constructor () {
141
- super('You are not connected to the wallet')
142
- this.name = 'RpcNotAuthorizeError'
169
+ static code = 10;
170
+
171
+ code = 10;
172
+
173
+ constructor() {
174
+ super('You are not connected to the wallet');
175
+ this.name = 'RpcNotAuthorizeError';
143
176
  }
144
177
  }
178
+ rpcErrors.push(RpcNotAuthorizeError);
145
179
 
146
180
  /**
147
181
  * @category exception
148
182
  */
149
183
  export class RpcPermissionDenyError extends RpcError {
150
- static code = 11
151
- code = 11
152
- constructor (address: EncodedData<'ak'>) {
153
- super(`You are not subscribed for account ${address}`)
154
- this.data = address
155
- this.name = 'RpcPermissionDenyError'
184
+ static code = 11;
185
+
186
+ code = 11;
187
+
188
+ constructor(address: Encoded.AccountAddress) {
189
+ super(`You are not subscribed for account ${address}`);
190
+ this.data = address;
191
+ this.name = 'RpcPermissionDenyError';
156
192
  }
157
193
  }
194
+ rpcErrors.push(RpcPermissionDenyError);
158
195
 
159
196
  /**
160
197
  * @category exception
161
198
  */
162
199
  export class RpcInternalError extends RpcError {
163
- static code = 12
164
- code = 12
165
- constructor () {
166
- super('The peer failed to execute your request due to unknown error')
167
- this.name = 'RpcInternalError'
200
+ static code = 12;
201
+
202
+ code = 12;
203
+
204
+ constructor() {
205
+ super('The peer failed to execute your request due to unknown error');
206
+ this.name = 'RpcInternalError';
168
207
  }
169
208
  }
209
+ rpcErrors.push(RpcInternalError);
170
210
 
171
211
  /**
172
212
  * @category exception
173
213
  */
174
214
  export class RpcMethodNotFoundError extends RpcError {
175
- static code = -32601
176
- code = -32601
177
- constructor () {
178
- super('Method not found')
179
- this.name = 'RpcMethodNotFoundError'
215
+ static code = -32601;
216
+
217
+ code = -32601;
218
+
219
+ constructor() {
220
+ super('Method not found');
221
+ this.name = 'RpcMethodNotFoundError';
180
222
  }
181
223
  }
224
+ rpcErrors.push(RpcMethodNotFoundError);
@@ -15,57 +15,58 @@
15
15
  * PERFORMANCE OF THIS SOFTWARE.
16
16
  */
17
17
 
18
- import BrowserConnection from './connection/Browser'
19
- import BrowserWindowMessageConnection from './connection/BrowserWindowMessage'
20
- import { MESSAGE_DIRECTION, METHODS } from './schema'
21
- import { UnsupportedPlatformError } from '../utils/errors'
18
+ import BrowserConnection from './connection/Browser';
19
+ import BrowserWindowMessageConnection from './connection/BrowserWindowMessage';
20
+ import { MESSAGE_DIRECTION, METHODS } from './schema';
21
+ import { UnsupportedPlatformError } from '../utils/errors';
22
22
 
23
23
  interface Wallet {
24
24
  info: {
25
- id: string
26
- type: string
27
- origin: string
28
- }
29
- getConnection: () => BrowserWindowMessageConnection
25
+ id: string;
26
+ type: string;
27
+ origin: string;
28
+ };
29
+ getConnection: () => BrowserWindowMessageConnection;
30
30
  }
31
31
  interface Wallets { [key: string]: Wallet }
32
32
 
33
33
  /**
34
34
  * A function to detect available wallets
35
+ * @category aepp wallet communication
35
36
  * @param connection - connection to use to detect wallets
36
37
  * @param onDetected - call-back function which trigger on new wallet
37
38
  * @returns a function to stop scanning
38
39
  */
39
40
  export default (
40
- connection: BrowserConnection = new BrowserWindowMessageConnection(),
41
- onDetected: ({ wallets, newWallet }: { wallets: Wallets, newWallet?: Wallet }) => void
41
+ connection: BrowserConnection,
42
+ onDetected: ({ wallets, newWallet }: { wallets: Wallets; newWallet?: Wallet }) => void,
42
43
  ): () => void => {
43
- if (window == null) throw new UnsupportedPlatformError('Window object not found, you can run wallet detector only in browser')
44
- const wallets: Wallets = {}
44
+ if (window == null) throw new UnsupportedPlatformError('Window object not found, you can run wallet detector only in browser');
45
+ const wallets: Wallets = {};
45
46
 
46
47
  connection.connect((
47
- { method, params }: { method: string, params: Wallet['info'] },
48
+ { method, params }: { method: string; params: Wallet['info'] },
48
49
  origin: string,
49
- source: Window
50
+ source: Window,
50
51
  ) => {
51
- if (method !== METHODS.readyToConnect || wallets[params.id] != null) return
52
+ if (method !== METHODS.readyToConnect || wallets[params.id] != null) return;
52
53
 
53
54
  const wallet = {
54
55
  info: params,
55
- getConnection () {
56
- const isExtension = params.type === 'extension'
56
+ getConnection() {
57
+ const isExtension = params.type === 'extension';
57
58
  return new BrowserWindowMessageConnection({
58
59
  sendDirection: isExtension ? MESSAGE_DIRECTION.to_waellet : undefined,
59
60
  receiveDirection: isExtension ? MESSAGE_DIRECTION.to_aepp : undefined,
60
61
  target: source,
61
- origin: isExtension ? window.origin : params.origin
62
- })
63
- }
64
- }
65
- wallets[wallet.info.id] = wallet
66
- onDetected({ wallets, newWallet: wallet })
67
- }, () => {})
68
- if (Object.keys(wallets).length > 0) onDetected({ wallets })
62
+ origin: isExtension ? window.origin : params.origin,
63
+ });
64
+ },
65
+ };
66
+ wallets[wallet.info.id] = wallet;
67
+ onDetected({ wallets, newWallet: wallet });
68
+ }, () => {});
69
+ if (Object.keys(wallets).length > 0) onDetected({ wallets });
69
70
 
70
- return () => connection.disconnect()
71
- }
71
+ return () => connection.disconnect();
72
+ };
@@ -352,26 +352,6 @@ schemas: !Schemas
352
352
  name: DryRunResultReason
353
353
  description: ''
354
354
  protocol: !Protocols {}
355
- - !StringSchema &ref_57
356
- type: string
357
- apiVersions:
358
- - !ApiVersion
359
- version: x.y.z
360
- language: !Languages
361
- default:
362
- name: ContractCallObjectReturnType
363
- description: The status of the call 'ok | error | revert'.
364
- protocol: !Protocols {}
365
- - !StringSchema &ref_62
366
- type: string
367
- apiVersions:
368
- - !ApiVersion
369
- version: x.y.z
370
- language: !Languages
371
- default:
372
- name: GAObjectReturnType
373
- description: The status of the call 'ok | error'.
374
- protocol: !Protocols {}
375
355
  - !StringSchema &ref_64
376
356
  type: string
377
357
  apiVersions:
@@ -829,6 +809,60 @@ schemas: !Schemas
829
809
  name: NextNonceStrategy
830
810
  description: ''
831
811
  protocol: !Protocols {}
812
+ - !SealedChoiceSchema &ref_57
813
+ choices:
814
+ - !ChoiceValue
815
+ value: ok
816
+ language:
817
+ default:
818
+ name: Ok
819
+ description: ''
820
+ - !ChoiceValue
821
+ value: error
822
+ language:
823
+ default:
824
+ name: Error
825
+ description: ''
826
+ - !ChoiceValue
827
+ value: revert
828
+ language:
829
+ default:
830
+ name: Revert
831
+ description: ''
832
+ type: sealed-choice
833
+ apiVersions:
834
+ - !ApiVersion
835
+ version: x.y.z
836
+ choiceType: *ref_0
837
+ language: !Languages
838
+ default:
839
+ name: ContractCallReturnType
840
+ description: The status of the call 'ok | error | revert'.
841
+ protocol: !Protocols {}
842
+ - !SealedChoiceSchema &ref_62
843
+ choices:
844
+ - !ChoiceValue
845
+ value: ok
846
+ language:
847
+ default:
848
+ name: Ok
849
+ description: ''
850
+ - !ChoiceValue
851
+ value: error
852
+ language:
853
+ default:
854
+ name: Error
855
+ description: ''
856
+ type: sealed-choice
857
+ apiVersions:
858
+ - !ApiVersion
859
+ version: x.y.z
860
+ choiceType: *ref_0
861
+ language: !Languages
862
+ default:
863
+ name: GAReturnType
864
+ description: The status of the call 'ok | error'.
865
+ protocol: !Protocols {}
832
866
  - !SealedChoiceSchema &ref_169
833
867
  choices:
834
868
  - !ChoiceValue
@@ -332,7 +332,7 @@ export interface ContractCallObject {
332
332
  /** Base64Check encoded tagged byte array */
333
333
  returnValue: string;
334
334
  /** The status of the call 'ok | error | revert'. */
335
- returnType: string;
335
+ returnType: ContractCallReturnType;
336
336
  }
337
337
 
338
338
  export interface Event {
@@ -359,7 +359,7 @@ export interface GAObject {
359
359
  /** Base64Check encoded tagged byte array */
360
360
  returnValue: string;
361
361
  /** The status of the call 'ok | error'. */
362
- returnType: string;
362
+ returnType: GAReturnType;
363
363
  innerObject?: TxInfoObject;
364
364
  }
365
365
 
@@ -991,6 +991,10 @@ export type TxType =
991
991
  export type AccountKind = "basic" | "generalized";
992
992
  /** Defines values for NextNonceStrategy. */
993
993
  export type NextNonceStrategy = "max" | "continuity";
994
+ /** Defines values for ContractCallReturnType. */
995
+ export type ContractCallReturnType = "ok" | "error" | "revert";
996
+ /** Defines values for GAReturnType. */
997
+ export type GAReturnType = "ok" | "error";
994
998
  /** Defines values for OracleQueryType. */
995
999
  export type OracleQueryType = "open" | "closed" | "all";
996
1000
 
@@ -1425,7 +1425,8 @@ export const ContractCallObject: coreClient.CompositeMapper = {
1425
1425
  serializedName: "return_type",
1426
1426
  required: true,
1427
1427
  type: {
1428
- name: "String"
1428
+ name: "Enum",
1429
+ allowedValues: ["ok", "error", "revert"]
1429
1430
  }
1430
1431
  }
1431
1432
  }
@@ -1540,7 +1541,8 @@ export const GAObject: coreClient.CompositeMapper = {
1540
1541
  serializedName: "return_type",
1541
1542
  required: true,
1542
1543
  type: {
1543
- name: "String"
1544
+ name: "Enum",
1545
+ allowedValues: ["ok", "error"]
1544
1546
  }
1545
1547
  },
1546
1548
  innerObject: {