diff --git a/apps/namadillo/public/config.toml b/apps/namadillo/public/config.toml index 9e4e902e0a..70c44d7539 100644 --- a/apps/namadillo/public/config.toml +++ b/apps/namadillo/public/config.toml @@ -4,3 +4,4 @@ #masp_indexer_url = "" #localnet_enabled = false #fathom_site_id = "" +#is_heliax_namadillo = false diff --git a/apps/namadillo/src/atoms/proposals/functions.ts b/apps/namadillo/src/atoms/proposals/functions.ts index e4f6526222..5e3886e5ea 100644 --- a/apps/namadillo/src/atoms/proposals/functions.ts +++ b/apps/namadillo/src/atoms/proposals/functions.ts @@ -25,6 +25,7 @@ import { VoteType, } from "@namada/types"; import { assertNever, mapUndefined } from "@namada/utils"; +import { appendNamadilloBranding } from "atoms/settings"; import BigNumber from "bignumber.js"; import * as E from "fp-ts/Either"; import * as t from "io-ts"; @@ -389,6 +390,8 @@ export const createVoteProposalTx = async ( ): Promise> => { try { const sdk = await getSdkInstance(); + const memo = appendNamadilloBranding(); + const voteProposalProps = { signer: account.address, proposalId, @@ -400,7 +403,8 @@ export const createVoteProposalTx = async ( gasConfig, chain, [voteProposalProps], - sdk.tx.buildVoteProposal + sdk.tx.buildVoteProposal, + memo ); return await signEncodedTx(encodedTx, account.address); } catch (err) { diff --git a/apps/namadillo/src/atoms/settings/atoms.ts b/apps/namadillo/src/atoms/settings/atoms.ts index e223bfc194..47987280f6 100644 --- a/apps/namadillo/src/atoms/settings/atoms.ts +++ b/apps/namadillo/src/atoms/settings/atoms.ts @@ -128,6 +128,10 @@ export const rpcUrlAtom = atom((get) => { return ""; }); +export const isHeliaxNamadilloAtom = atom((get) => { + return get(defaultServerConfigAtom).data?.is_heliax_namadillo ?? false; +}); + export const updateRpcUrlAtom = atomWithMutation(() => { return { mutationKey: ["update-rpc-url"], @@ -277,3 +281,20 @@ export const lastInvalidateShieldedContextAtom = atomWithStorage<{ } | undefined; }>("namadillo:last-invalidate-shielded-context", {}); + +/** + * Returns a memo with "Powered by Namadillo" appended if this is a Heliax Namadillo instance. + * @param userMemo - Optional user-provided memo text + * @returns The final memo to use in transactions + */ +export const appendNamadilloBranding = ( + userMemo?: string +): string | undefined => { + const store = getDefaultStore(); + const isHeliaxNamadillo = store.get(isHeliaxNamadilloAtom); + const branding = "Powered by Namadillo"; + + if (!isHeliaxNamadillo) return userMemo; + else if (userMemo) return `${userMemo} | ${branding}`; + else return branding; +}; diff --git a/apps/namadillo/src/atoms/staking/services.ts b/apps/namadillo/src/atoms/staking/services.ts index 233c1b0df1..96db1660fb 100644 --- a/apps/namadillo/src/atoms/staking/services.ts +++ b/apps/namadillo/src/atoms/staking/services.ts @@ -10,6 +10,7 @@ import { } from "@namada/sdk-multicore"; import { Account } from "@namada/types"; import { queryClient } from "App/Common/QueryProvider"; +import { appendNamadilloBranding } from "atoms/settings"; import { EncodedTxData, buildTx } from "lib/query"; import { Address, AddressBalance, ChainSettings, GasConfig } from "types"; import { getSdkInstance } from "utils/sdk"; @@ -29,13 +30,16 @@ export const createBondTx = async ( gasConfig: GasConfig ): Promise | undefined> => { const sdk = await getSdkInstance(); + const memo = appendNamadilloBranding(); + return await buildTx( sdk, account, gasConfig, chain, bondProps, - sdk.tx.buildBond + sdk.tx.buildBond, + memo ); }; @@ -46,13 +50,16 @@ export const createUnbondTx = async ( gasConfig: GasConfig ): Promise> => { const sdk = await getSdkInstance(); + const memo = appendNamadilloBranding(); + return await buildTx( sdk, account, gasConfig, chain, unbondProps, - sdk.tx.buildUnbond + sdk.tx.buildUnbond, + memo ); }; @@ -63,13 +70,16 @@ export const createReDelegateTx = async ( gasConfig: GasConfig ): Promise> => { const sdk = await getSdkInstance(); + const memo = appendNamadilloBranding(); + return await buildTx( sdk, account, gasConfig, chain, redelegateProps, - sdk.tx.buildRedelegate + sdk.tx.buildRedelegate, + memo ); }; @@ -80,13 +90,16 @@ export const createWithdrawTx = async ( gasConfig: GasConfig ): Promise> => { const sdk = await getSdkInstance(); + const memo = appendNamadilloBranding(); + return await buildTx( sdk, account, gasConfig, chain, withdrawProps, - sdk.tx.buildWithdraw + sdk.tx.buildWithdraw, + memo ); }; @@ -97,13 +110,16 @@ export const createClaimTx = async ( gasConfig: GasConfig ): Promise> => { const sdk = await getSdkInstance(); + const memo = appendNamadilloBranding(); + return await buildTx( sdk, account, gasConfig, chain, params, - sdk.tx.buildClaimRewards + sdk.tx.buildClaimRewards, + memo ); }; @@ -150,13 +166,16 @@ export const createClaimAndStakeTx = async ( } }); + const memo = appendNamadilloBranding(); + return await buildTx( sdk, account, gasConfig, chain, claimAndStakingParams, - buildClaimRewardsAndStake + buildClaimRewardsAndStake, + memo ); }; diff --git a/apps/namadillo/src/atoms/transfer/services.ts b/apps/namadillo/src/atoms/transfer/services.ts index 9e7ba4e91f..df7b96a92d 100644 --- a/apps/namadillo/src/atoms/transfer/services.ts +++ b/apps/namadillo/src/atoms/transfer/services.ts @@ -13,6 +13,7 @@ import { AccountType, GenDisposableSignerResponse, } from "@namada/types"; +import { appendNamadilloBranding } from "atoms/settings"; import BigNumber from "bignumber.js"; import * as Comlink from "comlink"; import { NamadaKeychain } from "hooks/useNamadaKeychain"; @@ -93,6 +94,8 @@ export const createTransparentTransferTx = async ( memo?: string ): Promise | undefined> => { const sdk = await getSdkInstance(); + const finalMemo = appendNamadilloBranding(memo); + return await buildTx( sdk, account, @@ -100,7 +103,7 @@ export const createTransparentTransferTx = async ( chain, props, sdk.tx.buildTransparentTransfer, - memo + finalMemo ); }; @@ -132,6 +135,8 @@ export const createShieldedTransferTx = async ( ledger.closeTransport(); } + const finalMemo = appendNamadilloBranding(memo); + return await workerBuildTxPair({ rpcUrl, nativeToken: chain.nativeTokenAddress, @@ -151,7 +156,7 @@ export const createShieldedTransferTx = async ( gasConfig, props: [msgValue], chain, - memo, + memo: finalMemo, }, }; return (await workerLink.shieldedTransfer(msg)).payload; @@ -184,6 +189,8 @@ export const createShieldingTransferTx = async ( ledger.closeTransport(); } + const finalMemo = appendNamadilloBranding(memo); + return await workerBuildTxPair({ rpcUrl, nativeToken: chain.nativeTokenAddress, @@ -202,7 +209,7 @@ export const createShieldingTransferTx = async ( props: [msgValue], chain, publicKeyRevealed, - memo, + memo: finalMemo, }, }; return (await workerLink.shield(msg)).payload; @@ -239,6 +246,8 @@ export const createUnshieldingTransferTx = async ( ledger.closeTransport(); } + const finalMemo = appendNamadilloBranding(memo); + return await workerBuildTxPair({ rpcUrl, nativeToken: chain.nativeTokenAddress, @@ -259,7 +268,7 @@ export const createUnshieldingTransferTx = async ( gasConfig, props: [msgValue], chain, - memo, + memo: finalMemo, }, }; return (await workerLink.unshield(msg)).payload; @@ -284,6 +293,8 @@ export const createIbcTx = async ( ledger.closeTransport(); } + const finalMemo = appendNamadilloBranding(memo); + return await workerBuildTxPair({ rpcUrl, nativeToken: chain.nativeTokenAddress, @@ -309,7 +320,7 @@ export const createIbcTx = async ( gasConfig, props: [msgValue], chain, - memo, + memo: finalMemo, publicKeyRevealed, }, }; @@ -338,6 +349,7 @@ export const createOsmosisSwapTx = async ( ledger.closeTransport(); } const { transfer } = props[0]; + const finalMemo = appendNamadilloBranding(memo); return await workerBuildTxPair({ rpcUrl, @@ -361,7 +373,7 @@ export const createOsmosisSwapTx = async ( gasConfig, props: [msgValue], chain, - memo, + memo: finalMemo, }, }; diff --git a/apps/namadillo/src/types.ts b/apps/namadillo/src/types.ts index b02739eee2..dcfc281eb6 100644 --- a/apps/namadillo/src/types.ts +++ b/apps/namadillo/src/types.ts @@ -71,6 +71,7 @@ export type SettingsTomlOptions = { rpc_url?: string; localnet_enabled?: boolean; fathom_site_id?: string; + is_heliax_namadillo?: boolean; }; export type ChainParameters = {