Skip to content

Typescript and E2e tests#7

Merged
sasurobert merged 16 commits intomainfrom
e2e-tests
Jan 28, 2026
Merged

Typescript and E2e tests#7
sasurobert merged 16 commits intomainfrom
e2e-tests

Conversation

@sasurobert
Copy link
Owner

Description

Tests

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits

@@ -81,17 +112,4 @@ export class ExactMultiversXServer implements ISchemeNetworkServer {

return req

Choose a reason for hiding this comment

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

In the go implementation we have the following logic - we should mirror this

if _, ok := reqCopy.Extra["assetTransferMethod"]; !ok {
		if reqCopy.Asset == multiversx.NativeTokenTicker {
			reqCopy.Extra["assetTransferMethod"] = multiversx.TransferMethodDirect
		} else {
			reqCopy.Extra["assetTransferMethod"] = multiversx.TransferMethodESDT
		}
	}

	if _, ok := reqCopy.Extra["gasLimit"]; !ok {
		if reqCopy.Extra["assetTransferMethod"] == multiversx.TransferMethodDirect {
			reqCopy.Extra["gasLimit"] = uint64(multiversx.GasLimitStandard)
		} else {
			reqCopy.Extra["gasLimit"] = uint64(multiversx.GasLimitESDT)
		}
	}

Choose a reason for hiding this comment

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

plus the checks in ValidatePaymentRequirements

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

const numericValue = parseFloat(cleanPrice)

if (!isNaN(numericValue)) {
// Convert USD to EGLD base units (18 decimals)

Choose a reason for hiding this comment

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

should remove the reasoning comments

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

*/
async parsePrice(price: unknown, _network: string): Promise<{ asset: string; amount: string }> {
async parsePrice(price: Price, _network: Network): Promise<AssetAmount> {
// Handle Price parsing similar to Go "ParsePrice"

Choose a reason for hiding this comment

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

Should remove the reasoning here

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

asset = typeof p.asset === 'string' ? p.asset : 'EGLD'
} else if (typeof price === 'string') {
amount = price // Assume EGLD if just amount string? Or error?
// Handle dollar format like "$0.001"

Choose a reason for hiding this comment

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

We should mirror the go implementation and accept all the same formats

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

x402Version: number,
paymentRequirements: PaymentRequirements,
): Promise<Pick<PaymentPayload, 'x402Version' | 'payload'>> {
if (!paymentRequirements.payTo) {

Choose a reason for hiding this comment

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

Plase mirror go improvements:

  1. Constants for ChainIds and Api Urls
  2. Relayed vs Non-Relayed transaction based on the assetTransferMethod field
  3. Refactor the big if/else condition in function calls so the code would be easier to read

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

gasPrice: BigInt(gasPrice),
data: new TransactionPayload(dataString),
chainID: chainRef,
version: 2,

Choose a reason for hiding this comment

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

missing version handling based on relayed vs non-relayed

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

})

if (relayer) {
// Future work: set relayer semantics if supported by SDK transaction object

Choose a reason for hiding this comment

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

I don't understand what should have been here

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

*/
constructor(private apiUrl: string = 'https://devnet-api.multiversx.com') {}
constructor(
private apiUrl: string = 'https://devnet-api.multiversx.com',

Choose a reason for hiding this comment

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

Use a constant here

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

relayerSignature: relayerSig, // might be empty
}

const response = await fetch(`${this.apiUrl}/transaction/simulate`, {

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

const pollIntervalMs = 2000
const startTime = Date.now()

while (Date.now() - startTime < timeoutMs) {

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

@sasurobert sasurobert merged commit 926eddd into main Jan 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants