@fxhash/shared 0.0.3 → 0.0.5
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/index.d.ts +1219 -1116
- package/dist/index.js +752 -572
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -1,631 +1,811 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { bigIntPow, enumKeys, getDecimalsNb, success } from "@fxhash/utils";
|
|
2
|
+
import { etherUnits } from "viem";
|
|
3
|
+
|
|
4
|
+
//#region src/types/entities/Account.ts
|
|
5
|
+
const accountTypeGuard = (entity) => {
|
|
6
|
+
return entity.username !== void 0;
|
|
4
7
|
};
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/types/entities/Action.ts
|
|
11
|
+
let TokenActionType = /* @__PURE__ */ function(TokenActionType$1) {
|
|
12
|
+
TokenActionType$1["NONE"] = "NONE";
|
|
13
|
+
TokenActionType$1["UPDATE_STATE"] = "UPDATE_STATE";
|
|
14
|
+
TokenActionType$1["UPDATE_PRICING"] = "UPDATE_PRICING";
|
|
15
|
+
TokenActionType$1["BURN_SUPPLY"] = "BURN_SUPPLY";
|
|
16
|
+
TokenActionType$1["CODEX_UPDATED"] = "CODEX_UPDATED";
|
|
17
|
+
TokenActionType$1["MINTED"] = "MINTED";
|
|
18
|
+
TokenActionType$1["MINTED_FROM"] = "MINTED_FROM";
|
|
19
|
+
TokenActionType$1["TICKET_MINTED"] = "TICKET_MINTED";
|
|
20
|
+
TokenActionType$1["TICKET_CLAIMED"] = "TICKET_CLAIMED";
|
|
21
|
+
TokenActionType$1["TICKET_PRICE_UPDATED"] = "TICKET_PRICE_UPDATED";
|
|
22
|
+
TokenActionType$1["GENTK_SIGNED"] = "GENTK_SIGNED";
|
|
23
|
+
TokenActionType$1["GENTK_REVEALED"] = "GENTK_REVEALED";
|
|
24
|
+
TokenActionType$1["GENTK_REDEEMED"] = "GENTK_REDEEMED";
|
|
25
|
+
TokenActionType$1["COMPLETED"] = "COMPLETED";
|
|
26
|
+
TokenActionType$1["TRANSFERED"] = "TRANSFERED";
|
|
27
|
+
TokenActionType$1["LISTING_V1"] = "LISTING_V1";
|
|
28
|
+
TokenActionType$1["LISTING_V1_CANCELLED"] = "LISTING_V1_CANCELLED";
|
|
29
|
+
TokenActionType$1["LISTING_V1_ACCEPTED"] = "LISTING_V1_ACCEPTED";
|
|
30
|
+
TokenActionType$1["LISTING_ETH_V1"] = "LISTING_ETH_V1";
|
|
31
|
+
TokenActionType$1["LISTING_BASE_V1"] = "LISTING_BASE_V1";
|
|
32
|
+
TokenActionType$1["LISTING_ETH_V1_CANCELLED"] = "LISTING_ETH_V1_CANCELLED";
|
|
33
|
+
TokenActionType$1["LISTING_BASE_V1_CANCELLED"] = "LISTING_BASE_V1_CANCELLED";
|
|
34
|
+
TokenActionType$1["LISTING_ETH_V1_ACCEPTED"] = "LISTING_ETH_V1_ACCEPTED";
|
|
35
|
+
TokenActionType$1["LISTING_BASE_V1_ACCEPTED"] = "LISTING_BASE_V1_ACCEPTED";
|
|
36
|
+
TokenActionType$1["LISTING_V2"] = "LISTING_V2";
|
|
37
|
+
TokenActionType$1["LISTING_V2_CANCELLED"] = "LISTING_V2_CANCELLED";
|
|
38
|
+
TokenActionType$1["LISTING_V2_ACCEPTED"] = "LISTING_V2_ACCEPTED";
|
|
39
|
+
TokenActionType$1["LISTING_V3"] = "LISTING_V3";
|
|
40
|
+
TokenActionType$1["LISTING_V3_CANCELLED"] = "LISTING_V3_CANCELLED";
|
|
41
|
+
TokenActionType$1["LISTING_V3_ACCEPTED"] = "LISTING_V3_ACCEPTED";
|
|
42
|
+
TokenActionType$1["OFFER"] = "OFFER";
|
|
43
|
+
TokenActionType$1["OFFER_CANCELLED"] = "OFFER_CANCELLED";
|
|
44
|
+
TokenActionType$1["OFFER_ACCEPTED"] = "OFFER_ACCEPTED";
|
|
45
|
+
TokenActionType$1["OFFER_ETH"] = "OFFER_ETH";
|
|
46
|
+
TokenActionType$1["OFFER_BASE"] = "OFFER_BASE";
|
|
47
|
+
TokenActionType$1["OFFER_CANCELLED_ETH"] = "OFFER_CANCELLED_ETH";
|
|
48
|
+
TokenActionType$1["OFFER_CANCELLED_BASE"] = "OFFER_CANCELLED_BASE";
|
|
49
|
+
TokenActionType$1["OFFER_ACCEPTED_ETH"] = "OFFER_ACCEPTED_ETH";
|
|
50
|
+
TokenActionType$1["OFFER_ACCEPTED_BASE"] = "OFFER_ACCEPTED_BASE";
|
|
51
|
+
TokenActionType$1["COLLECTION_OFFER_ETH"] = "COLLECTION_OFFER_ETH";
|
|
52
|
+
TokenActionType$1["COLLECTION_OFFER_BASE"] = "COLLECTION_OFFER_BASE";
|
|
53
|
+
TokenActionType$1["COLLECTION_OFFER_CANCELLED_ETH"] = "COLLECTION_OFFER_CANCELLED_ETH";
|
|
54
|
+
TokenActionType$1["COLLECTION_OFFER_CANCELLED_BASE"] = "COLLECTION_OFFER_CANCELLED_BASE";
|
|
55
|
+
TokenActionType$1["COLLECTION_OFFER_ACCEPTED_ETH"] = "COLLECTION_OFFER_ACCEPTED_ETH";
|
|
56
|
+
TokenActionType$1["COLLECTION_OFFER_ACCEPTED_BASE"] = "COLLECTION_OFFER_ACCEPTED_BASE";
|
|
57
|
+
TokenActionType$1["COLLECTION_OFFER"] = "COLLECTION_OFFER";
|
|
58
|
+
TokenActionType$1["COLLECTION_OFFER_CANCELLED"] = "COLLECTION_OFFER_CANCELLED";
|
|
59
|
+
TokenActionType$1["COLLECTION_OFFER_ACCEPTED"] = "COLLECTION_OFFER_ACCEPTED";
|
|
60
|
+
TokenActionType$1["AUCTION"] = "AUCTION";
|
|
61
|
+
TokenActionType$1["AUCTION_BID"] = "AUCTION_BID";
|
|
62
|
+
TokenActionType$1["AUCTION_CANCELLED"] = "AUCTION_CANCELLED";
|
|
63
|
+
TokenActionType$1["AUCTION_FULFILLED"] = "AUCTION_FULFILLED";
|
|
64
|
+
TokenActionType$1["ARTICLE_MINTED"] = "ARTICLE_MINTED";
|
|
65
|
+
TokenActionType$1["ARTICLE_METADATA_UPDATED"] = "ARTICLE_METADATA_UPDATED";
|
|
66
|
+
TokenActionType$1["ARTICLE_METADATA_LOCKED"] = "ARTICLE_METADATA_LOCKED";
|
|
67
|
+
TokenActionType$1["ARTICLE_EDITIONS_TRANSFERED"] = "ARTICLE_EDITIONS_TRANSFERED";
|
|
68
|
+
TokenActionType$1["OBJKT_STATE_UPDATE_ACTIVE"] = "OBJKT_STATE_UPDATE_ACTIVE";
|
|
69
|
+
TokenActionType$1["OBJKT_STATE_UPDATE_EVOLVED"] = "OBJKT_STATE_UPDATE_EVOLVED";
|
|
70
|
+
TokenActionType$1["OBJKT_STATE_UPDATE_LOCKED"] = "OBJKT_STATE_UPDATE_LOCKED";
|
|
71
|
+
TokenActionType$1["OBJKT_STATE_UPDATE_LIQUIDATED"] = "OBJKT_STATE_UPDATE_LIQUIDATED";
|
|
72
|
+
TokenActionType$1["OBJKT_STATE_UPDATE_REGENERATED"] = "OBJKT_STATE_UPDATE_REGENERATED";
|
|
73
|
+
return TokenActionType$1;
|
|
74
|
+
}({});
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/types/entities/Article.ts
|
|
78
|
+
let ArticleFlag = /* @__PURE__ */ function(ArticleFlag$1) {
|
|
79
|
+
ArticleFlag$1["NONE"] = "NONE";
|
|
80
|
+
ArticleFlag$1["CLEAN"] = "CLEAN";
|
|
81
|
+
ArticleFlag$1["REPORTED"] = "REPORTED";
|
|
82
|
+
ArticleFlag$1["AUTO_DETECT_COPY"] = "AUTO_DETECT_COPY";
|
|
83
|
+
ArticleFlag$1["MALICIOUS"] = "MALICIOUS";
|
|
84
|
+
ArticleFlag$1["HIDDEN"] = "HIDDEN";
|
|
85
|
+
return ArticleFlag$1;
|
|
86
|
+
}({});
|
|
82
87
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/types/entities/GenerativeToken.ts
|
|
90
|
+
let GenTokFlag = /* @__PURE__ */ function(GenTokFlag$1) {
|
|
91
|
+
GenTokFlag$1["NONE"] = "NONE";
|
|
92
|
+
GenTokFlag$1["CLEAN"] = "CLEAN";
|
|
93
|
+
GenTokFlag$1["REPORTED"] = "REPORTED";
|
|
94
|
+
GenTokFlag$1["AUTO_DETECT_COPY"] = "AUTO_DETECT_COPY";
|
|
95
|
+
GenTokFlag$1["MALICIOUS"] = "MALICIOUS";
|
|
96
|
+
GenTokFlag$1["HIDDEN"] = "HIDDEN";
|
|
97
|
+
return GenTokFlag$1;
|
|
98
|
+
}({});
|
|
99
|
+
let GenerativeTokenFormat = /* @__PURE__ */ function(GenerativeTokenFormat$1) {
|
|
100
|
+
GenerativeTokenFormat$1["LONG_FORM"] = "LONG_FORM";
|
|
101
|
+
GenerativeTokenFormat$1["OPEN_FORM"] = "OPEN_FORM";
|
|
102
|
+
return GenerativeTokenFormat$1;
|
|
103
|
+
}({});
|
|
104
|
+
let GenTokPricing = /* @__PURE__ */ function(GenTokPricing$1) {
|
|
105
|
+
GenTokPricing$1["FIXED"] = "FIXED";
|
|
106
|
+
GenTokPricing$1["DUTCH_AUCTION"] = "DUTCH_AUCTION";
|
|
107
|
+
return GenTokPricing$1;
|
|
108
|
+
}({});
|
|
109
|
+
let GenTokLabel = /* @__PURE__ */ function(GenTokLabel$1) {
|
|
110
|
+
GenTokLabel$1[GenTokLabel$1["EPILEPTIC_TRIGGER"] = 0] = "EPILEPTIC_TRIGGER";
|
|
111
|
+
GenTokLabel$1[GenTokLabel$1["SEXUAL_CONTENT"] = 1] = "SEXUAL_CONTENT";
|
|
112
|
+
GenTokLabel$1[GenTokLabel$1["SENSITIVE"] = 2] = "SENSITIVE";
|
|
113
|
+
GenTokLabel$1[GenTokLabel$1["IMAGE_COMPOSITION"] = 100] = "IMAGE_COMPOSITION";
|
|
114
|
+
GenTokLabel$1[GenTokLabel$1["ANIMATED"] = 101] = "ANIMATED";
|
|
115
|
+
GenTokLabel$1[GenTokLabel$1["INTERACTIVE"] = 102] = "INTERACTIVE";
|
|
116
|
+
GenTokLabel$1[GenTokLabel$1["PFP"] = 103] = "PFP";
|
|
117
|
+
GenTokLabel$1[GenTokLabel$1["AUDIO"] = 104] = "AUDIO";
|
|
118
|
+
GenTokLabel$1[GenTokLabel$1["INCLUDE_PRERENDERED_COMPONENTS"] = 105] = "INCLUDE_PRERENDERED_COMPONENTS";
|
|
119
|
+
GenTokLabel$1[GenTokLabel$1["CUSTOM_MINTING_INTERFACE"] = 106] = "CUSTOM_MINTING_INTERFACE";
|
|
120
|
+
GenTokLabel$1[GenTokLabel$1["FXHACKATHON2023"] = 302023] = "FXHACKATHON2023";
|
|
121
|
+
return GenTokLabel$1;
|
|
122
|
+
}({});
|
|
123
|
+
let GenTokLabelGroup = /* @__PURE__ */ function(GenTokLabelGroup$1) {
|
|
124
|
+
GenTokLabelGroup$1["WARNING"] = "WARNING";
|
|
125
|
+
GenTokLabelGroup$1["DETAILS"] = "DETAILS";
|
|
126
|
+
GenTokLabelGroup$1["HIGHLIGHT"] = "HIGHLIGHT";
|
|
127
|
+
return GenTokLabelGroup$1;
|
|
128
|
+
}({});
|
|
129
|
+
const GenTokLabel_Params = {
|
|
130
|
+
label: "Params",
|
|
131
|
+
shortLabel: "Params",
|
|
132
|
+
group: GenTokLabelGroup.HIGHLIGHT,
|
|
133
|
+
description: "This piece is using the fx(params) module, letting collector play with parameters before minting"
|
|
128
134
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
const GenTokLabel_Redeemable = {
|
|
136
|
+
label: "Redeemable",
|
|
137
|
+
shortLabel: "Redeemable",
|
|
138
|
+
group: GenTokLabelGroup.HIGHLIGHT,
|
|
139
|
+
description: "This project can be redeemed."
|
|
134
140
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
141
|
+
let GenerativeTokenVersion = /* @__PURE__ */ function(GenerativeTokenVersion$1) {
|
|
142
|
+
GenerativeTokenVersion$1["PRE_V3"] = "PRE_V3";
|
|
143
|
+
GenerativeTokenVersion$1["V3"] = "V3";
|
|
144
|
+
GenerativeTokenVersion$1["ETH_V1"] = "ETH_V1";
|
|
145
|
+
GenerativeTokenVersion$1["BASE_V1"] = "BASE_V1";
|
|
146
|
+
return GenerativeTokenVersion$1;
|
|
147
|
+
}({});
|
|
142
148
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/types/entities/LiveMinting.ts
|
|
151
|
+
let EventStatus = /* @__PURE__ */ function(EventStatus$1) {
|
|
152
|
+
EventStatus$1["PUBLISHED"] = "PUBLISHED";
|
|
153
|
+
EventStatus$1["DRAFT"] = "DRAFT";
|
|
154
|
+
EventStatus$1["HIDDEN"] = "HIDDEN";
|
|
155
|
+
return EventStatus$1;
|
|
156
|
+
}({});
|
|
157
|
+
let EventAvailability = /* @__PURE__ */ function(EventAvailability$1) {
|
|
158
|
+
EventAvailability$1["ONLINE"] = "ONLINE";
|
|
159
|
+
EventAvailability$1["IRL"] = "IRL";
|
|
160
|
+
return EventAvailability$1;
|
|
161
|
+
}({});
|
|
155
162
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/types/entities/ManagedWallet.ts
|
|
165
|
+
let EWalletOperatorState = /* @__PURE__ */ function(EWalletOperatorState$1) {
|
|
166
|
+
EWalletOperatorState$1["EMPTY"] = "EMPTY";
|
|
167
|
+
EWalletOperatorState$1["INITIALIZING"] = "INITIALIZING";
|
|
168
|
+
EWalletOperatorState$1["AVAILABLE"] = "AVAILABLE";
|
|
169
|
+
EWalletOperatorState$1["PREPARING"] = "PREPARING";
|
|
170
|
+
EWalletOperatorState$1["WAITING_CONFIRMATION"] = "WAITING_CONFIRMATION";
|
|
171
|
+
return EWalletOperatorState$1;
|
|
172
|
+
}({});
|
|
165
173
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/types/entities/Objkt.ts
|
|
176
|
+
let EObjktFeatureType = /* @__PURE__ */ function(EObjktFeatureType$1) {
|
|
177
|
+
EObjktFeatureType$1["BOOLEAN"] = "BOOLEAN";
|
|
178
|
+
EObjktFeatureType$1["STRING"] = "STRING";
|
|
179
|
+
EObjktFeatureType$1["NUMBER"] = "NUMBER";
|
|
180
|
+
return EObjktFeatureType$1;
|
|
181
|
+
}({});
|
|
173
182
|
function objktFeatureType(value) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
183
|
+
const type = typeof value;
|
|
184
|
+
if (type === "boolean") return EObjktFeatureType.BOOLEAN;
|
|
185
|
+
else if (type === "number") return EObjktFeatureType.NUMBER;
|
|
186
|
+
else return EObjktFeatureType.STRING;
|
|
178
187
|
}
|
|
179
188
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/types/entities/Offer.ts
|
|
191
|
+
const offerTypeGuard = (offer) => {
|
|
192
|
+
return offer.objkt !== void 0;
|
|
183
193
|
};
|
|
184
194
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/types/entities/Redeemable.ts
|
|
197
|
+
let RedeemableUserActionType = /* @__PURE__ */ function(RedeemableUserActionType$1) {
|
|
198
|
+
RedeemableUserActionType$1["INPUT_ADDRESS"] = "INPUT_ADDRESS";
|
|
199
|
+
RedeemableUserActionType$1["INPUT_EMAIL"] = "INPUT_EMAIL";
|
|
200
|
+
RedeemableUserActionType$1["INPUT_PHONE"] = "INPUT_PHONE";
|
|
201
|
+
RedeemableUserActionType$1["INPUT_LIST"] = "INPUT_LIST";
|
|
202
|
+
return RedeemableUserActionType$1;
|
|
203
|
+
}({});
|
|
193
204
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/types/entities/Reserve.ts
|
|
207
|
+
let EReserveMethod = /* @__PURE__ */ function(EReserveMethod$1) {
|
|
208
|
+
EReserveMethod$1["WHITELIST"] = "WHITELIST";
|
|
209
|
+
EReserveMethod$1["MINT_PASS"] = "MINT_PASS";
|
|
210
|
+
return EReserveMethod$1;
|
|
211
|
+
}({});
|
|
200
212
|
function isReserveWhiteList(reserve) {
|
|
201
|
-
|
|
213
|
+
return reserve.method === EReserveMethod.WHITELIST;
|
|
202
214
|
}
|
|
203
215
|
function isReserveMintPass(reserve) {
|
|
204
|
-
|
|
216
|
+
return reserve.method === EReserveMethod.MINT_PASS;
|
|
205
217
|
}
|
|
206
218
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/types/entities/User.ts
|
|
221
|
+
let UserFlag = /* @__PURE__ */ function(UserFlag$1) {
|
|
222
|
+
UserFlag$1["NONE"] = "NONE";
|
|
223
|
+
UserFlag$1["REVIEW"] = "REVIEW";
|
|
224
|
+
UserFlag$1["SUSPICIOUS"] = "SUSPICIOUS";
|
|
225
|
+
UserFlag$1["MALICIOUS"] = "MALICIOUS";
|
|
226
|
+
UserFlag$1["VERIFIED"] = "VERIFIED";
|
|
227
|
+
return UserFlag$1;
|
|
228
|
+
}({});
|
|
229
|
+
let UserAuthorization = /* @__PURE__ */ function(UserAuthorization$1) {
|
|
230
|
+
UserAuthorization$1["TOKEN_MODERATION"] = "TOKEN_MODERATION";
|
|
231
|
+
UserAuthorization$1["ARTICLE_MODERATION"] = "ARTICLE_MODERATION";
|
|
232
|
+
UserAuthorization$1["USER_MODERATION"] = "USER_MODERATION";
|
|
233
|
+
UserAuthorization$1["GOVERNANCE_MODERATION"] = "GOVERNANCE_MODERATION";
|
|
234
|
+
return UserAuthorization$1;
|
|
235
|
+
}({});
|
|
236
|
+
let UserType = /* @__PURE__ */ function(UserType$1) {
|
|
237
|
+
UserType$1["REGULAR"] = "REGULAR";
|
|
238
|
+
UserType$1["COLLAB_CONTRACT_V1"] = "COLLAB_CONTRACT_V1";
|
|
239
|
+
return UserType$1;
|
|
240
|
+
}({});
|
|
241
|
+
const UserFlagValues = {
|
|
242
|
+
NONE: 0,
|
|
243
|
+
REVIEW: 1,
|
|
244
|
+
SUSPICIOUS: 2,
|
|
245
|
+
MALICIOUS: 3,
|
|
246
|
+
VERIFIED: 10
|
|
234
247
|
};
|
|
235
248
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/types/Mint.ts
|
|
251
|
+
let CaptureTriggerMode = /* @__PURE__ */ function(CaptureTriggerMode$1) {
|
|
252
|
+
CaptureTriggerMode$1["DELAY"] = "DELAY";
|
|
253
|
+
CaptureTriggerMode$1["FN_TRIGGER"] = "FN_TRIGGER";
|
|
254
|
+
CaptureTriggerMode$1["FN_TRIGGER_GIF"] = "FN_TRIGGER_GIF";
|
|
255
|
+
return CaptureTriggerMode$1;
|
|
256
|
+
}({});
|
|
257
|
+
const CaptureTriggerModeList = Object.values(CaptureTriggerMode);
|
|
258
|
+
let CaptureMode = /* @__PURE__ */ function(CaptureMode$1) {
|
|
259
|
+
CaptureMode$1["CANVAS"] = "CANVAS";
|
|
260
|
+
CaptureMode$1["CUSTOM"] = "CUSTOM";
|
|
261
|
+
CaptureMode$1["VIEWPORT"] = "VIEWPORT";
|
|
262
|
+
return CaptureMode$1;
|
|
263
|
+
}({});
|
|
264
|
+
const CaptureModeList = Object.values(CaptureMode);
|
|
265
|
+
let GenTokEditions = /* @__PURE__ */ function(GenTokEditions$1) {
|
|
266
|
+
GenTokEditions$1["FIXED"] = "FIXED";
|
|
267
|
+
GenTokEditions$1["OPENED"] = "OPENED";
|
|
268
|
+
return GenTokEditions$1;
|
|
269
|
+
}({});
|
|
255
270
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/types/Sandbox.ts
|
|
273
|
+
let SandboxFileError = /* @__PURE__ */ function(SandboxFileError$1) {
|
|
274
|
+
SandboxFileError$1["UNKNOWN"] = "UNKNOWN";
|
|
275
|
+
SandboxFileError$1["WRONG_FORMAT"] = "WRONG_FORMAT";
|
|
276
|
+
SandboxFileError$1["NO_INDEX_HTML"] = "NO_INDEX_HTML";
|
|
277
|
+
SandboxFileError$1["NO_SNIPPET"] = "NO_SNIPPET";
|
|
278
|
+
SandboxFileError$1["FAILED_UNZIP"] = "FAILED_UNZIP";
|
|
279
|
+
return SandboxFileError$1;
|
|
280
|
+
}({});
|
|
265
281
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/types/Responses.ts
|
|
284
|
+
let ProfileUploadError = /* @__PURE__ */ function(ProfileUploadError$1) {
|
|
285
|
+
ProfileUploadError$1["UNKNOWN"] = "UNKNOWN";
|
|
286
|
+
ProfileUploadError$1["WRONG_FORMAT"] = "WRONG_FORMAT";
|
|
287
|
+
ProfileUploadError$1["IPFS_UPLOAD_FAILED"] = "IPFS_UPLOAD_FAILED";
|
|
288
|
+
return ProfileUploadError$1;
|
|
289
|
+
}({});
|
|
290
|
+
let AvatarUploadError = /* @__PURE__ */ function(AvatarUploadError$1) {
|
|
291
|
+
AvatarUploadError$1["UNKNOWN"] = "UNKNOWN";
|
|
292
|
+
AvatarUploadError$1["NO_FILE"] = "NO_FILE";
|
|
293
|
+
AvatarUploadError$1["WRONG_FORMAT"] = "WRONG_FORMAT";
|
|
294
|
+
AvatarUploadError$1["IPFS_UPLOAD_FAILED"] = "IPFS_UPLOAD_FAILED";
|
|
295
|
+
return AvatarUploadError$1;
|
|
296
|
+
}({});
|
|
297
|
+
let StaticGenError = /* @__PURE__ */ function(StaticGenError$1) {
|
|
298
|
+
StaticGenError$1["UNKNOWN"] = "UNKNOWN";
|
|
299
|
+
StaticGenError$1["MISSING_PARAMETERS"] = "MISSING_PARAMETERS";
|
|
300
|
+
StaticGenError$1["AUTH_FAILED"] = "AUTH_FAILED";
|
|
301
|
+
StaticGenError$1["INVALID_HASH"] = "INVALID_HASH";
|
|
302
|
+
StaticGenError$1["IPFS_UPLOAD_FAILED"] = "IPFS_UPLOAD_FAILED";
|
|
303
|
+
StaticGenError$1["NO_SNIPPET"] = "NO_SNIPPET";
|
|
304
|
+
return StaticGenError$1;
|
|
305
|
+
}({});
|
|
306
|
+
let PreviewError = /* @__PURE__ */ function(PreviewError$1) {
|
|
307
|
+
PreviewError$1["UNKNOWN"] = "UNKNOWN";
|
|
308
|
+
PreviewError$1["MISSING_PARAMETERS"] = "MISSING_PARAMETERS";
|
|
309
|
+
PreviewError$1["AUTH_FAILED"] = "AUTH_FAILED";
|
|
310
|
+
PreviewError$1["INCORRECT_PARAMETERS"] = "INCORRECT_PARAMETERS";
|
|
311
|
+
PreviewError$1["PREVIEW_ERROR"] = "PREVIEW_ERROR";
|
|
312
|
+
PreviewError$1["IPFS_ERROR"] = "IPFS_ERROR";
|
|
313
|
+
return PreviewError$1;
|
|
314
|
+
}({});
|
|
315
|
+
let TestPreviewError = /* @__PURE__ */ function(TestPreviewError$1) {
|
|
316
|
+
TestPreviewError$1["UNKNOWN"] = "UNKNOWN";
|
|
317
|
+
TestPreviewError$1["TIMEOUT"] = "TIMEOUT";
|
|
318
|
+
TestPreviewError$1["EXTRACT_SERVICE_UNREACHABLE"] = "EXTRACT_SERVICE_UNREACHABLE";
|
|
319
|
+
TestPreviewError$1["INVALID_INPUT_PARAMETERS"] = "INVALID_INPUT_PARAMETERS";
|
|
320
|
+
TestPreviewError$1["JOB_QUEUE_FAILED"] = "JOB_QUEUE_FAILED";
|
|
321
|
+
TestPreviewError$1["JOB_EXECUTION_FAILED"] = "JOB_EXECUTION_FAILED";
|
|
322
|
+
return TestPreviewError$1;
|
|
323
|
+
}({});
|
|
324
|
+
let MetadataError = /* @__PURE__ */ function(MetadataError$1) {
|
|
325
|
+
MetadataError$1["UNKNOWN"] = "UNKNOWN";
|
|
326
|
+
MetadataError$1["IPFS_ERROR"] = "IPFS_ERROR";
|
|
327
|
+
MetadataError$1["UPLOAD_ERROR"] = "UPLOAD_ERROR";
|
|
328
|
+
MetadataError$1["METADATA_EXISTS"] = "METADATA_EXISTS";
|
|
329
|
+
return MetadataError$1;
|
|
330
|
+
}({});
|
|
331
|
+
let MintError = /* @__PURE__ */ function(MintError$1) {
|
|
332
|
+
MintError$1["UNKNOWN"] = "UNKNOWN";
|
|
333
|
+
MintError$1["BAD_REQUEST"] = "BAD_REQUEST";
|
|
334
|
+
MintError$1["TOKEN_NOT_EXISTS"] = "TOKEN_NOT_EXISTS";
|
|
335
|
+
MintError$1["TOKEN_UNAVAILABLE"] = "TOKEN_UNAVAILABLE";
|
|
336
|
+
MintError$1["FAIL_GET_METADATA"] = "FAIL_GET_METADATA";
|
|
337
|
+
MintError$1["WRONG_TOKEN_METADATA"] = "WRONG_TOKEN_METADATA";
|
|
338
|
+
MintError$1["FAIL_AUTHENTICATE"] = "FAIL_AUTHENTICATE";
|
|
339
|
+
MintError$1["FAIL_GET_TOKEN"] = "FAIL_GET_TOKEN";
|
|
340
|
+
MintError$1["INVALID_TOKEN"] = "INVALID_TOKEN";
|
|
341
|
+
MintError$1["FAIL_ADD_IPFS"] = "FAIL_ADD_IPFS";
|
|
342
|
+
MintError$1["FAIL_PREVIEW"] = "FAIL_PREVIEW";
|
|
343
|
+
return MintError$1;
|
|
344
|
+
}({});
|
|
345
|
+
const MintErrors = Object.values(MintError);
|
|
346
|
+
let MintProgressMessage = /* @__PURE__ */ function(MintProgressMessage$1) {
|
|
347
|
+
MintProgressMessage$1["GET_TOKEN_DATA"] = "GET_TOKEN_DATA";
|
|
348
|
+
MintProgressMessage$1["GET_TOKEN_METADATA"] = "GET_TOKEN_METADATA";
|
|
349
|
+
MintProgressMessage$1["GET_GENERATIVE_TOKEN_CONTENTS"] = "GET_GENERATIVE_TOKEN_CONTENTS";
|
|
350
|
+
MintProgressMessage$1["ADD_CONTENT_IPFS"] = "ADD_CONTENT_IPFS";
|
|
351
|
+
MintProgressMessage$1["GENERATE_PREVIEW"] = "GENERATE_PREVIEW";
|
|
352
|
+
MintProgressMessage$1["AUTHENTICATE_TOKEN"] = "AUTHENTICATE_TOKEN";
|
|
353
|
+
return MintProgressMessage$1;
|
|
354
|
+
}({});
|
|
355
|
+
let SigningState = /* @__PURE__ */ function(SigningState$1) {
|
|
356
|
+
SigningState$1["NONE"] = "NONE";
|
|
357
|
+
SigningState$1["NOT_FOUND"] = "NOT_FOUND";
|
|
358
|
+
SigningState$1["QUEUED"] = "QUEUED";
|
|
359
|
+
SigningState$1["GENERATING_METADATA"] = "GENERATING_METADATA";
|
|
360
|
+
SigningState$1["METADATA_GENERATED"] = "METADATA_GENERATED";
|
|
361
|
+
SigningState$1["CALLING_CONTRACT"] = "CALLING_CONTRACT";
|
|
362
|
+
SigningState$1["SIGNED"] = "SIGNED";
|
|
363
|
+
return SigningState$1;
|
|
364
|
+
}({});
|
|
348
365
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
);
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/types/Metadata.ts
|
|
368
|
+
let ProcessRawTokenFeatureErrorType = /* @__PURE__ */ function(ProcessRawTokenFeatureErrorType$1) {
|
|
369
|
+
ProcessRawTokenFeatureErrorType$1["UNKNOWN"] = "UNKNOWN";
|
|
370
|
+
ProcessRawTokenFeatureErrorType$1["INVALID_PROPERTY_TYPE"] = "INVALID_PROPERTY_TYPE";
|
|
371
|
+
ProcessRawTokenFeatureErrorType$1["INVALID_FEATURES_SIGNATURE"] = "INVALID_FEATURES_SIGNATURE";
|
|
372
|
+
return ProcessRawTokenFeatureErrorType$1;
|
|
373
|
+
}({});
|
|
374
|
+
const ProcessRawTokenFeatureErrorTypes = Object.values(ProcessRawTokenFeatureErrorType);
|
|
359
375
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/wallet/ContractOperation.ts
|
|
378
|
+
/**
|
|
379
|
+
* A Blockchain Environment is based on the classification of the "blockchain
|
|
380
|
+
* engine".
|
|
381
|
+
* TODO: should decide between BlockchainEnv & BlockchainNetwork and harmonize
|
|
382
|
+
*/
|
|
383
|
+
let BlockchainEnv = /* @__PURE__ */ function(BlockchainEnv$1) {
|
|
384
|
+
BlockchainEnv$1["EVM"] = "EVM";
|
|
385
|
+
BlockchainEnv$1["TEZOS"] = "TEZOS";
|
|
386
|
+
return BlockchainEnv$1;
|
|
387
|
+
}({});
|
|
388
|
+
/**
|
|
389
|
+
* An array of all the `BlockchainEnv` enum values.
|
|
390
|
+
*/
|
|
391
|
+
const BlockchainEnvs = Object.values(BlockchainEnv);
|
|
392
|
+
let BlockchainNetwork = /* @__PURE__ */ function(BlockchainNetwork$1) {
|
|
393
|
+
BlockchainNetwork$1["TEZOS"] = "TEZOS";
|
|
394
|
+
BlockchainNetwork$1["ETHEREUM"] = "ETHEREUM";
|
|
395
|
+
return BlockchainNetwork$1;
|
|
396
|
+
}({});
|
|
397
|
+
const BlockchainNetworks = Object.keys(BlockchainNetwork);
|
|
398
|
+
let TransactionType = /* @__PURE__ */ function(TransactionType$1) {
|
|
399
|
+
TransactionType$1["OFFCHAIN"] = "OFFCHAIN";
|
|
400
|
+
TransactionType$1["ONCHAIN"] = "ONCHAIN";
|
|
401
|
+
return TransactionType$1;
|
|
402
|
+
}({});
|
|
403
|
+
let BlockchainType = /* @__PURE__ */ function(BlockchainType$1) {
|
|
404
|
+
BlockchainType$1["ETHEREUM"] = "ETHEREUM";
|
|
405
|
+
BlockchainType$1["TEZOS"] = "TEZOS";
|
|
406
|
+
BlockchainType$1["BASE"] = "BASE";
|
|
407
|
+
return BlockchainType$1;
|
|
408
|
+
}({});
|
|
409
|
+
const BlockchainTypes = enumKeys(BlockchainType);
|
|
410
|
+
const chainNetworkToChainMap = {
|
|
411
|
+
[BlockchainNetwork.ETHEREUM]: BlockchainType.ETHEREUM,
|
|
412
|
+
[BlockchainNetwork.TEZOS]: BlockchainType.TEZOS
|
|
391
413
|
};
|
|
414
|
+
/**
|
|
415
|
+
* Given a BlockchainNetwork, returns an associated BlockchainType of preference
|
|
416
|
+
*/
|
|
392
417
|
function networkToChain(network) {
|
|
393
|
-
|
|
418
|
+
return chainNetworkToChainMap[network];
|
|
394
419
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
420
|
+
const chainToChainEnvMap = {
|
|
421
|
+
[BlockchainType.BASE]: BlockchainEnv.EVM,
|
|
422
|
+
[BlockchainType.ETHEREUM]: BlockchainEnv.EVM,
|
|
423
|
+
[BlockchainType.TEZOS]: BlockchainEnv.TEZOS
|
|
399
424
|
};
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
425
|
+
const chainEnvToChainMap = {
|
|
426
|
+
[BlockchainEnv.EVM]: BlockchainType.ETHEREUM,
|
|
427
|
+
[BlockchainEnv.TEZOS]: BlockchainType.TEZOS
|
|
403
428
|
};
|
|
429
|
+
/**
|
|
430
|
+
* A Contract Operation defines a set of operations to run at different
|
|
431
|
+
* moments of the lifecycle of an operation. When an operation needs to be sent,
|
|
432
|
+
* its corresponding class is instantiated with the operation parameters and
|
|
433
|
+
* the following steps are performed:
|
|
434
|
+
* - prepare: preparation steps before calling a contract
|
|
435
|
+
* - call: the actual contract call
|
|
436
|
+
* - success: a message is emitted
|
|
437
|
+
* In case of failure, the whole lifecycle restarts, if the RPC is at cause it
|
|
438
|
+
* is swapped with another one. This logic is handled by an external runner.
|
|
439
|
+
*/
|
|
404
440
|
var ContractOperation = class {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
441
|
+
constructor(manager, params, chain) {
|
|
442
|
+
this.manager = manager;
|
|
443
|
+
this.params = params;
|
|
444
|
+
this.chain = chain;
|
|
445
|
+
}
|
|
410
446
|
};
|
|
411
447
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
// src/wallet/WalletCache.ts
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/wallet/WalletCache.ts
|
|
416
450
|
var WalletCacheClass = class {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
this.signaturesCache[address][options.type] = messageSigned;
|
|
442
|
-
}
|
|
451
|
+
constructor() {
|
|
452
|
+
this.signaturesCache = {};
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Get a signature from the cache, if the options allow, and if a valid
|
|
456
|
+
* signature can be found in the cache.
|
|
457
|
+
*/
|
|
458
|
+
signedMessageFromCache(address, options) {
|
|
459
|
+
if (!options.type) return null;
|
|
460
|
+
if (options.policy === "wallet-only") return null;
|
|
461
|
+
if (!this.signaturesCache[address]) return null;
|
|
462
|
+
if (!this.signaturesCache[address][options.type]) return null;
|
|
463
|
+
const msg = this.signaturesCache[address][options.type];
|
|
464
|
+
if (Date.now() - msg.signedAt.getTime() < 1e3 * 60 * 4) return msg;
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Cache a (message, signature) locally.
|
|
469
|
+
*/
|
|
470
|
+
cacheMessageSigned(address, messageSigned, options) {
|
|
471
|
+
if (!options.type) return;
|
|
472
|
+
if (!this.signaturesCache[address]) this.signaturesCache[address] = {};
|
|
473
|
+
this.signaturesCache[address][options.type] = messageSigned;
|
|
474
|
+
}
|
|
443
475
|
};
|
|
444
|
-
|
|
476
|
+
const WalletCache = new WalletCacheClass();
|
|
445
477
|
|
|
446
|
-
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/wallet/WalletManager.ts
|
|
447
480
|
var PendingSigningRequestError = class extends Error {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
481
|
+
constructor(..._args) {
|
|
482
|
+
super(..._args);
|
|
483
|
+
this.name = "PendingSigningRequestError";
|
|
484
|
+
this.message = "There is already a pending signing request";
|
|
485
|
+
}
|
|
453
486
|
};
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
487
|
+
let WalletConnectionErrorReason = /* @__PURE__ */ function(WalletConnectionErrorReason$1) {
|
|
488
|
+
WalletConnectionErrorReason$1["INCORRECT_CHAIN"] = "INCORRECT_CHAIN";
|
|
489
|
+
return WalletConnectionErrorReason$1;
|
|
490
|
+
}({});
|
|
458
491
|
var WalletConnectionError = class extends Error {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
492
|
+
constructor(reason) {
|
|
493
|
+
super(`Wallet connection failed due to ${reason} error`);
|
|
494
|
+
this.reason = reason;
|
|
495
|
+
this.name = "WalletConnectionError";
|
|
496
|
+
}
|
|
464
497
|
};
|
|
465
498
|
var UserRejectedError = class extends Error {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
499
|
+
constructor(..._args2) {
|
|
500
|
+
super(..._args2);
|
|
501
|
+
this.name = "UserRejectedError";
|
|
502
|
+
this.message = "User rejected the request";
|
|
503
|
+
}
|
|
471
504
|
};
|
|
472
505
|
var InsufficientFundsError = class extends Error {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
506
|
+
constructor(..._args3) {
|
|
507
|
+
super(..._args3);
|
|
508
|
+
this.name = "InsufficientFundsError";
|
|
509
|
+
this.message = "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account.";
|
|
510
|
+
}
|
|
478
511
|
};
|
|
479
512
|
var TransactionRevertedError = class extends Error {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
513
|
+
constructor(paramErrorName) {
|
|
514
|
+
super(`Transaction reverted with error: ${paramErrorName}`);
|
|
515
|
+
this.paramErrorName = paramErrorName;
|
|
516
|
+
this.name = "TransactionRevertedError";
|
|
517
|
+
this.errorName = paramErrorName;
|
|
518
|
+
}
|
|
486
519
|
};
|
|
487
520
|
var TransactionReceiptError = class extends Error {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
this.name = "TransactionReceiptError";
|
|
493
|
-
}
|
|
521
|
+
constructor() {
|
|
522
|
+
super(`Failed to locate transaction - please check for pending transactions in your wallet before resubmitting.`);
|
|
523
|
+
this.name = "TransactionReceiptError";
|
|
524
|
+
}
|
|
494
525
|
};
|
|
495
526
|
var TransactionUnknownError = class extends Error {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
this.errorName = paramErrorName;
|
|
503
|
-
}
|
|
527
|
+
constructor(paramErrorName) {
|
|
528
|
+
super(paramErrorName || `An unknown error occurred waiting for transaction - please check for pending transactions in your wallet before resubmitting.`);
|
|
529
|
+
this.paramErrorName = paramErrorName;
|
|
530
|
+
this.name = "TransactionUnknownError";
|
|
531
|
+
this.errorName = paramErrorName;
|
|
532
|
+
}
|
|
504
533
|
};
|
|
505
534
|
var NetworkError = class extends Error {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
535
|
+
constructor(..._args4) {
|
|
536
|
+
super(..._args4);
|
|
537
|
+
this.name = "NetworkError";
|
|
538
|
+
this.message = "Network error";
|
|
539
|
+
}
|
|
511
540
|
};
|
|
512
541
|
var BadRequestError = class extends Error {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
542
|
+
constructor(..._args5) {
|
|
543
|
+
super(..._args5);
|
|
544
|
+
this.name = "BadRequestError";
|
|
545
|
+
this.message = "Bad request";
|
|
546
|
+
}
|
|
518
547
|
};
|
|
519
548
|
var WalletManager = class {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
549
|
+
constructor(address) {
|
|
550
|
+
this.cache = WalletCache;
|
|
551
|
+
this.address = address;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Sign a message using the wallet associated with the manager. Some sign
|
|
555
|
+
* options can be provided, mainly for implementing cache-fetching for
|
|
556
|
+
* avoiding redundant signatures from the wallet.
|
|
557
|
+
*
|
|
558
|
+
* Signatures are stored in cache so that users don't have to repeatedly
|
|
559
|
+
* sign messages for similar operations, as long as messages are considered to
|
|
560
|
+
* be valid for their usage. This function returns a message signed of a
|
|
561
|
+
* given type if it's still valid in cache. A signature is considered valid
|
|
562
|
+
* if it was made less than 4 minutes ago.
|
|
563
|
+
*
|
|
564
|
+
* @remark For now, the cache policy enforces a 5 min cache time for the
|
|
565
|
+
* signatures, after which they are considered invalid. There isn't any way to
|
|
566
|
+
* change this with the current implementation, although it could be added.
|
|
567
|
+
*
|
|
568
|
+
* @param options Sign options, which can be used to determine whether the
|
|
569
|
+
* signature should be fetched from cache or not.
|
|
570
|
+
*/
|
|
571
|
+
signMessage(message, options) {
|
|
572
|
+
return new Promise(async (resolve) => {
|
|
573
|
+
if (options) {
|
|
574
|
+
const fromCache = this.cache.signedMessageFromCache(this.address, options);
|
|
575
|
+
if (fromCache) return resolve(success(fromCache));
|
|
576
|
+
}
|
|
577
|
+
const res = await this.signMessageWithWallet(message);
|
|
578
|
+
if (res.isFailure()) return resolve(res);
|
|
579
|
+
const messageSigned = {
|
|
580
|
+
message,
|
|
581
|
+
signature: res.value,
|
|
582
|
+
signedAt: /* @__PURE__ */ new Date()
|
|
583
|
+
};
|
|
584
|
+
if (options) this.cache.cacheMessageSigned(this.address, messageSigned, options);
|
|
585
|
+
return resolve(success(messageSigned));
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region src/lib/currencies.ts
|
|
592
|
+
/**
|
|
593
|
+
* A map of every currency and its declarative definition.
|
|
594
|
+
*/
|
|
595
|
+
const currenciesDef = {
|
|
596
|
+
[BlockchainType.ETHEREUM]: {
|
|
597
|
+
shortname: "ETH",
|
|
598
|
+
decimalDigits: etherUnits.wei,
|
|
599
|
+
basename: "ETH"
|
|
600
|
+
},
|
|
601
|
+
[BlockchainType.BASE]: {
|
|
602
|
+
shortname: "ETH (Base)",
|
|
603
|
+
decimalDigits: etherUnits.wei,
|
|
604
|
+
basename: "ETH"
|
|
605
|
+
},
|
|
606
|
+
[BlockchainType.TEZOS]: {
|
|
607
|
+
shortname: "TEZ",
|
|
608
|
+
decimalDigits: 6,
|
|
609
|
+
basename: "TEZ"
|
|
610
|
+
},
|
|
611
|
+
FXH: {
|
|
612
|
+
shortname: "FXH",
|
|
613
|
+
decimalDigits: 18,
|
|
614
|
+
basename: "FXH"
|
|
615
|
+
},
|
|
616
|
+
_default: {
|
|
617
|
+
shortname: "USD",
|
|
618
|
+
decimalDigits: 2,
|
|
619
|
+
basename: "USD"
|
|
620
|
+
}
|
|
563
621
|
};
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
StaticGenError,
|
|
608
|
-
TestPreviewError,
|
|
609
|
-
TokenActionType,
|
|
610
|
-
TransactionReceiptError,
|
|
611
|
-
TransactionRevertedError,
|
|
612
|
-
TransactionType,
|
|
613
|
-
TransactionUnknownError,
|
|
614
|
-
UserAuthorization,
|
|
615
|
-
UserFlag,
|
|
616
|
-
UserFlagValues,
|
|
617
|
-
UserRejectedError,
|
|
618
|
-
UserType,
|
|
619
|
-
WalletConnectionError,
|
|
620
|
-
WalletConnectionErrorReason,
|
|
621
|
-
WalletManager,
|
|
622
|
-
accountTypeGuard,
|
|
623
|
-
chainEnvToChainMap,
|
|
624
|
-
chainToChainEnvMap,
|
|
625
|
-
isReserveMintPass,
|
|
626
|
-
isReserveWhiteList,
|
|
627
|
-
networkToChain,
|
|
628
|
-
objktFeatureType,
|
|
629
|
-
offerTypeGuard
|
|
622
|
+
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region src/lib/units.ts
|
|
625
|
+
/**
|
|
626
|
+
* Given a number in mutez, outputs a more readable format such as
|
|
627
|
+
* 1.1K or 200.0K etc...
|
|
628
|
+
*/
|
|
629
|
+
function bigMutezFormatter(num, digits = 1) {
|
|
630
|
+
if (num === 0) return "0";
|
|
631
|
+
num = num * 1e-6;
|
|
632
|
+
const item = [
|
|
633
|
+
{
|
|
634
|
+
value: 1,
|
|
635
|
+
symbol: ""
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
value: 1e3,
|
|
639
|
+
symbol: "K"
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
value: 1e6,
|
|
643
|
+
symbol: "M"
|
|
644
|
+
}
|
|
645
|
+
].slice().reverse().find((item$1) => {
|
|
646
|
+
return num >= item$1.value;
|
|
647
|
+
});
|
|
648
|
+
if (num < 100) digits++;
|
|
649
|
+
const div = item ? item.value : 1;
|
|
650
|
+
return (num / div).toFixed(digits) + (item?.symbol ?? "");
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Given a number in mutez, outputs a string with decimals provided, if any
|
|
654
|
+
* Default to
|
|
655
|
+
*/
|
|
656
|
+
function displayDecimals(mutez, maxDecimals, exponent = 6) {
|
|
657
|
+
let decimals = getDecimalsNb(mutez, exponent);
|
|
658
|
+
decimals = maxDecimals != null ? Math.min(maxDecimals, decimals) : decimals;
|
|
659
|
+
const tez = mutez / Math.pow(10, exponent);
|
|
660
|
+
return ((tez - Math.floor(tez)) * 10 ** decimals | 0) > 0 ? Number(tez.toFixed(decimals)) : Math.floor(tez);
|
|
661
|
+
}
|
|
662
|
+
const defaultDisplayPriceOptions = {
|
|
663
|
+
abbreviateBig: false,
|
|
664
|
+
maxDecimals: void 0
|
|
630
665
|
};
|
|
666
|
+
/**
|
|
667
|
+
* Given a uint price, outputs a string in human-readable unit (ex 1 ETH, 1 XTZ)
|
|
668
|
+
* with an output which can be configured using options. The default options
|
|
669
|
+
* provide a full representation of the price value, to ensure it's properly
|
|
670
|
+
* displayed and to avoid bad surprises.
|
|
671
|
+
*
|
|
672
|
+
* @param options Some options for the display. The default options
|
|
673
|
+
* provide a full representation of the price value, to ensure it's properly
|
|
674
|
+
* displayed and to avoid bad surprises.
|
|
675
|
+
*
|
|
676
|
+
* @see units.test.ts For examples on usage
|
|
677
|
+
*/
|
|
678
|
+
function displayPrice(price, currency, options) {
|
|
679
|
+
const currDef = currenciesDef[currency];
|
|
680
|
+
const _opts = {
|
|
681
|
+
...defaultDisplayPriceOptions,
|
|
682
|
+
...options
|
|
683
|
+
};
|
|
684
|
+
const num = new BigIntDecimal(price, currDef.decimalDigits);
|
|
685
|
+
num.optimizeDecimals();
|
|
686
|
+
if (_opts.abbreviateBig) return num.abbreviate(_opts.maxDecimals);
|
|
687
|
+
else if (typeof _opts.maxDecimals !== "undefined") num.ceil(_opts.maxDecimals);
|
|
688
|
+
return num.toString();
|
|
689
|
+
}
|
|
690
|
+
const priceAbbrevSymbols = [{
|
|
691
|
+
exponent: 6,
|
|
692
|
+
symbol: "M"
|
|
693
|
+
}, {
|
|
694
|
+
exponent: 3,
|
|
695
|
+
symbol: "K"
|
|
696
|
+
}];
|
|
697
|
+
var BigIntDecimal = class {
|
|
698
|
+
constructor(int, decimals) {
|
|
699
|
+
this.int = int;
|
|
700
|
+
this.decimals = decimals;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Decrease the number of decimals as much as possible as long as the
|
|
704
|
+
* full precision is kept. Effectively, remove as many 0 digits on the
|
|
705
|
+
* right side of the decimal pointer.
|
|
706
|
+
*/
|
|
707
|
+
optimizeDecimals() {
|
|
708
|
+
const base = BigInt("10");
|
|
709
|
+
const zero = BigInt("0");
|
|
710
|
+
while (this.decimals > 0 && this.int % base === zero) {
|
|
711
|
+
this.decimals--;
|
|
712
|
+
this.int = this.int / base;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Round the number up so that it gets to a certain number of decimals,
|
|
717
|
+
* loosing some precision in the process. If the number of decimals is
|
|
718
|
+
* already lower than the given precision number, will not round further.
|
|
719
|
+
* Once this function is done it runs an decimal optimization to remove
|
|
720
|
+
* eventual zeros on the right side of the decimal.
|
|
721
|
+
* @param precision Number of decimals to round the number to
|
|
722
|
+
*/
|
|
723
|
+
ceil(precision) {
|
|
724
|
+
if (precision < 0) throw new Error("decimal precision < 0 !!");
|
|
725
|
+
if (this.decimals === 0) return;
|
|
726
|
+
if (this.decimals <= precision) {
|
|
727
|
+
this.optimizeDecimals();
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const base = BigInt("10");
|
|
731
|
+
while (this.decimals > precision) {
|
|
732
|
+
if (this.int % base > 0) this.int = this.int + base;
|
|
733
|
+
this.decimals--;
|
|
734
|
+
this.int = this.int / base;
|
|
735
|
+
}
|
|
736
|
+
this.optimizeDecimals();
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* A string representation of the number, conserving all the precision
|
|
740
|
+
* defined by the decimal.
|
|
741
|
+
*/
|
|
742
|
+
toString() {
|
|
743
|
+
let full = this.int.toString();
|
|
744
|
+
if (this.decimals === 0) return full;
|
|
745
|
+
if (this.decimals >= full.length) full = full.padStart(this.decimals + 1, "0");
|
|
746
|
+
const decIdx = full.length - this.decimals;
|
|
747
|
+
return full.slice(0, decIdx) + "." + full.slice(decIdx);
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* 100K, 100M, etc
|
|
751
|
+
* Adds the abbreviation at the end of the number, by rounding the lower
|
|
752
|
+
* orders.
|
|
753
|
+
* @param maxDecimals the maximum number of decimals to display, def: 3
|
|
754
|
+
* @remark The implementation isn't really great, as it mutates the current
|
|
755
|
+
* number for processing. Can be improved.
|
|
756
|
+
*/
|
|
757
|
+
abbreviate(maxDecimals = 3) {
|
|
758
|
+
const base = this.int / bigIntPow(BigInt(10), this.decimals);
|
|
759
|
+
if (base < BigInt(1)) return this.toString();
|
|
760
|
+
for (const abbrv of priceAbbrevSymbols) {
|
|
761
|
+
const exp = bigIntPow(BigInt(10), abbrv.exponent);
|
|
762
|
+
if (base > exp) {
|
|
763
|
+
this.decimals += abbrv.exponent;
|
|
764
|
+
this.ceil(maxDecimals);
|
|
765
|
+
return this.toString() + abbrv.symbol;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
this.ceil(maxDecimals);
|
|
769
|
+
return this.toString();
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* Takes some normalized royalties as input, and serialize it to a string ready
|
|
774
|
+
* to be displayed on the front-end. **It expects the royalty amount to be
|
|
775
|
+
* normalized, and will throw if not the case.**
|
|
776
|
+
* @param royalties A normalized value between [0; 1], ex: 0.1 = 10%, 0.01 = 1%
|
|
777
|
+
* @returns A text string ready to display on the front
|
|
778
|
+
*/
|
|
779
|
+
function displayRoyalties(royalties) {
|
|
780
|
+
if (royalties < 0 || royalties > 1) throw new Error(`The royalties passed (${royalties}) are not normalized, the value should be between 0 and 1`);
|
|
781
|
+
return (royalties * 100).toFixed(1) + "%";
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Given a number in the [0; 1] range, displays the percentage in an elegant manner
|
|
785
|
+
*/
|
|
786
|
+
function displayPercentage(x, prettifyLow = true) {
|
|
787
|
+
if (x < 0 || x > 1) throw new Error(`The x passed for displaying percentage (${x}) are not normalized, the value should be between 0 and 1`);
|
|
788
|
+
const x100 = x * 100;
|
|
789
|
+
if (x100 < 1e-4 && prettifyLow) return "< 0.0001";
|
|
790
|
+
let fixed = x100.toFixed(1);
|
|
791
|
+
let right = fixed.split(".").pop();
|
|
792
|
+
if (right && parseInt(right) === 0) return fixed.split(".")[0];
|
|
793
|
+
else return fixed;
|
|
794
|
+
}
|
|
795
|
+
function prettyPrintBytes(size) {
|
|
796
|
+
const units = [
|
|
797
|
+
"B",
|
|
798
|
+
"KB",
|
|
799
|
+
"MB"
|
|
800
|
+
];
|
|
801
|
+
let s = size;
|
|
802
|
+
for (const unit of units) {
|
|
803
|
+
if (s < 1e3) return s.toFixed(0) + unit;
|
|
804
|
+
s /= 1024;
|
|
805
|
+
}
|
|
806
|
+
return s.toFixed(0) + "GB";
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
//#endregion
|
|
810
|
+
export { ArticleFlag, AvatarUploadError, BadRequestError, BlockchainEnv, BlockchainEnvs, BlockchainNetwork, BlockchainNetworks, BlockchainType, BlockchainTypes, CaptureMode, CaptureModeList, CaptureTriggerMode, CaptureTriggerModeList, ContractOperation, EObjktFeatureType, EReserveMethod, EWalletOperatorState, EventAvailability, EventStatus, GenTokEditions, GenTokFlag, GenTokLabel, GenTokLabelGroup, GenTokLabel_Params, GenTokLabel_Redeemable, GenTokPricing, GenerativeTokenFormat, GenerativeTokenVersion, InsufficientFundsError, MetadataError, MintError, MintErrors, MintProgressMessage, NetworkError, PendingSigningRequestError, PreviewError, ProcessRawTokenFeatureErrorType, ProcessRawTokenFeatureErrorTypes, ProfileUploadError, RedeemableUserActionType, SandboxFileError, SigningState, StaticGenError, TestPreviewError, TokenActionType, TransactionReceiptError, TransactionRevertedError, TransactionType, TransactionUnknownError, UserAuthorization, UserFlag, UserFlagValues, UserRejectedError, UserType, WalletConnectionError, WalletConnectionErrorReason, WalletManager, accountTypeGuard, bigMutezFormatter, chainEnvToChainMap, chainToChainEnvMap, currenciesDef, displayDecimals, displayPercentage, displayPrice, displayRoyalties, isReserveMintPass, isReserveWhiteList, networkToChain, objktFeatureType, offerTypeGuard, prettyPrintBytes };
|
|
631
811
|
//# sourceMappingURL=index.js.map
|