Skip to content

Commit 049e1ab

Browse files
authored
fix: raw config merge fix, testnet -> dar for deal-ts-client fix (#1048)
* fix: raw config merge fix * fix * move * fix
1 parent 4ec72fb commit 049e1ab

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

cli/src/commands/chain/info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class Info extends BaseCommand<typeof Info> {
4242

4343
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
4444
const { default: contracts }: { default: unknown } = await import(
45-
`@fluencelabs/deal-ts-clients/dist/deployments/${chainEnv}.json`,
45+
`@fluencelabs/deal-ts-clients/dist/deployments/${chainEnv === "testnet" ? "dar" : chainEnv}.json`,
4646
{
4747
assert: { type: "json" },
4848
}

cli/src/lib/configs/project/provider.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,14 @@ function resolveCCPConfigYAML(
20052005
return mergeConfigYAMLWithRawConfig(config, computePeerCCPConfig);
20062006
}
20072007

2008-
// const ranges = ["1-2", "3-4", "5-6"];
2008+
function getObjByKey(obj: Record<string, unknown>, key: string): object {
2009+
if (!(key in obj)) {
2010+
return {};
2011+
}
2012+
2013+
const value = obj[key];
2014+
return typeof value === "object" && value !== null ? value : {};
2015+
}
20092016

20102017
function noxConfigYAMLToConfigToml(
20112018
{
@@ -2026,13 +2033,21 @@ function noxConfigYAMLToConfigToml(
20262033
walletKey: walletPrivateKey,
20272034
defaultBaseFee: chain.defaultBaseFee,
20282035
defaultPriorityFee: chain.defaultPriorityFee,
2036+
...getObjByKey(config, "chain_config"),
20292037
};
20302038

20312039
// Would be too hard to properly type this
20322040
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
20332041
return camelCaseKeysToSnakeCase({
20342042
...config,
2035-
...(listenIp === undefined ? {} : { listenConfig: { listenIp } }),
2043+
...(listenIp === undefined
2044+
? {}
2045+
: {
2046+
listenConfig: {
2047+
listenIp,
2048+
...getObjByKey(config, "listen_config"),
2049+
},
2050+
}),
20362051
chainConfig,
20372052
...(env === "local"
20382053
? {}
@@ -2047,6 +2062,7 @@ function noxConfigYAMLToConfigToml(
20472062
ccpConfig.rpcEndpoint?.port ?? DEFAULT_RPC_ENDPOINT_PORT,
20482063
)}`,
20492064
proofPollPeriod: ccp?.proofPollPeriod,
2065+
...getObjByKey(config, "chain_listener_config"),
20502066
},
20512067
}),
20522068
tokioMetricsEnabled: metrics?.tokioMetricsEnabled,
@@ -2124,7 +2140,10 @@ async function getDefaultNoxConfigYAML(): Promise<LatestNoxConfigYAML> {
21242140
const env = await ensureChainEnv();
21252141
const networkId = await getChainId();
21262142
const { DealClient } = await import("@fluencelabs/deal-ts-clients");
2127-
const contractAddresses = DealClient.getContractAddresses(env);
2143+
2144+
const contractAddresses = DealClient.getContractAddresses(
2145+
env === "testnet" ? "dar" : env,
2146+
);
21282147

21292148
return {
21302149
aquavmPoolSize: DEFAULT_AQUAVM_POOL_SIZE,

cli/src/lib/dealClient.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export async function getDealMatcherClient() {
121121
if (dealMatcherClient === undefined) {
122122
const { DealMatcherClient } = await import("@fluencelabs/deal-ts-clients");
123123
const env = await ensureChainEnv();
124-
dealMatcherClient = new DealMatcherClient(env);
124+
dealMatcherClient = new DealMatcherClient(env === "testnet" ? "dar" : env);
125125
}
126126

127127
return dealMatcherClient;
@@ -139,7 +139,7 @@ export async function getDealExplorerClient() {
139139
const env = await ensureChainEnv();
140140

141141
dealExplorerClient = await DealExplorerClient.create(
142-
env,
142+
env === "testnet" ? "dar" : env,
143143
undefined,
144144
provider,
145145
);
@@ -162,8 +162,12 @@ export async function getDealCliClient() {
162162

163163
async function createDealClient(signerOrProvider: Provider | Signer) {
164164
const { DealClient } = await import("@fluencelabs/deal-ts-clients");
165-
const chainEnv = await ensureChainEnv();
166-
const client = new DealClient(signerOrProvider, chainEnv);
165+
const env = await ensureChainEnv();
166+
167+
const client = new DealClient(
168+
signerOrProvider,
169+
env === "testnet" ? "dar" : env,
170+
);
167171

168172
await setTryTimeout(
169173
"check if blockchain client is connected",

0 commit comments

Comments
 (0)