Skip to content

Asem/v2 109/solana orders#3

Open
Asem-Abdelhady wants to merge 7 commits intomainfrom
asem/V2-109/solana-orders
Open

Asem/v2 109/solana orders#3
Asem-Abdelhady wants to merge 7 commits intomainfrom
asem/V2-109/solana-orders

Conversation

@Asem-Abdelhady
Copy link

@Asem-Abdelhady Asem-Abdelhady commented Mar 9, 2026

This PR supports:

  • Solana orders
  • Solans orders id deriviation

It has been tested against the solana changes in lintent

@Asem-Abdelhady Asem-Abdelhady requested a review from reednaa March 9, 2026 21:55
Copy link
Member

@reednaa reednaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits. Ideally we simplify the library rather than add to it.

@Asem-Abdelhady Asem-Abdelhady requested a review from reednaa March 11, 2026 10:17
Copy link
Member

@reednaa reednaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this properly catch 64 length addresses prefixed with 0x?

I would rather use something like: 0x${address.replace("0x", "").padStart("0", 64)}

Copy link
Author

@Asem-Abdelhady Asem-Abdelhady Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree

Comment on lines +30 to +31
if (lock.type === "solanaEscrow" && multichain === false)
return SOLANA_INPUT_SETTLER_ESCROW;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we add a new lock type for Solana?

Why not add chain type or similar as the differentiator?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're following the structure anyway i believe it's a good idea to commit to everything

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for bytes32Recipient. Call it recipient and add comments

asOrder(): TOrder;
inputChains(): bigint[];
orderId(): `0x${string}`;
compactClaimHash(): `0x${string}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required. Add a handler for EVM vs Solana and then provide compactClaimHash if chain is identified as EVM.

Comment on lines +121 to +124
input: {
token: firstInput.token.address,
amount: firstInput.amount,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 1 input? Please add verification for only 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way this works. Because multichain order has inputs.

Copy link
Author

@Asem-Abdelhady Asem-Abdelhady Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

multichain does not have originChainId so there shouldn't be a problem with that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants