@rango-dev/wallets-react 0.27.1-next.14 → 0.27.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hub/autoConnect.d.ts.map +1 -1
- package/dist/hub/helpers.d.ts +1 -2
- package/dist/hub/helpers.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 +5 -5
- package/dist/hub/utils.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/legacy/autoConnect.d.ts.map +1 -1
- package/dist/legacy/types.d.ts +24 -17
- 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/package.json +8 -14
- package/src/hub/autoConnect.ts +35 -62
- package/src/hub/helpers.ts +9 -14
- package/src/hub/mod.ts +1 -5
- package/src/hub/useHubAdapter.ts +46 -79
- package/src/hub/utils.ts +158 -155
- package/src/index.ts +1 -0
- package/src/legacy/autoConnect.ts +24 -12
- package/src/legacy/types.ts +25 -25
- package/src/useProviders.ts +6 -2
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js +0 -2
- package/dist/helpers/index.js.map +0 -7
- package/helpers/package.json +0 -8
- package/src/helpers/index.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/legacy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,aAAa,IAAI,OAAO,EACxB,kBAAkB,IAAI,kBAAkB,E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,OAAO,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IAItB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACtD,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,aAAa,CAAC,cAAc,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;CAC7D;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,eAAe,GAAG,GAAG,CAC/B,UAAU,EACV;IACE,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;CACtB,CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProviders.d.ts","sourceRoot":"","sources":["../src/useProviders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,aAAa,EAEd,MAAM,YAAY,CAAC;AAiBpB,iBAAS,YAAY,CAAC,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"useProviders.d.ts","sourceRoot":"","sources":["../src/useProviders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,aAAa,EAEd,MAAM,YAAY,CAAC;AAiBpB,iBAAS,YAAY,CAAC,KAAK,EAAE,aAAa,mBA+FzC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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":2342,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/hub/utils.ts":{"bytes":9250,"imports":[{"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":6964,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"ts-results","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":12311,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"ts-results","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":5369,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true}],"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":95377},"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/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":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","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":3108},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":2125},"src/legacy/autoConnect.ts":{"bytesInOutput":393},"src/legacy/hooks.ts":{"bytesInOutput":458},"src/legacy/useAutoConnect.ts":{"bytesInOutput":196},"src/legacy/utils.ts":{"bytesInOutput":92},"src/hub/helpers.ts":{"bytesInOutput":869},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":3923},"src/hub/autoConnect.ts":{"bytesInOutput":2058},"src/hub/useHubRefs.ts":{"bytesInOutput":510},"src/useProviders.ts":{"bytesInOutput":885},"src/legacy/types.ts":{"bytesInOutput":63}},"bytes":18359},"dist/helpers/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":59285},"dist/helpers/index.js":{"imports":[{"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":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"ts-results","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"ts-results","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":421},"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":47},"src/hub/helpers.ts":{"bytesInOutput":178},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":143},"src/hub/autoConnect.ts":{"bytesInOutput":156},"src/hub/useHubRefs.ts":{"bytesInOutput":97},"src/helpers/index.ts":{"bytesInOutput":0}},"bytes":3113}}}
|
|
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":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/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":9869,"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":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":93552},"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","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":1210},"src/index.ts":{"bytesInOutput":0},"src/provider.tsx":{"bytesInOutput":133},"src/legacy/context.ts":{"bytesInOutput":431},"src/hub/utils.ts":{"bytesInOutput":2795},"src/legacy/mod.ts":{"bytesInOutput":0},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":2125},"src/legacy/autoConnect.ts":{"bytesInOutput":442},"src/legacy/hooks.ts":{"bytesInOutput":458},"src/legacy/useAutoConnect.ts":{"bytesInOutput":196},"src/legacy/utils.ts":{"bytesInOutput":92},"src/hub/helpers.ts":{"bytesInOutput":775},"src/hub/mod.ts":{"bytesInOutput":0},"src/hub/useHubAdapter.ts":{"bytesInOutput":3612},"src/hub/autoConnect.ts":{"bytesInOutput":1741},"src/hub/useHubRefs.ts":{"bytesInOutput":510},"src/useProviders.ts":{"bytesInOutput":942},"src/legacy/types.ts":{"bytesInOutput":164}},"bytes":17566}}}
|
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.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -9,23 +9,18 @@
|
|
|
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"
|
|
16
12
|
}
|
|
17
13
|
},
|
|
18
14
|
"files": [
|
|
19
15
|
"dist",
|
|
20
|
-
"src"
|
|
21
|
-
"helpers"
|
|
16
|
+
"src"
|
|
22
17
|
],
|
|
23
18
|
"scripts": {
|
|
24
|
-
"build": "node ../../scripts/build/command.mjs --path wallets/react
|
|
19
|
+
"build": "node ../../scripts/build/command.mjs --path wallets/react",
|
|
25
20
|
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
26
21
|
"clean": "rimraf dist",
|
|
27
22
|
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
28
|
-
"lint": "eslint \"**/*.{ts,tsx}\"",
|
|
23
|
+
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore",
|
|
29
24
|
"test": "vitest",
|
|
30
25
|
"coverage": "vitest run --coverage"
|
|
31
26
|
},
|
|
@@ -35,10 +30,9 @@
|
|
|
35
30
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
36
31
|
},
|
|
37
32
|
"dependencies": {
|
|
38
|
-
"@rango-dev/wallets-core": "^0.40.1-next.
|
|
39
|
-
"@rango-dev/wallets-shared": "^0.41.1-next.
|
|
40
|
-
"rango-types": "^0.1.
|
|
41
|
-
"ts-results": "^3.3.0"
|
|
33
|
+
"@rango-dev/wallets-core": "^0.40.1-next.9",
|
|
34
|
+
"@rango-dev/wallets-shared": "^0.41.1-next.1",
|
|
35
|
+
"rango-types": "^0.1.74"
|
|
42
36
|
},
|
|
43
37
|
"devDependencies": {
|
|
44
38
|
"@types/react": "^18.0.25",
|
|
@@ -47,4 +41,4 @@
|
|
|
47
41
|
"publishConfig": {
|
|
48
42
|
"access": "public"
|
|
49
43
|
}
|
|
50
|
-
}
|
|
44
|
+
}
|
package/src/hub/autoConnect.ts
CHANGED
|
@@ -12,19 +12,13 @@ import {
|
|
|
12
12
|
legacyEagerConnectHandler,
|
|
13
13
|
legacyIsEvmNamespace,
|
|
14
14
|
} from '@rango-dev/wallets-core/legacy';
|
|
15
|
-
import { Result } from 'ts-results';
|
|
16
15
|
|
|
17
16
|
import { HUB_LAST_CONNECTED_WALLETS } from '../legacy/mod.js';
|
|
18
17
|
|
|
19
|
-
import {
|
|
18
|
+
import { sequentiallyRun } from './helpers.js';
|
|
20
19
|
import { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';
|
|
21
20
|
import { convertNamespaceNetworkToEvmChainId } from './utils.js';
|
|
22
21
|
|
|
23
|
-
// Getting connected wallets from storage
|
|
24
|
-
const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
|
|
25
|
-
HUB_LAST_CONNECTED_WALLETS
|
|
26
|
-
);
|
|
27
|
-
|
|
28
22
|
/**
|
|
29
23
|
* Run `.connect` action on some selected namespaces (passed as param) for a provider.
|
|
30
24
|
*/
|
|
@@ -66,57 +60,21 @@ async function eagerConnect(
|
|
|
66
60
|
targetNamespaces.push([namespaceInput, result]);
|
|
67
61
|
});
|
|
68
62
|
|
|
69
|
-
const
|
|
70
|
-
(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
await namespace.connect(chain).catch((e) => {
|
|
78
|
-
/*
|
|
79
|
-
* Since we check for connect failures using `instanceof Error`
|
|
80
|
-
* this check is added here to make sure the thrown error always is an instance of `Error`
|
|
81
|
-
*/
|
|
82
|
-
if (e instanceof Error) {
|
|
83
|
-
throw e;
|
|
84
|
-
}
|
|
85
|
-
throw new Error(e);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
);
|
|
63
|
+
const finalResult = targetNamespaces.map(([info, namespace]) => {
|
|
64
|
+
const evmChain = legacyIsEvmNamespace(info)
|
|
65
|
+
? convertNamespaceNetworkToEvmChainId(info, allBlockChains || [])
|
|
66
|
+
: undefined;
|
|
67
|
+
const chain = evmChain || info.network;
|
|
68
|
+
|
|
69
|
+
return async () => await namespace.connect(chain);
|
|
70
|
+
});
|
|
89
71
|
|
|
90
72
|
/**
|
|
91
73
|
* Sometimes calling methods on a instance in parallel, would cause an error in wallet.
|
|
92
74
|
* We are running a method at a time to make sure we are covering this.
|
|
93
75
|
* e.g. when we are trying to eagerConnect evm and solana on phantom at the same time, the last namespace throw an error.
|
|
94
76
|
*/
|
|
95
|
-
|
|
96
|
-
connectNamespacesPromises
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const failedNamespaces: LegacyNamespaceInputForConnect[] = [];
|
|
100
|
-
connectNamespacesResult.forEach((result, index) => {
|
|
101
|
-
if (result.err) {
|
|
102
|
-
failedNamespaces.push(targetNamespaces[index][0]);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
if (failedNamespaces.length > 0) {
|
|
107
|
-
lastConnectedWalletsFromStorage.removeNamespacesFromWallet(
|
|
108
|
-
type,
|
|
109
|
-
failedNamespaces.map((namespace) => namespace.namespace)
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const atLeastOneNamespaceConnectedSuccessfully = connectNamespacesResult.some(
|
|
114
|
-
(result) => result.ok
|
|
115
|
-
);
|
|
116
|
-
if (!atLeastOneNamespaceConnectedSuccessfully) {
|
|
117
|
-
throw new Error(`No namespace connected for ${type}`);
|
|
118
|
-
}
|
|
119
|
-
return Result.all(...connectNamespacesResult).unwrap();
|
|
77
|
+
return await sequentiallyRun(finalResult);
|
|
120
78
|
}
|
|
121
79
|
|
|
122
80
|
/*
|
|
@@ -134,13 +92,18 @@ export async function autoConnect(deps: {
|
|
|
134
92
|
wallets?: (WalletType | LegacyProviderInterface)[];
|
|
135
93
|
}): Promise<void> {
|
|
136
94
|
const { getHub, allBlockChains, getLegacyProvider, wallets } = deps;
|
|
95
|
+
|
|
96
|
+
// Getting connected wallets from storage
|
|
97
|
+
const lastConnectedWalletsFromStorage = new LastConnectedWalletsFromStorage(
|
|
98
|
+
HUB_LAST_CONNECTED_WALLETS
|
|
99
|
+
);
|
|
137
100
|
const lastConnectedWallets = lastConnectedWalletsFromStorage.list();
|
|
138
101
|
const walletIds = Object.keys(lastConnectedWallets);
|
|
139
102
|
|
|
140
103
|
const walletsToRemoveFromPersistance: string[] = [];
|
|
141
104
|
|
|
142
105
|
if (walletIds.length) {
|
|
143
|
-
const eagerConnectQueue:
|
|
106
|
+
const eagerConnectQueue: any[] = [];
|
|
144
107
|
|
|
145
108
|
// Run `.connect` if `.canEagerConnect` returns `true`.
|
|
146
109
|
walletIds.forEach((providerName) => {
|
|
@@ -155,13 +118,12 @@ export async function autoConnect(deps: {
|
|
|
155
118
|
|
|
156
119
|
const legacyProvider = getLegacyProvider(providerName);
|
|
157
120
|
|
|
158
|
-
let legacyInstance:
|
|
121
|
+
let legacyInstance: any;
|
|
159
122
|
try {
|
|
160
123
|
legacyInstance = legacyProvider.getInstance();
|
|
161
|
-
} catch {
|
|
124
|
+
} catch (e) {
|
|
162
125
|
console.warn(
|
|
163
|
-
"It seems instance isn't available yet
|
|
164
|
-
providerName
|
|
126
|
+
"It seems instance isn't available yet. This can happens when extension not loaded yet (sometimes when opening browser for first time) or extension is disabled."
|
|
165
127
|
);
|
|
166
128
|
return;
|
|
167
129
|
}
|
|
@@ -199,15 +161,26 @@ export async function autoConnect(deps: {
|
|
|
199
161
|
providerName,
|
|
200
162
|
}).catch((e) => {
|
|
201
163
|
walletsToRemoveFromPersistance.push(providerName);
|
|
202
|
-
|
|
164
|
+
throw e;
|
|
203
165
|
})
|
|
204
166
|
);
|
|
205
167
|
});
|
|
206
168
|
|
|
207
|
-
await Promise.
|
|
169
|
+
await Promise.allSettled(eagerConnectQueue);
|
|
208
170
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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;
|
|
179
|
+
|
|
180
|
+
if (canRestoreAnyConnection) {
|
|
181
|
+
lastConnectedWalletsFromStorage.removeWallets(
|
|
182
|
+
walletsToRemoveFromPersistance
|
|
183
|
+
);
|
|
184
|
+
}
|
|
212
185
|
}
|
|
213
186
|
}
|
package/src/hub/helpers.ts
CHANGED
|
@@ -3,11 +3,9 @@ import type {
|
|
|
3
3
|
Accounts,
|
|
4
4
|
AccountsWithActiveChain,
|
|
5
5
|
} from '@rango-dev/wallets-core/namespaces/common';
|
|
6
|
-
import type { Result } from 'ts-results';
|
|
7
6
|
|
|
8
7
|
import { legacyFormatAddressWithNetwork as formatAddressWithNetwork } from '@rango-dev/wallets-core/legacy';
|
|
9
8
|
import { CAIP } from '@rango-dev/wallets-core/utils';
|
|
10
|
-
import { Err, Ok } from 'ts-results';
|
|
11
9
|
|
|
12
10
|
export function mapCaipNamespaceToLegacyNetworkName(
|
|
13
11
|
chainId: CAIP.ChainIdParams | string
|
|
@@ -44,19 +42,16 @@ export function fromAccountIdToLegacyAddressFormat(account: string): string {
|
|
|
44
42
|
/**
|
|
45
43
|
* Getting a list of (lazy) promises and run them one after another.
|
|
46
44
|
*/
|
|
45
|
+
export async function sequentiallyRun<T extends () => Promise<unknown>>(
|
|
46
|
+
promises: Array<T>
|
|
47
|
+
): Promise<Array<T extends () => Promise<infer R> ? R : never>> {
|
|
48
|
+
const result = await promises.reduce(async (prev, task) => {
|
|
49
|
+
const previousResults = await prev;
|
|
50
|
+
const taskResult = await task();
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return promises.reduce(async (prevPromise, task) => {
|
|
52
|
-
const previousResults = await prevPromise;
|
|
53
|
-
try {
|
|
54
|
-
const taskResult = await task();
|
|
55
|
-
return [...previousResults, new Ok(taskResult)];
|
|
56
|
-
} catch (error) {
|
|
57
|
-
return [...previousResults, new Err(error)];
|
|
58
|
-
}
|
|
59
|
-
}, Promise.resolve<Result<R, unknown>[]>([]));
|
|
52
|
+
return [...previousResults, taskResult];
|
|
53
|
+
}, Promise.resolve([]) as Promise<any>);
|
|
54
|
+
return result;
|
|
60
55
|
}
|
|
61
56
|
|
|
62
57
|
export function isConnectResultEvm(
|
package/src/hub/mod.ts
CHANGED
package/src/hub/useHubAdapter.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { VersionedProviders } from '@rango-dev/wallets-core/utils';
|
|
|
6
6
|
|
|
7
7
|
import { type WalletInfo } from '@rango-dev/wallets-shared';
|
|
8
8
|
import { useEffect, useRef, useState } from 'react';
|
|
9
|
-
import { Ok, Result } from 'ts-results';
|
|
10
9
|
|
|
11
10
|
import {
|
|
12
11
|
type ConnectResult,
|
|
@@ -17,15 +16,15 @@ import {
|
|
|
17
16
|
import { useAutoConnect } from '../legacy/useAutoConnect.js';
|
|
18
17
|
|
|
19
18
|
import { autoConnect } from './autoConnect.js';
|
|
19
|
+
import { fromAccountIdToLegacyAddressFormat } from './helpers.js';
|
|
20
20
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} from './
|
|
24
|
-
import { LastConnectedWalletsFromStorage } from './lastConnectedWallets.js';
|
|
21
|
+
LastConnectedWalletsFromStorage,
|
|
22
|
+
type NamespaceInput,
|
|
23
|
+
} from './lastConnectedWallets.js';
|
|
25
24
|
import { useHubRefs } from './useHubRefs.js';
|
|
26
25
|
import {
|
|
26
|
+
checkHubStateAndTriggerEvents,
|
|
27
27
|
getLegacyProvider,
|
|
28
|
-
mapHubEventsToLegacy,
|
|
29
28
|
transformHubResultToLegacyResult,
|
|
30
29
|
tryConvertNamespaceNetworkToChainInfo,
|
|
31
30
|
} from './utils.js';
|
|
@@ -86,24 +85,19 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
86
85
|
*/
|
|
87
86
|
document.addEventListener('readystatechange', initHubWhenPageIsReady);
|
|
88
87
|
|
|
89
|
-
getStore()
|
|
90
|
-
.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
rerender((currentRender) => currentRender + 1);
|
|
105
|
-
})
|
|
106
|
-
.flushEvents();
|
|
88
|
+
getStore().subscribe((curr, prev) => {
|
|
89
|
+
if (dataRef.current.onUpdateState) {
|
|
90
|
+
checkHubStateAndTriggerEvents(
|
|
91
|
+
getHub(),
|
|
92
|
+
curr,
|
|
93
|
+
prev,
|
|
94
|
+
dataRef.current.onUpdateState,
|
|
95
|
+
dataRef.current.allVersionedProviders,
|
|
96
|
+
dataRef.current.allBlockChains
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
rerender((currentRender) => currentRender + 1);
|
|
100
|
+
});
|
|
107
101
|
}, []);
|
|
108
102
|
|
|
109
103
|
useAutoConnect({
|
|
@@ -172,9 +166,12 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
172
166
|
targetNamespaces.push([namespace, result]);
|
|
173
167
|
});
|
|
174
168
|
|
|
169
|
+
// Keeping only namespaces that connected successfully, then we'll store them on storage for auto connect functionality.
|
|
170
|
+
const successfulyConnectedNamespaces: NamespaceInput[] = [];
|
|
171
|
+
|
|
175
172
|
// Try to run `connect` on matched namespaces
|
|
176
173
|
const connectResultFromTargetNamespaces = targetNamespaces.map(
|
|
177
|
-
([namespaceInput, namespace]) => {
|
|
174
|
+
async ([namespaceInput, namespace]) => {
|
|
178
175
|
const network = tryConvertNamespaceNetworkToChainInfo(
|
|
179
176
|
namespaceInput,
|
|
180
177
|
params.allBlockChains || []
|
|
@@ -185,73 +182,47 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
185
182
|
* our assumption here is all the `connect` hasn't chain or if they have, they will accept it in first argument.
|
|
186
183
|
* By this assumption, always passing a chain should be problematic since it will be ignored if the namespace's `connect` hasn't chain.
|
|
187
184
|
*/
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
input: {
|
|
196
|
-
namespace: namespaceInput.namespace,
|
|
197
|
-
network: namespaceInput.network,
|
|
198
|
-
},
|
|
199
|
-
};
|
|
185
|
+
const result = namespace.connect(network);
|
|
186
|
+
return result
|
|
187
|
+
.then<ConnectResult>(transformHubResultToLegacyResult)
|
|
188
|
+
.then((res) => {
|
|
189
|
+
successfulyConnectedNamespaces.push({
|
|
190
|
+
namespace: namespaceInput.namespace,
|
|
191
|
+
network: namespaceInput.network,
|
|
200
192
|
});
|
|
193
|
+
return res;
|
|
194
|
+
});
|
|
201
195
|
}
|
|
202
196
|
);
|
|
203
197
|
|
|
204
|
-
/*
|
|
205
|
-
* We need to connect to namespace one after another, sending multiple requests at the same time may be failed.
|
|
206
|
-
* e.g. when wallet popup opens and asking for the password from the user, it should be resolved first, then other request will be resolved.
|
|
207
|
-
*/
|
|
208
|
-
const connectResultWithLegacyFormat = await runSequentiallyWithoutFailure(
|
|
209
|
-
connectResultFromTargetNamespaces
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
// Keeping only namespaces that connected successfully, then we'll store them on storage for auto connect functionality.
|
|
213
|
-
const successfullyConnectedNamespaces = connectResultWithLegacyFormat
|
|
214
|
-
.filter(<T, E>(result: Result<T, E>): result is Ok<T> => result.ok)
|
|
215
|
-
.map((result) => {
|
|
216
|
-
return {
|
|
217
|
-
namespace: result.val.input.namespace,
|
|
218
|
-
network: result.val.input.network,
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
|
|
222
198
|
// If Provider has support for auto connect, we will add the wallet to storage.
|
|
223
199
|
const legacyProvider = getLegacyProvider(
|
|
224
200
|
params.allVersionedProviders,
|
|
225
201
|
type
|
|
226
202
|
);
|
|
227
203
|
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
204
|
+
if (legacyProvider.canEagerConnect) {
|
|
205
|
+
void Promise.allSettled(connectResultFromTargetNamespaces).then(() => {
|
|
206
|
+
if (successfulyConnectedNamespaces.length > 0) {
|
|
207
|
+
lastConnectedWalletsFromStorage.addWallet(
|
|
208
|
+
type,
|
|
209
|
+
successfulyConnectedNamespaces
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
236
213
|
}
|
|
237
214
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
result.andThen((okResult) => new Ok(okResult.response))
|
|
215
|
+
const connectResultWithLegacyFormat = await Promise.all(
|
|
216
|
+
connectResultFromTargetNamespaces
|
|
241
217
|
);
|
|
242
218
|
|
|
243
|
-
|
|
244
|
-
if (allResult.err) {
|
|
245
|
-
throw allResult.val;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return allResult.unwrap();
|
|
219
|
+
return connectResultWithLegacyFormat;
|
|
249
220
|
},
|
|
250
221
|
async disconnect(type) {
|
|
251
222
|
const wallet = getHub().get(type);
|
|
252
223
|
if (!wallet) {
|
|
253
224
|
throw new Error(
|
|
254
|
-
`You should add ${type} to provider first then call '
|
|
225
|
+
`You should add ${type} to provider first then call 'connect'.`
|
|
255
226
|
);
|
|
256
227
|
}
|
|
257
228
|
|
|
@@ -263,12 +234,8 @@ export function useHubAdapter(params: UseAdapterParams): ProviderContext {
|
|
|
263
234
|
lastConnectedWalletsFromStorage.removeWallets([type]);
|
|
264
235
|
}
|
|
265
236
|
},
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
getHub().getAll().values()
|
|
269
|
-
).map(async (provider) => this.disconnect(provider.id));
|
|
270
|
-
|
|
271
|
-
return await Promise.allSettled(disconnectPromises);
|
|
237
|
+
disconnectAll() {
|
|
238
|
+
throw new Error('`disconnectAll` not implemented');
|
|
272
239
|
},
|
|
273
240
|
async getSigners(type) {
|
|
274
241
|
const provider = getLegacyProvider(params.allVersionedProviders, type);
|