@safe-global/protocol-kit 4.1.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/dist/src/Safe.d.ts +12 -17
  2. package/dist/src/Safe.js +159 -112
  3. package/dist/src/Safe.js.map +1 -1
  4. package/dist/src/SafeProvider.d.ts +11 -20
  5. package/dist/src/SafeProvider.js +141 -90
  6. package/dist/src/SafeProvider.js.map +1 -1
  7. package/dist/src/contracts/BaseContract.d.ts +26 -6
  8. package/dist/src/contracts/BaseContract.js +101 -14
  9. package/dist/src/contracts/BaseContract.js.map +1 -1
  10. package/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.d.ts +5 -4
  11. package/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.js +3 -2
  12. package/dist/src/contracts/CompatibilityFallbackHandler/CompatibilityFallbackHandlerBaseContract.js.map +1 -1
  13. package/dist/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.d.ts +4 -3
  14. package/dist/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.js +5 -5
  15. package/dist/src/contracts/CompatibilityFallbackHandler/v1.3.0/CompatibilityFallbackHandlerContract_v1_3_0.js.map +1 -1
  16. package/dist/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.d.ts +4 -3
  17. package/dist/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.js +5 -5
  18. package/dist/src/contracts/CompatibilityFallbackHandler/v1.4.1/CompatibilityFallbackHandlerContract_v1_4_1.js.map +1 -1
  19. package/dist/src/contracts/CreateCall/CreateCallBaseContract.d.ts +5 -4
  20. package/dist/src/contracts/CreateCall/CreateCallBaseContract.js +3 -2
  21. package/dist/src/contracts/CreateCall/CreateCallBaseContract.js.map +1 -1
  22. package/dist/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.d.ts +4 -3
  23. package/dist/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.js +7 -9
  24. package/dist/src/contracts/CreateCall/v1.3.0/CreateCallContract_v1_3_0.js.map +1 -1
  25. package/dist/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.d.ts +4 -3
  26. package/dist/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.js +7 -9
  27. package/dist/src/contracts/CreateCall/v1.4.1/CreateCallContract_v1_4_1.js.map +1 -1
  28. package/dist/src/contracts/MultiSend/MultiSendBaseContract.d.ts +5 -4
  29. package/dist/src/contracts/MultiSend/MultiSendBaseContract.js +3 -2
  30. package/dist/src/contracts/MultiSend/MultiSendBaseContract.js.map +1 -1
  31. package/dist/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.d.ts +5 -4
  32. package/dist/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.js +3 -2
  33. package/dist/src/contracts/MultiSend/MultiSendCallOnlyBaseContract.js.map +1 -1
  34. package/dist/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.d.ts +4 -3
  35. package/dist/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.js +5 -5
  36. package/dist/src/contracts/MultiSend/v1.1.1/MultiSendContract_v1_1_1.js.map +1 -1
  37. package/dist/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.d.ts +4 -3
  38. package/dist/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.js +5 -5
  39. package/dist/src/contracts/MultiSend/v1.3.0/MultiSendCallOnlyContract_v1_3_0.js.map +1 -1
  40. package/dist/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.d.ts +4 -3
  41. package/dist/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.js +5 -5
  42. package/dist/src/contracts/MultiSend/v1.3.0/MultiSendContract_v1_3_0.js.map +1 -1
  43. package/dist/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.d.ts +4 -3
  44. package/dist/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.js +5 -5
  45. package/dist/src/contracts/MultiSend/v1.4.1/MultiSendCallOnlyContract_v1_4_1.js.map +1 -1
  46. package/dist/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.d.ts +4 -3
  47. package/dist/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.js +5 -5
  48. package/dist/src/contracts/MultiSend/v1.4.1/MultiSendContract_v1_4_1.js.map +1 -1
  49. package/dist/src/contracts/Safe/SafeBaseContract.d.ts +5 -4
  50. package/dist/src/contracts/Safe/SafeBaseContract.js +3 -2
  51. package/dist/src/contracts/Safe/SafeBaseContract.js.map +1 -1
  52. package/dist/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.d.ts +7 -11
  53. package/dist/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.js +64 -42
  54. package/dist/src/contracts/Safe/v1.0.0/SafeContract_v1_0_0.js.map +1 -1
  55. package/dist/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.d.ts +4 -9
  56. package/dist/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.js +61 -39
  57. package/dist/src/contracts/Safe/v1.1.1/SafeContract_v1_1_1.js.map +1 -1
  58. package/dist/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.d.ts +5 -10
  59. package/dist/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.js +63 -41
  60. package/dist/src/contracts/Safe/v1.2.0/SafeContract_v1_2_0.js.map +1 -1
  61. package/dist/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.d.ts +5 -10
  62. package/dist/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.js +63 -41
  63. package/dist/src/contracts/Safe/v1.3.0/SafeContract_v1_3_0.js.map +1 -1
  64. package/dist/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.d.ts +5 -10
  65. package/dist/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.js +63 -41
  66. package/dist/src/contracts/Safe/v1.4.1/SafeContract_v1_4_1.js.map +1 -1
  67. package/dist/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.d.ts +5 -7
  68. package/dist/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.js +3 -2
  69. package/dist/src/contracts/SafeProxyFactory/SafeProxyFactoryBaseContract.js.map +1 -1
  70. package/dist/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.d.ts +5 -11
  71. package/dist/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.js +9 -38
  72. package/dist/src/contracts/SafeProxyFactory/v1.0.0/SafeProxyFactoryContract_v1_0_0.js.map +1 -1
  73. package/dist/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.d.ts +6 -12
  74. package/dist/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.js +12 -41
  75. package/dist/src/contracts/SafeProxyFactory/v1.1.1/SafeProxyFactoryContract_v1_1_1.js.map +1 -1
  76. package/dist/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.d.ts +5 -11
  77. package/dist/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.js +11 -40
  78. package/dist/src/contracts/SafeProxyFactory/v1.3.0/SafeProxyFactoryContract_v1_3_0.js.map +1 -1
  79. package/dist/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.d.ts +5 -11
  80. package/dist/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.js +10 -39
  81. package/dist/src/contracts/SafeProxyFactory/v1.4.1/SafeProxyFactoryContract_v1_4_1.js.map +1 -1
  82. package/dist/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.d.ts +5 -7
  83. package/dist/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.js +3 -2
  84. package/dist/src/contracts/SafeWebAuthnSharedSigner/SafeWebAuthnSharedSignerBaseContract.js.map +1 -1
  85. package/dist/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.d.ts +4 -3
  86. package/dist/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.js +9 -9
  87. package/dist/src/contracts/SafeWebAuthnSharedSigner/v0.2.1/SafeWebAuthnSharedSignerContract_v0_2_1.js.map +1 -1
  88. package/dist/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.d.ts +5 -7
  89. package/dist/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.js +3 -2
  90. package/dist/src/contracts/SafeWebAuthnSignerFactory/SafeWebAuthnSignerFactoryBaseContract.js.map +1 -1
  91. package/dist/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.d.ts +4 -3
  92. package/dist/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.js +8 -8
  93. package/dist/src/contracts/SafeWebAuthnSignerFactory/v0.2.1/SafeWebAuthnSignerFactoryContract_v0_2_1.js.map +1 -1
  94. package/dist/src/contracts/SignMessageLib/SignMessageLibBaseContract.d.ts +5 -4
  95. package/dist/src/contracts/SignMessageLib/SignMessageLibBaseContract.js +3 -2
  96. package/dist/src/contracts/SignMessageLib/SignMessageLibBaseContract.js.map +1 -1
  97. package/dist/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.d.ts +4 -3
  98. package/dist/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.js +7 -8
  99. package/dist/src/contracts/SignMessageLib/v1.3.0/SignMessageLibContract_v1_3_0.js.map +1 -1
  100. package/dist/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.d.ts +4 -3
  101. package/dist/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.js +7 -8
  102. package/dist/src/contracts/SignMessageLib/v1.4.1/SignMessageLibContract_v1_4_1.js.map +1 -1
  103. package/dist/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.d.ts +5 -4
  104. package/dist/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.js +3 -2
  105. package/dist/src/contracts/SimulateTxAccessor/SimulateTxAccessorBaseContract.js.map +1 -1
  106. package/dist/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.d.ts +4 -3
  107. package/dist/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.js +9 -7
  108. package/dist/src/contracts/SimulateTxAccessor/v1.3.0/SimulateTxAccessorContract_v1_3_0.js.map +1 -1
  109. package/dist/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.d.ts +4 -3
  110. package/dist/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.js +9 -7
  111. package/dist/src/contracts/SimulateTxAccessor/v1.4.1/SimulateTxAccessorContract_v1_4_1.js.map +1 -1
  112. package/dist/src/contracts/config.d.ts +8 -1
  113. package/dist/src/contracts/config.js +47 -16
  114. package/dist/src/contracts/config.js.map +1 -1
  115. package/dist/src/contracts/constants.d.ts +4 -3
  116. package/dist/src/contracts/constants.js +2 -1
  117. package/dist/src/contracts/constants.js.map +1 -1
  118. package/dist/src/contracts/contractInstances.d.ts +13 -12
  119. package/dist/src/contracts/contractInstances.js +34 -34
  120. package/dist/src/contracts/contractInstances.js.map +1 -1
  121. package/dist/src/contracts/safeDeploymentContracts.d.ts +6 -5
  122. package/dist/src/contracts/safeDeploymentContracts.js +26 -66
  123. package/dist/src/contracts/safeDeploymentContracts.js.map +1 -1
  124. package/dist/src/contracts/utils.d.ts +35 -13
  125. package/dist/src/contracts/utils.js +136 -55
  126. package/dist/src/contracts/utils.js.map +1 -1
  127. package/dist/src/index.d.ts +10 -6
  128. package/dist/src/index.js +7 -9
  129. package/dist/src/index.js.map +1 -1
  130. package/dist/src/managers/contractManager.js +12 -17
  131. package/dist/src/managers/contractManager.js.map +1 -1
  132. package/dist/src/managers/fallbackHandlerManager.js +5 -4
  133. package/dist/src/managers/fallbackHandlerManager.js.map +1 -1
  134. package/dist/src/managers/guardManager.js +5 -4
  135. package/dist/src/managers/guardManager.js.map +1 -1
  136. package/dist/src/types/contracts.d.ts +13 -13
  137. package/dist/src/types/index.d.ts +0 -1
  138. package/dist/src/types/index.js +0 -1
  139. package/dist/src/types/index.js.map +1 -1
  140. package/dist/src/types/safeConfig.d.ts +3 -1
  141. package/dist/src/types/safeProvider.d.ts +33 -5
  142. package/dist/src/types/transactions.d.ts +1 -1
  143. package/dist/src/utils/address.d.ts +1 -1
  144. package/dist/src/utils/address.js +1 -1
  145. package/dist/src/utils/address.js.map +1 -1
  146. package/dist/src/utils/block.d.ts +6 -0
  147. package/dist/src/utils/block.js +14 -0
  148. package/dist/src/utils/block.js.map +1 -0
  149. package/dist/src/utils/constants.d.ts +4 -3
  150. package/dist/src/utils/constants.js +2 -1
  151. package/dist/src/utils/constants.js.map +1 -1
  152. package/dist/src/utils/eip-3770/index.d.ts +1 -1
  153. package/dist/src/utils/eip-3770/index.js +2 -3
  154. package/dist/src/utils/eip-3770/index.js.map +1 -1
  155. package/dist/src/utils/eip-712/encode.d.ts +3 -0
  156. package/dist/src/utils/eip-712/encode.js +127 -0
  157. package/dist/src/utils/eip-712/encode.js.map +1 -0
  158. package/dist/src/utils/eip-712/index.d.ts +1 -1
  159. package/dist/src/utils/eip-712/index.js +5 -7
  160. package/dist/src/utils/eip-712/index.js.map +1 -1
  161. package/dist/src/utils/erc-20/index.d.ts +1 -1
  162. package/dist/src/utils/erc-20/index.js +12 -5
  163. package/dist/src/utils/erc-20/index.js.map +1 -1
  164. package/dist/src/utils/messages/SafeMessage.d.ts +1 -1
  165. package/dist/src/utils/passkeys/PasskeyClient.d.ts +5 -0
  166. package/dist/src/utils/passkeys/PasskeyClient.js +156 -0
  167. package/dist/src/utils/passkeys/PasskeyClient.js.map +1 -0
  168. package/dist/src/utils/passkeys/createPasskeyDeploymentTransaction.d.ts +2 -1
  169. package/dist/src/utils/passkeys/createPasskeyDeploymentTransaction.js +12 -12
  170. package/dist/src/utils/passkeys/createPasskeyDeploymentTransaction.js.map +1 -1
  171. package/dist/src/utils/passkeys/extractPasskeyData.d.ts +1 -2
  172. package/dist/src/utils/passkeys/extractPasskeyData.js +8 -15
  173. package/dist/src/utils/passkeys/extractPasskeyData.js.map +1 -1
  174. package/dist/src/utils/passkeys/getPasskeyOwnerAddress.js +10 -3
  175. package/dist/src/utils/passkeys/getPasskeyOwnerAddress.js.map +1 -1
  176. package/dist/src/utils/passkeys/index.d.ts +1 -1
  177. package/dist/src/utils/passkeys/index.js +1 -1
  178. package/dist/src/utils/passkeys/isSharedSigner.d.ts +2 -3
  179. package/dist/src/utils/passkeys/isSharedSigner.js +6 -5
  180. package/dist/src/utils/passkeys/isSharedSigner.js.map +1 -1
  181. package/dist/src/utils/provider.d.ts +3 -0
  182. package/dist/src/utils/provider.js +12 -0
  183. package/dist/src/utils/provider.js.map +1 -0
  184. package/dist/src/utils/safeVersions.js +2 -2
  185. package/dist/src/utils/safeVersions.js.map +1 -1
  186. package/dist/src/utils/signatures/SafeSignature.d.ts +1 -1
  187. package/dist/src/utils/signatures/utils.d.ts +4 -4
  188. package/dist/src/utils/signatures/utils.js +34 -20
  189. package/dist/src/utils/signatures/utils.js.map +1 -1
  190. package/dist/src/utils/transactions/SafeTransaction.d.ts +1 -1
  191. package/dist/src/utils/transactions/SafeTransaction.js.map +1 -1
  192. package/dist/src/utils/transactions/gas.d.ts +1 -1
  193. package/dist/src/utils/transactions/gas.js +37 -64
  194. package/dist/src/utils/transactions/gas.js.map +1 -1
  195. package/dist/src/utils/transactions/types.d.ts +17 -1
  196. package/dist/src/utils/transactions/utils.d.ts +11 -2
  197. package/dist/src/utils/transactions/utils.js +117 -27
  198. package/dist/src/utils/transactions/utils.js.map +1 -1
  199. package/dist/src/utils/types.d.ts +4 -0
  200. package/dist/src/utils/types.js +59 -1
  201. package/dist/src/utils/types.js.map +1 -1
  202. package/dist/tsconfig.build.tsbuildinfo +1 -1
  203. package/package.json +25 -34
  204. package/dist/src/SafeFactory.d.ts +0 -15
  205. package/dist/src/SafeFactory.js +0 -136
  206. package/dist/src/SafeFactory.js.map +0 -1
  207. package/dist/src/types/safeFactory.d.ts +0 -31
  208. package/dist/src/types/safeFactory.js +0 -3
  209. package/dist/src/types/safeFactory.js.map +0 -1
  210. package/dist/src/utils/passkeys/PasskeySigner.d.ts +0 -63
  211. package/dist/src/utils/passkeys/PasskeySigner.js +0 -163
  212. package/dist/src/utils/passkeys/PasskeySigner.js.map +0 -1
@@ -1,4 +1,5 @@
1
- import { SafeMultisigTransactionResponse, SafeSignature, SafeTransaction, SafeVersion, TransactionOptions, TransactionResult, MetaTransactionData, Transaction, EIP712TypedData } from '@safe-global/safe-core-sdk-types';
1
+ import { SafeMultisigTransactionResponse, SafeSignature, SafeTransaction, SafeVersion, TransactionOptions, TransactionResult, MetaTransactionData, Transaction, EIP712TypedData } from '@safe-global/types-kit';
2
+ import { ContractInfo } from './contracts/config';
2
3
  import ContractManager from './managers/contractManager';
3
4
  import { AddOwnerTxParams, AddPasskeyOwnerTxParams, ConnectSafeConfig, CreateTransactionProps, PredictedSafeProps, RemoveOwnerTxParams, SafeConfig, SigningMethodType, SwapOwnerTxParams, SafeModulesPaginated, RemovePasskeyOwnerTxParams } from './types';
4
5
  import { SafeTransactionOptionalProps } from './utils/transactions/types';
@@ -59,13 +60,13 @@ declare class Safe {
59
60
  *
60
61
  * @returns The address of the MultiSend contract
61
62
  */
62
- getMultiSendAddress(): Promise<string>;
63
+ getMultiSendAddress(): string;
63
64
  /**
64
65
  * Returns the address of the MultiSendCallOnly contract.
65
66
  *
66
67
  * @returns The address of the MultiSendCallOnly contract
67
68
  */
68
- getMultiSendCallOnlyAddress(): Promise<string>;
69
+ getMultiSendCallOnlyAddress(): string;
69
70
  /**
70
71
  * Checks if the current Safe is deployed.
71
72
  *
@@ -77,7 +78,7 @@ declare class Safe {
77
78
  *
78
79
  * @returns The Safe Singleton contract version
79
80
  */
80
- getContractVersion(): Promise<SafeVersion>;
81
+ getContractVersion(): SafeVersion;
81
82
  /**
82
83
  * Returns the list of Safe owner accounts.
83
84
  *
@@ -392,26 +393,17 @@ declare class Safe {
392
393
  * @async
393
394
  * @param {SafeTransaction} safeTransaction - The Safe transaction to be wrapped into the deployment batch.
394
395
  * @param {TransactionOptions} [transactionOptions] - Optional. Options for the transaction, such as from, gas price, gas limit, etc.
395
- * @param {string} [customSaltNonce] - Optional. a Custom salt nonce to be used for the deployment of the Safe. If not provided, a default value is used.
396
396
  * @returns {Promise<Transaction>} A promise that resolves to a Transaction object representing the prepared batch of transactions.
397
397
  * @throws Will throw an error if the safe is already deployed.
398
398
  *
399
399
  */
400
- wrapSafeTransactionIntoDeploymentBatch(safeTransaction: SafeTransaction, transactionOptions?: TransactionOptions, customSaltNonce?: string): Promise<Transaction>;
400
+ wrapSafeTransactionIntoDeploymentBatch(safeTransaction: SafeTransaction, transactionOptions?: TransactionOptions): Promise<Transaction>;
401
401
  /**
402
- * Creates a Safe deployment transaction.
403
- *
404
- * This function prepares a transaction for the deployment of a Safe.
405
- * Both the saltNonce and options parameters are optional, and if not
406
- * provided, default values will be used.
407
- *
408
- * @async
409
- * @param {string} [customSaltNonce] - Optional. a Custom salt nonce to be used for the deployment of the Safe. If not provided, a default value is used.
410
- * @param {TransactionOptions} [options] - Optional. Options for the transaction, such as gas price, gas limit, etc.
411
- * @returns {Promise<Transaction>} A promise that resolves to a Transaction object representing the prepared Safe deployment transaction.
402
+ * Creates a transaction to deploy a Safe Account.
412
403
  *
404
+ * @returns {Promise<Transaction>} Returns a promise that resolves to an Ethereum transaction with the fields `to`, `value`, and `data`, which can be used to deploy the Safe Account.
413
405
  */
414
- createSafeDeploymentTransaction(customSaltNonce?: string, transactionOptions?: TransactionOptions): Promise<Transaction>;
406
+ createSafeDeploymentTransaction(): Promise<Transaction>;
415
407
  /**
416
408
  * This function creates a batch of the provided Safe transactions using the MultiSend contract.
417
409
  * It groups the transactions together into a single transaction which can then be executed atomically.
@@ -444,5 +436,8 @@ declare class Safe {
444
436
  * @link https://github.com/safe-global/safe-contracts/blob/main/contracts/handler/CompatibilityFallbackHandler.sol
445
437
  */
446
438
  isValidSignature: (messageHash: string, signature?: SafeSignature[] | string) => Promise<boolean>;
439
+ getContractInfo: ({ contractAddress }: {
440
+ contractAddress: string;
441
+ }) => ContractInfo | undefined;
447
442
  }
448
443
  export default Safe;
package/dist/src/Safe.js CHANGED
@@ -13,9 +13,9 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
13
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
- var _Safe_instances, _Safe_predictedSafe, _Safe_safeProvider, _Safe_contractManager, _Safe_ownerManager, _Safe_moduleManager, _Safe_guardManager, _Safe_fallbackHandlerManager, _Safe_MAGIC_VALUE, _Safe_MAGIC_VALUE_BYTES, _Safe_initializeProtocolKit, _Safe_getFallbackHandlerContract;
16
+ var _Safe_instances, _Safe_predictedSafe, _Safe_safeProvider, _Safe_contractManager, _Safe_ownerManager, _Safe_moduleManager, _Safe_guardManager, _Safe_fallbackHandlerManager, _Safe_MAGIC_VALUE, _Safe_MAGIC_VALUE_BYTES, _Safe_initializeProtocolKit, _Safe_addPreValidatedSignature, _Safe_isReadyToExecute, _Safe_getFallbackHandlerContract;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const safe_core_sdk_types_1 = require("@safe-global/safe-core-sdk-types");
18
+ const types_kit_1 = require("@safe-global/types-kit");
19
19
  const utils_1 = require("./contracts/utils");
20
20
  const config_1 = require("./contracts/config");
21
21
  const contractManager_1 = __importDefault(require("./managers/contractManager"));
@@ -32,6 +32,7 @@ const safeDeploymentContracts_1 = require("./contracts/safeDeploymentContracts")
32
32
  const SafeMessage_1 = __importDefault(require("./utils/messages/SafeMessage"));
33
33
  const satisfies_1 = __importDefault(require("semver/functions/satisfies"));
34
34
  const SafeProvider_1 = __importDefault(require("./SafeProvider"));
35
+ const types_3 = require("./utils/types");
35
36
  const getPasskeyOwnerAddress_1 = __importDefault(require("./utils/passkeys/getPasskeyOwnerAddress"));
36
37
  const createPasskeyDeploymentTransaction_1 = __importDefault(require("./utils/passkeys/createPasskeyDeploymentTransaction"));
37
38
  const EQ_OR_GT_1_4_1 = '>=1.4.1';
@@ -67,7 +68,7 @@ class Safe {
67
68
  */
68
69
  this.getSafeMessageHash = async (messageHash) => {
69
70
  const safeAddress = await this.getAddress();
70
- const safeVersion = await this.getContractVersion();
71
+ const safeVersion = this.getContractVersion();
71
72
  const chainId = await this.getChainId();
72
73
  return (0, utils_2.calculateSafeMessageHash)(safeAddress, messageHash, safeVersion, chainId);
73
74
  };
@@ -86,16 +87,18 @@ class Safe {
86
87
  const safeAddress = await this.getAddress();
87
88
  const fallbackHandler = await __classPrivateFieldGet(this, _Safe_instances, "m", _Safe_getFallbackHandlerContract).call(this);
88
89
  const signatureToCheck = signature && Array.isArray(signature) ? (0, utils_2.buildSignatureBytes)(signature) : signature;
89
- // @ts-expect-error Argument of type isValidSignature(bytes32,bytes) is not assignable to parameter of type isValidSignature
90
- const data = fallbackHandler.encode('isValidSignature(bytes32,bytes)', [
91
- messageHash,
92
- signatureToCheck
93
- ]);
94
- // @ts-expect-error Argument of type isValidSignature(bytes32,bytes) is not assignable to parameter of type isValidSignature
95
- const bytesData = fallbackHandler.encode('isValidSignature(bytes,bytes)', [
96
- messageHash,
97
- signatureToCheck
98
- ]);
90
+ // both bytes and bytes32 ends up being resolved to a bytes-like structure which is represented by a `0x` prefixed address.
91
+ // because there is an overload going on, named-tuples (https://www.typescriptlang.org/play/?ts=4.0.2#example/named-tuples) are used to solve the ambiguity.
92
+ const bytes32Tuple = [
93
+ (0, types_3.asHash)(messageHash),
94
+ (0, types_3.asHex)(signatureToCheck)
95
+ ];
96
+ const data = fallbackHandler.encode('isValidSignature', bytes32Tuple);
97
+ const bytesTuple = [
98
+ (0, types_3.asHash)(messageHash),
99
+ (0, types_3.asHex)(signatureToCheck)
100
+ ];
101
+ const bytesData = fallbackHandler.encode('isValidSignature', bytesTuple);
99
102
  try {
100
103
  const isValidSignatureResponse = await Promise.all([
101
104
  __classPrivateFieldGet(this, _Safe_safeProvider, "f").call({
@@ -117,6 +120,9 @@ class Safe {
117
120
  return false;
118
121
  }
119
122
  };
123
+ this.getContractInfo = ({ contractAddress }) => {
124
+ return (0, config_1.getContractInfo)(contractAddress);
125
+ };
120
126
  }
121
127
  /**
122
128
  * Creates an instance of the Safe Core SDK.
@@ -206,7 +212,7 @@ class Safe {
206
212
  */
207
213
  async getAddress() {
208
214
  if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")) {
209
- const safeVersion = await this.getContractVersion();
215
+ const safeVersion = this.getContractVersion();
210
216
  if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
211
217
  throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
212
218
  }
@@ -221,7 +227,7 @@ class Safe {
221
227
  if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
222
228
  throw new Error('Safe is not deployed');
223
229
  }
224
- return await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.getAddress();
230
+ return __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.getAddress();
225
231
  }
226
232
  /**
227
233
  * Returns the ContractManager
@@ -244,16 +250,16 @@ class Safe {
244
250
  *
245
251
  * @returns The address of the MultiSend contract
246
252
  */
247
- async getMultiSendAddress() {
248
- return await __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendContract.getAddress();
253
+ getMultiSendAddress() {
254
+ return __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendContract.getAddress();
249
255
  }
250
256
  /**
251
257
  * Returns the address of the MultiSendCallOnly contract.
252
258
  *
253
259
  * @returns The address of the MultiSendCallOnly contract
254
260
  */
255
- async getMultiSendCallOnlyAddress() {
256
- return await __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendCallOnlyContract.getAddress();
261
+ getMultiSendCallOnlyAddress() {
262
+ return __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendCallOnlyContract.getAddress();
257
263
  }
258
264
  /**
259
265
  * Checks if the current Safe is deployed.
@@ -270,14 +276,14 @@ class Safe {
270
276
  *
271
277
  * @returns The Safe Singleton contract version
272
278
  */
273
- async getContractVersion() {
279
+ getContractVersion() {
274
280
  if (__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
275
- return __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.getVersion();
281
+ return __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.safeVersion;
276
282
  }
277
283
  if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f")?.safeDeploymentConfig?.safeVersion) {
278
- return Promise.resolve(__classPrivateFieldGet(this, _Safe_predictedSafe, "f").safeDeploymentConfig.safeVersion);
284
+ return __classPrivateFieldGet(this, _Safe_predictedSafe, "f").safeDeploymentConfig.safeVersion;
279
285
  }
280
- return Promise.resolve(config_1.DEFAULT_SAFE_VERSION);
286
+ return config_1.DEFAULT_SAFE_VERSION;
281
287
  }
282
288
  /**
283
289
  * Returns the list of Safe owner accounts.
@@ -393,7 +399,7 @@ class Safe {
393
399
  * @throws "Invalid empty array of transactions"
394
400
  */
395
401
  async createTransaction({ transactions, onlyCalls = false, options }) {
396
- const safeVersion = await this.getContractVersion();
402
+ const safeVersion = this.getContractVersion();
397
403
  if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f") && !(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
398
404
  throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
399
405
  }
@@ -408,10 +414,10 @@ class Safe {
408
414
  const multiSendData = (0, utils_3.encodeMultiSendData)(transactions.map(utils_3.standardizeMetaTransactionData));
409
415
  const multiSendTransaction = {
410
416
  ...options,
411
- to: await multiSendContract.getAddress(),
417
+ to: multiSendContract.getAddress(),
412
418
  value: '0',
413
- data: multiSendContract.encode('multiSend', [multiSendData]),
414
- operation: safe_core_sdk_types_1.OperationType.DelegateCall
419
+ data: multiSendContract.encode('multiSend', [(0, types_3.asHex)(multiSendData)]),
420
+ operation: types_kit_1.OperationType.DelegateCall
415
421
  };
416
422
  newTransaction = multiSendTransaction;
417
423
  }
@@ -485,7 +491,7 @@ class Safe {
485
491
  */
486
492
  async getTransactionHash(safeTransaction) {
487
493
  const safeAddress = await this.getAddress();
488
- const safeVersion = await this.getContractVersion();
494
+ const safeVersion = this.getContractVersion();
489
495
  const chainId = await this.getChainId();
490
496
  return (0, utils_2.calculateSafeTransactionHash)(safeAddress, safeTransaction.data, safeVersion, chainId);
491
497
  }
@@ -500,7 +506,7 @@ class Safe {
500
506
  const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
501
507
  if (isPasskeySigner && signerAddress) {
502
508
  let signature = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").signMessage(hash);
503
- signature = (0, utils_2.adjustVInSignature)(types_1.SigningMethod.ETH_SIGN, signature, hash, signerAddress);
509
+ signature = await (0, utils_2.adjustVInSignature)(types_1.SigningMethod.ETH_SIGN, signature, hash, signerAddress);
504
510
  const safeSignature = new utils_2.EthSafeSignature(signerAddress, signature, true);
505
511
  return safeSignature;
506
512
  }
@@ -528,16 +534,15 @@ class Safe {
528
534
  * @returns The signed Safe message
529
535
  */
530
536
  async signMessage(message, signingMethod = types_1.SigningMethod.ETH_SIGN_TYPED_DATA_V4, preimageSafeAddress) {
531
- const owners = await this.getOwners();
532
537
  const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
533
538
  if (!signerAddress) {
534
- throw new Error('SafeProvider must be initialized with a signer to use this method');
539
+ throw new Error('The protocol-kit requires a signer to use this method');
535
540
  }
536
- const addressIsOwner = owners.some((owner) => signerAddress && (0, utils_2.sameString)(owner, signerAddress));
541
+ const addressIsOwner = await this.isOwner(signerAddress);
537
542
  if (!addressIsOwner) {
538
543
  throw new Error('Messages can only be signed by Safe owners');
539
544
  }
540
- const safeVersion = await this.getContractVersion();
545
+ const safeVersion = this.getContractVersion();
541
546
  if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE &&
542
547
  (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_4_1) &&
543
548
  !preimageSafeAddress) {
@@ -587,7 +592,7 @@ class Safe {
587
592
  async signTypedData(eip712Data, methodVersion) {
588
593
  const safeEIP712Args = {
589
594
  safeAddress: await this.getAddress(),
590
- safeVersion: await this.getContractVersion(),
595
+ safeVersion: this.getContractVersion(),
591
596
  chainId: await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId(),
592
597
  data: eip712Data.data
593
598
  };
@@ -609,16 +614,15 @@ class Safe {
609
614
  const transaction = (0, utils_2.isSafeMultisigTransactionResponse)(safeTransaction)
610
615
  ? await this.toSafeTransactionType(safeTransaction)
611
616
  : safeTransaction;
612
- const owners = await this.getOwners();
613
617
  const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
614
618
  if (!signerAddress) {
615
- throw new Error('SafeProvider must be initialized with a signer to use this method');
619
+ throw new Error('The protocol-kit requires a signer to use this method');
616
620
  }
617
- const addressIsOwner = owners.some((owner) => signerAddress && (0, utils_2.sameString)(owner, signerAddress));
621
+ const addressIsOwner = await this.isOwner(signerAddress);
618
622
  if (!addressIsOwner) {
619
623
  throw new Error('Transactions can only be signed by Safe owners');
620
624
  }
621
- const safeVersion = await this.getContractVersion();
625
+ const safeVersion = this.getContractVersion();
622
626
  if (signingMethod === types_1.SigningMethod.SAFE_SIGNATURE &&
623
627
  (0, satisfies_1.default)(safeVersion, EQ_OR_GT_1_3_0) &&
624
628
  !preimageSafeAddress) {
@@ -640,7 +644,7 @@ class Safe {
640
644
  signature = await this.signTypedData(transaction, undefined);
641
645
  }
642
646
  else {
643
- const safeVersion = await this.getContractVersion();
647
+ const safeVersion = this.getContractVersion();
644
648
  const chainId = await this.getChainId();
645
649
  if (!(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ETH_SIGN, safeVersion)) {
646
650
  throw new Error('eth_sign is only supported by Safes >= v1.1.0');
@@ -677,12 +681,11 @@ class Safe {
677
681
  if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
678
682
  throw new Error('Safe is not deployed');
679
683
  }
680
- const owners = await this.getOwners();
681
684
  const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
682
685
  if (!signerAddress) {
683
- throw new Error('SafeProvider must be initialized with a signer to use this method');
686
+ throw new Error('The protocol-kit requires a signer to use this method');
684
687
  }
685
- const addressIsOwner = owners.some((owner) => signerAddress && (0, utils_2.sameString)(owner, signerAddress));
688
+ const addressIsOwner = await this.isOwner(signerAddress);
686
689
  if (!addressIsOwner) {
687
690
  throw new Error('Transaction hashes can only be approved by Safe owners');
688
691
  }
@@ -699,12 +702,15 @@ class Safe {
699
702
  */
700
703
  async getOwnersWhoApprovedTx(txHash) {
701
704
  if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
702
- throw new Error('Safe is not deployed');
705
+ return [];
703
706
  }
704
707
  const owners = await this.getOwners();
705
708
  const ownersWhoApproved = [];
706
709
  for (const owner of owners) {
707
- const [approved] = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.approvedHashes([owner, txHash]);
710
+ const [approved] = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.approvedHashes([
711
+ (0, types_3.asHex)(owner),
712
+ (0, types_3.asHash)(txHash)
713
+ ]);
708
714
  if (approved > 0) {
709
715
  ownersWhoApproved.push(owner);
710
716
  }
@@ -722,6 +728,10 @@ class Safe {
722
728
  * @throws "Current version of the Safe does not support the fallback handler functionality"
723
729
  */
724
730
  async createEnableFallbackHandlerTx(fallbackHandlerAddress, options) {
731
+ const safeVersion = await this.getContractVersion();
732
+ if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f") && !(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
733
+ throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
734
+ }
725
735
  const safeTransactionData = {
726
736
  to: await this.getAddress(),
727
737
  value: '0',
@@ -742,6 +752,10 @@ class Safe {
742
752
  * @throws "Current version of the Safe does not support the fallback handler functionality"
743
753
  */
744
754
  async createDisableFallbackHandlerTx(options) {
755
+ const safeVersion = await this.getContractVersion();
756
+ if (__classPrivateFieldGet(this, _Safe_predictedSafe, "f") && !(0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
757
+ throw new Error('Account Abstraction functionality is not available for Safes with version lower than v1.3.0');
758
+ }
745
759
  const safeTransactionData = {
746
760
  to: await this.getAddress(),
747
761
  value: '0',
@@ -1009,12 +1023,12 @@ class Safe {
1009
1023
  for (const owner of ownersWhoApprovedTx) {
1010
1024
  signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(owner));
1011
1025
  }
1012
- const owners = await this.getOwners();
1013
1026
  const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
1014
1027
  if (!signerAddress) {
1015
- throw new Error('SafeProvider must be initialized with a signer to use this method');
1028
+ throw new Error('The protocol-kit requires a signer to use this method');
1016
1029
  }
1017
- if (owners.includes(signerAddress)) {
1030
+ const addressIsOwner = await this.isOwner(signerAddress);
1031
+ if (addressIsOwner) {
1018
1032
  signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(signerAddress));
1019
1033
  }
1020
1034
  const isTxValid = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.isValidTransaction(signedSafeTransaction, {
@@ -1040,24 +1054,8 @@ class Safe {
1040
1054
  const transaction = (0, utils_2.isSafeMultisigTransactionResponse)(safeTransaction)
1041
1055
  ? await this.toSafeTransactionType(safeTransaction)
1042
1056
  : safeTransaction;
1043
- const signedSafeTransaction = await this.copyTransaction(transaction);
1044
- const txHash = await this.getTransactionHash(signedSafeTransaction);
1045
- const ownersWhoApprovedTx = await this.getOwnersWhoApprovedTx(txHash);
1046
- for (const owner of ownersWhoApprovedTx) {
1047
- signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(owner));
1048
- }
1049
- const owners = await this.getOwners();
1050
- const threshold = await this.getThreshold();
1051
- const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
1052
- if (threshold > signedSafeTransaction.signatures.size &&
1053
- signerAddress &&
1054
- owners.includes(signerAddress)) {
1055
- signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(signerAddress));
1056
- }
1057
- if (threshold > signedSafeTransaction.signatures.size) {
1058
- const signaturesMissing = threshold - signedSafeTransaction.signatures.size;
1059
- throw new Error(`There ${signaturesMissing > 1 ? 'are' : 'is'} ${signaturesMissing} signature${signaturesMissing > 1 ? 's' : ''} missing`);
1060
- }
1057
+ const signedSafeTransaction = await __classPrivateFieldGet(this, _Safe_instances, "m", _Safe_addPreValidatedSignature).call(this, transaction);
1058
+ await __classPrivateFieldGet(this, _Safe_instances, "m", _Safe_isReadyToExecute).call(this, signedSafeTransaction);
1061
1059
  const value = BigInt(signedSafeTransaction.data.value);
1062
1060
  if (value !== 0n) {
1063
1061
  const balance = await this.getBalance();
@@ -1065,6 +1063,7 @@ class Safe {
1065
1063
  throw new Error('Not enough Ether funds');
1066
1064
  }
1067
1065
  }
1066
+ const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
1068
1067
  const txResponse = await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.execTransaction(signedSafeTransaction, {
1069
1068
  from: signerAddress,
1070
1069
  ...options
@@ -1080,15 +1079,15 @@ class Safe {
1080
1079
  *
1081
1080
  */
1082
1081
  async getEncodedTransaction(safeTransaction) {
1083
- const safeVersion = await this.getContractVersion();
1082
+ const safeVersion = this.getContractVersion();
1084
1083
  const chainId = await this.getChainId();
1085
1084
  const customContracts = __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()];
1086
1085
  const isL1SafeSingleton = __classPrivateFieldGet(this, _Safe_contractManager, "f").isL1SafeSingleton;
1087
- const safeSingletonContract = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSafeContract({
1086
+ const safeSingletonContract = await (0, safeDeploymentContracts_1.getSafeContract)({
1087
+ safeProvider: __classPrivateFieldGet(this, _Safe_safeProvider, "f"),
1088
1088
  safeVersion,
1089
1089
  isL1SafeSingleton,
1090
- customContractAbi: customContracts?.safeSingletonAbi,
1091
- customContractAddress: customContracts?.safeSingletonAddress
1090
+ customContracts
1092
1091
  });
1093
1092
  const encodedTransaction = safeSingletonContract.encode('execTransaction', [
1094
1093
  safeTransaction.data.to,
@@ -1113,32 +1112,31 @@ class Safe {
1113
1112
  * @async
1114
1113
  * @param {SafeTransaction} safeTransaction - The Safe transaction to be wrapped into the deployment batch.
1115
1114
  * @param {TransactionOptions} [transactionOptions] - Optional. Options for the transaction, such as from, gas price, gas limit, etc.
1116
- * @param {string} [customSaltNonce] - Optional. a Custom salt nonce to be used for the deployment of the Safe. If not provided, a default value is used.
1117
1115
  * @returns {Promise<Transaction>} A promise that resolves to a Transaction object representing the prepared batch of transactions.
1118
1116
  * @throws Will throw an error if the safe is already deployed.
1119
1117
  *
1120
1118
  */
1121
- async wrapSafeTransactionIntoDeploymentBatch(safeTransaction, transactionOptions, customSaltNonce) {
1119
+ async wrapSafeTransactionIntoDeploymentBatch(safeTransaction, transactionOptions) {
1122
1120
  const isSafeDeployed = await this.isSafeDeployed();
1123
1121
  // if the safe is already deployed throws an error
1124
1122
  if (isSafeDeployed) {
1125
1123
  throw new Error('Safe already deployed');
1126
1124
  }
1127
1125
  // we create the deployment transaction
1128
- const safeDeploymentTransaction = await this.createSafeDeploymentTransaction(customSaltNonce);
1126
+ const safeDeploymentTransaction = await this.createSafeDeploymentTransaction();
1129
1127
  // First transaction of the batch: The Safe deployment Transaction
1130
1128
  const safeDeploymentBatchTransaction = {
1131
1129
  to: safeDeploymentTransaction.to,
1132
1130
  value: safeDeploymentTransaction.value,
1133
1131
  data: safeDeploymentTransaction.data,
1134
- operation: safe_core_sdk_types_1.OperationType.Call
1132
+ operation: types_kit_1.OperationType.Call
1135
1133
  };
1136
1134
  // Second transaction of the batch: The Safe Transaction
1137
1135
  const safeBatchTransaction = {
1138
1136
  to: await this.getAddress(),
1139
1137
  value: '0',
1140
1138
  data: await this.getEncodedTransaction(safeTransaction),
1141
- operation: safe_core_sdk_types_1.OperationType.Call
1139
+ operation: types_kit_1.OperationType.Call
1142
1140
  };
1143
1141
  // transactions for the batch
1144
1142
  const transactions = [safeDeploymentBatchTransaction, safeBatchTransaction];
@@ -1147,36 +1145,39 @@ class Safe {
1147
1145
  return safeDeploymentBatch;
1148
1146
  }
1149
1147
  /**
1150
- * Creates a Safe deployment transaction.
1151
- *
1152
- * This function prepares a transaction for the deployment of a Safe.
1153
- * Both the saltNonce and options parameters are optional, and if not
1154
- * provided, default values will be used.
1155
- *
1156
- * @async
1157
- * @param {string} [customSaltNonce] - Optional. a Custom salt nonce to be used for the deployment of the Safe. If not provided, a default value is used.
1158
- * @param {TransactionOptions} [options] - Optional. Options for the transaction, such as gas price, gas limit, etc.
1159
- * @returns {Promise<Transaction>} A promise that resolves to a Transaction object representing the prepared Safe deployment transaction.
1148
+ * Creates a transaction to deploy a Safe Account.
1160
1149
  *
1150
+ * @returns {Promise<Transaction>} Returns a promise that resolves to an Ethereum transaction with the fields `to`, `value`, and `data`, which can be used to deploy the Safe Account.
1161
1151
  */
1162
- async createSafeDeploymentTransaction(customSaltNonce, transactionOptions) {
1152
+ async createSafeDeploymentTransaction() {
1163
1153
  if (!__classPrivateFieldGet(this, _Safe_predictedSafe, "f")) {
1164
- throw new Error('Predict Safe should be present');
1154
+ throw new Error('Predict Safe should be present to build the Safe deployement transaction');
1165
1155
  }
1166
- const { safeAccountConfig, safeDeploymentConfig } = __classPrivateFieldGet(this, _Safe_predictedSafe, "f");
1167
- const safeVersion = await this.getContractVersion();
1156
+ const { safeAccountConfig, safeDeploymentConfig = {} } = __classPrivateFieldGet(this, _Safe_predictedSafe, "f");
1157
+ (0, utils_1.validateSafeAccountConfig)(safeAccountConfig);
1158
+ (0, utils_1.validateSafeDeploymentConfig)(safeDeploymentConfig);
1168
1159
  const safeProvider = __classPrivateFieldGet(this, _Safe_safeProvider, "f");
1169
1160
  const chainId = await safeProvider.getChainId();
1161
+ const safeVersion = safeDeploymentConfig?.safeVersion || config_1.DEFAULT_SAFE_VERSION;
1162
+ const saltNonce = safeDeploymentConfig?.saltNonce || (0, utils_1.getChainSpecificDefaultSaltNonce)(chainId);
1163
+ // we only check if the safe is deployed if safeVersion >= 1.3.0
1164
+ if ((0, utils_2.hasSafeFeature)(utils_2.SAFE_FEATURES.ACCOUNT_ABSTRACTION, safeVersion)) {
1165
+ const isSafeDeployed = await this.isSafeDeployed();
1166
+ // if the safe is already deployed throws an error
1167
+ if (isSafeDeployed) {
1168
+ throw new Error('Safe already deployed');
1169
+ }
1170
+ }
1170
1171
  const isL1SafeSingleton = __classPrivateFieldGet(this, _Safe_contractManager, "f").isL1SafeSingleton;
1171
1172
  const customContracts = __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()];
1172
- const safeSingletonContract = await safeProvider.getSafeContract({
1173
+ const safeSingletonContract = await (0, safeDeploymentContracts_1.getSafeContract)({
1174
+ safeProvider,
1173
1175
  safeVersion,
1174
1176
  isL1SafeSingleton,
1175
- customContractAddress: customContracts?.safeSingletonAddress,
1176
- customContractAbi: customContracts?.safeSingletonAbi
1177
+ customContracts
1177
1178
  });
1178
1179
  // we use the SafeProxyFactory.sol contract, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/proxies/SafeProxyFactory.sol
1179
- const safeProxyFactoryContract = await (0, safeDeploymentContracts_1.getProxyFactoryContract)({
1180
+ const safeProxyFactoryContract = await (0, safeDeploymentContracts_1.getSafeProxyFactoryContract)({
1180
1181
  safeProvider,
1181
1182
  safeVersion,
1182
1183
  customContracts
@@ -1188,17 +1189,13 @@ class Safe {
1188
1189
  safeAccountConfig: safeAccountConfig,
1189
1190
  customContracts
1190
1191
  });
1191
- const saltNonce = customSaltNonce ||
1192
- safeDeploymentConfig?.saltNonce ||
1193
- (0, utils_1.getChainSpecificDefaultSaltNonce)(chainId);
1194
1192
  const safeDeployTransactionData = {
1195
- ...transactionOptions, // optional transaction options like from, gasLimit, gasPrice...
1196
- to: await safeProxyFactoryContract.getAddress(),
1193
+ to: safeProxyFactoryContract.getAddress(),
1197
1194
  value: '0',
1198
1195
  // 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
1199
1196
  data: safeProxyFactoryContract.encode('createProxyWithNonce', [
1200
- await safeSingletonContract.getAddress(),
1201
- initializer, // call to the setup method to set the threshold & owners of the new Safe
1197
+ (0, types_3.asHex)(safeSingletonContract.getAddress()),
1198
+ (0, types_3.asHex)(initializer), // call to the setup method to set the threshold & owners of the new Safe
1202
1199
  BigInt(saltNonce)
1203
1200
  ])
1204
1201
  };
@@ -1216,20 +1213,15 @@ class Safe {
1216
1213
  *
1217
1214
  */
1218
1215
  async createTransactionBatch(transactions, transactionOptions) {
1219
- const chainId = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId();
1220
1216
  // we use the MultiSend contract to create the batch, see: https://github.com/safe-global/safe-contracts/blob/main/contracts/libraries/MultiSendCallOnly.sol
1221
- const multiSendCallOnlyContract = await (0, safeDeploymentContracts_1.getMultiSendCallOnlyContract)({
1222
- safeProvider: __classPrivateFieldGet(this, _Safe_safeProvider, "f"),
1223
- safeVersion: await this.getContractVersion(),
1224
- customContracts: __classPrivateFieldGet(this, _Safe_contractManager, "f").contractNetworks?.[chainId.toString()]
1225
- });
1217
+ const multiSendCallOnlyContract = __classPrivateFieldGet(this, _Safe_contractManager, "f").multiSendCallOnlyContract;
1226
1218
  // multiSend method with the transactions encoded
1227
1219
  const batchData = multiSendCallOnlyContract.encode('multiSend', [
1228
- (0, utils_3.encodeMultiSendData)(transactions) // encoded transactions
1220
+ (0, types_3.asHex)((0, utils_3.encodeMultiSendData)(transactions)) // encoded transactions
1229
1221
  ]);
1230
1222
  const transactionBatch = {
1231
1223
  ...transactionOptions, // optional transaction options like from, gasLimit, gasPrice...
1232
- to: await multiSendCallOnlyContract.getAddress(),
1224
+ to: multiSendCallOnlyContract.getAddress(),
1233
1225
  value: '0',
1234
1226
  data: batchData
1235
1227
  };
@@ -1247,7 +1239,12 @@ _Safe_predictedSafe = new WeakMap(), _Safe_safeProvider = new WeakMap(), _Safe_c
1247
1239
  */
1248
1240
  async function _Safe_initializeProtocolKit(config) {
1249
1241
  const { provider, signer, isL1SafeSingleton, contractNetworks } = config;
1250
- __classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init(provider, signer, config_1.DEFAULT_SAFE_VERSION, contractNetworks), "f");
1242
+ __classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init({
1243
+ provider,
1244
+ signer,
1245
+ safeVersion: config_1.DEFAULT_SAFE_VERSION,
1246
+ contractNetworks
1247
+ }), "f");
1251
1248
  if ((0, types_2.isSafeConfigWithPredictedSafe)(config)) {
1252
1249
  __classPrivateFieldSet(this, _Safe_predictedSafe, config.predictedSafe, "f");
1253
1250
  __classPrivateFieldSet(this, _Safe_contractManager, await contractManager_1.default.init({
@@ -1265,8 +1262,13 @@ async function _Safe_initializeProtocolKit(config) {
1265
1262
  contractNetworks
1266
1263
  }, __classPrivateFieldGet(this, _Safe_safeProvider, "f")), "f");
1267
1264
  }
1268
- const safeVersion = await this.getContractVersion();
1269
- __classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init(provider, signer, safeVersion, contractNetworks), "f");
1265
+ const safeVersion = this.getContractVersion();
1266
+ __classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init({
1267
+ provider,
1268
+ signer,
1269
+ safeVersion,
1270
+ contractNetworks
1271
+ }), "f");
1270
1272
  __classPrivateFieldSet(this, _Safe_ownerManager, new ownerManager_1.default(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract), "f");
1271
1273
  __classPrivateFieldSet(this, _Safe_moduleManager, new moduleManager_1.default(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract), "f");
1272
1274
  __classPrivateFieldSet(this, _Safe_guardManager, new guardManager_1.default(__classPrivateFieldGet(this, _Safe_safeProvider, "f"), __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract), "f");
@@ -1275,7 +1277,52 @@ async function _Safe_initializeProtocolKit(config) {
1275
1277
  if (isPasskeySigner) {
1276
1278
  const safeAddress = await this.getAddress();
1277
1279
  const owners = await this.getOwners();
1278
- __classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init(provider, signer, safeVersion, contractNetworks, safeAddress, owners), "f");
1280
+ __classPrivateFieldSet(this, _Safe_safeProvider, await SafeProvider_1.default.init({
1281
+ provider,
1282
+ signer,
1283
+ safeVersion,
1284
+ contractNetworks,
1285
+ safeAddress,
1286
+ owners
1287
+ }), "f");
1288
+ }
1289
+ }, _Safe_addPreValidatedSignature =
1290
+ /**
1291
+ * Adds a PreValidatedSignature to the transaction if the threshold is not reached.
1292
+ *
1293
+ * @async
1294
+ * @param {SafeTransaction} transaction - The transaction to add a signature to.
1295
+ * @returns {Promise<SafeTransaction>} A promise that resolves to the signed transaction.
1296
+ */
1297
+ async function _Safe_addPreValidatedSignature(transaction) {
1298
+ const signedSafeTransaction = await this.copyTransaction(transaction);
1299
+ const txHash = await this.getTransactionHash(signedSafeTransaction);
1300
+ const ownersWhoApprovedTx = await this.getOwnersWhoApprovedTx(txHash);
1301
+ for (const owner of ownersWhoApprovedTx) {
1302
+ signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(owner));
1303
+ }
1304
+ const owners = await this.getOwners();
1305
+ const threshold = await this.getThreshold();
1306
+ const signerAddress = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getSignerAddress();
1307
+ if (threshold > signedSafeTransaction.signatures.size &&
1308
+ signerAddress &&
1309
+ owners.includes(signerAddress)) {
1310
+ signedSafeTransaction.addSignature((0, utils_2.generatePreValidatedSignature)(signerAddress));
1311
+ }
1312
+ return signedSafeTransaction;
1313
+ }, _Safe_isReadyToExecute =
1314
+ /**
1315
+ * Checks if the transaction has enough signatures to be executed.
1316
+ *
1317
+ * @async
1318
+ * @param {SafeTransaction} transaction - The Safe transaction to check.
1319
+ * @throws Will throw an error if the required number of signatures is not met.
1320
+ */
1321
+ async function _Safe_isReadyToExecute(transaction) {
1322
+ const threshold = await this.getThreshold();
1323
+ if (threshold > transaction.signatures.size) {
1324
+ const signaturesMissing = threshold - transaction.signatures.size;
1325
+ throw new Error(`There ${signaturesMissing > 1 ? 'are' : 'is'} ${signaturesMissing} signature${signaturesMissing > 1 ? 's' : ''} missing`);
1279
1326
  }
1280
1327
  }, _Safe_getFallbackHandlerContract =
1281
1328
  /**
@@ -1287,7 +1334,7 @@ async function _Safe_getFallbackHandlerContract() {
1287
1334
  if (!__classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract) {
1288
1335
  throw new Error('Safe is not deployed');
1289
1336
  }
1290
- const safeVersion = (await __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.getVersion()) ?? config_1.DEFAULT_SAFE_VERSION;
1337
+ const safeVersion = __classPrivateFieldGet(this, _Safe_contractManager, "f").safeContract.safeVersion ?? config_1.DEFAULT_SAFE_VERSION;
1291
1338
  const chainId = await __classPrivateFieldGet(this, _Safe_safeProvider, "f").getChainId();
1292
1339
  const compatibilityFallbackHandlerContract = await (0, safeDeploymentContracts_1.getCompatibilityFallbackHandlerContract)({
1293
1340
  safeProvider: __classPrivateFieldGet(this, _Safe_safeProvider, "f"),