@safe-global/safe-deployments 1.36.0 → 1.37.1
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 +56 -28
- package/dist/accessors.js +1 -3
- package/dist/assets/v1.0.0/gnosis_safe.json +477 -103
- package/dist/assets/v1.0.0/proxy_factory.json +9 -6
- package/dist/assets/v1.1.1/default_callback_handler.json +12 -9
- package/dist/assets/v1.1.1/gnosis_safe.json +12 -9
- package/dist/assets/v1.1.1/multi_send.json +12 -9
- package/dist/assets/v1.1.1/proxy_factory.json +12 -9
- package/dist/assets/v1.2.0/gnosis_safe.json +12 -9
- package/dist/assets/v1.3.0/compatibility_fallback_handler.json +247 -222
- package/dist/assets/v1.3.0/create_call.json +247 -222
- package/dist/assets/v1.3.0/gnosis_safe.json +247 -222
- package/dist/assets/v1.3.0/gnosis_safe_l2.json +247 -222
- package/dist/assets/v1.3.0/multi_send.json +247 -222
- package/dist/assets/v1.3.0/multi_send_call_only.json +247 -222
- package/dist/assets/v1.3.0/proxy_factory.json +247 -222
- package/dist/assets/v1.3.0/sign_message_lib.json +248 -223
- package/dist/assets/v1.3.0/simulate_tx_accessor.json +247 -222
- package/dist/assets/v1.4.1/compatibility_fallback_handler.json +114 -41
- package/dist/assets/v1.4.1/create_call.json +114 -41
- package/dist/assets/v1.4.1/multi_send.json +114 -41
- package/dist/assets/v1.4.1/multi_send_call_only.json +114 -41
- package/dist/assets/v1.4.1/safe.json +114 -41
- package/dist/assets/v1.4.1/safe_l2.json +114 -41
- package/dist/assets/v1.4.1/safe_proxy_factory.json +115 -42
- package/dist/assets/v1.4.1/sign_message_lib.json +115 -42
- package/dist/assets/v1.4.1/simulate_tx_accessor.json +114 -41
- package/dist/factories.js +4 -1
- package/dist/handler.js +6 -5
- package/dist/libs.js +4 -12
- package/dist/safes.d.ts +3 -3
- package/dist/safes.js +6 -4
- package/dist/types.d.ts +28 -2
- package/dist/types.js +11 -0
- package/dist/utils.d.ts +9 -2
- package/dist/utils.js +34 -5
- package/package.json +15 -17
- package/src/__tests__/assets/v1/v1.0.0/gnosis_safe.json +794 -0
- package/src/__tests__/assets/v1/v1.0.0/proxy_factory.json +109 -0
- package/src/__tests__/assets/v1/v1.1.1/create_and_add_modules.json +57 -0
- package/src/__tests__/assets/v1/v1.1.1/create_call.json +88 -0
- package/src/__tests__/assets/v1/v1.1.1/default_callback_handler.json +210 -0
- package/src/__tests__/assets/v1/v1.1.1/gnosis_safe.json +999 -0
- package/src/__tests__/assets/v1/v1.1.1/multi_send.json +43 -0
- package/src/__tests__/assets/v1/v1.1.1/proxy_factory.json +189 -0
- package/src/__tests__/assets/v1/v1.2.0/gnosis_safe.json +1020 -0
- package/src/__tests__/assets/v1/v1.3.0/compatibility_fallback_handler.json +580 -0
- package/src/__tests__/assets/v1/v1.3.0/create_call.json +323 -0
- package/src/__tests__/assets/v1/v1.3.0/gnosis_safe.json +1288 -0
- package/src/__tests__/assets/v1/v1.3.0/gnosis_safe_l2.json +1393 -0
- package/src/__tests__/assets/v1/v1.3.0/multi_send.json +275 -0
- package/src/__tests__/assets/v1/v1.3.0/multi_send_call_only.json +270 -0
- package/src/__tests__/assets/v1/v1.3.0/proxy_factory.json +418 -0
- package/src/__tests__/assets/v1/v1.3.0/sign_message_lib.json +302 -0
- package/src/__tests__/assets/v1/v1.3.0/simulate_tx_accessor.json +306 -0
- package/src/__tests__/assets/v1/v1.4.1/compatibility_fallback_handler.json +445 -0
- package/src/__tests__/assets/v1/v1.4.1/create_call.json +190 -0
- package/src/__tests__/assets/v1/v1.4.1/multi_send.json +142 -0
- package/src/__tests__/assets/v1/v1.4.1/multi_send_call_only.json +137 -0
- package/src/__tests__/assets/v1/v1.4.1/safe.json +1121 -0
- package/src/__tests__/assets/v1/v1.4.1/safe_l2.json +1226 -0
- package/src/__tests__/assets/v1/v1.4.1/safe_proxy_factory.json +261 -0
- package/src/__tests__/assets/v1/v1.4.1/sign_message_lib.json +169 -0
- package/src/__tests__/assets/v1/v1.4.1/simulate_tx_accessor.json +173 -0
- package/src/__tests__/assets.test.ts +101 -38
- package/src/__tests__/factories.test.ts +3 -3
- package/src/__tests__/handler.test.ts +5 -5
- package/src/__tests__/libs.test.ts +9 -9
- package/src/__tests__/safes.test.ts +9 -12
- package/src/__tests__/utils.test.ts +271 -0
- package/src/accessors.ts +5 -7
- package/src/assets/v1.0.0/gnosis_safe.json +477 -103
- package/src/assets/v1.0.0/proxy_factory.json +9 -6
- package/src/assets/v1.1.1/create_and_add_modules.json +17 -10
- package/src/assets/v1.1.1/create_call.json +12 -9
- package/src/assets/v1.1.1/default_callback_handler.json +12 -9
- package/src/assets/v1.1.1/gnosis_safe.json +12 -9
- package/src/assets/v1.1.1/multi_send.json +12 -9
- package/src/assets/v1.1.1/proxy_factory.json +12 -9
- package/src/assets/v1.2.0/gnosis_safe.json +12 -9
- package/src/assets/v1.3.0/compatibility_fallback_handler.json +247 -222
- package/src/assets/v1.3.0/create_call.json +247 -222
- package/src/assets/v1.3.0/gnosis_safe.json +247 -222
- package/src/assets/v1.3.0/gnosis_safe_l2.json +247 -222
- package/src/assets/v1.3.0/multi_send.json +247 -222
- package/src/assets/v1.3.0/multi_send_call_only.json +247 -222
- package/src/assets/v1.3.0/proxy_factory.json +247 -222
- package/src/assets/v1.3.0/sign_message_lib.json +248 -223
- package/src/assets/v1.3.0/simulate_tx_accessor.json +247 -222
- package/src/assets/v1.4.1/compatibility_fallback_handler.json +115 -42
- package/src/assets/v1.4.1/create_call.json +115 -42
- package/src/assets/v1.4.1/multi_send.json +115 -42
- package/src/assets/v1.4.1/multi_send_call_only.json +115 -42
- package/src/assets/v1.4.1/safe.json +115 -42
- package/src/assets/v1.4.1/safe_l2.json +115 -42
- package/src/assets/v1.4.1/safe_proxy_factory.json +116 -43
- package/src/assets/v1.4.1/sign_message_lib.json +116 -43
- package/src/assets/v1.4.1/simulate_tx_accessor.json +115 -42
- package/src/factories.ts +14 -11
- package/src/handler.ts +24 -21
- package/src/index.ts +6 -6
- package/src/libs.ts +23 -31
- package/src/safes.ts +21 -19
- package/src/types.ts +84 -10
- package/src/utils.ts +50 -12
- package/src/__tests__/utilts.test.ts +0 -385
package/src/libs.ts
CHANGED
|
@@ -1,46 +1,38 @@
|
|
|
1
|
-
import CreateCall130 from './assets/v1.3.0/create_call.json'
|
|
2
|
-
import CreateCall141 from './assets/v1.4.1/create_call.json'
|
|
3
|
-
import MultiSend111 from './assets/v1.1.1/multi_send.json'
|
|
4
|
-
import MultiSend130 from './assets/v1.3.0/multi_send.json'
|
|
5
|
-
import MultiSend141 from './assets/v1.4.1/multi_send.json'
|
|
6
|
-
import MultiSendCallOnly130 from './assets/v1.3.0/multi_send_call_only.json'
|
|
7
|
-
import MultiSendCallOnly141 from './assets/v1.4.1/multi_send_call_only.json'
|
|
8
|
-
import SignMessageLib130 from './assets/v1.3.0/sign_message_lib.json'
|
|
9
|
-
import SignMessageLib141 from './assets/v1.4.1/sign_message_lib.json'
|
|
10
|
-
import { DeploymentFilter, SingletonDeployment } from './types'
|
|
11
|
-
import { findDeployment } from './utils'
|
|
1
|
+
import CreateCall130 from './assets/v1.3.0/create_call.json';
|
|
2
|
+
import CreateCall141 from './assets/v1.4.1/create_call.json';
|
|
3
|
+
import MultiSend111 from './assets/v1.1.1/multi_send.json';
|
|
4
|
+
import MultiSend130 from './assets/v1.3.0/multi_send.json';
|
|
5
|
+
import MultiSend141 from './assets/v1.4.1/multi_send.json';
|
|
6
|
+
import MultiSendCallOnly130 from './assets/v1.3.0/multi_send_call_only.json';
|
|
7
|
+
import MultiSendCallOnly141 from './assets/v1.4.1/multi_send_call_only.json';
|
|
8
|
+
import SignMessageLib130 from './assets/v1.3.0/sign_message_lib.json';
|
|
9
|
+
import SignMessageLib141 from './assets/v1.4.1/sign_message_lib.json';
|
|
10
|
+
import { DeploymentFilter, SingletonDeployment, SingletonDeploymentJSON } from './types';
|
|
11
|
+
import { findDeployment } from './utils';
|
|
12
12
|
|
|
13
13
|
// This is a sorted array (by preference, currently we use 111 in most cases)
|
|
14
|
-
const multiSendDeployments:
|
|
15
|
-
MultiSend141, MultiSend130, MultiSend111
|
|
16
|
-
]
|
|
14
|
+
const multiSendDeployments: SingletonDeploymentJSON[] = [MultiSend141, MultiSend130, MultiSend111];
|
|
17
15
|
|
|
18
16
|
export const getMultiSendDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
return findDeployment(filter, multiSendDeployments);
|
|
18
|
+
};
|
|
21
19
|
|
|
22
20
|
// This is a sorted array (by preference)
|
|
23
|
-
const multiSendCallOnlyDeployments:
|
|
24
|
-
MultiSendCallOnly141, MultiSendCallOnly130
|
|
25
|
-
]
|
|
21
|
+
const multiSendCallOnlyDeployments: SingletonDeploymentJSON[] = [MultiSendCallOnly141, MultiSendCallOnly130];
|
|
26
22
|
|
|
27
23
|
export const getMultiSendCallOnlyDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
|
|
28
|
-
|
|
29
|
-
}
|
|
24
|
+
return findDeployment(filter, multiSendCallOnlyDeployments);
|
|
25
|
+
};
|
|
30
26
|
|
|
31
27
|
// This is a sorted array (by preference)
|
|
32
|
-
const createCallDeployments:
|
|
33
|
-
CreateCall141, CreateCall130
|
|
34
|
-
]
|
|
28
|
+
const createCallDeployments: SingletonDeploymentJSON[] = [CreateCall141, CreateCall130];
|
|
35
29
|
|
|
36
30
|
export const getCreateCallDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
|
|
37
|
-
|
|
38
|
-
}
|
|
31
|
+
return findDeployment(filter, createCallDeployments);
|
|
32
|
+
};
|
|
39
33
|
|
|
40
|
-
const signMessageLibDeployments:
|
|
41
|
-
SignMessageLib141, SignMessageLib130
|
|
42
|
-
]
|
|
34
|
+
const signMessageLibDeployments: SingletonDeploymentJSON[] = [SignMessageLib141, SignMessageLib130];
|
|
43
35
|
|
|
44
36
|
export const getSignMessageLibDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
|
|
45
|
-
|
|
46
|
-
}
|
|
37
|
+
return findDeployment(filter, signMessageLibDeployments);
|
|
38
|
+
};
|
package/src/safes.ts
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import SafeL2141 from './assets/v1.4.1/safe_l2.json'
|
|
2
|
-
import Safe141 from './assets/v1.4.1/safe.json'
|
|
3
|
-
import GnosisSafeL2130 from './assets/v1.3.0/gnosis_safe_l2.json'
|
|
4
|
-
import GnosisSafe130 from './assets/v1.3.0/gnosis_safe.json'
|
|
5
|
-
import GnosisSafe120 from './assets/v1.2.0/gnosis_safe.json'
|
|
6
|
-
import GnosisSafe111 from './assets/v1.1.1/gnosis_safe.json'
|
|
7
|
-
import GnosisSafe100 from './assets/v1.0.0/gnosis_safe.json'
|
|
8
|
-
import { DeploymentFilter, SingletonDeployment } from './types'
|
|
9
|
-
import { findDeployment } from './utils'
|
|
1
|
+
import SafeL2141 from './assets/v1.4.1/safe_l2.json';
|
|
2
|
+
import Safe141 from './assets/v1.4.1/safe.json';
|
|
3
|
+
import GnosisSafeL2130 from './assets/v1.3.0/gnosis_safe_l2.json';
|
|
4
|
+
import GnosisSafe130 from './assets/v1.3.0/gnosis_safe.json';
|
|
5
|
+
import GnosisSafe120 from './assets/v1.2.0/gnosis_safe.json';
|
|
6
|
+
import GnosisSafe111 from './assets/v1.1.1/gnosis_safe.json';
|
|
7
|
+
import GnosisSafe100 from './assets/v1.0.0/gnosis_safe.json';
|
|
8
|
+
import { DeploymentFilter, SingletonDeployment, SingletonDeploymentJSON } from './types';
|
|
9
|
+
import { findDeployment } from './utils';
|
|
10
10
|
|
|
11
11
|
// This is a sorted array (newest to oldest), exported for tests
|
|
12
|
-
export const _safeDeployments:
|
|
13
|
-
Safe141,
|
|
14
|
-
|
|
12
|
+
export const _safeDeployments: SingletonDeploymentJSON[] = [
|
|
13
|
+
Safe141,
|
|
14
|
+
GnosisSafe130,
|
|
15
|
+
GnosisSafe120,
|
|
16
|
+
GnosisSafe111,
|
|
17
|
+
GnosisSafe100,
|
|
18
|
+
];
|
|
15
19
|
|
|
16
20
|
export const getSafeSingletonDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
|
|
17
|
-
|
|
18
|
-
}
|
|
21
|
+
return findDeployment(filter, _safeDeployments);
|
|
22
|
+
};
|
|
19
23
|
|
|
20
24
|
// This is a sorted array (newest to oldest), exported for tests
|
|
21
|
-
export const _safeL2Deployments:
|
|
22
|
-
SafeL2141, GnosisSafeL2130
|
|
23
|
-
]
|
|
25
|
+
export const _safeL2Deployments: SingletonDeploymentJSON[] = [SafeL2141, GnosisSafeL2130];
|
|
24
26
|
|
|
25
27
|
export const getSafeL2SingletonDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
+
return findDeployment(filter, _safeL2Deployments);
|
|
29
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -1,14 +1,88 @@
|
|
|
1
|
+
enum AddressType {
|
|
2
|
+
// The original address the contract was deployed on.
|
|
3
|
+
// Starting with 1.4.1, the contracts are deployed with an EIP155-compatible transaction.
|
|
4
|
+
CANONICAL = 'canonical',
|
|
5
|
+
|
|
6
|
+
// An address that was deployed with a transaction compatible with the EIP155 standard.
|
|
7
|
+
// The type is only used for 1.3.0 deployments.
|
|
8
|
+
EIP155 = 'eip155',
|
|
9
|
+
|
|
10
|
+
// An address that is deployed to the ZkSync VM networks.
|
|
11
|
+
ZKSYNC = 'zksync',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SingletonDeploymentJSON {
|
|
15
|
+
// Indicates if the deployment is released.
|
|
16
|
+
released: boolean;
|
|
17
|
+
|
|
18
|
+
// The name of the contract.
|
|
19
|
+
contractName: string;
|
|
20
|
+
|
|
21
|
+
// The version of the deployment.
|
|
22
|
+
version: string;
|
|
23
|
+
|
|
24
|
+
// The hash of the contract code.
|
|
25
|
+
codeHash: string;
|
|
26
|
+
|
|
27
|
+
// A record of network addresses, where the key is the network identifier and the value is either a single address type or an array of address types.
|
|
28
|
+
networkAddresses: Record<string, string | string[]>;
|
|
29
|
+
|
|
30
|
+
// A record of addresses, where the key is the address type and the value is the address.
|
|
31
|
+
// Possible addresses per version:
|
|
32
|
+
// 1.0.0: canonical
|
|
33
|
+
// 1.1.1: canonical
|
|
34
|
+
// 1.2.0: canonical
|
|
35
|
+
// 1.3.0: canonical, eip155, zksync
|
|
36
|
+
// 1.4.1: canonical, zksync
|
|
37
|
+
addresses: Record<string, string>;
|
|
38
|
+
|
|
39
|
+
// The ABI (Application Binary Interface) of the contract.
|
|
40
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
41
|
+
abi: any[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// This is the old type that only allows a single address for each network.
|
|
45
|
+
// It is still used for backwards compatibility.
|
|
1
46
|
export interface SingletonDeployment {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
47
|
+
// The default address of the deployment.
|
|
48
|
+
defaultAddress: string;
|
|
49
|
+
|
|
50
|
+
// Indicates if the deployment is released.
|
|
51
|
+
released: boolean;
|
|
52
|
+
|
|
53
|
+
// The name of the contract.
|
|
54
|
+
contractName: string;
|
|
55
|
+
|
|
56
|
+
// The version of the deployment.
|
|
57
|
+
version: string;
|
|
58
|
+
|
|
59
|
+
// The hash of the contract code.
|
|
60
|
+
codeHash: string;
|
|
61
|
+
|
|
62
|
+
// A record of addresses, where the key is the address type and the value is the address.
|
|
63
|
+
addresses: Record<string, string>;
|
|
64
|
+
|
|
65
|
+
// A record of network addresses, where the key is the network identifier and the value is the address.
|
|
66
|
+
networkAddresses: Record<string, string>;
|
|
67
|
+
|
|
68
|
+
// The ABI (Application Binary Interface) of the contract.
|
|
69
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
70
|
+
abi: any[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SingletonDeploymentV2 {
|
|
74
|
+
released: boolean;
|
|
75
|
+
contractName: string;
|
|
76
|
+
version: string;
|
|
77
|
+
codeHash: string;
|
|
78
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
79
|
+
abi: any[];
|
|
80
|
+
networkAddresses: Record<string, AddressType | AddressType[]>;
|
|
81
|
+
addresses: Partial<Record<AddressType, string>>;
|
|
8
82
|
}
|
|
9
83
|
|
|
10
84
|
export interface DeploymentFilter {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
85
|
+
version?: string;
|
|
86
|
+
released?: boolean;
|
|
87
|
+
network?: string;
|
|
88
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -1,16 +1,54 @@
|
|
|
1
|
-
import { DeploymentFilter, SingletonDeployment } from './types'
|
|
2
|
-
import semverSatisfies from 'semver/functions/satisfies'
|
|
1
|
+
import { DeploymentFilter, SingletonDeployment, SingletonDeploymentJSON } from './types';
|
|
2
|
+
import semverSatisfies from 'semver/functions/satisfies';
|
|
3
3
|
|
|
4
|
-
const DEFAULT_FILTER: DeploymentFilter = { released: true }
|
|
4
|
+
const DEFAULT_FILTER: DeploymentFilter = { released: true };
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// The older JSON format had a `defaultAddress` field, which became obsolete due to EIP-155 enforcement and non-EVM compatible chains.
|
|
7
|
+
// This led to multiple "default" addresses, sometimes on the same chain ID. To maintain backwards compatibility, we map `defaultAddress`
|
|
8
|
+
// to the address deployed on a chosen default network.
|
|
9
|
+
const DEFAULT_NETWORK_CHAIN_ID = '1';
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Maps a SingletonDeploymentJSON object to a SingletonDeployment object.
|
|
13
|
+
*
|
|
14
|
+
* @param {SingletonDeploymentJSON} deployment - The deployment JSON object to map.
|
|
15
|
+
* @returns {SingletonDeployment} - The mapped deployment object.
|
|
16
|
+
*/
|
|
17
|
+
const mapJsonToDeploymentsFormatV1 = (deployment: SingletonDeploymentJSON): SingletonDeployment => {
|
|
18
|
+
const defaultAddressType = Array.isArray(deployment.networkAddresses[DEFAULT_NETWORK_CHAIN_ID])
|
|
19
|
+
? deployment.networkAddresses[DEFAULT_NETWORK_CHAIN_ID][0]
|
|
20
|
+
: deployment.networkAddresses[DEFAULT_NETWORK_CHAIN_ID];
|
|
21
|
+
const defaultAddress = deployment.addresses[defaultAddressType];
|
|
22
|
+
const networkAddresses = Object.fromEntries(
|
|
23
|
+
Object.entries(deployment.networkAddresses).map(([chainId, addressTypes]) => [
|
|
24
|
+
chainId,
|
|
25
|
+
Array.isArray(addressTypes) ? deployment.addresses[addressTypes[0]] : deployment.addresses[addressTypes],
|
|
26
|
+
]),
|
|
27
|
+
);
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
return { ...deployment, defaultAddress, networkAddresses };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Finds a deployment that matches the given criteria.
|
|
34
|
+
*
|
|
35
|
+
* @param {DeploymentFilter} [criteria=DEFAULT_FILTER] - The filter criteria to match deployments.
|
|
36
|
+
* @param {SingletonDeploymentJSON[]} deployments - The list of deployment JSON objects to search.
|
|
37
|
+
* @returns {SingletonDeployment | undefined} - The found deployment object or undefined if no match is found.
|
|
38
|
+
*/
|
|
39
|
+
export const findDeployment = (
|
|
40
|
+
criteria: DeploymentFilter = DEFAULT_FILTER,
|
|
41
|
+
deployments: SingletonDeploymentJSON[],
|
|
42
|
+
): SingletonDeployment | undefined => {
|
|
43
|
+
const { version, released, network } = { ...DEFAULT_FILTER, ...criteria };
|
|
44
|
+
|
|
45
|
+
const deploymentJson = deployments.find((deployment) => {
|
|
46
|
+
if (version && !semverSatisfies(deployment.version, version)) return false;
|
|
47
|
+
if (typeof released === 'boolean' && deployment.released !== released) return false;
|
|
48
|
+
if (network && !deployment.networkAddresses[network]) return false;
|
|
49
|
+
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return deploymentJson ? mapJsonToDeploymentsFormatV1(deploymentJson) : undefined;
|
|
54
|
+
};
|
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import SafeL2141 from '../assets/v1.4.1/safe_l2.json';
|
|
2
|
-
import Safe141 from '../assets/v1.4.1/safe.json';
|
|
3
|
-
|
|
4
|
-
import GnosisSafeL2130 from '../assets/v1.3.0/gnosis_safe_l2.json';
|
|
5
|
-
import GnosisSafe130 from '../assets/v1.3.0/gnosis_safe.json';
|
|
6
|
-
import GnosisSafe120 from '../assets/v1.2.0/gnosis_safe.json';
|
|
7
|
-
import GnosisSafe111 from '../assets/v1.1.1/gnosis_safe.json';
|
|
8
|
-
import GnosisSafe100 from '../assets/v1.0.0/gnosis_safe.json';
|
|
9
|
-
import { findDeployment } from '../utils';
|
|
10
|
-
import { _safeDeployments, _safeL2Deployments } from '../safes';
|
|
11
|
-
import { SingletonDeployment } from '../types';
|
|
12
|
-
|
|
13
|
-
const _safeDeploymentsReverse = [..._safeDeployments].reverse();
|
|
14
|
-
|
|
15
|
-
describe('utils.ts', () => {
|
|
16
|
-
describe('findDeployment', () => {
|
|
17
|
-
it('should filter by released by default', () => {
|
|
18
|
-
const testUnreleasedDeployment: SingletonDeployment = {
|
|
19
|
-
defaultAddress: '',
|
|
20
|
-
version: '',
|
|
21
|
-
abi: [],
|
|
22
|
-
networkAddresses: { "1": "0xbeef" },
|
|
23
|
-
contractName: '',
|
|
24
|
-
released: false,
|
|
25
|
-
};
|
|
26
|
-
const testReleasedDeployment: SingletonDeployment = {
|
|
27
|
-
defaultAddress: '',
|
|
28
|
-
version: '',
|
|
29
|
-
abi: [],
|
|
30
|
-
networkAddresses: { "1": "0xbeef" },
|
|
31
|
-
contractName: '',
|
|
32
|
-
released: true, // Default filter value
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const testDeployments = [
|
|
36
|
-
testUnreleasedDeployment,
|
|
37
|
-
testUnreleasedDeployment,
|
|
38
|
-
testReleasedDeployment,
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
expect(findDeployment(undefined, testDeployments)).toBe(
|
|
42
|
-
testReleasedDeployment
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
// should preserve the released flag even if its not explicitly passed
|
|
46
|
-
expect(findDeployment({ network: '1' }, testDeployments)).toBe(
|
|
47
|
-
testReleasedDeployment
|
|
48
|
-
)
|
|
49
|
-
});
|
|
50
|
-
it('should return the correct deployment (filtered by version)', () => {
|
|
51
|
-
// Chronological deployments
|
|
52
|
-
expect(findDeployment({ version: '1.3.0' }, _safeDeployments)).toBe(
|
|
53
|
-
GnosisSafe130
|
|
54
|
-
);
|
|
55
|
-
expect(findDeployment({ version: '1.2.0' }, _safeDeployments)).toBe(
|
|
56
|
-
GnosisSafe120
|
|
57
|
-
);
|
|
58
|
-
expect(findDeployment({ version: '1.1.1' }, _safeDeployments)).toBe(
|
|
59
|
-
GnosisSafe111
|
|
60
|
-
);
|
|
61
|
-
expect(findDeployment({ version: '1.0.0' }, _safeDeployments)).toBe(
|
|
62
|
-
GnosisSafe100
|
|
63
|
-
);
|
|
64
|
-
// Incorrect filter:
|
|
65
|
-
expect(
|
|
66
|
-
findDeployment({ version: '2.0.0' }, _safeDeployments)
|
|
67
|
-
).toBeUndefined();
|
|
68
|
-
|
|
69
|
-
// L2 deployments
|
|
70
|
-
expect(findDeployment({ version: '1.3.0+L2' }, _safeL2Deployments)).toBe(
|
|
71
|
-
GnosisSafeL2130
|
|
72
|
-
);
|
|
73
|
-
// Incorrect filter:
|
|
74
|
-
expect(
|
|
75
|
-
findDeployment({ version: '2.0.0+L2' }, _safeL2Deployments)
|
|
76
|
-
).toBeUndefined();
|
|
77
|
-
});
|
|
78
|
-
it('should return the correct deployment (filtered by released flag)', () => {
|
|
79
|
-
const testUnreleasedDeployment: SingletonDeployment = {
|
|
80
|
-
defaultAddress: '',
|
|
81
|
-
version: '',
|
|
82
|
-
abi: [],
|
|
83
|
-
networkAddresses: { "1": "0xbeef" },
|
|
84
|
-
contractName: '',
|
|
85
|
-
released: false,
|
|
86
|
-
};
|
|
87
|
-
const testReleasedDeployment: SingletonDeployment = {
|
|
88
|
-
defaultAddress: '',
|
|
89
|
-
version: '',
|
|
90
|
-
abi: [],
|
|
91
|
-
networkAddresses: { "1": "0xbeef" },
|
|
92
|
-
contractName: '',
|
|
93
|
-
released: true, // Default filter value
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const testDeployments = [
|
|
97
|
-
testUnreleasedDeployment,
|
|
98
|
-
testReleasedDeployment,
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// Chronological deployments
|
|
103
|
-
expect(findDeployment({ released: true }, _safeDeployments)).toBe(
|
|
104
|
-
Safe141
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// Reverse chronological deployments
|
|
108
|
-
expect(findDeployment({ released: true }, _safeDeploymentsReverse)).toBe(
|
|
109
|
-
GnosisSafe100
|
|
110
|
-
);
|
|
111
|
-
// Released flag set to false:
|
|
112
|
-
expect(
|
|
113
|
-
findDeployment({ released: false }, testDeployments)
|
|
114
|
-
).toBe(testUnreleasedDeployment);
|
|
115
|
-
|
|
116
|
-
// L2 deployments
|
|
117
|
-
expect(findDeployment({ released: true }, _safeL2Deployments)).toBe(
|
|
118
|
-
SafeL2141
|
|
119
|
-
);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('should return the correct deployment (filtered by network)', () => {
|
|
123
|
-
// Reverse chronological deployments
|
|
124
|
-
expect(findDeployment({ network: '1' }, _safeDeploymentsReverse)).toBe(
|
|
125
|
-
GnosisSafe100
|
|
126
|
-
);
|
|
127
|
-
expect(
|
|
128
|
-
findDeployment({ network: '73799' }, _safeDeploymentsReverse)
|
|
129
|
-
).toBe(GnosisSafe111);
|
|
130
|
-
expect(
|
|
131
|
-
findDeployment({ network: '11297108109' }, _safeDeploymentsReverse)
|
|
132
|
-
).toBe(GnosisSafe130);
|
|
133
|
-
// Incorrect filter:
|
|
134
|
-
expect(
|
|
135
|
-
findDeployment({ network: '0' }, _safeDeploymentsReverse)
|
|
136
|
-
).toBeUndefined();
|
|
137
|
-
|
|
138
|
-
// L2 deployments
|
|
139
|
-
expect(findDeployment({ network: '100' }, _safeL2Deployments)).toBe(
|
|
140
|
-
SafeL2141
|
|
141
|
-
);
|
|
142
|
-
// Incorrect filter:
|
|
143
|
-
expect(
|
|
144
|
-
findDeployment({ network: '0' }, _safeL2Deployments)
|
|
145
|
-
).toBeUndefined();
|
|
146
|
-
});
|
|
147
|
-
it('should return the correct deployment (filtered by version and released)', () => {
|
|
148
|
-
// Chronological deployments
|
|
149
|
-
expect(
|
|
150
|
-
findDeployment({ version: '1.3.0', released: true }, _safeDeployments)
|
|
151
|
-
).toBe(GnosisSafe130);
|
|
152
|
-
expect(
|
|
153
|
-
findDeployment({ version: '1.2.0', released: true }, _safeDeployments)
|
|
154
|
-
).toBe(GnosisSafe120);
|
|
155
|
-
expect(
|
|
156
|
-
findDeployment({ version: '1.1.1', released: true }, _safeDeployments)
|
|
157
|
-
).toBe(GnosisSafe111);
|
|
158
|
-
expect(
|
|
159
|
-
findDeployment({ version: '1.0.0', released: true }, _safeDeployments)
|
|
160
|
-
).toBe(GnosisSafe100);
|
|
161
|
-
// Incorrect filter:
|
|
162
|
-
expect(
|
|
163
|
-
findDeployment({ version: '1.0.0', released: false }, _safeDeployments)
|
|
164
|
-
).toBeUndefined();
|
|
165
|
-
|
|
166
|
-
// L2 deployments
|
|
167
|
-
expect(
|
|
168
|
-
findDeployment({ version: '1.3.0', released: true }, _safeL2Deployments)
|
|
169
|
-
).toBe(GnosisSafeL2130);
|
|
170
|
-
expect(
|
|
171
|
-
findDeployment(
|
|
172
|
-
{ version: '1.3.0+L2', released: true },
|
|
173
|
-
_safeL2Deployments
|
|
174
|
-
)
|
|
175
|
-
).toBe(GnosisSafeL2130);
|
|
176
|
-
// Incorrect filter:
|
|
177
|
-
expect(
|
|
178
|
-
findDeployment(
|
|
179
|
-
{ version: '1.3.0+L2', released: false },
|
|
180
|
-
_safeL2Deployments
|
|
181
|
-
)
|
|
182
|
-
).toBeUndefined();
|
|
183
|
-
});
|
|
184
|
-
it('should return the correct deployment (filtered by version and network)', () => {
|
|
185
|
-
// Reverse chronological deployments
|
|
186
|
-
expect(
|
|
187
|
-
findDeployment(
|
|
188
|
-
{ version: '1.0.0', network: '1' },
|
|
189
|
-
_safeDeploymentsReverse
|
|
190
|
-
)
|
|
191
|
-
).toBe(GnosisSafe100);
|
|
192
|
-
expect(
|
|
193
|
-
findDeployment(
|
|
194
|
-
{ version: '1.1.1', network: '1' },
|
|
195
|
-
_safeDeploymentsReverse
|
|
196
|
-
)
|
|
197
|
-
).toBe(GnosisSafe111);
|
|
198
|
-
expect(
|
|
199
|
-
findDeployment(
|
|
200
|
-
{ version: '1.2.0', network: '1' },
|
|
201
|
-
_safeDeploymentsReverse
|
|
202
|
-
)
|
|
203
|
-
).toBe(GnosisSafe120);
|
|
204
|
-
expect(
|
|
205
|
-
findDeployment(
|
|
206
|
-
{ version: '1.3.0', network: '1' },
|
|
207
|
-
_safeDeploymentsReverse
|
|
208
|
-
)
|
|
209
|
-
).toBe(GnosisSafe130);
|
|
210
|
-
// Incorrect filter:
|
|
211
|
-
expect(
|
|
212
|
-
findDeployment(
|
|
213
|
-
{ version: '1.3.0', network: '0' },
|
|
214
|
-
_safeDeploymentsReverse
|
|
215
|
-
)
|
|
216
|
-
).toBeUndefined();
|
|
217
|
-
|
|
218
|
-
// L2 deployments
|
|
219
|
-
expect(
|
|
220
|
-
findDeployment({ version: '1.3.0', network: '100' }, _safeL2Deployments)
|
|
221
|
-
).toBe(GnosisSafeL2130);
|
|
222
|
-
expect(
|
|
223
|
-
findDeployment(
|
|
224
|
-
{ version: '1.3.0+L2', network: '100' },
|
|
225
|
-
_safeL2Deployments
|
|
226
|
-
)
|
|
227
|
-
).toBe(GnosisSafeL2130);
|
|
228
|
-
// Incorrect filter:
|
|
229
|
-
expect(
|
|
230
|
-
findDeployment(
|
|
231
|
-
{ version: '1.3.0+L2', network: '0' },
|
|
232
|
-
_safeL2Deployments
|
|
233
|
-
)
|
|
234
|
-
).toBeUndefined();
|
|
235
|
-
});
|
|
236
|
-
it('should return the correct deployment (filtered by released and network)', () => {
|
|
237
|
-
const testUnreleasedDeployment: SingletonDeployment = {
|
|
238
|
-
defaultAddress: '',
|
|
239
|
-
version: '',
|
|
240
|
-
abi: [],
|
|
241
|
-
networkAddresses: { "1": "0xbeef" },
|
|
242
|
-
contractName: '',
|
|
243
|
-
released: false,
|
|
244
|
-
};
|
|
245
|
-
const testReleasedDeployment: SingletonDeployment = {
|
|
246
|
-
defaultAddress: '',
|
|
247
|
-
version: '',
|
|
248
|
-
abi: [],
|
|
249
|
-
networkAddresses: { "1": "0xbeef" },
|
|
250
|
-
contractName: '',
|
|
251
|
-
released: true, // Default filter value
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
const testDeployments = [
|
|
255
|
-
testUnreleasedDeployment,
|
|
256
|
-
testUnreleasedDeployment,
|
|
257
|
-
testReleasedDeployment,
|
|
258
|
-
];
|
|
259
|
-
|
|
260
|
-
// Reverse chronological deployments
|
|
261
|
-
expect(
|
|
262
|
-
findDeployment(
|
|
263
|
-
{ released: true, network: '1' },
|
|
264
|
-
_safeDeploymentsReverse
|
|
265
|
-
)
|
|
266
|
-
).toBe(GnosisSafe100);
|
|
267
|
-
expect(
|
|
268
|
-
findDeployment(
|
|
269
|
-
{ released: true, network: '246' },
|
|
270
|
-
_safeDeploymentsReverse
|
|
271
|
-
)
|
|
272
|
-
).toBe(GnosisSafe111);
|
|
273
|
-
expect(
|
|
274
|
-
findDeployment(
|
|
275
|
-
{ released: true, network: '11297108109' },
|
|
276
|
-
_safeDeploymentsReverse
|
|
277
|
-
)
|
|
278
|
-
).toBe(GnosisSafe130);
|
|
279
|
-
// Incorrect filter:
|
|
280
|
-
expect(
|
|
281
|
-
findDeployment(
|
|
282
|
-
{ released: true, network: '0' },
|
|
283
|
-
_safeDeploymentsReverse
|
|
284
|
-
)
|
|
285
|
-
).toBeUndefined();
|
|
286
|
-
expect(
|
|
287
|
-
findDeployment(
|
|
288
|
-
{ released: false, network: '1' },
|
|
289
|
-
testDeployments
|
|
290
|
-
)
|
|
291
|
-
).toBe(testUnreleasedDeployment);
|
|
292
|
-
|
|
293
|
-
// L2 deployments
|
|
294
|
-
expect(
|
|
295
|
-
findDeployment({ released: true, network: '100' }, _safeL2Deployments)
|
|
296
|
-
).toBe(SafeL2141);
|
|
297
|
-
// Incorrect filter:
|
|
298
|
-
expect(
|
|
299
|
-
findDeployment({ released: true, network: '0' }, _safeL2Deployments)
|
|
300
|
-
).toBeUndefined();
|
|
301
|
-
expect(
|
|
302
|
-
findDeployment({ released: false, network: '100' }, testDeployments)
|
|
303
|
-
).toBeUndefined();
|
|
304
|
-
});
|
|
305
|
-
it('should return the correct deployment (filtered by version, released and network)', () => {
|
|
306
|
-
// Reverse chronological deployments
|
|
307
|
-
expect(
|
|
308
|
-
findDeployment(
|
|
309
|
-
{ version: '1.0.0', released: true, network: '1' },
|
|
310
|
-
_safeDeploymentsReverse
|
|
311
|
-
)
|
|
312
|
-
).toBe(GnosisSafe100);
|
|
313
|
-
expect(
|
|
314
|
-
findDeployment(
|
|
315
|
-
{ version: '1.1.1', released: true, network: '246' },
|
|
316
|
-
_safeDeploymentsReverse
|
|
317
|
-
)
|
|
318
|
-
).toBe(GnosisSafe111);
|
|
319
|
-
expect(
|
|
320
|
-
findDeployment(
|
|
321
|
-
{ version: '1.2.0', released: true, network: '73799' },
|
|
322
|
-
_safeDeploymentsReverse
|
|
323
|
-
)
|
|
324
|
-
).toBe(GnosisSafe120);
|
|
325
|
-
expect(
|
|
326
|
-
findDeployment(
|
|
327
|
-
{ version: '1.3.0', released: true, network: '11297108109' },
|
|
328
|
-
_safeDeploymentsReverse
|
|
329
|
-
)
|
|
330
|
-
).toBe(GnosisSafe130);
|
|
331
|
-
// Incorrect filter:
|
|
332
|
-
expect(
|
|
333
|
-
findDeployment(
|
|
334
|
-
{ version: '1.3.0', released: false, network: '11297108109' },
|
|
335
|
-
_safeDeploymentsReverse
|
|
336
|
-
)
|
|
337
|
-
).toBeUndefined();
|
|
338
|
-
expect(
|
|
339
|
-
findDeployment(
|
|
340
|
-
{ version: '1.3.0', released: true, network: '0' },
|
|
341
|
-
_safeDeploymentsReverse
|
|
342
|
-
)
|
|
343
|
-
).toBeUndefined();
|
|
344
|
-
expect(
|
|
345
|
-
findDeployment(
|
|
346
|
-
{ version: '2.0.0', released: true, network: '11297108109' },
|
|
347
|
-
_safeDeploymentsReverse
|
|
348
|
-
)
|
|
349
|
-
).toBeUndefined();
|
|
350
|
-
|
|
351
|
-
// L2 deployments
|
|
352
|
-
expect(
|
|
353
|
-
findDeployment(
|
|
354
|
-
{ version: '1.3.0', released: true, network: '100' },
|
|
355
|
-
_safeL2Deployments
|
|
356
|
-
)
|
|
357
|
-
).toBe(GnosisSafeL2130);
|
|
358
|
-
expect(
|
|
359
|
-
findDeployment(
|
|
360
|
-
{ version: '1.3.0+L2', released: true, network: '100' },
|
|
361
|
-
_safeL2Deployments
|
|
362
|
-
)
|
|
363
|
-
).toBe(GnosisSafeL2130);
|
|
364
|
-
// Incorrect filter:
|
|
365
|
-
expect(
|
|
366
|
-
findDeployment(
|
|
367
|
-
{ version: '1.3.0+L2', released: false, network: '100' },
|
|
368
|
-
_safeL2Deployments
|
|
369
|
-
)
|
|
370
|
-
).toBeUndefined();
|
|
371
|
-
expect(
|
|
372
|
-
findDeployment(
|
|
373
|
-
{ version: '1.3.0+L2', released: true, network: '0' },
|
|
374
|
-
_safeL2Deployments
|
|
375
|
-
)
|
|
376
|
-
).toBeUndefined();
|
|
377
|
-
expect(
|
|
378
|
-
findDeployment(
|
|
379
|
-
{ version: '2.0.0+L2', released: true, network: '100' },
|
|
380
|
-
_safeL2Deployments
|
|
381
|
-
)
|
|
382
|
-
).toBeUndefined();
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
});
|