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 {
internal_activity_id: string,
activity: string,
params: ActivityParams,
message: string,
}
export async function getUnsignedUpdate(
@ -254,17 +259,17 @@ export async function getUnsignedUpdate(
return data
}
export async function sendSignedUpdate(
export async function sendSignedActivity(
authToken: string,
internalActivityId: string,
activityParams: ActivityParams,
walletAddress: string,
signature: string,
): 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, {
method: "POST",
json: {
internal_activity_id: internalActivityId,
params: activityParams,
signer: createDidFromEthereumAddress(walletAddress),
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 { getWallet, getWalletSignature } from "@/utils/ethereum"
@ -13,11 +13,11 @@ async function signActivity(): Promise<void> {
}
const walletAddress = await signer.getAddress()
const authToken = ensureAuthToken()
const { internal_activity_id, activity } = await getUnsignedUpdate(authToken)
const signature = await getWalletSignature(signer, activity)
await sendSignedUpdate(
const { params, message } = await getUnsignedUpdate(authToken)
const signature = await getWalletSignature(signer, message)
await sendSignedActivity(
authToken,
internal_activity_id,
params,
walletAddress,
signature,
)