-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update code to use imports properly
Additionally, some code is refactored to simplify the usage of the SDK Note: there is a build_index.sh script that must be run to build the artifacts needed to import. This script is temporary and should be replace by a CI job that publishes to npm.
- Loading branch information
1 parent
2cc292d
commit f5a6582
Showing
4 changed files
with
130 additions
and
662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
// Import the package | ||
const SxTProofModule = await import("npm:sxt-chain-sdk"); | ||
|
||
// Extract the default export (SxTProof class) | ||
const SxTProof = SxTProofModule.default; | ||
const SxTSDK = await import( | ||
"https://raw.githubusercontent.com/spaceandtimelabs/sxt-proof-of-sql-sdk/feat/import-sdk/chainlink-functions/source/index.js" | ||
); | ||
|
||
// Define test parameters | ||
const queryString = 'SELECT SUM(BLOCK_NUMBER), COUNT(*) FROM ETHEREUM.BLOCKS'; | ||
const queryString = "SELECT SUM(BLOCK_NUMBER), COUNT(*) FROM ETHEREUM.BLOCKS"; | ||
const table = "ETHEREUM.BLOCKS"; | ||
// TODO: This is currently hardcoded. But, we need to make it dynamic. | ||
const commitmentKey = | ||
'0xca407206ec1ab726b2636c4b145ac28749505e273536fae35330b966dac69e86a4832a125c0464e066dd20add960efb518424c4f434b5320455448455245554d4a9e6f9b8d43f6ad008f8c291929dee201'; | ||
"0xca407206ec1ab726b2636c4b145ac28749505e273536fae35330b966dac69e86a4832a125c0464e066dd20add960efb518424c4f434b5320455448455245554d4a9e6f9b8d43f6ad008f8c291929dee201"; | ||
|
||
if (!secrets.apiKey) { | ||
throw Error("Missing secret: apiKey"); | ||
throw Error("Missing secret: apiKey"); | ||
} | ||
|
||
// Initialize the SxTProof instance | ||
const proof = new SxTProof(queryString, commitmentKey, secrets.apiKey); | ||
const proof = new SxTSDK.SxTClient( | ||
"https://api.spaceandtime.dev/v1/prove", | ||
"https://proxy.api.spaceandtime.dev/auth/apikey", | ||
"https://rpc.testnet.sxt.network/", | ||
secrets.apiKey, | ||
); | ||
|
||
try { | ||
// Kick off the proof and await execution | ||
const result = await proof.executeWorkflow(); | ||
console.log("Workflow completed successfully:", result); | ||
return Functions.encodeString("Verified"); | ||
// Kick off the proof and await execution | ||
const result = await proof.queryAndVerify(queryString, table, commitmentKey); | ||
console.log("Workflow completed successfully:", result); | ||
return Functions.encodeString("Verified"); | ||
} catch (error) { | ||
console.log("Workflow failed: ", error); | ||
return Functions.encodeString("Failed: ", error); | ||
} | ||
console.log("Workflow failed: ", error); | ||
return Functions.encodeString("Failed: ", error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
cd $SCRIPT_DIR | ||
|
||
curl $1/sxt_proof_of_sql_sdk_wasm.js | cat - ./index_tail.js > ./index.js | ||
curl $1/sxt_proof_of_sql_sdk_wasm_bg.wasm > ./sxt_proof_of_sql_sdk_wasm_bg.wasm |
Oops, something went wrong.