0.3.0 • Published 2 years ago
@pylon-protocol/hype v0.3.0
An experimental indexer framework. Allows subscribing on-chain events from Terra Blockchain.
Architecture Overview
Example
Subscribing CW20 Transfers in Real-Time
const hype = await createRealtimeHype();
const ancTransferFinder = createCw20TransferLogFinder('terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76');
hype.subscribe('anchor-transfer', async (block) => {
extractEventsInBlock(block, [ancTransferFinder])
.forEach(({ txHash, event: { from, to, amount } }) => {
console.log(`Sent ${amount} ANC from ${from} to ${to}`);
console.log(` -> https://finder.terra.money/mainnet/tx/${txHash}`);
});
});
await hype.start();
Indexing CW20 Transfer Logs in Real-Time
const datasource = new BlockPoller(
new LCDBlockFetcher(),
saveLastSyncedHeightInHivePersistence(new DynamoDBDriver({...})),
);
const hype = new Hype(datasource);
hype.subscribe(
'cw20-transfer',
createPersistentIndexer(Cw20TransferLog, async (block) =>
extractEventsInBlock(block, [
createReturningLogFinderRule(
{
type: 'from_contract',
attributes: [
['contract_address'],
['action', 'transfer'],
['from'],
['to'],
['amount'],
],
},
(_, match) => Cw20TransferLog.create({
token: match[0].value,
from: match[2].value,
to: match[3].value,
amount: match[4].value,
}),
),
])
),
);
await hype.start();
Indexing Specific Range of Blocks
Replace BlockPoller
with BlockBackFiller
.
const datasource = new BlockBackFiller(
new FCDBlockFetcher('https://hive.terra.dev/graphql'),
4980471, 4981423,
);
const hype = new Hype(datasource);
hype.subscribe('cw20-transfer', ...);
hype.start();
0.3.0
2 years ago
0.2.25
2 years ago
0.2.24
2 years ago
0.2.23
2 years ago
0.2.22
2 years ago
0.2.21
2 years ago
0.2.20
2 years ago
0.2.18
2 years ago
0.2.17
2 years ago
0.2.16
2 years ago
0.2.15
2 years ago
0.2.14
2 years ago
0.2.13
2 years ago
0.2.12
2 years ago
0.2.11
2 years ago
0.2.10
3 years ago
0.2.9
3 years ago
0.2.8
3 years ago
0.2.7
3 years ago
0.2.6
3 years ago
0.2.5
3 years ago
0.2.4
3 years ago
0.2.3
3 years ago
0.2.2
3 years ago
0.2.1
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago