forked from jamesbayly/algorand-planet-watch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68bf566
commit d468ce4
Showing
5 changed files
with
18 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
type Block @entity { | ||
id: ID! # A unique ID - The block hash | ||
height: Int! | ||
} | ||
|
||
type Transaction @entity { | ||
id: ID! # A unique ID - The transaction ID | ||
blockHeight: Int! | ||
sender: String! | ||
reciever: String | ||
amount: BigInt | ||
assetId: BigInt | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,18 @@ | ||
import { AlgorandBlock, AlgorandTransaction } from "@subql/types-algorand"; | ||
import { Block, Transaction } from "../types"; | ||
|
||
export async function handleBlock(block: AlgorandBlock): Promise<void> { | ||
const blockEntity: Block = Block.create({ | ||
id: block.genesisHash, | ||
height: block.round, | ||
}); | ||
await blockEntity.save(); | ||
} | ||
import { AlgorandTransaction } from "@subql/types-algorand"; | ||
import { Transaction } from "../types"; | ||
|
||
export async function handleTransaction( | ||
tx: AlgorandTransaction | ||
): Promise<void> { | ||
logger.info(JSON.stringify(tx)); | ||
const transactionEntity: Transaction = Transaction.create({ | ||
id: tx.id, | ||
blockHeight: tx.confirmedRound, | ||
sender: tx.sender, | ||
assetId: | ||
tx.txType === "afrz" | ||
? BigInt(tx.assetFreezeTransaction.assetId) | ||
: tx.txType === "acfg" | ||
? BigInt(tx.assetConfigTransaction.assetId) | ||
: undefined, | ||
amount: | ||
tx.txType === "axfer" | ||
? BigInt(tx.assetTransferTransaction.amount) | ||
: tx.txType === "pay" | ||
? BigInt(tx.paymentTransaction.amount) | ||
: undefined, | ||
}); | ||
if (tx.paymentTransaction) { | ||
(transactionEntity.reciever = tx.paymentTransaction.receiver), | ||
(transactionEntity.amount = BigInt(tx.paymentTransaction.amount)); | ||
} | ||
await transactionEntity.save(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,5 @@ | |
|
||
// Auto-generated , DO NOT EDIT | ||
|
||
export {Block} from "./Block" | ||
|
||
export {Transaction} from "./Transaction" | ||
|