axie-ronin-ethers-js-tools
Version:
A set of functions that make it easier for developers to interact with their Axies on the Ronin network and the maketplace.
36 lines (35 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = createActivity;
const constants_1 = require("../constants");
const utils_1 = require("../utils");
// create the activity on the user profile, this is optional
async function createActivity(action, data, accessToken) {
const activityQuery = `mutation AddActivity($action: Action!, $data: ActivityDataInput!) {
createActivity(action: $action, data: $data) {
result
__typename
}
}`;
const activityVariables = {
action,
data
};
// API request authorization headers
const headers = {
'authorization': `Bearer ${accessToken}`,
'x-api-key': process.env.SKYMAVIS_DAPP_KEY
};
// Create the activity on the marketplace
const activityResult = await (0, utils_1.apiRequest)(constants_1.GRAPHQL_URL, JSON.stringify({ query: activityQuery, variables: activityVariables }), headers);
if (activityResult === null || activityResult.data === undefined) {
console.log('Error creating activity');
return false;
}
if (activityResult.errors !== undefined) {
console.log('Error creating activity', activityResult.errors);
return false;
}
console.log(activityResult);
return activityResult.data.createActivity.result;
}