Skip to content

Commit

Permalink
update dat sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Aug 14, 2024
1 parent dc0787b commit 187aeb7
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 280 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ETH_RPC=https://rpc2.sepolia.org
NEAR_MULTICHAIN_CONTRACT=v2.multichain-mpc.testnet
NEAR_MULTICHAIN_CONTRACT=v1.signer-prod.testnet

NEAR_ACCOUNT_ID=
NEAR_ACCOUNT_PRIVATE_KEY=
Expand Down
2 changes: 1 addition & 1 deletion examples/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function loadArgs(): Promise<UserOptions> {
.option("mpcContractId", {
type: "string",
description: "Address of the mpc (signing) contract",
default: "v2.multichain-mpc.testnet",
default: "v1.signer-prod.testnet",
})
.help()
.alias("help", "h").argv;
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@
"private": true,
"scripts": {
"build": "rm -rf ./dist && tsc",
"start": "yarn example",
"example": "tsx examples/send-tx.ts",
"lint": "eslint . --ignore-pattern dist/",
"fmt": "prettier --write '{src,examples,tests}/**/*.{js,jsx,ts,tsx}'",
"all": "yarn fmt && yarn lint && yarn build && yarn ex"
"all": "yarn fmt && yarn lint && yarn build"
},
"dependencies": {
"@safe-global/safe-deployments": "^1.37.0",
"@safe-global/safe-modules-deployments": "^2.2.0",
"ethers": "^6.13.1",
"ethers-multisend": "^3.1.0",
"near-api-js": "^4.0.3",
"near-ca": "^0.1.0",
"near-ca": "^0.3.1",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/node": "^20.14.9",
"@types/node": "^22.3.0",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"dotenv": "^16.4.5",
"eslint": "^9.6.0",
"prettier": "^3.3.2",
Expand Down
14 changes: 6 additions & 8 deletions src/lib/near.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ export async function getNearSignature(
): Promise<string> {
const viemHash = typeof hash === "string" ? (hash as `0x${string}`) : hash;
// MPC Contract produces two possible signatures.
const signatures = await adapter.sign(viemHash);
for (const sig of signatures) {
if (
ethers.recoverAddress(hash, sig).toLocaleLowerCase() ===
adapter.address.toLocaleLowerCase()
) {
return sig;
}
const signature = await adapter.sign(viemHash);
if (
ethers.recoverAddress(hash, signature).toLocaleLowerCase() ===
adapter.address.toLocaleLowerCase()
) {
return signature;
}
throw new Error("Invalid signature!");
}
9 changes: 3 additions & 6 deletions src/tx-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers } from "ethers";
import { NearEthAdapter, MultichainContract } from "near-ca";
import { NearEthAdapter, MpcContract } from "near-ca";
import { Erc4337Bundler } from "./lib/bundler.js";
import { packSignature } from "./util.js";
import { getNearSignature } from "./lib/near.js";
Expand Down Expand Up @@ -42,16 +42,13 @@ export class TransactionManager {
ethRpc: string;
erc4337BundlerUrl: string;
nearAccount: Account;
mpcContractId: string;
safeSaltNonce?: string;
mpcContractId?: string;
}): Promise<TransactionManager> {
const provider = new ethers.JsonRpcProvider(config.ethRpc);
const [nearAdapter, safePack] = await Promise.all([
NearEthAdapter.fromConfig({
mpcContract: new MultichainContract(
config.nearAccount,
config.mpcContractId
),
mpcContract: new MpcContract(config.nearAccount, config.mpcContractId),
}),
ContractSuite.init(provider),
]);
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export interface PaymasterData {

export interface UserOptions {
usePaymaster: boolean;
recoveryAddress?: string;
safeSaltNonce: string;
mpcContractId?: string;
mpcContractId: string;
recoveryAddress?: string;
}

export type TStatus = "success" | "reverted";
Expand Down
Loading

0 comments on commit 187aeb7

Please sign in to comment.