Skip to content

Commit

Permalink
Add complere testnet contracts + configuration scripts (#71)
Browse files Browse the repository at this point in the history
* Add complere testnet contracts

* configure new identity network on complere

* skip unused feature
  • Loading branch information
Robert-H-Leonard authored Oct 9, 2024
1 parent 5d7c58c commit 0c750b8
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 133 deletions.
4 changes: 3 additions & 1 deletion smart-contract/deploy/defender-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export async function getDeploymentSigner() {
if(shouldUseDefender) {
return await loadRelayerSigner();
} else {
return new ethers.Wallet(process.env.LOCAL_DEPLOY_PRIVATE_KEY!);
const provider = new ethers.providers.JsonRpcProvider(process.env.BNB_TESTNET_RPC_URL!);

return new ethers.Wallet(process.env.LOCAL_DEPLOY_PRIVATE_KEY!, provider);
}
}

Expand Down
12 changes: 6 additions & 6 deletions smart-contract/deploy/deploy-gatewaytoken.ts
Original file line number Diff line number Diff line change
@@ -1,16 +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 } from "./utils";
import { BNB_TESTNET_CONTRACT_ADDRESSES, COMPLERE_TESTNET_CONTRACT_ADDRESSES } from "./utils";

async function main() {
const signer: Signer = await getDeploymentSigner();

const gatewayNetworkContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;
const gatekeeperContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatekeeper;
const gatewayStakingContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayStaking;
const chargeHandlerContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.chargeHandler;
const flagsStorageContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.flagsStorage;
const gatewayNetworkContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;
const gatekeeperContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatekeeper;
const gatewayStakingContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayStaking;
const chargeHandlerContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.chargeHandler;
const flagsStorageContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.flagsStorage;
const superAdmin = process.env.BSC_TESTNET_RELAYER!;
const name = "Gateway Token";
const symbol = "GWTK";
Expand Down
6 changes: 3 additions & 3 deletions smart-contract/deploy/gatewaynetwork.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { addContractToAdmin, sleep, verify, getDeploymentSigner } from "./defender-utils";
import { Signer } from '@ethersproject/abstract-signer/src.ts'
import { ethers, upgrades } from 'hardhat';
import { BNB_TESTNET_CONTRACT_ADDRESSES } from "./utils";
import { BNB_TESTNET_CONTRACT_ADDRESSES, COMPLERE_TESTNET_CONTRACT_ADDRESSES } from "./utils";


async function main() {
const testnetGatekeeperContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatekeeper;
const testnetStakingContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayStaking;
const testnetGatekeeperContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatekeeper;
const testnetStakingContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayStaking;

const signer: Signer = await getDeploymentSigner();
const signerAddress = await signer.getAddress();
Expand Down
4 changes: 2 additions & 2 deletions smart-contract/deploy/gatewaystaking.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { addContractToAdmin, getDeploymentSigner, sleep, verify } from "./defender-utils";
import { ethers , upgrades } from 'hardhat';
import { Signer } from '@ethersproject/abstract-signer/src.ts'
import { BNB_TESTNET_CONTRACT_ADDRESSES } from "./utils";
import { BNB_TESTNET_CONTRACT_ADDRESSES, COMPLERE_TESTNET_CONTRACT_ADDRESSES } from "./utils";

async function main() {
const testnetTokenContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.erc20;
const testnetTokenContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.erc20;

const args = [testnetTokenContractAddress , 'Identity Test Staking Vault', "ID_TEST_STAKE"];

Expand Down
27 changes: 27 additions & 0 deletions smart-contract/deploy/scripts/add-gatekeeper-to-default-network.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { sleep, getDeploymentSigner } from "../defender-utils";
import hre , { ethers, upgrades } from "hardhat";
import { Signer } from '@ethersproject/abstract-signer/src.ts'
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;
signer = await getDeploymentSigner();

const gatewayNetworkContractAddress = COMPLERE_TESTNET_CONTRACT_ADDRESSES.gatewayNetwork;

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


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


// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

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
4 changes: 2 additions & 2 deletions smart-contract/deploy/test-erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function main() {
const signer: Signer = await getDeploymentSigner();

const DummyERC20ContractFactory = await ethers.getContractFactory("DummyERC20", signer!);
const dummyERC20Contract = await DummyERC20ContractFactory.deploy(args);
const dummyERC20Contract = await DummyERC20ContractFactory.deploy(...args);

await dummyERC20Contract.deployed();
const deployedAddress = dummyERC20Contract.address;
Expand All @@ -19,7 +19,7 @@ async function main() {

await sleep(6000);

await verify(deployedAddress,[]);
await verify(deployedAddress,args);

// Need to wait to avoid rate limit
await sleep(2000);
Expand Down
20 changes: 16 additions & 4 deletions smart-contract/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,37 @@ export const BNB_TESTNET_CONTRACT_ADDRESSES: GatewayProtocolContractAddresses =
trustedForwarder: "0x96b905ff1edfadaec03879450f3dc35a8124dc05"
}

export const COMPLERE_TESTNET_CONTRACT_ADDRESSES: GatewayProtocolContractAddresses = {
flagsStorage: "0x35df92b2dFc8C606a1D2FAfE26e6B66182Ef5822",
gatekeeper: "0x222Ba251eD01B60144ca220bEB9Ed17ED98e3AAe",
gatewayNetwork: "0xf4F929E10dD465aF803EC0fa70dA5898129392F3",
chargeHandler: "0x412338eABdB8c88F1d83E91DBc2d289fC18b4Deb",
gatewayStaking: "0x6B231070318e4a0B2047402336Df78C0b2721102",
erc20: "0xE331C1096e9317bF76E5B8815E6ac7487099c763",
gatewayToken: "0x8252B797EA14F0006818FaefA6b3dCFefa39eaEd",
forwarder: "0x567b21dCFacf0Ba2bfCF6B059833a083b7cDf6d1",
trustedForwarder: "0x567b21dCFacf0Ba2bfCF6B059833a083b7cDf6d1"
}

/**
* Testnet wallets (foundry defaults)
*/

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
Loading

0 comments on commit 0c750b8

Please sign in to comment.