-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add provider strategy #46
Conversation
src/core/providers/DappProvider/helpers/signTransactions/helpers/getGuardedTransactions.ts
Outdated
Show resolved
Hide resolved
throw new Error(ProviderErrorsEnum.notInitialized); | ||
} | ||
|
||
if (!isBrowserWithPopupConfirmation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this should be configurable since we don't know all the browsers and maybe the user is using a different browser and needs the pop-up confirmation for it
) => Promise<Transaction[]>) | ||
| null = null; | ||
|
||
constructor(address: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you actually need addressIndex from the store
throw err; | ||
} | ||
if (eventBus) { | ||
eventBus.unsubscribe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventbus?.unsubscribe ?
|
||
const hwProviderLogin = provider.login; | ||
const provider = this.provider as unknown as IProvider; | ||
provider.setAccount({ address: this.address }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should also set addressIndex in HWProvider
document.body.appendChild(signModalElement); | ||
await customElements.whenDefined('sign-transactions-modal'); | ||
if (shouldInitiateLogin) { | ||
eventBus = await getEventBus('ledger-connect-modal'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should always be a one-way flow between opening the modal and getting the event bus. I can't see the need of a split
+
there is a different eventBus for signing transactions
createdProvider.getType = () => ProviderTypeEnum.ledger; | ||
|
||
await createdProvider.init?.(); | ||
const providerInstance = new LedgerProviderStrategy(address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question for all
|
||
createdProvider = provider as unknown as IProvider; | ||
const providerInstance = new WalletConnectProviderStrategy( | ||
walletConnectConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be fetched as a default from store inside the strategy?
@@ -42,13 +41,6 @@ export interface IProviderConfig { | |||
address: string; | |||
}; | |||
UI?: IProviderConfigUI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI should be removed
src/utils/modalEvent.ts
Outdated
import { safeWindow } from 'constants/index'; | ||
import { defineCustomElements } from 'lib/sdkDappCoreUi'; | ||
|
||
export const getModalElement = async < |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createModalElement?
@@ -16,6 +18,8 @@ type BaseDappConfigType = { | |||
* default: `true` | |||
*/ | |||
enableTansactionTracker?: boolean; | |||
crossWindow?: CrossWindowConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we make like providers: {walletconnect, crossWindow } ?
private _signMessage: ((messageToSign: Message) => Promise<Message>) | null = | ||
null; | ||
|
||
constructor(address?: string, walletAddress?: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize with props? : {address?:string, ...
src/utils/modalEvent.ts
Outdated
withEventBus?: boolean; | ||
}; | ||
|
||
export const createModalElement = async < |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename file to createModalElement
private _signMessage: ((messageToSign: Message) => Promise<Message>) | null = | ||
null; | ||
|
||
constructor({ address = '', walletAddress }: CrossWindowProviderProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
props: CrossWindowProviderProps = ...
otherwise you have to do constructor({}}
Proposal
Usage:
const providerInstance = new WalletConnectProviderStrategy( walletConnect );
const provider = await providerInstance.createProvider();