near-safe 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,4 +3,5 @@ export * from "./types";
3
3
  export * from "./util";
4
4
  export * from "./constants";
5
5
  export * from "./decode";
6
- export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, } from "near-ca";
6
+ export * from "./lib/safe-message";
7
+ export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, EthTransactionParams, } from "near-ca";
package/dist/cjs/index.js CHANGED
@@ -20,6 +20,7 @@ __exportStar(require("./types"), exports);
20
20
  __exportStar(require("./util"), exports);
21
21
  __exportStar(require("./constants"), exports);
22
22
  __exportStar(require("./decode"), exports);
23
+ __exportStar(require("./lib/safe-message"), exports);
23
24
  var near_ca_1 = require("near-ca");
24
25
  Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return near_ca_1.Network; } });
25
26
  Object.defineProperty(exports, "populateTx", { enumerable: true, get: function () { return near_ca_1.populateTx; } });
@@ -337,13 +337,15 @@ class NearSafe {
337
337
  }
338
338
  }
339
339
  encodeForSafe(from) {
340
- const fromLower = from.toLowerCase();
341
- if (![this.address, this.mpcAddress]
342
- .map((t) => t.toLowerCase())
343
- .includes(fromLower)) {
340
+ const lowerFrom = from.toLowerCase();
341
+ const lowerZero = viem_1.zeroAddress.toLowerCase();
342
+ const lowerSafe = this.address.toLowerCase();
343
+ const lowerMpc = this.mpcAddress.toLowerCase();
344
+ // We allow zeroAddress (and and treat is as from = safe)
345
+ if (![lowerSafe, lowerMpc, lowerZero].includes(lowerFrom)) {
344
346
  throw new Error(`Unexpected from address ${from}`);
345
347
  }
346
- return this.address.toLowerCase() === fromLower;
348
+ return [this.address.toLowerCase(), lowerZero].includes(lowerFrom);
347
349
  }
348
350
  async policyForChainId(chainId) {
349
351
  const bundler = this.bundlerForChainId(chainId);
@@ -3,4 +3,5 @@ export * from "./types";
3
3
  export * from "./util";
4
4
  export * from "./constants";
5
5
  export * from "./decode";
6
- export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, } from "near-ca";
6
+ export * from "./lib/safe-message";
7
+ export { Network, BaseTx, SignRequestData, populateTx, NetworkFields, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, EthTransactionParams, } from "near-ca";
package/dist/esm/index.js CHANGED
@@ -3,4 +3,5 @@ export * from "./types";
3
3
  export * from "./util";
4
4
  export * from "./constants";
5
5
  export * from "./decode";
6
+ export * from "./lib/safe-message";
6
7
  export { Network, populateTx, signatureFromOutcome, signatureFromTxHash, requestRouter as mpcRequestRouter, } from "near-ca";
@@ -1,5 +1,5 @@
1
1
  import { setupAdapter, signatureFromOutcome, toPayload, requestRouter as mpcRequestRouter, } from "near-ca";
2
- import { serializeSignature } from "viem";
2
+ import { serializeSignature, 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";
@@ -340,13 +340,15 @@ export class NearSafe {
340
340
  }
341
341
  }
342
342
  encodeForSafe(from) {
343
- const fromLower = from.toLowerCase();
344
- if (![this.address, this.mpcAddress]
345
- .map((t) => t.toLowerCase())
346
- .includes(fromLower)) {
343
+ const lowerFrom = from.toLowerCase();
344
+ const lowerZero = zeroAddress.toLowerCase();
345
+ const lowerSafe = this.address.toLowerCase();
346
+ const lowerMpc = this.mpcAddress.toLowerCase();
347
+ // We allow zeroAddress (and and treat is as from = safe)
348
+ if (![lowerSafe, lowerMpc, lowerZero].includes(lowerFrom)) {
347
349
  throw new Error(`Unexpected from address ${from}`);
348
350
  }
349
- return this.address.toLowerCase() === fromLower;
351
+ return [this.address.toLowerCase(), lowerZero].includes(lowerFrom);
350
352
  }
351
353
  async policyForChainId(chainId) {
352
354
  const bundler = this.bundlerForChainId(chainId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "near-safe",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "license": "MIT",
5
5
  "description": "An SDK for controlling Ethereum Smart Accounts via ERC4337 from a Near Account.",
6
6
  "author": "bh2smith",