Skip to content

Commit

Permalink
Merge branch 'main' into tmigone/sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
tmigone committed Dec 11, 2023
2 parents 0eb23c9 + a667f7a commit ca06ef3
Show file tree
Hide file tree
Showing 41 changed files with 794 additions and 701 deletions.
12 changes: 12 additions & 0 deletions addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -1533,6 +1533,12 @@
"runtimeCodeHash": "0x3a7fab6792b4dad58c7b59da19c5b65b3985d1be77024a9f86cb135965e9b462",
"txHash": "0x78ff2e39d5c33ddfb89b1dbee89bdbc24452843a051f860c94e4e9dd75ded9c3"
}
},
"EthereumDIDRegistry": {
"address": "0xF5f4cA61481558709AFa94AdEDa7B5F180f4AD59",
"creationCodeHash": "0x20cd202f7991716a84c097da5fbd365fd27f7f35f241f82c529ad7aba18b814b",
"runtimeCodeHash": "0x5f396ffd54b6cd6b3faded0f366c5d7e148cc54743926061be2dfd12a75391de",
"txHash": "0x2cefbc169b8ae51c263d0298956d86a397b05f11f076b71c918551f63fe33784"
}
},
"11155111": {
Expand Down Expand Up @@ -1754,6 +1760,12 @@
"runtimeCodeHash": "0x796b2cef94bab38e2cc4f82fef882d4c3441ef229329468d46fa72e1fd74be4a",
"txHash": "0xbadc145e826c54b4a4a0263701a29d6ecd11f8c6533c0d8e1cfe5422321d55f6"
}
},
"EthereumDIDRegistry": {
"address": "0xDe57D27e530c99bDa15Fe231B8C632E4a37E7343",
"creationCodeHash": "0x20cd202f7991716a84c097da5fbd365fd27f7f35f241f82c529ad7aba18b814b",
"runtimeCodeHash": "0x5f396ffd54b6cd6b3faded0f366c5d7e148cc54743926061be2dfd12a75391de",
"txHash": "0x8f3c9ae70242ed54c51a8f22c8d97f3ebc34cd65ccc4cc87054637b47610cf3a"
}
}
}
Binary file not shown.
8 changes: 4 additions & 4 deletions cli/commands/contracts/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export const setDelegationParameters = async (
const staking = cli.contracts.Staking

logger.info(`Setting the following delegation parameters for indexer ${cli.walletAddress}
indexingRewardCut = ${indexingRewardCut}
queryFeeCut = ${queryFeeCut}
cooldownBlocks = ${cooldownBlocks}
indexingRewardCut = ${indexingRewardCut}
queryFeeCut = ${queryFeeCut}
cooldownBlocks (deprecated) = ${cooldownBlocks}
`)
await sendTransaction(cli.wallet, staking, 'setDelegationParameters', [
indexingRewardCut,
Expand Down Expand Up @@ -305,7 +305,7 @@ export const stakingCommand = {
demandOption: true,
})
.option('cooldownBlocks', {
description: 'Period that need to pass to update delegation parameters',
description: 'Period that need to pass to update delegation parameters (deprecated)',
type: 'number',
})
},
Expand Down
4 changes: 0 additions & 4 deletions cli/commands/protocol/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ export const gettersList = {
'staking-thawing-period': { contract: 'Staking', name: 'thawingPeriod' },
'staking-max-allocation-epochs': { contract: 'Staking', name: 'maxAllocationEpochs' },
'staking-delegation-ratio': { contract: 'Staking', name: 'delegationRatio' },
'staking-delegation-parameters-cooldown': {
contract: 'Staking',
name: 'delegationParametersCooldown',
},
'staking-delegation-unbonding-period': { contract: 'Staking', name: 'delegationUnbondingPeriod' },
'protocol-percentage': { contract: 'Staking', name: 'protocolPercentage' },
// Curation
Expand Down
4 changes: 0 additions & 4 deletions cli/commands/protocol/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export const settersList = {
'staking-max-allocation-epochs': { contract: 'Staking', name: 'setMaxAllocationEpochs' },
'staking-protocol-percentage': { contract: 'Staking', name: 'setProtocolPercentage' },
'staking-delegation-parameters': { contract: 'Staking', name: 'setDelegationParameters' },
'staking-delegation-parameters-cooldown': {
contract: 'Staking',
name: 'setDelegationParametersCooldown',
},
'staking-delegation-unbonding-period': {
contract: 'Staking',
name: 'setDelegationUnbondingPeriod',
Expand Down
3 changes: 0 additions & 3 deletions config/graph.arbitrum-goerli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ contracts:
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
- fn: "syncAllContracts"
RewardsManager:
proxy: true
Expand Down
3 changes: 0 additions & 3 deletions config/graph.arbitrum-localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ contracts:
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
- fn: "syncAllContracts"
RewardsManager:
proxy: true
Expand Down
3 changes: 0 additions & 3 deletions config/graph.arbitrum-one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ contracts:
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
- fn: "syncAllContracts"
RewardsManager:
proxy: true
Expand Down
3 changes: 0 additions & 3 deletions config/graph.goerli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ contracts:
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
- fn: "syncAllContracts"
RewardsManager:
proxy: true
Expand Down
3 changes: 0 additions & 3 deletions config/graph.localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ contracts:
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
- fn: "syncAllContracts"
RewardsManager:
proxy: true
Expand Down
3 changes: 0 additions & 3 deletions config/graph.mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ contracts:
- fn: "setSlasher"
slasher: "${{DisputeManager.address}}"
allowed: true
- fn: "setAssetHolder"
assetHolder: "${{AllocationExchange.address}}"
allowed: true
- fn: "syncAllContracts"
RewardsManager:
proxy: true
Expand Down
118 changes: 48 additions & 70 deletions contracts/discovery/GNS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _subgraphID Subgraph ID
* @param _subgraphMetadata IPFS hash for the subgraph metadata
*/
function updateSubgraphMetadata(uint256 _subgraphID, bytes32 _subgraphMetadata)
external
override
onlySubgraphAuth(_subgraphID)
{
function updateSubgraphMetadata(
uint256 _subgraphID,
bytes32 _subgraphMetadata
) external override onlySubgraphAuth(_subgraphID) {
_setSubgraphMetadata(_subgraphID, _subgraphMetadata);
}

Expand All @@ -257,7 +256,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
uint256 subgraphID = _nextSubgraphID(subgraphOwner);
SubgraphData storage subgraphData = _getSubgraphData(subgraphID);
subgraphData.subgraphDeploymentID = _subgraphDeploymentID;
subgraphData.reserveRatioDeprecated = fixedReserveRatio;
subgraphData.__DEPRECATED_reserveRatio = fixedReserveRatio;

// Mint the NFT. Use the subgraphID as tokenID.
// This function will check the if tokenID already exists.
Expand Down Expand Up @@ -350,12 +349,9 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* Can only be done by the subgraph owner.
* @param _subgraphID Subgraph ID
*/
function deprecateSubgraph(uint256 _subgraphID)
external
override
notPaused
onlySubgraphAuth(_subgraphID)
{
function deprecateSubgraph(
uint256 _subgraphID
) external override notPaused onlySubgraphAuth(_subgraphID) {
// Subgraph check
SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID);

Expand All @@ -371,7 +367,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
// Deprecate the subgraph and do cleanup
subgraphData.disabled = true;
subgraphData.vSignal = 0;
subgraphData.reserveRatioDeprecated = 0;
subgraphData.__DEPRECATED_reserveRatio = 0;
// NOTE: We don't reset the following variable as we use it to test if the Subgraph was ever created
// subgraphData.subgraphDeploymentID = 0;

Expand Down Expand Up @@ -592,16 +588,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _tokensIn Tokens being exchanged for subgraph signal
* @return Amount of subgraph signal and curation tax
*/
function tokensToNSignal(uint256 _subgraphID, uint256 _tokensIn)
public
view
override
returns (
uint256,
uint256,
uint256
)
{
function tokensToNSignal(
uint256 _subgraphID,
uint256 _tokensIn
) public view override returns (uint256, uint256, uint256) {
SubgraphData storage subgraphData = _getSubgraphData(_subgraphID);
(uint256 vSignal, uint256 curationTax) = curation().tokensToSignal(
subgraphData.subgraphDeploymentID,
Expand All @@ -617,12 +607,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _nSignalIn Subgraph signal being exchanged for tokens
* @return Amount of tokens returned for an amount of subgraph signal
*/
function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn)
public
view
override
returns (uint256, uint256)
{
function nSignalToTokens(
uint256 _subgraphID,
uint256 _nSignalIn
) public view override returns (uint256, uint256) {
// Get subgraph or revert if not published
// It does not make sense to convert signal from a disabled or non-existing one
SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID);
Expand All @@ -637,12 +625,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _vSignalIn Amount of subgraph deployment signal to exchange for subgraph signal
* @return Amount of subgraph signal that can be bought
*/
function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn)
public
view
override
returns (uint256)
{
function vSignalToNSignal(
uint256 _subgraphID,
uint256 _vSignalIn
) public view override returns (uint256) {
SubgraphData storage subgraphData = _getSubgraphData(_subgraphID);

// Handle initialization by using 1:1 version to name signal
Expand All @@ -659,12 +645,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _nSignalIn Subgraph signal being exchanged for subgraph deployment signal
* @return Amount of subgraph deployment signal that can be returned
*/
function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn)
public
view
override
returns (uint256)
{
function nSignalToVSignal(
uint256 _subgraphID,
uint256 _nSignalIn
) public view override returns (uint256) {
SubgraphData storage subgraphData = _getSubgraphData(_subgraphID);
return subgraphData.vSignal.mul(_nSignalIn).div(subgraphData.nSignal);
}
Expand All @@ -675,12 +659,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _curator Curator address
* @return Amount of subgraph signal owned by a curator
*/
function getCuratorSignal(uint256 _subgraphID, address _curator)
public
view
override
returns (uint256)
{
function getCuratorSignal(
uint256 _subgraphID,
address _curator
) public view override returns (uint256) {
return _getSubgraphData(_subgraphID).curatorNSignal[_curator];
}

Expand All @@ -699,12 +681,9 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @return account Account that created the subgraph (or 0 if it's not a legacy subgraph)
* @return seqID Sequence number for the subgraph
*/
function getLegacySubgraphKey(uint256 _subgraphID)
public
view
override
returns (address account, uint256 seqID)
{
function getLegacySubgraphKey(
uint256 _subgraphID
) public view override returns (address account, uint256 seqID) {
LegacySubgraphKey storage legacySubgraphKey = legacySubgraphKeys[_subgraphID];
account = legacySubgraphKey.account;
seqID = legacySubgraphKey.accountSeqID;
Expand All @@ -731,8 +710,13 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
address _owner,
uint32 _curationTaxPercentage
) internal returns (uint256) {
// If curation or owner tax are zero, we don't need to charge owner tax
// so the amount of tokens to signal will remain the same.
// Note if owner tax is zero but curation tax is nonzero, the curation tax
// will still be charged (in Curation or L2Curation) - this function just calculates
// the owner's additional tax.
if (_curationTaxPercentage == 0 || ownerTaxPercentage == 0) {
return 0;
return _tokens;
}

// Tax on the total bonding curve funds
Expand Down Expand Up @@ -817,12 +801,9 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _subgraphID Subgraph ID
* @return Subgraph Data
*/
function _getSubgraphData(uint256 _subgraphID)
internal
view
virtual
returns (SubgraphData storage)
{
function _getSubgraphData(
uint256 _subgraphID
) internal view virtual returns (SubgraphData storage) {
// If there is a legacy subgraph created return it
LegacySubgraphKey storage legacySubgraphKey = legacySubgraphKeys[_subgraphID];
if (legacySubgraphKey.account != address(0)) {
Expand All @@ -846,11 +827,9 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* @param _subgraphID Subgraph ID
* @return Subgraph Data
*/
function _getSubgraphOrRevert(uint256 _subgraphID)
internal
view
returns (SubgraphData storage)
{
function _getSubgraphOrRevert(
uint256 _subgraphID
) internal view returns (SubgraphData storage) {
SubgraphData storage subgraphData = _getSubgraphData(_subgraphID);
require(_isPublished(subgraphData) == true, "GNS: Must be active");
return subgraphData;
Expand All @@ -862,11 +841,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall {
* Subgraph ID is the keccak hash of account+seqID
* @return Subgraph ID
*/
function _buildLegacySubgraphID(address _account, uint256 _seqID)
internal
pure
returns (uint256)
{
function _buildLegacySubgraphID(
address _account,
uint256 _seqID
) internal pure returns (uint256) {
return uint256(keccak256(abi.encodePacked(_account, _seqID)));
}

Expand Down
Loading

0 comments on commit ca06ef3

Please sign in to comment.