mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-16 03:40:37 +08:00
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:
@@ -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>
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user