Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/filebase-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ jobs:
NEXT_PUBLIC_FORKED_PROVIDER_API_KEY: ${{ secrets.NEXT_PUBLIC_FORKED_PROVIDER_API_KEY }}
NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}
NEXT_PUBLIC_POSTHOG_HOST: ${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }}
NEXT_PUBLIC_SERVICE_FEE_RECIPIENT: ${{ secrets.NEXT_PUBLIC_SERVICE_FEE_RECIPIENT || 'none' }}
NEXT_PUBLIC_SERVICE_FEE_DOT: ${{ secrets.NEXT_PUBLIC_SERVICE_FEE_DOT }}
NEXT_PUBLIC_SERVICE_FEE_KSM: ${{ secrets.NEXT_PUBLIC_SERVICE_FEE_KSM }}
run: |
[ -n "$NEXT_PUBLIC_SNOWBRIDGE_ENV" ] || { echo "::error::NEXT_PUBLIC_SNOWBRIDGE_ENV secret is not set (add the NEXT_PUBLIC_* repo secrets)."; exit 1; }
pnpm build
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/filebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ jobs:
NEXT_PUBLIC_FORKED_PROVIDER_API_KEY: ${{ secrets.NEXT_PUBLIC_FORKED_PROVIDER_API_KEY }}
NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}
NEXT_PUBLIC_POSTHOG_HOST: ${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }}
NEXT_PUBLIC_SERVICE_FEE_RECIPIENT: ${{ secrets.NEXT_PUBLIC_SERVICE_FEE_RECIPIENT }}
NEXT_PUBLIC_SERVICE_FEE_DOT: ${{ secrets.NEXT_PUBLIC_SERVICE_FEE_DOT }}
NEXT_PUBLIC_SERVICE_FEE_KSM: ${{ secrets.NEXT_PUBLIC_SERVICE_FEE_KSM }}
run: |
[ -n "$NEXT_PUBLIC_SNOWBRIDGE_ENV" ] || { echo "::error::NEXT_PUBLIC_SNOWBRIDGE_ENV secret is not set (add the NEXT_PUBLIC_* repo secrets)."; exit 1; }
[ -n "$NEXT_PUBLIC_SERVICE_FEE_RECIPIENT" ] || { echo "::error::NEXT_PUBLIC_SERVICE_FEE_RECIPIENT secret is not set; service fees would go to the relayer."; exit 1; }
pnpm build

# Single source of the pin logic (scripts/deploy-filebase.sh). It pins the
Expand Down
3 changes: 3 additions & 0 deletions hooks/useBridgeFeeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ async function fetchBridgeFeeInfo([
txValueUsd,
ethToUsdNumerator: BigInt(ethPriceCents),
ethToUsdDenominator: 100n,
// If set, the volume fee is deposited to this Asset Hub account instead of
// being added to the relayer fee.
serviceFeeRecipient: process.env.NEXT_PUBLIC_SERVICE_FEE_RECIPIENT,
};
}

Expand Down
33 changes: 32 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,42 @@ function gzipStatic() {
};
}

export default defineConfig(({ mode }) => {
// Without a recipient the SDK pays the volume fee to the relayer, so a deployed
// build must have one. Set it to "none" to build without a service fee.
function assertServiceFeeRecipient(
value: string | undefined,
isBuild: boolean,
) {
const label = "NEXT_PUBLIC_SERVICE_FEE_RECIPIENT";
if (value === "none") {
console.warn(
`[service fee] ${label}=none, the relayer keeps the volume fee.`,
);
return;
}
const valid = !!value && /^0x[0-9a-fA-F]{64}$/.test(value);
if (valid) return;
const reason = value
? `${label} is not a 32-byte hex account: ${value}`
: `${label} is not set`;
if (isBuild) {
throw new Error(
`${reason}. A deployed build must collect service fees. Set it to a 32-byte ` +
`Asset Hub account, or to "none" to build without one.`,
);
}
console.warn(`[service fee] ${reason}, the relayer keeps the volume fee.`);
}

export default defineConfig(({ mode, command }) => {
// Load .env files (incl. .env.local). The app reads config as
// `process.env.NEXT_PUBLIC_*`; we keep those call sites untouched and
// statically replace them at build time via `define`.
const env = loadEnv(mode, process.cwd(), "");
assertServiceFeeRecipient(
env.NEXT_PUBLIC_SERVICE_FEE_RECIPIENT,
command === "build",
);
const define: Record<string, string> = {};
for (const [key, value] of Object.entries(env)) {
if (key.startsWith("NEXT_PUBLIC_")) {
Expand Down
Loading