Skip to content

Commit 4c93803

Browse files
authored
rfk: use test client in fork tests (#3)
* Erhant/get events test rfks (#2) * fork test takes too long, revert
1 parent 04de215 commit 4c93803

16 files changed

+455
-54
lines changed

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"jestrunner.jestCommand": "node ../../node_modules/jest/bin/jest.js",
32
// https://raw.githubusercontent.com/PKief/vscode-material-icon-theme/main/images/folderIcons.png
43
"material-icon-theme.folders.associations": {
54
"abis": "Mappings",

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ yarn add dria-oracle-sdk
4242
pnpm add dria-oracle-sdk
4343
```
4444

45+
The SDK makes use of Arweave as well for large inputs & outputs to save gas, and this depends on a peer dependency:
46+
47+
```sh
48+
pnpm add @irys/sdk
49+
```
50+
4551
## Usage
4652

4753
Using Oracle SDK, the following happens when you make a request:

examples/common/index.mjs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { readFileSync } from "fs";
77
/** Setup an oracle & initialize it using env variables. */
88
export async function setupOracle() {
99
const SECRET_KEY = process.env.SECRET_KEY;
10-
const RPC_URL = process.env.RPC_URL ?? "https://base-sepolia-rpc.publicnode.com";
10+
const RPC_URL = "https://base-sepolia-rpc.publicnode.com";
1111
const COORDINATOR_ADDRESS = process.env.COORDINATOR_ADDRESS ?? "0x13f977bde221b470d3ae055cde7e1f84debfe202";
1212
const ARWEAVE_WALLET_PATH = process.env.ARWEAVE_WALLET_PATH;
1313

@@ -19,21 +19,23 @@ export async function setupOracle() {
1919
}
2020

2121
// create oracle client
22+
const account = privateKeyToAccount(SECRET_KEY);
2223
const oracle = new Oracle(
2324
{
2425
public: createPublicClient({
2526
chain: baseSepolia,
2627
transport: http(RPC_URL),
2728
}),
2829
wallet: createWalletClient({
29-
account: privateKeyToAccount(SECRET_KEY),
30+
account: account,
3031
chain: baseSepolia,
3132
transport: http(RPC_URL),
3233
}),
3334
},
3435
storage
3536
);
3637

38+
console.log("Your address:", account.address);
3739
console.log("Initializing oracle for coordinator:", COORDINATOR_ADDRESS);
3840
await oracle.init(COORDINATOR_ADDRESS);
3941

examples/events.mjs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Usage: node ./view.mjs
2+
import "dotenv/config";
3+
import { inspect } from "util";
4+
import { setupOracle } from "./common/index.mjs";
5+
6+
async function main() {
7+
const oracle = await setupOracle();
8+
9+
const protocol = process.argv[2] ?? "swan-purchase-protocol/0.1.0";
10+
console.log("Viewing events for protocol:", protocol);
11+
12+
const taskEvents = await oracle.getEvents({ protocol });
13+
console.log(
14+
inspect(taskEvents, {
15+
showHidden: true,
16+
depth: null,
17+
colors: true,
18+
})
19+
);
20+
}
21+
22+
main().catch(console.error);

examples/view.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ async function main() {
1010
const taskId = BigInt(process.argv[2] ?? 1);
1111
console.log("Viewing task:", taskId);
1212

13+
// TODO: add request here
14+
1315
console.log("\nGenerations:");
1416
const responses = await oracle.getResponses(taskId);
1517
for (const responseRaw of responses) {

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "dria-oracle-sdk",
3-
"version": "0.0.9",
4-
"description": "An on-chain AI oracle SDK for Dria",
3+
"version": "0.0.10",
4+
"description": "An on-chain LLM Oracle SDK for Dria",
55
"license": "MIT",
66
"author": "FirstBatch Team <[email protected]>",
77
"homepage": "https://github.com/firstbatchxyz/dria-oracle-sdk#readme",
88
"contributors": [
9-
"Erhan Tezcan <[email protected]>"
9+
"Erhan Tezcan <[email protected]> (https://github.com/erhant)"
1010
],
1111
"files": [
1212
"dist/",
@@ -36,6 +36,7 @@
3636
"dotenv": "^16.4.5",
3737
"jest": "^29.7.0",
3838
"pkgroll": "^2.5.1",
39+
"prool": "^0.0.16",
3940
"ts-jest": "^29.2.5",
4041
"ts-node": "^10.9.2",
4142
"tsx": "^4.19.2",

0 commit comments

Comments
 (0)