mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-11 10:14:07 +00:00
Implement data source and crypto host APIs (#104)
* Implement data source host APIs * Implement crypto host API
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Address, log, BigInt, BigDecimal, ByteArray, dataSource, ethereum, Bytes } from '@graphprotocol/graph-ts';
|
||||
import { Address, log, BigInt, BigDecimal, ByteArray, dataSource, ethereum, Bytes, crypto } from '@graphprotocol/graph-ts';
|
||||
|
||||
import {
|
||||
Example1,
|
||||
@@ -14,6 +14,9 @@ export function handleTest (event: Test): void {
|
||||
log.debug('event.block.hash: {}', [event.block.hash.toHexString()]);
|
||||
log.debug('event.block.stateRoot: {}', [event.block.stateRoot.toHexString()]);
|
||||
|
||||
log.debug('dataSource.network: {}', [dataSource.network()]);
|
||||
log.debug('dataSource.context: {}', [dataSource.context().entries.length.toString()]);
|
||||
|
||||
// Entities can be loaded from the store using a string ID; this ID
|
||||
// needs to be unique across all entities of the same type
|
||||
let author = Author.load(event.transaction.from.toHex());
|
||||
@@ -504,3 +507,12 @@ export function testEthereumDecode (encoded: string): string[] {
|
||||
decodedBool.toString()
|
||||
];
|
||||
}
|
||||
|
||||
export function testCrypto (hexString: string): string {
|
||||
const byteArray = ByteArray.fromHexString(hexString);
|
||||
const keccak256 = crypto.keccak256(byteArray);
|
||||
const keccak256String = keccak256.toHex();
|
||||
log.debug('keccak256 string: {}', [keccak256String]);
|
||||
|
||||
return keccak256String;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user