From 0f6323e2cce86b82838d474518259508756caa9b Mon Sep 17 00:00:00 2001 From: daniel <4954577+jaensen@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:11:19 +0200 Subject: [PATCH] v0.13.0 add default config --- package-lock.json | 1 + package.json | 2 +- packages/abi-v1/package.json | 2 +- packages/abi-v2/package.json | 2 +- packages/adapter-cometh/package.json | 4 +-- packages/adapter-ethers/package.json | 5 ++-- packages/adapter-ethers/rollup.config.js | 2 +- packages/adapter-safe-app/package.json | 4 +-- packages/adapter-safe/package.json | 2 +- packages/adapter/package.json | 2 +- packages/data/package.json | 4 +-- packages/profiles/package.json | 4 +-- packages/sdk/package.json | 12 ++++----- packages/sdk/src/circlesConfig.ts | 2 +- packages/sdk/src/config.ts | 16 ++++++++++++ packages/sdk/src/index.ts | 3 ++- packages/sdk/src/sdk.ts | 32 +++++++++++++----------- packages/utils/package.json | 2 +- 18 files changed, 61 insertions(+), 40 deletions(-) create mode 100644 packages/sdk/src/config.ts diff --git a/package-lock.json b/package-lock.json index d60d3a4..8c1aee5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6577,6 +6577,7 @@ "license": "MIT", "dependencies": { "@circles-sdk/adapter": "0.12.2", + "@circles-sdk/utils": "0.12.2", "ethers": "^6.13.2" }, "devDependencies": { diff --git a/package.json b/package.json index d45cf9a..f55444a 100644 --- a/package.json +++ b/package.json @@ -36,5 +36,5 @@ }, "name": "@cirlces-sdk/root", "license": "MIT", - "version": "0.12.2" + "version": "0.13.0" } diff --git a/packages/abi-v1/package.json b/packages/abi-v1/package.json index d7f5855..a613819 100644 --- a/packages/abi-v1/package.json +++ b/packages/abi-v1/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/abi-v1", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/abi-v2/package.json b/packages/abi-v2/package.json index 70b880c..d04d13b 100644 --- a/packages/abi-v2/package.json +++ b/packages/abi-v2/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/abi-v2", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter-cometh/package.json b/packages/adapter-cometh/package.json index 4d782d0..7a71f5b 100644 --- a/packages/adapter-cometh/package.json +++ b/packages/adapter-cometh/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-cometh", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.12.2", + "@circles-sdk/adapter": "0.13.0", "@cometh/connect-sdk": "1.2.29" }, "keywords": [], diff --git a/packages/adapter-ethers/package.json b/packages/adapter-ethers/package.json index 7797f56..28b3140 100644 --- a/packages/adapter-ethers/package.json +++ b/packages/adapter-ethers/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-ethers", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", @@ -18,7 +18,8 @@ }, "dependencies": { "ethers": "^6.13.2", - "@circles-sdk/adapter": "0.12.2" + "@circles-sdk/adapter": "0.13.0", + "@circles-sdk/utils": "0.13.0" }, "keywords": [], "author": "", diff --git a/packages/adapter-ethers/rollup.config.js b/packages/adapter-ethers/rollup.config.js index f302256..7551eee 100644 --- a/packages/adapter-ethers/rollup.config.js +++ b/packages/adapter-ethers/rollup.config.js @@ -16,5 +16,5 @@ export default { tsconfig: './tsconfig.json' }) ], - external: ["ethers"] + external: ["ethers", '@circles-sdk/utils'] }; diff --git a/packages/adapter-safe-app/package.json b/packages/adapter-safe-app/package.json index 9a69846..55ae9ef 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.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.12.2", + "@circles-sdk/adapter": "0.13.0", "@safe-global/safe-apps-sdk": "^9.1.0" }, "keywords": [], diff --git a/packages/adapter-safe/package.json b/packages/adapter-safe/package.json index f843942..9ae9c92 100644 --- a/packages/adapter-safe/package.json +++ b/packages/adapter-safe/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter-safe", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter/package.json b/packages/adapter/package.json index 926e7e9..bc904c8 100644 --- a/packages/adapter/package.json +++ b/packages/adapter/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/data/package.json b/packages/data/package.json index 86df12f..93820e0 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/data", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.12.2" + "@circles-sdk/utils": "0.13.0" }, "keywords": [], "author": "", diff --git a/packages/profiles/package.json b/packages/profiles/package.json index 99085b7..35bde44 100644 --- a/packages/profiles/package.json +++ b/packages/profiles/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/profiles", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.12.2" + "@circles-sdk/utils": "0.13.0" }, "keywords": [], "author": "", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 88176c7..5afb169 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/sdk", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,11 +17,11 @@ "author": "", "license": "MIT", "dependencies": { - "@circles-sdk/abi-v1": "0.12.2", - "@circles-sdk/abi-v2": "0.12.2", - "@circles-sdk/data": "0.12.2", - "@circles-sdk/profiles": "0.12.2", - "@circles-sdk/adapter-ethers": "0.12.2", + "@circles-sdk/abi-v1": "0.13.0", + "@circles-sdk/abi-v2": "0.13.0", + "@circles-sdk/data": "0.13.0", + "@circles-sdk/profiles": "0.13.0", + "@circles-sdk/adapter-ethers": "0.13.0", "ethers": "^6.13.2", "multihashes": "^4.0.3" }, diff --git a/packages/sdk/src/circlesConfig.ts b/packages/sdk/src/circlesConfig.ts index 6a82d5f..962b8a8 100644 --- a/packages/sdk/src/circlesConfig.ts +++ b/packages/sdk/src/circlesConfig.ts @@ -8,5 +8,5 @@ export interface CirclesConfig { readonly nameRegistryAddress?: string; readonly migrationAddress?: string; readonly baseGroupMintPolicy?: string; - readonly standardTreasuryPolicy?: string; + readonly standardTreasury?: string; } \ No newline at end of file diff --git a/packages/sdk/src/config.ts b/packages/sdk/src/config.ts new file mode 100644 index 0000000..413c127 --- /dev/null +++ b/packages/sdk/src/config.ts @@ -0,0 +1,16 @@ +import {CirclesConfig} from "./circlesConfig"; + +export const circlesConfig: { [chainId: number]: CirclesConfig } = { + 100: { + circlesRpcUrl: "https://rpc.aboutcircles.com/", + pathfinderUrl: "https://pathfinder.aboutcircles.com", + profileServiceUrl: "https://rpc.aboutcircles.com/profiles/", + v2PathfinderUrl: "https://rpc.aboutcircles.com/pathfinder/", + v1HubAddress: "0x29b9a7fbb8995b2423a71cc17cf9810798f6c543", + v2HubAddress: "0xc12C1E50ABB450d6205Ea2C3Fa861b3B834d13e8", + nameRegistryAddress: "0xA27566fD89162cC3D40Cb59c87AAaA49B85F3474", + migrationAddress: "0xD44B8dcFBaDfC78EA64c55B705BFc68199B56376", + baseGroupMintPolicy: "0xcCa27c26CF7BAC2a9928f42201d48220F0e3a549", + standardTreasury: "0x08F90aB73A515308f03A718257ff9887ED330C6e" + } +} \ No newline at end of file diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index cf32689..f01e4f1 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -5,4 +5,5 @@ export { V1Avatar } from './v1/v1Avatar'; export { CirclesConfig } from './circlesConfig'; export { AvatarRow, TrustListRow, TrustRelationRow } from '@circles-sdk/data'; export { AvatarInterface, AvatarInterfaceV2 } from './AvatarInterface'; -export { Pathfinder, TransferPath, TransferStep } from './v1/pathfinder'; \ No newline at end of file +export { Pathfinder, TransferPath, TransferStep } from './v1/pathfinder'; +export { circlesConfig } from './config'; \ No newline at end of file diff --git a/packages/sdk/src/sdk.ts b/packages/sdk/src/sdk.ts index eb3a026..cfce853 100644 --- a/packages/sdk/src/sdk.ts +++ b/packages/sdk/src/sdk.ts @@ -20,6 +20,7 @@ import {cidV0ToUint8Array} from '@circles-sdk/utils'; import {GroupProfile, Profile, Profiles} from '@circles-sdk/profiles'; import {ContractRunner, ZeroAddress} from "ethers"; import {SdkContractRunner, TransactionRequest} from "@circles-sdk/adapter"; +import {circlesConfig} from "./config"; /** * The SDK interface. @@ -142,33 +143,34 @@ export class Sdk implements SdkInterface { /** * Creates a new SDK instance. - * @param circlesConfig The chain specific Circles configuration. * @param contractRunner A contract runner instance and its address. + * @param config The optional chain specific Circles configuration. */ - constructor(circlesConfig: CirclesConfig, contractRunner: SdkContractRunner) { - this.circlesConfig = circlesConfig; + constructor(contractRunner: SdkContractRunner, config?: CirclesConfig) { + this.circlesConfig = config ?? circlesConfig[100]; + this.contractRunner = contractRunner; if (!this.contractRunner.address) { throw new Error('Contract runner is not initialized'); } - this.circlesRpc = new CirclesRpc(circlesConfig.circlesRpcUrl); + this.circlesRpc = new CirclesRpc(this.circlesConfig.circlesRpcUrl); this.data = new CirclesData(this.circlesRpc); - this.v1Hub = HubV1Factory.connect(circlesConfig.v1HubAddress ?? '0x29b9a7fBb8995b2423a71cC17cf9810798F6C543', this.contractRunner); - if (circlesConfig.v2HubAddress) { - this.v2Hub = HubV2Factory.connect(circlesConfig.v2HubAddress, this.contractRunner); + this.v1Hub = HubV1Factory.connect(this.circlesConfig.v1HubAddress ?? '0x29b9a7fBb8995b2423a71cC17cf9810798F6C543', this.contractRunner); + if (this.circlesConfig.v2HubAddress) { + this.v2Hub = HubV2Factory.connect(this.circlesConfig.v2HubAddress, this.contractRunner); } - if (circlesConfig.pathfinderUrl) { - this.v1Pathfinder = new Pathfinder(circlesConfig.pathfinderUrl); + if (this.circlesConfig.pathfinderUrl) { + this.v1Pathfinder = new Pathfinder(this.circlesConfig.pathfinderUrl); } - if (circlesConfig.v2PathfinderUrl) { - this.v2Pathfinder = new Pathfinder(circlesConfig.v2PathfinderUrl); + if (this.circlesConfig.v2PathfinderUrl) { + this.v2Pathfinder = new Pathfinder(this.circlesConfig.v2PathfinderUrl); } - if (circlesConfig.nameRegistryAddress) { - this.nameRegistry = NameRegistry__factory.connect(circlesConfig.nameRegistryAddress, this.contractRunner); + if (this.circlesConfig.nameRegistryAddress) { + this.nameRegistry = NameRegistry__factory.connect(this.circlesConfig.nameRegistryAddress, this.contractRunner); } - if (circlesConfig.profileServiceUrl) { - this.profiles = new Profiles(circlesConfig.profileServiceUrl); + if (this.circlesConfig.profileServiceUrl) { + this.profiles = new Profiles(this.circlesConfig.profileServiceUrl); } } diff --git a/packages/utils/package.json b/packages/utils/package.json index 1455949..99e0849 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/utils", - "version": "0.12.2", + "version": "0.13.0", "description": "", "type": "module", "main": "./dist/index.js",