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

Add Lit Protocol PKP Wallet Support #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
30 changes: 22 additions & 8 deletions packages/pkh-ethereum/src/authmethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,30 @@ async function createCACAO(
chainId: account.chainId.reference,
resources: opts.resources,
})
const signature = await safeSend(ethProvider, 'personal_sign', [
siweMessage.signMessage(),
account.address,
])
siweMessage.signature = signature
return Cacao.fromSiweMessage(siweMessage)
}

let payload = {
method: 'personal_sign',
params: [
siweMessage.signMessage(),
account.address,
],
}

let signature = 'rpcProvider' in ethProvider ? await ethProvider.sendAsync(payload) : await safeSend(ethProvider, payload.method, payload.params);

siweMessage.signature = signature
return Cacao.fromSiweMessage(siweMessage)
}

async function requestChainId(provider: any): Promise<number> {
const chainIdHex = (await safeSend(provider, 'eth_chainId', [])) as string

let payload = {
method: 'eth_chainId',
params: [],
};

let chainIdHex = 'rpcProvider' in provider ? await provider.sendAsync(payload) : await safeSend(provider, payload.method, payload.params);

return parseInt(chainIdHex, 16)
}

Expand Down