diff --git a/package.json b/package.json index fdee17e..fb7b93f 100644 --- a/package.json +++ b/package.json @@ -36,5 +36,5 @@ }, "name": "@cirlces-sdk/root", "license": "MIT", - "version": "0.13.3" + "version": "0.13.4" } diff --git a/packages/abi-v1/package.json b/packages/abi-v1/package.json index a6750f9..4c59b83 100644 --- a/packages/abi-v1/package.json +++ b/packages/abi-v1/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/abi-v1", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/abi-v2/package.json b/packages/abi-v2/package.json index e29b8a9..cf69eac 100644 --- a/packages/abi-v2/package.json +++ b/packages/abi-v2/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/abi-v2", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter-cometh/package.json b/packages/adapter-cometh/package.json index cf87c06..abc94a3 100644 --- a/packages/adapter-cometh/package.json +++ b/packages/adapter-cometh/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-cometh", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.13.3", + "@circles-sdk/adapter": "0.13.4", "@cometh/connect-sdk": "1.2.29" }, "keywords": [], diff --git a/packages/adapter-ethers/package.json b/packages/adapter-ethers/package.json index 81b5cb6..ccdf384 100644 --- a/packages/adapter-ethers/package.json +++ b/packages/adapter-ethers/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-ethers", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", @@ -18,8 +18,8 @@ }, "dependencies": { "ethers": "^6.13.2", - "@circles-sdk/adapter": "0.13.3", - "@circles-sdk/utils": "0.13.3" + "@circles-sdk/adapter": "0.13.4", + "@circles-sdk/utils": "0.13.4" }, "keywords": [], "author": "", diff --git a/packages/adapter-safe-app/package.json b/packages/adapter-safe-app/package.json index ecb12d2..bef0f0e 100644 --- a/packages/adapter-safe-app/package.json +++ b/packages/adapter-safe-app/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-safe-app", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.13.3", + "@circles-sdk/adapter": "0.13.4", "@safe-global/safe-apps-sdk": "^9.1.0" }, "keywords": [], diff --git a/packages/adapter-safe/package.json b/packages/adapter-safe/package.json index d7058de..c0de02d 100644 --- a/packages/adapter-safe/package.json +++ b/packages/adapter-safe/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-safe", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter/package.json b/packages/adapter/package.json index 62fb9a1..b79f004 100644 --- a/packages/adapter/package.json +++ b/packages/adapter/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/data/package.json b/packages/data/package.json index ffc9c54..fdf3d89 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/data", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.13.3" + "@circles-sdk/utils": "0.13.4" }, "keywords": [], "author": "", diff --git a/packages/data/src/circlesData.ts b/packages/data/src/circlesData.ts index 8e05ef8..aed9408 100644 --- a/packages/data/src/circlesData.ts +++ b/packages/data/src/circlesData.ts @@ -24,6 +24,7 @@ import {GroupRow} from './rows/groupRow'; import {TokenInfoRow} from './rows/tokenInfoRow'; import {parseRpcSubscriptionMessage, RcpSubscriptionEvent} from './events/parser'; import {FilterPredicate} from "./rpcSchema/filterPredicate"; +import {EventRow} from "./pagedQuery/eventRow"; export type TrustEvent = { blockNumber: number; @@ -125,7 +126,7 @@ function calculateBalances(row: TransactionHistoryRow) { staticAttoCircles = BigInt(rawBalance); staticCircles = attoCirclesToCircles(staticAttoCircles); - attoCircles = staticAttoCirclesToAttoCircles(staticAttoCircles) ; + attoCircles = staticAttoCirclesToAttoCircles(staticAttoCircles); circles = attoCirclesToCircles(attoCircles); attoCrc = tcToCrc(new Date(), circles); @@ -733,4 +734,41 @@ export class CirclesData implements CirclesDataInterface { limit: pageSize }); } + + /** + * Gets the metadata CID for an address. + * @param address + */ + async getMetadataCidForAddress(address: string): Promise { + // Get the newest CID for the given address + const query = new CirclesQuery(this.rpc, { + namespace: 'CrcV2', + table: 'UpdateMetadataDigest', + columns: [ + 'metadataDigest' + ], + filter: [ + { + Type: 'FilterPredicate', + FilterType: 'Equals', + Column: 'avatar', + Value: address.toLowerCase() + } + ], + sortOrder: 'DESC', + limit: 1 + }); + + if (!await query.queryNextPage()) { + return undefined; + } + const cidHex = query.currentPage?.results[0].metadataDigest; + if (!cidHex) { + return undefined; + } + const cidArr = hexStringToUint8Array(cidHex.substring(2)); + return uint8ArrayToCidV0(cidArr); + } } \ No newline at end of file diff --git a/packages/data/src/circlesDataInterface.ts b/packages/data/src/circlesDataInterface.ts index 7291861..016c525 100644 --- a/packages/data/src/circlesDataInterface.ts +++ b/packages/data/src/circlesDataInterface.ts @@ -1,15 +1,15 @@ -import { AvatarRow } from './rows/avatarRow'; -import { TokenBalanceRow } from './rows/tokenBalanceRow'; -import { CirclesQuery } from './pagedQuery/circlesQuery'; -import { TransactionHistoryRow } from './rows/transactionHistoryRow'; -import { TrustListRow } from './rows/trustListRow'; -import { TrustRelationRow } from './rows/trustRelationRow'; -import { Observable } from './observable'; -import { CirclesEvent } from './events/events'; -import { InvitationRow } from './rows/invitationRow'; -import { GroupRow } from './rows/groupRow'; -import { GroupMembershipRow } from './rows/groupMembershipRow'; -import { TokenInfoRow } from './rows/tokenInfoRow'; +import {AvatarRow} from './rows/avatarRow'; +import {TokenBalanceRow} from './rows/tokenBalanceRow'; +import {CirclesQuery} from './pagedQuery/circlesQuery'; +import {TransactionHistoryRow} from './rows/transactionHistoryRow'; +import {TrustListRow} from './rows/trustListRow'; +import {TrustRelationRow} from './rows/trustRelationRow'; +import {Observable} from './observable'; +import {CirclesEvent} from './events/events'; +import {InvitationRow} from './rows/invitationRow'; +import {GroupRow} from './rows/groupRow'; +import {GroupMembershipRow} from './rows/groupMembershipRow'; +import {TokenInfoRow} from './rows/tokenInfoRow'; export interface GroupQueryParams { nameStartsWith?: string; @@ -109,4 +109,10 @@ export interface CirclesDataInterface { * @param pageSize The maximum number of group memberships per page. */ getGroupMemberships(avatar: string, pageSize: number): CirclesQuery; + + /** + * Gets the metadata CID for an address. + * @param address + */ + getMetadataCidForAddress(address: string): Promise; } \ No newline at end of file diff --git a/packages/profiles/package.json b/packages/profiles/package.json index 4b3dc3f..7fb57c7 100644 --- a/packages/profiles/package.json +++ b/packages/profiles/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/profiles", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.13.3" + "@circles-sdk/utils": "0.13.4" }, "keywords": [], "author": "", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 8855a44..7863e89 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/sdk", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,11 +17,11 @@ "author": "", "license": "MIT", "dependencies": { - "@circles-sdk/abi-v1": "0.13.3", - "@circles-sdk/abi-v2": "0.13.3", - "@circles-sdk/data": "0.13.3", - "@circles-sdk/profiles": "0.13.3", - "@circles-sdk/adapter-ethers": "0.13.3", + "@circles-sdk/abi-v1": "0.13.4", + "@circles-sdk/abi-v2": "0.13.4", + "@circles-sdk/data": "0.13.4", + "@circles-sdk/profiles": "0.13.4", + "@circles-sdk/adapter-ethers": "0.13.4", "ethers": "^6.13.2", "multihashes": "^4.0.3" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index 777e6c3..b7a1000 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/utils", - "version": "0.13.3", + "version": "0.13.4", "description": "", "type": "module", "main": "./dist/index.js",