Skip to content

Commit

Permalink
Add complere testnet contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-H-Leonard committed Oct 9, 2024
1 parent 5d7c58c commit b3466b2
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 62 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
116 changes: 116 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,116 @@
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 { GatewayNetwork, GatewayToken, IGatewayNetwork } 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 gatewayTokenContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.gatewayToken;
const dummyERC20ContractAddress = BNB_TESTNET_CONTRACT_ADDRESSES.erc20;

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);
}


// 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;
});

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
12 changes: 12 additions & 0 deletions smart-contract/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ 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)
*/
Expand Down
56 changes: 8 additions & 48 deletions smart-contract/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,58 +32,13 @@ const derivedAccounts = {
count: 20,
};
const liveAccounts =
process.env.DEPLOYER_PRIVATE_KEY || process.env.PRIVATE_KEY
process.env.LOCAL_DEPLOY_PRIVATE_KEY || process.env.LOCAL_DEPLOY_PRIVATE_KEY
? [
`0x${process.env.DEPLOYER_PRIVATE_KEY || process.env.PRIVATE_KEY}`,
`0x${process.env.GATEKEEPER_PRIVATE_KEY || process.env.PRIVATE_KEY}`,
`0x${process.env.LOCAL_DEPLOY_PRIVATE_KEY || process.env.LOCAL_DEPLOY_PRIVATE_KEY}`,
`0x${process.env.LOCAL_DEPLOY_PRIVATE_KEY || process.env.LOCAL_DEPLOY_PRIVATE_KEY}`,
]
: [];

task('check-gt', 'check if a wallet has a gateway token for a particular gatekeeper network')
.addParam('address', 'The wallet to check')
.addParam('gatekeepernetwork', 'The gatekeeper network')
.setAction(checkGT);
task('create-gatekeeper-network', 'create a gatekeeper network')
.addParam('gatekeepernetwork', 'The gatekeeper network to create')
.addParam('gatekeeper', 'The gatekeeper to add')
.addParam('name', 'The name of the new gatekeeper network')
.setAction(createGatekeeperNetwork);
task('add-gatekeeper', 'add a gatekeeper to a network')
.addParam('gatekeeper', 'The gatekeeper to add')
.addParam('gatekeepernetwork', 'The gatekeeper network to add the gatekeeper to')
.setAction(addGatekeeper);
task('remove-gatekeeper', 'remove a gatekeeper from a network')
.addParam('gatekeeper', 'The gatekeeper to remove')
.addParam('gatekeepernetwork', 'The gatekeeper network to remove the gatekeeper from')
.setAction(removeGatekeeper);
task('issue-gt', 'issue a gateway token')
.addParam('gatekeepernetwork', 'The gatekeeper network to issue the token against')
.addParam('address', 'The wallet to issue the gateway token for')
.addFlag('forwarded', 'Forwards the transaction using an ERC2771 forwarder')
.setAction(issueGT);
task('fund', 'fund a wallet')
.addParam('from', 'The funder wallet')
.addParam('to', 'The wallet to fund')
.addParam('amount', 'The amount in eth to send')
.addFlag('dryrun', 'Do not actually send the transaction')
.setAction(fund);
task(
'print-private-key',
'Print the private key of a wallet used by hardhat (WARNING - DO NOT USE THIS FOR PRODUCTION KEYS)',
)
.addParam('index', 'the index of the wallet to get the private key for')
.setAction(printPrivateKey);
task('create-wallet', 'Create a test wallet').setAction(createWallet);
task('add-forwarder', 'add a forwarder to the gateway token smart contract (e.g. to support a relayer)')
.addParam('forwarder', 'The forwarder to add')
.setAction(addForwarder);
task('execute', 'sign and send a transaction')
.addParam('tx', 'the transaction to sign as a hex string')
.addParam('to', 'the recipient of the transaction')
.addParam('value', 'the amount to send with the transaction')
.setAction(execute);
task('get-balance', 'get the balance of the deployer').setAction(getBalance);

// Set the default contracts path to "contracts"
const defaultPath = './contracts';
const testContractsPath = './test/contracts';
Expand Down Expand Up @@ -121,6 +76,11 @@ module.exports = {
url: `${process.env.BNB_TESTNET_RPC_URL}`,
accounts: liveAccounts,
chainId: 97,
},
complereTestnet: {
url: `${process.env.BNB_TESTNET_RPC_URL}`,
accounts: liveAccounts,
chainId: 5918836757,
}
},
solidity: {
Expand Down

0 comments on commit b3466b2

Please sign in to comment.