near-safe 0.8.1 → 0.8.3

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.
@@ -19,7 +19,7 @@ const safe_message_1 = require("./lib/safe-message");
19
19
  function decodeTxData({ evmMessage, chainId, }) {
20
20
  const data = evmMessage;
21
21
  if ((0, safe_message_1.isRlpHex)(evmMessage)) {
22
- decodeRlpHex(chainId, evmMessage);
22
+ return decodeRlpHex(chainId, evmMessage);
23
23
  }
24
24
  if ((0, safe_message_1.isTransactionSerializable)(data)) {
25
25
  return decodeTransactionSerializable(chainId, data);
@@ -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);
@@ -12,7 +12,7 @@ import { isRlpHex, isTransactionSerializable } from "./lib/safe-message";
12
12
  export function decodeTxData({ evmMessage, chainId, }) {
13
13
  const data = evmMessage;
14
14
  if (isRlpHex(evmMessage)) {
15
- decodeRlpHex(chainId, evmMessage);
15
+ return decodeRlpHex(chainId, evmMessage);
16
16
  }
17
17
  if (isTransactionSerializable(data)) {
18
18
  return decodeTransactionSerializable(chainId, data);
@@ -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.1",
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",