@safe-global/sdk-starter-kit 1.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.
- package/README.md +35 -0
- package/dist/src/BaseClient.d.ts +82 -0
- package/dist/src/BaseClient.js +123 -0
- package/dist/src/BaseClient.js.map +1 -0
- package/dist/src/SafeClient.d.ts +62 -0
- package/dist/src/SafeClient.js +215 -0
- package/dist/src/SafeClient.js.map +1 -0
- package/dist/src/constants.d.ts +24 -0
- package/dist/src/constants.js +36 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/extensions/index.d.ts +3 -0
- package/dist/src/extensions/index.js +20 -0
- package/dist/src/extensions/index.js.map +1 -0
- package/dist/src/extensions/messages/SafeMessageClient.d.ts +41 -0
- package/dist/src/extensions/messages/SafeMessageClient.js +161 -0
- package/dist/src/extensions/messages/SafeMessageClient.js.map +1 -0
- package/dist/src/extensions/messages/offChainMessages.d.ts +38 -0
- package/dist/src/extensions/messages/offChainMessages.js +52 -0
- package/dist/src/extensions/messages/offChainMessages.js.map +1 -0
- package/dist/src/extensions/messages/onChainMessages.d.ts +28 -0
- package/dist/src/extensions/messages/onChainMessages.js +48 -0
- package/dist/src/extensions/messages/onChainMessages.js.map +1 -0
- package/dist/src/extensions/safe-operations/SafeOperationClient.d.ts +51 -0
- package/dist/src/extensions/safe-operations/SafeOperationClient.js +127 -0
- package/dist/src/extensions/safe-operations/SafeOperationClient.js.map +1 -0
- package/dist/src/extensions/safe-operations/safeOperations.d.ts +49 -0
- package/dist/src/extensions/safe-operations/safeOperations.js +85 -0
- package/dist/src/extensions/safe-operations/safeOperations.js.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +92 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +69 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/index.d.ts +19 -0
- package/dist/src/utils/index.js +57 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/proposeTransaction.d.ts +16 -0
- package/dist/src/utils/proposeTransaction.js +29 -0
- package/dist/src/utils/proposeTransaction.js.map +1 -0
- package/dist/src/utils/sendTransaction.d.ts +14 -0
- package/dist/src/utils/sendTransaction.js +28 -0
- package/dist/src/utils/sendTransaction.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# SDK Starter Kit
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40safe-global%2Fsdk-starter-kit)
|
|
4
|
+
[](https://github.com/safe-global/safe-core-sdk/releases)
|
|
5
|
+
[](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md)
|
|
6
|
+
|
|
7
|
+
Description TBD
|
|
8
|
+
|
|
9
|
+
## Table of contents
|
|
10
|
+
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Need Help or Have Questions?](#need-help-or-have-questions)
|
|
13
|
+
- [Contributing](#contributing)
|
|
14
|
+
- [License](#license)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Install the package with yarn or npm:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add @safe-global/sdk-starter-kit
|
|
22
|
+
npm install @safe-global/sdk-starter-kit
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Need Help or Have Questions?
|
|
26
|
+
|
|
27
|
+
If you have any doubts, questions, or need assistance, feel free to reach out! [Here you will find how to get support.](https://github.com/safe-global/safe-core-sdk/tree/main/SUPPORT.md)
|
|
28
|
+
|
|
29
|
+
## Contributing
|
|
30
|
+
|
|
31
|
+
Please read our [contribution guidelines](https://github.com/safe-global/safe-core-sdk/tree/main/CONTRIBUTING.md) before submitting any changes. We appreciate your help! 🙌
|
|
32
|
+
|
|
33
|
+
## <a name="license">License</a>
|
|
34
|
+
|
|
35
|
+
This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import Safe, { AddOwnerTxParams, RemoveOwnerTxParams, SwapOwnerTxParams } from '@safe-global/protocol-kit';
|
|
2
|
+
import SafeApiKit from '@safe-global/api-kit';
|
|
3
|
+
import { TransactionBase } from '@safe-global/types-kit';
|
|
4
|
+
import { ChangeThresholdTxParams } from './types';
|
|
5
|
+
export declare class BaseClient {
|
|
6
|
+
#private;
|
|
7
|
+
protocolKit: Safe;
|
|
8
|
+
apiKit: SafeApiKit;
|
|
9
|
+
constructor(protocolKit: Safe, apiKit: SafeApiKit);
|
|
10
|
+
/**
|
|
11
|
+
* Returns the Safe address.
|
|
12
|
+
*
|
|
13
|
+
* @returns {string} The Safe address
|
|
14
|
+
*/
|
|
15
|
+
getAddress(): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the current Safe is deployed.
|
|
18
|
+
*
|
|
19
|
+
* @returns {boolean} if the Safe contract is deployed
|
|
20
|
+
*/
|
|
21
|
+
isDeployed(): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if a specific address is an owner of the current Safe.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} ownerAddress - The account address
|
|
26
|
+
* @returns {boolean} TRUE if the account is an owner
|
|
27
|
+
*/
|
|
28
|
+
isOwner(ownerAddress: string): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the list of Safe owner accounts.
|
|
31
|
+
*
|
|
32
|
+
* @returns The list of owners
|
|
33
|
+
*/
|
|
34
|
+
getOwners(): Promise<string[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the Safe threshold.
|
|
37
|
+
*
|
|
38
|
+
* @returns {number} The Safe threshold
|
|
39
|
+
*/
|
|
40
|
+
getThreshold(): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the Safe nonce.
|
|
43
|
+
*
|
|
44
|
+
* @returns {number} The Safe nonce
|
|
45
|
+
*/
|
|
46
|
+
getNonce(): Promise<number>;
|
|
47
|
+
/**
|
|
48
|
+
* Returns a list of owners who have approved a specific Safe transaction.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} txHash - The Safe transaction hash
|
|
51
|
+
* @returns {string[]} The list of owners
|
|
52
|
+
*/
|
|
53
|
+
getOwnersWhoApprovedTransaction(txHash: string): Promise<string[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Encodes the data for adding a new owner to the Safe.
|
|
56
|
+
*
|
|
57
|
+
* @param {AddOwnerTxParams} addOwnerParams - The parameters for adding a new owner
|
|
58
|
+
* @returns {TransactionBase} The encoded data
|
|
59
|
+
*/
|
|
60
|
+
createAddOwnerTransaction(addOwnerParams: AddOwnerTxParams): Promise<TransactionBase>;
|
|
61
|
+
/**
|
|
62
|
+
* Encodes the data for removing an owner from the Safe.
|
|
63
|
+
*
|
|
64
|
+
* @param {RemoveOwnerTxParams} removeOwnerParams - The parameters for removing an owner
|
|
65
|
+
* @returns {TransactionBase} The encoded data
|
|
66
|
+
*/
|
|
67
|
+
createRemoveOwnerTransaction(removeOwnerParams: RemoveOwnerTxParams): Promise<TransactionBase>;
|
|
68
|
+
/**
|
|
69
|
+
* Encodes the data for swapping an owner in the Safe.
|
|
70
|
+
*
|
|
71
|
+
* @param {SwapOwnerTxParams} swapParams - The parameters for swapping an owner
|
|
72
|
+
* @returns {TransactionBase} The encoded data
|
|
73
|
+
*/
|
|
74
|
+
createSwapOwnerTransaction(swapParams: SwapOwnerTxParams): Promise<TransactionBase>;
|
|
75
|
+
/**
|
|
76
|
+
* Encodes the data for changing the Safe threshold.
|
|
77
|
+
*
|
|
78
|
+
* @param {ChangeThresholdTxParams} changeThresholdParams - The parameters for changing the Safe threshold
|
|
79
|
+
* @returns {TransactionBase} The encoded data
|
|
80
|
+
*/
|
|
81
|
+
createChangeThresholdTransaction(changeThresholdParams: ChangeThresholdTxParams): Promise<TransactionBase>;
|
|
82
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _BaseClient_instances, _BaseClient_buildTransaction;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BaseClient = void 0;
|
|
10
|
+
class BaseClient {
|
|
11
|
+
constructor(protocolKit, apiKit) {
|
|
12
|
+
_BaseClient_instances.add(this);
|
|
13
|
+
this.protocolKit = protocolKit;
|
|
14
|
+
this.apiKit = apiKit;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the Safe address.
|
|
18
|
+
*
|
|
19
|
+
* @returns {string} The Safe address
|
|
20
|
+
*/
|
|
21
|
+
async getAddress() {
|
|
22
|
+
return this.protocolKit.getAddress();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the current Safe is deployed.
|
|
26
|
+
*
|
|
27
|
+
* @returns {boolean} if the Safe contract is deployed
|
|
28
|
+
*/
|
|
29
|
+
async isDeployed() {
|
|
30
|
+
return this.protocolKit.isSafeDeployed();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a specific address is an owner of the current Safe.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} ownerAddress - The account address
|
|
36
|
+
* @returns {boolean} TRUE if the account is an owner
|
|
37
|
+
*/
|
|
38
|
+
async isOwner(ownerAddress) {
|
|
39
|
+
return this.protocolKit.isOwner(ownerAddress);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the list of Safe owner accounts.
|
|
43
|
+
*
|
|
44
|
+
* @returns The list of owners
|
|
45
|
+
*/
|
|
46
|
+
async getOwners() {
|
|
47
|
+
return this.protocolKit.getOwners();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the Safe threshold.
|
|
51
|
+
*
|
|
52
|
+
* @returns {number} The Safe threshold
|
|
53
|
+
*/
|
|
54
|
+
async getThreshold() {
|
|
55
|
+
return this.protocolKit.getThreshold();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the Safe nonce.
|
|
59
|
+
*
|
|
60
|
+
* @returns {number} The Safe nonce
|
|
61
|
+
*/
|
|
62
|
+
async getNonce() {
|
|
63
|
+
return this.protocolKit.getNonce();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns a list of owners who have approved a specific Safe transaction.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} txHash - The Safe transaction hash
|
|
69
|
+
* @returns {string[]} The list of owners
|
|
70
|
+
*/
|
|
71
|
+
async getOwnersWhoApprovedTransaction(txHash) {
|
|
72
|
+
return this.protocolKit.getOwnersWhoApprovedTx(txHash);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Encodes the data for adding a new owner to the Safe.
|
|
76
|
+
*
|
|
77
|
+
* @param {AddOwnerTxParams} addOwnerParams - The parameters for adding a new owner
|
|
78
|
+
* @returns {TransactionBase} The encoded data
|
|
79
|
+
*/
|
|
80
|
+
async createAddOwnerTransaction(addOwnerParams) {
|
|
81
|
+
const addOwnerTransaction = await this.protocolKit.createAddOwnerTx(addOwnerParams);
|
|
82
|
+
return __classPrivateFieldGet(this, _BaseClient_instances, "m", _BaseClient_buildTransaction).call(this, addOwnerTransaction);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Encodes the data for removing an owner from the Safe.
|
|
86
|
+
*
|
|
87
|
+
* @param {RemoveOwnerTxParams} removeOwnerParams - The parameters for removing an owner
|
|
88
|
+
* @returns {TransactionBase} The encoded data
|
|
89
|
+
*/
|
|
90
|
+
async createRemoveOwnerTransaction(removeOwnerParams) {
|
|
91
|
+
const removeOwnerTransaction = await this.protocolKit.createRemoveOwnerTx(removeOwnerParams);
|
|
92
|
+
return __classPrivateFieldGet(this, _BaseClient_instances, "m", _BaseClient_buildTransaction).call(this, removeOwnerTransaction);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Encodes the data for swapping an owner in the Safe.
|
|
96
|
+
*
|
|
97
|
+
* @param {SwapOwnerTxParams} swapParams - The parameters for swapping an owner
|
|
98
|
+
* @returns {TransactionBase} The encoded data
|
|
99
|
+
*/
|
|
100
|
+
async createSwapOwnerTransaction(swapParams) {
|
|
101
|
+
const swapOwnerTransaction = await this.protocolKit.createSwapOwnerTx(swapParams);
|
|
102
|
+
return __classPrivateFieldGet(this, _BaseClient_instances, "m", _BaseClient_buildTransaction).call(this, swapOwnerTransaction);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Encodes the data for changing the Safe threshold.
|
|
106
|
+
*
|
|
107
|
+
* @param {ChangeThresholdTxParams} changeThresholdParams - The parameters for changing the Safe threshold
|
|
108
|
+
* @returns {TransactionBase} The encoded data
|
|
109
|
+
*/
|
|
110
|
+
async createChangeThresholdTransaction(changeThresholdParams) {
|
|
111
|
+
const changeThresholdTransaction = await this.protocolKit.createChangeThresholdTx(changeThresholdParams.threshold);
|
|
112
|
+
return __classPrivateFieldGet(this, _BaseClient_instances, "m", _BaseClient_buildTransaction).call(this, changeThresholdTransaction);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.BaseClient = BaseClient;
|
|
116
|
+
_BaseClient_instances = new WeakSet(), _BaseClient_buildTransaction = async function _BaseClient_buildTransaction(safeTransaction) {
|
|
117
|
+
return {
|
|
118
|
+
to: safeTransaction.data.to,
|
|
119
|
+
value: safeTransaction.data.value,
|
|
120
|
+
data: safeTransaction.data.data
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=BaseClient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MAAtB,IAAI,EAAmB,mBAAmB,CAAC,CAAA;IACpD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,4BAA4B,CAChC,iBAAsC;QAEtC,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAA;QAE5F,OAAO,uBAAA,IAAI,2DAAkB,MAAtB,IAAI,EAAmB,sBAAsB,CAAC,CAAA;IACvD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,0BAA0B,CAAC,UAA6B;QAC5D,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAA;QAEjF,OAAO,uBAAA,IAAI,2DAAkB,MAAtB,IAAI,EAAmB,oBAAoB,CAAC,CAAA;IACrD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,gCAAgC,CACpC,qBAA8C;QAE9C,MAAM,0BAA0B,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAC/E,qBAAqB,CAAC,SAAS,CAChC,CAAA;QAED,OAAO,uBAAA,IAAI,2DAAkB,MAAtB,IAAI,EAAmB,0BAA0B,CAAC,CAAA;IAC3D,CAAC;CASF;AAvID,gCAuIC;sEAPC,KAAK,uCAAmB,eAAgC;IACtD,OAAO;QACL,EAAE,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE;QAC3B,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK;QACjC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI;KAChC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import Safe from '@safe-global/protocol-kit';
|
|
2
|
+
import SafeApiKit, { SafeMultisigTransactionListResponse } from '@safe-global/api-kit';
|
|
3
|
+
import { ConfirmTransactionProps, SafeClientResult, SendTransactionProps } from './types';
|
|
4
|
+
import { BaseClient } from './BaseClient';
|
|
5
|
+
/**
|
|
6
|
+
* @class
|
|
7
|
+
* This class provides the core functionality to create, sign and execute transactions.
|
|
8
|
+
* It also provides the ability to be extended with features through the extend function.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const safeClient = await createSafeClient({ ... })
|
|
12
|
+
*
|
|
13
|
+
* const { transactions } = await safeClient.send(...)
|
|
14
|
+
* await safeClient.confirm(transactions?.safeTxHash)
|
|
15
|
+
*/
|
|
16
|
+
export declare class SafeClient extends BaseClient {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(protocolKit: Safe, apiKit: SafeApiKit);
|
|
19
|
+
/**
|
|
20
|
+
* Sends transactions through the Safe protocol.
|
|
21
|
+
* You can send an array to transactions { to, value, data} that we will convert to a transaction batch
|
|
22
|
+
*
|
|
23
|
+
* @param {SendTransactionProps} props The SendTransactionProps object.
|
|
24
|
+
* @param {TransactionBase[]} props.transactions An array of transactions to be sent.
|
|
25
|
+
* @param {string} props.transactions[].to The recipient address of the transaction.
|
|
26
|
+
* @param {string} props.transactions[].value The value of the transaction.
|
|
27
|
+
* @param {string} props.transactions[].data The data of the transaction.
|
|
28
|
+
* @param {string} props.from The sender address of the transaction.
|
|
29
|
+
* @param {number | string} props.gasLimit The gas limit of the transaction.
|
|
30
|
+
* @param {number | string} props.gasPrice The gas price of the transaction.
|
|
31
|
+
* @param {number | string} props.maxFeePerGas The max fee per gas of the transaction.
|
|
32
|
+
* @param {number | string} props.maxPriorityFeePerGas The max priority fee per gas of the transaction.
|
|
33
|
+
* @param {number} props.nonce The nonce of the transaction.
|
|
34
|
+
* @returns {Promise<SafeClientResult>} A promise that resolves to the result of the transaction.
|
|
35
|
+
*/
|
|
36
|
+
send({ transactions, ...transactionOptions }: SendTransactionProps): Promise<SafeClientResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Confirms a transaction by its safe transaction hash.
|
|
39
|
+
*
|
|
40
|
+
* @param {ConfirmTransactionProps} props The ConfirmTransactionProps object.
|
|
41
|
+
* @param {string} props.safeTxHash The hash of the safe transaction to confirm.
|
|
42
|
+
* @returns {Promise<SafeClientResult>} A promise that resolves to the result of the confirmed transaction.
|
|
43
|
+
* @throws {Error} If the transaction confirmation fails.
|
|
44
|
+
*/
|
|
45
|
+
confirm({ safeTxHash }: ConfirmTransactionProps): Promise<SafeClientResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves the pending transactions for the current safe address.
|
|
48
|
+
*
|
|
49
|
+
* @async
|
|
50
|
+
* @returns {Promise<SafeMultisigTransactionListResponse>} A promise that resolves to an array of pending transactions.
|
|
51
|
+
* @throws {Error} If there is an issue retrieving the safe address or pending transactions.
|
|
52
|
+
*/
|
|
53
|
+
getPendingTransactions(): Promise<SafeMultisigTransactionListResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Extend the SafeClient with additional functionality.
|
|
56
|
+
*
|
|
57
|
+
* @param extendFunc
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
extend<T>(extendFunc: (client: this) => Promise<T>): Promise<this & T>;
|
|
61
|
+
extend<T>(extendFunc: (client: this) => T): this & T;
|
|
62
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var _SafeClient_instances, _SafeClient_deployAndExecuteTransaction, _SafeClient_deployAndProposeTransaction, _SafeClient_executeTransaction, _SafeClient_proposeTransaction, _SafeClient_reconnectSafe;
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SafeClient = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const BaseClient_1 = require("./BaseClient");
|
|
13
|
+
/**
|
|
14
|
+
* @class
|
|
15
|
+
* This class provides the core functionality to create, sign and execute transactions.
|
|
16
|
+
* It also provides the ability to be extended with features through the extend function.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const safeClient = await createSafeClient({ ... })
|
|
20
|
+
*
|
|
21
|
+
* const { transactions } = await safeClient.send(...)
|
|
22
|
+
* await safeClient.confirm(transactions?.safeTxHash)
|
|
23
|
+
*/
|
|
24
|
+
class SafeClient extends BaseClient_1.BaseClient {
|
|
25
|
+
constructor(protocolKit, apiKit) {
|
|
26
|
+
super(protocolKit, apiKit);
|
|
27
|
+
_SafeClient_instances.add(this);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sends transactions through the Safe protocol.
|
|
31
|
+
* You can send an array to transactions { to, value, data} that we will convert to a transaction batch
|
|
32
|
+
*
|
|
33
|
+
* @param {SendTransactionProps} props The SendTransactionProps object.
|
|
34
|
+
* @param {TransactionBase[]} props.transactions An array of transactions to be sent.
|
|
35
|
+
* @param {string} props.transactions[].to The recipient address of the transaction.
|
|
36
|
+
* @param {string} props.transactions[].value The value of the transaction.
|
|
37
|
+
* @param {string} props.transactions[].data The data of the transaction.
|
|
38
|
+
* @param {string} props.from The sender address of the transaction.
|
|
39
|
+
* @param {number | string} props.gasLimit The gas limit of the transaction.
|
|
40
|
+
* @param {number | string} props.gasPrice The gas price of the transaction.
|
|
41
|
+
* @param {number | string} props.maxFeePerGas The max fee per gas of the transaction.
|
|
42
|
+
* @param {number | string} props.maxPriorityFeePerGas The max priority fee per gas of the transaction.
|
|
43
|
+
* @param {number} props.nonce The nonce of the transaction.
|
|
44
|
+
* @returns {Promise<SafeClientResult>} A promise that resolves to the result of the transaction.
|
|
45
|
+
*/
|
|
46
|
+
async send({ transactions, ...transactionOptions }) {
|
|
47
|
+
const isSafeDeployed = await this.protocolKit.isSafeDeployed();
|
|
48
|
+
const isMultisigSafe = (await this.protocolKit.getThreshold()) > 1;
|
|
49
|
+
const safeTransaction = await this.protocolKit.createTransaction({ transactions });
|
|
50
|
+
if (isSafeDeployed) {
|
|
51
|
+
if (isMultisigSafe) {
|
|
52
|
+
// If the threshold is greater than 1, we need to propose the transaction first
|
|
53
|
+
return __classPrivateFieldGet(this, _SafeClient_instances, "m", _SafeClient_proposeTransaction).call(this, { safeTransaction });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// If the threshold is 1, we can execute the transaction
|
|
57
|
+
return __classPrivateFieldGet(this, _SafeClient_instances, "m", _SafeClient_executeTransaction).call(this, { safeTransaction, ...transactionOptions });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (isMultisigSafe) {
|
|
62
|
+
// If the threshold is greater than 1, we need to deploy the Safe account first and
|
|
63
|
+
// afterwards propose the transaction
|
|
64
|
+
// The transaction should be confirmed with other owners until the threshold is reached
|
|
65
|
+
return __classPrivateFieldGet(this, _SafeClient_instances, "m", _SafeClient_deployAndProposeTransaction).call(this, { safeTransaction, ...transactionOptions });
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// If the threshold is 1, we can deploy the Safe account and execute the transaction in one step
|
|
69
|
+
return __classPrivateFieldGet(this, _SafeClient_instances, "m", _SafeClient_deployAndExecuteTransaction).call(this, { safeTransaction, ...transactionOptions });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Confirms a transaction by its safe transaction hash.
|
|
75
|
+
*
|
|
76
|
+
* @param {ConfirmTransactionProps} props The ConfirmTransactionProps object.
|
|
77
|
+
* @param {string} props.safeTxHash The hash of the safe transaction to confirm.
|
|
78
|
+
* @returns {Promise<SafeClientResult>} A promise that resolves to the result of the confirmed transaction.
|
|
79
|
+
* @throws {Error} If the transaction confirmation fails.
|
|
80
|
+
*/
|
|
81
|
+
async confirm({ safeTxHash }) {
|
|
82
|
+
let transactionResponse = await this.apiKit.getTransaction(safeTxHash);
|
|
83
|
+
const safeAddress = await this.protocolKit.getAddress();
|
|
84
|
+
const signedTransaction = await this.protocolKit.signTransaction(transactionResponse);
|
|
85
|
+
await this.apiKit.confirmTransaction(safeTxHash, signedTransaction.encodedSignatures());
|
|
86
|
+
transactionResponse = await this.apiKit.getTransaction(safeTxHash);
|
|
87
|
+
if (transactionResponse.confirmations &&
|
|
88
|
+
transactionResponse.confirmationsRequired === transactionResponse.confirmations.length) {
|
|
89
|
+
const executedTransactionResponse = await this.protocolKit.executeTransaction(transactionResponse);
|
|
90
|
+
await (0, utils_1.waitSafeTxReceipt)(executedTransactionResponse);
|
|
91
|
+
return (0, utils_1.createSafeClientResult)({
|
|
92
|
+
status: constants_1.SafeClientTxStatus.EXECUTED,
|
|
93
|
+
safeAddress,
|
|
94
|
+
txHash: executedTransactionResponse.hash,
|
|
95
|
+
safeTxHash
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return (0, utils_1.createSafeClientResult)({
|
|
99
|
+
status: constants_1.SafeClientTxStatus.PENDING_SIGNATURES,
|
|
100
|
+
safeAddress,
|
|
101
|
+
safeTxHash
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves the pending transactions for the current safe address.
|
|
106
|
+
*
|
|
107
|
+
* @async
|
|
108
|
+
* @returns {Promise<SafeMultisigTransactionListResponse>} A promise that resolves to an array of pending transactions.
|
|
109
|
+
* @throws {Error} If there is an issue retrieving the safe address or pending transactions.
|
|
110
|
+
*/
|
|
111
|
+
async getPendingTransactions() {
|
|
112
|
+
const safeAddress = await this.protocolKit.getAddress();
|
|
113
|
+
return this.apiKit.getPendingTransactions(safeAddress);
|
|
114
|
+
}
|
|
115
|
+
extend(extendFunc) {
|
|
116
|
+
const result = extendFunc(this);
|
|
117
|
+
if (result instanceof Promise) {
|
|
118
|
+
return result.then((extensions) => Object.assign(this, extensions));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return Object.assign(this, result);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.SafeClient = SafeClient;
|
|
126
|
+
_SafeClient_instances = new WeakSet(), _SafeClient_deployAndExecuteTransaction =
|
|
127
|
+
/**
|
|
128
|
+
* Deploys and executes a transaction in one step.
|
|
129
|
+
*
|
|
130
|
+
* @param {SafeTransaction} safeTransaction The safe transaction to be executed
|
|
131
|
+
* @param {TransactionOptions} options Optional transaction options
|
|
132
|
+
* @returns A promise that resolves to the result of the transaction
|
|
133
|
+
*/
|
|
134
|
+
async function _SafeClient_deployAndExecuteTransaction({ safeTransaction, ...transactionOptions }) {
|
|
135
|
+
safeTransaction = await this.protocolKit.signTransaction(safeTransaction);
|
|
136
|
+
const transactionBatchWithDeployment = await this.protocolKit.wrapSafeTransactionIntoDeploymentBatch(safeTransaction, transactionOptions);
|
|
137
|
+
const hash = await (0, utils_1.sendTransaction)({
|
|
138
|
+
transaction: transactionBatchWithDeployment,
|
|
139
|
+
protocolKit: this.protocolKit
|
|
140
|
+
});
|
|
141
|
+
await __classPrivateFieldGet(this, _SafeClient_instances, "m", _SafeClient_reconnectSafe).call(this);
|
|
142
|
+
return (0, utils_1.createSafeClientResult)({
|
|
143
|
+
safeAddress: await this.protocolKit.getAddress(),
|
|
144
|
+
status: constants_1.SafeClientTxStatus.DEPLOYED_AND_EXECUTED,
|
|
145
|
+
deploymentTxHash: hash,
|
|
146
|
+
txHash: hash
|
|
147
|
+
});
|
|
148
|
+
}, _SafeClient_deployAndProposeTransaction =
|
|
149
|
+
/**
|
|
150
|
+
* Deploys and proposes a transaction in one step.
|
|
151
|
+
*
|
|
152
|
+
* @param {SafeTransaction} safeTransaction The safe transaction to be proposed
|
|
153
|
+
* @param {TransactionOptions} transactionOptions Optional transaction options
|
|
154
|
+
* @returns A promise that resolves to the result of the transaction
|
|
155
|
+
*/
|
|
156
|
+
async function _SafeClient_deployAndProposeTransaction({ safeTransaction, ...transactionOptions }) {
|
|
157
|
+
const safeDeploymentTransaction = await this.protocolKit.createSafeDeploymentTransaction();
|
|
158
|
+
const hash = await (0, utils_1.sendTransaction)({
|
|
159
|
+
transaction: { ...safeDeploymentTransaction, ...transactionOptions },
|
|
160
|
+
protocolKit: this.protocolKit
|
|
161
|
+
});
|
|
162
|
+
await __classPrivateFieldGet(this, _SafeClient_instances, "m", _SafeClient_reconnectSafe).call(this);
|
|
163
|
+
safeTransaction = await this.protocolKit.signTransaction(safeTransaction);
|
|
164
|
+
const safeTxHash = await (0, utils_1.proposeTransaction)({
|
|
165
|
+
safeTransaction,
|
|
166
|
+
protocolKit: this.protocolKit,
|
|
167
|
+
apiKit: this.apiKit
|
|
168
|
+
});
|
|
169
|
+
return (0, utils_1.createSafeClientResult)({
|
|
170
|
+
safeAddress: await this.protocolKit.getAddress(),
|
|
171
|
+
status: constants_1.SafeClientTxStatus.DEPLOYED_AND_PENDING_SIGNATURES,
|
|
172
|
+
deploymentTxHash: hash,
|
|
173
|
+
safeTxHash
|
|
174
|
+
});
|
|
175
|
+
}, _SafeClient_executeTransaction =
|
|
176
|
+
/**
|
|
177
|
+
* Executes a transaction.
|
|
178
|
+
*
|
|
179
|
+
* @param {SafeTransaction} safeTransaction The safe transaction to be executed
|
|
180
|
+
* @param {TransactionOptions} transactionOptions Optional transaction options
|
|
181
|
+
* @returns A promise that resolves to the result of the transaction
|
|
182
|
+
*/
|
|
183
|
+
async function _SafeClient_executeTransaction({ safeTransaction, ...transactionOptions }) {
|
|
184
|
+
safeTransaction = await this.protocolKit.signTransaction(safeTransaction);
|
|
185
|
+
const { hash } = await this.protocolKit.executeTransaction(safeTransaction, transactionOptions);
|
|
186
|
+
return (0, utils_1.createSafeClientResult)({
|
|
187
|
+
safeAddress: await this.protocolKit.getAddress(),
|
|
188
|
+
status: constants_1.SafeClientTxStatus.EXECUTED,
|
|
189
|
+
txHash: hash
|
|
190
|
+
});
|
|
191
|
+
}, _SafeClient_proposeTransaction =
|
|
192
|
+
/**
|
|
193
|
+
* Proposes a transaction to the Safe.
|
|
194
|
+
* @param { SafeTransaction } safeTransaction The safe transaction to propose
|
|
195
|
+
* @returns The SafeClientResult
|
|
196
|
+
*/
|
|
197
|
+
async function _SafeClient_proposeTransaction({ safeTransaction }) {
|
|
198
|
+
const safeTxHash = await (0, utils_1.proposeTransaction)({
|
|
199
|
+
safeTransaction,
|
|
200
|
+
protocolKit: this.protocolKit,
|
|
201
|
+
apiKit: this.apiKit
|
|
202
|
+
});
|
|
203
|
+
return (0, utils_1.createSafeClientResult)({
|
|
204
|
+
safeAddress: await this.protocolKit.getAddress(),
|
|
205
|
+
status: constants_1.SafeClientTxStatus.PENDING_SIGNATURES,
|
|
206
|
+
safeTxHash
|
|
207
|
+
});
|
|
208
|
+
}, _SafeClient_reconnectSafe = async function _SafeClient_reconnectSafe() {
|
|
209
|
+
this.protocolKit = await this.protocolKit.connect({
|
|
210
|
+
provider: this.protocolKit.getSafeProvider().provider,
|
|
211
|
+
signer: this.protocolKit.getSafeProvider().signer,
|
|
212
|
+
safeAddress: await this.protocolKit.getAddress()
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=SafeClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeClient.js","sourceRoot":"","sources":["../../src/SafeClient.ts"],"names":[],"mappings":";;;;;;;;;AAIA,8DAK2C;AAC3C,sEAA2E;AAO3E,6CAAyC;AAEzC;;;;;;;;;;GAUG;AACH,MAAa,UAAW,SAAQ,uBAAU;IACxC,YAAY,WAAiB,EAAE,MAAkB;QAC/C,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;;IAC5B,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,IAAI,CAAC,EACT,YAAY,EACZ,GAAG,kBAAkB,EACA;QACrB,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,WAAW,CA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I,CAAC,WAAW,CAAC,OAAO,CAAC;QAChD,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ;QACrD,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,MAAM;QACjD,WAAW,EAAE,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE;KACjD,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare enum SafeClientTxStatus {
|
|
2
|
+
DEPLOYED_AND_EXECUTED = "DEPLOYED_AND_EXECUTED",
|
|
3
|
+
DEPLOYED_AND_PENDING_SIGNATURES = "DEPLOYED_AND_PENDING_SIGNATURES",
|
|
4
|
+
EXECUTED = "EXECUTED",
|
|
5
|
+
PENDING_SIGNATURES = "PENDING_SIGNATURES",
|
|
6
|
+
MESSAGE_PENDING_SIGNATURES = "MESSAGE_PENDING_SIGNATURES",
|
|
7
|
+
MESSAGE_CONFIRMED = "MESSAGE_CONFIRMED",
|
|
8
|
+
DEPLOYED_AND_MESSAGE_PENDING_SIGNATURES = "DEPLOYED_AND_MESSAGE_PENDING_SIGNATURES",
|
|
9
|
+
DEPLOYED_AND_MESSAGE_CONFIRMED = "DEPLOYED_AND_MESSAGE_CONFIRMED",
|
|
10
|
+
SAFE_OPERATION_EXECUTED = "SAFE_OPERATION_EXECUTED",
|
|
11
|
+
SAFE_OPERATION_PENDING_SIGNATURES = "SAFE_OPERATION_PENDING_SIGNATURES"
|
|
12
|
+
}
|
|
13
|
+
export declare const MESSAGES: {
|
|
14
|
+
DEPLOYED_AND_EXECUTED: string;
|
|
15
|
+
DEPLOYED_AND_PENDING_SIGNATURES: string;
|
|
16
|
+
EXECUTED: string;
|
|
17
|
+
PENDING_SIGNATURES: string;
|
|
18
|
+
MESSAGE_PENDING_SIGNATURES: string;
|
|
19
|
+
MESSAGE_CONFIRMED: string;
|
|
20
|
+
DEPLOYED_AND_MESSAGE_PENDING_SIGNATURES: string;
|
|
21
|
+
DEPLOYED_AND_MESSAGE_CONFIRMED: string;
|
|
22
|
+
SAFE_OPERATION_EXECUTED: string;
|
|
23
|
+
SAFE_OPERATION_PENDING_SIGNATURES: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MESSAGES = exports.SafeClientTxStatus = void 0;
|
|
4
|
+
var SafeClientTxStatus;
|
|
5
|
+
(function (SafeClientTxStatus) {
|
|
6
|
+
SafeClientTxStatus["DEPLOYED_AND_EXECUTED"] = "DEPLOYED_AND_EXECUTED";
|
|
7
|
+
SafeClientTxStatus["DEPLOYED_AND_PENDING_SIGNATURES"] = "DEPLOYED_AND_PENDING_SIGNATURES";
|
|
8
|
+
SafeClientTxStatus["EXECUTED"] = "EXECUTED";
|
|
9
|
+
SafeClientTxStatus["PENDING_SIGNATURES"] = "PENDING_SIGNATURES";
|
|
10
|
+
SafeClientTxStatus["MESSAGE_PENDING_SIGNATURES"] = "MESSAGE_PENDING_SIGNATURES";
|
|
11
|
+
SafeClientTxStatus["MESSAGE_CONFIRMED"] = "MESSAGE_CONFIRMED";
|
|
12
|
+
SafeClientTxStatus["DEPLOYED_AND_MESSAGE_PENDING_SIGNATURES"] = "DEPLOYED_AND_MESSAGE_PENDING_SIGNATURES";
|
|
13
|
+
SafeClientTxStatus["DEPLOYED_AND_MESSAGE_CONFIRMED"] = "DEPLOYED_AND_MESSAGE_CONFIRMED";
|
|
14
|
+
SafeClientTxStatus["SAFE_OPERATION_EXECUTED"] = "SAFE_OPERATION_EXECUTED";
|
|
15
|
+
SafeClientTxStatus["SAFE_OPERATION_PENDING_SIGNATURES"] = "SAFE_OPERATION_PENDING_SIGNATURES";
|
|
16
|
+
})(SafeClientTxStatus || (exports.SafeClientTxStatus = SafeClientTxStatus = {}));
|
|
17
|
+
const TRANSACTION_EXECUTED = 'The transaction has been executed, check the ethereumTxHash in the transactions property to view it on the corresponding blockchain explorer';
|
|
18
|
+
const TRANSACTION_SAVED = 'The transaction was not executed on-chain yet. There are pending signatures and you need to confirm it with other Safe owners first. Use the confirm(safeTxHash) method with other signer connected to the client';
|
|
19
|
+
const OFFCHAIN_MESSAGE_SAVED = 'The message was stored using the Safe Transaction Service, you need to confirm it with other Safe owners in order to make it valid. Use the confirmMessage(messageHash) method with other signer connected to the client';
|
|
20
|
+
const OFFCHAIN_MESSAGE_CONFIRMED = 'The message was stored using Safe services and now is confirmed and valid';
|
|
21
|
+
const SAFE_OPERATION_SAVED = 'The UserOperation was stored using the Safe Transaction Service as an SafeOperation, you need to confirm it with other Safe owners in order to make it valid. Use the confirmSafeOperation(safeOperationHash) method with other signer connected to the client';
|
|
22
|
+
const SAFE_OPERATION_SENT_TO_BUNDLER = 'The SafeOperation was sent to the bundler for being processed. Check the userOperationHash in the safeOperations property to see the SafeOperation in the corresponding explorer';
|
|
23
|
+
const SAFE_DEPLOYED = 'A new Safe account was deployed, check the ethereumTxHash in the safeAccountDeployment property to view it on the corresponding blockchain explorer';
|
|
24
|
+
exports.MESSAGES = {
|
|
25
|
+
[SafeClientTxStatus.DEPLOYED_AND_EXECUTED]: `${SAFE_DEPLOYED}. ${TRANSACTION_EXECUTED}`,
|
|
26
|
+
[SafeClientTxStatus.DEPLOYED_AND_PENDING_SIGNATURES]: `${SAFE_DEPLOYED}. ${TRANSACTION_SAVED}`,
|
|
27
|
+
[SafeClientTxStatus.EXECUTED]: TRANSACTION_EXECUTED,
|
|
28
|
+
[SafeClientTxStatus.PENDING_SIGNATURES]: TRANSACTION_SAVED,
|
|
29
|
+
[SafeClientTxStatus.MESSAGE_PENDING_SIGNATURES]: OFFCHAIN_MESSAGE_SAVED,
|
|
30
|
+
[SafeClientTxStatus.MESSAGE_CONFIRMED]: OFFCHAIN_MESSAGE_CONFIRMED,
|
|
31
|
+
[SafeClientTxStatus.DEPLOYED_AND_MESSAGE_PENDING_SIGNATURES]: `${SAFE_DEPLOYED}. ${OFFCHAIN_MESSAGE_SAVED}`,
|
|
32
|
+
[SafeClientTxStatus.DEPLOYED_AND_MESSAGE_CONFIRMED]: `${SAFE_DEPLOYED}. ${OFFCHAIN_MESSAGE_CONFIRMED}`,
|
|
33
|
+
[SafeClientTxStatus.SAFE_OPERATION_EXECUTED]: SAFE_OPERATION_SENT_TO_BUNDLER,
|
|
34
|
+
[SafeClientTxStatus.SAFE_OPERATION_PENDING_SIGNATURES]: SAFE_OPERATION_SAVED
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC5B,qEAA+C,CAAA;IAC/C,yFAAmE,CAAA;IACnE,2CAAqB,CAAA;IACrB,+DAAyC,CAAA;IACzC,+EAAyD,CAAA;IACzD,6DAAuC,CAAA;IACvC,yGAAmF,CAAA;IACnF,uFAAiE,CAAA;IACjE,yEAAmD,CAAA;IACnD,6FAAuE,CAAA;AACzE,CAAC,EAXW,kBAAkB,kCAAlB,kBAAkB,QAW7B;AAED,MAAM,oBAAoB,GACxB,8IAA8I,CAAA;AAChJ,MAAM,iBAAiB,GACrB,mNAAmN,CAAA;AACrN,MAAM,sBAAsB,GAC1B,0NAA0N,CAAA;AAC5N,MAAM,0BAA0B,GAC9B,2EAA2E,CAAA;AAC7E,MAAM,oBAAoB,GACxB,gQAAgQ,CAAA;AAClQ,MAAM,8BAA8B,GAClC,kLAAkL,CAAA;AACpL,MAAM,aAAa,GACjB,qJAAqJ,CAAA;AAE1I,QAAA,QAAQ,GAAG;IACtB,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,GAAG,aAAa,KAAK,oBAAoB,EAAE;IACvF,CAAC,kBAAkB,CAAC,+BAA+B,CAAC,EAAE,GAAG,aAAa,KAAK,iBAAiB,EAAE;IAC9F,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE,oBAAoB;IACnD,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,EAAE,iBAAiB;IAC1D,CAAC,kBAAkB,CAAC,0BAA0B,CAAC,EAAE,sBAAsB;IACvE,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,EAAE,0BAA0B;IAClE,CAAC,kBAAkB,CAAC,uCAAuC,CAAC,EAAE,GAAG,aAAa,KAAK,sBAAsB,EAAE;IAC3G,CAAC,kBAAkB,CAAC,8BAA8B,CAAC,EAAE,GAAG,aAAa,KAAK,0BAA0B,EAAE;IACtG,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,EAAE,8BAA8B;IAC5E,CAAC,kBAAkB,CAAC,iCAAiC,CAAC,EAAE,oBAAoB;CAC7E,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./messages/onChainMessages"), exports);
|
|
18
|
+
__exportStar(require("./messages/offChainMessages"), exports);
|
|
19
|
+
__exportStar(require("./safe-operations/safeOperations"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA0C;AAC1C,8DAA2C;AAC3C,mEAAgD"}
|