-
Notifications
You must be signed in to change notification settings - Fork 2
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
CCIP-4474 manual exec lbtc #8
Conversation
Coverage Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting there!
src/lib/offchain.ts
Outdated
const attestations: (string | undefined)[] = [] | ||
for (const [i, _] of msg.tokenAmounts.entries()) { | ||
const destTokenData = parseSourceTokenData(msg.sourceTokenData[i]).extraData | ||
// If attestation is required, SourceTokenData.extraData will be 32 bytes ('0x' + 64 hex chars) | ||
// otherwise attestation is not required | ||
if (destTokenData.length !== 66) { | ||
attestations.push(undefined) | ||
continue | ||
} | ||
// check that this is LBTC indeed | ||
if (lbtcDepositHashes.includes(destTokenData)) { | ||
attestations.push(await getLbtcAttestation(destTokenData, isTestnet)) | ||
} | ||
} | ||
return attestations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function return usage requires exactly 1 entry per tokenAmount
, otherwise the align by index inside fetchOffchainTokenData
is not gonna work properly; But your loop here doesn't guarantee it'll return exactly tokenAmounts.length
entries (e.g. when destTokenData.length == 66
but lbtcDepositHashes
doesn't include it).
I'd suggest a Promise.all(tokenAmounts.map)
(which guarantees/expresses better 1-to-1 result), and inside, you do your checks/requests, return the result if you have it, and let it fall through to return undefined
in the end if some condition isn't met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/lib/offchain.ts
Outdated
|
||
type AttestationResponse = | ||
| { error: 'string' } | ||
| { status: 'pending_confirmations' } | ||
| { status: 'complete'; attestation: string } | ||
|
||
type LombardAttestation = { status: string; message_hash: string; attestation: string } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I see you compare status
here with some constant. You don't need to extract that const in a global var, but if you can get a small list of possible status, it'd be nice to hardcode them as a union of string literals here, as it'll aid the constant comparison down there.
type LombardAttestation = { status: string; message_hash: string; attestation: string } | |
type LombardAttestation = { status: string; message_hash: string; attestation: string } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on this implementation!
Can you add a CHANGELOG entry, please? |
Add lbtc manual exec feature. If destTokenData is more than 32 bytes - attestation is disabled onchain else - call lombard attestation api for a proof and include it as offchain token data
Add lbtc manual exec feature.
If destTokenData is more than 32 bytes - attestation is disabled onchain
else - call lombard attestation api for a proof and include it as offchain token data