Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development into master #87

Merged
merged 43 commits into from
Aug 15, 2024
Merged
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
977b422
feat: oval multi unlocker
md0x Jul 15, 2024
588cd5d
feat: add contract types
md0x Jul 16, 2024
7efa89d
feat: change structure and signatures
md0x Jul 16, 2024
ddfd91e
feat: comments and env var
md0x Jul 16, 2024
87bac83
feat: ci tests
md0x Jul 16, 2024
b3731f7
feat: fix tests
md0x Jul 16, 2024
cb52562
feat: fix tests bis
md0x Jul 16, 2024
9a5c3e2
fix: tests ci
md0x Jul 16, 2024
c092f09
fix: tests ci pkeys
md0x Jul 16, 2024
de05da5
feat: simplify
md0x Jul 16, 2024
ba6590b
feat: remove dep
md0x Jul 16, 2024
c33b1de
feat: init configs
md0x Jul 16, 2024
d66cad8
feat: remove extra type
md0x Jul 16, 2024
0aa2f98
feat: clean tests
md0x Jul 16, 2024
4131b76
feat: oval discovery
md0x Jul 17, 2024
9dfd12e
feat: oval discovery improvements
md0x Jul 17, 2024
9783f18
feat: simplify call
md0x Jul 17, 2024
7d2017b
feat: improve oval discovery initialization
md0x Jul 17, 2024
28ba4fc
feat: data structure wallet manager
md0x Jul 18, 2024
8773050
feat: improve wallet manager selection criteria
md0x Jul 19, 2024
6654052
feat: add log to notify if key used multiple times
md0x Jul 19, 2024
31d21c5
feat: tests use public getWallet
md0x Jul 19, 2024
69b24fb
feat: encode unlock for Permission Proxy
md0x Jul 19, 2024
79fd454
feat: check that sender is correct
md0x Jul 19, 2024
8ab9061
feat: update permission call
md0x Jul 19, 2024
f2fb908
feat: refine comments
md0x Jul 19, 2024
6bb034a
fix: stub permission proxy call
md0x Jul 19, 2024
34679cb
feat: readme
md0x Jul 19, 2024
878e47d
fix: flashbots signature header verification
Reinis-FRP Jul 23, 2024
d814d73
feat: rename function and comments
md0x Jul 23, 2024
0460468
fix: flashbots signature header verification (#84)
Reinis-FRP Jul 23, 2024
5c77377
feat: add try catch
md0x Jul 23, 2024
fee339d
feat: simplify factory update logic
md0x Jul 23, 2024
54d3ed1
Merge branch 'development' into pablo/oval-shared-unlockers
md0x Jul 23, 2024
9ef3966
feat: remove contract types
md0x Jul 31, 2024
5a1c469
feat: ignore contract types
md0x Jul 31, 2024
fe07a88
feat: oval abi
md0x Jul 31, 2024
35bf78e
feat: oval discovery warm up log
md0x Jul 31, 2024
aeb58ae
feat: update oval node to support oval factory deployments (#83)
md0x Jul 31, 2024
85102e5
feat: fix start script
md0x Jul 31, 2024
b4f53f7
feat: fix start script (#85)
md0x Jul 31, 2024
1a85c59
feat: use shared configs in headers as well
md0x Aug 8, 2024
e607ef2
feat: use shared configs in headers as well (#86)
md0x Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
@@ -176,14 +176,12 @@ function isOvalConfig(input: unknown): input is OvalConfig {
typeof input === "object" &&
input !== null &&
!Array.isArray(input) &&
(
("unlockerKey" in input && typeof input["unlockerKey"] === "string" &&
((!input["unlockerKey"].startsWith("0x") && isHexString("0x" + input["unlockerKey"], 32)) ||
isHexString(input["unlockerKey"], 32)) &&
!("gckmsKeyId" in input)) ||
("gckmsKeyId" in input && typeof input["gckmsKeyId"] === "string" &&
!("unlockerKey" in input))
) &&
(("unlockerKey" in input &&
typeof input["unlockerKey"] === "string" &&
((!input["unlockerKey"].startsWith("0x") && isHexString("0x" + input["unlockerKey"], 32)) ||
isHexString(input["unlockerKey"], 32)) &&
!("gckmsKeyId" in input)) ||
("gckmsKeyId" in input && typeof input["gckmsKeyId"] === "string" && !("unlockerKey" in input))) &&
"refundAddress" in input &&
typeof input["refundAddress"] === "string" &&
isAddress(input["refundAddress"]) &&
@@ -204,7 +202,8 @@ function isOvalConfigs(input: unknown): input is OvalConfigs {
Object.keys(input).length === new Set(Object.keys(input)).size &&
Object.keys(input).every((key) => isAddress(key)) &&
Object.values(input).every((value) => isOvalConfig(value)) &&
Object.values(input).length === new Set(Object.values(input).map((value) => value.unlockerKey || value.gckmsKeyId)).size
Object.values(input).length ===
new Set(Object.values(input).map((value) => value.unlockerKey || value.gckmsKeyId)).size
);
}

@@ -283,16 +282,31 @@ export function verifyBundleSignature(
return null;
}

const bundleSignaturePublicKey = xFlashbotsSignatureHeader.split(":")[0];
const bundleSignedMessage = xFlashbotsSignatureHeader.split(":")[1];
const xFlashbotsSignatureHeaderParts = xFlashbotsSignatureHeader.split(":");
if (xFlashbotsSignatureHeaderParts.length !== 2) {
Logger.debug(
req.transactionId,
`Invalid signature header: ${xFlashbotsSignatureHeader}, expected address and signature separated by a colon`,
);
return null;
}

const bundleSignaturePublicKey = xFlashbotsSignatureHeaderParts[0];
if (!isAddress(bundleSignaturePublicKey)) {
Logger.debug(req.transactionId, `Invalid signature header: ${xFlashbotsSignatureHeader}, expected valid address`);
return null;
}
const bundleSignatureAddress = getAddress(bundleSignaturePublicKey);

const bundleSignedMessage = xFlashbotsSignatureHeaderParts[1];

const serializedBody = JSON.stringify(body);

const hash = ethers.id(serializedBody);

const recoveredAddress = ethers.verifyMessage(hash, bundleSignedMessage);

const verified = recoveredAddress === bundleSignaturePublicKey;
const verified = recoveredAddress === bundleSignatureAddress;

return verified ? recoveredAddress : null;
}
@@ -314,7 +328,7 @@ export class WalletManager {
private static instance: WalletManager;
private wallets: Record<string, Wallet> = {};

private constructor() { }
private constructor() {}

public static getInstance(): WalletManager {
if (!WalletManager.instance) {
@@ -346,4 +360,4 @@ export class WalletManager {
}
return this.wallets[checkSummedAddress].connect(provider);
}
}
}