@safe-global/safe-deployments 1.37.0 → 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 (112) hide show
  1. package/README.md +150 -31
  2. package/dist/accessors.d.ts +14 -1
  3. package/dist/accessors.js +19 -11
  4. package/dist/assets/v1.0.0/gnosis_safe.json +479 -103
  5. package/dist/assets/v1.0.0/proxy_factory.json +11 -6
  6. package/dist/assets/v1.1.1/default_callback_handler.json +14 -9
  7. package/dist/assets/v1.1.1/gnosis_safe.json +14 -9
  8. package/dist/assets/v1.1.1/multi_send.json +14 -9
  9. package/dist/assets/v1.1.1/proxy_factory.json +14 -9
  10. package/dist/assets/v1.2.0/gnosis_safe.json +14 -9
  11. package/dist/assets/v1.3.0/compatibility_fallback_handler.json +259 -235
  12. package/dist/assets/v1.3.0/create_call.json +259 -235
  13. package/dist/assets/v1.3.0/gnosis_safe.json +259 -235
  14. package/dist/assets/v1.3.0/gnosis_safe_l2.json +259 -235
  15. package/dist/assets/v1.3.0/multi_send.json +259 -235
  16. package/dist/assets/v1.3.0/multi_send_call_only.json +259 -235
  17. package/dist/assets/v1.3.0/proxy_factory.json +259 -235
  18. package/dist/assets/v1.3.0/sign_message_lib.json +260 -236
  19. package/dist/assets/v1.3.0/simulate_tx_accessor.json +259 -235
  20. package/dist/assets/v1.4.1/compatibility_fallback_handler.json +119 -108
  21. package/dist/assets/v1.4.1/create_call.json +119 -108
  22. package/dist/assets/v1.4.1/multi_send.json +119 -108
  23. package/dist/assets/v1.4.1/multi_send_call_only.json +119 -108
  24. package/dist/assets/v1.4.1/safe.json +119 -108
  25. package/dist/assets/v1.4.1/safe_l2.json +119 -108
  26. package/dist/assets/v1.4.1/safe_proxy_factory.json +120 -109
  27. package/dist/assets/v1.4.1/sign_message_lib.json +120 -109
  28. package/dist/assets/v1.4.1/simulate_tx_accessor.json +119 -108
  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 -13
  33. package/dist/handler.d.ts +29 -1
  34. package/dist/handler.js +55 -24
  35. package/dist/libs.d.ts +45 -1
  36. package/dist/libs.js +62 -32
  37. package/dist/safes.d.ts +23 -3
  38. package/dist/safes.js +32 -21
  39. package/dist/types.d.ts +37 -2
  40. package/dist/utils.d.ts +12 -2
  41. package/dist/utils.js +61 -9
  42. package/package.json +18 -19
  43. package/src/__tests__/assets/v1/v1.0.0/gnosis_safe.json +796 -0
  44. package/src/__tests__/assets/v1/v1.0.0/proxy_factory.json +111 -0
  45. package/src/__tests__/assets/v1/v1.1.1/create_and_add_modules.json +59 -0
  46. package/src/__tests__/assets/v1/v1.1.1/create_call.json +90 -0
  47. package/src/__tests__/assets/v1/v1.1.1/default_callback_handler.json +212 -0
  48. package/src/__tests__/assets/v1/v1.1.1/gnosis_safe.json +1001 -0
  49. package/src/__tests__/assets/v1/v1.1.1/multi_send.json +45 -0
  50. package/src/__tests__/assets/v1/v1.1.1/proxy_factory.json +191 -0
  51. package/src/__tests__/assets/v1/v1.2.0/gnosis_safe.json +1022 -0
  52. package/src/__tests__/assets/v1/v1.3.0/compatibility_fallback_handler.json +588 -0
  53. package/src/__tests__/assets/v1/v1.3.0/create_call.json +331 -0
  54. package/src/__tests__/assets/v1/v1.3.0/gnosis_safe.json +1296 -0
  55. package/src/__tests__/assets/v1/v1.3.0/gnosis_safe_l2.json +1401 -0
  56. package/src/__tests__/assets/v1/v1.3.0/multi_send.json +283 -0
  57. package/src/__tests__/assets/v1/v1.3.0/multi_send_call_only.json +278 -0
  58. package/src/__tests__/assets/v1/v1.3.0/proxy_factory.json +426 -0
  59. package/src/__tests__/assets/v1/v1.3.0/sign_message_lib.json +310 -0
  60. package/src/__tests__/assets/v1/v1.3.0/simulate_tx_accessor.json +314 -0
  61. package/src/__tests__/assets/v1/v1.4.1/compatibility_fallback_handler.json +447 -0
  62. package/src/__tests__/assets/v1/v1.4.1/create_call.json +192 -0
  63. package/src/__tests__/assets/v1/v1.4.1/multi_send.json +144 -0
  64. package/src/__tests__/assets/v1/v1.4.1/multi_send_call_only.json +139 -0
  65. package/src/__tests__/assets/v1/v1.4.1/safe.json +1123 -0
  66. package/src/__tests__/assets/v1/v1.4.1/safe_l2.json +1228 -0
  67. package/src/__tests__/assets/v1/v1.4.1/safe_proxy_factory.json +263 -0
  68. package/src/__tests__/assets/v1/v1.4.1/sign_message_lib.json +171 -0
  69. package/src/__tests__/assets/v1/v1.4.1/simulate_tx_accessor.json +175 -0
  70. package/src/__tests__/assets.test.ts +101 -38
  71. package/src/__tests__/factories.test.ts +3 -3
  72. package/src/__tests__/handler.test.ts +5 -5
  73. package/src/__tests__/libs.test.ts +9 -9
  74. package/src/__tests__/safes.test.ts +9 -12
  75. package/src/__tests__/utils.test.ts +421 -0
  76. package/src/accessors.ts +21 -12
  77. package/src/assets/v1.0.0/gnosis_safe.json +479 -103
  78. package/src/assets/v1.0.0/proxy_factory.json +11 -6
  79. package/src/assets/v1.1.1/create_and_add_modules.json +19 -10
  80. package/src/assets/v1.1.1/create_call.json +14 -9
  81. package/src/assets/v1.1.1/default_callback_handler.json +14 -9
  82. package/src/assets/v1.1.1/gnosis_safe.json +14 -9
  83. package/src/assets/v1.1.1/multi_send.json +14 -9
  84. package/src/assets/v1.1.1/proxy_factory.json +14 -9
  85. package/src/assets/v1.2.0/gnosis_safe.json +14 -9
  86. package/src/assets/v1.3.0/compatibility_fallback_handler.json +259 -235
  87. package/src/assets/v1.3.0/create_call.json +259 -235
  88. package/src/assets/v1.3.0/gnosis_safe.json +259 -235
  89. package/src/assets/v1.3.0/gnosis_safe_l2.json +259 -235
  90. package/src/assets/v1.3.0/multi_send.json +259 -235
  91. package/src/assets/v1.3.0/multi_send_call_only.json +259 -235
  92. package/src/assets/v1.3.0/proxy_factory.json +259 -235
  93. package/src/assets/v1.3.0/sign_message_lib.json +260 -236
  94. package/src/assets/v1.3.0/simulate_tx_accessor.json +259 -235
  95. package/src/assets/v1.4.1/compatibility_fallback_handler.json +119 -108
  96. package/src/assets/v1.4.1/create_call.json +119 -108
  97. package/src/assets/v1.4.1/multi_send.json +119 -108
  98. package/src/assets/v1.4.1/multi_send_call_only.json +119 -108
  99. package/src/assets/v1.4.1/safe.json +119 -108
  100. package/src/assets/v1.4.1/safe_l2.json +119 -108
  101. package/src/assets/v1.4.1/safe_proxy_factory.json +120 -109
  102. package/src/assets/v1.4.1/sign_message_lib.json +120 -109
  103. package/src/assets/v1.4.1/simulate_tx_accessor.json +119 -108
  104. package/src/deployments.ts +90 -0
  105. package/src/factories.ts +19 -14
  106. package/src/handler.ts +62 -26
  107. package/src/index.ts +6 -6
  108. package/src/libs.ts +69 -35
  109. package/src/safes.ts +34 -22
  110. package/src/types.ts +86 -10
  111. package/src/utils.ts +105 -12
  112. package/src/__tests__/utilts.test.ts +0 -385
package/README.md CHANGED
@@ -3,87 +3,206 @@
3
3
  [![npm version](https://badge.fury.io/js/%40safe-global%2Fsafe-deployments.svg)](https://badge.fury.io/js/%40safe-global%2Fsafe-deployments)
4
4
  [![CI](https://github.com/safe-global/safe-deployments/actions/workflows/test.yml/badge.svg)](https://github.com/safe-global/safe-deployments/actions/workflows/test.yml)
5
5
 
6
- This contract contains a collection of deployments of the contract of the [Safe contracts repository](https://github.com/safe-global/safe-contracts).
6
+ This contract contains a collection of deployments of the contract of the [Safe contracts repository](https://github.com/safe-global/safe-smart-account).
7
7
 
8
- For each deployment the address on the different networks and the abi files are available. To get an overview of the available versions check the available [json assets](./src/assets/).
8
+ The addresses on the different networks and the abi files are available for each deployment. To get an overview of the available versions, check the available [json assets](./src/assets/).
9
9
 
10
- To add additional deployments please follow the [deployment steps in the Safe contract repository](https://github.com/safe-global/safe-contracts#deployments).
10
+ ## Adding additional deployments:
11
+
12
+ 1. Follow the [deployment steps in the Safe contract repository](https://github.com/safe-global/safe-smart-contracts#deployments).
13
+ 2. Verify that the addresses match the expected address for each contract. You can find them under the "addresses" mapping in the respective JSON file in the [assets folder](./src/assets/).
14
+ 3. Create a PR adding the new deployment. Example PR can be found [here](https://github.com/safe-global/safe-deployments/pull/676).
11
15
 
12
16
  ## Install
17
+
13
18
  - npm - `npm i @safe-global/safe-deployments`
14
19
  - yarn - `yarn add @safe-global/safe-deployments`
15
20
 
16
21
  ## Usage
17
22
 
18
- It is possible to directly use the json files in the [assets folder](./src/assets/) that contain the addresses and abi definitions.
23
+ It is possible to directly use the JSON files in the [assets folder](./src/assets/) that contain the addresses and ABI definitions.
19
24
 
20
- An alternative is to use the JavaScript library methods to query the correct deployment. The library supports different methods to get the deployment of a specific contract.
25
+ An alternative is using JavaScript library methods to query the correct deployment. The library supports different methods to get the deployment of a specific contract.
21
26
 
22
- Each of the method takes an optional `DeploymentFilter` as a parameter.
27
+ Each of the methods takes an optional `DeploymentFilter` as a parameter.
23
28
 
24
29
  ```ts
25
30
  interface DeploymentFilter {
26
- version?: string,
27
- released?: boolean, // Defaults to true if no filter is specified
28
- network?: string // Chain id of the network
31
+ version?: string;
32
+ released?: boolean; // Defaults to true if no filter is specified
33
+ network?: string; // Chain id of the network
29
34
  }
30
35
  ```
31
36
 
32
- The method will return a `SingletonDeployment` object or `undefined` if no deployment was found for the specified filter.
37
+ ### V1 Methods (single deployments)
38
+
39
+ Those methods will return a `SingletonDeployment` object or `undefined` if no deployment was found for the specified filter.
40
+
41
+ ```ts
42
+ export interface SingletonDeployment {
43
+ // The default address of the deployment.
44
+ defaultAddress: string;
45
+
46
+ // Indicates if the deployment is released.
47
+ released: boolean;
48
+
49
+ // The name of the contract.
50
+ contractName: string;
51
+
52
+ // The version of the deployment.
53
+ version: string;
54
+
55
+ // The address & hash of the contract code, where the key is the deployment type.
56
+ // There could be multiple deployment types: canonical, eip155, zksync
57
+ // Possible addresses per version:
58
+ // 1.0.0: canonical
59
+ // 1.1.1: canonical
60
+ // 1.2.0: canonical
61
+ // 1.3.0: canonical, eip155, zksync
62
+ // 1.4.1: canonical, zksync
63
+ // Ex: deployments: { "canonical": { "codeHash": "0x1234", "address": "0x5678"}}
64
+ deployments: Record<string, { address: string; codeHash: string }>;
65
+
66
+ // A record of network addresses, where the key is the network identifier and the value is the address.
67
+ networkAddresses: Record<string, string>;
68
+
69
+ // The ABI (Application Binary Interface) of the contract.
70
+ abi: any[];
71
+ }
72
+ ```
73
+
74
+ - Safe
75
+
76
+ ```ts
77
+ const safeSingleton = getSafeSingletonDeployment();
78
+
79
+ // Returns latest contract version, even if not finally released yet
80
+ const safeSingletonNightly = getSafeSingletonDeployment({ released: undefined });
81
+
82
+ // Returns released contract version for specific network
83
+ const safeSingletonGörli = getSafeSingletonDeployment({ network: '5' });
84
+
85
+ // Returns released contract version for specific version
86
+ const safeSingleton100 = getSafeSingletonDeployment({ version: '1.0.0' });
87
+
88
+ // Version with additional events used on L2 networks
89
+ const safeL2Singleton = getSafeL2SingletonDeployment();
90
+ ```
91
+
92
+ - Factories
93
+
94
+ ```ts
95
+ const proxyFactory = getProxyFactoryDeployment();
96
+ ```
97
+
98
+ - Libraries
33
99
 
34
100
  ```ts
35
- interface SingletonDeployment {
36
- defaultAddress: string, // Address the contract was deployed to by the Safe team
37
- version: string,
38
- abi: any[],
39
- networkAddresses: Record<string, string>, // Address of the contract by network
40
- contractName: string,
41
- released: boolean // A released version was audited and has a running bug bounty
101
+ const multiSendLib = getMultiSendDeployment();
102
+
103
+ const multiSendCallOnlyLib = getMultiSendCallOnlyDeployment();
104
+
105
+ const createCallLib = getCreateCallDeployment();
106
+
107
+ const signMessageLib = getSignMessageLibDeployment();
108
+ ```
109
+
110
+ - Handler
111
+
112
+ ```ts
113
+
114
+ const callbackHandler = getDefaultCallbackHandlerDeployment();
115
+
116
+ const compatHandler = getCompatibilityFallbackHandlerDeployment();
117
+ ```
118
+
119
+ ### V2 Methods (multiple deployments)
120
+
121
+ We added a new methods that allow multiple deployment addresses for a contract.
122
+
123
+ Those methods will return a `SingletonDeployment` object or `undefined` if no deployment was found for the specified filter. Notice the difference in the `networkAddresses` field.
124
+
125
+ ```ts
126
+ export interface SingletonDeployment {
127
+ // The default address of the deployment.
128
+ defaultAddress: string;
129
+
130
+ // Indicates if the deployment is released.
131
+ released: boolean;
132
+
133
+ // The name of the contract.
134
+ contractName: string;
135
+
136
+ // The version of the deployment.
137
+ version: string;
138
+
139
+ // The address & hash of the contract code, where the key is the deployment type.
140
+ // There could be multiple deployment types: canonical, eip155, zksync
141
+ // Possible addresses per version:
142
+ // 1.0.0: canonical
143
+ // 1.1.1: canonical
144
+ // 1.2.0: canonical
145
+ // 1.3.0: canonical, eip155, zksync
146
+ // 1.4.1: canonical, zksync
147
+ // Ex: deployments: { "canonical": { "codeHash": "0x1234", "address": "0x5678"}}
148
+ deployments: Record<string, { address: string; codeHash: string }>;
149
+
150
+ // A record of network addresses, where the key is the network identifier and the value is the address.
151
+ networkAddresses: Record<string, string | string[]>;
152
+
153
+ // The ABI (Application Binary Interface) of the contract.
154
+ abi: any[];
42
155
  }
43
156
  ```
44
157
 
45
158
  - Safe
159
+
46
160
  ```ts
47
- const safeSingleton = getSafeSingletonDeployment()
161
+ const safeSingleton = getSafeSingletonDeployments();
48
162
 
49
163
  // Returns latest contract version, even if not finally released yet
50
- const safeSingletonNightly = getSafeSingletonDeployment({ released: undefined })
164
+ const safeSingletonNightly = getSafeSingletonDeployments({ released: undefined });
51
165
 
52
166
  // Returns released contract version for specific network
53
- const safeSingletonGörli = getSafeSingletonDeployment({ network: "5" })
167
+ const safeSingletonGörli = getSafeSingletonDeployments({ network: '5' });
54
168
 
55
169
  // Returns released contract version for specific version
56
- const safeSingleton100 = getSafeSingletonDeployment({ version: "1.0.0" })
170
+ const safeSingleton100 = getSafeSingletonDeployments({ version: '1.0.0' });
57
171
 
58
172
  // Version with additional events used on L2 networks
59
- const safeL2Singleton = getSafeL2SingletonDeployment()
173
+ const safeL2Singleton = getSafeL2SingletonDeployments();
60
174
  ```
61
175
 
62
176
  - Factories
177
+
63
178
  ```ts
64
- const proxyFactory = getProxyFactoryDeployment()
179
+ const proxyFactory = getProxyFactoryDeployments();
65
180
  ```
66
181
 
67
182
  - Libraries
183
+
68
184
  ```ts
69
- const multiSendLib = getMultiSendDeployment()
185
+ const multiSendLib = getMultiSendDeployments();
186
+
187
+ const multiSendCallOnlyLib = getMultiSendCallOnlyDeployments();
70
188
 
71
- const multiSendCallOnlyLib = getMultiSendCallOnlyDeployment()
189
+ const createCallLib = getCreateCallDeployments();
72
190
 
73
- const createCallLib = getCreateCallDeployment()
191
+ const signMessageLib = getSignMessageLibDeployments();
74
192
  ```
75
193
 
76
194
  - Handler
195
+
77
196
  ```ts
78
- // Returns recommended handler
79
- const fallbackHandler = getFallbackHandlerDeployment()
80
197
 
81
- const callbackHandler = getDefaultCallbackHandlerDeployment()
198
+ const callbackHandler = getDefaultCallbackHandlerDeployments();
82
199
 
83
- const compatHandler = getCompatibilityFallbackHandlerDeployment()
200
+ const compatHandler = getCompatibilityFallbackHandlerDeployments();
84
201
  ```
202
+
85
203
  ## Release cycle
86
- `safe-deployments` release cycle is once per month, except urgent issues that require immediate attention.
204
+
205
+ `safe-deployments` release cycle is once per month, except for urgent issues that require immediate attention.
87
206
 
88
207
  ## Notes
89
208
 
@@ -1,2 +1,15 @@
1
- import { DeploymentFilter, SingletonDeployment } from './types';
1
+ import { DeploymentFilter, SingletonDeployment, SingletonDeploymentV2 } from './types';
2
+ /**
3
+ * Retrieves a single simulate transaction accessor deployment based on the provided filter.
4
+ *
5
+ * @param {DeploymentFilter} [filter] - Optional filter to apply when searching for the deployment.
6
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if no deployment matches the filter.
7
+ */
2
8
  export declare const getSimulateTxAccessorDeployment: (filter?: DeploymentFilter) => SingletonDeployment | undefined;
9
+ /**
10
+ * Retrieves multiple simulate transaction accessor deployments based on the provided filter.
11
+ *
12
+ * @param {DeploymentFilter} [filter] - Optional filter to apply when searching for the deployments.
13
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments in the specified format or undefined if no deployments match the filter.
14
+ */
15
+ export declare const getSimulateTxAccessorDeployments: (filter?: DeploymentFilter) => SingletonDeploymentV2 | undefined;
package/dist/accessors.js CHANGED
@@ -1,17 +1,25 @@
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.getSimulateTxAccessorDeployment = void 0;
7
- const simulate_tx_accessor_json_1 = __importDefault(require("./assets/v1.3.0/simulate_tx_accessor.json"));
8
- const simulate_tx_accessor_json_2 = __importDefault(require("./assets/v1.4.1/simulate_tx_accessor.json"));
3
+ exports.getSimulateTxAccessorDeployments = exports.getSimulateTxAccessorDeployment = void 0;
9
4
  const utils_1 = require("./utils");
10
- // This is a sorted array (newest to oldest)
11
- const accessorDeployments = [
12
- simulate_tx_accessor_json_2.default, simulate_tx_accessor_json_1.default
13
- ];
5
+ const deployments_1 = require("./deployments");
6
+ /**
7
+ * Retrieves a single simulate transaction accessor deployment based on the provided filter.
8
+ *
9
+ * @param {DeploymentFilter} [filter] - Optional filter to apply when searching for the deployment.
10
+ * @returns {SingletonDeployment | undefined} - The found deployment or undefined if no deployment matches the filter.
11
+ */
14
12
  const getSimulateTxAccessorDeployment = (filter) => {
15
- return (0, utils_1.findDeployment)(filter, accessorDeployments);
13
+ return (0, utils_1.findDeployment)(filter, deployments_1._ACCESSOR_DEPLOYMENTS);
16
14
  };
17
15
  exports.getSimulateTxAccessorDeployment = getSimulateTxAccessorDeployment;
16
+ /**
17
+ * Retrieves multiple simulate transaction accessor deployments based on the provided filter.
18
+ *
19
+ * @param {DeploymentFilter} [filter] - Optional filter to apply when searching for the deployments.
20
+ * @returns {SingletonDeploymentV2 | undefined} - The found deployments in the specified format or undefined if no deployments match the filter.
21
+ */
22
+ const getSimulateTxAccessorDeployments = (filter) => {
23
+ return (0, utils_1.findDeployment)(filter, deployments_1._ACCESSOR_DEPLOYMENTS, "multiple" /* DeploymentFormats.MULTIPLE */);
24
+ };
25
+ exports.getSimulateTxAccessorDeployments = getSimulateTxAccessorDeployments;