Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update gif-next #43

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": ["anvil:7545"],
"forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
//"postCreateCommand": "sudo chown node node_modules && npm install",
Expand Down
2 changes: 1 addition & 1 deletion lib/gif-next
Submodule gif-next updated 81 files
+3 −4 contracts/distribution/DistributionService.sol
+10 −5 contracts/instance/IInstance.sol
+24 −8 contracts/instance/IInstanceService.sol
+59 −32 contracts/instance/Instance.sol
+2 −0 contracts/instance/InstanceReader.sol
+85 −8 contracts/instance/InstanceService.sol
+4 −16 contracts/instance/InstanceStore.sol
+11 −6 contracts/instance/base/BalanceStore.sol
+2 −25 contracts/instance/base/Cloneable.sol
+1 −3 contracts/instance/base/ObjectManager.sol
+5 −4 contracts/oracle/OracleService.sol
+19 −19 contracts/pool/BundleService.sol
+6 −7 contracts/pool/PoolService.sol
+5 −5 contracts/product/ApplicationService.sol
+5 −5 contracts/product/ClaimService.sol
+5 −5 contracts/product/PolicyService.sol
+4 −5 contracts/product/PricingService.sol
+5 −5 contracts/product/ProductService.sol
+35 −0 contracts/registry/IServiceAuthorization.sol
+6 −0 contracts/registry/Registry.sol
+244 −148 contracts/registry/RegistryAdmin.sol
+5 −5 contracts/registry/RegistryService.sol
+0 −5 contracts/registry/RegistryServiceManager.sol
+96 −169 contracts/registry/ReleaseManager.sol
+86 −0 contracts/registry/ServiceAuthorization.sol
+200 −0 contracts/registry/ServiceAuthorizationV3.sol
+0 −173 contracts/registry/ServiceAuthorizationsLib.sol
+759 −0 contracts/shared/AccessAdmin.sol
+6 −1 contracts/shared/AccessManagerCustom.sol
+12 −1 contracts/shared/AccessManagerExtended.sol
+4 −5 contracts/shared/ComponentService.sol
+168 −0 contracts/shared/IAccessAdmin.sol
+7 −0 contracts/shared/IService.sol
+27 −21 contracts/shared/Service.sol
+11 −7 contracts/staking/IStakingService.sol
+52 −0 contracts/staking/StakeManagerLib.sol
+58 −96 contracts/staking/Staking.sol
+61 −56 contracts/staking/StakingService.sol
+0 −1 contracts/staking/StakingServiceManager.sol
+79 −38 contracts/staking/StakingStore.sol
+135 −62 contracts/type/ObjectType.sol
+74 −19 contracts/type/RoleId.sol
+102 −0 contracts/type/Selector.sol
+53 −0 contracts/type/String.sol
+93 −516 package-lock.json
+1 −1 scripts/libs/instance.ts
+66 −35 scripts/libs/libraries.ts
+33 −2 scripts/libs/registry.ts
+1 −7 scripts/libs/release.ts
+60 −40 scripts/libs/services.ts
+23 −15 test/GifDeployer.t.sol
+37 −0 test/TestDeployAll.t.sol
+348 −1 test/base/GifDeployer.sol
+148 −236 test/base/GifTest.sol
+6 −4 test/component/distribution/Referral.t.sol
+13 −5 test/mock/AccessManagedMock.sol
+1 −1 test/mock/MockSizeService.sol
+2 −2 test/mock/RegistryServiceMock.sol
+30 −8 test/mock/ServiceMock.sol
+51 −7 test/registry/RegisterConcrete.t.sol
+10 −10 test/registry/RegisterContinuous.t.sol
+1 −1 test/registry/RegisterFuzz.t.sol
+13 −13 test/registry/RegisterServiceConcrete.t.sol
+29 −29 test/registry/RegisterServiceContinuous.t.sol
+1 −1 test/registry/RegisterServiceFuzz.t.sol
+17 −77 test/registry/RegistryTestBase.sol
+1 −1 test/registry/RegistryTestBaseWithPreset.sol
+70 −0 test/registry/ServiceMockAuthorizationV3.sol
+17 −17 test/registryService/GetAndVerifyContractInfo.t.sol
+2 −4 test/registryService/GetAndVerifyContractInfoFuzz.t.sol
+1 −1 test/registryService/RegisterService.t.sol
+39 −39 test/registryService/RegistryServiceHarnessTestBase.sol
+5 −53 test/registryService/RegistryServiceTestBase.sol
+12 −12 test/registryService/VerifyObjectInfo.t.sol
+1 −1 test/registryService/VerifyObjectInfoFuzz.t.sol
+1,408 −0 test/shared/AccessAdmin.t.sol
+469 −0 test/shared/AccessAdminManageMock.t.sol
+1 −3 test/staking/Staking.t.sol
+34 −52 test/staking/TargetManagement.t.sol
+4 −1 test/staking/TvlCalculation.t.sol
+48 −0 test/type/ObjectType.t.sol
26 changes: 20 additions & 6 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ async function main() {
const instanceAccessManagerAddress = await instance.getInstanceAccessManager();
const registryAddress = await instance.getRegistry();
const instanceAccessManager = AccessManagerExtendedInitializeable__factory.connect(instanceAccessManagerAddress, instanceOwner);
await executeTx(() => instanceAccessManager.grantRole(DISTRIBUTION_OWNER_ROLE, distributionOwner.address, 0));
console.log(`Distribution owner role granted to ${distributionOwner.address} at ${instanceAccessManagerAddress}`);
await executeTx(() => instanceAccessManager.grantRole(POOL_OWNER_ROLE, poolOwner.address, 0));
console.log(`Pool owner role granted to ${poolOwner.address} at ${instanceAccessManagerAddress}`);
await executeTx(() => instanceAccessManager.grantRole(PRODUCT_OWNER_ROLE, productOwner.address, 0));
console.log(`Product owner role granted to ${productOwner.address} at ${instanceAccessManagerAddress}`);
try {
await executeTx(() => instanceAccessManager.grantRole(DISTRIBUTION_OWNER_ROLE, distributionOwner.address, 0));
console.log(`Distribution owner role granted to ${distributionOwner.address} at ${instanceAccessManagerAddress}`);
await executeTx(() => instanceAccessManager.grantRole(POOL_OWNER_ROLE, poolOwner.address, 0));
console.log(`Pool owner role granted to ${poolOwner.address} at ${instanceAccessManagerAddress}`);
await executeTx(() => instanceAccessManager.grantRole(PRODUCT_OWNER_ROLE, productOwner.address, 0));
console.log(`Product owner role granted to ${productOwner.address} at ${instanceAccessManagerAddress}`);
} catch (error) {
const failure = instanceAccessManager.interface.parseError(error.data);
logger.error(failure?.name);
logger.error(failure?.args);
throw error;
}

const { address: usdcMockAddress } = await deployContract(
"UsdcMock",
Expand Down Expand Up @@ -63,6 +70,8 @@ async function main() {
poolAddress,
distributionAddress,
nftIdLibAddress!,
amountLibAddress!,
feeLibAddress!,
);

// workaround to get script to stop
Expand Down Expand Up @@ -179,6 +188,8 @@ async function deployAndRegisterProduct(
poolAddress: AddressLike,
distributionAddress: AddressLike,
nftIdLibAddress: AddressLike,
amountLibAddress: AddressLike,
feeLibAddress: AddressLike,
): Promise<{ product: Product, productNftId: bigint, productAddress: AddressLike }> {
const productName = "InsuranceProduct-" + Math.random().toString(16).substring(7);
const fee = {
Expand All @@ -202,6 +213,8 @@ async function deployAndRegisterProduct(
],
{
libraries: {
AmountLib: amountLibAddress,
FeeLib: feeLibAddress,
NftIdLib: nftIdLibAddress,
}
});
Expand All @@ -222,5 +235,6 @@ async function deployAndRegisterProduct(

main().catch((error) => {
logger.error(error.stack);
logger.error(error.data);
process.exit(1);
});
6 changes: 3 additions & 3 deletions scripts/libs/gif_constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const DISTRIBUTION_OWNER_ROLE = 2;
export const POOL_OWNER_ROLE = 4;
export const PRODUCT_OWNER_ROLE = 5;
export const DISTRIBUTION_OWNER_ROLE = 13;
export const POOL_OWNER_ROLE = 14;
export const PRODUCT_OWNER_ROLE = 11;

export const OBJECT_TYPE_PRODUCT = 110;
export const OBJECT_TYPE_DISTRIBUTION = 120;
Expand Down
16 changes: 11 additions & 5 deletions scripts/run_deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ async function main() {
const feeLibAddress = process.env.FEELIB_ADDRESS;
const nftIdLibAddress = process.env.NFTIDLIB_ADDRESS;
const referralLibAddress = process.env.REFERRALLIB_ADDRESS;
const riskIdLibAddress = process.env.RISKIDLIB_ADDRESS;
const roleIdLibAddress = process.env.ROLEIDLIB_ADDRESS;
const secondsLibAddress = process.env.SECONDSLIB_ADDRESS;
const ufixedLibAddress = process.env.UFIXEDLIB_ADDRESS;

const instanceNftId = process.env.INSTANCE_NFTID;
Expand Down Expand Up @@ -73,18 +75,22 @@ async function main() {
const { address: deployerAddress, contract: deployerContract } = await deployContract(
"Deployer",
distributionOwner,
// [],
[
registryAddress!,
instanceNftId,
distributionOwner,
"42"
],
{
"libraries": {
"AmountLib": amountLibAddress,
"FeeLib": feeLibAddress,
"DistributionDeployer": distributionLibAddress,
"PoolDeployer": poolLibAddress,
"ProductDeployer": productLibAddress
"ProductDeployer": productLibAddress,
"ReferralLib": referralLibAddress,
"RiskIdLib": riskIdLibAddress,
"RoleIdLib": roleIdLibAddress,
"SecondsLib": secondsLibAddress,
"UFixedLib": ufixedLibAddress,
}
});

Expand All @@ -98,11 +104,11 @@ async function main() {
const productNftId = await deployer.getProductNftId();
const usdcMockAddress = await deployer.getUsdc();

logger.info(`USDC mock deployed at ${usdcMockAddress}`);
logger.info(`Deployer deployed at ${deployerAddress}`);
logger.info(`Distribution deployed at ${distributionAddress} with NFT ID ${distributionNftId}`);
logger.info(`Pool deployed at ${poolAddress} with NFT ID ${poolNftId}`);
logger.info(`Product deployed at ${productAddress} with NFT ID ${productNftId}`);
logger.info(`USDC mock deployed at ${usdcMockAddress}`);

// workaround to get script to stop
process.exit(0);
Expand Down