near-safe 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,6 @@ import { Erc4337Bundler } from "./lib/bundler";
4
4
  import { UserOperation, UserOperationReceipt } from "./types";
5
5
  import { MetaTransaction } from "ethers-multisend";
6
6
  import { ContractSuite } from "./lib/safe";
7
- import { Account } from "near-api-js";
8
7
  export declare class TransactionManager {
9
8
  readonly provider: ethers.JsonRpcProvider;
10
9
  readonly nearAdapter: NearEthAdapter;
@@ -18,8 +17,7 @@ export declare class TransactionManager {
18
17
  static create(config: {
19
18
  ethRpc: string;
20
19
  erc4337BundlerUrl: string;
21
- nearAccount: Account;
22
- mpcContractId: string;
20
+ nearAdapter: NearEthAdapter;
23
21
  safeSaltNonce?: string;
24
22
  }): Promise<TransactionManager>;
25
23
  get safeNotDeployed(): boolean;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransactionManager = void 0;
4
4
  const ethers_1 = require("ethers");
5
- const near_ca_1 = require("near-ca");
6
5
  const bundler_1 = require("./lib/bundler");
7
6
  const util_1 = require("./util");
8
7
  const near_1 = require("./lib/near");
@@ -20,20 +19,16 @@ class TransactionManager {
20
19
  this._safeNotDeployed = safeNotDeployed;
21
20
  }
22
21
  static async create(config) {
22
+ const adapter = config.nearAdapter;
23
23
  const provider = new ethers_1.ethers.JsonRpcProvider(config.ethRpc);
24
- const [nearAdapter, safePack] = await Promise.all([
25
- near_ca_1.NearEthAdapter.fromConfig({
26
- mpcContract: new near_ca_1.MpcContract(config.nearAccount, config.mpcContractId),
27
- }),
28
- safe_1.ContractSuite.init(provider),
29
- ]);
30
- console.log(`Near Adapter: ${nearAdapter.nearAccountId()} <> ${nearAdapter.address}`);
24
+ const safePack = await safe_1.ContractSuite.init(provider);
25
+ console.log(`Near Adapter: ${adapter.nearAccountId()} <> ${adapter.address}`);
31
26
  const bundler = new bundler_1.Erc4337Bundler(config.erc4337BundlerUrl, await safePack.entryPoint.getAddress());
32
- const setup = await safePack.getSetup([nearAdapter.address]);
27
+ const setup = await safePack.getSetup([adapter.address]);
33
28
  const safeAddress = await safePack.addressForSetup(setup, config.safeSaltNonce);
34
29
  const safeNotDeployed = (await provider.getCode(safeAddress)) === "0x";
35
30
  console.log(`Safe Address: ${safeAddress} - deployed? ${!safeNotDeployed}`);
36
- return new TransactionManager(provider, nearAdapter, safePack, bundler, setup, safeAddress, config.safeSaltNonce || "0", safeNotDeployed);
31
+ return new TransactionManager(provider, adapter, safePack, bundler, setup, safeAddress, config.safeSaltNonce || "0", safeNotDeployed);
37
32
  }
38
33
  get safeNotDeployed() {
39
34
  return this._safeNotDeployed;
@@ -4,7 +4,6 @@ import { Erc4337Bundler } from "./lib/bundler";
4
4
  import { UserOperation, UserOperationReceipt } from "./types";
5
5
  import { MetaTransaction } from "ethers-multisend";
6
6
  import { ContractSuite } from "./lib/safe";
7
- import { Account } from "near-api-js";
8
7
  export declare class TransactionManager {
9
8
  readonly provider: ethers.JsonRpcProvider;
10
9
  readonly nearAdapter: NearEthAdapter;
@@ -18,8 +17,7 @@ export declare class TransactionManager {
18
17
  static create(config: {
19
18
  ethRpc: string;
20
19
  erc4337BundlerUrl: string;
21
- nearAccount: Account;
22
- mpcContractId: string;
20
+ nearAdapter: NearEthAdapter;
23
21
  safeSaltNonce?: string;
24
22
  }): Promise<TransactionManager>;
25
23
  get safeNotDeployed(): boolean;
@@ -1,5 +1,4 @@
1
1
  import { ethers } from "ethers";
2
- import { NearEthAdapter, MpcContract } from "near-ca";
3
2
  import { Erc4337Bundler } from "./lib/bundler";
4
3
  import { packSignature } from "./util";
5
4
  import { getNearSignature } from "./lib/near";
@@ -25,20 +24,16 @@ export class TransactionManager {
25
24
  this._safeNotDeployed = safeNotDeployed;
26
25
  }
27
26
  static async create(config) {
27
+ const adapter = config.nearAdapter;
28
28
  const provider = new ethers.JsonRpcProvider(config.ethRpc);
29
- const [nearAdapter, safePack] = await Promise.all([
30
- NearEthAdapter.fromConfig({
31
- mpcContract: new MpcContract(config.nearAccount, config.mpcContractId),
32
- }),
33
- ContractSuite.init(provider),
34
- ]);
35
- console.log(`Near Adapter: ${nearAdapter.nearAccountId()} <> ${nearAdapter.address}`);
29
+ const safePack = await ContractSuite.init(provider);
30
+ console.log(`Near Adapter: ${adapter.nearAccountId()} <> ${adapter.address}`);
36
31
  const bundler = new Erc4337Bundler(config.erc4337BundlerUrl, await safePack.entryPoint.getAddress());
37
- const setup = await safePack.getSetup([nearAdapter.address]);
32
+ const setup = await safePack.getSetup([adapter.address]);
38
33
  const safeAddress = await safePack.addressForSetup(setup, config.safeSaltNonce);
39
34
  const safeNotDeployed = (await provider.getCode(safeAddress)) === "0x";
40
35
  console.log(`Safe Address: ${safeAddress} - deployed? ${!safeNotDeployed}`);
41
- return new TransactionManager(provider, nearAdapter, safePack, bundler, setup, safeAddress, config.safeSaltNonce || "0", safeNotDeployed);
36
+ return new TransactionManager(provider, adapter, safePack, bundler, setup, safeAddress, config.safeSaltNonce || "0", safeNotDeployed);
42
37
  }
43
38
  get safeNotDeployed() {
44
39
  return this._safeNotDeployed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "near-safe",
3
- "version": "0.0.5",
3
+ "version": "0.1.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",