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

feat: subgraph availability manager contract #882

Merged
merged 40 commits into from
Aug 21, 2024
Merged
Changes from 10 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ad358fb
feat: subgraph availability manager contract
Maikol Nov 16, 2023
77e8dc3
feat: vote denied many
Maikol Nov 20, 2023
1805cd9
fix: pr feedback changes
Maikol Nov 24, 2023
f4942f2
fix: use natspec for state variables comments
Maikol Nov 27, 2023
fa9b153
fix: use currentNonce to refresh votes, init oracles with valid addre…
Maikol Nov 27, 2023
08e269f
fix: update functions docs
Maikol Nov 28, 2023
35f6392
fix: removed unnecessary code in tests
Maikol Nov 28, 2023
0896337
fix: typo, comments and changed maxOracles to be a constant
Maikol Dec 8, 2023
ad4baec
fix: change constant variable name to match style guide
Maikol Dec 11, 2023
a67ad20
chore: deploy to staging
Maikol Dec 21, 2023
ddbcc86
fix: emit oracle set event on init
Maikol Dec 21, 2023
48ffb3a
Merge remote-tracking branch 'origin/main' into mde/sam-contract
Maikol Jan 9, 2024
26f1c7a
fix: change mapping for an array to make storage cheaper
Maikol Jan 9, 2024
eeeb314
fix: update comments
Maikol Jan 10, 2024
1ad7935
fix: make currentNonce public
Maikol Jan 10, 2024
fbdf6af
fix: added input validation for executionThreshold (OZ L-01)
Maikol Feb 1, 2024
94e6d05
docs: added missing docstrings for events (OZ L-03)
Maikol Feb 1, 2024
9f9db2e
fix: change OracleVote event order (OZ N-01)
Maikol Feb 1, 2024
f2aa2fa
fix: gas optimization (OZ N-02)
Maikol Feb 1, 2024
a52066c
fix: clear vote for earlier rounds (OZ L-02)
Maikol Feb 2, 2024
1ce46f0
fix: change to if/else
Maikol Feb 2, 2024
ef35364
fix: remove setDeniedMany since it's unused (OZ N-03)
Maikol Feb 2, 2024
9562b28
Merge pull request #935 from graphprotocol/mde/pr935-fix-oz-l-01
Maikol Feb 20, 2024
fa9d0cb
Merge pull request #936 from graphprotocol/mde/pr936-fix-oz-l-03
Maikol Feb 20, 2024
0c547c4
Merge pull request #937 from graphprotocol/mde/pr937-fix-oz-n-01
Maikol Feb 20, 2024
0698989
Merge pull request #938 from graphprotocol/mde/pr938-fix-oz-n-02
Maikol Feb 20, 2024
374e387
Merge pull request #939 from graphprotocol/mde/pr939-fix-oz-l-02
Maikol Feb 20, 2024
58463a8
Merge pull request #940 from graphprotocol/mde/pr400-fix-ox-n-03
Maikol Feb 20, 2024
06885f3
Merge branch 'main' into mde/sam-contract
Maikol Mar 13, 2024
bcf6957
fix: indentation
Maikol Mar 13, 2024
4c01fc4
chore: deploy to arbitrum-sepolia and remove sepolia
Maikol Mar 12, 2024
87bb02d
fix: remove debugging log
Maikol Mar 12, 2024
b24377e
fix: e2e tests
Maikol Mar 13, 2024
09271fd
fix: building error
Maikol Mar 13, 2024
6428bda
fix: update deployment
Maikol May 1, 2024
b45b21f
fix: new deployment
Maikol May 2, 2024
152521b
chore: testnet deployment
Maikol May 30, 2024
113fe69
fix: testnet deployment
Maikol May 30, 2024
19faf45
chore: deploy SAM to arbitrum-one
Maikol Jun 20, 2024
7fe43b8
Merge pull request #961 from graphprotocol/mde/sam-contract-deployments
Maikol Jun 21, 2024
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
38 changes: 19 additions & 19 deletions packages/contracts/addresses-staging.json
Original file line number Diff line number Diff line change
@@ -203,6 +203,25 @@
"runtimeCodeHash": "0xd853da2001c213dd00d674114c254f18a7b5a36aabc5452fb492b9b4faf2faa9",
"txHash": "0xf868871475dc711c5c03818b16a922f740bc2fc314d24586df2255161a907422"
}
},
"SubgraphAvailabilityManager": {
"address": "0xF00AA63f1a8eE67BAD135759eC7a6542b1d56a8f",
"constructorArgs": [
"0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3",
"0x00b9d319E3D09E83c62f453B44354049Dd93a345",
"3",
"300",
[
"0xb4d396a40BB976118Bb2c9DB9C5539e65c7Fe64A",
"0x633259dB4A33DB664d4C3Fa57BEc45E5030131E2",
"0x9FC436A69E290227b99A9CE0468a1b9D73068E80",
"0xC9b90ab0B9cA63fDBfB46f66BE813ea94561614d",
"0xf3B8F917EcFA569089CF6A0988F9a9F5155cEF83"
]
],
"creationCodeHash": "0xc34842fa42ee2f21e3a435b52fa69a122a5de795448faa890fbc63d4838f45da",
"runtimeCodeHash": "0xe6c0ccd0b0514dd55e58806b1c84f09805dd6202985722579c11d7e252df6b8d",
"txHash": "0x5c1dd91c76e547fe31a5df822353b50e93eb795b915aac0ea8f8364229e9c29c"
}
},
"11155111": {
@@ -424,25 +443,6 @@
"runtimeCodeHash": "0x3cb8a7336234c7826c8f5a437ad2c6615c2e4b4201096a49cb6876264ac47182",
"txHash": "0xf0765b7fe12702a7de3644bb1bcd6549bce1b8b738f2136e94bf39d10521b3e3"
}
},
"SubgraphAvailabilityManager": {
"address": "0x8fa39178Bdf76aca23635FF343BeeED7aA1D45ec",
"constructorArgs": [
"0x559081D91F5Ff43dfE51A07C216F8E6893805B35",
"0x9a86322dEa5136C74ee6d1b06F4Ab9A6bB2724E0",
"5",
"300",
[
"0x840daec5dF962D49cf2EFd789c4E40A7b7e0117D",
"0x840daec5dF962D49cf2EFd789c4E40A7b7e0117D",
"0x840daec5dF962D49cf2EFd789c4E40A7b7e0117D",
"0x840daec5dF962D49cf2EFd789c4E40A7b7e0117D",
"0x840daec5dF962D49cf2EFd789c4E40A7b7e0117D"
]
],
"creationCodeHash": "0x70ff001c11d5120782503f0d129f388d8800571f7e9dfbc81bbff048e3a58444",
"runtimeCodeHash": "0x237aca4c61c6d9b391322c0b24e2d26d9d540787507c6d30c474c86866b15dea",
"txHash": "0xf68af53d379c9ffbfa4794d5226fcd92e95bbce7017f5eefaacd147d0f5f40bc"
}
}
}
38 changes: 38 additions & 0 deletions packages/contracts/addresses.json
Original file line number Diff line number Diff line change
@@ -790,6 +790,25 @@
"creationCodeHash": "0xbfc20ab9b880712ab90b5dec9d2a14c724b0bf7c20f02ede8ea76610bd41b6ef",
"runtimeCodeHash": "0xd7fdd744c7a88993435a2978876b1e4341c5e0fb4d611011bb56e8738ab2485d",
"txHash": "0xcc449d1ca1007fba76b25e987ea0d39164acf4027c10c40bd669ede1c65dc569"
},
"SubgraphAvailabilityManager": {
"address": "0x1cB555359319A94280aCf85372Ac2323AaE2f5fd",
"constructorArgs": [
"0x8C6de8F8D562f3382417340A6994601eE08D3809",
"0x971B9d3d0Ae3ECa029CAB5eA1fB0F72c85e6a525",
"3",
"300",
[
"0xdcAA0a094F2Eb7cF7f73248EE64217D59B7B938d",
"0xBD9dc46cb1dd9F31dCbF0617c2Dd5f77A21dB8e8",
"0x16eAd4088d4308a7A4E0F7a1455ed56CDf1AC8AA",
"0x61923453906Eadc15fc1F610B8D1b67bc27658c2",
"0x10eb33C5E2fb6c7a37B110Cc4930d03A9e4C4D09"
]
],
"creationCodeHash": "0xc34842fa42ee2f21e3a435b52fa69a122a5de795448faa890fbc63d4838f45da",
"runtimeCodeHash": "0x52fcfd39c6ab3cf5ed4a736bc38eb1153d73c8cf1ca9e23370badc7843467ab4",
"txHash": "0x2eb44036d157e39c56377403029aebde4961028b404fc8c3f4cadc0f299d06dd"
}
},
"421613": {
@@ -1221,6 +1240,25 @@
"creationCodeHash": "0x20cd202f7991716a84c097da5fbd365fd27f7f35f241f82c529ad7aba18b814b",
"runtimeCodeHash": "0x5f396ffd54b6cd6b3faded0f366c5d7e148cc54743926061be2dfd12a75391de",
"txHash": "0x2cefbc169b8ae51c263d0298956d86a397b05f11f076b71c918551f63fe33784"
},
"SubgraphAvailabilityManager": {
"address": "0x71D9aE967d1f31fbbD1817150902de78f8f2f73E",
"constructorArgs": [
"0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3",
"0x1F49caE7669086c8ba53CC35d1E9f80176d67E79",
"3",
"300",
[
"0x5e4e823Ed094c035133eEC5Ec0d08ae1Af04e9Fa",
"0x5aeE4c46cF9260E85E630ca7d9D757D5D5DbaFD6",
"0x7369Cf2a917296c36f506144f3dE552403d1e1f1",
"0x1e1f84c07e0471fc979f6f08228b0bd34cda9e54",
"0x711aEA1f358DFAf74D34B4B525F9190e631F406C"
]
],
"creationCodeHash": "0xc34842fa42ee2f21e3a435b52fa69a122a5de795448faa890fbc63d4838f45da",
"runtimeCodeHash": "0x3907d0fe5a1fa28fee51100e57a3b193dfcee6720163067011e787262b1749bb",
"txHash": "0xb00751b4dc1c0603fe1b8b9ae9de8840ad1c29b42489c5bb267d80b10ae44ef0"
}
},
"11155111": {
16 changes: 9 additions & 7 deletions packages/contracts/config/graph.arbitrum-hardhat.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,12 @@ general:
arbitrator: &arbitrator "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0" # Arbitration Council
governor: &governor "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b" # Graph Council
authority: &authority "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d" # Authority that signs payment vouchers
availabilityOracle: &availabilityOracle "0xd03ea8624C8C5987235048901fB614fDcA89b117" # Subgraph Availability Oracle
availabilityOracles: &availabilityOracles # Subgraph Availability Oracles
- "0xd03ea8624C8C5987235048901fB614fDcA89b117"
- "0xd03ea8624C8C5987235048901fB614fDcA89b117"
- "0xd03ea8624C8C5987235048901fB614fDcA89b117"
- "0xd03ea8624C8C5987235048901fB614fDcA89b117"
- "0xd03ea8624C8C5987235048901fB614fDcA89b117"
pauseGuardian: &pauseGuardian "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC" # Protocol pause guardian
allocationExchangeOwner: &allocationExchangeOwner "0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9" # Allocation Exchange owner

@@ -131,7 +136,7 @@ contracts:
- fn: "setIssuancePerBlock"
issuancePerBlock: "114155251141552511415" # per block increase of total supply, blocks in a year = 365*60*60*24/12
- fn: "setSubgraphAvailabilityOracle"
subgraphAvailabilityOracle: *availabilityOracle
subgraphAvailabilityOracle: "${{SubgraphAvailabilityManager.address}}"
- fn: "syncAllContracts"
AllocationExchange:
init:
@@ -151,11 +156,8 @@ contracts:
pauseGuardian: *pauseGuardian
SubgraphAvailabilityManager:
init:
governor: "${{Env.deployer}}"
governor: *governor
rewardsManager: "${{RewardsManager.address}}"
executionThreshold: 5
voteTimeLimit: 300
oracles: [*availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle]
calls:
- fn: "transferOwnership"
owner: *governor
oracles: *availabilityOracles
16 changes: 9 additions & 7 deletions packages/contracts/config/graph.arbitrum-localhost.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,12 @@ general:
arbitrator: &arbitrator "0x4237154FE0510FdE3575656B60c68a01B9dCDdF8" # Arbitration Council
governor: &governor "0x1257227a2ECA34834940110f7B5e341A5143A2c4" # Graph Council
authority: &authority "0x12B8D08b116E1E3cc29eE9Cf42bB0AA8129C3215" # Authority that signs payment vouchers
availabilityOracle: &availabilityOracle "0x7694a48065f063a767a962610C6717c59F36b445" # Subgraph Availability Oracle
availabilityOracles: &availabilityOracles # Subgraph Availability Oracles
- "0x7694a48065f063a767a962610C6717c59F36b445"
- "0x7694a48065f063a767a962610C6717c59F36b445"
- "0x7694a48065f063a767a962610C6717c59F36b445"
- "0x7694a48065f063a767a962610C6717c59F36b445"
- "0x7694a48065f063a767a962610C6717c59F36b445"
pauseGuardian: &pauseGuardian "0x601060e0DC5349AA55EC73df5A58cB0FC1cD2e3C" # Protocol pause guardian
allocationExchangeOwner: &allocationExchangeOwner "0xbD38F7b67a591A5cc7D642e1026E5095B819d952" # Allocation Exchange owner

@@ -132,7 +137,7 @@ contracts:
- fn: "setIssuancePerBlock"
issuancePerBlock: "6036500000000000000" # per block increase of total supply, blocks in a year = 365*60*60*24/12
- fn: "setSubgraphAvailabilityOracle"
subgraphAvailabilityOracle: *availabilityOracle
subgraphAvailabilityOracle: "${{SubgraphAvailabilityManager.address}}"
- fn: "syncAllContracts"
AllocationExchange:
init:
@@ -152,11 +157,8 @@ contracts:
pauseGuardian: *pauseGuardian
SubgraphAvailabilityManager:
init:
governor: "${{Env.deployer}}"
governor: *governor
rewardsManager: "${{RewardsManager.address}}"
executionThreshold: 5
voteTimeLimit: 300
oracles: [*availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle]
calls:
- fn: "transferOwnership"
owner: *governor
oracles: *availabilityOracles
16 changes: 14 additions & 2 deletions packages/contracts/config/graph.arbitrum-sepolia.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,12 @@ general:
arbitrator: &arbitrator "0x1726A5d52e279d02ff4732eCeB2D67BFE5Add328" # EOA (TODO: update to a multisig)
governor: &governor "0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3" # EOA (TODO: update to a multisig)
authority: &authority "0x49D4CFC037430cA9355B422bAeA7E9391e1d3215" # Authority that signs payment vouchers
availabilityOracle: &availabilityOracle "0x5e4e823Ed094c035133eEC5Ec0d08ae1Af04e9Fa" # Subgraph Availability Oracle
availabilityOracles: &availabilityOracles # Array of Subgraph Availability Oracles
- "0x5e4e823Ed094c035133eEC5Ec0d08ae1Af04e9Fa"
- "0x5aeE4c46cF9260E85E630ca7d9D757D5D5DbaFD6"
- "0x7369Cf2a917296c36f506144f3dE552403d1e1f1"
- "0x1e1f84c07e0471fc979f6f08228b0bd34cda9e54"
- "0x711aEA1f358DFAf74D34B4B525F9190e631F406C"
pauseGuardian: &pauseGuardian "0xa0444508232dA3FA6C2f96a5f105f3f0cc0d20D7" # Protocol pause guardian
allocationExchangeOwner: &allocationExchangeOwner "0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3" # Allocation Exchange owner

@@ -131,7 +136,7 @@ contracts:
- fn: "setIssuancePerBlock"
issuancePerBlock: "6036500000000000000" # per block increase of total supply, blocks in a year = 365*60*60*24/12
- fn: "setSubgraphAvailabilityOracle"
subgraphAvailabilityOracle: *availabilityOracle
subgraphAvailabilityOracle: "${{SubgraphAvailabilityManager.address}}"
- fn: "syncAllContracts"
AllocationExchange:
init:
@@ -149,3 +154,10 @@ contracts:
- fn: "syncAllContracts"
- fn: "setPauseGuardian"
pauseGuardian: *pauseGuardian
SubgraphAvailabilityManager:
init:
governor: *governor
rewardsManager: "${{RewardsManager.address}}"
executionThreshold: 5
voteTimeLimit: 300
oracles: *availabilityOracles
10 changes: 0 additions & 10 deletions packages/contracts/config/graph.hardhat.yml
Original file line number Diff line number Diff line change
@@ -158,13 +158,3 @@ contracts:
controller: "${{Controller.address}}"
calls:
- fn: "syncAllContracts"
SubgraphAvailabilityManager:
init:
governor: "${{Env.deployer}}"
rewardsManager: "${{RewardsManager.address}}"
executionThreshold: 5
voteTimeLimit: 300
oracles: [*availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle]
calls:
- fn: "transferOwnership"
owner: *governor
10 changes: 0 additions & 10 deletions packages/contracts/config/graph.localhost.yml
Original file line number Diff line number Diff line change
@@ -159,13 +159,3 @@ contracts:
controller: "${{Controller.address}}"
calls:
- fn: "syncAllContracts"
SubgraphAvailabilityManager:
init:
governor: "${{Env.deployer}}"
rewardsManager: "${{RewardsManager.address}}"
executionThreshold: 5
voteTimeLimit: 300
oracles: [*availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle]
calls:
- fn: "transferOwnership"
owner: *governor
10 changes: 0 additions & 10 deletions packages/contracts/config/graph.sepolia.yml
Original file line number Diff line number Diff line change
@@ -159,13 +159,3 @@ contracts:
controller: "${{Controller.address}}"
calls:
- fn: "syncAllContracts"
SubgraphAvailabilityManager:
init:
governor: "${{Env.deployer}}"
rewardsManager: "${{RewardsManager.address}}"
executionThreshold: 5
voteTimeLimit: 300
oracles: [*availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle, *availabilityOracle]
calls:
- fn: "transferOwnership"
owner: *governor
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { isGraphL2ChainId } from '@graphprotocol/sdk'
import { NamedAccounts } from '@graphprotocol/sdk/gre'

describe('[L1] RewardsManager configuration', () => {
const graph = hre.graph()
const { RewardsManager } = graph.contracts

before(function () {
let namedAccounts: NamedAccounts

before(async function () {
if (isGraphL2ChainId(graph.chainId)) this.skip()
namedAccounts = await graph.getNamedAccounts()
})

it('issuancePerBlock should match "issuancePerBlock" in the config file', async function () {
const value = await RewardsManager.issuancePerBlock()
expect(value).eq('114693500000000000000') // hardcoded as it's set with a function call rather than init parameter
})

it('should allow subgraph availability oracle to deny rewards', async function () {
const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle()
expect(availabilityOracle).eq(namedAccounts.availabilityOracle.address)
})
})
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import hre from 'hardhat'

describe('[L2] RewardsManager configuration', () => {
const graph = hre.graph()
const { RewardsManager } = graph.contracts
const { RewardsManager, SubgraphAvailabilityManager } = graph.contracts

before(function () {
if (isGraphL1ChainId(graph.chainId)) this.skip()
@@ -14,4 +14,9 @@ describe('[L2] RewardsManager configuration', () => {
const value = await RewardsManager.issuancePerBlock()
expect(value).eq('6036500000000000000') // hardcoded as it's set with a function call rather than init parameter
})

it('should allow subgraph availability manager to deny rewards', async function () {
const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle()
expect(availabilityOracle).eq(SubgraphAvailabilityManager.address)
})
})
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
import { expect } from 'chai'
import hre from 'hardhat'
import { NamedAccounts } from '@graphprotocol/sdk/gre'

describe('RewardsManager configuration', () => {
const {
getNamedAccounts,
contracts: { RewardsManager, Controller },
} = hre.graph()

let namedAccounts: NamedAccounts

before(async () => {
namedAccounts = await getNamedAccounts()
})

it('should be controlled by Controller', async function () {
const controller = await RewardsManager.controller()
expect(controller).eq(Controller.address)
})

it('should allow subgraph availability oracle to deny rewards', async function () {
const availabilityOracle = await RewardsManager.subgraphAvailabilityOracle()
expect(availabilityOracle).eq(namedAccounts.availabilityOracle.address)
})
})
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ import { ethers } from 'hardhat'

import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'

import { SubgraphAvailabilityManager } from '../../build/types/SubgraphAvailabilityManager'
import { IRewardsManager } from '../../build/types/IRewardsManager'
import { SubgraphAvailabilityManager } from '../../../build/types/SubgraphAvailabilityManager'
import { IRewardsManager } from '../../../build/types/IRewardsManager'

import { NetworkFixture } from '../lib/fixtures'

@@ -64,7 +64,6 @@ describe('SubgraphAvailabilityManager', () => {
fixture = new NetworkFixture(graph.provider)
contracts = await fixture.load(governor)
rewardsManager = contracts.RewardsManager as IRewardsManager
console.log('Llega hasta aca?')
const deployResult = await deploy(DeployType.Deploy, governor, {
name: 'SubgraphAvailabilityManager',
args: [governor.address, rewardsManager.address, executionThreshold, voteTimeLimit, oracles],
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ export const GraphNetworkSharedContractNameList = [
'RewardsManager',
'DisputeManager',
'AllocationExchange',
'SubgraphAvailabilityManager',
] as const
export const GraphNetworkOptionalContractNameList = [
'IENS',
@@ -35,6 +34,7 @@ export const GraphNetworkL2ContractNameList = [
'L2GNS',
'L2Staking',
'L2GraphTokenGateway',
'SubgraphAvailabilityManager',
] as const

export const GraphNetworkContractNameList = [
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ import type {
L2GNS,
L2Curation,
StakingExtension,
SubgraphAvailabilityManager,
} from '@graphprotocol/contracts'
import { ContractList } from '../../../lib/types/contract'
import { loadArtifact } from '../../../lib/deploy/artifacts'
@@ -63,6 +64,7 @@ export interface GraphNetworkContracts extends ContractList<GraphNetworkContract
GraphCurationToken: GraphCurationToken
StakingExtension: StakingExtension
IENS?: IENS
SubgraphAvailabilityManager: SubgraphAvailabilityManager

// Only L1
L1GraphToken?: GraphToken
22 changes: 16 additions & 6 deletions packages/sdk/src/gre/accounts.ts
Original file line number Diff line number Diff line change
@@ -25,8 +25,15 @@ export async function getNamedAccounts(
const namedAccounts = namedAccountList.reduce(
async (accountsPromise, name) => {
const accounts = await accountsPromise
const address = getItemValue(readConfig(graphConfigPath, true), `general/${name}`)
accounts[name] = await SignerWithAddress.create(provider.getSigner(address))
let address
try {
address = getItemValue(readConfig(graphConfigPath, true), `general/${name}`)
} catch (e) {
// Skip if not found
}
if (address) {
accounts[name] = await SignerWithAddress.create(provider.getSigner(address))
}
return accounts
},
Promise.resolve({} as NamedAccounts),
@@ -46,10 +53,13 @@ export async function getTestAccounts(
): Promise<SignerWithAddress[]> {
// Get list of privileged accounts we don't want as test accounts
const namedAccounts = await getNamedAccounts(provider, graphConfigPath)
const blacklist = namedAccountList.map((a) => {
const account = namedAccounts[a]
return account.address
})
const blacklist = namedAccountList.reduce((accounts: string[], name) => {
const account = namedAccounts[name]
if (account) {
accounts.push(account.address)
}
return accounts
}, [])
blacklist.push((await getDeployer(provider)).address)

// Get signers and filter out blacklisted accounts