near-safe 0.8.8 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/decode/explain.d.ts +38 -0
- package/dist/cjs/decode/explain.js +97 -0
- package/dist/cjs/decode/index.d.ts +2 -8
- package/dist/cjs/decode/index.js +16 -50
- package/dist/cjs/decode/sign-request.d.ts +8 -0
- package/dist/cjs/decode/sign-request.js +44 -0
- package/dist/cjs/decode/util.d.ts +0 -10
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/lib/bundler.d.ts +7 -2
- package/dist/cjs/lib/bundler.js +8 -12
- package/dist/cjs/lib/safe-message.d.ts +1 -3
- package/dist/cjs/lib/safe-message.js +0 -30
- package/dist/cjs/near-safe.js +2 -2
- package/dist/cjs/types/guards.d.ts +6 -0
- package/dist/cjs/types/guards.js +90 -0
- package/dist/cjs/{types.d.ts → types/index.d.ts} +5 -9
- package/dist/cjs/types/index.js +28 -0
- package/dist/cjs/util.d.ts +2 -1
- package/dist/cjs/util.js +23 -2
- package/dist/esm/decode/explain.d.ts +38 -0
- package/dist/esm/decode/explain.js +91 -0
- package/dist/esm/decode/index.d.ts +2 -8
- package/dist/esm/decode/index.js +2 -49
- package/dist/esm/decode/sign-request.d.ts +8 -0
- package/dist/esm/decode/sign-request.js +41 -0
- package/dist/esm/decode/util.d.ts +0 -10
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/bundler.d.ts +7 -2
- package/dist/esm/lib/bundler.js +9 -13
- package/dist/esm/lib/safe-message.d.ts +1 -3
- package/dist/esm/lib/safe-message.js +1 -29
- package/dist/esm/near-safe.js +2 -2
- package/dist/esm/types/guards.d.ts +6 -0
- package/dist/esm/types/guards.js +83 -0
- package/dist/esm/{types.d.ts → types/index.d.ts} +5 -9
- package/dist/esm/{types.js → types/index.js} +1 -0
- package/dist/esm/util.d.ts +2 -1
- package/dist/esm/util.js +22 -2
- package/package.json +2 -2
- package/dist/cjs/types.js +0 -13
package/dist/esm/util.js
CHANGED
@@ -17,13 +17,13 @@ export function packPaymasterData(data) {
|
|
17
17
|
: "0x");
|
18
18
|
}
|
19
19
|
export function containsValue(transactions) {
|
20
|
-
return transactions.some((tx) => tx.value !==
|
20
|
+
return transactions.some((tx) => BigInt(tx.value) !== 0n);
|
21
21
|
}
|
22
22
|
export async function isContract(address, chainId) {
|
23
23
|
return (await getClient(chainId).getCode({ address })) !== undefined;
|
24
24
|
}
|
25
25
|
export function getClient(chainId) {
|
26
|
-
// TODO(bh2smith)
|
26
|
+
// TODO(bh2smith): Update defailt client URL in viem for sepolia.
|
27
27
|
if (chainId === 11155111) {
|
28
28
|
return createPublicClient({ transport: http(DEFAULT_SETUP_RPC) });
|
29
29
|
}
|
@@ -130,3 +130,23 @@ export function assertUnique(iterable, errorMessage = "The collection contains m
|
|
130
130
|
throw new Error(errorMessage);
|
131
131
|
}
|
132
132
|
}
|
133
|
+
export function userOpTransactionCost(userOp) {
|
134
|
+
// Convert values from hex to decimal
|
135
|
+
const preVerificationGas = BigInt(userOp.preVerificationGas);
|
136
|
+
const verificationGasLimit = BigInt(userOp.verificationGasLimit);
|
137
|
+
const callGasLimit = BigInt(userOp.callGasLimit);
|
138
|
+
const paymasterVerificationGasLimit = BigInt(userOp.paymasterVerificationGasLimit || "0x0");
|
139
|
+
const paymasterPostOpGasLimit = BigInt(userOp.paymasterPostOpGasLimit || "0x0");
|
140
|
+
// Sum total gas
|
141
|
+
const totalGasUsed = preVerificationGas +
|
142
|
+
verificationGasLimit +
|
143
|
+
callGasLimit +
|
144
|
+
paymasterVerificationGasLimit +
|
145
|
+
paymasterPostOpGasLimit;
|
146
|
+
// Convert maxFeePerGas from hex to decimal
|
147
|
+
const maxFeePerGas = BigInt(userOp.maxFeePerGas);
|
148
|
+
// Calculate total cost in wei
|
149
|
+
const totalCostInWei = totalGasUsed * maxFeePerGas;
|
150
|
+
// Convert to Ether for a human-readable value
|
151
|
+
return totalCostInWei;
|
152
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "near-safe",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.9.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",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"dependencies": {
|
44
44
|
"@safe-global/safe-gateway-typescript-sdk": "^3.22.2",
|
45
45
|
"near-api-js": "^5.0.1",
|
46
|
-
"near-ca": "^0.7.
|
46
|
+
"near-ca": "^0.7.2",
|
47
47
|
"semver": "^7.6.3",
|
48
48
|
"viem": "^2.21.41"
|
49
49
|
},
|
package/dist/cjs/types.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.OperationType = void 0;
|
4
|
-
/**
|
5
|
-
* Enum representing the type of operation in a meta-transaction.
|
6
|
-
*/
|
7
|
-
var OperationType;
|
8
|
-
(function (OperationType) {
|
9
|
-
/** Standard call operation (0). */
|
10
|
-
OperationType[OperationType["Call"] = 0] = "Call";
|
11
|
-
/** Delegate call operation (1). */
|
12
|
-
OperationType[OperationType["DelegateCall"] = 1] = "DelegateCall";
|
13
|
-
})(OperationType || (exports.OperationType = OperationType = {}));
|