@gearbox-protocol/deploy-tools 4.1.1-next.1 → 4.1.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.
Files changed (2) hide show
  1. package/dist/index.mjs +549 -108
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -137917,7 +137917,7 @@ var require_httpRequests = __commonJS({
137917
137917
  HttpMethod2["Get"] = "get";
137918
137918
  HttpMethod2["Post"] = "post";
137919
137919
  HttpMethod2["Delete"] = "delete";
137920
- })(HttpMethod = exports2.HttpMethod || (exports2.HttpMethod = {}));
137920
+ })(HttpMethod || (exports2.HttpMethod = HttpMethod = {}));
137921
137921
  async function sendRequest({ url: url2, method, body }) {
137922
137922
  const response = await (0, node_fetch_1.default)(url2, {
137923
137923
  method,
@@ -171363,8 +171363,11 @@ var require_re = __commonJS({
171363
171363
  createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
171364
171364
  createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
171365
171365
  createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
171366
- createToken("COERCE", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:$|[^\\d])`);
171366
+ createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
171367
+ createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
171368
+ createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
171367
171369
  createToken("COERCERTL", src[t.COERCE], true);
171370
+ createToken("COERCERTLFULL", src[t.COERCEFULL], true);
171368
171371
  createToken("LONETILDE", "(?:~>?)");
171369
171372
  createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
171370
171373
  exports2.tildeTrimReplace = "$1~";
@@ -183394,40 +183397,43 @@ var require_utils14 = __commonJS({
183394
183397
  ]);
183395
183398
  }
183396
183399
  exports2.encodeSetupCallData = encodeSetupCallData;
183397
- var memoizedGetProxyFactoryContract = (0, memoized_1.createMemoizedFunction)(safeDeploymentContracts_1.getProxyFactoryContract);
183398
- var memoizedGetSafeContract = (0, memoized_1.createMemoizedFunction)(safeDeploymentContracts_1.getSafeContract);
183399
- var memoizedGetProxyCreationCode = (0, memoized_1.createMemoizedFunction)(async ({ ethAdapter, safeVersion, customContracts }) => {
183400
+ var memoizedGetProxyFactoryContract = (0, memoized_1.createMemoizedFunction)(({ ethAdapter, safeVersion, customContracts }) => (0, safeDeploymentContracts_1.getProxyFactoryContract)({ ethAdapter, safeVersion, customContracts }));
183401
+ var memoizedGetProxyCreationCode = (0, memoized_1.createMemoizedFunction)(async ({ ethAdapter, safeVersion, customContracts, chainId }) => {
183400
183402
  const safeProxyFactoryContract = await memoizedGetProxyFactoryContract({
183401
183403
  ethAdapter,
183402
183404
  safeVersion,
183403
- customContracts
183405
+ customContracts,
183406
+ chainId
183404
183407
  });
183405
183408
  return safeProxyFactoryContract.proxyCreationCode();
183406
183409
  });
183410
+ var memoizedGetSafeContract = (0, memoized_1.createMemoizedFunction)(({ ethAdapter, safeVersion, isL1SafeSingleton, customContracts }) => (0, safeDeploymentContracts_1.getSafeContract)({ ethAdapter, safeVersion, isL1SafeSingleton, customContracts }));
183407
183411
  function getChainSpecificDefaultSaltNonce(chainId) {
183408
183412
  return `0x${Buffer.from((0, sha3_1.keccak_256)(exports2.PREDETERMINED_SALT_NONCE + chainId)).toString("hex")}`;
183409
183413
  }
183410
183414
  exports2.getChainSpecificDefaultSaltNonce = getChainSpecificDefaultSaltNonce;
183411
- async function predictSafeAddress({ ethAdapter, safeAccountConfig, safeDeploymentConfig = {}, isL1SafeSingleton = false, customContracts }) {
183415
+ async function predictSafeAddress({ ethAdapter, chainId, safeAccountConfig, safeDeploymentConfig = {}, isL1SafeSingleton = false, customContracts }) {
183412
183416
  (0, exports2.validateSafeAccountConfig)(safeAccountConfig);
183413
183417
  (0, exports2.validateSafeDeploymentConfig)(safeDeploymentConfig);
183414
- const chainId = await ethAdapter.getChainId();
183415
183418
  const { safeVersion = config_1.DEFAULT_SAFE_VERSION, saltNonce = getChainSpecificDefaultSaltNonce(chainId) } = safeDeploymentConfig;
183416
183419
  const safeProxyFactoryContract = await memoizedGetProxyFactoryContract({
183417
183420
  ethAdapter,
183418
183421
  safeVersion,
183419
- customContracts
183422
+ customContracts,
183423
+ chainId: chainId.toString()
183420
183424
  });
183421
183425
  const proxyCreationCode = await memoizedGetProxyCreationCode({
183422
183426
  ethAdapter,
183423
183427
  safeVersion,
183424
- customContracts
183428
+ customContracts,
183429
+ chainId: chainId.toString()
183425
183430
  });
183426
183431
  const safeContract = await memoizedGetSafeContract({
183427
183432
  ethAdapter,
183428
183433
  safeVersion,
183429
183434
  isL1SafeSingleton,
183430
- customContracts
183435
+ customContracts,
183436
+ chainId: chainId.toString()
183431
183437
  });
183432
183438
  const initializer = await encodeSetupCallData({
183433
183439
  ethAdapter,
@@ -194855,9 +194861,11 @@ var require_config2 = __commonJS({
194855
194861
  { chainId: 61n, shortName: "etc" },
194856
194862
  { chainId: 63n, shortName: "metc" },
194857
194863
  { chainId: 69n, shortName: "okov" },
194864
+ { chainId: 71n, shortName: "cfxtest" },
194858
194865
  { chainId: 81n, shortName: "joc" },
194859
194866
  { chainId: 82n, shortName: "meter" },
194860
194867
  { chainId: 83n, shortName: "meter-test" },
194868
+ { chainId: 88n, shortName: "tomo" },
194861
194869
  { chainId: 97n, shortName: "bnbt" },
194862
194870
  { chainId: 100n, shortName: "gno" },
194863
194871
  { chainId: 106n, shortName: "vlx" },
@@ -194868,8 +194876,11 @@ var require_config2 = __commonJS({
194868
194876
  { chainId: 137n, shortName: "matic" },
194869
194877
  { chainId: 148n, shortName: "shimmerevm-mainnet" },
194870
194878
  { chainId: 155n, shortName: "tenet-testnet" },
194879
+ { chainId: 169n, shortName: "manta" },
194880
+ { chainId: 204n, shortName: "opbnb" },
194871
194881
  { chainId: 246n, shortName: "ewt" },
194872
194882
  { chainId: 250n, shortName: "ftm" },
194883
+ { chainId: 255n, shortName: "kroma" },
194873
194884
  { chainId: 280n, shortName: "zksync-goerli" },
194874
194885
  { chainId: 288n, shortName: "boba" },
194875
194886
  { chainId: 291n, shortName: "orderly" },
@@ -194880,6 +194891,7 @@ var require_config2 = __commonJS({
194880
194891
  { chainId: 336n, shortName: "sdn" },
194881
194892
  { chainId: 338n, shortName: "tcro" },
194882
194893
  { chainId: 420n, shortName: "ogor" },
194894
+ { chainId: 424n, shortName: "PNG" },
194883
194895
  { chainId: 570n, shortName: "sys-rollux" },
194884
194896
  { chainId: 588n, shortName: "metis-stardust" },
194885
194897
  { chainId: 592n, shortName: "astr" },
@@ -194889,6 +194901,7 @@ var require_config2 = __commonJS({
194889
194901
  { chainId: 787n, shortName: "aca" },
194890
194902
  { chainId: 1001n, shortName: "baobab" },
194891
194903
  { chainId: 1008n, shortName: "eun" },
194904
+ { chainId: 1030n, shortName: "cfx" },
194892
194905
  { chainId: 1088n, shortName: "metis-andromeda" },
194893
194906
  { chainId: 1101n, shortName: "zkevm" },
194894
194907
  { chainId: 1111n, shortName: "wemix" },
@@ -194903,6 +194916,7 @@ var require_config2 = __commonJS({
194903
194916
  { chainId: 1294n, shortName: "bobabeam" },
194904
194917
  { chainId: 1442n, shortName: "testnet-zkEVM-mango" },
194905
194918
  { chainId: 1559n, shortName: "tenet" },
194919
+ { chainId: 1663n, shortName: "Gobi" },
194906
194920
  { chainId: 1807n, shortName: "rana" },
194907
194921
  { chainId: 1890n, shortName: "lightlink_phoenix" },
194908
194922
  { chainId: 1891n, shortName: "lightlink_pegasus" },
@@ -194915,8 +194929,10 @@ var require_config2 = __commonJS({
194915
194929
  { chainId: 2021n, shortName: "edg" },
194916
194930
  { chainId: 2221n, shortName: "tkava" },
194917
194931
  { chainId: 2222n, shortName: "kava" },
194932
+ { chainId: 2358n, shortName: "kroma-sepolia" },
194918
194933
  { chainId: 3737n, shortName: "csb" },
194919
194934
  { chainId: 4002n, shortName: "tftm" },
194935
+ { chainId: 4337n, shortName: "beam" },
194920
194936
  { chainId: 4460n, shortName: "orderlyl2" },
194921
194937
  { chainId: 4689n, shortName: "iotex-mainnet" },
194922
194938
  { chainId: 4918n, shortName: "txvm" },
@@ -194926,8 +194942,11 @@ var require_config2 = __commonJS({
194926
194942
  { chainId: 5700n, shortName: "tsys" },
194927
194943
  { chainId: 6102n, shortName: "cascadia" },
194928
194944
  { chainId: 7001n, shortName: "zetachain-athens" },
194945
+ { chainId: 7332n, shortName: "EON" },
194929
194946
  { chainId: 7341n, shortName: "shyft" },
194930
194947
  { chainId: 7700n, shortName: "canto" },
194948
+ { chainId: 8192n, shortName: "tqf" },
194949
+ { chainId: 8194n, shortName: "ttqf" },
194931
194950
  { chainId: 8217n, shortName: "cypress" },
194932
194951
  { chainId: 8453n, shortName: "base" },
194933
194952
  { chainId: 9000n, shortName: "evmos-testnet" },
@@ -194937,13 +194956,16 @@ var require_config2 = __commonJS({
194937
194956
  { chainId: 10001n, shortName: "smartbchtest" },
194938
194957
  { chainId: 10081n, shortName: "joct" },
194939
194958
  { chainId: 10200n, shortName: "chi" },
194959
+ { chainId: 10243n, shortName: "aa" },
194940
194960
  { chainId: 11235n, shortName: "islm" },
194941
194961
  { chainId: 11437n, shortName: "shyftt" },
194942
194962
  { chainId: 11891n, shortName: "Arianee" },
194943
194963
  { chainId: 12357n, shortName: "rei-testnet" },
194964
+ { chainId: 13337n, shortName: "beam-testnet" },
194944
194965
  { chainId: 17000n, shortName: "holesky" },
194945
194966
  { chainId: 23294n, shortName: "sapphire" },
194946
194967
  { chainId: 23295n, shortName: "sapphire-testnet" },
194968
+ { chainId: 34443n, shortName: "mode" },
194947
194969
  { chainId: 42161n, shortName: "arb1" },
194948
194970
  { chainId: 42170n, shortName: "arb-nova" },
194949
194971
  { chainId: 42220n, shortName: "celo" },
@@ -194956,13 +194978,15 @@ var require_config2 = __commonJS({
194956
194978
  { chainId: 54211n, shortName: "islmt" },
194957
194979
  { chainId: 56288n, shortName: "boba-bnb" },
194958
194980
  { chainId: 57000n, shortName: "tsys-rollux" },
194981
+ { chainId: 58008n, shortName: "sepPNG" },
194959
194982
  { chainId: 59140n, shortName: "linea-testnet" },
194960
194983
  { chainId: 59144n, shortName: "linea" },
194961
194984
  { chainId: 71401n, shortName: "gw-testnet-v1" },
194962
194985
  { chainId: 71402n, shortName: "gw-mainnet-v1" },
194963
194986
  { chainId: 73799n, shortName: "vt" },
194964
194987
  { chainId: 80001n, shortName: "maticmum" },
194965
- { chainId: 84531n, shortName: "base-gor" },
194988
+ { chainId: 84531n, shortName: "basegor" },
194989
+ { chainId: 84532n, shortName: "basesep" },
194966
194990
  { chainId: 200101n, shortName: "milktada" },
194967
194991
  { chainId: 200202n, shortName: "milktalgo" },
194968
194992
  { chainId: 333999n, shortName: "olympus" },
@@ -194975,8 +194999,10 @@ var require_config2 = __commonJS({
194975
194999
  { chainId: 622277n, shortName: "rth" },
194976
195000
  { chainId: 7777777n, shortName: "zora" },
194977
195001
  { chainId: 11155111n, shortName: "sep" },
195002
+ { chainId: 222000222n, shortName: "kanazawa" },
194978
195003
  { chainId: 245022926n, shortName: "neonevm-devnet" },
194979
195004
  { chainId: 245022934n, shortName: "neonevm-mainnet" },
195005
+ { chainId: 333000333n, shortName: "meld" },
194980
195006
  { chainId: 1313161554n, shortName: "aurora" },
194981
195007
  { chainId: 1313161555n, shortName: "aurora-testnet" },
194982
195008
  { chainId: 1666600000n, shortName: "hmy-s0" },
@@ -195053,7 +195079,8 @@ var require_eip_712 = __commonJS({
195053
195079
  return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
195054
195080
  };
195055
195081
  Object.defineProperty(exports2, "__esModule", { value: true });
195056
- exports2.generateTypedData = exports2.getEip712MessageTypes = exports2.EIP712_DOMAIN = exports2.EIP712_DOMAIN_BEFORE_V130 = void 0;
195082
+ exports2.generateTypedData = exports2.hashSafeMessage = exports2.hashTypedData = exports2.getEip712MessageTypes = exports2.getEip712TxTypes = exports2.EIP712_DOMAIN = exports2.EIP712_DOMAIN_BEFORE_V130 = void 0;
195083
+ var ethers_1 = require_lib228();
195057
195084
  var satisfies_1 = __importDefault2(require_satisfies());
195058
195085
  var EQ_OR_GT_1_3_0 = ">=1.3.0";
195059
195086
  exports2.EIP712_DOMAIN_BEFORE_V130 = [
@@ -195072,7 +195099,7 @@ var require_eip_712 = __commonJS({
195072
195099
  name: "verifyingContract"
195073
195100
  }
195074
195101
  ];
195075
- function getEip712MessageTypes(safeVersion) {
195102
+ function getEip712TxTypes(safeVersion) {
195076
195103
  const eip712WithChainId = (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0);
195077
195104
  return {
195078
195105
  EIP712Domain: eip712WithChainId ? exports2.EIP712_DOMAIN : exports2.EIP712_DOMAIN_BEFORE_V130,
@@ -195090,24 +195117,59 @@ var require_eip_712 = __commonJS({
195090
195117
  ]
195091
195118
  };
195092
195119
  }
195093
- exports2.getEip712MessageTypes = getEip712MessageTypes;
195094
- function generateTypedData({ safeAddress, safeVersion, chainId, safeTransactionData }) {
195120
+ exports2.getEip712TxTypes = getEip712TxTypes;
195121
+ function getEip712MessageTypes(safeVersion) {
195095
195122
  const eip712WithChainId = (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0);
195096
- const typedData = {
195097
- types: getEip712MessageTypes(safeVersion),
195098
- domain: {
195099
- verifyingContract: safeAddress
195100
- },
195101
- primaryType: "SafeTx",
195102
- message: {
195103
- ...safeTransactionData,
195104
- value: safeTransactionData.value,
195105
- safeTxGas: safeTransactionData.safeTxGas,
195106
- baseGas: safeTransactionData.baseGas,
195107
- gasPrice: safeTransactionData.gasPrice,
195108
- nonce: safeTransactionData.nonce
195109
- }
195123
+ return {
195124
+ EIP712Domain: eip712WithChainId ? exports2.EIP712_DOMAIN : exports2.EIP712_DOMAIN_BEFORE_V130,
195125
+ SafeMessage: [{ type: "bytes", name: "message" }]
195110
195126
  };
195127
+ }
195128
+ exports2.getEip712MessageTypes = getEip712MessageTypes;
195129
+ var hashTypedData = (typedData) => {
195130
+ const { EIP712Domain: _, ...types2 } = typedData.types;
195131
+ return ethers_1.ethers.TypedDataEncoder.hash(typedData.domain, types2, typedData.message);
195132
+ };
195133
+ exports2.hashTypedData = hashTypedData;
195134
+ var hashMessage2 = (message) => {
195135
+ return ethers_1.ethers.hashMessage(message);
195136
+ };
195137
+ var hashSafeMessage = (message) => {
195138
+ return typeof message === "string" ? hashMessage2(message) : (0, exports2.hashTypedData)(message);
195139
+ };
195140
+ exports2.hashSafeMessage = hashSafeMessage;
195141
+ function generateTypedData({ safeAddress, safeVersion, chainId, data }) {
195142
+ const isSafeTransactionDataType = data.hasOwnProperty("to");
195143
+ const eip712WithChainId = (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0);
195144
+ let typedData;
195145
+ if (isSafeTransactionDataType) {
195146
+ const txData = data;
195147
+ typedData = {
195148
+ types: getEip712TxTypes(safeVersion),
195149
+ domain: {
195150
+ verifyingContract: safeAddress
195151
+ },
195152
+ primaryType: "SafeTx",
195153
+ message: {
195154
+ ...txData,
195155
+ value: txData.value,
195156
+ safeTxGas: txData.safeTxGas,
195157
+ baseGas: txData.baseGas,
195158
+ gasPrice: txData.gasPrice,
195159
+ nonce: txData.nonce
195160
+ }
195161
+ };
195162
+ } else {
195163
+ const message = data;
195164
+ typedData = {
195165
+ types: getEip712MessageTypes(safeVersion),
195166
+ domain: {
195167
+ verifyingContract: safeAddress
195168
+ },
195169
+ primaryType: "SafeMessage",
195170
+ message: { message: (0, exports2.hashSafeMessage)(message) }
195171
+ };
195172
+ }
195111
195173
  if (eip712WithChainId) {
195112
195174
  typedData.domain.chainId = chainId.toString();
195113
195175
  }
@@ -195134,7 +195196,7 @@ var require_safeVersions = __commonJS({
195134
195196
  SAFE_FEATURES2["SAFE_FALLBACK_HANDLER"] = "SAFE_FALLBACK_HANDLER";
195135
195197
  SAFE_FEATURES2["ETH_SIGN"] = "ETH_SIGN";
195136
195198
  SAFE_FEATURES2["ACCOUNT_ABSTRACTION"] = "ACCOUNT_ABSTRACTION";
195137
- })(SAFE_FEATURES = exports2.SAFE_FEATURES || (exports2.SAFE_FEATURES = {}));
195199
+ })(SAFE_FEATURES || (exports2.SAFE_FEATURES = SAFE_FEATURES = {}));
195138
195200
  var SAFE_FEATURES_BY_VERSION = {
195139
195201
  [SAFE_FEATURES.SAFE_TX_GAS_OPTIONAL]: ">=1.3.0",
195140
195202
  [SAFE_FEATURES.SAFE_TX_GUARDS]: ">=1.3.0",
@@ -195166,16 +195228,20 @@ var require_SafeSignature = __commonJS({
195166
195228
  * @param signature - The Safe signature
195167
195229
  * @returns The Safe signature instance
195168
195230
  */
195169
- constructor(signer, signature) {
195231
+ constructor(signer, signature, isContractSignature = false) {
195170
195232
  this.signer = signer;
195171
195233
  this.data = signature;
195234
+ this.isContractSignature = isContractSignature;
195172
195235
  }
195173
195236
  /**
195174
195237
  * Returns the static part of the Safe signature.
195175
195238
  *
195176
195239
  * @returns The static part of the Safe signature
195177
195240
  */
195178
- staticPart() {
195241
+ staticPart(dynamicOffset) {
195242
+ if (this.isContractSignature) {
195243
+ return `${this.signer.slice(2).padStart(64, "0")}${dynamicOffset || ""}00`;
195244
+ }
195179
195245
  return this.data;
195180
195246
  }
195181
195247
  /**
@@ -195184,6 +195250,10 @@ var require_SafeSignature = __commonJS({
195184
195250
  * @returns The dynamic part of the Safe signature
195185
195251
  */
195186
195252
  dynamicPart() {
195253
+ if (this.isContractSignature) {
195254
+ const dynamicPartLength = (this.data.slice(2).length / 2).toString(16).padStart(64, "0");
195255
+ return `${dynamicPartLength}${this.data.slice(2)}`;
195256
+ }
195187
195257
  return "";
195188
195258
  }
195189
195259
  };
@@ -195191,15 +195261,39 @@ var require_SafeSignature = __commonJS({
195191
195261
  }
195192
195262
  });
195193
195263
 
195264
+ // ../../node_modules/@safe-global/protocol-kit/dist/src/types/index.js
195265
+ var require_types14 = __commonJS({
195266
+ "../../node_modules/@safe-global/protocol-kit/dist/src/types/index.js"(exports2) {
195267
+ "use strict";
195268
+ Object.defineProperty(exports2, "__esModule", { value: true });
195269
+ exports2.SigningMethod = void 0;
195270
+ var SigningMethod;
195271
+ (function(SigningMethod2) {
195272
+ SigningMethod2["ETH_SIGN"] = "eth_sign";
195273
+ SigningMethod2["ETH_SIGN_TYPED_DATA"] = "eth_signTypedData";
195274
+ SigningMethod2["ETH_SIGN_TYPED_DATA_V3"] = "eth_signTypedData_v3";
195275
+ SigningMethod2["ETH_SIGN_TYPED_DATA_V4"] = "eth_signTypedData_v4";
195276
+ SigningMethod2["SAFE_SIGNATURE"] = "safe_sign";
195277
+ })(SigningMethod || (exports2.SigningMethod = SigningMethod = {}));
195278
+ }
195279
+ });
195280
+
195194
195281
  // ../../node_modules/@safe-global/protocol-kit/dist/src/utils/signatures/utils.js
195195
195282
  var require_utils19 = __commonJS({
195196
195283
  "../../node_modules/@safe-global/protocol-kit/dist/src/utils/signatures/utils.js"(exports2) {
195197
195284
  "use strict";
195285
+ var __importDefault2 = exports2 && exports2.__importDefault || function(mod2) {
195286
+ return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
195287
+ };
195198
195288
  Object.defineProperty(exports2, "__esModule", { value: true });
195199
- exports2.generateEIP712Signature = exports2.generateSignature = exports2.adjustVInSignature = exports2.isTxHashSignedWithPrefix = exports2.generatePreValidatedSignature = void 0;
195289
+ exports2.calculateSafeMessageHash = exports2.calculateSafeTransactionHash = exports2.preimageSafeMessageHash = exports2.preimageSafeTransactionHash = exports2.buildSignatureBytes = exports2.buildContractSignature = exports2.generateEIP712Signature = exports2.generateSignature = exports2.adjustVInSignature = exports2.isTxHashSignedWithPrefix = exports2.generatePreValidatedSignature = void 0;
195290
+ var ethers_1 = require_lib228();
195200
195291
  var ethereumjs_util_1 = require_dist4();
195292
+ var satisfies_1 = __importDefault2(require_satisfies());
195201
195293
  var address_1 = require_address8();
195202
195294
  var SafeSignature_1 = require_SafeSignature();
195295
+ var eip_712_1 = require_eip_712();
195296
+ var types_1 = require_types14();
195203
195297
  function generatePreValidatedSignature(ownerAddress) {
195204
195298
  const signature = "0x000000000000000000000000" + ownerAddress.slice(2) + "000000000000000000000000000000000000000000000000000000000000000001";
195205
195299
  return new SafeSignature_1.EthSafeSignature(ownerAddress, signature);
@@ -195229,7 +195323,7 @@ var require_utils19 = __commonJS({
195229
195323
  if (!ETHEREUM_V_VALUES.includes(signatureV)) {
195230
195324
  throw new Error("Invalid signature");
195231
195325
  }
195232
- if (signingMethod === "eth_sign") {
195326
+ if (signingMethod === types_1.SigningMethod.ETH_SIGN) {
195233
195327
  if (signatureV < MIN_VALID_V_VALUE_FOR_SAFE_ECDSA) {
195234
195328
  signatureV += MIN_VALID_V_VALUE_FOR_SAFE_ECDSA;
195235
195329
  }
@@ -195239,7 +195333,7 @@ var require_utils19 = __commonJS({
195239
195333
  signatureV += 4;
195240
195334
  }
195241
195335
  }
195242
- if (signingMethod === "eth_signTypedData") {
195336
+ if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA) {
195243
195337
  if (signatureV < MIN_VALID_V_VALUE_FOR_SAFE_ECDSA) {
195244
195338
  signatureV += MIN_VALID_V_VALUE_FOR_SAFE_ECDSA;
195245
195339
  }
@@ -195254,20 +195348,67 @@ var require_utils19 = __commonJS({
195254
195348
  throw new Error("EthAdapter must be initialized with a signer to use this method");
195255
195349
  }
195256
195350
  let signature = await ethAdapter.signMessage(hash2);
195257
- signature = (0, exports2.adjustVInSignature)("eth_sign", signature, hash2, signerAddress);
195351
+ signature = (0, exports2.adjustVInSignature)(types_1.SigningMethod.ETH_SIGN, signature, hash2, signerAddress);
195258
195352
  return new SafeSignature_1.EthSafeSignature(signerAddress, signature);
195259
195353
  }
195260
195354
  exports2.generateSignature = generateSignature;
195261
- async function generateEIP712Signature(ethAdapter, safeTransactionEIP712Args, methodVersion) {
195355
+ async function generateEIP712Signature(ethAdapter, safeEIP712Args, methodVersion) {
195262
195356
  const signerAddress = await ethAdapter.getSignerAddress();
195263
195357
  if (!signerAddress) {
195264
195358
  throw new Error("EthAdapter must be initialized with a signer to use this method");
195265
195359
  }
195266
- let signature = await ethAdapter.signTypedData(safeTransactionEIP712Args, methodVersion);
195267
- signature = (0, exports2.adjustVInSignature)("eth_signTypedData", signature);
195360
+ let signature = await ethAdapter.signTypedData(safeEIP712Args, methodVersion);
195361
+ signature = (0, exports2.adjustVInSignature)(types_1.SigningMethod.ETH_SIGN_TYPED_DATA, signature);
195268
195362
  return new SafeSignature_1.EthSafeSignature(signerAddress, signature);
195269
195363
  }
195270
195364
  exports2.generateEIP712Signature = generateEIP712Signature;
195365
+ var buildContractSignature = async (signatures, signerSafeAddress) => {
195366
+ const contractSignature = new SafeSignature_1.EthSafeSignature(signerSafeAddress, (0, exports2.buildSignatureBytes)(signatures), true);
195367
+ return contractSignature;
195368
+ };
195369
+ exports2.buildContractSignature = buildContractSignature;
195370
+ var buildSignatureBytes = (signatures) => {
195371
+ const SIGNATURE_LENGTH_BYTES = 65;
195372
+ signatures.sort((left, right) => left.signer.toLowerCase().localeCompare(right.signer.toLowerCase()));
195373
+ let signatureBytes = "0x";
195374
+ let dynamicBytes = "";
195375
+ for (const signature of signatures) {
195376
+ if (signature.isContractSignature) {
195377
+ const dynamicPartPosition = (signatures.length * SIGNATURE_LENGTH_BYTES + dynamicBytes.length / 2).toString(16).padStart(64, "0");
195378
+ signatureBytes += signature.staticPart(dynamicPartPosition);
195379
+ dynamicBytes += signature.dynamicPart();
195380
+ } else {
195381
+ signatureBytes += signature.data.slice(2);
195382
+ }
195383
+ }
195384
+ return signatureBytes + dynamicBytes;
195385
+ };
195386
+ exports2.buildSignatureBytes = buildSignatureBytes;
195387
+ var preimageSafeTransactionHash = (safeAddress, safeTx, safeVersion, chainId) => {
195388
+ const safeTxTypes = (0, eip_712_1.getEip712TxTypes)(safeVersion);
195389
+ return ethers_1.ethers.TypedDataEncoder.encode({ verifyingContract: safeAddress, chainId }, { SafeTx: safeTxTypes.SafeTx }, safeTx);
195390
+ };
195391
+ exports2.preimageSafeTransactionHash = preimageSafeTransactionHash;
195392
+ var preimageSafeMessageHash = (safeAddress, message, safeVersion, chainId) => {
195393
+ const safeMessageTypes = (0, eip_712_1.getEip712MessageTypes)(safeVersion);
195394
+ return ethers_1.ethers.TypedDataEncoder.encode({ verifyingContract: safeAddress, chainId }, { SafeMessage: safeMessageTypes.SafeMessage }, { message });
195395
+ };
195396
+ exports2.preimageSafeMessageHash = preimageSafeMessageHash;
195397
+ var EQ_OR_GT_1_3_0 = ">=1.3.0";
195398
+ var calculateSafeTransactionHash = (safeAddress, safeTx, safeVersion, chainId) => {
195399
+ const safeTxTypes = (0, eip_712_1.getEip712TxTypes)(safeVersion);
195400
+ const domain = { verifyingContract: safeAddress };
195401
+ if ((0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0)) {
195402
+ domain.chainId = chainId;
195403
+ }
195404
+ return ethers_1.ethers.TypedDataEncoder.hash(domain, { SafeTx: safeTxTypes.SafeTx }, safeTx);
195405
+ };
195406
+ exports2.calculateSafeTransactionHash = calculateSafeTransactionHash;
195407
+ var calculateSafeMessageHash = (safeAddress, message, safeVersion, chainId) => {
195408
+ const safeMessageTypes = (0, eip_712_1.getEip712MessageTypes)(safeVersion);
195409
+ return ethers_1.ethers.TypedDataEncoder.hash({ verifyingContract: safeAddress, chainId }, { SafeMessage: safeMessageTypes.SafeMessage }, { message });
195410
+ };
195411
+ exports2.calculateSafeMessageHash = calculateSafeMessageHash;
195271
195412
  }
195272
195413
  });
195273
195414
 
@@ -195613,27 +195754,20 @@ var require_SafeTransaction = __commonJS({
195613
195754
  "../../node_modules/@safe-global/protocol-kit/dist/src/utils/transactions/SafeTransaction.js"(exports2) {
195614
195755
  "use strict";
195615
195756
  Object.defineProperty(exports2, "__esModule", { value: true });
195757
+ var signatures_1 = require_signatures();
195616
195758
  var EthSafeTransaction = class {
195617
195759
  constructor(data) {
195618
195760
  this.signatures = /* @__PURE__ */ new Map();
195619
195761
  this.data = data;
195620
195762
  }
195763
+ getSignature(signer) {
195764
+ return this.signatures.get(signer.toLowerCase());
195765
+ }
195621
195766
  addSignature(signature) {
195622
195767
  this.signatures.set(signature.signer.toLowerCase(), signature);
195623
195768
  }
195624
195769
  encodedSignatures() {
195625
- const signers = Array.from(this.signatures.keys()).sort();
195626
- const baseOffset = signers.length * 65;
195627
- let staticParts = "";
195628
- let dynamicParts = "";
195629
- signers.forEach((signerAddress) => {
195630
- const signature = this.signatures.get(signerAddress);
195631
- staticParts += signature?.staticPart(
195632
- /*baseOffset + dynamicParts.length / 2*/
195633
- ).slice(2);
195634
- dynamicParts += signature?.dynamicPart();
195635
- });
195636
- return "0x" + staticParts + dynamicParts;
195770
+ return (0, signatures_1.buildSignatureBytes)(Array.from(this.signatures.values()));
195637
195771
  }
195638
195772
  };
195639
195773
  exports2.default = EthSafeTransaction;
@@ -195641,7 +195775,7 @@ var require_SafeTransaction = __commonJS({
195641
195775
  });
195642
195776
 
195643
195777
  // ../../node_modules/@safe-global/protocol-kit/dist/src/utils/transactions/types.js
195644
- var require_types14 = __commonJS({
195778
+ var require_types15 = __commonJS({
195645
195779
  "../../node_modules/@safe-global/protocol-kit/dist/src/utils/transactions/types.js"(exports2) {
195646
195780
  "use strict";
195647
195781
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -195788,7 +195922,7 @@ var require_transactions = __commonJS({
195788
195922
  Object.defineProperty(exports2, "__esModule", { value: true });
195789
195923
  __exportStar2(require_gas(), exports2);
195790
195924
  __exportStar2(require_SafeTransaction(), exports2);
195791
- __exportStar2(require_types14(), exports2);
195925
+ __exportStar2(require_types15(), exports2);
195792
195926
  __exportStar2(require_utils20(), exports2);
195793
195927
  }
195794
195928
  });
@@ -196218,6 +196352,31 @@ var require_ownerManager = __commonJS({
196218
196352
  }
196219
196353
  });
196220
196354
 
196355
+ // ../../node_modules/@safe-global/protocol-kit/dist/src/utils/messages/SafeMessage.js
196356
+ var require_SafeMessage = __commonJS({
196357
+ "../../node_modules/@safe-global/protocol-kit/dist/src/utils/messages/SafeMessage.js"(exports2) {
196358
+ "use strict";
196359
+ Object.defineProperty(exports2, "__esModule", { value: true });
196360
+ var signatures_1 = require_signatures();
196361
+ var EthSafeMessage = class {
196362
+ constructor(data) {
196363
+ this.signatures = /* @__PURE__ */ new Map();
196364
+ this.data = data;
196365
+ }
196366
+ getSignature(signer) {
196367
+ return this.signatures.get(signer.toLowerCase());
196368
+ }
196369
+ addSignature(signature) {
196370
+ this.signatures.set(signature.signer.toLowerCase(), signature);
196371
+ }
196372
+ encodedSignatures() {
196373
+ return (0, signatures_1.buildSignatureBytes)(Array.from(this.signatures.values()));
196374
+ }
196375
+ };
196376
+ exports2.default = EthSafeMessage;
196377
+ }
196378
+ });
196379
+
196221
196380
  // ../../node_modules/@safe-global/protocol-kit/dist/src/Safe.js
196222
196381
  var require_Safe = __commonJS({
196223
196382
  "../../node_modules/@safe-global/protocol-kit/dist/src/Safe.js"(exports2) {
@@ -196248,6 +196407,8 @@ var require_Safe = __commonJS({
196248
196407
  var _Safe_moduleManager;
196249
196408
  var _Safe_guardManager;
196250
196409
  var _Safe_fallbackHandlerManager;
196410
+ var _Safe_MAGIC_VALUE;
196411
+ var _Safe_MAGIC_VALUE_BYTES;
196251
196412
  Object.defineProperty(exports2, "__esModule", { value: true });
196252
196413
  var safe_core_sdk_types_1 = require_src3();
196253
196414
  var utils_1 = require_utils14();
@@ -196257,12 +196418,16 @@ var require_Safe = __commonJS({
196257
196418
  var guardManager_1 = __importDefault2(require_guardManager());
196258
196419
  var moduleManager_1 = __importDefault2(require_moduleManager());
196259
196420
  var ownerManager_1 = __importDefault2(require_ownerManager());
196421
+ var types_1 = require_types14();
196260
196422
  var utils_2 = require_utils21();
196261
- var utils_3 = require_utils19();
196262
196423
  var SafeTransaction_1 = __importDefault2(require_SafeTransaction());
196263
- var utils_4 = require_utils20();
196264
- var types_1 = require_types12();
196424
+ var utils_3 = require_utils20();
196425
+ var types_2 = require_types12();
196265
196426
  var safeDeploymentContracts_1 = require_safeDeploymentContracts();
196427
+ var SafeMessage_1 = __importDefault2(require_SafeMessage());
196428
+ var satisfies_1 = __importDefault2(require_satisfies());
196429
+ var EQ_OR_GT_1_4_1 = ">=1.4.1";
196430
+ var EQ_OR_GT_1_3_0 = ">=1.3.0";
196266
196431
  var Safe = class _Safe {
196267
196432
  constructor() {
196268
196433
  _Safe_predictedSafe.set(this, void 0);
@@ -196272,6 +196437,56 @@ var require_Safe = __commonJS({
196272
196437
  _Safe_moduleManager.set(this, void 0);
196273
196438
  _Safe_guardManager.set(this, void 0);
196274
196439
  _Safe_fallbackHandlerManager.set(this, void 0);
196440
+ _Safe_MAGIC_VALUE.set(this, "0x1626ba7e");
196441
+ _Safe_MAGIC_VALUE_BYTES.set(
196442
+ this,
196443
+ "0x20c13b0b"
196444
+ /**
196445
+ * Creates an instance of the Safe Core SDK.
196446
+ * @param config - Ethers Safe configuration
196447
+ * @returns The Safe Core SDK instance
196448
+ * @throws "The SDK must be initialized with a safeAddress or a predictedSafe"
196449
+ * @throws "SafeProxy contract is not deployed on the current network"
196450
+ * @throws "MultiSend contract is not deployed on the current network"
196451
+ * @throws "MultiSendCallOnly contract is not deployed on the current network"
196452
+ */
196453
+ );
196454
+ this.getSafeMessageHash = async (messageHash) => {
196455
+ const safeAddress = await this.getAddress();
196456
+ const safeVersion = await this.getContractVersion();
196457
+ const chainId = await this.getChainId();
196458
+ return (0, utils_2.calculateSafeMessageHash)(safeAddress, messageHash, safeVersion, chainId);
196459
+ };
196460
+ this.isValidSignature = async (messageHash, signature = "0x") => {
196461
+ const safeAddress = await this.getAddress();
196462
+ const fallbackHandler = await this.getFallbackHandlerContract();
196463
+ const signatureToCheck = signature && Array.isArray(signature) ? (0, utils_2.buildSignatureBytes)(signature) : signature;
196464
+ const data = fallbackHandler.encode("isValidSignature(bytes32,bytes)", [
196465
+ messageHash,
196466
+ signatureToCheck
196467
+ ]);
196468
+ const bytesData = fallbackHandler.encode("isValidSignature(bytes,bytes)", [
196469
+ messageHash,
196470
+ signatureToCheck
196471
+ ]);
196472
+ try {
196473
+ const isValidSignatureResponse = await Promise.all([
196474
+ __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").call({
196475
+ from: safeAddress,
196476
+ to: safeAddress,
196477
+ data
196478
+ }),
196479
+ __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").call({
196480
+ from: safeAddress,
196481
+ to: safeAddress,
196482
+ data: bytesData
196483
+ })
196484
+ ]);
196485
+ return !!isValidSignatureResponse.length && (isValidSignatureResponse[0].slice(0, 10).toLowerCase() === __classPrivateFieldGet2(this, _Safe_MAGIC_VALUE, "f") || isValidSignatureResponse[1].slice(0, 10).toLowerCase() === __classPrivateFieldGet2(this, _Safe_MAGIC_VALUE_BYTES, "f"));
196486
+ } catch (error) {
196487
+ return false;
196488
+ }
196489
+ };
196275
196490
  }
196276
196491
  /**
196277
196492
  * Creates an instance of the Safe Core SDK.
@@ -196298,7 +196513,7 @@ var require_Safe = __commonJS({
196298
196513
  async init(config) {
196299
196514
  const { ethAdapter, isL1SafeSingleton, contractNetworks } = config;
196300
196515
  __classPrivateFieldSet2(this, _Safe_ethAdapter, ethAdapter, "f");
196301
- if ((0, types_1.isSafeConfigWithPredictedSafe)(config)) {
196516
+ if ((0, types_2.isSafeConfigWithPredictedSafe)(config)) {
196302
196517
  __classPrivateFieldSet2(this, _Safe_predictedSafe, config.predictedSafe, "f");
196303
196518
  __classPrivateFieldSet2(this, _Safe_contractManager, await contractManager_1.default.create({
196304
196519
  ethAdapter: __classPrivateFieldGet2(this, _Safe_ethAdapter, "f"),
@@ -196371,6 +196586,7 @@ var require_Safe = __commonJS({
196371
196586
  const chainId = await __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").getChainId();
196372
196587
  return (0, utils_1.predictSafeAddress)({
196373
196588
  ethAdapter: __classPrivateFieldGet2(this, _Safe_ethAdapter, "f"),
196589
+ chainId,
196374
196590
  customContracts: __classPrivateFieldGet2(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()],
196375
196591
  ...__classPrivateFieldGet2(this, _Safe_predictedSafe, "f")
196376
196592
  });
@@ -196549,7 +196765,7 @@ var require_Safe = __commonJS({
196549
196765
  let newTransaction;
196550
196766
  if (transactions.length > 1) {
196551
196767
  const multiSendContract = onlyCalls ? __classPrivateFieldGet2(this, _Safe_contractManager, "f").multiSendCallOnlyContract : __classPrivateFieldGet2(this, _Safe_contractManager, "f").multiSendContract;
196552
- const multiSendData = (0, utils_4.encodeMultiSendData)(transactions.map(utils_4.standardizeMetaTransactionData));
196768
+ const multiSendData = (0, utils_3.encodeMultiSendData)(transactions.map(utils_3.standardizeMetaTransactionData));
196553
196769
  const multiSendTransaction = {
196554
196770
  ...options,
196555
196771
  to: await multiSendContract.getAddress(),
@@ -196562,7 +196778,7 @@ var require_Safe = __commonJS({
196562
196778
  newTransaction = { ...options, ...transactions[0] };
196563
196779
  }
196564
196780
  if (__classPrivateFieldGet2(this, _Safe_predictedSafe, "f")) {
196565
- return new SafeTransaction_1.default(await (0, utils_4.standardizeSafeTransactionData)({
196781
+ return new SafeTransaction_1.default(await (0, utils_3.standardizeSafeTransactionData)({
196566
196782
  predictedSafe: __classPrivateFieldGet2(this, _Safe_predictedSafe, "f"),
196567
196783
  ethAdapter: __classPrivateFieldGet2(this, _Safe_ethAdapter, "f"),
196568
196784
  tx: newTransaction,
@@ -196572,7 +196788,7 @@ var require_Safe = __commonJS({
196572
196788
  if (!__classPrivateFieldGet2(this, _Safe_contractManager, "f").safeContract) {
196573
196789
  throw new Error("Safe is not deployed");
196574
196790
  }
196575
- return new SafeTransaction_1.default(await (0, utils_4.standardizeSafeTransactionData)({
196791
+ return new SafeTransaction_1.default(await (0, utils_3.standardizeSafeTransactionData)({
196576
196792
  safeContract: __classPrivateFieldGet2(this, _Safe_contractManager, "f").safeContract,
196577
196793
  ethAdapter: __classPrivateFieldGet2(this, _Safe_ethAdapter, "f"),
196578
196794
  tx: newTransaction,
@@ -196624,15 +196840,13 @@ var require_Safe = __commonJS({
196624
196840
  * Returns the transaction hash of a Safe transaction.
196625
196841
  *
196626
196842
  * @param safeTransaction - The Safe transaction
196627
- * @returns The transaction hash of the Safe transaction
196843
+ * @returns The hash of the Safe transaction
196628
196844
  */
196629
196845
  async getTransactionHash(safeTransaction) {
196630
- if (!__classPrivateFieldGet2(this, _Safe_contractManager, "f").safeContract) {
196631
- throw new Error("Safe is not deployed");
196632
- }
196633
- const safeTransactionData = safeTransaction.data;
196634
- const txHash = await __classPrivateFieldGet2(this, _Safe_contractManager, "f").safeContract.getTransactionHash(safeTransactionData);
196635
- return txHash;
196846
+ const safeAddress = await this.getAddress();
196847
+ const safeVersion = await this.getContractVersion();
196848
+ const chainId = await this.getChainId();
196849
+ return (0, utils_2.calculateSafeTransactionHash)(safeAddress, safeTransaction.data, safeVersion, chainId);
196636
196850
  }
196637
196851
  /**
196638
196852
  * Signs a hash using the current signer account.
@@ -196640,34 +196854,101 @@ var require_Safe = __commonJS({
196640
196854
  * @param hash - The hash to sign
196641
196855
  * @returns The Safe signature
196642
196856
  */
196643
- async signTransactionHash(hash2) {
196644
- return (0, utils_3.generateSignature)(__classPrivateFieldGet2(this, _Safe_ethAdapter, "f"), hash2);
196857
+ async signHash(hash2) {
196858
+ const signature = await (0, utils_2.generateSignature)(__classPrivateFieldGet2(this, _Safe_ethAdapter, "f"), hash2);
196859
+ return signature;
196860
+ }
196861
+ /**
196862
+ * Returns a Safe message ready to be signed by the owners.
196863
+ *
196864
+ * @param message - The message
196865
+ * @returns The Safe message
196866
+ */
196867
+ createMessage(message) {
196868
+ return new SafeMessage_1.default(message);
196869
+ }
196870
+ /**
196871
+ * Returns the Safe message with a new signature
196872
+ *
196873
+ * @param message The message to be signed
196874
+ * @param signingMethod The signature type
196875
+ * @param preimageSafeAddress If the preimage is required, the address of the Safe that will be used to calculate the preimage.
196876
+ * This field is mandatory for 1.4.1 contract versions Because the safe uses the old EIP-1271 interface which uses `bytes` instead of `bytes32` for the message
196877
+ * we need to use the pre-image of the message to calculate the message hash
196878
+ * https://github.com/safe-global/safe-contracts/blob/192c7dc67290940fcbc75165522bb86a37187069/test/core/Safe.Signatures.spec.ts#L229-L233
196879
+ * @returns The signed Safe message
196880
+ */
196881
+ async signMessage(message, signingMethod = types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4, preimageSafeAddress) {
196882
+ const owners = await this.getOwners();
196883
+ const signerAddress = await __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").getSignerAddress();
196884
+ if (!signerAddress) {
196885
+ throw new Error("EthAdapter must be initialized with a signer to use this method");
196886
+ }
196887
+ const addressIsOwner = owners.some((owner) => signerAddress && (0, utils_2.sameString)(owner, signerAddress));
196888
+ if (!addressIsOwner) {
196889
+ throw new Error("Messages can only be signed by Safe owners");
196890
+ }
196891
+ const safeVersion = await this.getContractVersion();
196892
+ if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE && (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_4_1) && !preimageSafeAddress) {
196893
+ throw new Error("The parent Safe account address is mandatory for contract signatures");
196894
+ }
196895
+ let signature;
196896
+ if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4) {
196897
+ signature = await this.signTypedData(message, "v4");
196898
+ } else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V3) {
196899
+ signature = await this.signTypedData(message, "v3");
196900
+ } else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA) {
196901
+ signature = await this.signTypedData(message, void 0);
196902
+ } else {
196903
+ const chainId = await this.getChainId();
196904
+ if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ETH_SIGN, safeVersion)) {
196905
+ throw new Error("eth_sign is only supported by Safes >= v1.1.0");
196906
+ }
196907
+ let safeMessageHash;
196908
+ if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE && preimageSafeAddress && (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_4_1)) {
196909
+ const messageHashData = (0, utils_2.preimageSafeMessageHash)(preimageSafeAddress, (0, utils_2.hashSafeMessage)(message.data), safeVersion, chainId);
196910
+ safeMessageHash = await this.getSafeMessageHash(messageHashData);
196911
+ } else {
196912
+ safeMessageHash = await this.getSafeMessageHash((0, utils_2.hashSafeMessage)(message.data));
196913
+ }
196914
+ signature = await this.signHash(safeMessageHash);
196915
+ }
196916
+ const signedSafeMessage = this.createMessage(message.data);
196917
+ message.signatures.forEach((signature2) => {
196918
+ signedSafeMessage.addSignature(signature2);
196919
+ });
196920
+ signedSafeMessage.addSignature(signature);
196921
+ return signedSafeMessage;
196645
196922
  }
196646
196923
  /**
196647
196924
  * Signs a transaction according to the EIP-712 using the current signer account.
196648
196925
  *
196649
- * @param safeTransaction - The Safe transaction to be signed
196926
+ * @param eip712Data - The Safe Transaction or message hash to be signed
196650
196927
  * @param methodVersion - EIP-712 version. Optional
196651
196928
  * @returns The Safe signature
196652
196929
  */
196653
- async signTypedData(safeTransaction, methodVersion) {
196654
- const safeTransactionEIP712Args = {
196930
+ async signTypedData(eip712Data, methodVersion) {
196931
+ const safeEIP712Args = {
196655
196932
  safeAddress: await this.getAddress(),
196656
196933
  safeVersion: await this.getContractVersion(),
196657
196934
  chainId: await this.getEthAdapter().getChainId(),
196658
- safeTransactionData: safeTransaction.data
196935
+ data: eip712Data.data
196659
196936
  };
196660
- return (0, utils_3.generateEIP712Signature)(__classPrivateFieldGet2(this, _Safe_ethAdapter, "f"), safeTransactionEIP712Args, methodVersion);
196937
+ return (0, utils_2.generateEIP712Signature)(__classPrivateFieldGet2(this, _Safe_ethAdapter, "f"), safeEIP712Args, methodVersion);
196661
196938
  }
196662
196939
  /**
196663
196940
  * Adds the signature of the current signer to the Safe transaction object.
196664
196941
  *
196665
196942
  * @param safeTransaction - The Safe transaction to be signed
196666
196943
  * @param signingMethod - Method followed to sign a transaction. Optional. Default value is "eth_sign"
196944
+ * @param preimageSafeAddress - If the preimage is required, the address of the Safe that will be used to calculate the preimage
196945
+ * This field is mandatory for 1.3.0 and 1.4.1 contract versions Because the safe uses the old EIP-1271 interface which uses `bytes` instead of `bytes32` for the message
196946
+ * we need to use the pre-image of the message to calculate the message hash
196947
+ * https://github.com/safe-global/safe-contracts/blob/192c7dc67290940fcbc75165522bb86a37187069/test/core/Safe.Signatures.spec.ts#L229-L233
196667
196948
  * @returns The signed Safe transaction
196668
196949
  * @throws "Transactions can only be signed by Safe owners"
196669
196950
  */
196670
- async signTransaction(safeTransaction, signingMethod = "eth_signTypedData_v4") {
196951
+ async signTransaction(safeTransaction, signingMethod = types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4, preimageSafeAddress) {
196671
196952
  const transaction = (0, utils_2.isSafeMultisigTransactionResponse)(safeTransaction) ? await this.toSafeTransactionType(safeTransaction) : safeTransaction;
196672
196953
  const owners = await this.getOwners();
196673
196954
  const signerAddress = await __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").getSignerAddress();
@@ -196678,20 +196959,31 @@ var require_Safe = __commonJS({
196678
196959
  if (!addressIsOwner) {
196679
196960
  throw new Error("Transactions can only be signed by Safe owners");
196680
196961
  }
196962
+ const safeVersion = await this.getContractVersion();
196963
+ if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE && (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0) && !preimageSafeAddress) {
196964
+ throw new Error("The parent Safe account address is mandatory for contract signatures");
196965
+ }
196681
196966
  let signature;
196682
- if (signingMethod === "eth_signTypedData_v4") {
196967
+ if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4) {
196683
196968
  signature = await this.signTypedData(transaction, "v4");
196684
- } else if (signingMethod === "eth_signTypedData_v3") {
196969
+ } else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V3) {
196685
196970
  signature = await this.signTypedData(transaction, "v3");
196686
- } else if (signingMethod === "eth_signTypedData") {
196687
- signature = await this.signTypedData(transaction);
196971
+ } else if (signingMethod === types_1.SigningMethod.ETH_SIGN_TYPED_DATA) {
196972
+ signature = await this.signTypedData(transaction, void 0);
196688
196973
  } else {
196689
- const safeVersion = await this.getContractVersion();
196690
- if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ETH_SIGN, safeVersion)) {
196974
+ const safeVersion2 = await this.getContractVersion();
196975
+ const chainId = await this.getChainId();
196976
+ if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ETH_SIGN, safeVersion2)) {
196691
196977
  throw new Error("eth_sign is only supported by Safes >= v1.1.0");
196692
196978
  }
196693
- const txHash = await this.getTransactionHash(transaction);
196694
- signature = await this.signTransactionHash(txHash);
196979
+ let txHash;
196980
+ if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE && (0, satisfies_1.default)(safeVersion2, EQ_OR_GT_1_3_0) && preimageSafeAddress) {
196981
+ const txHashData = (0, utils_2.preimageSafeTransactionHash)(preimageSafeAddress, safeTransaction.data, safeVersion2, chainId);
196982
+ txHash = await this.getSafeMessageHash(txHashData);
196983
+ } else {
196984
+ txHash = await this.getTransactionHash(transaction);
196985
+ }
196986
+ signature = await this.signHash(txHash);
196695
196987
  }
196696
196988
  const signedSafeTransaction = await this.copyTransaction(transaction);
196697
196989
  signedSafeTransaction.addSignature(signature);
@@ -197010,7 +197302,7 @@ var require_Safe = __commonJS({
197010
197302
  const txHash = await this.getTransactionHash(signedSafeTransaction);
197011
197303
  const ownersWhoApprovedTx = await this.getOwnersWhoApprovedTx(txHash);
197012
197304
  for (const owner of ownersWhoApprovedTx) {
197013
- signedSafeTransaction.addSignature((0, utils_3.generatePreValidatedSignature)(owner));
197305
+ signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(owner));
197014
197306
  }
197015
197307
  const owners = await this.getOwners();
197016
197308
  const signerAddress = await __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").getSignerAddress();
@@ -197018,7 +197310,7 @@ var require_Safe = __commonJS({
197018
197310
  throw new Error("EthAdapter must be initialized with a signer to use this method");
197019
197311
  }
197020
197312
  if (owners.includes(signerAddress)) {
197021
- signedSafeTransaction.addSignature((0, utils_3.generatePreValidatedSignature)(signerAddress));
197313
+ signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(signerAddress));
197022
197314
  }
197023
197315
  const isTxValid = await __classPrivateFieldGet2(this, _Safe_contractManager, "f").safeContract.isValidTransaction(signedSafeTransaction, {
197024
197316
  from: signerAddress,
@@ -197045,13 +197337,13 @@ var require_Safe = __commonJS({
197045
197337
  const txHash = await this.getTransactionHash(signedSafeTransaction);
197046
197338
  const ownersWhoApprovedTx = await this.getOwnersWhoApprovedTx(txHash);
197047
197339
  for (const owner of ownersWhoApprovedTx) {
197048
- signedSafeTransaction.addSignature((0, utils_3.generatePreValidatedSignature)(owner));
197340
+ signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(owner));
197049
197341
  }
197050
197342
  const owners = await this.getOwners();
197051
197343
  const threshold = await this.getThreshold();
197052
197344
  const signerAddress = await __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").getSignerAddress();
197053
197345
  if (threshold > signedSafeTransaction.signatures.size && signerAddress && owners.includes(signerAddress)) {
197054
- signedSafeTransaction.addSignature((0, utils_3.generatePreValidatedSignature)(signerAddress));
197346
+ signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(signerAddress));
197055
197347
  }
197056
197348
  if (threshold > signedSafeTransaction.signatures.size) {
197057
197349
  const signaturesMissing = threshold - signedSafeTransaction.signatures.size;
@@ -197185,12 +197477,14 @@ var require_Safe = __commonJS({
197185
197477
  const saltNonce = customSaltNonce || safeDeploymentConfig?.saltNonce || (0, utils_1.getChainSpecificDefaultSaltNonce)(chainId);
197186
197478
  const safeDeployTransactionData = {
197187
197479
  ...transactionOptions,
197480
+ // optional transaction options like from, gasLimit, gasPrice...
197188
197481
  to: await safeProxyFactoryContract.getAddress(),
197189
197482
  value: "0",
197190
197483
  // we use the createProxyWithNonce method to create the Safe in a deterministic address, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/proxies/SafeProxyFactory.sol#L52
197191
197484
  data: safeProxyFactoryContract.encode("createProxyWithNonce", [
197192
197485
  await safeSingletonContract.getAddress(),
197193
197486
  initializer,
197487
+ // call to the setup method to set the threshold & owners of the new Safe
197194
197488
  saltNonce
197195
197489
  ])
197196
197490
  };
@@ -197215,19 +197509,38 @@ var require_Safe = __commonJS({
197215
197509
  customContracts: __classPrivateFieldGet2(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()]
197216
197510
  });
197217
197511
  const batchData = multiSendCallOnlyContract.encode("multiSend", [
197218
- (0, utils_4.encodeMultiSendData)(transactions)
197512
+ (0, utils_3.encodeMultiSendData)(transactions)
197219
197513
  // encoded transactions
197220
197514
  ]);
197221
197515
  const transactionBatch = {
197222
197516
  ...transactionOptions,
197517
+ // optional transaction options like from, gasLimit, gasPrice...
197223
197518
  to: await multiSendCallOnlyContract.getAddress(),
197224
197519
  value: "0",
197225
197520
  data: batchData
197226
197521
  };
197227
197522
  return transactionBatch;
197228
197523
  }
197524
+ /**
197525
+ * Get the fallback handler contract
197526
+ *
197527
+ * @returns The fallback Handler contract
197528
+ */
197529
+ async getFallbackHandlerContract() {
197530
+ if (!__classPrivateFieldGet2(this, _Safe_contractManager, "f").safeContract) {
197531
+ throw new Error("Safe is not deployed");
197532
+ }
197533
+ const safeVersion = await __classPrivateFieldGet2(this, _Safe_contractManager, "f").safeContract.getVersion() ?? config_1.DEFAULT_SAFE_VERSION;
197534
+ const chainId = await __classPrivateFieldGet2(this, _Safe_ethAdapter, "f").getChainId();
197535
+ const compatibilityFallbackHandlerContract = await (0, safeDeploymentContracts_1.getCompatibilityFallbackHandlerContract)({
197536
+ ethAdapter: __classPrivateFieldGet2(this, _Safe_ethAdapter, "f"),
197537
+ safeVersion,
197538
+ customContracts: __classPrivateFieldGet2(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()]
197539
+ });
197540
+ return compatibilityFallbackHandlerContract;
197541
+ }
197229
197542
  };
197230
- _Safe_predictedSafe = /* @__PURE__ */ new WeakMap(), _Safe_ethAdapter = /* @__PURE__ */ new WeakMap(), _Safe_contractManager = /* @__PURE__ */ new WeakMap(), _Safe_ownerManager = /* @__PURE__ */ new WeakMap(), _Safe_moduleManager = /* @__PURE__ */ new WeakMap(), _Safe_guardManager = /* @__PURE__ */ new WeakMap(), _Safe_fallbackHandlerManager = /* @__PURE__ */ new WeakMap();
197543
+ _Safe_predictedSafe = /* @__PURE__ */ new WeakMap(), _Safe_ethAdapter = /* @__PURE__ */ new WeakMap(), _Safe_contractManager = /* @__PURE__ */ new WeakMap(), _Safe_ownerManager = /* @__PURE__ */ new WeakMap(), _Safe_moduleManager = /* @__PURE__ */ new WeakMap(), _Safe_guardManager = /* @__PURE__ */ new WeakMap(), _Safe_fallbackHandlerManager = /* @__PURE__ */ new WeakMap(), _Safe_MAGIC_VALUE = /* @__PURE__ */ new WeakMap(), _Safe_MAGIC_VALUE_BYTES = /* @__PURE__ */ new WeakMap();
197231
197544
  exports2.default = Safe;
197232
197545
  }
197233
197546
  });
@@ -205327,13 +205640,13 @@ var require_EthersAdapter = __commonJS({
205327
205640
  const messageArray = __classPrivateFieldGet2(this, _EthersAdapter_ethers, "f").getBytes(message);
205328
205641
  return __classPrivateFieldGet2(this, _EthersAdapter_signer, "f").signMessage(messageArray);
205329
205642
  }
205330
- async signTypedData(safeTransactionEIP712Args) {
205643
+ async signTypedData(safeEIP712Args) {
205331
205644
  if (!__classPrivateFieldGet2(this, _EthersAdapter_signer, "f")) {
205332
205645
  throw new Error("EthAdapter must be initialized with a signer to use this method");
205333
205646
  }
205334
205647
  if ((0, utils_2.isTypedDataSigner)(__classPrivateFieldGet2(this, _EthersAdapter_signer, "f"))) {
205335
- const typedData = (0, utils_1.generateTypedData)(safeTransactionEIP712Args);
205336
- const signature = await __classPrivateFieldGet2(this, _EthersAdapter_signer, "f").signTypedData(typedData.domain, { SafeTx: typedData.types.SafeTx }, typedData.message);
205648
+ const typedData = (0, utils_1.generateTypedData)(safeEIP712Args);
205649
+ const signature = await __classPrivateFieldGet2(this, _EthersAdapter_signer, "f").signTypedData(typedData.domain, typedData.primaryType === "SafeMessage" ? { SafeMessage: typedData.types.SafeMessage } : { SafeTx: typedData.types.SafeTx }, typedData.message);
205337
205650
  return signature;
205338
205651
  }
205339
205652
  throw new Error("The current signer does not implement EIP-712 to sign typed data");
@@ -206392,6 +206705,7 @@ var require_Web3Adapter = __commonJS({
206392
206705
  Object.defineProperty(exports2, "__esModule", { value: true });
206393
206706
  var utils_1 = require_utils21();
206394
206707
  var contractInstancesWeb3_1 = require_contractInstancesWeb3();
206708
+ var types_1 = require_types14();
206395
206709
  var Web3Adapter = class {
206396
206710
  constructor({ web3, signerAddress }) {
206397
206711
  _Web3Adapter_web3.set(this, void 0);
@@ -206523,16 +206837,16 @@ var require_Web3Adapter = __commonJS({
206523
206837
  }
206524
206838
  return __classPrivateFieldGet2(this, _Web3Adapter_web3, "f").eth.sign(message, __classPrivateFieldGet2(this, _Web3Adapter_signerAddress, "f"));
206525
206839
  }
206526
- async signTypedData(safeTransactionEIP712Args, methodVersion) {
206840
+ async signTypedData(safeEIP712Args, methodVersion) {
206527
206841
  if (!__classPrivateFieldGet2(this, _Web3Adapter_signerAddress, "f")) {
206528
206842
  throw new Error("This method requires a signer");
206529
206843
  }
206530
- const typedData = (0, utils_1.generateTypedData)(safeTransactionEIP712Args);
206531
- let method = "eth_signTypedData_v3";
206844
+ const typedData = (0, utils_1.generateTypedData)(safeEIP712Args);
206845
+ let method = types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V3;
206532
206846
  if (methodVersion === "v4") {
206533
- method = "eth_signTypedData_v4";
206847
+ method = types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4;
206534
206848
  } else if (!methodVersion) {
206535
- method = "eth_signTypedData";
206849
+ method = types_1.SigningMethod.ETH_SIGN_TYPED_DATA;
206536
206850
  }
206537
206851
  const jsonTypedData = JSON.stringify(typedData);
206538
206852
  const signedTypedData = {
@@ -206691,6 +207005,7 @@ var require_safeFactory = __commonJS({
206691
207005
  };
206692
207006
  return (0, utils_1.predictSafeAddress)({
206693
207007
  ethAdapter: __classPrivateFieldGet2(this, _SafeFactory_ethAdapter, "f"),
207008
+ chainId,
206694
207009
  safeAccountConfig,
206695
207010
  safeDeploymentConfig,
206696
207011
  isL1SafeSingleton: __classPrivateFieldGet2(this, _SafeFactory_isL1SafeSingleton, "f"),
@@ -206804,7 +207119,8 @@ var require_src7 = __commonJS({
206804
207119
  return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
206805
207120
  };
206806
207121
  Object.defineProperty(exports2, "__esModule", { value: true });
206807
- exports2.validateEip3770Address = exports2.standardizeSafeTransactionData = exports2.predictSafeAddress = exports2.isGasTokenCompatibleWithHandlePayment = exports2.getSignMessageLibContract = exports2.getSafeContract = exports2.getProxyFactoryContract = exports2.getMultiSendContract = exports2.getMultiSendCallOnlyContract = exports2.getERC20Decimals = exports2.getCreateCallContract = exports2.getCompatibilityFallbackHandlerContract = exports2.encodeSetupCallData = exports2.encodeMultiSendData = exports2.encodeCreateProxyWithNonce = exports2.Web3Adapter = exports2.SignMessageLibWeb3Contract = exports2.SignMessageLibEthersContract = exports2.SafeProxyFactoryWeb3Contract = exports2.SafeProxyFactoryEthersContract = exports2.SafeFactory = exports2.SafeContractWeb3 = exports2.SafeContractEthers = exports2.PREDETERMINED_SALT_NONCE = exports2.MultiSendWeb3Contract = exports2.MultiSendEthersContract = exports2.MultiSendCallOnlyWeb3Contract = exports2.MultiSendCallOnlyEthersContract = exports2.EthersAdapter = exports2.EthSafeSignature = exports2.DEFAULT_SAFE_VERSION = exports2.createERC20TokenTransferTransaction = exports2.CreateCallWeb3Contract = exports2.CreateCallEthersContract = exports2.ContractManager = exports2.estimateSafeDeploymentGas = exports2.estimateSafeTxGas = exports2.estimateTxGas = exports2.estimateTxBaseGas = void 0;
207122
+ exports2.hashSafeMessage = exports2.getEip712MessageTypes = exports2.getEip712TxTypes = exports2.preimageSafeMessageHash = exports2.preimageSafeTransactionHash = exports2.buildSignatureBytes = exports2.buildContractSignature = exports2.generateEIP712Signature = exports2.generateSignature = exports2.validateEthereumAddress = exports2.validateEip3770Address = exports2.standardizeSafeTransactionData = exports2.predictSafeAddress = exports2.isGasTokenCompatibleWithHandlePayment = exports2.getSignMessageLibContract = exports2.getSafeContract = exports2.getProxyFactoryContract = exports2.getMultiSendContract = exports2.getMultiSendCallOnlyContract = exports2.getERC20Decimals = exports2.getCreateCallContract = exports2.getCompatibilityFallbackHandlerContract = exports2.encodeSetupCallData = exports2.encodeMultiSendData = exports2.encodeCreateProxyWithNonce = exports2.Web3Adapter = exports2.SigningMethod = exports2.SignMessageLibWeb3Contract = exports2.SignMessageLibEthersContract = exports2.SafeProxyFactoryWeb3Contract = exports2.SafeProxyFactoryEthersContract = exports2.SafeFactory = exports2.SafeContractWeb3 = exports2.SafeContractEthers = exports2.PREDETERMINED_SALT_NONCE = exports2.MultiSendWeb3Contract = exports2.MultiSendEthersContract = exports2.MultiSendCallOnlyWeb3Contract = exports2.MultiSendCallOnlyEthersContract = exports2.EthersAdapter = exports2.EthSafeSignature = exports2.DEFAULT_SAFE_VERSION = exports2.createERC20TokenTransferTransaction = exports2.CreateCallWeb3Contract = exports2.CreateCallEthersContract = exports2.ContractManager = exports2.estimateSafeDeploymentGas = exports2.estimateSafeTxGas = exports2.estimateTxGas = exports2.estimateTxBaseGas = void 0;
207123
+ exports2.generateTypedData = void 0;
206808
207124
  var Safe_1 = __importDefault2(require_Safe());
206809
207125
  var ethers_1 = require_ethers3();
206810
207126
  Object.defineProperty(exports2, "CreateCallEthersContract", { enumerable: true, get: function() {
@@ -206893,6 +207209,10 @@ var require_src7 = __commonJS({
206893
207209
  exports2.ContractManager = contractManager_1.default;
206894
207210
  var safeFactory_1 = __importDefault2(require_safeFactory());
206895
207211
  exports2.SafeFactory = safeFactory_1.default;
207212
+ var types_1 = require_types14();
207213
+ Object.defineProperty(exports2, "SigningMethod", { enumerable: true, get: function() {
207214
+ return types_1.SigningMethod;
207215
+ } });
206896
207216
  var utils_2 = require_utils21();
206897
207217
  Object.defineProperty(exports2, "EthSafeSignature", { enumerable: true, get: function() {
206898
207218
  return utils_2.EthSafeSignature;
@@ -206909,6 +207229,9 @@ var require_src7 = __commonJS({
206909
207229
  Object.defineProperty(exports2, "estimateSafeDeploymentGas", { enumerable: true, get: function() {
206910
207230
  return utils_2.estimateSafeDeploymentGas;
206911
207231
  } });
207232
+ Object.defineProperty(exports2, "validateEthereumAddress", { enumerable: true, get: function() {
207233
+ return utils_2.validateEthereumAddress;
207234
+ } });
206912
207235
  Object.defineProperty(exports2, "validateEip3770Address", { enumerable: true, get: function() {
206913
207236
  return utils_2.validateEip3770Address;
206914
207237
  } });
@@ -206929,6 +207252,38 @@ var require_src7 = __commonJS({
206929
207252
  Object.defineProperty(exports2, "createERC20TokenTransferTransaction", { enumerable: true, get: function() {
206930
207253
  return erc_20_1.createERC20TokenTransferTransaction;
206931
207254
  } });
207255
+ var utils_4 = require_utils19();
207256
+ Object.defineProperty(exports2, "generateSignature", { enumerable: true, get: function() {
207257
+ return utils_4.generateSignature;
207258
+ } });
207259
+ Object.defineProperty(exports2, "generateEIP712Signature", { enumerable: true, get: function() {
207260
+ return utils_4.generateEIP712Signature;
207261
+ } });
207262
+ Object.defineProperty(exports2, "buildContractSignature", { enumerable: true, get: function() {
207263
+ return utils_4.buildContractSignature;
207264
+ } });
207265
+ Object.defineProperty(exports2, "buildSignatureBytes", { enumerable: true, get: function() {
207266
+ return utils_4.buildSignatureBytes;
207267
+ } });
207268
+ Object.defineProperty(exports2, "preimageSafeTransactionHash", { enumerable: true, get: function() {
207269
+ return utils_4.preimageSafeTransactionHash;
207270
+ } });
207271
+ Object.defineProperty(exports2, "preimageSafeMessageHash", { enumerable: true, get: function() {
207272
+ return utils_4.preimageSafeMessageHash;
207273
+ } });
207274
+ var eip_712_1 = require_eip_712();
207275
+ Object.defineProperty(exports2, "getEip712TxTypes", { enumerable: true, get: function() {
207276
+ return eip_712_1.getEip712TxTypes;
207277
+ } });
207278
+ Object.defineProperty(exports2, "getEip712MessageTypes", { enumerable: true, get: function() {
207279
+ return eip_712_1.getEip712MessageTypes;
207280
+ } });
207281
+ Object.defineProperty(exports2, "hashSafeMessage", { enumerable: true, get: function() {
207282
+ return eip_712_1.hashSafeMessage;
207283
+ } });
207284
+ Object.defineProperty(exports2, "generateTypedData", { enumerable: true, get: function() {
207285
+ return eip_712_1.generateTypedData;
207286
+ } });
206932
207287
  exports2.default = Safe_1.default;
206933
207288
  }
206934
207289
  });
@@ -206980,6 +207335,7 @@ var require_SafeApiKit = __commonJS({
206980
207335
  var _SafeApiKit_instances;
206981
207336
  var _SafeApiKit_chainId;
206982
207337
  var _SafeApiKit_txServiceBaseUrl;
207338
+ var _SafeApiKit_isValidAddress;
206983
207339
  var _SafeApiKit_getEip3770Address;
206984
207340
  Object.defineProperty(exports2, "__esModule", { value: true });
206985
207341
  var httpRequests_1 = require_httpRequests();
@@ -207490,8 +207846,87 @@ var require_SafeApiKit = __commonJS({
207490
207846
  method: httpRequests_1.HttpMethod.Get
207491
207847
  });
207492
207848
  }
207849
+ /**
207850
+ * Get a message by its safe message hash
207851
+ * @param messageHash The Safe message hash
207852
+ * @returns The message
207853
+ */
207854
+ async getMessage(messageHash) {
207855
+ if (!messageHash) {
207856
+ throw new Error("Invalid messageHash");
207857
+ }
207858
+ return (0, httpRequests_1.sendRequest)({
207859
+ url: `${__classPrivateFieldGet2(this, _SafeApiKit_txServiceBaseUrl, "f")}/v1/messages/${messageHash}/`,
207860
+ method: httpRequests_1.HttpMethod.Get
207861
+ });
207862
+ }
207863
+ /**
207864
+ * Get the list of messages associated to a Safe account
207865
+ * @param safeAddress The safe address
207866
+ * @param options The options to filter the list of messages
207867
+ * @returns The paginated list of messages
207868
+ */
207869
+ async getMessages(safeAddress, { ordering, limit, offset } = {}) {
207870
+ if (!__classPrivateFieldGet2(this, _SafeApiKit_instances, "m", _SafeApiKit_isValidAddress).call(this, safeAddress)) {
207871
+ throw new Error("Invalid safeAddress");
207872
+ }
207873
+ const url2 = new URL(`${__classPrivateFieldGet2(this, _SafeApiKit_txServiceBaseUrl, "f")}/v1/safes/${safeAddress}/messages/`);
207874
+ if (ordering) {
207875
+ url2.searchParams.set("ordering", ordering);
207876
+ }
207877
+ if (limit) {
207878
+ url2.searchParams.set("limit", limit);
207879
+ }
207880
+ if (offset) {
207881
+ url2.searchParams.set("offset", offset);
207882
+ }
207883
+ return (0, httpRequests_1.sendRequest)({
207884
+ url: url2.toString(),
207885
+ method: httpRequests_1.HttpMethod.Get
207886
+ });
207887
+ }
207888
+ /**
207889
+ * Creates a new message with an initial signature
207890
+ * Add more signatures from other owners using addMessageSignature()
207891
+ * @param safeAddress The safe address
207892
+ * @param options The raw message to add, signature and safeAppId if any
207893
+ */
207894
+ async addMessage(safeAddress, addMessageProps) {
207895
+ if (!__classPrivateFieldGet2(this, _SafeApiKit_instances, "m", _SafeApiKit_isValidAddress).call(this, safeAddress)) {
207896
+ throw new Error("Invalid safeAddress");
207897
+ }
207898
+ return (0, httpRequests_1.sendRequest)({
207899
+ url: `${__classPrivateFieldGet2(this, _SafeApiKit_txServiceBaseUrl, "f")}/v1/safes/${safeAddress}/messages/`,
207900
+ method: httpRequests_1.HttpMethod.Post,
207901
+ body: addMessageProps
207902
+ });
207903
+ }
207904
+ /**
207905
+ * Add a signature to an existing message
207906
+ * @param messageHash The safe message hash
207907
+ * @param signature The signature
207908
+ */
207909
+ async addMessageSignature(messageHash, signature) {
207910
+ if (!messageHash || !signature) {
207911
+ throw new Error("Invalid messageHash or signature");
207912
+ }
207913
+ return (0, httpRequests_1.sendRequest)({
207914
+ url: `${__classPrivateFieldGet2(this, _SafeApiKit_txServiceBaseUrl, "f")}/v1/messages/${messageHash}/signatures/`,
207915
+ method: httpRequests_1.HttpMethod.Post,
207916
+ body: {
207917
+ signature
207918
+ }
207919
+ });
207920
+ }
207493
207921
  };
207494
- _SafeApiKit_chainId = /* @__PURE__ */ new WeakMap(), _SafeApiKit_txServiceBaseUrl = /* @__PURE__ */ new WeakMap(), _SafeApiKit_instances = /* @__PURE__ */ new WeakSet(), _SafeApiKit_getEip3770Address = function _SafeApiKit_getEip3770Address2(fullAddress) {
207922
+ _SafeApiKit_chainId = /* @__PURE__ */ new WeakMap(), _SafeApiKit_txServiceBaseUrl = /* @__PURE__ */ new WeakMap(), _SafeApiKit_instances = /* @__PURE__ */ new WeakSet(), _SafeApiKit_isValidAddress = function _SafeApiKit_isValidAddress2(address) {
207923
+ try {
207924
+ (0, protocol_kit_1.validateEthereumAddress)(address);
207925
+ return true;
207926
+ } catch {
207927
+ return false;
207928
+ }
207929
+ }, _SafeApiKit_getEip3770Address = function _SafeApiKit_getEip3770Address2(fullAddress) {
207495
207930
  return (0, protocol_kit_1.validateEip3770Address)(fullAddress, __classPrivateFieldGet2(this, _SafeApiKit_chainId, "f"));
207496
207931
  };
207497
207932
  exports2.default = SafeApiKit2;
@@ -208069,21 +208504,27 @@ var require_coerce = __commonJS({
208069
208504
  options = options || {};
208070
208505
  let match = null;
208071
208506
  if (!options.rtl) {
208072
- match = version4.match(re[t.COERCE]);
208507
+ match = version4.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
208073
208508
  } else {
208509
+ const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
208074
208510
  let next;
208075
- while ((next = re[t.COERCERTL].exec(version4)) && (!match || match.index + match[0].length !== version4.length)) {
208511
+ while ((next = coerceRtlRegex.exec(version4)) && (!match || match.index + match[0].length !== version4.length)) {
208076
208512
  if (!match || next.index + next[0].length !== match.index + match[0].length) {
208077
208513
  match = next;
208078
208514
  }
208079
- re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
208515
+ coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
208080
208516
  }
208081
- re[t.COERCERTL].lastIndex = -1;
208517
+ coerceRtlRegex.lastIndex = -1;
208082
208518
  }
208083
208519
  if (match === null) {
208084
208520
  return null;
208085
208521
  }
208086
- return parse2(`${match[2]}.${match[3] || "0"}.${match[4] || "0"}`, options);
208522
+ const major2 = match[2];
208523
+ const minor = match[3] || "0";
208524
+ const patch = match[4] || "0";
208525
+ const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
208526
+ const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
208527
+ return parse2(`${major2}.${minor}.${patch}${prerelease}${build}`, options);
208087
208528
  };
208088
208529
  module2.exports = coerce;
208089
208530
  }
@@ -231376,7 +231817,7 @@ var require_SourcifyChain = __commonJS({
231376
231817
  });
231377
231818
 
231378
231819
  // ../../node_modules/@ethereum-sourcify/lib-sourcify/build/main/lib/types.js
231379
- var require_types15 = __commonJS({
231820
+ var require_types16 = __commonJS({
231380
231821
  "../../node_modules/@ethereum-sourcify/lib-sourcify/build/main/lib/types.js"(exports2) {
231381
231822
  "use strict";
231382
231823
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -231427,7 +231868,7 @@ var require_main2 = __commonJS({
231427
231868
  Object.defineProperty(exports2, "SourcifyChain", { enumerable: true, get: function() {
231428
231869
  return __importDefault2(SourcifyChain_1).default;
231429
231870
  } });
231430
- __exportStar2(require_types15(), exports2);
231871
+ __exportStar2(require_types16(), exports2);
231431
231872
  __exportStar2(require_solidityCompiler(), exports2);
231432
231873
  exports2.setLibSourcifyLogger = logger_1.setLogger;
231433
231874
  exports2.setLibSourcifyLoggerLevel = logger_1.setLevel;
@@ -326599,7 +327040,7 @@ function zeroLT() {
326599
327040
  }
326600
327041
 
326601
327042
  // package.json
326602
- var version3 = "4.1.0";
327043
+ var version3 = "0.0.0";
326603
327044
 
326604
327045
  // src/index.ts
326605
327046
  var program2 = new Command();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/deploy-tools",
3
3
  "description": "Gearbox deploy tools",
4
- "version": "4.1.1-next.1",
4
+ "version": "4.1.1",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"
@@ -38,9 +38,9 @@
38
38
  "@chialab/esbuild-plugin-commonjs": "^0.18.0",
39
39
  "@ethereum-sourcify/bytecode-utils": "^1.2.1",
40
40
  "@ethereum-sourcify/lib-sourcify": "^1.4.1",
41
- "@gearbox-protocol/deploy-tools-node": "4.1.0",
42
- "@gearbox-protocol/deploy-tools-shared": "4.1.0",
43
- "@gearbox-protocol/deploy-tools-types": "4.1.0",
41
+ "@gearbox-protocol/deploy-tools-node": "0.0.0",
42
+ "@gearbox-protocol/deploy-tools-shared": "0.0.0",
43
+ "@gearbox-protocol/deploy-tools-types": "0.0.0",
44
44
  "@gearbox-protocol/sdk-gov": "^1.28.2",
45
45
  "@types/lodash-es": "^4.17.12",
46
46
  "@types/node": "^20.10.8",