@rango-dev/wallets-react 0.27.1-next.1 → 0.27.1-next.10
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.
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +7 -0
- package/dist/hub/autoConnect.d.ts.map +1 -1
- package/dist/hub/helpers.d.ts +1 -1
- package/dist/hub/helpers.d.ts.map +1 -1
- package/dist/hub/lastConnectedWallets.d.ts +2 -1
- package/dist/hub/lastConnectedWallets.d.ts.map +1 -1
- package/dist/hub/mod.d.ts +1 -1
- package/dist/hub/mod.d.ts.map +1 -1
- package/dist/hub/useHubAdapter.d.ts.map +1 -1
- package/dist/hub/utils.d.ts +3 -8
- package/dist/hub/utils.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/legacy/autoConnect.d.ts.map +1 -1
- package/dist/legacy/types.d.ts +0 -1
- package/dist/legacy/types.d.ts.map +1 -1
- package/dist/useProviders.d.ts.map +1 -1
- package/dist/wallets-react.build.json +1 -1
- package/helpers/package.json +8 -0
- package/package.json +12 -7
- package/src/helpers/index.ts +1 -0
- package/src/hub/autoConnect.ts +62 -33
- package/src/hub/helpers.ts +9 -3
- package/src/hub/lastConnectedWallets.ts +22 -1
- package/src/hub/mod.ts +5 -1
- package/src/hub/useHubAdapter.ts +8 -4
- package/src/hub/utils.ts +83 -43
- package/src/index.ts +0 -1
- package/src/legacy/autoConnect.ts +12 -24
- package/src/legacy/types.ts +0 -1
- package/src/useProviders.ts +2 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/hub/constants.ts":{"bytes":146,"imports":[],"format":"esm"},"src/hub/lastConnectedWallets.ts":{"bytes":4059,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/hub/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/helpers.ts":{"bytes":4652,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/hub/constants.ts","kind":"import-statement","original":"../hub/constants.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"../hub/lastConnectedWallets.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/context.ts":{"bytes":905,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/hub/helpers.ts":{"bytes":2205,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/utils.ts":{"bytes":9293,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/autoConnect.ts":{"bytes":2509,"imports":[{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"../hub/lastConnectedWallets.js"},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"./mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/hooks.ts":{"bytes":1545,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/utils.ts":{"bytes":230,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useAutoConnect.ts":{"bytes":628,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useLegacyProviders.ts":{"bytes":7308,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/autoConnect.ts","kind":"import-statement","original":"./autoConnect.js"},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./hooks.js"},{"path":"src/legacy/useAutoConnect.ts","kind":"import-statement","original":"./useAutoConnect.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/mod.ts":{"bytes":321,"imports":[{"path":"src/hub/constants.ts","kind":"import-statement","original":"../hub/constants.js"},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"src/legacy/useLegacyProviders.ts","kind":"import-statement","original":"./useLegacyProviders.js"}],"format":"esm"},"src/hub/autoConnect.ts":{"bytes":6183,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/useHubRefs.ts":{"bytes":1365,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/useHubAdapter.ts":{"bytes":11168,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/legacy/useAutoConnect.ts","kind":"import-statement","original":"../legacy/useAutoConnect.js"},{"path":"src/hub/autoConnect.ts","kind":"import-statement","original":"./autoConnect.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"src/hub/useHubRefs.ts","kind":"import-statement","original":"./useHubRefs.js"},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/mod.ts":{"bytes":132,"imports":[{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"src/hub/useHubAdapter.ts","kind":"import-statement","original":"./useHubAdapter.js"}],"format":"esm"},"src/useProviders.ts":{"bytes":3513,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"./hub/mod.js"},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"./legacy/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/provider.tsx":{"bytes":405,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./legacy/context.js"},{"path":"src/useProviders.ts","kind":"import-statement","original":"./useProviders.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/types.ts":{"bytes":5184,"imports":[],"format":"esm"},"src/index.ts":{"bytes":235,"imports":[{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./legacy/helpers.js"},{"path":"src/provider.tsx","kind":"import-statement","original":"./provider.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./legacy/hooks.js"},{"path":"src/legacy/types.ts","kind":"import-statement","original":"./legacy/types.js"},{"path":"src/hub/mod.ts","kind":"import-statement","original":"./hub/mod.js"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":91432},"dist/index.js":{"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["Events","Provider","availableWallets","checkWalletProviders","choose","clearPersistance","connectedWallets","defaultWalletState","isAsync","makeEventHandler","needsCheckInstallation","separateLegacyAndHubProviders","stateReducer","tryPersistWallet","tryRemoveWalletFromPersistance","useWallets"],"entryPoint":"src/index.ts","inputs":{"src/legacy/helpers.ts":{"bytesInOutput":1401},"src/hub/constants.ts":{"bytesInOutput":65},"src/hub/lastConnectedWallets.ts":{"bytesInOutput":998},"src/index.ts":{"bytesInOutput":0},"src/provider.tsx":{"bytesInOutput":133},"src/legacy/context.ts":{"bytesInOutput":431},"src/hub/utils.ts":{"bytesInOutput":2700},"src/hub/helpers.ts":{"bytesInOutput":769},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":3612},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":2127},"src/legacy/autoConnect.ts":{"bytesInOutput":444},"src/legacy/hooks.ts":{"bytesInOutput":460},"src/legacy/useAutoConnect.ts":{"bytesInOutput":197},"src/legacy/utils.ts":{"bytesInOutput":94},"src/hub/autoConnect.ts":{"bytesInOutput":1740},"src/hub/useHubRefs.ts":{"bytesInOutput":510},"src/useProviders.ts":{"bytesInOutput":942},"src/legacy/types.ts":{"bytesInOutput":164}},"bytes":17261}}}
|
|
1
|
+
{"inputs":{"src/hub/constants.ts":{"bytes":146,"imports":[],"format":"esm"},"src/hub/lastConnectedWallets.ts":{"bytes":4867,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/hub/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/helpers.ts":{"bytes":4652,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/hub/constants.ts","kind":"import-statement","original":"../hub/constants.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"../hub/lastConnectedWallets.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/context.ts":{"bytes":905,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/autoConnect.ts":{"bytes":2046,"imports":[{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"../hub/lastConnectedWallets.js"},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"./mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/hooks.ts":{"bytes":1545,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/utils.ts":{"bytes":230,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useAutoConnect.ts":{"bytes":628,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useLegacyProviders.ts":{"bytes":7308,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/autoConnect.ts","kind":"import-statement","original":"./autoConnect.js"},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./hooks.js"},{"path":"src/legacy/useAutoConnect.ts","kind":"import-statement","original":"./useAutoConnect.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/mod.ts":{"bytes":321,"imports":[{"path":"src/hub/constants.ts","kind":"import-statement","original":"../hub/constants.js"},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"src/legacy/useLegacyProviders.ts","kind":"import-statement","original":"./useLegacyProviders.js"}],"format":"esm"},"src/hub/helpers.ts":{"bytes":2307,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/utils.ts":{"bytes":10648,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/autoConnect.ts":{"bytes":7018,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/useHubRefs.ts":{"bytes":1365,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/useHubAdapter.ts":{"bytes":11338,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"../legacy/mod.js"},{"path":"src/legacy/useAutoConnect.ts","kind":"import-statement","original":"../legacy/useAutoConnect.js"},{"path":"src/hub/autoConnect.ts","kind":"import-statement","original":"./autoConnect.js"},{"path":"src/hub/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/hub/lastConnectedWallets.ts","kind":"import-statement","original":"./lastConnectedWallets.js"},{"path":"src/hub/useHubRefs.ts","kind":"import-statement","original":"./useHubRefs.js"},{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/mod.ts":{"bytes":162,"imports":[{"path":"src/hub/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"src/hub/useHubAdapter.ts","kind":"import-statement","original":"./useHubAdapter.js"}],"format":"esm"},"src/useProviders.ts":{"bytes":3425,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"./hub/mod.js"},{"path":"src/legacy/mod.ts","kind":"import-statement","original":"./legacy/mod.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/provider.tsx":{"bytes":405,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./legacy/context.js"},{"path":"src/useProviders.ts","kind":"import-statement","original":"./useProviders.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/types.ts":{"bytes":5147,"imports":[],"format":"esm"},"src/index.ts":{"bytes":173,"imports":[{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./legacy/helpers.js"},{"path":"src/provider.tsx","kind":"import-statement","original":"./provider.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./legacy/hooks.js"},{"path":"src/legacy/types.ts","kind":"import-statement","original":"./legacy/types.js"}],"format":"esm"},"src/helpers/index.ts":{"bytes":55,"imports":[{"path":"src/hub/mod.ts","kind":"import-statement","original":"../hub/mod.js"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":95643},"dist/index.js":{"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["Events","Provider","availableWallets","checkWalletProviders","choose","clearPersistance","connectedWallets","defaultWalletState","isAsync","makeEventHandler","needsCheckInstallation","stateReducer","tryPersistWallet","tryRemoveWalletFromPersistance","useWallets"],"entryPoint":"src/index.ts","inputs":{"src/legacy/helpers.ts":{"bytesInOutput":1401},"src/hub/constants.ts":{"bytesInOutput":65},"src/hub/lastConnectedWallets.ts":{"bytesInOutput":1210},"src/index.ts":{"bytesInOutput":0},"src/provider.tsx":{"bytesInOutput":133},"src/legacy/context.ts":{"bytesInOutput":431},"src/hub/utils.ts":{"bytesInOutput":2902},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":2126},"src/legacy/autoConnect.ts":{"bytesInOutput":393},"src/legacy/hooks.ts":{"bytesInOutput":460},"src/legacy/useAutoConnect.ts":{"bytesInOutput":197},"src/legacy/utils.ts":{"bytesInOutput":94},"src/hub/helpers.ts":{"bytesInOutput":822},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":3681},"src/hub/autoConnect.ts":{"bytesInOutput":2054},"src/hub/useHubRefs.ts":{"bytesInOutput":510},"src/useProviders.ts":{"bytesInOutput":885},"src/legacy/types.ts":{"bytesInOutput":164}},"bytes":17967},"dist/helpers/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":59715},"dist/helpers/index.js":{"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["getAllLegacyProviders"],"entryPoint":"src/helpers/index.ts","inputs":{"src/hub/utils.ts":{"bytesInOutput":547},"src/hub/constants.ts":{"bytesInOutput":65},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/context.ts":{"bytesInOutput":427},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":52},"src/hub/lastConnectedWallets.ts":{"bytesInOutput":1210},"src/legacy/helpers.ts":{"bytesInOutput":59},"src/legacy/hooks.ts":{"bytesInOutput":109},"src/legacy/useAutoConnect.ts":{"bytesInOutput":46},"src/hub/helpers.ts":{"bytesInOutput":135},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":97},"src/hub/autoConnect.ts":{"bytesInOutput":119},"src/hub/useHubRefs.ts":{"bytesInOutput":97},"src/helpers/index.ts":{"bytesInOutput":0}},"bytes":3112}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/wallets-react",
|
|
3
|
-
"version": "0.27.1-next.
|
|
3
|
+
"version": "0.27.1-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -9,18 +9,23 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./helpers": {
|
|
14
|
+
"types": "./dist/helpers/index.d.ts",
|
|
15
|
+
"default": "./dist/helpers/index.js"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
15
19
|
"dist",
|
|
16
|
-
"src"
|
|
20
|
+
"src",
|
|
21
|
+
"helpers"
|
|
17
22
|
],
|
|
18
23
|
"scripts": {
|
|
19
|
-
"build": "node ../../scripts/build/command.mjs --path wallets/react",
|
|
24
|
+
"build": "node ../../scripts/build/command.mjs --path wallets/react --inputs src/index.ts,src/helpers/index.ts",
|
|
20
25
|
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
21
26
|
"clean": "rimraf dist",
|
|
22
27
|
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
23
|
-
"lint": "eslint \"**/*.{ts,tsx}\"
|
|
28
|
+
"lint": "eslint \"**/*.{ts,tsx}\"",
|
|
24
29
|
"test": "vitest",
|
|
25
30
|
"coverage": "vitest run --coverage"
|
|
26
31
|
},
|
|
@@ -30,8 +35,8 @@
|
|
|
30
35
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
31
36
|
},
|
|
32
37
|
"dependencies": {
|
|
33
|
-
"@rango-dev/wallets-core": "^0.40.1-next.
|
|
34
|
-
"@rango-dev/wallets-shared": "^0.41.1-next.
|
|
38
|
+
"@rango-dev/wallets-core": "^0.40.1-next.10",
|
|
39
|
+
"@rango-dev/wallets-shared": "^0.41.1-next.3",
|
|
35
40
|
"rango-types": "^0.1.74"
|
|
36
41
|
},
|
|
37
42
|
"devDependencies": {
|
|
@@ -41,4 +46,4 @@
|
|
|
41
46
|
"publishConfig": {
|
|
42
47
|
"access": "public"
|
|
43
48
|
}
|
|
44
|
-
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getAllLegacyProviders } from '../hub/mod.js';
|
package/src/hub/autoConnect.ts
CHANGED
|
@@ -15,10 +15,15 @@ import {
|
|
|
15
15
|
|
|
16
16
|
import { HUB_LAST_CONNECTED_WALLETS } from '../legacy/mod.js';
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { runSequentiallyWithoutFailure } from './helpers.js';
|
|
19
19
|
import { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';
|
|
20
20
|
import { convertNamespaceNetworkToEvmChainId } from './utils.js';
|
|
21
21
|
|
|
22
|
+
// Getting connected wallets from storage
|
|
23
|
+
const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
|
|
24
|
+
HUB_LAST_CONNECTED_WALLETS
|
|
25
|
+
);
|
|
26
|
+
|
|
22
27
|
/**
|
|
23
28
|
* Run `.connect` action on some selected namespaces (passed as param) for a provider.
|
|
24
29
|
*/
|
|
@@ -60,21 +65,60 @@ async function eagerConnect(
|
|
|
60
65
|
targetNamespaces.push([namespaceInput, result]);
|
|
61
66
|
});
|
|
62
67
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
const connectNamespacesPromises = targetNamespaces.map(
|
|
69
|
+
([info, namespace]) => {
|
|
70
|
+
const evmChain = legacyIsEvmNamespace(info)
|
|
71
|
+
? convertNamespaceNetworkToEvmChainId(info, allBlockChains || [])
|
|
72
|
+
: undefined;
|
|
73
|
+
const chain = evmChain || info.network;
|
|
74
|
+
|
|
75
|
+
return async () =>
|
|
76
|
+
await namespace.connect(chain).catch((e) => {
|
|
77
|
+
/*
|
|
78
|
+
* Since we check for connect failures using `instanceof Error`
|
|
79
|
+
* this check is added here to make sure the thrown error always is an instance of `Error`
|
|
80
|
+
*/
|
|
81
|
+
if (e instanceof Error) {
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
throw new Error(e);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
);
|
|
71
88
|
|
|
72
89
|
/**
|
|
73
90
|
* Sometimes calling methods on a instance in parallel, would cause an error in wallet.
|
|
74
91
|
* We are running a method at a time to make sure we are covering this.
|
|
75
92
|
* e.g. when we are trying to eagerConnect evm and solana on phantom at the same time, the last namespace throw an error.
|
|
76
93
|
*/
|
|
77
|
-
|
|
94
|
+
const connectNamespacesResult = await runSequentiallyWithoutFailure(
|
|
95
|
+
connectNamespacesPromises
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const failedNamespaces: LegacyNamespaceInputForConnect[] = [];
|
|
99
|
+
connectNamespacesResult.forEach((result, index) => {
|
|
100
|
+
if (result instanceof Error) {
|
|
101
|
+
failedNamespaces.push(targetNamespaces[index][0]);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (failedNamespaces.length > 0) {
|
|
106
|
+
lastConnectedWalletsFromStorage.removeNamespacesFromWallet(
|
|
107
|
+
type,
|
|
108
|
+
failedNamespaces.map((namespace) => namespace.namespace)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const atLeastOneNamespaceConnectedSuccessfully =
|
|
113
|
+
connectNamespacesResult.length - failedNamespaces.length > 0;
|
|
114
|
+
if (!atLeastOneNamespaceConnectedSuccessfully) {
|
|
115
|
+
throw new Error(`No namespace connected for ${type}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const successfulResult = connectNamespacesResult.filter(
|
|
119
|
+
(result) => !(result instanceof Error)
|
|
120
|
+
);
|
|
121
|
+
return successfulResult;
|
|
78
122
|
}
|
|
79
123
|
|
|
80
124
|
/*
|
|
@@ -92,11 +136,6 @@ export async function autoConnect(deps: {
|
|
|
92
136
|
wallets?: (WalletType | LegacyProviderInterface)[];
|
|
93
137
|
}): Promise<void> {
|
|
94
138
|
const { getHub, allBlockChains, getLegacyProvider, wallets } = deps;
|
|
95
|
-
|
|
96
|
-
// Getting connected wallets from storage
|
|
97
|
-
const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
|
|
98
|
-
HUB_LAST_CONNECTED_WALLETS
|
|
99
|
-
);
|
|
100
139
|
const lastConnectedWallets = lastConnectedWalletsFromStorage.list();
|
|
101
140
|
const walletIds = Object.keys(lastConnectedWallets);
|
|
102
141
|
|
|
@@ -123,7 +162,8 @@ export async function autoConnect(deps: {
|
|
|
123
162
|
legacyInstance = legacyProvider.getInstance();
|
|
124
163
|
} catch (e) {
|
|
125
164
|
console.warn(
|
|
126
|
-
"It seems instance isn't available yet. This can
|
|
165
|
+
"It seems instance isn't available yet for auto connect. This can happen when extension not loaded yet (sometimes when opening browser for first time) or extension is disabled. Desired wallet:",
|
|
166
|
+
providerName
|
|
127
167
|
);
|
|
128
168
|
return;
|
|
129
169
|
}
|
|
@@ -131,7 +171,7 @@ export async function autoConnect(deps: {
|
|
|
131
171
|
const namespaces: LegacyNamespaceInputForConnect[] = lastConnectedWallets[
|
|
132
172
|
providerName
|
|
133
173
|
].map((namespace) => ({
|
|
134
|
-
namespace: namespace.
|
|
174
|
+
namespace: namespace.namespace,
|
|
135
175
|
network: namespace.network,
|
|
136
176
|
}));
|
|
137
177
|
|
|
@@ -161,26 +201,15 @@ export async function autoConnect(deps: {
|
|
|
161
201
|
providerName,
|
|
162
202
|
}).catch((e) => {
|
|
163
203
|
walletsToRemoveFromPersistance.push(providerName);
|
|
164
|
-
|
|
204
|
+
console.warn(e);
|
|
165
205
|
})
|
|
166
206
|
);
|
|
167
207
|
});
|
|
168
208
|
|
|
169
|
-
await Promise.
|
|
170
|
-
|
|
171
|
-
/*
|
|
172
|
-
*After successfully connecting to at least one wallet,
|
|
173
|
-
*we will removing the other wallets from persistence.
|
|
174
|
-
*If we are unable to connect to any wallet,
|
|
175
|
-
*the persistence will not be removed and the eager connection will be retried with another page load.
|
|
176
|
-
*/
|
|
177
|
-
const canRestoreAnyConnection =
|
|
178
|
-
walletIds.length > walletsToRemoveFromPersistance.length;
|
|
209
|
+
await Promise.all(eagerConnectQueue);
|
|
179
210
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
);
|
|
184
|
-
}
|
|
211
|
+
lastConnectedWalletsFromStorage.removeWallets(
|
|
212
|
+
walletsToRemoveFromPersistance
|
|
213
|
+
);
|
|
185
214
|
}
|
|
186
215
|
}
|
package/src/hub/helpers.ts
CHANGED
|
@@ -42,14 +42,20 @@ export function fromAccountIdToLegacyAddressFormat(account: string): string {
|
|
|
42
42
|
/**
|
|
43
43
|
* Getting a list of (lazy) promises and run them one after another.
|
|
44
44
|
*/
|
|
45
|
-
export async function
|
|
45
|
+
export async function runSequentiallyWithoutFailure<
|
|
46
|
+
T extends () => Promise<unknown>
|
|
47
|
+
>(
|
|
46
48
|
promises: Array<T>
|
|
47
49
|
): Promise<Array<T extends () => Promise<infer R> ? R : never>> {
|
|
48
50
|
const result = await promises.reduce(async (prev, task) => {
|
|
49
51
|
const previousResults = await prev;
|
|
50
|
-
|
|
52
|
+
try {
|
|
53
|
+
const taskResult = await task();
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
return [...previousResults, taskResult];
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return [...previousResults, error];
|
|
58
|
+
}
|
|
53
59
|
}, Promise.resolve([]) as Promise<any>);
|
|
54
60
|
return result;
|
|
55
61
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from './constants.js';
|
|
9
9
|
|
|
10
10
|
export interface NamespaceInput {
|
|
11
|
-
|
|
11
|
+
namespace: Namespace;
|
|
12
12
|
network: string | undefined;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -53,6 +53,12 @@ export class LastConnectedWalletsFromStorage {
|
|
|
53
53
|
}
|
|
54
54
|
throw new Error('Not implemented');
|
|
55
55
|
}
|
|
56
|
+
removeNamespacesFromWallet(providerId: string, namespaceIds: string[]) {
|
|
57
|
+
if (this.#storageKey === HUB_LAST_CONNECTED_WALLETS) {
|
|
58
|
+
return this.#removeNamespaceFromWalletHub(providerId, namespaceIds);
|
|
59
|
+
}
|
|
60
|
+
throw new Error('Not implemented');
|
|
61
|
+
}
|
|
56
62
|
|
|
57
63
|
#listFromLegacy(): LastConnectedWalletsStorage {
|
|
58
64
|
const persistor = new Persistor<LegacyLastConnectedWalletsStorage>();
|
|
@@ -105,6 +111,21 @@ export class LastConnectedWalletsFromStorage {
|
|
|
105
111
|
|
|
106
112
|
persistor.setItem(this.#storageKey, storageState);
|
|
107
113
|
}
|
|
114
|
+
#removeNamespaceFromWalletHub(
|
|
115
|
+
providerId: string,
|
|
116
|
+
namespaceIds: string[]
|
|
117
|
+
): void {
|
|
118
|
+
const persistor = new Persistor<LastConnectedWalletsStorage>();
|
|
119
|
+
const storageState = persistor.getItem(this.#storageKey) || {};
|
|
120
|
+
|
|
121
|
+
const currentProviderNamespaces = storageState[providerId];
|
|
122
|
+
const newProviderNamespaces = currentProviderNamespaces.filter(
|
|
123
|
+
(namespace) => !namespaceIds.includes(namespace.namespace)
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
this.#removeWalletsFromHub([providerId]);
|
|
127
|
+
this.#addWalletToHub(providerId, newProviderNamespaces);
|
|
128
|
+
}
|
|
108
129
|
#removeWalletsFromLegacy(providerIds?: string[]): void {
|
|
109
130
|
const persistor = new Persistor<LegacyLastConnectedWalletsStorage>();
|
|
110
131
|
const storageState = persistor.getItem(this.#storageKey) || [];
|
package/src/hub/mod.ts
CHANGED
package/src/hub/useHubAdapter.ts
CHANGED
|
@@ -187,7 +187,7 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
187
187
|
.then<ConnectResult>(transformHubResultToLegacyResult)
|
|
188
188
|
.then((res) => {
|
|
189
189
|
successfulyConnectedNamespaces.push({
|
|
190
|
-
|
|
190
|
+
namespace: namespaceInput.namespace,
|
|
191
191
|
network: namespaceInput.network,
|
|
192
192
|
});
|
|
193
193
|
return res;
|
|
@@ -222,7 +222,7 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
222
222
|
const wallet = getHub().get(type);
|
|
223
223
|
if (!wallet) {
|
|
224
224
|
throw new Error(
|
|
225
|
-
`You should add ${type} to provider first then call '
|
|
225
|
+
`You should add ${type} to provider first then call 'disconnect'.`
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -234,8 +234,12 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
234
234
|
lastConnectedWalletsFromStorage.removeWallets([type]);
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
|
-
disconnectAll() {
|
|
238
|
-
|
|
237
|
+
async disconnectAll() {
|
|
238
|
+
const disconnectPromises: Promise<any>[] = Array.from(
|
|
239
|
+
getHub().getAll().values()
|
|
240
|
+
).map(async (provider) => this.disconnect(provider.id));
|
|
241
|
+
|
|
242
|
+
return await Promise.allSettled(disconnectPromises);
|
|
239
243
|
},
|
|
240
244
|
async getSigners(type) {
|
|
241
245
|
const provider = getLegacyProvider(params.allVersionedProviders, type);
|
package/src/hub/utils.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AllProxiedNamespaces } from './types.js';
|
|
2
|
-
import type { ConnectResult, ProviderProps } from '../legacy/mod.js';
|
|
3
2
|
import type { Hub, Provider, State } from '@rango-dev/wallets-core';
|
|
4
3
|
import type {
|
|
5
4
|
LegacyNamespaceInputForConnect,
|
|
@@ -23,42 +22,40 @@ import {
|
|
|
23
22
|
} from '@rango-dev/wallets-shared';
|
|
24
23
|
import { type BlockchainMeta, isEvmBlockchain } from 'rango-types';
|
|
25
24
|
|
|
25
|
+
import {
|
|
26
|
+
type ConnectResult,
|
|
27
|
+
HUB_LAST_CONNECTED_WALLETS,
|
|
28
|
+
type ProviderProps,
|
|
29
|
+
} from '../legacy/mod.js';
|
|
30
|
+
|
|
26
31
|
import {
|
|
27
32
|
fromAccountIdToLegacyAddressFormat,
|
|
28
33
|
isConnectResultEvm,
|
|
29
34
|
isConnectResultSolana,
|
|
30
35
|
} from './helpers.js';
|
|
36
|
+
import { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';
|
|
31
37
|
|
|
32
38
|
/* Gets a list of hub and legacy providers and returns a tuple which separates them. */
|
|
33
39
|
export function separateLegacyAndHubProviders(
|
|
34
|
-
providers: VersionedProviders[]
|
|
35
|
-
options?: { isExperimentalEnabled?: boolean }
|
|
40
|
+
providers: VersionedProviders[]
|
|
36
41
|
): [LegacyProviderInterface[], Provider[]] {
|
|
37
42
|
const LEGACY_VERSION = '0.0.0';
|
|
38
43
|
const HUB_VERSION = '1.0.0';
|
|
39
|
-
const { isExperimentalEnabled = false } = options || {};
|
|
40
|
-
|
|
41
|
-
if (isExperimentalEnabled) {
|
|
42
|
-
const legacyProviders: LegacyProviderInterface[] = [];
|
|
43
|
-
const hubProviders: Provider[] = [];
|
|
44
|
-
|
|
45
|
-
providers.forEach((provider) => {
|
|
46
|
-
try {
|
|
47
|
-
const target = pickVersion(provider, HUB_VERSION);
|
|
48
|
-
hubProviders.push(target[1]);
|
|
49
|
-
} catch {
|
|
50
|
-
const target = pickVersion(provider, LEGACY_VERSION);
|
|
51
|
-
legacyProviders.push(target[1]);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
const legacyProviders: LegacyProviderInterface[] = [];
|
|
46
|
+
const hubProviders: Provider[] = [];
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
providers.forEach((provider) => {
|
|
49
|
+
try {
|
|
50
|
+
const target = pickVersion(provider, HUB_VERSION);
|
|
51
|
+
hubProviders.push(target[1]);
|
|
52
|
+
} catch {
|
|
53
|
+
const target = pickVersion(provider, LEGACY_VERSION);
|
|
54
|
+
legacyProviders.push(target[1]);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return [legacyProviders, hubProviders];
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
export function findProviderByType(
|
|
@@ -72,6 +69,11 @@ export function findProviderByType(
|
|
|
72
69
|
* We will call this function on hub's `subscribe`.
|
|
73
70
|
* it will check states and will emit legacy events for backward compatibility.
|
|
74
71
|
*/
|
|
72
|
+
|
|
73
|
+
const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
|
|
74
|
+
HUB_LAST_CONNECTED_WALLETS
|
|
75
|
+
);
|
|
76
|
+
|
|
75
77
|
export function checkHubStateAndTriggerEvents(
|
|
76
78
|
hub: Hub,
|
|
77
79
|
currentState: State,
|
|
@@ -99,8 +101,11 @@ export function checkHubStateAndTriggerEvents(
|
|
|
99
101
|
let hasAccountChanged = false;
|
|
100
102
|
let hasNetworkChanged = false;
|
|
101
103
|
let hasProviderDisconnected = false;
|
|
104
|
+
let anyNamespaceIsConnected = false;
|
|
102
105
|
// It will pick the last network from namespaces.
|
|
103
106
|
let maybeNetwork = null;
|
|
107
|
+
const disconnectedNamespacesIds: string[] = [];
|
|
108
|
+
|
|
104
109
|
provider.getAll().forEach((namespace) => {
|
|
105
110
|
const storeId = generateStoreId(providerId, namespace.namespaceId);
|
|
106
111
|
const currentNamespaceState = namespaceStateSelector(
|
|
@@ -124,29 +129,45 @@ export function checkHubStateAndTriggerEvents(
|
|
|
124
129
|
// TODO: `accounts` has been frozen, we should check and find where object.freeze() is calling.
|
|
125
130
|
|
|
126
131
|
// Check for accounts
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
fromAccountIdToLegacyAddressFormat
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
if (accounts) {
|
|
137
|
-
accounts = [...accounts, ...formattedAddresses];
|
|
138
|
-
} else {
|
|
139
|
-
accounts = [...formattedAddresses];
|
|
140
|
-
}
|
|
141
|
-
|
|
132
|
+
if (currentNamespaceState.accounts) {
|
|
133
|
+
anyNamespaceIsConnected = true;
|
|
134
|
+
if (
|
|
135
|
+
previousNamespaceState.accounts?.slice().sort().toString() !==
|
|
136
|
+
currentNamespaceState.accounts?.slice().sort().toString()
|
|
137
|
+
) {
|
|
142
138
|
hasAccountChanged = true;
|
|
139
|
+
}
|
|
140
|
+
const formattedAddresses = currentNamespaceState.accounts.map(
|
|
141
|
+
fromAccountIdToLegacyAddressFormat
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
if (accounts) {
|
|
145
|
+
accounts = [...accounts, ...formattedAddresses];
|
|
143
146
|
} else {
|
|
144
|
-
accounts =
|
|
145
|
-
hasProviderDisconnected = true;
|
|
147
|
+
accounts = [...formattedAddresses];
|
|
146
148
|
}
|
|
149
|
+
} else if (!!previousNamespaceState.accounts) {
|
|
150
|
+
/*
|
|
151
|
+
* If previously namespace was connected and now we can not get any accounts from the namespace, the namespace should be considered as disconnected.
|
|
152
|
+
* For example switching to an account which did not permitted to connect yet or maybe the account does not support the requested namespace.
|
|
153
|
+
*/
|
|
154
|
+
disconnectedNamespacesIds.push(namespace.namespaceId);
|
|
155
|
+
hasAccountChanged = true;
|
|
147
156
|
}
|
|
148
157
|
});
|
|
149
158
|
|
|
159
|
+
if (disconnectedNamespacesIds.length > 0) {
|
|
160
|
+
lastConnectedWalletsFromStorage.removeNamespacesFromWallet(
|
|
161
|
+
providerId,
|
|
162
|
+
disconnectedNamespacesIds
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (disconnectedNamespacesIds.length > 0 && !anyNamespaceIsConnected) {
|
|
167
|
+
accounts = null;
|
|
168
|
+
hasProviderDisconnected = true;
|
|
169
|
+
}
|
|
170
|
+
|
|
150
171
|
let legacyProvider;
|
|
151
172
|
try {
|
|
152
173
|
legacyProvider = getLegacyProvider(allProviders, providerId);
|
|
@@ -202,6 +223,8 @@ export function checkHubStateAndTriggerEvents(
|
|
|
202
223
|
);
|
|
203
224
|
}
|
|
204
225
|
if (hasAccountChanged) {
|
|
226
|
+
// This event is triggered to clear wallet state and after that set new accounts for wallet
|
|
227
|
+
onUpdateState(providerId, Events.ACCOUNTS, null, coreState, eventInfo);
|
|
205
228
|
onUpdateState(
|
|
206
229
|
providerId,
|
|
207
230
|
Events.ACCOUNTS,
|
|
@@ -225,12 +248,29 @@ export function checkHubStateAndTriggerEvents(
|
|
|
225
248
|
});
|
|
226
249
|
}
|
|
227
250
|
|
|
251
|
+
export function getAllLegacyProviders(
|
|
252
|
+
allProviders: VersionedProviders[]
|
|
253
|
+
): LegacyProviderInterface[] {
|
|
254
|
+
const LEGACY_VERSION = '0.0.0';
|
|
255
|
+
|
|
256
|
+
const legacyProviders: LegacyProviderInterface[] = [];
|
|
257
|
+
|
|
258
|
+
allProviders.forEach((provider) => {
|
|
259
|
+
const target = pickVersion(provider, LEGACY_VERSION);
|
|
260
|
+
legacyProviders.push(target[1]);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
return legacyProviders;
|
|
264
|
+
}
|
|
265
|
+
|
|
228
266
|
export function getLegacyProvider(
|
|
229
267
|
allProviders: VersionedProviders[],
|
|
230
268
|
type: string
|
|
231
269
|
): LegacyProviderInterface {
|
|
232
|
-
const [
|
|
233
|
-
|
|
270
|
+
const legacyProviders: LegacyProviderInterface[] =
|
|
271
|
+
getAllLegacyProviders(allProviders);
|
|
272
|
+
|
|
273
|
+
const provider = legacyProviders.find((legacyProvider) => {
|
|
234
274
|
return legacyProvider.config.type === type;
|
|
235
275
|
});
|
|
236
276
|
|
package/src/index.ts
CHANGED