Skip to content

Commit

Permalink
Add WalletConnect description (keep-starknet-strange#188)
Browse files Browse the repository at this point in the history
* Add WalletConnect description

* fix

* fix2

* spelling
  • Loading branch information
maciejka authored Jun 24, 2024
1 parent 8c6d489 commit 2f2073f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br/> 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<br/> Bob's SN address
transfer->>erc20: transferFrom(Alice, Bob, x)
deactivate Alice
```

#### SocialPay

##### Alice sends tokens to Bob

```mermaid
sequenceDiagram
Expand Down
14 changes: 7 additions & 7 deletions onchain/src/social/deposit.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions onchain/src/social/request.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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<ByteArray> = SocialRequest {
public_key: 0xa2611fdbcbcc1e43ef809341ddef4a98c15ff6e6410ff7ed0c2b1c4f2a2cc2f5_u256,
Expand All @@ -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<ByteArray> = SocialRequest {
public_key: 0xa2611fdbcbcc1e43ef809341ddef4a98c15ff6e6410ff7ed0c2b1c4f2a2cc2f4_u256,
created_at: 1716380267_u64,
Expand Down

0 comments on commit 2f2073f

Please sign in to comment.