Move signer into session store

The Metamask and WalletConnect signer are updated one any account
change, but currently we store them only in the static config object.
This commit moves this to the session store to improve this behaviour

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2022-05-20 13:10:53 +02:00
committed by Alexis Sellier
parent ab3c8f5657
commit be0ff349df
9 changed files with 149 additions and 36 deletions
+3 -3
View File
@@ -32,7 +32,7 @@
if (!amount || amount === "0") { return [false, "Not able to withdraw zero tokens"]; }
if (toWei(amount).gt(maxWithdrawAmount)) return [false, `Reduce amount, max withdrawal is ${formatEther(maxWithdrawAmount)}`];
let currentTime = new Date().getTime();
let timelock = await calculateTimeLock(amount, $session.signer, config);
let timelock = await calculateTimeLock(amount, $session.config.signer, config);
// Converting a 10 digit to 13 digit timestamp by multiplying by 1000
// since JS doesn't display a correct Date string when passing a 10 digit timestamp.
let nextAvailableWithdraw = lastWithdrawal.add(timelock).mul(1000);
@@ -48,8 +48,8 @@
}
$: if ($session) {
getMaxWithdrawAmount($session.signer, config).then(x => maxWithdrawAmount = x);
lastWithdrawalByUser($session.signer, config).then(x => lastWithdrawal = x);
getMaxWithdrawAmount($session.config.signer, config).then(x => maxWithdrawAmount = x);
lastWithdrawalByUser($session.config.signer, config).then(x => lastWithdrawal = x);
}
</script>
+1 -1
View File
@@ -25,7 +25,7 @@
try {
if ($session) {
state.status = Status.Signing;
const tx = await withdraw(amount, $session.signer, config);
const tx = await withdraw(amount, $session.config.signer, config);
state.status = Status.Pending;
await tx.wait();
state.status = Status.Success;
+1 -1
View File
@@ -109,7 +109,7 @@
</span>
<!-- User Session -->
<div class="siwe">
{#if session?.signer}
{#if session?.config.signer}
{#if siweSession}
<div class="session-info">
<span class="signed-in text-small">Signed in as</span>