Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
hardingjam committed Sep 30, 2024
1 parent 43fb3c4 commit 79f4b39
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/frames/[projectName]/[strategyName]/[deployment]/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,28 @@ const handleRequest = frames(async (ctx) => {
const yamlData = ctx.yamlData;
let currentState: FrameState = ctx.state as unknown as FrameState;

// Handle state restoration after transactions
// Handle state restoration from URL after transactions
if (ctx.url.searchParams.has('currentState')) {
currentState = JSON.parse(decodeURI(ctx.url.searchParams.get('currentState')!));
}

// Add strategy name and description to state from YAML
if (currentState && !currentState.strategyName) {
currentState.strategyName = yamlData.gui.name;
}
if (currentState && !currentState.strategyDescription) {
currentState.strategyDescription = yamlData.gui.description;
}

// Add deployment option to state from URL
if (currentState && !currentState.deploymentOption && ctx.url.pathname.split('/')[4]) {
currentState.deploymentOption =
yamlData.gui.deployments.find(
(deployment: any) => deployment.deployment === ctx.url.pathname.split('/')[4]
) || undefined;
}

if (currentState && !currentState.strategyDescription) {
currentState.strategyDescription = yamlData.gui.description;
}

// Get token infos from YAML
if (currentState && !currentState.tokenInfos.length) {
const tokenInfos = await getTokenInfos(yamlData);
currentState.tokenInfos = tokenInfos;
Expand Down Expand Up @@ -66,10 +68,10 @@ const handleRequest = frames(async (ctx) => {
// Generate buttons based on current state
const buttonsData = await generateButtonsData(yamlData, currentState);

// Load font
const dmSansLight = fs.readFile(
path.join(path.resolve(process.cwd(), 'public/_fonts'), 'DMSans-Light.ttf')
);

const [dmSansLightData] = await Promise.all([dmSansLight]);

return {
Expand Down

0 comments on commit 79f4b39

Please sign in to comment.