From 2f2073f59123fb05ac6a5347cfe28d7584a7c715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kami=C5=84ski=20=40=20StarkWare?= Date: Mon, 24 Jun 2024 12:19:02 +0200 Subject: [PATCH] Add WalletConnect description (#188) * Add WalletConnect description * fix * fix2 * spelling --- README.md | 48 ++++++++++++++++++++++++++++++-- onchain/src/social/deposit.cairo | 14 +++++----- onchain/src/social/request.cairo | 6 ++-- 3 files changed, 57 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index dd451901..d23272d7 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,53 @@ Tech stack: ## Architecture -### SocialPay +### Tips +There are two alternatives: WalletConnect one which expects Nostr users to setup oridinary Starknet wallet like Argent or Bravvos and so called SocialPay which uses custom Account Abstraction contract based on bip340 signature scheme (Nostr native one). -#### Alice sends tokens to Bob +#### Wallet Connect +##### Tip to a recipient that never accepted the tip +```mermaid +sequenceDiagram + actor Alice + actor Bob + participant transfer as Transfer Contract + participant erc20 as ERC20 + + Note over Alice,erc20: Alice tip is escrowed by the Transfer Contract + activate Alice + Alice->>erc20: approve(Transfer Contract, x) + Alice->>transfer: transfer(Bob Nostr Address, x) + transfer->>erc20: transferFrom(Alice, Transfer Contract, x) + transfer->>Alice: deposit_id + deactivate Alice + + + Note over Alice,erc20: Bob claims the tip with his Nostr identity + activate Bob + Bob->>transfer: claim(deposit_id) + Note right of Bob: deposit_id is signed
with Nostr key + transfer->>erc20: transferFrom(Transfer Contract, Bob, x) + deactivate Bob +``` + +##### Tip to a recipient that earlier accepted the tip +```mermaid +sequenceDiagram + actor Alice + participant transfer as Transfer Contract + participant erc20 as ERC20 + + activate Alice + Alice->>erc20: approve(Transfer Contract, x) + Alice->>transfer: transfer(Bob Nostr Address, x) + Note left of transfer: Transfer Contract knows
Bob's SN address + transfer->>erc20: transferFrom(Alice, Bob, x) + deactivate Alice +``` + +#### SocialPay + +##### Alice sends tokens to Bob ```mermaid sequenceDiagram diff --git a/onchain/src/social/deposit.cairo b/onchain/src/social/deposit.cairo index 69f95120..870288d4 100644 --- a/onchain/src/social/deposit.cairo +++ b/onchain/src/social/deposit.cairo @@ -368,7 +368,7 @@ mod tests { let amount = 100_u256; cheat_caller_address_global(sender_address); - erc20.approve(escrow.contract_address, amount + amount); + erc20.approve(escrow.contract_address, amount); stop_cheat_caller_address_global(); start_cheat_caller_address(escrow.contract_address, sender_address); @@ -386,7 +386,7 @@ mod tests { let amount = 100_u256; cheat_caller_address_global(sender_address); - erc20.approve(escrow.contract_address, amount + amount); + erc20.approve(escrow.contract_address, amount); stop_cheat_caller_address_global(); start_cheat_caller_address(escrow.contract_address, sender_address); @@ -412,7 +412,7 @@ mod tests { let amount = 100_u256; cheat_caller_address_global(sender_address); - erc20.approve(escrow.contract_address, amount + amount); + erc20.approve(escrow.contract_address, amount); stop_cheat_caller_address_global(); start_cheat_caller_address(escrow.contract_address, sender_address); @@ -434,7 +434,7 @@ mod tests { let amount = 100_u256; cheat_caller_address_global(sender_address); - erc20.approve(escrow.contract_address, amount + amount); + erc20.approve(escrow.contract_address, amount); stop_cheat_caller_address_global(); start_cheat_caller_address(escrow.contract_address, sender_address); @@ -453,7 +453,7 @@ mod tests { let amount = 100_u256; cheat_caller_address_global(sender_address); - erc20.approve(escrow.contract_address, amount + amount); + erc20.approve(escrow.contract_address, amount); stop_cheat_caller_address_global(); start_cheat_caller_address(escrow.contract_address, sender_address); @@ -476,7 +476,7 @@ mod tests { let amount = 100_u256; cheat_caller_address_global(sender_address); - erc20.approve(escrow.contract_address, amount + amount); + erc20.approve(escrow.contract_address, amount); stop_cheat_caller_address_global(); start_cheat_caller_address(escrow.contract_address, sender_address); @@ -495,7 +495,7 @@ mod tests { let amount = 100_u256; cheat_caller_address_global(sender_address); - erc20.approve(escrow.contract_address, amount + amount); + erc20.approve(escrow.contract_address, amount); stop_cheat_caller_address_global(); start_cheat_caller_address(escrow.contract_address, sender_address); diff --git a/onchain/src/social/request.cairo b/onchain/src/social/request.cairo index 3e426f51..cb75ac2a 100644 --- a/onchain/src/social/request.cairo +++ b/onchain/src/social/request.cairo @@ -153,7 +153,8 @@ mod tests { #[test] fn verify_invalid_content() { - // valid content = "nprofile1qys8wumn8ghj7un9d3shjtn2daukymme9e3k7mtdw4hxjare9e3k7mgqyzzxqw6wxqyyqqmv4rxgz2l0ej8zgrqfkuupycuatnwcannad6ayqx7zdcy + // valid content = + // "nprofile1qys8wumn8ghj7un9d3shjtn2daukymme9e3k7mtdw4hxjare9e3k7mgqyzzxqw6wxqyyqqmv4rxgz2l0ej8zgrqfkuupycuatnwcannad6ayqx7zdcy // send 1 USDC to nprofile1qqs2sa3zk4a49umxg4lgvlsaenrqaf33ejkffd78f2cgy4xy38h393s2w22mm" let r: SocialRequest = SocialRequest { public_key: 0xa2611fdbcbcc1e43ef809341ddef4a98c15ff6e6410ff7ed0c2b1c4f2a2cc2f5_u256, @@ -172,7 +173,8 @@ mod tests { #[test] fn verify_invalid_public_key() { - // valid public_key = 0xa2611fdbcbcc1e43ef809341ddef4a98c15ff6e6410ff7ed0c2b1c4f2a2cc2f5_u256 + // valid public_key = + // 0xa2611fdbcbcc1e43ef809341ddef4a98c15ff6e6410ff7ed0c2b1c4f2a2cc2f5_u256 let r: SocialRequest = SocialRequest { public_key: 0xa2611fdbcbcc1e43ef809341ddef4a98c15ff6e6410ff7ed0c2b1c4f2a2cc2f4_u256, created_at: 1716380267_u64,