Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

Run this command to locally compile an XAHL Hook source file (inside ./contracts) from .c to .wasm code:

`$ hooks-cli compile-c contracts-c build`
`$ hooks-cli compile-c contracts-c/toolbox build`
`$ hooks-cli compile-c contracts-c/txns build`

You can also build a single hook with;

Expand Down Expand Up @@ -46,4 +47,4 @@ Run JS Hooks Integration tests

Run single JS Hooks Integration test

`$ yarn run test:integration-js test/integration-js/toolbox/base.test.ts`
`$ yarn run test:integration-js test/integration-js/toolbox/base.test.ts`
7 changes: 6 additions & 1 deletion src/Xrpld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ export class Xrpld {
txResponse?.result?.meta as TransactionMetadata
)
if (hookExecutions.executions.length === 1) {
let returnCode = BigInt(
`0x${hookExecutions.executions[0].HookReturnCode}`
)
if (returnCode & 0x8000000000000000n)
returnCode = -(returnCode & ~0x8000000000000000n)
throw Error(
`${hookExecutions.executions[0].HookReturnCode}: ${hookExecutions.executions[0].HookReturnString}`
`${returnCode}: ${hookExecutions.executions[0].HookReturnString}`
)
}
throw Error(JSON.stringify(hookExecutions.executions))
Expand Down
2 changes: 1 addition & 1 deletion src/models/iHookExecutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface iHookExecution {
HookHash: string
HookInstructionCount: string
HookResult: number
HookReturnCode: number
HookReturnCode: string
HookReturnString: string
HookStateChangeCount: number
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration-c/hooks/toolbox/filterOnXrp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('filterOnXrp', () => {
} catch (error: unknown) {
if (error instanceof Error) {
expect(error.message).toEqual(
'e: filter_on_xrp: Ignoring non XAH Transaction'
'14: filter_on_xrp: Ignoring non XAH Transaction'
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration-c/hooks/toolbox/hookOnTT.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('hookOnTT', () => {
} catch (error: unknown) {
if (error instanceof Error) {
expect(error.message).toEqual(
'f: hook_on_tt: HookOn field is incorrectly set.'
'15: hook_on_tt: HookOn field is incorrectly set.'
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/integration-c/hooks/toolbox/stateForeignBasic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('stateForeignBasic', () => {
})
} catch (error: any) {
expect(error.message).toEqual(
'22: state_foreign_basic: Could not get foreign state'
'34: state_foreign_basic: Could not get foreign state'
)
}
})
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('stateForeignBasic', () => {
})
} catch (error: any) {
expect(error.message).toEqual(
'22: state_foreign_basic: Could not get foreign state'
'34: state_foreign_basic: Could not get foreign state'
)
}
})
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('stateForeignBasic', () => {
})
} catch (error: any) {
expect(error.message).toEqual(
'27: state_foreign_basic: Could not set foreign state'
'39: state_foreign_basic: Could not set foreign state'
)
}
})
Expand Down
4 changes: 2 additions & 2 deletions test/integration-c/hooks/toolbox/utilSha512.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('utilSha512', () => {
tx: builtTx,
})
} catch (error: any) {
expect(error.message).toEqual('35: util_sha512: Hashes do not match')
expect(error.message).toEqual('53: util_sha512: Hashes do not match')
}
})

Expand Down Expand Up @@ -170,7 +170,7 @@ describe('utilSha512', () => {
tx: builtTx,
})
} catch (error: any) {
expect(error.message).toEqual('35: util_sha512: Hashes do not match')
expect(error.message).toEqual('53: util_sha512: Hashes do not match')
}
})

Expand Down
2 changes: 1 addition & 1 deletion test/integration-js/hooks/toolbox/hookOnTT.js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('hookOnTT', () => {
} catch (error: unknown) {
if (error instanceof Error) {
expect(error.message).toEqual(
'8000000000000025: hookOnTT.ts: HookOn field is incorrectly set.'
'-37: hookOnTT.ts: HookOn field is incorrectly set.'
)
}
}
Expand Down
Loading