Skip to content

Commit

Permalink
feat(node)!: return time as Date instance
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Node returns time in KeyBlock and MicroBlockHeader as Date
Apply a change
```diff
-const time = new Date(
-  (await node.getTopHeader()).time,
-);
+const time = (await node.getTopHeader()).time;
```
  • Loading branch information
davidyuk committed Aug 16, 2024
1 parent e48ffd1 commit e0e33ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/integration/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ describe('Node client', () => {
}));
});

it('returns time as Date', async () => {
const block = await node.getTopHeader();
expect(block.time).to.be.instanceOf(Date);
expect(block.time.getFullYear()).to.be.within(2024, 2030);
});

it('doesn\'t remember failed version request', async () => {
let shouldFail = true;
class CustomNode extends Node {
Expand Down
9 changes: 9 additions & 0 deletions tooling/autorest/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ directive:
throw errors even for explained response with not 200 code
https://github.com/Azure/autorest.typescript/issues/463#issuecomment-524203041
- from: openapi-document
where: $..properties.time
set:
type: 'integer'
format: 'unixtime'
reason: >
Convert time as milliseconds to dates
https://github.com/aeternity/aeternity/issues/4386
- from: openapi-document
where: $.components.schemas
transform: >
Expand Down

0 comments on commit e0e33ea

Please sign in to comment.