@stackedapp/utils 2.16.0 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILevelCondition, ICurrencyCondition, IStakedTokensCondition, ITrustScoreCondition, IDaysInGameCondition, ILoginStreakCondition, IAchievementCondition, IMembershipCondition, IQuestCondition, IEntityLinkCondition, IDynamicConditionItem, IIdentifiersCondition, ITokenBalanceCondition, IStackedAccountCondition, IUserSettingsCondition, IBuyItemCondition, ISpendCurrencyCondition, IDepositCurrencyCondition, ISocialCondition, ILoginCondition, ICompletionContextCondition, ILinkedCompletionsCondition, IDynamicTrackerCondition, IContractInteractionCondition, ICompletionTrackers, ConditionDetail, StackedSnapshot, StackedBaseUserExtra } from '@stackedapp/types';
|
|
1
|
+
import { ILevelCondition, ICurrencyCondition, IStakedTokensCondition, ITrustScoreCondition, IDaysInGameCondition, ILoginStreakCondition, IAchievementCondition, IMembershipCondition, IQuestCondition, IEntityLinkCondition, IDynamicConditionItem, IIdentifiersCondition, ITokenBalanceCondition, IStackedAccountCondition, IUserSettingsCondition, IBuyItemCondition, ISpendCurrencyCondition, IDepositCurrencyCondition, ISocialCondition, ILoginCondition, ICompletionContextCondition, ILinkedCompletionsCondition, IDynamicTrackerCondition, IContractInteractionCondition, ISocialEngagementCondition, ICompletionTrackers, ConditionDetail, StackedSnapshot, StackedBaseUserExtra } from '@stackedapp/types';
|
|
2
2
|
export interface EvalContext {
|
|
3
3
|
snap: StackedSnapshot;
|
|
4
4
|
additionalData?: StackedBaseUserExtra;
|
|
@@ -38,4 +38,5 @@ export declare function evaluateSocial(cond: ISocialCondition, ctx: EvalContext)
|
|
|
38
38
|
export declare function evaluateLinkedCompletions(cond: ILinkedCompletionsCondition, ctx: EvalContext): EvalResult;
|
|
39
39
|
export declare function evaluateDynamicTracker(cond: IDynamicTrackerCondition, ctx: EvalContext): EvalResult;
|
|
40
40
|
export declare function evaluateContractInteraction(cond: IContractInteractionCondition, ctx: EvalContext): EvalResult;
|
|
41
|
+
export declare function evaluateSocialEngagement(cond: ISocialEngagementCondition, ctx: EvalContext): EvalResult;
|
|
41
42
|
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -24,6 +24,7 @@ exports.evaluateSocial = evaluateSocial;
|
|
|
24
24
|
exports.evaluateLinkedCompletions = evaluateLinkedCompletions;
|
|
25
25
|
exports.evaluateDynamicTracker = evaluateDynamicTracker;
|
|
26
26
|
exports.evaluateContractInteraction = evaluateContractInteraction;
|
|
27
|
+
exports.evaluateSocialEngagement = evaluateSocialEngagement;
|
|
27
28
|
const types_1 = require("@stackedapp/types");
|
|
28
29
|
const template_1 = require("../template");
|
|
29
30
|
const dynamic_1 = require("../dynamic");
|
|
@@ -787,4 +788,24 @@ function evaluateContractInteraction(cond, ctx) {
|
|
|
787
788
|
maxClaims,
|
|
788
789
|
};
|
|
789
790
|
}
|
|
791
|
+
function evaluateSocialEngagement(cond, ctx) {
|
|
792
|
+
const tracker = ctx.completionTrackers?.socialEngagement?.[cond.id];
|
|
793
|
+
const isMet = tracker?.verified === true;
|
|
794
|
+
const actionTextMap = {
|
|
795
|
+
follow: `Follow @${cond.targetUsername || '?'} on X`,
|
|
796
|
+
retweet: 'Retweet a post on X',
|
|
797
|
+
quoteTweet: cond.requiredWords?.length
|
|
798
|
+
? `Quote tweet on X with ${cond.requiredWords.map((w) => `"${w}"`).join(', ')}`
|
|
799
|
+
: 'Quote tweet on X',
|
|
800
|
+
};
|
|
801
|
+
return {
|
|
802
|
+
isMet,
|
|
803
|
+
details: [{
|
|
804
|
+
isMet, kind: 'socialEngagement',
|
|
805
|
+
trackerAmount: isMet ? 1 : 0, trackerGoal: 1,
|
|
806
|
+
percentCompleted: isMet ? 100 : 0,
|
|
807
|
+
text: actionTextMap[cond.action] || 'Complete X/Twitter engagement',
|
|
808
|
+
}],
|
|
809
|
+
};
|
|
810
|
+
}
|
|
790
811
|
//# sourceMappingURL=handlers.js.map
|
package/dist/conditions/index.js
CHANGED
|
@@ -42,6 +42,7 @@ function evaluateCompletionOnlyCondition(cond, ctx) {
|
|
|
42
42
|
case 'linkedCompletions': return (0, handlers_1.evaluateLinkedCompletions)(cond, ctx);
|
|
43
43
|
case 'dynamicTracker': return (0, handlers_1.evaluateDynamicTracker)(cond, ctx);
|
|
44
44
|
case 'contractInteraction': return (0, handlers_1.evaluateContractInteraction)(cond, ctx);
|
|
45
|
+
case 'socialEngagement': return (0, handlers_1.evaluateSocialEngagement)(cond, ctx);
|
|
45
46
|
// base kinds handled by evaluateBaseCondition
|
|
46
47
|
case 'level':
|
|
47
48
|
case 'currency':
|
|
@@ -385,6 +386,7 @@ const meetsCompletionConditionsBeforeExpiry = ({ completionConditions, completio
|
|
|
385
386
|
case 'completionContext':
|
|
386
387
|
case 'linkedCompletions':
|
|
387
388
|
case 'contractInteraction':
|
|
389
|
+
case 'socialEngagement':
|
|
388
390
|
if (completionTrackers?.lastUpdated != null && wasUpdatedAfterExpiry(completionTrackers.lastUpdated)) {
|
|
389
391
|
return false;
|
|
390
392
|
}
|