-
Notifications
You must be signed in to change notification settings - Fork 59
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
refactor(svm): restructure utils into modular files under src folder #793
Changes from 7 commits
7468827
3ba41b1
d70639d
2889494
3c8b690
a5fb1de
431a657
4a74498
fa3186d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,7 @@ import { PublicKey } from "@solana/web3.js"; | |
import { SvmSpoke } from "../../target/types/svm_spoke"; | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
import { readProgramEvents, strPublicKey } from "../../src/SvmUtils"; | ||
import { u8Array32ToInt } from "../../test/svm/utils"; | ||
import { readProgramEvents } from "../../src/svm"; | ||
|
||
// Set up the provider | ||
const provider = AnchorProvider.env(); | ||
|
@@ -47,27 +46,30 @@ async function queryFills(): Promise<void> { | |
console.log("No fill events found for the given seed."); | ||
return; | ||
} | ||
|
||
console.log("Fill events fetched successfully:"); | ||
fillEvents.forEach((event, index) => { | ||
console.log(`Fill Event ${index + 1}:`); | ||
console.table([ | ||
{ Property: "inputToken", Value: strPublicKey(event.data.inputToken) }, | ||
{ Property: "outputToken", Value: strPublicKey(event.data.outputToken) }, | ||
{ Property: "inputToken", Value: new PublicKey(event.data.inputToken).toString() }, | ||
{ Property: "outputToken", Value: new PublicKey(event.data.outputToken).toString() }, | ||
{ Property: "inputAmount", Value: event.data.inputAmount.toString() }, | ||
{ Property: "outputAmount", Value: event.data.outputAmount.toString() }, | ||
{ Property: "repaymentChainId", Value: event.data.repaymentChainId.toString() }, | ||
{ Property: "originChainId", Value: event.data.originChainId.toString() }, | ||
{ Property: "depositId", Value: event.data.depositId.toString() }, | ||
{ Property: "depositIdNum", Value: u8Array32ToInt(event.data.depositId).toString() }, | ||
{ Property: "fillDeadline", Value: event.data.fillDeadline.toString() }, | ||
{ Property: "exclusivityDeadline", Value: event.data.exclusivityDeadline.toString() }, | ||
{ Property: "exclusiveRelayer", Value: strPublicKey(event.data.exclusiveRelayer) }, | ||
{ Property: "relayer", Value: strPublicKey(event.data.relayer) }, | ||
{ Property: "depositor", Value: strPublicKey(event.data.depositor) }, | ||
{ Property: "recipient", Value: strPublicKey(event.data.recipient) }, | ||
{ Property: "messageHash", Value: event.data.messageHash.toString() }, | ||
{ Property: "updatedRecipient", Value: strPublicKey(event.data.relayExecutionInfo.updatedRecipient) }, | ||
{ Property: "updatedMessageHash", Value: event.data.relayExecutionInfo.updatedMessageHash.toString() }, | ||
{ Property: "exclusiveRelayer", Value: new PublicKey(event.data.exclusiveRelayer).toString() }, | ||
{ Property: "relayer", Value: new PublicKey(event.data.relayer).toString() }, | ||
{ Property: "depositor", Value: new PublicKey(event.data.depositor).toString() }, | ||
{ Property: "recipient", Value: new PublicKey(event.data.recipient).toString() }, | ||
{ Property: "message", Value: event.data.message.toString() }, | ||
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. fill events don't have full message anymore. instead its messageHash 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. ye, this will be broken now if used. I think it could be due to a merge issue you had. |
||
{ | ||
Property: "updatedRecipient", | ||
Value: new PublicKey(event.data.relayExecutionInfo.updatedRecipient).toString(), | ||
}, | ||
{ Property: "updatedMessage", Value: event.data.relayExecutionInfo.updatedMessage.toString() }, | ||
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. updatedMessageHash 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. This was a mistake when merging/solving conflicts. Fixed now. |
||
{ Property: "updatedOutputAmount", Value: event.data.relayExecutionInfo.updatedOutputAmount.toString() }, | ||
{ Property: "fillType", Value: event.data.relayExecutionInfo.fillType }, | ||
]); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,7 @@ import { | |
import { SvmSpoke } from "../../target/types/svm_spoke"; | ||
import yargs from "yargs"; | ||
import { hideBin } from "yargs/helpers"; | ||
import { calculateRelayHashUint8Array } from "../../src/SvmUtils"; | ||
import { intToU8Array32 } from "../../test/svm/utils"; | ||
import { calculateRelayHashUint8Array } from "../../src/svm"; | ||
|
||
// Set up the provider | ||
const provider = AnchorProvider.env(); | ||
|
@@ -36,7 +35,7 @@ const argv = yargs(hideBin(process.argv)) | |
.option("inputAmount", { type: "number", demandOption: true, describe: "Input amount" }) | ||
.option("outputAmount", { type: "number", demandOption: true, describe: "Output amount" }) | ||
.option("originChainId", { type: "string", demandOption: true, describe: "Origin chain ID" }) | ||
.option("depositId", { type: "string", demandOption: true, describe: "Deposit ID" }) | ||
.option("depositId", { type: "array", demandOption: true, describe: "Deposit ID" }) | ||
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. its too cumbersome to pass array in command line (need to repeat --depositId param for each byte. Better use string and parse it as hex (if it starts with 0x) or number 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. This was a mistake when merging/solving conflicts. Fixed now. |
||
.option("fillDeadline", { type: "number", demandOption: false, describe: "Fill deadline" }) | ||
.option("exclusivityDeadline", { type: "number", demandOption: false, describe: "Exclusivity deadline" }).argv; | ||
|
||
|
@@ -50,7 +49,7 @@ async function fillV3Relay(): Promise<void> { | |
const inputAmount = new BN(resolvedArgv.inputAmount); | ||
const outputAmount = new BN(resolvedArgv.outputAmount); | ||
const originChainId = new BN(resolvedArgv.originChainId); | ||
const depositId = intToU8Array32(new BN(resolvedArgv.depositId)); | ||
const depositId = resolvedArgv.depositId; | ||
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. why change this 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. Same :) This was a mistake when merging/solving conflicts. Fixed now. |
||
const fillDeadline = resolvedArgv.fillDeadline || Math.floor(Date.now() / 1000) + 60; // Current time + 1 minute | ||
const exclusivityDeadline = resolvedArgv.exclusivityDeadline || Math.floor(Date.now() / 1000) + 30; // Current time + 30 seconds | ||
const message = Buffer.from(""); | ||
|
@@ -65,7 +64,7 @@ async function fillV3Relay(): Promise<void> { | |
inputAmount, | ||
outputAmount, | ||
originChainId, | ||
depositId, | ||
depositId: depositId.map((id) => Number(id)), | ||
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. this might be based on old version. we had it fixed recently |
||
fillDeadline, | ||
exclusivityDeadline, | ||
message, | ||
|
@@ -155,7 +154,7 @@ async function fillV3Relay(): Promise<void> { | |
state: statePda, | ||
signer: signer.publicKey, | ||
instructionParams: program.programId, | ||
mint: outputToken, | ||
mintAccount: outputToken, | ||
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. should be mint 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. same comment as before, likely due to a merge issue. |
||
relayerTokenAccount: relayerTokenAccount, | ||
recipientTokenAccount: recipientTokenAccount, | ||
fillStatus: fillStatusPda, | ||
|
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.
why drop strPublicKey helper, we introduced this recently
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.
Fixed.