Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Aut-Labs/contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabyl committed Jun 23, 2024
2 parents 0017d22 + c1fbc93 commit 8c7071e
Show file tree
Hide file tree
Showing 12 changed files with 350 additions and 169 deletions.
2 changes: 1 addition & 1 deletion contracts/autid/AutIDUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract contract AutIDUtils {
}

function _revertForInvalidCommitment(uint256 commitment) internal pure {
if (!(commitment > MIN_GLOBAL_COMMITMENT && commitment < MAX_GLOBAL_COMMITMENT)) {
if (!(commitment >= MIN_GLOBAL_COMMITMENT && commitment <= MAX_GLOBAL_COMMITMENT)) {
revert InvalidCommitment();
}
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/nova/NovaRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ contract NovaRegistry is INovaRegistry, ERC2771ContextUpgradeable, OwnableUpgrad
function _checkAllowlist() internal view {
if (_msgSender() == deployerAddress || _msgSender() == upgradeableBeacon.owner()) return;
if (address(allowlist) != address(0)) {
if (!allowlist.isAllowed(_msgSender())) {
revert IAllowlist.Unallowed();
}
// if (!allowlist.isAllowed(_msgSender())) {
// revert IAllowlist.Unallowed();
// }
if ((novaDeployers[_msgSender()].length != 0)) {
revert IAllowlist.AlreadyDeployedANova();
// `novaDeployers` state is not stored within allowlist,
Expand Down
72 changes: 72 additions & 0 deletions deployments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,75 @@
8. onboardingRole3: 0x6152e235De0cC9D00b6aC8243767D3471C6D389B


80002 1714740120
0. globalParametersProxy: 0xE21ecE10b02a858CeeFF3E116650919C59dF48e9
1. autIDProxy: 0x0F5C79B642Da6a76F8c015F6D543bdC98CB49f70
2. novaRegistryProxy: 0x251961B0F718b35B3173fA5af04710E61f461a75
3. pluginRegistryProxy: 0x4c50bdf751637cd00465d55C95FF91af48047B13
4. allowlist: 0x199AA436089bF15eff4770bd41E34964576B1A92
5. basicOnboarding: 0xE34B3e4904CdfCB36Dd8AD17959281A48b0B63e8
6. onboardingRole1: 0x21Bcaa77abd5E250AC0858EddE6671d056CF6A75
7. onboardingRole2: 0x2E36000ce7B17fDa0A4c3bc30cB8cDD3d5Ae66B8
8. onboardingRole3: 0x5adb0eeA9ABD684A3665E8943B3995505758cfEf


80002 1715026983
0. globalParametersProxy: 0x332bBF8BbC2F1C3f3FD78859f132e0EC8EB4De11
1. autIDProxy: 0x39aCB17ef02aF56413B689514b74EBDF86944B83
2. novaRegistryProxy: 0x50f59009D5a5c6Bafc69F451C078Aa38A810bd07
3. pluginRegistryProxy: 0xdbD5B017009Cbcc5Fe26CEb0995A9bFcd7669689
4. allowlist: 0x36a4beA81FaD858f9E08485Afd803b71BeA641D4
5. basicOnboarding: 0xB45546898C66fD899fc8f5f5A2168B7C4c26788B
6. onboardingRole1: 0xf64b5fCCaC3263DB227261660bcCB4d4498216cf
7. onboardingRole2: 0x99C86680BB6d8c4bBb522d889Ee497Fb30bF4e4F
8. onboardingRole3: 0xa6b491614197bE43b616d34482e90AFf821BB6FA


80002 1715027635
0. globalParametersProxy: 0x9D41AF807564b1BaBAb545816Af6746a18DdC066
1. autIDProxy: 0xDf8610E895094Be04A206bE2eBa16B8749799499
2. novaRegistryProxy: 0x5f57801530CeF74703424cc5FaB09bF4F003E181
3. pluginRegistryProxy: 0x2d25AE2D11813383E8624DF8599839D25Ec85Df1
4. allowlist: 0xd2fa5e0Ced0d4eDDA80d48bC5068e77d55d4841A
5. basicOnboarding: 0x4b9418Db17e1f82bDbd7456f1F1AF039b1852392
6. onboardingRole1: 0x39f903B05b7Aee2f002FaDAcF43d41dA142D54dD
7. onboardingRole2: 0xF3c672a92ee51527246Cba318A01071D6799e792
8. onboardingRole3: 0x7D7Ea90638aEc24Cbe792712701BA15ce9D13a95


137 1715790353
0. globalParametersProxy: 0xFa562DA37F13A47151D0355933c139F288e40e84
1. autIDProxy: 0xA8D2eaa40C7cc0Ed6A6B0e85B50767b82715d7bD
2. novaRegistryProxy: 0xF3954e1d1152f64592E8E7ECD1c0DCca5f1de427
3. pluginRegistryProxy: 0x97dBcB61d52F91eAEAc182b3aeb56A1B3e258c0b
4. allowlist: 0x589ec87992F3Fe65544CA76bd6a63225c36d970E
5. basicOnboarding: 0x53f7981E5e3b980F125EB72d7F4632e4DebA6A49
6. onboardingRole1: 0x536E6e54c988e8Bb58742fB5748Fb168DAce9a4a
7. onboardingRole2: 0x0837504Cb181Bf60A8453A3525dc9f5689f2Fcf0
8. onboardingRole3: 0x1fF7BE03f686EFD3D6882640b60508a6E4CcF4E8


80002 1715790714
0. globalParametersProxy: 0x3A41D486C22B50b1400231E4D8c24C52Dc6E2500
1. autIDProxy: 0x4767071FBAa11cF74D52F23482ECCDC7e09bf369
2. novaRegistryProxy: 0x35EC5fbE50EB25eCc39a8B7396cb0C44F3f6D617
3. pluginRegistryProxy: 0xcC2f6d0830B9279f9fD6F132Da7c16Ab0aDEfC4d
4. allowlist: 0x742fCBFa07103d993D603B225E5397B296332C3A
5. basicOnboarding: 0x673ec5bfB255850fFF6e8ECfd7aCe1a62f1c55CC
6. onboardingRole1: 0xb17e49097D2AAC6744D5B27c6939986854e90BA7
7. onboardingRole2: 0xbD7D5f69572C473b21DE15881bE908813e27152B
8. onboardingRole3: 0xe4E05Df812bFAAD2F798811698A353039f4010Dd


137 1715790837
0. globalParametersProxy: 0xFa562DA37F13A47151D0355933c139F288e40e84
1. autIDProxy: 0xA8D2eaa40C7cc0Ed6A6B0e85B50767b82715d7bD
2. novaRegistryProxy: 0xF3954e1d1152f64592E8E7ECD1c0DCca5f1de427
3. pluginRegistryProxy: 0x97dBcB61d52F91eAEAc182b3aeb56A1B3e258c0b
4. allowlist: 0x589ec87992F3Fe65544CA76bd6a63225c36d970E
5. basicOnboarding: 0x53f7981E5e3b980F125EB72d7F4632e4DebA6A49
6. onboardingRole1: 0x536E6e54c988e8Bb58742fB5748Fb168DAce9a4a
7. onboardingRole2: 0x0837504Cb181Bf60A8453A3525dc9f5689f2Fcf0
8. onboardingRole3: 0x1fF7BE03f686EFD3D6882640b60508a6E4CcF4E8


12 changes: 7 additions & 5 deletions script/DeployAll.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,30 @@ import "forge-std/Script.sol";
contract DeployAll is Script {
address public trustedForwarder;
address public owner;
uint256 public privateKey;

struct TNamedAddress {
address target;
string name;
}

function setUp() public {
if (block.chainid == 31337) {
// todo: replace 31337 by forge constant
if (block.chainid == 137) {
trustedForwarder = address(new TrustedForwarder());
owner = vm.envAddress("A1");
owner = vm.envAddress("MAINNET_OWNER_ADDRESS");
privateKey = vm.envUint("MAINNET_PRIVATE_KEY");
} else if (block.chainid == 80002) {
trustedForwarder = address(new TrustedForwarder());
owner = 0x09Ed23BB6F9Ccc3Fd9b3BC4C859D049bf4AB4D43;
owner = vm.envAddress("TESTNET_OWNER_ADDRESS");
privateKey = vm.envUint("TESTNET_PRIVATE_KEY");
} else {
revert("invalid chainid");
}
console.log("setUp -- done");
}

function run() public {
vm.startBroadcast(vm.envUint("PVK_A1"));
vm.startBroadcast(privateKey);

address novaImpl = address(new Nova());
address novaRegistryImpl = address(new NovaRegistry(trustedForwarder));
Expand Down
12 changes: 12 additions & 0 deletions script/deploy_mainnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Check if .env file exists
ENV_FILE="../.env"
if [ ! -f $ENV_FILE ]; then
echo ".env file not found in the parent directory!"
exit 1
fi

export $(grep -v '^#' $ENV_FILE | xargs)

forge script ./DeployAll.s.sol --rpc-url $MAINNET_RPC_URL --private-key $MAINNET_PRIVATE_KEY --broadcast --legacy
12 changes: 12 additions & 0 deletions script/deploy_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Check if .env file exists
ENV_FILE="../.env"
if [ ! -f $ENV_FILE ]; then
echo ".env file not found in the parent directory!"
exit 1
fi

export $(grep -v '^#' $ENV_FILE | xargs)

forge script ./DeployAll.s.sol --rpc-url $TESTNET_RPC_URL --private-key $TESTNET_PRIVATE_KEY --broadcast --legacy
21 changes: 21 additions & 0 deletions subgraphs/deploy_mainnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Check if .env file exists
ENV_FILE="../.env"
if [ ! -f $ENV_FILE ]; then
echo ".env file not found in the parent directory!"
exit 1
fi

export $(grep -v '^#' $ENV_FILE | xargs)

SUBGRAPH_NETWORK=polygon
SUBGRAPH_BLOCK=57002848
SUBGRAPH_AUTID_ADDRESS="0xA8D2eaa40C7cc0Ed6A6B0e85B50767b82715d7bD"
SUBGRAPH_NOVA_REGISTRY_ADDRESS="0xF3954e1d1152f64592E8E7ECD1c0DCca5f1de427"

npm run codegen && npm run build && graph deploy $MAINNET_SUBGRAPH_NAME \
--version-label $MAINNET_SUBGRAPH_VERSION \
--node $MAINNET_SUBGRAPH_NODE \
--ipfs $MAINNET_SUBGRAPH_IPFS \
--deploy-key $MAINNET_SUBGRAPH_DEPLOY_KEY
21 changes: 21 additions & 0 deletions subgraphs/deploy_testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Check if .env file exists
ENV_FILE="../.env"
if [ ! -f $ENV_FILE ]; then
echo ".env file not found in the parent directory!"
exit 1
fi

export $(grep -v '^#' $ENV_FILE | xargs)

SUBGRAPH_NETWORK=polygon-amoy
SUBGRAPH_BLOCK=6486436
SUBGRAPH_AUTID_ADDRESS=0xDf8610E895094Be04A206bE2eBa16B8749799499
SUBGRAPH_NOVA_REGISTRY_ADDRESS=0x5f57801530CeF74703424cc5FaB09bF4F003E181

npm run codegen && npm run build && graph deploy $TESTNET_SUBGRAPH_NAME \
--version-label $TESTNET_SUBGRAPH_VERSION \
--node $TESTNET_SUBGRAPH_NODE \
--ipfs $TESTNET_SUBGRAPH_IPFS \
--deploy-key $TESTNET_SUBGRAPH_DEPLOY_KEY
3 changes: 2 additions & 1 deletion subgraphs/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
type AutID @entity(immutable: false) {
id: ID!
owner: Bytes!
owner: Bytes!
tokenID: BigInt!
username: String!
novaAddress: Bytes
role: BigInt
commitment: BigInt
joinedNovas: [Bytes!] @default(value: [])
metadataUri: String
blockNumber: BigInt!
blockTimestamp: BigInt!
Expand Down
17 changes: 12 additions & 5 deletions subgraphs/src/aut-id.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Bytes } from "@graphprotocol/graph-ts";
import {
NovaJoined,
RecordCreated,
TokenMetadataUpdated,
// CommitmentUpdated,
// MetadataUriSet,
// NovaWithdrawn,
} from "../generated/AutID/AutID";
import { AutID } from "../generated/schema";

Expand All @@ -27,18 +25,27 @@ export function handleRecordCreated(event: RecordCreated): void {

autID.save();
}

export function handleNovaJoined(event: NovaJoined): void {
let id = event.params.account.toHexString();

let autID = AutID.load(id);
if (autID == null) {
autID = new AutID(id);
autID.joinedNovas = [];
}

autID.role = event.params.role;
autID.commitment = event.params.commitment;
autID.novaAddress = event.params.nova;
autID.novaAddress = event.params.nova as Bytes;

if (autID.joinedNovas == null) {
autID.joinedNovas = [];
}

let novaAddress = event.params.nova as Bytes;
let novas = autID.joinedNovas as Array<Bytes>;
novas.push(novaAddress);
autID.joinedNovas = novas;

autID.save();
}
Expand Down
8 changes: 2 additions & 6 deletions subgraphs/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dataSources:
name: AutID
network: polygon-amoy
source:
address: "0x0F5C79B642Da6a76F8c015F6D543bdC98CB49f70"
address: "0xDf8610E895094Be04A206bE2eBa16B8749799499"
startBlock: 6486436
abi: AutID
mapping:
Expand All @@ -25,16 +25,12 @@ dataSources:
handler: handleNovaJoined
- event: TokenMetadataUpdated(uint256,address,string)
handler: handleTokenMetadataUpdated
# - event: CommitmentUpdated(address,address,uint256)
# handler: handleCommitmentUpdated
# - event: NovaWithdrawn(address,address)
# handler: handleNovaWithdrawn
file: ./src/aut-id.ts
- kind: ethereum
name: NovaRegistry
network: polygon-amoy
source:
address: "0x251961B0F718b35B3173fA5af04710E61f461a75"
address: "0x5f57801530CeF74703424cc5FaB09bF4F003E181"
abi: NovaRegistry
startBlock: 6486436
mapping:
Expand Down
Loading

0 comments on commit 8c7071e

Please sign in to comment.