@bananapus/nana-sdk-core 2.5.1 → 2.6.0
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.
- package/dist/cjs/safe.d.ts +208 -0
- package/dist/cjs/safe.d.ts.map +1 -0
- package/dist/cjs/safe.js +396 -0
- package/dist/cjs/safe.js.map +1 -0
- package/dist/esm/safe.d.ts +208 -0
- package/dist/esm/safe.d.ts.map +1 -0
- package/dist/esm/safe.js +381 -0
- package/dist/esm/safe.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from "viem";
|
|
2
|
+
export declare const SAFE_FACTORY: `0x${string}`;
|
|
3
|
+
export declare const SAFE_SINGLETON: `0x${string}`;
|
|
4
|
+
export declare const SAFE_FALLBACK: `0x${string}`;
|
|
5
|
+
export declare const MULTICALL3: `0x${string}`;
|
|
6
|
+
export declare const MAX_SAFE_OWNERS = 50;
|
|
7
|
+
export declare const SAFE_CREATE_ABI: readonly [{
|
|
8
|
+
readonly name: "proxyCreationCode";
|
|
9
|
+
readonly type: "function";
|
|
10
|
+
readonly stateMutability: "pure";
|
|
11
|
+
readonly inputs: readonly [];
|
|
12
|
+
readonly outputs: readonly [{
|
|
13
|
+
readonly type: "bytes";
|
|
14
|
+
}];
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "createProxyWithNonce";
|
|
17
|
+
readonly type: "function";
|
|
18
|
+
readonly stateMutability: "nonpayable";
|
|
19
|
+
readonly inputs: readonly [{
|
|
20
|
+
readonly type: "address";
|
|
21
|
+
readonly name: "singleton";
|
|
22
|
+
}, {
|
|
23
|
+
readonly type: "bytes";
|
|
24
|
+
readonly name: "initializer";
|
|
25
|
+
}, {
|
|
26
|
+
readonly type: "uint256";
|
|
27
|
+
readonly name: "saltNonce";
|
|
28
|
+
}];
|
|
29
|
+
readonly outputs: readonly [{
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
readonly name: "proxy";
|
|
32
|
+
}];
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "setup";
|
|
35
|
+
readonly type: "function";
|
|
36
|
+
readonly stateMutability: "nonpayable";
|
|
37
|
+
readonly inputs: readonly [{
|
|
38
|
+
readonly type: "address[]";
|
|
39
|
+
readonly name: "owners";
|
|
40
|
+
}, {
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
readonly name: "threshold";
|
|
43
|
+
}, {
|
|
44
|
+
readonly type: "address";
|
|
45
|
+
readonly name: "to";
|
|
46
|
+
}, {
|
|
47
|
+
readonly type: "bytes";
|
|
48
|
+
readonly name: "data";
|
|
49
|
+
}, {
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
readonly name: "fallbackHandler";
|
|
52
|
+
}, {
|
|
53
|
+
readonly type: "address";
|
|
54
|
+
readonly name: "paymentToken";
|
|
55
|
+
}, {
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
readonly name: "payment";
|
|
58
|
+
}, {
|
|
59
|
+
readonly type: "address";
|
|
60
|
+
readonly name: "paymentReceiver";
|
|
61
|
+
}];
|
|
62
|
+
readonly outputs: readonly [];
|
|
63
|
+
}];
|
|
64
|
+
export declare const CREATE_BATCH_ABI: readonly [{
|
|
65
|
+
readonly name: "aggregate3Value";
|
|
66
|
+
readonly type: "function";
|
|
67
|
+
readonly stateMutability: "payable";
|
|
68
|
+
readonly inputs: readonly [{
|
|
69
|
+
readonly type: "tuple[]";
|
|
70
|
+
readonly components: readonly [{
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
readonly name: "target";
|
|
73
|
+
}, {
|
|
74
|
+
readonly type: "bool";
|
|
75
|
+
readonly name: "allowFailure";
|
|
76
|
+
}, {
|
|
77
|
+
readonly type: "uint256";
|
|
78
|
+
readonly name: "value";
|
|
79
|
+
}, {
|
|
80
|
+
readonly type: "bytes";
|
|
81
|
+
readonly name: "callData";
|
|
82
|
+
}];
|
|
83
|
+
readonly name: "calls";
|
|
84
|
+
}];
|
|
85
|
+
readonly outputs: readonly [{
|
|
86
|
+
readonly type: "tuple[]";
|
|
87
|
+
readonly components: readonly [{
|
|
88
|
+
readonly type: "bool";
|
|
89
|
+
readonly name: "success";
|
|
90
|
+
}, {
|
|
91
|
+
readonly type: "bytes";
|
|
92
|
+
readonly name: "returnData";
|
|
93
|
+
}];
|
|
94
|
+
readonly name: "returnData";
|
|
95
|
+
}];
|
|
96
|
+
}];
|
|
97
|
+
export type SafeDeploymentPlan = {
|
|
98
|
+
owners: Address[];
|
|
99
|
+
threshold: number;
|
|
100
|
+
saltNonce: Hex;
|
|
101
|
+
proxyCreationCode: Hex;
|
|
102
|
+
address: Address;
|
|
103
|
+
};
|
|
104
|
+
export type SafeCall = {
|
|
105
|
+
to: Address;
|
|
106
|
+
data: Hex;
|
|
107
|
+
value: bigint;
|
|
108
|
+
};
|
|
109
|
+
export type SafeAddressInput = {
|
|
110
|
+
kind: "existing";
|
|
111
|
+
address: Address;
|
|
112
|
+
} | {
|
|
113
|
+
kind: "create";
|
|
114
|
+
owners: Address[];
|
|
115
|
+
threshold: number;
|
|
116
|
+
saltNonce: Hex;
|
|
117
|
+
};
|
|
118
|
+
export type SafeVerificationOptions = {
|
|
119
|
+
/** Missing code is allowed only for a preflight check, never receipt acceptance. */
|
|
120
|
+
allowMissing?: boolean;
|
|
121
|
+
/** Use the receipt block to recover a launch even after subsequent owner changes. */
|
|
122
|
+
blockNumber?: bigint;
|
|
123
|
+
};
|
|
124
|
+
/** Plain Safe only: no delegatecall hook, modules, guard, or setup payments. */
|
|
125
|
+
export declare function buildSafeInitializer(policy: {
|
|
126
|
+
owners: readonly Address[];
|
|
127
|
+
threshold: number;
|
|
128
|
+
}): Hex;
|
|
129
|
+
/** Owner order and the original 32-byte salt are part of the deterministic address. */
|
|
130
|
+
export declare function predictSafeAddress(plan: Omit<SafeDeploymentPlan, "address">): Address;
|
|
131
|
+
export declare function validateSafeDeploymentPlan(plan: SafeDeploymentPlan): void;
|
|
132
|
+
/** Check canonical dependencies before trusting factory-returned creation code. */
|
|
133
|
+
export declare function readSafeCreationCode(client: PublicClient): Promise<Hex>;
|
|
134
|
+
/** Existing inputs are address-only: this does not certify an arbitrary address as a Safe. */
|
|
135
|
+
export declare function resolveSafeAddress(input: SafeAddressInput, clients: readonly PublicClient[]): Promise<{
|
|
136
|
+
address: Address;
|
|
137
|
+
plan?: SafeDeploymentPlan;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Certify this module's plain Safe profile, failing closed on malformed state or RPC errors.
|
|
141
|
+
* Receipt recovery pins every code, storage, and raw policy read to blockNumber.
|
|
142
|
+
* Contract signers are supported; this verifies their membership, not their own policy.
|
|
143
|
+
*/
|
|
144
|
+
export declare function verifySafeDeployments(client: PublicClient, plans: readonly SafeDeploymentPlan[], options?: SafeVerificationOptions): Promise<boolean>;
|
|
145
|
+
export declare function checkSafeDeployments(client: PublicClient, plans?: readonly SafeDeploymentPlan[]): Promise<void>;
|
|
146
|
+
/** Optional factory calls are idempotent only with preflight, simulation, and receipt verification. */
|
|
147
|
+
export declare function buildSafeDeploymentCalls(plans: readonly SafeDeploymentPlan[]): {
|
|
148
|
+
target: `0x${string}`;
|
|
149
|
+
allowFailure: true;
|
|
150
|
+
value: bigint;
|
|
151
|
+
callData: `0x${string}`;
|
|
152
|
+
}[];
|
|
153
|
+
export declare function buildSafeDeploymentTx(chainId: number, plans: readonly SafeDeploymentPlan[]): {
|
|
154
|
+
chainId: number;
|
|
155
|
+
address: `0x${string}`;
|
|
156
|
+
abi: readonly [{
|
|
157
|
+
readonly name: "aggregate3Value";
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
readonly stateMutability: "payable";
|
|
160
|
+
readonly inputs: readonly [{
|
|
161
|
+
readonly type: "tuple[]";
|
|
162
|
+
readonly components: readonly [{
|
|
163
|
+
readonly type: "address";
|
|
164
|
+
readonly name: "target";
|
|
165
|
+
}, {
|
|
166
|
+
readonly type: "bool";
|
|
167
|
+
readonly name: "allowFailure";
|
|
168
|
+
}, {
|
|
169
|
+
readonly type: "uint256";
|
|
170
|
+
readonly name: "value";
|
|
171
|
+
}, {
|
|
172
|
+
readonly type: "bytes";
|
|
173
|
+
readonly name: "callData";
|
|
174
|
+
}];
|
|
175
|
+
readonly name: "calls";
|
|
176
|
+
}];
|
|
177
|
+
readonly outputs: readonly [{
|
|
178
|
+
readonly type: "tuple[]";
|
|
179
|
+
readonly components: readonly [{
|
|
180
|
+
readonly type: "bool";
|
|
181
|
+
readonly name: "success";
|
|
182
|
+
}, {
|
|
183
|
+
readonly type: "bytes";
|
|
184
|
+
readonly name: "returnData";
|
|
185
|
+
}];
|
|
186
|
+
readonly name: "returnData";
|
|
187
|
+
}];
|
|
188
|
+
}];
|
|
189
|
+
functionName: "aggregate3Value";
|
|
190
|
+
args: readonly [{
|
|
191
|
+
target: `0x${string}`;
|
|
192
|
+
allowFailure: true;
|
|
193
|
+
value: bigint;
|
|
194
|
+
callData: `0x${string}`;
|
|
195
|
+
}[]];
|
|
196
|
+
value: bigint;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Multicall3 changes msg.sender. Use only a sender-independent or already authenticated
|
|
200
|
+
* forwarded launch. This helper cannot decide the launch contract's authorization semantics.
|
|
201
|
+
* Simulate the returned call, verifySafeLaunchSimulation, then verify receipt-block state.
|
|
202
|
+
*/
|
|
203
|
+
export declare function bundleSafeLaunch(call: SafeCall, plans?: readonly SafeDeploymentPlan[]): SafeCall;
|
|
204
|
+
/** Require the exact reviewed factory calls, their order, one mandatory launch, and its value. */
|
|
205
|
+
export declare function unbundleSafeLaunch(call: SafeCall, plans?: readonly SafeDeploymentPlan[]): SafeCall;
|
|
206
|
+
/** Outer simulation success is insufficient: an optional deployment may have failed. */
|
|
207
|
+
export declare function verifySafeLaunchSimulation(client: PublicClient, plans?: readonly SafeDeploymentPlan[], data?: Hex): Promise<void>;
|
|
208
|
+
//# sourceMappingURL=safe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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AQ,EACd,KAAK,GAAE,SAAS,kBAAkB,EAAO,GACxC,QAAQ,CA2BV;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EACd,KAAK,GAAE,SAAS,kBAAkB,EAAO,GACxC,QAAQ,CAmBV;AAED,wFAAwF;AACxF,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,YAAY,EACpB,KAAK,GAAE,SAAS,kBAAkB,EAAO,EACzC,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
|
package/dist/cjs/safe.js
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CREATE_BATCH_ABI = exports.SAFE_CREATE_ABI = exports.MAX_SAFE_OWNERS = exports.MULTICALL3 = exports.SAFE_FALLBACK = exports.SAFE_SINGLETON = exports.SAFE_FACTORY = void 0;
|
|
4
|
+
exports.buildSafeInitializer = buildSafeInitializer;
|
|
5
|
+
exports.predictSafeAddress = predictSafeAddress;
|
|
6
|
+
exports.validateSafeDeploymentPlan = validateSafeDeploymentPlan;
|
|
7
|
+
exports.readSafeCreationCode = readSafeCreationCode;
|
|
8
|
+
exports.resolveSafeAddress = resolveSafeAddress;
|
|
9
|
+
exports.verifySafeDeployments = verifySafeDeployments;
|
|
10
|
+
exports.checkSafeDeployments = checkSafeDeployments;
|
|
11
|
+
exports.buildSafeDeploymentCalls = buildSafeDeploymentCalls;
|
|
12
|
+
exports.buildSafeDeploymentTx = buildSafeDeploymentTx;
|
|
13
|
+
exports.bundleSafeLaunch = bundleSafeLaunch;
|
|
14
|
+
exports.unbundleSafeLaunch = unbundleSafeLaunch;
|
|
15
|
+
exports.verifySafeLaunchSimulation = verifySafeLaunchSimulation;
|
|
16
|
+
const viem_1 = require("viem");
|
|
17
|
+
// Canonical Safe 1.4.1 deployments, from safe-global/safe-deployments.
|
|
18
|
+
// A fixed singleton and initializer preserve CREATE2 addresses across chains.
|
|
19
|
+
exports.SAFE_FACTORY = (0, viem_1.getAddress)("0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67");
|
|
20
|
+
exports.SAFE_SINGLETON = (0, viem_1.getAddress)("0x41675C099F32341bf84BFc5382aF534df5C7461a");
|
|
21
|
+
exports.SAFE_FALLBACK = (0, viem_1.getAddress)("0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99");
|
|
22
|
+
exports.MULTICALL3 = (0, viem_1.getAddress)("0xcA11bde05977b3631167028862bE2a173976CA11");
|
|
23
|
+
exports.MAX_SAFE_OWNERS = 50;
|
|
24
|
+
const contracts = [
|
|
25
|
+
[
|
|
26
|
+
exports.SAFE_FACTORY,
|
|
27
|
+
"0x50c3cdc4074750a7a974204a716c999edd37482f907608d960b2b025ee0b3317",
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
exports.SAFE_SINGLETON,
|
|
31
|
+
"0x1fe2df852ba3299d6534ef416eefa406e56ced995bca886ab7a553e6d0c5e1c4",
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
exports.SAFE_FALLBACK,
|
|
35
|
+
"0x7c6007a5d711cea8dfd5d91f5940ec29c7f200fe511eb1fc1397b367af3c42f9",
|
|
36
|
+
],
|
|
37
|
+
];
|
|
38
|
+
const PROXY_CODE_HASH = "0xd7d408ebcd99b2b70be43e20253d6d92a8ea8fab29bd3be7f55b10032331fb4c";
|
|
39
|
+
const SENTINEL = "0x0000000000000000000000000000000000000001";
|
|
40
|
+
const SINGLETON_SLOT = (0, viem_1.toHex)(0n, { size: 32 });
|
|
41
|
+
const GUARD_SLOT = "0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8";
|
|
42
|
+
const FALLBACK_SLOT = "0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5";
|
|
43
|
+
exports.SAFE_CREATE_ABI = (0, viem_1.parseAbi)([
|
|
44
|
+
"function proxyCreationCode() pure returns (bytes)",
|
|
45
|
+
"function createProxyWithNonce(address singleton, bytes initializer, uint256 saltNonce) returns (address proxy)",
|
|
46
|
+
"function setup(address[] owners,uint256 threshold,address to,bytes data,address fallbackHandler,address paymentToken,uint256 payment,address paymentReceiver)",
|
|
47
|
+
]);
|
|
48
|
+
exports.CREATE_BATCH_ABI = (0, viem_1.parseAbi)([
|
|
49
|
+
"function aggregate3Value((address target,bool allowFailure,uint256 value,bytes callData)[] calls) payable returns ((bool success,bytes returnData)[] returnData)",
|
|
50
|
+
]);
|
|
51
|
+
const READ_ABI = (0, viem_1.parseAbi)([
|
|
52
|
+
"function masterCopy() view returns (address)",
|
|
53
|
+
"function VERSION() view returns (string)",
|
|
54
|
+
"function getThreshold() view returns (uint256)",
|
|
55
|
+
"function getOwners() view returns (address[])",
|
|
56
|
+
"function getModulesPaginated(address start,uint256 pageSize) view returns (address[],address)",
|
|
57
|
+
]);
|
|
58
|
+
function validAddress(address) {
|
|
59
|
+
return (0, viem_1.isAddress)(address) && BigInt(address) > 1n;
|
|
60
|
+
}
|
|
61
|
+
/** Plain Safe only: no delegatecall hook, modules, guard, or setup payments. */
|
|
62
|
+
function buildSafeInitializer(policy) {
|
|
63
|
+
if (!Array.isArray(policy.owners) ||
|
|
64
|
+
policy.owners.length < 1 ||
|
|
65
|
+
policy.owners.length > exports.MAX_SAFE_OWNERS ||
|
|
66
|
+
policy.owners.some((owner) => !validAddress(owner)) ||
|
|
67
|
+
new Set(policy.owners.map((owner) => owner.toLowerCase())).size !==
|
|
68
|
+
policy.owners.length)
|
|
69
|
+
throw new Error("A Safe needs 1–50 unique nonzero, nonsentinel owner addresses.");
|
|
70
|
+
if (!Number.isInteger(policy.threshold) ||
|
|
71
|
+
policy.threshold < 1 ||
|
|
72
|
+
policy.threshold > policy.owners.length) {
|
|
73
|
+
throw new Error("Invalid Safe approval policy.");
|
|
74
|
+
}
|
|
75
|
+
return (0, viem_1.encodeFunctionData)({
|
|
76
|
+
abi: exports.SAFE_CREATE_ABI,
|
|
77
|
+
functionName: "setup",
|
|
78
|
+
args: [
|
|
79
|
+
policy.owners,
|
|
80
|
+
BigInt(policy.threshold),
|
|
81
|
+
viem_1.zeroAddress,
|
|
82
|
+
"0x",
|
|
83
|
+
exports.SAFE_FALLBACK,
|
|
84
|
+
viem_1.zeroAddress,
|
|
85
|
+
0n,
|
|
86
|
+
viem_1.zeroAddress,
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** Owner order and the original 32-byte salt are part of the deterministic address. */
|
|
91
|
+
function predictSafeAddress(plan) {
|
|
92
|
+
if (!/^0x[\da-f]{64}$/i.test(plan.saltNonce) ||
|
|
93
|
+
!/^0x(?:[\da-f]{2}){1,2048}$/i.test(plan.proxyCreationCode)) {
|
|
94
|
+
throw new Error("Invalid Safe deployment record.");
|
|
95
|
+
}
|
|
96
|
+
const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["bytes32", "uint256"], [(0, viem_1.keccak256)(buildSafeInitializer(plan)), BigInt(plan.saltNonce)]));
|
|
97
|
+
return (0, viem_1.getContractAddress)({
|
|
98
|
+
opcode: "CREATE2",
|
|
99
|
+
from: exports.SAFE_FACTORY,
|
|
100
|
+
salt,
|
|
101
|
+
bytecode: (0, viem_1.concatHex)([
|
|
102
|
+
plan.proxyCreationCode,
|
|
103
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_SINGLETON), { size: 32 }),
|
|
104
|
+
]),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function validateSafeDeploymentPlan(plan) {
|
|
108
|
+
if (!validAddress(plan.address) ||
|
|
109
|
+
!(0, viem_1.isAddressEqual)(predictSafeAddress(plan), plan.address)) {
|
|
110
|
+
throw new Error("The Safe address differs from its saved owners and policy.");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function validatePlans(plans) {
|
|
114
|
+
if (!Array.isArray(plans))
|
|
115
|
+
throw new Error("Invalid Safe deployment plans.");
|
|
116
|
+
plans.forEach(validateSafeDeploymentPlan);
|
|
117
|
+
if (new Set(plans.map((plan) => plan.address.toLowerCase())).size !==
|
|
118
|
+
plans.length) {
|
|
119
|
+
throw new Error("Duplicate Safe deployment plans.");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function codeMatches(code, hash) {
|
|
123
|
+
return (typeof code === "string" &&
|
|
124
|
+
/^0x(?:[\da-f]{2}){1,24576}$/i.test(code) &&
|
|
125
|
+
(0, viem_1.keccak256)(code) === hash);
|
|
126
|
+
}
|
|
127
|
+
/** Check canonical dependencies before trusting factory-returned creation code. */
|
|
128
|
+
async function readSafeCreationCode(client) {
|
|
129
|
+
await Promise.all(contracts.map(async ([address, hash]) => {
|
|
130
|
+
if (!codeMatches(await client.getCode({ address }), hash)) {
|
|
131
|
+
throw new Error(`The canonical Safe 1.4.1 contract is unavailable at ${address}.`);
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
const proxyCreationCode = await client.readContract({
|
|
135
|
+
address: exports.SAFE_FACTORY,
|
|
136
|
+
abi: exports.SAFE_CREATE_ABI,
|
|
137
|
+
functionName: "proxyCreationCode",
|
|
138
|
+
});
|
|
139
|
+
if (!/^0x(?:[\da-f]{2}){1,2048}$/i.test(proxyCreationCode))
|
|
140
|
+
throw new Error("Invalid Safe proxy creation code.");
|
|
141
|
+
return proxyCreationCode;
|
|
142
|
+
}
|
|
143
|
+
/** Existing inputs are address-only: this does not certify an arbitrary address as a Safe. */
|
|
144
|
+
async function resolveSafeAddress(input, clients) {
|
|
145
|
+
if (input.kind === "existing") {
|
|
146
|
+
if (!validAddress(input.address))
|
|
147
|
+
throw new Error("Enter a valid existing Safe address.");
|
|
148
|
+
return { address: (0, viem_1.getAddress)(input.address) };
|
|
149
|
+
}
|
|
150
|
+
if (input.kind !== "create")
|
|
151
|
+
throw new Error("Invalid Safe address input.");
|
|
152
|
+
// Validate local inputs before any network request.
|
|
153
|
+
buildSafeInitializer(input);
|
|
154
|
+
if (!/^0x[\da-f]{64}$/i.test(input.saltNonce))
|
|
155
|
+
throw new Error("Invalid Safe deployment salt.");
|
|
156
|
+
if (!clients.length)
|
|
157
|
+
throw new Error("Select at least one network to create a Safe.");
|
|
158
|
+
const codes = await Promise.all(clients.map(readSafeCreationCode));
|
|
159
|
+
if (codes.some((code) => code.toLowerCase() !== codes[0].toLowerCase()))
|
|
160
|
+
throw new Error("Safe creation code differs across the selected networks.");
|
|
161
|
+
const policy = {
|
|
162
|
+
owners: input.owners.map((owner) => (0, viem_1.getAddress)(owner)),
|
|
163
|
+
threshold: input.threshold,
|
|
164
|
+
saltNonce: input.saltNonce,
|
|
165
|
+
proxyCreationCode: codes[0],
|
|
166
|
+
};
|
|
167
|
+
const plan = { ...policy, address: predictSafeAddress(policy) };
|
|
168
|
+
return { address: plan.address, plan };
|
|
169
|
+
}
|
|
170
|
+
async function boundedCall(client, address, data, gas, maxBytes, blockNumber) {
|
|
171
|
+
// Raw RPC cannot follow a contract-selected CCIP/OffchainLookup URL.
|
|
172
|
+
const result = await client.request({
|
|
173
|
+
method: "eth_call",
|
|
174
|
+
params: [
|
|
175
|
+
{ to: address, data, gas: (0, viem_1.toHex)(gas) },
|
|
176
|
+
blockNumber === undefined ? "latest" : (0, viem_1.toHex)(blockNumber),
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
if (typeof result !== "string" ||
|
|
180
|
+
!/^0x(?:[\da-f]{2})*$/i.test(result) ||
|
|
181
|
+
result.length > 2 + maxBytes * 2) {
|
|
182
|
+
throw new Error("Invalid or oversized Safe policy response.");
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Certify this module's plain Safe profile, failing closed on malformed state or RPC errors.
|
|
188
|
+
* Receipt recovery pins every code, storage, and raw policy read to blockNumber.
|
|
189
|
+
* Contract signers are supported; this verifies their membership, not their own policy.
|
|
190
|
+
*/
|
|
191
|
+
async function verifySafeDeployments(client, plans, options = {}) {
|
|
192
|
+
validatePlans(plans);
|
|
193
|
+
const { blockNumber, allowMissing = false } = options;
|
|
194
|
+
if (blockNumber !== undefined && blockNumber < 0n)
|
|
195
|
+
throw new Error("Invalid Safe verification block.");
|
|
196
|
+
let complete = true;
|
|
197
|
+
for (const plan of plans) {
|
|
198
|
+
const code = await client.getCode({ address: plan.address, blockNumber });
|
|
199
|
+
if (allowMissing && (code === undefined || code === "0x")) {
|
|
200
|
+
complete = false;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
const mismatch = () => new Error(`The Safe at ${plan.address} does not match its reviewed owners and policy.`);
|
|
204
|
+
if (!codeMatches(code, PROXY_CODE_HASH))
|
|
205
|
+
throw mismatch();
|
|
206
|
+
const singleton = await client.getStorageAt({
|
|
207
|
+
address: plan.address,
|
|
208
|
+
slot: SINGLETON_SLOT,
|
|
209
|
+
blockNumber,
|
|
210
|
+
});
|
|
211
|
+
if (singleton?.toLowerCase() !==
|
|
212
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_SINGLETON), { size: 32 }).toLowerCase())
|
|
213
|
+
throw mismatch();
|
|
214
|
+
// Do not delegate through a claimed implementation before checking its exact runtime.
|
|
215
|
+
for (const [address, hash] of contracts.slice(1)) {
|
|
216
|
+
if (!codeMatches(await client.getCode({ address, blockNumber }), hash))
|
|
217
|
+
throw mismatch();
|
|
218
|
+
}
|
|
219
|
+
const call = (data, maxBytes, gas = 100000n) => boundedCall(client, plan.address, data, gas, maxBytes, blockNumber);
|
|
220
|
+
const [masterCopy, version, threshold, ownersData, modules, guard, fallback,] = await Promise.all([
|
|
221
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "masterCopy" }), 32),
|
|
222
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "VERSION" }), 96),
|
|
223
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "getThreshold" }), 32),
|
|
224
|
+
call((0, viem_1.encodeFunctionData)({ abi: READ_ABI, functionName: "getOwners" }), 64 + exports.MAX_SAFE_OWNERS * 32, 400000n),
|
|
225
|
+
call((0, viem_1.encodeFunctionData)({
|
|
226
|
+
abi: READ_ABI,
|
|
227
|
+
functionName: "getModulesPaginated",
|
|
228
|
+
args: [SENTINEL, 1n],
|
|
229
|
+
}), 128, 500000n),
|
|
230
|
+
client.getStorageAt({
|
|
231
|
+
address: plan.address,
|
|
232
|
+
slot: GUARD_SLOT,
|
|
233
|
+
blockNumber,
|
|
234
|
+
}),
|
|
235
|
+
client.getStorageAt({
|
|
236
|
+
address: plan.address,
|
|
237
|
+
slot: FALLBACK_SLOT,
|
|
238
|
+
blockNumber,
|
|
239
|
+
}),
|
|
240
|
+
]);
|
|
241
|
+
if (masterCopy.toLowerCase() !==
|
|
242
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_SINGLETON), { size: 32 }).toLowerCase() ||
|
|
243
|
+
version.toLowerCase() !==
|
|
244
|
+
(0, viem_1.encodeFunctionResult)({
|
|
245
|
+
abi: READ_ABI,
|
|
246
|
+
functionName: "VERSION",
|
|
247
|
+
result: "1.4.1",
|
|
248
|
+
}).toLowerCase() ||
|
|
249
|
+
threshold.toLowerCase() !==
|
|
250
|
+
(0, viem_1.toHex)(BigInt(plan.threshold), { size: 32 }).toLowerCase() ||
|
|
251
|
+
modules.toLowerCase() !==
|
|
252
|
+
(0, viem_1.encodeFunctionResult)({
|
|
253
|
+
abi: READ_ABI,
|
|
254
|
+
functionName: "getModulesPaginated",
|
|
255
|
+
result: [[], SENTINEL],
|
|
256
|
+
}).toLowerCase() ||
|
|
257
|
+
guard?.toLowerCase() !== (0, viem_1.toHex)(0n, { size: 32 }) ||
|
|
258
|
+
fallback?.toLowerCase() !==
|
|
259
|
+
(0, viem_1.toHex)(BigInt(exports.SAFE_FALLBACK), { size: 32 }).toLowerCase() ||
|
|
260
|
+
ownersData.length !== 2 + (64 + plan.owners.length * 32) * 2 ||
|
|
261
|
+
ownersData.slice(2, 66).toLowerCase() !==
|
|
262
|
+
(0, viem_1.toHex)(32n, { size: 32 }).slice(2) ||
|
|
263
|
+
ownersData.slice(66, 130).toLowerCase() !==
|
|
264
|
+
(0, viem_1.toHex)(BigInt(plan.owners.length), { size: 32 }).slice(2))
|
|
265
|
+
throw mismatch();
|
|
266
|
+
const owners = (0, viem_1.decodeFunctionResult)({
|
|
267
|
+
abi: READ_ABI,
|
|
268
|
+
functionName: "getOwners",
|
|
269
|
+
data: ownersData,
|
|
270
|
+
});
|
|
271
|
+
if (new Set(owners.map((owner) => owner.toLowerCase())).size !==
|
|
272
|
+
plan.owners.length ||
|
|
273
|
+
plan.owners.some((owner) => !owners.some((actual) => (0, viem_1.isAddressEqual)(actual, owner))))
|
|
274
|
+
throw mismatch();
|
|
275
|
+
}
|
|
276
|
+
return complete;
|
|
277
|
+
}
|
|
278
|
+
async function checkSafeDeployments(client, plans = []) {
|
|
279
|
+
if (!plans.length)
|
|
280
|
+
return;
|
|
281
|
+
validatePlans(plans);
|
|
282
|
+
const code = await readSafeCreationCode(client);
|
|
283
|
+
if (plans.some((plan) => plan.proxyCreationCode.toLowerCase() !== code.toLowerCase()))
|
|
284
|
+
throw new Error("The saved Safe creation code changed.");
|
|
285
|
+
await verifySafeDeployments(client, plans, { allowMissing: true });
|
|
286
|
+
}
|
|
287
|
+
/** Optional factory calls are idempotent only with preflight, simulation, and receipt verification. */
|
|
288
|
+
function buildSafeDeploymentCalls(plans) {
|
|
289
|
+
validatePlans(plans);
|
|
290
|
+
return plans.map((plan) => ({
|
|
291
|
+
target: exports.SAFE_FACTORY,
|
|
292
|
+
allowFailure: true,
|
|
293
|
+
value: 0n,
|
|
294
|
+
callData: (0, viem_1.encodeFunctionData)({
|
|
295
|
+
abi: exports.SAFE_CREATE_ABI,
|
|
296
|
+
functionName: "createProxyWithNonce",
|
|
297
|
+
args: [
|
|
298
|
+
exports.SAFE_SINGLETON,
|
|
299
|
+
buildSafeInitializer(plan),
|
|
300
|
+
BigInt(plan.saltNonce),
|
|
301
|
+
],
|
|
302
|
+
}),
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
function buildSafeDeploymentTx(chainId, plans) {
|
|
306
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0)
|
|
307
|
+
throw new Error("Invalid Safe deployment chain.");
|
|
308
|
+
return {
|
|
309
|
+
chainId,
|
|
310
|
+
address: exports.MULTICALL3,
|
|
311
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
312
|
+
functionName: "aggregate3Value",
|
|
313
|
+
args: [buildSafeDeploymentCalls(plans)],
|
|
314
|
+
value: 0n,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Multicall3 changes msg.sender. Use only a sender-independent or already authenticated
|
|
319
|
+
* forwarded launch. This helper cannot decide the launch contract's authorization semantics.
|
|
320
|
+
* Simulate the returned call, verifySafeLaunchSimulation, then verify receipt-block state.
|
|
321
|
+
*/
|
|
322
|
+
function bundleSafeLaunch(call, plans = []) {
|
|
323
|
+
if (!plans.length)
|
|
324
|
+
return call;
|
|
325
|
+
if (!validAddress(call.to) ||
|
|
326
|
+
!/^0x(?:[\da-f]{2})*$/i.test(call.data) ||
|
|
327
|
+
typeof call.value !== "bigint" ||
|
|
328
|
+
call.value < 0n)
|
|
329
|
+
throw new Error("Invalid Safe launch call.");
|
|
330
|
+
const calls = [
|
|
331
|
+
...buildSafeDeploymentCalls(plans),
|
|
332
|
+
{
|
|
333
|
+
target: call.to,
|
|
334
|
+
allowFailure: false,
|
|
335
|
+
value: call.value,
|
|
336
|
+
callData: call.data,
|
|
337
|
+
},
|
|
338
|
+
];
|
|
339
|
+
return {
|
|
340
|
+
to: exports.MULTICALL3,
|
|
341
|
+
value: call.value,
|
|
342
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
343
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
344
|
+
functionName: "aggregate3Value",
|
|
345
|
+
args: [calls],
|
|
346
|
+
}),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/** Require the exact reviewed factory calls, their order, one mandatory launch, and its value. */
|
|
350
|
+
function unbundleSafeLaunch(call, plans = []) {
|
|
351
|
+
if (!plans.length)
|
|
352
|
+
return call;
|
|
353
|
+
if (!(0, viem_1.isAddressEqual)(call.to, exports.MULTICALL3))
|
|
354
|
+
throw new Error("The saved Safe launch is not a creation batch.");
|
|
355
|
+
const { args } = (0, viem_1.decodeFunctionData)({
|
|
356
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
357
|
+
data: call.data,
|
|
358
|
+
});
|
|
359
|
+
const last = args[0][args[0].length - 1];
|
|
360
|
+
if (!last)
|
|
361
|
+
throw new Error("The saved creation batch is empty.");
|
|
362
|
+
const inner = { to: last.target, data: last.callData, value: call.value };
|
|
363
|
+
if (bundleSafeLaunch(inner, plans).data.toLowerCase() !==
|
|
364
|
+
call.data.toLowerCase())
|
|
365
|
+
throw new Error("The saved creation batch differs from its reviewed Safes and launch.");
|
|
366
|
+
return inner;
|
|
367
|
+
}
|
|
368
|
+
/** Outer simulation success is insufficient: an optional deployment may have failed. */
|
|
369
|
+
async function verifySafeLaunchSimulation(client, plans = [], data) {
|
|
370
|
+
if (!plans.length)
|
|
371
|
+
return;
|
|
372
|
+
validatePlans(plans);
|
|
373
|
+
if (!data)
|
|
374
|
+
throw new Error("The Safe creation simulation returned no results.");
|
|
375
|
+
const results = (0, viem_1.decodeFunctionResult)({
|
|
376
|
+
abi: exports.CREATE_BATCH_ABI,
|
|
377
|
+
functionName: "aggregate3Value",
|
|
378
|
+
data,
|
|
379
|
+
});
|
|
380
|
+
if (results.length !== plans.length + 1 ||
|
|
381
|
+
!results[results.length - 1].success)
|
|
382
|
+
throw new Error("The creation batch did not simulate every required call.");
|
|
383
|
+
for (const [index, plan] of plans.entries()) {
|
|
384
|
+
const result = results[index];
|
|
385
|
+
if (result.success) {
|
|
386
|
+
if (result.returnData.toLowerCase() !==
|
|
387
|
+
(0, viem_1.toHex)(BigInt(plan.address), { size: 32 }).toLowerCase())
|
|
388
|
+
throw new Error("The simulated factory returned a different Safe address.");
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
// Only an already-deployed Safe with the exact policy can explain an accepted failure.
|
|
392
|
+
await verifySafeDeployments(client, [plan]);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe.js","sourceRoot":"","sources":["../../src/safe.ts"],"names":[],"mappings":";;;AAkGA,oDAoCC;AAGD,gDAwBC;AAED,gEASC;AAsBD,oDAkBC;AAGD,gDA2BC;AAiCD,sDA2HC;AAED,oDAcC;AAGD,4DAgBC;AAED,sDAcC;AAOD,4CA8BC;AAGD,gDAsBC;AAGD,gEAkCC;AApiBD,+BAkBc;AAEd,uEAAuE;AACvE,8EAA8E;AACjE,QAAA,YAAY,GAAG,IAAA,iBAAU,EACpC,4CAA4C,CAC7C,CAAC;AACW,QAAA,cAAc,GAAG,IAAA,iBAAU,EACtC,4CAA4C,CAC7C,CAAC;AACW,QAAA,aAAa,GAAG,IAAA,iBAAU,EACrC,4CAA4C,CAC7C,CAAC;AACW,QAAA,UAAU,GAAG,IAAA,iBAAU,EAClC,4CAA4C,CAC7C,CAAC;AACW,QAAA,eAAe,GAAG,EAAE,CAAC;AAElC,MAAM,SAAS,GAAG;IAChB;QACE,oBAAY;QACZ,oEAAoE;KACrE;IACD;QACE,sBAAc;QACd,oEAAoE;KACrE;IACD;QACE,qBAAa;QACb,oEAAoE;KACrE;CACO,CAAC;AACX,MAAM,eAAe,GACnB,oEAAoE,CAAC;AACvE,MAAM,QAAQ,GAAG,4CAAqD,CAAC;AACvE,MAAM,cAAc,GAAG,IAAA,YAAK,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,MAAM,UAAU,GACd,oEAA6E,CAA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,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACN,CAAC;aAAM,CAAC;YACN,uFAAuF;YACvF,MAAM,qBAAqB,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from "viem";
|
|
2
|
+
export declare const SAFE_FACTORY: `0x${string}`;
|
|
3
|
+
export declare const SAFE_SINGLETON: `0x${string}`;
|
|
4
|
+
export declare const SAFE_FALLBACK: `0x${string}`;
|
|
5
|
+
export declare const MULTICALL3: `0x${string}`;
|
|
6
|
+
export declare const MAX_SAFE_OWNERS = 50;
|
|
7
|
+
export declare const SAFE_CREATE_ABI: readonly [{
|
|
8
|
+
readonly name: "proxyCreationCode";
|
|
9
|
+
readonly type: "function";
|
|
10
|
+
readonly stateMutability: "pure";
|
|
11
|
+
readonly inputs: readonly [];
|
|
12
|
+
readonly outputs: readonly [{
|
|
13
|
+
readonly type: "bytes";
|
|
14
|
+
}];
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "createProxyWithNonce";
|
|
17
|
+
readonly type: "function";
|
|
18
|
+
readonly stateMutability: "nonpayable";
|
|
19
|
+
readonly inputs: readonly [{
|
|
20
|
+
readonly type: "address";
|
|
21
|
+
readonly name: "singleton";
|
|
22
|
+
}, {
|
|
23
|
+
readonly type: "bytes";
|
|
24
|
+
readonly name: "initializer";
|
|
25
|
+
}, {
|
|
26
|
+
readonly type: "uint256";
|
|
27
|
+
readonly name: "saltNonce";
|
|
28
|
+
}];
|
|
29
|
+
readonly outputs: readonly [{
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
readonly name: "proxy";
|
|
32
|
+
}];
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "setup";
|
|
35
|
+
readonly type: "function";
|
|
36
|
+
readonly stateMutability: "nonpayable";
|
|
37
|
+
readonly inputs: readonly [{
|
|
38
|
+
readonly type: "address[]";
|
|
39
|
+
readonly name: "owners";
|
|
40
|
+
}, {
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
readonly name: "threshold";
|
|
43
|
+
}, {
|
|
44
|
+
readonly type: "address";
|
|
45
|
+
readonly name: "to";
|
|
46
|
+
}, {
|
|
47
|
+
readonly type: "bytes";
|
|
48
|
+
readonly name: "data";
|
|
49
|
+
}, {
|
|
50
|
+
readonly type: "address";
|
|
51
|
+
readonly name: "fallbackHandler";
|
|
52
|
+
}, {
|
|
53
|
+
readonly type: "address";
|
|
54
|
+
readonly name: "paymentToken";
|
|
55
|
+
}, {
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
readonly name: "payment";
|
|
58
|
+
}, {
|
|
59
|
+
readonly type: "address";
|
|
60
|
+
readonly name: "paymentReceiver";
|
|
61
|
+
}];
|
|
62
|
+
readonly outputs: readonly [];
|
|
63
|
+
}];
|
|
64
|
+
export declare const CREATE_BATCH_ABI: readonly [{
|
|
65
|
+
readonly name: "aggregate3Value";
|
|
66
|
+
readonly type: "function";
|
|
67
|
+
readonly stateMutability: "payable";
|
|
68
|
+
readonly inputs: readonly [{
|
|
69
|
+
readonly type: "tuple[]";
|
|
70
|
+
readonly components: readonly [{
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
readonly name: "target";
|
|
73
|
+
}, {
|
|
74
|
+
readonly type: "bool";
|
|
75
|
+
readonly name: "allowFailure";
|
|
76
|
+
}, {
|
|
77
|
+
readonly type: "uint256";
|
|
78
|
+
readonly name: "value";
|
|
79
|
+
}, {
|
|
80
|
+
readonly type: "bytes";
|
|
81
|
+
readonly name: "callData";
|
|
82
|
+
}];
|
|
83
|
+
readonly name: "calls";
|
|
84
|
+
}];
|
|
85
|
+
readonly outputs: readonly [{
|
|
86
|
+
readonly type: "tuple[]";
|
|
87
|
+
readonly components: readonly [{
|
|
88
|
+
readonly type: "bool";
|
|
89
|
+
readonly name: "success";
|
|
90
|
+
}, {
|
|
91
|
+
readonly type: "bytes";
|
|
92
|
+
readonly name: "returnData";
|
|
93
|
+
}];
|
|
94
|
+
readonly name: "returnData";
|
|
95
|
+
}];
|
|
96
|
+
}];
|
|
97
|
+
export type SafeDeploymentPlan = {
|
|
98
|
+
owners: Address[];
|
|
99
|
+
threshold: number;
|
|
100
|
+
saltNonce: Hex;
|
|
101
|
+
proxyCreationCode: Hex;
|
|
102
|
+
address: Address;
|
|
103
|
+
};
|
|
104
|
+
export type SafeCall = {
|
|
105
|
+
to: Address;
|
|
106
|
+
data: Hex;
|
|
107
|
+
value: bigint;
|
|
108
|
+
};
|
|
109
|
+
export type SafeAddressInput = {
|
|
110
|
+
kind: "existing";
|
|
111
|
+
address: Address;
|
|
112
|
+
} | {
|
|
113
|
+
kind: "create";
|
|
114
|
+
owners: Address[];
|
|
115
|
+
threshold: number;
|
|
116
|
+
saltNonce: Hex;
|
|
117
|
+
};
|
|
118
|
+
export type SafeVerificationOptions = {
|
|
119
|
+
/** Missing code is allowed only for a preflight check, never receipt acceptance. */
|
|
120
|
+
allowMissing?: boolean;
|
|
121
|
+
/** Use the receipt block to recover a launch even after subsequent owner changes. */
|
|
122
|
+
blockNumber?: bigint;
|
|
123
|
+
};
|
|
124
|
+
/** Plain Safe only: no delegatecall hook, modules, guard, or setup payments. */
|
|
125
|
+
export declare function buildSafeInitializer(policy: {
|
|
126
|
+
owners: readonly Address[];
|
|
127
|
+
threshold: number;
|
|
128
|
+
}): Hex;
|
|
129
|
+
/** Owner order and the original 32-byte salt are part of the deterministic address. */
|
|
130
|
+
export declare function predictSafeAddress(plan: Omit<SafeDeploymentPlan, "address">): Address;
|
|
131
|
+
export declare function validateSafeDeploymentPlan(plan: SafeDeploymentPlan): void;
|
|
132
|
+
/** Check canonical dependencies before trusting factory-returned creation code. */
|
|
133
|
+
export declare function readSafeCreationCode(client: PublicClient): Promise<Hex>;
|
|
134
|
+
/** Existing inputs are address-only: this does not certify an arbitrary address as a Safe. */
|
|
135
|
+
export declare function resolveSafeAddress(input: SafeAddressInput, clients: readonly PublicClient[]): Promise<{
|
|
136
|
+
address: Address;
|
|
137
|
+
plan?: SafeDeploymentPlan;
|
|
138
|
+
}>;
|
|
139
|
+
/**
|
|
140
|
+
* Certify this module's plain Safe profile, failing closed on malformed state or RPC errors.
|
|
141
|
+
* Receipt recovery pins every code, storage, and raw policy read to blockNumber.
|
|
142
|
+
* Contract signers are supported; this verifies their membership, not their own policy.
|
|
143
|
+
*/
|
|
144
|
+
export declare function verifySafeDeployments(client: PublicClient, plans: readonly SafeDeploymentPlan[], options?: SafeVerificationOptions): Promise<boolean>;
|
|
145
|
+
export declare function checkSafeDeployments(client: PublicClient, plans?: readonly SafeDeploymentPlan[]): Promise<void>;
|
|
146
|
+
/** Optional factory calls are idempotent only with preflight, simulation, and receipt verification. */
|
|
147
|
+
export declare function buildSafeDeploymentCalls(plans: readonly SafeDeploymentPlan[]): {
|
|
148
|
+
target: `0x${string}`;
|
|
149
|
+
allowFailure: true;
|
|
150
|
+
value: bigint;
|
|
151
|
+
callData: `0x${string}`;
|
|
152
|
+
}[];
|
|
153
|
+
export declare function buildSafeDeploymentTx(chainId: number, plans: readonly SafeDeploymentPlan[]): {
|
|
154
|
+
chainId: number;
|
|
155
|
+
address: `0x${string}`;
|
|
156
|
+
abi: readonly [{
|
|
157
|
+
readonly name: "aggregate3Value";
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
readonly stateMutability: "payable";
|
|
160
|
+
readonly inputs: readonly [{
|
|
161
|
+
readonly type: "tuple[]";
|
|
162
|
+
readonly components: readonly [{
|
|
163
|
+
readonly type: "address";
|
|
164
|
+
readonly name: "target";
|
|
165
|
+
}, {
|
|
166
|
+
readonly type: "bool";
|
|
167
|
+
readonly name: "allowFailure";
|
|
168
|
+
}, {
|
|
169
|
+
readonly type: "uint256";
|
|
170
|
+
readonly name: "value";
|
|
171
|
+
}, {
|
|
172
|
+
readonly type: "bytes";
|
|
173
|
+
readonly name: "callData";
|
|
174
|
+
}];
|
|
175
|
+
readonly name: "calls";
|
|
176
|
+
}];
|
|
177
|
+
readonly outputs: readonly [{
|
|
178
|
+
readonly type: "tuple[]";
|
|
179
|
+
readonly components: readonly [{
|
|
180
|
+
readonly type: "bool";
|
|
181
|
+
readonly name: "success";
|
|
182
|
+
}, {
|
|
183
|
+
readonly type: "bytes";
|
|
184
|
+
readonly name: "returnData";
|
|
185
|
+
}];
|
|
186
|
+
readonly name: "returnData";
|
|
187
|
+
}];
|
|
188
|
+
}];
|
|
189
|
+
functionName: "aggregate3Value";
|
|
190
|
+
args: readonly [{
|
|
191
|
+
target: `0x${string}`;
|
|
192
|
+
allowFailure: true;
|
|
193
|
+
value: bigint;
|
|
194
|
+
callData: `0x${string}`;
|
|
195
|
+
}[]];
|
|
196
|
+
value: bigint;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Multicall3 changes msg.sender. Use only a sender-independent or already authenticated
|
|
200
|
+
* forwarded launch. This helper cannot decide the launch contract's authorization semantics.
|
|
201
|
+
* Simulate the returned call, verifySafeLaunchSimulation, then verify receipt-block state.
|
|
202
|
+
*/
|
|
203
|
+
export declare function bundleSafeLaunch(call: SafeCall, plans?: readonly SafeDeploymentPlan[]): SafeCall;
|
|
204
|
+
/** Require the exact reviewed factory calls, their order, one mandatory launch, and its value. */
|
|
205
|
+
export declare function unbundleSafeLaunch(call: SafeCall, plans?: readonly SafeDeploymentPlan[]): SafeCall;
|
|
206
|
+
/** Outer simulation success is insufficient: an optional deployment may have failed. */
|
|
207
|
+
export declare function verifySafeLaunchSimulation(client: PublicClient, plans?: readonly SafeDeploymentPlan[], data?: Hex): Promise<void>;
|
|
208
|
+
//# sourceMappingURL=safe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../src/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EAeL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,CAA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,GACxC,QAAQ,CAmBV;AAED,wFAAwF;AACxF,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,YAAY,EACpB,KAAK,GAAE,SAAS,kBAAkB,EAAO,EACzC,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
|
package/dist/esm/safe.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { concatHex, decodeFunctionData, decodeFunctionResult, encodeFunctionData, encodeFunctionResult, encodePacked, getAddress, getContractAddress, isAddress, isAddressEqual, keccak256, parseAbi, toHex, zeroAddress, } from "viem";
|
|
2
|
+
// Canonical Safe 1.4.1 deployments, from safe-global/safe-deployments.
|
|
3
|
+
// A fixed singleton and initializer preserve CREATE2 addresses across chains.
|
|
4
|
+
export const SAFE_FACTORY = getAddress("0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67");
|
|
5
|
+
export const SAFE_SINGLETON = getAddress("0x41675C099F32341bf84BFc5382aF534df5C7461a");
|
|
6
|
+
export const SAFE_FALLBACK = getAddress("0xfd0732Dc9E303f09fCEf3a7388Ad10A83459Ec99");
|
|
7
|
+
export const MULTICALL3 = getAddress("0xcA11bde05977b3631167028862bE2a173976CA11");
|
|
8
|
+
export const MAX_SAFE_OWNERS = 50;
|
|
9
|
+
const contracts = [
|
|
10
|
+
[
|
|
11
|
+
SAFE_FACTORY,
|
|
12
|
+
"0x50c3cdc4074750a7a974204a716c999edd37482f907608d960b2b025ee0b3317",
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
SAFE_SINGLETON,
|
|
16
|
+
"0x1fe2df852ba3299d6534ef416eefa406e56ced995bca886ab7a553e6d0c5e1c4",
|
|
17
|
+
],
|
|
18
|
+
[
|
|
19
|
+
SAFE_FALLBACK,
|
|
20
|
+
"0x7c6007a5d711cea8dfd5d91f5940ec29c7f200fe511eb1fc1397b367af3c42f9",
|
|
21
|
+
],
|
|
22
|
+
];
|
|
23
|
+
const PROXY_CODE_HASH = "0xd7d408ebcd99b2b70be43e20253d6d92a8ea8fab29bd3be7f55b10032331fb4c";
|
|
24
|
+
const SENTINEL = "0x0000000000000000000000000000000000000001";
|
|
25
|
+
const SINGLETON_SLOT = toHex(0n, { size: 32 });
|
|
26
|
+
const GUARD_SLOT = "0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8";
|
|
27
|
+
const FALLBACK_SLOT = "0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5";
|
|
28
|
+
export const SAFE_CREATE_ABI = parseAbi([
|
|
29
|
+
"function proxyCreationCode() pure returns (bytes)",
|
|
30
|
+
"function createProxyWithNonce(address singleton, bytes initializer, uint256 saltNonce) returns (address proxy)",
|
|
31
|
+
"function setup(address[] owners,uint256 threshold,address to,bytes data,address fallbackHandler,address paymentToken,uint256 payment,address paymentReceiver)",
|
|
32
|
+
]);
|
|
33
|
+
export const CREATE_BATCH_ABI = parseAbi([
|
|
34
|
+
"function aggregate3Value((address target,bool allowFailure,uint256 value,bytes callData)[] calls) payable returns ((bool success,bytes returnData)[] returnData)",
|
|
35
|
+
]);
|
|
36
|
+
const READ_ABI = parseAbi([
|
|
37
|
+
"function masterCopy() view returns (address)",
|
|
38
|
+
"function VERSION() view returns (string)",
|
|
39
|
+
"function getThreshold() view returns (uint256)",
|
|
40
|
+
"function getOwners() view returns (address[])",
|
|
41
|
+
"function getModulesPaginated(address start,uint256 pageSize) view returns (address[],address)",
|
|
42
|
+
]);
|
|
43
|
+
function validAddress(address) {
|
|
44
|
+
return isAddress(address) && BigInt(address) > 1n;
|
|
45
|
+
}
|
|
46
|
+
/** Plain Safe only: no delegatecall hook, modules, guard, or setup payments. */
|
|
47
|
+
export function buildSafeInitializer(policy) {
|
|
48
|
+
if (!Array.isArray(policy.owners) ||
|
|
49
|
+
policy.owners.length < 1 ||
|
|
50
|
+
policy.owners.length > MAX_SAFE_OWNERS ||
|
|
51
|
+
policy.owners.some((owner) => !validAddress(owner)) ||
|
|
52
|
+
new Set(policy.owners.map((owner) => owner.toLowerCase())).size !==
|
|
53
|
+
policy.owners.length)
|
|
54
|
+
throw new Error("A Safe needs 1–50 unique nonzero, nonsentinel owner addresses.");
|
|
55
|
+
if (!Number.isInteger(policy.threshold) ||
|
|
56
|
+
policy.threshold < 1 ||
|
|
57
|
+
policy.threshold > policy.owners.length) {
|
|
58
|
+
throw new Error("Invalid Safe approval policy.");
|
|
59
|
+
}
|
|
60
|
+
return encodeFunctionData({
|
|
61
|
+
abi: SAFE_CREATE_ABI,
|
|
62
|
+
functionName: "setup",
|
|
63
|
+
args: [
|
|
64
|
+
policy.owners,
|
|
65
|
+
BigInt(policy.threshold),
|
|
66
|
+
zeroAddress,
|
|
67
|
+
"0x",
|
|
68
|
+
SAFE_FALLBACK,
|
|
69
|
+
zeroAddress,
|
|
70
|
+
0n,
|
|
71
|
+
zeroAddress,
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Owner order and the original 32-byte salt are part of the deterministic address. */
|
|
76
|
+
export function predictSafeAddress(plan) {
|
|
77
|
+
if (!/^0x[\da-f]{64}$/i.test(plan.saltNonce) ||
|
|
78
|
+
!/^0x(?:[\da-f]{2}){1,2048}$/i.test(plan.proxyCreationCode)) {
|
|
79
|
+
throw new Error("Invalid Safe deployment record.");
|
|
80
|
+
}
|
|
81
|
+
const salt = keccak256(encodePacked(["bytes32", "uint256"], [keccak256(buildSafeInitializer(plan)), BigInt(plan.saltNonce)]));
|
|
82
|
+
return getContractAddress({
|
|
83
|
+
opcode: "CREATE2",
|
|
84
|
+
from: SAFE_FACTORY,
|
|
85
|
+
salt,
|
|
86
|
+
bytecode: concatHex([
|
|
87
|
+
plan.proxyCreationCode,
|
|
88
|
+
toHex(BigInt(SAFE_SINGLETON), { size: 32 }),
|
|
89
|
+
]),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export function validateSafeDeploymentPlan(plan) {
|
|
93
|
+
if (!validAddress(plan.address) ||
|
|
94
|
+
!isAddressEqual(predictSafeAddress(plan), plan.address)) {
|
|
95
|
+
throw new Error("The Safe address differs from its saved owners and policy.");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function validatePlans(plans) {
|
|
99
|
+
if (!Array.isArray(plans))
|
|
100
|
+
throw new Error("Invalid Safe deployment plans.");
|
|
101
|
+
plans.forEach(validateSafeDeploymentPlan);
|
|
102
|
+
if (new Set(plans.map((plan) => plan.address.toLowerCase())).size !==
|
|
103
|
+
plans.length) {
|
|
104
|
+
throw new Error("Duplicate Safe deployment plans.");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function codeMatches(code, hash) {
|
|
108
|
+
return (typeof code === "string" &&
|
|
109
|
+
/^0x(?:[\da-f]{2}){1,24576}$/i.test(code) &&
|
|
110
|
+
keccak256(code) === hash);
|
|
111
|
+
}
|
|
112
|
+
/** Check canonical dependencies before trusting factory-returned creation code. */
|
|
113
|
+
export async function readSafeCreationCode(client) {
|
|
114
|
+
await Promise.all(contracts.map(async ([address, hash]) => {
|
|
115
|
+
if (!codeMatches(await client.getCode({ address }), hash)) {
|
|
116
|
+
throw new Error(`The canonical Safe 1.4.1 contract is unavailable at ${address}.`);
|
|
117
|
+
}
|
|
118
|
+
}));
|
|
119
|
+
const proxyCreationCode = await client.readContract({
|
|
120
|
+
address: SAFE_FACTORY,
|
|
121
|
+
abi: SAFE_CREATE_ABI,
|
|
122
|
+
functionName: "proxyCreationCode",
|
|
123
|
+
});
|
|
124
|
+
if (!/^0x(?:[\da-f]{2}){1,2048}$/i.test(proxyCreationCode))
|
|
125
|
+
throw new Error("Invalid Safe proxy creation code.");
|
|
126
|
+
return proxyCreationCode;
|
|
127
|
+
}
|
|
128
|
+
/** Existing inputs are address-only: this does not certify an arbitrary address as a Safe. */
|
|
129
|
+
export async function resolveSafeAddress(input, clients) {
|
|
130
|
+
if (input.kind === "existing") {
|
|
131
|
+
if (!validAddress(input.address))
|
|
132
|
+
throw new Error("Enter a valid existing Safe address.");
|
|
133
|
+
return { address: getAddress(input.address) };
|
|
134
|
+
}
|
|
135
|
+
if (input.kind !== "create")
|
|
136
|
+
throw new Error("Invalid Safe address input.");
|
|
137
|
+
// Validate local inputs before any network request.
|
|
138
|
+
buildSafeInitializer(input);
|
|
139
|
+
if (!/^0x[\da-f]{64}$/i.test(input.saltNonce))
|
|
140
|
+
throw new Error("Invalid Safe deployment salt.");
|
|
141
|
+
if (!clients.length)
|
|
142
|
+
throw new Error("Select at least one network to create a Safe.");
|
|
143
|
+
const codes = await Promise.all(clients.map(readSafeCreationCode));
|
|
144
|
+
if (codes.some((code) => code.toLowerCase() !== codes[0].toLowerCase()))
|
|
145
|
+
throw new Error("Safe creation code differs across the selected networks.");
|
|
146
|
+
const policy = {
|
|
147
|
+
owners: input.owners.map((owner) => getAddress(owner)),
|
|
148
|
+
threshold: input.threshold,
|
|
149
|
+
saltNonce: input.saltNonce,
|
|
150
|
+
proxyCreationCode: codes[0],
|
|
151
|
+
};
|
|
152
|
+
const plan = { ...policy, address: predictSafeAddress(policy) };
|
|
153
|
+
return { address: plan.address, plan };
|
|
154
|
+
}
|
|
155
|
+
async function boundedCall(client, address, data, gas, maxBytes, blockNumber) {
|
|
156
|
+
// Raw RPC cannot follow a contract-selected CCIP/OffchainLookup URL.
|
|
157
|
+
const result = await client.request({
|
|
158
|
+
method: "eth_call",
|
|
159
|
+
params: [
|
|
160
|
+
{ to: address, data, gas: toHex(gas) },
|
|
161
|
+
blockNumber === undefined ? "latest" : toHex(blockNumber),
|
|
162
|
+
],
|
|
163
|
+
});
|
|
164
|
+
if (typeof result !== "string" ||
|
|
165
|
+
!/^0x(?:[\da-f]{2})*$/i.test(result) ||
|
|
166
|
+
result.length > 2 + maxBytes * 2) {
|
|
167
|
+
throw new Error("Invalid or oversized Safe policy response.");
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Certify this module's plain Safe profile, failing closed on malformed state or RPC errors.
|
|
173
|
+
* Receipt recovery pins every code, storage, and raw policy read to blockNumber.
|
|
174
|
+
* Contract signers are supported; this verifies their membership, not their own policy.
|
|
175
|
+
*/
|
|
176
|
+
export async function verifySafeDeployments(client, plans, options = {}) {
|
|
177
|
+
validatePlans(plans);
|
|
178
|
+
const { blockNumber, allowMissing = false } = options;
|
|
179
|
+
if (blockNumber !== undefined && blockNumber < 0n)
|
|
180
|
+
throw new Error("Invalid Safe verification block.");
|
|
181
|
+
let complete = true;
|
|
182
|
+
for (const plan of plans) {
|
|
183
|
+
const code = await client.getCode({ address: plan.address, blockNumber });
|
|
184
|
+
if (allowMissing && (code === undefined || code === "0x")) {
|
|
185
|
+
complete = false;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const mismatch = () => new Error(`The Safe at ${plan.address} does not match its reviewed owners and policy.`);
|
|
189
|
+
if (!codeMatches(code, PROXY_CODE_HASH))
|
|
190
|
+
throw mismatch();
|
|
191
|
+
const singleton = await client.getStorageAt({
|
|
192
|
+
address: plan.address,
|
|
193
|
+
slot: SINGLETON_SLOT,
|
|
194
|
+
blockNumber,
|
|
195
|
+
});
|
|
196
|
+
if (singleton?.toLowerCase() !==
|
|
197
|
+
toHex(BigInt(SAFE_SINGLETON), { size: 32 }).toLowerCase())
|
|
198
|
+
throw mismatch();
|
|
199
|
+
// Do not delegate through a claimed implementation before checking its exact runtime.
|
|
200
|
+
for (const [address, hash] of contracts.slice(1)) {
|
|
201
|
+
if (!codeMatches(await client.getCode({ address, blockNumber }), hash))
|
|
202
|
+
throw mismatch();
|
|
203
|
+
}
|
|
204
|
+
const call = (data, maxBytes, gas = 100000n) => boundedCall(client, plan.address, data, gas, maxBytes, blockNumber);
|
|
205
|
+
const [masterCopy, version, threshold, ownersData, modules, guard, fallback,] = await Promise.all([
|
|
206
|
+
call(encodeFunctionData({ abi: READ_ABI, functionName: "masterCopy" }), 32),
|
|
207
|
+
call(encodeFunctionData({ abi: READ_ABI, functionName: "VERSION" }), 96),
|
|
208
|
+
call(encodeFunctionData({ abi: READ_ABI, functionName: "getThreshold" }), 32),
|
|
209
|
+
call(encodeFunctionData({ abi: READ_ABI, functionName: "getOwners" }), 64 + MAX_SAFE_OWNERS * 32, 400000n),
|
|
210
|
+
call(encodeFunctionData({
|
|
211
|
+
abi: READ_ABI,
|
|
212
|
+
functionName: "getModulesPaginated",
|
|
213
|
+
args: [SENTINEL, 1n],
|
|
214
|
+
}), 128, 500000n),
|
|
215
|
+
client.getStorageAt({
|
|
216
|
+
address: plan.address,
|
|
217
|
+
slot: GUARD_SLOT,
|
|
218
|
+
blockNumber,
|
|
219
|
+
}),
|
|
220
|
+
client.getStorageAt({
|
|
221
|
+
address: plan.address,
|
|
222
|
+
slot: FALLBACK_SLOT,
|
|
223
|
+
blockNumber,
|
|
224
|
+
}),
|
|
225
|
+
]);
|
|
226
|
+
if (masterCopy.toLowerCase() !==
|
|
227
|
+
toHex(BigInt(SAFE_SINGLETON), { size: 32 }).toLowerCase() ||
|
|
228
|
+
version.toLowerCase() !==
|
|
229
|
+
encodeFunctionResult({
|
|
230
|
+
abi: READ_ABI,
|
|
231
|
+
functionName: "VERSION",
|
|
232
|
+
result: "1.4.1",
|
|
233
|
+
}).toLowerCase() ||
|
|
234
|
+
threshold.toLowerCase() !==
|
|
235
|
+
toHex(BigInt(plan.threshold), { size: 32 }).toLowerCase() ||
|
|
236
|
+
modules.toLowerCase() !==
|
|
237
|
+
encodeFunctionResult({
|
|
238
|
+
abi: READ_ABI,
|
|
239
|
+
functionName: "getModulesPaginated",
|
|
240
|
+
result: [[], SENTINEL],
|
|
241
|
+
}).toLowerCase() ||
|
|
242
|
+
guard?.toLowerCase() !== toHex(0n, { size: 32 }) ||
|
|
243
|
+
fallback?.toLowerCase() !==
|
|
244
|
+
toHex(BigInt(SAFE_FALLBACK), { size: 32 }).toLowerCase() ||
|
|
245
|
+
ownersData.length !== 2 + (64 + plan.owners.length * 32) * 2 ||
|
|
246
|
+
ownersData.slice(2, 66).toLowerCase() !==
|
|
247
|
+
toHex(32n, { size: 32 }).slice(2) ||
|
|
248
|
+
ownersData.slice(66, 130).toLowerCase() !==
|
|
249
|
+
toHex(BigInt(plan.owners.length), { size: 32 }).slice(2))
|
|
250
|
+
throw mismatch();
|
|
251
|
+
const owners = decodeFunctionResult({
|
|
252
|
+
abi: READ_ABI,
|
|
253
|
+
functionName: "getOwners",
|
|
254
|
+
data: ownersData,
|
|
255
|
+
});
|
|
256
|
+
if (new Set(owners.map((owner) => owner.toLowerCase())).size !==
|
|
257
|
+
plan.owners.length ||
|
|
258
|
+
plan.owners.some((owner) => !owners.some((actual) => isAddressEqual(actual, owner))))
|
|
259
|
+
throw mismatch();
|
|
260
|
+
}
|
|
261
|
+
return complete;
|
|
262
|
+
}
|
|
263
|
+
export async function checkSafeDeployments(client, plans = []) {
|
|
264
|
+
if (!plans.length)
|
|
265
|
+
return;
|
|
266
|
+
validatePlans(plans);
|
|
267
|
+
const code = await readSafeCreationCode(client);
|
|
268
|
+
if (plans.some((plan) => plan.proxyCreationCode.toLowerCase() !== code.toLowerCase()))
|
|
269
|
+
throw new Error("The saved Safe creation code changed.");
|
|
270
|
+
await verifySafeDeployments(client, plans, { allowMissing: true });
|
|
271
|
+
}
|
|
272
|
+
/** Optional factory calls are idempotent only with preflight, simulation, and receipt verification. */
|
|
273
|
+
export function buildSafeDeploymentCalls(plans) {
|
|
274
|
+
validatePlans(plans);
|
|
275
|
+
return plans.map((plan) => ({
|
|
276
|
+
target: SAFE_FACTORY,
|
|
277
|
+
allowFailure: true,
|
|
278
|
+
value: 0n,
|
|
279
|
+
callData: encodeFunctionData({
|
|
280
|
+
abi: SAFE_CREATE_ABI,
|
|
281
|
+
functionName: "createProxyWithNonce",
|
|
282
|
+
args: [
|
|
283
|
+
SAFE_SINGLETON,
|
|
284
|
+
buildSafeInitializer(plan),
|
|
285
|
+
BigInt(plan.saltNonce),
|
|
286
|
+
],
|
|
287
|
+
}),
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
export function buildSafeDeploymentTx(chainId, plans) {
|
|
291
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0)
|
|
292
|
+
throw new Error("Invalid Safe deployment chain.");
|
|
293
|
+
return {
|
|
294
|
+
chainId,
|
|
295
|
+
address: MULTICALL3,
|
|
296
|
+
abi: CREATE_BATCH_ABI,
|
|
297
|
+
functionName: "aggregate3Value",
|
|
298
|
+
args: [buildSafeDeploymentCalls(plans)],
|
|
299
|
+
value: 0n,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Multicall3 changes msg.sender. Use only a sender-independent or already authenticated
|
|
304
|
+
* forwarded launch. This helper cannot decide the launch contract's authorization semantics.
|
|
305
|
+
* Simulate the returned call, verifySafeLaunchSimulation, then verify receipt-block state.
|
|
306
|
+
*/
|
|
307
|
+
export function bundleSafeLaunch(call, plans = []) {
|
|
308
|
+
if (!plans.length)
|
|
309
|
+
return call;
|
|
310
|
+
if (!validAddress(call.to) ||
|
|
311
|
+
!/^0x(?:[\da-f]{2})*$/i.test(call.data) ||
|
|
312
|
+
typeof call.value !== "bigint" ||
|
|
313
|
+
call.value < 0n)
|
|
314
|
+
throw new Error("Invalid Safe launch call.");
|
|
315
|
+
const calls = [
|
|
316
|
+
...buildSafeDeploymentCalls(plans),
|
|
317
|
+
{
|
|
318
|
+
target: call.to,
|
|
319
|
+
allowFailure: false,
|
|
320
|
+
value: call.value,
|
|
321
|
+
callData: call.data,
|
|
322
|
+
},
|
|
323
|
+
];
|
|
324
|
+
return {
|
|
325
|
+
to: MULTICALL3,
|
|
326
|
+
value: call.value,
|
|
327
|
+
data: encodeFunctionData({
|
|
328
|
+
abi: CREATE_BATCH_ABI,
|
|
329
|
+
functionName: "aggregate3Value",
|
|
330
|
+
args: [calls],
|
|
331
|
+
}),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/** Require the exact reviewed factory calls, their order, one mandatory launch, and its value. */
|
|
335
|
+
export function unbundleSafeLaunch(call, plans = []) {
|
|
336
|
+
if (!plans.length)
|
|
337
|
+
return call;
|
|
338
|
+
if (!isAddressEqual(call.to, MULTICALL3))
|
|
339
|
+
throw new Error("The saved Safe launch is not a creation batch.");
|
|
340
|
+
const { args } = decodeFunctionData({
|
|
341
|
+
abi: CREATE_BATCH_ABI,
|
|
342
|
+
data: call.data,
|
|
343
|
+
});
|
|
344
|
+
const last = args[0][args[0].length - 1];
|
|
345
|
+
if (!last)
|
|
346
|
+
throw new Error("The saved creation batch is empty.");
|
|
347
|
+
const inner = { to: last.target, data: last.callData, value: call.value };
|
|
348
|
+
if (bundleSafeLaunch(inner, plans).data.toLowerCase() !==
|
|
349
|
+
call.data.toLowerCase())
|
|
350
|
+
throw new Error("The saved creation batch differs from its reviewed Safes and launch.");
|
|
351
|
+
return inner;
|
|
352
|
+
}
|
|
353
|
+
/** Outer simulation success is insufficient: an optional deployment may have failed. */
|
|
354
|
+
export async function verifySafeLaunchSimulation(client, plans = [], data) {
|
|
355
|
+
if (!plans.length)
|
|
356
|
+
return;
|
|
357
|
+
validatePlans(plans);
|
|
358
|
+
if (!data)
|
|
359
|
+
throw new Error("The Safe creation simulation returned no results.");
|
|
360
|
+
const results = decodeFunctionResult({
|
|
361
|
+
abi: CREATE_BATCH_ABI,
|
|
362
|
+
functionName: "aggregate3Value",
|
|
363
|
+
data,
|
|
364
|
+
});
|
|
365
|
+
if (results.length !== plans.length + 1 ||
|
|
366
|
+
!results[results.length - 1].success)
|
|
367
|
+
throw new Error("The creation batch did not simulate every required call.");
|
|
368
|
+
for (const [index, plan] of plans.entries()) {
|
|
369
|
+
const result = results[index];
|
|
370
|
+
if (result.success) {
|
|
371
|
+
if (result.returnData.toLowerCase() !==
|
|
372
|
+
toHex(BigInt(plan.address), { size: 32 }).toLowerCase())
|
|
373
|
+
throw new Error("The simulated factory returned a different Safe address.");
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
// Only an already-deployed Safe with the exact policy can explain an accepted failure.
|
|
377
|
+
await verifySafeDeployments(client, [plan]);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
//# sourceMappingURL=safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe.js","sourceRoot":"","sources":["../../src/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,SAAS,EACT,QAAQ,EACR,KAAK,EACL,WAAW,GAIZ,MAAM,MAAM,CAAC;AAEd,uEAAuE;AACvE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,4CAA4C,CAC7C,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CACtC,4CAA4C,CAC7C,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CACrC,4CAA4C,CAC7C,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,4CAA4C,CAC7C,CAAC;AACF,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,MAAM,SAAS,GAAG;IAChB;QACE,YAAY;QACZ,oEAAoE;KACrE;IACD;QACE,cAAc;QACd,oEAAoE;KACrE;IACD;QACE,aAAa;QACb,oEAAoE;KACrE;CACO,CAAC;AACX,MAAM,eAAe,GACnB,oEAAoE,CAAC;AACvE,MAAM,QAAQ,GAAG,4CAAqD,CAAC;AACvE,MAAM,cAAc,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/C,MAAM,UAAU,GACd,oEAA6E,CAAC;AAChF,MAAM,aAAa,GACjB,oEAA6E,CAAC;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG,QA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
|
|
2
2
|
"name": "@bananapus/nana-sdk-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": {
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"import": "./dist/esm/jbcenter.js",
|
|
37
37
|
"require": "./dist/cjs/jbcenter.js"
|
|
38
38
|
},
|
|
39
|
+
"./safe": {
|
|
40
|
+
"types": "./dist/esm/safe.d.ts",
|
|
41
|
+
"import": "./dist/esm/safe.js",
|
|
42
|
+
"require": "./dist/cjs/safe.js"
|
|
43
|
+
},
|
|
39
44
|
"./v6": {
|
|
40
45
|
"types": "./dist/esm/v6/index.d.ts",
|
|
41
46
|
"import": "./dist/esm/v6/index.js",
|