near-safe 0.8.5-beta.0 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/decode/util.js +1 -2
- package/dist/cjs/lib/multisend.d.ts +1 -1
- package/dist/cjs/lib/multisend.js +3 -13
- package/dist/cjs/near-safe.d.ts +3 -7
- package/dist/cjs/near-safe.js +8 -12
- package/dist/esm/decode/util.js +1 -2
- package/dist/esm/lib/multisend.d.ts +1 -1
- package/dist/esm/lib/multisend.js +2 -12
- package/dist/esm/near-safe.d.ts +3 -7
- package/dist/esm/near-safe.js +10 -14
- package/package.json +2 -2
package/dist/cjs/decode/util.js
CHANGED
@@ -4,7 +4,6 @@ exports.decodeTransactionSerializable = decodeTransactionSerializable;
|
|
4
4
|
exports.decodeRlpHex = decodeRlpHex;
|
5
5
|
exports.decodeTypedData = decodeTypedData;
|
6
6
|
exports.decodeUserOperation = decodeUserOperation;
|
7
|
-
const decodeMulti_1 = require("ethers-multisend/build/cjs/decodeMulti");
|
8
7
|
const viem_1 = require("viem");
|
9
8
|
const deployments_1 = require("../_gen/deployments");
|
10
9
|
const multisend_1 = require("../lib/multisend");
|
@@ -52,7 +51,7 @@ function decodeUserOperation(chainId, userOp) {
|
|
52
51
|
});
|
53
52
|
// Determine if singular or double!
|
54
53
|
const transactions = (0, multisend_1.isMultisendTx)(args)
|
55
|
-
? (0,
|
54
|
+
? (0, multisend_1.decodeMulti)(args[2])
|
56
55
|
: [
|
57
56
|
{
|
58
57
|
to: args[0],
|
@@ -3,4 +3,4 @@ import { MetaTransaction } from "../types";
|
|
3
3
|
export declare const MULTI_SEND_ABI: string[];
|
4
4
|
export declare function encodeMulti(transactions: readonly MetaTransaction[], multiSendContractAddress?: string): MetaTransaction;
|
5
5
|
export declare function isMultisendTx(args: readonly unknown[]): boolean;
|
6
|
-
export declare function
|
6
|
+
export declare function decodeMulti(data: Hex): MetaTransaction[];
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MULTI_SEND_ABI = void 0;
|
4
4
|
exports.encodeMulti = encodeMulti;
|
5
5
|
exports.isMultisendTx = isMultisendTx;
|
6
|
-
exports.
|
6
|
+
exports.decodeMulti = decodeMulti;
|
7
7
|
const viem_1 = require("viem");
|
8
8
|
const types_1 = require("../types");
|
9
9
|
exports.MULTI_SEND_ABI = ["function multiSend(bytes memory transactions)"];
|
@@ -45,9 +45,6 @@ function isMultisendTx(args) {
|
|
45
45
|
return (to === MULTISEND_141.toLowerCase() ||
|
46
46
|
to === MULTISEND_CALLONLY_141.toLowerCase());
|
47
47
|
}
|
48
|
-
// import { Interface } from '@ethersproject/abi';
|
49
|
-
// import { getAddress } from '@ethersproject/address';
|
50
|
-
// import { BigNumber } from '@ethersproject/bignumber';
|
51
48
|
function unpack(packed, startIndex) {
|
52
49
|
// read operation from first 8 bits (= 2 hex digits)
|
53
50
|
const operation = parseInt(packed.substring(startIndex, startIndex + 2), 16);
|
@@ -67,16 +64,9 @@ function unpack(packed, startIndex) {
|
|
67
64
|
endIndex,
|
68
65
|
};
|
69
66
|
}
|
70
|
-
function
|
71
|
-
// const multiSendContract = new Interface(MULTI_SEND_ABI);
|
72
|
-
// const tx = multiSendContract.parseTransaction({ data });
|
73
|
-
// const multiSendAbiItem = parseAbiItem({
|
74
|
-
// type: "function",
|
75
|
-
// name: "multiSend",
|
76
|
-
// inputs: [{ name: "data", type: "bytes" }],
|
77
|
-
// });
|
67
|
+
function decodeMulti(data) {
|
78
68
|
const tx = (0, viem_1.decodeFunctionData)({
|
79
|
-
abi: exports.MULTI_SEND_ABI,
|
69
|
+
abi: (0, viem_1.parseAbi)(exports.MULTI_SEND_ABI),
|
80
70
|
data,
|
81
71
|
});
|
82
72
|
const [transactionsEncoded] = tx.args;
|
package/dist/cjs/near-safe.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { NearConfig } from "near-api-js/lib/near";
|
2
|
-
import { FinalExecutionOutcome } from "near-api-js/lib/providers";
|
3
2
|
import { NearEthAdapter, SignRequestData, EncodedSignRequest } from "near-ca";
|
4
3
|
import { Address, Hash, Hex } from "viem";
|
5
4
|
import { SafeContractSuite } from "./lib/safe";
|
@@ -99,15 +98,12 @@ export declare class NearSafe {
|
|
99
98
|
* Warning: Uses a private ethRPC with sensitive Pimlico API key (should be run server side).
|
100
99
|
*
|
101
100
|
* @param {number} chainId - The ID of the EVM network to which the transaction should be broadcasted.
|
102
|
-
* @param {
|
101
|
+
* @param {Signature} signature - The valid signature of the unsignedUserOp.
|
103
102
|
* @param {UserOperation} unsignedUserOp - The unsigned user operation to be broadcasted. This includes transaction data such as the destination address and data payload.
|
104
|
-
* @returns {Promise<
|
103
|
+
* @returns {Promise<Hash>} - A promise that resolves hash of the executed user operation.
|
105
104
|
* @throws {Error} - Throws an error if the EVM broadcast fails, including the error message for debugging.
|
106
105
|
*/
|
107
|
-
|
108
|
-
signature: Hex;
|
109
|
-
opHash: Hash;
|
110
|
-
}>;
|
106
|
+
broadcastBundler(chainId: number, signatureHex: Hex, unsignedUserOp: UserOperation): Promise<Hash>;
|
111
107
|
/**
|
112
108
|
* Executes a user operation on the specified blockchain network.
|
113
109
|
* Warning: Uses a private ethRPC with sensitive Pimlico API key (should be run server side).
|
package/dist/cjs/near-safe.js
CHANGED
@@ -150,24 +150,20 @@ class NearSafe {
|
|
150
150
|
* Warning: Uses a private ethRPC with sensitive Pimlico API key (should be run server side).
|
151
151
|
*
|
152
152
|
* @param {number} chainId - The ID of the EVM network to which the transaction should be broadcasted.
|
153
|
-
* @param {
|
153
|
+
* @param {Signature} signature - The valid signature of the unsignedUserOp.
|
154
154
|
* @param {UserOperation} unsignedUserOp - The unsigned user operation to be broadcasted. This includes transaction data such as the destination address and data payload.
|
155
|
-
* @returns {Promise<
|
155
|
+
* @returns {Promise<Hash>} - A promise that resolves hash of the executed user operation.
|
156
156
|
* @throws {Error} - Throws an error if the EVM broadcast fails, including the error message for debugging.
|
157
157
|
*/
|
158
|
-
async
|
159
|
-
const signature = (0, util_1.packSignature)((0, viem_1.serializeSignature)((0, near_ca_1.signatureFromOutcome)(outcome)));
|
158
|
+
async broadcastBundler(chainId, signatureHex, unsignedUserOp) {
|
160
159
|
try {
|
161
|
-
return {
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
signature,
|
166
|
-
}),
|
167
|
-
};
|
160
|
+
return this.executeTransaction(chainId, {
|
161
|
+
...unsignedUserOp,
|
162
|
+
signature: (0, util_1.packSignature)(signatureHex),
|
163
|
+
});
|
168
164
|
}
|
169
165
|
catch (error) {
|
170
|
-
throw new Error(`Failed
|
166
|
+
throw new Error(`Failed Bundler broadcast: ${error instanceof Error ? error.message : String(error)}`);
|
171
167
|
}
|
172
168
|
}
|
173
169
|
/**
|
package/dist/esm/decode/util.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { decodeMulti } from "ethers-multisend/build/cjs/decodeMulti";
|
2
1
|
import { decodeFunctionData, formatEther, parseTransaction, serializeTransaction, } from "viem";
|
3
2
|
import { SAFE_DEPLOYMENTS } from "../_gen/deployments";
|
4
|
-
import { isMultisendTx } from "../lib/multisend";
|
3
|
+
import { decodeMulti, isMultisendTx } from "../lib/multisend";
|
5
4
|
export function decodeTransactionSerializable(chainId, tx) {
|
6
5
|
const { gas, maxFeePerGas, maxPriorityFeePerGas, to } = tx;
|
7
6
|
if (chainId !== tx.chainId) {
|
@@ -3,4 +3,4 @@ import { MetaTransaction } from "../types";
|
|
3
3
|
export declare const MULTI_SEND_ABI: string[];
|
4
4
|
export declare function encodeMulti(transactions: readonly MetaTransaction[], multiSendContractAddress?: string): MetaTransaction;
|
5
5
|
export declare function isMultisendTx(args: readonly unknown[]): boolean;
|
6
|
-
export declare function
|
6
|
+
export declare function decodeMulti(data: Hex): MetaTransaction[];
|
@@ -39,9 +39,6 @@ export function isMultisendTx(args) {
|
|
39
39
|
return (to === MULTISEND_141.toLowerCase() ||
|
40
40
|
to === MULTISEND_CALLONLY_141.toLowerCase());
|
41
41
|
}
|
42
|
-
// import { Interface } from '@ethersproject/abi';
|
43
|
-
// import { getAddress } from '@ethersproject/address';
|
44
|
-
// import { BigNumber } from '@ethersproject/bignumber';
|
45
42
|
function unpack(packed, startIndex) {
|
46
43
|
// read operation from first 8 bits (= 2 hex digits)
|
47
44
|
const operation = parseInt(packed.substring(startIndex, startIndex + 2), 16);
|
@@ -61,16 +58,9 @@ function unpack(packed, startIndex) {
|
|
61
58
|
endIndex,
|
62
59
|
};
|
63
60
|
}
|
64
|
-
export function
|
65
|
-
// const multiSendContract = new Interface(MULTI_SEND_ABI);
|
66
|
-
// const tx = multiSendContract.parseTransaction({ data });
|
67
|
-
// const multiSendAbiItem = parseAbiItem({
|
68
|
-
// type: "function",
|
69
|
-
// name: "multiSend",
|
70
|
-
// inputs: [{ name: "data", type: "bytes" }],
|
71
|
-
// });
|
61
|
+
export function decodeMulti(data) {
|
72
62
|
const tx = decodeFunctionData({
|
73
|
-
abi: MULTI_SEND_ABI,
|
63
|
+
abi: parseAbi(MULTI_SEND_ABI),
|
74
64
|
data,
|
75
65
|
});
|
76
66
|
const [transactionsEncoded] = tx.args;
|
package/dist/esm/near-safe.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { NearConfig } from "near-api-js/lib/near";
|
2
|
-
import { FinalExecutionOutcome } from "near-api-js/lib/providers";
|
3
2
|
import { NearEthAdapter, SignRequestData, EncodedSignRequest } from "near-ca";
|
4
3
|
import { Address, Hash, Hex } from "viem";
|
5
4
|
import { SafeContractSuite } from "./lib/safe";
|
@@ -99,15 +98,12 @@ export declare class NearSafe {
|
|
99
98
|
* Warning: Uses a private ethRPC with sensitive Pimlico API key (should be run server side).
|
100
99
|
*
|
101
100
|
* @param {number} chainId - The ID of the EVM network to which the transaction should be broadcasted.
|
102
|
-
* @param {
|
101
|
+
* @param {Signature} signature - The valid signature of the unsignedUserOp.
|
103
102
|
* @param {UserOperation} unsignedUserOp - The unsigned user operation to be broadcasted. This includes transaction data such as the destination address and data payload.
|
104
|
-
* @returns {Promise<
|
103
|
+
* @returns {Promise<Hash>} - A promise that resolves hash of the executed user operation.
|
105
104
|
* @throws {Error} - Throws an error if the EVM broadcast fails, including the error message for debugging.
|
106
105
|
*/
|
107
|
-
|
108
|
-
signature: Hex;
|
109
|
-
opHash: Hash;
|
110
|
-
}>;
|
106
|
+
broadcastBundler(chainId: number, signatureHex: Hex, unsignedUserOp: UserOperation): Promise<Hash>;
|
111
107
|
/**
|
112
108
|
* Executes a user operation on the specified blockchain network.
|
113
109
|
* Warning: Uses a private ethRPC with sensitive Pimlico API key (should be run server side).
|
package/dist/esm/near-safe.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { setupAdapter,
|
2
|
-
import {
|
1
|
+
import { setupAdapter, toPayload, requestRouter as mpcRequestRouter, } from "near-ca";
|
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";
|
@@ -153,24 +153,20 @@ export class NearSafe {
|
|
153
153
|
* Warning: Uses a private ethRPC with sensitive Pimlico API key (should be run server side).
|
154
154
|
*
|
155
155
|
* @param {number} chainId - The ID of the EVM network to which the transaction should be broadcasted.
|
156
|
-
* @param {
|
156
|
+
* @param {Signature} signature - The valid signature of the unsignedUserOp.
|
157
157
|
* @param {UserOperation} unsignedUserOp - The unsigned user operation to be broadcasted. This includes transaction data such as the destination address and data payload.
|
158
|
-
* @returns {Promise<
|
158
|
+
* @returns {Promise<Hash>} - A promise that resolves hash of the executed user operation.
|
159
159
|
* @throws {Error} - Throws an error if the EVM broadcast fails, including the error message for debugging.
|
160
160
|
*/
|
161
|
-
async
|
162
|
-
const signature = packSignature(serializeSignature(signatureFromOutcome(outcome)));
|
161
|
+
async broadcastBundler(chainId, signatureHex, unsignedUserOp) {
|
163
162
|
try {
|
164
|
-
return {
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
signature,
|
169
|
-
}),
|
170
|
-
};
|
163
|
+
return this.executeTransaction(chainId, {
|
164
|
+
...unsignedUserOp,
|
165
|
+
signature: packSignature(signatureHex),
|
166
|
+
});
|
171
167
|
}
|
172
168
|
catch (error) {
|
173
|
-
throw new Error(`Failed
|
169
|
+
throw new Error(`Failed Bundler broadcast: ${error instanceof Error ? error.message : String(error)}`);
|
174
170
|
}
|
175
171
|
}
|
176
172
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "near-safe",
|
3
|
-
"version": "0.8.5
|
3
|
+
"version": "0.8.5",
|
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,7 +42,6 @@
|
|
42
42
|
},
|
43
43
|
"dependencies": {
|
44
44
|
"@safe-global/safe-gateway-typescript-sdk": "^3.22.2",
|
45
|
-
"ethers-multisend": "^3.1.0",
|
46
45
|
"near-api-js": "^5.0.0",
|
47
46
|
"near-ca": "^0.6.0",
|
48
47
|
"semver": "^7.6.3",
|
@@ -61,6 +60,7 @@
|
|
61
60
|
"eslint": "^9.6.0",
|
62
61
|
"eslint-plugin-import": "^2.30.0",
|
63
62
|
"ethers": "^6.13.1",
|
63
|
+
"ethers-multisend": "^3.1.0",
|
64
64
|
"jest": "^29.7.0",
|
65
65
|
"prettier": "^3.3.2",
|
66
66
|
"ts-jest": "^29.1.5",
|