near-safe 0.11.1 → 0.12.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/lib/safe.js +4 -3
- package/dist/cjs/near-safe.js +3 -1
- package/dist/cjs/util.d.ts +1 -2
- package/dist/cjs/util.js +2 -7
- package/dist/esm/lib/safe.js +5 -4
- package/dist/esm/near-safe.js +5 -3
- package/dist/esm/util.d.ts +1 -2
- package/dist/esm/util.js +2 -6
- package/package.json +12 -13
package/dist/cjs/lib/safe.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.SafeContractSuite = void 0;
|
4
|
+
const near_ca_1 = require("near-ca");
|
4
5
|
const viem_1 = require("viem");
|
5
6
|
const deployments_1 = require("../_gen/deployments");
|
6
7
|
const constants_1 = require("../constants");
|
@@ -76,7 +77,7 @@ class SafeContractSuite {
|
|
76
77
|
}
|
77
78
|
async getOpHash(chainId, unsignedUserOp) {
|
78
79
|
const { factory, factoryData, verificationGasLimit, callGasLimit, maxPriorityFeePerGas, maxFeePerGas, } = unsignedUserOp;
|
79
|
-
const client = await
|
80
|
+
const client = await near_ca_1.Network.fromChainId(chainId).client;
|
80
81
|
const opHash = await client.readContract({
|
81
82
|
address: this.m4337.address,
|
82
83
|
abi: this.m4337.abi,
|
@@ -132,7 +133,7 @@ class SafeContractSuite {
|
|
132
133
|
};
|
133
134
|
}
|
134
135
|
async getNonce(address, chainId) {
|
135
|
-
const nonce = (await
|
136
|
+
const nonce = (await near_ca_1.Network.fromChainId(chainId).client.readContract({
|
136
137
|
abi: this.entryPoint.abi,
|
137
138
|
address: this.entryPoint.address,
|
138
139
|
functionName: "getNonce",
|
@@ -141,7 +142,7 @@ class SafeContractSuite {
|
|
141
142
|
return nonce;
|
142
143
|
}
|
143
144
|
async prevOwner(chainId, safeAddress, owner) {
|
144
|
-
const client =
|
145
|
+
const client = near_ca_1.Network.fromChainId(chainId).client;
|
145
146
|
const currentOwners = await client.readContract({
|
146
147
|
address: safeAddress,
|
147
148
|
// abi: this.singleton.abi,
|
package/dist/cjs/near-safe.js
CHANGED
@@ -67,7 +67,9 @@ class NearSafe {
|
|
67
67
|
* @returns {Promise<bigint>} - A promise that resolves to the balance of the Safe account in wei.
|
68
68
|
*/
|
69
69
|
async getBalance(chainId) {
|
70
|
-
return await
|
70
|
+
return await near_ca_1.Network.fromChainId(chainId).client.getBalance({
|
71
|
+
address: this.address,
|
72
|
+
});
|
71
73
|
}
|
72
74
|
/**
|
73
75
|
* Constructs a user operation for the specified chain, including necessary gas fees, nonce, and paymaster data.
|
package/dist/cjs/util.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { SessionRequestParams } from "near-ca";
|
2
|
-
import { Address, Hex
|
2
|
+
import { Address, Hex } from "viem";
|
3
3
|
import { PaymasterData, MetaTransaction, UserOperation } from "./types";
|
4
4
|
export declare const PLACEHOLDER_SIG: `0x${string}`;
|
5
5
|
type IntLike = Hex | bigint | string | number;
|
@@ -8,7 +8,6 @@ export declare function packSignature(signature: `0x${string}`, validFrom?: numb
|
|
8
8
|
export declare function packPaymasterData(data: PaymasterData): Hex;
|
9
9
|
export declare function containsValue(transactions: MetaTransaction[]): boolean;
|
10
10
|
export declare function isContract(address: Address, chainId: number): Promise<boolean>;
|
11
|
-
export declare function getClient(chainId: number, rpcUrl?: string): PublicClient;
|
12
11
|
export declare function metaTransactionsFromRequest(params: SessionRequestParams): MetaTransaction[];
|
13
12
|
export declare function saltNonceFromMessage(input: string): string;
|
14
13
|
/**
|
package/dist/cjs/util.js
CHANGED
@@ -5,7 +5,6 @@ exports.packSignature = packSignature;
|
|
5
5
|
exports.packPaymasterData = packPaymasterData;
|
6
6
|
exports.containsValue = containsValue;
|
7
7
|
exports.isContract = isContract;
|
8
|
-
exports.getClient = getClient;
|
9
8
|
exports.metaTransactionsFromRequest = metaTransactionsFromRequest;
|
10
9
|
exports.saltNonceFromMessage = saltNonceFromMessage;
|
11
10
|
exports.signatureFromTxHash = signatureFromTxHash;
|
@@ -34,12 +33,8 @@ function containsValue(transactions) {
|
|
34
33
|
return transactions.some((tx) => BigInt(tx.value) !== 0n);
|
35
34
|
}
|
36
35
|
async function isContract(address, chainId) {
|
37
|
-
return (await
|
38
|
-
|
39
|
-
function getClient(chainId, rpcUrl) {
|
40
|
-
// Caution: rpcUrl might not be aligned with chainId!
|
41
|
-
const options = rpcUrl ? { rpcUrl } : {};
|
42
|
-
return near_ca_1.Network.fromChainId(chainId, options).client;
|
36
|
+
return ((await near_ca_1.Network.fromChainId(chainId).client.getCode({ address })) !==
|
37
|
+
undefined);
|
43
38
|
}
|
44
39
|
function metaTransactionsFromRequest(params) {
|
45
40
|
let transactions;
|
package/dist/esm/lib/safe.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
import { Network } from "near-ca";
|
1
2
|
import { concat, createPublicClient, encodeFunctionData, encodePacked, getAddress, getCreate2Address, http, keccak256, parseAbi, toHex, zeroAddress, } from "viem";
|
2
3
|
import { SAFE_DEPLOYMENTS } from "../_gen/deployments";
|
3
4
|
import { DEFAULT_SETUP_RPC, SENTINEL_OWNERS, USER_OP_IDENTIFIER, } from "../constants";
|
4
|
-
import { PLACEHOLDER_SIG,
|
5
|
+
import { PLACEHOLDER_SIG, packGas, packPaymasterData } from "../util";
|
5
6
|
/**
|
6
7
|
* All contracts used in account creation & execution
|
7
8
|
*/
|
@@ -80,7 +81,7 @@ export class SafeContractSuite {
|
|
80
81
|
}
|
81
82
|
async getOpHash(chainId, unsignedUserOp) {
|
82
83
|
const { factory, factoryData, verificationGasLimit, callGasLimit, maxPriorityFeePerGas, maxFeePerGas, } = unsignedUserOp;
|
83
|
-
const client = await
|
84
|
+
const client = await Network.fromChainId(chainId).client;
|
84
85
|
const opHash = await client.readContract({
|
85
86
|
address: this.m4337.address,
|
86
87
|
abi: this.m4337.abi,
|
@@ -136,7 +137,7 @@ export class SafeContractSuite {
|
|
136
137
|
};
|
137
138
|
}
|
138
139
|
async getNonce(address, chainId) {
|
139
|
-
const nonce = (await
|
140
|
+
const nonce = (await Network.fromChainId(chainId).client.readContract({
|
140
141
|
abi: this.entryPoint.abi,
|
141
142
|
address: this.entryPoint.address,
|
142
143
|
functionName: "getNonce",
|
@@ -145,7 +146,7 @@ export class SafeContractSuite {
|
|
145
146
|
return nonce;
|
146
147
|
}
|
147
148
|
async prevOwner(chainId, safeAddress, owner) {
|
148
|
-
const client =
|
149
|
+
const client = Network.fromChainId(chainId).client;
|
149
150
|
const currentOwners = await client.readContract({
|
150
151
|
address: safeAddress,
|
151
152
|
// abi: this.singleton.abi,
|
package/dist/esm/near-safe.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import { setupAdapter, toPayload, requestRouter as mpcRequestRouter, } from "near-ca";
|
1
|
+
import { setupAdapter, toPayload, requestRouter as mpcRequestRouter, Network, } from "near-ca";
|
2
2
|
import { zeroAddress } from "viem";
|
3
3
|
import { DEFAULT_SAFE_SALT_NONCE } from "./constants";
|
4
4
|
import { Erc4337Bundler } from "./lib/bundler";
|
5
5
|
import { encodeMulti } from "./lib/multisend";
|
6
6
|
import { SafeContractSuite } from "./lib/safe";
|
7
7
|
import { decodeSafeMessage } from "./lib/safe-message";
|
8
|
-
import { assertUnique,
|
8
|
+
import { assertUnique, isContract, metaTransactionsFromRequest, packSignature, } from "./util";
|
9
9
|
export class NearSafe {
|
10
10
|
nearAdapter;
|
11
11
|
address;
|
@@ -70,7 +70,9 @@ export class NearSafe {
|
|
70
70
|
* @returns {Promise<bigint>} - A promise that resolves to the balance of the Safe account in wei.
|
71
71
|
*/
|
72
72
|
async getBalance(chainId) {
|
73
|
-
return await
|
73
|
+
return await Network.fromChainId(chainId).client.getBalance({
|
74
|
+
address: this.address,
|
75
|
+
});
|
74
76
|
}
|
75
77
|
/**
|
76
78
|
* Constructs a user operation for the specified chain, including necessary gas fees, nonce, and paymaster data.
|
package/dist/esm/util.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { SessionRequestParams } from "near-ca";
|
2
|
-
import { Address, Hex
|
2
|
+
import { Address, Hex } from "viem";
|
3
3
|
import { PaymasterData, MetaTransaction, UserOperation } from "./types";
|
4
4
|
export declare const PLACEHOLDER_SIG: `0x${string}`;
|
5
5
|
type IntLike = Hex | bigint | string | number;
|
@@ -8,7 +8,6 @@ export declare function packSignature(signature: `0x${string}`, validFrom?: numb
|
|
8
8
|
export declare function packPaymasterData(data: PaymasterData): Hex;
|
9
9
|
export declare function containsValue(transactions: MetaTransaction[]): boolean;
|
10
10
|
export declare function isContract(address: Address, chainId: number): Promise<boolean>;
|
11
|
-
export declare function getClient(chainId: number, rpcUrl?: string): PublicClient;
|
12
11
|
export declare function metaTransactionsFromRequest(params: SessionRequestParams): MetaTransaction[];
|
13
12
|
export declare function saltNonceFromMessage(input: string): string;
|
14
13
|
/**
|
package/dist/esm/util.js
CHANGED
@@ -19,12 +19,8 @@ export function containsValue(transactions) {
|
|
19
19
|
return transactions.some((tx) => BigInt(tx.value) !== 0n);
|
20
20
|
}
|
21
21
|
export async function isContract(address, chainId) {
|
22
|
-
return (await
|
23
|
-
|
24
|
-
export function getClient(chainId, rpcUrl) {
|
25
|
-
// Caution: rpcUrl might not be aligned with chainId!
|
26
|
-
const options = rpcUrl ? { rpcUrl } : {};
|
27
|
-
return Network.fromChainId(chainId, options).client;
|
22
|
+
return ((await Network.fromChainId(chainId).client.getCode({ address })) !==
|
23
|
+
undefined);
|
28
24
|
}
|
29
25
|
export function metaTransactionsFromRequest(params) {
|
30
26
|
let transactions;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "near-safe",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.12.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",
|
@@ -37,29 +37,28 @@
|
|
37
37
|
"example": "tsx examples/send-tx.ts",
|
38
38
|
"lint": "prettier --check '{src,examples,tests}/**/*.{js,jsx,ts,tsx}' && eslint . --ignore-pattern dist/",
|
39
39
|
"fmt": "prettier --write '{src,examples,tests}/**/*.{js,jsx,ts,tsx}' && bun lint --fix",
|
40
|
-
"test": "jest",
|
41
40
|
"all": "bun fmt && bun lint && bun build"
|
42
41
|
},
|
43
42
|
"dependencies": {
|
44
43
|
"@safe-global/safe-gateway-typescript-sdk": "^3.23.1",
|
45
44
|
"glob": "^11.0.3",
|
46
|
-
"near-api-js": "^6.
|
47
|
-
"near-ca": "
|
45
|
+
"near-api-js": "^6.3.0",
|
46
|
+
"near-ca": "0.12.0",
|
48
47
|
"semver": "^7.7.2",
|
49
|
-
"viem": "^2.
|
48
|
+
"viem": "^2.37.8"
|
50
49
|
},
|
51
50
|
"devDependencies": {
|
52
51
|
"@duneanalytics/client-sdk": "^0.2.5",
|
53
|
-
"@safe-global/safe-deployments": "^1.37.
|
54
|
-
"@safe-global/safe-modules-deployments": "^2.2.
|
52
|
+
"@safe-global/safe-deployments": "^1.37.45",
|
53
|
+
"@safe-global/safe-modules-deployments": "^2.2.16",
|
55
54
|
"@types/jest": "^30.0.0",
|
56
|
-
"@types/node": "^24.
|
57
|
-
"@types/semver": "^7.7.
|
55
|
+
"@types/node": "^24.5.2",
|
56
|
+
"@types/semver": "^7.7.1",
|
58
57
|
"@types/yargs": "^17.0.33",
|
59
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
60
|
-
"@typescript-eslint/parser": "^8.
|
61
|
-
"dotenv": "^17.2.
|
62
|
-
"eslint": "^9.
|
58
|
+
"@typescript-eslint/eslint-plugin": "^8.44.1",
|
59
|
+
"@typescript-eslint/parser": "^8.44.1",
|
60
|
+
"dotenv": "^17.2.2",
|
61
|
+
"eslint": "^9.36.0",
|
63
62
|
"eslint-plugin-import": "^2.32.0",
|
64
63
|
"prettier": "^3.6.2",
|
65
64
|
"tsx": "^4.20.5",
|