@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,325 +0,0 @@
1
- import { __awaiter } from 'tslib';
2
- import { Buffer } from 'buffer';
3
- import { CosmJSOfflineSigner, CosmJSOfflineSignerOnlyAmino } from '@keplr-wallet/provider';
4
- import { payloadId } from '@walletconnect/utils';
5
- import deepmerge from 'deepmerge';
6
- import { IndexedDBKVStore } from './utils/indexDB.js';
7
-
8
- /* eslint-disable */
9
- // VersionFormatRegExp checks if a chainID is in the format required for parsing versions
10
- // The chainID should be in the form: `{identifier}-{version}`
11
- const ChainVersionFormatRegExp = /(.+)-([\d]+)/;
12
- function parseChainId(chainId) {
13
- const split = chainId.split(ChainVersionFormatRegExp).filter(Boolean);
14
- if (split.length !== 2) {
15
- return {
16
- identifier: chainId,
17
- version: 0,
18
- };
19
- }
20
- else {
21
- return { identifier: split[0], version: parseInt(split[1]) };
22
- }
23
- }
24
- class KeplrWalletConnectV1 {
25
- constructor(connector, options = {}) {
26
- this.connector = connector;
27
- this.options = options;
28
- this.version = '0.9.0';
29
- this.mode = 'walletconnect';
30
- this.defaultOptions = {};
31
- this.onCallReqeust = (error, payload) => __awaiter(this, void 0, void 0, function* () {
32
- if (error) {
33
- console.log(error);
34
- return;
35
- }
36
- if (!payload) {
37
- return;
38
- }
39
- if (payload.method === 'keplr_keystore_may_changed_event_wallet_connect_v1') {
40
- const param = payload.params[0];
41
- if (!param) {
42
- return;
43
- }
44
- const lastSeenKeys = yield this.getAllLastSeenKey();
45
- if (!lastSeenKeys) {
46
- return;
47
- }
48
- const mayChangedKeyMap = {};
49
- for (const mayChangedKey of param.keys) {
50
- mayChangedKeyMap[mayChangedKey.chainIdentifier] = {
51
- address: mayChangedKey.address,
52
- algo: param.algo,
53
- bech32Address: mayChangedKey.bech32Address,
54
- isKeystone: param.isKeystone,
55
- isNanoLedger: param.isNanoLedger,
56
- name: param.name,
57
- pubKey: mayChangedKey.pubKey,
58
- };
59
- }
60
- let hasChanged = false;
61
- for (const chainId of Object.keys(lastSeenKeys)) {
62
- const savedKey = lastSeenKeys[chainId];
63
- if (savedKey) {
64
- const { identifier } = parseChainId(chainId);
65
- const mayChangedKey = mayChangedKeyMap[identifier];
66
- if (mayChangedKey) {
67
- if (mayChangedKey.algo !== savedKey.algo ||
68
- mayChangedKey.name !== savedKey.name ||
69
- mayChangedKey.isKeystone !== savedKey.isKeystone ||
70
- mayChangedKey.isNanoLedger !== savedKey.isNanoLedger ||
71
- mayChangedKey.address !== savedKey.address ||
72
- mayChangedKey.bech32Address !== savedKey.bech32Address ||
73
- mayChangedKey.pubKey !== savedKey.pubKey) {
74
- hasChanged = true;
75
- lastSeenKeys[chainId] = mayChangedKey;
76
- }
77
- }
78
- }
79
- }
80
- if (hasChanged) {
81
- yield this.saveAllLastSeenKey(lastSeenKeys);
82
- window.dispatchEvent(new Event('keplr_keystorechange'));
83
- }
84
- }
85
- });
86
- if (!options.kvStore) {
87
- options.kvStore = new IndexedDBKVStore('keplr_wallet_connect');
88
- }
89
- connector.on('disconnect', () => {
90
- this.clearSaved();
91
- });
92
- connector.on('call_request', this.onCallReqeust);
93
- }
94
- clearSaved() {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- const kvStore = this.options.kvStore;
97
- yield Promise.all([
98
- kvStore.set(this.getKeyHasEnabled(), null),
99
- kvStore.set(this.getKeyLastSeenKey(), null),
100
- ]);
101
- });
102
- }
103
- sendCustomRequest(request, options) {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- if (this.options.onBeforeSendRequest) {
106
- yield this.options.onBeforeSendRequest(request, options);
107
- }
108
- const res = yield this.connector.sendCustomRequest(request, options);
109
- if (this.options.onAfterSendRequest) {
110
- yield this.options.onAfterSendRequest(res, request, options);
111
- }
112
- return res;
113
- });
114
- }
115
- enable(chainIds) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- if (typeof chainIds === 'string') {
118
- chainIds = [chainIds];
119
- }
120
- const hasEnabledChainIds = yield this.getHasEnabledChainIds();
121
- let allEnabled = true;
122
- for (const chainId of chainIds) {
123
- if (hasEnabledChainIds.indexOf(chainId) < 0) {
124
- allEnabled = false;
125
- break;
126
- }
127
- }
128
- if (allEnabled) {
129
- return;
130
- }
131
- yield this.sendCustomRequest({
132
- id: payloadId(),
133
- jsonrpc: '2.0',
134
- method: 'keplr_enable_wallet_connect_v1',
135
- params: chainIds,
136
- });
137
- yield this.saveHasEnabledChainIds(chainIds);
138
- });
139
- }
140
- getKeyHasEnabled() {
141
- return `${this.connector.session.handshakeTopic}-enabled`;
142
- }
143
- getHasEnabledChainIds() {
144
- var _a;
145
- return __awaiter(this, void 0, void 0, function* () {
146
- return ((_a = (yield this.options.kvStore.get(this.getKeyHasEnabled()))) !== null && _a !== void 0 ? _a : []);
147
- });
148
- }
149
- saveHasEnabledChainIds(chainIds) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- const hasEnabledChainIds = yield this.getHasEnabledChainIds();
152
- for (const chainId of chainIds) {
153
- if (hasEnabledChainIds.indexOf(chainId) < 0) {
154
- hasEnabledChainIds.push(chainId);
155
- }
156
- }
157
- yield this.options.kvStore.set(this.getKeyHasEnabled(), hasEnabledChainIds);
158
- });
159
- }
160
- enigmaDecrypt(_chainId, _ciphertext, _nonce) {
161
- throw new Error('Not yet implemented');
162
- }
163
- enigmaEncrypt(_chainId, _contractCodeHash,
164
- // eslint-disable-next-line @typescript-eslint/ban-types
165
- _msg) {
166
- throw new Error('Not yet implemented');
167
- }
168
- experimentalSuggestChain(_chainInfo) {
169
- throw new Error('Not yet implemented');
170
- }
171
- getEnigmaPubKey(_chainId) {
172
- throw new Error('Not yet implemented');
173
- }
174
- getEnigmaTxEncryptionKey(_chainId, _nonce) {
175
- throw new Error('Not yet implemented');
176
- }
177
- getEnigmaUtils(_chainId) {
178
- throw new Error('Not yet implemented');
179
- }
180
- getKey(chainId) {
181
- return __awaiter(this, void 0, void 0, function* () {
182
- const lastSeenKey = yield this.getLastSeenKey(chainId);
183
- if (lastSeenKey) {
184
- return {
185
- address: Buffer.from(lastSeenKey.address, 'hex'),
186
- algo: lastSeenKey.algo,
187
- bech32Address: lastSeenKey.bech32Address,
188
- isKeystone: lastSeenKey.isKeystone,
189
- isNanoLedger: lastSeenKey.isNanoLedger,
190
- name: lastSeenKey.name,
191
- pubKey: Buffer.from(lastSeenKey.pubKey, 'hex'),
192
- };
193
- }
194
- const response = (yield this.sendCustomRequest({
195
- id: payloadId(),
196
- jsonrpc: '2.0',
197
- method: 'keplr_get_key_wallet_connect_v1',
198
- params: [chainId],
199
- }))[0];
200
- yield this.saveLastSeenKey(chainId, response);
201
- return {
202
- address: Buffer.from(response.address, 'hex'),
203
- algo: response.algo,
204
- bech32Address: response.bech32Address,
205
- isKeystone: response.isKeystone,
206
- isNanoLedger: response.isNanoLedger,
207
- name: response.name,
208
- pubKey: Buffer.from(response.pubKey, 'hex'),
209
- };
210
- });
211
- }
212
- getKeyLastSeenKey() {
213
- return `${this.connector.session.handshakeTopic}-key`;
214
- }
215
- getLastSeenKey(chainId) {
216
- return __awaiter(this, void 0, void 0, function* () {
217
- const saved = yield this.getAllLastSeenKey();
218
- if (!saved) {
219
- return undefined;
220
- }
221
- return saved[chainId];
222
- });
223
- }
224
- getAllLastSeenKey() {
225
- return __awaiter(this, void 0, void 0, function* () {
226
- return yield this.options.kvStore.get(this.getKeyLastSeenKey());
227
- });
228
- }
229
- saveAllLastSeenKey(data) {
230
- return __awaiter(this, void 0, void 0, function* () {
231
- yield this.options.kvStore.set(this.getKeyLastSeenKey(), data);
232
- });
233
- }
234
- saveLastSeenKey(chainId, response) {
235
- return __awaiter(this, void 0, void 0, function* () {
236
- let saved = yield this.getAllLastSeenKey();
237
- if (!saved) {
238
- saved = {};
239
- }
240
- saved[chainId] = response;
241
- yield this.saveAllLastSeenKey(saved);
242
- });
243
- }
244
- signArbitrary(_chainId, _signer, _data) {
245
- throw new Error('Not yet implemented');
246
- }
247
- verifyArbitrary(_chainId, _signer, _data, _signature) {
248
- throw new Error('Not yet implemented');
249
- }
250
- signEthereum(_chainId, _signer, _data, _mode) {
251
- throw new Error('Not yet implemented');
252
- }
253
- signICNSAdr36(_chainId, _contractAddress, _owner, _username, _addressChainIds) {
254
- throw new Error('Not yet implemented');
255
- }
256
- getOfflineSigner(chainId) {
257
- return new CosmJSOfflineSigner(chainId, this);
258
- }
259
- getOfflineSignerAuto(chainId) {
260
- return __awaiter(this, void 0, void 0, function* () {
261
- const key = yield this.getKey(chainId);
262
- if (key.isNanoLedger) {
263
- return new CosmJSOfflineSignerOnlyAmino(chainId, this);
264
- }
265
- return new CosmJSOfflineSigner(chainId, this);
266
- });
267
- }
268
- getOfflineSignerOnlyAmino(chainId) {
269
- return new CosmJSOfflineSignerOnlyAmino(chainId, this);
270
- }
271
- getSecret20ViewingKey(_chainId, _contractAddress) {
272
- throw new Error('Not yet implemented');
273
- }
274
- /**
275
- * In the extension environment, this API let the extension to send the tx on behalf of the client.
276
- * 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.
277
- * However, this approach is not efficient and hard to ensure the stability and `KeplrWalletConnect` should have the informations of rpc and rest endpoints.
278
- * 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`.
279
- * @param chainId
280
- * @param stdTx
281
- * @param mode
282
- */
283
- sendTx(chainId, tx, mode) {
284
- if (this.options.sendTx) {
285
- return this.options.sendTx(chainId, tx, mode);
286
- }
287
- throw new Error('send tx is not delivered by options');
288
- }
289
- signAmino(chainId, signer, signDoc, signOptions = {}) {
290
- var _a;
291
- return __awaiter(this, void 0, void 0, function* () {
292
- return (yield this.sendCustomRequest({
293
- id: payloadId(),
294
- jsonrpc: '2.0',
295
- method: 'keplr_sign_amino_wallet_connect_v1',
296
- params: [
297
- chainId,
298
- signer,
299
- signDoc,
300
- deepmerge((_a = this.defaultOptions.sign) !== null && _a !== void 0 ? _a : {}, signOptions),
301
- ],
302
- }))[0];
303
- });
304
- }
305
- signDirect(_chainId, _signer, _signDoc, _signOptions = {}) {
306
- throw new Error('Not yet implemented');
307
- }
308
- suggestToken(_chainId, _contractAddress, _viewingKey) {
309
- throw new Error('Not yet implemented');
310
- }
311
- experimentalSignEIP712CosmosTx_v0(_chainId, _signer, _eip712, _signDoc, _signOptions = {}) {
312
- throw new Error('Not yet implemented');
313
- }
314
- getChainInfosWithoutEndpoints() {
315
- throw new Error('Not yet implemented');
316
- }
317
- disable(_chainIds) {
318
- throw new Error('Not yet implemented');
319
- }
320
- changeKeyRingName(_opts) {
321
- throw new Error('Not yet implemented');
322
- }
323
- }
324
-
325
- export { KeplrWalletConnectV1 };
@@ -1,111 +0,0 @@
1
- 'use strict';
2
-
3
- var tslib = require('tslib');
4
- var BloctoSDK = require('@blocto/sdk');
5
- var ethers = require('ethers');
6
- var logger = require('../../utils/logger.cjs');
7
- var EthWalletConnector = require('./EthWalletConnector.cjs');
8
- var ethProviderHelper = require('./ethProviderHelper.cjs');
9
-
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var BloctoSDK__default = /*#__PURE__*/_interopDefaultLegacy(BloctoSDK);
13
-
14
- class BloctoEvm extends EthWalletConnector.EthWalletConnector {
15
- constructor({ evmNetworks }) {
16
- var _a, _b;
17
- // Taken from : https://docs.blocto.app/blocto-sdk/javascript-sdk/evm-sdk/provider
18
- const BLOCTO_SUPPORTED_CHAIN_IDS = [1, 4, 56, 97, 137, 80001, 43114, 43113];
19
- const bloctoSupportedNetworks = evmNetworks.filter((n) => BLOCTO_SUPPORTED_CHAIN_IDS.includes(n.chainId));
20
- super({ evmNetworks: bloctoSupportedNetworks });
21
- this.LOCAL_STORAGE_KEY = 'dynamic_blocto_evm_chain_id';
22
- this.name = 'bloctoevm';
23
- this.canConnectViaCustodialService = true;
24
- this.connectedChain = 'EVM';
25
- this.supportedChains = ['EVM', 'ETH'];
26
- this.ethProviderHelper = new ethProviderHelper.EthProviderHelper();
27
- this.supportsNetworkSwitching = () => false;
28
- this.chainId =
29
- Number(localStorage.getItem(this.LOCAL_STORAGE_KEY)) ||
30
- ((_a = bloctoSupportedNetworks.find((n) => n.chainId === 137)) === null || _a === void 0 ? void 0 : _a.chainId) ||
31
- ((_b = bloctoSupportedNetworks[0]) === null || _b === void 0 ? void 0 : _b.chainId);
32
- }
33
- getClient() {
34
- if (!this.client) {
35
- const network = this.evmNetworks.find((n) => n.chainId === this.chainId);
36
- if (network) {
37
- this.client = new BloctoSDK__default["default"]({
38
- ethereum: {
39
- chainId: `0x${this.chainId.toString(16)}`,
40
- rpc: network.rpcUrls[0],
41
- },
42
- });
43
- }
44
- else {
45
- logger.logger.error("Couldn't find a configured network for Blocto EVM");
46
- }
47
- }
48
- return this.client;
49
- }
50
- getWeb3Provider() {
51
- const client = this.getClient();
52
- // If there are no accounts yet, we shouldn't wrap the provider in ethers
53
- if (client && client.ethereum && client.ethereum.accounts.length > 0) {
54
- return new ethers.ethers.providers.Web3Provider(client.ethereum);
55
- }
56
- else {
57
- return undefined;
58
- }
59
- }
60
- // We are calling the client directly and not via Web3Provider because if we will wrap it in Ethers,
61
- // Ethers will be making retries on failure. This becomes an issue on the connect step.
62
- // When Blocto's modal closes prior to receiving a response with the address on the connect step,
63
- // then ethers would retry and the modal will open again.
64
- fetchPublicAddress() {
65
- return tslib.__awaiter(this, void 0, void 0, function* () {
66
- try {
67
- const client = this.getClient();
68
- if (client && client.ethereum) {
69
- const addresses = yield client.ethereum.request({
70
- method: 'eth_requestAccounts',
71
- });
72
- if (addresses.length > 0) {
73
- return addresses[0];
74
- }
75
- }
76
- return undefined;
77
- }
78
- catch (e) {
79
- logger.logger.error(e);
80
- return Promise.reject(e);
81
- }
82
- });
83
- }
84
- signMessage(messageToSign) {
85
- return tslib.__awaiter(this, void 0, void 0, function* () {
86
- try {
87
- const signer = yield this.getSigner();
88
- return yield (signer === null || signer === void 0 ? void 0 : signer.signMessage(messageToSign));
89
- }
90
- catch (e) {
91
- if (e.message === 'User declined the signing request') {
92
- return Promise.reject({ code: '4001' });
93
- }
94
- else {
95
- return Promise.reject(e);
96
- }
97
- }
98
- });
99
- }
100
- endSession() {
101
- return tslib.__awaiter(this, void 0, void 0, function* () {
102
- const client = this.getClient();
103
- localStorage.removeItem('sdk.session');
104
- if (client && client.ethereum && client.ethereum.accounts.length > 0) {
105
- yield client.ethereum.request({ method: 'wallet_disconnect' });
106
- }
107
- });
108
- }
109
- }
110
-
111
- module.exports = BloctoEvm;
@@ -1,25 +0,0 @@
1
- import { ethers } from 'ethers';
2
- import { Chain } from '@dynamic-labs/wallet-connector-core';
3
- import { EvmNetwork } from './evm-network';
4
- import { EthWalletConnector } from './EthWalletConnector';
5
- import { EthProviderHelper } from './ethProviderHelper';
6
- declare class BloctoEvm extends EthWalletConnector {
7
- LOCAL_STORAGE_KEY: string;
8
- private client?;
9
- name: string;
10
- canConnectViaCustodialService: boolean;
11
- connectedChain: Chain;
12
- supportedChains: Chain[];
13
- chainId: number;
14
- ethProviderHelper: EthProviderHelper;
15
- supportsNetworkSwitching: () => boolean;
16
- constructor({ evmNetworks }: {
17
- evmNetworks: EvmNetwork[];
18
- });
19
- private getClient;
20
- getWeb3Provider(): ethers.providers.Web3Provider | undefined;
21
- fetchPublicAddress(): Promise<string | undefined>;
22
- signMessage(messageToSign: string): Promise<string | undefined>;
23
- endSession(): Promise<void>;
24
- }
25
- export default BloctoEvm;
@@ -1,105 +0,0 @@
1
- import { __awaiter } from 'tslib';
2
- import BloctoSDK from '@blocto/sdk';
3
- import { ethers } from 'ethers';
4
- import { logger } from '../../utils/logger.js';
5
- import { EthWalletConnector } from './EthWalletConnector.js';
6
- import { EthProviderHelper } from './ethProviderHelper.js';
7
-
8
- class BloctoEvm extends EthWalletConnector {
9
- constructor({ evmNetworks }) {
10
- var _a, _b;
11
- // Taken from : https://docs.blocto.app/blocto-sdk/javascript-sdk/evm-sdk/provider
12
- const BLOCTO_SUPPORTED_CHAIN_IDS = [1, 4, 56, 97, 137, 80001, 43114, 43113];
13
- const bloctoSupportedNetworks = evmNetworks.filter((n) => BLOCTO_SUPPORTED_CHAIN_IDS.includes(n.chainId));
14
- super({ evmNetworks: bloctoSupportedNetworks });
15
- this.LOCAL_STORAGE_KEY = 'dynamic_blocto_evm_chain_id';
16
- this.name = 'bloctoevm';
17
- this.canConnectViaCustodialService = true;
18
- this.connectedChain = 'EVM';
19
- this.supportedChains = ['EVM', 'ETH'];
20
- this.ethProviderHelper = new EthProviderHelper();
21
- this.supportsNetworkSwitching = () => false;
22
- this.chainId =
23
- Number(localStorage.getItem(this.LOCAL_STORAGE_KEY)) ||
24
- ((_a = bloctoSupportedNetworks.find((n) => n.chainId === 137)) === null || _a === void 0 ? void 0 : _a.chainId) ||
25
- ((_b = bloctoSupportedNetworks[0]) === null || _b === void 0 ? void 0 : _b.chainId);
26
- }
27
- getClient() {
28
- if (!this.client) {
29
- const network = this.evmNetworks.find((n) => n.chainId === this.chainId);
30
- if (network) {
31
- this.client = new BloctoSDK({
32
- ethereum: {
33
- chainId: `0x${this.chainId.toString(16)}`,
34
- rpc: network.rpcUrls[0],
35
- },
36
- });
37
- }
38
- else {
39
- logger.error("Couldn't find a configured network for Blocto EVM");
40
- }
41
- }
42
- return this.client;
43
- }
44
- getWeb3Provider() {
45
- const client = this.getClient();
46
- // If there are no accounts yet, we shouldn't wrap the provider in ethers
47
- if (client && client.ethereum && client.ethereum.accounts.length > 0) {
48
- return new ethers.providers.Web3Provider(client.ethereum);
49
- }
50
- else {
51
- return undefined;
52
- }
53
- }
54
- // We are calling the client directly and not via Web3Provider because if we will wrap it in Ethers,
55
- // Ethers will be making retries on failure. This becomes an issue on the connect step.
56
- // When Blocto's modal closes prior to receiving a response with the address on the connect step,
57
- // then ethers would retry and the modal will open again.
58
- fetchPublicAddress() {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- try {
61
- const client = this.getClient();
62
- if (client && client.ethereum) {
63
- const addresses = yield client.ethereum.request({
64
- method: 'eth_requestAccounts',
65
- });
66
- if (addresses.length > 0) {
67
- return addresses[0];
68
- }
69
- }
70
- return undefined;
71
- }
72
- catch (e) {
73
- logger.error(e);
74
- return Promise.reject(e);
75
- }
76
- });
77
- }
78
- signMessage(messageToSign) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- try {
81
- const signer = yield this.getSigner();
82
- return yield (signer === null || signer === void 0 ? void 0 : signer.signMessage(messageToSign));
83
- }
84
- catch (e) {
85
- if (e.message === 'User declined the signing request') {
86
- return Promise.reject({ code: '4001' });
87
- }
88
- else {
89
- return Promise.reject(e);
90
- }
91
- }
92
- });
93
- }
94
- endSession() {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- const client = this.getClient();
97
- localStorage.removeItem('sdk.session');
98
- if (client && client.ethereum && client.ethereum.accounts.length > 0) {
99
- yield client.ethereum.request({ method: 'wallet_disconnect' });
100
- }
101
- });
102
- }
103
- }
104
-
105
- export { BloctoEvm as default };