@0xsequence/api 0.0.0-20220804202525 → 0.0.0-20220825181818

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,11 @@
1
- export * from "./declarations/src/index";
1
+ // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
+ // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
+
4
+ // curious why you need to?
5
+ // this file exists so that you can import from the entrypoint normally
6
+ // except that it points to your source file and you don't need to run build constantly
7
+ // which means we need to re-export all of the modules from your source file
8
+ // and since export * doesn't include default exports, we need to read your source file
9
+ // to check for a default export and re-export it if it exists
10
+ // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
+ export * from "../src/index";
@@ -1,7 +1,16 @@
1
- 'use strict';
1
+ "use strict";
2
+ // this file might look strange and you might be wondering what it's for
3
+ // it's lets you import your source files by importing this entrypoint
4
+ // as you would import it if it was built with preconstruct build
5
+ // this file is slightly different to some others though
6
+ // it has a require hook which compiles your code with Babel
7
+ // this means that you don't have to set up @babel/register or anything like that
8
+ // but you can still require this module and it'll be compiled
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./0xsequence-api.cjs.prod.js");
5
- } else {
6
- module.exports = require("./0xsequence-api.cjs.dev.js");
7
- }
10
+ // this bit of code imports the require hook and registers it
11
+ let unregister = require("../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../..", "..");
12
+
13
+ // this re-exports the source file
14
+ module.exports = require("../src/index.ts");
15
+
16
+ unregister();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/api",
3
- "version": "0.0.0-20220804202525",
3
+ "version": "0.0.0-20220825181818",
4
4
  "description": "api sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/api",
6
6
  "source": "src/index.ts",
@@ -1,581 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var fetch = require('cross-fetch');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
8
-
9
- var fetch__default = /*#__PURE__*/_interopDefault(fetch);
10
-
11
- function _extends() {
12
- _extends = Object.assign || function (target) {
13
- for (var i = 1; i < arguments.length; i++) {
14
- var source = arguments[i];
15
-
16
- for (var key in source) {
17
- if (Object.prototype.hasOwnProperty.call(source, key)) {
18
- target[key] = source[key];
19
- }
20
- }
21
- }
22
-
23
- return target;
24
- };
25
-
26
- return _extends.apply(this, arguments);
27
- }
28
-
29
- /* eslint-disable */
30
- // sequence-api v0.4.0 d026b8c7eb9ac3c9c5ed52994a34e2463c1aaa14
31
- // --
32
- // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
33
- // Do not edit by hand. Update your webrpc schema and re-generate.
34
- // WebRPC description and code-gen version
35
- const WebRPCVersion = "v1"; // Schema version of your RIDL schema
36
-
37
- const WebRPCSchemaVersion = "v0.4.0"; // Schema hash generated from your RIDL schema
38
-
39
- const WebRPCSchemaHash = "d026b8c7eb9ac3c9c5ed52994a34e2463c1aaa14"; //
40
- // Types
41
- //
42
-
43
- exports.SmartRampOrderStatus = void 0;
44
-
45
- (function (SmartRampOrderStatus) {
46
- SmartRampOrderStatus["UNKNOWN"] = "UNKNOWN";
47
- SmartRampOrderStatus["RUNNING_CHECKS"] = "RUNNING_CHECKS";
48
- SmartRampOrderStatus["PROCESSING"] = "PROCESSING";
49
- SmartRampOrderStatus["FAILED"] = "FAILED";
50
- SmartRampOrderStatus["COMPLETE"] = "COMPLETE";
51
- })(exports.SmartRampOrderStatus || (exports.SmartRampOrderStatus = {}));
52
-
53
- exports.SortOrder = void 0;
54
-
55
- (function (SortOrder) {
56
- SortOrder["DESC"] = "DESC";
57
- SortOrder["ASC"] = "ASC";
58
- })(exports.SortOrder || (exports.SortOrder = {}));
59
-
60
- //
61
- // Client
62
- //
63
- class API {
64
- constructor(hostname, fetch) {
65
- this.hostname = void 0;
66
- this.fetch = void 0;
67
- this.path = '/rpc/API/';
68
-
69
- this.ping = headers => {
70
- return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
71
- return buildResponse(res).then(_data => {
72
- return {
73
- status: _data.status
74
- };
75
- });
76
- });
77
- };
78
-
79
- this.version = headers => {
80
- return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
81
- return buildResponse(res).then(_data => {
82
- return {
83
- version: _data.version
84
- };
85
- });
86
- });
87
- };
88
-
89
- this.runtimeStatus = headers => {
90
- return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
91
- return buildResponse(res).then(_data => {
92
- return {
93
- status: _data.status
94
- };
95
- });
96
- });
97
- };
98
-
99
- this.getSequenceContext = headers => {
100
- return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers)).then(res => {
101
- return buildResponse(res).then(_data => {
102
- return {
103
- data: _data.data
104
- };
105
- });
106
- });
107
- };
108
-
109
- this.getAuthToken = (args, headers) => {
110
- return this.fetch(this.url('GetAuthToken'), createHTTPRequest(args, headers)).then(res => {
111
- return buildResponse(res).then(_data => {
112
- return {
113
- status: _data.status,
114
- jwtToken: _data.jwtToken,
115
- address: _data.address,
116
- user: _data.user
117
- };
118
- });
119
- });
120
- };
121
-
122
- this.sendPasswordlessLink = (args, headers) => {
123
- return this.fetch(this.url('SendPasswordlessLink'), createHTTPRequest(args, headers)).then(res => {
124
- return buildResponse(res).then(_data => {
125
- return {
126
- status: _data.status
127
- };
128
- });
129
- });
130
- };
131
-
132
- this.friendList = (args, headers) => {
133
- return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers)).then(res => {
134
- return buildResponse(res).then(_data => {
135
- return {
136
- page: _data.page,
137
- friends: _data.friends
138
- };
139
- });
140
- });
141
- };
142
-
143
- this.getFriendByAddress = (args, headers) => {
144
- return this.fetch(this.url('GetFriendByAddress'), createHTTPRequest(args, headers)).then(res => {
145
- return buildResponse(res).then(_data => {
146
- return {
147
- status: _data.status,
148
- friend: _data.friend
149
- };
150
- });
151
- });
152
- };
153
-
154
- this.searchFriends = (args, headers) => {
155
- return this.fetch(this.url('SearchFriends'), createHTTPRequest(args, headers)).then(res => {
156
- return buildResponse(res).then(_data => {
157
- return {
158
- friends: _data.friends
159
- };
160
- });
161
- });
162
- };
163
-
164
- this.addFriend = (args, headers) => {
165
- return this.fetch(this.url('AddFriend'), createHTTPRequest(args, headers)).then(res => {
166
- return buildResponse(res).then(_data => {
167
- return {
168
- status: _data.status,
169
- friend: _data.friend
170
- };
171
- });
172
- });
173
- };
174
-
175
- this.updateFriendNickname = (args, headers) => {
176
- return this.fetch(this.url('UpdateFriendNickname'), createHTTPRequest(args, headers)).then(res => {
177
- return buildResponse(res).then(_data => {
178
- return {
179
- status: _data.status,
180
- friend: _data.friend
181
- };
182
- });
183
- });
184
- };
185
-
186
- this.removeFriend = (args, headers) => {
187
- return this.fetch(this.url('RemoveFriend'), createHTTPRequest(args, headers)).then(res => {
188
- return buildResponse(res).then(_data => {
189
- return {
190
- status: _data.status
191
- };
192
- });
193
- });
194
- };
195
-
196
- this.contractCall = (args, headers) => {
197
- return this.fetch(this.url('ContractCall'), createHTTPRequest(args, headers)).then(res => {
198
- return buildResponse(res).then(_data => {
199
- return {
200
- returns: _data.returns
201
- };
202
- });
203
- });
204
- };
205
-
206
- this.decodeContractCall = (args, headers) => {
207
- return this.fetch(this.url('DecodeContractCall'), createHTTPRequest(args, headers)).then(res => {
208
- return buildResponse(res).then(_data => {
209
- return {
210
- call: _data.call
211
- };
212
- });
213
- });
214
- };
215
-
216
- this.lookupContractCallSelectors = (args, headers) => {
217
- return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers)).then(res => {
218
- return buildResponse(res).then(_data => {
219
- return {
220
- signatures: _data.signatures
221
- };
222
- });
223
- });
224
- };
225
-
226
- this.userStorageFetch = (args, headers) => {
227
- return this.fetch(this.url('UserStorageFetch'), createHTTPRequest(args, headers)).then(res => {
228
- return buildResponse(res).then(_data => {
229
- return {
230
- object: _data.object
231
- };
232
- });
233
- });
234
- };
235
-
236
- this.userStorageSave = (args, headers) => {
237
- return this.fetch(this.url('UserStorageSave'), createHTTPRequest(args, headers)).then(res => {
238
- return buildResponse(res).then(_data => {
239
- return {
240
- ok: _data.ok
241
- };
242
- });
243
- });
244
- };
245
-
246
- this.userStorageDelete = (args, headers) => {
247
- return this.fetch(this.url('UserStorageDelete'), createHTTPRequest(args, headers)).then(res => {
248
- return buildResponse(res).then(_data => {
249
- return {
250
- ok: _data.ok
251
- };
252
- });
253
- });
254
- };
255
-
256
- this.userStorageFetchAll = (args, headers) => {
257
- return this.fetch(this.url('UserStorageFetchAll'), createHTTPRequest(args, headers)).then(res => {
258
- return buildResponse(res).then(_data => {
259
- return {
260
- objects: _data.objects
261
- };
262
- });
263
- });
264
- };
265
-
266
- this.getMoonpayLink = (args, headers) => {
267
- return this.fetch(this.url('GetMoonpayLink'), createHTTPRequest(args, headers)).then(res => {
268
- return buildResponse(res).then(_data => {
269
- return {
270
- signedUrl: _data.signedUrl
271
- };
272
- });
273
- });
274
- };
275
-
276
- this.isUsingGoogleMail = (args, headers) => {
277
- return this.fetch(this.url('IsUsingGoogleMail'), createHTTPRequest(args, headers)).then(res => {
278
- return buildResponse(res).then(_data => {
279
- return {
280
- yes: _data.yes
281
- };
282
- });
283
- });
284
- };
285
-
286
- this.isValidSignature = (args, headers) => {
287
- return this.fetch(this.url('IsValidSignature'), createHTTPRequest(args, headers)).then(res => {
288
- return buildResponse(res).then(_data => {
289
- return {
290
- isValid: _data.isValid
291
- };
292
- });
293
- });
294
- };
295
-
296
- this.isValidMessageSignature = (args, headers) => {
297
- return this.fetch(this.url('IsValidMessageSignature'), createHTTPRequest(args, headers)).then(res => {
298
- return buildResponse(res).then(_data => {
299
- return {
300
- isValid: _data.isValid
301
- };
302
- });
303
- });
304
- };
305
-
306
- this.isValidTypedDataSignature = (args, headers) => {
307
- return this.fetch(this.url('IsValidTypedDataSignature'), createHTTPRequest(args, headers)).then(res => {
308
- return buildResponse(res).then(_data => {
309
- return {
310
- isValid: _data.isValid
311
- };
312
- });
313
- });
314
- };
315
-
316
- this.isValidETHAuthProof = (args, headers) => {
317
- return this.fetch(this.url('IsValidETHAuthProof'), createHTTPRequest(args, headers)).then(res => {
318
- return buildResponse(res).then(_data => {
319
- return {
320
- isValid: _data.isValid
321
- };
322
- });
323
- });
324
- };
325
-
326
- this.getCoinPrices = (args, headers) => {
327
- return this.fetch(this.url('GetCoinPrices'), createHTTPRequest(args, headers)).then(res => {
328
- return buildResponse(res).then(_data => {
329
- return {
330
- tokenPrices: _data.tokenPrices
331
- };
332
- });
333
- });
334
- };
335
-
336
- this.getCollectiblePrices = (args, headers) => {
337
- return this.fetch(this.url('GetCollectiblePrices'), createHTTPRequest(args, headers)).then(res => {
338
- return buildResponse(res).then(_data => {
339
- return {
340
- tokenPrices: _data.tokenPrices
341
- };
342
- });
343
- });
344
- };
345
-
346
- this.getExchangeRate = (args, headers) => {
347
- return this.fetch(this.url('GetExchangeRate'), createHTTPRequest(args, headers)).then(res => {
348
- return buildResponse(res).then(_data => {
349
- return {
350
- exchangeRate: _data.exchangeRate
351
- };
352
- });
353
- });
354
- };
355
-
356
- this.listPayCardsOnFile = headers => {
357
- return this.fetch(this.url('ListPayCardsOnFile'), createHTTPRequest({}, headers)).then(res => {
358
- return buildResponse(res).then(_data => {
359
- return {
360
- payCards: _data.payCards
361
- };
362
- });
363
- });
364
- };
365
-
366
- this.savePayCard = (args, headers) => {
367
- return this.fetch(this.url('SavePayCard'), createHTTPRequest(args, headers)).then(res => {
368
- return buildResponse(res).then(_data => {
369
- return {
370
- ok: _data.ok,
371
- payCard: _data.payCard
372
- };
373
- });
374
- });
375
- };
376
-
377
- this.updatePayCardCVC = (args, headers) => {
378
- return this.fetch(this.url('UpdatePayCardCVC'), createHTTPRequest(args, headers)).then(res => {
379
- return buildResponse(res).then(_data => {
380
- return {
381
- ok: _data.ok
382
- };
383
- });
384
- });
385
- };
386
-
387
- this.deletePayCard = (args, headers) => {
388
- return this.fetch(this.url('DeletePayCard'), createHTTPRequest(args, headers)).then(res => {
389
- return buildResponse(res).then(_data => {
390
- return {
391
- ok: _data.ok
392
- };
393
- });
394
- });
395
- };
396
-
397
- this.smartRampQuote = (args, headers) => {
398
- return this.fetch(this.url('SmartRampQuote'), createHTTPRequest(args, headers)).then(res => {
399
- return buildResponse(res).then(_data => {
400
- return {
401
- status: _data.status,
402
- quoteDetails: _data.quoteDetails
403
- };
404
- });
405
- });
406
- };
407
-
408
- this.smartRampPurchase = (args, headers) => {
409
- return this.fetch(this.url('SmartRampPurchase'), createHTTPRequest(args, headers)).then(res => {
410
- return buildResponse(res).then(_data => {
411
- return {
412
- processing: _data.processing,
413
- receipt: _data.receipt
414
- };
415
- });
416
- });
417
- };
418
-
419
- this.smartRampWaitOrderConfirmation = (args, headers) => {
420
- return this.fetch(this.url('SmartRampWaitOrderConfirmation'), createHTTPRequest(args, headers)).then(res => {
421
- return buildResponse(res).then(_data => {
422
- return {
423
- done: _data.done,
424
- receipt: _data.receipt
425
- };
426
- });
427
- });
428
- };
429
-
430
- this.smartRampGetOrder = (args, headers) => {
431
- return this.fetch(this.url('SmartRampGetOrder'), createHTTPRequest(args, headers)).then(res => {
432
- return buildResponse(res).then(_data => {
433
- return {
434
- order: _data.order
435
- };
436
- });
437
- });
438
- };
439
-
440
- this.smartRampCheckCardAuthorization = (args, headers) => {
441
- return this.fetch(this.url('SmartRampCheckCardAuthorization'), createHTTPRequest(args, headers)).then(res => {
442
- return buildResponse(res).then(_data => {
443
- return {
444
- cardAuth: _data.cardAuth
445
- };
446
- });
447
- });
448
- };
449
-
450
- this.smartRampSubmitCardAuthorization = (args, headers) => {
451
- return this.fetch(this.url('SmartRampSubmitCardAuthorization'), createHTTPRequest(args, headers)).then(res => {
452
- return buildResponse(res).then(_data => {
453
- return {
454
- status: _data.status
455
- };
456
- });
457
- });
458
- };
459
-
460
- this.smartRampOrdersList = (args, headers) => {
461
- return this.fetch(this.url('SmartRampOrdersList'), createHTTPRequest(args, headers)).then(res => {
462
- return buildResponse(res).then(_data => {
463
- return {
464
- page: _data.page,
465
- orders: _data.orders
466
- };
467
- });
468
- });
469
- };
470
-
471
- this.getInviteInfo = headers => {
472
- return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers)).then(res => {
473
- return buildResponse(res).then(_data => {
474
- return {
475
- inviteInfo: _data.inviteInfo
476
- };
477
- });
478
- });
479
- };
480
-
481
- this.isValidAccessCode = (args, headers) => {
482
- return this.fetch(this.url('IsValidAccessCode'), createHTTPRequest(args, headers)).then(res => {
483
- return buildResponse(res).then(_data => {
484
- return {
485
- status: _data.status
486
- };
487
- });
488
- });
489
- };
490
-
491
- this.internalClaimAccessCode = (args, headers) => {
492
- return this.fetch(this.url('InternalClaimAccessCode'), createHTTPRequest(args, headers)).then(res => {
493
- return buildResponse(res).then(_data => {
494
- return {
495
- status: _data.status
496
- };
497
- });
498
- });
499
- };
500
-
501
- this.walletRecover = (args, headers) => {
502
- return this.fetch(this.url('WalletRecover'), createHTTPRequest(args, headers)).then(res => {
503
- return buildResponse(res).then(_data => {
504
- return {
505
- encryptedWallet: _data.encryptedWallet
506
- };
507
- });
508
- });
509
- };
510
-
511
- this.hostname = hostname;
512
- this.fetch = fetch;
513
- }
514
-
515
- url(name) {
516
- return this.hostname + this.path + name;
517
- }
518
-
519
- }
520
-
521
- const createHTTPRequest = (body = {}, headers = {}) => {
522
- return {
523
- method: 'POST',
524
- headers: _extends({}, headers, {
525
- 'Content-Type': 'application/json'
526
- }),
527
- body: JSON.stringify(body || {})
528
- };
529
- };
530
-
531
- const buildResponse = res => {
532
- return res.text().then(text => {
533
- let data;
534
-
535
- try {
536
- data = JSON.parse(text);
537
- } catch (err) {
538
- throw {
539
- code: 'unknown',
540
- msg: `expecting JSON, got: ${text}`,
541
- status: res.status
542
- };
543
- }
544
-
545
- if (!res.ok) {
546
- throw data; // webrpc error response
547
- }
548
-
549
- return data;
550
- });
551
- };
552
-
553
- class SequenceAPIClient extends API {
554
- constructor(hostname, jwtAuth) {
555
- super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch__default["default"]);
556
- this.jwtAuth = jwtAuth;
557
-
558
- this._fetch = (input, init) => {
559
- // automatically include jwt auth header to requests
560
- // if its been set on the api client
561
- const headers = {};
562
-
563
- if (this.jwtAuth && this.jwtAuth.length > 0) {
564
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
565
- } // before the request is made
566
-
567
-
568
- init.headers = _extends({}, init.headers, headers);
569
- return fetch__default["default"](input, init);
570
- };
571
-
572
- this.fetch = this._fetch;
573
- }
574
-
575
- }
576
-
577
- exports.API = API;
578
- exports.SequenceAPIClient = SequenceAPIClient;
579
- exports.WebRPCSchemaHash = WebRPCSchemaHash;
580
- exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
581
- exports.WebRPCVersion = WebRPCVersion;