From f9d33d6dbb80251ca4181600a94bea55cad777fb Mon Sep 17 00:00:00 2001 From: Anurag Date: Sat, 20 Sep 2025 01:00:18 +0530 Subject: [PATCH 1/2] Add hashOracle utility hash function --- packages/xrpl/src/utils/hashes/README.md | 4 ++++ packages/xrpl/src/utils/hashes/index.ts | 16 ++++++++++++++++ packages/xrpl/src/utils/hashes/ledgerSpaces.ts | 1 + packages/xrpl/src/utils/index.ts | 2 ++ packages/xrpl/test/utils/hashes.test.ts | 11 +++++++++++ 5 files changed, 34 insertions(+) diff --git a/packages/xrpl/src/utils/hashes/README.md b/packages/xrpl/src/utils/hashes/README.md index 89ff79b13e..faa347fdca 100644 --- a/packages/xrpl/src/utils/hashes/README.md +++ b/packages/xrpl/src/utils/hashes/README.md @@ -60,6 +60,10 @@ Compute the hash of a ledger. Compute the hash of an escrow, given the owner's classic address (starting with `r`) and the account sequence number of the `EscrowCreate` escrow transaction. +### hashOracle = (address, documentId): string + +Compute the hash of an oracle, given the owner's classic address (starting with `r`) and the OracleDocumentID of the `OracleSet` transaction. + ### hashPaymentChannel = (address, dstAddress, sequence): string Compute the hash of a payment channel, given the owner's classic address (starting with `r`), the classic address of the destination, and the account sequence number of the `PaymentChannelCreate` payment channel transaction. diff --git a/packages/xrpl/src/utils/hashes/index.ts b/packages/xrpl/src/utils/hashes/index.ts index 9d32f6bfa1..c91a66d706 100644 --- a/packages/xrpl/src/utils/hashes/index.ts +++ b/packages/xrpl/src/utils/hashes/index.ts @@ -163,6 +163,22 @@ export function hashEscrow(address: string, sequence: number): string { ) } +/** + * Compute the Hash of an Oracle LedgerEntry. + * + * @param address - Address of the owner of the Oracle. + * @param documentId - OracleDocumentID of the Oracle. + * @returns The hash of the Oracle LedgerEntry. + * @category Utilities + */ +export function hashOracle(address: string, documentId: number): string { + return sha512Half( + ledgerSpaceHex('oracle') + + addressToHex(address) + + documentId.toString(HEX).padStart(BYTE_LENGTH * 2, '0'), + ) +} + /** * Compute the hash of a Payment Channel. * diff --git a/packages/xrpl/src/utils/hashes/ledgerSpaces.ts b/packages/xrpl/src/utils/hashes/ledgerSpaces.ts index e2af0c6aae..1f47775b6c 100644 --- a/packages/xrpl/src/utils/hashes/ledgerSpaces.ts +++ b/packages/xrpl/src/utils/hashes/ledgerSpaces.ts @@ -17,6 +17,7 @@ const ledgerSpaces = { offer: 'o', // Directory of things owned by an account. ownerDir: 'O', + oracle: 'R', // Directory of order books. bookDir: 'B', contract: 'c', diff --git a/packages/xrpl/src/utils/index.ts b/packages/xrpl/src/utils/index.ts index 2304384e90..6877611166 100644 --- a/packages/xrpl/src/utils/index.ts +++ b/packages/xrpl/src/utils/index.ts @@ -45,6 +45,7 @@ import { hashLedger, hashLedgerHeader, hashEscrow, + hashOracle, hashPaymentChannel, } from './hashes' import parseNFTokenID from './parseNFTokenID' @@ -178,6 +179,7 @@ const hashes = { hashLedger, hashLedgerHeader, hashEscrow, + hashOracle, hashPaymentChannel, } diff --git a/packages/xrpl/test/utils/hashes.test.ts b/packages/xrpl/test/utils/hashes.test.ts index 6b75989de4..b4cdf14137 100644 --- a/packages/xrpl/test/utils/hashes.test.ts +++ b/packages/xrpl/test/utils/hashes.test.ts @@ -16,6 +16,7 @@ import { hashTxTree, hashTrustline, hashEscrow, + hashOracle, hashPaymentChannel, hashSignedTx, hashAccountRoot, @@ -138,6 +139,16 @@ describe('Hashes', function () { assert.equal(actualEntryHash, expectedEntryHash) }) + it('calcOracleEntryHash', function () { + const account = 'rsNvoAZ9MquZSRhu4cEY9wTv1VqHXpVPPt' + const documentId = 1 + const expectedEntryHash = + 'D463D13ACF77206306BE891DF410655213FBD2C1F2B58A492E7F556A41A44338' + const actualEntryHash = hashOracle(account, documentId) + + assert.equal(actualEntryHash, expectedEntryHash) + }) + it('calcPaymentChannelEntryHash', function () { const account = 'rDx69ebzbowuqztksVDmZXjizTd12BVr4x' const dstAccount = 'rLFtVprxUEfsH54eCWKsZrEQzMDsx1wqso' From 118c2a537ca9f1747650f461cea7df4e34a523da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:38:15 +0000 Subject: [PATCH 2/2] build(deps-dev): bump eslint from 9.35.0 to 9.38.0 Bumps [eslint](https://github.com/eslint/eslint) from 9.35.0 to 9.38.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Commits](https://github.com/eslint/eslint/compare/v9.35.0...v9.38.0) --- updated-dependencies: - dependency-name: eslint dependency-version: 9.38.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 60 +++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3e6a7b2cda..fdf51c7db5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -613,11 +613,13 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.21.0", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.1.tgz", + "integrity": "sha512-aw1gNayWpdI/jSYVgzN5pL0cfzU02GT3NBpeT/DXbx1/1x7ZKxFPd9bwrzygx/qiwIQiJ1sw/zD8qY/kRvlGHA==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/object-schema": "^2.1.6", + "@eslint/object-schema": "^2.1.7", "debug": "^4.3.1", "minimatch": "^3.1.2" }, @@ -627,6 +629,8 @@ }, "node_modules/@eslint/config-array/node_modules/brace-expansion": { "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { @@ -636,6 +640,8 @@ }, "node_modules/@eslint/config-array/node_modules/minimatch": { "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "license": "ISC", "dependencies": { @@ -646,19 +652,22 @@ } }, "node_modules/@eslint/config-helpers": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.1.tgz", - "integrity": "sha512-xR93k9WhrDYpXHORXpxVL5oHj3Era7wo6k/Wd8/IsQNnZUTzkGS29lyn3nAT05v6ltUuTFVCCYDEGfy2Or/sPA==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.1.tgz", + "integrity": "sha512-csZAzkNhsgwb0I/UAV6/RGFTbiakPCf0ZrGmrIxQpYvGZ00PhTkSnyKNolphgIvmnJeGw6rcGVEXfTzUnFuEvw==", "dev": true, "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.16.0" + }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/core": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.2.tgz", - "integrity": "sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==", + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.16.0.tgz", + "integrity": "sha512-nmC8/totwobIiFcGkDza3GIKfAw1+hLiYVrh3I1nIomQ8PEr5cxg34jnkmGawul/ep52wGRAcyeDCNtWKSOj4Q==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -722,9 +731,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.35.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.35.0.tgz", - "integrity": "sha512-30iXE9whjlILfWobBkNerJo+TXYsgVM5ERQwMcMKCHckHflCmf7wXDAHlARoWnh0s1U72WqlbeyE7iAcCzuCPw==", + "version": "9.38.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.38.0.tgz", + "integrity": "sha512-UZ1VpFvXf9J06YG9xQBdnzU+kthors6KjhMAl6f4gH4usHyh31rUf2DLGInT8RFYIReYXNSydgPY0V2LuWgl7A==", "dev": true, "license": "MIT", "engines": { @@ -735,7 +744,9 @@ } }, "node_modules/@eslint/object-schema": { - "version": "2.1.6", + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", "dev": true, "license": "Apache-2.0", "engines": { @@ -743,13 +754,13 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.5.tgz", - "integrity": "sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.0.tgz", + "integrity": "sha512-sB5uyeq+dwCWyPi31B2gQlVlo+j5brPlWx4yZBrEaRo/nhdDE8Xke1gsGgtiBdaBTxuTkceLVuVt/pclrasb0A==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/core": "^0.15.2", + "@eslint/core": "^0.16.0", "levn": "^0.4.1" }, "engines": { @@ -5914,25 +5925,24 @@ } }, "node_modules/eslint": { - "version": "9.35.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.35.0.tgz", - "integrity": "sha512-QePbBFMJFjgmlE+cXAlbHZbHpdFVS2E/6vzCy7aKlebddvl1vadiC4JFV5u/wqTkNUwEV8WrQi257jf5f06hrg==", + "version": "9.38.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.38.0.tgz", + "integrity": "sha512-t5aPOpmtJcZcz5UJyY2GbvpDlsK5E8JqRqoKtfiKE3cNh437KIqfJr3A3AKf5k64NPx6d0G3dno6XDY05PqPtw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.21.0", - "@eslint/config-helpers": "^0.3.1", - "@eslint/core": "^0.15.2", + "@eslint/config-array": "^0.21.1", + "@eslint/config-helpers": "^0.4.1", + "@eslint/core": "^0.16.0", "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.35.0", - "@eslint/plugin-kit": "^0.3.5", + "@eslint/js": "9.38.0", + "@eslint/plugin-kit": "^0.4.0", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", - "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.6",