Update
Updating a user will only succeed for the user object associated with the user's wallet. The lowercase value of the user name must remain the same.
Update a Sage user
import { useSignAndExecuteTransaction } from '@mysten/dapp-kit';
import { useUser } from '@sage-app/sdk/react';
interface UserUpdateInput {
amounts: number[]; // payment amounts set to [0, 0]
avatarHash?: string;
bannerHash?: string;
description: string;
name: string;
self: string; // user's wallet address
userId: string; // user's object address
}
...
const { mutateAsync: signAndExecuteTransaction } = useSignAndExecuteTransaction();
const { update } = useUser();
...
const updateUser = async (data: UserUpdateInput) => {
const { ok, err, transaction } = await update(data);
const { digest } = await signAndExecuteTransaction({
transaction
});
};
Error Codes
User Actions module
Code
Value
Meaning
373
EUserNameMismatch
The lowercase value of the new channel name must match the lowercase value of the old channel name, or the user object is not associated with the wallet address.
User Fees module
Code
Value
Meaning
370
EIncorrectCoinType
Custom payment type does not match configured custom payment coin.
371
EIncorrectCustomPayment
Incorrect custom payment value.
372
EIncorrectSuiPayment
Incorrect sui payment value.
Querying for Channel Update Events
import { EventId, SuiClient, getFullnodeUrl } from '@mysten/sui/client';
import { SageClient } from '@sage-app/sdk/client';
...
interface QueryInput {
cursor?: EventId;
}
const appId = '<YOUR_APP_ID>';
const network = 'mainnet' | 'testnet';
const suiClient = new SuiClient({ url: getFullnodeUrl(network) });
const sageClient = new SageClient({ appId, network, suiClient });
...
const pollUserUpdates = async ({ cursor }) => {
const {
eventCount,
events,
hasNextPage,
nextCursor
} = await sageClient.queryUserCreateEvents({ cursor }: QueryInput);
// do something with events
setTimeout(() => pollUserUpdates({ cursor: nextCursor }), 5000);
};
In this case events will take the shape of an array of UserUpdateEvent:
interface UserUpdateEvent {
avatarHash: string;
bannerHash: string;
description: string;
updatedAt: string;
userKey: string; // e.g. "matrix-rick" (unique value, lowercase)
userName: string; // e.g. "MaTriX-riCK" (display name)
}
Last updated