Skip to content

Commit

Permalink
Prepare for Monorepo & Remove Ethers
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Nov 18, 2024
1 parent aa267a5 commit 5077122
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 310 deletions.
1 change: 0 additions & 1 deletion examples/send-tx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dotenv from "dotenv";
import { ethers } from "ethers";
import { formatEther, isAddress } from "viem";

import { loadArgs, loadEnv } from "./cli";
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"example": "tsx examples/send-tx.ts",
"lint": "prettier --check '{src,examples,tests}/**/*.{js,jsx,ts,tsx}' && eslint . --ignore-pattern dist/",
"fmt": "prettier --write '{src,examples,tests}/**/*.{js,jsx,ts,tsx}' && yarn lint --fix",
"test": "jest",
"test": "jest --passWithNoTests",
"all": "yarn fmt && yarn lint && yarn build"
},
"dependencies": {
Expand All @@ -59,8 +59,6 @@
"dotenv": "^16.4.5",
"eslint": "^9.14.0",
"eslint-plugin-import": "^2.31.0",
"ethers": "^6.13.4",
"ethers-multisend": "^3.1.0",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export * from "./lib/safe-message";
// TODO: Improve re-exports...
export {
Network,
BaseTx,
SignRequestData,
type BaseTx,
type SignRequestData,
populateTx,
NetworkFields,
type NetworkFields,
signatureFromOutcome,
signatureFromTxHash,
requestRouter as mpcRequestRouter,
EthTransactionParams,
type EthTransactionParams,
isRlpHex,
} from "near-ca";
2 changes: 1 addition & 1 deletion src/lib/safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,6 @@ export class SafeContractSuite {
if (ownerIndex === -1) {
throw new Error(`Not a current owner: ${owner}`);
}
return ownerIndex > 0 ? currentOwners[ownerIndex - 1] : SENTINEL_OWNERS;
return ownerIndex > 0 ? currentOwners[ownerIndex - 1]! : SENTINEL_OWNERS;
}
}
4 changes: 3 additions & 1 deletion src/near-safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ export class NearSafe {

// Assert uniqueness
assertUnique(fromAddresses);

if (!fromAddresses[0]) {
throw new Error("No from address provided");
}
// Early return with eoaEncoding if `from` is not the Safe
if (!this.encodeForSafe(fromAddresses[0])) {
// TODO: near-ca needs to update this for typed data like we did.
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe("Near Safe Requests", () => {
method: "eth_signTypedData_v4",
params: [adapter.mpcAddress, typedDataString],
});
expect(nearPayload.actions[0].params.args).toStrictEqual({
expect(nearPayload.actions[0]!.params.args).toStrictEqual({
request: {
path: "ethereum,1",
payload: [
Expand Down
235 changes: 0 additions & 235 deletions tests/unit/ethers-safe.ts

This file was deleted.

9 changes: 4 additions & 5 deletions tests/unit/lib/multisend.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { decodeMulti as decodeMultiEthers } from "ethers-multisend";
import { encodeFunctionData, erc20Abi, Hex, parseUnits, toHex } from "viem";

import { OperationType } from "../../../src";
Expand Down Expand Up @@ -69,17 +68,17 @@ describe("Multisend", () => {
operation: OperationType.Call,
to: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
value: toHex(BigInt(parseUnits("10", 18))),
data: "0x00",
data: "0x",
},
{
operation: OperationType.Call,
to: "0x36F4BFC9f49Dc5D4b2d10c4a48a6b30128BD79bC",
value: "0x00",
value: "0x0",
data: ercTransferData,
},
];

const multiSendTx = encodeMulti(input);
const result = decodeMultiEthers(multiSendTx.data);
expect(result).toStrictEqual(input);
expect(decodeMultiViem(multiSendTx.data as Hex)).toStrictEqual(input);
});
});
Loading

0 comments on commit 5077122

Please sign in to comment.