with one click
add-mutation
// Add a new blockchain mutation wrapper using @ecency/sdk in the mobile app
// Add a new blockchain mutation wrapper using @ecency/sdk in the mobile app
| name | add-mutation |
| description | Add a new blockchain mutation wrapper using @ecency/sdk in the mobile app |
| argument-hint | ["operation-name"] |
| disable-model-invocation | true |
Create a mobile mutation wrapper for an @ecency/sdk mutation hook.
@ecency/sdk (platform-agnostic mutation hook)
|
src/providers/sdk/mutations/use<Operation>Mutation.ts (mobile wrapper — adds auth context)
|
Screen / Component (calls the mutation)
The SDK handles all broadcast logic (key signing, HiveSigner, HiveAuth fallback, auth upgrade).
The mobile wrapper just provides the current user and auth context via useMutationAuth().
Location: src/providers/sdk/mutations/use<Operation>Mutation.ts
Every wrapper follows this exact pattern:
import { use<Operation> } from '@ecency/sdk';
import { useMutationAuth } from './common';
export function use<Operation>Mutation() {
const { username, authContext } = useMutationAuth();
return use<Operation>(username, authContext);
}
useMutationAuth() (from ./common.ts) provides:
username — from Redux selectCurrentAccountauthContext — { adapter: mobilePlatformAdapter, enableFallback: true }Add to src/providers/sdk/mutations/index.ts:
export { use<Operation>Mutation } from './use<Operation>Mutation';
import { use<Operation>Mutation } from '../providers/sdk/mutations';
function MyScreen() {
const mutation = use<Operation>Mutation();
const handleSubmit = async () => {
try {
await mutation.mutateAsync({ /* operation params */ });
// Success handling
} catch (error) {
// Error handling (auth upgrade, cancellation, etc.)
}
};
}
The mobilePlatformAdapter in src/providers/sdk/mobilePlatformAdapter.ts handles:
hive-uri encoded operationsHiveAuthBroadcastSheet for keychain app signingAuthUpgradeSheet to collect the key temporarily (60s expiry)You do NOT need to handle any of this in the wrapper — the SDK + adapter handles it automatically.
If the operation isn't in @ecency/sdk yet, create it there first:
Location: packages/sdk/src/modules/<domain>/mutations/use-<operation>.ts
import { useBroadcastMutation, AuthorityLevel } from "@/modules/core/mutations/use-broadcast-mutation";
import { AuthContextV2 } from "@/modules/core/types/auth";
export function use<Operation>(username?: string, auth?: AuthContextV2) {
return useBroadcastMutation(
["<operation-key>"],
async (args: { /* params */ }) => {
return [["<hive_operation_name>", { /* fields */ }]];
},
username,
auth,
{
authorityLevel: AuthorityLevel.POSTING, // or ACTIVE
}
);
}
Then rebuild SDK: cd ../vision-next && pnpm --filter @ecency/sdk build
onSuccess/onError callbacks or handle in the calling component../providers/sdk/mutations@ecency/sdk versionAdd a new feature or screen to the Ecency mobile app following established patterns
Use an @ecency/sdk query in the mobile app or create a new app-specific query
Add a new bottom sheet (action sheet) to the mobile app
Review code changes for bugs, pattern violations, and common pitfalls in ecency-mobile
Debug common issues in the Ecency mobile app with known solutions and investigation patterns