Skip to content

Commit 64ce151

Browse files
authored
Merge pull request #4 from ora-io/dev
Dev - Upgrade to version 0.0.8
2 parents bc3f104 + d695bf8 commit 64ce151

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1114
-405
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
assets/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ lib-cov
99
logs
1010
node_modules
1111
temp
12+
*.env

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 ORA Protocol <https://github.com/ora-io>
3+
Copyright (c) 2024 ORA Protocol <https://ora.io>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,11 @@
11
# ORA STACK
22

3-
[![npm version][npm-version-src]][npm-version-href]
4-
[![npm downloads][npm-downloads-src]][npm-downloads-href]
5-
[![bundle][bundle-src]][bundle-href]
6-
[![JSDocs][jsdocs-src]][jsdocs-href]
7-
[![License][license-src]][license-href]
8-
9-
<!-- Badges -->
10-
11-
[npm-version-src]: https://img.shields.io/npm/v/pkg-placeholder?style=flat&colorA=080f12&colorB=6e70d4
12-
[npm-version-href]: https://npmjs.com/package/pkg-placeholder
13-
[npm-downloads-src]: https://img.shields.io/npm/dm/pkg-placeholder?style=flat&colorA=080f12&colorB=6e70d4
14-
[npm-downloads-href]: https://npmjs.com/package/pkg-placeholder
15-
[bundle-src]: https://img.shields.io/bundlephobia/minzip/pkg-placeholder?style=flat&colorA=080f12&colorB=6e70d4&label=minzip
16-
[bundle-href]: https://bundlephobia.com/result?p=pkg-placeholder
17-
[license-src]: https://img.shields.io/github/license/murongg/pkg-placeholder.svg?style=flat&colorA=080f12&colorB=6e70d4
18-
[license-href]: https://github.co/pkg-placeholder/blob/main/LICENSE
19-
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=6e70d4
20-
[jsdocs-href]: https://www.jsdocs.io/package/pkg-placeholder
21-
223
## What is ORA STACK
234
ORA Stack is a comprehensive framework designed for quickly setting up a web3 Oracle Service.
245

256
It includes:
267
- [Orap](./packages/orap/): the declarative signal-based backend framework;
27-
- [REK](./packages/rek/): the reliable ethereum toolkit;
8+
- [Reku](./packages/reku/): the reliable ethereum toolkit and utils;
289
- [Utils](./packages/utils/): the common swiss-knife package.
2910

3011
Comming soon:

assets/orap.logo.png

305 KB
Loading

assets/reku.logo.png

164 KB
Loading

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ora-stack",
3-
"version": "0.0.0",
3+
"version": "0.0.8",
44
"private": true,
55
"packageManager": "[email protected]",
66
"description": "",
@@ -61,6 +61,7 @@
6161
"@types/node": "^22.1.0",
6262
"bumpp": "^9.4.2",
6363
"consola": "^3.2.3",
64+
"dotenv": "^16.4.5",
6465
"eslint": "^8.54.0",
6566
"esno": "^4.7.0",
6667
"ethers": "^6.13.2",

packages/orap/README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1+
<div align="center"><img src="https://github.com/ora-io/ora-stack/blob/main/assets/orap.logo.png?raw=true" alt="Orap Icon" width="200"/></div>
2+
13
# ORAP: Oracle Application Framework
24

3-
ORAP is an out of box, express style framework.
5+
[![npm version][npm-version-src]][npm-version-href]
6+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
7+
[![bundle][bundle-src]][bundle-href]
8+
[![JSDocs][jsdocs-src]][jsdocs-href]
9+
[![License][license-src]][license-href]
10+
11+
<!-- Badges -->
12+
13+
[npm-version-src]: https://img.shields.io/npm/v/@ora-io/orap?style=flat&colorA=080f12&colorB=6e70d4
14+
[npm-version-href]: https://npmjs.com/package/@ora-io/orap
15+
[npm-downloads-src]: https://img.shields.io/npm/dm/@ora-io/orap?style=flat&colorA=080f12&colorB=6e70d4
16+
[npm-downloads-href]: https://npmjs.com/package/@ora-io/orap
17+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/@ora-io/orap?style=flat&colorA=080f12&colorB=6e70d4&label=minzip
18+
[bundle-href]: https://bundlephobia.com/result?p=@ora-io/orap
19+
[license-src]: https://img.shields.io/badge/License-MIT-yellow.svg?style=flat&colorA=080f12&colorB=6e70d4
20+
[license-href]: https://github.com/ora-io/ora-stack/blob/main/LICENSE
21+
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=6e70d4
22+
[jsdocs-href]: https://www.jsdocs.io/package/@ora-io/orap
23+
24+
ORAP is a declarative framework for building oracle services, handy to use out of the box.
425

526
## Usage
627
```ts
@@ -20,7 +41,7 @@ const eventSignalParam = {
2041
const handle = (...args: any) => { console.log('handle', args) }
2142

2243
orap.event(eventSignalParam, handle)
23-
.crosscheck({ intervalMsMin: 1000, batchBlocksCount: 1, blockIntervalMs: 12000 })
44+
.crosscheck({ pollingInterval: 1000, batchBlocksCount: 1, blockInterval: 12000 })
2445

2546
orap.listen(
2647
{ wsProvider: 'wss://127.0.0.1', httpProvider: 'http://127.0.0.1' },
@@ -54,6 +75,6 @@ etc.
5475

5576
### EventSignal
5677
- define event listener as simple as: `orap.event({address:"0x", abi:"", eventName: "Transfer"}, handleSignal)`
57-
- provide crosschecker by `rek`, available config please checkout `AutoCrossCheckParam` in `rek`
78+
- provide crosschecker by `reku`, available config please checkout `AutoCrossCheckParam` in `reku`
5879
- currently one and only one crosschecker is set to each event signal
5980
- store: provide 2 options: use memory or redis, checkout `orap/store`

packages/orap/mock/demo/app.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import type { EventLog } from 'ethers'
2+
import { redisStore } from '@ora-io/utils'
3+
import type { ListenOptions } from '../../index'
4+
import { Orap, StoreManager } from '../../index'
5+
import { config, logger } from './config'
6+
import ABI from './erc20.abi.json'
7+
import { TransferTask } from './taskTransfer'
8+
9+
// new orap
10+
const orap = new Orap()
11+
// set to app specific logger
12+
orap.setLogger(logger)
13+
14+
let store: any
15+
let sm: any
16+
17+
export function startDemo(options: ListenOptions, storeConfig?: any) {
18+
store = redisStore(storeConfig) // use redis
19+
// store = memoryStore(storeConfig); // use memory
20+
sm = new StoreManager(store)
21+
22+
const eventSignalParam = {
23+
address: config.MAINNET_USDT_ADDR,
24+
abi: ABI,
25+
eventName: config.TRANSFER_EVENT_NAME,
26+
}
27+
28+
orap.event(eventSignalParam, handleSignal)
29+
.crosscheck({
30+
store,
31+
storeKeyPrefix: 'ora-stack:orap:demo:cc:',
32+
storeTtl: config.CROSSCHECKER_CACHE_TTL,
33+
pollingInterval: 3000,
34+
batchBlocksCount: 1,
35+
blockInterval: 12000,
36+
delayBlockFromLatest: 1,
37+
})
38+
39+
// start processors
40+
startProcessor()
41+
// start signal listener
42+
orap.listen(
43+
options,
44+
() => { logger.log('listening on provider.network') },
45+
)
46+
}
47+
48+
async function handleSignal(from: any, to: any, amount: any, event: EventLog) {
49+
logger.log('handleSignal', event.transactionHash)
50+
const task = new TransferTask(event.transactionHash, from, to, amount)
51+
await task.save(sm)
52+
}
53+
54+
// TODO: make the following DBApp?
55+
async function startProcessor() {
56+
while (true) {
57+
const task = await TransferTask.load(sm)
58+
await task.handle()
59+
// await task.remove(sm) // delete task from store when finished
60+
await task.done(sm) // save task in store when finished
61+
}
62+
}

packages/orap/mock/demo/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Logger } from '@ora-io/utils'
2+
3+
export const config = {
4+
MAINNET_USDT_ADDR: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
5+
TRANSFER_EVENT_NAME: 'Transfer',
6+
TASK_TTL: 60000,
7+
TASK_DONE_TTL: 60000,
8+
CROSSCHECKER_CACHE_TTL: 60000,
9+
}
10+
11+
const logLevel = 'debug'
12+
export const logger = new Logger(logLevel, '[orap-mock-demo]')

0 commit comments

Comments
 (0)