Skip to content

Commit

Permalink
configure new identity network on complere
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-H-Leonard committed Oct 9, 2024
1 parent b3466b2 commit 481d2c7
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 163 deletions.
97 changes: 4 additions & 93 deletions smart-contract/deploy/scripts/add-gatekeeper-to-default-network.ts
Original file line number Diff line number Diff line change
@@ -1,109 +1,20 @@
import { sleep, getDeploymentSigner } from "../defender-utils";
import hre , { ethers, upgrades } from "hardhat";
import { Signer } from '@ethersproject/abstract-signer/src.ts'
import { BNB_TESTNET_CONTRACT_ADDRESSES, ZERO_ADDRESS, gatekeeperOneTestnetWallet, gatekeeperTwoTestnetWallet, testNetworkName, testNetworkNameWithErc20Fees, testNetworkNameWithNativeFees, trustSwiftlyTestnetGatekeeperWallet } from "../utils";
import { COMPLERE_TESTNET_CONTRACT_ADDRESSES, ZERO_ADDRESS, gatekeeperOneTestnetWallet, gatekeeperTwoTestnetWallet, testNetworkName, testNetworkNameWithErc20Fees, testNetworkNameWithNativeFees, trustSwiftlyTestnetGatekeeperWallet } from "../utils";
import { GatewayNetwork, GatewayToken, IGatewayNetwork } from "../../typechain-types";

async function main() {
let signer: Signer;
if(process.env.SHOULD_USE_DEFENDER! == "true") {
signer = await getDeploymentSigner();
}
signer = await getDeploymentSigner();

const gatewayNetworkContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;
const gatewayTokenContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayToken;
const dummyERC20ContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.erc20;
const gatewayNetworkContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;

const provider = new ethers.providers.JsonRpcProvider(process.env.BNB_TESTNET_RPC_URL!);


const GatewayTokenContractFactory = await ethers.getContractFactory("GatewayToken", signer!);


// Refersh existing token
const NetworkContractFactory = await ethers.getContractFactory("GatewayNetwork", signer!);
const networkContract = NetworkContractFactory.attach(gatewayNetworkContractAddress) as GatewayNetwork;


await networkContract.connect(signer!).addGatekeeper("0xa0Ee7A142d267C1f36714E4a8F75612F20a79720", testNetworkName);

// const testNetworkOne: IGatewayNetwork.GatekeeperNetworkDataStruct = {
// primaryAuthority: trustSwiftlyTestnetWallet.address,
// name: testNetworkNameWithErc20Fees,
// passExpireDurationInSeconds: 2628000,
// networkFeatureMask: 0,
// networkFee: {
// issueFee: 100,
// refreshFee: 100,
// expireFee: 100,
// freezeFee: 100
// },
// supportedToken: dummyERC20ContractAddress,
// gatekeepers: [],
// lastFeeUpdateTimestamp: 0
// }

// console.log(`Creating testNetworkOne`);

// await networkContract.connect(signer!).createNetwork(testNetworkOne);



// await sleep(2000);

// // Network 2: testNetworkNameWithNativeFees
// // - Create
// // - Add gatekeeper 2 as gatekeeper + primary authority
// // Gatekeeper claim primary authority

// const testNetworkTwo: IGatewayNetwork.GatekeeperNetworkDataStruct = {
// primaryAuthority: gatekeeprTwo.address,
// name: testNetworkNameWithNativeFees,
// passExpireDurationInSeconds: 2628000,
// networkFeatureMask: 0,
// networkFee: {
// issueFee: 100,
// refreshFee: 100,
// expireFee: 100,
// freezeFee: 100
// },
// supportedToken: ZERO_ADDRESS,
// gatekeepers: [],
// lastFeeUpdateTimestamp: 0
// }

// console.log(`Creating testNetworkTwo`);

// await networkContract.connect(signer!).createNetwork(testNetworkTwo, {gasLimit: 500000});


// await sleep(2000);

// // Network 3: identity.com
// // - Create
// // - Add defender relayer as gatekeeper + primary autority
// // Gatekeeper claim primary authority
// const defaultIdentityNetwork: IGatewayNetwork.GatekeeperNetworkDataStruct = {
// primaryAuthority: await signer!.getAddress(),
// name: testNetworkName,
// passExpireDurationInSeconds: 2628000,
// networkFeatureMask: 0,
// networkFee: {
// issueFee: 0,
// refreshFee: 0,
// expireFee: 0,
// freezeFee: 0
// },
// supportedToken: ZERO_ADDRESS,
// gatekeepers: [],
// lastFeeUpdateTimestamp: 0
// }

// console.log(`Creating defaultIdentityNetwork`);

// await networkContract.connect(signer!).createNetwork(defaultIdentityNetwork, {gasLimit: 500000});

await sleep(2000);
await networkContract.connect(signer!).addGatekeeper(await signer.getAddress(), testNetworkName);
}


Expand Down
112 changes: 56 additions & 56 deletions smart-contract/deploy/scripts/initalize-default-test-networks.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { sleep, getDeploymentSigner } from "../defender-utils";
import hre , { ethers, upgrades } from "hardhat";
import { Signer } from '@ethersproject/abstract-signer/src.ts'
import { BNB_TESTNET_CONTRACT_ADDRESSES, ZERO_ADDRESS, gatekeeperOneTestnetWallet, gatekeeperTwoTestnetWallet, testNetworkName, testNetworkNameWithErc20Fees, testNetworkNameWithNativeFees } from "../utils";
import { COMPLERE_TESTNET_CONTRACT_ADDRESSES, ZERO_ADDRESS, gatekeeperOneTestnetWallet, gatekeeperTwoTestnetWallet, testNetworkName, testNetworkNameWithErc20Fees, testNetworkNameWithNativeFees } from "../utils";
import { GatewayNetwork, IGatewayNetwork } from "../../typechain-types";
import { utils } from "ethers";

async function main() {
let signer: Signer;
if(process.env.SHOULD_USE_DEFENDER! == "true") {
signer = await getDeploymentSigner();
}
signer = await getDeploymentSigner();

const gatewayNetworkContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;
const dummyERC20ContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.erc20;
const gatewayNetworkContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;
const dummyERC20ContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.erc20;

const provider = new ethers.providers.JsonRpcProvider(process.env.BNB_TESTNET_RPC_URL!);

Expand All @@ -26,19 +25,20 @@ async function main() {
const networkContract = NetworkContractFactory.attach(gatewayNetworkContractAddress) as GatewayNetwork;

const testNetworkOne: IGatewayNetwork.GatekeeperNetworkDataStruct = {
primaryAuthority: gatekeeprOne.address,
name: testNetworkNameWithErc20Fees,
primaryAuthority: await signer.getAddress(),
name: testNetworkName,
passExpireDurationInSeconds: 2628000,
networkFeatureMask: 0,
networkFee: {
issueFee: 100,
refreshFee: 100,
expireFee: 100,
freezeFee: 100
issueFee: 0,
refreshFee: 0,
expireFee: 0,
freezeFee: 0
},
supportedToken: dummyERC20ContractAddress,
gatekeepers: [],
lastFeeUpdateTimestamp: 0
lastFeeUpdateTimestamp: 0,
description: utils.formatBytes32String("Identity KYC Network")
}

console.log(`Creating testNetworkOne`);
Expand All @@ -49,57 +49,57 @@ async function main() {

await sleep(2000);

// Network 2: testNetworkNameWithNativeFees
// - Create
// - Add gatekeeper 2 as gatekeeper + primary authority
// Gatekeeper claim primary authority
// // Network 2: testNetworkNameWithNativeFees
// // - Create
// // - Add gatekeeper 2 as gatekeeper + primary authority
// // Gatekeeper claim primary authority

const testNetworkTwo: IGatewayNetwork.GatekeeperNetworkDataStruct = {
primaryAuthority: gatekeeprTwo.address,
name: testNetworkNameWithNativeFees,
passExpireDurationInSeconds: 2628000,
networkFeatureMask: 0,
networkFee: {
issueFee: 100,
refreshFee: 100,
expireFee: 100,
freezeFee: 100
},
supportedToken: ZERO_ADDRESS,
gatekeepers: [],
lastFeeUpdateTimestamp: 0
}
// const testNetworkTwo: IGatewayNetwork.GatekeeperNetworkDataStruct = {
// primaryAuthority: gatekeeprTwo.address,
// name: testNetworkNameWithNativeFees,
// passExpireDurationInSeconds: 2628000,
// networkFeatureMask: 0,
// networkFee: {
// issueFee: 100,
// refreshFee: 100,
// expireFee: 100,
// freezeFee: 100
// },
// supportedToken: ZERO_ADDRESS,
// gatekeepers: [],
// lastFeeUpdateTimestamp: 0
// }

console.log(`Creating testNetworkTwo`);
// console.log(`Creating testNetworkTwo`);

await networkContract.connect(signer!).createNetwork(testNetworkTwo, {gasLimit: 500000});
// await networkContract.connect(signer!).createNetwork(testNetworkTwo, {gasLimit: 500000});


await sleep(2000);
// await sleep(2000);

// Network 3: identity.com
// - Create
// - Add defender relayer as gatekeeper + primary autority
// Gatekeeper claim primary authority
const defaultIdentityNetwork: IGatewayNetwork.GatekeeperNetworkDataStruct = {
primaryAuthority: await signer!.getAddress(),
name: testNetworkName,
passExpireDurationInSeconds: 2628000,
networkFeatureMask: 0,
networkFee: {
issueFee: 0,
refreshFee: 0,
expireFee: 0,
freezeFee: 0
},
supportedToken: ZERO_ADDRESS,
gatekeepers: [],
lastFeeUpdateTimestamp: 0
}
// // Network 3: identity.com
// // - Create
// // - Add defender relayer as gatekeeper + primary autority
// // Gatekeeper claim primary authority
// const defaultIdentityNetwork: IGatewayNetwork.GatekeeperNetworkDataStruct = {
// primaryAuthority: await signer!.getAddress(),
// name: testNetworkName,
// passExpireDurationInSeconds: 2628000,
// networkFeatureMask: 0,
// networkFee: {
// issueFee: 0,
// refreshFee: 0,
// expireFee: 0,
// freezeFee: 0
// },
// supportedToken: ZERO_ADDRESS,
// gatekeepers: [],
// lastFeeUpdateTimestamp: 0
// }

console.log(`Creating defaultIdentityNetwork`);
// console.log(`Creating defaultIdentityNetwork`);

await networkContract.connect(signer!).createNetwork(defaultIdentityNetwork, {gasLimit: 500000});
// await networkContract.connect(signer!).createNetwork(defaultIdentityNetwork, {gasLimit: 500000});

await sleep(2000);
}
Expand Down
18 changes: 8 additions & 10 deletions smart-contract/deploy/scripts/initalize-protocol.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { sleep, getDeploymentSigner } from "../defender-utils";
import hre , { ethers, upgrades } from "hardhat";
import { Signer } from '@ethersproject/abstract-signer/src.ts'
import { BNB_TESTNET_CONTRACT_ADDRESSES } from "../utils";
import { COMPLERE_TESTNET_CONTRACT_ADDRESSES } from "../utils";
import { ChargeHandler, Gatekeeper, GatewayNetwork, GatewayToken } from "../../typechain-types";

async function main() {
let signer: Signer;
if(process.env.SHOULD_USE_DEFENDER! == "true") {
signer = await getDeploymentSigner();
}

const gatewayNetworkContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;
const gatekeeperContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatekeeper;
const chargeHandlerContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.chargeHandler;
const gatewayTokenContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayToken;
const trustedForwarderContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.trustedForwarder;
signer = await getDeploymentSigner();

const gatewayNetworkContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;
const gatekeeperContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatekeeper;
const chargeHandlerContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.chargeHandler;
const gatewayTokenContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayToken;
const trustedForwarderContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.trustedForwarder;

/**
* Charge Handler
Expand Down
8 changes: 4 additions & 4 deletions smart-contract/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ export const COMPLERE_TESTNET_CONTRACT_ADDRESSES: GatewayProtocolContractAddress
export const DEFAULT_MNEMONIC =
"test test test test test test test test test test test junk";


// All addresses are default foundry addresses
export const deployerWallet = new Wallet("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
export const gatekeeperOneTestnetWallet = new Wallet("0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"); // 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
export const gatekeeperTwoTestnetWallet = new Wallet("0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"); // 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
export const userOneWallet = new Wallet("0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a"); // 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65

export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
export const testNetworkName = utils.formatBytes32String("Identity.com KYC Verification");
export const testNetworkName = utils.formatBytes32String("Identity-KYC-Verification");


export const testNetworkNameWithErc20Fees = "0x6e7574776f726b5f476974685f65726332305f66656573000000000000000000"; // gatekeeper 1
export const testNetworkNameWithNativeFees = "0x6e6574776f726b5f776974685f6e61746976655f666565730000000000000000"; // gatekeeper 2
export const testNetworkNameWithErc20Fees = "0x6e7574776f726b5f476974685f65726332305f66656573000000000000000000";
export const testNetworkNameWithNativeFees = "0x6e6574776f726b5f776974685f6e61746976655f666565730000000000000000";

export async function loadRelayerSigner(provider?: ethers.providers.Provider) {
const credentials = {apiKey: process.env.DEFENDER_RELAY_API_KEY!, apiSecret: process.env.DEFENDER_RELAY_SECRET!};
Expand Down

0 comments on commit 481d2c7

Please sign in to comment.