Skip to content

Commit

Permalink
feat: update viem and debug 7702 auth
Browse files Browse the repository at this point in the history
  • Loading branch information
adamegyed committed Jan 13, 2025
1 parent dc967f5 commit b235ac9
Show file tree
Hide file tree
Showing 25 changed files with 683 additions and 131 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ site/.vitepress/cache/**/*

/examples/*
!/examples/ui-demo
/examples/ui-demo/contracts
/examples/ui-demo/.next/*

**/.turbo/*
Expand Down
4 changes: 2 additions & 2 deletions .vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"prool": "^0.0.15",
"tar": "^7.4.1",
"typescript-template": "*",
"viem": "2.20.0"
"viem": "2.22.6"
},
"dependencies": {
"@aa-sdk/core": "^4.0.0-alpha.8"
}
}
}
4 changes: 2 additions & 2 deletions aa-sdk/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"zod": "^3.22.4"
},
"peerDependencies": {
"viem": "^2.20.0"
"viem": "^2.22.6"
},
"repository": {
"type": "git",
Expand All @@ -65,4 +65,4 @@
},
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
"gitHead": "ee46e8bb857de3b631044fa70714ea706d9e317d"
}
}
6 changes: 1 addition & 5 deletions aa-sdk/core/src/middleware/defaults/7702signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,13 @@ export const default7702UserOpSigner: ClientMiddlewareFn = async (
r,
s,
v,
yParity = v,
yParity = v ? v - 27n : undefined,
} = await signer.signAuthorization({
chainId: client.chain.id,
contractAddress: implAddress,
nonce: accountNonce,
});

if (!yParity) {
throw new Error("incomplete signature!");
}

return {
...uo,
authorizationTuple: {
Expand Down
4 changes: 2 additions & 2 deletions aa-sdk/ethers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@ethersproject/wallet": "^5.7.0"
},
"peerDependencies": {
"viem": "^2.20.0"
"viem": "^2.22.6"
},
"repository": {
"type": "git",
Expand All @@ -70,4 +70,4 @@
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
},
"gitHead": "ee46e8bb857de3b631044fa70714ea706d9e317d"
}
}
4 changes: 2 additions & 2 deletions account-kit/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"zustand": "^5.0.0-rc.2"
},
"peerDependencies": {
"viem": "^2.20.0",
"viem": "^2.22.6",
"wagmi": "^2.12.7"
},
"publishConfig": {
Expand All @@ -73,4 +73,4 @@
"optionalDependencies": {
"alchemy-sdk": "^3.0.0"
}
}
}
4 changes: 2 additions & 2 deletions account-kit/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"zod": "^3.22.4"
},
"peerDependencies": {
"viem": "^2.20.0"
"viem": "^2.22.6"
},
"publishConfig": {
"access": "public",
Expand All @@ -68,4 +68,4 @@
"optionalDependencies": {
"alchemy-sdk": "^3.0.0"
}
}
}
4 changes: 2 additions & 2 deletions account-kit/plugingen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@
"zod": "^3.22.4"
},
"peerDependencies": {
"viem": "^2.20.0"
"viem": "^2.22.6"
}
}
}
4 changes: 2 additions & 2 deletions account-kit/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.4.3",
"viem": "^2.20.0",
"viem": "^2.22.6",
"wagmi": "^2.12.7"
},
"resolutions": {
"viem": "2.20.0"
"viem": "2.22.6"
},
"publishConfig": {
"access": "public",
Expand Down
4 changes: 2 additions & 2 deletions account-kit/signer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"zod": "^3.22.4"
},
"peerDependencies": {
"viem": "^2.20.0"
"viem": "^2.22.6"
},
"publishConfig": {
"access": "public",
Expand All @@ -73,4 +73,4 @@
},
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
"gitHead": "ee46e8bb857de3b631044fa70714ea706d9e317d"
}
}
2 changes: 1 addition & 1 deletion account-kit/smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@
"@account-kit/infra": "^4.8.0"
},
"peerDependencies": {
"viem": "^2.20.0"
"viem": "^2.22.6"
}
}
4 changes: 2 additions & 2 deletions examples/ui-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"react-dom": "^18",
"react-syntax-highlighter": "^15.5.0",
"tailwind-merge": "^2.3.0",
"viem": "^2.20.0",
"viem": "^2.22.6",
"wagmi": "^2.12.7",
"zod": "^3.0.0",
"zustand": "^5.0.0-rc.2"
Expand All @@ -52,4 +52,4 @@
"tailwindcss-animate": "^1.0.7",
"typescript": "^5"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export async function POST(
});

const res = await fetch(
`https://rpc.mekong.ethpandaops.io/${params.routes.join("/")}`,
`http://internal-rundler-odyssey-prod-alb-567331340.us-east-1.elb.amazonaws.com:3000/${params.routes.join(
"/"
)}`,
{
method: "POST",
body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ export async function POST(req: NextRequest) {
headers[key] = value;
});

const res = await fetch("https://rpc.mekong.ethpandaops.io", {
method: "POST",
headers: {
...headers,
},
body,
});
const res = await fetch(
"http://internal-rundler-odyssey-prod-alb-567331340.us-east-1.elb.amazonaws.com:3000",
{
method: "POST",
headers: {
...headers,
},
body,
}
);

if (!res.ok) {
return NextResponse.json(await res.json().catch((e) => ({})), {
Expand Down
1 change: 0 additions & 1 deletion examples/ui-demo/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ export default function Home() {
isEOAUser={isEOAUser}
isSmartWallet={walletType === WalletTypes.smart}
/>
{user && !isEOAUser && <Debug7702Button />}
</div>
</div>
</main>
Expand Down
54 changes: 48 additions & 6 deletions examples/ui-demo/src/components/shared/7702/Debug7702Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { Button } from "../Button";
// useSmartAccountClient,
// } from "@account-kit/react";
import { privateKeyToAccount } from "viem/accounts";
import { createPublicClient } from "viem";
import { createPublicClient, toRlp, fromRlp } from "viem";
import {
createBundlerClientFromExisting,
LocalAccountSigner,
} from "@aa-sdk/core";
import { mekong, splitMekongTransport } from "./transportSetup";
import { odyssey, splitOdysseyTransport } from "./transportSetup";
import { send7702UO } from "./demoSend7702UO";
import { useSigner } from "@account-kit/react";

Expand All @@ -23,8 +23,8 @@ export const Debug7702Button = () => {

const runFunc = async (local: boolean) => {
const publicClient = createPublicClient({
chain: mekong,
transport: splitMekongTransport,
chain: odyssey,
transport: splitOdysseyTransport,
});

// console.log("reported chain id: ", await publicClient.getChainId());
Expand Down Expand Up @@ -61,25 +61,67 @@ export const Debug7702Button = () => {

send7702UO(
bundlerClient,
splitMekongTransport,
splitOdysseyTransport,
new LocalAccountSigner(localAccount)
);
} else {
if (!signer) {
console.error("No signer found");
return;
}
send7702UO(bundlerClient, splitMekongTransport, signer);
send7702UO(bundlerClient, splitOdysseyTransport, signer);
}
};

const runLocal = () => runFunc(true);
const runSigner = () => runFunc(false);

const rlpEncode = () => {
const chain_id = "0xde9fb";
const address = "0x69007702764179f14f51cdce752f4f775d74e139";
const nonce = "0x";
const yParity = "0x1c";
const r =
"0x2943f6154757e02a7c8264f9c2f79fac321beef60578746c61eb84a5fc4525d7";
const s =
"0x6a23e53538e028c06f5b149e33424ea11358eecec44ecd8819fbf67ceb03a957";

// // result: 0xf85d830de9fb9469007702764179f14f51cdce752f4f775d74e1390001a02943f6154757e02a7c8264f9c2f79fac321beef60578746c61eb84a5fc4525d7a06a23e53538e028c06f5b149e33424ea11358eecec44ecd8819fbf67ceb03a957
// // result 2: 0xf85ff85d830de9fb9469007702764179f14f51cdce752f4f775d74e1390001a02943f6154757e02a7c8264f9c2f79fac321beef60578746c61eb84a5fc4525d7a06a23e53538e028c06f5b149e33424ea11358eecec44ecd8819fbf67ceb03a957
// // ext result: 0xf85d830de9fb9470d37dc45141e10c42f27e432458218ed4e1aab78080a084039480ba511822433b50a1dea5738e7a946ba187172c02f00076e4a87545a1a001dc4c5f78b6c81f5a695ee8725346a45bf9d1d1f7c1437532efd31a9769fda5

// const chain_id = "0xde9fb";
// const address = "0x69007702764179f14f51cdce752f4f775d74e139";
// const nonce = "0x0";
// const yParity = "0x1c";
// const r = "0x2943f6154757e02a7c8264f9c2f79fac321beef60578746c61eb84a5fc4525d7";
// const s = "0x6a23e53538e028c06f5b149e33424ea11358eecec44ecd8819fbf67ceb03a957";

// // result: 0xf85d830de9fb9469007702764179f14f51cdce752f4f775d74e139001ca02943f6154757e02a7c8264f9c2f79fac321beef60578746c61eb84a5fc4525d7a06a23e53538e028c06f5b149e33424ea11358eecec44ecd8819fbf67ceb03a957

const encoded = toRlp([chain_id, address, nonce, yParity, r, s]);

console.log("encoded: ", encoded);
};

const rlpDecode = () => {
// const input = "0xf85d830de9fb9470d37dc45141e10c42f27e432458218ed4e1aab78080a084039480ba511822433b50a1dea5738e7a946ba187172c02f00076e4a87545a1a001dc4c5f78b6c81f5a695ee8725346a45bf9d1d1f7c1437532efd31a9769fda5";

// From cast sign-auth with the local pkey
const input =
"0xf85d830de9fb9469007702764179f14f51cdce752f4f775d74e1398080a07e650c48b0033a147681165efb7fe9b6195f64f41f71f4b8e503657fd57c3609a00ad5d521d5bbfdcda9d3b9d7b9790cd6ed695d7d63ec08ef49de9631ea0e9b25";

// result:

console.log(fromRlp(input));
};

return (
<div>
<Button onClick={runLocal}>Debug 7702 local</Button>
<Button onClick={runSigner}>Debug 7702 signer</Button>
<Button onClick={rlpEncode}>RLP encode</Button>
<Button onClick={rlpDecode}>RLP decode</Button>
</div>
);
};
2 changes: 2 additions & 0 deletions examples/ui-demo/src/components/shared/7702/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MintCard7702 } from "./MintCard7702";
import { TransactionsCard } from "./TransactionsCard";
import { useMint } from "./useMint";
import { useTransactions } from "./useTransaction";
import { Debug7702Button } from "./Debug7702Button";

export const Wrapper7702 = () => {
const {
Expand Down Expand Up @@ -35,6 +36,7 @@ export const Wrapper7702 = () => {
transactions={transactions}
handleTransactions={handleTransactions}
/>
<Debug7702Button />
</div>
);
};
Loading

0 comments on commit b235ac9

Please sign in to comment.