Skip to content

Commit ea8f0f1

Browse files
authored
Merge pull request #271 from OceanProtocolEnterprise/feat/stage
Feat/stage
2 parents 6d92e05 + e85a4c9 commit ea8f0f1

13 files changed

Lines changed: 53 additions & 23 deletions

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# NEXT_PUBLIC_HIDE_ONBOARDING_MODULE_BY_DEFAULT=true
1515
# NEXT_PUBLIC_NODE_URI_INDEXED=["https://.."]
1616
# NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
17+
# NEXT_PUBLIC_DATASPACE=oceanenterprise
1718
# NEXT_PUBLIC_ESCROW_ADDRESSES={"11155111":"0x5494711392a67DA50D3bC7b1fcC2d1877cFaA4d2", "11155420":"0x4D49eEedFac8Ea03328c0E4871b680C06d892092"}
1819
# NEXT_PUBLIC_NODE_URI_MAP={"1":"https://mainnet...", "10":"https://optimism...", "11155111":"https://eth-sepolia.g.alchemy.com/.., "11155420":"https://opt-sepolia.g.alchemy.com/..}
1920
# NEXT_PUBLIC_CONSUME_MARKET_ORDER_FEE_MAP={"11155111":[{"token":"0x1B083D8584dd3e6Ff37d04a6e7e82b5F622f3985","amount":"1500000000000000000"}, {"token": "0x08210F9170F89Ab7658F0B5E3fF39b0E03C594D4", "amount": "2000000"}]}

app.config.cjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,8 @@ module.exports = {
177177
getEnv('NEXT_PUBLIC_PROVIDER_URL') ||
178178
process.env.NEXT_PUBLIC_PROVIDER_URL ||
179179
'https://ocean-node-vm3.oceanenterprise.io'
180-
]
180+
],
181+
182+
dataspace:
183+
getEnv('NEXT_PUBLIC_DATASPACE') || process.env.NEXT_PUBLIC_DATASPACE || null
181184
}

scripts/docker-entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ const config = {
3737
process.env.NEXT_PUBLIC_CREDENTIAL_VALIDITY_DURATION,
3838
NEXT_PUBLIC_NODE_URI_MAP: process.env.NEXT_PUBLIC_NODE_URI_MAP,
3939
NEXT_PUBLIC_MARKET_FEE_ADDRESS: process.env.NEXT_PUBLIC_MARKET_FEE_ADDRESS,
40-
NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES: process.env.NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES
40+
NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES:
41+
process.env.NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES,
42+
NEXT_PUBLIC_DATASPACE: process.env.NEXT_PUBLIC_DATASPACE
4143
}
4244
4345
fs.writeFileSync(

scripts/write-runtime-config.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ const config = {
5757
NEXT_PUBLIC_NODE_URI_MAP: process.env.NEXT_PUBLIC_NODE_URI_MAP,
5858
NEXT_PUBLIC_MARKET_FEE_ADDRESS: process.env.NEXT_PUBLIC_MARKET_FEE_ADDRESS,
5959
NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES:
60-
process.env.NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES
60+
process.env.NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES,
61+
NEXT_PUBLIC_DATASPACE: process.env.NEXT_PUBLIC_DATASPACE
6162
}
6263

6364
const outputPath = path.join(process.cwd(), 'public', 'runtime-config.js')

src/@context/MarketMetadata/_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface AppConfig {
3939
showPreviewAlert: string
4040
ssiEnabled: boolean
4141
showOnboardingModuleByDefault: boolean
42+
dataspace: string | null
4243
}
4344
export interface SiteContent {
4445
siteTitle: string

src/@types/ddo/CredentialSubject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface CredentialSubject {
1212
credentials: Credential
1313
chainId: number
1414
nftAddress: string
15+
dataspace?: string
1516
event?: Event
1617
datatokens?: AssetDatatoken[]
1718
}

src/@utils/aquarius/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import axios, { CancelToken, AxiosResponse } from 'axios'
44
import {
55
metadataCacheUri,
66
allowDynamicPricing,
7-
nodeUriIndex
7+
nodeUriIndex,
8+
dataspace
89
} from '../../../app.config.cjs'
910
import {
1011
SortDirectionOptions,
@@ -119,11 +120,17 @@ FilterTerm | undefined {
119120
: getFilterTerm('indexedMetadata.stats.prices.type', 'pool')
120121
}
121122

123+
function getDataspaceFilterTerm(): FilterTerm | undefined {
124+
if (!dataspace) return undefined
125+
return getFilterTerm('credentialSubject.dataspace.keyword', dataspace)
126+
}
127+
122128
export function generateBaseQuery(
123129
baseQueryParams: BaseQueryParams,
124130
index?: string,
125131
allNode?: boolean
126132
): SearchQuery {
133+
const dataspaceFilterTerm = getDataspaceFilterTerm()
127134
const generatedQuery = {
128135
index: index ?? 'op_ddo_v5.0.0',
129136
from: baseQueryParams.esPaginationOptions?.from || 0,
@@ -165,7 +172,8 @@ export function generateBaseQuery(
165172
}
166173
}
167174
]
168-
: [])
175+
: []),
176+
...(dataspaceFilterTerm ? [dataspaceFilterTerm] : [])
169177
]
170178
}
171179
}

src/@utils/provider.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
PolicyServerInitiateActionData,
2424
PolicyServerInitiateComputeActionData
2525
} from 'src/@types/PolicyServer'
26-
import { getOceanConfig } from '@utils/ocean'
2726

2827
export async function initializeProviderForComputeMulti(
2928
datasets:
@@ -40,13 +39,11 @@ export async function initializeProviderForComputeMulti(
4039
computeEnv: ComputeEnvironment,
4140
selectedResources: ResourceType,
4241
svcIndexAlgo: number,
42+
paymentTokenAddress: string,
4343
algoParams?: Record<string, any>,
4444
datasetParams?: Record<string, any>
4545
) {
4646
const safeDatasets = datasets ?? []
47-
const { oceanTokenAddress } = getOceanConfig(
48-
algorithm.credentialSubject.chainId
49-
)
5047
const computeAssets = safeDatasets.map(
5148
({ asset, service, accessDetails }) => ({
5249
documentId: asset.id,
@@ -113,7 +110,7 @@ export async function initializeProviderForComputeMulti(
113110
computeAssets,
114111
computeAlgo,
115112
computeEnv.id,
116-
oceanTokenAddress,
113+
paymentTokenAddress,
117114
validUntil,
118115
providerUrl,
119116
accountId,

src/@utils/runtimeConfig.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type RuntimeConfig = {
2525
NEXT_PUBLIC_MARKET_FEE_ADDRESS?: string
2626
NEXT_PUBLIC_MARKET_DEVELOPMENT?: string
2727
NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES?: string
28+
NEXT_PUBLIC_DATASPACE?: string
2829
}
2930

3031
declare global {
@@ -70,7 +71,8 @@ const runtimeConfig: RuntimeConfig = (() => {
7071
NEXT_PUBLIC_MARKET_FEE_ADDRESS: process.env.NEXT_PUBLIC_MARKET_FEE_ADDRESS,
7172
NEXT_PUBLIC_MARKET_DEVELOPMENT: process.env.NEXT_PUBLIC_MARKET_DEVELOPMENT,
7273
NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES:
73-
process.env.NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES
74+
process.env.NEXT_PUBLIC_ALLOWED_ERC20_ADDRESSES,
75+
NEXT_PUBLIC_DATASPACE: process.env.NEXT_PUBLIC_DATASPACE
7476
}
7577

7678
if (typeof window !== 'undefined' && window.__RUNTIME_CONFIG__) {

src/components/ComputeWizard/ComputeWizardController.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ export default function ComputeWizardController({
323323
initError,
324324
setInitError
325325
} = useComputeInitialization({
326-
oceanTokenAddress: baseTokenAddress,
327326
web3Provider
328327
})
329328
const {
@@ -598,6 +597,19 @@ export default function ComputeWizardController({
598597
datasetParams[param.name] = param.value ?? param.default ?? ''
599598
})
600599
}
600+
const paymentTokenAddress =
601+
formValues?.baseToken ||
602+
baseTokenAddress ||
603+
selectedComputeEnv.fees?.[
604+
String(formValues?.user?.chainId || asset.credentialSubject.chainId)
605+
]?.[0]?.feeToken
606+
607+
if (!paymentTokenAddress) {
608+
throw new Error(
609+
'No payment token selected. Please choose a price token in C2D Environment Configuration.'
610+
)
611+
}
612+
601613
const initResult = await initializePricingAndProvider({
602614
datasetsForProvider,
603615
algorithmAsset: actualAlgorithmAsset,
@@ -608,6 +620,7 @@ export default function ComputeWizardController({
608620
selectedComputeEnv,
609621
selectedResources,
610622
algoIndex: actualSvcIndex,
623+
paymentTokenAddress,
611624
algoParams,
612625
datasetParams,
613626
accountId,

0 commit comments

Comments
 (0)