@stackedapp/utils 0.26.1
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.
- package/dist/blockchain_utils.d.ts +6 -0
- package/dist/blockchain_utils.js +13 -0
- package/dist/conditions.d.ts +133 -0
- package/dist/conditions.js +1295 -0
- package/dist/dynamic.d.ts +3 -0
- package/dist/dynamic.js +12 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/dist/template.d.ts +21 -0
- package/dist/template.js +54 -0
- package/package.json +24 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deconstructAddressNetworkId = exports.addressNetworkId = void 0;
|
|
4
|
+
const addressNetworkId = (contractAddress, network) => {
|
|
5
|
+
return `${contractAddress.toLowerCase()}:${network.toUpperCase()}`;
|
|
6
|
+
};
|
|
7
|
+
exports.addressNetworkId = addressNetworkId;
|
|
8
|
+
const deconstructAddressNetworkId = (addressNetwork) => {
|
|
9
|
+
const [address, network] = addressNetwork.split(':');
|
|
10
|
+
return { address, network };
|
|
11
|
+
};
|
|
12
|
+
exports.deconstructAddressNetworkId = deconstructAddressNetworkId;
|
|
13
|
+
//# sourceMappingURL=blockchain_utils.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { StackedCompletionConditions, StackedOffer, StackedSnapshot, StackedBaseUserExtra, StackedBaseConditions, StackedClaimableConditions, StackedClaimableTrackers, StackedCompletionTrackers, StackedDynamicCondition, StackedDynamicGroup, StackedOfferTrackers } from '@stackedapp/types';
|
|
2
|
+
export declare const DEFAULT_ENTITY_KIND = "_default";
|
|
3
|
+
export declare const meetsBaseConditions: ({ conditions, playerSnap, addDetails, playerOffer, additionalData, }: {
|
|
4
|
+
conditions: StackedBaseConditions;
|
|
5
|
+
playerSnap: StackedSnapshot;
|
|
6
|
+
addDetails?: boolean;
|
|
7
|
+
playerOffer?: {
|
|
8
|
+
createdAt?: Date | number;
|
|
9
|
+
claimedCount?: number;
|
|
10
|
+
trackers?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
additionalData?: StackedBaseUserExtra;
|
|
13
|
+
}) => {
|
|
14
|
+
isValid: boolean;
|
|
15
|
+
conditionData?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
isValid: boolean;
|
|
18
|
+
conditionData: {
|
|
19
|
+
isMet: boolean;
|
|
20
|
+
kind?: keyof StackedBaseConditions;
|
|
21
|
+
trackerAmount?: number;
|
|
22
|
+
trackerGoal?: number;
|
|
23
|
+
text: string;
|
|
24
|
+
}[] | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare const hasCompletionConditions: (conditions: StackedCompletionConditions) => boolean;
|
|
27
|
+
export declare const meetsLinkedEntityOffersCondition: ({ linkedEntityOffers, matchingLinks, linkedPOfferMap, }: {
|
|
28
|
+
linkedEntityOffers: {
|
|
29
|
+
kind?: string;
|
|
30
|
+
offer_id?: string;
|
|
31
|
+
link?: boolean;
|
|
32
|
+
};
|
|
33
|
+
matchingLinks: Array<{
|
|
34
|
+
playerId: string;
|
|
35
|
+
kind?: string;
|
|
36
|
+
}>;
|
|
37
|
+
linkedPOfferMap: Map<string, StackedOffer>;
|
|
38
|
+
}) => {
|
|
39
|
+
isValid: boolean;
|
|
40
|
+
linkedPlayerOffer_ids?: string[];
|
|
41
|
+
};
|
|
42
|
+
export declare const offerMeetsCompletionConditions: (offer: StackedOffer, snapshot: StackedSnapshot, additionalData?: StackedBaseUserExtra) => {
|
|
43
|
+
isValid: boolean;
|
|
44
|
+
availableClaimsNow: number;
|
|
45
|
+
conditionData?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
isValid: boolean;
|
|
48
|
+
conditionData: {
|
|
49
|
+
isMet: boolean;
|
|
50
|
+
kind?: keyof StackedCompletionConditions | "context";
|
|
51
|
+
trackerAmount?: number;
|
|
52
|
+
trackerGoal?: number;
|
|
53
|
+
text: string;
|
|
54
|
+
}[];
|
|
55
|
+
availableClaimsNow: number;
|
|
56
|
+
};
|
|
57
|
+
export declare const meetsCompletionConditions: ({ completionConditions, completionTrackers, playerSnap, playerOffer, addDetails, maxClaimCount, additionalData, }: {
|
|
58
|
+
completionConditions: StackedCompletionConditions;
|
|
59
|
+
completionTrackers?: StackedCompletionTrackers;
|
|
60
|
+
playerSnap: StackedSnapshot;
|
|
61
|
+
playerOffer: {
|
|
62
|
+
createdAt?: Date | number;
|
|
63
|
+
trackers?: StackedOfferTrackers;
|
|
64
|
+
};
|
|
65
|
+
addDetails?: boolean;
|
|
66
|
+
maxClaimCount?: number;
|
|
67
|
+
additionalData?: StackedBaseUserExtra;
|
|
68
|
+
}) => {
|
|
69
|
+
isValid: boolean;
|
|
70
|
+
availableClaimsNow: number;
|
|
71
|
+
conditionData?: undefined;
|
|
72
|
+
} | {
|
|
73
|
+
isValid: boolean;
|
|
74
|
+
conditionData: {
|
|
75
|
+
isMet: boolean;
|
|
76
|
+
kind?: keyof StackedCompletionConditions | "context";
|
|
77
|
+
trackerAmount?: number;
|
|
78
|
+
trackerGoal?: number;
|
|
79
|
+
text: string;
|
|
80
|
+
}[];
|
|
81
|
+
availableClaimsNow: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Checks if completion conditions were met before a specific expiry time.
|
|
85
|
+
* Returns true if all relevant condition fields were updated before expiryTime.
|
|
86
|
+
*
|
|
87
|
+
* @param completionConditions - The completion conditions to check
|
|
88
|
+
* @param completionTrackers - The completion trackers (for buyItem, spendCurrency, etc.)
|
|
89
|
+
* @param playerSnap - The player snapshot with field timestamps
|
|
90
|
+
* @returns true if all conditions were met before expiry, false otherwise
|
|
91
|
+
*/
|
|
92
|
+
export declare const meetsCompletionConditionsBeforeExpiry: ({ completionConditions, completionTrackers, playerSnap, playerOffer, maxClaimCount, }: {
|
|
93
|
+
completionConditions: StackedCompletionConditions;
|
|
94
|
+
completionTrackers?: StackedCompletionTrackers;
|
|
95
|
+
playerSnap: StackedSnapshot;
|
|
96
|
+
playerOffer: {
|
|
97
|
+
createdAt?: Date | number;
|
|
98
|
+
claimedCount?: number;
|
|
99
|
+
trackers?: Record<string, any>;
|
|
100
|
+
expiresAt?: Date | number | string;
|
|
101
|
+
};
|
|
102
|
+
maxClaimCount?: number;
|
|
103
|
+
}) => boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Calculates the maximum number of claims supported by a single dynamic condition.
|
|
106
|
+
*/
|
|
107
|
+
export declare function getMaxClaimsForDynamicCondition(dynamicObj: Record<string, string | number | boolean>, cond: StackedDynamicCondition): number;
|
|
108
|
+
/**
|
|
109
|
+
* Calculates the maximum number of claims supported by a group of dynamic conditions.
|
|
110
|
+
*/
|
|
111
|
+
export declare function getMaxClaimsForDynamicGroup(dynamicObj: Record<string, string | number | boolean>, dynamicGroup: StackedDynamicGroup, currentClaimCount?: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Evaluates a group of dynamic conditions with logical links (AND, OR, AND NOT).
|
|
114
|
+
* @param dynamicObj - The player's dynamic object with any key and string or number value.
|
|
115
|
+
* @param dynamicGroup - The group of conditions and links to check.
|
|
116
|
+
* @param claimMultiplier - Multiplier to scale conditions (used for numeric comparisons).
|
|
117
|
+
* @returns true if the group evaluates to true, false otherwise.
|
|
118
|
+
*/
|
|
119
|
+
export declare function meetsDynamicConditions(dynamicObj: Record<string, string | number | boolean> | undefined | null, dynamicGroup: StackedDynamicGroup, claimMultiplier?: number): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Checks if a PlayerOffer meets its claimable conditions (completed -> claimable transition).
|
|
122
|
+
* @param claimableConditions - The offer's claimableConditions (from IOffer)
|
|
123
|
+
* @param claimableTrackers - The player offer's claimableTrackers
|
|
124
|
+
*/
|
|
125
|
+
export declare function meetsClaimableConditions({ claimableConditions, playerOfferTrackers, claimableTrackers, }: {
|
|
126
|
+
claimableConditions?: StackedClaimableConditions;
|
|
127
|
+
playerOfferTrackers?: StackedOfferTrackers;
|
|
128
|
+
claimableTrackers?: StackedClaimableTrackers;
|
|
129
|
+
}): {
|
|
130
|
+
isValid: boolean;
|
|
131
|
+
};
|
|
132
|
+
export declare function aggregateTokenBalances(data?: StackedBaseUserExtra): Record<string, number>;
|
|
133
|
+
//# sourceMappingURL=conditions.d.ts.map
|