diff --git a/package.json b/package.json index 4219e59..9fde7c5 100644 --- a/package.json +++ b/package.json @@ -36,5 +36,5 @@ }, "name": "@cirlces-sdk/root", "license": "MIT", - "version": "0.15.0" + "version": "0.15.1" } diff --git a/packages/abi-v1/package.json b/packages/abi-v1/package.json index e75547e..67dc87c 100644 --- a/packages/abi-v1/package.json +++ b/packages/abi-v1/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/abi-v1", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/abi-v2/package.json b/packages/abi-v2/package.json index b636a02..c1d135e 100644 --- a/packages/abi-v2/package.json +++ b/packages/abi-v2/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/abi-v2", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter-cometh/package.json b/packages/adapter-cometh/package.json index 2cfa1d0..76d1570 100644 --- a/packages/adapter-cometh/package.json +++ b/packages/adapter-cometh/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-cometh", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.15.0", + "@circles-sdk/adapter": "0.15.1", "@cometh/connect-sdk": "1.2.29" }, "keywords": [], diff --git a/packages/adapter-ethers/package.json b/packages/adapter-ethers/package.json index 4eaffc1..75f40c0 100644 --- a/packages/adapter-ethers/package.json +++ b/packages/adapter-ethers/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-ethers", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -18,8 +18,8 @@ }, "dependencies": { "ethers": "^6.13.2", - "@circles-sdk/adapter": "0.15.0", - "@circles-sdk/utils": "0.15.0" + "@circles-sdk/adapter": "0.15.1", + "@circles-sdk/utils": "0.15.1" }, "keywords": [], "author": "", diff --git a/packages/adapter-safe-app/package.json b/packages/adapter-safe-app/package.json index 4b8ff0f..1a55535 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.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.15.0", + "@circles-sdk/adapter": "0.15.1", "@safe-global/safe-apps-sdk": "^9.1.0" }, "keywords": [], diff --git a/packages/adapter-safe/package.json b/packages/adapter-safe/package.json index 0ffbb89..ce8879c 100644 --- a/packages/adapter-safe/package.json +++ b/packages/adapter-safe/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-safe", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter/package.json b/packages/adapter/package.json index 65ad9dc..86e5c64 100644 --- a/packages/adapter/package.json +++ b/packages/adapter/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/data/package.json b/packages/data/package.json index 32109cf..a9b115c 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/data", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.15.0" + "@circles-sdk/utils": "0.15.1" }, "keywords": [], "author": "", diff --git a/packages/profiles/package.json b/packages/profiles/package.json index 405ecc1..68da13d 100644 --- a/packages/profiles/package.json +++ b/packages/profiles/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/profiles", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.15.0" + "@circles-sdk/utils": "0.15.1" }, "keywords": [], "author": "", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 1d9d107..c415f0e 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/sdk", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,11 +17,11 @@ "author": "", "license": "MIT", "dependencies": { - "@circles-sdk/abi-v1": "0.15.0", - "@circles-sdk/abi-v2": "0.15.0", - "@circles-sdk/data": "0.15.0", - "@circles-sdk/profiles": "0.15.0", - "@circles-sdk/adapter-ethers": "0.15.0", + "@circles-sdk/abi-v1": "0.15.1", + "@circles-sdk/abi-v2": "0.15.1", + "@circles-sdk/data": "0.15.1", + "@circles-sdk/profiles": "0.15.1", + "@circles-sdk/adapter-ethers": "0.15.1", "ethers": "^6.13.2", "multihashes": "^4.0.3" }, diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index ba13956..0289582 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -111,10 +111,6 @@ interface SdkInterface { canSelfMigrate: (avatarInfo: AvatarRow) => Promise; } -/** - * Wraps a contract runner with its address. - */ - /** * The SDK provides a high-level interface to interact with the Circles protocol. @@ -479,7 +475,23 @@ export class Sdk implements SdkInterface { batch.addTransaction(calculateIssuanceTx); } - // 4. Migrate trust relations + // 4. Migrate v1 balances of the avatar. But only if the tokenOwner of the migrated token is already on v2 or if it's the own token. + const balances = await this.data.getTokenBalances(avatar); + const v1Balances = balances.filter(o => o.version === 1); + const tokenOwners = v1Balances.map(o => o.tokenOwner); + const tokenOwnerInfo = await this.data.getAvatarInfoBatch(tokenOwners); + const tokenOwnerInfoMap = tokenOwnerInfo.reduce((acc: Record, o) => { + acc[o.avatar] = o; + return acc; + }, {}); + + const tokensToMigrate = v1Balances.filter(o => o.tokenOwner == avatar || tokenOwnerInfoMap[o.tokenOwner]?.version === 2); + if (tokensToMigrate.length > 0) { + // Add 'migrate' to the batch + await this.migrateV1TokensBatch(avatar, tokensToMigrate.map(o => o.tokenAddress), batch); + } + + // 5. Migrate trust relations if (trustRelations) { // Add 'trust' to the batch for (const trustRelation of trustRelations) { diff --git a/packages/utils/package.json b/packages/utils/package.json index 00b33b4..c0f9221 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/utils", - "version": "0.15.0", + "version": "0.15.1", "description": "", "type": "module", "main": "./dist/index.js",