near-safe 0.8.7 → 0.9.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/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 +17 -17
- 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",
|
@@ -42,30 +42,30 @@
|
|
42
42
|
},
|
43
43
|
"dependencies": {
|
44
44
|
"@safe-global/safe-gateway-typescript-sdk": "^3.22.2",
|
45
|
-
"near-api-js": "^5.0.
|
46
|
-
"near-ca": "^0.
|
45
|
+
"near-api-js": "^5.0.1",
|
46
|
+
"near-ca": "^0.7.2",
|
47
47
|
"semver": "^7.6.3",
|
48
48
|
"viem": "^2.21.41"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
51
|
-
"@safe-global/safe-deployments": "^1.37.
|
52
|
-
"@safe-global/safe-modules-deployments": "^2.2.
|
53
|
-
"@types/jest": "^29.5.
|
54
|
-
"@types/node": "^22.
|
51
|
+
"@safe-global/safe-deployments": "^1.37.14",
|
52
|
+
"@safe-global/safe-modules-deployments": "^2.2.4",
|
53
|
+
"@types/jest": "^29.5.14",
|
54
|
+
"@types/node": "^22.9.0",
|
55
55
|
"@types/semver": "^7.5.8",
|
56
|
-
"@types/yargs": "^17.0.
|
57
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
58
|
-
"@typescript-eslint/parser": "^8.
|
56
|
+
"@types/yargs": "^17.0.33",
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
58
|
+
"@typescript-eslint/parser": "^8.13.0",
|
59
59
|
"dotenv": "^16.4.5",
|
60
|
-
"eslint": "^9.
|
61
|
-
"eslint-plugin-import": "^2.
|
62
|
-
"ethers": "^6.13.
|
60
|
+
"eslint": "^9.14.0",
|
61
|
+
"eslint-plugin-import": "^2.31.0",
|
62
|
+
"ethers": "^6.13.4",
|
63
63
|
"ethers-multisend": "^3.1.0",
|
64
64
|
"jest": "^29.7.0",
|
65
|
-
"prettier": "^3.3.
|
66
|
-
"ts-jest": "^29.
|
67
|
-
"tsx": "^4.
|
68
|
-
"typescript": "^5.
|
65
|
+
"prettier": "^3.3.3",
|
66
|
+
"ts-jest": "^29.2.5",
|
67
|
+
"tsx": "^4.19.2",
|
68
|
+
"typescript": "^5.6.3",
|
69
69
|
"yargs": "^17.7.2"
|
70
70
|
},
|
71
71
|
"resolutions": {
|
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 = {}));
|