mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-06-24 11:06:47 +00:00
Compare commits
8 Commits
xahau-bina
...
PriceOracl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0e8a9f294 | ||
|
|
0a531625ed | ||
|
|
503cf345a0 | ||
|
|
d89ee1abb3 | ||
|
|
bc8ae32ad0 | ||
|
|
79f952737b | ||
|
|
f84ac1f587 | ||
|
|
6a8408309e |
2
.github/workflows/nodejs.yml
vendored
2
.github/workflows/nodejs.yml
vendored
@@ -4,7 +4,7 @@
|
|||||||
name: Node.js CI
|
name: Node.js CI
|
||||||
|
|
||||||
env:
|
env:
|
||||||
XAHAUD_VERSION: 2026.6.21-release+3350
|
XAHAUD_VERSION: 2026.6.16-dev+3330
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -16048,7 +16048,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/xahau": {
|
"packages/xahau": {
|
||||||
"version": "4.1.0",
|
"version": "4.0.4",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@scure/bip32": "^1.3.1",
|
"@scure/bip32": "^1.3.1",
|
||||||
@@ -16058,7 +16058,7 @@
|
|||||||
"bignumber.js": "^9.0.0",
|
"bignumber.js": "^9.0.0",
|
||||||
"eventemitter3": "^5.0.1",
|
"eventemitter3": "^5.0.1",
|
||||||
"xahau-address-codec": "^5.0.0",
|
"xahau-address-codec": "^5.0.0",
|
||||||
"xahau-binary-codec": "^2.2.0",
|
"xahau-binary-codec": "^2.1.3",
|
||||||
"xahau-keypairs": "^2.0.0"
|
"xahau-keypairs": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -16091,7 +16091,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packages/xahau-binary-codec": {
|
"packages/xahau-binary-codec": {
|
||||||
"version": "2.2.0",
|
"version": "2.1.3",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@xrplf/isomorphic": "^1.0.1",
|
"@xrplf/isomorphic": "^1.0.1",
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
## 2.1.0 (2026-06-23)
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Support for the Price Oracles amendment (XLS-47).
|
* Support for the Price Oracles amendment (XLS-47).
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xahau-binary-codec",
|
"name": "xahau-binary-codec",
|
||||||
"version": "2.2.0",
|
"version": "2.1.3",
|
||||||
"description": "Xahau Network binary codec",
|
"description": "Xahau Network binary codec",
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# xahau.js Release History
|
# xrpl.js Release History
|
||||||
|
|
||||||
|
Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xrpl-announce) for release announcements. We recommend that xrpl.js (ripple-lib) users stay up-to-date with the latest stable release.
|
||||||
|
|
||||||
## Unreleased Changes
|
## Unreleased Changes
|
||||||
|
|
||||||
## 4.1.0 (2026-06-23)
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Support for HookOnV2 Amendment
|
* Support for HookOnV2 Amendment
|
||||||
* Support for IOUClaimReward Amendment
|
* Support for IOUClaimReward Amendment
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xahau",
|
"name": "xahau",
|
||||||
"version": "4.1.0",
|
"version": "4.0.4",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"description": "A TypeScript/JavaScript API for interacting with the Xahau Network in Node.js and the browser",
|
"description": "A TypeScript/JavaScript API for interacting with the Xahau Network in Node.js and the browser",
|
||||||
"files": [
|
"files": [
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
"bignumber.js": "^9.0.0",
|
"bignumber.js": "^9.0.0",
|
||||||
"eventemitter3": "^5.0.1",
|
"eventemitter3": "^5.0.1",
|
||||||
"xahau-address-codec": "^5.0.0",
|
"xahau-address-codec": "^5.0.0",
|
||||||
"xahau-binary-codec": "^2.2.0",
|
"xahau-binary-codec": "^2.1.3",
|
||||||
"xahau-keypairs": "^2.0.0"
|
"xahau-keypairs": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ class Client extends EventEmitter<EventTypes> {
|
|||||||
* @returns The autofilled transaction.
|
* @returns The autofilled transaction.
|
||||||
* @throws ValidationError If Amount and DeliverMax fields are not identical in a Payment 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>(
|
public async autofill<T extends SubmittableTransaction>(
|
||||||
transaction: T,
|
transaction: T,
|
||||||
signersCount?: number,
|
signersCount?: number,
|
||||||
@@ -681,34 +681,6 @@ class Client extends EventEmitter<EventTypes> {
|
|||||||
promises.push(setLatestValidatedLedgerSequence(this, tx))
|
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)
|
await Promise.all(promises).then(() => tx)
|
||||||
|
|
||||||
if (tx.Fee == null) {
|
if (tx.Fee == null) {
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
|
|
||||||
import { EscrowFinish, Payment, Transaction } from '../../src'
|
import { EscrowFinish, Payment, Transaction } from '../../src'
|
||||||
import { ValidationError } from '../../src/errors'
|
|
||||||
import xahaud from '../fixtures/xahaud'
|
import xahaud from '../fixtures/xahaud'
|
||||||
import {
|
import {
|
||||||
setupClient,
|
setupClient,
|
||||||
teardownClient,
|
teardownClient,
|
||||||
type XrplTestContext,
|
type XrplTestContext,
|
||||||
} from '../setupClient'
|
} from '../setupClient'
|
||||||
import { assertRejects } from '../testUtils'
|
|
||||||
|
|
||||||
const NetworkID = 1025
|
const NetworkID = 1025
|
||||||
const Fee = '10'
|
const Fee = '10'
|
||||||
@@ -17,8 +15,6 @@ const LastLedgerSequence = 2908734
|
|||||||
|
|
||||||
describe('client.autofill', function () {
|
describe('client.autofill', function () {
|
||||||
let testContext: XrplTestContext
|
let testContext: XrplTestContext
|
||||||
const AMOUNT = '1234'
|
|
||||||
let paymentTx: Payment
|
|
||||||
|
|
||||||
async function setupMockRippledVersionAndID(
|
async function setupMockRippledVersionAndID(
|
||||||
buildVersion: string,
|
buildVersion: string,
|
||||||
@@ -42,64 +38,6 @@ describe('client.autofill', function () {
|
|||||||
})
|
})
|
||||||
afterAll(async () => teardownClient(testContext))
|
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 () {
|
it('should not autofill if fields are present', async function () {
|
||||||
const tx: Transaction = {
|
const tx: Transaction = {
|
||||||
TransactionType: 'DepositPreauth',
|
TransactionType: 'DepositPreauth',
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { assert } from 'chai'
|
|
||||||
|
|
||||||
import { Payment, Wallet } from '../../../src'
|
import { Payment, Wallet } from '../../../src'
|
||||||
import serverUrl from '../serverUrl'
|
import serverUrl from '../serverUrl'
|
||||||
import {
|
import {
|
||||||
@@ -14,22 +12,9 @@ const TIMEOUT = 20000
|
|||||||
|
|
||||||
describe('Payment', function () {
|
describe('Payment', function () {
|
||||||
let testContext: XrplIntegrationTestContext
|
let testContext: XrplIntegrationTestContext
|
||||||
let paymentTx: Payment
|
|
||||||
const AMOUNT = '10000000'
|
|
||||||
// This wallet is used for DeliverMax related tests
|
// This wallet is used for DeliverMax related tests
|
||||||
let senderWallet: Wallet
|
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 () => {
|
beforeAll(async () => {
|
||||||
testContext = await setupClient(serverUrl)
|
testContext = await setupClient(serverUrl)
|
||||||
senderWallet = await generateFundedWallet(testContext.client)
|
senderWallet = await generateFundedWallet(testContext.client)
|
||||||
@@ -49,57 +34,4 @@ describe('Payment', function () {
|
|||||||
},
|
},
|
||||||
TIMEOUT,
|
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,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user