Skip to content

Commit

Permalink
Merge pull request #406 from Kodylow/fix-config-gen-submit
Browse files Browse the repository at this point in the history
fix: required config gen local and consensus + fix password runtime error
  • Loading branch information
elsirion authored Mar 30, 2024
2 parents 07c428a + 3bcb230 commit f209a59
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
10 changes: 6 additions & 4 deletions apps/guardian-ui/src/components/SetConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
formatApiErrorMessage,
getModuleParamsFromConfig,
applyConfigGenModuleParams,
removeConfigGenModuleConsensusParams,
} from '../utils/api';
import { isValidMeta, isValidNumber } from '../utils/validators';
import { NumberFormControl } from './NumberFormControl';
Expand Down Expand Up @@ -210,7 +209,7 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
configs: {
hostServerUrl,
meta: {},
modules: removeConfigGenModuleConsensusParams(moduleConfigs),
modules: moduleConfigs,
},
});
}
Expand Down Expand Up @@ -250,7 +249,9 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
</FormHelperText>
</FormControl>
<FormControl
isInvalid={password !== confirmPassword && password.length > 0}
isInvalid={
!!password && password !== confirmPassword && password.length > 0
}
>
<FormLabel>{t('set-config.confirm-password')}</FormLabel>
<Input
Expand All @@ -259,7 +260,8 @@ export const SetConfiguration: React.FC<Props> = ({ next }: Props) => {
onChange={(ev) => setConfirmPassword(ev.currentTarget.value)}
/>
<FormErrorMessage>
{password !== confirmPassword &&
{!!password &&
password !== confirmPassword &&
password.length > 0 &&
t('set-config.error-password-mismatch')}
</FormErrorMessage>
Expand Down
1 change: 1 addition & 0 deletions apps/guardian-ui/src/setup/SetupContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export const SetupContextProvider: React.FC<SetupContextProviderProps> = ({
// Followers set their own connection name, and hosts server URL to connect to.
await api.setConfigGenConnections(myName, configs.hostServerUrl);

console.log('configs', configs);
// Followers submit ONLY their local config gen params.
await api.setConfigGenParams(configs);

Expand Down
13 changes: 0 additions & 13 deletions apps/guardian-ui/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ export function applyConfigGenModuleParams(
return newModuleParams;
}

/**
* Filter out consensus module config gen params to only have local ones.
*/
export function removeConfigGenModuleConsensusParams(
moduleParams: ConfigGenParams['modules']
): ConfigGenParams['modules'] {
const newParams = { ...moduleParams };
Object.values(newParams).forEach((module) => {
module[1] = { local: module[1].local };
});
return newParams;
}

/**
* Given a config, filter out all non-default modules
*/
Expand Down
17 changes: 7 additions & 10 deletions packages/types/src/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,31 @@ export type ModuleConfig<T extends ModuleKind = ModuleKind> = {
export type LnModuleParams = [
ModuleKind.Ln,
{
consensus?: object;
local?: object;
consensus: object;
local: object;
}
];
export type MintModuleParams = [
ModuleKind.Mint,
{
consensus?: { mint_amounts: number[] };
local?: object;
consensus: { mint_amounts: number[] };
local: object;
}
];
export type WalletModuleParams = [
ModuleKind.Wallet,
{
consensus?: {
consensus: {
finality_delay: number;
network: Network;
client_default_bitcoin_rpc: BitcoinRpc;
};
local?: {
local: {
bitcoin_rpc: BitcoinRpc;
};
}
];
export type OtherModuleParams = [
string,
{ consensus?: object; local?: object }
];
export type OtherModuleParams = [string, { consensus: object; local: object }];
export type AnyModuleParams =
| LnModuleParams
| MintModuleParams
Expand Down

0 comments on commit f209a59

Please sign in to comment.