Skip to content

Commit 3b2f2fc

Browse files
committed
fix example, rfk task param check
1 parent 90baab9 commit 3b2f2fc

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SECRET_KEY=
55
RPC_URL=https://base-sepolia.g.alchemy.com/v2/<api-key>
66

77
## Contract Address
8-
COORDINATOR_ADDRESS=0x1deaca041f094ec67baa4fb36d333cb652e6b7a7
8+
COORDINATOR_ADDRESS=0x13f977bde221b470d3ae055cde7e1f84debfe202
99

1010
## Arweave
1111
ARWEAVE_PATH=./arweave-keyfile.json

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ pnpm test
132132

133133
### Base Sepolia Testnet
134134

135-
| Contract | Address |
136-
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------- |
137-
| Registry | [`0xbff452f736c0a2c0122b6d629c4d996274703d3b`](https://base-sepolia.blockscout.com/address/0xbff452f736c0a2c0122b6d629c4d996274703d3b) |
138-
| Coordinator | [`0x1deaca041f094ec67baa4fb36d333cb652e6b7a7`](https://base-sepolia.blockscout.com/address/0x1deaca041f094ec67baa4fb36d333cb652e6b7a7) |
135+
| Contract | Address |
136+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------ |
137+
| Registry | [`408d245a853137e44a2465d5c66061f97582eae9`](https://base-sepolia.blockscout.com/address/0x408d245a853137e44a2465d5c66061f97582eae9) |
138+
| Coordinator | [`13f977bde221b470d3ae055cde7e1f84debfe202`](https://base-sepolia.blockscout.com/address/0x13f977bde221b470d3ae055cde7e1f84debfe202) |
139139

140140
## License
141141

examples/request.mjs

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import { createPublicClient, createWalletClient, http } from "viem";
44
import { privateKeyToAccount } from "viem/accounts";
55
import { baseSepolia } from "viem/chains";
66
import { Oracle, ArweaveStorage } from "dria-oracle-sdk";
7+
import { inspect } from "util";
78

89
async function main() {
910
const SECRET_KEY = process.env.SECRET_KEY;
1011
const RPC_URL = process.env.RPC_URL ?? "https://base-sepolia-rpc.publicnode.com";
11-
const COORDINATOR_ADDRESS = process.env.COORDINATOR_ADDRESS ?? "0x1deaca041f094ec67baa4fb36d333cb652e6b7a7";
12+
const COORDINATOR_ADDRESS = process.env.COORDINATOR_ADDRESS ?? "0x13f977bde221b470d3ae055cde7e1f84debfe202";
1213

1314
// create oracle instance
1415
const oracle = new Oracle(
@@ -38,15 +39,17 @@ async function main() {
3839
}
3940

4041
// make a request
42+
console.log("Preparing request");
4143
const input = process.argv[2];
4244
if (!input) {
4345
throw new Error("Provide an input.");
4446
}
4547
const model = "*";
4648
const requestObj = await oracle.request(input, model, {
4749
taskParameters: {
48-
numValidations: 2,
50+
difficulty: 2,
4951
numGenerations: 2,
52+
numValidations: 1,
5053
},
5154
});
5255

@@ -58,17 +61,22 @@ async function main() {
5861
await oracle.wait(taskId);
5962

6063
// read best result
61-
console.log("Reading results:");
6264
const response = await oracle.read(taskId);
63-
console.log("Response:");
64-
console.log({ response });
65+
console.log("Reading best result:");
66+
console.log(response);
6567

6668
// read validations
67-
const validations = await oracle.getValidations(taskId);
6869
console.log("Validations:");
70+
const validations = await oracle.getValidations(taskId);
6971
for (const validationRaw of validations) {
7072
const validation = await oracle.processValidation(validationRaw);
71-
console.log({ validation });
73+
console.log(
74+
inspect(validation, {
75+
showHidden: true,
76+
depth: null,
77+
colors: true,
78+
})
79+
);
7280
}
7381
}
7482

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dria-oracle-sdk",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "An on-chain AI oracle SDK for Dria",
55
"license": "MIT",
66
"author": "FirstBatch Team <[email protected]>",

src/client.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ export class Oracle<T extends Transport, C extends Chain, K = unknown> {
164164

165165
// check task parameter
166166
const taskParameters = { ...this.taskParameters, ...opts.taskParameters };
167-
if (taskParameters.numValidations !== 0 && taskParameters.numGenerations === 1) {
168-
throw new Error("numGenerations must be greater than 1 when numValidations is not 0.");
167+
if (taskParameters.numGenerations === 0) {
168+
throw new Error("Number of generations cant be 0.");
169169
}
170170

171171
// models are comma-separated

0 commit comments

Comments
 (0)