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.
- package/dist/cjs/scripts/fetch-deployments.d.ts +17 -0
- package/dist/cjs/scripts/fetch-deployments.js +59 -0
- package/dist/cjs/src/_gen/deployments.d.ts +2 -0
- package/dist/cjs/src/_gen/deployments.js +1889 -0
- package/dist/cjs/{index.d.ts → src/index.d.ts} +1 -1
- package/dist/cjs/{index.js → src/index.js} +1 -1
- package/dist/{esm → cjs/src}/lib/bundler.d.ts +1 -0
- package/dist/cjs/{lib → src/lib}/bundler.js +15 -4
- package/dist/cjs/{lib → src/lib}/safe-message.d.ts +2 -7
- package/dist/cjs/{lib → src/lib}/safe-message.js +0 -17
- package/dist/cjs/src/lib/safe.d.ts +21 -0
- package/dist/cjs/{lib → src/lib}/safe.js +12 -56
- package/dist/cjs/{tx-manager.d.ts → src/near-safe.d.ts} +22 -21
- package/dist/cjs/{tx-manager.js → src/near-safe.js} +65 -63
- package/dist/cjs/{types.d.ts → src/types.d.ts} +23 -1
- package/dist/esm/scripts/fetch-deployments.d.ts +17 -0
- package/dist/esm/scripts/fetch-deployments.js +54 -0
- package/dist/esm/src/_gen/deployments.d.ts +2 -0
- package/dist/esm/src/_gen/deployments.js +1886 -0
- package/dist/esm/{index.d.ts → src/index.d.ts} +1 -1
- package/dist/esm/{index.js → src/index.js} +1 -1
- package/dist/{cjs → esm/src}/lib/bundler.d.ts +1 -0
- package/dist/esm/{lib → src/lib}/bundler.js +14 -4
- package/dist/esm/{lib → src/lib}/safe-message.d.ts +2 -7
- package/dist/esm/{lib → src/lib}/safe-message.js +0 -16
- package/dist/esm/src/lib/safe.d.ts +21 -0
- package/dist/esm/{lib → src/lib}/safe.js +11 -55
- package/dist/esm/{tx-manager.d.ts → src/near-safe.d.ts} +22 -21
- package/dist/esm/{tx-manager.js → src/near-safe.js} +65 -64
- package/dist/esm/{types.d.ts → src/types.d.ts} +23 -1
- package/package.json +4 -3
- package/dist/cjs/lib/safe.d.ts +0 -27
- package/dist/esm/lib/safe.d.ts +0 -27
- /package/dist/cjs/{lib → src/lib}/multisend.d.ts +0 -0
- /package/dist/cjs/{lib → src/lib}/multisend.js +0 -0
- /package/dist/cjs/{types.js → src/types.js} +0 -0
- /package/dist/cjs/{util.d.ts → src/util.d.ts} +0 -0
- /package/dist/cjs/{util.js → src/util.js} +0 -0
- /package/dist/esm/{lib → src/lib}/multisend.d.ts +0 -0
- /package/dist/esm/{lib → src/lib}/multisend.js +0 -0
- /package/dist/esm/{types.js → src/types.js} +0 -0
- /package/dist/esm/{util.d.ts → src/util.d.ts} +0 -0
- /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
|
+
}
|