Skip to content

Commit 6fae983

Browse files
authored
Change logger to Winston (#470)
1 parent 72f7bb6 commit 6fae983

31 files changed

+1089
-906
lines changed

cli/commands/airdrop.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const sure = async (message = 'Are you sure?'): Promise<boolean> => {
7474
message,
7575
})
7676
if (!res.confirm) {
77-
logger.success('Cancelled')
77+
logger.info('Cancelled')
7878
return false
7979
}
8080
return true
@@ -98,7 +98,7 @@ const loadRecipients = (path: string): Array<AirdropRecipient> => {
9898
// Test for zero amount and fail
9999
const weiAmount = parseGRT(amount)
100100
if (weiAmount.eq(0)) {
101-
logger.fatal(`Error loading address "${address}" - amount is zero`)
101+
logger.crit(`Error loading address "${address}" - amount is zero`)
102102
process.exit(0)
103103
}
104104

@@ -107,7 +107,7 @@ const loadRecipients = (path: string): Array<AirdropRecipient> => {
107107
getAddress(address)
108108
} catch (err) {
109109
// Full stop on error
110-
logger.fatal(`Error loading address "${address}" please review the input file`)
110+
logger.crit(`Error loading address "${address}" please review the input file`)
111111
process.exit(1)
112112
}
113113
results.push({ address, amount: weiAmount, txHash })
@@ -172,28 +172,28 @@ export const airdrop = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
172172
const totalAmount = sumTotalAmount(recipients)
173173

174174
// Summary
175-
logger.log(`# Batch Size: ${cliArgs.batchSize}`)
176-
logger.log(`# Concurrency: ${cliArgs.concurrency}`)
177-
logger.log(`> Token: ${graphToken.address}`)
178-
logger.log(`> Distributing: ${formatGRT(totalAmount)} tokens (${totalAmount} wei)`)
179-
logger.log(`> Resumelist: ${resumeList.length} addresses`)
180-
logger.log(`> Recipients: ${recipients.length} addresses\n`)
175+
logger.info(`# Batch Size: ${cliArgs.batchSize}`)
176+
logger.info(`# Concurrency: ${cliArgs.concurrency}`)
177+
logger.info(`> Token: ${graphToken.address}`)
178+
logger.info(`> Distributing: ${formatGRT(totalAmount)} tokens (${totalAmount} wei)`)
179+
logger.info(`> Resumelist: ${resumeList.length} addresses`)
180+
logger.info(`> Recipients: ${recipients.length} addresses\n`)
181181

182182
// Validity check
183183
if (totalAmount.eq(0)) {
184-
logger.fatal('Cannot proceed with a distribution of zero tokens')
184+
logger.crit('Cannot proceed with a distribution of zero tokens')
185185
process.exit(1)
186186
}
187187

188188
// Load airdrop contract
189189
const disperseContract = getDisperseContract(cli.chainId, cli.wallet.provider)
190190
if (!disperseContract.address) {
191-
logger.fatal('Disperse contract not found. Please review your network settings.')
191+
logger.crit('Disperse contract not found. Please review your network settings.')
192192
process.exit(1)
193193
}
194194

195195
// Confirmation
196-
logger.log('Are you sure you want to proceed with the distribution?')
196+
logger.info('Are you sure you want to proceed with the distribution?')
197197
if (!(await sure())) {
198198
process.exit(1)
199199
}
@@ -204,9 +204,9 @@ export const airdrop = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
204204
await graphToken.functions['allowance'](cli.wallet.address, disperseContract.address)
205205
)[0]
206206
if (allowance.gte(totalAmount)) {
207-
logger.log('Already have enough allowance, no need to approve more...')
207+
logger.info('Already have enough allowance, no need to approve more...')
208208
} else {
209-
logger.log(
209+
logger.info(
210210
`Approve disperse:${disperseContract.address} for ${formatGRT(
211211
totalAmount,
212212
)} tokens (${totalAmount} wei)`,
@@ -234,7 +234,7 @@ export const airdrop = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
234234
batchNum++
235235
logger.info(`Sending batch #${batchNum} : ${recipientsCount}/${recipients.length}`)
236236
for (const recipient of batch) {
237-
logger.log(
237+
logger.info(
238238
` > Transferring ${recipient.address} => ${formatGRT(recipient.amount)} (${
239239
recipient.amount
240240
} wei)`,

cli/commands/contracts/any.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export const any = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void>
1313
const attachedContract = getContractAt(contract, addressEntry.address).connect(cli.wallet)
1414

1515
if (cliArgs.type == 'get') {
16-
logger.log(`Getting ${func}...`)
16+
logger.info(`Getting ${func}...`)
1717
const contractFn: ContractFunction = attachedContract.functions[func]
1818
const value = await contractFn(...params)
19-
logger.success(`${func} = ${value}`)
19+
logger.info(`${func} = ${value}`)
2020
} else if (cliArgs.type == 'set') {
21-
logger.log(`Setting ${func}...`)
21+
logger.info(`Setting ${func}...`)
2222
await sendTransaction(cli.wallet, attachedContract, func, params)
2323
}
2424
}

cli/commands/contracts/curation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export const mint = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void>
1212
const curation = cli.contracts.Curation
1313
const graphToken = cli.contracts.GraphToken
1414

15-
logger.log('First calling approve() to ensure curation contract can call transferFrom()...')
15+
logger.info('First calling approve() to ensure curation contract can call transferFrom()...')
1616
await sendTransaction(cli.wallet, graphToken, 'approve', [curation.address, amount])
17-
logger.log(`Signaling on ${subgraphID} with ${cliArgs.amount} tokens...`)
17+
logger.info(`Signaling on ${subgraphID} with ${cliArgs.amount} tokens...`)
1818
await sendTransaction(cli.wallet, curation, 'mint', [subgraphID, amount, 0], {
1919
gasLimit: 2000000,
2020
})
@@ -24,7 +24,7 @@ export const burn = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void>
2424
const amount = parseGRT(cliArgs.amount)
2525
const curation = cli.contracts.Curation
2626

27-
logger.log(`Burning signal on ${subgraphID} with ${cliArgs.amount} tokens...`)
27+
logger.info(`Burning signal on ${subgraphID} with ${cliArgs.amount} tokens...`)
2828
await sendTransaction(cli.wallet, curation, 'burn', [subgraphID, amount, 0])
2929
}
3030

cli/commands/contracts/disputeManager.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ async function setupIndexer(
5858
const indexerAllocatedTokens = toGRT('10000')
5959
const metadata = HashZero
6060

61-
logger.log('Transferring tokens to the indexer...')
61+
logger.info('Transferring tokens to the indexer...')
6262
await sendTransaction(cli.wallet, grt, 'transfer', [indexer.address, indexerTokens])
63-
logger.log('Approving the staking address to pull tokens...')
63+
logger.info('Approving the staking address to pull tokens...')
6464
await sendTransaction(cli.wallet, grt, 'approve', [staking.address, indexerTokens])
65-
logger.log('Staking...')
65+
logger.info('Staking...')
6666
await sendTransaction(cli.wallet, staking, 'stake', [indexerTokens])
67-
logger.log('Allocating...')
67+
logger.info('Allocating...')
6868
await sendTransaction(cli.wallet, staking, 'allocate', [
6969
receipt.subgraphDeploymentID,
7070
indexerAllocatedTokens,
@@ -109,7 +109,7 @@ export const createTestQueryDisputeConflict = async (
109109
disputeManagerAddr,
110110
)
111111

112-
logger.log(`Creating conflicting attestations...`)
112+
logger.info(`Creating conflicting attestations...`)
113113
await sendTransaction(cli.wallet, disputeManager, 'createQueryDisputeConflict', [
114114
encodeAttestation(attestation1),
115115
encodeAttestation(attestation2),
@@ -138,10 +138,10 @@ export const createTestIndexingDispute = async (
138138
const disputeManager = cli.contracts.DisputeManager
139139
const grt = cli.contracts.GraphToken
140140

141-
logger.log('Approving the dispute address to pull tokens...')
141+
logger.info('Approving the dispute address to pull tokens...')
142142
await sendTransaction(cli.wallet, grt, 'approve', [disputeManager.address, deposit])
143143

144-
logger.log(`Creating indexing dispute...`)
144+
logger.info(`Creating indexing dispute...`)
145145
await sendTransaction(cli.wallet, disputeManager, 'createIndexingDispute', [
146146
indexerChannelKey.address,
147147
deposit,
@@ -151,21 +151,21 @@ export const createTestIndexingDispute = async (
151151
export const accept = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
152152
const disputeManager = cli.contracts.DisputeManager
153153
const disputeID = cliArgs.disputeID
154-
logger.log(`Accepting...`)
154+
logger.info(`Accepting...`)
155155
await sendTransaction(cli.wallet, disputeManager, 'acceptDispute', ...[disputeID])
156156
}
157157

158158
export const reject = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
159159
const disputeManager = cli.contracts.DisputeManager
160160
const disputeID = cliArgs.disputeID
161-
logger.log(`Rejecting...`)
161+
logger.info(`Rejecting...`)
162162
await sendTransaction(cli.wallet, disputeManager, 'rejectDispute', ...[disputeID])
163163
}
164164

165165
export const draw = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
166166
const disputeManager = cli.contracts.DisputeManager
167167
const disputeID = cliArgs.disputeID
168-
logger.log(`Drawing...`)
168+
logger.info(`Drawing...`)
169169
await sendTransaction(cli.wallet, disputeManager, 'drawDispute', ...[disputeID])
170170
}
171171

cli/commands/contracts/ens.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ export const registerTestName = async (cli: CLIEnvironment, cliArgs: CLIArgs): P
1313
const labelNameFull = `${normalizedName}.${'eth'}`
1414
const labelHashFull = utils.namehash(labelNameFull)
1515
const label = utils.keccak256(utils.toUtf8Bytes(normalizedName))
16-
logger.log(`Namehash for ${labelNameFull}: ${labelHashFull}`)
17-
logger.log(`Registering ${name} with ${cli.walletAddress} on the test registrar`)
16+
logger.info(`Namehash for ${labelNameFull}: ${labelHashFull}`)
17+
logger.info(`Registering ${name} with ${cli.walletAddress} on the test registrar`)
1818
await sendTransaction(cli.wallet, testRegistrar, 'register', [label, cli.walletAddress])
1919
}
2020
export const checkOwner = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
2121
const name = cliArgs.name
2222
const ens = cli.contracts.IENS
2323
const node = nameToNode(name)
2424
const res = await ens.owner(node)
25-
logger.success(`owner = ${res}`)
25+
logger.info(`owner = ${res}`)
2626
}
2727

2828
export const nameToNode = (name: string): string => {
2929
const node = utils.namehash(`${name}.eth`)
30-
logger.log(`Name: ${name}`)
31-
logger.log(`Node: ${node}`)
30+
logger.info(`Name: ${name}`)
31+
logger.info(`Node: ${node}`)
3232
return node
3333
}
3434

cli/commands/contracts/ethereumDIDRegistry.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import { logger } from '../../logging'
99

1010
const handleAccountMetadata = async (ipfs: string, path: string): Promise<string> => {
1111
const metadata = jsonToAccountMetadata(JSON.parse(fs.readFileSync(__dirname + path).toString()))
12-
logger.log('Meta data:')
13-
logger.log(' Code Repository: ', metadata.codeRepository || '')
14-
logger.log(' Description: ', metadata.description || '')
15-
logger.log(' Image: ', metadata.image || '')
16-
logger.log(' Name: ', metadata.name || '')
17-
logger.log(' Website: ', metadata.website || '')
18-
logger.log(' Display name: ', metadata.displayName || '')
12+
logger.info('Meta data:')
13+
logger.info(' Code Repository: ', metadata.codeRepository || '')
14+
logger.info(' Description: ', metadata.description || '')
15+
logger.info(' Image: ', metadata.image || '')
16+
logger.info(' Name: ', metadata.name || '')
17+
logger.info(' Website: ', metadata.website || '')
18+
logger.info(' Display name: ', metadata.displayName || '')
1919

2020
const ipfsClient = IPFS.createIpfsClient(ipfs)
21-
logger.log('\nUpload JSON meta data to IPFS...')
21+
logger.info('\nUpload JSON meta data to IPFS...')
2222
const result = await ipfsClient.add(Buffer.from(JSON.stringify(metadata)))
2323
const metaHash = result[0].hash
2424
try {
@@ -29,7 +29,7 @@ const handleAccountMetadata = async (ipfs: string, path: string): Promise<string
2929
} catch (e) {
3030
throw new Error(`Failed to retrieve and parse JSON meta data after uploading: ${e.message}`)
3131
}
32-
logger.log(`Upload metadata successful: ${metaHash}\n`)
32+
logger.info(`Upload metadata successful: ${metaHash}\n`)
3333
return IPFS.ipfsHashToBytes32(metaHash)
3434
}
3535

@@ -41,7 +41,7 @@ export const setAttribute = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promi
4141
const name = '0x72abcb436eed911d1b6046bbe645c235ec3767c842eb1005a6da9326c2347e4c'
4242
const metaHashBytes = await handleAccountMetadata(ipfsEndpoint, metadataPath)
4343

44-
logger.log(`Setting attribute on ethereum DID registry ...`)
44+
logger.info(`Setting attribute on ethereum DID registry ...`)
4545
await sendTransaction(cli.wallet, ethereumDIDRegistry, 'setAttribute', [
4646
cli.walletAddress,
4747
name,

cli/commands/contracts/gns.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const setDefaultName = async (cli: CLIEnvironment, cliArgs: CLIArgs): Pro
1414
const node = nameToNode(name)
1515
const gns = cli.contracts.GNS
1616

17-
logger.log(`Setting default name as ${name} for ${graphAccount}...`)
17+
logger.info(`Setting default name as ${name} for ${graphAccount}...`)
1818
await sendTransaction(cli.wallet, gns, 'setDefaultName', [graphAccount, nameSystem, node, name])
1919
}
2020

@@ -30,7 +30,7 @@ export const publishNewSubgraph = async (cli: CLIEnvironment, cliArgs: CLIArgs):
3030
const subgraphHashBytes = await pinMetadataToIPFS(ipfs, 'subgraph', subgraphPath)
3131
const gns = cli.contracts.GNS
3232

33-
logger.log(`Publishing new subgraph for ${graphAccount}`)
33+
logger.info(`Publishing new subgraph for ${graphAccount}`)
3434
await sendTransaction(cli.wallet, gns, 'publishNewSubgraph', [
3535
graphAccount,
3636
subgraphDeploymentIDBytes,
@@ -50,7 +50,7 @@ export const publishNewVersion = async (cli: CLIEnvironment, cliArgs: CLIArgs):
5050
const versionHashBytes = await pinMetadataToIPFS(ipfs, 'version', versionPath)
5151
const gns = cli.contracts.GNS
5252

53-
logger.log(`Publishing new subgraph version for ${graphAccount}`)
53+
logger.info(`Publishing new subgraph version for ${graphAccount}`)
5454
await sendTransaction(cli.wallet, gns, 'publishNewVersion', [
5555
graphAccount,
5656
subgraphNumber,
@@ -63,7 +63,7 @@ export const deprecate = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<
6363
const graphAccount = cliArgs.graphAccount
6464
const subgraphNumber = cliArgs.subgraphNumber
6565
const gns = cli.contracts.GNS
66-
logger.log(`Deprecating subgraph ${graphAccount}-${subgraphNumber}...`)
66+
logger.info(`Deprecating subgraph ${graphAccount}-${subgraphNumber}...`)
6767
await sendTransaction(cli.wallet, gns, 'deprecate', [graphAccount, subgraphNumber])
6868
}
6969

@@ -78,7 +78,7 @@ export const updateSubgraphMetadata = async (
7878
const subgraphHashBytes = await pinMetadataToIPFS(ipfs, 'subgraph', subgraphPath)
7979
const gns = cli.contracts.GNS
8080

81-
logger.log(`Updating subgraph metadata for ${graphAccount}-${subgraphNumber}...`)
81+
logger.info(`Updating subgraph metadata for ${graphAccount}-${subgraphNumber}...`)
8282
await sendTransaction(cli.wallet, gns, 'updateSubgraphMetadata', [
8383
graphAccount,
8484
subgraphNumber,
@@ -92,7 +92,7 @@ export const mintNSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promis
9292
const tokens = parseGRT(cliArgs.tokens)
9393
const gns = cli.contracts.GNS
9494

95-
logger.log(`Minting nSignal for ${graphAccount}-${subgraphNumber}...`)
95+
logger.info(`Minting nSignal for ${graphAccount}-${subgraphNumber}...`)
9696
await sendTransaction(cli.wallet, gns, 'mintNSignal', [graphAccount, subgraphNumber, tokens])
9797
}
9898

@@ -102,7 +102,7 @@ export const burnNSignal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promis
102102
const nSignal = cliArgs.nSignal
103103
const gns = cli.contracts.GNS
104104

105-
logger.log(`Burning nSignal from ${graphAccount}-${subgraphNumber}...`)
105+
logger.info(`Burning nSignal from ${graphAccount}-${subgraphNumber}...`)
106106
await sendTransaction(cli.wallet, gns, 'burnNSignal', [graphAccount, subgraphNumber, nSignal])
107107
}
108108

@@ -111,7 +111,7 @@ export const withdrawGRT = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promis
111111
const subgraphNumber = cliArgs.subgraphNumber
112112
const gns = cli.contracts.GNS
113113

114-
logger.log(`Withdrawing locked GRT from subgraph ${graphAccount}-${subgraphNumber}...`)
114+
logger.info(`Withdrawing locked GRT from subgraph ${graphAccount}-${subgraphNumber}...`)
115115
await sendTransaction(cli.wallet, gns, 'withdrawGRT', [graphAccount, subgraphNumber])
116116
}
117117

cli/commands/contracts/governance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const createProposal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Pro
1313
const resolution = cliArgs.resolution
1414
const governance = cli.contracts.Governance
1515

16-
logger.log(`Creating proposal ${id}...`)
16+
logger.info(`Creating proposal ${id}...`)
1717
await sendTransaction(cli.wallet, governance, 'createProposal', [id, votes, metadata, resolution])
1818
}
1919

@@ -24,7 +24,7 @@ export const upgradeProposal = async (cli: CLIEnvironment, cliArgs: CLIArgs): Pr
2424
const resolution = cliArgs.resolution
2525
const governance = cli.contracts.Governance
2626

27-
logger.log(`Upgrade proposal ${id}...`)
27+
logger.info(`Upgrade proposal ${id}...`)
2828
await sendTransaction(cli.wallet, governance, 'upgradeProposal', [
2929
id,
3030
votes,

cli/commands/contracts/graphToken.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ export const mint = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void>
1010
const account = cliArgs.account
1111
const graphToken = cli.contracts.GraphToken
1212

13-
logger.log(`Minting ${cliArgs.amount} tokens for user ${account}...`)
13+
logger.info(`Minting ${cliArgs.amount} tokens for user ${account}...`)
1414
await sendTransaction(cli.wallet, graphToken, 'mint', [account, amount])
1515
}
1616

1717
export const burn = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<void> => {
1818
const amount = parseGRT(cliArgs.amount)
1919
const graphToken = cli.contracts.GraphToken
2020

21-
logger.log(`Burning ${cliArgs.amount} tokens...`)
21+
logger.info(`Burning ${cliArgs.amount} tokens...`)
2222
await sendTransaction(cli.wallet, graphToken, 'burn', [amount])
2323
}
2424

@@ -27,7 +27,7 @@ export const transfer = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<v
2727
const account = cliArgs.account
2828
const graphToken = cli.contracts.GraphToken
2929

30-
logger.log(`Transferring ${cliArgs.amount} tokens to user ${account}...`)
30+
logger.info(`Transferring ${cliArgs.amount} tokens to user ${account}...`)
3131
await sendTransaction(cli.wallet, graphToken, 'transfer', [account, amount])
3232
}
3333

@@ -36,7 +36,7 @@ export const approve = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<vo
3636
const account = cliArgs.account
3737
const graphToken = cli.contracts.GraphToken
3838

39-
logger.log(`Approving ${cliArgs.amount} tokens for user ${account} to spend...`)
39+
logger.info(`Approving ${cliArgs.amount} tokens for user ${account} to spend...`)
4040
await sendTransaction(cli.wallet, graphToken, 'approve', [account, amount])
4141
}
4242

@@ -45,9 +45,9 @@ export const allowance = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<
4545
const spender = cliArgs.spender
4646
const graphToken = cli.contracts.GraphToken
4747

48-
logger.log(`Checking ${account} allowance set for spender ${spender}...`)
48+
logger.info(`Checking ${account} allowance set for spender ${spender}...`)
4949
const res = await graphToken.allowance(account, spender)
50-
logger.success(`allowance = ${res}`)
50+
logger.info(`allowance = ${res}`)
5151
}
5252

5353
export const graphTokenCommand = {

0 commit comments

Comments
 (0)