Skip to content

Commit

Permalink
Merge pull request #46 from Agoric/ta/index-fast-usdc
Browse files Browse the repository at this point in the history
indexes for Fast USDC
  • Loading branch information
turadg authored Jan 9, 2025
2 parents 073e3d8 + 43b9818 commit ed81831
Show file tree
Hide file tree
Showing 21 changed files with 2,436 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Codegen
run: yarn codegen
# After codegen because that makes src/types/
- run: yarn tsc
- run: yarn tsc --project typecheck.tsconfig.json
- name: Build
run: yarn build
env:
Expand Down
44 changes: 41 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,65 @@ The fastest way to get support is by [searching our documentation](https://acade

## Developing

### Locally
### With A3P

1. Start up an A3P instance

```sh
docker run -p 26657:26657 -p 1317:1317 -p 9090:9090 ghcr.io/agoric/agoric-3-proposals:latest
```

2. Start up the Indexer
Or with a proposal that you've built in a3p-integration,

```sh
docker run -p 26657:26657 -p 1317:1317 -p 9090:9090 ghcr.io/agoric/agoric-3-proposals:use-fast-usdc
```

2. Confirm the data is visible with [vstorage viewer](https://vstorage.agoric.net/?endpoint=http%3A%2F%2Flocalhost%3A26657)

3. Start up the Indexer
After the A3P instance is up and running, initiate the indexer with the following command:

```sh
AGORIC_NET=docker yarn dev
```

3. Accessing the GraphQL Interface
4. Access the GraphQL playground
Once the indexer is operational, access the GraphQL interface to query indexed data:

- Open a web browser and navigate to http://localhost:3000.
- Use the provided interface to write and execute your GraphQL queries.

### With multichain-testing

Make some transactions.

```sh
cd multichain-testing && yarn
make setup # if you've never ran starship
docker pull ghcr.io/agoric/agoric-sdk:dev # to make sure you have the latest IBC hooks changes
make stop
make start FILE=config.fusdc.yaml # wait ~7 mins
yarn test:fast-usdc test/fast-usdc/fast-usdc.test.ts
```

View [published.fastUsdc](https://vstorage.agoric.net/?endpoint=http%3A%2F%2Flocalhost%3A26657&path=published.fastUsdc)

Start a fresh indexer:

```sh
scripts/restart-dev.sh
```

Play at http://localhost:3000/

Cleanup…

```sh
cd multichain-testing
make stop
```

### Troubleshooting the Indexer

If you encounter issues with the indexer:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ services:
- ci

graphql-engine:
image: onfinality/subql-query:v2.13.0
image: onfinality/subql-query:v2.19.0
ports:
- 3000:3000
depends_on:
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "agoric-indexer",
"private": true,
"version": "0.0.1",
"description": "This is the SubQuery project for indexing the Agoric chain",
"main": "dist/index.js",
Expand All @@ -8,7 +9,6 @@
"codegen": "subql codegen",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker compose pull && docker compose --profile default up --remove-orphans --detach",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-cosmos test",
"prettier:check": "prettier --list-different . --print-width 120",
"prettier:write": "prettier --write . --print-width 120"
Expand All @@ -23,7 +23,10 @@
"author": "Agoric OpCo",
"license": "Apache-2.0",
"devDependencies": {
"@agoric/internal": "0.4.0-u18.0",
"@agoric/fast-usdc": "0.2.0-u18.0",
"@agoric/inter-protocol": "0.17.0-u18.6",
"@agoric/internal": "0.4.0-u18.1",
"@agoric/smart-wallet": "0.5.4-u18.5",
"@cosmjs/stargate": "^0.28.9",
"@endo/eventual-send": "^1.2.8",
"@subql/cli": "^5.4.0",
Expand All @@ -46,5 +49,5 @@
"resolutions": {
"@subql/node-core": "^16.1.0"
},
"packageManager": "yarn@4.5.3"
"packageManager": "yarn@4.6.0"
}
21 changes: 21 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,24 @@ type BundleInstall @entity {
compressedBundle: String!
submitter: String!
}

enum FastUsdcTransactionStatus {
OBSERVED
ADVANCING
ADVANCED
ADVANCE_FAILED
FORWARDING
FORWARDED
FORWARD_FAILED
DISBURSED
}

type FastUsdcTransaction @entity {
id: ID!
sourceAddress: String! @index
eud: String!
usdcAmount: BigInt!
status: FastUsdcTransactionStatus! @index
contractFee: BigInt
poolFee: BigInt
}
39 changes: 0 additions & 39 deletions scripts/ci.package.json

This file was deleted.

20 changes: 0 additions & 20 deletions scripts/ci.tsconfig.json

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/copy-ts-config.sh

This file was deleted.

14 changes: 14 additions & 0 deletions scripts/restart-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ueo pipefail

# clean
docker compose --profile default down
rm -rf .data

# build
yarn subql codegen >/dev/null
AGORIC_NET=docker yarn subql build >/dev/null
grep --silent host.docker.internal project.yaml || exit 1

# run
docker compose --profile default up --remove-orphans
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/// <reference types="@agoric/zoe/src/contractSupport/types-ambient"/>

//Exports all handler functions
export * from './mappings/mappingHandlers';
6 changes: 4 additions & 2 deletions src/mappings/events/boardAux.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { CosmosBlock } from '@subql/types-cosmos';
import { BoardAux } from '../../types';
import type { StreamCell } from '@agoric/internal/src/lib-chainStorage';

export const boardAuxEventKit = (block: any, data: any, module: string, path: string) => {
export const boardAuxEventKit = (block: CosmosBlock, data: StreamCell, module: string, path: string) => {
async function saveBoardAux(payload: any): Promise<Promise<any>[]> {
const boardAux = new BoardAux(
path,
BigInt(data.blockHeight),
block.block.header.time as any,
block.block.header.time as Date,
payload.allegedName,
payload.displayInfo.assetKind,
payload.displayInfo.decimalPlaces ?? 0,
Expand Down
122 changes: 122 additions & 0 deletions src/mappings/events/fastUsdc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Fast USDC events

## Transaction

Supports queries like,

```graphql
{
_metadata {
lastProcessedHeight
}
fastUsdcTransactions {
totalCount
edges {
node {
contractFee
eud
nodeId
id
poolFee
sourceAddress
status
usdcAmount
}
}
}
fastUsdcTransaction(id: "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761786") {
id
sourceAddress
usdcAmount
contractFee
eud
nodeId
poolFee
status
}
stateChangeEvents(last: 4) {
nodes {
id
}
}
}
```

Resulting in something like,

```json
{
"data": {
"_metadata": {
"lastProcessedHeight": 9141
},
"fastUsdcTransactions": {
"totalCount": 3,
"edges": [
{
"node": {
"contractFee": "1002000",
"eud": "agoric10rchpd57ggt73kmr5dssunm53jwz75pa8jjtav2ytcgwtr8fn0h5yalx8az423padaek6me30fmhzapsdqm8xwtevy6h5dpnd568jvms89m8v6nxxuexkut3ddnx663nxfuk5qpqjw8vq8",
"nodeId": "WyJmYXN0X3VzZGNfdHJhbnNhY3Rpb25zIiwiMzE4YzcxMDQtYzgxYS00ZTAyLTliNmYtOTBhYmFiODVkYmZkIl0=",
"id": "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761795",
"poolFee": "4008000",
"sourceAddress": "0x9a9eE9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9",
"status": "DISBURSED",
"usdcAmount": "2000000000"
}
},
{
"node": {
"contractFee": "1002000",
"eud": "agoric10rchpd57ggt73kmr5dssunm53jwz75pa8jjtav2ytcgwtr8fn0h5yalx8az423pav9nk7unfvvchwenhxdnrsmpevcekxu34wgekgvn4xd5r2mr5dpe8za3h0yenywtw0yehqdpsqqsqlnd2q6",
"nodeId": "WyJmYXN0X3VzZGNfdHJhbnNhY3Rpb25zIiwiNmIxZjQwODgtOTdmZC00MGJmLWE3YWItY2U3OTZmNjAzNTRhIl0=",
"id": "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761707",
"poolFee": "4008000",
"sourceAddress": "0x9a9eE9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9",
"status": "DISBURSED",
"usdcAmount": "1600000000"
}
},
{
"node": {
"contractFee": "1002000",
"eud": "agoric10rchpd57ggt73kmr5dssunm53jwz75pa8jjtav2ytcgwtr8fn0h5yalx8az423padehkymr9xyehvcmkxaehwv3swsu8gar6wc6rwupewq6kuunhxe58wdm6dfcrsm3jvdeku6qqyqjvq49q",
"nodeId": "WyJmYXN0X3VzZGNfdHJhbnNhY3Rpb25zIiwiOTQxMWMyYTgtYjAwYS00ZjgzLWJlY2MtMDU3OTU5YmUwYzk0Il0=",
"id": "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761786",
"poolFee": "4008000",
"sourceAddress": "0x9a9eE9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9",
"status": "DISBURSED",
"usdcAmount": "1000000000"
}
}
]
},
"fastUsdcTransaction": {
"id": "0xc81bc6105b60a234c7c50ac17816ebcd5561d366df8bf3be59ff387552761786",
"sourceAddress": "0x9a9eE9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9e9",
"usdcAmount": "1000000000",
"contractFee": "1002000",
"eud": "agoric10rchpd57ggt73kmr5dssunm53jwz75pa8jjtav2ytcgwtr8fn0h5yalx8az423padehkymr9xyehvcmkxaehwv3swsu8gar6wc6rwupewq6kuunhxe58wdm6dfcrsm3jvdeku6qqyqjvq49q",
"nodeId": "WyJmYXN0X3VzZGNfdHJhbnNhY3Rpb25zIiwiOTQxMWMyYTgtYjAwYS00ZjgzLWJlY2MtMDU3OTU5YmUwYzk0Il0=",
"poolFee": "4008000",
"status": "DISBURSED"
},
"stateChangeEvents": {
"nodes": [
{
"id": "6555:18:0"
},
{
"id": "303:17:1"
},
{
"id": "301:22:2"
},
{
"id": "415:18:0"
}
]
}
}
}
```
Loading

0 comments on commit ed81831

Please sign in to comment.