@safe-global/relay-kit 1.2.0 → 2.0.0-alpha.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/LICENSE.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Safe Ecosystem Foundation
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Safe Ecosystem Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
- # Relay Kit
2
-
3
- [![NPM Version](https://badge.fury.io/js/%40safe-global%2Frelay-kit.svg)](https://badge.fury.io/js/%40safe-global%2Frelay-kit)
4
- [![GitHub Release](https://img.shields.io/github/release/safe-global/safe-core-sdk.svg?style=flat)](https://github.com/safe-global/safe-core-sdk/releases)
5
- [![GitHub](https://img.shields.io/github/license/safe-global/safe-core-sdk)](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md)
6
-
7
- The Relay Kit allows to abstract users from the transaction fees payment (gas fees) allowing the use of native token or ERC-20 tokens. This will enable you to pay transaction fees directly from funding available in a Safe.
8
-
9
- ## Reference
10
-
11
- - [Relay Kit docs](https://docs.safe.global/learn/safe-core-account-abstraction-sdk/relay-kit)
12
-
13
- ## License
14
-
15
- This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
1
+ # Relay Kit
2
+
3
+ [![NPM Version](https://badge.fury.io/js/%40safe-global%2Frelay-kit.svg)](https://badge.fury.io/js/%40safe-global%2Frelay-kit)
4
+ [![GitHub Release](https://img.shields.io/github/release/safe-global/safe-core-sdk.svg?style=flat)](https://github.com/safe-global/safe-core-sdk/releases)
5
+ [![GitHub](https://img.shields.io/github/license/safe-global/safe-core-sdk)](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md)
6
+
7
+ The Relay Kit allows to abstract users from the transaction fees payment (gas fees) allowing the use of native token or ERC-20 tokens. This will enable you to pay transaction fees directly from funding available in a Safe.
8
+
9
+ ## Reference
10
+
11
+ - [Relay Kit docs](https://docs.safe.global/safe-core-aa-sdk/relay-kit)
12
+
13
+ ## License
14
+
15
+ This library is [released under MIT](https://github.com/safe-global/safe-core-sdk/blob/main/LICENSE.md).
@@ -0,0 +1,33 @@
1
+ import Safe from '@safe-global/protocol-kit';
2
+ import { MetaTransactionOptions, SafeTransaction } from '@safe-global/safe-core-sdk-types';
3
+ import { RelayKitTransaction } from './types';
4
+ export declare abstract class RelayKitBasePack {
5
+ protocolKit: Safe;
6
+ /**
7
+ * The packs implemented using our SDK should extend this class and therefore provide a Safe SDK instance
8
+ * @constructor
9
+ * @param protocolKit The Safe SDK instance
10
+ */
11
+ constructor(protocolKit: Safe);
12
+ /**
13
+ * Get an estimation of the fee that will be paid for a transaction
14
+ * @param chainId The chain id
15
+ * @param gasLimit Max amount of gas willing to consume
16
+ * @param gasToken Token address (or 0 if ETH) that is used for the payment
17
+ */
18
+ abstract getEstimateFee(chainId: bigint, gasLimit: string, gasToken?: string): Promise<string>;
19
+ /**
20
+ * Creates a Safe transaction designed to be executed using the relayer.
21
+ * @param {RelayKitTransaction} RelayKitTransaction - Properties required to create the transaction.
22
+ * @returns {Promise<SafeTransaction>} - Returns a Promise that resolves with a SafeTransaction object.
23
+ */
24
+ abstract createRelayedTransaction({ transactions, options, onlyCalls }: RelayKitTransaction): Promise<SafeTransaction>;
25
+ /**
26
+ * Sends the Safe transaction to the relayer for execution.
27
+ * If the Safe is not deployed, it creates a batch of transactions including the Safe deployment transaction.
28
+ * @param {SafeTransaction} safeTransaction - The Safe transaction to be executed
29
+ * @param {MetaTransactionOptions} options - The transaction options
30
+ * @returns {Promise<RelayResponse>} Returns a Promise that resolves with a RelayResponse object.
31
+ */
32
+ abstract executeRelayTransaction(safeTransaction: SafeTransaction, options?: MetaTransactionOptions): Promise<unknown>;
33
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RelayKitBasePack = void 0;
4
+ class RelayKitBasePack {
5
+ /**
6
+ * The packs implemented using our SDK should extend this class and therefore provide a Safe SDK instance
7
+ * @constructor
8
+ * @param protocolKit The Safe SDK instance
9
+ */
10
+ constructor(protocolKit) {
11
+ this.protocolKit = protocolKit;
12
+ }
13
+ }
14
+ exports.RelayKitBasePack = RelayKitBasePack;
15
+ //# sourceMappingURL=RelayKitBasePack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RelayKitBasePack.js","sourceRoot":"","sources":["../../src/RelayKitBasePack.ts"],"names":[],"mappings":";;;AAKA,MAAsB,gBAAgB;IAGpC;;;;OAIG;IACH,YAAY,WAAiB;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;CAgCF;AA1CD,4CA0CC"}
@@ -2,3 +2,5 @@ export declare const GELATO_NATIVE_TOKEN_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEee
2
2
  export declare const GELATO_FEE_COLLECTOR = "0x3AC05161b76a35c1c28dC99Aa01BEd7B24cEA3bf";
3
3
  export declare const GELATO_RELAY_URL = "https://relay.gelato.digital";
4
4
  export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
5
+ export declare const GELATO_GAS_EXECUTION_OVERHEAD = 150000;
6
+ export declare const GELATO_TRANSFER_GAS_COST = 15000;
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZERO_ADDRESS = exports.GELATO_RELAY_URL = exports.GELATO_FEE_COLLECTOR = exports.GELATO_NATIVE_TOKEN_ADDRESS = void 0;
3
+ exports.GELATO_TRANSFER_GAS_COST = exports.GELATO_GAS_EXECUTION_OVERHEAD = exports.ZERO_ADDRESS = exports.GELATO_RELAY_URL = exports.GELATO_FEE_COLLECTOR = exports.GELATO_NATIVE_TOKEN_ADDRESS = void 0;
4
4
  exports.GELATO_NATIVE_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
5
5
  exports.GELATO_FEE_COLLECTOR = '0x3AC05161b76a35c1c28dC99Aa01BEd7B24cEA3bf';
6
6
  exports.GELATO_RELAY_URL = 'https://relay.gelato.digital';
7
7
  exports.ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
8
+ // see: https://docs.gelato.network/developer-services/relay/quick-start/optional-parameters#optional-parameters
9
+ exports.GELATO_GAS_EXECUTION_OVERHEAD = 150000;
10
+ // gas cost of the separate ERC20 transfer to pay the fees to the Gelato relayer
11
+ exports.GELATO_TRANSFER_GAS_COST = 15000;
8
12
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG,4CAA4C,CAAA;AAE1E,QAAA,oBAAoB,GAAG,4CAA4C,CAAA;AAEnE,QAAA,gBAAgB,GAAG,8BAA8B,CAAA;AAEjD,QAAA,YAAY,GAAG,4CAA4C,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,2BAA2B,GAAG,4CAA4C,CAAA;AAE1E,QAAA,oBAAoB,GAAG,4CAA4C,CAAA;AAEnE,QAAA,gBAAgB,GAAG,8BAA8B,CAAA;AAEjD,QAAA,YAAY,GAAG,4CAA4C,CAAA;AAExE,gHAAgH;AACnG,QAAA,6BAA6B,GAAG,MAAO,CAAA;AAEpD,gFAAgF;AACnE,QAAA,wBAAwB,GAAG,KAAM,CAAA"}
@@ -1,2 +1,4 @@
1
1
  export * from './packs/gelato/GelatoRelayPack';
2
+ export * from './packs/gelato/types';
3
+ export * from './RelayKitBasePack';
2
4
  export * from './types';
package/dist/src/index.js CHANGED
@@ -15,5 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./packs/gelato/GelatoRelayPack"), exports);
18
+ __exportStar(require("./packs/gelato/types"), exports);
19
+ __exportStar(require("./RelayKitBasePack"), exports);
18
20
  __exportStar(require("./types"), exports);
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA8C;AAC9C,0CAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA8C;AAC9C,uDAAoC;AAEpC,qDAAkC;AAClC,0CAAuB"}
@@ -1,16 +1,66 @@
1
1
  import { RelayResponse, TransactionStatusResponse } from '@gelatonetwork/relay-sdk';
2
- import Safe from '@safe-global/protocol-kit';
3
- import { RelayPack } from '../../types';
4
- import { MetaTransactionData, MetaTransactionOptions, RelayTransaction, SafeTransaction } from '@safe-global/safe-core-sdk-types';
5
- export declare class GelatoRelayPack implements RelayPack {
2
+ import { RelayKitBasePack } from '../../RelayKitBasePack';
3
+ import { RelayKitTransaction } from '../../types';
4
+ import { MetaTransactionOptions, RelayTransaction, SafeTransaction } from '@safe-global/safe-core-sdk-types';
5
+ import { GelatoOptions } from './types';
6
+ export declare class GelatoRelayPack extends RelayKitBasePack {
6
7
  #private;
7
- constructor(apiKey?: string);
8
+ constructor({ apiKey, protocolKit }: GelatoOptions);
8
9
  private _getFeeToken;
9
10
  getFeeCollector(): string;
10
- getEstimateFee(chainId: number, gasLimit: string, gasToken?: string): Promise<string>;
11
+ getEstimateFee(chainId: bigint, gasLimit: string, gasToken?: string): Promise<string>;
11
12
  getTaskStatus(taskId: string): Promise<TransactionStatusResponse | undefined>;
12
- createRelayedTransaction(safe: Safe, transactions: MetaTransactionData[], options: MetaTransactionOptions): Promise<SafeTransaction>;
13
- sendSponsorTransaction(target: string, encodedTransaction: string, chainId: number): Promise<RelayResponse>;
14
- sendSyncTransaction(target: string, encodedTransaction: string, chainId: number, options: MetaTransactionOptions): Promise<RelayResponse>;
13
+ /**
14
+ * Creates a payment transaction to Gelato
15
+ *
16
+ * @private
17
+ * @async
18
+ * @function
19
+ * @param {string} gas - The gas amount for the payment.
20
+ * @param {MetaTransactionOptions} options - Options for the meta transaction.
21
+ * @returns {Promise<Transaction>} Promise object representing the created payment transaction.
22
+ *
23
+ */
24
+ private createPaymentToGelato;
25
+ /**
26
+ * Creates a Safe transaction designed to be executed using the Gelato Relayer.
27
+ *
28
+ * @param {RelayKitTransaction} RelayKitTransaction - Properties required to create the transaction.
29
+ * @returns {Promise<SafeTransaction>} Returns a Promise that resolves with a SafeTransaction object.
30
+ */
31
+ createRelayedTransaction({ transactions, onlyCalls, options }: RelayKitTransaction): Promise<SafeTransaction>;
32
+ /**
33
+ * Creates a Safe transaction designed to be executed using the Gelato Relayer and
34
+ * uses the handlePayment function defined in the Safe contract to pay the fees
35
+ * to the Gelato relayer.
36
+ *
37
+ * @async
38
+ * @function createTransactionWithHandlePayment
39
+ * @param {RelayKitTransaction} RelayKitTransaction - Properties needed to create the transaction.
40
+ * @returns {Promise<SafeTransaction>} Returns a promise that resolves to the created SafeTransaction.
41
+ * @private
42
+ */
43
+ private createTransactionWithHandlePayment;
44
+ /**
45
+ * Creates a Safe transaction designed to be executed using the Gelato Relayer and
46
+ * uses a separate ERC20 transfer to pay the fees to the Gelato relayer.
47
+ *
48
+ * @async
49
+ * @function createTransactionWithTransfer
50
+ * @param {RelayKitTransaction} RelayKitTransaction - Properties needed to create the transaction.
51
+ * @returns {Promise<SafeTransaction>} Returns a promise that resolves to the created SafeTransaction.
52
+ * @private
53
+ */
54
+ private createTransactionWithTransfer;
55
+ sendSponsorTransaction(target: string, encodedTransaction: string, chainId: bigint): Promise<RelayResponse>;
56
+ sendSyncTransaction(target: string, encodedTransaction: string, chainId: bigint, options: MetaTransactionOptions): Promise<RelayResponse>;
15
57
  relayTransaction({ target, encodedTransaction, chainId, options }: RelayTransaction): Promise<RelayResponse>;
58
+ /**
59
+ * Sends the Safe transaction to the Gelato Relayer for execution.
60
+ * If the Safe is not deployed, it creates a batch of transactions including the Safe deployment transaction.
61
+ *
62
+ * @param {SafeTransaction} safeTransaction - The Safe transaction to be executed.
63
+ * @returns {Promise<RelayResponse>} Returns a Promise that resolves with a RelayResponse object.
64
+ */
65
+ executeRelayTransaction(safeTransaction: SafeTransaction, options?: MetaTransactionOptions): Promise<RelayResponse>;
16
66
  }
@@ -13,11 +13,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _GelatoRelayPack_gelatoRelay, _GelatoRelayPack_apiKey;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.GelatoRelayPack = void 0;
16
- const bignumber_1 = require("@ethersproject/bignumber");
17
16
  const relay_sdk_1 = require("@gelatonetwork/relay-sdk");
17
+ const protocol_kit_1 = require("@safe-global/protocol-kit");
18
+ const RelayKitBasePack_1 = require("../../RelayKitBasePack");
18
19
  const constants_1 = require("../../constants");
19
- class GelatoRelayPack {
20
- constructor(apiKey) {
20
+ class GelatoRelayPack extends RelayKitBasePack_1.RelayKitBasePack {
21
+ constructor({ apiKey, protocolKit }) {
22
+ super(protocolKit);
21
23
  _GelatoRelayPack_gelatoRelay.set(this, void 0);
22
24
  _GelatoRelayPack_apiKey.set(this, void 0);
23
25
  __classPrivateFieldSet(this, _GelatoRelayPack_gelatoRelay, new relay_sdk_1.GelatoRelay(), "f");
@@ -31,36 +33,181 @@ class GelatoRelayPack {
31
33
  }
32
34
  async getEstimateFee(chainId, gasLimit, gasToken) {
33
35
  const feeToken = this._getFeeToken(gasToken);
34
- const estimation = await __classPrivateFieldGet(this, _GelatoRelayPack_gelatoRelay, "f").getEstimatedFee(chainId, feeToken, bignumber_1.BigNumber.from(gasLimit), true);
36
+ const estimation = await __classPrivateFieldGet(this, _GelatoRelayPack_gelatoRelay, "f").getEstimatedFee(chainId, feeToken, BigInt(gasLimit), false);
35
37
  return estimation.toString();
36
38
  }
37
39
  async getTaskStatus(taskId) {
38
40
  return __classPrivateFieldGet(this, _GelatoRelayPack_gelatoRelay, "f").getTaskStatus(taskId);
39
41
  }
40
- async createRelayedTransaction(safe, transactions, options) {
41
- const { gasLimit, gasToken, isSponsored } = options;
42
- const nonce = await safe.getNonce();
42
+ /**
43
+ * Creates a payment transaction to Gelato
44
+ *
45
+ * @private
46
+ * @async
47
+ * @function
48
+ * @param {string} gas - The gas amount for the payment.
49
+ * @param {MetaTransactionOptions} options - Options for the meta transaction.
50
+ * @returns {Promise<Transaction>} Promise object representing the created payment transaction.
51
+ *
52
+ */
53
+ async createPaymentToGelato(gas, options) {
54
+ const chainId = await this.protocolKit.getChainId();
55
+ const gelatoAddress = this.getFeeCollector();
56
+ const gasToken = options.gasToken ?? constants_1.ZERO_ADDRESS;
57
+ const paymentToGelato = await this.getEstimateFee(chainId, gas, gasToken);
58
+ // The Gelato payment transaction
59
+ const transferToGelato = (0, protocol_kit_1.createERC20TokenTransferTransaction)(gasToken, gelatoAddress, paymentToGelato);
60
+ return transferToGelato;
61
+ }
62
+ /**
63
+ * Creates a Safe transaction designed to be executed using the Gelato Relayer.
64
+ *
65
+ * @param {RelayKitTransaction} RelayKitTransaction - Properties required to create the transaction.
66
+ * @returns {Promise<SafeTransaction>} Returns a Promise that resolves with a SafeTransaction object.
67
+ */
68
+ async createRelayedTransaction({ transactions, onlyCalls = false, options = {} }) {
69
+ const { isSponsored = false } = options;
43
70
  if (isSponsored) {
44
- const sponsoredTransaction = await safe.createTransaction({
71
+ const nonce = await this.protocolKit.getNonce();
72
+ const sponsoredTransaction = await this.protocolKit.createTransaction({
45
73
  safeTransactionData: transactions,
74
+ onlyCalls,
46
75
  options: {
47
76
  nonce
48
77
  }
49
78
  });
50
79
  return sponsoredTransaction;
51
80
  }
52
- const chainId = await safe.getChainId();
53
- const estimation = await this.getEstimateFee(chainId, gasLimit, gasToken);
54
- const syncTransaction = await safe.createTransaction({
81
+ // If the ERC20 gas token does not follow the standard 18 decimals, we cannot use handlePayment to pay Gelato fees.
82
+ const gasToken = options.gasToken ?? constants_1.ZERO_ADDRESS;
83
+ const isGasTokenCompatible = await (0, protocol_kit_1.isGasTokenCompatibleWithHandlePayment)(gasToken, this.protocolKit);
84
+ if (!isGasTokenCompatible) {
85
+ // if the ERC20 gas token is not compatible (less than 18 decimals like USDC), a separate transfer is required to pay Gelato fees.
86
+ return this.createTransactionWithTransfer({ transactions, onlyCalls, options });
87
+ }
88
+ // If the gas token is compatible (Native token or standard ERC20), we use handlePayment function present in the Safe contract to pay Gelato fees
89
+ return this.createTransactionWithHandlePayment({ transactions, onlyCalls, options });
90
+ }
91
+ /**
92
+ * Creates a Safe transaction designed to be executed using the Gelato Relayer and
93
+ * uses the handlePayment function defined in the Safe contract to pay the fees
94
+ * to the Gelato relayer.
95
+ *
96
+ * @async
97
+ * @function createTransactionWithHandlePayment
98
+ * @param {RelayKitTransaction} RelayKitTransaction - Properties needed to create the transaction.
99
+ * @returns {Promise<SafeTransaction>} Returns a promise that resolves to the created SafeTransaction.
100
+ * @private
101
+ */
102
+ async createTransactionWithHandlePayment({ transactions, onlyCalls = false, options = {} }) {
103
+ const { gasLimit } = options;
104
+ const nonce = await this.protocolKit.getNonce();
105
+ // this transaction is only used for gas estimations
106
+ const transactionToEstimateGas = await this.protocolKit.createTransaction({
107
+ safeTransactionData: transactions,
108
+ onlyCalls,
109
+ options: {
110
+ nonce
111
+ }
112
+ });
113
+ // as we set gasPrice to 1, safeTxGas is set to a non-zero value to prevent transaction failure due to out-of-gas errors. value see: https://github.com/safe-global/safe-contracts/blob/main/contracts/Safe.sol#L203
114
+ const gasPrice = '1';
115
+ const safeTxGas = await (0, protocol_kit_1.estimateSafeTxGas)(this.protocolKit, transactionToEstimateGas);
116
+ const gasToken = options.gasToken ?? constants_1.ZERO_ADDRESS;
117
+ const refundReceiver = this.getFeeCollector();
118
+ const chainId = await this.protocolKit.getChainId();
119
+ // if a custom gasLimit is provided, we do not need to estimate the gas cost
120
+ if (gasLimit) {
121
+ const paymentToGelato = await this.getEstimateFee(chainId, gasLimit, gasToken);
122
+ const syncTransaction = await this.protocolKit.createTransaction({
123
+ safeTransactionData: transactions,
124
+ onlyCalls,
125
+ options: {
126
+ baseGas: paymentToGelato,
127
+ gasPrice,
128
+ safeTxGas,
129
+ gasToken,
130
+ refundReceiver,
131
+ nonce
132
+ }
133
+ });
134
+ return syncTransaction;
135
+ }
136
+ // If gasLimit is not provided, we need to estimate the gas cost.
137
+ const baseGas = await (0, protocol_kit_1.estimateTxBaseGas)(this.protocolKit, transactionToEstimateGas);
138
+ const safeDeploymentGasCost = await (0, protocol_kit_1.estimateSafeDeploymentGas)(this.protocolKit);
139
+ const totalGas = Number(baseGas) + // baseGas
140
+ Number(safeTxGas) + // safeTxGas
141
+ Number(safeDeploymentGasCost) + // Safe deploymet gas cost if it is required
142
+ constants_1.GELATO_GAS_EXECUTION_OVERHEAD; // Gelato execution overhead
143
+ const paymentToGelato = await this.getEstimateFee(chainId, String(totalGas), gasToken);
144
+ const syncTransaction = await this.protocolKit.createTransaction({
145
+ safeTransactionData: transactions,
146
+ onlyCalls,
147
+ options: {
148
+ baseGas: paymentToGelato,
149
+ gasPrice,
150
+ safeTxGas,
151
+ gasToken,
152
+ refundReceiver,
153
+ nonce
154
+ }
155
+ });
156
+ return syncTransaction;
157
+ }
158
+ /**
159
+ * Creates a Safe transaction designed to be executed using the Gelato Relayer and
160
+ * uses a separate ERC20 transfer to pay the fees to the Gelato relayer.
161
+ *
162
+ * @async
163
+ * @function createTransactionWithTransfer
164
+ * @param {RelayKitTransaction} RelayKitTransaction - Properties needed to create the transaction.
165
+ * @returns {Promise<SafeTransaction>} Returns a promise that resolves to the created SafeTransaction.
166
+ * @private
167
+ */
168
+ async createTransactionWithTransfer({ transactions, onlyCalls = false, options = {} }) {
169
+ const { gasLimit } = options;
170
+ const nonce = await this.protocolKit.getNonce();
171
+ const gasToken = options.gasToken ?? constants_1.ZERO_ADDRESS;
172
+ // if a custom gasLimit is provided, we do not need to estimate the gas cost
173
+ if (gasLimit) {
174
+ const transferToGelato = await this.createPaymentToGelato(gasLimit, options);
175
+ const syncTransaction = await this.protocolKit.createTransaction({
176
+ safeTransactionData: [...transactions, transferToGelato],
177
+ onlyCalls,
178
+ options: {
179
+ nonce,
180
+ gasToken
181
+ }
182
+ });
183
+ return syncTransaction;
184
+ }
185
+ // If gasLimit is not provided, we need to estimate the gas cost.
186
+ // this transaction is only used for gas estimations
187
+ const transactionToEstimateGas = await this.protocolKit.createTransaction({
55
188
  safeTransactionData: transactions,
189
+ onlyCalls,
56
190
  options: {
57
- baseGas: estimation,
58
- gasPrice: '1',
59
- gasToken: gasToken !== null && gasToken !== void 0 ? gasToken : constants_1.ZERO_ADDRESS,
60
- refundReceiver: this.getFeeCollector(),
61
191
  nonce
62
192
  }
63
193
  });
194
+ const safeTxGas = await (0, protocol_kit_1.estimateSafeTxGas)(this.protocolKit, transactionToEstimateGas);
195
+ const baseGas = await (0, protocol_kit_1.estimateTxBaseGas)(this.protocolKit, transactionToEstimateGas);
196
+ const safeDeploymentGasCost = await (0, protocol_kit_1.estimateSafeDeploymentGas)(this.protocolKit);
197
+ const totalGas = Number(baseGas) + // baseGas
198
+ Number(safeTxGas) + // safeTxGas without Gelato payment transfer
199
+ Number(safeDeploymentGasCost) + // Safe deploymet gas cost if it is required
200
+ constants_1.GELATO_TRANSFER_GAS_COST + // Gelato payment transfer
201
+ constants_1.GELATO_GAS_EXECUTION_OVERHEAD; // Gelato execution overhead
202
+ const transferToGelato = await this.createPaymentToGelato(String(totalGas), options);
203
+ const syncTransaction = await this.protocolKit.createTransaction({
204
+ safeTransactionData: [...transactions, transferToGelato],
205
+ onlyCalls,
206
+ options: {
207
+ nonce,
208
+ gasToken
209
+ }
210
+ });
64
211
  return syncTransaction;
65
212
  }
66
213
  async sendSponsorTransaction(target, encodedTransaction, chainId) {
@@ -86,17 +233,55 @@ class GelatoRelayPack {
86
233
  isRelayContext: false
87
234
  };
88
235
  const relayRequestOptions = {
89
- gasLimit
236
+ gasLimit: gasLimit ? BigInt(gasLimit) : undefined
90
237
  };
91
238
  const response = await __classPrivateFieldGet(this, _GelatoRelayPack_gelatoRelay, "f").callWithSyncFee(request, relayRequestOptions);
92
239
  return response;
93
240
  }
94
- async relayTransaction({ target, encodedTransaction, chainId, options }) {
241
+ async relayTransaction({ target, encodedTransaction, chainId, options = {} }) {
95
242
  const response = options.isSponsored
96
243
  ? this.sendSponsorTransaction(target, encodedTransaction, chainId)
97
244
  : this.sendSyncTransaction(target, encodedTransaction, chainId, options);
98
245
  return response;
99
246
  }
247
+ /**
248
+ * Sends the Safe transaction to the Gelato Relayer for execution.
249
+ * If the Safe is not deployed, it creates a batch of transactions including the Safe deployment transaction.
250
+ *
251
+ * @param {SafeTransaction} safeTransaction - The Safe transaction to be executed.
252
+ * @returns {Promise<RelayResponse>} Returns a Promise that resolves with a RelayResponse object.
253
+ */
254
+ async executeRelayTransaction(safeTransaction, options) {
255
+ const isSafeDeployed = await this.protocolKit.isSafeDeployed();
256
+ const chainId = await this.protocolKit.getChainId();
257
+ const safeAddress = await this.protocolKit.getAddress();
258
+ const safeTransactionEncodedData = await this.protocolKit.getEncodedTransaction(safeTransaction);
259
+ const gasToken = options?.gasToken || safeTransaction.data.gasToken;
260
+ if (isSafeDeployed) {
261
+ const relayTransaction = {
262
+ target: safeAddress,
263
+ encodedTransaction: safeTransactionEncodedData,
264
+ chainId,
265
+ options: {
266
+ ...options,
267
+ gasToken
268
+ }
269
+ };
270
+ return this.relayTransaction(relayTransaction);
271
+ }
272
+ // if the Safe is not deployed we create a batch with the Safe deployment transaction and the provided Safe transaction
273
+ const safeDeploymentBatch = await this.protocolKit.wrapSafeTransactionIntoDeploymentBatch(safeTransaction);
274
+ const relayTransaction = {
275
+ target: safeDeploymentBatch.to,
276
+ encodedTransaction: safeDeploymentBatch.data,
277
+ chainId,
278
+ options: {
279
+ ...options,
280
+ gasToken
281
+ }
282
+ };
283
+ return this.relayTransaction(relayTransaction);
284
+ }
100
285
  }
101
286
  exports.GelatoRelayPack = GelatoRelayPack;
102
287
  _GelatoRelayPack_gelatoRelay = new WeakMap(), _GelatoRelayPack_apiKey = new WeakMap();
@@ -1 +1 @@
1
- {"version":3,"file":"GelatoRelayPack.js","sourceRoot":"","sources":["../../../../src/packs/gelato/GelatoRelayPack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAoD;AACpD,wDAOiC;AAEjC,gEAIyC;AASzC,MAAa,eAAe;IAI1B,YAAY,MAAe;QAH3B,+CAAgC;QAChC,0CAAgB;QAGd,uBAAA,IAAI,gCAAgB,IAAI,uBAAkB,EAAE,MAAA,CAAA;QAC5C,uBAAA,IAAI,2BAAW,MAAM,MAAA,CAAA;IACvB,CAAC;IAEO,YAAY,CAAC,QAAiB;QACpC,OAAO,CAAC,QAAQ,IAAI,QAAQ,KAAK,wBAAY,CAAC,CAAC,CAAC,uCAA2B,CAAC,CAAC,CAAC,QAAQ,CAAA;IACxF,CAAC;IAED,eAAe;QACb,OAAO,gCAAoB,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAe,EAAE,QAAgB,EAAE,QAAiB;QACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAC5C,MAAM,UAAU,GAAG,MAAM,uBAAA,IAAI,oCAAa,CAAC,eAAe,CACxD,OAAO,EACP,QAAQ,EACR,qBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EACxB,IAAI,CACL,CAAA;QACD,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAc;QAChC,OAAO,uBAAA,IAAI,oCAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAED,KAAK,CAAC,wBAAwB,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