-
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
Showing
8 changed files
with
971 additions
and
28 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
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 |
---|---|---|
@@ -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 |
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 |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { TransactionRecord } from '@agoric/fast-usdc/src/types'; | ||
import type { StreamCell } from '@agoric/internal/src/lib-chainStorage'; | ||
import type { CosmosBlock } from '@subql/types-cosmos'; | ||
import assert from 'assert'; | ||
import { FastUsdcTransaction, FastUsdcTransactionStatus } from '../../types'; | ||
|
||
export const transactionEventKit = (block: CosmosBlock, data: StreamCell, module: string, path: string) => { | ||
async function saveTransaction(payload: TransactionRecord): Promise<Promise<any>[]> { | ||
logger.info(`saveTransaction ${JSON.stringify(payload)}`); | ||
// extract the segment after the last period | ||
const id = path.split('.').pop(); | ||
assert(id, 'saveTransaction must only be called on transaction paths'); | ||
|
||
let t: FastUsdcTransaction; | ||
if (payload.status === FastUsdcTransactionStatus.OBSERVED) { | ||
assert(payload['evidence'], 'implied by OBSERVED'); | ||
assert.equal(payload.evidence.txHash, id, 'txHash must match path'); | ||
t = FastUsdcTransaction.create({ | ||
id, | ||
eud: payload.evidence?.aux.recipientAddress, | ||
sourceAddress: payload.evidence?.tx.sender, | ||
status: payload.status, | ||
usdcAmount: payload.evidence?.tx.amount, | ||
}); | ||
} else { | ||
const found = await FastUsdcTransaction.get(id); | ||
assert(found, 'no matching transaction'); | ||
t = found; | ||
t.status = payload.status; | ||
if (payload.split) { | ||
t.contractFee = payload.split.ContractFee.value; | ||
t.poolFee = payload.split.PoolFee.value; | ||
} | ||
} | ||
|
||
return [t.save()]; | ||
} | ||
|
||
return { saveTransaction }; | ||
}; |
Oops, something went wrong.