Conversation
|
@jacogr is there anything else you need from us before running these workflows? This work was done as part of a W3F grant and it would be great to get it out there for the community! |
takahser
left a comment
There was a problem hiding this comment.
@BeroBurny @danforbes thanks for your PR which is part of this delivery.
I added some comments, feel free to check them out.
| export function injectExtensions (): Promise<boolean[]> { | ||
| return Promise.all([ | ||
| initPolkadotSnap | ||
| ].map((method) => { | ||
| // Timeout injecting extension | ||
| return Promise.race([ | ||
| method(), | ||
| new Promise<false>((resolve) => { | ||
| setTimeout((): void => { | ||
| resolve(false); | ||
| }, 1000 /* 1 sec */); | ||
| }) | ||
| ]); | ||
| })); | ||
| } |
There was a problem hiding this comment.
-
Why does the return time have to be
Promise<boolean[]>? After all,initPolkadotSnapis just returning a singlePromise<boolean>. -
In general, this code could be simplified when using
rxjswhich already is a dependency:
| export function injectExtensions (): Promise<boolean[]> { | |
| return Promise.all([ | |
| initPolkadotSnap | |
| ].map((method) => { | |
| // Timeout injecting extension | |
| return Promise.race([ | |
| method(), | |
| new Promise<false>((resolve) => { | |
| setTimeout((): void => { | |
| resolve(false); | |
| }, 1000 /* 1 sec */); | |
| }) | |
| ]); | |
| })); | |
| } | |
| export const injectExtensions = () => | |
| firstValueFrom(from(initPolkadotSnap()) | |
| .pipe( | |
| timeout(1000), // timeout if initPolkadotSnap() doesn't resolve after 1s | |
| catchError(() => of(false)), | |
| )); |
(Please note that I haven't actually tested this code)
There was a problem hiding this comment.
-
Idea is to make it future proof it there will be another wallet like MM snaps so users can easily add it to apps
for example@polkadot/extension-compat-metamaskyou can just importinitMetaMaskand add it to the list to support it -
did the same solution with
RxJs(personally for me is more complex as I'm uset to async/await js)
|
@BeroBurny / @danforbes, could you resolve the conflicts or resubmit, so this has a chance of being merged? |
|
Thank you for the feedback, @semuelle! I have informed @BeroBurny and @irubido that this Issue should take priority over the other one you recently commented on - please let me know if you disagree 🙏🏻 |
|
@semuelle - this PR should be up-to-date 🚀 Please let us know if there's anything else we can do to help the team evaluate things. We're getting started on support for parachains, etc now 💪🏻 |
Integrate Metamask Snaps Accounts into Polkadot JS Apps