Conversation
reednaa
left a comment
There was a problem hiding this comment.
A few nits. Ideally we simplify the library rather than add to it.
reednaa
left a comment
There was a problem hiding this comment.
The added files does not have test coverage unlike all other files in this repository.
Provide coverage of solanaStandard.spec.ts.
Here are a variety of agent findings:
src/intent/solanaStandard.ts
- The amount field in mandateInputSchema uses "u64" but borshEncodeSolanaOrder passes BigInt(order.input.amount) — this is fine for
u64, but the amount in mandateOutputSchema uses bytes32 (big-endian 32-byte encoding), which is inconsistent. Verify this matches
the SVM program's actual layout. - The standardOrderToSolanaOrder conversion only uses the first input (order.inputs[0]), silently dropping all others. A
StandardOrder can have multiple inputs — should this throw if inputs.length > 1 rather than silently truncating? - borshEncodeSolanaOrder is exported but not re-exported from src/intent/index.ts. Intentional or oversight?
src/intent/helpers/output-encoding.ts
- outputSettler is now computed per-output via getSettler?.(token.chainId) ?? COIN_FILLER — this is a meaningful behavioral change
for all EVM orders too (previously settled globally). Ensure no regression for existing EVM paths.
src/helpers/convert.ts
- The early-return guard for already-bytes32 addresses is reasonable, but a Solana address (base58 string) would fail silently or
produce wrong output if passed here. The comment says "Accept only EVM addresses here" but there's no enforcement — could confuse
callers
|
|
||
| export function addressToBytes32(address: `0x${string}`): `0x${string}` { | ||
| if (address.length === 66) return address; // already bytes32 with 0x prefix | ||
| if (address.length === 64) return `0x${address}`; // already bytes32 without 0x |
There was a problem hiding this comment.
Does this properly catch 64 length addresses prefixed with 0x?
I would rather use something like: 0x${address.replace("0x", "").padStart("0", 64)}
There was a problem hiding this comment.
yeah i think we should remove if (address.length === 64) also we don't need to check the address length in address.length !== 40 for EVM since we are already constraining the template with address: 0x${string} in the parameters.
| verifier, | ||
| sameChain, | ||
| recipient, | ||
| bytes32Recipient, |
There was a problem hiding this comment.
I don't like using bytes32Recipient since it seems inaccurate. I would rather continue using recipient and then add natspec that recipient has to be bytes32.
| if (lock.type === "solanaEscrow" && multichain === false) | ||
| return SOLANA_INPUT_SETTLER_ESCROW; |
There was a problem hiding this comment.
Why do we add a new lock type for Solana?
Why not add chain type or similar as the differentiator?
There was a problem hiding this comment.
Since we're following the structure anyway i believe it's a good idea to commit to everything
There was a problem hiding this comment.
what i'm also okay with is adding a field inside the lock that identifies the chain
| const currentTime = Math.floor(Date.now() / 1000); | ||
| const bytes32Recipient = this.outputRecipient ? addressToBytes32(this.outputRecipient) : addressToBytes32(this.walletUser); | ||
|
|
||
| if (this.lock.type === "solanaEscrow") { |
There was a problem hiding this comment.
See previous message. This does not seem correct.
| ]); | ||
|
|
||
| const currentTime = Math.floor(Date.now() / 1000); | ||
| const bytes32Recipient = this.outputRecipient ? addressToBytes32(this.outputRecipient) : addressToBytes32(this.walletUser); |
There was a problem hiding this comment.
No need for bytes32Recipient. Call it recipient and add comments
| asOrder(): TOrder; | ||
| inputChains(): bigint[]; | ||
| orderId(): `0x${string}`; | ||
| compactClaimHash(): `0x${string}`; |
There was a problem hiding this comment.
This is required. Add a handler for EVM vs Solana and then provide compactClaimHash if chain is identified as EVM.
| input: { | ||
| token: firstInput.token.address, | ||
| amount: firstInput.amount, | ||
| }, |
There was a problem hiding this comment.
Only 1 input? Please add verification for only 1.
There was a problem hiding this comment.
Yes solana supports only one, at least for now. I agree there should be length verification
|
|
||
| const outputSettler = COIN_FILLER; | ||
| return outputTokens.map(({ token, amount }) => { | ||
| const outputSettler = getSettler?.(token.chainId) ?? COIN_FILLER; |
There was a problem hiding this comment.
Potentially bad fallback for Solana consumers
|
|
||
| export function isStandardOrder(order: OrderLike): order is StandardOrder { | ||
| return "originChainId" in order; | ||
| return "originChainId" in order && "inputs" in order; |
There was a problem hiding this comment.
There is no way this works. Because multichain order has inputs.
There was a problem hiding this comment.
multichain does not have originChainId so there shouldn't be a problem with that
This PR supports:
It has been tested against the solana changes in lintent