diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4c67a0e1..842484f4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -103,11 +103,11 @@ jobs:
tag: ${{ steps.setup_tags.outputs.tag }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
-
+
- name: Setup tags for docker image
id: setup_tags
run: echo "tag=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
-
+
- name: Use Node.js
uses: actions/setup-node@7c29869aec4da703a571b27bcd84d4f15af0b56e
with:
@@ -128,6 +128,29 @@ jobs:
- name: Dump context
uses: crazy-max/ghaction-dump-context@v2
+ setup-build-args:
+ runs-on: ubuntu-latest
+ name: Setup build argument values for docker
+ outputs:
+ network: ${{ steps.network_name_step.outputs.network_name }}
+ is_public: ${{ steps.network_name_step.outputs.is_public }}
+ steps:
+ - name: Dump context
+ uses: crazy-max/ghaction-dump-context@v2
+ - name: Info
+ run: |
+ echo "This is triggered by: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
+ - name: Define network name
+ id: network_name_step
+ run: |
+ if [ "${{ github.event_name}}" = 'release' -a ${{!github.event.release.prerelease}} ] || [ ${{github.event.inputs.ENVIRONMENT_NAME || ''}} = 'Stokenet' -a ${{github.event_name }} = 'workflow_dispatch' ]; then
+ echo "is_public="true"" >> $GITHUB_OUTPUT
+ echo "network_name="${{ github.event.inputs.ENVIRONMENT_NAME }}"" >> $GITHUB_OUTPUT
+ else
+ echo "is_public="false"" >> $GITHUB_OUTPUT
+ echo "network_name=""" >> $GITHUB_OUTPUT
+ fi
+
push-docker-image:
name: (PRIVATE) Docker AMD
needs:
@@ -135,17 +158,20 @@ jobs:
uses: radixdlt/public-iac-resuable-artifacts/.github/workflows/docker-build.yml@main
with:
runs_on: ubuntu-latest
- image_registry: "docker.io"
- image_organization: "radixdlt"
- image_name: "private-radix-dapp-toolkit"
+ image_registry: 'docker.io'
+ image_organization: 'radixdlt'
+ image_name: 'private-radix-dapp-toolkit'
tag: ${{ needs.build.outputs.tag }}
tags: |
type=semver,pattern={{version}}
- context: "./"
- dockerfile: "./Dockerfile"
- platforms: "linux/amd64"
+ context: './'
+ dockerfile: './Dockerfile'
+ platforms: 'linux/amd64'
scan_image: true
snyk_target_ref: ${{ github.ref_name }}
+ build-args: |
+ NETWORK_NAME=${{needs.setup-build-args.outputs.network}}
+ IS_PUBLIC=${{needs.setup-build-args.outputs.is_public}}
snyk-monitor:
runs-on: ubuntu-latest
diff --git a/Dockerfile b/Dockerfile
index 166e025b..46e59ac0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,6 +11,15 @@ COPY package.json ./
COPY package-lock.json ./
RUN npm install
+ARG NETWORK_NAME
+ENV VITE_NETWORK_NAME=$NETWORK_NAME
+
+ARG IS_PUBLIC
+ENV VITE_IS_PUBLIC=$IS_PUBLIC
+
+RUN echo "The VITE_IS_PUBLIC variable value is $VITE_IS_PUBLIC"
+RUN echo "The VITE_NETWORK_NAME variable value is $VITE_NETWORK_NAME"
+
# Copy rest of the files
COPY . .
diff --git a/TEST b/TEST
new file mode 100644
index 00000000..f2af0edd
--- /dev/null
+++ b/TEST
@@ -0,0 +1 @@
+network_name=, is_public=true
diff --git a/build.sh b/build.sh
index 42e2613d..c20fc2f9 100755
--- a/build.sh
+++ b/build.sh
@@ -3,4 +3,4 @@
set -e
# Build the docker image
-docker build -t sandbox:latest .
\ No newline at end of file
+docker build -t sandbox:latest . --build-arg NETWORK_NAME=Stokenet --build-arg IS_PUBLIC=false
\ No newline at end of file
diff --git a/examples/.env.public b/examples/.env.public
new file mode 100644
index 00000000..1c0d7168
--- /dev/null
+++ b/examples/.env.public
@@ -0,0 +1,2 @@
+VITE_NETWORK_NAME=Stokenet
+VITE_IS_PUBLIC=true
\ No newline at end of file
diff --git a/examples/config.ts b/examples/config.ts
new file mode 100644
index 00000000..79b77e6a
--- /dev/null
+++ b/examples/config.ts
@@ -0,0 +1,4 @@
+///
+
+export const IS_PUBLIC = import.meta.env.VITE_IS_PUBLIC === 'true'
+export const ENV_NETWORK_NAME = import.meta.env.VITE_NETWORK_NAME
diff --git a/examples/helpers/get-network-id.ts b/examples/helpers/get-network-id.ts
index 4b1f5d37..e6f4cda7 100644
--- a/examples/helpers/get-network-id.ts
+++ b/examples/helpers/get-network-id.ts
@@ -1,6 +1,13 @@
-import { RadixNetwork } from '@radixdlt/babylon-gateway-api-sdk'
+import {
+ RadixNetwork,
+ RadixNetworkConfig,
+} from '@radixdlt/babylon-gateway-api-sdk'
+import { ENV_NETWORK_NAME } from '../config'
-export const DEFAULT_NETWORK_ID = RadixNetwork.RCnetV3.toString()
+const networkId = RadixNetworkConfig?.[ENV_NETWORK_NAME]?.networkId
+
+export const DEFAULT_NETWORK_ID =
+ String(networkId) || RadixNetwork.Stokenet.toString()
export const getNetworkId = () => {
const urlParams = new URLSearchParams(window.location.search)
diff --git a/examples/layouts/Header.tsx b/examples/layouts/Header.tsx
index 32c187d3..34b012a4 100644
--- a/examples/layouts/Header.tsx
+++ b/examples/layouts/Header.tsx
@@ -10,6 +10,7 @@ import Select from '@mui/joy/Select'
import Option from '@mui/joy/Option'
import { setNetworkId, useNetworkId } from '../network/state'
import { RadixNetworkConfig } from '@radixdlt/babylon-gateway-api-sdk'
+import { IS_PUBLIC } from '../config'
declare global {
namespace JSX {
@@ -50,12 +51,14 @@ export const Header = ({
>
-
+
+
+
- {Object.values(RadixNetworkConfig).map(
- ({ networkId, networkName }) => (
-
+
+ >
+ ) : (
+ Object.values(RadixNetworkConfig).map(
+ ({ networkId, networkName }) => (
+
+ )
)
)}
diff --git a/examples/layouts/Sidebar.tsx b/examples/layouts/Sidebar.tsx
index f59f8a9c..ddfaaa2e 100644
--- a/examples/layouts/Sidebar.tsx
+++ b/examples/layouts/Sidebar.tsx
@@ -7,6 +7,7 @@ import ListItemButton from '@mui/joy/ListItemButton'
import ListItemContent from '@mui/joy/ListItemContent'
import KeyboardArrowDownRoundedIcon from '@mui/icons-material/KeyboardArrowDownRounded'
import { NavLink } from 'react-router-dom'
+import { IS_PUBLIC } from '../config'
export const Sidebar = () => (
@@ -29,39 +30,52 @@ export const Sidebar = () => (
}}
>
{[
- { path: 'data-request', label: 'Data Requests' },
- { path: 'one-time-data-request', label: 'One Time Data Requests' },
- { path: 'create-token', label: 'Create Token' },
- { path: 'pools', label: 'Pools' },
- { path: 'standard-metadata', label: 'Standard Metadata' },
+ { path: 'data-request', label: 'Data Requests', hidePublic: false },
+ {
+ path: 'one-time-data-request',
+ label: 'One Time Data Requests',
+ hidePublic: false,
+ },
+ { path: 'create-token', label: 'Create Token', hidePublic: true },
+ { path: 'pools', label: 'Pools', hidePublic: true },
+ {
+ path: 'standard-metadata',
+ label: 'Standard Metadata',
+ hidePublic: true,
+ },
{
path: 'send-transaction',
label: 'Send Transaction',
+ hidePublic: true,
},
{
path: 'rola',
label: 'ROLA',
+ hidePublic: true,
},
{
path: 'integration-tests',
label: 'Integration Tests',
+ hidePublic: true,
},
- { path: 'settings', label: 'Settings' },
- ].map((item) => (
-
- {({ isActive }) => (
-
-
- {item.label}
-
-
- )}
-
- ))}
+ { path: 'settings', label: 'Settings', hidePublic: false },
+ ]
+ .filter((item) => !item.hidePublic || !IS_PUBLIC)
+ .map((item) => (
+
+ {({ isActive }) => (
+
+
+ {item.label}
+
+
+ )}
+
+ ))}
diff --git a/examples/network/state.ts b/examples/network/state.ts
index 03090932..9d66f22f 100644
--- a/examples/network/state.ts
+++ b/examples/network/state.ts
@@ -6,6 +6,7 @@ import {
RadixNetwork,
RadixNetworkConfigById,
} from '@radixdlt/babylon-gateway-api-sdk'
+import { DEFAULT_NETWORK_ID } from '../helpers/get-network-id'
export const bootstrapNetwork = (networkId: number) => {
const gatewayApi = GatewayApiClient.initialize({
@@ -39,7 +40,7 @@ const getNetworkIdDefault = () => {
const networkId = parseInt(
urlParams.get('networkId') ||
localStorage.getItem('networkId') ||
- RadixNetwork.Stokenet.toString(),
+ DEFAULT_NETWORK_ID,
10
)
return networkId
diff --git a/examples/router.tsx b/examples/router.tsx
index cc9c7874..cdd67e04 100644
--- a/examples/router.tsx
+++ b/examples/router.tsx
@@ -10,49 +10,67 @@ import { RolaPage } from './rola/RolaPage'
import { OneTimeDataRequestsPage } from './one-time-data-request/OneTimeDataRequestsPage'
import { PoolsPage } from './pools/PoolsPage'
import { StandardMetadataPage } from './standard-metadata/StandardMetadataPage'
+import { IS_PUBLIC } from './config'
export const router = createBrowserRouter([
{
path: '/',
element: ,
children: [
- { index: true, element: },
+ {
+ index: true,
+ element: ,
+ hidePublic: false,
+ },
{
path: 'data-request',
element: ,
+ hidePublic: false,
},
{
path: 'one-time-data-request',
element: ,
+ hidePublic: false,
},
{
path: 'create-token',
element: ,
+ hidePublic: true,
},
{
path: 'integration-tests',
element: ,
+ hidePublic: true,
},
{
path: 'standard-metadata',
element: ,
+ hidePublic: true,
},
{
path: 'send-transaction',
element: ,
+ hidePublic: true,
},
{
path: 'pools',
element: ,
+ hidePublic: true,
},
{
path: 'settings',
element: ,
+ hidePublic: false,
},
{
path: 'rola',
element: ,
+ hidePublic: true,
},
- ],
+ ]
+ .filter((route) => {
+ return !IS_PUBLIC || !route.hidePublic
+ })
+ .map(({ path, element }) => ({ path, element })),
},
])
diff --git a/examples/settings/SettingsPage.tsx b/examples/settings/SettingsPage.tsx
index f687debd..09dd889a 100644
--- a/examples/settings/SettingsPage.tsx
+++ b/examples/settings/SettingsPage.tsx
@@ -8,6 +8,7 @@ import Select from '@mui/joy/Select'
import Option from '@mui/joy/Option'
import { FormControl, FormLabel } from '@mui/joy'
import { patchConnectButtonConfig, useConnectButtonConfig } from '../rdt/state'
+import { IS_PUBLIC } from '../config'
export const SettingsPage = () => {
const connectButtonConfig = useConnectButtonConfig()
const dAppDefinitionAddress = useDAppDefinitionAddress()
@@ -26,28 +27,31 @@ export const SettingsPage = () => {
gap: 2,
}}
>
-
-
+
+ )}
+
Theme
diff --git a/package.json b/package.json
index 5c01c812..018bef5e 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,10 @@
],
"scripts": {
"dev": "vite serve examples",
+ "dev:public": "vite serve examples --mode public",
"build": "tsc && vite build",
+ "build:sandbox": "vite build examples",
+ "build:sandbox:public": "vite build examples --mode public",
"prepare": "npx husky install",
"test": "jest",
"test:watch": "jest --watch"