Skip to content

Commit 12af6db

Browse files
committed
move mobile callbacks to the externalSigningProviders
1 parent 0dde15a commit 12af6db

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

demo-app/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ <h3>Other demos:</h3>
192192
walletConnectV2ProjectId: 'f502675c63610bfe4454080ac86d70e6',
193193
walletConnectV2RelayAddresses: ['wss://relay.walletconnect.com'],
194194
qrCodeContainer: 'qr-code-container',
195+
onQrPending: () => { uiPending(true); },
196+
onQrLoaded: () => { uiPending(false); },
195197
}
196198
}
197199
},
@@ -210,9 +212,6 @@ <h3>Other demos:</h3>
210212
onTxSent: (txOnNetwork) => { const hash = txOnNetwork.txHash; hash && updateTxHashContainer(hash, true); },
211213
onTxFinalized: (tx) => { tx?.hash && updateTxHashContainer(tx.hash); uiPending(false); },
212214
onTxFailure: (tx, error) => { displayError(error); uiPending(false); },
213-
// Qr code callbacks:
214-
onQrPending: () => { uiPending(true); },
215-
onQrLoaded: () => { uiPending(false); },
216215
// Signing callbacks:
217216
onSignMsgStart: (message) => { uiPending(true); },
218217
onSignMsgFinalized: (message, messageSignature) => { messageSignature && updateOperationResultContainer(`➡️ The signature for "${message}" message:\n${messageSignature}`); uiPending(false); },

packages/elven.js/src/initialize-events-store.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ export const initializeEventsStore = (initOptions: InitOptions) => {
3737
}
3838

3939
// Qr code initialization
40-
if (initOptions.onQrPending) {
41-
EventsStore.set(EventStoreEvents.onQrPending, initOptions.onQrPending);
40+
const mobileConfig = initOptions?.externalSigningProviders?.mobile?.config;
41+
if (mobileConfig?.onQrPending) {
42+
EventsStore.set(EventStoreEvents.onQrPending, mobileConfig.onQrPending);
4243
}
43-
if (initOptions.onQrLoaded) {
44-
EventsStore.set(EventStoreEvents.onQrLoaded, initOptions.onQrLoaded);
44+
if (mobileConfig?.onQrLoaded) {
45+
EventsStore.set(EventStoreEvents.onQrLoaded, mobileConfig.onQrLoaded);
4546
}
4647

4748
// Transactions initialization

packages/elven.js/src/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export interface MobileSigningProviderConfig {
1717
walletConnectV2ProjectId: string;
1818
walletConnectV2RelayAddresses: string[];
1919
qrCodeContainer: string | HTMLElement;
20+
onQrPending: () => void;
21+
onQrLoaded: () => void;
2022
}
2123

2224
export interface WalletConnectV2Provider
@@ -74,9 +76,6 @@ export interface InitOptions {
7476
onLogoutStart?: () => void;
7577
onLogoutSuccess?: () => void;
7678
onLogoutFailure?: (error: string) => void;
77-
// Qr
78-
onQrPending?: () => void;
79-
onQrLoaded?: () => void;
8079
// Transaction
8180
onTxStart?: (transaction: Transaction) => void;
8281
onTxSent?: (transaction: Transaction) => void;

0 commit comments

Comments
 (0)