@safe-vanity-blockie/safe-config 0.4.1 → 1.0.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/README.md +1 -0
- package/dist/address-class.d.ts +17 -0
- package/dist/address-class.d.ts.map +1 -0
- package/dist/address-class.js +49 -0
- package/dist/address-class.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/setup.d.ts +3 -2
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +3 -2
- package/dist/setup.js.map +1 -1
- package/dist/versions.d.ts +10 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +13 -0
- package/dist/versions.js.map +1 -0
- package/package.json +5 -4
- package/src/address-class.ts +67 -0
- package/src/index.ts +6 -0
- package/src/setup.ts +3 -2
- package/src/versions.ts +16 -0
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ npm install @safe-vanity-blockie/safe-config
|
|
|
21
21
|
| Export | Purpose |
|
|
22
22
|
| --- | --- |
|
|
23
23
|
| `loadSafeConstants` | resolve proxy factory, singleton and init code hash for a chain |
|
|
24
|
+
| `addressClassFor` | which chains give a Safe the same address on a version, offline from safe-deployments |
|
|
24
25
|
| `verifyWithProtocolKit` | cross-check a derived address against the official Safe Protocol Kit |
|
|
25
26
|
| `ZKSYNC_CHAIN_IDS` | chains whose CREATE2 derivation differs, so an address is not portable |
|
|
26
27
|
| `SafeSetup`, `SetupInput` | the setup shape and its input form |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SupportedSafeVersion } from './versions.js';
|
|
2
|
+
/**
|
|
3
|
+
* Which chains give a Safe the same address, per Safe version: two chains with the same class give
|
|
4
|
+
* every (owners, threshold, saltNonce) the same address, and two with different classes do not.
|
|
5
|
+
*
|
|
6
|
+
* Resolved from safe-deployments the way `loadSafeConstants` resolves it through protocol-kit: the
|
|
7
|
+
* proxy factory, the singleton (L1 on mainnet, L2 elsewhere — protocol-kit's default, so a forced
|
|
8
|
+
* `isL1SafeSingleton` is not modelled) and the compatibility fallback handler, each the first
|
|
9
|
+
* address listed for the chain. Those three are what a chain contributes to a standard-EVM Safe
|
|
10
|
+
* address — the factory directly, the singleton through the initCodeHash, and the handler through
|
|
11
|
+
* the initializerHash. test/address-class.test.ts pins the resulting partition against what was
|
|
12
|
+
* measured on live RPCs.
|
|
13
|
+
*
|
|
14
|
+
* Undefined for a chain safe-deployments has no deployment for, and for zkSync-family chains.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addressClassFor(chainId: number, safeVersion: SupportedSafeVersion): string | undefined;
|
|
17
|
+
//# sourceMappingURL=address-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-class.d.ts","sourceRoot":"","sources":["../src/address-class.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAqCzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,oBAAoB,GAChC,MAAM,GAAG,SAAS,CAIpB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getCompatibilityFallbackHandlerDeployment, getProxyFactoryDeployment, getSafeL2SingletonDeployment, getSafeSingletonDeployment, } from '@safe-global/safe-deployments';
|
|
2
|
+
import { ZKSYNC_CHAIN_IDS } from './setup.js';
|
|
3
|
+
/**
|
|
4
|
+
* Chains on which protocol-kit defaults to the L1 singleton (Safe.sol) rather than SafeL2.sol.
|
|
5
|
+
* Mirrors protocol-kit's own `safeDeploymentsL1ChainIds`, which it does not export.
|
|
6
|
+
*/
|
|
7
|
+
const L1_SINGLETON_CHAIN_IDS = new Set([1]);
|
|
8
|
+
/** The address protocol-kit resolves for a deployment on a chain: the first one listed. */
|
|
9
|
+
function deployedAddress(deployment, chainId) {
|
|
10
|
+
const addresses = deployment?.networkAddresses[String(chainId)];
|
|
11
|
+
return (Array.isArray(addresses) ? addresses[0] : addresses)?.toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
function resolveAddressClass(chainId, safeVersion) {
|
|
14
|
+
// Same contract addresses, different CREATE2 formula: sharing them says nothing about the Safe.
|
|
15
|
+
if (ZKSYNC_CHAIN_IDS.has(BigInt(chainId)))
|
|
16
|
+
return undefined;
|
|
17
|
+
const filter = { version: safeVersion, network: String(chainId), released: true };
|
|
18
|
+
const singleton = L1_SINGLETON_CHAIN_IDS.has(chainId)
|
|
19
|
+
? getSafeSingletonDeployment(filter)
|
|
20
|
+
: getSafeL2SingletonDeployment(filter);
|
|
21
|
+
const parts = [
|
|
22
|
+
deployedAddress(getProxyFactoryDeployment(filter), chainId),
|
|
23
|
+
deployedAddress(singleton, chainId),
|
|
24
|
+
deployedAddress(getCompatibilityFallbackHandlerDeployment(filter), chainId),
|
|
25
|
+
];
|
|
26
|
+
return parts.every((part) => part !== undefined) ? parts.join(' ') : undefined;
|
|
27
|
+
}
|
|
28
|
+
const classes = new Map();
|
|
29
|
+
/**
|
|
30
|
+
* Which chains give a Safe the same address, per Safe version: two chains with the same class give
|
|
31
|
+
* every (owners, threshold, saltNonce) the same address, and two with different classes do not.
|
|
32
|
+
*
|
|
33
|
+
* Resolved from safe-deployments the way `loadSafeConstants` resolves it through protocol-kit: the
|
|
34
|
+
* proxy factory, the singleton (L1 on mainnet, L2 elsewhere — protocol-kit's default, so a forced
|
|
35
|
+
* `isL1SafeSingleton` is not modelled) and the compatibility fallback handler, each the first
|
|
36
|
+
* address listed for the chain. Those three are what a chain contributes to a standard-EVM Safe
|
|
37
|
+
* address — the factory directly, the singleton through the initCodeHash, and the handler through
|
|
38
|
+
* the initializerHash. test/address-class.test.ts pins the resulting partition against what was
|
|
39
|
+
* measured on live RPCs.
|
|
40
|
+
*
|
|
41
|
+
* Undefined for a chain safe-deployments has no deployment for, and for zkSync-family chains.
|
|
42
|
+
*/
|
|
43
|
+
export function addressClassFor(chainId, safeVersion) {
|
|
44
|
+
const key = `${chainId}:${safeVersion}`;
|
|
45
|
+
if (!classes.has(key))
|
|
46
|
+
classes.set(key, resolveAddressClass(chainId, safeVersion));
|
|
47
|
+
return classes.get(key);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=address-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address-class.js","sourceRoot":"","sources":["../src/address-class.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yCAAyC,EACzC,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,GAE3B,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAG7C;;;GAGG;AACH,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEhE,2FAA2F;AAC3F,SAAS,eAAe,CACtB,UAA2C,EAC3C,OAAe;IAEf,MAAM,SAAS,GAAG,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,CAAA;AAC7E,CAAC;AAED,SAAS,mBAAmB,CAC1B,OAAe,EACf,WAAiC;IAEjC,gGAAgG;IAChG,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IAC3D,MAAM,MAAM,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IACjF,MAAM,SAAS,GAAG,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC;QACnD,CAAC,CAAC,0BAA0B,CAAC,MAAM,CAAC;QACpC,CAAC,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,KAAK,GAAG;QACZ,eAAe,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAC3D,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC;QACnC,eAAe,CAAC,yCAAyC,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;KAC5E,CAAA;IACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAChF,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAA;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,WAAiC;IAEjC,MAAM,GAAG,GAAG,GAAG,OAAO,IAAI,WAAW,EAAE,CAAA;IACvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAA;IAClF,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACzB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export { addressClassFor } from './address-class.js';
|
|
1
2
|
export { loadSafeConstants, type SafeSetup, type SetupInput, verifyWithProtocolKit, ZKSYNC_CHAIN_IDS, } from './setup.js';
|
|
3
|
+
export { DEFAULT_SAFE_VERSION, SUPPORTED_SAFE_VERSIONS, type SupportedSafeVersion, } from './versions.js';
|
|
2
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EACL,iBAAiB,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EACL,iBAAiB,EAGjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GAExB,MAAM,eAAe,CAAA"}
|
package/dist/setup.d.ts
CHANGED
|
@@ -31,8 +31,9 @@ export interface SafeSetup {
|
|
|
31
31
|
* These are the chain IDs protocol-kit itself gates its zkSync formula on internally
|
|
32
32
|
* (ZKSYNC_MAINNET = 324, ZKSYNC_TESTNET = 300, ZKSYNC_LENS = 232), per the installed
|
|
33
33
|
* @safe-global/protocol-kit@8.0.5 source. protocol-kit additionally gates on
|
|
34
|
-
* `safeVersion <= 1.4.1`,
|
|
35
|
-
*
|
|
34
|
+
* `safeVersion <= 1.4.1`, so for 1.5.0 it would predict with the standard EVM formula instead.
|
|
35
|
+
* This tool has not verified that against a live zkSync deployment, so every version is
|
|
36
|
+
* rejected on these chains alike: a plain set membership check on chain ID.
|
|
36
37
|
*/
|
|
37
38
|
export declare const ZKSYNC_CHAIN_IDS: ReadonlySet<bigint>;
|
|
38
39
|
/**
|
package/dist/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,EACb,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAU,KAAK,GAAG,EAAa,MAAM,MAAM,CAAA;AAElD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,WAAW,CAAA;IACxB,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,aAAa,CAAA;IACxB,YAAY,EAAE;QAAE,eAAe,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,GAAG,CAAC;QAAC,YAAY,EAAE,GAAG,CAAA;KAAE,CAAA;IACvE,YAAY,EAAE,YAAY,CAAA;IAC1B,iBAAiB,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1D,WAAW,EAAE,WAAW,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED
|
|
1
|
+
{"version":3,"file":"setup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ED
|
@@ -6,8 +6,9 @@ import { concat, keccak256 } from 'viem';
|
|
|
6
6
|
* These are the chain IDs protocol-kit itself gates its zkSync formula on internally
|
|
7
7
|
* (ZKSYNC_MAINNET = 324, ZKSYNC_TESTNET = 300, ZKSYNC_LENS = 232), per the installed
|
|
8
8
|
* @safe-global/protocol-kit@8.0.5 source. protocol-kit additionally gates on
|
|
9
|
-
* `safeVersion <= 1.4.1`,
|
|
10
|
-
*
|
|
9
|
+
* `safeVersion <= 1.4.1`, so for 1.5.0 it would predict with the standard EVM formula instead.
|
|
10
|
+
* This tool has not verified that against a live zkSync deployment, so every version is
|
|
11
|
+
* rejected on these chains alike: a plain set membership check on chain ID.
|
|
11
12
|
*/
|
|
12
13
|
export const ZKSYNC_CHAIN_IDS = new Set([324n, 300n, 232n]);
|
|
13
14
|
/**
|
package/dist/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,kBAAkB,EAClB,YAAY,GACb,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,UAAU,EAAsB,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAY,SAAS,EAAE,MAAM,MAAM,CAAA;AAqBlD
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,kBAAkB,EAClB,YAAY,GACb,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,UAAU,EAAsB,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAY,SAAS,EAAE,MAAM,MAAM,CAAA;AAqBlD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,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,CAAC,CAAC,iBAAwB,EAAE,gBAAuB,CAAC,CAAC,CAAC,CAAA;IAC3F,MAAM,OAAO,GAAG,eAAe,CAAC,UAAU,EAAS,CAAA;IAEnD,OAAO;QACL,OAAO;QACP,SAAS,EAAE;YACT,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC;YAC5C,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;YAC5B,YAAY,EAAE,UAAU,CAAC,YAAY,CAAC;SACvC;QACD,YAAY,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE;QACxD,YAAY;QACZ,iBAAiB;QACjB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAA;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAgB,EAChB,SAAiB,EACjB,OAAe;IAEf,MAAM,SAAS,GAAG,MAAM,kBAAkB,CAAC;QACzC,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,oBAAoB,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE;QACnE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;KAC3C,CAAC,CAAA;IACF,IAAI,SAAS,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QACtD,MAAM,IAAI,KAAK,CACb,mCAAmC,SAAS,0BAA0B,OAAO,IAAI;YAC/E,wCAAwC,SAAS,CAAC,WAAW,EAAE,EAAE,CACpE,CAAA;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Safe versions the CLI and the web app accept, newest first. One list for both, so a version
|
|
3
|
+
* cannot be minable in one and rejected by the other. Each must be a version protocol-kit knows,
|
|
4
|
+
* which the `satisfies` below enforces at compile time.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SUPPORTED_SAFE_VERSIONS: readonly ["1.5.0", "1.4.1", "1.3.0"];
|
|
7
|
+
export type SupportedSafeVersion = (typeof SUPPORTED_SAFE_VERSIONS)[number];
|
|
8
|
+
/** What a config that names no version mines and deploys. It is part of the address. */
|
|
9
|
+
export declare const DEFAULT_SAFE_VERSION: SupportedSafeVersion;
|
|
10
|
+
//# sourceMappingURL=versions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,sCAIO,CAAA;AAC3C,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3E,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,EAAE,oBAA8B,CAAA"}
|
package/dist/versions.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Safe versions the CLI and the web app accept, newest first. One list for both, so a version
|
|
3
|
+
* cannot be minable in one and rejected by the other. Each must be a version protocol-kit knows,
|
|
4
|
+
* which the `satisfies` below enforces at compile time.
|
|
5
|
+
*/
|
|
6
|
+
export const SUPPORTED_SAFE_VERSIONS = [
|
|
7
|
+
'1.5.0',
|
|
8
|
+
'1.4.1',
|
|
9
|
+
'1.3.0',
|
|
10
|
+
];
|
|
11
|
+
/** What a config that names no version mines and deploys. It is part of the address. */
|
|
12
|
+
export const DEFAULT_SAFE_VERSION = '1.5.0';
|
|
13
|
+
//# sourceMappingURL=versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,OAAO;IACP,OAAO;IACP,OAAO;CACkC,CAAA;AAG3C,wFAAwF;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAAyB,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-vanity-blockie/safe-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Resolve canonical Safe contract addresses and build the setup inputs for counterfactual address derivation",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
],
|
|
37
37
|
"sideEffects": false,
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@safe-global/protocol-kit": "^8.0.
|
|
39
|
+
"@safe-global/protocol-kit": "^8.0.7",
|
|
40
|
+
"@safe-global/safe-deployments": "^1.37.63",
|
|
40
41
|
"@safe-global/types-kit": "^4.0.1",
|
|
41
|
-
"viem": "^2.
|
|
42
|
-
"@safe-vanity-blockie/core": "0.
|
|
42
|
+
"viem": "^2.57.2",
|
|
43
|
+
"@safe-vanity-blockie/core": "1.0.0"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"build": "tsc -p tsconfig.json",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCompatibilityFallbackHandlerDeployment,
|
|
3
|
+
getProxyFactoryDeployment,
|
|
4
|
+
getSafeL2SingletonDeployment,
|
|
5
|
+
getSafeSingletonDeployment,
|
|
6
|
+
type SingletonDeployment,
|
|
7
|
+
} from '@safe-global/safe-deployments'
|
|
8
|
+
import { ZKSYNC_CHAIN_IDS } from './setup.js'
|
|
9
|
+
import type { SupportedSafeVersion } from './versions.js'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Chains on which protocol-kit defaults to the L1 singleton (Safe.sol) rather than SafeL2.sol.
|
|
13
|
+
* Mirrors protocol-kit's own `safeDeploymentsL1ChainIds`, which it does not export.
|
|
14
|
+
*/
|
|
15
|
+
const L1_SINGLETON_CHAIN_IDS: ReadonlySet<number> = new Set([1])
|
|
16
|
+
|
|
17
|
+
/** The address protocol-kit resolves for a deployment on a chain: the first one listed. */
|
|
18
|
+
function deployedAddress(
|
|
19
|
+
deployment: SingletonDeployment | undefined,
|
|
20
|
+
chainId: number,
|
|
21
|
+
): string | undefined {
|
|
22
|
+
const addresses = deployment?.networkAddresses[String(chainId)]
|
|
23
|
+
return (Array.isArray(addresses) ? addresses[0] : addresses)?.toLowerCase()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function resolveAddressClass(
|
|
27
|
+
chainId: number,
|
|
28
|
+
safeVersion: SupportedSafeVersion,
|
|
29
|
+
): string | undefined {
|
|
30
|
+
// Same contract addresses, different CREATE2 formula: sharing them says nothing about the Safe.
|
|
31
|
+
if (ZKSYNC_CHAIN_IDS.has(BigInt(chainId))) return undefined
|
|
32
|
+
const filter = { version: safeVersion, network: String(chainId), released: true }
|
|
33
|
+
const singleton = L1_SINGLETON_CHAIN_IDS.has(chainId)
|
|
34
|
+
? getSafeSingletonDeployment(filter)
|
|
35
|
+
: getSafeL2SingletonDeployment(filter)
|
|
36
|
+
const parts = [
|
|
37
|
+
deployedAddress(getProxyFactoryDeployment(filter), chainId),
|
|
38
|
+
deployedAddress(singleton, chainId),
|
|
39
|
+
deployedAddress(getCompatibilityFallbackHandlerDeployment(filter), chainId),
|
|
40
|
+
]
|
|
41
|
+
return parts.every((part) => part !== undefined) ? parts.join(' ') : undefined
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const classes = new Map<string, string | undefined>()
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Which chains give a Safe the same address, per Safe version: two chains with the same class give
|
|
48
|
+
* every (owners, threshold, saltNonce) the same address, and two with different classes do not.
|
|
49
|
+
*
|
|
50
|
+
* Resolved from safe-deployments the way `loadSafeConstants` resolves it through protocol-kit: the
|
|
51
|
+
* proxy factory, the singleton (L1 on mainnet, L2 elsewhere — protocol-kit's default, so a forced
|
|
52
|
+
* `isL1SafeSingleton` is not modelled) and the compatibility fallback handler, each the first
|
|
53
|
+
* address listed for the chain. Those three are what a chain contributes to a standard-EVM Safe
|
|
54
|
+
* address — the factory directly, the singleton through the initCodeHash, and the handler through
|
|
55
|
+
* the initializerHash. test/address-class.test.ts pins the resulting partition against what was
|
|
56
|
+
* measured on live RPCs.
|
|
57
|
+
*
|
|
58
|
+
* Undefined for a chain safe-deployments has no deployment for, and for zkSync-family chains.
|
|
59
|
+
*/
|
|
60
|
+
export function addressClassFor(
|
|
61
|
+
chainId: number,
|
|
62
|
+
safeVersion: SupportedSafeVersion,
|
|
63
|
+
): string | undefined {
|
|
64
|
+
const key = `${chainId}:${safeVersion}`
|
|
65
|
+
if (!classes.has(key)) classes.set(key, resolveAddressClass(chainId, safeVersion))
|
|
66
|
+
return classes.get(key)
|
|
67
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { addressClassFor } from './address-class.js'
|
|
1
2
|
export {
|
|
2
3
|
loadSafeConstants,
|
|
3
4
|
type SafeSetup,
|
|
@@ -5,3 +6,8 @@ export {
|
|
|
5
6
|
verifyWithProtocolKit,
|
|
6
7
|
ZKSYNC_CHAIN_IDS,
|
|
7
8
|
} from './setup.js'
|
|
9
|
+
export {
|
|
10
|
+
DEFAULT_SAFE_VERSION,
|
|
11
|
+
SUPPORTED_SAFE_VERSIONS,
|
|
12
|
+
type SupportedSafeVersion,
|
|
13
|
+
} from './versions.js'
|
package/src/setup.ts
CHANGED
|
@@ -33,8 +33,9 @@ export interface SafeSetup {
|
|
|
33
33
|
* These are the chain IDs protocol-kit itself gates its zkSync formula on internally
|
|
34
34
|
* (ZKSYNC_MAINNET = 324, ZKSYNC_TESTNET = 300, ZKSYNC_LENS = 232), per the installed
|
|
35
35
|
* @safe-global/protocol-kit@8.0.5 source. protocol-kit additionally gates on
|
|
36
|
-
* `safeVersion <= 1.4.1`,
|
|
37
|
-
*
|
|
36
|
+
* `safeVersion <= 1.4.1`, so for 1.5.0 it would predict with the standard EVM formula instead.
|
|
37
|
+
* This tool has not verified that against a live zkSync deployment, so every version is
|
|
38
|
+
* rejected on these chains alike: a plain set membership check on chain ID.
|
|
38
39
|
*/
|
|
39
40
|
export const ZKSYNC_CHAIN_IDS: ReadonlySet<bigint> = new Set([324n, 300n, 232n])
|
|
40
41
|
|
package/src/versions.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SafeVersion } from '@safe-global/types-kit'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The Safe versions the CLI and the web app accept, newest first. One list for both, so a version
|
|
5
|
+
* cannot be minable in one and rejected by the other. Each must be a version protocol-kit knows,
|
|
6
|
+
* which the `satisfies` below enforces at compile time.
|
|
7
|
+
*/
|
|
8
|
+
export const SUPPORTED_SAFE_VERSIONS = [
|
|
9
|
+
'1.5.0',
|
|
10
|
+
'1.4.1',
|
|
11
|
+
'1.3.0',
|
|
12
|
+
] as const satisfies readonly SafeVersion[]
|
|
13
|
+
export type SupportedSafeVersion = (typeof SUPPORTED_SAFE_VERSIONS)[number]
|
|
14
|
+
|
|
15
|
+
/** What a config that names no version mines and deploys. It is part of the address. */
|
|
16
|
+
export const DEFAULT_SAFE_VERSION: SupportedSafeVersion = '1.5.0'
|