Skip to content

Commit 973458f

Browse files
committedAug 4, 2023
update code
1 parent 671a00c commit 973458f

File tree

25 files changed

+169
-98
lines changed

25 files changed

+169
-98
lines changed
 

‎cli/utils.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,22 @@ export const craftEndpoint = (
129129
}graphql`
130130
}
131131

132-
const getEnv = (key: string, defaultValue?: string): string => {
132+
export const getEnv = (key: string, defaultValue?: string): string => {
133133
const value = Deno.env.get(key)
134134
if (!value && !defaultValue) {
135135
throw new Error(`Missing environment variable: ${key}`)
136136
}
137137
return value || defaultValue || ''
138138
}
139139

140-
const collectRpcUrls = () => {
140+
export const collectRpcUrls = () => {
141141
const rpcUrls: Record<string, string> = {}
142142
for (const chain of Object.keys(supportedChains)) {
143143
try {
144144
rpcUrls[chain] = getEnv(`${chain.toUpperCase()}_RPC_URL`)
145-
} catch (e) {}
145+
} catch (_e) {
146+
// ignore
147+
}
146148
}
147149
return rpcUrls
148150
}

‎deno.lock

+45-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/block-handler-vaults/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
This Arkive keeps an accurate historical record of the sharePrice of a given set of YearnV2 Abi Vaults. sharePrice increases as profits are distributed to the vaults, but may also decrease if loss is incurred. It may be valuable to track this information in case of incidents or in order to optimize the vaults for instance.
33
### Dependencies
44
* Docker
5-
* Full Arkive RPC (Infura, Ankr, Alchemy, etc)
5+
* Full Archive RPC (Infura, Ankr, Alchemy, etc)
66

77
### Arkive Usage
88

99
First make sure .env is configured correctly with your RPC endpoint. In this example we are connecting the `mainnet` with the Ankr public ETH endpoint.
10-
> RPC_URL=mainnet=https://rpc.ankr.com/eth
10+
> MAINNET_RPC_URL=https://rpc.ankr.com/eth
1111
1212
All available tasks can been seen with
1313
> deno task
@@ -21,7 +21,7 @@ To reset the database and resync the Arkive run `reset` task
2121
### Using the GraphQL Explorer
2222
If Arkiver is running there should now be webpage avaiable at http://0.0.0.0:4000/graphql
2323

24-
In the left side you can use the no-code explorer to pick and chose which Entities and what fields of the Entities you would like to look at. Here is an example query for this Arkive. This fetches the latest VaultSnapshot entity.
24+
In the left side you can use the no-code explorer to pick and choose which Entities and what fields of the Entities you would like to look at. Here is an example query for this Arkive. This fetches the latest VaultSnapshot entity.
2525
```
2626
query MyQuery {
2727
VaultSnapshot(sort: _ID_DESC) {

‎examples/block-handler-vaults/abis/YearnV2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const YearnV2Abi = [{
1+
export const YEARN_V2_ABI = [{
22
'name': 'Transfer',
33
'inputs': [{ 'name': 'sender', 'type': 'address', 'indexed': true }, {
44
'name': 'receiver',

‎examples/block-handler-vaults/handlers/vault.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { formatUnits, getContract } from 'npm:viem'
22
import { type BlockHandler } from 'https://deno.land/x/robo_arkiver@v0.4.19/mod.ts'
33
import { VaultSnapshot } from '../entities/vault.ts'
4-
import { YearnV2Abi } from '../abis/YearnV2.ts'
4+
import { YEARN_V2_ABI } from '../abis/YearnV2.ts'
55

66
const VAULTS = [
77
{ address: '0xdA816459F1AB5631232FE5e97a05BBBb94970c95', block: 12796965 }, // yvDAI
@@ -12,7 +12,7 @@ export const snapshotVault: BlockHandler = async ({
1212
block,
1313
client,
1414
store,
15-
logger
15+
logger,
1616
}): Promise<void> => {
1717
// Filter out vaults that haven't been deployed yet
1818
const liveVaults = VAULTS.filter((e) => e.block < Number(block.number))
@@ -21,12 +21,12 @@ export const snapshotVault: BlockHandler = async ({
2121
const vaults = await Promise.all(liveVaults.map(async (vault) => {
2222
const contract = getContract({
2323
address: vault.address,
24-
abi: YearnV2Abi,
24+
abi: YEARN_V2_ABI,
2525
publicClient: client,
2626
})
2727
return {
2828
address: vault.address,
29-
vault: { address: vault.address, abi: YearnV2Abi } as const,
29+
vault: { address: vault.address, abi: YEARN_V2_ABI } as const,
3030
contract,
3131
name: await store.retrieve(
3232
`${vault.address}:name`,
@@ -47,7 +47,7 @@ export const snapshotVault: BlockHandler = async ({
4747
const sharePrices = await Promise.all(vaults.map((e) => {
4848
return client.readContract({
4949
address: e.address,
50-
abi: YearnV2Abi,
50+
abi: YEARN_V2_ABI,
5151
functionName: 'pricePerShare',
5252
blockNumber: block.number,
5353
})
@@ -60,14 +60,13 @@ export const snapshotVault: BlockHandler = async ({
6060
)
6161
logger.info(`${vault.name} share price updated to ${sharePrice}`)
6262
return new VaultSnapshot({
63-
// id: `${vault.address}-${Number(block.number)}`,
63+
// id: `${vault.address}-${Number(block.number)}`,
6464
block: Number(block.number),
6565
timestamp: Number(block.timestamp),
6666
vault: vault.address,
6767
sharePrice: sharePrice,
6868
name: vault.name,
6969
symbol: vault.symbol,
7070
})
71-
7271
}).map((e) => e.save())
7372
}

‎examples/block-handler-vaults/manifest.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ const manifest = new Manifest('yearn-vaults')
66

77
manifest
88
.addEntity(VaultSnapshot)
9-
.addChain('mainnet')
10-
.addBlockHandler({
11-
blockInterval: 1000,
12-
startBlockHeight: 12790000n,
13-
handler: snapshotVault,
14-
})
9+
.addChain('mainnet', (chain) =>
10+
chain
11+
.addBlockHandler({
12+
blockInterval: 1000,
13+
startBlockHeight: 12790000n,
14+
handler: snapshotVault,
15+
}))
1516

1617
export default manifest
1718
.build()

‎examples/erc20-balance-history/erc20.ts ‎examples/erc20-balance-history/Erc20.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default [{
1+
export const ERC_20_ABI = [{
22
'inputs': [],
33
'stateMutability': 'nonpayable',
44
'type': 'constructor',

‎examples/erc20-balance-history/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
This Arkive keeps an accurate historical record of the balance of an account of a given ERC20 token. It uses the Balance entity as a mutable variable updates as events are handled and is used to keep track of an accounts balance as we sync eventually reflecting true onchain balance. BalanceHistory is an unchanging entity which stores balance over time and is indexed by the `block` field.
33
### Dependencies
44
* Docker
5-
* Full Arkive RPC (Infura, Ankr, Alchemy, etc)
5+
* Full Archive RPC (Infura, Ankr, Alchemy, etc)
66

77
### Arkive Usage
88

99
First make sure .env is configured correctly with your RPC endpoint. In this example we are connecting the `mainnet` with the Ankr public ETH endpoint.
10-
> RPC_URL=mainnet=https://rpc.ankr.com/eth
10+
> MAINNET_RPC_URL=https://rpc.ankr.com/eth
1111
1212
All available tasks can been seen with
1313
> deno task

‎examples/erc20-balance-history/handlers.ts

+28-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1-
import { formatUnits, numberToHex, fromHex } from 'npm:viem'
1+
import { formatUnits, fromHex, numberToHex } from 'npm:viem'
22
import { type EventHandlerFor } from 'https://deno.land/x/robo_arkiver@v0.4.19/mod.ts'
33
import erc20 from './erc20.ts'
44
import { Balance, BalanceHistory, Transfer } from './entities.ts'
55

66
// Alternatively, you can pull this from the chain
77
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
88

9-
const getBalance = async (user: string, token: string, client, block, store) => {
9+
const getBalance = async (
10+
user: string,
11+
token: string,
12+
client,
13+
block,
14+
store,
15+
) => {
1016
const bal = await Balance.findOne({ user })
11-
if (bal){
17+
if (bal) {
1218
return bal
1319
} else {
1420
let userBalance = await client.readContract({
15-
address: token,
16-
abi: erc20,
17-
functionName: 'balanceOf',
18-
blockNumber: block.blockNumber,
19-
args: [user]
20-
})
21+
address: token,
22+
abi: erc20,
23+
functionName: 'balanceOf',
24+
blockNumber: block.blockNumber,
25+
args: [user],
26+
})
2127
return new Balance({ user, token, balance: numberToHex(userBalance) })
2228
}
23-
24-
2529
}
2630

2731
export const onTransfer: EventHandlerFor<typeof erc20, 'Transfer'> = async (
@@ -52,21 +56,27 @@ export const onTransfer: EventHandlerFor<typeof erc20, 'Transfer'> = async (
5256
})
5357
record.save()
5458

55-
const updateBalance = async (user: string, value: bigint, client, block, store) => {
59+
const updateBalance = async (
60+
user: string,
61+
value: bigint,
62+
client,
63+
block,
64+
store,
65+
) => {
5666
// ignore zero address
5767
if (user === ZERO_ADDRESS) {
5868
return
5969
}
6070

6171
// grab the balance entry for the user
6272
let bal = new Balance({})
63-
try{
73+
try {
6474
bal = await getBalance(user, address, client, block, store)
65-
} catch(e){
75+
} catch (e) {
6676
logger.error(`getBalance error: ${e}`)
6777
return
6878
}
69-
79+
7080
// adjust the value
7181
bal.balance = numberToHex(fromHex(bal.balance, 'bigint') + value)
7282

@@ -78,7 +88,9 @@ export const onTransfer: EventHandlerFor<typeof erc20, 'Transfer'> = async (
7888
user,
7989
balance: bal.balance,
8090
})
81-
logger.info(`Balance of ${user} updated to ${bal.balance} at block ${block} on ${address}`)
91+
logger.info(
92+
`Balance of ${user} updated to ${bal.balance} at block ${block} on ${address}`,
93+
)
8294

8395
// Save both the balance and the history entry
8496
return Promise.all([
+9-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.4.19/mod.ts'
2-
import erc20 from './erc20.ts'
2+
import { ERC_20_ABI } from './Erc20.ts'
33
import { Entities } from './entities.ts'
44
import { onTransfer } from './handlers.ts'
55

66
const manifest = new Manifest('frax-balances')
77

88
manifest
99
.addEntities(Entities)
10-
.addChain('mainnet', { blockRange: 500n })
11-
.addContract(erc20)
12-
.addSources({ '0x853d955aCEf822Db058eb8505911ED77F175b99e': 11465581n })
13-
.addEventHandlers({ 'Transfer': onTransfer })
10+
.addChain('mainnet', (chain) =>
11+
chain
12+
.addContract({
13+
abi: ERC_20_ABI,
14+
name: 'Erc20',
15+
sources: { '0x853d955aCEf822Db058eb8505911ED77F175b99e': 11465581n },
16+
eventHandlers: { 'Transfer': onTransfer },
17+
}))
1418

1519
export default manifest.build()

‎examples/erc20-events/erc20.ts ‎examples/erc20-events/Erc20.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default [{
1+
export const ERC_20_ABI = [{
22
'inputs': [],
33
'stateMutability': 'nonpayable',
44
'type': 'constructor',

‎examples/erc20-events/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
This Arkive has two entities, Transfer and Approval. The Arkive also has two corresponding event handlers onTransfer and onApproval which are triggered when the `Transfer` and `Approval` events are emitted by the source contract which is configured to `WETH` in the manifest. When the handlers are triggered they parse the amount and store either an Approval or Transfer entity in the database.
33
### Dependencies
44
* Docker
5-
* Full Arkive RPC (Infura, Ankr, Alchemy, etc)
5+
* Full Archive RPC (Infura, Ankr, Alchemy, etc)
66

77
### Arkive Usage
88

99
First make sure .env is configured correctly with your RPC endpoint. In this example we are connecting the `mainnet` with the Ankr public ETH endpoint.
10-
> RPC_URL=mainnet=https://rpc.ankr.com/eth
10+
> MAINNET_RPC_URL=https://rpc.ankr.com/eth
1111
1212
All available tasks can been seen with
1313
> deno task

‎examples/erc20-events/entities.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { createEntity } from 'https://deno.land/x/robo_arkiver@v0.4.19/mod.ts'
22

33
// @note: "Index: true" enhances graphql queries
4-
export const Transfer = createEntity('Transfer', {
4+
export const Transfer = createEntity<any>('Transfer', {
55
block: { type: Number, index: true },
66
hash: String,
77
from: String,
88
to: String,
99
value: String,
1010
})
1111

12-
export const Approval = createEntity('Approval', {
12+
export const Approval = createEntity<any>('Approval', {
1313
block: { type: Number, index: true },
1414
hash: String,
1515
owner: String,

‎examples/erc20-events/handlers.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { formatUnits } from 'npm:viem'
22
import { type EventHandlerFor } from 'https://deno.land/x/robo_arkiver@v0.4.19/mod.ts'
3-
import erc20 from './erc20.ts'
3+
import { ERC_20_ABI } from './Erc20.ts'
44
import { Approval, Transfer } from './entities.ts'
55

66
// Alternatively, you can pull this from the chain
77
const TOKEN_DECIMALS = 18
88

9-
// deno-lint-ignore require-await
10-
export const onTransfer: EventHandlerFor<typeof erc20, 'Transfer'> = async (
9+
export const onTransfer: EventHandlerFor<typeof ERC_20_ABI, 'Transfer'> = (
1110
{ event, logger },
1211
) => {
1312
const { from, to, value } = event.args
@@ -21,11 +20,12 @@ export const onTransfer: EventHandlerFor<typeof erc20, 'Transfer'> = async (
2120
})
2221
record.save()
2322
const parsedValue = parseFloat(formatUnits(value, TOKEN_DECIMALS))
24-
logger.info(`Transfer of ${parsedValue} from ${from} to ${to} on ${event.address}`)
23+
logger.info(
24+
`Transfer of ${parsedValue} from ${from} to ${to} on ${event.address}`,
25+
)
2526
}
2627

27-
// deno-lint-ignore require-await
28-
export const onApproval: EventHandlerFor<typeof erc20, 'Approval'> = async (
28+
export const onApproval: EventHandlerFor<typeof ERC_20_ABI, 'Approval'> = (
2929
{ event, logger },
3030
) => {
3131
const { owner, spender, value } = event.args
@@ -39,6 +39,8 @@ export const onApproval: EventHandlerFor<typeof erc20, 'Approval'> = async (
3939
value: parsedValue,
4040
})
4141
record.save()
42-
43-
logger.info(`Approval of ${parsedValue} from ${owner} to ${spender} on ${event.address}`)
42+
43+
logger.info(
44+
`Approval of ${parsedValue} from ${owner} to ${spender} on ${event.address}`,
45+
)
4446
}

‎examples/erc20-events/manifest.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { Manifest } from 'https://deno.land/x/robo_arkiver@v0.4.19/mod.ts'
2-
import erc20 from './erc20.ts'
2+
import { ERC_20_ABI } from './Erc20.ts'
33
import { Approval, Transfer } from './entities.ts'
44
import { onApproval, onTransfer } from './handlers.ts'
55

66
const manifest = new Manifest('weth-events')
77

88
manifest
99
.addEntities([Transfer, Approval])
10-
.addChain('mainnet', { blockRange: 500n })
11-
.addContract('ERC20', erc20)
12-
.addSources({ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2': 4729568n })
13-
.addEventHandlers({ 'Transfer': onTransfer })
14-
.addEventHandlers({ 'Approval': onApproval })
10+
.addChain('mainnet', (chain) =>
11+
chain
12+
.addContract({
13+
abi: ERC_20_ABI,
14+
name: 'Erc20',
15+
sources: { '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2': 4729568n },
16+
eventHandlers: { 'Transfer': onTransfer, 'Approval': onApproval },
17+
}))
1518

1619
export default manifest.build()

‎examples/event-wildcard/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ In this example we are attaching to the Transfer event on all contracts. This me
1313
The event data is parsed into a human readable format and logged to the console.
1414
### Dependencies
1515
* Docker
16-
* Full Arkive RPC (Infura, Ankr, Alchemy, etc)
16+
* Full Archive RPC (Infura, Ankr, Alchemy, etc)
1717

1818
### Arkive Usage
1919

2020
First make sure .env is configured correctly with your RPC endpoint. In this example we are connecting the `mainnet` with the Ankr public ETH endpoint.
21-
> RPC_URL=mainnet=https://rpc.ankr.com/eth
21+
> MAINNET_RPC_URL=https://rpc.ankr.com/eth
2222
2323
All available tasks can been seen with
2424
> deno task

‎examples/event-wildcard/abis/erc20.ts ‎examples/event-wildcard/abis/Erc20.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default [{
1+
export const ERC_20_ABI = [{
22
'inputs': [],
33
'stateMutability': 'nonpayable',
44
'type': 'constructor',

‎examples/event-wildcard/handlers/transfer.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { EventHandlerFor, formatUnits } from '../deps.ts'
2-
import erc20 from '../abis/erc20.ts'
2+
import { ERC_20_ABI } from '../abis/Erc20.ts'
33

4-
export const transferHandler: EventHandlerFor<typeof erc20, 'Transfer'> =
4+
export const transferHandler: EventHandlerFor<typeof ERC_20_ABI, 'Transfer'> =
55
async (
66
{ event, client, store, logger },
77
) => {
@@ -15,7 +15,7 @@ export const transferHandler: EventHandlerFor<typeof erc20, 'Transfer'> =
1515
`${address}:decimals`,
1616
async () =>
1717
await client.readContract({
18-
abi: erc20,
18+
abi: ERC_20_ABI,
1919
functionName: 'decimals',
2020
address,
2121
}),

‎examples/event-wildcard/manifest.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { Manifest } from './deps.ts'
2-
import erc20 from './abis/erc20.ts'
2+
import { ERC_20_ABI } from './abis/Erc20.ts'
33
import { transferHandler } from './handlers/transfer.ts'
44

55
const manifest = new Manifest('agnostic-events')
66

77
manifest
8-
.addChain('avalanche', { blockRange: 100n })
9-
.addContract('ERC20', erc20)
10-
.addSources({ '*': 27347402n })
11-
.addEventHandlers({ 'Transfer': transferHandler })
8+
.addChain('avalanche', (chain) =>
9+
chain
10+
.addContract({
11+
name: 'Erc20',
12+
abi: ERC_20_ABI,
13+
sources: { '*': 27347402n },
14+
eventHandlers: { 'Transfer': transferHandler },
15+
}))
1216

1317
export default manifest.build()

‎examples/library/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
This arkive handles `Transfer` events. It keeps track of the `Balance` entity. Balance starts at zero and in increased and decreased according to the `Transfer` event.
33
### Dependencies
44
* Docker
5-
* Full Arkive RPC (Infura, Ankr, Alchemy, etc)
5+
* Full Archive RPC (Infura, Ankr, Alchemy, etc)
66

77
### Arkive Usage
88

99
First make sure .env is configured correctly with your RPC endpoint. In this example we are connecting the `mainnet` with the Ankr public ETH endpoint.
10-
> RPC_URL=mainnet=https://rpc.ankr.com/eth
10+
> MAINNET_RPC_URL=https://rpc.ankr.com/eth
1111
1212
All available tasks can been seen with
1313
> deno task

‎examples/library/deps.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export { formatUnits } from 'npm:viem'
22
export {
33
createEntity,
44
type EventHandlerFor,
5-
Manifest
5+
Manifest,
66
} from 'https://deno.land/x/robo_arkiver@v0.4.19/mod.ts'
77
export {
8+
Erc721Lib,
89
type Erc721Opts,
9-
Erc721Lib
10-
} from "https://deno.land/x/robo_arkiver@v0.4.19/libs.ts";
10+
} from 'https://deno.land/x/robo_arkiver@v0.4.19/libs.ts'

‎examples/library/manifest.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { Manifest, Erc721Lib, type Erc721Opts } from './deps.ts'
1+
import { Erc721Lib, type Erc721Opts, Manifest } from './deps.ts'
22

3-
const manifest = new Manifest('simple')
3+
const manifest = new Manifest('libs')
44

55
const opts: Erc721Opts = {
6-
contract: {"0xbd3531da5cf5857e7cfaa92426877b022e612cf8", 12876179},
7-
async: true
6+
contract: { '0xbd3531da5cf5857e7cfaa92426877b022e612cf8': 12876179n },
7+
async: true,
88
}
99

1010
manifest
11-
.addChain('mainnet', { blockRange: 100n })
12-
.use([Erc721Lib.create(opts)])
13-
11+
.addChain('mainnet', (chain) => chain.use([Erc721Lib.create(opts)]))
12+
1413
export default manifest.build()

‎examples/simple/erc20.ts ‎examples/simple/Erc20.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default [{
1+
export const ERC_20_ABI = [{
22
'inputs': [],
33
'stateMutability': 'nonpayable',
44
'type': 'constructor',

‎examples/simple/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
This arkive handles `Transfer` events. It keeps track of the `Balance` entity. Balance starts at zero and in increased and decreased according to the `Transfer` event.
33
### Dependencies
44
* Docker
5-
* Historical RPC (Infura, Ankr, Alchemy, etc)
5+
* Full Archive RPC (Infura, Ankr, Alchemy, etc)
66

77
### Arkive Usage
88

99
First make sure .env is configured correctly with your RPC endpoint. In this example we are connecting the `mainnet` with the Ankr public ETH endpoint.
10-
> RPC_URL=mainnet=https://rpc.ankr.com/eth
10+
> MAINNET_RPC_URL=https://rpc.ankr.com/eth
1111
1212
All available tasks can been seen with
1313
> deno task

‎examples/simple/manifest.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { Manifest } from './deps.ts'
2-
import erc20 from './erc20.ts'
2+
import { ERC_20_ABI } from './Erc20.ts'
33
import { Balance } from './entities.ts'
44
import { transferHandler } from './transferHandler.ts'
55

66
const manifest = new Manifest('simple')
77

88
manifest
99
.addEntity(Balance)
10-
.addChain('mainnet', { blockRange: 100n })
11-
.addContract('ERC20', erc20)
12-
.addSources({ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2': 16987011n })
13-
.addEventHandlers({ 'Transfer': transferHandler })
10+
.addChain('mainnet', (chain) =>
11+
chain
12+
.addContract({
13+
name: 'Erc20',
14+
abi: ERC_20_ABI,
15+
sources: { '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2': 16987011n },
16+
eventHandlers: { 'Transfer': transferHandler },
17+
}))
1418

1519
export default manifest.build()

0 commit comments

Comments
 (0)
Please sign in to comment.