@dynamic-labs/multi-wallet 0.17.0-RC.2 → 0.17.0-RC.21

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 (277) hide show
  1. package/CHANGELOG.md +242 -0
  2. package/package.json +10 -26
  3. package/src/index.cjs +0 -69
  4. package/src/index.d.ts +0 -18
  5. package/src/index.js +1 -23
  6. package/src/multi-wallet.cjs +38 -182
  7. package/src/multi-wallet.d.ts +1 -4
  8. package/src/multi-wallet.js +37 -180
  9. package/src/types.d.ts +12 -50
  10. package/src/utils/getApiProviders.cjs +15 -0
  11. package/src/utils/getApiProviders.d.ts +17 -0
  12. package/src/utils/getApiProviders.js +11 -0
  13. package/src/utils/message.cjs +3 -4
  14. package/src/utils/message.d.ts +2 -2
  15. package/src/utils/message.js +1 -2
  16. package/src/errors.cjs +0 -65
  17. package/src/errors.d.ts +0 -30
  18. package/src/errors.js +0 -53
  19. package/src/polyfills.cjs +0 -16
  20. package/src/polyfills.d.ts +0 -1
  21. package/src/polyfills.js +0 -14
  22. package/src/rpcProviders.cjs +0 -76
  23. package/src/rpcProviders.d.ts +0 -5
  24. package/src/rpcProviders.js +0 -69
  25. package/src/utils/CancellablePromise/CancellablePromise.cjs +0 -33
  26. package/src/utils/CancellablePromise/CancellablePromise.d.ts +0 -9
  27. package/src/utils/CancellablePromise/CancellablePromise.js +0 -29
  28. package/src/utils/CancellablePromise/index.d.ts +0 -1
  29. package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.cjs +0 -54
  30. package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.d.ts +0 -3
  31. package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.js +0 -50
  32. package/src/utils/assignConfirmationScreenToProvider/index.d.ts +0 -1
  33. package/src/utils/convertors.cjs +0 -43
  34. package/src/utils/convertors.d.ts +0 -3
  35. package/src/utils/convertors.js +0 -38
  36. package/src/utils/encoding.cjs +0 -18
  37. package/src/utils/encoding.d.ts +0 -4
  38. package/src/utils/encoding.js +0 -12
  39. package/src/utils/extractNonce.cjs +0 -13
  40. package/src/utils/extractNonce.d.ts +0 -1
  41. package/src/utils/extractNonce.js +0 -9
  42. package/src/utils/getChainInfo/getChainInfo.cjs +0 -59
  43. package/src/utils/getChainInfo/getChainInfo.d.ts +0 -2
  44. package/src/utils/getChainInfo/getChainInfo.js +0 -55
  45. package/src/utils/getChainInfo/index.d.ts +0 -1
  46. package/src/utils/getWalletConnectorByName.cjs +0 -19
  47. package/src/utils/getWalletConnectorByName.d.ts +0 -2
  48. package/src/utils/getWalletConnectorByName.js +0 -15
  49. package/src/utils/isEmailOTPWalletConnector/index.d.ts +0 -1
  50. package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.cjs +0 -7
  51. package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +0 -2
  52. package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.js +0 -3
  53. package/src/utils/isEmailWalletConnector/index.d.ts +0 -1
  54. package/src/utils/isEmailWalletConnector/isEmailWalletConnector.cjs +0 -7
  55. package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +0 -2
  56. package/src/utils/isEmailWalletConnector/isEmailWalletConnector.js +0 -3
  57. package/src/utils/isFunction/index.d.ts +0 -1
  58. package/src/utils/isFunction/isFunction.cjs +0 -8
  59. package/src/utils/isFunction/isFunction.d.ts +0 -1
  60. package/src/utils/isFunction/isFunction.js +0 -4
  61. package/src/utils/isMobile.cjs +0 -54
  62. package/src/utils/isMobile.d.ts +0 -13
  63. package/src/utils/isMobile.js +0 -46
  64. package/src/utils/isSameAddress/index.d.ts +0 -1
  65. package/src/utils/isSameAddress/isSameAddress.cjs +0 -9
  66. package/src/utils/isSameAddress/isSameAddress.d.ts +0 -1
  67. package/src/utils/isSameAddress/isSameAddress.js +0 -5
  68. package/src/utils/isSameAddress/utils/index.d.ts +0 -1
  69. package/src/utils/isSameAddress/utils/normalizeAddress/index.d.ts +0 -1
  70. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.cjs +0 -17
  71. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.d.ts +0 -1
  72. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.js +0 -13
  73. package/src/utils/isSocialWalletConnector/index.d.ts +0 -1
  74. package/src/utils/isSocialWalletConnector/isSocialWalletConnector.cjs +0 -7
  75. package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +0 -2
  76. package/src/utils/isSocialWalletConnector/isSocialWalletConnector.js +0 -3
  77. package/src/utils/isUnsupportedProviderError/index.d.ts +0 -1
  78. package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.cjs +0 -13
  79. package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.d.ts +0 -6
  80. package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.js +0 -9
  81. package/src/utils/localStorageAsync.cjs +0 -28
  82. package/src/utils/localStorageAsync.d.ts +0 -3
  83. package/src/utils/localStorageAsync.js +0 -22
  84. package/src/utils/logger.cjs +0 -9
  85. package/src/utils/logger.d.ts +0 -2
  86. package/src/utils/logger.js +0 -5
  87. package/src/utils/normalizeWalletName/index.d.ts +0 -1
  88. package/src/utils/normalizeWalletName/normalizeWalletName.cjs +0 -7
  89. package/src/utils/normalizeWalletName/normalizeWalletName.d.ts +0 -1
  90. package/src/utils/normalizeWalletName/normalizeWalletName.js +0 -3
  91. package/src/utils/shouldLowercaseAddress.cjs +0 -11
  92. package/src/utils/shouldLowercaseAddress.d.ts +0 -1
  93. package/src/utils/shouldLowercaseAddress.js +0 -7
  94. package/src/utils/walletConnect.cjs +0 -30
  95. package/src/utils/walletConnect.d.ts +0 -4
  96. package/src/utils/walletConnect.js +0 -26
  97. package/src/wallets/ProviderLookup.cjs +0 -18
  98. package/src/wallets/ProviderLookup.d.ts +0 -4
  99. package/src/wallets/ProviderLookup.js +0 -14
  100. package/src/wallets/algorand/MyAlgoWalletConnector.cjs +0 -149
  101. package/src/wallets/algorand/MyAlgoWalletConnector.d.ts +0 -21
  102. package/src/wallets/algorand/MyAlgoWalletConnector.js +0 -143
  103. package/src/wallets/algorand/myalgoSigner.cjs +0 -24
  104. package/src/wallets/algorand/myalgoSigner.d.ts +0 -21
  105. package/src/wallets/algorand/myalgoSigner.js +0 -20
  106. package/src/wallets/clients/coinbase/coinbase.cjs +0 -73
  107. package/src/wallets/clients/coinbase/coinbase.d.ts +0 -6
  108. package/src/wallets/clients/coinbase/coinbase.js +0 -66
  109. package/src/wallets/clients/coinbase/index.d.ts +0 -2
  110. package/src/wallets/clients/coinbase/types.d.ts +0 -14
  111. package/src/wallets/clients/walletConnect/index.d.ts +0 -1
  112. package/src/wallets/clients/walletConnect/types.d.ts +0 -4
  113. package/src/wallets/clients/walletConnect/walletConnect.cjs +0 -204
  114. package/src/wallets/clients/walletConnect/walletConnect.d.ts +0 -22
  115. package/src/wallets/clients/walletConnect/walletConnect.js +0 -187
  116. package/src/wallets/constants.cjs +0 -16
  117. package/src/wallets/constants.d.ts +0 -4
  118. package/src/wallets/constants.js +0 -10
  119. package/src/wallets/cosmos/KeplrWalletConnect.cjs +0 -196
  120. package/src/wallets/cosmos/KeplrWalletConnect.d.ts +0 -46
  121. package/src/wallets/cosmos/KeplrWalletConnect.js +0 -194
  122. package/src/wallets/cosmos/KeplrWalletConnector.cjs +0 -193
  123. package/src/wallets/cosmos/KeplrWalletConnector.d.ts +0 -70
  124. package/src/wallets/cosmos/KeplrWalletConnector.js +0 -189
  125. package/src/wallets/cosmos/getKeplrConnector.cjs +0 -18
  126. package/src/wallets/cosmos/getKeplrConnector.d.ts +0 -6
  127. package/src/wallets/cosmos/getKeplrConnector.js +0 -14
  128. package/src/wallets/cosmos/index.d.ts +0 -1
  129. package/src/wallets/cosmos/utils/indexDB.cjs +0 -97
  130. package/src/wallets/cosmos/utils/indexDB.d.ts +0 -18
  131. package/src/wallets/cosmos/utils/indexDB.js +0 -93
  132. package/src/wallets/cosmos/wcClient.cjs +0 -333
  133. package/src/wallets/cosmos/wcClient.d.ts +0 -104
  134. package/src/wallets/cosmos/wcClient.js +0 -325
  135. package/src/wallets/ethereum/BloctoEvm.cjs +0 -111
  136. package/src/wallets/ethereum/BloctoEvm.d.ts +0 -25
  137. package/src/wallets/ethereum/BloctoEvm.js +0 -105
  138. package/src/wallets/ethereum/EthWalletConnector.cjs +0 -191
  139. package/src/wallets/ethereum/EthWalletConnector.d.ts +0 -35
  140. package/src/wallets/ethereum/EthWalletConnector.js +0 -187
  141. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -63
  142. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.d.ts +0 -12
  143. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -59
  144. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/index.d.ts +0 -1
  145. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.cjs +0 -62
  146. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.d.ts +0 -11
  147. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.js +0 -58
  148. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/index.d.ts +0 -1
  149. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.cjs +0 -102
  150. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +0 -33
  151. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +0 -98
  152. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/index.d.ts +0 -2
  153. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +0 -55
  154. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.d.ts +0 -12
  155. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +0 -51
  156. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/index.d.ts +0 -1
  157. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +0 -175
  158. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +0 -53
  159. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +0 -171
  160. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/index.d.ts +0 -2
  161. package/src/wallets/ethereum/MagicConnector/index.d.ts +0 -5
  162. package/src/wallets/ethereum/coinbase.cjs +0 -65
  163. package/src/wallets/ethereum/coinbase.d.ts +0 -26
  164. package/src/wallets/ethereum/coinbase.js +0 -63
  165. package/src/wallets/ethereum/ethProviderHelper.cjs +0 -197
  166. package/src/wallets/ethereum/ethProviderHelper.d.ts +0 -40
  167. package/src/wallets/ethereum/ethProviderHelper.js +0 -193
  168. package/src/wallets/ethereum/evm-network.cjs +0 -20
  169. package/src/wallets/ethereum/evm-network.d.ts +0 -22
  170. package/src/wallets/ethereum/evm-network.js +0 -16
  171. package/src/wallets/ethereum/fortmatic.cjs +0 -75
  172. package/src/wallets/ethereum/fortmatic.d.ts +0 -26
  173. package/src/wallets/ethereum/fortmatic.js +0 -69
  174. package/src/wallets/ethereum/injected/BloctoInjected.cjs +0 -13
  175. package/src/wallets/ethereum/injected/BloctoInjected.d.ts +0 -6
  176. package/src/wallets/ethereum/injected/BloctoInjected.js +0 -11
  177. package/src/wallets/ethereum/injected/BraveEvm.cjs +0 -13
  178. package/src/wallets/ethereum/injected/BraveEvm.d.ts +0 -6
  179. package/src/wallets/ethereum/injected/BraveEvm.js +0 -11
  180. package/src/wallets/ethereum/injected/Dawn.cjs +0 -13
  181. package/src/wallets/ethereum/injected/Dawn.d.ts +0 -6
  182. package/src/wallets/ethereum/injected/Dawn.js +0 -11
  183. package/src/wallets/ethereum/injected/ExodusEvm.cjs +0 -13
  184. package/src/wallets/ethereum/injected/ExodusEvm.d.ts +0 -6
  185. package/src/wallets/ethereum/injected/ExodusEvm.js +0 -11
  186. package/src/wallets/ethereum/injected/Frame.cjs +0 -13
  187. package/src/wallets/ethereum/injected/Frame.d.ts +0 -6
  188. package/src/wallets/ethereum/injected/Frame.js +0 -11
  189. package/src/wallets/ethereum/injected/GameStop.cjs +0 -13
  190. package/src/wallets/ethereum/injected/GameStop.d.ts +0 -6
  191. package/src/wallets/ethereum/injected/GameStop.js +0 -11
  192. package/src/wallets/ethereum/injected/Opera.cjs +0 -13
  193. package/src/wallets/ethereum/injected/Opera.d.ts +0 -6
  194. package/src/wallets/ethereum/injected/Opera.js +0 -11
  195. package/src/wallets/ethereum/injected/PhantomEvm.cjs +0 -37
  196. package/src/wallets/ethereum/injected/PhantomEvm.d.ts +0 -7
  197. package/src/wallets/ethereum/injected/PhantomEvm.js +0 -35
  198. package/src/wallets/ethereum/injected/Trust.cjs +0 -13
  199. package/src/wallets/ethereum/injected/Trust.d.ts +0 -6
  200. package/src/wallets/ethereum/injected/Trust.js +0 -11
  201. package/src/wallets/ethereum/injected/UnknownInjectedWallet.cjs +0 -13
  202. package/src/wallets/ethereum/injected/UnknownInjectedWallet.d.ts +0 -6
  203. package/src/wallets/ethereum/injected/UnknownInjectedWallet.js +0 -11
  204. package/src/wallets/ethereum/injected/Zerion.cjs +0 -13
  205. package/src/wallets/ethereum/injected/Zerion.d.ts +0 -6
  206. package/src/wallets/ethereum/injected/Zerion.js +0 -11
  207. package/src/wallets/ethereum/meta-mask.cjs +0 -63
  208. package/src/wallets/ethereum/meta-mask.d.ts +0 -26
  209. package/src/wallets/ethereum/meta-mask.js +0 -61
  210. package/src/wallets/flow/FlowWalletConnector.cjs +0 -163
  211. package/src/wallets/flow/FlowWalletConnector.d.ts +0 -29
  212. package/src/wallets/flow/FlowWalletConnector.js +0 -158
  213. package/src/wallets/flow/blocto.cjs +0 -22
  214. package/src/wallets/flow/blocto.d.ts +0 -7
  215. package/src/wallets/flow/blocto.js +0 -20
  216. package/src/wallets/flow/dapper.cjs +0 -22
  217. package/src/wallets/flow/dapper.d.ts +0 -7
  218. package/src/wallets/flow/dapper.js +0 -20
  219. package/src/wallets/flow/lilico.cjs +0 -42
  220. package/src/wallets/flow/lilico.d.ts +0 -8
  221. package/src/wallets/flow/lilico.js +0 -40
  222. package/src/wallets/getMobileOrInjectedWallet.cjs +0 -26
  223. package/src/wallets/getMobileOrInjectedWallet.d.ts +0 -8
  224. package/src/wallets/getMobileOrInjectedWallet.js +0 -22
  225. package/src/wallets/getWalletConnectConnector.cjs +0 -19
  226. package/src/wallets/getWalletConnectConnector.d.ts +0 -8
  227. package/src/wallets/getWalletConnectConnector.js +0 -15
  228. package/src/wallets/solana/CoinbaseSolana.cjs +0 -54
  229. package/src/wallets/solana/CoinbaseSolana.d.ts +0 -17
  230. package/src/wallets/solana/CoinbaseSolana.js +0 -52
  231. package/src/wallets/solana/glow.cjs +0 -51
  232. package/src/wallets/solana/glow.d.ts +0 -16
  233. package/src/wallets/solana/glow.js +0 -49
  234. package/src/wallets/solana/injected/BraveSol.cjs +0 -18
  235. package/src/wallets/solana/injected/BraveSol.d.ts +0 -6
  236. package/src/wallets/solana/injected/BraveSol.js +0 -16
  237. package/src/wallets/solana/injected/ExodusSol.cjs +0 -12
  238. package/src/wallets/solana/injected/ExodusSol.d.ts +0 -5
  239. package/src/wallets/solana/injected/ExodusSol.js +0 -10
  240. package/src/wallets/solana/phantom-ledger.cjs +0 -71
  241. package/src/wallets/solana/phantom-ledger.d.ts +0 -16
  242. package/src/wallets/solana/phantom-ledger.js +0 -65
  243. package/src/wallets/solana/phantom.cjs +0 -74
  244. package/src/wallets/solana/phantom.d.ts +0 -17
  245. package/src/wallets/solana/phantom.js +0 -72
  246. package/src/wallets/solana/slope.cjs +0 -96
  247. package/src/wallets/solana/slope.d.ts +0 -27
  248. package/src/wallets/solana/slope.js +0 -94
  249. package/src/wallets/solana/solProviderHelper.cjs +0 -164
  250. package/src/wallets/solana/solProviderHelper.d.ts +0 -29
  251. package/src/wallets/solana/solProviderHelper.js +0 -160
  252. package/src/wallets/solana/solWalletConnector.cjs +0 -57
  253. package/src/wallets/solana/solWalletConnector.d.ts +0 -18
  254. package/src/wallets/solana/solWalletConnector.js +0 -53
  255. package/src/wallets/solana/solflare.cjs +0 -65
  256. package/src/wallets/solana/solflare.d.ts +0 -14
  257. package/src/wallets/solana/solflare.js +0 -63
  258. package/src/wallets/starknet/argentx.cjs +0 -20
  259. package/src/wallets/starknet/argentx.d.ts +0 -7
  260. package/src/wallets/starknet/argentx.js +0 -18
  261. package/src/wallets/starknet/braavos.cjs +0 -33
  262. package/src/wallets/starknet/braavos.d.ts +0 -7
  263. package/src/wallets/starknet/braavos.js +0 -31
  264. package/src/wallets/starknet/ethereumContractAbi.cjs +0 -357
  265. package/src/wallets/starknet/ethereumContractAbi.js +0 -355
  266. package/src/wallets/starknet/starknetWalletConnector.cjs +0 -171
  267. package/src/wallets/starknet/starknetWalletConnector.d.ts +0 -34
  268. package/src/wallets/starknet/starknetWalletConnector.js +0 -169
  269. package/src/wallets/walletConnect/index.d.ts +0 -2
  270. package/src/wallets/walletConnect/walletConnect.cjs +0 -130
  271. package/src/wallets/walletConnect/walletConnect.d.ts +0 -34
  272. package/src/wallets/walletConnect/walletConnect.js +0 -124
  273. package/src/wallets/walletConnect/walletConnectV2.cjs +0 -268
  274. package/src/wallets/walletConnect/walletConnectV2.d.ts +0 -38
  275. package/src/wallets/walletConnect/walletConnectV2.js +0 -262
  276. package/src/wallets/walletConnect/zerion.d.ts +0 -8
  277. package/src/wallets/window.d.ts +0 -95
@@ -1,333 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib = require('tslib');
6
- var buffer = require('buffer');
7
- var provider = require('@keplr-wallet/provider');
8
- var utils = require('@walletconnect/utils');
9
- var deepmerge = require('deepmerge');
10
- var indexDB = require('./utils/indexDB.cjs');
11
-
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var deepmerge__default = /*#__PURE__*/_interopDefaultLegacy(deepmerge);
15
-
16
- /* eslint-disable */
17
- // VersionFormatRegExp checks if a chainID is in the format required for parsing versions
18
- // The chainID should be in the form: `{identifier}-{version}`
19
- const ChainVersionFormatRegExp = /(.+)-([\d]+)/;
20
- function parseChainId(chainId) {
21
- const split = chainId.split(ChainVersionFormatRegExp).filter(Boolean);
22
- if (split.length !== 2) {
23
- return {
24
- identifier: chainId,
25
- version: 0,
26
- };
27
- }
28
- else {
29
- return { identifier: split[0], version: parseInt(split[1]) };
30
- }
31
- }
32
- class KeplrWalletConnectV1 {
33
- constructor(connector, options = {}) {
34
- this.connector = connector;
35
- this.options = options;
36
- this.version = '0.9.0';
37
- this.mode = 'walletconnect';
38
- this.defaultOptions = {};
39
- this.onCallReqeust = (error, payload) => tslib.__awaiter(this, void 0, void 0, function* () {
40
- if (error) {
41
- console.log(error);
42
- return;
43
- }
44
- if (!payload) {
45
- return;
46
- }
47
- if (payload.method === 'keplr_keystore_may_changed_event_wallet_connect_v1') {
48
- const param = payload.params[0];
49
- if (!param) {
50
- return;
51
- }
52
- const lastSeenKeys = yield this.getAllLastSeenKey();
53
- if (!lastSeenKeys) {
54
- return;
55
- }
56
- const mayChangedKeyMap = {};
57
- for (const mayChangedKey of param.keys) {
58
- mayChangedKeyMap[mayChangedKey.chainIdentifier] = {
59
- address: mayChangedKey.address,
60
- algo: param.algo,
61
- bech32Address: mayChangedKey.bech32Address,
62
- isKeystone: param.isKeystone,
63
- isNanoLedger: param.isNanoLedger,
64
- name: param.name,
65
- pubKey: mayChangedKey.pubKey,
66
- };
67
- }
68
- let hasChanged = false;
69
- for (const chainId of Object.keys(lastSeenKeys)) {
70
- const savedKey = lastSeenKeys[chainId];
71
- if (savedKey) {
72
- const { identifier } = parseChainId(chainId);
73
- const mayChangedKey = mayChangedKeyMap[identifier];
74
- if (mayChangedKey) {
75
- if (mayChangedKey.algo !== savedKey.algo ||
76
- mayChangedKey.name !== savedKey.name ||
77
- mayChangedKey.isKeystone !== savedKey.isKeystone ||
78
- mayChangedKey.isNanoLedger !== savedKey.isNanoLedger ||
79
- mayChangedKey.address !== savedKey.address ||
80
- mayChangedKey.bech32Address !== savedKey.bech32Address ||
81
- mayChangedKey.pubKey !== savedKey.pubKey) {
82
- hasChanged = true;
83
- lastSeenKeys[chainId] = mayChangedKey;
84
- }
85
- }
86
- }
87
- }
88
- if (hasChanged) {
89
- yield this.saveAllLastSeenKey(lastSeenKeys);
90
- window.dispatchEvent(new Event('keplr_keystorechange'));
91
- }
92
- }
93
- });
94
- if (!options.kvStore) {
95
- options.kvStore = new indexDB.IndexedDBKVStore('keplr_wallet_connect');
96
- }
97
- connector.on('disconnect', () => {
98
- this.clearSaved();
99
- });
100
- connector.on('call_request', this.onCallReqeust);
101
- }
102
- clearSaved() {
103
- return tslib.__awaiter(this, void 0, void 0, function* () {
104
- const kvStore = this.options.kvStore;
105
- yield Promise.all([
106
- kvStore.set(this.getKeyHasEnabled(), null),
107
- kvStore.set(this.getKeyLastSeenKey(), null),
108
- ]);
109
- });
110
- }
111
- sendCustomRequest(request, options) {
112
- return tslib.__awaiter(this, void 0, void 0, function* () {
113
- if (this.options.onBeforeSendRequest) {
114
- yield this.options.onBeforeSendRequest(request, options);
115
- }
116
- const res = yield this.connector.sendCustomRequest(request, options);
117
- if (this.options.onAfterSendRequest) {
118
- yield this.options.onAfterSendRequest(res, request, options);
119
- }
120
- return res;
121
- });
122
- }
123
- enable(chainIds) {
124
- return tslib.__awaiter(this, void 0, void 0, function* () {
125
- if (typeof chainIds === 'string') {
126
- chainIds = [chainIds];
127
- }
128
- const hasEnabledChainIds = yield this.getHasEnabledChainIds();
129
- let allEnabled = true;
130
- for (const chainId of chainIds) {
131
- if (hasEnabledChainIds.indexOf(chainId) < 0) {
132
- allEnabled = false;
133
- break;
134
- }
135
- }
136
- if (allEnabled) {
137
- return;
138
- }
139
- yield this.sendCustomRequest({
140
- id: utils.payloadId(),
141
- jsonrpc: '2.0',
142
- method: 'keplr_enable_wallet_connect_v1',
143
- params: chainIds,
144
- });
145
- yield this.saveHasEnabledChainIds(chainIds);
146
- });
147
- }
148
- getKeyHasEnabled() {
149
- return `${this.connector.session.handshakeTopic}-enabled`;
150
- }
151
- getHasEnabledChainIds() {
152
- var _a;
153
- return tslib.__awaiter(this, void 0, void 0, function* () {
154
- return ((_a = (yield this.options.kvStore.get(this.getKeyHasEnabled()))) !== null && _a !== void 0 ? _a : []);
155
- });
156
- }
157
- saveHasEnabledChainIds(chainIds) {
158
- return tslib.__awaiter(this, void 0, void 0, function* () {
159
- const hasEnabledChainIds = yield this.getHasEnabledChainIds();
160
- for (const chainId of chainIds) {
161
- if (hasEnabledChainIds.indexOf(chainId) < 0) {
162
- hasEnabledChainIds.push(chainId);
163
- }
164
- }
165
- yield this.options.kvStore.set(this.getKeyHasEnabled(), hasEnabledChainIds);
166
- });
167
- }
168
- enigmaDecrypt(_chainId, _ciphertext, _nonce) {
169
- throw new Error('Not yet implemented');
170
- }
171
- enigmaEncrypt(_chainId, _contractCodeHash,
172
- // eslint-disable-next-line @typescript-eslint/ban-types
173
- _msg) {
174
- throw new Error('Not yet implemented');
175
- }
176
- experimentalSuggestChain(_chainInfo) {
177
- throw new Error('Not yet implemented');
178
- }
179
- getEnigmaPubKey(_chainId) {
180
- throw new Error('Not yet implemented');
181
- }
182
- getEnigmaTxEncryptionKey(_chainId, _nonce) {
183
- throw new Error('Not yet implemented');
184
- }
185
- getEnigmaUtils(_chainId) {
186
- throw new Error('Not yet implemented');
187
- }
188
- getKey(chainId) {
189
- return tslib.__awaiter(this, void 0, void 0, function* () {
190
- const lastSeenKey = yield this.getLastSeenKey(chainId);
191
- if (lastSeenKey) {
192
- return {
193
- address: buffer.Buffer.from(lastSeenKey.address, 'hex'),
194
- algo: lastSeenKey.algo,
195
- bech32Address: lastSeenKey.bech32Address,
196
- isKeystone: lastSeenKey.isKeystone,
197
- isNanoLedger: lastSeenKey.isNanoLedger,
198
- name: lastSeenKey.name,
199
- pubKey: buffer.Buffer.from(lastSeenKey.pubKey, 'hex'),
200
- };
201
- }
202
- const response = (yield this.sendCustomRequest({
203
- id: utils.payloadId(),
204
- jsonrpc: '2.0',
205
- method: 'keplr_get_key_wallet_connect_v1',
206
- params: [chainId],
207
- }))[0];
208
- yield this.saveLastSeenKey(chainId, response);
209
- return {
210
- address: buffer.Buffer.from(response.address, 'hex'),
211
- algo: response.algo,
212
- bech32Address: response.bech32Address,
213
- isKeystone: response.isKeystone,
214
- isNanoLedger: response.isNanoLedger,
215
- name: response.name,
216
- pubKey: buffer.Buffer.from(response.pubKey, 'hex'),
217
- };
218
- });
219
- }
220
- getKeyLastSeenKey() {
221
- return `${this.connector.session.handshakeTopic}-key`;
222
- }
223
- getLastSeenKey(chainId) {
224
- return tslib.__awaiter(this, void 0, void 0, function* () {
225
- const saved = yield this.getAllLastSeenKey();
226
- if (!saved) {
227
- return undefined;
228
- }
229
- return saved[chainId];
230
- });
231
- }
232
- getAllLastSeenKey() {
233
- return tslib.__awaiter(this, void 0, void 0, function* () {
234
- return yield this.options.kvStore.get(this.getKeyLastSeenKey());
235
- });
236
- }
237
- saveAllLastSeenKey(data) {
238
- return tslib.__awaiter(this, void 0, void 0, function* () {
239
- yield this.options.kvStore.set(this.getKeyLastSeenKey(), data);
240
- });
241
- }
242
- saveLastSeenKey(chainId, response) {
243
- return tslib.__awaiter(this, void 0, void 0, function* () {
244
- let saved = yield this.getAllLastSeenKey();
245
- if (!saved) {
246
- saved = {};
247
- }
248
- saved[chainId] = response;
249
- yield this.saveAllLastSeenKey(saved);
250
- });
251
- }
252
- signArbitrary(_chainId, _signer, _data) {
253
- throw new Error('Not yet implemented');
254
- }
255
- verifyArbitrary(_chainId, _signer, _data, _signature) {
256
- throw new Error('Not yet implemented');
257
- }
258
- signEthereum(_chainId, _signer, _data, _mode) {
259
- throw new Error('Not yet implemented');
260
- }
261
- signICNSAdr36(_chainId, _contractAddress, _owner, _username, _addressChainIds) {
262
- throw new Error('Not yet implemented');
263
- }
264
- getOfflineSigner(chainId) {
265
- return new provider.CosmJSOfflineSigner(chainId, this);
266
- }
267
- getOfflineSignerAuto(chainId) {
268
- return tslib.__awaiter(this, void 0, void 0, function* () {
269
- const key = yield this.getKey(chainId);
270
- if (key.isNanoLedger) {
271
- return new provider.CosmJSOfflineSignerOnlyAmino(chainId, this);
272
- }
273
- return new provider.CosmJSOfflineSigner(chainId, this);
274
- });
275
- }
276
- getOfflineSignerOnlyAmino(chainId) {
277
- return new provider.CosmJSOfflineSignerOnlyAmino(chainId, this);
278
- }
279
- getSecret20ViewingKey(_chainId, _contractAddress) {
280
- throw new Error('Not yet implemented');
281
- }
282
- /**
283
- * In the extension environment, this API let the extension to send the tx on behalf of the client.
284
- * But, in the wallet connect environment, in order to send the tx on behalf of the client, wallet should receive the tx data from remote.
285
- * However, this approach is not efficient and hard to ensure the stability and `KeplrWalletConnect` should have the informations of rpc and rest endpoints.
286
- * So, rather than implementing this, just fallback to the client sided implementation or throw error of the client sided implementation is not delivered to the `options`.
287
- * @param chainId
288
- * @param stdTx
289
- * @param mode
290
- */
291
- sendTx(chainId, tx, mode) {
292
- if (this.options.sendTx) {
293
- return this.options.sendTx(chainId, tx, mode);
294
- }
295
- throw new Error('send tx is not delivered by options');
296
- }
297
- signAmino(chainId, signer, signDoc, signOptions = {}) {
298
- var _a;
299
- return tslib.__awaiter(this, void 0, void 0, function* () {
300
- return (yield this.sendCustomRequest({
301
- id: utils.payloadId(),
302
- jsonrpc: '2.0',
303
- method: 'keplr_sign_amino_wallet_connect_v1',
304
- params: [
305
- chainId,
306
- signer,
307
- signDoc,
308
- deepmerge__default["default"]((_a = this.defaultOptions.sign) !== null && _a !== void 0 ? _a : {}, signOptions),
309
- ],
310
- }))[0];
311
- });
312
- }
313
- signDirect(_chainId, _signer, _signDoc, _signOptions = {}) {
314
- throw new Error('Not yet implemented');
315
- }
316
- suggestToken(_chainId, _contractAddress, _viewingKey) {
317
- throw new Error('Not yet implemented');
318
- }
319
- experimentalSignEIP712CosmosTx_v0(_chainId, _signer, _eip712, _signDoc, _signOptions = {}) {
320
- throw new Error('Not yet implemented');
321
- }
322
- getChainInfosWithoutEndpoints() {
323
- throw new Error('Not yet implemented');
324
- }
325
- disable(_chainIds) {
326
- throw new Error('Not yet implemented');
327
- }
328
- changeKeyRingName(_opts) {
329
- throw new Error('Not yet implemented');
330
- }
331
- }
332
-
333
- exports.KeplrWalletConnectV1 = KeplrWalletConnectV1;
@@ -1,104 +0,0 @@
1
- import { ChainInfo, EthSignType, Keplr, KeplrIntereactionOptions, KeplrMode, KeplrSignOptions, Key, DirectSignResponse, OfflineDirectSigner, AminoSignResponse, BroadcastMode, OfflineAminoSigner, StdSignature, StdSignDoc, ICNSAdr36Signatures, ChainInfoWithoutEndpoints, SecretUtils } from '@keplr-wallet/types';
2
- import { KVStore } from './utils/indexDB';
3
- export type KeplrGetKeyWalletCoonectV1Response = {
4
- address: string;
5
- algo: string;
6
- bech32Address: string;
7
- isKeystone: boolean;
8
- isNanoLedger: boolean;
9
- name: string;
10
- pubKey: string;
11
- };
12
- export type KeplrKeystoreMayChangedEventParam = {
13
- algo: string;
14
- isKeystone: boolean;
15
- isNanoLedger: boolean;
16
- keys: {
17
- address: string;
18
- bech32Address: string;
19
- chainIdentifier: string;
20
- pubKey: string;
21
- }[];
22
- name: string;
23
- };
24
- export declare class KeplrWalletConnectV1 implements Keplr {
25
- readonly connector: any;
26
- readonly options: {
27
- kvStore?: KVStore;
28
- onAfterSendRequest?: (response: any, request: Partial<any>, options?: any) => Promise<void> | void;
29
- onBeforeSendRequest?: (request: Partial<any>, options?: any) => Promise<void> | void;
30
- sendTx?: Keplr['sendTx'];
31
- };
32
- constructor(connector: any, options?: {
33
- kvStore?: KVStore;
34
- onAfterSendRequest?: (response: any, request: Partial<any>, options?: any) => Promise<void> | void;
35
- onBeforeSendRequest?: (request: Partial<any>, options?: any) => Promise<void> | void;
36
- sendTx?: Keplr['sendTx'];
37
- });
38
- readonly version: string;
39
- readonly mode: KeplrMode;
40
- defaultOptions: KeplrIntereactionOptions;
41
- protected readonly onCallReqeust: (error: Error | null, payload: any | null) => Promise<void>;
42
- protected clearSaved(): Promise<void>;
43
- protected sendCustomRequest(request: Partial<any>, options?: any): Promise<any>;
44
- enable(chainIds: string | string[]): Promise<void>;
45
- protected getKeyHasEnabled(): string;
46
- protected getHasEnabledChainIds(): Promise<string[]>;
47
- protected saveHasEnabledChainIds(chainIds: string[]): Promise<void>;
48
- enigmaDecrypt(_chainId: string, _ciphertext: Uint8Array, _nonce: Uint8Array): Promise<Uint8Array>;
49
- enigmaEncrypt(_chainId: string, _contractCodeHash: string, _msg: object): Promise<Uint8Array>;
50
- experimentalSuggestChain(_chainInfo: ChainInfo): Promise<void>;
51
- getEnigmaPubKey(_chainId: string): Promise<Uint8Array>;
52
- getEnigmaTxEncryptionKey(_chainId: string, _nonce: Uint8Array): Promise<Uint8Array>;
53
- getEnigmaUtils(_chainId: string): SecretUtils;
54
- getKey(chainId: string): Promise<Key>;
55
- protected getKeyLastSeenKey(): string;
56
- protected getLastSeenKey(chainId: string): Promise<KeplrGetKeyWalletCoonectV1Response | undefined>;
57
- protected getAllLastSeenKey(): Promise<{
58
- [chainId: string]: KeplrGetKeyWalletCoonectV1Response | undefined;
59
- } | undefined>;
60
- protected saveAllLastSeenKey(data: {
61
- [chainId: string]: KeplrGetKeyWalletCoonectV1Response | undefined;
62
- }): Promise<void>;
63
- protected saveLastSeenKey(chainId: string, response: KeplrGetKeyWalletCoonectV1Response): Promise<void>;
64
- signArbitrary(_chainId: string, _signer: string, _data: string | Uint8Array): Promise<StdSignature>;
65
- verifyArbitrary(_chainId: string, _signer: string, _data: string | Uint8Array, _signature: StdSignature): Promise<boolean>;
66
- signEthereum(_chainId: string, _signer: string, _data: string | Uint8Array, _mode: EthSignType): Promise<Uint8Array>;
67
- signICNSAdr36(_chainId: string, _contractAddress: string, _owner: string, _username: string, _addressChainIds: string[]): Promise<ICNSAdr36Signatures>;
68
- getOfflineSigner(chainId: string): OfflineAminoSigner & OfflineDirectSigner;
69
- getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;
70
- getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner;
71
- getSecret20ViewingKey(_chainId: string, _contractAddress: string): Promise<string>;
72
- /**
73
- * In the extension environment, this API let the extension to send the tx on behalf of the client.
74
- * But, in the wallet connect environment, in order to send the tx on behalf of the client, wallet should receive the tx data from remote.
75
- * However, this approach is not efficient and hard to ensure the stability and `KeplrWalletConnect` should have the informations of rpc and rest endpoints.
76
- * So, rather than implementing this, just fallback to the client sided implementation or throw error of the client sided implementation is not delivered to the `options`.
77
- * @param chainId
78
- * @param stdTx
79
- * @param mode
80
- */
81
- sendTx(chainId: string, tx: Uint8Array, mode: BroadcastMode): Promise<Uint8Array>;
82
- signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: KeplrSignOptions): Promise<AminoSignResponse>;
83
- signDirect(_chainId: string, _signer: string, _signDoc: {
84
- accountNumber?: any | null;
85
- authInfoBytes?: Uint8Array | null;
86
- bodyBytes?: Uint8Array | null;
87
- chainId?: string | null;
88
- }, _signOptions?: KeplrSignOptions): Promise<DirectSignResponse>;
89
- suggestToken(_chainId: string, _contractAddress: string, _viewingKey?: string): Promise<void>;
90
- experimentalSignEIP712CosmosTx_v0(_chainId: string, _signer: string, _eip712: {
91
- domain: Record<string, any>;
92
- primaryType: string;
93
- types: Record<string, {
94
- name: string;
95
- type: string;
96
- }[] | undefined>;
97
- }, _signDoc: StdSignDoc, _signOptions?: KeplrSignOptions): Promise<AminoSignResponse>;
98
- getChainInfosWithoutEndpoints(): Promise<ChainInfoWithoutEndpoints[]>;
99
- disable(_chainIds?: string | string[]): Promise<void>;
100
- changeKeyRingName(_opts: {
101
- defaultName: string;
102
- editable?: boolean | undefined;
103
- }): Promise<string>;
104
- }