@safe-global/protocol-kit 0.1.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -16
- package/dist/src/Safe.d.ts +13 -52
- package/dist/src/Safe.js +180 -57
- package/dist/src/Safe.js.map +1 -1
- package/dist/src/adapters/ethers/EthersAdapter.d.ts +8 -8
- package/dist/src/adapters/ethers/EthersAdapter.js +23 -31
- package/dist/src/adapters/ethers/EthersAdapter.js.map +1 -1
- package/dist/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.d.ts +1 -1
- package/dist/src/adapters/ethers/contracts/CreateCall/CreateCallEthersContract.js +1 -1
- package/dist/src/adapters/ethers/contracts/GnosisSafe/GnosisSafeContractEthers.d.ts +1 -1
- package/dist/src/adapters/ethers/contracts/GnosisSafe/GnosisSafeContractEthers.js +1 -1
- package/dist/src/adapters/ethers/contracts/GnosisSafeProxyFactory/GnosisSafeProxyFactoryEthersContract.d.ts +1 -1
- package/dist/src/adapters/ethers/contracts/GnosisSafeProxyFactory/GnosisSafeProxyFactoryEthersContract.js +1 -1
- package/dist/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibEthersContract.d.ts +1 -1
- package/dist/src/adapters/ethers/contracts/SignMessageLib/SignMessageLibEthersContract.js +1 -1
- package/dist/src/adapters/ethers/utils/index.d.ts +8 -0
- package/dist/src/adapters/ethers/utils/index.js +15 -1
- package/dist/src/adapters/ethers/utils/index.js.map +1 -1
- package/dist/src/adapters/web3/Web3Adapter.d.ts +8 -8
- package/dist/src/adapters/web3/Web3Adapter.js +17 -9
- package/dist/src/adapters/web3/Web3Adapter.js.map +1 -1
- package/dist/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.d.ts +1 -1
- package/dist/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.js +1 -6
- package/dist/src/adapters/web3/contracts/CreateCall/CreateCallWeb3Contract.js.map +1 -1
- package/dist/src/adapters/web3/contracts/GnosisSafe/GnosisSafeContractWeb3.d.ts +1 -1
- package/dist/src/adapters/web3/contracts/GnosisSafe/GnosisSafeContractWeb3.js +1 -6
- package/dist/src/adapters/web3/contracts/GnosisSafe/GnosisSafeContractWeb3.js.map +1 -1
- package/dist/src/adapters/web3/contracts/GnosisSafeProxyFactory/GnosisSafeProxyFactoryWeb3Contract.d.ts +1 -1
- package/dist/src/adapters/web3/contracts/GnosisSafeProxyFactory/GnosisSafeProxyFactoryWeb3Contract.js +1 -6
- package/dist/src/adapters/web3/contracts/GnosisSafeProxyFactory/GnosisSafeProxyFactoryWeb3Contract.js.map +1 -1
- package/dist/src/adapters/web3/contracts/SignMessageLib/SignMessageLibWeb3Contract.d.ts +1 -1
- package/dist/src/adapters/web3/contracts/SignMessageLib/SignMessageLibWeb3Contract.js +1 -6
- package/dist/src/adapters/web3/contracts/SignMessageLib/SignMessageLibWeb3Contract.js.map +1 -1
- package/dist/src/contracts/safeDeploymentContracts.d.ts +8 -9
- package/dist/src/contracts/safeDeploymentContracts.js +15 -15
- package/dist/src/contracts/safeDeploymentContracts.js.map +1 -1
- package/dist/src/contracts/utils.d.ts +21 -0
- package/dist/src/contracts/utils.js +105 -0
- package/dist/src/contracts/utils.js.map +1 -0
- package/dist/src/index.d.ts +8 -6
- package/dist/src/index.js +27 -20
- package/dist/src/index.js.map +1 -1
- package/dist/src/managers/contractManager.d.ts +4 -5
- package/dist/src/managers/contractManager.js +27 -22
- package/dist/src/managers/contractManager.js.map +1 -1
- package/dist/src/managers/fallbackHandlerManager.d.ts +1 -1
- package/dist/src/managers/fallbackHandlerManager.js +9 -0
- package/dist/src/managers/fallbackHandlerManager.js.map +1 -1
- package/dist/src/managers/guardManager.d.ts +1 -1
- package/dist/src/managers/guardManager.js +9 -0
- package/dist/src/managers/guardManager.js.map +1 -1
- package/dist/src/managers/moduleManager.d.ts +1 -1
- package/dist/src/managers/moduleManager.js +12 -0
- package/dist/src/managers/moduleManager.js.map +1 -1
- package/dist/src/managers/ownerManager.d.ts +1 -1
- package/dist/src/managers/ownerManager.js +21 -0
- package/dist/src/managers/ownerManager.js.map +1 -1
- package/dist/src/safeFactory/index.d.ts +5 -23
- package/dist/src/safeFactory/index.js +23 -63
- package/dist/src/safeFactory/index.js.map +1 -1
- package/dist/src/types/index.d.ts +114 -0
- package/dist/src/utils/eip-3770/config.js +11 -0
- package/dist/src/utils/eip-3770/config.js.map +1 -1
- package/dist/src/utils/index.d.ts +2 -1
- package/dist/src/utils/index.js +2 -1
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/safeVersions.d.ts +2 -1
- package/dist/src/utils/safeVersions.js +3 -1
- package/dist/src/utils/safeVersions.js.map +1 -1
- package/dist/src/utils/signatures/SafeSignature.d.ts +1 -2
- package/dist/src/utils/signatures/SafeSignature.js +3 -2
- package/dist/src/utils/signatures/SafeSignature.js.map +1 -1
- package/dist/src/utils/signatures/index.d.ts +2 -12
- package/dist/src/utils/signatures/index.js +15 -90
- package/dist/src/utils/signatures/index.js.map +1 -1
- package/dist/src/utils/signatures/utils.d.ts +11 -0
- package/dist/src/utils/signatures/utils.js +91 -0
- package/dist/src/utils/signatures/utils.js.map +1 -0
- package/dist/src/utils/transactions/gas.d.ts +1 -1
- package/dist/src/utils/transactions/gas.js +10 -10
- package/dist/src/utils/transactions/gas.js.map +1 -1
- package/dist/src/utils/transactions/utils.d.ts +3 -2
- package/dist/src/utils/transactions/utils.js +27 -14
- package/dist/src/utils/transactions/utils.js.map +1 -1
- package/dist/src/utils/types.d.ts +2 -0
- package/dist/src/utils/types.js +8 -0
- package/dist/src/utils/types.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/dist/src/safeFactory/utils.d.ts +0 -3
- package/dist/src/safeFactory/utils.js +0 -19
- package/dist/src/safeFactory/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Protocol Kit
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/%40safe-global%2Fprotocol-kit)
|
|
4
4
|
[](https://github.com/safe-global/safe-core-sdk/releases)
|
|
5
5
|
[](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md)
|
|
6
6
|
|
|
@@ -36,7 +36,7 @@ npm build
|
|
|
36
36
|
|
|
37
37
|
## <a name="getting-started">Getting Started</a>
|
|
38
38
|
|
|
39
|
-
The following steps show how to set up the
|
|
39
|
+
The following steps show how to set up the Protocol Kit, deploy a new Safe, create a Safe transaction, generate the required signatures from owners and execute the transaction. However, using the Protocol Kit alone will not allow for the collection of owner signatures off-chain. To do this and be able to see and confirm the pending transactions shown in the [Safe Web App](https://app.safe.global/), it is recommended that you follow this other [guide](/guides/integrating-the-safe-core-sdk.md) that covers the use of the Protocol Kit, combined with the API Kit.
|
|
40
40
|
|
|
41
41
|
### 1. Instantiate an EthAdapter
|
|
42
42
|
|
|
@@ -69,15 +69,15 @@ const safeAccountConfig: SafeAccountConfig = {
|
|
|
69
69
|
const safeSdk: Safe = await safeFactory.deploySafe({ safeAccountConfig })
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
The `deploySafe` method executes a transaction from the `owner1` account, deploys a new Safe and returns an instance of the
|
|
72
|
+
The `deploySafe` method executes a transaction from the `owner1` account, deploys a new Safe and returns an instance of the Protocol Kit connected to the new Safe. Check the `deploySafe` method in the [API Reference](#factory-api) for more details on additional configuration parameters and callbacks.
|
|
73
73
|
|
|
74
74
|
Call the `getAddress` method, for example, to check the address of the newly deployed Safe.
|
|
75
75
|
|
|
76
76
|
```js
|
|
77
|
-
const newSafeAddress = safeSdk.getAddress()
|
|
77
|
+
const newSafeAddress = await safeSdk.getAddress()
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
To instantiate the
|
|
80
|
+
To instantiate the Protocol Kit from an existing Safe just pass to it an instance of the `EthAdapter` class and the Safe address.
|
|
81
81
|
|
|
82
82
|
```js
|
|
83
83
|
import Safe from '@safe-global/protocol-kit'
|
|
@@ -202,7 +202,7 @@ const safeFactory = await SafeFactory.create({ ethAdapter })
|
|
|
202
202
|
|
|
203
203
|
### deploySafe
|
|
204
204
|
|
|
205
|
-
Deploys a new Safe and returns an instance of the
|
|
205
|
+
Deploys a new Safe and returns an instance of the Protocol Kit connected to the deployed Safe. The address of the Master Copy, Safe contract version and the contract (`GnosisSafe.sol` or `GnosisSafeL2.sol`) of the deployed Safe will depend on the initialization of the `safeFactory` instance.
|
|
206
206
|
|
|
207
207
|
```js
|
|
208
208
|
const safeAccountConfig: SafeAccountConfig = {
|
|
@@ -219,7 +219,7 @@ const safeAccountConfig: SafeAccountConfig = {
|
|
|
219
219
|
const safeSdk = await safeFactory.deploySafe({ safeAccountConfig })
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
This method can optionally receive the `
|
|
222
|
+
This method can optionally receive the `saltNonce` parameter.
|
|
223
223
|
|
|
224
224
|
```js
|
|
225
225
|
const safeAccountConfig: SafeAccountConfig = {
|
|
@@ -232,9 +232,10 @@ const safeAccountConfig: SafeAccountConfig = {
|
|
|
232
232
|
payment, // Optional
|
|
233
233
|
paymentReceiver // Optional
|
|
234
234
|
}
|
|
235
|
-
const safeDeploymentConfig: SafeDeploymentConfig = { saltNonce }
|
|
236
235
|
|
|
237
|
-
const
|
|
236
|
+
const saltNonce = '<YOUR_CUSTOM_VALUE>'
|
|
237
|
+
|
|
238
|
+
const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, saltNonce })
|
|
238
239
|
```
|
|
239
240
|
|
|
240
241
|
Optionally, some properties can be passed as execution options:
|
|
@@ -265,7 +266,7 @@ const options: EthersTransactionOptions = {
|
|
|
265
266
|
const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, safeDeploymentConfig, options })
|
|
266
267
|
```
|
|
267
268
|
|
|
268
|
-
It can also take an optional callback which receives the `txHash` of the Safe deployment transaction prior to returning a new instance of the
|
|
269
|
+
It can also take an optional callback which receives the `txHash` of the Safe deployment transaction prior to returning a new instance of the Protocol Kit:
|
|
269
270
|
|
|
270
271
|
```js
|
|
271
272
|
const callback = (txHash: string): void => {
|
|
@@ -279,7 +280,9 @@ const safeSdk = await safeFactory.deploySafe({ safeAccountConfig, callback })
|
|
|
279
280
|
|
|
280
281
|
### create
|
|
281
282
|
|
|
282
|
-
Returns an instance of the
|
|
283
|
+
Returns an instance of the Protocol Kit connected to a Safe. The provided Safe must be a `safeAddress` or a `predictedSafe`.
|
|
284
|
+
|
|
285
|
+
Initialization of a deployed Safe using the `safeAddress` property:
|
|
283
286
|
|
|
284
287
|
```js
|
|
285
288
|
import Safe from '@safe-global/protocol-kit'
|
|
@@ -287,6 +290,19 @@ import Safe from '@safe-global/protocol-kit'
|
|
|
287
290
|
const safeSdk = await Safe.create({ ethAdapter, safeAddress })
|
|
288
291
|
```
|
|
289
292
|
|
|
293
|
+
Initialization of a not deployed Safe using the `predictedSafe` property. Because Safes are deployed in a deterministic way, passing a `predictedSafe` will allow to initialize the SDK with the Safe configuration and use it to some extent before it is deployed:
|
|
294
|
+
|
|
295
|
+
```js
|
|
296
|
+
import Safe, { PredictedSafeProps } from '@safe-global/protocol-kit'
|
|
297
|
+
|
|
298
|
+
const predictedSafe: PredictedSafeProps = {
|
|
299
|
+
safeAccountConfig,
|
|
300
|
+
safeDeploymentConfig
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const safeSdk = await Safe.create({ ethAdapter, predictedSafe })
|
|
304
|
+
```
|
|
305
|
+
|
|
290
306
|
- The `isL1SafeMasterCopy` flag
|
|
291
307
|
|
|
292
308
|
There are two versions of the Safe contracts: [GnosisSafe.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafe.sol) that does not trigger events in order to save gas and [GnosisSafeL2.sol](https://github.com/safe-global/safe-contracts/blob/v1.3.0/contracts/GnosisSafeL2.sol) that does, which is more appropriate for L2 networks.
|
|
@@ -329,10 +345,25 @@ const safeSdk = await Safe.create({ ethAdapter, safeAddress })
|
|
|
329
345
|
|
|
330
346
|
### connect
|
|
331
347
|
|
|
332
|
-
Returns a new instance of the Safe
|
|
348
|
+
Returns a new instance of the Protocol Kit connected to a new Safe or a new Signer. The new connected signer can be passed via the `ethAdapter` property while the new connected Safe can be passed using a `safeAddress` or a `predictedSafe`.
|
|
349
|
+
|
|
350
|
+
Connection of a deployed Safe using the `safeAddress` property:
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
const safeSdk = await safeSdk.connect({ ethAdapter, safeAddress })
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Connection of a not deployed Safe using the `predictedSafe` property. Because Safes are deployed in a deterministic way, passing a `predictedSafe` will allow to connect a Safe to the SDK with the Safe configuration:
|
|
333
357
|
|
|
334
358
|
```js
|
|
335
|
-
|
|
359
|
+
import { PredictedSafeProps } from '@safe-global/protocol-kit'
|
|
360
|
+
|
|
361
|
+
const predictedSafe: PredictedSafeProps = {
|
|
362
|
+
safeAccountConfig,
|
|
363
|
+
safeDeploymentConfig
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const safeSdk = await safeSdk.connect({ ethAdapter, predictedSafe })
|
|
336
367
|
```
|
|
337
368
|
|
|
338
369
|
- The `isL1SafeMasterCopy` flag
|
|
@@ -379,7 +410,7 @@ const safeSdk2 = await safeSdk.connect({ ethAdapter, safeAddress })
|
|
|
379
410
|
Returns the address of the current SafeProxy contract.
|
|
380
411
|
|
|
381
412
|
```js
|
|
382
|
-
const safeAddress = safeSdk.getAddress()
|
|
413
|
+
const safeAddress = await safeSdk.getAddress()
|
|
383
414
|
```
|
|
384
415
|
|
|
385
416
|
### getContractVersion
|
|
@@ -464,7 +495,7 @@ const isOwner = await safeSdk.isOwner(address)
|
|
|
464
495
|
|
|
465
496
|
### createTransaction
|
|
466
497
|
|
|
467
|
-
Returns a Safe transaction ready to be signed by the owners and executed. The
|
|
498
|
+
Returns a Safe transaction ready to be signed by the owners and executed. The Protocol Kit supports the creation of single Safe transactions but also MultiSend transactions.
|
|
468
499
|
|
|
469
500
|
- **Single transactions**
|
|
470
501
|
|
package/dist/src/Safe.d.ts
CHANGED
|
@@ -1,66 +1,20 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import { EthAdapter,
|
|
2
|
+
import { EthAdapter, SafeMultisigTransactionResponse, SafeSignature, SafeTransaction, SafeVersion, TransactionOptions, TransactionResult } from '@safe-global/safe-core-sdk-types';
|
|
3
3
|
import ContractManager from './managers/contractManager';
|
|
4
|
-
import {
|
|
5
|
-
import SafeSignature from './utils/signatures/SafeSignature';
|
|
4
|
+
import { AddOwnerTxParams, ConnectSafeConfig, CreateTransactionProps, RemoveOwnerTxParams, SafeConfig, SwapOwnerTxParams } from './types';
|
|
6
5
|
import { SafeTransactionOptionalProps } from './utils/transactions/types';
|
|
7
|
-
export interface SafeConfig {
|
|
8
|
-
/** ethAdapter - Ethereum adapter */
|
|
9
|
-
ethAdapter: EthAdapter;
|
|
10
|
-
/** safeAddress - The address of the Safe account to use */
|
|
11
|
-
safeAddress: string;
|
|
12
|
-
/** isL1SafeMasterCopy - Forces to use the GnosisSafe L1 version of the contract instead of the L2 version */
|
|
13
|
-
isL1SafeMasterCopy?: boolean;
|
|
14
|
-
/** contractNetworks - Contract network configuration */
|
|
15
|
-
contractNetworks?: ContractNetworksConfig;
|
|
16
|
-
}
|
|
17
|
-
export interface ConnectSafeConfig {
|
|
18
|
-
/** ethAdapter - Ethereum adapter */
|
|
19
|
-
ethAdapter?: EthAdapter;
|
|
20
|
-
/** safeAddress - The address of the Safe account to use */
|
|
21
|
-
safeAddress?: string;
|
|
22
|
-
/** isL1SafeMasterCopy - Forces to use the GnosisSafe L1 version of the contract instead of the L2 version */
|
|
23
|
-
isL1SafeMasterCopy?: boolean;
|
|
24
|
-
/** contractNetworks - Contract network configuration */
|
|
25
|
-
contractNetworks?: ContractNetworksConfig;
|
|
26
|
-
}
|
|
27
|
-
export interface CreateTransactionProps {
|
|
28
|
-
/** safeTransactionData - The transaction or transaction array to process */
|
|
29
|
-
safeTransactionData: SafeTransactionDataPartial | MetaTransactionData[];
|
|
30
|
-
/** options - The transaction array optional properties */
|
|
31
|
-
options?: SafeTransactionOptionalProps;
|
|
32
|
-
/** onlyCalls - Forces the execution of the transaction array with MultiSendCallOnly contract */
|
|
33
|
-
onlyCalls?: boolean;
|
|
34
|
-
}
|
|
35
|
-
export interface AddOwnerTxParams {
|
|
36
|
-
/** ownerAddress - The address of the new owner */
|
|
37
|
-
ownerAddress: string;
|
|
38
|
-
/** threshold - The new threshold */
|
|
39
|
-
threshold?: number;
|
|
40
|
-
}
|
|
41
|
-
export interface RemoveOwnerTxParams {
|
|
42
|
-
/** ownerAddress - The address of the owner that will be removed */
|
|
43
|
-
ownerAddress: string;
|
|
44
|
-
/** threshold - The new threshold */
|
|
45
|
-
threshold?: number;
|
|
46
|
-
}
|
|
47
|
-
export interface SwapOwnerTxParams {
|
|
48
|
-
/** oldOwnerAddress - The old owner address */
|
|
49
|
-
oldOwnerAddress: string;
|
|
50
|
-
/** newOwnerAddress - The new owner address */
|
|
51
|
-
newOwnerAddress: string;
|
|
52
|
-
}
|
|
53
6
|
declare class Safe {
|
|
54
7
|
#private;
|
|
55
8
|
/**
|
|
56
9
|
* Creates an instance of the Safe Core SDK.
|
|
57
10
|
* @param config - Ethers Safe configuration
|
|
58
11
|
* @returns The Safe Core SDK instance
|
|
12
|
+
* @throws "The SDK must be initialized with a safeAddress or a predictedSafe"
|
|
59
13
|
* @throws "SafeProxy contract is not deployed on the current network"
|
|
60
14
|
* @throws "MultiSend contract is not deployed on the current network"
|
|
61
15
|
* @throws "MultiSendCallOnly contract is not deployed on the current network"
|
|
62
16
|
*/
|
|
63
|
-
static create(
|
|
17
|
+
static create(config: SafeConfig): Promise<Safe>;
|
|
64
18
|
/**
|
|
65
19
|
* Initializes the Safe Core SDK instance.
|
|
66
20
|
* @param config - Safe configuration
|
|
@@ -73,17 +27,18 @@ declare class Safe {
|
|
|
73
27
|
/**
|
|
74
28
|
* Returns a new instance of the Safe Core SDK.
|
|
75
29
|
* @param config - Connect Safe configuration
|
|
30
|
+
* @throws "A safeAddress and a predictedSafe cannot be connected at the same time"
|
|
76
31
|
* @throws "SafeProxy contract is not deployed on the current network"
|
|
77
32
|
* @throws "MultiSend contract is not deployed on the current network"
|
|
78
33
|
* @throws "MultiSendCallOnly contract is not deployed on the current network"
|
|
79
34
|
*/
|
|
80
|
-
connect(
|
|
35
|
+
connect(config: ConnectSafeConfig): Promise<Safe>;
|
|
81
36
|
/**
|
|
82
37
|
* Returns the address of the current SafeProxy contract.
|
|
83
38
|
*
|
|
84
39
|
* @returns The address of the SafeProxy contract
|
|
85
40
|
*/
|
|
86
|
-
getAddress(): string
|
|
41
|
+
getAddress(): Promise<string>;
|
|
87
42
|
/**
|
|
88
43
|
* Returns the ContractManager
|
|
89
44
|
*
|
|
@@ -108,6 +63,12 @@ declare class Safe {
|
|
|
108
63
|
* @returns The address of the MultiSendCallOnly contract
|
|
109
64
|
*/
|
|
110
65
|
getMultiSendCallOnlyAddress(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Checks if the current Safe is deployed.
|
|
68
|
+
*
|
|
69
|
+
* @returns TRUE if the Safe contract is deployed
|
|
70
|
+
*/
|
|
71
|
+
isSafeDeployed(): Promise<boolean>;
|
|
111
72
|
/**
|
|
112
73
|
* Returns the Safe Master Copy contract version.
|
|
113
74
|
*
|