@0xsequence/api 0.0.0-202182516517 → 0.0.0-202182517435

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @0xsequence/api
2
2
 
3
- ## 0.0.0-202182516517
3
+ ## 0.0.0-202182517435
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -1,11 +1 @@
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
+ export * from "./declarations/src/index";
@@ -0,0 +1,306 @@
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,16 +1,7 @@
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
1
+ 'use strict';
9
2
 
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();
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
+ }
@@ -0,0 +1,306 @@
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;
@@ -0,0 +1,294 @@
1
+ import fetch from 'cross-fetch';
2
+
3
+ function _extends() {
4
+ _extends = Object.assign || function (target) {
5
+ for (var i = 1; i < arguments.length; i++) {
6
+ var source = arguments[i];
7
+
8
+ for (var key in source) {
9
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
10
+ target[key] = source[key];
11
+ }
12
+ }
13
+ }
14
+
15
+ return target;
16
+ };
17
+
18
+ return _extends.apply(this, arguments);
19
+ }
20
+
21
+ /* eslint-disable */
22
+ // sequence-api v0.4.0 8e3575e965dc76a152d48e0b6660271db4d0c5be
23
+ // --
24
+ // This file has been generated by https://github.com/webrpc/webrpc using gen/typescript
25
+ // Do not edit by hand. Update your webrpc schema and re-generate.
26
+ // WebRPC description and code-gen version
27
+ const WebRPCVersion = "v1"; // Schema version of your RIDL schema
28
+
29
+ const WebRPCSchemaVersion = "v0.4.0"; // Schema hash generated from your RIDL schema
30
+
31
+ const WebRPCSchemaHash = "8e3575e965dc76a152d48e0b6660271db4d0c5be"; //
32
+ // Types
33
+ //
34
+
35
+ let SortOrder;
36
+
37
+ (function (SortOrder) {
38
+ SortOrder["DESC"] = "DESC";
39
+ SortOrder["ASC"] = "ASC";
40
+ })(SortOrder || (SortOrder = {}));
41
+
42
+ //
43
+ // Client
44
+ //
45
+ class API {
46
+ constructor(hostname, fetch) {
47
+ this.hostname = void 0;
48
+ this.fetch = void 0;
49
+ this.path = '/rpc/API/';
50
+
51
+ this.ping = headers => {
52
+ return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
53
+ return buildResponse(res).then(_data => {
54
+ return {
55
+ status: _data.status
56
+ };
57
+ });
58
+ });
59
+ };
60
+
61
+ this.version = headers => {
62
+ return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
63
+ return buildResponse(res).then(_data => {
64
+ return {
65
+ version: _data.version
66
+ };
67
+ });
68
+ });
69
+ };
70
+
71
+ this.runtimeStatus = headers => {
72
+ return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
73
+ return buildResponse(res).then(_data => {
74
+ return {
75
+ status: _data.status
76
+ };
77
+ });
78
+ });
79
+ };
80
+
81
+ this.getSequenceContext = headers => {
82
+ return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers)).then(res => {
83
+ return buildResponse(res).then(_data => {
84
+ return {
85
+ data: _data.data
86
+ };
87
+ });
88
+ });
89
+ };
90
+
91
+ this.getAuthToken = (args, headers) => {
92
+ return this.fetch(this.url('GetAuthToken'), createHTTPRequest(args, headers)).then(res => {
93
+ return buildResponse(res).then(_data => {
94
+ return {
95
+ status: _data.status,
96
+ jwtToken: _data.jwtToken,
97
+ address: _data.address,
98
+ user: _data.user
99
+ };
100
+ });
101
+ });
102
+ };
103
+
104
+ this.friendList = (args, headers) => {
105
+ return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers)).then(res => {
106
+ return buildResponse(res).then(_data => {
107
+ return {
108
+ page: _data.page,
109
+ friends: _data.friends
110
+ };
111
+ });
112
+ });
113
+ };
114
+
115
+ this.getFriendByAddress = (args, headers) => {
116
+ return this.fetch(this.url('GetFriendByAddress'), createHTTPRequest(args, headers)).then(res => {
117
+ return buildResponse(res).then(_data => {
118
+ return {
119
+ status: _data.status,
120
+ friend: _data.friend
121
+ };
122
+ });
123
+ });
124
+ };
125
+
126
+ this.searchFriends = (args, headers) => {
127
+ return this.fetch(this.url('SearchFriends'), createHTTPRequest(args, headers)).then(res => {
128
+ return buildResponse(res).then(_data => {
129
+ return {
130
+ friends: _data.friends
131
+ };
132
+ });
133
+ });
134
+ };
135
+
136
+ this.addFriend = (args, headers) => {
137
+ return this.fetch(this.url('AddFriend'), createHTTPRequest(args, headers)).then(res => {
138
+ return buildResponse(res).then(_data => {
139
+ return {
140
+ status: _data.status,
141
+ friend: _data.friend
142
+ };
143
+ });
144
+ });
145
+ };
146
+
147
+ this.updateFriendNickname = (args, headers) => {
148
+ return this.fetch(this.url('UpdateFriendNickname'), createHTTPRequest(args, headers)).then(res => {
149
+ return buildResponse(res).then(_data => {
150
+ return {
151
+ status: _data.status,
152
+ friend: _data.friend
153
+ };
154
+ });
155
+ });
156
+ };
157
+
158
+ this.removeFriend = (args, headers) => {
159
+ return this.fetch(this.url('RemoveFriend'), createHTTPRequest(args, headers)).then(res => {
160
+ return buildResponse(res).then(_data => {
161
+ return {
162
+ status: _data.status
163
+ };
164
+ });
165
+ });
166
+ };
167
+
168
+ this.contractCall = (args, headers) => {
169
+ return this.fetch(this.url('ContractCall'), createHTTPRequest(args, headers)).then(res => {
170
+ return buildResponse(res).then(_data => {
171
+ return {
172
+ returns: _data.returns
173
+ };
174
+ });
175
+ });
176
+ };
177
+
178
+ this.decodeContractCall = (args, headers) => {
179
+ return this.fetch(this.url('DecodeContractCall'), createHTTPRequest(args, headers)).then(res => {
180
+ return buildResponse(res).then(_data => {
181
+ return {
182
+ call: _data.call
183
+ };
184
+ });
185
+ });
186
+ };
187
+
188
+ this.lookupContractCallSelectors = (args, headers) => {
189
+ return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers)).then(res => {
190
+ return buildResponse(res).then(_data => {
191
+ return {
192
+ signatures: _data.signatures
193
+ };
194
+ });
195
+ });
196
+ };
197
+
198
+ this.getInviteInfo = headers => {
199
+ return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers)).then(res => {
200
+ return buildResponse(res).then(_data => {
201
+ return {
202
+ inviteInfo: _data.inviteInfo
203
+ };
204
+ });
205
+ });
206
+ };
207
+
208
+ this.internalClaimAccessCode = (args, headers) => {
209
+ return this.fetch(this.url('InternalClaimAccessCode'), createHTTPRequest(args, headers)).then(res => {
210
+ return buildResponse(res).then(_data => {
211
+ return {
212
+ status: _data.status
213
+ };
214
+ });
215
+ });
216
+ };
217
+
218
+ this.walletRecover = (args, headers) => {
219
+ return this.fetch(this.url('WalletRecover'), createHTTPRequest(args, headers)).then(res => {
220
+ return buildResponse(res).then(_data => {
221
+ return {
222
+ encryptedWallet: _data.encryptedWallet
223
+ };
224
+ });
225
+ });
226
+ };
227
+
228
+ this.hostname = hostname;
229
+ this.fetch = fetch;
230
+ }
231
+
232
+ url(name) {
233
+ return this.hostname + this.path + name;
234
+ }
235
+
236
+ }
237
+
238
+ const createHTTPRequest = (body = {}, headers = {}) => {
239
+ return {
240
+ method: 'POST',
241
+ headers: _extends({}, headers, {
242
+ 'Content-Type': 'application/json'
243
+ }),
244
+ body: JSON.stringify(body || {})
245
+ };
246
+ };
247
+
248
+ const buildResponse = res => {
249
+ return res.text().then(text => {
250
+ let data;
251
+
252
+ try {
253
+ data = JSON.parse(text);
254
+ } catch (err) {
255
+ throw {
256
+ code: 'unknown',
257
+ msg: `expecting JSON, got: ${text}`,
258
+ status: res.status
259
+ };
260
+ }
261
+
262
+ if (!res.ok) {
263
+ throw data; // webrpc error response
264
+ }
265
+
266
+ return data;
267
+ });
268
+ };
269
+
270
+ class SequenceAPIClient extends API {
271
+ constructor(hostname, jwtAuth) {
272
+ super(hostname, fetch);
273
+ this.jwtAuth = jwtAuth;
274
+
275
+ this._fetch = (input, init) => {
276
+ // automatically include jwt auth header to requests
277
+ // if its been set on the api client
278
+ const headers = {};
279
+
280
+ if (this.jwtAuth && this.jwtAuth.length > 0) {
281
+ headers['Authorization'] = `BEARER ${this.jwtAuth}`;
282
+ } // before the request is made
283
+
284
+
285
+ init.headers = _extends({}, init.headers, headers);
286
+ return fetch(input, init);
287
+ };
288
+
289
+ this.fetch = this._fetch;
290
+ }
291
+
292
+ }
293
+
294
+ export { API, SequenceAPIClient, SortOrder, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion };
@@ -0,0 +1,270 @@
1
+ export declare const WebRPCVersion = "v1";
2
+ export declare const WebRPCSchemaVersion = "v0.4.0";
3
+ export declare const WebRPCSchemaHash = "8e3575e965dc76a152d48e0b6660271db4d0c5be";
4
+ export declare enum SortOrder {
5
+ DESC = "DESC",
6
+ ASC = "ASC"
7
+ }
8
+ export interface Version {
9
+ webrpcVersion: string;
10
+ schemaVersion: string;
11
+ schemaHash: string;
12
+ appVersion: string;
13
+ }
14
+ export interface RuntimeStatus {
15
+ healthOK: boolean;
16
+ startTime: string;
17
+ uptime: number;
18
+ ver: string;
19
+ branch: string;
20
+ commitHash: string;
21
+ checks: RuntimeChecks;
22
+ }
23
+ export interface RuntimeChecks {
24
+ }
25
+ export interface SequenceContext {
26
+ factory: string;
27
+ mainModule: string;
28
+ mainModuleUpgradable: string;
29
+ guestModule: string;
30
+ utils: string;
31
+ }
32
+ export interface User {
33
+ address: string;
34
+ username: string;
35
+ avatar: string;
36
+ bio: string;
37
+ location: string;
38
+ locale: string;
39
+ backup?: boolean;
40
+ backupConfirmed?: boolean;
41
+ maxInvites?: number;
42
+ updatedAt?: string;
43
+ createdAt?: string;
44
+ }
45
+ export interface WalletBackup {
46
+ accountAddress: string;
47
+ secretHash: string;
48
+ encryptedWallet: string;
49
+ userConfirmed: boolean;
50
+ updatedAt?: string;
51
+ createdAt?: string;
52
+ }
53
+ export interface Friend {
54
+ id: number;
55
+ userAddress: string;
56
+ friendAddress: string;
57
+ nickname: string;
58
+ user?: User;
59
+ createdAt?: string;
60
+ }
61
+ export interface InviteCode {
62
+ usesLeft: number;
63
+ ownerAccount: string;
64
+ email?: string;
65
+ url: string;
66
+ createdAt?: string;
67
+ expiresAt?: string;
68
+ }
69
+ export interface InviteCodeAccount {
70
+ claimedByUserAddress: string;
71
+ claimedAt?: string;
72
+ }
73
+ export interface InviteInfo {
74
+ expiryInHours: number;
75
+ max: number;
76
+ invites: Array<InviteCode>;
77
+ }
78
+ export interface ContractCall {
79
+ signature: string;
80
+ function: string;
81
+ args: Array<ContractCallArg>;
82
+ }
83
+ export interface ContractCallArg {
84
+ name?: string;
85
+ type: string;
86
+ value: any;
87
+ }
88
+ export interface Transaction {
89
+ delegateCall: boolean;
90
+ revertOnError: boolean;
91
+ gasLimit: string;
92
+ target: string;
93
+ value: string;
94
+ data: string;
95
+ call?: ContractCall;
96
+ }
97
+ export interface Page {
98
+ pageSize?: number;
99
+ page?: number;
100
+ totalRecords?: number;
101
+ column?: string;
102
+ before?: any;
103
+ after?: any;
104
+ sort?: Array<SortBy>;
105
+ }
106
+ export interface SortBy {
107
+ column: string;
108
+ order: SortOrder;
109
+ }
110
+ export interface API {
111
+ ping(headers?: object): Promise<PingReturn>;
112
+ version(headers?: object): Promise<VersionReturn>;
113
+ runtimeStatus(headers?: object): Promise<RuntimeStatusReturn>;
114
+ getSequenceContext(headers?: object): Promise<GetSequenceContextReturn>;
115
+ getAuthToken(args: GetAuthTokenArgs, headers?: object): Promise<GetAuthTokenReturn>;
116
+ friendList(args: FriendListArgs, headers?: object): Promise<FriendListReturn>;
117
+ getFriendByAddress(args: GetFriendByAddressArgs, headers?: object): Promise<GetFriendByAddressReturn>;
118
+ searchFriends(args: SearchFriendsArgs, headers?: object): Promise<SearchFriendsReturn>;
119
+ addFriend(args: AddFriendArgs, headers?: object): Promise<AddFriendReturn>;
120
+ updateFriendNickname(args: UpdateFriendNicknameArgs, headers?: object): Promise<UpdateFriendNicknameReturn>;
121
+ removeFriend(args: RemoveFriendArgs, headers?: object): Promise<RemoveFriendReturn>;
122
+ contractCall(args: ContractCallArgs, headers?: object): Promise<ContractCallReturn>;
123
+ decodeContractCall(args: DecodeContractCallArgs, headers?: object): Promise<DecodeContractCallReturn>;
124
+ lookupContractCallSelectors(args: LookupContractCallSelectorsArgs, headers?: object): Promise<LookupContractCallSelectorsReturn>;
125
+ getInviteInfo(headers?: object): Promise<GetInviteInfoReturn>;
126
+ internalClaimAccessCode(args: InternalClaimAccessCodeArgs, headers?: object): Promise<InternalClaimAccessCodeReturn>;
127
+ walletRecover(args: WalletRecoverArgs, headers?: object): Promise<WalletRecoverReturn>;
128
+ }
129
+ export interface PingArgs {
130
+ }
131
+ export interface PingReturn {
132
+ status: boolean;
133
+ }
134
+ export interface VersionArgs {
135
+ }
136
+ export interface VersionReturn {
137
+ version: Version;
138
+ }
139
+ export interface RuntimeStatusArgs {
140
+ }
141
+ export interface RuntimeStatusReturn {
142
+ status: RuntimeStatus;
143
+ }
144
+ export interface GetSequenceContextArgs {
145
+ }
146
+ export interface GetSequenceContextReturn {
147
+ data: SequenceContext;
148
+ }
149
+ export interface GetAuthTokenArgs {
150
+ ewtString: string;
151
+ }
152
+ export interface GetAuthTokenReturn {
153
+ status: boolean;
154
+ jwtToken: string;
155
+ address: string;
156
+ user?: User;
157
+ }
158
+ export interface FriendListArgs {
159
+ page?: Page;
160
+ }
161
+ export interface FriendListReturn {
162
+ page: Page;
163
+ friends: Array<Friend>;
164
+ }
165
+ export interface GetFriendByAddressArgs {
166
+ friendAddress: string;
167
+ }
168
+ export interface GetFriendByAddressReturn {
169
+ status: boolean;
170
+ friend: Friend;
171
+ }
172
+ export interface SearchFriendsArgs {
173
+ filterUsername: string;
174
+ }
175
+ export interface SearchFriendsReturn {
176
+ friends: Array<Friend>;
177
+ }
178
+ export interface AddFriendArgs {
179
+ friendAddress: string;
180
+ optionalNickname?: string;
181
+ }
182
+ export interface AddFriendReturn {
183
+ status: boolean;
184
+ friend?: Friend;
185
+ }
186
+ export interface UpdateFriendNicknameArgs {
187
+ friendAddress: string;
188
+ nickname: string;
189
+ }
190
+ export interface UpdateFriendNicknameReturn {
191
+ status: boolean;
192
+ friend?: Friend;
193
+ }
194
+ export interface RemoveFriendArgs {
195
+ friendAddress: string;
196
+ }
197
+ export interface RemoveFriendReturn {
198
+ status: boolean;
199
+ }
200
+ export interface ContractCallArgs {
201
+ chainID: string;
202
+ contract: string;
203
+ inputExpr: string;
204
+ outputExpr: string;
205
+ args: Array<string>;
206
+ }
207
+ export interface ContractCallReturn {
208
+ returns: Array<string>;
209
+ }
210
+ export interface DecodeContractCallArgs {
211
+ callData: string;
212
+ }
213
+ export interface DecodeContractCallReturn {
214
+ call: ContractCall;
215
+ }
216
+ export interface LookupContractCallSelectorsArgs {
217
+ selectors: Array<string>;
218
+ }
219
+ export interface LookupContractCallSelectorsReturn {
220
+ signatures: Array<Array<string>>;
221
+ }
222
+ export interface GetInviteInfoArgs {
223
+ }
224
+ export interface GetInviteInfoReturn {
225
+ inviteInfo: InviteInfo;
226
+ }
227
+ export interface InternalClaimAccessCodeArgs {
228
+ address: string;
229
+ accessCode: string;
230
+ }
231
+ export interface InternalClaimAccessCodeReturn {
232
+ status: boolean;
233
+ }
234
+ export interface WalletRecoverArgs {
235
+ username: string;
236
+ secretHash: string;
237
+ }
238
+ export interface WalletRecoverReturn {
239
+ encryptedWallet: string;
240
+ }
241
+ export declare class API implements API {
242
+ protected hostname: string;
243
+ protected fetch: Fetch;
244
+ protected path: string;
245
+ constructor(hostname: string, fetch: Fetch);
246
+ private url;
247
+ ping: (headers?: object | undefined) => Promise<PingReturn>;
248
+ version: (headers?: object | undefined) => Promise<VersionReturn>;
249
+ runtimeStatus: (headers?: object | undefined) => Promise<RuntimeStatusReturn>;
250
+ getSequenceContext: (headers?: object | undefined) => Promise<GetSequenceContextReturn>;
251
+ getAuthToken: (args: GetAuthTokenArgs, headers?: object | undefined) => Promise<GetAuthTokenReturn>;
252
+ friendList: (args: FriendListArgs, headers?: object | undefined) => Promise<FriendListReturn>;
253
+ getFriendByAddress: (args: GetFriendByAddressArgs, headers?: object | undefined) => Promise<GetFriendByAddressReturn>;
254
+ searchFriends: (args: SearchFriendsArgs, headers?: object | undefined) => Promise<SearchFriendsReturn>;
255
+ addFriend: (args: AddFriendArgs, headers?: object | undefined) => Promise<AddFriendReturn>;
256
+ updateFriendNickname: (args: UpdateFriendNicknameArgs, headers?: object | undefined) => Promise<UpdateFriendNicknameReturn>;
257
+ removeFriend: (args: RemoveFriendArgs, headers?: object | undefined) => Promise<RemoveFriendReturn>;
258
+ contractCall: (args: ContractCallArgs, headers?: object | undefined) => Promise<ContractCallReturn>;
259
+ decodeContractCall: (args: DecodeContractCallArgs, headers?: object | undefined) => Promise<DecodeContractCallReturn>;
260
+ lookupContractCallSelectors: (args: LookupContractCallSelectorsArgs, headers?: object | undefined) => Promise<LookupContractCallSelectorsReturn>;
261
+ getInviteInfo: (headers?: object | undefined) => Promise<GetInviteInfoReturn>;
262
+ internalClaimAccessCode: (args: InternalClaimAccessCodeArgs, headers?: object | undefined) => Promise<InternalClaimAccessCodeReturn>;
263
+ walletRecover: (args: WalletRecoverArgs, headers?: object | undefined) => Promise<WalletRecoverReturn>;
264
+ }
265
+ export interface WebRPCError extends Error {
266
+ code: string;
267
+ msg: string;
268
+ status: number;
269
+ }
270
+ export declare type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
@@ -0,0 +1,7 @@
1
+ export * from './api.gen';
2
+ import { API as BaseSequenceAPI } from './api.gen';
3
+ export declare class SequenceAPIClient extends BaseSequenceAPI {
4
+ jwtAuth?: string | undefined;
5
+ constructor(hostname: string, jwtAuth?: string | undefined);
6
+ _fetch: (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/api",
3
- "version": "0.0.0-202182516517",
3
+ "version": "0.0.0-202182517435",
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",