Skip to content

Commit 59bbcfc

Browse files
committed
1 parent 98e97d7 commit 59bbcfc

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

src/constants/rofl-8004.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { sepolia } from 'viem/chains'
33
export const ROFL_8004_DOCKER_IMAGE =
44
'ghcr.io/oasisprotocol/rofl-8004:latest@sha256:3b4348cb5fe192c28398be93955abc025e3d9977d1f80121ef1068458d6d1f77'
55
export const ROFL_8004_SERVICE_NAME = 'rofl-8004'
6+
export const ROFL_8004_VOLUME_NAME = 'rofl-8004-volume'
67
export const ROFL_8004_SERVICE_ENV_PREFIX = 'ERC8004'
78

89
export const ROFL_8004_METADATA_KEY = 'net.oasis.app.erc8004_agent_id' // "{chainId}:{agentId}"

src/pages/CreateApp/useComposeValidation.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as yaml from 'yaml'
22
import { useState } from 'react'
33
import { useValidateRofl } from '../../backend/api'
44
import { useRoflAppBackendAuthContext } from '../../contexts/RoflAppBackendAuth/hooks'
5-
import { ROFL_8004_SERVICE_NAME } from '../../constants/rofl-8004.ts'
5+
import { ROFL_8004_SERVICE_NAME, ROFL_8004_VOLUME_NAME } from '../../constants/rofl-8004.ts'
66

77
type ValidationState = {
88
isValidating: boolean
@@ -45,6 +45,14 @@ export function useComposeValidation() {
4545
})
4646
return false
4747
}
48+
49+
if (parsed?.volumes?.[ROFL_8004_VOLUME_NAME]) {
50+
setValidationState({
51+
isValidating: false,
52+
validationError: `Volume name "${ROFL_8004_VOLUME_NAME}" is reserved and cannot be used.`,
53+
})
54+
return false
55+
}
4856
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- ignore YAML parsing error
4957
} catch (_err) {
5058
// Let backend validation handle the error

src/utils/rofl-8004.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ import {
44
ROFL_8004_SERVICE_ENV_PREFIX,
55
ROFL_8004_SERVICE_NAME,
66
ROFL_8004_SUPPORTED_CHAINS,
7+
ROFL_8004_VOLUME_NAME,
78
} from '../constants/rofl-8004.ts'
89
import { RoflInstance } from '../nexus/generated/api.ts'
910
import { AppData, ERC8004FormData } from '../pages/CreateApp/types.ts'
1011
import * as yaml from 'yaml'
1112
import { parse } from 'yaml'
1213

14+
interface ComposeFile {
15+
services: Record<string, unknown>
16+
volumes?: Record<string, unknown | null>
17+
[key: string]: unknown
18+
}
19+
1320
export const fromMetadataToAgentMetadata = (
1421
metadata: RoflInstance['metadata'],
1522
): { chainId: number | null; agentId: bigint | null; chainName: string | null } | null => {
@@ -41,7 +48,7 @@ export const hasRofl8004ServiceSecrets = (appData: AppData) => {
4148
}
4249

4350
export const addRofl8004ServiceToCompose = (composeYaml: string, appData: AppData): string => {
44-
const compose = parse(composeYaml)
51+
const compose = parse(composeYaml) as ComposeFile
4552

4653
const environment = Object.keys(appData.inputs?.secrets ?? {})
4754
.filter(key => key.toUpperCase().startsWith(ROFL_8004_SERVICE_ENV_PREFIX))
@@ -71,8 +78,13 @@ export const addRofl8004ServiceToCompose = (composeYaml: string, appData: AppDat
7178
image: ROFL_8004_DOCKER_IMAGE,
7279
platform: 'linux/amd64',
7380
environment,
74-
volumes: ['/run/rofl-appd.sock:/run/rofl-appd.sock'],
81+
volumes: ['/run/rofl-appd.sock:/run/rofl-appd.sock', `${ROFL_8004_VOLUME_NAME}:/root/.rofl-8004`],
82+
}
83+
84+
if (!compose.volumes) {
85+
compose.volumes = {}
7586
}
87+
compose.volumes[ROFL_8004_VOLUME_NAME] = null
7688

7789
return yaml.stringify(compose)
7890
}

0 commit comments

Comments
 (0)