@0xsequence/api 0.0.0-2021827201516 → 0.0.0-20220427054350

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,306 +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 8e3575e965dc76a152d48e0b6660271db4d0c5be
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 = "8e3575e965dc76a152d48e0b6660271db4d0c5be"; //
40
- // Types
41
- //
42
-
43
- exports.SortOrder = void 0;
44
-
45
- (function (SortOrder) {
46
- SortOrder["DESC"] = "DESC";
47
- SortOrder["ASC"] = "ASC";
48
- })(exports.SortOrder || (exports.SortOrder = {}));
49
-
50
- //
51
- // Client
52
- //
53
- class API {
54
- constructor(hostname, fetch) {
55
- this.hostname = void 0;
56
- this.fetch = void 0;
57
- this.path = '/rpc/API/';
58
-
59
- this.ping = headers => {
60
- return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
61
- return buildResponse(res).then(_data => {
62
- return {
63
- status: _data.status
64
- };
65
- });
66
- });
67
- };
68
-
69
- this.version = headers => {
70
- return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
71
- return buildResponse(res).then(_data => {
72
- return {
73
- version: _data.version
74
- };
75
- });
76
- });
77
- };
78
-
79
- this.runtimeStatus = headers => {
80
- return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
81
- return buildResponse(res).then(_data => {
82
- return {
83
- status: _data.status
84
- };
85
- });
86
- });
87
- };
88
-
89
- this.getSequenceContext = headers => {
90
- return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers)).then(res => {
91
- return buildResponse(res).then(_data => {
92
- return {
93
- data: _data.data
94
- };
95
- });
96
- });
97
- };
98
-
99
- this.getAuthToken = (args, headers) => {
100
- return this.fetch(this.url('GetAuthToken'), createHTTPRequest(args, headers)).then(res => {
101
- return buildResponse(res).then(_data => {
102
- return {
103
- status: _data.status,
104
- jwtToken: _data.jwtToken,
105
- address: _data.address,
106
- user: _data.user
107
- };
108
- });
109
- });
110
- };
111
-
112
- this.friendList = (args, headers) => {
113
- return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers)).then(res => {
114
- return buildResponse(res).then(_data => {
115
- return {
116
- page: _data.page,
117
- friends: _data.friends
118
- };
119
- });
120
- });
121
- };
122
-
123
- this.getFriendByAddress = (args, headers) => {
124
- return this.fetch(this.url('GetFriendByAddress'), createHTTPRequest(args, headers)).then(res => {
125
- return buildResponse(res).then(_data => {
126
- return {
127
- status: _data.status,
128
- friend: _data.friend
129
- };
130
- });
131
- });
132
- };
133
-
134
- this.searchFriends = (args, headers) => {
135
- return this.fetch(this.url('SearchFriends'), createHTTPRequest(args, headers)).then(res => {
136
- return buildResponse(res).then(_data => {
137
- return {
138
- friends: _data.friends
139
- };
140
- });
141
- });
142
- };
143
-
144
- this.addFriend = (args, headers) => {
145
- return this.fetch(this.url('AddFriend'), createHTTPRequest(args, headers)).then(res => {
146
- return buildResponse(res).then(_data => {
147
- return {
148
- status: _data.status,
149
- friend: _data.friend
150
- };
151
- });
152
- });
153
- };
154
-
155
- this.updateFriendNickname = (args, headers) => {
156
- return this.fetch(this.url('UpdateFriendNickname'), createHTTPRequest(args, headers)).then(res => {
157
- return buildResponse(res).then(_data => {
158
- return {
159
- status: _data.status,
160
- friend: _data.friend
161
- };
162
- });
163
- });
164
- };
165
-
166
- this.removeFriend = (args, headers) => {
167
- return this.fetch(this.url('RemoveFriend'), createHTTPRequest(args, headers)).then(res => {
168
- return buildResponse(res).then(_data => {
169
- return {
170
- status: _data.status
171
- };
172
- });
173
- });
174
- };
175
-
176
- this.contractCall = (args, headers) => {
177
- return this.fetch(this.url('ContractCall'), createHTTPRequest(args, headers)).then(res => {
178
- return buildResponse(res).then(_data => {
179
- return {
180
- returns: _data.returns
181
- };
182
- });
183
- });
184
- };
185
-
186
- this.decodeContractCall = (args, headers) => {
187
- return this.fetch(this.url('DecodeContractCall'), createHTTPRequest(args, headers)).then(res => {
188
- return buildResponse(res).then(_data => {
189
- return {
190
- call: _data.call
191
- };
192
- });
193
- });
194
- };
195
-
196
- this.lookupContractCallSelectors = (args, headers) => {
197
- return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers)).then(res => {
198
- return buildResponse(res).then(_data => {
199
- return {
200
- signatures: _data.signatures
201
- };
202
- });
203
- });
204
- };
205
-
206
- this.getInviteInfo = headers => {
207
- return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers)).then(res => {
208
- return buildResponse(res).then(_data => {
209
- return {
210
- inviteInfo: _data.inviteInfo
211
- };
212
- });
213
- });
214
- };
215
-
216
- this.internalClaimAccessCode = (args, headers) => {
217
- return this.fetch(this.url('InternalClaimAccessCode'), createHTTPRequest(args, headers)).then(res => {
218
- return buildResponse(res).then(_data => {
219
- return {
220
- status: _data.status
221
- };
222
- });
223
- });
224
- };
225
-
226
- this.walletRecover = (args, headers) => {
227
- return this.fetch(this.url('WalletRecover'), createHTTPRequest(args, headers)).then(res => {
228
- return buildResponse(res).then(_data => {
229
- return {
230
- encryptedWallet: _data.encryptedWallet
231
- };
232
- });
233
- });
234
- };
235
-
236
- this.hostname = hostname;
237
- this.fetch = fetch;
238
- }
239
-
240
- url(name) {
241
- return this.hostname + this.path + name;
242
- }
243
-
244
- }
245
-
246
- const createHTTPRequest = (body = {}, headers = {}) => {
247
- return {
248
- method: 'POST',
249
- headers: _extends({}, headers, {
250
- 'Content-Type': 'application/json'
251
- }),
252
- body: JSON.stringify(body || {})
253
- };
254
- };
255
-
256
- const buildResponse = res => {
257
- return res.text().then(text => {
258
- let data;
259
-
260
- try {
261
- data = JSON.parse(text);
262
- } catch (err) {
263
- throw {
264
- code: 'unknown',
265
- msg: `expecting JSON, got: ${text}`,
266
- status: res.status
267
- };
268
- }
269
-
270
- if (!res.ok) {
271
- throw data; // webrpc error response
272
- }
273
-
274
- return data;
275
- });
276
- };
277
-
278
- class SequenceAPIClient extends API {
279
- constructor(hostname, jwtAuth) {
280
- super(hostname, fetch__default['default']);
281
- this.jwtAuth = jwtAuth;
282
-
283
- this._fetch = (input, init) => {
284
- // automatically include jwt auth header to requests
285
- // if its been set on the api client
286
- const headers = {};
287
-
288
- if (this.jwtAuth && this.jwtAuth.length > 0) {
289
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
290
- } // before the request is made
291
-
292
-
293
- init.headers = _extends({}, init.headers, headers);
294
- return fetch__default['default'](input, init);
295
- };
296
-
297
- this.fetch = this._fetch;
298
- }
299
-
300
- }
301
-
302
- exports.API = API;
303
- exports.SequenceAPIClient = SequenceAPIClient;
304
- exports.WebRPCSchemaHash = WebRPCSchemaHash;
305
- exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
306
- exports.WebRPCVersion = WebRPCVersion;
@@ -1,306 +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 8e3575e965dc76a152d48e0b6660271db4d0c5be
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 = "8e3575e965dc76a152d48e0b6660271db4d0c5be"; //
40
- // Types
41
- //
42
-
43
- exports.SortOrder = void 0;
44
-
45
- (function (SortOrder) {
46
- SortOrder["DESC"] = "DESC";
47
- SortOrder["ASC"] = "ASC";
48
- })(exports.SortOrder || (exports.SortOrder = {}));
49
-
50
- //
51
- // Client
52
- //
53
- class API {
54
- constructor(hostname, fetch) {
55
- this.hostname = void 0;
56
- this.fetch = void 0;
57
- this.path = '/rpc/API/';
58
-
59
- this.ping = headers => {
60
- return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
61
- return buildResponse(res).then(_data => {
62
- return {
63
- status: _data.status
64
- };
65
- });
66
- });
67
- };
68
-
69
- this.version = headers => {
70
- return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
71
- return buildResponse(res).then(_data => {
72
- return {
73
- version: _data.version
74
- };
75
- });
76
- });
77
- };
78
-
79
- this.runtimeStatus = headers => {
80
- return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
81
- return buildResponse(res).then(_data => {
82
- return {
83
- status: _data.status
84
- };
85
- });
86
- });
87
- };
88
-
89
- this.getSequenceContext = headers => {
90
- return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers)).then(res => {
91
- return buildResponse(res).then(_data => {
92
- return {
93
- data: _data.data
94
- };
95
- });
96
- });
97
- };
98
-
99
- this.getAuthToken = (args, headers) => {
100
- return this.fetch(this.url('GetAuthToken'), createHTTPRequest(args, headers)).then(res => {
101
- return buildResponse(res).then(_data => {
102
- return {
103
- status: _data.status,
104
- jwtToken: _data.jwtToken,
105
- address: _data.address,
106
- user: _data.user
107
- };
108
- });
109
- });
110
- };
111
-
112
- this.friendList = (args, headers) => {
113
- return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers)).then(res => {
114
- return buildResponse(res).then(_data => {
115
- return {
116
- page: _data.page,
117
- friends: _data.friends
118
- };
119
- });
120
- });
121
- };
122
-
123
- this.getFriendByAddress = (args, headers) => {
124
- return this.fetch(this.url('GetFriendByAddress'), createHTTPRequest(args, headers)).then(res => {
125
- return buildResponse(res).then(_data => {
126
- return {
127
- status: _data.status,
128
- friend: _data.friend
129
- };
130
- });
131
- });
132
- };
133
-
134
- this.searchFriends = (args, headers) => {
135
- return this.fetch(this.url('SearchFriends'), createHTTPRequest(args, headers)).then(res => {
136
- return buildResponse(res).then(_data => {
137
- return {
138
- friends: _data.friends
139
- };
140
- });
141
- });
142
- };
143
-
144
- this.addFriend = (args, headers) => {
145
- return this.fetch(this.url('AddFriend'), createHTTPRequest(args, headers)).then(res => {
146
- return buildResponse(res).then(_data => {
147
- return {
148
- status: _data.status,
149
- friend: _data.friend
150
- };
151
- });
152
- });
153
- };
154
-
155
- this.updateFriendNickname = (args, headers) => {
156
- return this.fetch(this.url('UpdateFriendNickname'), createHTTPRequest(args, headers)).then(res => {
157
- return buildResponse(res).then(_data => {
158
- return {
159
- status: _data.status,
160
- friend: _data.friend
161
- };
162
- });
163
- });
164
- };
165
-
166
- this.removeFriend = (args, headers) => {
167
- return this.fetch(this.url('RemoveFriend'), createHTTPRequest(args, headers)).then(res => {
168
- return buildResponse(res).then(_data => {
169
- return {
170
- status: _data.status
171
- };
172
- });
173
- });
174
- };
175
-
176
- this.contractCall = (args, headers) => {
177
- return this.fetch(this.url('ContractCall'), createHTTPRequest(args, headers)).then(res => {
178
- return buildResponse(res).then(_data => {
179
- return {
180
- returns: _data.returns
181
- };
182
- });
183
- });
184
- };
185
-
186
- this.decodeContractCall = (args, headers) => {
187
- return this.fetch(this.url('DecodeContractCall'), createHTTPRequest(args, headers)).then(res => {
188
- return buildResponse(res).then(_data => {
189
- return {
190
- call: _data.call
191
- };
192
- });
193
- });
194
- };
195
-
196
- this.lookupContractCallSelectors = (args, headers) => {
197
- return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers)).then(res => {
198
- return buildResponse(res).then(_data => {
199
- return {
200
- signatures: _data.signatures
201
- };
202
- });
203
- });
204
- };
205
-
206
- this.getInviteInfo = headers => {
207
- return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers)).then(res => {
208
- return buildResponse(res).then(_data => {
209
- return {
210
- inviteInfo: _data.inviteInfo
211
- };
212
- });
213
- });
214
- };
215
-
216
- this.internalClaimAccessCode = (args, headers) => {
217
- return this.fetch(this.url('InternalClaimAccessCode'), createHTTPRequest(args, headers)).then(res => {
218
- return buildResponse(res).then(_data => {
219
- return {
220
- status: _data.status
221
- };
222
- });
223
- });
224
- };
225
-
226
- this.walletRecover = (args, headers) => {
227
- return this.fetch(this.url('WalletRecover'), createHTTPRequest(args, headers)).then(res => {
228
- return buildResponse(res).then(_data => {
229
- return {
230
- encryptedWallet: _data.encryptedWallet
231
- };
232
- });
233
- });
234
- };
235
-
236
- this.hostname = hostname;
237
- this.fetch = fetch;
238
- }
239
-
240
- url(name) {
241
- return this.hostname + this.path + name;
242
- }
243
-
244
- }
245
-
246
- const createHTTPRequest = (body = {}, headers = {}) => {
247
- return {
248
- method: 'POST',
249
- headers: _extends({}, headers, {
250
- 'Content-Type': 'application/json'
251
- }),
252
- body: JSON.stringify(body || {})
253
- };
254
- };
255
-
256
- const buildResponse = res => {
257
- return res.text().then(text => {
258
- let data;
259
-
260
- try {
261
- data = JSON.parse(text);
262
- } catch (err) {
263
- throw {
264
- code: 'unknown',
265
- msg: `expecting JSON, got: ${text}`,
266
- status: res.status
267
- };
268
- }
269
-
270
- if (!res.ok) {
271
- throw data; // webrpc error response
272
- }
273
-
274
- return data;
275
- });
276
- };
277
-
278
- class SequenceAPIClient extends API {
279
- constructor(hostname, jwtAuth) {
280
- super(hostname, fetch__default['default']);
281
- this.jwtAuth = jwtAuth;
282
-
283
- this._fetch = (input, init) => {
284
- // automatically include jwt auth header to requests
285
- // if its been set on the api client
286
- const headers = {};
287
-
288
- if (this.jwtAuth && this.jwtAuth.length > 0) {
289
- headers['Authorization'] = `BEARER ${this.jwtAuth}`;
290
- } // before the request is made
291
-
292
-
293
- init.headers = _extends({}, init.headers, headers);
294
- return fetch__default['default'](input, init);
295
- };
296
-
297
- this.fetch = this._fetch;
298
- }
299
-
300
- }
301
-
302
- exports.API = API;
303
- exports.SequenceAPIClient = SequenceAPIClient;
304
- exports.WebRPCSchemaHash = WebRPCSchemaHash;
305
- exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
306
- exports.WebRPCVersion = WebRPCVersion;