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.
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/near-safe.js +7 -5
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/near-safe.js +8 -6
- package/package.json +1 -1
package/dist/cjs/index.d.ts
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
|
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; } });
|
package/dist/cjs/near-safe.js
CHANGED
@@ -337,13 +337,15 @@ class NearSafe {
|
|
337
337
|
}
|
338
338
|
}
|
339
339
|
encodeForSafe(from) {
|
340
|
-
const
|
341
|
-
|
342
|
-
|
343
|
-
|
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()
|
348
|
+
return [this.address.toLowerCase(), lowerZero].includes(lowerFrom);
|
347
349
|
}
|
348
350
|
async policyForChainId(chainId) {
|
349
351
|
const bundler = this.bundlerForChainId(chainId);
|
package/dist/esm/index.d.ts
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
|
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";
|
package/dist/esm/near-safe.js
CHANGED
@@ -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
|
344
|
-
|
345
|
-
|
346
|
-
|
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()
|
351
|
+
return [this.address.toLowerCase(), lowerZero].includes(lowerFrom);
|
350
352
|
}
|
351
353
|
async policyForChainId(chainId) {
|
352
354
|
const bundler = this.bundlerForChainId(chainId);
|