mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-07-06 06:40:21 +00:00
Compare commits
2 Commits
xahau-bina
...
xahau@4.1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6edc5a4a83 | ||
|
|
919315ef69 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -16048,7 +16048,7 @@
|
||||
}
|
||||
},
|
||||
"packages/xahau": {
|
||||
"version": "4.1.0",
|
||||
"version": "4.1.1",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@scure/bip32": "^1.3.1",
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
## Unreleased Changes
|
||||
|
||||
### 4.1.1 (2026-07-03)
|
||||
|
||||
### Fixed
|
||||
* Fix HookName validation on HookName deletion
|
||||
|
||||
## 4.1.0 (2026-06-23)
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xahau",
|
||||
"version": "4.1.0",
|
||||
"version": "4.1.1",
|
||||
"license": "ISC",
|
||||
"description": "A TypeScript/JavaScript API for interacting with the Xahau Network in Node.js and the browser",
|
||||
"files": [
|
||||
|
||||
@@ -79,7 +79,11 @@ export function validateSetHook(tx: Record<string, unknown>): void {
|
||||
`SetHook: HookNamespace in Hook must be a 256-bit (32-byte) hexadecimal value`,
|
||||
)
|
||||
}
|
||||
if (HookName !== undefined && !HOOKNAME_REGEX.test(HookName)) {
|
||||
if (
|
||||
HookName !== undefined &&
|
||||
HookName.length !== 0 &&
|
||||
!HOOKNAME_REGEX.test(HookName)
|
||||
) {
|
||||
throw new ValidationError(
|
||||
`SetHook: HookName in Hook must be a hex string of 8-32 hex characters`,
|
||||
)
|
||||
|
||||
@@ -135,4 +135,49 @@ describe('SetHook', function () {
|
||||
},
|
||||
TIMEOUT,
|
||||
)
|
||||
|
||||
it('hook name update', async () => {
|
||||
let setHookTx: SetHook = {
|
||||
TransactionType: 'SetHook',
|
||||
Account: wallet.classicAddress,
|
||||
Hooks: [
|
||||
{
|
||||
Hook: {
|
||||
CreateCode: acceptHook,
|
||||
HookApiVersion: 0,
|
||||
HookName: '484F4F4B',
|
||||
HookOn: '00'.repeat(32),
|
||||
HookNamespace: '00'.repeat(32),
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
await testTransaction(testContext.client, setHookTx, wallet)
|
||||
{
|
||||
const ledgerEntryResponse = await testContext.client.request({
|
||||
command: 'ledger_entry',
|
||||
hook: { account: wallet.classicAddress },
|
||||
})
|
||||
const node = ledgerEntryResponse.result.node as Hook
|
||||
const hook = node.Hooks[0].Hook
|
||||
expect(hook.HookName).toEqual('484F4F4B')
|
||||
}
|
||||
|
||||
// delete HookName
|
||||
setHookTx = {
|
||||
TransactionType: 'SetHook',
|
||||
Account: wallet.classicAddress,
|
||||
Hooks: [{ Hook: { HookName: '' } }],
|
||||
}
|
||||
await testTransaction(testContext.client, setHookTx, wallet)
|
||||
{
|
||||
const ledgerEntryResponse = await testContext.client.request({
|
||||
command: 'ledger_entry',
|
||||
hook: { account: wallet.classicAddress },
|
||||
})
|
||||
const node = ledgerEntryResponse.result.node as Hook
|
||||
const hook = node.Hooks[0].Hook
|
||||
expect(hook.HookName).toBeUndefined()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -175,7 +175,7 @@ describe('SetHook', function () {
|
||||
assert.throws(() => validate(setHookTx), ValidationError, errorMessage)
|
||||
})
|
||||
|
||||
it.each(['', '0'.repeat(7), '0'.repeat(33), 'ZZZZZZZZ'])(
|
||||
it.each(['00', '0000', '000000', '0'.repeat(7), '0'.repeat(33), 'ZZZZZZZZ'])(
|
||||
`throws w/ invalid HookName in Hooks: %s`,
|
||||
function (value: string) {
|
||||
setHookTx.Hooks = [
|
||||
@@ -195,4 +195,16 @@ describe('SetHook', function () {
|
||||
assert.throws(() => validate(setHookTx), ValidationError, errorMessage)
|
||||
},
|
||||
)
|
||||
|
||||
it(`valid HookName "" (deletion) in Hooks`, function () {
|
||||
setHookTx.Hooks = [
|
||||
{
|
||||
Hook: {
|
||||
HookName: '',
|
||||
},
|
||||
},
|
||||
]
|
||||
assert.doesNotThrow(() => validateSetHook(setHookTx))
|
||||
assert.doesNotThrow(() => validate(setHookTx))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user