near-safe 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/dist/cjs/scripts/fetch-deployments.d.ts +17 -0
  2. package/dist/cjs/scripts/fetch-deployments.js +59 -0
  3. package/dist/cjs/src/_gen/deployments.d.ts +2 -0
  4. package/dist/cjs/src/_gen/deployments.js +1889 -0
  5. package/dist/cjs/{index.d.ts → src/index.d.ts} +1 -1
  6. package/dist/cjs/{index.js → src/index.js} +1 -1
  7. package/dist/{esm → cjs/src}/lib/bundler.d.ts +1 -0
  8. package/dist/cjs/{lib → src/lib}/bundler.js +15 -4
  9. package/dist/cjs/{lib → src/lib}/safe-message.d.ts +2 -7
  10. package/dist/cjs/{lib → src/lib}/safe-message.js +0 -17
  11. package/dist/cjs/src/lib/safe.d.ts +21 -0
  12. package/dist/cjs/{lib → src/lib}/safe.js +12 -56
  13. package/dist/cjs/{tx-manager.d.ts → src/near-safe.d.ts} +22 -21
  14. package/dist/cjs/{tx-manager.js → src/near-safe.js} +65 -63
  15. package/dist/cjs/{types.d.ts → src/types.d.ts} +23 -1
  16. package/dist/esm/scripts/fetch-deployments.d.ts +17 -0
  17. package/dist/esm/scripts/fetch-deployments.js +54 -0
  18. package/dist/esm/src/_gen/deployments.d.ts +2 -0
  19. package/dist/esm/src/_gen/deployments.js +1886 -0
  20. package/dist/esm/{index.d.ts → src/index.d.ts} +1 -1
  21. package/dist/esm/{index.js → src/index.js} +1 -1
  22. package/dist/{cjs → esm/src}/lib/bundler.d.ts +1 -0
  23. package/dist/esm/{lib → src/lib}/bundler.js +14 -4
  24. package/dist/esm/{lib → src/lib}/safe-message.d.ts +2 -7
  25. package/dist/esm/{lib → src/lib}/safe-message.js +0 -16
  26. package/dist/esm/src/lib/safe.d.ts +21 -0
  27. package/dist/esm/{lib → src/lib}/safe.js +11 -55
  28. package/dist/esm/{tx-manager.d.ts → src/near-safe.d.ts} +22 -21
  29. package/dist/esm/{tx-manager.js → src/near-safe.js} +65 -64
  30. package/dist/esm/{types.d.ts → src/types.d.ts} +23 -1
  31. package/package.json +4 -3
  32. package/dist/cjs/lib/safe.d.ts +0 -27
  33. package/dist/esm/lib/safe.d.ts +0 -27
  34. /package/dist/cjs/{lib → src/lib}/multisend.d.ts +0 -0
  35. /package/dist/cjs/{lib → src/lib}/multisend.js +0 -0
  36. /package/dist/cjs/{types.js → src/types.js} +0 -0
  37. /package/dist/cjs/{util.d.ts → src/util.d.ts} +0 -0
  38. /package/dist/cjs/{util.js → src/util.js} +0 -0
  39. /package/dist/esm/{lib → src/lib}/multisend.d.ts +0 -0
  40. /package/dist/esm/{lib → src/lib}/multisend.js +0 -0
  41. /package/dist/esm/{types.js → src/types.js} +0 -0
  42. /package/dist/esm/{util.d.ts → src/util.d.ts} +0 -0
  43. /package/dist/esm/{util.js → src/util.js} +0 -0
@@ -0,0 +1,17 @@
1
+ import { Deployment, SafeDeployments } from "../src/types";
2
+ export declare const SAFE_VERSION = "1.4.1";
3
+ export declare const MODULE_VERSION = "0.3.0";
4
+ type DeploymentFn = (filter?: {
5
+ version: string;
6
+ }) => {
7
+ networkAddresses: {
8
+ [chainId: string]: string;
9
+ };
10
+ abi: unknown[];
11
+ } | undefined;
12
+ type DeploymentArgs = {
13
+ version: string;
14
+ };
15
+ export declare function getDeployment(fn: DeploymentFn, { version }: DeploymentArgs): Promise<Deployment>;
16
+ export declare function fetchDeployments(safeVersion?: string, moduleVersion?: string): Promise<SafeDeployments>;
17
+ export {};
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MODULE_VERSION = exports.SAFE_VERSION = void 0;
4
+ exports.getDeployment = getDeployment;
5
+ exports.fetchDeployments = fetchDeployments;
6
+ const safe_deployments_1 = require("@safe-global/safe-deployments");
7
+ const safe_modules_deployments_1 = require("@safe-global/safe-modules-deployments");
8
+ const viem_1 = require("viem");
9
+ const util_1 = require("../src/util");
10
+ // Define the deployment version and chain ID (e.g., "1.4.1" for Safe contracts, "0.3.0" for modules)
11
+ exports.SAFE_VERSION = "1.4.1";
12
+ exports.MODULE_VERSION = "0.3.0";
13
+ async function getDeployment(fn, { version }) {
14
+ const deployment = fn({ version });
15
+ if (!deployment) {
16
+ throw new Error(`Deployment not found for ${fn.name} version ${version}`);
17
+ }
18
+ // TODO: maybe call parseAbi on deployment.abi here.
19
+ return {
20
+ address: deployment.networkAddresses["11155111"],
21
+ abi: deployment.abi,
22
+ };
23
+ }
24
+ async function fetchDeployments(safeVersion = exports.SAFE_VERSION, moduleVersion = exports.MODULE_VERSION) {
25
+ console.log("Fetching deployments...");
26
+ const safeDeployment = async (fn) => getDeployment(fn, { version: safeVersion });
27
+ const m4337Deployment = async (fn) => getDeployment(fn, { version: moduleVersion });
28
+ try {
29
+ // Fetch deployments for Safe and 4337 modules
30
+ const [singleton, proxyFactory, moduleSetup, m4337] = await Promise.all([
31
+ safeDeployment(safe_deployments_1.getSafeL2SingletonDeployment),
32
+ safeDeployment(safe_deployments_1.getProxyFactoryDeployment),
33
+ m4337Deployment(safe_modules_deployments_1.getSafeModuleSetupDeployment),
34
+ m4337Deployment(safe_modules_deployments_1.getSafe4337ModuleDeployment),
35
+ ]);
36
+ // TODO - this is a cheeky hack.
37
+ const client = (0, util_1.getClient)(11155111);
38
+ const entryPoint = {
39
+ address: (await client.readContract({
40
+ address: m4337.address,
41
+ abi: m4337.abi,
42
+ functionName: "SUPPORTED_ENTRYPOINT",
43
+ })),
44
+ abi: (0, viem_1.parseAbi)([
45
+ "function getNonce(address, uint192 key) view returns (uint256 nonce)",
46
+ ]),
47
+ };
48
+ return {
49
+ singleton,
50
+ proxyFactory,
51
+ moduleSetup,
52
+ m4337,
53
+ entryPoint,
54
+ };
55
+ }
56
+ catch (error) {
57
+ throw new Error(`Error fetching deployments: ${error}`);
58
+ }
59
+ }
@@ -0,0 +1,2 @@
1
+ import { SafeDeployments } from "../types";
2
+ export declare const SAFE_DEPLOYMENTS: SafeDeployments;