@sonarwatch/portfolio-core 0.15.8 → 0.15.10
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/src/Airdrop.d.ts +31 -3
- package/src/Airdrop.js +9 -1
- package/src/Airdrop.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.15.10](https://github.com/sonarwatch/portfolio/compare/core-0.15.9...core-0.15.10) (2025-06-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [0.15.9](https://github.com/sonarwatch/portfolio/compare/core-0.15.8...core-0.15.9) (2025-06-02)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [0.15.8](https://github.com/sonarwatch/portfolio/compare/core-0.15.7...core-0.15.8) (2025-05-27)
|
|
6
14
|
|
|
7
15
|
|
package/package.json
CHANGED
package/src/Airdrop.d.ts
CHANGED
|
@@ -19,18 +19,19 @@ export declare enum AirdropItemStatus {
|
|
|
19
19
|
potentiallyClaimable = "2_potentiallyClaimable",
|
|
20
20
|
claimed = "3_claimed",
|
|
21
21
|
claimExpired = "4_claimExpired",
|
|
22
|
-
ineligible = "5_ineligible"
|
|
22
|
+
ineligible = "5_ineligible",
|
|
23
|
+
partiallyClaimed = "6_partiallyClaimed"
|
|
23
24
|
}
|
|
24
25
|
export declare function isEligibleAmount(amount: number): boolean;
|
|
25
26
|
export declare function getAirdropStatus(claimStart?: number, claimEnd?: number): AirdropStatus;
|
|
26
|
-
export declare function getAirdropItemStatus(airdropStatus: AirdropStatus, amount: number, isClaimed: IsClaimed): AirdropItemStatus;
|
|
27
|
+
export declare function getAirdropItemStatus(airdropStatus: AirdropStatus, amount: number, isClaimed: IsClaimed, claims?: Claim[]): AirdropItemStatus;
|
|
27
28
|
export type AirdropRaw = {
|
|
28
29
|
/**
|
|
29
30
|
* The airdrop id. (e.g. 'jupiter_season1')
|
|
30
31
|
*/
|
|
31
32
|
id: string;
|
|
32
33
|
/**
|
|
33
|
-
* A name for the airdrop. Should not
|
|
34
|
+
* A name for the airdrop. Should not contain the emitter name. (e.g. 'Season #1')
|
|
34
35
|
*/
|
|
35
36
|
name?: string;
|
|
36
37
|
/**
|
|
@@ -72,6 +73,10 @@ export type AirdropItemRaw = {
|
|
|
72
73
|
* If set to null it means that claim status is unknowned.
|
|
73
74
|
*/
|
|
74
75
|
isClaimed: IsClaimed;
|
|
76
|
+
/**
|
|
77
|
+
* The airdrop item claim proofs.
|
|
78
|
+
*/
|
|
79
|
+
claims?: Claim[];
|
|
75
80
|
/**
|
|
76
81
|
* The airdropped item address.
|
|
77
82
|
*/
|
|
@@ -89,6 +94,10 @@ export type AirdropItemRaw = {
|
|
|
89
94
|
* The airdropped item image uri.
|
|
90
95
|
*/
|
|
91
96
|
imageUri?: string;
|
|
97
|
+
/**
|
|
98
|
+
* The potential on-chain account address which represent the claim status.
|
|
99
|
+
*/
|
|
100
|
+
ref?: string;
|
|
92
101
|
};
|
|
93
102
|
export type Airdrop = Omit<AirdropRaw, 'items'> & {
|
|
94
103
|
/**
|
|
@@ -134,6 +143,25 @@ export type AirdropItem = AirdropItemRaw & {
|
|
|
134
143
|
*/
|
|
135
144
|
value: UsdValue;
|
|
136
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* Represents a claim proof.
|
|
148
|
+
* It contains the timestamp of the claim and the amount of tokens claimed.
|
|
149
|
+
* The txId is optional and can be used to track the transaction.
|
|
150
|
+
*/
|
|
151
|
+
export type Claim = {
|
|
152
|
+
/**
|
|
153
|
+
* Timestamp of the claim (in ms).
|
|
154
|
+
*/
|
|
155
|
+
date: number;
|
|
156
|
+
/**
|
|
157
|
+
* The claim amount.
|
|
158
|
+
*/
|
|
159
|
+
amount: number;
|
|
160
|
+
/**
|
|
161
|
+
* The claim txId.
|
|
162
|
+
*/
|
|
163
|
+
txId?: string;
|
|
164
|
+
};
|
|
137
165
|
/**
|
|
138
166
|
* Represents the result of a fetcher.
|
|
139
167
|
*/
|
package/src/Airdrop.js
CHANGED
|
@@ -16,6 +16,7 @@ var AirdropItemStatus;
|
|
|
16
16
|
AirdropItemStatus["claimed"] = "3_claimed";
|
|
17
17
|
AirdropItemStatus["claimExpired"] = "4_claimExpired";
|
|
18
18
|
AirdropItemStatus["ineligible"] = "5_ineligible";
|
|
19
|
+
AirdropItemStatus["partiallyClaimed"] = "6_partiallyClaimed";
|
|
19
20
|
})(AirdropItemStatus || (exports.AirdropItemStatus = AirdropItemStatus = {}));
|
|
20
21
|
function isEligibleAmount(amount) {
|
|
21
22
|
return amount > 0;
|
|
@@ -34,7 +35,7 @@ function getAirdropStatus(claimStart, claimEnd) {
|
|
|
34
35
|
return AirdropStatus.unknowned;
|
|
35
36
|
}
|
|
36
37
|
exports.getAirdropStatus = getAirdropStatus;
|
|
37
|
-
function getAirdropItemStatus(airdropStatus, amount, isClaimed) {
|
|
38
|
+
function getAirdropItemStatus(airdropStatus, amount, isClaimed, claims) {
|
|
38
39
|
if (!isEligibleAmount(amount))
|
|
39
40
|
return AirdropItemStatus.ineligible;
|
|
40
41
|
if (isClaimed === true)
|
|
@@ -48,6 +49,13 @@ function getAirdropItemStatus(airdropStatus, amount, isClaimed) {
|
|
|
48
49
|
// From here, isClaimed === false
|
|
49
50
|
if (airdropStatus === AirdropStatus.closed)
|
|
50
51
|
return AirdropItemStatus.claimExpired;
|
|
52
|
+
if (claims && airdropStatus === AirdropStatus.open) {
|
|
53
|
+
const claimedAmount = claims.reduce((acc, claim) => acc + claim.amount, 0);
|
|
54
|
+
if (claimedAmount >= amount)
|
|
55
|
+
return AirdropItemStatus.claimed;
|
|
56
|
+
if (claimedAmount > 0)
|
|
57
|
+
return AirdropItemStatus.partiallyClaimed;
|
|
58
|
+
}
|
|
51
59
|
return AirdropItemStatus.claimable;
|
|
52
60
|
}
|
|
53
61
|
exports.getAirdropItemStatus = getAirdropItemStatus;
|
package/src/Airdrop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Airdrop.js","sourceRoot":"","sources":["../../../../packages/core/src/Airdrop.ts"],"names":[],"mappings":";;;AAKA,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,0CAAyB,CAAA;IACzB,gCAAe,CAAA;IACf,oCAAmB,CAAA;AACrB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAQD,IAAY,
|
|
1
|
+
{"version":3,"file":"Airdrop.js","sourceRoot":"","sources":["../../../../packages/core/src/Airdrop.ts"],"names":[],"mappings":";;;AAKA,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,0CAAyB,CAAA;IACzB,gCAAe,CAAA;IACf,oCAAmB,CAAA;AACrB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAQD,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,8CAAyB,CAAA;IACzB,wDAAmC,CAAA;IACnC,oEAA+C,CAAA;IAC/C,0CAAqB,CAAA;IACrB,oDAA+B,CAAA;IAC/B,gDAA2B,CAAA;IAC3B,4DAAuC,CAAA;AACzC,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B;AAED,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,OAAO,MAAM,GAAG,CAAC,CAAC;AACpB,CAAC;AAFD,4CAEC;AAED,SAAgB,gBAAgB,CAC9B,UAAmB,EACnB,QAAiB;IAEjB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,IAAI,UAAU,IAAI,UAAU,GAAG,GAAG;QAAE,OAAO,aAAa,CAAC,UAAU,CAAC;IACpE,IAAI,QAAQ,IAAI,QAAQ,GAAG,GAAG;QAAE,OAAO,aAAa,CAAC,MAAM,CAAC;IAC5D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