Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions packages/subgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Follow these steps to build and deploy the subgraph:
cd path/to/filecoin-pay-explorer/subgraph
```

2. **Install Dependencies:**
1. **Install Dependencies:**
Comment thread
silent-cipher marked this conversation as resolved.
Install the necessary node modules:

```bash
Expand All @@ -37,28 +37,21 @@ Follow these steps to build and deploy the subgraph:
yarn install
```

3. **Generate Code:**
The Graph CLI uses the `subgraph.yaml` manifest and GraphQL schema (`schema.graphql`) to generate AssemblyScript types.

```bash
npm run codegen
```

4. **Build the Subgraph:**
Compile your subgraph code into WebAssembly (WASM).
1. **Generate Code and Build the Subgraph:**
The Graph CLI uses the `subgraph.yaml` manifest and GraphQL schema (`schema.graphql`) to generate AssemblyScript types. Then compile your subgraph code into WebAssembly (WASM).

```bash
npm run build
```

5. **Authenticate with Goldsky:**
1. **Authenticate with Goldsky:**
Log in to your Goldsky account using the CLI. Go to settings section of your Goldsky dashboard to get your API key.

```bash
goldsky login
```

6. **Deploy to Goldsky:**
1. **Deploy to Goldsky:**
Use the Goldsky CLI to deploy your built subgraph.

```bash
Expand All @@ -69,7 +62,7 @@ Follow these steps to build and deploy the subgraph:
- Replace `<version>` with a version identifier (e.g., `v0.0.1`).
- You can manage your deployments and find your subgraph details in the [Goldsky Dashboard](https://app.goldsky.com/). The deployment command will output the GraphQL endpoint URL for your subgraph upon successful completion. **Copy this URL**, as you will need it for the client.

7. **Tag the Subgraph (Optional):**
1. **Tag the Subgraph (Optional):**
Tag the subgraph you deployed in step 6.

```bash
Expand Down
4 changes: 1 addition & 3 deletions packages/subgraph/config/calibration.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"network": "filecoin-testnet",
"paymentsContractAddress": "0x09a0fDc2723fAd1A7b8e3e00eE5DF73841df55a0",
"paymentsContractStartBlock": 3120649,
"usdfcContractAddress": "0xb3042734b608a1B16e9e86B374A3f3e389B4cDf0",
"usdfcContractStartBlock": 3120649
"paymentsContractStartBlock": 3120649
}
6 changes: 1 addition & 5 deletions packages/subgraph/config/mainnet.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"network": "filecoin",
"paymentsContractAddress": "0x23b1e018F08BB982348b15a86ee926eEBf7F4DAa",
"paymentsContractStartBlock": 5873369,
"usdfcContractAddress": "0x80B98d3aA09FFff255c3ba4A241111Ff1262F045",
"usdfcContractStartBlock": 5873369,
"axlUsdcContractAddress": "0xeb466342c4d449bc9f53a865d5cb90586f405215",
"axlUsdcContractStartBlock": 5873369
"paymentsContractStartBlock": 5873369
}
13 changes: 11 additions & 2 deletions packages/subgraph/src/payments.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, Bytes, dataSource, log } from "@graphprotocol/graph-ts";
import { Address, Bytes, DataSourceContext, dataSource, log } from "@graphprotocol/graph-ts";
import {
AccountLockupSettled as AccountLockupSettledEvent,
DepositRecorded as DepositRecordedEvent,
Expand All @@ -13,7 +13,8 @@ import {
WithdrawRecorded as WithdrawRecordedEvent,
} from "../generated/Payments/Payments";
import { Account, FeeAuctionPurchase, OperatorApproval, Rail, Settlement, Token, UserToken } from "../generated/schema";
import { Transfer as TransferEvent } from "../generated/USDFC/erc20";
import { TokenTemplate } from "../generated/templates";
import { Transfer as TransferEvent } from "../generated/templates/TokenTemplate/erc20";
import {
computeSettledLockup,
createOneTimePayment,
Expand Down Expand Up @@ -556,6 +557,14 @@ export function handleDepositRecorded(event: DepositRecordedEvent): void {
userToken.funds = userToken.funds.plus(amount);
userToken.save();

if (isNewToken) {
const paymentsAddress = event.address;
const context = new DataSourceContext();
context.setBytes("paymentsAddress", paymentsAddress);

TokenTemplate.createWithContext(tokenAddress, context);
}

// Collect Metrics
MetricsCollectionOrchestrator.collectTokenActivityMetrics(
tokenAddress,
Expand Down
45 changes: 5 additions & 40 deletions packages/subgraph/templates/subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,51 +59,17 @@ dataSources:
handler: handleAccountLockupSettled
file: ./src/payments.ts

# USDFC Transfer events from FilecoinPay capture fee-auction purchases (burnForFees)
templates:

# Token Transfer events from FilecoinPay capture fee-auction purchases (burnForFees)
# without needing trace_filter. burnForFees emits no event directly; instead it calls
# ERC-20 transfer to the auction recipient, producing a standard Transfer log we can
# anchor on. We filter by from == FilecoinPay and the top-level tx's function selector.

# USDFC
- kind: ethereum
name: USDFC
network: "{{network}}"
source:
abi: erc20
address: "{{usdfcContractAddress}}"
startBlock: {{usdfcContractStartBlock}}
context:
paymentsAddress:
type: Bytes
data: "{{paymentsContractAddress}}"
mapping:
kind: ethereum/events
apiVersion: 0.0.9
language: wasm/assemblyscript
entities:
- Token
- FeeAuctionPurchase
abis:
- name: erc20
file: ./config/erc20-abi.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleFeeAuctionTransfer
file: ./src/payments.ts

# axlUSDC
{{#axlUsdcContractAddress}}
- kind: ethereum
name: USDFC
- name: TokenTemplate
kind: ethereum
network: "{{network}}"
source:
abi: erc20
address: "{{axlUsdcContractAddress}}"
startBlock: {{axlUsdcContractStartBlock}}
context:
paymentsAddress:
type: Bytes
data: "{{paymentsContractAddress}}"
mapping:
kind: ethereum/events
apiVersion: 0.0.9
Expand All @@ -118,4 +84,3 @@ dataSources:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleFeeAuctionTransfer
file: ./src/payments.ts
{{/axlUsdcContractAddress}}
Loading