@andrewkimjoseph/celina-sdk 0.25.6 → 0.25.7
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/build/clients/citizen-sdk.d.ts +1 -1
- package/build/clients/citizen-sdk.js +1 -8
- package/build/clients/citizen-sdk.js.map +1 -1
- package/build/clients/generated/citizen-sdk.bundle.js +1133 -0
- package/build/clients/generated/mento-sdk.bundle.js +20343 -0
- package/build/clients/generated/uniswap-sdk.bundle.js +29715 -0
- package/build/clients/mento-sdk.d.ts +1 -1
- package/build/clients/mento-sdk.js +1 -8
- package/build/clients/mento-sdk.js.map +1 -1
- package/build/clients/uniswap-sdk.d.ts +3 -3
- package/build/clients/uniswap-sdk.js +3 -12
- package/build/clients/uniswap-sdk.js.map +1 -1
- package/build/src/clients/citizen-sdk.d.ts +1 -1
- package/build/src/clients/citizen-sdk.js +1 -8
- package/build/src/clients/citizen-sdk.js.map +1 -1
- package/build/src/clients/mento-sdk.d.ts +1 -1
- package/build/src/clients/mento-sdk.js +1 -8
- package/build/src/clients/mento-sdk.js.map +1 -1
- package/build/src/clients/uniswap-sdk.d.ts +3 -3
- package/build/src/clients/uniswap-sdk.js +3 -12
- package/build/src/clients/uniswap-sdk.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,1133 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// node_modules/lz-string/libs/lz-string.js
|
|
28
|
+
var require_lz_string = __commonJS({
|
|
29
|
+
"node_modules/lz-string/libs/lz-string.js"(exports, module) {
|
|
30
|
+
var LZString = (function() {
|
|
31
|
+
var f = String.fromCharCode;
|
|
32
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
33
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
34
|
+
var baseReverseDic = {};
|
|
35
|
+
function getBaseValue(alphabet, character) {
|
|
36
|
+
if (!baseReverseDic[alphabet]) {
|
|
37
|
+
baseReverseDic[alphabet] = {};
|
|
38
|
+
for (var i = 0; i < alphabet.length; i++) {
|
|
39
|
+
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return baseReverseDic[alphabet][character];
|
|
43
|
+
}
|
|
44
|
+
var LZString2 = {
|
|
45
|
+
compressToBase64: function(input) {
|
|
46
|
+
if (input == null) return "";
|
|
47
|
+
var res = LZString2._compress(input, 6, function(a) {
|
|
48
|
+
return keyStrBase64.charAt(a);
|
|
49
|
+
});
|
|
50
|
+
switch (res.length % 4) {
|
|
51
|
+
// To produce valid Base64
|
|
52
|
+
default:
|
|
53
|
+
// When could this happen ?
|
|
54
|
+
case 0:
|
|
55
|
+
return res;
|
|
56
|
+
case 1:
|
|
57
|
+
return res + "===";
|
|
58
|
+
case 2:
|
|
59
|
+
return res + "==";
|
|
60
|
+
case 3:
|
|
61
|
+
return res + "=";
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
decompressFromBase64: function(input) {
|
|
65
|
+
if (input == null) return "";
|
|
66
|
+
if (input == "") return null;
|
|
67
|
+
return LZString2._decompress(input.length, 32, function(index) {
|
|
68
|
+
return getBaseValue(keyStrBase64, input.charAt(index));
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
compressToUTF16: function(input) {
|
|
72
|
+
if (input == null) return "";
|
|
73
|
+
return LZString2._compress(input, 15, function(a) {
|
|
74
|
+
return f(a + 32);
|
|
75
|
+
}) + " ";
|
|
76
|
+
},
|
|
77
|
+
decompressFromUTF16: function(compressed) {
|
|
78
|
+
if (compressed == null) return "";
|
|
79
|
+
if (compressed == "") return null;
|
|
80
|
+
return LZString2._decompress(compressed.length, 16384, function(index) {
|
|
81
|
+
return compressed.charCodeAt(index) - 32;
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
//compress into uint8array (UCS-2 big endian format)
|
|
85
|
+
compressToUint8Array: function(uncompressed) {
|
|
86
|
+
var compressed = LZString2.compress(uncompressed);
|
|
87
|
+
var buf = new Uint8Array(compressed.length * 2);
|
|
88
|
+
for (var i = 0, TotalLen = compressed.length; i < TotalLen; i++) {
|
|
89
|
+
var current_value = compressed.charCodeAt(i);
|
|
90
|
+
buf[i * 2] = current_value >>> 8;
|
|
91
|
+
buf[i * 2 + 1] = current_value % 256;
|
|
92
|
+
}
|
|
93
|
+
return buf;
|
|
94
|
+
},
|
|
95
|
+
//decompress from uint8array (UCS-2 big endian format)
|
|
96
|
+
decompressFromUint8Array: function(compressed) {
|
|
97
|
+
if (compressed === null || compressed === void 0) {
|
|
98
|
+
return LZString2.decompress(compressed);
|
|
99
|
+
} else {
|
|
100
|
+
var buf = new Array(compressed.length / 2);
|
|
101
|
+
for (var i = 0, TotalLen = buf.length; i < TotalLen; i++) {
|
|
102
|
+
buf[i] = compressed[i * 2] * 256 + compressed[i * 2 + 1];
|
|
103
|
+
}
|
|
104
|
+
var result = [];
|
|
105
|
+
buf.forEach(function(c) {
|
|
106
|
+
result.push(f(c));
|
|
107
|
+
});
|
|
108
|
+
return LZString2.decompress(result.join(""));
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
//compress into a string that is already URI encoded
|
|
112
|
+
compressToEncodedURIComponent: function(input) {
|
|
113
|
+
if (input == null) return "";
|
|
114
|
+
return LZString2._compress(input, 6, function(a) {
|
|
115
|
+
return keyStrUriSafe.charAt(a);
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
//decompress from an output of compressToEncodedURIComponent
|
|
119
|
+
decompressFromEncodedURIComponent: function(input) {
|
|
120
|
+
if (input == null) return "";
|
|
121
|
+
if (input == "") return null;
|
|
122
|
+
input = input.replace(/ /g, "+");
|
|
123
|
+
return LZString2._decompress(input.length, 32, function(index) {
|
|
124
|
+
return getBaseValue(keyStrUriSafe, input.charAt(index));
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
compress: function(uncompressed) {
|
|
128
|
+
return LZString2._compress(uncompressed, 16, function(a) {
|
|
129
|
+
return f(a);
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
_compress: function(uncompressed, bitsPerChar, getCharFromInt) {
|
|
133
|
+
if (uncompressed == null) return "";
|
|
134
|
+
var i, value, context_dictionary = {}, context_dictionaryToCreate = {}, context_c = "", context_wc = "", context_w = "", context_enlargeIn = 2, context_dictSize = 3, context_numBits = 2, context_data = [], context_data_val = 0, context_data_position = 0, ii;
|
|
135
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
136
|
+
context_c = uncompressed.charAt(ii);
|
|
137
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary, context_c)) {
|
|
138
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
139
|
+
context_dictionaryToCreate[context_c] = true;
|
|
140
|
+
}
|
|
141
|
+
context_wc = context_w + context_c;
|
|
142
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary, context_wc)) {
|
|
143
|
+
context_w = context_wc;
|
|
144
|
+
} else {
|
|
145
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
146
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
147
|
+
for (i = 0; i < context_numBits; i++) {
|
|
148
|
+
context_data_val = context_data_val << 1;
|
|
149
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
150
|
+
context_data_position = 0;
|
|
151
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
152
|
+
context_data_val = 0;
|
|
153
|
+
} else {
|
|
154
|
+
context_data_position++;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
value = context_w.charCodeAt(0);
|
|
158
|
+
for (i = 0; i < 8; i++) {
|
|
159
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
160
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
161
|
+
context_data_position = 0;
|
|
162
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
163
|
+
context_data_val = 0;
|
|
164
|
+
} else {
|
|
165
|
+
context_data_position++;
|
|
166
|
+
}
|
|
167
|
+
value = value >> 1;
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
value = 1;
|
|
171
|
+
for (i = 0; i < context_numBits; i++) {
|
|
172
|
+
context_data_val = context_data_val << 1 | value;
|
|
173
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
174
|
+
context_data_position = 0;
|
|
175
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
176
|
+
context_data_val = 0;
|
|
177
|
+
} else {
|
|
178
|
+
context_data_position++;
|
|
179
|
+
}
|
|
180
|
+
value = 0;
|
|
181
|
+
}
|
|
182
|
+
value = context_w.charCodeAt(0);
|
|
183
|
+
for (i = 0; i < 16; i++) {
|
|
184
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
185
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
186
|
+
context_data_position = 0;
|
|
187
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
188
|
+
context_data_val = 0;
|
|
189
|
+
} else {
|
|
190
|
+
context_data_position++;
|
|
191
|
+
}
|
|
192
|
+
value = value >> 1;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
context_enlargeIn--;
|
|
196
|
+
if (context_enlargeIn == 0) {
|
|
197
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
198
|
+
context_numBits++;
|
|
199
|
+
}
|
|
200
|
+
delete context_dictionaryToCreate[context_w];
|
|
201
|
+
} else {
|
|
202
|
+
value = context_dictionary[context_w];
|
|
203
|
+
for (i = 0; i < context_numBits; i++) {
|
|
204
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
205
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
206
|
+
context_data_position = 0;
|
|
207
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
208
|
+
context_data_val = 0;
|
|
209
|
+
} else {
|
|
210
|
+
context_data_position++;
|
|
211
|
+
}
|
|
212
|
+
value = value >> 1;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
context_enlargeIn--;
|
|
216
|
+
if (context_enlargeIn == 0) {
|
|
217
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
218
|
+
context_numBits++;
|
|
219
|
+
}
|
|
220
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
221
|
+
context_w = String(context_c);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (context_w !== "") {
|
|
225
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate, context_w)) {
|
|
226
|
+
if (context_w.charCodeAt(0) < 256) {
|
|
227
|
+
for (i = 0; i < context_numBits; i++) {
|
|
228
|
+
context_data_val = context_data_val << 1;
|
|
229
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
230
|
+
context_data_position = 0;
|
|
231
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
232
|
+
context_data_val = 0;
|
|
233
|
+
} else {
|
|
234
|
+
context_data_position++;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
value = context_w.charCodeAt(0);
|
|
238
|
+
for (i = 0; i < 8; i++) {
|
|
239
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
240
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
241
|
+
context_data_position = 0;
|
|
242
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
243
|
+
context_data_val = 0;
|
|
244
|
+
} else {
|
|
245
|
+
context_data_position++;
|
|
246
|
+
}
|
|
247
|
+
value = value >> 1;
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
value = 1;
|
|
251
|
+
for (i = 0; i < context_numBits; i++) {
|
|
252
|
+
context_data_val = context_data_val << 1 | value;
|
|
253
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
254
|
+
context_data_position = 0;
|
|
255
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
256
|
+
context_data_val = 0;
|
|
257
|
+
} else {
|
|
258
|
+
context_data_position++;
|
|
259
|
+
}
|
|
260
|
+
value = 0;
|
|
261
|
+
}
|
|
262
|
+
value = context_w.charCodeAt(0);
|
|
263
|
+
for (i = 0; i < 16; i++) {
|
|
264
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
265
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
266
|
+
context_data_position = 0;
|
|
267
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
268
|
+
context_data_val = 0;
|
|
269
|
+
} else {
|
|
270
|
+
context_data_position++;
|
|
271
|
+
}
|
|
272
|
+
value = value >> 1;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
context_enlargeIn--;
|
|
276
|
+
if (context_enlargeIn == 0) {
|
|
277
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
278
|
+
context_numBits++;
|
|
279
|
+
}
|
|
280
|
+
delete context_dictionaryToCreate[context_w];
|
|
281
|
+
} else {
|
|
282
|
+
value = context_dictionary[context_w];
|
|
283
|
+
for (i = 0; i < context_numBits; i++) {
|
|
284
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
285
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
286
|
+
context_data_position = 0;
|
|
287
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
288
|
+
context_data_val = 0;
|
|
289
|
+
} else {
|
|
290
|
+
context_data_position++;
|
|
291
|
+
}
|
|
292
|
+
value = value >> 1;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
context_enlargeIn--;
|
|
296
|
+
if (context_enlargeIn == 0) {
|
|
297
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
298
|
+
context_numBits++;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
value = 2;
|
|
302
|
+
for (i = 0; i < context_numBits; i++) {
|
|
303
|
+
context_data_val = context_data_val << 1 | value & 1;
|
|
304
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
305
|
+
context_data_position = 0;
|
|
306
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
307
|
+
context_data_val = 0;
|
|
308
|
+
} else {
|
|
309
|
+
context_data_position++;
|
|
310
|
+
}
|
|
311
|
+
value = value >> 1;
|
|
312
|
+
}
|
|
313
|
+
while (true) {
|
|
314
|
+
context_data_val = context_data_val << 1;
|
|
315
|
+
if (context_data_position == bitsPerChar - 1) {
|
|
316
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
317
|
+
break;
|
|
318
|
+
} else context_data_position++;
|
|
319
|
+
}
|
|
320
|
+
return context_data.join("");
|
|
321
|
+
},
|
|
322
|
+
decompress: function(compressed) {
|
|
323
|
+
if (compressed == null) return "";
|
|
324
|
+
if (compressed == "") return null;
|
|
325
|
+
return LZString2._decompress(compressed.length, 32768, function(index) {
|
|
326
|
+
return compressed.charCodeAt(index);
|
|
327
|
+
});
|
|
328
|
+
},
|
|
329
|
+
_decompress: function(length, resetValue, getNextValue) {
|
|
330
|
+
var dictionary = [], next, enlargeIn = 4, dictSize = 4, numBits = 3, entry = "", result = [], i, w, bits, resb, maxpower, power, c, data = { val: getNextValue(0), position: resetValue, index: 1 };
|
|
331
|
+
for (i = 0; i < 3; i += 1) {
|
|
332
|
+
dictionary[i] = i;
|
|
333
|
+
}
|
|
334
|
+
bits = 0;
|
|
335
|
+
maxpower = Math.pow(2, 2);
|
|
336
|
+
power = 1;
|
|
337
|
+
while (power != maxpower) {
|
|
338
|
+
resb = data.val & data.position;
|
|
339
|
+
data.position >>= 1;
|
|
340
|
+
if (data.position == 0) {
|
|
341
|
+
data.position = resetValue;
|
|
342
|
+
data.val = getNextValue(data.index++);
|
|
343
|
+
}
|
|
344
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
345
|
+
power <<= 1;
|
|
346
|
+
}
|
|
347
|
+
switch (next = bits) {
|
|
348
|
+
case 0:
|
|
349
|
+
bits = 0;
|
|
350
|
+
maxpower = Math.pow(2, 8);
|
|
351
|
+
power = 1;
|
|
352
|
+
while (power != maxpower) {
|
|
353
|
+
resb = data.val & data.position;
|
|
354
|
+
data.position >>= 1;
|
|
355
|
+
if (data.position == 0) {
|
|
356
|
+
data.position = resetValue;
|
|
357
|
+
data.val = getNextValue(data.index++);
|
|
358
|
+
}
|
|
359
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
360
|
+
power <<= 1;
|
|
361
|
+
}
|
|
362
|
+
c = f(bits);
|
|
363
|
+
break;
|
|
364
|
+
case 1:
|
|
365
|
+
bits = 0;
|
|
366
|
+
maxpower = Math.pow(2, 16);
|
|
367
|
+
power = 1;
|
|
368
|
+
while (power != maxpower) {
|
|
369
|
+
resb = data.val & data.position;
|
|
370
|
+
data.position >>= 1;
|
|
371
|
+
if (data.position == 0) {
|
|
372
|
+
data.position = resetValue;
|
|
373
|
+
data.val = getNextValue(data.index++);
|
|
374
|
+
}
|
|
375
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
376
|
+
power <<= 1;
|
|
377
|
+
}
|
|
378
|
+
c = f(bits);
|
|
379
|
+
break;
|
|
380
|
+
case 2:
|
|
381
|
+
return "";
|
|
382
|
+
}
|
|
383
|
+
dictionary[3] = c;
|
|
384
|
+
w = c;
|
|
385
|
+
result.push(c);
|
|
386
|
+
while (true) {
|
|
387
|
+
if (data.index > length) {
|
|
388
|
+
return "";
|
|
389
|
+
}
|
|
390
|
+
bits = 0;
|
|
391
|
+
maxpower = Math.pow(2, numBits);
|
|
392
|
+
power = 1;
|
|
393
|
+
while (power != maxpower) {
|
|
394
|
+
resb = data.val & data.position;
|
|
395
|
+
data.position >>= 1;
|
|
396
|
+
if (data.position == 0) {
|
|
397
|
+
data.position = resetValue;
|
|
398
|
+
data.val = getNextValue(data.index++);
|
|
399
|
+
}
|
|
400
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
401
|
+
power <<= 1;
|
|
402
|
+
}
|
|
403
|
+
switch (c = bits) {
|
|
404
|
+
case 0:
|
|
405
|
+
bits = 0;
|
|
406
|
+
maxpower = Math.pow(2, 8);
|
|
407
|
+
power = 1;
|
|
408
|
+
while (power != maxpower) {
|
|
409
|
+
resb = data.val & data.position;
|
|
410
|
+
data.position >>= 1;
|
|
411
|
+
if (data.position == 0) {
|
|
412
|
+
data.position = resetValue;
|
|
413
|
+
data.val = getNextValue(data.index++);
|
|
414
|
+
}
|
|
415
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
416
|
+
power <<= 1;
|
|
417
|
+
}
|
|
418
|
+
dictionary[dictSize++] = f(bits);
|
|
419
|
+
c = dictSize - 1;
|
|
420
|
+
enlargeIn--;
|
|
421
|
+
break;
|
|
422
|
+
case 1:
|
|
423
|
+
bits = 0;
|
|
424
|
+
maxpower = Math.pow(2, 16);
|
|
425
|
+
power = 1;
|
|
426
|
+
while (power != maxpower) {
|
|
427
|
+
resb = data.val & data.position;
|
|
428
|
+
data.position >>= 1;
|
|
429
|
+
if (data.position == 0) {
|
|
430
|
+
data.position = resetValue;
|
|
431
|
+
data.val = getNextValue(data.index++);
|
|
432
|
+
}
|
|
433
|
+
bits |= (resb > 0 ? 1 : 0) * power;
|
|
434
|
+
power <<= 1;
|
|
435
|
+
}
|
|
436
|
+
dictionary[dictSize++] = f(bits);
|
|
437
|
+
c = dictSize - 1;
|
|
438
|
+
enlargeIn--;
|
|
439
|
+
break;
|
|
440
|
+
case 2:
|
|
441
|
+
return result.join("");
|
|
442
|
+
}
|
|
443
|
+
if (enlargeIn == 0) {
|
|
444
|
+
enlargeIn = Math.pow(2, numBits);
|
|
445
|
+
numBits++;
|
|
446
|
+
}
|
|
447
|
+
if (dictionary[c]) {
|
|
448
|
+
entry = dictionary[c];
|
|
449
|
+
} else {
|
|
450
|
+
if (c === dictSize) {
|
|
451
|
+
entry = w + w.charAt(0);
|
|
452
|
+
} else {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
result.push(entry);
|
|
457
|
+
dictionary[dictSize++] = w + entry.charAt(0);
|
|
458
|
+
enlargeIn--;
|
|
459
|
+
w = entry;
|
|
460
|
+
if (enlargeIn == 0) {
|
|
461
|
+
enlargeIn = Math.pow(2, numBits);
|
|
462
|
+
numBits++;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
return LZString2;
|
|
468
|
+
})();
|
|
469
|
+
if (typeof define === "function" && define.amd) {
|
|
470
|
+
define(function() {
|
|
471
|
+
return LZString;
|
|
472
|
+
});
|
|
473
|
+
} else if (typeof module !== "undefined" && module != null) {
|
|
474
|
+
module.exports = LZString;
|
|
475
|
+
} else if (typeof angular !== "undefined" && angular != null) {
|
|
476
|
+
angular.module("LZString", []).factory("LZString", function() {
|
|
477
|
+
return LZString;
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
// node_modules/@goodsdks/citizen-sdk/dist/index.js
|
|
484
|
+
var import_lz_string = __toESM(require_lz_string(), 1);
|
|
485
|
+
import { parseAbi, zeroAddress, getAddress, ContractFunctionExecutionError, createPublicClient, http } from "viem";
|
|
486
|
+
import { waitForTransactionReceipt } from "viem/actions";
|
|
487
|
+
var FV_IDENTIFIER_MSG2 = `Sign this message to request verifying your account <account> and to create your own secret unique identifier for your anonymized record.
|
|
488
|
+
You can use this identifier in the future to delete this anonymized record.
|
|
489
|
+
WARNING: do not sign this message unless you trust the website/application requesting this signature.`;
|
|
490
|
+
var Envs = {
|
|
491
|
+
production: {
|
|
492
|
+
dappUrl: "https://wallet.gooddollar.org",
|
|
493
|
+
identityUrl: "https://goodid.gooddollar.org",
|
|
494
|
+
backend: "https://goodserver.gooddollar.org",
|
|
495
|
+
goodCollectiveUrl: "https://goodcollective.vercel.app/"
|
|
496
|
+
},
|
|
497
|
+
staging: {
|
|
498
|
+
dappUrl: "https://qa.gooddollar.org",
|
|
499
|
+
identityUrl: "https://goodid-qa.vercel.app",
|
|
500
|
+
backend: "https://goodserver-qa.herokuapp.com",
|
|
501
|
+
goodCollectiveUrl: "https://dev-goodcollective.vercel.app/"
|
|
502
|
+
},
|
|
503
|
+
development: {
|
|
504
|
+
dappUrl: "https://dev.gooddollar.org",
|
|
505
|
+
identityUrl: "https://goodid-dev.vercel.app",
|
|
506
|
+
backend: "https://good-server.herokuapp.com",
|
|
507
|
+
goodCollectiveUrl: "https://dev-goodcollective.vercel.app/"
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
var SupportedChains = /* @__PURE__ */ ((SupportedChains6) => {
|
|
511
|
+
SupportedChains6[SupportedChains6["FUSE"] = 122] = "FUSE";
|
|
512
|
+
SupportedChains6[SupportedChains6["CELO"] = 42220] = "CELO";
|
|
513
|
+
SupportedChains6[SupportedChains6["XDC"] = 50] = "XDC";
|
|
514
|
+
return SupportedChains6;
|
|
515
|
+
})(SupportedChains || {});
|
|
516
|
+
var makeExplorer = (baseUrl) => ({
|
|
517
|
+
address: (address) => `${baseUrl}/address/${address}`,
|
|
518
|
+
tx: (hash) => `${baseUrl}/tx/${hash}`
|
|
519
|
+
});
|
|
520
|
+
var chainConfigs = {
|
|
521
|
+
[
|
|
522
|
+
122
|
|
523
|
+
/* FUSE */
|
|
524
|
+
]: {
|
|
525
|
+
id: 122,
|
|
526
|
+
key: "FUSE",
|
|
527
|
+
label: "Fuse",
|
|
528
|
+
shortName: "Fuse",
|
|
529
|
+
explorer: makeExplorer("https://explorer.fuse.io"),
|
|
530
|
+
rpcUrls: ["https://rpc.fuse.io", "https://fuse-rpc.gateway.pokt.network"],
|
|
531
|
+
defaultGasPrice: BigInt(11e9),
|
|
532
|
+
claimGasBuffer: 150000n,
|
|
533
|
+
fvDefaultChain: 42220,
|
|
534
|
+
contracts: {
|
|
535
|
+
production: {
|
|
536
|
+
identityContract: "0x2F9C28de9e6d44b71B91b8BA337A5D82e308E7BE",
|
|
537
|
+
ubiContract: "0xd253A5203817225e9768C05E5996d642fb96bA86",
|
|
538
|
+
faucetContract: "0x01ab5966C1d742Ae0CFF7f14cC0F4D85156e83d9",
|
|
539
|
+
g$Contract: "0x495d133B938596C9984d462F007B676bDc57eCEC"
|
|
540
|
+
},
|
|
541
|
+
staging: {
|
|
542
|
+
identityContract: "0xb0cD4828Cc90C5BC28f4920Adf2Fd8F025003D7E",
|
|
543
|
+
ubiContract: "0x54469071Ca82B46A2C01C09D38ca6Ca4347EB21d",
|
|
544
|
+
faucetContract: "0x70f361EDB97B245E8A68573637A31886A427fe2a",
|
|
545
|
+
g$Contract: "0xe39236a9Cf13f65DB8adD06BD4b834C65c523d2b"
|
|
546
|
+
},
|
|
547
|
+
development: {
|
|
548
|
+
identityContract: "0x1e006225cff7d37411db28f652e0Da9D20325eBb",
|
|
549
|
+
ubiContract: "0x3bdeB796950301FfC9568fAF89B7370f8B217321",
|
|
550
|
+
faucetContract: "0x09Ad3430D146aa662eA8c20cBEBceBC0bbB3FB0a",
|
|
551
|
+
g$Contract: "0x79BeecC4b165Ccf547662cB4f7C0e83b3796E5b3"
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
[
|
|
556
|
+
42220
|
|
557
|
+
/* CELO */
|
|
558
|
+
]: {
|
|
559
|
+
id: 42220,
|
|
560
|
+
key: "CELO",
|
|
561
|
+
label: "Celo",
|
|
562
|
+
shortName: "Celo",
|
|
563
|
+
explorer: makeExplorer("https://celoscan.io"),
|
|
564
|
+
rpcUrls: ["https://forno.celo.org", "https://rpc.ankr.com/celo"],
|
|
565
|
+
defaultGasPrice: BigInt(25001e6),
|
|
566
|
+
claimGasBuffer: 250000n,
|
|
567
|
+
fvDefaultChain: 42220,
|
|
568
|
+
contracts: {
|
|
569
|
+
production: {
|
|
570
|
+
identityContract: "0xC361A6E67822a0EDc17D899227dd9FC50BD62F42",
|
|
571
|
+
ubiContract: "0x43d72Ff17701B2DA814620735C39C620Ce0ea4A1",
|
|
572
|
+
faucetContract: "0x4F93Fa058b03953C851eFaA2e4FC5C34afDFAb84",
|
|
573
|
+
g$Contract: "0x62B8B11039FcfE5aB0C56E502b1C372A3d2a9c7A"
|
|
574
|
+
},
|
|
575
|
+
staging: {
|
|
576
|
+
identityContract: "0x0108BBc09772973aC27983Fc17c7D82D8e87ef4D",
|
|
577
|
+
ubiContract: "0x2881d417dA066600372753E73A3570F0781f18cB",
|
|
578
|
+
faucetContract: "0x9A0F8AEc626A0f493941Ceb1dA6021cFB0567293",
|
|
579
|
+
g$Contract: "0x61FA0fB802fd8345C06da558240E0651886fec69"
|
|
580
|
+
},
|
|
581
|
+
development: {
|
|
582
|
+
identityContract: "0xF25fA0D4896271228193E782831F6f3CFCcF169C",
|
|
583
|
+
ubiContract: "0x6B86F82293552C3B9FE380FC038A89e0328C7C5f",
|
|
584
|
+
faucetContract: "0x635b420e95b364def3A031166dA4bC4F57bf9dEB",
|
|
585
|
+
g$Contract: "0xFa51eFDc0910CCdA91732e6806912Fa12e2FD475"
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
[
|
|
590
|
+
50
|
|
591
|
+
/* XDC */
|
|
592
|
+
]: {
|
|
593
|
+
id: 50,
|
|
594
|
+
key: "XDC",
|
|
595
|
+
label: "XDC Network",
|
|
596
|
+
shortName: "XDC",
|
|
597
|
+
explorer: makeExplorer("https://xdcscan.com"),
|
|
598
|
+
rpcUrls: ["https://rpc.ankr.com/xdc"],
|
|
599
|
+
defaultGasPrice: BigInt(125e8),
|
|
600
|
+
claimGasBuffer: 150000n,
|
|
601
|
+
fvDefaultChain: 50,
|
|
602
|
+
contracts: {
|
|
603
|
+
production: {
|
|
604
|
+
identityContract: "0x27a4a02C9ed591E1a86e2e5D05870292c34622C9",
|
|
605
|
+
ubiContract: "0x22867567E2D80f2049200E25C6F31CB6Ec2F0faf",
|
|
606
|
+
faucetContract: "0x7344Da1Be296f03fbb8082aDaC5696058B5a9bd9",
|
|
607
|
+
g$Contract: "0xEC2136843a983885AebF2feB3931F73A8eBEe50c"
|
|
608
|
+
},
|
|
609
|
+
development: {
|
|
610
|
+
identityContract: "0xa6632e9551A340E8582cc797017fbA645695E29f",
|
|
611
|
+
ubiContract: "0xA2619D468EfE2f6D8b3D915B999327C8fE13aE2c",
|
|
612
|
+
faucetContract: "0x5CE5e22329914F3317B770184a405E91ef72e489",
|
|
613
|
+
g$Contract: "0xA13625A72Aef90645CfCe34e25c114629d7855e7"
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
var chainIds = Object.values(SupportedChains).filter(
|
|
619
|
+
(value) => typeof value === "number"
|
|
620
|
+
);
|
|
621
|
+
var chainIdSet = new Set(chainIds);
|
|
622
|
+
var isSupportedChain = (chainId) => typeof chainId === "number" && chainIdSet.has(chainId);
|
|
623
|
+
var createRpcUrlIterator = (chainId) => {
|
|
624
|
+
const urls = [...chainConfigs[chainId]?.rpcUrls ?? []];
|
|
625
|
+
if (!urls.length) {
|
|
626
|
+
throw new Error(`No RPC URLs configured for chain ${chainId}`);
|
|
627
|
+
}
|
|
628
|
+
let index = 0;
|
|
629
|
+
return () => {
|
|
630
|
+
const url = urls[index];
|
|
631
|
+
index = (index + 1) % urls.length;
|
|
632
|
+
return url;
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
var identityV2ABI = parseAbi([
|
|
636
|
+
// Whitelist management (IdentityV2)
|
|
637
|
+
"function addWhitelisted(address account)",
|
|
638
|
+
"function removeWhitelisted(address account)",
|
|
639
|
+
"function getWhitelistedRoot(address account) view returns (address)",
|
|
640
|
+
"function lastAuthenticated(address account) view returns (uint256)",
|
|
641
|
+
"function authenticationPeriod() view returns (uint256)",
|
|
642
|
+
// Wallet-link methods (IdentityV4)
|
|
643
|
+
"function connectAccount(address account) external",
|
|
644
|
+
"function disconnectAccount(address account) external",
|
|
645
|
+
"function connectedAccounts(address account) view returns (address)"
|
|
646
|
+
]);
|
|
647
|
+
var ubiSchemeV2ABI = parseAbi([
|
|
648
|
+
"function claim() returns (bool)",
|
|
649
|
+
"function checkEntitlement() view returns (uint256)",
|
|
650
|
+
"function checkEntitlement(address _member) view returns (uint256)",
|
|
651
|
+
"function getDailyStats() view returns (uint256 claimers, uint256 amount)",
|
|
652
|
+
"function periodStart() view returns (uint256)",
|
|
653
|
+
"function currentDay() view returns (uint256)",
|
|
654
|
+
"event UBIClaimed(address indexed account, uint256 amount)"
|
|
655
|
+
]);
|
|
656
|
+
var faucetABI = parseAbi([
|
|
657
|
+
"function minTopping() view returns (uint8)",
|
|
658
|
+
"function getToppingAmount() view returns (uint256)",
|
|
659
|
+
"function canTop(address _user) view returns (bool)",
|
|
660
|
+
"function topWallet(address _user) payable"
|
|
661
|
+
]);
|
|
662
|
+
var g$ABI = parseAbi([
|
|
663
|
+
"function balanceOf(address account) view returns (uint256)"
|
|
664
|
+
]);
|
|
665
|
+
var WALLET_LINK_SECURITY_MESSAGES = {
|
|
666
|
+
connect: [
|
|
667
|
+
"SECURITY NOTICE \u2014 Connect Wallet",
|
|
668
|
+
"You are about to link a secondary wallet to your GoodDollar identity.",
|
|
669
|
+
"\u2022 Only connect wallets you own and control.",
|
|
670
|
+
"\u2022 All connected wallets share a single daily UBI claim.",
|
|
671
|
+
"\u2022 The whitelisted root identity is the only account that can connect a wallet.",
|
|
672
|
+
"Do not proceed if you did not initiate this action."
|
|
673
|
+
].join("\n"),
|
|
674
|
+
disconnect: [
|
|
675
|
+
"SECURITY NOTICE \u2014 Disconnect Wallet",
|
|
676
|
+
"You are about to remove a wallet from your GoodDollar identity.",
|
|
677
|
+
"\u2022 Once disconnected the wallet no longer shares your UBI claim.",
|
|
678
|
+
"\u2022 Either the root identity or the connected account itself can disconnect.",
|
|
679
|
+
"Do not proceed if you did not initiate this action."
|
|
680
|
+
].join("\n")
|
|
681
|
+
};
|
|
682
|
+
var resolveChainAndContract = (walletClient, env) => {
|
|
683
|
+
const chainId = walletClient.chain?.id;
|
|
684
|
+
if (!isSupportedChain(chainId)) {
|
|
685
|
+
throw new Error(`Unsupported chain ID.`);
|
|
686
|
+
}
|
|
687
|
+
const contractEnvAddresses = chainConfigs[chainId]?.contracts[env] ?? null;
|
|
688
|
+
if (!contractEnvAddresses) {
|
|
689
|
+
throw new Error(
|
|
690
|
+
`Contract address for environment "${env}" on chain "${chainConfigs[chainId].label}" not found. Try a different environment or chain.`
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
return { chainId, contractEnvAddresses };
|
|
694
|
+
};
|
|
695
|
+
var createRpcIteratorRegistry = () => /* @__PURE__ */ new Map();
|
|
696
|
+
var getIterator = (chainId, registry) => {
|
|
697
|
+
if (!registry.has(chainId)) {
|
|
698
|
+
registry.set(chainId, createRpcUrlIterator(chainId));
|
|
699
|
+
}
|
|
700
|
+
const iterator = registry.get(chainId);
|
|
701
|
+
if (!iterator) {
|
|
702
|
+
throw new Error(`RPC iterator not available for chain ${chainId}`);
|
|
703
|
+
}
|
|
704
|
+
return iterator;
|
|
705
|
+
};
|
|
706
|
+
var getRpcFallbackClient = (chainId, registry) => {
|
|
707
|
+
const iterator = getIterator(chainId, registry);
|
|
708
|
+
const rpcUrl = iterator();
|
|
709
|
+
return createPublicClient({
|
|
710
|
+
transport: http(rpcUrl)
|
|
711
|
+
});
|
|
712
|
+
};
|
|
713
|
+
var initializeIdentityContract = (publicClient, contractAddress) => ({
|
|
714
|
+
publicClient,
|
|
715
|
+
contractAddress
|
|
716
|
+
});
|
|
717
|
+
var IdentitySDK = class _IdentitySDK {
|
|
718
|
+
account;
|
|
719
|
+
publicClient;
|
|
720
|
+
walletClient;
|
|
721
|
+
contract;
|
|
722
|
+
env = "production";
|
|
723
|
+
chainId;
|
|
724
|
+
fvDefaultChain;
|
|
725
|
+
rpcIterators = createRpcIteratorRegistry();
|
|
726
|
+
/**
|
|
727
|
+
* Initializes the IdentitySDK.
|
|
728
|
+
* @param publicClient - The PublicClient instance.
|
|
729
|
+
* @param walletClient - The WalletClient with WalletActions.
|
|
730
|
+
* @param env - The environment to use ("production" | "staging" | "development").
|
|
731
|
+
*/
|
|
732
|
+
constructor({
|
|
733
|
+
account,
|
|
734
|
+
publicClient,
|
|
735
|
+
walletClient,
|
|
736
|
+
env
|
|
737
|
+
}) {
|
|
738
|
+
if (!walletClient.account) {
|
|
739
|
+
throw new Error(
|
|
740
|
+
"IdentitySDK: WalletClient must have an account attached."
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
this.publicClient = publicClient;
|
|
744
|
+
this.walletClient = walletClient;
|
|
745
|
+
this.env = env;
|
|
746
|
+
this.account = account ?? walletClient.account.address;
|
|
747
|
+
const { chainId, contractEnvAddresses } = resolveChainAndContract(
|
|
748
|
+
walletClient,
|
|
749
|
+
env
|
|
750
|
+
);
|
|
751
|
+
this.chainId = chainId;
|
|
752
|
+
this.fvDefaultChain = chainConfigs[chainId]?.fvDefaultChain ?? chainId;
|
|
753
|
+
this.contract = initializeIdentityContract(
|
|
754
|
+
this.publicClient,
|
|
755
|
+
contractEnvAddresses.identityContract
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
static async init(props) {
|
|
759
|
+
const [account] = await props.walletClient.getAddresses();
|
|
760
|
+
return new _IdentitySDK({ account, ...props });
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Evaluates security constraints and prompts the user with security messages if required.
|
|
764
|
+
* Custodial/automated flows can bypass this entirely via `skipSecurityMessage: true`.
|
|
765
|
+
* For native wallet flows, `onSecurityMessage` receives the notice and must resolve
|
|
766
|
+
* to `true` for the transaction to proceed. Without either option the message is
|
|
767
|
+
* logged to `console.info` as a headless default.
|
|
768
|
+
* @param action - The wallet link action being performed ("connect" or "disconnect").
|
|
769
|
+
* @param options - Additional wallet link options including security prompt handlers.
|
|
770
|
+
*/
|
|
771
|
+
async runSecurityCheck(action, options) {
|
|
772
|
+
if (options?.skipSecurityMessage) return;
|
|
773
|
+
const message = WALLET_LINK_SECURITY_MESSAGES[action];
|
|
774
|
+
if (options?.onSecurityMessage) {
|
|
775
|
+
const confirmed = await options.onSecurityMessage(message);
|
|
776
|
+
if (!confirmed) {
|
|
777
|
+
throw new Error(
|
|
778
|
+
`Wallet ${action} cancelled: user did not confirm security notice.`
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
console.info(`[IdentitySDK] ${message}`);
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Submits a transaction and waits for its receipt.
|
|
787
|
+
* @param params - Parameters for simulating the contract call.
|
|
788
|
+
* @param onHash - Optional callback to receive the transaction hash.
|
|
789
|
+
* @returns The transaction receipt.
|
|
790
|
+
* @throws If submission fails or no active wallet address is found.
|
|
791
|
+
*/
|
|
792
|
+
async submitAndWait(params, onHash) {
|
|
793
|
+
try {
|
|
794
|
+
if (!this.account) throw new Error("No active wallet address found.");
|
|
795
|
+
const { request } = await this.publicClient.simulateContract({
|
|
796
|
+
account: this.account,
|
|
797
|
+
...params
|
|
798
|
+
});
|
|
799
|
+
const hash = await this.walletClient.writeContract(request);
|
|
800
|
+
onHash?.(hash);
|
|
801
|
+
return waitForTransactionReceipt(this.publicClient, { hash });
|
|
802
|
+
} catch (error) {
|
|
803
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
804
|
+
console.error("submitAndWait Error:", error);
|
|
805
|
+
throw new Error(`Failed to submit transaction: ${message}`);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Returns whitelist status of main account or any connected account.
|
|
810
|
+
* @param account - The account address to check.
|
|
811
|
+
* @returns An object containing whitelist status and root address.
|
|
812
|
+
* @reference: https://docs.gooddollar.org/user-guides/connect-another-wallet-address-to-identity
|
|
813
|
+
*/
|
|
814
|
+
async getWhitelistedRoot(account) {
|
|
815
|
+
try {
|
|
816
|
+
const root = await this.publicClient.readContract({
|
|
817
|
+
address: this.contract.contractAddress,
|
|
818
|
+
abi: identityV2ABI,
|
|
819
|
+
functionName: "getWhitelistedRoot",
|
|
820
|
+
args: [account]
|
|
821
|
+
});
|
|
822
|
+
return {
|
|
823
|
+
isWhitelisted: root !== zeroAddress,
|
|
824
|
+
root
|
|
825
|
+
};
|
|
826
|
+
} catch (error) {
|
|
827
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
828
|
+
console.error("getWhitelistedRoot Error:", error);
|
|
829
|
+
throw new Error(`Failed to get whitelisted root: ${message}`);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Checks the wallet-link connection status of the given account.
|
|
834
|
+
*
|
|
835
|
+
* When `chainId` is provided the query is scoped to that single chain only.
|
|
836
|
+
* When omitted, all supported chains are queried in parallel via Promise.allSettled
|
|
837
|
+
* and one ChainConnectedStatus entry is returned per chain.
|
|
838
|
+
*
|
|
839
|
+
* App-provided public clients always take precedence. For the SDK's current
|
|
840
|
+
* chain `this.publicClient` is reused when no override is passed. For other
|
|
841
|
+
* chains the SDK falls back to local read-only RPC clients using the same
|
|
842
|
+
* fallback flow as other multi-chain reads.
|
|
843
|
+
*
|
|
844
|
+
* @param account - The account address to check.
|
|
845
|
+
* @param chainId - Optional. Restricts the query to this chain only.
|
|
846
|
+
* @param publicClients - Optional. App-level public clients keyed by SupportedChains ID.
|
|
847
|
+
* @returns An array of ChainConnectedStatus (one entry per queried chain).
|
|
848
|
+
*/
|
|
849
|
+
async checkConnectedStatus(account, chainId, publicClients) {
|
|
850
|
+
const configs = chainId ? Object.values(chainConfigs).filter((config) => config.id === chainId) : Object.values(chainConfigs);
|
|
851
|
+
const settled = await Promise.allSettled(
|
|
852
|
+
configs.map(async (config) => {
|
|
853
|
+
const contracts = config.contracts[this.env];
|
|
854
|
+
if (!contracts) {
|
|
855
|
+
return {
|
|
856
|
+
chainId: config.id,
|
|
857
|
+
chainName: config.label,
|
|
858
|
+
isConnected: false,
|
|
859
|
+
root: zeroAddress,
|
|
860
|
+
error: `No contract configured for env "${this.env}" on ${config.label}`
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
const isPrimaryChain = this.chainId === config.id;
|
|
864
|
+
const client = publicClients?.[config.id] ?? (isPrimaryChain ? this.publicClient : getRpcFallbackClient(config.id, this.rpcIterators));
|
|
865
|
+
const root = await client.readContract({
|
|
866
|
+
address: contracts.identityContract,
|
|
867
|
+
abi: identityV2ABI,
|
|
868
|
+
functionName: "connectedAccounts",
|
|
869
|
+
args: [account]
|
|
870
|
+
});
|
|
871
|
+
return {
|
|
872
|
+
chainId: config.id,
|
|
873
|
+
chainName: config.label,
|
|
874
|
+
isConnected: root !== zeroAddress,
|
|
875
|
+
root
|
|
876
|
+
};
|
|
877
|
+
})
|
|
878
|
+
);
|
|
879
|
+
return settled.map((result, i) => {
|
|
880
|
+
const config = configs[i];
|
|
881
|
+
if (result.status === "fulfilled") return result.value;
|
|
882
|
+
return {
|
|
883
|
+
chainId: config.id,
|
|
884
|
+
chainName: config.label,
|
|
885
|
+
isConnected: false,
|
|
886
|
+
root: zeroAddress,
|
|
887
|
+
error: result.reason?.message ?? "Unknown RPC error"
|
|
888
|
+
};
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Retrieves identity expiry data for a given account.
|
|
893
|
+
* @param account - The account address.
|
|
894
|
+
* @returns The identity expiry data.
|
|
895
|
+
*/
|
|
896
|
+
async getIdentityExpiryData(account) {
|
|
897
|
+
try {
|
|
898
|
+
const [lastAuthenticated, authPeriod] = await Promise.all([
|
|
899
|
+
this.publicClient.readContract({
|
|
900
|
+
address: this.contract.contractAddress,
|
|
901
|
+
abi: identityV2ABI,
|
|
902
|
+
functionName: "lastAuthenticated",
|
|
903
|
+
args: [account]
|
|
904
|
+
}),
|
|
905
|
+
this.publicClient.readContract({
|
|
906
|
+
address: this.contract.contractAddress,
|
|
907
|
+
abi: identityV2ABI,
|
|
908
|
+
functionName: "authenticationPeriod",
|
|
909
|
+
args: []
|
|
910
|
+
})
|
|
911
|
+
]);
|
|
912
|
+
return { lastAuthenticated, authPeriod };
|
|
913
|
+
} catch (error) {
|
|
914
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
915
|
+
console.error("getIdentityExpiryData Error:", error);
|
|
916
|
+
throw new Error(
|
|
917
|
+
`Failed to retrieve identity expiry data: ${message}`
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Updates the wallet-link status of an account.
|
|
923
|
+
* The whitelisted root identity must be the signer for `connectAccount`,
|
|
924
|
+
* while `disconnectAccount` can be called by either the root identity or
|
|
925
|
+
* the connected account itself.
|
|
926
|
+
* Custodial flows can pass `skipSecurityMessage: true` to bypass the notice;
|
|
927
|
+
* the underlying transaction signing is handled by the app-provided walletClient
|
|
928
|
+
* (or IdentityCustodialSDK for LocalAccount signers).
|
|
929
|
+
* @param action - The wallet-link action to submit.
|
|
930
|
+
* @param account - The account address to update.
|
|
931
|
+
* @param options - Additional options, such as security prompts.
|
|
932
|
+
* @returns The transaction receipt.
|
|
933
|
+
*/
|
|
934
|
+
async updateConnectionStatus(action, account, options) {
|
|
935
|
+
const securityAction = action === "connectAccount" ? "connect" : "disconnect";
|
|
936
|
+
const actionLabel = action === "connectAccount" ? "connect" : "disconnect";
|
|
937
|
+
try {
|
|
938
|
+
await this.runSecurityCheck(securityAction, options);
|
|
939
|
+
return this.submitAndWait(
|
|
940
|
+
{
|
|
941
|
+
address: this.contract.contractAddress,
|
|
942
|
+
abi: identityV2ABI,
|
|
943
|
+
functionName: action,
|
|
944
|
+
args: [account]
|
|
945
|
+
},
|
|
946
|
+
options?.onHash
|
|
947
|
+
);
|
|
948
|
+
} catch (error) {
|
|
949
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
950
|
+
console.error("updateConnectionStatus Error:", error);
|
|
951
|
+
throw new Error(`Failed to ${actionLabel} account: ${message}`);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Connects a new account to the identity.
|
|
956
|
+
* The whitelisted root identity must be the signer. No additional message
|
|
957
|
+
* signature is required beyond the transaction itself.
|
|
958
|
+
* @param account - The account address to connect.
|
|
959
|
+
* @param options - Additional options, such as security prompts.
|
|
960
|
+
* @returns The transaction receipt.
|
|
961
|
+
*/
|
|
962
|
+
async connectAccount(account, options) {
|
|
963
|
+
return this.updateConnectionStatus("connectAccount", account, options);
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Disconnects an account from the identity.
|
|
967
|
+
* Either the root identity or the connected account itself can call this.
|
|
968
|
+
* @param account - The account address to disconnect.
|
|
969
|
+
* @param options - Additional options, such as security prompts.
|
|
970
|
+
* @returns The transaction receipt.
|
|
971
|
+
*/
|
|
972
|
+
async disconnectAccount(account, options) {
|
|
973
|
+
return this.updateConnectionStatus("disconnectAccount", account, options);
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Generates a Face Verification Link.
|
|
977
|
+
* @param popupMode - Whether to generate a popup link.
|
|
978
|
+
* @param callbackUrl - The URL to callback after verification.
|
|
979
|
+
* @param chainId - The blockchain network ID.
|
|
980
|
+
* @returns The generated Face Verification link.
|
|
981
|
+
*/
|
|
982
|
+
async generateFVLink(popupMode = false, callbackUrl, chainId) {
|
|
983
|
+
try {
|
|
984
|
+
const address = getAddress(this.account);
|
|
985
|
+
if (!address) throw new Error("No wallet address found.");
|
|
986
|
+
const nonce = Math.floor(Date.now() / 1e3).toString();
|
|
987
|
+
const fvSigMessage = FV_IDENTIFIER_MSG2.replace("<account>", address);
|
|
988
|
+
const fvSig = await this.walletClient.signMessage({
|
|
989
|
+
account: address,
|
|
990
|
+
message: fvSigMessage
|
|
991
|
+
});
|
|
992
|
+
const { identityUrl } = Envs[this.env];
|
|
993
|
+
if (!identityUrl) {
|
|
994
|
+
throw new Error("identityUrl is not defined in environment settings.");
|
|
995
|
+
}
|
|
996
|
+
if (!fvSig) {
|
|
997
|
+
throw new Error("Missing signature for Face Verification.");
|
|
998
|
+
}
|
|
999
|
+
if (!popupMode && !callbackUrl) {
|
|
1000
|
+
throw new Error("Callback URL is required for redirect mode.");
|
|
1001
|
+
}
|
|
1002
|
+
const url = new URL(identityUrl);
|
|
1003
|
+
const fallbackChain = this.fvDefaultChain ?? this.chainId;
|
|
1004
|
+
const resolvedChain = typeof chainId === "number" ? chainId : fallbackChain;
|
|
1005
|
+
const fvChain = isSupportedChain(resolvedChain) ? resolvedChain : fallbackChain;
|
|
1006
|
+
const params = {
|
|
1007
|
+
account: address,
|
|
1008
|
+
nonce,
|
|
1009
|
+
fvsig: fvSig,
|
|
1010
|
+
chain: fvChain
|
|
1011
|
+
};
|
|
1012
|
+
if (callbackUrl) {
|
|
1013
|
+
params[popupMode ? "cbu" : "rdu"] = callbackUrl;
|
|
1014
|
+
}
|
|
1015
|
+
url.searchParams.append(
|
|
1016
|
+
"lz",
|
|
1017
|
+
(0, import_lz_string.compressToEncodedURIComponent)(JSON.stringify(params))
|
|
1018
|
+
);
|
|
1019
|
+
return url.toString();
|
|
1020
|
+
} catch (error) {
|
|
1021
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1022
|
+
console.error("generateFVLink Error:", error);
|
|
1023
|
+
throw new Error(
|
|
1024
|
+
`Failed to generate Face Verification link: ${message}`
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Calculates the identity expiry timestamp.
|
|
1030
|
+
* @param lastAuthenticated - The timestamp of last authentication.
|
|
1031
|
+
* @param authPeriod - The authentication period.
|
|
1032
|
+
* @returns The identity expiry data.
|
|
1033
|
+
*/
|
|
1034
|
+
calculateIdentityExpiry(lastAuthenticated, authPeriod) {
|
|
1035
|
+
const MS_IN_A_SECOND = 1e3;
|
|
1036
|
+
const MS_IN_A_DAY = 24 * 60 * 60 * MS_IN_A_SECOND;
|
|
1037
|
+
const periodInMs = authPeriod * BigInt(MS_IN_A_DAY);
|
|
1038
|
+
const expiryTimestamp = lastAuthenticated * BigInt(MS_IN_A_SECOND) + periodInMs;
|
|
1039
|
+
return { expiryTimestamp };
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
var DAY = 1e3 * 60 * 60 * 24;
|
|
1043
|
+
var IdentityCustodialSDK = class extends IdentitySDK {
|
|
1044
|
+
/**
|
|
1045
|
+
* Override submitAndWait to handle account retrieval differently for custodial wallets
|
|
1046
|
+
* @param params - Parameters for simulating the contract call.
|
|
1047
|
+
* @param onHash - Optional callback to receive the transaction hash.
|
|
1048
|
+
* @returns The transaction receipt.
|
|
1049
|
+
* @throws If submission fails or no active wallet address is found.
|
|
1050
|
+
*/
|
|
1051
|
+
async submitAndWait(params, onHash) {
|
|
1052
|
+
try {
|
|
1053
|
+
const account = this.walletClient.account?.address;
|
|
1054
|
+
if (!account) throw new Error("No active wallet address found.");
|
|
1055
|
+
const { request } = await this.publicClient.simulateContract({
|
|
1056
|
+
account,
|
|
1057
|
+
...params
|
|
1058
|
+
});
|
|
1059
|
+
const hash = await this.walletClient.writeContract(request);
|
|
1060
|
+
onHash?.(hash);
|
|
1061
|
+
return waitForTransactionReceipt(this.publicClient, { hash });
|
|
1062
|
+
} catch (error) {
|
|
1063
|
+
console.error("submitAndWait Error:", error);
|
|
1064
|
+
throw new Error(`Failed to submit transaction: ${error.message}`);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Override generateFVLink to handle LocalAccount message signing for Celo RPC compatibility
|
|
1069
|
+
* @param popupMode - Whether to generate a popup link.
|
|
1070
|
+
* @param callbackUrl - The URL to callback after verification.
|
|
1071
|
+
* @param chainId - The blockchain network ID.
|
|
1072
|
+
* @returns The generated Face Verification link.
|
|
1073
|
+
*/
|
|
1074
|
+
async generateFVLink(popupMode = false, callbackUrl, chainId) {
|
|
1075
|
+
try {
|
|
1076
|
+
const account = this.walletClient.account;
|
|
1077
|
+
if (!account?.address) throw new Error("No wallet address found.");
|
|
1078
|
+
const nonce = Math.floor(Date.now() / 1e3).toString();
|
|
1079
|
+
const fvSigMessage = FV_IDENTIFIER_MSG2.replace("<account>", account.address);
|
|
1080
|
+
let fvSig;
|
|
1081
|
+
if ("signMessage" in account) {
|
|
1082
|
+
fvSig = await account.signMessage({
|
|
1083
|
+
message: fvSigMessage
|
|
1084
|
+
});
|
|
1085
|
+
} else {
|
|
1086
|
+
try {
|
|
1087
|
+
fvSig = await this.walletClient.signMessage({
|
|
1088
|
+
account: account.address,
|
|
1089
|
+
message: fvSigMessage
|
|
1090
|
+
});
|
|
1091
|
+
} catch (rpcError) {
|
|
1092
|
+
throw new Error(`Message signing failed: Celo RPC doesn't support personal_sign. Use a local account instead. ${rpcError.message}`);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
const { identityUrl } = Envs[this.env];
|
|
1096
|
+
if (!identityUrl) {
|
|
1097
|
+
throw new Error("identityUrl is not defined in environment settings.");
|
|
1098
|
+
}
|
|
1099
|
+
if (!fvSig) {
|
|
1100
|
+
throw new Error("Missing signature for Face Verification.");
|
|
1101
|
+
}
|
|
1102
|
+
if (!popupMode && !callbackUrl) {
|
|
1103
|
+
throw new Error("Callback URL is required for redirect mode.");
|
|
1104
|
+
}
|
|
1105
|
+
const url = new URL(identityUrl);
|
|
1106
|
+
const params = {
|
|
1107
|
+
account: account.address,
|
|
1108
|
+
nonce,
|
|
1109
|
+
fvsig: fvSig,
|
|
1110
|
+
chain: chainId || await this.publicClient.getChainId()
|
|
1111
|
+
};
|
|
1112
|
+
if (callbackUrl) {
|
|
1113
|
+
params[popupMode ? "cbu" : "rdu"] = callbackUrl;
|
|
1114
|
+
}
|
|
1115
|
+
url.searchParams.append(
|
|
1116
|
+
"lz",
|
|
1117
|
+
(0, import_lz_string.compressToEncodedURIComponent)(JSON.stringify(params))
|
|
1118
|
+
);
|
|
1119
|
+
return url.toString();
|
|
1120
|
+
} catch (error) {
|
|
1121
|
+
console.error("generateFVLink Error:", error);
|
|
1122
|
+
throw new Error(
|
|
1123
|
+
`Failed to generate Face Verification link: ${error.message}`
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
// citizen-sdk.entry.ts
|
|
1130
|
+
var IdentitySDK2 = IdentityCustodialSDK ?? IdentitySDK;
|
|
1131
|
+
export {
|
|
1132
|
+
IdentitySDK2 as IdentitySDK
|
|
1133
|
+
};
|