-
Notifications
You must be signed in to change notification settings - Fork 2
debugging workflows #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
debugging workflows #103
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -49,7 +49,7 @@ interface PORResponse { | |
|
||
interface ReserveInfo { | ||
lastUpdated: Date; | ||
totalReserve: bigint; | ||
totalReserve: number; | ||
} | ||
|
||
// Utility function to safely stringify objects with bigints | ||
|
@@ -79,7 +79,7 @@ const fetchReserveInfo = ( | |
|
||
return { | ||
lastUpdated: new Date(porResp.updatedAt), | ||
totalReserve: BigInt(Math.floor(porResp.totalToken * 1e18)), // Scale to 18 decimals | ||
totalReserve: porResp.totalToken | ||
}; | ||
}; | ||
|
||
|
@@ -240,16 +240,17 @@ const updateReserves = ( | |
}) | ||
.result(); | ||
|
||
const txHash = resp.txHash; | ||
// TODO: Why does the writeReport fail with an "execution reverted" error? | ||
const txHash = resp.txHash || Uint8Array.from('0x000000000000000000000000000000') | ||
|
||
if (!txHash) { | ||
throw new Error("Failed to write report"); | ||
throw new Error(`Failed to write report: ${resp.errorMessage}`) | ||
} | ||
|
||
runtime.log( | ||
`Write report transaction succeeded at txHash: ${txHash.toString()}` | ||
`Write report transaction succeeded at txHash: ${bytesToHex(txHash)}` | ||
); | ||
return txHash.toString(); | ||
return txHash.toString() | ||
}; | ||
|
||
const doPOR = (runtime: Runtime<Config>): string => { | ||
|
@@ -272,8 +273,7 @@ const doPOR = (runtime: Runtime<Config>): string => { | |
const totalSupply = getTotalSupply(runtime); | ||
runtime.log(`TotalSupply ${totalSupply.toString()}`); | ||
|
||
const totalReserveScaled = (reserveInfo as unknown as ReserveInfo) | ||
.totalReserve; | ||
const totalReserveScaled = BigInt(reserveInfo.totalReserve * 1e18); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scale here to 18 decimals instead of in fetchReserveInfo to match the Go workflow |
||
runtime.log(`TotalReserveScaled ${totalReserveScaled.toString()}`); | ||
|
||
const nativeTokenBalance = fetchNativeTokenBalance( | ||
|
@@ -293,7 +293,7 @@ const doPOR = (runtime: Runtime<Config>): string => { | |
|
||
updateReserves(runtime, totalSupply, totalReserveScaled); | ||
|
||
return totalReserveScaled.toString(); | ||
return reserveInfo.totalReserve.toString(); | ||
}; | ||
|
||
const getLastMessage = ( | ||
|
@@ -356,6 +356,8 @@ const onCronTrigger = ( | |
throw new Error("Scheduled execution time is required"); | ||
} | ||
|
||
runtime.log('Running CronTrigger'); | ||
|
||
return doPOR(runtime); | ||
}; | ||
|
||
|
@@ -397,11 +399,11 @@ const onHTTPTrigger = ( | |
return doPOR(runtime); | ||
} | ||
|
||
// Log the raw JSON for debugging | ||
runtime.log("Payload bytes"); | ||
// Log the raw JSON for debugging (human-readable). | ||
runtime.log(`Payload bytes payloadBytes ${payload.input.toString()}`) | ||
|
||
try { | ||
runtime.log("Parsed HTTP trigger received"); | ||
runtime.log(`Parsed HTTP trigger received payload ${payload.input.toString()}`); | ||
return doPOR(runtime); | ||
} catch (error) { | ||
runtime.log("Failed to parse HTTP trigger payload"); | ||
|
@@ -412,7 +414,6 @@ const onHTTPTrigger = ( | |
const initWorkflow = (config: Config) => { | ||
const cronTrigger = new cre.capabilities.CronCapability(); | ||
const httpTrigger = new cre.capabilities.HTTPCapability(); | ||
|
||
const network = getNetwork({ | ||
chainFamily: "evm", | ||
chainSelectorName: config.evms[0].chainSelectorName, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ernest-nowacki I can't tell if the abi function is not correct or if the Go side is doing something tricky here. I can run through this step in Go, but here I always get an "execution reverted" error. How did you generate the
writeReportFromUpdateReserves
call in abi.ts?