diff --git a/package.json b/package.json index f55444a..4b6da2c 100644 --- a/package.json +++ b/package.json @@ -36,5 +36,5 @@ }, "name": "@cirlces-sdk/root", "license": "MIT", - "version": "0.13.0" + "version": "0.13.1" } diff --git a/packages/abi-v1/package.json b/packages/abi-v1/package.json index a613819..5174c28 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.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/abi-v2/package.json b/packages/abi-v2/package.json index d04d13b..9a15c6a 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.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter-cometh/package.json b/packages/adapter-cometh/package.json index 7a71f5b..01daaa4 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.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.13.0", + "@circles-sdk/adapter": "0.13.1", "@cometh/connect-sdk": "1.2.29" }, "keywords": [], diff --git a/packages/adapter-ethers/package.json b/packages/adapter-ethers/package.json index 28b3140..2931e21 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.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -18,8 +18,8 @@ }, "dependencies": { "ethers": "^6.13.2", - "@circles-sdk/adapter": "0.13.0", - "@circles-sdk/utils": "0.13.0" + "@circles-sdk/adapter": "0.13.1", + "@circles-sdk/utils": "0.13.1" }, "keywords": [], "author": "", diff --git a/packages/adapter-safe-app/package.json b/packages/adapter-safe-app/package.json index 55ae9ef..0af06cb 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.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/adapter": "0.13.0", + "@circles-sdk/adapter": "0.13.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 9ae9c92..f2f6128 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.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/adapter-safe/src/index.ts b/packages/adapter-safe/src/index.ts index 0c888d0..500e6b0 100644 --- a/packages/adapter-safe/src/index.ts +++ b/packages/adapter-safe/src/index.ts @@ -4,9 +4,56 @@ import { TransactionRequest, TransactionResponse as SdkTransactionResponse } from '@circles-sdk/adapter'; import Safe, {SafeConfig} from "@safe-global/protocol-kit"; -import {BrowserProvider, Eip1193Provider, Provider} from "ethers"; +import {BrowserProvider, Eip1193Provider, ethers, Provider} from "ethers"; import {MetaTransaction, OperationType} from "ethers-multisend"; +export class SafeSdkPrivateKeyContractRunner implements SdkContractRunner { + address?: string; + safe?: Safe; + private rpcUrl: string; + private privateKey: string; + + constructor(privateKey: string, rpcUrl: string) { + this.privateKey = privateKey; + this.rpcUrl = rpcUrl; + this.provider = new ethers.JsonRpcProvider(this.rpcUrl); + } + + async init(safeAddress: string): Promise { + this.address = safeAddress; + this.safe = await Safe.init({ + provider: this.rpcUrl, + signer: this.privateKey, + safeAddress: safeAddress + }); + } + + provider: Provider; + estimateGas?: ((tx: SdkTransactionRequest) => Promise) | undefined = async (tx) => this.provider.estimateGas(tx); + call?: ((tx: SdkTransactionRequest) => Promise) | undefined = async (tx) => this.provider.call(tx); + resolveName?: ((name: string) => Promise) | undefined = async (name) => this.provider.resolveName(name); + sendTransaction?: ((tx: SdkTransactionRequest) => Promise) | undefined = async (tx) => { + if (!this.safe) { + throw new Error("Safe not initialized") + } + const txs = await this.safe.createTransaction({ + transactions: [{ + to: tx.to, + value: (tx.value?.toString() ?? "0"), + data: tx.data + }] + }); + const txResponse = await this.safe.executeTransaction(txs); + return txResponse.transactionResponse; + }; + sendBatchTransaction?: () => BatchRun = () => { + if (!this.safe) { + throw new Error("Not initialized"); + } + return new SafeBatchRun(this.safe); + } +} + export class SafeSdkBrowserContractRunner implements SdkContractRunner { address?: string; browserProvider: BrowserProvider; diff --git a/packages/adapter/package.json b/packages/adapter/package.json index bc904c8..75a4a96 100644 --- a/packages/adapter/package.json +++ b/packages/adapter/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/adapter", - "version": "0.13.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", diff --git a/packages/data/package.json b/packages/data/package.json index 93820e0..7daddfe 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/data", - "version": "0.13.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.13.0" + "@circles-sdk/utils": "0.13.1" }, "keywords": [], "author": "", diff --git a/packages/profiles/package.json b/packages/profiles/package.json index 35bde44..235129f 100644 --- a/packages/profiles/package.json +++ b/packages/profiles/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/profiles", - "version": "0.13.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,7 +17,7 @@ "build": "rollup -c" }, "dependencies": { - "@circles-sdk/utils": "0.13.0" + "@circles-sdk/utils": "0.13.1" }, "keywords": [], "author": "", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 5afb169..f12495a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/sdk", - "version": "0.13.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js", @@ -17,11 +17,11 @@ "author": "", "license": "MIT", "dependencies": { - "@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", + "@circles-sdk/abi-v1": "0.13.1", + "@circles-sdk/abi-v2": "0.13.1", + "@circles-sdk/data": "0.13.1", + "@circles-sdk/profiles": "0.13.1", + "@circles-sdk/adapter-ethers": "0.13.1", "ethers": "^6.13.2", "multihashes": "^4.0.3" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index 99e0849..cc71740 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@circles-sdk/utils", - "version": "0.13.0", + "version": "0.13.1", "description": "", "type": "module", "main": "./dist/index.js",