Skip to content

Commit

Permalink
Merge pull request #11 from starkbamse/bump-version-readme
Browse files Browse the repository at this point in the history
Bump version, readme
  • Loading branch information
saefstroem authored Sep 18, 2024
2 parents 7db0166 + e714852 commit ebbc4c9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ crate-type = ["cdylib", "rlib"]

[package]
name = "rustlink"
version = "0.0.3"
version = "0.0.4"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "A lightweight and easy-to-use library for periodically retrieving data from the Chainlink decentralized data feed."
Expand Down
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ Here is a simple example of how you can use `rustlink` to retrieve the latest pr

```rust
use async_std::channel::unbounded;
use rustlink::config::{Reflector, Rustlink};
use rustlink::core::{Reflector, Rustlink};
#[tokio::main]
async fn main(){
let mut contracts: Vec<(String, String)> = Vec::new();
contracts.push((
"ETH".to_string(),"0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e".to_string(),
"ETH".to_string(),
"0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e".to_string(),
));
let (sender, receiver) = unbounded();
Expand All @@ -89,6 +91,7 @@ async fn main(){
1,
Reflector::Sender(sender),
contracts,
std::time::Duration::from_secs(10),
)
.unwrap();
rustlink.start();
Expand All @@ -107,33 +110,35 @@ loop {
```

## WASM Usage

```javascript
import init, { RustlinkJS } from '../web/rustlink.js';
async function runWasm() {
await init(); // Initialize the wasm module
// Example data
const rpcUrl = "https://bsc-dataseed1.binance.org/";
const fetchIntervalSeconds = BigInt(1);
const contracts = [
["ETH", "0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e"],
["1INCH", "0x9a177Bb9f5b6083E962f9e62bD21d4b5660Aeb03"],
];
async function callback(roundData) {
console.log("Callback received:", roundData);
}
let rustlink = new RustlinkJS(rpcUrl, fetchIntervalSeconds, contracts, callback);
rustlink.start();
console.log("Stopping after 5 seconds");
setTimeout(() => {
rustlink.stop();
}, 5000);
await init(); // Initialize the wasm module
// Example data
const rpcUrl = "https://bsc-dataseed1.binance.org/";
const fetchIntervalSeconds = BigInt(1);
const contracts = [
["ETH", "0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e"],
["1INCH", "0x9a177Bb9f5b6083E962f9e62bD21d4b5660Aeb03"],
];
async function callback(roundData) {
console.log("Callback received:", roundData);
}
let rustlink = new RustlinkJS(rpcUrl, fetchIntervalSeconds, contracts, callback, 10);
rustlink.start();
console.log("Stopping after 5 seconds");
setTimeout(() => {
rustlink.stop();
}, 5000);
}
runWasm();
```
## License
This library is licensed under the MIT license. See the [LICENSE](LICENSE) file for more details.

0 comments on commit ebbc4c9

Please sign in to comment.