aavegotchi-cli 0.1.0 → 0.2.0

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/dist/schemas.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.batchPlanSchema = exports.batchStepSchema = exports.legacyCliConfigSchema = exports.cliConfigSchema = exports.profileSchema = exports.policySchema = exports.signerSchema = void 0;
3
+ exports.gbmBidSchema = exports.gbmAuctionSchema = exports.baazaarErc1155ListingSchema = exports.baazaarErc721ListingSchema = exports.subgraphVariablesSchema = exports.batchPlanSchema = exports.batchStepSchema = exports.legacyCliConfigSchema = exports.cliConfigSchema = exports.profileSchema = exports.policySchema = exports.signerSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const addressSchema = zod_1.z
6
6
  .string()
@@ -77,3 +77,61 @@ exports.batchPlanSchema = zod_1.z.object({
77
77
  continueOnError: zod_1.z.boolean().optional(),
78
78
  steps: zod_1.z.array(exports.batchStepSchema).min(1),
79
79
  });
80
+ exports.subgraphVariablesSchema = zod_1.z.object({}).catchall(zod_1.z.unknown());
81
+ exports.baazaarErc721ListingSchema = zod_1.z.object({
82
+ id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value) => String(value)),
83
+ category: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value) => String(value)),
84
+ erc721TokenAddress: addressSchema,
85
+ tokenId: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
86
+ seller: addressSchema,
87
+ priceInWei: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
88
+ cancelled: zod_1.z.boolean(),
89
+ timeCreated: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
90
+ timePurchased: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
91
+ });
92
+ exports.baazaarErc1155ListingSchema = zod_1.z.object({
93
+ id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value) => String(value)),
94
+ category: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value) => String(value)),
95
+ erc1155TokenAddress: addressSchema,
96
+ erc1155TypeId: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
97
+ quantity: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
98
+ seller: addressSchema,
99
+ priceInWei: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
100
+ cancelled: zod_1.z.boolean(),
101
+ sold: zod_1.z.boolean(),
102
+ timeCreated: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
103
+ });
104
+ exports.gbmAuctionSchema = zod_1.z.object({
105
+ id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value) => String(value)),
106
+ type: zod_1.z.string().optional(),
107
+ contractAddress: addressSchema,
108
+ tokenId: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
109
+ quantity: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
110
+ seller: addressSchema,
111
+ highestBid: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
112
+ highestBidder: addressSchema.optional(),
113
+ totalBids: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
114
+ startsAt: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
115
+ endsAt: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
116
+ claimAt: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)).optional(),
117
+ claimed: zod_1.z.boolean(),
118
+ cancelled: zod_1.z.boolean(),
119
+ presetId: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)).optional(),
120
+ category: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)).optional(),
121
+ buyNowPrice: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)).optional(),
122
+ startBidPrice: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)).optional(),
123
+ });
124
+ exports.gbmBidSchema = zod_1.z.object({
125
+ id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value) => String(value)),
126
+ bidder: addressSchema,
127
+ amount: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
128
+ bidTime: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)),
129
+ outbid: zod_1.z.boolean(),
130
+ previousBid: zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.bigint()]).transform((value) => String(value)).optional(),
131
+ previousBidder: addressSchema.optional(),
132
+ auction: zod_1.z
133
+ .object({
134
+ id: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).transform((value) => String(value)),
135
+ })
136
+ .optional(),
137
+ });
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeSubgraphQuery = executeSubgraphQuery;
4
+ const errors_1 = require("../errors");
5
+ const sources_1 = require("./sources");
6
+ const DEFAULT_TIMEOUT_MS = 10000;
7
+ const DEFAULT_RETRIES = 1;
8
+ const DEFAULT_AUTH_ENV_VAR = "GOLDSKY_API_KEY";
9
+ function ensureAuthEnvVarName(value) {
10
+ if (!/^[A-Z_][A-Z0-9_]*$/.test(value)) {
11
+ throw new errors_1.CliError("INVALID_ARGUMENT", `Invalid auth env var '${value}'.`, 2, {
12
+ authEnvVar: value,
13
+ });
14
+ }
15
+ return value;
16
+ }
17
+ async function fetchWithTimeout(url, init, timeoutMs, details) {
18
+ const controller = new AbortController();
19
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
20
+ try {
21
+ return await fetch(url, {
22
+ ...init,
23
+ signal: controller.signal,
24
+ });
25
+ }
26
+ catch (error) {
27
+ if (error instanceof Error && error.name === "AbortError") {
28
+ throw new errors_1.CliError("SUBGRAPH_TIMEOUT", `Subgraph query timed out after ${timeoutMs}ms.`, 2, {
29
+ ...details,
30
+ timeoutMs,
31
+ });
32
+ }
33
+ throw new errors_1.CliError("SUBGRAPH_HTTP_ERROR", "Failed to reach subgraph endpoint.", 2, {
34
+ ...details,
35
+ message: error instanceof Error ? error.message : String(error),
36
+ });
37
+ }
38
+ finally {
39
+ clearTimeout(timer);
40
+ }
41
+ }
42
+ function parseGraphQlPayload(raw, details) {
43
+ let parsed;
44
+ try {
45
+ parsed = JSON.parse(raw);
46
+ }
47
+ catch {
48
+ throw new errors_1.CliError("SUBGRAPH_INVALID_RESPONSE", "Subgraph response was not valid JSON.", 2, details);
49
+ }
50
+ if (!parsed || typeof parsed !== "object") {
51
+ throw new errors_1.CliError("SUBGRAPH_INVALID_RESPONSE", "Subgraph response shape is invalid.", 2, details);
52
+ }
53
+ return parsed;
54
+ }
55
+ function isRetriableError(error) {
56
+ return error.code === "SUBGRAPH_TIMEOUT" || error.code === "SUBGRAPH_HTTP_ERROR";
57
+ }
58
+ async function executeSubgraphQuery(options) {
59
+ const resolved = (0, sources_1.resolveSubgraphEndpoint)({
60
+ source: options.source,
61
+ subgraphUrl: options.subgraphUrl,
62
+ allowUntrustedSubgraph: options.allowUntrustedSubgraph,
63
+ });
64
+ const authEnvVar = ensureAuthEnvVarName(options.authEnvVar || DEFAULT_AUTH_ENV_VAR);
65
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
66
+ if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
67
+ throw new errors_1.CliError("INVALID_ARGUMENT", "--timeout-ms must be a positive integer.", 2, {
68
+ timeoutMs,
69
+ });
70
+ }
71
+ const retries = DEFAULT_RETRIES;
72
+ const headers = {
73
+ "content-type": "application/json",
74
+ };
75
+ const authToken = process.env[authEnvVar];
76
+ if (authToken) {
77
+ headers.authorization = `Bearer ${authToken}`;
78
+ }
79
+ const requestBody = JSON.stringify({
80
+ query: options.query,
81
+ variables: options.variables || {},
82
+ });
83
+ const requestDetails = {
84
+ source: resolved.source,
85
+ endpoint: resolved.endpoint,
86
+ queryName: options.queryName,
87
+ };
88
+ let lastError;
89
+ for (let attempt = 0; attempt <= retries; attempt++) {
90
+ try {
91
+ const response = await fetchWithTimeout(resolved.endpoint, {
92
+ method: "POST",
93
+ headers,
94
+ body: requestBody,
95
+ }, timeoutMs, requestDetails);
96
+ const responseText = await response.text();
97
+ if (!response.ok) {
98
+ throw new errors_1.CliError("SUBGRAPH_HTTP_ERROR", `Subgraph endpoint returned HTTP ${response.status}.`, 2, {
99
+ ...requestDetails,
100
+ status: response.status,
101
+ body: responseText.slice(0, 500),
102
+ });
103
+ }
104
+ const payload = parseGraphQlPayload(responseText, requestDetails);
105
+ if (Array.isArray(payload.errors) && payload.errors.length > 0) {
106
+ throw new errors_1.CliError("SUBGRAPH_GRAPHQL_ERROR", "Subgraph query returned GraphQL errors.", 2, {
107
+ ...requestDetails,
108
+ errors: payload.errors,
109
+ });
110
+ }
111
+ if (!("data" in payload)) {
112
+ throw new errors_1.CliError("SUBGRAPH_INVALID_RESPONSE", "Subgraph response missing 'data' field.", 2, requestDetails);
113
+ }
114
+ return {
115
+ source: resolved.source,
116
+ endpoint: resolved.endpoint,
117
+ queryName: options.queryName,
118
+ data: payload.data,
119
+ ...(options.raw ? { raw: payload } : {}),
120
+ };
121
+ }
122
+ catch (error) {
123
+ if (error instanceof errors_1.CliError) {
124
+ lastError = error;
125
+ if (attempt < retries && isRetriableError(error)) {
126
+ continue;
127
+ }
128
+ throw error;
129
+ }
130
+ lastError = new errors_1.CliError("SUBGRAPH_HTTP_ERROR", "Subgraph request failed.", 2, {
131
+ ...requestDetails,
132
+ message: error instanceof Error ? error.message : String(error),
133
+ });
134
+ if (attempt < retries) {
135
+ continue;
136
+ }
137
+ throw lastError;
138
+ }
139
+ }
140
+ throw (lastError ||
141
+ new errors_1.CliError("SUBGRAPH_HTTP_ERROR", "Subgraph request failed.", 2, {
142
+ ...requestDetails,
143
+ }));
144
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toLowercaseAddress = toLowercaseAddress;
4
+ exports.normalizeBaazaarErc721Listing = normalizeBaazaarErc721Listing;
5
+ exports.normalizeBaazaarErc1155Listing = normalizeBaazaarErc1155Listing;
6
+ exports.normalizeGbmAuction = normalizeGbmAuction;
7
+ exports.normalizeGbmBid = normalizeGbmBid;
8
+ exports.normalizeBaazaarErc721Listings = normalizeBaazaarErc721Listings;
9
+ exports.normalizeBaazaarErc1155Listings = normalizeBaazaarErc1155Listings;
10
+ exports.normalizeGbmAuctions = normalizeGbmAuctions;
11
+ exports.normalizeGbmBids = normalizeGbmBids;
12
+ const schemas_1 = require("../schemas");
13
+ const errors_1 = require("../errors");
14
+ function toNormalizeError(message, details) {
15
+ return new errors_1.CliError("SUBGRAPH_INVALID_RESPONSE", message, 2, details);
16
+ }
17
+ function toLowercaseAddress(value) {
18
+ if (!/^0x[a-fA-F0-9]{40}$/.test(value)) {
19
+ throw toNormalizeError("Subgraph response includes invalid address.", {
20
+ value,
21
+ });
22
+ }
23
+ return value.toLowerCase();
24
+ }
25
+ function parseWithSchema(name, value, parser) {
26
+ try {
27
+ return parser.parse(value);
28
+ }
29
+ catch (error) {
30
+ throw toNormalizeError(`Failed to parse subgraph payload for ${name}.`, {
31
+ name,
32
+ message: error instanceof Error ? error.message : String(error),
33
+ });
34
+ }
35
+ }
36
+ function normalizeBaazaarErc721Listing(value) {
37
+ const parsed = parseWithSchema("erc721Listing", value, schemas_1.baazaarErc721ListingSchema);
38
+ return {
39
+ ...parsed,
40
+ erc721TokenAddress: toLowercaseAddress(parsed.erc721TokenAddress),
41
+ seller: toLowercaseAddress(parsed.seller),
42
+ };
43
+ }
44
+ function normalizeBaazaarErc1155Listing(value) {
45
+ const parsed = parseWithSchema("erc1155Listing", value, schemas_1.baazaarErc1155ListingSchema);
46
+ return {
47
+ ...parsed,
48
+ erc1155TokenAddress: toLowercaseAddress(parsed.erc1155TokenAddress),
49
+ seller: toLowercaseAddress(parsed.seller),
50
+ };
51
+ }
52
+ function normalizeGbmAuction(value) {
53
+ const parsed = parseWithSchema("auction", value, schemas_1.gbmAuctionSchema);
54
+ return {
55
+ ...parsed,
56
+ contractAddress: toLowercaseAddress(parsed.contractAddress),
57
+ seller: toLowercaseAddress(parsed.seller),
58
+ ...(parsed.highestBidder ? { highestBidder: toLowercaseAddress(parsed.highestBidder) } : {}),
59
+ };
60
+ }
61
+ function normalizeGbmBid(value) {
62
+ const parsed = parseWithSchema("bid", value, schemas_1.gbmBidSchema);
63
+ return {
64
+ id: parsed.id,
65
+ bidder: toLowercaseAddress(parsed.bidder),
66
+ amount: parsed.amount,
67
+ bidTime: parsed.bidTime,
68
+ outbid: parsed.outbid,
69
+ ...(parsed.previousBid ? { previousBid: parsed.previousBid } : {}),
70
+ ...(parsed.previousBidder ? { previousBidder: toLowercaseAddress(parsed.previousBidder) } : {}),
71
+ ...(parsed.auction?.id ? { auctionId: parsed.auction.id } : {}),
72
+ };
73
+ }
74
+ function normalizeBaazaarErc721Listings(values) {
75
+ return values.map((value) => normalizeBaazaarErc721Listing(value));
76
+ }
77
+ function normalizeBaazaarErc1155Listings(values) {
78
+ return values.map((value) => normalizeBaazaarErc1155Listing(value));
79
+ }
80
+ function normalizeGbmAuctions(values) {
81
+ return values.map((value) => normalizeGbmAuction(value));
82
+ }
83
+ function normalizeGbmBids(values) {
84
+ return values.map((value) => normalizeGbmBid(value));
85
+ }
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GBM_BIDS_BY_BIDDER_QUERY = exports.GBM_BIDS_BY_AUCTION_QUERY = exports.GBM_MINE_AUCTIONS_QUERY = exports.GBM_ACTIVE_AUCTIONS_QUERY = exports.GBM_AUCTION_BY_ID_QUERY = exports.BAAZAAR_MINE_ERC1155_QUERY = exports.BAAZAAR_MINE_ERC721_QUERY = exports.BAAZAAR_ACTIVE_ERC1155_QUERY = exports.BAAZAAR_ACTIVE_ERC721_QUERY = exports.BAAZAAR_ERC1155_LISTING_BY_ID_QUERY = exports.BAAZAAR_ERC721_LISTING_BY_ID_QUERY = exports.SUBGRAPH_INTROSPECTION_QUERY = void 0;
4
+ exports.SUBGRAPH_INTROSPECTION_QUERY = `
5
+ query {
6
+ __schema {
7
+ queryType {
8
+ fields {
9
+ name
10
+ }
11
+ }
12
+ }
13
+ }
14
+ `.trim();
15
+ exports.BAAZAAR_ERC721_LISTING_BY_ID_QUERY = `
16
+ query($id: ID!) {
17
+ erc721Listing(id: $id) {
18
+ id
19
+ category
20
+ erc721TokenAddress
21
+ tokenId
22
+ seller
23
+ priceInWei
24
+ cancelled
25
+ timeCreated
26
+ timePurchased
27
+ }
28
+ }
29
+ `.trim();
30
+ exports.BAAZAAR_ERC1155_LISTING_BY_ID_QUERY = `
31
+ query($id: ID!) {
32
+ erc1155Listing(id: $id) {
33
+ id
34
+ category
35
+ erc1155TokenAddress
36
+ erc1155TypeId
37
+ quantity
38
+ seller
39
+ priceInWei
40
+ cancelled
41
+ sold
42
+ timeCreated
43
+ }
44
+ }
45
+ `.trim();
46
+ exports.BAAZAAR_ACTIVE_ERC721_QUERY = `
47
+ query($first: Int!, $skip: Int!) {
48
+ erc721Listings(
49
+ first: $first
50
+ skip: $skip
51
+ orderBy: timeCreated
52
+ orderDirection: desc
53
+ where: { cancelled: false, timePurchased: "0" }
54
+ ) {
55
+ id
56
+ category
57
+ erc721TokenAddress
58
+ tokenId
59
+ seller
60
+ priceInWei
61
+ cancelled
62
+ timeCreated
63
+ timePurchased
64
+ }
65
+ }
66
+ `.trim();
67
+ exports.BAAZAAR_ACTIVE_ERC1155_QUERY = `
68
+ query($first: Int!, $skip: Int!) {
69
+ erc1155Listings(
70
+ first: $first
71
+ skip: $skip
72
+ orderBy: timeCreated
73
+ orderDirection: desc
74
+ where: { cancelled: false, sold: false }
75
+ ) {
76
+ id
77
+ category
78
+ erc1155TokenAddress
79
+ erc1155TypeId
80
+ quantity
81
+ seller
82
+ priceInWei
83
+ cancelled
84
+ sold
85
+ timeCreated
86
+ }
87
+ }
88
+ `.trim();
89
+ exports.BAAZAAR_MINE_ERC721_QUERY = `
90
+ query($seller: Bytes!, $first: Int!, $skip: Int!) {
91
+ erc721Listings(
92
+ first: $first
93
+ skip: $skip
94
+ orderBy: timeCreated
95
+ orderDirection: desc
96
+ where: { seller: $seller }
97
+ ) {
98
+ id
99
+ category
100
+ erc721TokenAddress
101
+ tokenId
102
+ seller
103
+ priceInWei
104
+ cancelled
105
+ timeCreated
106
+ timePurchased
107
+ }
108
+ }
109
+ `.trim();
110
+ exports.BAAZAAR_MINE_ERC1155_QUERY = `
111
+ query($seller: Bytes!, $first: Int!, $skip: Int!) {
112
+ erc1155Listings(
113
+ first: $first
114
+ skip: $skip
115
+ orderBy: timeCreated
116
+ orderDirection: desc
117
+ where: { seller: $seller }
118
+ ) {
119
+ id
120
+ category
121
+ erc1155TokenAddress
122
+ erc1155TypeId
123
+ quantity
124
+ seller
125
+ priceInWei
126
+ cancelled
127
+ sold
128
+ timeCreated
129
+ }
130
+ }
131
+ `.trim();
132
+ exports.GBM_AUCTION_BY_ID_QUERY = `
133
+ query($id: ID!) {
134
+ auction(id: $id) {
135
+ id
136
+ type
137
+ contractAddress
138
+ tokenId
139
+ quantity
140
+ seller
141
+ highestBid
142
+ highestBidder
143
+ totalBids
144
+ startsAt
145
+ endsAt
146
+ claimAt
147
+ claimed
148
+ cancelled
149
+ presetId
150
+ category
151
+ buyNowPrice
152
+ startBidPrice
153
+ }
154
+ }
155
+ `.trim();
156
+ exports.GBM_ACTIVE_AUCTIONS_QUERY = `
157
+ query($now: BigInt!, $first: Int!, $skip: Int!) {
158
+ auctions(
159
+ first: $first
160
+ skip: $skip
161
+ orderBy: endsAt
162
+ orderDirection: asc
163
+ where: { claimed: false, cancelled: false, startsAt_lte: $now, endsAt_gt: $now }
164
+ ) {
165
+ id
166
+ type
167
+ contractAddress
168
+ tokenId
169
+ quantity
170
+ seller
171
+ highestBid
172
+ highestBidder
173
+ totalBids
174
+ startsAt
175
+ endsAt
176
+ claimAt
177
+ claimed
178
+ cancelled
179
+ presetId
180
+ category
181
+ buyNowPrice
182
+ startBidPrice
183
+ }
184
+ }
185
+ `.trim();
186
+ exports.GBM_MINE_AUCTIONS_QUERY = `
187
+ query($seller: Bytes!, $first: Int!, $skip: Int!) {
188
+ auctions(
189
+ first: $first
190
+ skip: $skip
191
+ orderBy: createdAt
192
+ orderDirection: desc
193
+ where: { seller: $seller }
194
+ ) {
195
+ id
196
+ type
197
+ contractAddress
198
+ tokenId
199
+ quantity
200
+ seller
201
+ highestBid
202
+ highestBidder
203
+ totalBids
204
+ startsAt
205
+ endsAt
206
+ claimAt
207
+ claimed
208
+ cancelled
209
+ presetId
210
+ category
211
+ buyNowPrice
212
+ startBidPrice
213
+ }
214
+ }
215
+ `.trim();
216
+ exports.GBM_BIDS_BY_AUCTION_QUERY = `
217
+ query($auctionId: String!, $first: Int!, $skip: Int!) {
218
+ bids(
219
+ first: $first
220
+ skip: $skip
221
+ orderBy: bidTime
222
+ orderDirection: desc
223
+ where: { auction: $auctionId }
224
+ ) {
225
+ id
226
+ bidder
227
+ amount
228
+ bidTime
229
+ outbid
230
+ previousBid
231
+ previousBidder
232
+ }
233
+ }
234
+ `.trim();
235
+ exports.GBM_BIDS_BY_BIDDER_QUERY = `
236
+ query($bidder: Bytes!, $first: Int!, $skip: Int!) {
237
+ bids(
238
+ first: $first
239
+ skip: $skip
240
+ orderBy: bidTime
241
+ orderDirection: desc
242
+ where: { bidder: $bidder }
243
+ ) {
244
+ id
245
+ bidder
246
+ amount
247
+ bidTime
248
+ outbid
249
+ previousBid
250
+ previousBidder
251
+ auction {
252
+ id
253
+ }
254
+ }
255
+ }
256
+ `.trim();
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_GBM_DIAMOND = exports.BASE_AAVEGOTCHI_DIAMOND = exports.GBM_BASE_ENDPOINT = exports.CORE_BASE_ENDPOINT = void 0;
4
+ exports.listSubgraphSources = listSubgraphSources;
5
+ exports.parseSubgraphSourceAlias = parseSubgraphSourceAlias;
6
+ exports.resolveSubgraphEndpoint = resolveSubgraphEndpoint;
7
+ const errors_1 = require("../errors");
8
+ exports.CORE_BASE_ENDPOINT = "https://api.goldsky.com/api/public/project_cmh3flagm0001r4p25foufjtt/subgraphs/aavegotchi-core-base/prod/gn";
9
+ exports.GBM_BASE_ENDPOINT = "https://api.goldsky.com/api/public/project_cmh3flagm0001r4p25foufjtt/subgraphs/aavegotchi-gbm-baazaar-base/prod/gn";
10
+ exports.BASE_AAVEGOTCHI_DIAMOND = "0xa99c4b08201f2913db8d28e71d020c4298f29dbf";
11
+ exports.BASE_GBM_DIAMOND = "0x80320a0000c7a6a34086e2acad6915ff57ffda31";
12
+ const SOURCE_MAP = {
13
+ "core-base": {
14
+ alias: "core-base",
15
+ endpoint: exports.CORE_BASE_ENDPOINT,
16
+ description: "Aavegotchi core base subgraph (Baazaar listings and core entities).",
17
+ },
18
+ "gbm-base": {
19
+ alias: "gbm-base",
20
+ endpoint: exports.GBM_BASE_ENDPOINT,
21
+ description: "Aavegotchi GBM baazaar base subgraph (auctions and bids).",
22
+ },
23
+ };
24
+ function listSubgraphSources() {
25
+ return Object.values(SOURCE_MAP);
26
+ }
27
+ function parseSubgraphSourceAlias(value) {
28
+ if (!value) {
29
+ throw new errors_1.CliError("MISSING_ARGUMENT", "subgraph source is required (--source).", 2);
30
+ }
31
+ const normalized = value.trim().toLowerCase();
32
+ if (normalized === "core-base" || normalized === "gbm-base") {
33
+ return normalized;
34
+ }
35
+ throw new errors_1.CliError("SUBGRAPH_SOURCE_UNKNOWN", `Unknown subgraph source '${value}'.`, 2, {
36
+ source: value,
37
+ supportedSources: Object.keys(SOURCE_MAP),
38
+ });
39
+ }
40
+ function parseHttpsUrl(value) {
41
+ let parsed;
42
+ try {
43
+ parsed = new URL(value);
44
+ }
45
+ catch {
46
+ throw new errors_1.CliError("INVALID_ARGUMENT", "subgraph url must be a valid URL.", 2, {
47
+ subgraphUrl: value,
48
+ });
49
+ }
50
+ if (parsed.protocol !== "https:") {
51
+ throw new errors_1.CliError("SUBGRAPH_ENDPOINT_BLOCKED", "Custom subgraph url must use HTTPS.", 2, {
52
+ subgraphUrl: value,
53
+ });
54
+ }
55
+ return parsed.toString();
56
+ }
57
+ function resolveSubgraphEndpoint(input) {
58
+ const source = SOURCE_MAP[input.source];
59
+ if (!source) {
60
+ throw new errors_1.CliError("SUBGRAPH_SOURCE_UNKNOWN", `Unknown subgraph source '${input.source}'.`, 2, {
61
+ source: input.source,
62
+ supportedSources: Object.keys(SOURCE_MAP),
63
+ });
64
+ }
65
+ if (!input.subgraphUrl) {
66
+ return {
67
+ source: source.alias,
68
+ endpoint: source.endpoint,
69
+ isCustomEndpoint: false,
70
+ };
71
+ }
72
+ const endpoint = parseHttpsUrl(input.subgraphUrl);
73
+ if (endpoint === source.endpoint) {
74
+ return {
75
+ source: source.alias,
76
+ endpoint,
77
+ isCustomEndpoint: false,
78
+ };
79
+ }
80
+ if (!input.allowUntrustedSubgraph) {
81
+ throw new errors_1.CliError("SUBGRAPH_ENDPOINT_BLOCKED", "Custom subgraph endpoint blocked by default. Pass --allow-untrusted-subgraph to override.", 2, {
82
+ source: source.alias,
83
+ canonicalEndpoint: source.endpoint,
84
+ requestedEndpoint: endpoint,
85
+ });
86
+ }
87
+ return {
88
+ source: source.alias,
89
+ endpoint,
90
+ isCustomEndpoint: true,
91
+ };
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aavegotchi-cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Agent-first CLI for automating Aavegotchi app and onchain workflows",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,7 +11,8 @@
11
11
  "main": "dist/index.js",
12
12
  "files": [
13
13
  "dist",
14
- "README.md"
14
+ "README.md",
15
+ "CHANGELOG.md"
15
16
  ],
16
17
  "bin": {
17
18
  "ag": "dist/index.js",