Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #53 from ar-io/PE-5003-add-sort-key
Browse files Browse the repository at this point in the history
feat(sortKey): add sortKey to contract response
  • Loading branch information
dtfiedler authored Nov 10, 2023
2 parents 6806e6a + 1a5e2b1 commit a934f6c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
ignores: [(message) => message.includes('[skip ci]')],
rules: {
'header-max-length': [0, 'always'],
'body-max-line-length': [0, 'always'],
},
};
7 changes: 5 additions & 2 deletions src/api/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ async function readThroughToContractState(
contractTxId,
cacheKey: cacheKey.toString(),
});
const { cachedValue } = await inFlightRequest;
const { cachedValue, sortKey } = await inFlightRequest;
return {
...cachedValue,
sortKey,
evaluationOptions,
};
}
Expand Down Expand Up @@ -182,14 +183,16 @@ async function readThroughToContractState(
});

// await the response
const { cachedValue } = await requestMap.get(cacheId);
const { cachedValue, sortKey } = await requestMap.get(cacheId);
logger?.debug('Successfully evaluated contract state.', {
contractTxId,
cacheKey: cacheKey.toString(),
sortKey,
});

return {
...cachedValue,
sortKey,
evaluationOptions,
};
}
Expand Down
3 changes: 2 additions & 1 deletion src/routes/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ export async function contractHandler(ctx: KoaContext, next: Next) {
logger.debug('Fetching contract state', {
contractTxId,
});
const { state, evaluationOptions } = await getContractState({
const { state, evaluationOptions, sortKey } = await getContractState({
contractTxId,
warp,
logger,
});
ctx.body = {
contractTxId,
state,
sortKey,
evaluationOptions,
};

Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export type ContractReservedResponse = ContractBaseResponse & {
// Warp types

export type EvaluatedContractState = EvalStateResult<any> & {

Check warning on line 71 in src/types.ts

View workflow job for this annotation

GitHub Actions / build (lint:check)

Unexpected any. Specify a different type
evaluationOptions?: Partial<EvaluationOptions>;
evaluationOptions: Partial<EvaluationOptions>;
sortKey: string;
};

export type EvaluatedReadInteraction = {
Expand Down

0 comments on commit a934f6c

Please sign in to comment.