Compare commits

..

8 Commits

Author SHA1 Message Date
tequ
b0e8a9f294 after fixPriceOracleOrder 2026-06-18 22:25:25 +09:00
tequ
0a531625ed update fixture 2026-06-18 21:46:01 +09:00
tequ
503cf345a0 disable max-lines worning 2026-06-18 21:32:59 +09:00
Chenna Keshava B S
d89ee1abb3 fix #2911: Update OracleSet transaction model, unit, integ tests (#2913)
* fix #2911: Update OracleSet transaction model, unit, integ tests

---------

Co-authored-by: Omar Khan <khancodegt@gmail.com>
2026-06-18 21:25:36 +09:00
Omar Khan
bc8ae32ad0 feat: add input check for OracleSet params AssetPrice and Scale (#2699)
* add input check for AssetPrice and Scale being either both present or excluded
2026-06-18 21:24:53 +09:00
tequ
79f952737b fix definitions.json 2026-06-18 21:23:38 +09:00
tequ
f84ac1f587 Merge remote-tracking branch 'upstream/main-xahau' into PriceOracle 2026-06-18 21:20:11 +09:00
Omar Khan
6a8408309e feat: add Price Oracles support (#2688) 2026-06-18 21:19:49 +09:00
6 changed files with 7 additions and 165 deletions

6
package-lock.json generated
View File

@@ -16048,7 +16048,7 @@
}
},
"packages/xahau": {
"version": "4.1.0-alpha.0",
"version": "4.0.4",
"license": "ISC",
"dependencies": {
"@scure/bip32": "^1.3.1",
@@ -16058,7 +16058,7 @@
"bignumber.js": "^9.0.0",
"eventemitter3": "^5.0.1",
"xahau-address-codec": "^5.0.0",
"xahau-binary-codec": "^2.2.0-alpha.0",
"xahau-binary-codec": "^2.1.3",
"xahau-keypairs": "^2.0.0"
},
"devDependencies": {
@@ -16091,7 +16091,7 @@
}
},
"packages/xahau-binary-codec": {
"version": "2.2.0-alpha.0",
"version": "2.1.3",
"license": "ISC",
"dependencies": {
"@xrplf/isomorphic": "^1.0.1",

View File

@@ -1,6 +1,6 @@
{
"name": "xahau-binary-codec",
"version": "2.2.0-alpha.0",
"version": "2.1.3",
"description": "Xahau Network binary codec",
"files": [
"dist/*",

View File

@@ -1,6 +1,6 @@
{
"name": "xahau",
"version": "4.1.0-alpha.0",
"version": "4.0.4",
"license": "ISC",
"description": "A TypeScript/JavaScript API for interacting with the Xahau Network in Node.js and the browser",
"files": [
@@ -29,7 +29,7 @@
"bignumber.js": "^9.0.0",
"eventemitter3": "^5.0.1",
"xahau-address-codec": "^5.0.0",
"xahau-binary-codec": "^2.2.0-alpha.0",
"xahau-binary-codec": "^2.1.3",
"xahau-keypairs": "^2.0.0"
},
"devDependencies": {

View File

@@ -660,7 +660,7 @@ class Client extends EventEmitter<EventTypes> {
* @returns The autofilled transaction.
* @throws ValidationError If Amount and DeliverMax fields are not identical in a Payment Transaction
*/
// eslint-disable-next-line complexity -- handling Payment transaction API v2 requires more logic
public async autofill<T extends SubmittableTransaction>(
transaction: T,
signersCount?: number,
@@ -681,34 +681,6 @@ class Client extends EventEmitter<EventTypes> {
promises.push(setLatestValidatedLedgerSequence(this, tx))
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
if (tx.TransactionType === 'Payment' && tx.DeliverMax != null) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- This is a valid null check for Amount
if (tx.Amount == null) {
// If only DeliverMax is provided, use it to populate the Amount field
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- DeliverMax is a known RPC-level property
tx.Amount = tx.DeliverMax
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- This is a valid null check for Amount
if (tx.Amount != null && tx.Amount !== tx.DeliverMax) {
return Promise.reject(
new ValidationError(
'PaymentTransaction: Amount and DeliverMax fields must be identical when both are provided',
),
)
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
// @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
delete tx.DeliverMax
}
await Promise.all(promises).then(() => tx)
if (tx.Fee == null) {

View File

@@ -1,14 +1,12 @@
import { assert } from 'chai'
import { EscrowFinish, Payment, Transaction } from '../../src'
import { ValidationError } from '../../src/errors'
import xahaud from '../fixtures/xahaud'
import {
setupClient,
teardownClient,
type XrplTestContext,
} from '../setupClient'
import { assertRejects } from '../testUtils'
const NetworkID = 1025
const Fee = '10'
@@ -17,8 +15,6 @@ const LastLedgerSequence = 2908734
describe('client.autofill', function () {
let testContext: XrplTestContext
const AMOUNT = '1234'
let paymentTx: Payment
async function setupMockRippledVersionAndID(
buildVersion: string,
@@ -42,64 +38,6 @@ describe('client.autofill', function () {
})
afterAll(async () => teardownClient(testContext))
beforeEach(async () => {
paymentTx = {
TransactionType: 'Payment',
Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
Amount: AMOUNT,
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
DestinationTag: 1,
Fee: '12',
Flags: 2147483648,
LastLedgerSequence: 65953073,
Sequence: 65923914,
SigningPubKey:
'02F9E33F16DF9507705EC954E3F94EB5F10D1FC4A354606DBE6297DBB1096FE654',
TxnSignature:
'3045022100E3FAE0EDEC3D6A8FF6D81BC9CF8288A61B7EEDE8071E90FF9314CB4621058D10022043545CF631706D700CEE65A1DB83EFDD185413808292D9D90F14D87D3DC2D8CB',
InvoiceID:
'6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
Paths: [
[{ currency: 'BTC', issuer: 'r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X' }],
],
SendMax: '100000000',
}
})
it('Validate Payment transaction API v2: Payment Transaction: Specify Only Amount field', async function () {
const txResult = await testContext.client.autofill(paymentTx)
assert.strictEqual(txResult.Amount, AMOUNT)
})
it('Validate Payment transaction API v2: Payment Transaction: Specify Only DeliverMax field', async function () {
// @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
paymentTx.DeliverMax = paymentTx.Amount
// @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
delete paymentTx.Amount
const txResult = await testContext.client.autofill(paymentTx)
assert.strictEqual(txResult.Amount, AMOUNT)
})
it('Validate Payment transaction API v2: Payment Transaction: identical DeliverMax and Amount fields', async function () {
// @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
paymentTx.DeliverMax = paymentTx.Amount
const txResult = await testContext.client.autofill(paymentTx)
assert.strictEqual(txResult.Amount, AMOUNT)
assert.strictEqual('DeliverMax' in txResult, false)
})
it('Validate Payment transaction API v2: Payment Transaction: differing DeliverMax and Amount fields', async function () {
// @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
paymentTx.DeliverMax = '6789'
paymentTx.Amount = '1234'
await assertRejects(testContext.client.autofill(paymentTx), ValidationError)
})
it('should not autofill if fields are present', async function () {
const tx: Transaction = {
TransactionType: 'DepositPreauth',

View File

@@ -1,5 +1,3 @@
import { assert } from 'chai'
import { Payment, Wallet } from '../../../src'
import serverUrl from '../serverUrl'
import {
@@ -14,22 +12,9 @@ const TIMEOUT = 20000
describe('Payment', function () {
let testContext: XrplIntegrationTestContext
let paymentTx: Payment
const AMOUNT = '10000000'
// This wallet is used for DeliverMax related tests
let senderWallet: Wallet
beforeEach(async () => {
// this payment transaction JSON needs to be refreshed before every test.
// Because, we tinker with Amount and DeliverMax fields in the API v2 tests
paymentTx = {
TransactionType: 'Payment',
Account: senderWallet.classicAddress,
Amount: AMOUNT,
Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
}
})
beforeAll(async () => {
testContext = await setupClient(serverUrl)
senderWallet = await generateFundedWallet(testContext.client)
@@ -49,57 +34,4 @@ describe('Payment', function () {
},
TIMEOUT,
)
it(
'Validate Payment transaction API v2: Payment Transaction: Specify Only Amount field',
async () => {
const result = await testTransaction(
testContext.client,
paymentTx,
senderWallet,
)
assert.equal(result.result.engine_result_code, 0)
assert.equal((result.result.tx_json as Payment).Amount, AMOUNT)
},
TIMEOUT,
)
it(
'Validate Payment transaction API v2: Payment Transaction: Specify Only DeliverMax field',
async () => {
// @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
paymentTx.DeliverMax = paymentTx.Amount
// @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
delete paymentTx.Amount
const result = await testTransaction(
testContext.client,
paymentTx,
senderWallet,
)
assert.equal(result.result.engine_result_code, 0)
assert.equal((result.result.tx_json as Payment).Amount, AMOUNT)
},
TIMEOUT,
)
it(
'Validate Payment transaction API v2: Payment Transaction: identical DeliverMax and Amount fields',
async () => {
// @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
paymentTx.DeliverMax = paymentTx.Amount
const result = await testTransaction(
testContext.client,
paymentTx,
senderWallet,
)
assert.equal(result.result.engine_result_code, 0)
assert.equal((result.result.tx_json as Payment).Amount, AMOUNT)
},
TIMEOUT,
)
})