Skip to content

Commit

Permalink
feat: publish 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nachomazzara committed Apr 11, 2020
1 parent 08f254c commit 799d401
Show file tree
Hide file tree
Showing 8 changed files with 2,912 additions and 7,838 deletions.
79 changes: 79 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:8

working_directory: /tmp/eth-block-timestamp

steps:
- checkout
- restore_cache:
keys:
- dependencies-{{ checksum "package-lock.json" }}
- run:
name: Install node dependencies
command: npm install
- save_cache:
paths:
- node_modules
key: dependencies-{{ checksum "package-lock.json" }}
- run:
name: Build library
command: npm run build:lib
- save_cache:
paths:
- dist
key: dist-{{ .Branch }}-{{ .Revision }}

test:
docker:
- image: circleci/node:8-browsers
environment:
CHROME_BIN: '/usr/bin/google-chrome'
- image: ethereum/client-go
command: |
--identity="TEST_NODE"
--networkid="53611"
--rpc
--rpcaddr 0.0.0.0
--rpcapi admin,debug,eth,miner,net,personal,shh,txpool,web3
--ws
--wsaddr 0.0.0.0
--wsapi admin,debug,eth,miner,net,personal,shh,txpool,web3
--wsorigins "*"
--mine
--minerthreads=1
--dev
working_directory: /tmp/eth-block-timestamp

steps:
- checkout
- setup_remote_docker:
version: 17.05.0-ce
- restore_cache:
keys:
- dependencies-{{ checksum "package-lock.json" }}
- run:
name: Install node dependencies
command: npm install
- save_cache:
paths:
- node_modules
key: dependencies-{{ checksum "package-lock.json" }}
- restore_cache:
keys:
- dist-{{ .Branch }}-{{ .Revision }}
- run:
name: Run tests
command: npm run test:lib

workflows:
version: 2
test-build-release:
jobs:
- build
- test:
requires:
- build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# testing
/coverage
.nyc_output

# production
/build
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,33 @@

> Get a block number by its date
## Check -> https://blockbytime.com
## Demo -> https://blockbytime.com

## Install

```bash
npm i eth-block-timestamp
```

### Usage

```typescript
const blocks = new Blocks(
(window as any).ethereum || 'https://mainnet.infura.io/v3/{API_KEY}'
)

// Get first block info
const { block, timestamp } = await blocks.getDate('first')

// Get latest block info
const { block, timestamp } = await blocks.getDate('latest')

// Get block info at 03/20/2020
const { block, timestamp } = await blocks.getDate('03/20/2020')

// Get block info at 03/20/2020 03:10:00 AM
const { block, timestamp } = await blocks.getDate('03/20/2020 03:10:00 AM')

// Get block info at 1586618608 (Unix Timestamp)
const { block, timestamp } = await blocks.getDate('1586618608')
```
Loading

0 comments on commit 799d401

Please sign in to comment.