Skip to content

Commit b8a0c14

Browse files
committed
feat: make transaction logging optional
Signed-off-by: Tomás Migone <[email protected]>
1 parent ffa75d1 commit b8a0c14

File tree

12 files changed

+40
-11
lines changed

12 files changed

+40
-11
lines changed

packages/hardhat-graph-protocol/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# hardhat-graph-protocol
22

3+
## 0.1.13
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- @graphprotocol/toolshed@0.4.0
9+
310
## 0.1.12
411

512
### Patch Changes

packages/hardhat-graph-protocol/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hardhat-graph-protocol",
3-
"version": "0.1.12",
3+
"version": "0.1.13",
44
"publishConfig": {
55
"access": "public"
66
},

packages/horizon/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"hardhat": "^2.22.18",
5656
"hardhat-contract-sizer": "^2.10.0",
5757
"hardhat-gas-reporter": "^1.0.8",
58-
"hardhat-graph-protocol": "workspace:^0.1.12",
58+
"hardhat-graph-protocol": "workspace:^0.1.13",
5959
"hardhat-secure-accounts": "^1.0.5",
6060
"lint-staged": "^15.2.2",
6161
"prettier": "^3.2.5",

packages/subgraph-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"hardhat": "^2.22.18",
5757
"hardhat-contract-sizer": "^2.10.0",
5858
"hardhat-gas-reporter": "^1.0.8",
59-
"hardhat-graph-protocol": "workspace:^0.1.12",
59+
"hardhat-graph-protocol": "workspace:^0.1.13",
6060
"hardhat-secure-accounts": "^1.0.5",
6161
"json5": "^2.2.3",
6262
"lint-staged": "^15.2.2",

packages/toolshed/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @graphprotocol/toolshed
22

3+
## 0.4.0
4+
5+
### Minor Changes
6+
7+
- Make transaction logging optional, default to false for connect methods
8+
9+
### Patch Changes
10+
11+
- @graphprotocol/horizon@0.3.2
12+
- @graphprotocol/subgraph-service@0.3.4
13+
314
## 0.3.2
415

516
### Patch Changes

packages/toolshed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@graphprotocol/toolshed",
3-
"version": "0.3.2",
3+
"version": "0.4.0",
44
"publishConfig": {
55
"access": "public"
66
},

packages/toolshed/src/deployments/address-book.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,13 @@ export abstract class AddressBook<
175175
*
176176
* @param addressBook Address book to use
177177
* @param signerOrProvider Signer or provider to use
178+
* @param enableTxLogging Enable transaction logging to console and output file. Defaults to false.
178179
* @returns the loaded contracts
179180
*/
180181
_loadContracts(
181182
artifactsPath: string | string[] | Record<ContractName, string>,
182183
signerOrProvider?: Signer | Provider,
184+
enableTxLogging?: boolean,
183185
): ContractList<ContractName> {
184186
const contracts = {} as ContractList<ContractName>
185187
if (this.listEntries().length == 0) {
@@ -205,6 +207,7 @@ export abstract class AddressBook<
205207
this.getEntry(contractName).address,
206208
artifactPath,
207209
signerOrProvider,
210+
enableTxLogging,
208211
)
209212
contracts[contractName] = contract
210213
}

packages/toolshed/src/deployments/contract.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type ContractList<T extends string = string> = Partial<Record<T, unknown>
1010
* @param name Name of the contract
1111
* @param addressBook Address book to use
1212
* @param signerOrProvider Signer or provider to use
13-
* @param enableTxLogging Enable transaction logging to console and output file. Defaults to `true`
13+
* @param enableTxLogging Enable transaction logging to console and output file. Defaults to false.
1414
* @param optional If true, the contract is optional and will not throw if it cannot be loaded
1515
* @returns the loaded contract
1616
*
@@ -21,6 +21,7 @@ export function loadContract<ContractName extends string = string>(
2121
address: string,
2222
artifactsPath: string | string[],
2323
signerOrProvider?: Signer | Provider,
24+
enableTxLogging?: boolean,
2425
): Contract {
2526
try {
2627
let contract = new Contract(address, loadArtifact(name, artifactsPath).abi, signerOrProvider)
@@ -29,7 +30,9 @@ export function loadContract<ContractName extends string = string>(
2930
contract = contract.connect(signerOrProvider) as Contract
3031
}
3132

32-
contract = wrapTransactionCalls(contract, name)
33+
if (enableTxLogging) {
34+
contract = wrapTransactionCalls(contract, name)
35+
}
3336

3437
return contract
3538
} catch (err: unknown) {

packages/toolshed/src/deployments/horizon/address-book.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export class GraphHorizonAddressBook extends AddressBook<number, GraphHorizonCon
2121

2222
loadContracts(
2323
signerOrProvider?: Signer | Provider,
24+
enableTxLogging?: boolean,
2425
): GraphHorizonContracts {
2526
logDebug('Loading Graph Horizon contracts...')
2627

2728
const contracts = this._loadContracts(
2829
GraphHorizonArtifactsMap,
2930
signerOrProvider,
31+
enableTxLogging,
3032
)
3133

3234
// rewire HorizonStaking to include HorizonStakingExtension abi

packages/toolshed/src/deployments/horizon/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type { GraphHorizonContractName, GraphHorizonContracts } from './contract
2626

2727
export function loadGraphHorizon(addressBookPath: string, chainId: number, provider: HardhatEthersProvider) {
2828
const addressBook = new GraphHorizonAddressBook(addressBookPath, chainId)
29-
const contracts = addressBook.loadContracts(provider)
29+
const contracts = addressBook.loadContracts(provider, true)
3030
return {
3131
addressBook: addressBook,
3232
contracts: contracts,
@@ -39,5 +39,5 @@ export function connectGraphHorizon(chainId: number, signerOrProvider: Signer |
3939
addressBookPath ?? require.resolve('@graphprotocol/horizon/addresses.json'),
4040
chainId,
4141
)
42-
return addressBook.loadContracts(signerOrProvider)
42+
return addressBook.loadContracts(signerOrProvider, false)
4343
}

packages/toolshed/src/deployments/subgraph-service/address-book.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class SubgraphServiceAddressBook extends AddressBook<number, SubgraphServ
2020

2121
loadContracts(
2222
signerOrProvider?: Signer | Provider,
23+
enableTxLogging?: boolean,
2324
): SubgraphServiceContracts {
2425
logDebug('Loading Subgraph Service contracts...')
2526

@@ -29,6 +30,7 @@ export class SubgraphServiceAddressBook extends AddressBook<number, SubgraphServ
2930
const contracts = this._loadContracts(
3031
filteredArtifactsMap as typeof SubgraphServiceArtifactsMap,
3132
signerOrProvider,
33+
enableTxLogging,
3234
)
3335

3436
// Aliases

packages/toolshed/src/deployments/subgraph-service/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ export type { LegacyDisputeManager } from './types'
1010

1111
export function loadSubgraphService(addressBookPath: string, chainId: number, provider: HardhatEthersProvider) {
1212
const addressBook = new SubgraphServiceAddressBook(addressBookPath, chainId)
13+
const contracts = addressBook.loadContracts(provider, true)
1314
return {
1415
addressBook: addressBook,
15-
contracts: addressBook.loadContracts(provider),
16-
actions: loadActions(addressBook.loadContracts(provider)),
16+
contracts: contracts,
17+
actions: loadActions(contracts),
1718
}
1819
}
1920

@@ -22,5 +23,5 @@ export function connectSubgraphService(chainId: number, signerOrProvider: Signer
2223
addressBookPath ?? require.resolve('@graphprotocol/subgraph-service/addresses.json'),
2324
chainId,
2425
)
25-
return addressBook.loadContracts(signerOrProvider)
26+
return addressBook.loadContracts(signerOrProvider, false)
2627
}

0 commit comments

Comments
 (0)