near-safe 0.7.3 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/near-safe.d.ts +1 -1
- package/dist/cjs/near-safe.js +43 -27
- package/dist/cjs/types.d.ts +2 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/near-safe.d.ts +1 -1
- package/dist/esm/near-safe.js +43 -27
- package/dist/esm/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
@@ -2,4 +2,4 @@ export * from "./near-safe";
|
|
2
2
|
export * from "./types";
|
3
3
|
export * from "./util";
|
4
4
|
export * from "./constants";
|
5
|
-
export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, } from "near-ca";
|
5
|
+
export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, } from "near-ca";
|
package/dist/cjs/index.js
CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
exports.populateTx = exports.Network = void 0;
|
17
|
+
exports.signatureFromTxHash = exports.signatureFromOutcome = exports.populateTx = exports.Network = void 0;
|
18
18
|
__exportStar(require("./near-safe"), exports);
|
19
19
|
__exportStar(require("./types"), exports);
|
20
20
|
__exportStar(require("./util"), exports);
|
@@ -22,3 +22,5 @@ __exportStar(require("./constants"), exports);
|
|
22
22
|
var near_ca_1 = require("near-ca");
|
23
23
|
Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return near_ca_1.Network; } });
|
24
24
|
Object.defineProperty(exports, "populateTx", { enumerable: true, get: function () { return near_ca_1.populateTx; } });
|
25
|
+
Object.defineProperty(exports, "signatureFromOutcome", { enumerable: true, get: function () { return near_ca_1.signatureFromOutcome; } });
|
26
|
+
Object.defineProperty(exports, "signatureFromTxHash", { enumerable: true, get: function () { return near_ca_1.signatureFromTxHash; } });
|
package/dist/cjs/near-safe.d.ts
CHANGED
@@ -160,7 +160,7 @@ export declare class NearSafe {
|
|
160
160
|
* Decodes transaction data for a given EVM transaction and extracts relevant details.
|
161
161
|
*
|
162
162
|
* @param {EvmTransactionData} data - The raw transaction data to be decoded.
|
163
|
-
* @returns {
|
163
|
+
* @returns {DecodedMultisend} - An object containing the chain ID, estimated cost, and a list of decoded meta-transactions.
|
164
164
|
*/
|
165
165
|
decodeTxData(data: EvmTransactionData): DecodedMultisend;
|
166
166
|
/**
|
package/dist/cjs/near-safe.js
CHANGED
@@ -244,34 +244,49 @@ class NearSafe {
|
|
244
244
|
* Decodes transaction data for a given EVM transaction and extracts relevant details.
|
245
245
|
*
|
246
246
|
* @param {EvmTransactionData} data - The raw transaction data to be decoded.
|
247
|
-
* @returns {
|
247
|
+
* @returns {DecodedMultisend} - An object containing the chain ID, estimated cost, and a list of decoded meta-transactions.
|
248
248
|
*/
|
249
249
|
decodeTxData(data) {
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
250
|
+
try {
|
251
|
+
const userOp = JSON.parse(data.data);
|
252
|
+
const { callGasLimit, maxFeePerGas, maxPriorityFeePerGas } = userOp;
|
253
|
+
const maxGasPrice = BigInt(maxFeePerGas) + BigInt(maxPriorityFeePerGas);
|
254
|
+
const { args } = (0, viem_1.decodeFunctionData)({
|
255
|
+
abi: this.safePack.m4337.abi,
|
256
|
+
data: userOp.callData,
|
257
|
+
});
|
258
|
+
// Determine if singular or double!
|
259
|
+
const transactions = (0, multisend_1.isMultisendTx)(args)
|
260
|
+
? (0, ethers_multisend_1.decodeMulti)(args[2])
|
261
|
+
: [
|
262
|
+
{
|
263
|
+
to: args[0],
|
264
|
+
value: args[1],
|
265
|
+
data: args[2],
|
266
|
+
operation: args[3],
|
267
|
+
},
|
268
|
+
];
|
269
|
+
return {
|
270
|
+
chainId: data.chainId,
|
271
|
+
// This is an upper bound on the gas fees (could be lower)
|
272
|
+
costEstimate: (0, viem_1.formatEther)(BigInt(callGasLimit) * maxGasPrice),
|
273
|
+
transactions,
|
274
|
+
};
|
275
|
+
}
|
276
|
+
catch (error) {
|
277
|
+
if (error instanceof SyntaxError) {
|
278
|
+
return {
|
279
|
+
chainId: data.chainId,
|
280
|
+
costEstimate: "0",
|
281
|
+
transactions: [],
|
282
|
+
message: data.data,
|
283
|
+
};
|
284
|
+
}
|
285
|
+
else {
|
286
|
+
const message = error instanceof Error ? error.message : String(error);
|
287
|
+
throw new Error(`decodeTxData: Unexpected error - ${message}`);
|
288
|
+
}
|
289
|
+
}
|
275
290
|
}
|
276
291
|
/**
|
277
292
|
* Handles routing of signature requests based on the provided method, chain ID, and parameters.
|
@@ -308,7 +323,8 @@ class NearSafe {
|
|
308
323
|
const [messageHash, _] = params;
|
309
324
|
const message = (0, safe_message_1.decodeSafeMessage)(messageHash, safeInfo);
|
310
325
|
return {
|
311
|
-
|
326
|
+
// TODO(bh2smith) this is a bit of a hack.
|
327
|
+
evmMessage: message.decodedMessage,
|
312
328
|
payload: (0, near_ca_1.toPayload)(message.safeMessageHash),
|
313
329
|
hash: message.safeMessageHash,
|
314
330
|
};
|
package/dist/cjs/types.d.ts
CHANGED
@@ -234,6 +234,8 @@ export interface DecodedMultisend {
|
|
234
234
|
costEstimate: string;
|
235
235
|
/** The list of meta-transactions included in the multisend. */
|
236
236
|
transactions: MetaTransaction[];
|
237
|
+
/** Raw Message to sign if no transactions present. */
|
238
|
+
message?: string;
|
237
239
|
}
|
238
240
|
/**
|
239
241
|
* Represents encoded transaction data for both NEAR and EVM networks.
|
package/dist/esm/index.d.ts
CHANGED
@@ -2,4 +2,4 @@ export * from "./near-safe";
|
|
2
2
|
export * from "./types";
|
3
3
|
export * from "./util";
|
4
4
|
export * from "./constants";
|
5
|
-
export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, } from "near-ca";
|
5
|
+
export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, } from "near-ca";
|
package/dist/esm/index.js
CHANGED
package/dist/esm/near-safe.d.ts
CHANGED
@@ -160,7 +160,7 @@ export declare class NearSafe {
|
|
160
160
|
* Decodes transaction data for a given EVM transaction and extracts relevant details.
|
161
161
|
*
|
162
162
|
* @param {EvmTransactionData} data - The raw transaction data to be decoded.
|
163
|
-
* @returns {
|
163
|
+
* @returns {DecodedMultisend} - An object containing the chain ID, estimated cost, and a list of decoded meta-transactions.
|
164
164
|
*/
|
165
165
|
decodeTxData(data: EvmTransactionData): DecodedMultisend;
|
166
166
|
/**
|
package/dist/esm/near-safe.js
CHANGED
@@ -247,34 +247,49 @@ export class NearSafe {
|
|
247
247
|
* Decodes transaction data for a given EVM transaction and extracts relevant details.
|
248
248
|
*
|
249
249
|
* @param {EvmTransactionData} data - The raw transaction data to be decoded.
|
250
|
-
* @returns {
|
250
|
+
* @returns {DecodedMultisend} - An object containing the chain ID, estimated cost, and a list of decoded meta-transactions.
|
251
251
|
*/
|
252
252
|
decodeTxData(data) {
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
253
|
+
try {
|
254
|
+
const userOp = JSON.parse(data.data);
|
255
|
+
const { callGasLimit, maxFeePerGas, maxPriorityFeePerGas } = userOp;
|
256
|
+
const maxGasPrice = BigInt(maxFeePerGas) + BigInt(maxPriorityFeePerGas);
|
257
|
+
const { args } = decodeFunctionData({
|
258
|
+
abi: this.safePack.m4337.abi,
|
259
|
+
data: userOp.callData,
|
260
|
+
});
|
261
|
+
// Determine if singular or double!
|
262
|
+
const transactions = isMultisendTx(args)
|
263
|
+
? decodeMulti(args[2])
|
264
|
+
: [
|
265
|
+
{
|
266
|
+
to: args[0],
|
267
|
+
value: args[1],
|
268
|
+
data: args[2],
|
269
|
+
operation: args[3],
|
270
|
+
},
|
271
|
+
];
|
272
|
+
return {
|
273
|
+
chainId: data.chainId,
|
274
|
+
// This is an upper bound on the gas fees (could be lower)
|
275
|
+
costEstimate: formatEther(BigInt(callGasLimit) * maxGasPrice),
|
276
|
+
transactions,
|
277
|
+
};
|
278
|
+
}
|
279
|
+
catch (error) {
|
280
|
+
if (error instanceof SyntaxError) {
|
281
|
+
return {
|
282
|
+
chainId: data.chainId,
|
283
|
+
costEstimate: "0",
|
284
|
+
transactions: [],
|
285
|
+
message: data.data,
|
286
|
+
};
|
287
|
+
}
|
288
|
+
else {
|
289
|
+
const message = error instanceof Error ? error.message : String(error);
|
290
|
+
throw new Error(`decodeTxData: Unexpected error - ${message}`);
|
291
|
+
}
|
292
|
+
}
|
278
293
|
}
|
279
294
|
/**
|
280
295
|
* Handles routing of signature requests based on the provided method, chain ID, and parameters.
|
@@ -311,7 +326,8 @@ export class NearSafe {
|
|
311
326
|
const [messageHash, _] = params;
|
312
327
|
const message = decodeSafeMessage(messageHash, safeInfo);
|
313
328
|
return {
|
314
|
-
|
329
|
+
// TODO(bh2smith) this is a bit of a hack.
|
330
|
+
evmMessage: message.decodedMessage,
|
315
331
|
payload: toPayload(message.safeMessageHash),
|
316
332
|
hash: message.safeMessageHash,
|
317
333
|
};
|
package/dist/esm/types.d.ts
CHANGED
@@ -234,6 +234,8 @@ export interface DecodedMultisend {
|
|
234
234
|
costEstimate: string;
|
235
235
|
/** The list of meta-transactions included in the multisend. */
|
236
236
|
transactions: MetaTransaction[];
|
237
|
+
/** Raw Message to sign if no transactions present. */
|
238
|
+
message?: string;
|
237
239
|
}
|
238
240
|
/**
|
239
241
|
* Represents encoded transaction data for both NEAR and EVM networks.
|