@secondlayer/subgraphs 0.11.6 → 0.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -7
- package/dist/src/templates.d.ts +0 -12
- package/dist/src/templates.js +0 -268
- package/dist/src/templates.js.map +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/subgraphs",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -21,10 +21,6 @@
|
|
|
21
21
|
"types": "./dist/src/validate.d.ts",
|
|
22
22
|
"import": "./dist/src/validate.js"
|
|
23
23
|
},
|
|
24
|
-
"./templates": {
|
|
25
|
-
"types": "./dist/src/templates.d.ts",
|
|
26
|
-
"import": "./dist/src/templates.js"
|
|
27
|
-
},
|
|
28
24
|
"./runtime/source-matcher": {
|
|
29
25
|
"types": "./dist/src/runtime/source-matcher.d.ts",
|
|
30
26
|
"import": "./dist/src/runtime/source-matcher.js"
|
|
@@ -41,8 +37,8 @@
|
|
|
41
37
|
"prepublishOnly": "bun run build"
|
|
42
38
|
},
|
|
43
39
|
"dependencies": {
|
|
44
|
-
"@secondlayer/shared": "^1.
|
|
45
|
-
"@secondlayer/stacks": "^0.
|
|
40
|
+
"@secondlayer/shared": "^1.1.0",
|
|
41
|
+
"@secondlayer/stacks": "^0.3.0",
|
|
46
42
|
"kysely": "0.28.15",
|
|
47
43
|
"postgres": "^3.4.6",
|
|
48
44
|
"zod": "^4.3.6"
|
package/dist/src/templates.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
interface SubgraphTemplate {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
category: "defi" | "nft" | "token" | "infrastructure";
|
|
6
|
-
code: string;
|
|
7
|
-
prompt: string;
|
|
8
|
-
}
|
|
9
|
-
declare const templates: SubgraphTemplate[];
|
|
10
|
-
declare function getTemplateById(id: string): SubgraphTemplate | undefined;
|
|
11
|
-
declare function getTemplatesByCategory(category: string): SubgraphTemplate[];
|
|
12
|
-
export { templates, getTemplatesByCategory, getTemplateById, SubgraphTemplate };
|
package/dist/src/templates.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
// src/templates.ts
|
|
5
|
-
var templates = [
|
|
6
|
-
{
|
|
7
|
-
id: "dex-swaps",
|
|
8
|
-
name: "DEX Swap Tracking",
|
|
9
|
-
description: "Track swap events from ALEX or any AMM pool. Indexes token pairs, amounts, and traders.",
|
|
10
|
-
category: "defi",
|
|
11
|
-
code: `import { defineSubgraph } from '@secondlayer/subgraphs';
|
|
12
|
-
|
|
13
|
-
export default defineSubgraph({
|
|
14
|
-
name: 'dex-swaps',
|
|
15
|
-
sources: {
|
|
16
|
-
swap: { type: 'print_event', contractId: 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01', topic: 'swap' },
|
|
17
|
-
},
|
|
18
|
-
schema: {
|
|
19
|
-
swaps: {
|
|
20
|
-
columns: {
|
|
21
|
-
sender: { type: 'principal', indexed: true },
|
|
22
|
-
token_x: { type: 'text' },
|
|
23
|
-
token_y: { type: 'text' },
|
|
24
|
-
amount_x: { type: 'uint' },
|
|
25
|
-
amount_y: { type: 'uint' },
|
|
26
|
-
},
|
|
27
|
-
indexes: [['sender', 'token_x']],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
handlers: {
|
|
31
|
-
swap: (event, ctx) => {
|
|
32
|
-
ctx.insert('swaps', {
|
|
33
|
-
sender: ctx.tx.sender,
|
|
34
|
-
token_x: event.data.tokenX,
|
|
35
|
-
token_y: event.data.tokenY,
|
|
36
|
-
amount_x: event.data.dx,
|
|
37
|
-
amount_y: event.data.dy,
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
`,
|
|
43
|
-
prompt: "Create a Secondlayer subgraph that tracks DEX swap events from ALEX AMM pool. Index sender, token pairs, and amounts."
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: "nft-marketplace",
|
|
47
|
-
name: "NFT Marketplace",
|
|
48
|
-
description: "Index NFT listings, sales, and cancellations. Track prices and ownership changes.",
|
|
49
|
-
category: "nft",
|
|
50
|
-
code: `import { defineSubgraph } from '@secondlayer/subgraphs';
|
|
51
|
-
|
|
52
|
-
export default defineSubgraph({
|
|
53
|
-
name: 'nft-marketplace',
|
|
54
|
-
sources: {
|
|
55
|
-
listItem: { type: 'print_event', contractId: 'SP...marketplace', topic: 'list-item' },
|
|
56
|
-
unlistItem: { type: 'print_event', contractId: 'SP...marketplace', topic: 'unlist-item' },
|
|
57
|
-
purchase: { type: 'print_event', contractId: 'SP...marketplace', topic: 'purchase' },
|
|
58
|
-
},
|
|
59
|
-
schema: {
|
|
60
|
-
listings: {
|
|
61
|
-
columns: {
|
|
62
|
-
nft_id: { type: 'uint', indexed: true },
|
|
63
|
-
seller: { type: 'principal', indexed: true },
|
|
64
|
-
price: { type: 'uint' },
|
|
65
|
-
status: { type: 'text' },
|
|
66
|
-
},
|
|
67
|
-
uniqueKeys: [['nft_id']],
|
|
68
|
-
},
|
|
69
|
-
sales: {
|
|
70
|
-
columns: {
|
|
71
|
-
nft_id: { type: 'uint', indexed: true },
|
|
72
|
-
seller: { type: 'principal' },
|
|
73
|
-
buyer: { type: 'principal', indexed: true },
|
|
74
|
-
price: { type: 'uint' },
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
handlers: {
|
|
79
|
-
listItem: (event, ctx) => {
|
|
80
|
-
ctx.upsert('listings', { nft_id: event.data.nftId }, {
|
|
81
|
-
nft_id: event.data.nftId,
|
|
82
|
-
seller: ctx.tx.sender,
|
|
83
|
-
price: event.data.price,
|
|
84
|
-
status: 'active',
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
unlistItem: (event, ctx) => {
|
|
88
|
-
ctx.update('listings', { nft_id: event.data.nftId }, { status: 'cancelled' });
|
|
89
|
-
},
|
|
90
|
-
purchase: (event, ctx) => {
|
|
91
|
-
ctx.update('listings', { nft_id: event.data.nftId }, { status: 'sold' });
|
|
92
|
-
ctx.insert('sales', {
|
|
93
|
-
nft_id: event.data.nftId,
|
|
94
|
-
seller: event.data.seller,
|
|
95
|
-
buyer: ctx.tx.sender,
|
|
96
|
-
price: event.data.price,
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
`,
|
|
102
|
-
prompt: "Create a Secondlayer subgraph for an NFT marketplace. Track listings, cancellations, and sales with prices."
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
id: "token-transfers",
|
|
106
|
-
name: "Token Transfers",
|
|
107
|
-
description: "Track fungible token transfers with running balance computation per address.",
|
|
108
|
-
category: "token",
|
|
109
|
-
code: `import { defineSubgraph } from '@secondlayer/subgraphs';
|
|
110
|
-
|
|
111
|
-
export default defineSubgraph({
|
|
112
|
-
name: 'token-transfers',
|
|
113
|
-
sources: {
|
|
114
|
-
transfer: { type: 'ft_transfer', assetIdentifier: 'SP...token' },
|
|
115
|
-
},
|
|
116
|
-
schema: {
|
|
117
|
-
transfers: {
|
|
118
|
-
columns: {
|
|
119
|
-
from_addr: { type: 'principal', indexed: true },
|
|
120
|
-
to_addr: { type: 'principal', indexed: true },
|
|
121
|
-
amount: { type: 'uint' },
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
balances: {
|
|
125
|
-
columns: {
|
|
126
|
-
address: { type: 'principal', indexed: true },
|
|
127
|
-
balance: { type: 'uint' },
|
|
128
|
-
},
|
|
129
|
-
uniqueKeys: [['address']],
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
handlers: {
|
|
133
|
-
transfer: async (event, ctx) => {
|
|
134
|
-
ctx.insert('transfers', {
|
|
135
|
-
from_addr: event.sender,
|
|
136
|
-
to_addr: event.recipient,
|
|
137
|
-
amount: event.amount,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Update sender balance
|
|
141
|
-
const senderBal = await ctx.findOne('balances', { address: event.sender });
|
|
142
|
-
const senderPrev = senderBal ? BigInt(senderBal.balance as string) : 0n;
|
|
143
|
-
ctx.upsert('balances', { address: event.sender }, {
|
|
144
|
-
address: event.sender,
|
|
145
|
-
balance: senderPrev - event.amount,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
// Update recipient balance
|
|
149
|
-
const recipBal = await ctx.findOne('balances', { address: event.recipient });
|
|
150
|
-
const recipPrev = recipBal ? BigInt(recipBal.balance as string) : 0n;
|
|
151
|
-
ctx.upsert('balances', { address: event.recipient }, {
|
|
152
|
-
address: event.recipient,
|
|
153
|
-
balance: recipPrev + event.amount,
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
`,
|
|
159
|
-
prompt: "Create a Secondlayer subgraph that tracks token transfers and computes running balances per address."
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
id: "bns-names",
|
|
163
|
-
name: "BNS Names",
|
|
164
|
-
description: "Index BNS name registrations and transfers. Search names by owner or namespace.",
|
|
165
|
-
category: "infrastructure",
|
|
166
|
-
code: `import { defineSubgraph } from '@secondlayer/subgraphs';
|
|
167
|
-
|
|
168
|
-
export default defineSubgraph({
|
|
169
|
-
name: 'bns-names',
|
|
170
|
-
sources: {
|
|
171
|
-
nameRegister: { type: 'contract_call', contractId: 'SP000000000000000000002Q6VF78.bns', functionName: 'name-register' },
|
|
172
|
-
nameTransfer: { type: 'contract_call', contractId: 'SP000000000000000000002Q6VF78.bns', functionName: 'name-transfer' },
|
|
173
|
-
},
|
|
174
|
-
schema: {
|
|
175
|
-
names: {
|
|
176
|
-
columns: {
|
|
177
|
-
name: { type: 'text', indexed: true, search: true },
|
|
178
|
-
namespace: { type: 'text', indexed: true },
|
|
179
|
-
owner: { type: 'principal', indexed: true },
|
|
180
|
-
},
|
|
181
|
-
uniqueKeys: [['name', 'namespace']],
|
|
182
|
-
},
|
|
183
|
-
transfers: {
|
|
184
|
-
columns: {
|
|
185
|
-
name: { type: 'text' },
|
|
186
|
-
namespace: { type: 'text' },
|
|
187
|
-
from_addr: { type: 'principal' },
|
|
188
|
-
to_addr: { type: 'principal' },
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
handlers: {
|
|
193
|
-
nameRegister: (event, ctx) => {
|
|
194
|
-
ctx.upsert('names', { name: event.args.name, namespace: event.args.namespace }, {
|
|
195
|
-
name: event.args.name,
|
|
196
|
-
namespace: event.args.namespace,
|
|
197
|
-
owner: ctx.tx.sender,
|
|
198
|
-
});
|
|
199
|
-
},
|
|
200
|
-
nameTransfer: (event, ctx) => {
|
|
201
|
-
ctx.update('names', { name: event.args.name, namespace: event.args.namespace }, {
|
|
202
|
-
owner: event.args.newOwner,
|
|
203
|
-
});
|
|
204
|
-
ctx.insert('transfers', {
|
|
205
|
-
name: event.args.name,
|
|
206
|
-
namespace: event.args.namespace,
|
|
207
|
-
from_addr: event.args.sender,
|
|
208
|
-
to_addr: event.args.newOwner,
|
|
209
|
-
});
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
`,
|
|
214
|
-
prompt: "Create a Secondlayer subgraph for BNS name registrations and transfers on Stacks."
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
id: "stx-whales",
|
|
218
|
-
name: "STX Whale Alerts",
|
|
219
|
-
description: "Track large STX transfers above a configurable threshold. Great for monitoring whale activity.",
|
|
220
|
-
category: "token",
|
|
221
|
-
code: `import { defineSubgraph } from '@secondlayer/subgraphs';
|
|
222
|
-
|
|
223
|
-
const WHALE_THRESHOLD = 100_000_000_000n; // 100k STX in microSTX
|
|
224
|
-
|
|
225
|
-
export default defineSubgraph({
|
|
226
|
-
name: 'stx-whales',
|
|
227
|
-
sources: {
|
|
228
|
-
stxTransfer: { type: 'stx_transfer' },
|
|
229
|
-
},
|
|
230
|
-
schema: {
|
|
231
|
-
whale_transfers: {
|
|
232
|
-
columns: {
|
|
233
|
-
sender: { type: 'principal', indexed: true },
|
|
234
|
-
receiver: { type: 'principal', indexed: true },
|
|
235
|
-
amount: { type: 'uint' },
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
handlers: {
|
|
240
|
-
stxTransfer: (event, ctx) => {
|
|
241
|
-
if (event.amount >= WHALE_THRESHOLD) {
|
|
242
|
-
ctx.insert('whale_transfers', {
|
|
243
|
-
sender: event.sender,
|
|
244
|
-
receiver: event.recipient,
|
|
245
|
-
amount: event.amount,
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
`,
|
|
252
|
-
prompt: "Create a Secondlayer subgraph that tracks STX transfers above 100k STX as whale alerts."
|
|
253
|
-
}
|
|
254
|
-
];
|
|
255
|
-
function getTemplateById(id) {
|
|
256
|
-
return templates.find((t) => t.id === id);
|
|
257
|
-
}
|
|
258
|
-
function getTemplatesByCategory(category) {
|
|
259
|
-
return templates.filter((t) => t.category === category);
|
|
260
|
-
}
|
|
261
|
-
export {
|
|
262
|
-
templates,
|
|
263
|
-
getTemplatesByCategory,
|
|
264
|
-
getTemplateById
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
//# debugId=F4B252C88EAA2F7964756E2164756E21
|
|
268
|
-
//# sourceMappingURL=templates.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/templates.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"export interface SubgraphTemplate {\n\tid: string;\n\tname: string;\n\tdescription: string;\n\tcategory: \"defi\" | \"nft\" | \"token\" | \"infrastructure\";\n\tcode: string;\n\tprompt: string;\n}\n\nexport const templates: SubgraphTemplate[] = [\n\t{\n\t\tid: \"dex-swaps\",\n\t\tname: \"DEX Swap Tracking\",\n\t\tdescription:\n\t\t\t\"Track swap events from ALEX or any AMM pool. Indexes token pairs, amounts, and traders.\",\n\t\tcategory: \"defi\",\n\t\tcode: `import { defineSubgraph } from '@secondlayer/subgraphs';\n\nexport default defineSubgraph({\n name: 'dex-swaps',\n sources: {\n swap: { type: 'print_event', contractId: 'SP102V8P0F7JX67ARQ77WEA3D3CFB5XW39REDT0AM.amm-pool-v2-01', topic: 'swap' },\n },\n schema: {\n swaps: {\n columns: {\n sender: { type: 'principal', indexed: true },\n token_x: { type: 'text' },\n token_y: { type: 'text' },\n amount_x: { type: 'uint' },\n amount_y: { type: 'uint' },\n },\n indexes: [['sender', 'token_x']],\n },\n },\n handlers: {\n swap: (event, ctx) => {\n ctx.insert('swaps', {\n sender: ctx.tx.sender,\n token_x: event.data.tokenX,\n token_y: event.data.tokenY,\n amount_x: event.data.dx,\n amount_y: event.data.dy,\n });\n },\n },\n});\n`,\n\t\tprompt:\n\t\t\t\"Create a Secondlayer subgraph that tracks DEX swap events from ALEX AMM pool. Index sender, token pairs, and amounts.\",\n\t},\n\t{\n\t\tid: \"nft-marketplace\",\n\t\tname: \"NFT Marketplace\",\n\t\tdescription:\n\t\t\t\"Index NFT listings, sales, and cancellations. Track prices and ownership changes.\",\n\t\tcategory: \"nft\",\n\t\tcode: `import { defineSubgraph } from '@secondlayer/subgraphs';\n\nexport default defineSubgraph({\n name: 'nft-marketplace',\n sources: {\n listItem: { type: 'print_event', contractId: 'SP...marketplace', topic: 'list-item' },\n unlistItem: { type: 'print_event', contractId: 'SP...marketplace', topic: 'unlist-item' },\n purchase: { type: 'print_event', contractId: 'SP...marketplace', topic: 'purchase' },\n },\n schema: {\n listings: {\n columns: {\n nft_id: { type: 'uint', indexed: true },\n seller: { type: 'principal', indexed: true },\n price: { type: 'uint' },\n status: { type: 'text' },\n },\n uniqueKeys: [['nft_id']],\n },\n sales: {\n columns: {\n nft_id: { type: 'uint', indexed: true },\n seller: { type: 'principal' },\n buyer: { type: 'principal', indexed: true },\n price: { type: 'uint' },\n },\n },\n },\n handlers: {\n listItem: (event, ctx) => {\n ctx.upsert('listings', { nft_id: event.data.nftId }, {\n nft_id: event.data.nftId,\n seller: ctx.tx.sender,\n price: event.data.price,\n status: 'active',\n });\n },\n unlistItem: (event, ctx) => {\n ctx.update('listings', { nft_id: event.data.nftId }, { status: 'cancelled' });\n },\n purchase: (event, ctx) => {\n ctx.update('listings', { nft_id: event.data.nftId }, { status: 'sold' });\n ctx.insert('sales', {\n nft_id: event.data.nftId,\n seller: event.data.seller,\n buyer: ctx.tx.sender,\n price: event.data.price,\n });\n },\n },\n});\n`,\n\t\tprompt:\n\t\t\t\"Create a Secondlayer subgraph for an NFT marketplace. Track listings, cancellations, and sales with prices.\",\n\t},\n\t{\n\t\tid: \"token-transfers\",\n\t\tname: \"Token Transfers\",\n\t\tdescription:\n\t\t\t\"Track fungible token transfers with running balance computation per address.\",\n\t\tcategory: \"token\",\n\t\tcode: `import { defineSubgraph } from '@secondlayer/subgraphs';\n\nexport default defineSubgraph({\n name: 'token-transfers',\n sources: {\n transfer: { type: 'ft_transfer', assetIdentifier: 'SP...token' },\n },\n schema: {\n transfers: {\n columns: {\n from_addr: { type: 'principal', indexed: true },\n to_addr: { type: 'principal', indexed: true },\n amount: { type: 'uint' },\n },\n },\n balances: {\n columns: {\n address: { type: 'principal', indexed: true },\n balance: { type: 'uint' },\n },\n uniqueKeys: [['address']],\n },\n },\n handlers: {\n transfer: async (event, ctx) => {\n ctx.insert('transfers', {\n from_addr: event.sender,\n to_addr: event.recipient,\n amount: event.amount,\n });\n\n // Update sender balance\n const senderBal = await ctx.findOne('balances', { address: event.sender });\n const senderPrev = senderBal ? BigInt(senderBal.balance as string) : 0n;\n ctx.upsert('balances', { address: event.sender }, {\n address: event.sender,\n balance: senderPrev - event.amount,\n });\n\n // Update recipient balance\n const recipBal = await ctx.findOne('balances', { address: event.recipient });\n const recipPrev = recipBal ? BigInt(recipBal.balance as string) : 0n;\n ctx.upsert('balances', { address: event.recipient }, {\n address: event.recipient,\n balance: recipPrev + event.amount,\n });\n },\n },\n});\n`,\n\t\tprompt:\n\t\t\t\"Create a Secondlayer subgraph that tracks token transfers and computes running balances per address.\",\n\t},\n\t{\n\t\tid: \"bns-names\",\n\t\tname: \"BNS Names\",\n\t\tdescription:\n\t\t\t\"Index BNS name registrations and transfers. Search names by owner or namespace.\",\n\t\tcategory: \"infrastructure\",\n\t\tcode: `import { defineSubgraph } from '@secondlayer/subgraphs';\n\nexport default defineSubgraph({\n name: 'bns-names',\n sources: {\n nameRegister: { type: 'contract_call', contractId: 'SP000000000000000000002Q6VF78.bns', functionName: 'name-register' },\n nameTransfer: { type: 'contract_call', contractId: 'SP000000000000000000002Q6VF78.bns', functionName: 'name-transfer' },\n },\n schema: {\n names: {\n columns: {\n name: { type: 'text', indexed: true, search: true },\n namespace: { type: 'text', indexed: true },\n owner: { type: 'principal', indexed: true },\n },\n uniqueKeys: [['name', 'namespace']],\n },\n transfers: {\n columns: {\n name: { type: 'text' },\n namespace: { type: 'text' },\n from_addr: { type: 'principal' },\n to_addr: { type: 'principal' },\n },\n },\n },\n handlers: {\n nameRegister: (event, ctx) => {\n ctx.upsert('names', { name: event.args.name, namespace: event.args.namespace }, {\n name: event.args.name,\n namespace: event.args.namespace,\n owner: ctx.tx.sender,\n });\n },\n nameTransfer: (event, ctx) => {\n ctx.update('names', { name: event.args.name, namespace: event.args.namespace }, {\n owner: event.args.newOwner,\n });\n ctx.insert('transfers', {\n name: event.args.name,\n namespace: event.args.namespace,\n from_addr: event.args.sender,\n to_addr: event.args.newOwner,\n });\n },\n },\n});\n`,\n\t\tprompt:\n\t\t\t\"Create a Secondlayer subgraph for BNS name registrations and transfers on Stacks.\",\n\t},\n\t{\n\t\tid: \"stx-whales\",\n\t\tname: \"STX Whale Alerts\",\n\t\tdescription:\n\t\t\t\"Track large STX transfers above a configurable threshold. Great for monitoring whale activity.\",\n\t\tcategory: \"token\",\n\t\tcode: `import { defineSubgraph } from '@secondlayer/subgraphs';\n\nconst WHALE_THRESHOLD = 100_000_000_000n; // 100k STX in microSTX\n\nexport default defineSubgraph({\n name: 'stx-whales',\n sources: {\n stxTransfer: { type: 'stx_transfer' },\n },\n schema: {\n whale_transfers: {\n columns: {\n sender: { type: 'principal', indexed: true },\n receiver: { type: 'principal', indexed: true },\n amount: { type: 'uint' },\n },\n },\n },\n handlers: {\n stxTransfer: (event, ctx) => {\n if (event.amount >= WHALE_THRESHOLD) {\n ctx.insert('whale_transfers', {\n sender: event.sender,\n receiver: event.recipient,\n amount: event.amount,\n });\n }\n },\n },\n});\n`,\n\t\tprompt:\n\t\t\t\"Create a Secondlayer subgraph that tracks STX transfers above 100k STX as whale alerts.\",\n\t},\n];\n\nexport function getTemplateById(id: string): SubgraphTemplate | undefined {\n\treturn templates.find((t) => t.id === id);\n}\n\nexport function getTemplatesByCategory(category: string): SubgraphTemplate[] {\n\treturn templates.filter((t) => t.category === category);\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;AASO,IAAM,YAAgC;AAAA,EAC5C;AAAA,IACC,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,aACC;AAAA,IACD,UAAU;AAAA,IACV,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgCN,QACC;AAAA,EACF;AAAA,EACA;AAAA,IACC,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,aACC;AAAA,IACD,U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