Skip to content

Commit 099d509

Browse files
Tm/upgrade-ledger-2fa (#976)
* Change ledger guardian signing to cross window * Resolve comments
1 parent 8686c30 commit 099d509

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

docs/sdk-and-tools/sdk-dapp/internal-processes/guardians.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,22 @@ All signing providers (except Ledger) take care internally of formatting the tra
4444
After formatting the transaction and applying the signature provided by the Ledger device, the transaction must be signed by the Guardian. This is done by sending the transaction (or transactions array) to the web wallet 2FA hook. The web wallet will then prompt the user to sign the transaction with the Guardian account, and respond with the signed transaction.
4545

4646
```js
47-
import { WalletProvider } from '@multiversx/sdk-web-wallet-provider';
47+
import { CrossWindowProvider } from "@multiversx/sdk-web-wallet-cross-window-provider";
4848

49-
const walletProvider = new WalletProvider('https://wallet.multiversx.com/dapp/init');
50-
walletProvider.guardTransactions(transactions, {
51-
callbackUrl: encodeURIComponent('https://my-dapp.com'),
52-
});
53-
```
54-
Once transactions are back from the web wallet, they can be retrieved as follows:
49+
// instantiate wallet cross-window provider
50+
await CrossWindowProvider.getInstance().init();
51+
const crossWindowProvider = CrossWindowProvider.getInstance();
52+
crossWindowProvider.setWalletUrl(WALLET_PROVIDER_URL);
5553

56-
```js
57-
const signedTransactions = new WalletProvider('https://wallet.multiversx.com/dapp/init').getTransactionsFromWalletUrl();
58-
```
54+
// set sender
55+
const ledgerSenderBech32 = await this.hwProvider.getAddress();
56+
const sender = Address.newFromBech32(ledgerSenderBech32); // or "erd1...abc" witohut awaiting `getAddress()`
57+
crossWindowProvider.setAddress(sender);
58+
59+
// To complete the transaction, the user will sign using their Ledger device. This requires an additional step: a confirmation popup will appear, prompting the user to approve the action, after which a new tab will open in the browser.
60+
crossWindowProvider.setShouldShowConsentPopup(true);
5961

62+
const guardedTransactions = await crossWindowProvider.guardTransactions(
63+
signedTransactions
64+
);
65+
```

0 commit comments

Comments
 (0)