Skip to content

Commit 48ffb3a

Browse files
committed
Merge remote-tracking branch 'origin/main' into mde/sam-contract
2 parents ddbcc86 + bd2f487 commit 48ffb3a

File tree

22 files changed

+257
-354
lines changed

22 files changed

+257
-354
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
pushd packages/${{ inputs.package }}
3232
yarn npm publish --tag ${{ inputs.tag }} --access public
3333
env:
34-
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34+
YARN_NPM_AUTH_TOKEN: ${{ secrets.GRAPHPROTOCOL_NPM_TOKEN }}

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ yarn-error.log*
66
node_modules/
77

88
# Yarn
9-
.yarn/*
9+
.yarn/
1010
!.yarn/patches
1111
!.yarn/releases
1212
!.yarn/plugins
@@ -31,7 +31,7 @@ bin/
3131
.vscode
3232

3333
# Coverage and other reports
34-
/reports
34+
reports/
3535
coverage.json
3636

3737
# Local test files
@@ -42,4 +42,4 @@ tx-*.log
4242
addresses-fork.json
4343

4444
# Keys
45-
.keystore
45+
.keystore

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"scripts": {
1414
"postinstall": "husky install",
1515
"clean": "yarn workspaces foreach --all --parallel --verbose run clean",
16+
"clean:all": "yarn clean && rm -rf node_modules packages/*/node_modules",
1617
"build": "yarn workspaces foreach --all --verbose run build",
1718
"lint": "yarn workspaces foreach --all --parallel --verbose run lint",
1819
"test": "yarn workspaces foreach --all --parallel --verbose --interlaced run test"

packages/contracts/addresses.json

Lines changed: 0 additions & 319 deletions
Large diffs are not rendered by default.

packages/contracts/cli/commands/protocol/configure-bridge.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ export const configureL1Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
1515
const l2AddressBook = getAddressBook(cliArgs.addressBook, l2ChainId)
1616
const arbAddressBook = getAddressBook(cliArgs.arbAddressBook, cli.chainId.toString())
1717

18+
// Gateway
1819
const gateway = cli.contracts['L1GraphTokenGateway']
1920

2021
const l2GRT = l2AddressBook.getEntry('L2GraphToken')
2122
logger.info('L2 GRT address: ' + l2GRT.address)
2223
await sendTransaction(cli.wallet, gateway, 'setL2TokenAddress', [l2GRT.address])
2324

24-
const l2Counterpart = l2AddressBook.getEntry('L2GraphTokenGateway')
25-
logger.info('L2 Gateway address: ' + l2Counterpart.address)
26-
await sendTransaction(cli.wallet, gateway, 'setL2CounterpartAddress', [l2Counterpart.address])
25+
const l2GatewayCounterpart = l2AddressBook.getEntry('L2GraphTokenGateway')
26+
logger.info('L2 Gateway address: ' + l2GatewayCounterpart.address)
27+
await sendTransaction(cli.wallet, gateway, 'setL2CounterpartAddress', [
28+
l2GatewayCounterpart.address,
29+
])
2730

31+
// Escrow
2832
const bridgeEscrow = cli.contracts.BridgeEscrow
2933
logger.info('Escrow address: ' + bridgeEscrow.address)
3034
await sendTransaction(cli.wallet, gateway, 'setEscrowAddress', [bridgeEscrow.address])
@@ -39,6 +43,22 @@ export const configureL1Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
3943
l1Inbox.address,
4044
l1Router.address,
4145
])
46+
47+
// GNS
48+
const gns = cli.contracts.L1GNS
49+
const l2GNSCounterpart = l2AddressBook.getEntry('L2GNS')
50+
logger.info('L2 GNS address: ' + l2GNSCounterpart.address)
51+
await sendTransaction(cli.wallet, gns, 'setCounterpartGNSAddress', [l2GNSCounterpart.address])
52+
await sendTransaction(cli.wallet, gateway, 'addToCallhookAllowlist', [gns.address])
53+
54+
// Staking
55+
const staking = cli.contracts.L1Staking
56+
const l2StakingCounterpart = l2AddressBook.getEntry('L2Staking')
57+
logger.info('L2 Staking address: ' + l2StakingCounterpart.address)
58+
await sendTransaction(cli.wallet, staking, 'setCounterpartStakingAddress', [
59+
l2StakingCounterpart.address,
60+
])
61+
await sendTransaction(cli.wallet, gateway, 'addToCallhookAllowlist', [staking.address])
4262
}
4363

4464
export const configureL2Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
@@ -52,6 +72,7 @@ export const configureL2Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
5272
const l1AddressBook = getAddressBook(cliArgs.addressBook, l1ChainId)
5373
const arbAddressBook = getAddressBook(cliArgs.arbAddressBook, cli.chainId.toString())
5474

75+
// Gateway
5576
const gateway = cli.contracts['L2GraphTokenGateway']
5677
const token = cli.contracts['L2GraphToken']
5778

@@ -70,6 +91,20 @@ export const configureL2Bridge = async (cli: CLIEnvironment, cliArgs: CLIArgs):
7091

7192
logger.info('L2 Gateway address: ' + gateway.address)
7293
await sendTransaction(cli.wallet, token, 'setGateway', [gateway.address])
94+
95+
// GNS
96+
const gns = cli.contracts.L2GNS
97+
const l1GNSCounterpart = l1AddressBook.getEntry('L1GNS')
98+
logger.info('L1 GNS address: ' + l1GNSCounterpart.address)
99+
await sendTransaction(cli.wallet, gns, 'setCounterpartGNSAddress', [l1GNSCounterpart.address])
100+
101+
// Staking
102+
const staking = cli.contracts.L2Staking
103+
const l1StakingCounterpart = l1AddressBook.getEntry('L1Staking')
104+
logger.info('L1 Staking address: ' + l1StakingCounterpart.address)
105+
await sendTransaction(cli.wallet, staking, 'setCounterpartStakingAddress', [
106+
l1StakingCounterpart.address,
107+
])
73108
}
74109

75110
export const configureL1BridgeCommand = {

packages/contracts/cli/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Overrides } from 'ethers'
44
export const local = {
55
mnemonic: 'myth like bonus scare over problem client lizard pioneer submit female collect',
66
providerUrl: 'http://localhost:8545',
7-
addressBookPath: './addresses.json',
7+
addressBookPath: './addresses-local.json',
88
graphConfigPath: './config/graph.mainnet.yml',
99
accountNumber: '0',
1010
arbitrumAddressBookPath: './arbitrum-addresses.json',

packages/contracts/e2e/deployment/config/l1/graphToken.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isGraphChainId } from '@graphprotocol/sdk'
1+
import { isGraphL2ChainId } from '@graphprotocol/sdk'
22
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
33
import { expect } from 'chai'
44
import hre from 'hardhat'
@@ -10,7 +10,7 @@ describe('[L1] GraphToken', () => {
1010
let unauthorized: SignerWithAddress
1111

1212
before(async function () {
13-
if (isGraphChainId(graph.chainId)) this.skip()
13+
if (isGraphL2ChainId(graph.chainId)) this.skip()
1414
unauthorized = (await graph.getTestAccounts())[0]
1515
})
1616

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { expect } from 'chai'
3+
import hre from 'hardhat'
4+
import { isGraphL2ChainId } from '@graphprotocol/sdk'
5+
6+
describe('[L1] GNS', () => {
7+
const graph = hre.graph()
8+
const { L1GNS, L1GraphTokenGateway } = graph.contracts
9+
10+
let unauthorized: SignerWithAddress
11+
12+
before(async function () {
13+
if (isGraphL2ChainId(graph.chainId)) this.skip()
14+
unauthorized = (await graph.getTestAccounts())[0]
15+
})
16+
17+
describe('L1GNS', () => {
18+
it('counterpartGNSAddress should match the L2GNS address', async () => {
19+
const l2GNS = await L1GNS.counterpartGNSAddress()
20+
expect(l2GNS).eq(graph.l2.contracts.L2GNS.address)
21+
})
22+
23+
it('should be added to callhookAllowlist', async () => {
24+
const isAllowed = await L1GraphTokenGateway.callhookAllowlist(L1GNS.address)
25+
expect(isAllowed).true
26+
})
27+
})
28+
})
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { expect } from 'chai'
3+
import hre from 'hardhat'
4+
import { isGraphL2ChainId } from '@graphprotocol/sdk'
5+
6+
describe('[L1] Staking', () => {
7+
const graph = hre.graph()
8+
const { L1Staking, L1GraphTokenGateway } = graph.contracts
9+
10+
let unauthorized: SignerWithAddress
11+
12+
before(async function () {
13+
if (isGraphL2ChainId(graph.chainId)) this.skip()
14+
unauthorized = (await graph.getTestAccounts())[0]
15+
})
16+
17+
describe('L1Staking', () => {
18+
it('counterpartStakingAddress should match the L2Staking address', async () => {
19+
// counterpartStakingAddress is internal so we access the storage directly
20+
const l2StakingData = await hre.ethers.provider.getStorageAt(L1Staking.address, 24)
21+
const l2Staking = hre.ethers.utils.defaultAbiCoder.decode(['address'], l2StakingData)[0]
22+
expect(l2Staking).eq(graph.l2.contracts.L2Staking.address)
23+
})
24+
25+
it('should be added to callhookAllowlist', async () => {
26+
const isAllowed = await L1GraphTokenGateway.callhookAllowlist(L1Staking.address)
27+
expect(isAllowed).true
28+
})
29+
})
30+
})
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
2+
import { expect } from 'chai'
3+
import hre from 'hardhat'
4+
import { isGraphL1ChainId } from '@graphprotocol/sdk'
5+
6+
describe('[L2] GNS', () => {
7+
const graph = hre.graph()
8+
const { L2GNS } = graph.l2.contracts
9+
10+
let unauthorized: SignerWithAddress
11+
12+
before(async function () {
13+
if (isGraphL1ChainId(graph.chainId)) this.skip()
14+
unauthorized = (await graph.getTestAccounts())[0]
15+
})
16+
17+
describe('L2GNS', () => {
18+
it('counterpartGNSAddress should match the L1GNS address', async () => {
19+
const l1GNS = await L2GNS.counterpartGNSAddress()
20+
expect(l1GNS).eq(graph.l1.contracts.L1GNS.address)
21+
})
22+
})
23+
})

0 commit comments

Comments
 (0)