From 1a25aa56335dc31143be269ed522ae3502e89cb9 Mon Sep 17 00:00:00 2001 From: Jack Hamer <47187316+JackHamer09@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:03:14 +0200 Subject: [PATCH] fix: sso session config update (#260) --- .../30.zksync-sso/5.getting-started.md | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/content/00.build/30.zksync-sso/5.getting-started.md b/content/00.build/30.zksync-sso/5.getting-started.md index 0f287f98..3238bd75 100644 --- a/content/00.build/30.zksync-sso/5.getting-started.md +++ b/content/00.build/30.zksync-sso/5.getting-started.md @@ -48,12 +48,22 @@ Just 2 steps: session: { feeLimit: parseEther("0.1"), - // Allow ETH transfers to a specific address: transfers: [ + // Allow ETH transfers of up to 0.1 ETH to specific address { to: "0x188bd99cd7D4d78d4E605Aeea12C17B32CC3135A", valueLimit: parseEther("0.1"), }, + + // Allow ETH transfers to specific address with a limit of 0.1 ETH per hour + // until the session expires + { + to: "0x188bd99cd7D4d78d4E605Aeea12C17B32CC3135A", + valueLimit: { + limit: parseEther("0.1"), + period: BigInt(60 * 60), // 1 hour in seconds + }, + }, ], // Allow calling specific smart contracts (e.g. ERC20 transfer): @@ -64,18 +74,21 @@ Just 2 steps: // Optional call constraints (unconstrained othewise): constraints: [ + + // Only allow transfers to this address { index: 0, condition: "Equal", - refValue: "0x6cC8cf7f6b488C58AA909B77E6e65c631c204784", // Only allow transfers to this address + refValue: "0x6cC8cf7f6b488C58AA909B77E6e65c631c204784", }, + + // Transfer up to 0.2 tokens { index: 1, - condition: "LessEqual", - refValue: toHex(parseUnits("0.1", TOKEN.decimals), { size: 32 }), // Limit the transfer amount to 0.1 tokens + limit: parseUnits("0.2", TOKEN.decimals), // Unlimited if omitted }, ], - } + }, ], }, }); @@ -103,12 +116,22 @@ Just 2 steps: session: { feeLimit: parseEther("0.1"), - // Allow ETH transfers to a specific address: transfers: [ + // Allow ETH transfers of up to 0.1 ETH to specific address { to: "0x188bd99cd7D4d78d4E605Aeea12C17B32CC3135A", valueLimit: parseEther("0.1"), }, + + // Allow ETH transfers to specific address with a limit of 0.1 ETH per hour + // until the session expires + { + to: "0x188bd99cd7D4d78d4E605Aeea12C17B32CC3135A", + valueLimit: { + limit: parseEther("0.1"), + period: BigInt(60 * 60), // 1 hour in seconds + }, + }, ], // Allow calling specific smart contracts (e.g. ERC20 transfer): @@ -119,18 +142,21 @@ Just 2 steps: // Optional call constraints (unconstrained othewise): constraints: [ + + // Only allow transfers to this address { index: 0, condition: "Equal", - refValue: "0x6cC8cf7f6b488C58AA909B77E6e65c631c204784", // Only allow transfers to this address + refValue: "0x6cC8cf7f6b488C58AA909B77E6e65c631c204784", }, + + // Transfer up to 0.2 tokens { index: 1, - condition: "LessEqual", - refValue: toHex(parseUnits("0.1", TOKEN.decimals), { size: 32 }), // Limit the transfer amount to 0.1 tokens + limit: parseUnits("0.2", TOKEN.decimals), // Unlimited if omitted }, ], - } + }, ], }, });