near-safe 0.0.4 → 0.0.5

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.
@@ -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
- encodeSignatureRequest(unsignedUserOp: UserOperation): Promise<NearEthTxData>;
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>;
@@ -65,16 +65,27 @@ class TransactionManager {
65
65
  async opHash(userOp) {
66
66
  return this.safePack.getOpHash(userOp);
67
67
  }
68
- async encodeSignatureRequest(unsignedUserOp) {
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 txData = this.nearAdapter.encodeSignRequest({
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
- ...txData,
77
- evmMessage: unsignedUserOp,
87
+ ...signRequest,
88
+ evmMessage: JSON.stringify(unsignedUserOp),
78
89
  };
79
90
  }
80
91
  async executeTransaction(userOp) {
@@ -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
- encodeSignatureRequest(unsignedUserOp: UserOperation): Promise<NearEthTxData>;
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>;
@@ -70,16 +70,27 @@ export class TransactionManager {
70
70
  async opHash(userOp) {
71
71
  return this.safePack.getOpHash(userOp);
72
72
  }
73
- async encodeSignatureRequest(unsignedUserOp) {
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 txData = this.nearAdapter.encodeSignRequest({
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
- ...txData,
82
- evmMessage: unsignedUserOp,
92
+ ...signRequest,
93
+ evmMessage: JSON.stringify(unsignedUserOp),
83
94
  };
84
95
  }
85
96
  async executeTransaction(userOp) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "near-safe",
3
- "version": "0.0.4",
3
+ "version": "0.0.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",