near-safe 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/tx-manager.d.ts +2 -2
- package/dist/cjs/tx-manager.js +15 -4
- package/dist/esm/tx-manager.d.ts +2 -2
- package/dist/esm/tx-manager.js +15 -4
- package/package.json +1 -1
package/dist/cjs/tx-manager.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ethers } from "ethers";
|
2
|
-
import { NearEthAdapter, NearEthTxData } from "near-ca";
|
2
|
+
import { NearEthAdapter, NearEthTxData, BaseTx } from "near-ca";
|
3
3
|
import { Erc4337Bundler } from "./lib/bundler";
|
4
4
|
import { UserOperation, UserOperationReceipt } from "./types";
|
5
5
|
import { MetaTransaction } from "ethers-multisend";
|
@@ -31,7 +31,7 @@ export declare class TransactionManager {
|
|
31
31
|
}): Promise<UserOperation>;
|
32
32
|
signTransaction(safeOpHash: string): Promise<string>;
|
33
33
|
opHash(userOp: UserOperation): Promise<string>;
|
34
|
-
|
34
|
+
encodeSignRequest(tx: BaseTx): Promise<NearEthTxData>;
|
35
35
|
executeTransaction(userOp: UserOperation): Promise<UserOperationReceipt>;
|
36
36
|
addOwnerTx(address: string): MetaTransaction;
|
37
37
|
safeSufficientlyFunded(transactions: MetaTransaction[], gasCost: bigint): Promise<boolean>;
|
package/dist/cjs/tx-manager.js
CHANGED
@@ -65,16 +65,27 @@ class TransactionManager {
|
|
65
65
|
async opHash(userOp) {
|
66
66
|
return this.safePack.getOpHash(userOp);
|
67
67
|
}
|
68
|
-
async
|
68
|
+
async encodeSignRequest(tx) {
|
69
|
+
// TODO - This is sloppy and ignores ChainId!
|
70
|
+
const unsignedUserOp = await this.buildTransaction({
|
71
|
+
transactions: [
|
72
|
+
{
|
73
|
+
to: tx.to,
|
74
|
+
value: (tx.value || 0n).toString(),
|
75
|
+
data: tx.data || "0x",
|
76
|
+
},
|
77
|
+
],
|
78
|
+
usePaymaster: true,
|
79
|
+
});
|
69
80
|
const safeOpHash = (await this.opHash(unsignedUserOp));
|
70
|
-
const
|
81
|
+
const signRequest = await this.nearAdapter.encodeSignRequest({
|
71
82
|
method: "hash",
|
72
83
|
chainId: 0,
|
73
84
|
params: safeOpHash,
|
74
85
|
});
|
75
86
|
return {
|
76
|
-
...
|
77
|
-
evmMessage: unsignedUserOp,
|
87
|
+
...signRequest,
|
88
|
+
evmMessage: JSON.stringify(unsignedUserOp),
|
78
89
|
};
|
79
90
|
}
|
80
91
|
async executeTransaction(userOp) {
|
package/dist/esm/tx-manager.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ethers } from "ethers";
|
2
|
-
import { NearEthAdapter, NearEthTxData } from "near-ca";
|
2
|
+
import { NearEthAdapter, NearEthTxData, BaseTx } from "near-ca";
|
3
3
|
import { Erc4337Bundler } from "./lib/bundler";
|
4
4
|
import { UserOperation, UserOperationReceipt } from "./types";
|
5
5
|
import { MetaTransaction } from "ethers-multisend";
|
@@ -31,7 +31,7 @@ export declare class TransactionManager {
|
|
31
31
|
}): Promise<UserOperation>;
|
32
32
|
signTransaction(safeOpHash: string): Promise<string>;
|
33
33
|
opHash(userOp: UserOperation): Promise<string>;
|
34
|
-
|
34
|
+
encodeSignRequest(tx: BaseTx): Promise<NearEthTxData>;
|
35
35
|
executeTransaction(userOp: UserOperation): Promise<UserOperationReceipt>;
|
36
36
|
addOwnerTx(address: string): MetaTransaction;
|
37
37
|
safeSufficientlyFunded(transactions: MetaTransaction[], gasCost: bigint): Promise<boolean>;
|
package/dist/esm/tx-manager.js
CHANGED
@@ -70,16 +70,27 @@ export class TransactionManager {
|
|
70
70
|
async opHash(userOp) {
|
71
71
|
return this.safePack.getOpHash(userOp);
|
72
72
|
}
|
73
|
-
async
|
73
|
+
async encodeSignRequest(tx) {
|
74
|
+
// TODO - This is sloppy and ignores ChainId!
|
75
|
+
const unsignedUserOp = await this.buildTransaction({
|
76
|
+
transactions: [
|
77
|
+
{
|
78
|
+
to: tx.to,
|
79
|
+
value: (tx.value || 0n).toString(),
|
80
|
+
data: tx.data || "0x",
|
81
|
+
},
|
82
|
+
],
|
83
|
+
usePaymaster: true,
|
84
|
+
});
|
74
85
|
const safeOpHash = (await this.opHash(unsignedUserOp));
|
75
|
-
const
|
86
|
+
const signRequest = await this.nearAdapter.encodeSignRequest({
|
76
87
|
method: "hash",
|
77
88
|
chainId: 0,
|
78
89
|
params: safeOpHash,
|
79
90
|
});
|
80
91
|
return {
|
81
|
-
...
|
82
|
-
evmMessage: unsignedUserOp,
|
92
|
+
...signRequest,
|
93
|
+
evmMessage: JSON.stringify(unsignedUserOp),
|
83
94
|
};
|
84
95
|
}
|
85
96
|
async executeTransaction(userOp) {
|