near-safe 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ export declare class SafeContractSuite {
14
14
  addressForSetup(setup: Hex, saltNonce?: string): Promise<Address>;
15
15
  getSetup(owners: string[]): Hex;
16
16
  addOwnerData(newOwner: Address): Hex;
17
- getOpHash(unsignedUserOp: UserOperation): Promise<Hash>;
17
+ getOpHash(chainId: number, unsignedUserOp: UserOperation): Promise<Hash>;
18
18
  private factoryDataForSetup;
19
19
  buildUserOp(nonce: bigint, txData: MetaTransaction, safeAddress: Address, feeData: GasPrice, setup: string, safeNotDeployed: boolean, safeSaltNonce: string): Promise<UnsignedUserOperation>;
20
20
  getNonce(address: Address, chainId: number): Promise<bigint>;
@@ -64,9 +64,10 @@ class SafeContractSuite {
64
64
  args: [newOwner, 1],
65
65
  });
66
66
  }
67
- async getOpHash(unsignedUserOp) {
67
+ async getOpHash(chainId, unsignedUserOp) {
68
68
  const { factory, factoryData, verificationGasLimit, callGasLimit, maxPriorityFeePerGas, maxFeePerGas, } = unsignedUserOp;
69
- const opHash = await this.dummyClient.readContract({
69
+ const client = await (0, util_1.getClient)(chainId);
70
+ const opHash = await client.readContract({
70
71
  address: this.m4337.address,
71
72
  abi: this.m4337.abi,
72
73
  functionName: "getOperationHash",
@@ -3,7 +3,7 @@ import { FinalExecutionOutcome } from "near-api-js/lib/providers";
3
3
  import { NearEthAdapter, SignRequestData } from "near-ca";
4
4
  import { Address, Hash, Hex } from "viem";
5
5
  import { SafeContractSuite } from "./lib/safe";
6
- import { EncodedTxData, EvmTransactionData, MetaTransaction, UserOperation, UserOperationReceipt } from "./types";
6
+ import { DecodedMultisend, EncodedTxData, EvmTransactionData, MetaTransaction, UserOperation, UserOperationReceipt } from "./types";
7
7
  export interface NearSafeConfig {
8
8
  accountId: string;
9
9
  mpcContractId: string;
@@ -85,7 +85,7 @@ export declare class NearSafe {
85
85
  * @param {UserOperation} userOp - The user operation for which the hash needs to be computed.
86
86
  * @returns {Promise<Hash>} - A promise that resolves to the hash of the provided user operation.
87
87
  */
88
- opHash(userOp: UserOperation): Promise<Hash>;
88
+ opHash(chainId: number, userOp: UserOperation): Promise<Hash>;
89
89
  /**
90
90
  * Encodes a request to sign a transaction using either a paymaster or the user's own funds.
91
91
  *
@@ -162,11 +162,7 @@ export declare class NearSafe {
162
162
  * @param {EvmTransactionData} data - The raw transaction data to be decoded.
163
163
  * @returns {{ chainId: number; costEstimate: string; transactions: MetaTransaction[] }} - An object containing the chain ID, estimated cost, and a list of decoded meta-transactions.
164
164
  */
165
- decodeTxData(data: EvmTransactionData): {
166
- chainId: number;
167
- costEstimate: string;
168
- transactions: MetaTransaction[];
169
- };
165
+ decodeTxData(data: EvmTransactionData): DecodedMultisend;
170
166
  /**
171
167
  * Handles routing of signature requests based on the provided method, chain ID, and parameters.
172
168
  *
@@ -118,8 +118,8 @@ class NearSafe {
118
118
  * @param {UserOperation} userOp - The user operation for which the hash needs to be computed.
119
119
  * @returns {Promise<Hash>} - A promise that resolves to the hash of the provided user operation.
120
120
  */
121
- async opHash(userOp) {
122
- return this.safePack.getOpHash(userOp);
121
+ async opHash(chainId, userOp) {
122
+ return this.safePack.getOpHash(chainId, userOp);
123
123
  }
124
124
  /**
125
125
  * Encodes a request to sign a transaction using either a paymaster or the user's own funds.
@@ -317,11 +317,11 @@ class NearSafe {
317
317
  transactions,
318
318
  usePaymaster,
319
319
  });
320
- const opHash = await this.opHash(userOp);
320
+ const opHash = await this.opHash(chainId, userOp);
321
321
  return {
322
322
  payload: (0, near_ca_1.toPayload)(opHash),
323
323
  evmMessage: JSON.stringify(userOp),
324
- hash: await this.opHash(userOp),
324
+ hash: await this.opHash(chainId, userOp),
325
325
  };
326
326
  }
327
327
  }
@@ -1,113 +1,247 @@
1
1
  import { FunctionCallTransaction, SignArgs } from "near-ca";
2
2
  import { Address, Hex, ParseAbi } from "viem";
3
+ /**
4
+ * Represents a collection of Safe contract deployments, each with its own address and ABI.
5
+ */
3
6
  export type SafeDeployments = {
7
+ /** Deployment for the singleton contract. */
4
8
  singleton: Deployment;
9
+ /** Deployment for the proxy factory contract. */
5
10
  proxyFactory: Deployment;
11
+ /** Deployment for the module setup contract. */
6
12
  moduleSetup: Deployment;
13
+ /** Deployment for the m4337 module contract. */
7
14
  m4337: Deployment;
15
+ /** Deployment for the entry point contract. */
8
16
  entryPoint: Deployment;
9
17
  };
18
+ /**
19
+ * Represents the details of a deployed contract, including its ABI and address.
20
+ */
10
21
  export interface Deployment {
22
+ /** The ABI of the deployed contract. Can be a raw ABI array or a parsed ABI. */
11
23
  abi: unknown[] | ParseAbi<readonly string[]>;
24
+ /** The address of the deployed contract. */
12
25
  address: Address;
13
26
  }
27
+ /**
28
+ * Represents an unsigned user operation that can be sent to the EntryPoint contract.
29
+ */
14
30
  export interface UnsignedUserOperation {
31
+ /** The sender's address initiating the user operation. */
15
32
  sender: Address;
33
+ /** The unique nonce associated with this user operation. */
16
34
  nonce: string;
35
+ /** The optional factory address to use for creating new contracts. */
17
36
  factory?: Address;
37
+ /** Optional additional data for the factory, typically used for contract initialization. */
18
38
  factoryData?: Hex;
39
+ /** The encoded data for the contract call or transaction execution. */
19
40
  callData: Hex;
41
+ /** Maximum priority fee per gas unit for the transaction. */
20
42
  maxPriorityFeePerGas: Hex;
43
+ /** Maximum fee per gas unit for the transaction. */
21
44
  maxFeePerGas: Hex;
22
45
  }
23
46
  /**
24
- * Supported Representation of UserOperation for EntryPoint v0.7
47
+ * Supported representation of a user operation for EntryPoint version 0.7, including gas limits and signature.
25
48
  */
26
49
  export interface UserOperation extends UnsignedUserOperation {
50
+ /** The gas limit for verification of the operation. */
27
51
  verificationGasLimit: Hex;
52
+ /** The gas limit for the execution of the operation call. */
28
53
  callGasLimit: Hex;
54
+ /** The gas used before verification begins. */
29
55
  preVerificationGas: Hex;
56
+ /** Optional signature for the user operation. */
30
57
  signature?: Hex;
31
58
  }
59
+ /**
60
+ * Represents additional paymaster-related data for a user operation.
61
+ */
32
62
  export interface PaymasterData {
63
+ /** Optional paymaster address responsible for covering gas costs. */
33
64
  paymaster?: Address;
65
+ /** Optional additional data required by the paymaster. */
34
66
  paymasterData?: Hex;
67
+ /** The gas limit for paymaster verification. */
35
68
  paymasterVerificationGasLimit?: Hex;
69
+ /** The gas limit for paymaster post-operation execution. */
36
70
  paymasterPostOpGasLimit?: Hex;
71
+ /** The gas limit for operation verification. */
37
72
  verificationGasLimit: Hex;
73
+ /** The gas limit for the operation call execution. */
38
74
  callGasLimit: Hex;
75
+ /** The gas used before verification begins. */
39
76
  preVerificationGas: Hex;
40
77
  }
78
+ /**
79
+ * User configuration options for transaction building and user operation execution.
80
+ */
41
81
  export interface UserOptions {
82
+ /** Whether to use a paymaster for gas fee coverage. */
42
83
  usePaymaster: boolean;
84
+ /** The unique nonce used to differentiate multiple Safe setups. */
43
85
  safeSaltNonce: string;
86
+ /** The NEAR contract ID for the MPC contract. */
44
87
  mpcContractId: string;
88
+ /** Optional recovery address in case of key compromise or other emergency situations. */
45
89
  recoveryAddress?: string;
46
90
  }
91
+ /**
92
+ * Represents the possible transaction statuses.
93
+ */
47
94
  export type TxStatus = "success" | "reverted";
95
+ /**
96
+ * Represents a log entry in a transaction receipt.
97
+ */
48
98
  interface Log {
99
+ /** The index of the log in the transaction. */
49
100
  logIndex: string;
101
+ /** The index of the transaction within the block. */
50
102
  transactionIndex: string;
103
+ /** The hash of the transaction containing the log. */
51
104
  transactionHash: string;
105
+ /** The hash of the block containing the transaction. */
52
106
  blockHash: string;
107
+ /** The number of the block containing the transaction. */
53
108
  blockNumber: string;
109
+ /** The address that generated the log. */
54
110
  address: string;
111
+ /** The raw data of the log. */
55
112
  data: string;
113
+ /** The topics associated with the log event. */
56
114
  topics: string[];
57
115
  }
116
+ /**
117
+ * Represents a transaction receipt returned by the blockchain.
118
+ */
58
119
  interface Receipt {
120
+ /** The hash of the transaction. */
59
121
  transactionHash: Hex;
122
+ /** The index of the transaction within the block. */
60
123
  transactionIndex: bigint;
124
+ /** The hash of the block containing the transaction. */
61
125
  blockHash: Hex;
126
+ /** The number of the block containing the transaction. */
62
127
  blockNumber: bigint;
128
+ /** The address from which the transaction originated. */
63
129
  from: Address;
130
+ /** Optional address to which the transaction was sent (if applicable). */
64
131
  to?: Address;
132
+ /** The cumulative gas used in the block up to this transaction. */
65
133
  cumulativeGasUsed: bigint;
134
+ /** The status of the transaction (success or reverted). */
66
135
  status: TxStatus;
136
+ /** The total gas used by this transaction. */
67
137
  gasUsed: bigint;
138
+ /** Optional address of a newly deployed contract (if applicable). */
68
139
  contractAddress?: Address;
140
+ /** The logs bloom filter for the transaction. */
69
141
  logsBloom: Hex;
142
+ /** The effective gas price used in the transaction. */
70
143
  effectiveGasPrice: bigint;
71
144
  }
145
+ /**
146
+ * Represents the receipt of a user operation including its details, logs, and result.
147
+ */
72
148
  export type UserOperationReceipt = {
149
+ /** The hash of the user operation. */
73
150
  userOpHash: Hex;
151
+ /** The address of the entry point contract handling the user operation. */
74
152
  entryPoint: Address;
153
+ /** The sender's address initiating the user operation. */
75
154
  sender: Address;
155
+ /** The nonce of the user operation. */
76
156
  nonce: bigint;
157
+ /** Optional paymaster address responsible for covering gas costs. */
77
158
  paymaster?: Address;
159
+ /** The actual gas used by the operation. */
78
160
  actualGasUsed: bigint;
161
+ /** The actual gas cost of the operation. */
79
162
  actualGasCost: bigint;
163
+ /** Whether the user operation succeeded or failed. */
80
164
  success: boolean;
165
+ /** Optional reason for failure if the operation was unsuccessful. */
81
166
  reason?: string;
167
+ /** The transaction receipt associated with the user operation. */
82
168
  receipt: Receipt;
169
+ /** The list of logs generated by the user operation. */
83
170
  logs: Log[];
84
171
  };
172
+ /**
173
+ * Represents the different gas prices for transaction execution based on priority levels.
174
+ */
85
175
  export interface GasPrices {
176
+ /** Gas price for slower transactions. */
86
177
  slow: GasPrice;
178
+ /** Gas price for standard transactions. */
87
179
  standard: GasPrice;
180
+ /** Gas price for fast transactions. */
88
181
  fast: GasPrice;
89
182
  }
183
+ /**
184
+ * Represents a specific gas price configuration for transaction execution.
185
+ */
90
186
  export interface GasPrice {
187
+ /** Maximum fee per gas unit for the transaction. */
91
188
  maxFeePerGas: Hex;
189
+ /** Maximum priority fee per gas unit for the transaction. */
92
190
  maxPriorityFeePerGas: Hex;
93
191
  }
192
+ /**
193
+ * Enum representing the type of operation in a meta-transaction.
194
+ */
94
195
  export declare enum OperationType {
196
+ /** Standard call operation (0). */
95
197
  Call = 0,
198
+ /** Delegate call operation (1). */
96
199
  DelegateCall = 1
97
200
  }
201
+ /**
202
+ * Represents a meta-transaction, which includes the destination address, value, data, and type of operation.
203
+ */
98
204
  export interface MetaTransaction {
205
+ /** The destination address for the meta-transaction. */
99
206
  readonly to: string;
207
+ /** The value to be sent with the transaction (as a string to handle large numbers). */
100
208
  readonly value: string;
209
+ /** The encoded data for the contract call or function execution. */
101
210
  readonly data: string;
211
+ /** Optional type of operation (call or delegate call). */
102
212
  readonly operation?: OperationType;
103
213
  }
214
+ /**
215
+ * Represents raw transaction data for an EVM transaction.
216
+ */
104
217
  export interface EvmTransactionData {
218
+ /** The chain ID of the network where the transaction is being executed. */
105
219
  chainId: number;
220
+ /** The raw data of the transaction. */
106
221
  data: string;
222
+ /** The hash of the transaction. */
107
223
  hash: string;
108
224
  }
225
+ /**
226
+ * Represents the decoded details of a multisend transaction.
227
+ */
228
+ export interface DecodedMultisend {
229
+ /** The chain ID of the network where the multisend transaction is being executed. */
230
+ chainId: number;
231
+ /** The estimated cost of the multisend transaction in Ether.
232
+ * This is an upper bound on the transaction fee (could wind up lower).
233
+ */
234
+ costEstimate: string;
235
+ /** The list of meta-transactions included in the multisend. */
236
+ transactions: MetaTransaction[];
237
+ }
238
+ /**
239
+ * Represents encoded transaction data for both NEAR and EVM networks.
240
+ */
109
241
  export interface EncodedTxData {
242
+ /** The encoded transaction data for the EVM network. */
110
243
  evmData: EvmTransactionData;
244
+ /** The encoded payload for a NEAR function call, including the signing arguments. */
111
245
  nearPayload: FunctionCallTransaction<{
112
246
  request: SignArgs;
113
247
  }>;
package/dist/cjs/types.js CHANGED
@@ -1,8 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OperationType = void 0;
4
+ /**
5
+ * Enum representing the type of operation in a meta-transaction.
6
+ */
4
7
  var OperationType;
5
8
  (function (OperationType) {
9
+ /** Standard call operation (0). */
6
10
  OperationType[OperationType["Call"] = 0] = "Call";
11
+ /** Delegate call operation (1). */
7
12
  OperationType[OperationType["DelegateCall"] = 1] = "DelegateCall";
8
13
  })(OperationType || (exports.OperationType = OperationType = {}));
@@ -14,7 +14,7 @@ export declare class SafeContractSuite {
14
14
  addressForSetup(setup: Hex, saltNonce?: string): Promise<Address>;
15
15
  getSetup(owners: string[]): Hex;
16
16
  addOwnerData(newOwner: Address): Hex;
17
- getOpHash(unsignedUserOp: UserOperation): Promise<Hash>;
17
+ getOpHash(chainId: number, unsignedUserOp: UserOperation): Promise<Hash>;
18
18
  private factoryDataForSetup;
19
19
  buildUserOp(nonce: bigint, txData: MetaTransaction, safeAddress: Address, feeData: GasPrice, setup: string, safeNotDeployed: boolean, safeSaltNonce: string): Promise<UnsignedUserOperation>;
20
20
  getNonce(address: Address, chainId: number): Promise<bigint>;
@@ -68,9 +68,10 @@ export class SafeContractSuite {
68
68
  args: [newOwner, 1],
69
69
  });
70
70
  }
71
- async getOpHash(unsignedUserOp) {
71
+ async getOpHash(chainId, unsignedUserOp) {
72
72
  const { factory, factoryData, verificationGasLimit, callGasLimit, maxPriorityFeePerGas, maxFeePerGas, } = unsignedUserOp;
73
- const opHash = await this.dummyClient.readContract({
73
+ const client = await getClient(chainId);
74
+ const opHash = await client.readContract({
74
75
  address: this.m4337.address,
75
76
  abi: this.m4337.abi,
76
77
  functionName: "getOperationHash",
@@ -3,7 +3,7 @@ import { FinalExecutionOutcome } from "near-api-js/lib/providers";
3
3
  import { NearEthAdapter, SignRequestData } from "near-ca";
4
4
  import { Address, Hash, Hex } from "viem";
5
5
  import { SafeContractSuite } from "./lib/safe";
6
- import { EncodedTxData, EvmTransactionData, MetaTransaction, UserOperation, UserOperationReceipt } from "./types";
6
+ import { DecodedMultisend, EncodedTxData, EvmTransactionData, MetaTransaction, UserOperation, UserOperationReceipt } from "./types";
7
7
  export interface NearSafeConfig {
8
8
  accountId: string;
9
9
  mpcContractId: string;
@@ -85,7 +85,7 @@ export declare class NearSafe {
85
85
  * @param {UserOperation} userOp - The user operation for which the hash needs to be computed.
86
86
  * @returns {Promise<Hash>} - A promise that resolves to the hash of the provided user operation.
87
87
  */
88
- opHash(userOp: UserOperation): Promise<Hash>;
88
+ opHash(chainId: number, userOp: UserOperation): Promise<Hash>;
89
89
  /**
90
90
  * Encodes a request to sign a transaction using either a paymaster or the user's own funds.
91
91
  *
@@ -162,11 +162,7 @@ export declare class NearSafe {
162
162
  * @param {EvmTransactionData} data - The raw transaction data to be decoded.
163
163
  * @returns {{ chainId: number; costEstimate: string; transactions: MetaTransaction[] }} - An object containing the chain ID, estimated cost, and a list of decoded meta-transactions.
164
164
  */
165
- decodeTxData(data: EvmTransactionData): {
166
- chainId: number;
167
- costEstimate: string;
168
- transactions: MetaTransaction[];
169
- };
165
+ decodeTxData(data: EvmTransactionData): DecodedMultisend;
170
166
  /**
171
167
  * Handles routing of signature requests based on the provided method, chain ID, and parameters.
172
168
  *
@@ -121,8 +121,8 @@ export class NearSafe {
121
121
  * @param {UserOperation} userOp - The user operation for which the hash needs to be computed.
122
122
  * @returns {Promise<Hash>} - A promise that resolves to the hash of the provided user operation.
123
123
  */
124
- async opHash(userOp) {
125
- return this.safePack.getOpHash(userOp);
124
+ async opHash(chainId, userOp) {
125
+ return this.safePack.getOpHash(chainId, userOp);
126
126
  }
127
127
  /**
128
128
  * Encodes a request to sign a transaction using either a paymaster or the user's own funds.
@@ -320,11 +320,11 @@ export class NearSafe {
320
320
  transactions,
321
321
  usePaymaster,
322
322
  });
323
- const opHash = await this.opHash(userOp);
323
+ const opHash = await this.opHash(chainId, userOp);
324
324
  return {
325
325
  payload: toPayload(opHash),
326
326
  evmMessage: JSON.stringify(userOp),
327
- hash: await this.opHash(userOp),
327
+ hash: await this.opHash(chainId, userOp),
328
328
  };
329
329
  }
330
330
  }
@@ -1,113 +1,247 @@
1
1
  import { FunctionCallTransaction, SignArgs } from "near-ca";
2
2
  import { Address, Hex, ParseAbi } from "viem";
3
+ /**
4
+ * Represents a collection of Safe contract deployments, each with its own address and ABI.
5
+ */
3
6
  export type SafeDeployments = {
7
+ /** Deployment for the singleton contract. */
4
8
  singleton: Deployment;
9
+ /** Deployment for the proxy factory contract. */
5
10
  proxyFactory: Deployment;
11
+ /** Deployment for the module setup contract. */
6
12
  moduleSetup: Deployment;
13
+ /** Deployment for the m4337 module contract. */
7
14
  m4337: Deployment;
15
+ /** Deployment for the entry point contract. */
8
16
  entryPoint: Deployment;
9
17
  };
18
+ /**
19
+ * Represents the details of a deployed contract, including its ABI and address.
20
+ */
10
21
  export interface Deployment {
22
+ /** The ABI of the deployed contract. Can be a raw ABI array or a parsed ABI. */
11
23
  abi: unknown[] | ParseAbi<readonly string[]>;
24
+ /** The address of the deployed contract. */
12
25
  address: Address;
13
26
  }
27
+ /**
28
+ * Represents an unsigned user operation that can be sent to the EntryPoint contract.
29
+ */
14
30
  export interface UnsignedUserOperation {
31
+ /** The sender's address initiating the user operation. */
15
32
  sender: Address;
33
+ /** The unique nonce associated with this user operation. */
16
34
  nonce: string;
35
+ /** The optional factory address to use for creating new contracts. */
17
36
  factory?: Address;
37
+ /** Optional additional data for the factory, typically used for contract initialization. */
18
38
  factoryData?: Hex;
39
+ /** The encoded data for the contract call or transaction execution. */
19
40
  callData: Hex;
41
+ /** Maximum priority fee per gas unit for the transaction. */
20
42
  maxPriorityFeePerGas: Hex;
43
+ /** Maximum fee per gas unit for the transaction. */
21
44
  maxFeePerGas: Hex;
22
45
  }
23
46
  /**
24
- * Supported Representation of UserOperation for EntryPoint v0.7
47
+ * Supported representation of a user operation for EntryPoint version 0.7, including gas limits and signature.
25
48
  */
26
49
  export interface UserOperation extends UnsignedUserOperation {
50
+ /** The gas limit for verification of the operation. */
27
51
  verificationGasLimit: Hex;
52
+ /** The gas limit for the execution of the operation call. */
28
53
  callGasLimit: Hex;
54
+ /** The gas used before verification begins. */
29
55
  preVerificationGas: Hex;
56
+ /** Optional signature for the user operation. */
30
57
  signature?: Hex;
31
58
  }
59
+ /**
60
+ * Represents additional paymaster-related data for a user operation.
61
+ */
32
62
  export interface PaymasterData {
63
+ /** Optional paymaster address responsible for covering gas costs. */
33
64
  paymaster?: Address;
65
+ /** Optional additional data required by the paymaster. */
34
66
  paymasterData?: Hex;
67
+ /** The gas limit for paymaster verification. */
35
68
  paymasterVerificationGasLimit?: Hex;
69
+ /** The gas limit for paymaster post-operation execution. */
36
70
  paymasterPostOpGasLimit?: Hex;
71
+ /** The gas limit for operation verification. */
37
72
  verificationGasLimit: Hex;
73
+ /** The gas limit for the operation call execution. */
38
74
  callGasLimit: Hex;
75
+ /** The gas used before verification begins. */
39
76
  preVerificationGas: Hex;
40
77
  }
78
+ /**
79
+ * User configuration options for transaction building and user operation execution.
80
+ */
41
81
  export interface UserOptions {
82
+ /** Whether to use a paymaster for gas fee coverage. */
42
83
  usePaymaster: boolean;
84
+ /** The unique nonce used to differentiate multiple Safe setups. */
43
85
  safeSaltNonce: string;
86
+ /** The NEAR contract ID for the MPC contract. */
44
87
  mpcContractId: string;
88
+ /** Optional recovery address in case of key compromise or other emergency situations. */
45
89
  recoveryAddress?: string;
46
90
  }
91
+ /**
92
+ * Represents the possible transaction statuses.
93
+ */
47
94
  export type TxStatus = "success" | "reverted";
95
+ /**
96
+ * Represents a log entry in a transaction receipt.
97
+ */
48
98
  interface Log {
99
+ /** The index of the log in the transaction. */
49
100
  logIndex: string;
101
+ /** The index of the transaction within the block. */
50
102
  transactionIndex: string;
103
+ /** The hash of the transaction containing the log. */
51
104
  transactionHash: string;
105
+ /** The hash of the block containing the transaction. */
52
106
  blockHash: string;
107
+ /** The number of the block containing the transaction. */
53
108
  blockNumber: string;
109
+ /** The address that generated the log. */
54
110
  address: string;
111
+ /** The raw data of the log. */
55
112
  data: string;
113
+ /** The topics associated with the log event. */
56
114
  topics: string[];
57
115
  }
116
+ /**
117
+ * Represents a transaction receipt returned by the blockchain.
118
+ */
58
119
  interface Receipt {
120
+ /** The hash of the transaction. */
59
121
  transactionHash: Hex;
122
+ /** The index of the transaction within the block. */
60
123
  transactionIndex: bigint;
124
+ /** The hash of the block containing the transaction. */
61
125
  blockHash: Hex;
126
+ /** The number of the block containing the transaction. */
62
127
  blockNumber: bigint;
128
+ /** The address from which the transaction originated. */
63
129
  from: Address;
130
+ /** Optional address to which the transaction was sent (if applicable). */
64
131
  to?: Address;
132
+ /** The cumulative gas used in the block up to this transaction. */
65
133
  cumulativeGasUsed: bigint;
134
+ /** The status of the transaction (success or reverted). */
66
135
  status: TxStatus;
136
+ /** The total gas used by this transaction. */
67
137
  gasUsed: bigint;
138
+ /** Optional address of a newly deployed contract (if applicable). */
68
139
  contractAddress?: Address;
140
+ /** The logs bloom filter for the transaction. */
69
141
  logsBloom: Hex;
142
+ /** The effective gas price used in the transaction. */
70
143
  effectiveGasPrice: bigint;
71
144
  }
145
+ /**
146
+ * Represents the receipt of a user operation including its details, logs, and result.
147
+ */
72
148
  export type UserOperationReceipt = {
149
+ /** The hash of the user operation. */
73
150
  userOpHash: Hex;
151
+ /** The address of the entry point contract handling the user operation. */
74
152
  entryPoint: Address;
153
+ /** The sender's address initiating the user operation. */
75
154
  sender: Address;
155
+ /** The nonce of the user operation. */
76
156
  nonce: bigint;
157
+ /** Optional paymaster address responsible for covering gas costs. */
77
158
  paymaster?: Address;
159
+ /** The actual gas used by the operation. */
78
160
  actualGasUsed: bigint;
161
+ /** The actual gas cost of the operation. */
79
162
  actualGasCost: bigint;
163
+ /** Whether the user operation succeeded or failed. */
80
164
  success: boolean;
165
+ /** Optional reason for failure if the operation was unsuccessful. */
81
166
  reason?: string;
167
+ /** The transaction receipt associated with the user operation. */
82
168
  receipt: Receipt;
169
+ /** The list of logs generated by the user operation. */
83
170
  logs: Log[];
84
171
  };
172
+ /**
173
+ * Represents the different gas prices for transaction execution based on priority levels.
174
+ */
85
175
  export interface GasPrices {
176
+ /** Gas price for slower transactions. */
86
177
  slow: GasPrice;
178
+ /** Gas price for standard transactions. */
87
179
  standard: GasPrice;
180
+ /** Gas price for fast transactions. */
88
181
  fast: GasPrice;
89
182
  }
183
+ /**
184
+ * Represents a specific gas price configuration for transaction execution.
185
+ */
90
186
  export interface GasPrice {
187
+ /** Maximum fee per gas unit for the transaction. */
91
188
  maxFeePerGas: Hex;
189
+ /** Maximum priority fee per gas unit for the transaction. */
92
190
  maxPriorityFeePerGas: Hex;
93
191
  }
192
+ /**
193
+ * Enum representing the type of operation in a meta-transaction.
194
+ */
94
195
  export declare enum OperationType {
196
+ /** Standard call operation (0). */
95
197
  Call = 0,
198
+ /** Delegate call operation (1). */
96
199
  DelegateCall = 1
97
200
  }
201
+ /**
202
+ * Represents a meta-transaction, which includes the destination address, value, data, and type of operation.
203
+ */
98
204
  export interface MetaTransaction {
205
+ /** The destination address for the meta-transaction. */
99
206
  readonly to: string;
207
+ /** The value to be sent with the transaction (as a string to handle large numbers). */
100
208
  readonly value: string;
209
+ /** The encoded data for the contract call or function execution. */
101
210
  readonly data: string;
211
+ /** Optional type of operation (call or delegate call). */
102
212
  readonly operation?: OperationType;
103
213
  }
214
+ /**
215
+ * Represents raw transaction data for an EVM transaction.
216
+ */
104
217
  export interface EvmTransactionData {
218
+ /** The chain ID of the network where the transaction is being executed. */
105
219
  chainId: number;
220
+ /** The raw data of the transaction. */
106
221
  data: string;
222
+ /** The hash of the transaction. */
107
223
  hash: string;
108
224
  }
225
+ /**
226
+ * Represents the decoded details of a multisend transaction.
227
+ */
228
+ export interface DecodedMultisend {
229
+ /** The chain ID of the network where the multisend transaction is being executed. */
230
+ chainId: number;
231
+ /** The estimated cost of the multisend transaction in Ether.
232
+ * This is an upper bound on the transaction fee (could wind up lower).
233
+ */
234
+ costEstimate: string;
235
+ /** The list of meta-transactions included in the multisend. */
236
+ transactions: MetaTransaction[];
237
+ }
238
+ /**
239
+ * Represents encoded transaction data for both NEAR and EVM networks.
240
+ */
109
241
  export interface EncodedTxData {
242
+ /** The encoded transaction data for the EVM network. */
110
243
  evmData: EvmTransactionData;
244
+ /** The encoded payload for a NEAR function call, including the signing arguments. */
111
245
  nearPayload: FunctionCallTransaction<{
112
246
  request: SignArgs;
113
247
  }>;
package/dist/esm/types.js CHANGED
@@ -1,5 +1,10 @@
1
+ /**
2
+ * Enum representing the type of operation in a meta-transaction.
3
+ */
1
4
  export var OperationType;
2
5
  (function (OperationType) {
6
+ /** Standard call operation (0). */
3
7
  OperationType[OperationType["Call"] = 0] = "Call";
8
+ /** Delegate call operation (1). */
4
9
  OperationType[OperationType["DelegateCall"] = 1] = "DelegateCall";
5
10
  })(OperationType || (OperationType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "near-safe",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "description": "An SDK for controlling Ethereum Smart Accounts via ERC4337 from a Near Account.",
6
6
  "author": "bh2smith",
@@ -44,7 +44,7 @@
44
44
  "@safe-global/safe-gateway-typescript-sdk": "^3.22.2",
45
45
  "ethers-multisend": "^3.1.0",
46
46
  "near-api-js": "^5.0.0",
47
- "near-ca": "^0.5.6",
47
+ "near-ca": "^0.5.7",
48
48
  "semver": "^7.6.3",
49
49
  "viem": "^2.16.5"
50
50
  },