Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbayly committed Aug 5, 2022
1 parent 68bf566 commit d468ce4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 48 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "algorand-subql-starter",
"name": "algorand-planet-watch",
"version": "1.0.0",
"description": "This project can be used as a starting point for developing your Algorand SubQuery project",
"description": "This project is a quick start guide for developing your Algorand SubQuery project, it indexes Algorand PlanetWatch token transfers",
"main": "dist/index.js",
"scripts": {
"build": "subql build",
Expand All @@ -10,8 +10,8 @@
"codegen": "./node_modules/.bin/subql codegen",
"start:docker": "docker-compose pull && docker-compose up"
},
"homepage": "https://github.com/subquery/algorand-subql-starter",
"repository": "github:subquery/algorand-subql-starterr",
"homepage": "https://github.com/jamesbayly/algorand-planet-watch",
"repository": "github:jamesbayly/algorand-planet-watch",
"files": [
"dist",
"schema.graphql",
Expand Down
20 changes: 6 additions & 14 deletions project.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
specVersion: 1.0.0
name: algorand-subql-starter
name: algorand-planet-watch
version: 1.0.0
runner:
node:
Expand All @@ -9,8 +9,8 @@ runner:
name: "@subql/query"
version: "*"
description: >-
This project can be used as a starting point for developing your Algorand SubQuery project
repository: "https://github.com/subquery/algorand-subql-starter"
This project is a quick start guide for developing your Algorand SubQuery project, it indexes Algorand PlanetWatch token transfers
repository: "https://github.com/jamesbayly/algorand-planet-watch"
schema:
file: ./schema.graphql
network:
Expand All @@ -19,21 +19,13 @@ network:
endpoint: "https://algoindexer.testnet.algoexplorerapi.io"
dataSources:
- kind: algorand/Runtime
startBlock: 50000 # Block to start indexing from (or the block when your contract was deployed)
startBlock: 8712119 # Block that planet was created on https://algoexplorer.io/tx/G66KX3TLKXUI547DFB4MNVY7SJVADOJKGP4SWMRC632GFHSFX5KQ
mapping:
file: ./dist/index.js
handlers:
- handler: handleBlock
kind: algorand/BlockHandler
- handler: handleTransaction
kind: algorand/TransactionHandler
filter:
# payments from the Planet Watch Address
txType: pay
# payments from the Planet Watch Address for the PLANET asset
assetId: 27165954
sender: "ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754"
receiver: "ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754"
- handler: handleTransaction
kind: algorand/TransactionHandler
filter:
txType: acfg
applicationId: 1
7 changes: 1 addition & 6 deletions schema.graphql
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
}
29 changes: 7 additions & 22 deletions src/mappings/mappingHandlers.ts
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();
}
2 changes: 0 additions & 2 deletions src/types/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

// Auto-generated , DO NOT EDIT

export {Block} from "./Block"

export {Transaction} from "./Transaction"

0 comments on commit d468ce4

Please sign in to comment.