Skip to content

Commit

Permalink
fix web wallet transaction callbackUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Jun 4, 2023
1 parent eb8bd5b commit e1f856e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### [0.6.0](https://github.com/useElven/core/releases/tag/v0.6.0) (2023-06-04)
- improvements for nonce incrementation to let triggering multiple transactions at the same time. The logic is slightly different, but it shouldn't break anything
- improvements for nonce incrementation to let trigger multiple transactions at the same time. The logic is slightly different, but it shouldn't break anything (you can test it [here](https://useelven-react-vite-demo.netlify.app/). For now, additional steps are required for the Web Wallet to manage the pending states in UI properly. They solution is presented in the [demo here](https://github.com/useElven/react-vite/blob/main/src/components/demo/EgldTx.tsx)). There will be more improvements in that regard.

### [0.5.0](https://github.com/useElven/core/releases/tag/v0.5.0) (2023-05-28)
- Breaking: switch to using sdk-native-auth-client instead passing string-based login tokens. There is no fallback or other option, so it is a breaking change. Native Auth is recommended. The old way of doing that will be deprecated. Please freeze the previous version if you are not ready to switch yet
Expand Down
7 changes: 6 additions & 1 deletion src/hooks/common-helpers/signAndSendTxOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ export const signAndSendTxOperations = async (
if (dappProvider instanceof WalletProvider) {
const currentUrl = window?.location.href;
await dappProvider.signTransaction(tx, {
callbackUrl: webWalletRedirectUrl || currentUrl,
callbackUrl:
webWalletRedirectUrl && window
? encodeURIComponent(
`${window.location.origin}${webWalletRedirectUrl}`
)
: currentUrl,
});
}
if (dappProvider instanceof ExtensionProvider) {
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/common-helpers/useWebWalletTxSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const useWebWalletTxSend = ({
transactionObj.data = Buffer.from(transactionObj.data).toString(
'base64'
);
window.history.replaceState(null, '', window.location.pathname);

setPending(true);
cb?.({ pending: true });
const transaction = Transaction.fromPlainObject(transactionObj);
Expand All @@ -80,6 +80,7 @@ export const useWebWalletTxSend = ({
setPending(false);
cb?.({ pending: false });
setAccountState('nonce', currentNonce + 1);
window.history.replaceState(null, '', window.location.pathname);
}
}
};
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export function useTransaction(
networkStateSnap.dappProvider &&
networkStateSnap.apiNetworkProvider &&
currentNonce !== undefined &&
!pending &&
accountSnap.address
) {
setPending(true);
Expand Down

0 comments on commit e1f856e

Please sign in to comment.