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

Experiment/session bundler url #4649

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions packages/sign-client/src/controllers/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,19 @@
this.client.logger.error("request() -> isValidRequest() failed");
throw error;
}

const { chainId, request, topic, expiry = ENGINE_RPC_OPTS.wc_sessionRequest.req.ttl } = params;

const session = this.client.session.get(topic);

console.log(">>>> checking to intercept", {params, sessionProps: session.sessionProperties})

Check failure on line 460 in packages/sign-client/src/controllers/engine.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

Unexpected console statement
const intercepted = await this.interceptRequestIfConfigured(params, session.sessionProperties ?? {})
console.log(">>>> intercept", {intercepted})

Check failure on line 462 in packages/sign-client/src/controllers/engine.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

Unexpected console statement

if(intercepted) {
return intercepted
}

const clientRpcId = payloadId();
const relayRpcId = getBigIntRpcId().toString() as any;
const { done, resolve, reject } = createDelayedPromise<T>(
Expand Down Expand Up @@ -1030,6 +1041,44 @@

// ---------- Private Helpers --------------------------------------- //

private interceptGetCallsStatus = async (request: EngineTypes.RequestParams, sessionProperties: ProposalTypes.SessionProperties) => {
const bundlerUrl = sessionProperties.bundler_url;

const response = await fetch(bundlerUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formatJsonRpcRequest("eth_getUserOperationReceipt", [request.request.params[0]]))
})

const json = await response.json()

console.log(">>>>", {json})

Check failure on line 1057 in packages/sign-client/src/controllers/engine.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

Unexpected console statement

return json;
}

private interceptRequestIfConfigured = async (request: EngineTypes.RequestParams, sessionProperties: ProposalTypes.SessionProperties) => {

Check warning on line 1062 in packages/sign-client/src/controllers/engine.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

Async method 'interceptRequestIfConfigured' has no 'await' expression
const interceptableMethods = []
const interceptionMethods = {
["wallet_getCallsStatus"]: this.interceptGetCallsStatus
} as const;

if(Object.keys(sessionProperties).includes("bundler_url")) {
interceptableMethods.push("wallet_getCallsStatus")
}

console.log(">>>>", { interceptableMethods, method: request.request.method })

Check failure on line 1072 in packages/sign-client/src/controllers/engine.ts

View workflow job for this annotation

GitHub Actions / code_style (lint)

Unexpected console statement

if(interceptableMethods.includes(request.request.method)) {
return interceptionMethods[request.request.method](request, sessionProperties)
}

return null;
}


private cleanupDuplicatePairings: EnginePrivate["cleanupDuplicatePairings"] = async (
session: SessionTypes.Struct,
) => {
Expand Down
Loading