Skip to content

Commit

Permalink
feat: use new solidity library and fix impersonation with leo accounts (
Browse files Browse the repository at this point in the history
  • Loading branch information
yum0e authored Jul 19, 2023
1 parent 650979e commit 7825ba6
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 178 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/sismo-connect-packages"]
path = lib/sismo-connect-packages
url = https://github.com/sismo-core/sismo-connect-packages
[submodule "lib/sismo-connect-solidity"]
path = lib/sismo-connect-solidity
url = https://github.com/sismo-core/sismo-connect-solidity
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ forge install
```bash
# in another terminal
# starts a local fork of Mumbai
yarn anvil
yarn chain
```

### Launch the local application
Expand Down
164 changes: 0 additions & 164 deletions abi/Airdrop.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,170 +201,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "isSelectableByUser",
"type": "bool"
}
],
"name": "buildSignature",
"outputs": [
{
"components": [
{
"internalType": "bytes",
"name": "message",
"type": "bytes"
},
{
"internalType": "bool",
"name": "isSelectableByUser",
"type": "bool"
},
{
"internalType": "bytes",
"name": "extraData",
"type": "bytes"
}
],
"internalType": "struct SignatureRequest",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "message",
"type": "bytes"
},
{
"internalType": "bytes",
"name": "extraData",
"type": "bytes"
}
],
"name": "buildSignature",
"outputs": [
{
"components": [
{
"internalType": "bytes",
"name": "message",
"type": "bytes"
},
{
"internalType": "bool",
"name": "isSelectableByUser",
"type": "bool"
},
{
"internalType": "bytes",
"name": "extraData",
"type": "bytes"
}
],
"internalType": "struct SignatureRequest",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "isSelectableByUser",
"type": "bool"
},
{
"internalType": "bytes",
"name": "extraData",
"type": "bytes"
}
],
"name": "buildSignature",
"outputs": [
{
"components": [
{
"internalType": "bytes",
"name": "message",
"type": "bytes"
},
{
"internalType": "bool",
"name": "isSelectableByUser",
"type": "bool"
},
{
"internalType": "bytes",
"name": "extraData",
"type": "bytes"
}
],
"internalType": "struct SignatureRequest",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "message",
"type": "bytes"
},
{
"internalType": "bool",
"name": "isSelectableByUser",
"type": "bool"
},
{
"internalType": "bytes",
"name": "extraData",
"type": "bytes"
}
],
"name": "buildSignature",
"outputs": [
{
"components": [
{
"internalType": "bytes",
"name": "message",
"type": "bytes"
},
{
"internalType": "bool",
"name": "isSelectableByUser",
"type": "bool"
},
{
"internalType": "bytes",
"name": "extraData",
"type": "bytes"
}
],
"internalType": "struct SignatureRequest",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
2 changes: 1 addition & 1 deletion front/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const sismoConnectConfig: SismoConnectConfig = {
// For development purposes
// insert any account that you want to impersonate here
// Never use this in production
impersonate: ["dhadrien.sismo.eth", "twitter:dhadrien_", "github:dhadrien"],
impersonate: ["leo21.sismo.eth", "twitter:leo21_eth", "github:leo21"],
},
};

Expand Down
1 change: 0 additions & 1 deletion lib/sismo-connect-packages
Submodule sismo-connect-packages deleted from ec6624
1 change: 1 addition & 0 deletions lib/sismo-connect-solidity
Submodule sismo-connect-solidity added at 52441a
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"anvil": "anvil --fork-url https://rpc.ankr.com/polygon_mumbai --chain-id 5151111",
"chain": "anvil --fork-url https://rpc.ankr.com/polygon_mumbai --chain-id 5151111",
"deploy-local": "yarn deploy-airdrop && yarn generate-abi",
"generate-abi": "front/script/generate-abi.sh",
"deploy-airdrop": "forge script DeployAirdrop --rpc-url http://localhost:8545 -vv --mnemonics 'test test test test test test test test test test test junk' --sender '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266' --broadcast",
Expand Down
2 changes: 1 addition & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
forge-std/=lib/forge-std/src/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
sismo-connect-solidity/=lib/sismo-connect-packages/packages/sismo-connect-solidity/src/
sismo-connect-solidity/=lib/sismo-connect-solidity/src/
10 changes: 5 additions & 5 deletions src/Airdrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.17;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "forge-std/console.sol";
import "sismo-connect-solidity/SismoLib.sol"; // <--- add a Sismo Connect import
import "sismo-connect-solidity/SismoConnectLib.sol"; // <--- add a Sismo Connect import

/*
* @title Airdrop
Expand Down Expand Up @@ -34,16 +34,16 @@ contract Airdrop is ERC20, SismoConnect {
SismoConnectVerifiedResult memory result = verify({
responseBytes: response,
// we want the user to prove that he owns a Sismo Vault
// we are recreating the auth request made in the frontend to be sure that
// we are recreating the auth request made in the frontend to be sure that
// the proofs provided in the response are valid with respect to this auth request
auth: buildAuth({authType: AuthType.VAULT}),
// we also want to check if the signed message provided in the response is the signature of the user's address
signature: buildSignature({message: abi.encode(msg.sender)})
signature: buildSignature({message: abi.encode(msg.sender)})
});

// if the proofs and signed message are valid, we take the userId from the verified result
// in this case the userId is the vaultId (since we used AuthType.VAULT in the auth request),
// it is the anonymous identifier of a user's vault for a specific app
// in this case the userId is the vaultId (since we used AuthType.VAULT in the auth request),
// it is the anonymous identifier of a user's vault for a specific app
// --> vaultId = hash(userVaultSecret, appId)
uint256 vaultId = result.getUserId(AuthType.VAULT);

Expand Down
2 changes: 1 addition & 1 deletion tests/base/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.17;

import "forge-std/Test.sol";
import "forge-std/console.sol";
import {IAddressesProvider} from "sismo-connect-solidity/SismoLib.sol";
import {IAddressesProvider} from "sismo-connect-solidity/SismoConnectLib.sol";

interface IAvailableRootsRegistry {
event RegisteredRoot(uint256 root);
Expand Down

0 comments on commit 7825ba6

Please sign in to comment.