Skip to content

Commit 8593ca6

Browse files
authored
Merge pull request #102 from kaleido-io/default-ns
update sandbox to work with different namespaces
2 parents 5a7d32f + 86176f5 commit 8593ca6

File tree

8 files changed

+23
-4
lines changed

8 files changed

+23
-4
lines changed

server/src/clients/firefly.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { InternalServerError } from 'routing-controllers';
33

44
export const firefly = new FireFly({
55
host: process.env.FF_ENDPOINT || 'http://localhost:5000',
6+
namespace: process.env.FF_DEFAULT_NAMESPACE || 'default',
67
});
78

89
firefly.onError((err) => {

server/src/controllers/common.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Get, InternalServerError, JsonController, Param, QueryParam } from 'rou
22
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
33
import { firefly } from '../clients/firefly';
44
import { FFStatus, Organization, Plugin, Plugins, Transaction, Verifier } from '../interfaces';
5-
5+
const DEFAULT_NAMESPACE = process.env.FF_DEFAULT_NAMESPACE || 'default';
66
/**
77
* Common Operations - API Server
88
*/
@@ -35,7 +35,7 @@ export class CommonController {
3535
async verifiers(): Promise<Verifier[]> {
3636
try {
3737
const orgs = await firefly.getOrganizations();
38-
let verifiers = await firefly.getVerifiers('default');
38+
let verifiers = await firefly.getVerifiers(DEFAULT_NAMESPACE);
3939
if (verifiers.length === 0) {
4040
// attempt to query legacy ff_system verifiers
4141
verifiers = await firefly.getVerifiers('ff_system');
@@ -61,7 +61,7 @@ export class CommonController {
6161
@OpenAPI({ summary: 'List verifiers (such as Ethereum keys) for local organization' })
6262
async verifierSelf(): Promise<Verifier[]> {
6363
const status = await firefly.getStatus();
64-
const verifiers = await firefly.getVerifiers('default');
64+
const verifiers = await firefly.getVerifiers(DEFAULT_NAMESPACE);
6565
const result: Verifier[] = [];
6666
for (const v of verifiers) {
6767
if (status.org?.id === v.identity) {
@@ -101,11 +101,13 @@ export class CommonController {
101101
if ("multiparty" in status) {
102102
return {
103103
multiparty: status.multiparty?.enabled,
104+
namespace: DEFAULT_NAMESPACE,
104105
};
105106
} else {
106107
// Assume multiparty mode if `multiparty` key is missing from status
107108
return {
108-
multiparty: true
109+
multiparty: true,
110+
namespace: DEFAULT_NAMESPACE,
109111
}
110112
}
111113
}

server/src/interfaces.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,4 +388,7 @@ export class DatatypeInterface {
388388
export class FFStatus {
389389
@IsBoolean()
390390
multiparty: boolean;
391+
392+
@IsString()
393+
namespace: string;
391394
}

ui/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function App() {
4444
type: '',
4545
id: '',
4646
});
47+
const [namespace, setNamespace] = useState('');
4748
const [tokensDisabled, setTokensDisabled] = useState(false);
4849
const [blockchainPlugin, setBlockchainPlugin] = useState('');
4950
const [tutorialSections, setTutorialSections] = useState<ITutorialSection[]>(
@@ -66,6 +67,7 @@ function App() {
6667
);
6768
const ffStatus = statusResponse as IFireflyStatus;
6869
setMultiparty(ffStatus.multiparty);
70+
setNamespace(ffStatus.namespace);
6971
if (ffStatus.multiparty === true) {
7072
setTutorialSections(TutorialSections);
7173
fetchCatcher(SDK_PATHS.verifiers)
@@ -122,6 +124,7 @@ function App() {
122124
blockchainPlugin,
123125
multiparty,
124126
tutorialSections,
127+
namespace,
125128
}}
126129
>
127130
<StyledEngineProvider injectFirst>

ui/src/components/Header.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import ReconnectingWebSocket from 'reconnecting-websocket';
3939
import { ReactComponent as DiscordLogo } from '../assets/Discord-Logo-White.svg';
4040
import { ResourceUrls } from '../constants/ResourceUrls';
4141
import { EventContext } from '../contexts/EventContext';
42+
import { ApplicationContext } from '../contexts/ApplicationContext';
4243
import { FF_EVENTS } from '../ff_models/eventTypes';
4344
import { DEFAULT_BORDER_RADIUS, DEFAULT_PADDING, FFColors } from '../theme';
4445
import { MenuLogo } from './Logos/MenuLogo';
@@ -52,6 +53,7 @@ export const Header: React.FC = () => {
5253
const { t } = useTranslation();
5354
const theme = useTheme();
5455
const { addLogToHistory } = useContext(EventContext);
56+
const { namespace } = useContext(ApplicationContext);
5557
const [wsConnected, setWsConnected] = useState<boolean>(false);
5658
const webSocket = useRef<ReconnectingWebSocket | null>(null);
5759
const [isModalOpen, setIsModalOpen] = useState(false);
@@ -201,6 +203,11 @@ export const Header: React.FC = () => {
201203
onClick={connectToWS}
202204
/>
203205
</Tooltip>
206+
<Grid item paddingLeft={1}>
207+
<Typography>
208+
{t('namespaceX', { namespace: namespace })}
209+
</Typography>
210+
</Grid>
204211
<IconButton
205212
color="inherit"
206213
onClick={() => setIsModalOpen(true)}

ui/src/contexts/ApplicationContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface IApplicationContext {
3636
blockchainPlugin: string;
3737
multiparty: boolean;
3838
tutorialSections: ITutorialSection[];
39+
namespace: string;
3940
}
4041

4142
export const ApplicationContext = createContext({} as IApplicationContext);

ui/src/interfaces/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface IApiStatus {
1010

1111
export interface IFireflyStatus {
1212
multiparty: boolean;
13+
namespace: string;
1314
}
1415

1516
export interface IBatch {

ui/src/translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"name": "Name",
120120
"namespaceConfirmed": "Namespace Confirmed",
121121
"namespaceID": "Namespace ID",
122+
"namespaceX": "Namespace: {{namespace}}",
122123
"noAPIsRegisteredWithFireFly": "No APIs Registered with FireFly",
123124
"noBalancesForWallet": "No Balances for Wallet",
124125
"noConnectors": "No Token Connectors",

0 commit comments

Comments
 (0)