@aboutcircles/sdk-rpc 0.1.28 → 0.1.30

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.
Files changed (40) hide show
  1. package/dist/client.d.ts +9 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +58 -11
  4. package/dist/index.js +2 -2
  5. package/dist/methods/group.d.ts +30 -60
  6. package/dist/methods/group.d.ts.map +1 -1
  7. package/dist/methods/group.js +86 -160
  8. package/dist/methods/index.d.ts +1 -0
  9. package/dist/methods/index.d.ts.map +1 -1
  10. package/dist/methods/index.js +1 -0
  11. package/dist/methods/invitation.d.ts +99 -5
  12. package/dist/methods/invitation.d.ts.map +1 -1
  13. package/dist/methods/invitation.js +130 -164
  14. package/dist/methods/profile.d.ts +12 -4
  15. package/dist/methods/profile.d.ts.map +1 -1
  16. package/dist/methods/profile.js +16 -43
  17. package/dist/methods/query.d.ts +38 -9
  18. package/dist/methods/query.d.ts.map +1 -1
  19. package/dist/methods/query.js +38 -13
  20. package/dist/methods/sdk.d.ts +142 -0
  21. package/dist/methods/sdk.d.ts.map +1 -0
  22. package/dist/methods/sdk.js +165 -0
  23. package/dist/methods/token.d.ts +9 -15
  24. package/dist/methods/token.d.ts.map +1 -1
  25. package/dist/methods/token.js +14 -39
  26. package/dist/methods/transaction.d.ts +20 -21
  27. package/dist/methods/transaction.d.ts.map +1 -1
  28. package/dist/methods/transaction.js +32 -89
  29. package/dist/methods/trust.d.ts +30 -6
  30. package/dist/methods/trust.d.ts.map +1 -1
  31. package/dist/methods/trust.js +46 -50
  32. package/dist/pagedQuery.d.ts +7 -49
  33. package/dist/pagedQuery.d.ts.map +1 -1
  34. package/dist/pagedQuery.js +17 -146
  35. package/dist/rpc.d.ts +8 -3
  36. package/dist/rpc.d.ts.map +1 -1
  37. package/dist/rpc.js +14 -4
  38. package/dist/types.d.ts +4 -5
  39. package/dist/types.d.ts.map +1 -1
  40. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import type { RpcClient } from '../client.js';
2
- import type { Address, TrustRelation, AggregatedTrustRelation } from '@aboutcircles/sdk-types';
2
+ import type { Address, TrustRelation, AggregatedTrustRelation, TrustNetworkSummary, AggregatedTrustRelationsResponse, ValidInvitersResponse } from '@aboutcircles/sdk-types';
3
3
  import { PagedQuery } from '../pagedQuery.js';
4
4
  /**
5
5
  * Trust relation RPC methods
@@ -49,9 +49,7 @@ export declare class TrustMethods {
49
49
  getTrustRelations(avatar: Address, limit?: number, sortOrder?: 'ASC' | 'DESC'): PagedQuery<TrustRelation>;
50
50
  /**
51
51
  * Get aggregated trust relations for an address
52
- * Groups trust relations by counterpart and determines relationship type
53
- *
54
- * Note: This method fetches ALL trust relations for aggregation.
52
+ * Uses the native RPC method for efficient server-side aggregation
55
53
  *
56
54
  * @param avatar - Avatar address to query trust relations for
57
55
  * @returns Aggregated trust relations with relationship types
@@ -62,8 +60,8 @@ export declare class TrustMethods {
62
60
  * '0xde374ece6fa50e781e81aac78e811b33d16912c7'
63
61
  * );
64
62
  * // Returns: [
65
- * // { subjectAvatar: '0x...', relation: 'mutuallyTrusts', objectAvatar: '0x...', timestamp: 123 },
66
- * // { subjectAvatar: '0x...', relation: 'trusts', objectAvatar: '0x...', timestamp: 456 }
63
+ * // { subjectAvatar: '0x...', relation: 'mutuallyTrusts', objectAvatar: '0x...', timestamp: 123, expiryTime: 0, objectAvatarType: 'Human' },
64
+ * // { subjectAvatar: '0x...', relation: 'trusts', objectAvatar: '0x...', timestamp: 456, expiryTime: 0, objectAvatarType: 'Group' }
67
65
  * // ]
68
66
  * ```
69
67
  */
@@ -110,5 +108,31 @@ export declare class TrustMethods {
110
108
  * ```
111
109
  */
112
110
  getMutualTrusts(avatar: Address): Promise<AggregatedTrustRelation[]>;
111
+ /**
112
+ * Get trust network summary
113
+ * Includes counts of direct trusts, trusted by, and mutual trusts
114
+ *
115
+ * @param avatar - Avatar address to query
116
+ * @param maxDepth - Maximum depth for network calculation (default: 2)
117
+ * @returns Trust network summary
118
+ */
119
+ getTrustNetworkSummary(avatar: Address, maxDepth?: number): Promise<TrustNetworkSummary>;
120
+ /**
121
+ * Get enriched aggregated trust relations
122
+ * Returns classified trust relations (mutual, trusts, trustedBy) with avatar info
123
+ *
124
+ * @param avatar - Avatar address to query
125
+ * @returns Enriched aggregated trust relations
126
+ */
127
+ getAggregatedTrustRelationsEnriched(avatar: Address): Promise<AggregatedTrustRelationsResponse>;
128
+ /**
129
+ * Get valid inviters for an address
130
+ * Returns addresses that trust the given address and have sufficient balance
131
+ *
132
+ * @param avatar - Avatar address to query
133
+ * @param minimumBalance - Minimum balance required (optional)
134
+ * @returns List of valid inviters
135
+ */
136
+ getValidInviters(avatar: Address, minimumBalance?: string): Promise<ValidInvitersResponse>;
113
137
  }
114
138
  //# sourceMappingURL=trust.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../../src/methods/trust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAmD,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEhJ,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAErC,OAAO,CAAC,sBAAsB;IAW9B;;;;;;;;;;;;;;;OAeG;IAEG,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAQ9E;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,iBAAiB,CACf,MAAM,EAAE,OAAO,EACf,KAAK,GAAE,MAAY,EACnB,SAAS,GAAE,KAAK,GAAG,MAAe,GACjC,UAAU,CAAC,aAAa,CAAC;IA4D5B;;;;;;;;;;;;;;;;;;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OAYG;IACG,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAOvE;;;;;;;;;;;;OAYG;IACG,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAOpE;;;;;;;;;;;;OAYG;IACG,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAO1E;;;;;;;OAOG;IACG,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOjG;;;;;;OAMG;IACG,mCAAmC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAMrG;;;;;;;OAOG;IACG,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAOjG"}
@@ -118,9 +118,7 @@ export class TrustMethods {
118
118
  }
119
119
  /**
120
120
  * Get aggregated trust relations for an address
121
- * Groups trust relations by counterpart and determines relationship type
122
- *
123
- * Note: This method fetches ALL trust relations for aggregation.
121
+ * Uses the native RPC method for efficient server-side aggregation
124
122
  *
125
123
  * @param avatar - Avatar address to query trust relations for
126
124
  * @returns Aggregated trust relations with relationship types
@@ -131,58 +129,15 @@ export class TrustMethods {
131
129
  * '0xde374ece6fa50e781e81aac78e811b33d16912c7'
132
130
  * );
133
131
  * // Returns: [
134
- * // { subjectAvatar: '0x...', relation: 'mutuallyTrusts', objectAvatar: '0x...', timestamp: 123 },
135
- * // { subjectAvatar: '0x...', relation: 'trusts', objectAvatar: '0x...', timestamp: 456 }
132
+ * // { subjectAvatar: '0x...', relation: 'mutuallyTrusts', objectAvatar: '0x...', timestamp: 123, expiryTime: 0, objectAvatarType: 'Human' },
133
+ * // { subjectAvatar: '0x...', relation: 'trusts', objectAvatar: '0x...', timestamp: 456, expiryTime: 0, objectAvatarType: 'Group' }
136
134
  * // ]
137
135
  * ```
138
136
  */
139
137
  async getAggregatedTrustRelations(avatar) {
140
138
  const normalized = normalizeAddress(avatar);
141
- // Fetch all trust relations by paginating
142
- const query = this.getTrustRelations(normalized, 1000);
143
- const trustListRows = [];
144
- while (await query.queryNextPage()) {
145
- trustListRows.push(...query.currentPage.results);
146
- if (!query.currentPage.hasMore)
147
- break;
148
- }
149
- // Group trust list rows by counterpart avatar
150
- const trustBucket = {};
151
- trustListRows.forEach((row) => {
152
- // Normalize addresses for comparison (both are already checksummed from getTrustRelations)
153
- const trusterNorm = normalizeAddress(row.truster);
154
- const trusteeNorm = normalizeAddress(row.trustee);
155
- const counterpart = trusterNorm !== normalized ? row.truster : row.trustee;
156
- if (!trustBucket[counterpart]) {
157
- trustBucket[counterpart] = [];
158
- }
159
- trustBucket[counterpart].push(row);
160
- });
161
- // Determine trust relations
162
- const result = Object.entries(trustBucket)
163
- .filter(([address]) => normalizeAddress(address) !== normalized)
164
- .map(([address, rows]) => {
165
- const maxTimestamp = Math.max(...rows.map((o) => o.timestamp));
166
- let relation;
167
- if (rows.length === 2) {
168
- relation = 'mutuallyTrusts';
169
- }
170
- else if (normalizeAddress(rows[0]?.trustee) === normalized) {
171
- relation = 'trustedBy';
172
- }
173
- else if (normalizeAddress(rows[0]?.truster) === normalized) {
174
- relation = 'trusts';
175
- }
176
- else {
177
- throw new Error(`Unexpected trust list row. Couldn't determine trust relation.`);
178
- }
179
- return {
180
- subjectAvatar: normalized,
181
- relation,
182
- objectAvatar: address,
183
- timestamp: maxTimestamp,
184
- };
185
- });
139
+ // Use native RPC method for server-side aggregation
140
+ const result = await this.client.call('circles_getAggregatedTrustRelations', [normalized]);
186
141
  return checksumAddresses(result);
187
142
  }
188
143
  /**
@@ -242,4 +197,45 @@ export class TrustMethods {
242
197
  const filtered = relations.filter((r) => r.relation === 'mutuallyTrusts');
243
198
  return checksumAddresses(filtered);
244
199
  }
200
+ /**
201
+ * Get trust network summary
202
+ * Includes counts of direct trusts, trusted by, and mutual trusts
203
+ *
204
+ * @param avatar - Avatar address to query
205
+ * @param maxDepth - Maximum depth for network calculation (default: 2)
206
+ * @returns Trust network summary
207
+ */
208
+ async getTrustNetworkSummary(avatar, maxDepth = 2) {
209
+ return this.client.call('circles_getTrustNetworkSummary', [
210
+ normalizeAddress(avatar),
211
+ maxDepth
212
+ ]);
213
+ }
214
+ /**
215
+ * Get enriched aggregated trust relations
216
+ * Returns classified trust relations (mutual, trusts, trustedBy) with avatar info
217
+ *
218
+ * @param avatar - Avatar address to query
219
+ * @returns Enriched aggregated trust relations
220
+ */
221
+ async getAggregatedTrustRelationsEnriched(avatar) {
222
+ return this.client.call('circles_getAggregatedTrustRelationsEnriched', [
223
+ normalizeAddress(avatar)
224
+ ]);
225
+ }
226
+ /**
227
+ * Get valid inviters for an address
228
+ * Returns addresses that trust the given address and have sufficient balance
229
+ *
230
+ * @param avatar - Avatar address to query
231
+ * @param minimumBalance - Minimum balance required (optional)
232
+ * @returns List of valid inviters
233
+ */
234
+ async getValidInviters(avatar, minimumBalance) {
235
+ const params = [normalizeAddress(avatar)];
236
+ if (minimumBalance) {
237
+ params.push(minimumBalance);
238
+ }
239
+ return this.client.call('circles_getValidInviters', params);
240
+ }
245
241
  }
@@ -2,14 +2,13 @@ import type { RpcClient } from './client.js';
2
2
  import type { PagedQueryParams, OrderBy } from '@aboutcircles/sdk-types';
3
3
  import type { CursorColumn, FlexiblePagedResult } from './types.js';
4
4
  /**
5
- * A class for querying Circles RPC nodes with cursor-based pagination.
6
- * Supports both event-based pagination (default) and custom cursor pagination (for view tables).
5
+ * A class for querying Circles RPC nodes with server-side cursor-based pagination.
6
+ * Uses circles_paginated_query which returns {columns, rows, hasMore, nextCursor}.
7
7
  *
8
8
  * @typeParam TRow The type of the rows returned by the query.
9
9
  *
10
10
  * @example
11
11
  * ```typescript
12
- * // Event-based pagination
13
12
  * const query = new PagedQuery<GroupMembershipRow>(rpc.client, {
14
13
  * namespace: 'V_CrcV2',
15
14
  * table: 'GroupMemberships',
@@ -19,16 +18,10 @@ import type { CursorColumn, FlexiblePagedResult } from './types.js';
19
18
  * limit: 100
20
19
  * });
21
20
  *
22
- * // Custom cursor pagination (for view tables)
23
- * const viewQuery = new PagedQuery<GroupTokenHolderRow>(rpc.client, {
24
- * namespace: 'V_CrcV2',
25
- * table: 'GroupTokenHoldersBalance',
26
- * sortOrder: 'ASC',
27
- * columns: ['group', 'holder', 'totalBalance'],
28
- * cursorColumns: [{ name: 'holder', sortOrder: 'ASC' }],
29
- * filter: [{ Type: 'FilterPredicate', FilterType: 'Equals', Column: 'group', Value: '0x...' }],
30
- * limit: 100
31
- * });
21
+ * while (await query.queryNextPage()) {
22
+ * console.log(query.currentPage!.results);
23
+ * if (!query.currentPage!.hasMore) break;
24
+ * }
32
25
  * ```
33
26
  */
34
27
  export declare class PagedQuery<TRow = any> {
@@ -48,52 +41,17 @@ export declare class PagedQuery<TRow = any> {
48
41
  * Builds cursor columns for event-based tables
49
42
  */
50
43
  private buildEventCursorColumns;
51
- /**
52
- * Transforms a cursor value for use in query filters
53
- */
54
- private transformCursorValue;
55
- /**
56
- * Creates an equality predicate for a cursor column
57
- */
58
- private createEqualityPredicate;
59
- /**
60
- * Creates a comparison predicate for a cursor column (> or <)
61
- */
62
- private createComparisonPredicate;
63
- /**
64
- * Builds cursor filter for pagination using composite cursor columns.
65
- *
66
- * Creates an OR conjunction of predicates for each cursor level:
67
- * - First level: col1 > cursor.col1
68
- * - Second level: col1 = cursor.col1 AND col2 > cursor.col2
69
- * - Third level: col1 = cursor.col1 AND col2 = cursor.col2 AND col3 > cursor.col3
70
- *
71
- * This ensures correct pagination across all cursor columns.
72
- */
73
- private buildCursorFilter;
74
44
  /**
75
45
  * Builds the order by clause.
76
46
  * If orderColumns are provided, uses those. Otherwise builds from cursor columns.
77
47
  */
78
48
  private buildOrderBy;
79
- /**
80
- * Combines base filters with cursor filter
81
- */
82
- private combineFilters;
83
49
  /**
84
50
  * Converts query response rows to typed objects
85
51
  */
86
52
  private rowsToObjects;
87
53
  /**
88
- * Extracts cursor values from a row
89
- */
90
- private rowToCursor;
91
- /**
92
- * Gets first and last cursors from result set
93
- */
94
- private getCursors;
95
- /**
96
- * Queries the next page of results.
54
+ * Queries the next page of results using server-side cursor pagination.
97
55
  *
98
56
  * @returns True if results were found, false otherwise
99
57
  */
@@ -1 +1 @@
1
- {"version":3,"file":"pagedQuery.d.ts","sourceRoot":"","sources":["../src/pagedQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,gBAAgB,EAEhB,OAAO,EAGR,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAWpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,UAAU,CAAC,IAAI,GAAG,GAAG;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAIrB;IACF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAY;IAE1C,IAAI,WAAW,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,SAAS,CAEvD;IAED,OAAO,CAAC,YAAY,CAAC,CAA4B;gBAG/C,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,GAAG;QACzB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAC/B,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;QACzB,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;KACpC,EACD,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK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AM,EAAE,gBAAgB,GAAG;QACzB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAC/B,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;QACzB,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;KACpC,EACD,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI;IAWrC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;OAGG;IACH,OAAO,CAAC,YAAY;IAWpB;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;;;OAIG;IACU,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAkC9C;;OAEG;IACI,KAAK,IAAI,IAAI;CAGrB"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Cursor configuration for different table types
2
+ * Default cursor columns for event-based tables (blockNumber, transactionIndex, logIndex DESC)
3
3
  */
4
4
  const EVENT_CURSOR_COLUMNS = [
5
5
  { name: 'blockNumber', sortOrder: 'DESC' },
@@ -7,14 +7,13 @@ const EVENT_CURSOR_COLUMNS = [
7
7
  { name: 'logIndex', sortOrder: 'DESC' },
8
8
  ];
9
9
  /**
10
- * A class for querying Circles RPC nodes with cursor-based pagination.
11
- * Supports both event-based pagination (default) and custom cursor pagination (for view tables).
10
+ * A class for querying Circles RPC nodes with server-side cursor-based pagination.
11
+ * Uses circles_paginated_query which returns {columns, rows, hasMore, nextCursor}.
12
12
  *
13
13
  * @typeParam TRow The type of the rows returned by the query.
14
14
  *
15
15
  * @example
16
16
  * ```typescript
17
- * // Event-based pagination
18
17
  * const query = new PagedQuery<GroupMembershipRow>(rpc.client, {
19
18
  * namespace: 'V_CrcV2',
20
19
  * table: 'GroupMemberships',
@@ -24,16 +23,10 @@ const EVENT_CURSOR_COLUMNS = [
24
23
  * limit: 100
25
24
  * });
26
25
  *
27
- * // Custom cursor pagination (for view tables)
28
- * const viewQuery = new PagedQuery<GroupTokenHolderRow>(rpc.client, {
29
- * namespace: 'V_CrcV2',
30
- * table: 'GroupTokenHoldersBalance',
31
- * sortOrder: 'ASC',
32
- * columns: ['group', 'holder', 'totalBalance'],
33
- * cursorColumns: [{ name: 'holder', sortOrder: 'ASC' }],
34
- * filter: [{ Type: 'FilterPredicate', FilterType: 'Equals', Column: 'group', Value: '0x...' }],
35
- * limit: 100
36
- * });
26
+ * while (await query.queryNextPage()) {
27
+ * console.log(query.currentPage!.results);
28
+ * if (!query.currentPage!.hasMore) break;
29
+ * }
37
30
  * ```
38
31
  */
39
32
  export class PagedQuery {
@@ -51,7 +44,7 @@ export class PagedQuery {
51
44
  this.params = params;
52
45
  this.rowTransformer = rowTransformer || params.rowTransformer;
53
46
  this.orderColumns = params.orderColumns;
54
- // Determine cursor columns based on table type
47
+ // Cursor columns only used for buildOrderBy() — actual pagination is server-side
55
48
  this.cursorColumns = params.cursorColumns || this.buildEventCursorColumns();
56
49
  }
57
50
  /**
@@ -62,96 +55,11 @@ export class PagedQuery {
62
55
  ...col,
63
56
  sortOrder: this.params.sortOrder
64
57
  }));
65
- // Add batchIndex for TransferBatch table
66
58
  if (this.params.table === 'TransferBatch') {
67
59
  columns.push({ name: 'batchIndex', sortOrder: this.params.sortOrder });
68
60
  }
69
61
  return columns;
70
62
  }
71
- /**
72
- * Transforms a cursor value for use in query filters
73
- */
74
- transformCursorValue(value, transformer) {
75
- if (transformer)
76
- return transformer(value);
77
- if (typeof value === 'bigint')
78
- return value.toString();
79
- return value;
80
- }
81
- /**
82
- * Creates an equality predicate for a cursor column
83
- */
84
- createEqualityPredicate(column, value) {
85
- return {
86
- Type: 'FilterPredicate',
87
- FilterType: 'Equals',
88
- Column: column.name,
89
- Value: this.transformCursorValue(value, column.toValue),
90
- };
91
- }
92
- /**
93
- * Creates a comparison predicate for a cursor column (> or <)
94
- */
95
- createComparisonPredicate(column, value) {
96
- const filterType = column.sortOrder === 'ASC' ? 'GreaterThan' : 'LessThan';
97
- return {
98
- Type: 'FilterPredicate',
99
- FilterType: filterType,
100
- Column: column.name,
101
- Value: this.transformCursorValue(value, column.toValue),
102
- };
103
- }
104
- /**
105
- * Builds cursor filter for pagination using composite cursor columns.
106
- *
107
- * Creates an OR conjunction of predicates for each cursor level:
108
- * - First level: col1 > cursor.col1
109
- * - Second level: col1 = cursor.col1 AND col2 > cursor.col2
110
- * - Third level: col1 = cursor.col1 AND col2 = cursor.col2 AND col3 > cursor.col3
111
- *
112
- * This ensures correct pagination across all cursor columns.
113
- */
114
- buildCursorFilter(cursor) {
115
- if (!cursor)
116
- return [];
117
- const orPredicates = [];
118
- for (let level = 0; level < this.cursorColumns.length; level++) {
119
- const currentColumn = this.cursorColumns[level];
120
- const cursorValue = cursor[currentColumn.name];
121
- if (cursorValue === undefined)
122
- continue;
123
- if (level === 0) {
124
- // First level: simple comparison (col > value)
125
- orPredicates.push(this.createComparisonPredicate(currentColumn, cursorValue));
126
- }
127
- else {
128
- // Subsequent levels: equality for all previous + comparison for current
129
- const andPredicates = [];
130
- // Add equality predicates for all previous columns
131
- for (let prevLevel = 0; prevLevel < level; prevLevel++) {
132
- const prevColumn = this.cursorColumns[prevLevel];
133
- const prevValue = cursor[prevColumn.name];
134
- if (prevValue !== undefined) {
135
- andPredicates.push(this.createEqualityPredicate(prevColumn, prevValue));
136
- }
137
- }
138
- // Add comparison predicate for current column
139
- andPredicates.push(this.createComparisonPredicate(currentColumn, cursorValue));
140
- orPredicates.push({
141
- Type: 'Conjunction',
142
- ConjunctionType: 'And',
143
- Predicates: andPredicates,
144
- });
145
- }
146
- }
147
- if (orPredicates.length === 0)
148
- return [];
149
- return [{
150
- Type: 'Conjunction',
151
- ConjunctionType: 'Or',
152
- Predicates: orPredicates,
153
- }];
154
- }
155
63
  /**
156
64
  * Builds the order by clause.
157
65
  * If orderColumns are provided, uses those. Otherwise builds from cursor columns.
@@ -165,22 +73,6 @@ export class PagedQuery {
165
73
  SortOrder: col.sortOrder,
166
74
  }));
167
75
  }
168
- /**
169
- * Combines base filters with cursor filter
170
- */
171
- combineFilters(baseFilters, cursorFilter) {
172
- if (!baseFilters?.length && !cursorFilter?.length)
173
- return [];
174
- if (!baseFilters?.length)
175
- return cursorFilter || [];
176
- if (!cursorFilter?.length)
177
- return baseFilters;
178
- return [{
179
- Type: 'Conjunction',
180
- ConjunctionType: 'And',
181
- Predicates: [...baseFilters, ...cursorFilter],
182
- }];
183
- }
184
76
  /**
185
77
  * Converts query response rows to typed objects
186
78
  */
@@ -195,52 +87,31 @@ export class PagedQuery {
195
87
  });
196
88
  }
197
89
  /**
198
- * Extracts cursor values from a row
199
- */
200
- rowToCursor(row) {
201
- const cursor = {};
202
- for (const column of this.cursorColumns) {
203
- cursor[column.name] = row[column.name];
204
- }
205
- return cursor;
206
- }
207
- /**
208
- * Gets first and last cursors from result set
209
- */
210
- getCursors(results) {
211
- if (results.length === 0)
212
- return {};
213
- return {
214
- first: this.rowToCursor(results[0]),
215
- last: this.rowToCursor(results[results.length - 1]),
216
- };
217
- }
218
- /**
219
- * Queries the next page of results.
90
+ * Queries the next page of results using server-side cursor pagination.
220
91
  *
221
92
  * @returns True if results were found, false otherwise
222
93
  */
223
94
  async queryNextPage() {
224
- const cursorFilter = this.buildCursorFilter(this._currentPage?.lastCursor);
225
- const combinedFilter = this.combineFilters(this.params.filter, cursorFilter);
226
95
  const queryParams = {
227
96
  Namespace: this.params.namespace,
228
97
  Table: this.params.table,
229
98
  Columns: this.params.columns,
230
- Filter: combinedFilter,
99
+ Filter: this.params.filter || [],
231
100
  Order: this.buildOrderBy(),
232
101
  Limit: this.params.limit,
233
102
  };
234
- const response = await this.client.call('circles_query', [queryParams]);
103
+ // Pass [queryParams] or [queryParams, nextCursor] to circles_paginated_query
104
+ const rpcParams = this._currentPage?.nextCursor
105
+ ? [queryParams, this._currentPage.nextCursor]
106
+ : [queryParams];
107
+ const response = await this.client.call('circles_paginated_query', rpcParams);
235
108
  const results = this.rowsToObjects(response);
236
- const cursors = this.getCursors(results);
237
109
  this._currentPage = {
238
110
  limit: this.params.limit,
239
111
  size: results.length,
240
- firstCursor: cursors.first,
241
- lastCursor: cursors.last,
242
112
  sortOrder: this.params.sortOrder,
243
- hasMore: results.length === this.params.limit,
113
+ hasMore: response.hasMore,
114
+ nextCursor: response.nextCursor ?? undefined,
244
115
  results,
245
116
  };
246
117
  return results.length > 0;
package/dist/rpc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RpcClient } from './client.js';
2
- import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods } from './methods/index.js';
2
+ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, SdkMethods } from './methods/index.js';
3
3
  /**
4
4
  * Main RPC class for Circles protocol RPC interactions
5
5
  *
@@ -12,7 +12,7 @@ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMe
12
12
  * const rpc = new CirclesRpc();
13
13
  *
14
14
  * // Use custom RPC endpoint
15
- * const rpc = new CirclesRpc('https://rpc.circlesubi.network/');
15
+ * const rpc = new CirclesRpc('https://rpc.aboutcircles.com/');
16
16
  *
17
17
  * // Find a path
18
18
  * const path = await rpc.pathfinder.findPath({
@@ -32,6 +32,9 @@ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMe
32
32
  *
33
33
  * // Get profile
34
34
  * const profile = await rpc.profile.getProfileByAddress('0xc3a1428c04c426cdf513c6fc8e09f55ddaf50cd7');
35
+ *
36
+ * // Get consolidated profile view (Phase 3 SDK enablement)
37
+ * const profileView = await rpc.sdk.getProfileView('0xde374ece6fa50e781e81aac78e811b33d16912c7');
35
38
  * ```
36
39
  */
37
40
  export declare class CirclesRpc {
@@ -46,10 +49,11 @@ export declare class CirclesRpc {
46
49
  private _invitation?;
47
50
  private _transaction?;
48
51
  private _group?;
52
+ private _sdk?;
49
53
  /**
50
54
  * Create a new CirclesRpc instance
51
55
  *
52
- * @param rpcUrl RPC URL to use (defaults to https://rpc.circlesubi.network/)
56
+ * @param rpcUrl RPC URL to use (defaults to https://rpc.aboutcircles.com/)
53
57
  */
54
58
  constructor(rpcUrl?: string);
55
59
  get pathfinder(): PathfinderMethods;
@@ -62,6 +66,7 @@ export declare class CirclesRpc {
62
66
  get invitation(): InvitationMethods;
63
67
  get transaction(): TransactionMethods;
64
68
  get group(): GroupMethods;
69
+ get sdk(): SdkMethods;
65
70
  /**
66
71
  * Update the RPC URL
67
72
  */
package/dist/rpc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,UAAU;IACrB,SAAgB,MAAM,EAAE,SAAS,CAAC;IAElC,OAAO,CAAC,WAAW,CAAC,CAAoB;IACxC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,WAAW,CAAC,CAAoB;IACxC,OAAO,CAAC,YAAY,CAAC,CAAqB;IAC1C,OAAO,CAAC,MAAM,CAAC,CAAe;IAE9B;;;;OAIG;gBACS,MAAM,GAAE,MAA0C;IAI9D,IAAI,UAAU,IAAI,iBAAiB,CAKlC;IAED,IAA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AC,CAAa;IAE1B;;;;OAIG;gBACS,MAAM,GAAE,MAAwC;IAI5D,IAAI,UAAU,IAAI,iBAAiB,CAKlC;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,OAAO,IAAI,cAAc,CAK5B;IAED,IAAI,MAAM,IAAI,aAAa,CAK1B;IAED,IAAI,OAAO,IAAI,cAAc,CAK5B;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,UAAU,IAAI,iBAAiB,CAKlC;IAED,IAAI,WAAW,IAAI,kBAAkB,CAKpC;IAED,IAAI,KAAK,IAAI,YAAY,CAKxB;IAED,IAAI,GAAG,IAAI,UAAU,CAKpB;IAED;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
package/dist/rpc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RpcClient } from './client.js';
2
- import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, } from './methods/index.js';
2
+ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMethods, ProfileMethods, TokenMethods, InvitationMethods, TransactionMethods, GroupMethods, SdkMethods, } from './methods/index.js';
3
3
  /**
4
4
  * Main RPC class for Circles protocol RPC interactions
5
5
  *
@@ -12,7 +12,7 @@ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMe
12
12
  * const rpc = new CirclesRpc();
13
13
  *
14
14
  * // Use custom RPC endpoint
15
- * const rpc = new CirclesRpc('https://rpc.circlesubi.network/');
15
+ * const rpc = new CirclesRpc('https://rpc.aboutcircles.com/');
16
16
  *
17
17
  * // Find a path
18
18
  * const path = await rpc.pathfinder.findPath({
@@ -32,6 +32,9 @@ import { PathfinderMethods, QueryMethods, TrustMethods, BalanceMethods, AvatarMe
32
32
  *
33
33
  * // Get profile
34
34
  * const profile = await rpc.profile.getProfileByAddress('0xc3a1428c04c426cdf513c6fc8e09f55ddaf50cd7');
35
+ *
36
+ * // Get consolidated profile view (Phase 3 SDK enablement)
37
+ * const profileView = await rpc.sdk.getProfileView('0xde374ece6fa50e781e81aac78e811b33d16912c7');
35
38
  * ```
36
39
  */
37
40
  export class CirclesRpc {
@@ -46,12 +49,13 @@ export class CirclesRpc {
46
49
  _invitation;
47
50
  _transaction;
48
51
  _group;
52
+ _sdk;
49
53
  /**
50
54
  * Create a new CirclesRpc instance
51
55
  *
52
- * @param rpcUrl RPC URL to use (defaults to https://rpc.circlesubi.network/)
56
+ * @param rpcUrl RPC URL to use (defaults to https://rpc.aboutcircles.com/)
53
57
  */
54
- constructor(rpcUrl = 'https://rpc.circlesubi.network/') {
58
+ constructor(rpcUrl = 'https://rpc.aboutcircles.com/') {
55
59
  this.client = new RpcClient(rpcUrl);
56
60
  }
57
61
  get pathfinder() {
@@ -114,6 +118,12 @@ export class CirclesRpc {
114
118
  }
115
119
  return this._group;
116
120
  }
121
+ get sdk() {
122
+ if (!this._sdk) {
123
+ this._sdk = new SdkMethods(this.client);
124
+ }
125
+ return this._sdk;
126
+ }
117
127
  /**
118
128
  * Update the RPC URL
119
129
  */
package/dist/types.d.ts CHANGED
@@ -60,23 +60,22 @@ export interface GroupTokenHolderRow {
60
60
  fractionOwnership: number;
61
61
  }
62
62
  /**
63
- * Configuration for a cursor column in pagination
63
+ * Configuration for a cursor column in pagination.
64
+ * Used only for buildOrderBy() — cursor columns define the sort order.
64
65
  */
65
66
  export interface CursorColumn {
66
67
  name: string;
67
68
  sortOrder: 'ASC' | 'DESC';
68
- toValue?: (value: any) => string | number | boolean;
69
69
  }
70
70
  /**
71
- * Flexible paged result that works with both event-based and custom cursors
71
+ * Flexible paged result using server-side opaque cursors
72
72
  */
73
73
  export interface FlexiblePagedResult<TRow> {
74
74
  limit: number;
75
75
  size: number;
76
- firstCursor?: Record<string, any>;
77
- lastCursor?: Record<string, any>;
78
76
  sortOrder: 'ASC' | 'DESC';
79
77
  hasMore: boolean;
78
+ nextCursor?: string;
80
79
  results: TRow[];
81
80
  }
82
81
  //# sourceMappingURL=types.d.ts.map