Use new /send_activity API method instead of /signed_update

This commit is contained in:
silverpill 2022-11-07 18:50:31 +00:00
parent f939d9ff9a
commit 9e0c883bc9
2 changed files with 16 additions and 11 deletions

View file

@ -240,9 +240,14 @@ export async function updateProfile(
} }
} }
interface ActivityParams {
type: "update",
[key: string]: any,
}
interface UnsignedActivity { interface UnsignedActivity {
internal_activity_id: string, params: ActivityParams,
activity: string, message: string,
} }
export async function getUnsignedUpdate( export async function getUnsignedUpdate(
@ -254,17 +259,17 @@ export async function getUnsignedUpdate(
return data return data
} }
export async function sendSignedUpdate( export async function sendSignedActivity(
authToken: string, authToken: string,
internalActivityId: string, activityParams: ActivityParams,
walletAddress: string, walletAddress: string,
signature: string, signature: string,
): Promise<void> { ): Promise<void> {
const url = `${BACKEND_URL}/api/v1/accounts/signed_update` const url = `${BACKEND_URL}/api/v1/accounts/send_activity`
const response = await http(url, { const response = await http(url, {
method: "POST", method: "POST",
json: { json: {
internal_activity_id: internalActivityId, params: activityParams,
signer: createDidFromEthereumAddress(walletAddress), signer: createDidFromEthereumAddress(walletAddress),
signature: signature.replace(/0x/, ""), signature: signature.replace(/0x/, ""),
}, },

View file

@ -1,4 +1,4 @@
import { getUnsignedUpdate, sendSignedUpdate } from "@/api/users" import { getUnsignedUpdate, sendSignedActivity } from "@/api/users"
import { useCurrentUser } from "@/store/user" import { useCurrentUser } from "@/store/user"
import { getWallet, getWalletSignature } from "@/utils/ethereum" import { getWallet, getWalletSignature } from "@/utils/ethereum"
@ -13,11 +13,11 @@ async function signActivity(): Promise<void> {
} }
const walletAddress = await signer.getAddress() const walletAddress = await signer.getAddress()
const authToken = ensureAuthToken() const authToken = ensureAuthToken()
const { internal_activity_id, activity } = await getUnsignedUpdate(authToken) const { params, message } = await getUnsignedUpdate(authToken)
const signature = await getWalletSignature(signer, activity) const signature = await getWalletSignature(signer, message)
await sendSignedUpdate( await sendSignedActivity(
authToken, authToken,
internal_activity_id, params,
walletAddress, walletAddress,
signature, signature,
) )