@aboutcircles/sdk-runner 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.
@@ -1,7 +1,9 @@
1
1
  import type { Address, TransactionRequest } from '@aboutcircles/sdk-types';
2
2
  import type { ContractRunner, BatchRun } from './runner.js';
3
- import type { PublicClient, TransactionReceipt, Chain } from 'viem';
4
- import type { EIP1193Provider } from 'viem';
3
+ import type { PublicClient, TransactionReceipt } from 'viem';
4
+ import type { Eip1193Provider } from '@safe-global/protocol-kit';
5
+ import Safe from '@safe-global/protocol-kit';
6
+ import { type ChainLike } from './chain-types.js';
5
7
  /**
6
8
  * Safe browser contract runner implementation using Safe Protocol Kit
7
9
  * Executes transactions through a Safe multisig wallet using the browser's Web3 provider
@@ -41,29 +43,38 @@ export declare class SafeBrowserRunner implements ContractRunner {
41
43
  * await runner.init();
42
44
  * ```
43
45
  */
44
- constructor(publicClient: PublicClient, eip1193Provider: EIP1193Provider, safeAddress?: Address);
46
+ constructor(publicClient: PublicClient, eip1193Provider: Eip1193Provider, safeAddress?: Address);
45
47
  /**
46
48
  * Create and initialize a SafeBrowserRunner in one step
47
49
  * @param rpcUrl - The RPC URL to connect to
48
50
  * @param eip1193Provider - The EIP-1193 provider from the browser (e.g., window.ethereum)
49
51
  * @param safeAddress - The address of the Safe wallet
50
- * @param chain - The viem chain configuration (e.g., gnosis from 'viem/chains')
52
+ * @param chain - Chain configuration (accepts viem Chain or ChainConfig object)
51
53
  * @returns An initialized SafeBrowserRunner instance
52
54
  *
53
55
  * @example
54
56
  * ```typescript
55
57
  * import { gnosis } from 'viem/chains';
56
- * import { SafeBrowserRunner } from '@aboutcircles/sdk-runner';
58
+ * import { SafeBrowserRunner, chains } from '@aboutcircles/sdk-runner';
57
59
  *
60
+ * // Using viem chain (for backward compatibility)
58
61
  * const runner = await SafeBrowserRunner.create(
59
62
  * 'https://rpc.gnosischain.com',
60
63
  * window.ethereum,
61
64
  * '0xYourSafeAddress...',
62
65
  * gnosis
63
66
  * );
67
+ *
68
+ * // Using built-in chain config (no viem import needed)
69
+ * const runner = await SafeBrowserRunner.create(
70
+ * 'https://rpc.gnosischain.com',
71
+ * window.ethereum,
72
+ * '0xYourSafeAddress...',
73
+ * chains.gnosis
74
+ * );
64
75
  * ```
65
76
  */
66
- static create(rpcUrl: string, eip1193Provider: EIP1193Provider, safeAddress: Address, chain: Chain): Promise<SafeBrowserRunner>;
77
+ static create(rpcUrl: string, eip1193Provider: Eip1193Provider, safeAddress: Address, chain: ChainLike): Promise<SafeBrowserRunner>;
67
78
  /**
68
79
  * Initialize the runner with a Safe address
69
80
  * @param safeAddress - The address of the Safe wallet (optional if provided in constructor)
@@ -110,7 +121,7 @@ export declare class SafeBrowserBatchRun implements BatchRun {
110
121
  private readonly safe;
111
122
  private readonly publicClient;
112
123
  private readonly transactions;
113
- constructor(safe: any, publicClient: PublicClient);
124
+ constructor(safe: InstanceType<typeof Safe>, publicClient: PublicClient);
114
125
  /**
115
126
  * Add a transaction to the batch
116
127
  */
@@ -118,7 +129,7 @@ export declare class SafeBrowserBatchRun implements BatchRun {
118
129
  /**
119
130
  * Get the Safe transaction data for all batched transactions
120
131
  */
121
- getSafeTransaction(): Promise<any>;
132
+ getSafeTransaction(): Promise<import("@safe-global/types-kit").SafeTransaction>;
122
133
  /**
123
134
  * Execute all batched transactions and wait for confirmation
124
135
  * The user will be prompted to sign the transaction through their Web3 wallet
@@ -1 +1 @@
1
- {"version":3,"file":"safe-browser-runner.d.ts","sourceRoot":"","sources":["../src/safe-browser-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAO,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO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G,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBhD;;;OAGG;IACH,OAAO,CAAC,UAAU;IAOlB;;OAEG;IACH,WAAW,GAAU,IAAI,kBAAkB,KAAG,OAAO,CAAC,MAAM,CAAC,CAW3D;IAEF;;OAEG;IACH,IAAI,GAAU,IAAI,kBAAkB,KAAG,OAAO,CAAC,MAAM,CAAC,CAapD;IAEF;;OAEG;IACH,WAAW,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUxD;IAEF;;;;;;;OAOG;IACH,eAAe,GAAU,KAAK,kBAAkB,EAAE,KAAG,OAAO,CAAC,kBAAkB,CAAC,CA0C9E;IAEF;;;OAGG;IACH,oBAAoB,QAAO,mBAAmB,CAG5C;CACH;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,QAAQ;IAIhD,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAJ/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;gBAGtC,IAAI,EAAE,YAAY,CAAC,OAAO,IAAI,CAAC,EAC/B,YAAY,EAAE,YAAY;IAG7C;;OAEG;IACH,cAAc,CAAC,EAAE,EAAE,kBAAkB;IAIrC;;OAEG;IACG,kBAAkB;IAexB;;;;;OAKG;IACG,GAAG,IAAI,OAAO,CAAC,kBAAkB,CAAC;CA0BzC"}
@@ -1,12 +1,8 @@
1
1
  import { createPublicClient, http } from 'viem';
2
2
  import { OperationType } from '@safe-global/safe-core-sdk-types';
3
+ import Safe from '@safe-global/protocol-kit';
3
4
  import { RunnerError } from './errors.js';
4
- // Use require for Safe to ensure compatibility with bun's CJS/ESM interop
5
- // Safe Protocol Kit v5 uses CommonJS exports, so we use require() for proper interop
6
- // eslint-disable-next-line @typescript-eslint/no-var-requires
7
- //@todo double check the import format
8
- const SafeModule = require('@safe-global/protocol-kit');
9
- const Safe = SafeModule.default || SafeModule;
5
+ import { asViemChain } from './chain-types.js';
10
6
  /**
11
7
  * Safe browser contract runner implementation using Safe Protocol Kit
12
8
  * Executes transactions through a Safe multisig wallet using the browser's Web3 provider
@@ -56,25 +52,34 @@ export class SafeBrowserRunner {
56
52
  * @param rpcUrl - The RPC URL to connect to
57
53
  * @param eip1193Provider - The EIP-1193 provider from the browser (e.g., window.ethereum)
58
54
  * @param safeAddress - The address of the Safe wallet
59
- * @param chain - The viem chain configuration (e.g., gnosis from 'viem/chains')
55
+ * @param chain - Chain configuration (accepts viem Chain or ChainConfig object)
60
56
  * @returns An initialized SafeBrowserRunner instance
61
57
  *
62
58
  * @example
63
59
  * ```typescript
64
60
  * import { gnosis } from 'viem/chains';
65
- * import { SafeBrowserRunner } from '@aboutcircles/sdk-runner';
61
+ * import { SafeBrowserRunner, chains } from '@aboutcircles/sdk-runner';
66
62
  *
63
+ * // Using viem chain (for backward compatibility)
67
64
  * const runner = await SafeBrowserRunner.create(
68
65
  * 'https://rpc.gnosischain.com',
69
66
  * window.ethereum,
70
67
  * '0xYourSafeAddress...',
71
68
  * gnosis
72
69
  * );
70
+ *
71
+ * // Using built-in chain config (no viem import needed)
72
+ * const runner = await SafeBrowserRunner.create(
73
+ * 'https://rpc.gnosischain.com',
74
+ * window.ethereum,
75
+ * '0xYourSafeAddress...',
76
+ * chains.gnosis
77
+ * );
73
78
  * ```
74
79
  */
75
80
  static async create(rpcUrl, eip1193Provider, safeAddress, chain) {
76
81
  const publicClient = createPublicClient({
77
- chain,
82
+ chain: asViemChain(chain),
78
83
  transport: http(rpcUrl),
79
84
  });
80
85
  const runner = new SafeBrowserRunner(publicClient, eip1193Provider, safeAddress);
@@ -1,6 +1,9 @@
1
1
  import type { Address, Hex, TransactionRequest } from '@aboutcircles/sdk-types';
2
2
  import type { ContractRunner, BatchRun } from './runner.js';
3
- import type { PublicClient, TransactionReceipt, Chain } from 'viem';
3
+ import type { PublicClient, TransactionReceipt } from 'viem';
4
+ import type { SafeTransaction } from '@safe-global/types-kit';
5
+ import { type ChainLike } from './chain-types.js';
6
+ import Safe from '@safe-global/protocol-kit';
4
7
  /**
5
8
  * Batch transaction runner for Safe
6
9
  * Allows multiple transactions to be batched and executed together
@@ -9,7 +12,7 @@ export declare class SafeBatchRun implements BatchRun {
9
12
  private readonly safe;
10
13
  private readonly publicClient;
11
14
  private readonly transactions;
12
- constructor(safe: any, publicClient: PublicClient);
15
+ constructor(safe: InstanceType<typeof Safe>, publicClient: PublicClient);
13
16
  /**
14
17
  * Add a transaction to the batch
15
18
  */
@@ -17,7 +20,7 @@ export declare class SafeBatchRun implements BatchRun {
17
20
  /**
18
21
  * Get the Safe transaction data for all batched transactions
19
22
  */
20
- getSafeTransaction(): Promise<any>;
23
+ getSafeTransaction(): Promise<SafeTransaction>;
21
24
  /**
22
25
  * Execute all batched transactions and wait for confirmation
23
26
  * @throws {RunnerError} If transaction reverts or execution fails
@@ -48,23 +51,32 @@ export declare class SafeContractRunner implements ContractRunner {
48
51
  * @param rpcUrl - The RPC URL to connect to
49
52
  * @param privateKey - The private key of one of the Safe signers
50
53
  * @param safeAddress - The address of the Safe wallet
51
- * @param chain - The viem chain configuration (e.g., gnosis from 'viem/chains')
54
+ * @param chain - Chain configuration (accepts viem Chain or ChainConfig object)
52
55
  * @returns An initialized SafeContractRunner instance
53
56
  *
54
57
  * @example
55
58
  * ```typescript
56
59
  * import { gnosis } from 'viem/chains';
57
- * import { SafeContractRunner } from '@aboutcircles/sdk-runner';
60
+ * import { SafeContractRunner, chains } from '@aboutcircles/sdk-runner';
58
61
  *
62
+ * // Using viem chain (for backward compatibility)
59
63
  * const runner = await SafeContractRunner.create(
60
64
  * 'https://rpc.gnosischain.com',
61
65
  * '0xYourPrivateKey...',
62
66
  * '0xYourSafeAddress...',
63
67
  * gnosis
64
68
  * );
69
+ *
70
+ * // Using built-in chain config (no viem import needed)
71
+ * const runner = await SafeContractRunner.create(
72
+ * 'https://rpc.gnosischain.com',
73
+ * '0xYourPrivateKey...',
74
+ * '0xYourSafeAddress...',
75
+ * chains.gnosis
76
+ * );
65
77
  * ```
66
78
  */
67
- static create(rpcUrl: string, privateKey: Hex, safeAddress: Address, chain: Chain): Promise<SafeContractRunner>;
79
+ static create(rpcUrl: string, privateKey: Hex, safeAddress: Address, chain: ChainLike): Promise<SafeContractRunner>;
68
80
  /**
69
81
  * Initialize the runner with a Safe address
70
82
  * @param safeAddress - The address of the Safe wallet (optional if provided in constructor)
@@ -1 +1 @@
1
- {"version":3,"file":"safe-runner.d.ts","sourceRoot":"","sources":["../src/safe-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAYpE;;;GAGG;AACH,qBAAa,YAAa,YAAW,QAAQ;IAIzC,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAJ/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;gBAGtC,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,YAAY;IAG7C;;OAEG;IACH,cAAc,CAAC,EAAE,EAAE,kBAAkB;IAIrC;;OAEG;IACG,kBAAkB;IAexB;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,kBAAkB,CAAC;CA0BzC;AAED;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IAChD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;IAElC,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAC,CAAU;IAC9B,OAAO,CAAC,IAAI,CAAC,CAAM;IAEnB;;;;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OAAO,CAAC,MAAM,CAAC,CAapD;IAEF;;OAEG;IACH,WAAW,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUxD;IAEF;;;;;OAKG;IACH,eAAe,GAAU,KAAK,kBAAkB,EAAE,KAAG,OAAO,CAAC,kBAAkB,CAAC,CA0C9E;IAEF;;;OAGG;IACH,oBAAoB,QAAO,YAAY,CAGrC;CACH"}
@@ -1,11 +1,8 @@
1
1
  import { createPublicClient, http } from 'viem';
2
2
  import { OperationType } from '@safe-global/safe-core-sdk-types';
3
3
  import { RunnerError } from './errors.js';
4
- // Use require for Safe to ensure compatibility with bun's CJS/ESM interop
5
- // Safe Protocol Kit v5 uses CommonJS exports, so we use require() for proper interop
6
- // eslint-disable-next-line @typescript-eslint/no-var-requires
7
- const SafeModule = require('@safe-global/protocol-kit');
8
- const Safe = SafeModule.default || SafeModule;
4
+ import { asViemChain } from './chain-types.js';
5
+ import Safe from '@safe-global/protocol-kit';
9
6
  /**
10
7
  * Batch transaction runner for Safe
11
8
  * Allows multiple transactions to be batched and executed together
@@ -91,25 +88,34 @@ export class SafeContractRunner {
91
88
  * @param rpcUrl - The RPC URL to connect to
92
89
  * @param privateKey - The private key of one of the Safe signers
93
90
  * @param safeAddress - The address of the Safe wallet
94
- * @param chain - The viem chain configuration (e.g., gnosis from 'viem/chains')
91
+ * @param chain - Chain configuration (accepts viem Chain or ChainConfig object)
95
92
  * @returns An initialized SafeContractRunner instance
96
93
  *
97
94
  * @example
98
95
  * ```typescript
99
96
  * import { gnosis } from 'viem/chains';
100
- * import { SafeContractRunner } from '@aboutcircles/sdk-runner';
97
+ * import { SafeContractRunner, chains } from '@aboutcircles/sdk-runner';
101
98
  *
99
+ * // Using viem chain (for backward compatibility)
102
100
  * const runner = await SafeContractRunner.create(
103
101
  * 'https://rpc.gnosischain.com',
104
102
  * '0xYourPrivateKey...',
105
103
  * '0xYourSafeAddress...',
106
104
  * gnosis
107
105
  * );
106
+ *
107
+ * // Using built-in chain config (no viem import needed)
108
+ * const runner = await SafeContractRunner.create(
109
+ * 'https://rpc.gnosischain.com',
110
+ * '0xYourPrivateKey...',
111
+ * '0xYourSafeAddress...',
112
+ * chains.gnosis
113
+ * );
108
114
  * ```
109
115
  */
110
116
  static async create(rpcUrl, privateKey, safeAddress, chain) {
111
117
  const publicClient = createPublicClient({
112
- chain,
118
+ chain: asViemChain(chain),
113
119
  transport: http(rpcUrl),
114
120
  });
115
121
  const runner = new SafeContractRunner(publicClient, privateKey, rpcUrl, safeAddress);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aboutcircles/sdk-runner",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Contract runner implementations for Circles SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,7 +12,8 @@
12
12
  }
13
13
  },
14
14
  "scripts": {
15
- "build": "bun build ./src/index.ts --outdir ./dist --format esm && tsc --emitDeclarationOnly",
15
+ "build": "bun build ./src/index.ts --outdir ./dist --format esm && tsc --emitDeclarationOnly && bun run patch:esm",
16
+ "patch:esm": "node -e \"const fs=require('fs');const f='dist/index.js';let c=fs.readFileSync(f,'utf8');c=c.replace(/__toESM\\(require_src3\\(\\), 1\\)/g,'__toESM(require_src3(), 0)');fs.writeFileSync(f,c);console.log('Patched ESM interop for protocol-kit');\"",
16
17
  "dev": "tsc --build --watch",
17
18
  "clean": "rm -rf dist tsconfig.tsbuildinfo"
18
19
  },