@safe-global/safe-deployments 1.37.1 → 1.37.2

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.
Files changed (107) hide show
  1. package/README.md +101 -10
  2. package/dist/accessors.d.ts +14 -1
  3. package/dist/accessors.js +19 -9
  4. package/dist/assets/v1.0.0/gnosis_safe.json +5 -3
  5. package/dist/assets/v1.0.0/proxy_factory.json +5 -3
  6. package/dist/assets/v1.1.1/default_callback_handler.json +5 -3
  7. package/dist/assets/v1.1.1/gnosis_safe.json +5 -3
  8. package/dist/assets/v1.1.1/multi_send.json +5 -3
  9. package/dist/assets/v1.1.1/proxy_factory.json +5 -3
  10. package/dist/assets/v1.2.0/gnosis_safe.json +5 -3
  11. package/dist/assets/v1.3.0/compatibility_fallback_handler.json +17 -5
  12. package/dist/assets/v1.3.0/create_call.json +17 -5
  13. package/dist/assets/v1.3.0/gnosis_safe.json +17 -5
  14. package/dist/assets/v1.3.0/gnosis_safe_l2.json +17 -5
  15. package/dist/assets/v1.3.0/multi_send.json +17 -5
  16. package/dist/assets/v1.3.0/multi_send_call_only.json +17 -5
  17. package/dist/assets/v1.3.0/proxy_factory.json +17 -5
  18. package/dist/assets/v1.3.0/sign_message_lib.json +17 -5
  19. package/dist/assets/v1.3.0/simulate_tx_accessor.json +17 -5
  20. package/dist/assets/v1.4.1/compatibility_fallback_handler.json +8 -3
  21. package/dist/assets/v1.4.1/create_call.json +8 -3
  22. package/dist/assets/v1.4.1/multi_send.json +8 -3
  23. package/dist/assets/v1.4.1/multi_send_call_only.json +8 -3
  24. package/dist/assets/v1.4.1/safe.json +8 -3
  25. package/dist/assets/v1.4.1/safe_l2.json +8 -3
  26. package/dist/assets/v1.4.1/safe_proxy_factory.json +8 -3
  27. package/dist/assets/v1.4.1/sign_message_lib.json +8 -3
  28. package/dist/assets/v1.4.1/simulate_tx_accessor.json +8 -3
  29. package/dist/deployments.d.ts +12 -0
  30. package/dist/deployments.js +71 -0
  31. package/dist/factories.d.ts +12 -1
  32. package/dist/factories.js +17 -16
  33. package/dist/handler.d.ts +29 -1
  34. package/dist/handler.js +55 -25
  35. package/dist/libs.d.ts +45 -1
  36. package/dist/libs.js +62 -24
  37. package/dist/safes.d.ts +23 -3
  38. package/dist/safes.js +32 -23
  39. package/dist/types.d.ts +21 -12
  40. package/dist/types.js +0 -11
  41. package/dist/utils.d.ts +5 -2
  42. package/dist/utils.js +34 -11
  43. package/package.json +6 -5
  44. package/src/__tests__/assets/v1/v1.0.0/gnosis_safe.json +5 -3
  45. package/src/__tests__/assets/v1/v1.0.0/proxy_factory.json +5 -3
  46. package/src/__tests__/assets/v1/v1.1.1/create_and_add_modules.json +5 -3
  47. package/src/__tests__/assets/v1/v1.1.1/create_call.json +5 -3
  48. package/src/__tests__/assets/v1/v1.1.1/default_callback_handler.json +5 -3
  49. package/src/__tests__/assets/v1/v1.1.1/gnosis_safe.json +5 -3
  50. package/src/__tests__/assets/v1/v1.1.1/multi_send.json +5 -3
  51. package/src/__tests__/assets/v1/v1.1.1/proxy_factory.json +5 -3
  52. package/src/__tests__/assets/v1/v1.2.0/gnosis_safe.json +5 -3
  53. package/src/__tests__/assets/v1/v1.3.0/compatibility_fallback_handler.json +13 -5
  54. package/src/__tests__/assets/v1/v1.3.0/create_call.json +13 -5
  55. package/src/__tests__/assets/v1/v1.3.0/gnosis_safe.json +13 -5
  56. package/src/__tests__/assets/v1/v1.3.0/gnosis_safe_l2.json +13 -5
  57. package/src/__tests__/assets/v1/v1.3.0/multi_send.json +13 -5
  58. package/src/__tests__/assets/v1/v1.3.0/multi_send_call_only.json +13 -5
  59. package/src/__tests__/assets/v1/v1.3.0/proxy_factory.json +13 -5
  60. package/src/__tests__/assets/v1/v1.3.0/sign_message_lib.json +13 -5
  61. package/src/__tests__/assets/v1/v1.3.0/simulate_tx_accessor.json +13 -5
  62. package/src/__tests__/assets/v1/v1.4.1/compatibility_fallback_handler.json +5 -3
  63. package/src/__tests__/assets/v1/v1.4.1/create_call.json +5 -3
  64. package/src/__tests__/assets/v1/v1.4.1/multi_send.json +5 -3
  65. package/src/__tests__/assets/v1/v1.4.1/multi_send_call_only.json +5 -3
  66. package/src/__tests__/assets/v1/v1.4.1/safe.json +5 -3
  67. package/src/__tests__/assets/v1/v1.4.1/safe_l2.json +5 -3
  68. package/src/__tests__/assets/v1/v1.4.1/safe_proxy_factory.json +5 -3
  69. package/src/__tests__/assets/v1/v1.4.1/sign_message_lib.json +5 -3
  70. package/src/__tests__/assets/v1/v1.4.1/simulate_tx_accessor.json +5 -3
  71. package/src/__tests__/assets.test.ts +7 -7
  72. package/src/__tests__/utils.test.ts +386 -236
  73. package/src/accessors.ts +19 -8
  74. package/src/assets/v1.0.0/gnosis_safe.json +5 -3
  75. package/src/assets/v1.0.0/proxy_factory.json +5 -3
  76. package/src/assets/v1.1.1/create_and_add_modules.json +5 -3
  77. package/src/assets/v1.1.1/create_call.json +5 -3
  78. package/src/assets/v1.1.1/default_callback_handler.json +5 -3
  79. package/src/assets/v1.1.1/gnosis_safe.json +5 -3
  80. package/src/assets/v1.1.1/multi_send.json +5 -3
  81. package/src/assets/v1.1.1/proxy_factory.json +5 -3
  82. package/src/assets/v1.2.0/gnosis_safe.json +5 -3
  83. package/src/assets/v1.3.0/compatibility_fallback_handler.json +17 -5
  84. package/src/assets/v1.3.0/create_call.json +17 -5
  85. package/src/assets/v1.3.0/gnosis_safe.json +17 -5
  86. package/src/assets/v1.3.0/gnosis_safe_l2.json +17 -5
  87. package/src/assets/v1.3.0/multi_send.json +17 -5
  88. package/src/assets/v1.3.0/multi_send_call_only.json +17 -5
  89. package/src/assets/v1.3.0/proxy_factory.json +17 -5
  90. package/src/assets/v1.3.0/sign_message_lib.json +17 -5
  91. package/src/assets/v1.3.0/simulate_tx_accessor.json +17 -5
  92. package/src/assets/v1.4.1/compatibility_fallback_handler.json +8 -3
  93. package/src/assets/v1.4.1/create_call.json +8 -3
  94. package/src/assets/v1.4.1/multi_send.json +8 -3
  95. package/src/assets/v1.4.1/multi_send_call_only.json +8 -3
  96. package/src/assets/v1.4.1/safe.json +8 -3
  97. package/src/assets/v1.4.1/safe_l2.json +8 -3
  98. package/src/assets/v1.4.1/safe_proxy_factory.json +8 -3
  99. package/src/assets/v1.4.1/sign_message_lib.json +8 -3
  100. package/src/assets/v1.4.1/simulate_tx_accessor.json +8 -3
  101. package/src/deployments.ts +90 -0
  102. package/src/factories.ts +17 -15
  103. package/src/handler.ts +56 -23
  104. package/src/libs.ts +64 -22
  105. package/src/safes.ts +31 -21
  106. package/src/types.ts +27 -25
  107. package/src/utils.ts +63 -8
package/dist/handler.js CHANGED
@@ -1,35 +1,65 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getFallbackHandlerDeployment = exports.getCompatibilityFallbackHandlerDeployment = exports.getDefaultCallbackHandlerDeployment = void 0;
7
- const default_callback_handler_json_1 = __importDefault(require("./assets/v1.1.1/default_callback_handler.json"));
8
- const compatibility_fallback_handler_json_1 = __importDefault(require("./assets/v1.3.0/compatibility_fallback_handler.json"));
9
- const compatibility_fallback_handler_json_2 = __importDefault(require("./assets/v1.4.1/compatibility_fallback_handler.json"));
3
+ exports.getFallbackHandlerDeployment = exports.getCompatibilityFallbackHandlerDeployments = exports.getCompatibilityFallbackHandlerDeployment = exports.getDefaultCallbackHandlerDeployments = exports.getDefaultCallbackHandlerDeployment = void 0;
10
4
  const utils_1 = require("./utils");
11
- // This is a sorted array (by preference)
12
- const defaultCallbackHandlerDeployments = [default_callback_handler_json_1.default];
5
+ const deployments_1 = require("./deployments");
6
+ /**
7
+ * Get the default callback handler deployment based on the provided filter.
8
+ * @param {DeploymentFilter} [filter] - Optional filter to apply to the deployment search.
9
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if not found.
10
+ */
13
11
  const getDefaultCallbackHandlerDeployment = (filter) => {
14
- return (0, utils_1.findDeployment)(filter, defaultCallbackHandlerDeployments);
12
+ return (0, utils_1.findDeployment)(filter, deployments_1._DEFAULT_CALLBACK_HANDLER_DEPLOYMENTS);
15
13
  };
16
14
  exports.getDefaultCallbackHandlerDeployment = getDefaultCallbackHandlerDeployment;
17
- // This is a sorted array (by preference)
18
- const compatFallbackHandlerDeployments = [
19
- compatibility_fallback_handler_json_2.default,
20
- compatibility_fallback_handler_json_1.default,
21
- ];
15
+ /**
16
+ * Get all default callback handler deployments based on the provided filter.
17
+ * @param {DeploymentFilter} [filter] - Optional filter to apply to the deployment search.
18
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments in version 2 format or undefined if not found.
19
+ */
20
+ const getDefaultCallbackHandlerDeployments = (filter) => {
21
+ return (0, utils_1.findDeployment)(filter, deployments_1._DEFAULT_CALLBACK_HANDLER_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
22
+ };
23
+ exports.getDefaultCallbackHandlerDeployments = getDefaultCallbackHandlerDeployments;
24
+ /**
25
+ * Get the compatibility fallback handler deployment based on the provided filter.
26
+ * @param {DeploymentFilter} [filter] - Optional filter to apply to the deployment search.
27
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if not found.
28
+ */
22
29
  const getCompatibilityFallbackHandlerDeployment = (filter) => {
23
- return (0, utils_1.findDeployment)(filter, compatFallbackHandlerDeployments);
30
+ return (0, utils_1.findDeployment)(filter, deployments_1._COMPAT_FALLBACK_HANDLER_DEPLOYMENTS);
24
31
  };
25
32
  exports.getCompatibilityFallbackHandlerDeployment = getCompatibilityFallbackHandlerDeployment;
26
- // This is a sorted array (by preference)
27
- const fallbackHandlerDeployments = [
28
- compatibility_fallback_handler_json_2.default,
29
- compatibility_fallback_handler_json_1.default,
30
- default_callback_handler_json_1.default,
31
- ];
32
- const getFallbackHandlerDeployment = (filter) => {
33
- return (0, utils_1.findDeployment)(filter, fallbackHandlerDeployments);
33
+ /**
34
+ * Get all compatibility fallback handler deployments based on the provided filter.
35
+ * @param {DeploymentFilter} [filter] - Optional filter to apply to the deployment search.
36
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments in version 2 format or undefined if not found.
37
+ */
38
+ const getCompatibilityFallbackHandlerDeployments = (filter) => {
39
+ return (0, utils_1.findDeployment)(filter, deployments_1._COMPAT_FALLBACK_HANDLER_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
34
40
  };
35
- exports.getFallbackHandlerDeployment = getFallbackHandlerDeployment;
41
+ exports.getCompatibilityFallbackHandlerDeployments = getCompatibilityFallbackHandlerDeployments;
42
+ /**
43
+ * Get the fallback handler deployment based on the provided filter. This method is an alias for `getCompatibilityFallbackHandlerDeployment`.
44
+ * Kept for backwards compatibility.
45
+ * @param {DeploymentFilter} [filter] - Optional filter to apply to the deployment search.
46
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if not found.
47
+ */
48
+ exports.getFallbackHandlerDeployment = exports.getCompatibilityFallbackHandlerDeployment;
49
+ // Leaving the comment here so it's not a part of the JSDoc
50
+ // Previously, the function code was this:
51
+ // // This is a sorted array (by preference)
52
+ // const fallbackHandlerDeployments: SingletonDeploymentJSON[] = [
53
+ // CompatibilityFallbackHandler141,
54
+ // CompatibilityFallbackHandler130,
55
+ // DefaultCallbackHandler130,
56
+ // ];
57
+ // export const getFallbackHandlerDeployment = (filter?: DeploymentFilter): SingletonDeployment | undefined => {
58
+ // return findDeployment(filter, fallbackHandlerDeployments);
59
+ // };
60
+ // The problem with the function is that there’s no possible filter that would make the function return the last element of the array
61
+ // (DefaultCallbackHandler130 ), since we only allow to filter by version, networks and released flag. The only possible way is to have
62
+ // the default callback handler deployed to a network where the compatibility fallback handler isn’t deployed, but we require the whole
63
+ // suite of the contracts be deployed to a network.
64
+ // Since we didn't want to enforce a preferred fallback handler on the deployments package level,
65
+ // we decided to alias it to getCompatibilityFallbackHandlerDeployment (previously returned value)
package/dist/libs.d.ts CHANGED
@@ -1,5 +1,49 @@
1
- import { DeploymentFilter, SingletonDeployment } from './types';
1
+ import { DeploymentFilter, SingletonDeployment, SingletonDeploymentV2 } from './types';
2
+ /**
3
+ * Get the MultiSend deployment based on the provided filter.
4
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
5
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
6
+ */
2
7
  export declare const getMultiSendDeployment: (filter?: DeploymentFilter) => SingletonDeployment | undefined;
8
+ /**
9
+ * Get all MultiSend deployments based on the provided filter.
10
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
11
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
12
+ */
13
+ export declare const getMultiSendDeployments: (filter?: DeploymentFilter) => SingletonDeploymentV2 | undefined;
14
+ /**
15
+ * Get the MultiSendCallOnly deployment based on the provided filter.
16
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
17
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
18
+ */
3
19
  export declare const getMultiSendCallOnlyDeployment: (filter?: DeploymentFilter) => SingletonDeployment | undefined;
20
+ /**
21
+ * Get all MultiSendCallOnly deployments based on the provided filter.
22
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
23
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
24
+ */
25
+ export declare const getMultiSendCallOnlyDeployments: (filter?: DeploymentFilter) => SingletonDeploymentV2 | undefined;
26
+ /**
27
+ * Get the CreateCall deployment based on the provided filter.
28
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
29
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
30
+ */
4
31
  export declare const getCreateCallDeployment: (filter?: DeploymentFilter) => SingletonDeployment | undefined;
32
+ /**
33
+ * Get all CreateCall deployments based on the provided filter.
34
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
35
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
36
+ */
37
+ export declare const getCreateCallDeployments: (filter?: DeploymentFilter) => SingletonDeploymentV2 | undefined;
38
+ /**
39
+ * Get the SignMessageLib deployment based on the provided filter.
40
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
41
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
42
+ */
5
43
  export declare const getSignMessageLibDeployment: (filter?: DeploymentFilter) => SingletonDeployment | undefined;
44
+ /**
45
+ * Get all SignMessageLib deployments based on the provided filter.
46
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
47
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
48
+ */
49
+ export declare const getSignMessageLibDeployments: (filter?: DeploymentFilter) => SingletonDeploymentV2 | undefined;
package/dist/libs.js CHANGED
@@ -1,39 +1,77 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSignMessageLibDeployment = exports.getCreateCallDeployment = exports.getMultiSendCallOnlyDeployment = exports.getMultiSendDeployment = void 0;
7
- const create_call_json_1 = __importDefault(require("./assets/v1.3.0/create_call.json"));
8
- const create_call_json_2 = __importDefault(require("./assets/v1.4.1/create_call.json"));
9
- const multi_send_json_1 = __importDefault(require("./assets/v1.1.1/multi_send.json"));
10
- const multi_send_json_2 = __importDefault(require("./assets/v1.3.0/multi_send.json"));
11
- const multi_send_json_3 = __importDefault(require("./assets/v1.4.1/multi_send.json"));
12
- const multi_send_call_only_json_1 = __importDefault(require("./assets/v1.3.0/multi_send_call_only.json"));
13
- const multi_send_call_only_json_2 = __importDefault(require("./assets/v1.4.1/multi_send_call_only.json"));
14
- const sign_message_lib_json_1 = __importDefault(require("./assets/v1.3.0/sign_message_lib.json"));
15
- const sign_message_lib_json_2 = __importDefault(require("./assets/v1.4.1/sign_message_lib.json"));
3
+ exports.getSignMessageLibDeployments = exports.getSignMessageLibDeployment = exports.getCreateCallDeployments = exports.getCreateCallDeployment = exports.getMultiSendCallOnlyDeployments = exports.getMultiSendCallOnlyDeployment = exports.getMultiSendDeployments = exports.getMultiSendDeployment = void 0;
4
+ const deployments_1 = require("./deployments");
16
5
  const utils_1 = require("./utils");
17
- // This is a sorted array (by preference, currently we use 111 in most cases)
18
- const multiSendDeployments = [multi_send_json_3.default, multi_send_json_2.default, multi_send_json_1.default];
6
+ /**
7
+ * Get the MultiSend deployment based on the provided filter.
8
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
9
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
10
+ */
19
11
  const getMultiSendDeployment = (filter) => {
20
- return (0, utils_1.findDeployment)(filter, multiSendDeployments);
12
+ return (0, utils_1.findDeployment)(filter, deployments_1._MULTI_SEND_DEPLOYMENTS);
21
13
  };
22
14
  exports.getMultiSendDeployment = getMultiSendDeployment;
23
- // This is a sorted array (by preference)
24
- const multiSendCallOnlyDeployments = [multi_send_call_only_json_2.default, multi_send_call_only_json_1.default];
15
+ /**
16
+ * Get all MultiSend deployments based on the provided filter.
17
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
18
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
19
+ */
20
+ const getMultiSendDeployments = (filter) => {
21
+ return (0, utils_1.findDeployment)(filter, deployments_1._MULTI_SEND_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
22
+ };
23
+ exports.getMultiSendDeployments = getMultiSendDeployments;
24
+ /**
25
+ * Get the MultiSendCallOnly deployment based on the provided filter.
26
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
27
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
28
+ */
25
29
  const getMultiSendCallOnlyDeployment = (filter) => {
26
- return (0, utils_1.findDeployment)(filter, multiSendCallOnlyDeployments);
30
+ return (0, utils_1.findDeployment)(filter, deployments_1._MULTI_SEND_CALL_ONLY_DEPLOYMENTS);
27
31
  };
28
32
  exports.getMultiSendCallOnlyDeployment = getMultiSendCallOnlyDeployment;
29
- // This is a sorted array (by preference)
30
- const createCallDeployments = [create_call_json_2.default, create_call_json_1.default];
33
+ /**
34
+ * Get all MultiSendCallOnly deployments based on the provided filter.
35
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
36
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
37
+ */
38
+ const getMultiSendCallOnlyDeployments = (filter) => {
39
+ return (0, utils_1.findDeployment)(filter, deployments_1._MULTI_SEND_CALL_ONLY_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
40
+ };
41
+ exports.getMultiSendCallOnlyDeployments = getMultiSendCallOnlyDeployments;
42
+ /**
43
+ * Get the CreateCall deployment based on the provided filter.
44
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
45
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
46
+ */
31
47
  const getCreateCallDeployment = (filter) => {
32
- return (0, utils_1.findDeployment)(filter, createCallDeployments);
48
+ return (0, utils_1.findDeployment)(filter, deployments_1._CREATE_CALL_DEPLOYMENTS);
33
49
  };
34
50
  exports.getCreateCallDeployment = getCreateCallDeployment;
35
- const signMessageLibDeployments = [sign_message_lib_json_2.default, sign_message_lib_json_1.default];
51
+ /**
52
+ * Get all CreateCall deployments based on the provided filter.
53
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
54
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
55
+ */
56
+ const getCreateCallDeployments = (filter) => {
57
+ return (0, utils_1.findDeployment)(filter, deployments_1._CREATE_CALL_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
58
+ };
59
+ exports.getCreateCallDeployments = getCreateCallDeployments;
60
+ /**
61
+ * Get the SignMessageLib deployment based on the provided filter.
62
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployment.
63
+ * @returns {SingletonDeployment | undefined} - The matched deployment or undefined if not found.
64
+ */
36
65
  const getSignMessageLibDeployment = (filter) => {
37
- return (0, utils_1.findDeployment)(filter, signMessageLibDeployments);
66
+ return (0, utils_1.findDeployment)(filter, deployments_1._SIGN_MESSAGE_LIB_DEPLOYMENTS);
38
67
  };
39
68
  exports.getSignMessageLibDeployment = getSignMessageLibDeployment;
69
+ /**
70
+ * Get all SignMessageLib deployments based on the provided filter.
71
+ * @param {DeploymentFilter} [filter] - The filter criteria for the deployments.
72
+ * @returns {SingletonDeploymentV2 | undefined} - The matched deployments or undefined if not found.
73
+ */
74
+ const getSignMessageLibDeployments = (filter) => {
75
+ return (0, utils_1.findDeployment)(filter, deployments_1._SIGN_MESSAGE_LIB_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
76
+ };
77
+ exports.getSignMessageLibDeployments = getSignMessageLibDeployments;
package/dist/safes.d.ts CHANGED
@@ -1,5 +1,25 @@
1
- import { DeploymentFilter, SingletonDeployment, SingletonDeploymentJSON } from './types';
2
- export declare const _safeDeployments: SingletonDeploymentJSON[];
1
+ import { DeploymentFilter, SingletonDeployment, SingletonDeploymentV2 } from './types';
2
+ /**
3
+ * Finds the latest safe singleton deployment that matches the given filter.
4
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployment.
5
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if no deployment matches the filter.
6
+ */
3
7
  export declare const getSafeSingletonDeployment: (filter?: DeploymentFilter) => SingletonDeployment | undefined;
4
- export declare const _safeL2Deployments: SingletonDeploymentJSON[];
8
+ /**
9
+ * Finds all safe singleton deployments that match the given filter.
10
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployments.
11
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments or undefined if no deployments match the filter.
12
+ */
13
+ export declare const getSafeSingletonDeployments: (filter?: DeploymentFilter) => SingletonDeploymentV2 | undefined;
14
+ /**
15
+ * Finds the latest safe L2 singleton deployment that matches the given filter.
16
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployment.
17
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if no deployment matches the filter.
18
+ */
5
19
  export declare const getSafeL2SingletonDeployment: (filter?: DeploymentFilter) => SingletonDeployment | undefined;
20
+ /**
21
+ * Finds all safe L2 singleton deployments that match the given filter.
22
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployments.
23
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments or undefined if no deployments match the filter.
24
+ */
25
+ export declare const getSafeL2SingletonDeployments: (filter?: DeploymentFilter) => SingletonDeploymentV2 | undefined;
package/dist/safes.js CHANGED
@@ -1,32 +1,41 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSafeL2SingletonDeployment = exports._safeL2Deployments = exports.getSafeSingletonDeployment = exports._safeDeployments = void 0;
7
- const safe_l2_json_1 = __importDefault(require("./assets/v1.4.1/safe_l2.json"));
8
- const safe_json_1 = __importDefault(require("./assets/v1.4.1/safe.json"));
9
- const gnosis_safe_l2_json_1 = __importDefault(require("./assets/v1.3.0/gnosis_safe_l2.json"));
10
- const gnosis_safe_json_1 = __importDefault(require("./assets/v1.3.0/gnosis_safe.json"));
11
- const gnosis_safe_json_2 = __importDefault(require("./assets/v1.2.0/gnosis_safe.json"));
12
- const gnosis_safe_json_3 = __importDefault(require("./assets/v1.1.1/gnosis_safe.json"));
13
- const gnosis_safe_json_4 = __importDefault(require("./assets/v1.0.0/gnosis_safe.json"));
3
+ exports.getSafeL2SingletonDeployments = exports.getSafeL2SingletonDeployment = exports.getSafeSingletonDeployments = exports.getSafeSingletonDeployment = void 0;
4
+ const deployments_1 = require("./deployments");
14
5
  const utils_1 = require("./utils");
15
- // This is a sorted array (newest to oldest), exported for tests
16
- exports._safeDeployments = [
17
- safe_json_1.default,
18
- gnosis_safe_json_1.default,
19
- gnosis_safe_json_2.default,
20
- gnosis_safe_json_3.default,
21
- gnosis_safe_json_4.default,
22
- ];
6
+ /**
7
+ * Finds the latest safe singleton deployment that matches the given filter.
8
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployment.
9
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if no deployment matches the filter.
10
+ */
23
11
  const getSafeSingletonDeployment = (filter) => {
24
- return (0, utils_1.findDeployment)(filter, exports._safeDeployments);
12
+ return (0, utils_1.findDeployment)(filter, deployments_1._SAFE_DEPLOYMENTS);
25
13
  };
26
14
  exports.getSafeSingletonDeployment = getSafeSingletonDeployment;
27
- // This is a sorted array (newest to oldest), exported for tests
28
- exports._safeL2Deployments = [safe_l2_json_1.default, gnosis_safe_l2_json_1.default];
15
+ /**
16
+ * Finds all safe singleton deployments that match the given filter.
17
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployments.
18
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments or undefined if no deployments match the filter.
19
+ */
20
+ const getSafeSingletonDeployments = (filter) => {
21
+ return (0, utils_1.findDeployment)(filter, deployments_1._SAFE_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
22
+ };
23
+ exports.getSafeSingletonDeployments = getSafeSingletonDeployments;
24
+ /**
25
+ * Finds the latest safe L2 singleton deployment that matches the given filter.
26
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployment.
27
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if no deployment matches the filter.
28
+ */
29
29
  const getSafeL2SingletonDeployment = (filter) => {
30
- return (0, utils_1.findDeployment)(filter, exports._safeL2Deployments);
30
+ return (0, utils_1.findDeployment)(filter, deployments_1._SAFE_L2_DEPLOYMENTS);
31
31
  };
32
32
  exports.getSafeL2SingletonDeployment = getSafeL2SingletonDeployment;
33
+ /**
34
+ * Finds all safe L2 singleton deployments that match the given filter.
35
+ * @param {DeploymentFilter} [filter] - The filter to apply when searching for the deployments.
36
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments or undefined if no deployments match the filter.
37
+ */
38
+ const getSafeL2SingletonDeployments = (filter) => {
39
+ return (0, utils_1.findDeployment)(filter, deployments_1._SAFE_L2_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
40
+ };
41
+ exports.getSafeL2SingletonDeployments = getSafeL2SingletonDeployments;
package/dist/types.d.ts CHANGED
@@ -1,15 +1,20 @@
1
- declare enum AddressType {
2
- CANONICAL = "canonical",
3
- EIP155 = "eip155",
4
- ZKSYNC = "zksync"
1
+ export type AddressType = 'canonical' | 'eip155' | 'zksync';
2
+ export declare const enum DeploymentFormats {
3
+ SINGLETON = "singleton",
4
+ MULTIPLE = "multiple"
5
5
  }
6
+ type AtLeastOne<T, U = {
7
+ [K in keyof T]: Pick<T, K>;
8
+ }> = Partial<T> & U[keyof U];
6
9
  export interface SingletonDeploymentJSON {
7
10
  released: boolean;
8
11
  contractName: string;
9
12
  version: string;
10
- codeHash: string;
11
- networkAddresses: Record<string, string | string[]>;
12
- addresses: Record<string, string>;
13
+ deployments: AtLeastOne<Record<AddressType, {
14
+ address: string;
15
+ codeHash: string;
16
+ }>>;
17
+ networkAddresses: Record<string, AddressType | AddressType[]>;
13
18
  abi: any[];
14
19
  }
15
20
  export interface SingletonDeployment {
@@ -17,8 +22,10 @@ export interface SingletonDeployment {
17
22
  released: boolean;
18
23
  contractName: string;
19
24
  version: string;
20
- codeHash: string;
21
- addresses: Record<string, string>;
25
+ deployments: AtLeastOne<Record<AddressType, {
26
+ address: string;
27
+ codeHash: string;
28
+ }>>;
22
29
  networkAddresses: Record<string, string>;
23
30
  abi: any[];
24
31
  }
@@ -26,10 +33,12 @@ export interface SingletonDeploymentV2 {
26
33
  released: boolean;
27
34
  contractName: string;
28
35
  version: string;
29
- codeHash: string;
36
+ deployments: AtLeastOne<Record<AddressType, {
37
+ address: string;
38
+ codeHash: string;
39
+ }>>;
30
40
  abi: any[];
31
- networkAddresses: Record<string, AddressType | AddressType[]>;
32
- addresses: Partial<Record<AddressType, string>>;
41
+ networkAddresses: Record<string, string | string[]>;
33
42
  }
34
43
  export interface DeploymentFilter {
35
44
  version?: string;
package/dist/types.js CHANGED
@@ -1,13 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var AddressType;
4
- (function (AddressType) {
5
- // The original address the contract was deployed on.
6
- // Starting with 1.4.1, the contracts are deployed with an EIP155-compatible transaction.
7
- AddressType["CANONICAL"] = "canonical";
8
- // An address that was deployed with a transaction compatible with the EIP155 standard.
9
- // The type is only used for 1.3.0 deployments.
10
- AddressType["EIP155"] = "eip155";
11
- // An address that is deployed to the ZkSync VM networks.
12
- AddressType["ZKSYNC"] = "zksync";
13
- })(AddressType || (AddressType = {}));
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- import { DeploymentFilter, SingletonDeployment, SingletonDeploymentJSON } from './types';
1
+ import { DeploymentFilter, SingletonDeployment, SingletonDeploymentJSON, DeploymentFormats, SingletonDeploymentV2 } from './types';
2
2
  /**
3
3
  * Finds a deployment that matches the given criteria.
4
+ * This function is implemented as a regular function to allow for overloading: https://github.com/microsoft/TypeScript/issues/33482
4
5
  *
5
6
  * @param {DeploymentFilter} [criteria=DEFAULT_FILTER] - The filter criteria to match deployments.
6
7
  * @param {SingletonDeploymentJSON[]} deployments - The list of deployment JSON objects to search.
7
8
  * @returns {SingletonDeployment | undefined} - The found deployment object or undefined if no match is found.
8
9
  */
9
- export declare const findDeployment: (criteria: DeploymentFilter | undefined, deployments: SingletonDeploymentJSON[]) => SingletonDeployment | undefined;
10
+ declare function findDeployment(criteria: DeploymentFilter | undefined, deployments: SingletonDeploymentJSON[], format?: DeploymentFormats.SINGLETON): SingletonDeployment | undefined;
11
+ declare function findDeployment(criteria: DeploymentFilter | undefined, deployments: SingletonDeploymentJSON[], format: DeploymentFormats.MULTIPLE): SingletonDeploymentV2 | undefined;
12
+ export { findDeployment };
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.findDeployment = void 0;
6
+ exports.findDeployment = findDeployment;
7
7
  const satisfies_1 = __importDefault(require("semver/functions/satisfies"));
8
8
  const DEFAULT_FILTER = { released: true };
9
9
  // The older JSON format had a `defaultAddress` field, which became obsolete due to EIP-155 enforcement and non-EVM compatible chains.
@@ -20,21 +20,38 @@ const mapJsonToDeploymentsFormatV1 = (deployment) => {
20
20
  const defaultAddressType = Array.isArray(deployment.networkAddresses[DEFAULT_NETWORK_CHAIN_ID])
21
21
  ? deployment.networkAddresses[DEFAULT_NETWORK_CHAIN_ID][0]
22
22
  : deployment.networkAddresses[DEFAULT_NETWORK_CHAIN_ID];
23
- const defaultAddress = deployment.addresses[defaultAddressType];
23
+ // The usage of non-null assertion below is safe, because we validate that the asset files are properly formed in tests
24
+ const defaultAddress = deployment.deployments[defaultAddressType].address;
24
25
  const networkAddresses = Object.fromEntries(Object.entries(deployment.networkAddresses).map(([chainId, addressTypes]) => [
25
26
  chainId,
26
- Array.isArray(addressTypes) ? deployment.addresses[addressTypes[0]] : deployment.addresses[addressTypes],
27
+ Array.isArray(addressTypes)
28
+ ? deployment.deployments[addressTypes[0]].address
29
+ : deployment.deployments[addressTypes].address,
27
30
  ]));
28
31
  return Object.assign(Object.assign({}, deployment), { defaultAddress, networkAddresses });
29
32
  };
30
33
  /**
31
- * Finds a deployment that matches the given criteria.
34
+ * Maps a SingletonDeploymentJSON object to a SingletonDeploymentV2 object.
35
+ *
36
+ * This function transforms the `networkAddresses` field of the deployment JSON object.
37
+ * It converts each entry in `networkAddresses` to an array of addresses, using the `addresses` field
38
+ * to resolve each address type.
32
39
  *
33
- * @param {DeploymentFilter} [criteria=DEFAULT_FILTER] - The filter criteria to match deployments.
34
- * @param {SingletonDeploymentJSON[]} deployments - The list of deployment JSON objects to search.
35
- * @returns {SingletonDeployment | undefined} - The found deployment object or undefined if no match is found.
40
+ * @param {SingletonDeploymentJSON} deployment - The deployment JSON object to map.
41
+ * @returns {SingletonDeploymentV2} - The mapped deployment object in V2 format.
36
42
  */
37
- const findDeployment = (criteria = DEFAULT_FILTER, deployments) => {
43
+ const mapJsonToDeploymentsFormatV2 = (deployment) => {
44
+ const newJson = Object.assign({}, deployment);
45
+ newJson.networkAddresses = Object.fromEntries(Object.entries(deployment.networkAddresses).map(([chainId, addressTypes]) => [
46
+ chainId,
47
+ (Array.isArray(addressTypes)
48
+ ? // The usage of non-null assertion below is safe, because we validate that the asset files are properly formed in tests
49
+ addressTypes.map((addressType) => deployment.deployments[addressType].address)
50
+ : deployment.deployments[addressTypes].address),
51
+ ]));
52
+ return newJson;
53
+ };
54
+ function findDeployment(criteria = DEFAULT_FILTER, deployments, format = "singleton" /* DeploymentFormats.SINGLETON */) {
38
55
  const { version, released, network } = Object.assign(Object.assign({}, DEFAULT_FILTER), criteria);
39
56
  const deploymentJson = deployments.find((deployment) => {
40
57
  if (version && !(0, satisfies_1.default)(deployment.version, version))
@@ -45,6 +62,12 @@ const findDeployment = (criteria = DEFAULT_FILTER, deployments) => {
45
62
  return false;
46
63
  return true;
47
64
  });
48
- return deploymentJson ? mapJsonToDeploymentsFormatV1(deploymentJson) : undefined;
49
- };
50
- exports.findDeployment = findDeployment;
65
+ if (!deploymentJson)
66
+ return undefined;
67
+ if (format === "multiple" /* DeploymentFormats.MULTIPLE */) {
68
+ return mapJsonToDeploymentsFormatV2(deploymentJson);
69
+ }
70
+ else {
71
+ return mapJsonToDeploymentsFormatV1(deploymentJson);
72
+ }
73
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@safe-global/safe-deployments",
3
- "version": "1.37.1",
3
+ "version": "1.37.2",
4
4
  "description": "Collection of Safe singleton deployments",
5
5
  "homepage": "https://github.com/safe-global/safe-deployments/",
6
6
  "license": "MIT",
@@ -8,18 +8,17 @@
8
8
  "typings": "dist/index.d.ts",
9
9
  "files": [
10
10
  "dist",
11
- "src",
12
- "test",
13
- "build"
11
+ "src"
14
12
  ],
15
13
  "scripts": {
16
14
  "build": "rimraf dist && tsc",
17
15
  "lint": "npm run lint:ts && npm run lint:json",
18
- "lint:ts": "eslint --max-warnings 0 src/",
16
+ "lint:ts": "eslint --max-warnings 0 src/ scripts/",
19
17
  "lint:json": "prettier -c src/assets/*/*.json",
20
18
  "lint:fix": "npm run lint:fix:ts && npm run lint:fix:json",
21
19
  "lint:fix:ts": "npm run lint:ts -- --fix",
22
20
  "lint:fix:json": "prettier -w src/assets/*/*.json",
21
+ "verify": "ts-node scripts/verify.ts",
23
22
  "prepack": "npm run build",
24
23
  "test": "jest"
25
24
  },
@@ -44,9 +43,11 @@
44
43
  "eslint": "^8.57.0",
45
44
  "eslint-config-prettier": "^9.1.0",
46
45
  "eslint-plugin-prettier": "^5.1.3",
46
+ "ethers": "^6.13.1",
47
47
  "jest": "^29.7.0",
48
48
  "prettier": "^3.3.2",
49
49
  "ts-jest": "^29.1.5",
50
+ "ts-node": "^10.9.2",
50
51
  "typescript": "^5.5.2",
51
52
  "typescript-eslint": "^7.14.1"
52
53
  },
@@ -3,9 +3,11 @@
3
3
  "released": true,
4
4
  "contractName": "GnosisSafe",
5
5
  "version": "1.0.0",
6
- "codeHash": "0xe1f1593df76e69abc2d692792c80f329457551d5e83dde597546a1d58764da80",
7
- "addresses": {
8
- "canonical": "0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A"
6
+ "deployments": {
7
+ "canonical": {
8
+ "address": "0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A",
9
+ "codeHash": "0xe1f1593df76e69abc2d692792c80f329457551d5e83dde597546a1d58764da80"
10
+ }
9
11
  },
10
12
  "networkAddresses": {
11
13
  "1": "0xb6029EA3B2c51D09a50B53CA8012FeEB05bDa35A",
@@ -3,9 +3,11 @@
3
3
  "released": true,
4
4
  "contractName": "ProxyFactory",
5
5
  "version": "1.0.0",
6
- "codeHash": "0x84a375ad96ab395850d46cd601ed6354d3cf3fb67cec0caf18f34af5c9d1a7f0",
7
- "addresses": {
8
- "canonical": "0x12302fE9c02ff50939BaAaaf415fc226C078613C"
6
+ "deployments": {
7
+ "canonical": {
8
+ "address": "0x12302fE9c02ff50939BaAaaf415fc226C078613C",
9
+ "codeHash": "0x84a375ad96ab395850d46cd601ed6354d3cf3fb67cec0caf18f34af5c9d1a7f0"
10
+ }
9
11
  },
10
12
  "networkAddresses": {
11
13
  "1": "0x12302fE9c02ff50939BaAaaf415fc226C078613C",
@@ -3,9 +3,11 @@
3
3
  "released": true,
4
4
  "contractName": "CreateAndAddModules",
5
5
  "version": "1.1.1",
6
- "codeHash": "0x83941bb48a3e3302a6e502e61513981ad02f3870f2d15e6d9cd301d616a0ba38",
7
- "addresses": {
8
- "canonical": "0xF61A721642B0c0C8b334bA3763BA1326F53798C0"
6
+ "deployments": {
7
+ "canonical": {
8
+ "address": "0xF61A721642B0c0C8b334bA3763BA1326F53798C0",
9
+ "codeHash": "0x83941bb48a3e3302a6e502e61513981ad02f3870f2d15e6d9cd301d616a0ba38"
10
+ }
9
11
  },
10
12
  "networkAddresses": {
11
13
  "1": "0xF61A721642B0c0C8b334bA3763BA1326F53798C0",
@@ -3,9 +3,11 @@
3
3
  "released": true,
4
4
  "contractName": "CreateCall",
5
5
  "version": "1.1.1",
6
- "codeHash": "0x9de5afc9afd2bc0e329d9b4fa34955da45bb8e11587c645c5ff5287d7507adeb",
7
- "addresses": {
8
- "canonical": "0x8538FcBccba7f5303d2C679Fa5d7A629A8c9bf4A"
6
+ "deployments": {
7
+ "canonical": {
8
+ "address": "0x8538FcBccba7f5303d2C679Fa5d7A629A8c9bf4A",
9
+ "codeHash": "0x9de5afc9afd2bc0e329d9b4fa34955da45bb8e11587c645c5ff5287d7507adeb"
10
+ }
9
11
  },
10
12
  "networkAddresses": {
11
13
  "1": "0x8538FcBccba7f5303d2C679Fa5d7A629A8c9bf4A",
@@ -3,9 +3,11 @@
3
3
  "released": true,
4
4
  "contractName": "DefaultCallbackHandler",
5
5
  "version": "1.1.1",
6
- "codeHash": "0x919a9f5dd111a01f7a8e4b1f5c6a972bb2d1441c67bdec71de6a09d0be92f5b9",
7
- "addresses": {
8
- "canonical": "0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44"
6
+ "deployments": {
7
+ "canonical": {
8
+ "address": "0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44",
9
+ "codeHash": "0x919a9f5dd111a01f7a8e4b1f5c6a972bb2d1441c67bdec71de6a09d0be92f5b9"
10
+ }
9
11
  },
10
12
  "networkAddresses": {
11
13
  "1": "0xd5D82B6aDDc9027B22dCA772Aa68D5d74cdBdF44",