@aboutcircles/sdk-rpc 0.1.27 → 0.1.29

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 (39) hide show
  1. package/dist/client.d.ts.map +1 -1
  2. package/dist/client.js +20 -11
  3. package/dist/index.js +2 -2
  4. package/dist/methods/group.d.ts +30 -60
  5. package/dist/methods/group.d.ts.map +1 -1
  6. package/dist/methods/group.js +86 -160
  7. package/dist/methods/index.d.ts +1 -0
  8. package/dist/methods/index.d.ts.map +1 -1
  9. package/dist/methods/index.js +1 -0
  10. package/dist/methods/invitation.d.ts +99 -5
  11. package/dist/methods/invitation.d.ts.map +1 -1
  12. package/dist/methods/invitation.js +130 -164
  13. package/dist/methods/profile.d.ts +12 -4
  14. package/dist/methods/profile.d.ts.map +1 -1
  15. package/dist/methods/profile.js +16 -43
  16. package/dist/methods/query.d.ts +38 -9
  17. package/dist/methods/query.d.ts.map +1 -1
  18. package/dist/methods/query.js +38 -13
  19. package/dist/methods/sdk.d.ts +142 -0
  20. package/dist/methods/sdk.d.ts.map +1 -0
  21. package/dist/methods/sdk.js +165 -0
  22. package/dist/methods/token.d.ts +9 -15
  23. package/dist/methods/token.d.ts.map +1 -1
  24. package/dist/methods/token.js +14 -39
  25. package/dist/methods/transaction.d.ts +20 -21
  26. package/dist/methods/transaction.d.ts.map +1 -1
  27. package/dist/methods/transaction.js +32 -89
  28. package/dist/methods/trust.d.ts +30 -6
  29. package/dist/methods/trust.d.ts.map +1 -1
  30. package/dist/methods/trust.js +46 -50
  31. package/dist/pagedQuery.d.ts +7 -49
  32. package/dist/pagedQuery.d.ts.map +1 -1
  33. package/dist/pagedQuery.js +17 -146
  34. package/dist/rpc.d.ts +8 -3
  35. package/dist/rpc.d.ts.map +1 -1
  36. package/dist/rpc.js +14 -4
  37. package/dist/types.d.ts +4 -5
  38. package/dist/types.d.ts.map +1 -1
  39. package/package.json +1 -1
@@ -0,0 +1,142 @@
1
+ import type { Address, ProfileView, TrustNetworkSummary, AggregatedTrustRelation, ValidInvitersResponse, PagedResponse, EnrichedTransaction, ProfileSearchResponse } from '@aboutcircles/sdk-types';
2
+ import type { RpcClient } from '../client';
3
+ /**
4
+ * SDK Enablement RPC methods
5
+ * These methods reduce SDK round-trips by consolidating common multi-call patterns
6
+ */
7
+ export declare class SdkMethods {
8
+ private client;
9
+ constructor(client: RpcClient);
10
+ /**
11
+ * Get a complete profile view combining avatar info, profile data, trust stats, and balances
12
+ *
13
+ * Replaces 6-7 separate RPC calls:
14
+ * - circles_getAvatarInfo
15
+ * - circles_getProfileByAddress
16
+ * - circles_getTrustRelations
17
+ * - circles_getTotalBalance (v1)
18
+ * - circlesV2_getTotalBalance (v2)
19
+ *
20
+ * @param address - Avatar address to query
21
+ * @returns Consolidated profile view with all data
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const profileView = await rpc.sdk.getProfileView('0xde374ece6fa50e781e81aac78e811b33d16912c7');
26
+ * console.log(`${profileView.profile?.name} has ${profileView.trustStats.trustsCount} trusts`);
27
+ * console.log(`V2 Balance: ${profileView.v2Balance}`);
28
+ * ```
29
+ */
30
+ getProfileView(address: Address): Promise<ProfileView>;
31
+ /**
32
+ * Get aggregated trust network summary including mutual trusts and network reach
33
+ *
34
+ * Server-side aggregation reduces client-side processing and provides ready-to-display statistics.
35
+ * Network reach = (trusts ∪ trustedBy).count = trustsCount + trustedByCount - mutualTrustsCount
36
+ *
37
+ * @param address - Avatar address to query
38
+ * @param maxDepth - Maximum network depth to analyze (default: 2)
39
+ * @returns Trust network summary with aggregated metrics
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const summary = await rpc.sdk.getTrustNetworkSummary('0xde374ece6fa50e781e81aac78e811b33d16912c7');
44
+ * console.log(`Network reach: ${summary.networkReach}`);
45
+ * console.log(`Mutual trusts: ${summary.mutualTrustsCount}`);
46
+ * ```
47
+ */
48
+ getTrustNetworkSummary(address: Address, maxDepth?: number): Promise<TrustNetworkSummary>;
49
+ /**
50
+ * Get trust relations categorized by type (mutual, one-way trusts, one-way trusted-by)
51
+ *
52
+ * Replaces client-side categorization + multiple getAvatarInfo calls.
53
+ * Returns relationships organized for easy UI rendering (different icons/colors per type).
54
+ *
55
+ * @param address - Avatar address to query
56
+ * @returns Trust relations categorized with enriched avatar info
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const relations = await rpc.sdk.getAggregatedTrustRelations('0xde374ece6fa50e781e81aac78e811b33d16912c7');
61
+ * // Returns flat array: [{subjectAvatar, relation, objectAvatar, ...}]
62
+ * const mutual = relations.filter(r => r.relation === 'mutuallyTrusts');
63
+ * console.log(`Mutual trusts: ${mutual.length}`);
64
+ * ```
65
+ */
66
+ getAggregatedTrustRelations(address: Address): Promise<AggregatedTrustRelation[]>;
67
+ /**
68
+ * Get list of addresses that trust you AND have sufficient balance to invite
69
+ *
70
+ * Useful for invitation flows and invitation escrow scenarios.
71
+ * Server-side filtering reduces data transfer and client-side processing.
72
+ *
73
+ * @param address - Avatar address to query
74
+ * @param minimumBalance - Optional minimum balance threshold (as TimeCircles string)
75
+ * @returns List of valid inviters with balances and avatar info
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Find all potential inviters
80
+ * const inviters = await rpc.sdk.getValidInviters('0xde374ece6fa50e781e81aac78e811b33d16912c7');
81
+ *
82
+ * // Find inviters with at least 50 CRC balance
83
+ * const richInviters = await rpc.sdk.getValidInviters(
84
+ * '0xde374ece6fa50e781e81aac78e811b33d16912c7',
85
+ * '50.0'
86
+ * );
87
+ * ```
88
+ */
89
+ getValidInviters(address: Address, minimumBalance?: string): Promise<ValidInvitersResponse>;
90
+ /**
91
+ * Get transaction history with enriched participant profiles and metadata
92
+ *
93
+ * Replaces circles_events + multiple getProfileByAddress calls + client-side event processing.
94
+ * Returns transaction history ready for UI display with participant names and avatars.
95
+ *
96
+ * @param address - Avatar address to query
97
+ * @param fromBlock - Starting block number
98
+ * @param toBlock - Optional ending block number (null for latest)
99
+ * @param limit - Maximum number of transactions (default: 50)
100
+ * @returns Enriched transaction history with participant profiles
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const history = await rpc.sdk.getTransactionHistoryEnriched(
105
+ * '0xde374ece6fa50e781e81aac78e811b33d16912c7',
106
+ * 30282299,
107
+ * null,
108
+ * 20
109
+ * );
110
+ *
111
+ * for (const tx of history.results) {
112
+ * console.log(`Tx: ${tx.transactionHash}, event: ${JSON.stringify(tx.event)}`);
113
+ * // Access participant profiles via tx.participants[address]
114
+ * }
115
+ * ```
116
+ */
117
+ getTransactionHistoryEnriched(address: Address, fromBlock?: number, toBlock?: number | null, limit?: number, cursor?: string | null): Promise<PagedResponse<EnrichedTransaction>>;
118
+ /**
119
+ * Unified search across profiles by address prefix OR name/description text
120
+ *
121
+ * Combines address lookup and full-text search in a single endpoint.
122
+ * Automatically detects search type based on query format (0x prefix = address search).
123
+ *
124
+ * @param query - Search query (address prefix or name/description text)
125
+ * @param limit - Maximum number of results (default: 20)
126
+ * @param cursor - Pagination cursor from previous response (null for first page)
127
+ * @param types - Optional array of avatar types to filter by
128
+ * @returns Unified search results with profiles
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * // Search by name
133
+ * const byName = await rpc.sdk.searchProfileByAddressOrName('Alice');
134
+ *
135
+ * // Paginate through results
136
+ * const page1 = await rpc.sdk.searchProfileByAddressOrName('developer', 10);
137
+ * const page2 = await rpc.sdk.searchProfileByAddressOrName('developer', 10, page1.nextCursor);
138
+ * ```
139
+ */
140
+ searchProfileByAddressOrName(query: string, limit?: number, cursor?: string | null, types?: string[]): Promise<ProfileSearchResponse>;
141
+ }
142
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/methods/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C;;;GAGG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAErC;;;;;;;;;;;;;;;;;;;OAmBG;IACG,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ5D;;;;;;;;;;;;;;;;OAgBG;IACG,sBAAsB,CAC1B,OAAO,EAAE,OAAO,EAChB,QAAQ,GAAE,MAAU,GACnB,OAAO,CAAC,mBAAmB,CAAC;IAQ/B;;;;;;;;;;;;;;;;OAgBG;IACG,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAQvF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,gBAAgB,CACpB,OAAO,EAAE,OAAO,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,qBAAqB,CAAC;IAUjC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,6BAA6B,CACjC,OAAO,EAAE,OAAO,EAChB,SAAS,GAAE,MAAU,EACrB,OAAO,GAAE,MAAM,GAAG,IAAW,EAC7B,KAAK,GAAE,MAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAc9C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,4BAA4B,CAChC,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,qBAAqB,CAAC;CAMlC"}
@@ -0,0 +1,165 @@
1
+ import { normalizeAddress, checksumAddresses } from '../utils';
2
+ /**
3
+ * SDK Enablement RPC methods
4
+ * These methods reduce SDK round-trips by consolidating common multi-call patterns
5
+ */
6
+ export class SdkMethods {
7
+ client;
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ /**
12
+ * Get a complete profile view combining avatar info, profile data, trust stats, and balances
13
+ *
14
+ * Replaces 6-7 separate RPC calls:
15
+ * - circles_getAvatarInfo
16
+ * - circles_getProfileByAddress
17
+ * - circles_getTrustRelations
18
+ * - circles_getTotalBalance (v1)
19
+ * - circlesV2_getTotalBalance (v2)
20
+ *
21
+ * @param address - Avatar address to query
22
+ * @returns Consolidated profile view with all data
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const profileView = await rpc.sdk.getProfileView('0xde374ece6fa50e781e81aac78e811b33d16912c7');
27
+ * console.log(`${profileView.profile?.name} has ${profileView.trustStats.trustsCount} trusts`);
28
+ * console.log(`V2 Balance: ${profileView.v2Balance}`);
29
+ * ```
30
+ */
31
+ async getProfileView(address) {
32
+ const normalizedAddress = normalizeAddress(address);
33
+ return this.client.call('circles_getProfileView', [normalizedAddress]);
34
+ }
35
+ /**
36
+ * Get aggregated trust network summary including mutual trusts and network reach
37
+ *
38
+ * Server-side aggregation reduces client-side processing and provides ready-to-display statistics.
39
+ * Network reach = (trusts ∪ trustedBy).count = trustsCount + trustedByCount - mutualTrustsCount
40
+ *
41
+ * @param address - Avatar address to query
42
+ * @param maxDepth - Maximum network depth to analyze (default: 2)
43
+ * @returns Trust network summary with aggregated metrics
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const summary = await rpc.sdk.getTrustNetworkSummary('0xde374ece6fa50e781e81aac78e811b33d16912c7');
48
+ * console.log(`Network reach: ${summary.networkReach}`);
49
+ * console.log(`Mutual trusts: ${summary.mutualTrustsCount}`);
50
+ * ```
51
+ */
52
+ async getTrustNetworkSummary(address, maxDepth = 2) {
53
+ const normalizedAddress = normalizeAddress(address);
54
+ return this.client.call('circles_getTrustNetworkSummary', [normalizedAddress, maxDepth]);
55
+ }
56
+ /**
57
+ * Get trust relations categorized by type (mutual, one-way trusts, one-way trusted-by)
58
+ *
59
+ * Replaces client-side categorization + multiple getAvatarInfo calls.
60
+ * Returns relationships organized for easy UI rendering (different icons/colors per type).
61
+ *
62
+ * @param address - Avatar address to query
63
+ * @returns Trust relations categorized with enriched avatar info
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const relations = await rpc.sdk.getAggregatedTrustRelations('0xde374ece6fa50e781e81aac78e811b33d16912c7');
68
+ * // Returns flat array: [{subjectAvatar, relation, objectAvatar, ...}]
69
+ * const mutual = relations.filter(r => r.relation === 'mutuallyTrusts');
70
+ * console.log(`Mutual trusts: ${mutual.length}`);
71
+ * ```
72
+ */
73
+ async getAggregatedTrustRelations(address) {
74
+ const normalizedAddress = normalizeAddress(address);
75
+ return this.client.call('circles_getAggregatedTrustRelations', [normalizedAddress]);
76
+ }
77
+ /**
78
+ * Get list of addresses that trust you AND have sufficient balance to invite
79
+ *
80
+ * Useful for invitation flows and invitation escrow scenarios.
81
+ * Server-side filtering reduces data transfer and client-side processing.
82
+ *
83
+ * @param address - Avatar address to query
84
+ * @param minimumBalance - Optional minimum balance threshold (as TimeCircles string)
85
+ * @returns List of valid inviters with balances and avatar info
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * // Find all potential inviters
90
+ * const inviters = await rpc.sdk.getValidInviters('0xde374ece6fa50e781e81aac78e811b33d16912c7');
91
+ *
92
+ * // Find inviters with at least 50 CRC balance
93
+ * const richInviters = await rpc.sdk.getValidInviters(
94
+ * '0xde374ece6fa50e781e81aac78e811b33d16912c7',
95
+ * '50.0'
96
+ * );
97
+ * ```
98
+ */
99
+ async getValidInviters(address, minimumBalance) {
100
+ const normalizedAddress = normalizeAddress(address);
101
+ const response = await this.client.call('circles_getValidInviters', minimumBalance ? [normalizedAddress, minimumBalance] : [normalizedAddress]);
102
+ return checksumAddresses(response);
103
+ }
104
+ /**
105
+ * Get transaction history with enriched participant profiles and metadata
106
+ *
107
+ * Replaces circles_events + multiple getProfileByAddress calls + client-side event processing.
108
+ * Returns transaction history ready for UI display with participant names and avatars.
109
+ *
110
+ * @param address - Avatar address to query
111
+ * @param fromBlock - Starting block number
112
+ * @param toBlock - Optional ending block number (null for latest)
113
+ * @param limit - Maximum number of transactions (default: 50)
114
+ * @returns Enriched transaction history with participant profiles
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const history = await rpc.sdk.getTransactionHistoryEnriched(
119
+ * '0xde374ece6fa50e781e81aac78e811b33d16912c7',
120
+ * 30282299,
121
+ * null,
122
+ * 20
123
+ * );
124
+ *
125
+ * for (const tx of history.results) {
126
+ * console.log(`Tx: ${tx.transactionHash}, event: ${JSON.stringify(tx.event)}`);
127
+ * // Access participant profiles via tx.participants[address]
128
+ * }
129
+ * ```
130
+ */
131
+ async getTransactionHistoryEnriched(address, fromBlock = 0, toBlock = null, limit = 50, cursor) {
132
+ const normalizedAddress = normalizeAddress(address);
133
+ const response = await this.client.call('circles_getTransactionHistoryEnriched', [normalizedAddress, fromBlock, toBlock, limit, cursor ?? null]);
134
+ return {
135
+ hasMore: response.hasMore,
136
+ nextCursor: response.nextCursor,
137
+ results: checksumAddresses(response.results),
138
+ };
139
+ }
140
+ /**
141
+ * Unified search across profiles by address prefix OR name/description text
142
+ *
143
+ * Combines address lookup and full-text search in a single endpoint.
144
+ * Automatically detects search type based on query format (0x prefix = address search).
145
+ *
146
+ * @param query - Search query (address prefix or name/description text)
147
+ * @param limit - Maximum number of results (default: 20)
148
+ * @param cursor - Pagination cursor from previous response (null for first page)
149
+ * @param types - Optional array of avatar types to filter by
150
+ * @returns Unified search results with profiles
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * // Search by name
155
+ * const byName = await rpc.sdk.searchProfileByAddressOrName('Alice');
156
+ *
157
+ * // Paginate through results
158
+ * const page1 = await rpc.sdk.searchProfileByAddressOrName('developer', 10);
159
+ * const page2 = await rpc.sdk.searchProfileByAddressOrName('developer', 10, page1.nextCursor);
160
+ * ```
161
+ */
162
+ async searchProfileByAddressOrName(query, limit = 20, cursor, types) {
163
+ return this.client.call('circles_searchProfileByAddressOrName', types ? [query, limit, cursor ?? null, types] : [query, limit, cursor ?? null]);
164
+ }
165
+ }
@@ -1,6 +1,5 @@
1
1
  import type { RpcClient } from '../client.js';
2
- import type { Address, TokenInfo, TokenHolder, SortOrder } from '@aboutcircles/sdk-types';
3
- import { PagedQuery } from '../pagedQuery.js';
2
+ import type { Address, TokenInfo, TokenHolderRow, PagedResponse } from '@aboutcircles/sdk-types';
4
3
  /**
5
4
  * Token information RPC methods
6
5
  */
@@ -39,23 +38,18 @@ export declare class TokenMethods {
39
38
  * Get token holders for a specific token address with pagination
40
39
  *
41
40
  * @param tokenAddress - The token address to query holders for
42
- * @param limit - Maximum number of results per page (default: 100)
43
- * @param sortOrder - Sort order for results (default: 'DESC' - highest balance first)
44
- * @returns PagedQuery instance for token holders
41
+ * @param limit - Maximum number of results to return (default: 100, max: 1000)
42
+ * @returns Array of token holders with their balances
45
43
  *
46
44
  * @example
47
45
  * ```typescript
48
- * const holdersQuery = rpc.token.getTokenHolders('0x42cedde51198d1773590311e2a340dc06b24cb37', 10);
49
- *
50
- * while (await holdersQuery.queryNextPage()) {
51
- * const page = holdersQuery.currentPage!;
52
- * console.log(`Found ${page.size} holders`);
53
- * page.results.forEach(holder => {
54
- * console.log(`${holder.account}: ${holder.demurragedTotalBalance}`);
55
- * });
56
- * }
46
+ * const holders = await rpc.token.getTokenHolders('0x42cedde51198d1773590311e2a340dc06b24cb37', 100);
47
+ * console.log(`Found ${holders.length} holders`);
48
+ * holders.forEach(holder => {
49
+ * console.log(`${holder.account}: ${holder.balance}`);
50
+ * });
57
51
  * ```
58
52
  */
59
- getTokenHolders(tokenAddress: Address, limit?: number, sortOrder?: SortOrder): PagedQuery<TokenHolder>;
53
+ getTokenHolders(tokenAddress: Address, limit?: number, cursor?: string | null): Promise<PagedResponse<TokenHolderRow>>;
60
54
  }
61
55
  //# sourceMappingURL=token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/methods/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAE1F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAErC;;;;;;;;;;;OAWG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAKpE;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAenE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,eAAe,CACb,YAAY,EAAE,OAAO,EACrB,KAAK,GAAE,MAAY,EACnB,SAAS,GAAE,SAAkB,GAC5B,UAAU,CAAC,WAAW,CAAC;CAiC3B"}
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/methods/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAIjG;;GAEG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAErC;;;;;;;;;;;OAWG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAKpE;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAenE;;;;;;;;;;;;;;;OAeG;IACG,eAAe,CACnB,YAAY,EAAE,OAAO,EACrB,KAAK,GAAE,MAAY,EACnB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;CAY1C"}
@@ -51,49 +51,24 @@ export class TokenMethods {
51
51
  * Get token holders for a specific token address with pagination
52
52
  *
53
53
  * @param tokenAddress - The token address to query holders for
54
- * @param limit - Maximum number of results per page (default: 100)
55
- * @param sortOrder - Sort order for results (default: 'DESC' - highest balance first)
56
- * @returns PagedQuery instance for token holders
54
+ * @param limit - Maximum number of results to return (default: 100, max: 1000)
55
+ * @returns Array of token holders with their balances
57
56
  *
58
57
  * @example
59
58
  * ```typescript
60
- * const holdersQuery = rpc.token.getTokenHolders('0x42cedde51198d1773590311e2a340dc06b24cb37', 10);
61
- *
62
- * while (await holdersQuery.queryNextPage()) {
63
- * const page = holdersQuery.currentPage!;
64
- * console.log(`Found ${page.size} holders`);
65
- * page.results.forEach(holder => {
66
- * console.log(`${holder.account}: ${holder.demurragedTotalBalance}`);
67
- * });
68
- * }
59
+ * const holders = await rpc.token.getTokenHolders('0x42cedde51198d1773590311e2a340dc06b24cb37', 100);
60
+ * console.log(`Found ${holders.length} holders`);
61
+ * holders.forEach(holder => {
62
+ * console.log(`${holder.account}: ${holder.balance}`);
63
+ * });
69
64
  * ```
70
65
  */
71
- getTokenHolders(tokenAddress, limit = 100, sortOrder = 'DESC') {
72
- const normalizedTokenAddress = normalizeAddress(tokenAddress);
73
- return new PagedQuery(this.client, {
74
- namespace: 'V_CrcV2',
75
- table: 'BalancesByAccountAndToken',
76
- columns: ['account', 'tokenAddress', 'demurragedTotalBalance'],
77
- filter: [{
78
- Type: 'FilterPredicate',
79
- FilterType: 'Equals',
80
- Column: 'tokenAddress',
81
- Value: normalizedTokenAddress
82
- }],
83
- cursorColumns: [
84
- { name: 'demurragedTotalBalance', sortOrder },
85
- { name: 'account', sortOrder: 'ASC' } // Secondary sort for deterministic ordering
86
- ],
87
- orderColumns: [
88
- { Column: 'demurragedTotalBalance', SortOrder: sortOrder },
89
- { Column: 'account', SortOrder: 'ASC' }
90
- ],
91
- limit,
92
- sortOrder
93
- }, (row) => ({
94
- account: row.account,
95
- tokenAddress: row.tokenAddress,
96
- demurragedTotalBalance: row.demurragedTotalBalance
97
- }));
66
+ async getTokenHolders(tokenAddress, limit = 100, cursor) {
67
+ const response = await this.client.call('circles_getTokenHolders', [normalizeAddress(tokenAddress), limit, cursor ?? null]);
68
+ return {
69
+ hasMore: response.hasMore,
70
+ nextCursor: response.nextCursor,
71
+ results: checksumAddresses(response.results),
72
+ };
98
73
  }
99
74
  }
@@ -1,7 +1,5 @@
1
1
  import type { RpcClient } from '../client.js';
2
- import type { Address } from '@aboutcircles/sdk-types';
3
- import type { TransactionHistoryRow } from '../types.js';
4
- import { PagedQuery } from '../pagedQuery.js';
2
+ import type { Address, TransactionHistoryRow, EnrichedTransaction, PagedResponse } from '@aboutcircles/sdk-types';
5
3
  /**
6
4
  * Transaction history RPC methods
7
5
  */
@@ -9,33 +7,34 @@ export declare class TransactionMethods {
9
7
  private client;
10
8
  constructor(client: RpcClient);
11
9
  /**
12
- * Get transaction history for an address using cursor-based pagination
10
+ * Get transaction history for an address
13
11
  *
14
- * Returns a PagedQuery instance that can be used to fetch transaction history page by page.
15
- * Automatically calculates circle amounts for each v2 transaction.
12
+ * Uses the native RPC method which efficiently queries transfers and calculates
13
+ * all circle amount formats server-side. Fetches all results using cursor-based
14
+ * pagination up to the specified limit.
16
15
  *
17
16
  * @param avatar - Avatar address to query transaction history for
18
- * @param limit - Number of transactions per page (default: 50)
19
- * @param sortOrder - Sort order for results (default: 'DESC')
20
- * @returns PagedQuery instance for iterating through transaction history
17
+ * @param limit - Maximum number of transactions to return (default: 50)
18
+ * @returns Array of transaction history rows with all circle amount formats
21
19
  *
22
20
  * @example
23
21
  * ```typescript
24
- * const query = rpc.transaction.getTransactionHistory('0xAvatar...', 50);
25
- *
26
- * // Get first page
27
- * await query.queryNextPage();
28
- * query.currentPage.results.forEach(tx => {
22
+ * const history = await rpc.transaction.getTransactionHistory('0xAvatar...', 50);
23
+ * history.forEach(tx => {
29
24
  * console.log(`${tx.from} -> ${tx.to}: ${tx.circles} CRC`);
30
25
  * });
31
- *
32
- * // Get next page if available
33
- * if (query.currentPage.hasMore) {
34
- * await query.queryNextPage();
35
- * // Process next page...
36
- * }
37
26
  * ```
38
27
  */
39
- getTransactionHistory(avatar: Address, limit?: number, sortOrder?: 'ASC' | 'DESC'): PagedQuery<TransactionHistoryRow>;
28
+ getTransactionHistory(avatar: Address, limit?: number, cursor?: string | null): Promise<PagedResponse<TransactionHistoryRow>>;
29
+ /**
30
+ * Get enriched transaction history
31
+ * Includes profile data and pre-calculated balance formats
32
+ *
33
+ * @param avatar - Avatar address to query
34
+ * @param limit - Number of transactions per page (default: 20)
35
+ * @param cursor - Pagination cursor
36
+ * @returns Paged response with enriched transactions
37
+ */
38
+ getTransactionHistoryEnriched(avatar: Address, fromBlock?: number, toBlock?: number | null, limit?: number, cursor?: string | null): Promise<PagedResponse<EnrichedTransaction>>;
40
39
  }
41
40
  //# sourceMappingURL=transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/methods/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiC9C;;GAEG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,qBAAqB,CACnB,MAAM,EAAE,OAAO,EACf,KAAK,GAAE,MAAW,EAClB,SAAS,GAAE,KAAK,GAAG,MAAe,GACjC,UAAU,CAAC,qBAAqB,CAAC;CAyDrC"}
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/methods/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGlH;;GAEG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAErC;;;;;;;;;;;;;;;;;;OAkBG;IACG,qBAAqB,CACzB,MAAM,EAAE,OAAO,EACf,KAAK,GAAE,MAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAahD;;;;;;;;OAQG;IACG,6BAA6B,CACjC,MAAM,EAAE,OAAO,EACf,SAAS,GAAE,MAAU,EACrB,OAAO,GAAE,MAAM,GAAG,IAAW,EAC7B,KAAK,GAAE,MAAW,EAClB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAY/C"}
@@ -1,26 +1,4 @@
1
1
  import { normalizeAddress, checksumAddresses } from '../utils.js';
2
- import { CirclesConverter } from '@aboutcircles/sdk-utils/circlesConverter';
3
- import { PagedQuery } from '../pagedQuery.js';
4
- /**
5
- * Calculate circle amounts for v2 transactions
6
- */
7
- function calculateCircleAmounts(value, timestamp) {
8
- // v2: value is attoCircles (demurraged)
9
- const attoCircles = BigInt(value);
10
- const circles = CirclesConverter.attoCirclesToCircles(attoCircles);
11
- const attoCrc = CirclesConverter.attoCirclesToAttoCrc(attoCircles, BigInt(timestamp));
12
- const crc = CirclesConverter.attoCirclesToCircles(attoCrc);
13
- const staticAttoCircles = CirclesConverter.attoCirclesToAttoStaticCircles(attoCircles, BigInt(timestamp));
14
- const staticCircles = CirclesConverter.attoCirclesToCircles(staticAttoCircles);
15
- return {
16
- attoCircles,
17
- circles,
18
- staticAttoCircles,
19
- staticCircles,
20
- attoCrc,
21
- crc,
22
- };
23
- }
24
2
  /**
25
3
  * Transaction history RPC methods
26
4
  */
@@ -30,82 +8,47 @@ export class TransactionMethods {
30
8
  this.client = client;
31
9
  }
32
10
  /**
33
- * Get transaction history for an address using cursor-based pagination
11
+ * Get transaction history for an address
34
12
  *
35
- * Returns a PagedQuery instance that can be used to fetch transaction history page by page.
36
- * Automatically calculates circle amounts for each v2 transaction.
13
+ * Uses the native RPC method which efficiently queries transfers and calculates
14
+ * all circle amount formats server-side. Fetches all results using cursor-based
15
+ * pagination up to the specified limit.
37
16
  *
38
17
  * @param avatar - Avatar address to query transaction history for
39
- * @param limit - Number of transactions per page (default: 50)
40
- * @param sortOrder - Sort order for results (default: 'DESC')
41
- * @returns PagedQuery instance for iterating through transaction history
18
+ * @param limit - Maximum number of transactions to return (default: 50)
19
+ * @returns Array of transaction history rows with all circle amount formats
42
20
  *
43
21
  * @example
44
22
  * ```typescript
45
- * const query = rpc.transaction.getTransactionHistory('0xAvatar...', 50);
46
- *
47
- * // Get first page
48
- * await query.queryNextPage();
49
- * query.currentPage.results.forEach(tx => {
23
+ * const history = await rpc.transaction.getTransactionHistory('0xAvatar...', 50);
24
+ * history.forEach(tx => {
50
25
  * console.log(`${tx.from} -> ${tx.to}: ${tx.circles} CRC`);
51
26
  * });
52
- *
53
- * // Get next page if available
54
- * if (query.currentPage.hasMore) {
55
- * await query.queryNextPage();
56
- * // Process next page...
57
- * }
58
27
  * ```
59
28
  */
60
- getTransactionHistory(avatar, limit = 50, sortOrder = 'DESC') {
61
- const normalized = normalizeAddress(avatar);
62
- const filter = [
63
- {
64
- Type: 'Conjunction',
65
- ConjunctionType: 'And',
66
- Predicates: [
67
- {
68
- Type: 'FilterPredicate',
69
- FilterType: 'Equals',
70
- Column: 'version',
71
- Value: 2,
72
- },
73
- {
74
- Type: 'Conjunction',
75
- ConjunctionType: 'Or',
76
- Predicates: [
77
- {
78
- Type: 'FilterPredicate',
79
- FilterType: 'Equals',
80
- Column: 'from',
81
- Value: normalized,
82
- },
83
- {
84
- Type: 'FilterPredicate',
85
- FilterType: 'Equals',
86
- Column: 'to',
87
- Value: normalized,
88
- },
89
- ],
90
- },
91
- ],
92
- },
93
- ];
94
- return new PagedQuery(this.client, {
95
- namespace: 'V_Crc',
96
- table: 'TransferSummary',
97
- sortOrder,
98
- columns: [], // Empty array returns all columns
99
- filter,
100
- limit,
101
- }, (row) => {
102
- // Calculate circle amounts
103
- const amounts = calculateCircleAmounts(row.value, row.timestamp);
104
- const result = {
105
- ...row,
106
- ...amounts,
107
- };
108
- return checksumAddresses(result);
109
- });
29
+ async getTransactionHistory(avatar, limit = 50, cursor) {
30
+ const response = await this.client.call('circles_getTransactionHistory', [normalizeAddress(avatar), limit, cursor ?? null]);
31
+ return {
32
+ hasMore: response.hasMore,
33
+ nextCursor: response.nextCursor,
34
+ results: checksumAddresses(response.results),
35
+ };
36
+ }
37
+ /**
38
+ * Get enriched transaction history
39
+ * Includes profile data and pre-calculated balance formats
40
+ *
41
+ * @param avatar - Avatar address to query
42
+ * @param limit - Number of transactions per page (default: 20)
43
+ * @param cursor - Pagination cursor
44
+ * @returns Paged response with enriched transactions
45
+ */
46
+ async getTransactionHistoryEnriched(avatar, fromBlock = 0, toBlock = null, limit = 20, cursor) {
47
+ const response = await this.client.call('circles_getTransactionHistoryEnriched', [normalizeAddress(avatar), fromBlock, toBlock, limit, cursor ?? null]);
48
+ return {
49
+ hasMore: response.hasMore,
50
+ nextCursor: response.nextCursor,
51
+ results: checksumAddresses(response.results),
52
+ };
110
53
  }
111
54
  }