near-safe 0.9.2 → 0.9.4

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.
@@ -4,4 +4,5 @@ export * from "./util";
4
4
  export * from "./constants";
5
5
  export * from "./decode";
6
6
  export * from "./lib/safe-message";
7
- export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, EthTransactionParams, isRlpHex, } from "near-ca";
7
+ export { SafeContractSuite } from "./lib/safe";
8
+ export { Network, type BaseTx, type SignRequestData, populateTx, type NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, type EthTransactionParams, isRlpHex, } from "near-ca";
package/dist/cjs/index.js CHANGED
@@ -14,13 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isRlpHex = exports.mpcRequestRouter = exports.signatureFromTxHash = exports.signatureFromOutcome = exports.populateTx = exports.Network = void 0;
17
+ exports.isRlpHex = exports.mpcRequestRouter = exports.signatureFromTxHash = exports.signatureFromOutcome = exports.populateTx = exports.Network = exports.SafeContractSuite = void 0;
18
18
  __exportStar(require("./near-safe"), exports);
19
19
  __exportStar(require("./types"), exports);
20
20
  __exportStar(require("./util"), exports);
21
21
  __exportStar(require("./constants"), exports);
22
22
  __exportStar(require("./decode"), exports);
23
23
  __exportStar(require("./lib/safe-message"), exports);
24
+ var safe_1 = require("./lib/safe");
25
+ Object.defineProperty(exports, "SafeContractSuite", { enumerable: true, get: function () { return safe_1.SafeContractSuite; } });
24
26
  // TODO: Improve re-exports...
25
27
  var near_ca_1 = require("near-ca");
26
28
  Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return near_ca_1.Network; } });
@@ -170,4 +170,6 @@ export declare class NearSafe {
170
170
  requestRouter({ method, chainId, params }: SignRequestData, sponsorshipPolicy?: string): Promise<EncodedSignRequest>;
171
171
  encodeForSafe(from: string): boolean;
172
172
  policyForChainId(chainId: number): Promise<SponsorshipPolicyData[]>;
173
+ deploymentRequest(chainId: number): SignRequestData;
174
+ addOwnerRequest(chainId: number, recoveryAddress: Address): SignRequestData;
173
175
  }
@@ -277,6 +277,9 @@ class NearSafe {
277
277
  })();
278
278
  // Assert uniqueness
279
279
  (0, util_1.assertUnique)(fromAddresses);
280
+ if (!fromAddresses[0]) {
281
+ throw new Error("No from address provided");
282
+ }
280
283
  // Early return with eoaEncoding if `from` is not the Safe
281
284
  if (!this.encodeForSafe(fromAddresses[0])) {
282
285
  // TODO: near-ca needs to update this for typed data like we did.
@@ -347,5 +350,31 @@ class NearSafe {
347
350
  const bundler = this.bundlerForChainId(chainId);
348
351
  return bundler.getSponsorshipPolicies();
349
352
  }
353
+ deploymentRequest(chainId) {
354
+ return {
355
+ method: "eth_sendTransaction",
356
+ chainId,
357
+ params: [
358
+ {
359
+ from: this.address,
360
+ to: viem_1.zeroAddress,
361
+ value: "0x0",
362
+ data: "0x",
363
+ },
364
+ ],
365
+ };
366
+ }
367
+ addOwnerRequest(chainId, recoveryAddress) {
368
+ return {
369
+ method: "eth_sendTransaction",
370
+ chainId,
371
+ params: [{
372
+ from: this.address,
373
+ to: this.address,
374
+ value: "0x0",
375
+ data: new safe_1.SafeContractSuite().addOwnerData(recoveryAddress)
376
+ }],
377
+ };
378
+ }
350
379
  }
351
380
  exports.NearSafe = NearSafe;
@@ -4,4 +4,5 @@ export * from "./util";
4
4
  export * from "./constants";
5
5
  export * from "./decode";
6
6
  export * from "./lib/safe-message";
7
- export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, EthTransactionParams, isRlpHex, } from "near-ca";
7
+ export { SafeContractSuite } from "./lib/safe";
8
+ export { Network, type BaseTx, type SignRequestData, populateTx, type NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, type EthTransactionParams, isRlpHex, } from "near-ca";
package/dist/esm/index.js CHANGED
@@ -4,5 +4,6 @@ export * from "./util";
4
4
  export * from "./constants";
5
5
  export * from "./decode";
6
6
  export * from "./lib/safe-message";
7
+ export { SafeContractSuite } from "./lib/safe";
7
8
  // TODO: Improve re-exports...
8
9
  export { Network, populateTx, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, isRlpHex, } from "near-ca";
@@ -170,4 +170,6 @@ export declare class NearSafe {
170
170
  requestRouter({ method, chainId, params }: SignRequestData, sponsorshipPolicy?: string): Promise<EncodedSignRequest>;
171
171
  encodeForSafe(from: string): boolean;
172
172
  policyForChainId(chainId: number): Promise<SponsorshipPolicyData[]>;
173
+ deploymentRequest(chainId: number): SignRequestData;
174
+ addOwnerRequest(chainId: number, recoveryAddress: Address): SignRequestData;
173
175
  }
@@ -280,6 +280,9 @@ export class NearSafe {
280
280
  })();
281
281
  // Assert uniqueness
282
282
  assertUnique(fromAddresses);
283
+ if (!fromAddresses[0]) {
284
+ throw new Error("No from address provided");
285
+ }
283
286
  // Early return with eoaEncoding if `from` is not the Safe
284
287
  if (!this.encodeForSafe(fromAddresses[0])) {
285
288
  // TODO: near-ca needs to update this for typed data like we did.
@@ -350,4 +353,30 @@ export class NearSafe {
350
353
  const bundler = this.bundlerForChainId(chainId);
351
354
  return bundler.getSponsorshipPolicies();
352
355
  }
356
+ deploymentRequest(chainId) {
357
+ return {
358
+ method: "eth_sendTransaction",
359
+ chainId,
360
+ params: [
361
+ {
362
+ from: this.address,
363
+ to: zeroAddress,
364
+ value: "0x0",
365
+ data: "0x",
366
+ },
367
+ ],
368
+ };
369
+ }
370
+ addOwnerRequest(chainId, recoveryAddress) {
371
+ return {
372
+ method: "eth_sendTransaction",
373
+ chainId,
374
+ params: [{
375
+ from: this.address,
376
+ to: this.address,
377
+ value: "0x0",
378
+ data: new SafeContractSuite().addOwnerData(recoveryAddress)
379
+ }],
380
+ };
381
+ }
353
382
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "near-safe",
3
- "version": "0.9.2",
3
+ "version": "0.9.4",
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,7 +37,7 @@
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}' && yarn lint --fix",
40
- "test": "jest",
40
+ "test": "jest --passWithNoTests",
41
41
  "all": "yarn fmt && yarn lint && yarn build"
42
42
  },
43
43
  "dependencies": {
@@ -59,8 +59,6 @@
59
59
  "dotenv": "^16.4.5",
60
60
  "eslint": "^9.14.0",
61
61
  "eslint-plugin-import": "^2.31.0",
62
- "ethers": "^6.13.4",
63
- "ethers-multisend": "^3.1.0",
64
62
  "jest": "^29.7.0",
65
63
  "prettier": "^3.3.3",
66
64
  "ts-jest": "^29.2.5",