Skip to content

Commit 2abdd7f

Browse files
committed
Init
1 parent 28c53ec commit 2abdd7f

File tree

13 files changed

+4827
-64
lines changed

13 files changed

+4827
-64
lines changed

accs-contract-call/contracts/.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ cache/
33
out/
44

55
# Ignores development broadcast logs
6-
!/broadcast
7-
/broadcast/*/31337/
8-
/broadcast/**/dry-run/
6+
/broadcast
97

108
# Docs
119
docs/

accs-contract-call/contracts/script/Counter.s.sol renamed to accs-contract-call/contracts/script/AccessControl.s.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
pragma solidity ^0.8.13;
33

44
import {Script, console} from "forge-std/Script.sol";
5-
import {Counter} from "../src/Counter.sol";
5+
import {AccessControl} from "../src/AccessControl.sol";
66

7-
contract CounterScript is Script {
8-
Counter public counter;
7+
contract DeployAccessControl is Script {
8+
AccessControl public accessControl;
99

1010
function setUp() public {}
1111

1212
function run() public {
1313
vm.startBroadcast();
1414

15-
counter = new Counter();
15+
accessControl = new AccessControl();
1616

1717
vm.stopBroadcast();
1818
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
contract AccessControl {
5+
mapping(address => bool) public revokedAccess;
6+
7+
function grantAccess(address user) public {
8+
revokedAccess[user] = false;
9+
}
10+
11+
function revokeAccess(address user) public {
12+
revokedAccess[user] = true;
13+
}
14+
15+
function hasRevokedAccess(address user) public view returns (bool) {
16+
return revokedAccess[user];
17+
}
18+
}

accs-contract-call/contracts/src/Counter.sol

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {Test, console} from "forge-std/Test.sol";
5+
import {AccessControl} from "../src/AccessControl.sol";
6+
7+
contract AccessControlTest is Test {
8+
AccessControl public accessControl;
9+
10+
function setUp() public {
11+
accessControl = new AccessControl();
12+
}
13+
14+
function testGrantAccess() public {
15+
address user = address(0xBEEF);
16+
accessControl.grantAccess(user);
17+
assertFalse(accessControl.hasRevokedAccess(user));
18+
}
19+
20+
function testRevokeAccess() public {
21+
address user = address(0xCAFE);
22+
accessControl.revokeAccess(user);
23+
assertTrue(accessControl.hasRevokedAccess(user));
24+
}
25+
26+
function testHasRevokedAccess() public {
27+
address user1 = address(0xDEAD);
28+
address user2 = address(0xFEED);
29+
30+
accessControl.revokeAccess(user1);
31+
accessControl.grantAccess(user2);
32+
33+
assertTrue(accessControl.hasRevokedAccess(user1));
34+
assertFalse(accessControl.hasRevokedAccess(user2));
35+
}
36+
}

accs-contract-call/contracts/test/Counter.t.sol

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
ETHEREUM_PRIVATE_KEY=
2+
DEPLOYED_ACCESS_CONTROL_CONTRACT_ADDRESS=0xf960775B87fF2f53Eb962A8845F647615047389E
3+
LIT_CAPACITY_CREDIT_TOKEN_ID=
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Revoke Access to Encrypted Data
2+
3+
This code example demonstrates how access can be revoked to decrypt data using `EvmContractConditions` to making a request to an Access Control Contract.
4+
5+
## Running the Example
6+
7+
1. Install the dependencies with `yarn`
8+
2. Copy the `.env.example` file to `.env` and set the environment variables
9+
- `ETHEREUM_PRIVATE_KEY` - The private key of the Ethereum account that will be used to:
10+
- Mint Lit Capacity Credits if one wasn't provided
11+
- Create the Lit Capacity Delegation Auth Sig
12+
- Create the Lit Auth Sig to generate the Session Signatures
13+
- `DEPLOYED_ACCESS_CONTROL_CONTRACT_ADDRESS` - The address of the deployed Access Control Contract
14+
- [The contract](../contracts/src/AccessControl.sol) has been deployed on the Lit Chronicle Yellowstone blockchain at: `0xf960775B87fF2f53Eb962A8845F647615047389E` for testing purposes
15+
- `LIT_CAPACITY_CREDIT_TOKEN_ID` - The ID of the Lit Capacity Credit Token to avoid minting a new one when the example is ran
16+
3. Run the included tests using `yarn test`

accs-contract-call/nodejs/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
},
1010
"dependencies": {
1111
"@dotenvx/dotenvx": "^0.44.1",
12+
"@lit-protocol/auth-helpers": "^6.4.10",
13+
"@lit-protocol/constants": "^6.4.10",
14+
"@lit-protocol/contracts-sdk": "^6.4.10",
15+
"@lit-protocol/lit-node-client": "^6.4.10",
16+
"@lit-protocol/types": "^6.4.10",
1217
"ethers": "v5"
1318
},
1419
"devDependencies": {
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"abi": [
3+
{
4+
"type": "function",
5+
"name": "grantAccess",
6+
"inputs": [
7+
{ "name": "user", "type": "address", "internalType": "address" }
8+
],
9+
"outputs": [],
10+
"stateMutability": "nonpayable"
11+
},
12+
{
13+
"type": "function",
14+
"name": "hasRevokedAccess",
15+
"inputs": [
16+
{ "name": "user", "type": "address", "internalType": "address" }
17+
],
18+
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
19+
"stateMutability": "view"
20+
},
21+
{
22+
"type": "function",
23+
"name": "revokeAccess",
24+
"inputs": [
25+
{ "name": "user", "type": "address", "internalType": "address" }
26+
],
27+
"outputs": [],
28+
"stateMutability": "nonpayable"
29+
},
30+
{
31+
"type": "function",
32+
"name": "revokedAccess",
33+
"inputs": [{ "name": "", "type": "address", "internalType": "address" }],
34+
"outputs": [{ "name": "", "type": "bool", "internalType": "bool" }],
35+
"stateMutability": "view"
36+
}
37+
],
38+
"bytecode": {
39+
"object": "0x608060405234801561001057600080fd5b5061017d806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630ae5e7391461005157806333db35eb14610082578063479ceae4146100b957806385e68531146100e5575b600080fd5b61008061005f366004610117565b6001600160a01b03166000908152602081905260409020805460ff19169055565b005b6100a5610090366004610117565b60006020819052908152604090205460ff1681565b604051901515815260200160405180910390f35b6100a56100c7366004610117565b6001600160a01b031660009081526020819052604090205460ff1690565b6100806100f3366004610117565b6001600160a01b03166000908152602081905260409020805460ff19166001179055565b60006020828403121561012957600080fd5b81356001600160a01b038116811461014057600080fd5b939250505056fea26469706673582212204aac2421257252aadb759db2113b18263d4f171961154f7a5886243ccb76d0dc64736f6c63430008180033",
40+
"sourceMap": "65:377:23:-:0;;;;;;;;;;;;;;;;;;;",
41+
"linkReferences": {}
42+
},
43+
"deployedBytecode": {
44+
"object": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630ae5e7391461005157806333db35eb14610082578063479ceae4146100b957806385e68531146100e5575b600080fd5b61008061005f366004610117565b6001600160a01b03166000908152602081905260409020805460ff19169055565b005b6100a5610090366004610117565b60006020819052908152604090205460ff1681565b604051901515815260200160405180910390f35b6100a56100c7366004610117565b6001600160a01b031660009081526020819052604090205460ff1690565b6100806100f3366004610117565b6001600160a01b03166000908152602081905260409020805460ff19166001179055565b60006020828403121561012957600080fd5b81356001600160a01b038116811461014057600080fd5b939250505056fea26469706673582212204aac2421257252aadb759db2113b18263d4f171961154f7a5886243ccb76d0dc64736f6c63430008180033",
45+
"sourceMap": "65:377:23:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;146:86;;;;;;:::i;:::-;-1:-1:-1;;;;;198:19:23;220:5;198:19;;;;;;;;;;:27;;-1:-1:-1;;198:27:23;;;146:86;;;94:45;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;470:14:25;;463:22;445:41;;433:2;418:18;94:45:23;;;;;;;330:110;;;;;;:::i;:::-;-1:-1:-1;;;;;414:19:23;391:4;414:19;;;;;;;;;;;;;;330:110;238:86;;;;;;:::i;:::-;-1:-1:-1;;;;;291:19:23;:13;:19;;;;;;;;;;:26;;-1:-1:-1;;291:26:23;313:4;291:26;;;238:86;14:286:25;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;168:23;;-1:-1:-1;;;;;220:31:25;;210:42;;200:70;;266:1;263;256:12;200:70;289:5;14:286;-1:-1:-1;;;14:286:25:o",
46+
"linkReferences": {}
47+
},
48+
"methodIdentifiers": {
49+
"grantAccess(address)": "0ae5e739",
50+
"hasRevokedAccess(address)": "479ceae4",
51+
"revokeAccess(address)": "85e68531",
52+
"revokedAccess(address)": "33db35eb"
53+
},
54+
"rawMetadata": "{\"compiler\":{\"version\":\"0.8.24+commit.e11b9ed9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"grantAccess\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"hasRevokedAccess\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"revokeAccess\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"revokedAccess\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/AccessControl.sol\":\"AccessControl\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":forge-std/=lib/forge-std/src/\"]},\"sources\":{\"src/AccessControl.sol\":{\"keccak256\":\"0x55fbfa938109b27bafe8180ddadd2bfa81e48a135bda357e7c34f01917081462\",\"license\":\"UNLICENSED\",\"urls\":[\"bzz-raw://2c6988e051364f8dc1e72976f92b31cb8395be980b39dda7e0c6130b643808ca\",\"dweb:/ipfs/QmUAyEgakTh5QcXiMtAQ2LM1ZW27xJ58HnqBPM4GbdhVcX\"]}},\"version\":1}",
55+
"metadata": {
56+
"compiler": { "version": "0.8.24+commit.e11b9ed9" },
57+
"language": "Solidity",
58+
"output": {
59+
"abi": [
60+
{
61+
"inputs": [
62+
{ "internalType": "address", "name": "user", "type": "address" }
63+
],
64+
"stateMutability": "nonpayable",
65+
"type": "function",
66+
"name": "grantAccess"
67+
},
68+
{
69+
"inputs": [
70+
{ "internalType": "address", "name": "user", "type": "address" }
71+
],
72+
"stateMutability": "view",
73+
"type": "function",
74+
"name": "hasRevokedAccess",
75+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }]
76+
},
77+
{
78+
"inputs": [
79+
{ "internalType": "address", "name": "user", "type": "address" }
80+
],
81+
"stateMutability": "nonpayable",
82+
"type": "function",
83+
"name": "revokeAccess"
84+
},
85+
{
86+
"inputs": [
87+
{ "internalType": "address", "name": "", "type": "address" }
88+
],
89+
"stateMutability": "view",
90+
"type": "function",
91+
"name": "revokedAccess",
92+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }]
93+
}
94+
],
95+
"devdoc": { "kind": "dev", "methods": {}, "version": 1 },
96+
"userdoc": { "kind": "user", "methods": {}, "version": 1 }
97+
},
98+
"settings": {
99+
"remappings": ["forge-std/=lib/forge-std/src/"],
100+
"optimizer": { "enabled": true, "runs": 200 },
101+
"metadata": { "bytecodeHash": "ipfs" },
102+
"compilationTarget": { "src/AccessControl.sol": "AccessControl" },
103+
"evmVersion": "paris",
104+
"libraries": {}
105+
},
106+
"sources": {
107+
"src/AccessControl.sol": {
108+
"keccak256": "0x55fbfa938109b27bafe8180ddadd2bfa81e48a135bda357e7c34f01917081462",
109+
"urls": [
110+
"bzz-raw://2c6988e051364f8dc1e72976f92b31cb8395be980b39dda7e0c6130b643808ca",
111+
"dweb:/ipfs/QmUAyEgakTh5QcXiMtAQ2LM1ZW27xJ58HnqBPM4GbdhVcX"
112+
],
113+
"license": "UNLICENSED"
114+
}
115+
},
116+
"version": 1
117+
},
118+
"id": 23
119+
}

0 commit comments

Comments
 (0)