@0xsequence/metadata 0.0.0-20220412184039 → 0.0.0-20220413180329

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,5 +1,11 @@
1
1
  # @0xsequence/metadata
2
2
 
3
+ ## 0.0.0-20220413180329
4
+
5
+ ### Patch Changes
6
+
7
+ - update metadata proto
8
+
3
9
  ## 0.0.0-20220412184039
4
10
 
5
11
  ### Patch Changes
@@ -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,263 @@
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-metadata v0.4.0 376fc6f21f770a4d0457a039d13b6aca6d174e3f
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 = "376fc6f21f770a4d0457a039d13b6aca6d174e3f"; //
40
+ // Types
41
+ //
42
+
43
+ exports.ContractType = void 0;
44
+
45
+ (function (ContractType) {
46
+ ContractType["ERC20"] = "ERC20";
47
+ ContractType["ContractURI"] = "ContractURI";
48
+ ContractType["OpenSea"] = "OpenSea";
49
+ ContractType["ERC1155"] = "ERC1155";
50
+ ContractType["ERC721"] = "ERC721";
51
+ ContractType["UNKNOWN"] = "UNKNOWN";
52
+ })(exports.ContractType || (exports.ContractType = {}));
53
+
54
+ exports.SwapType = void 0;
55
+
56
+ (function (SwapType) {
57
+ SwapType["UNKNOWN"] = "UNKNOWN";
58
+ SwapType["BUY"] = "BUY";
59
+ SwapType["SELL"] = "SELL";
60
+ })(exports.SwapType || (exports.SwapType = {}));
61
+
62
+ exports.SortOrder = void 0;
63
+
64
+ (function (SortOrder) {
65
+ SortOrder["DESC"] = "DESC";
66
+ SortOrder["ASC"] = "ASC";
67
+ })(exports.SortOrder || (exports.SortOrder = {}));
68
+
69
+ //
70
+ // Client
71
+ //
72
+ class Metadata {
73
+ constructor(hostname, fetch) {
74
+ this.hostname = void 0;
75
+ this.fetch = void 0;
76
+ this.path = '/rpc/Metadata/';
77
+
78
+ this.ping = headers => {
79
+ return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
80
+ return buildResponse(res).then(_data => {
81
+ return {
82
+ status: _data.status
83
+ };
84
+ });
85
+ });
86
+ };
87
+
88
+ this.version = headers => {
89
+ return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
90
+ return buildResponse(res).then(_data => {
91
+ return {
92
+ version: _data.version
93
+ };
94
+ });
95
+ });
96
+ };
97
+
98
+ this.runtimeStatus = headers => {
99
+ return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
100
+ return buildResponse(res).then(_data => {
101
+ return {
102
+ status: _data.status
103
+ };
104
+ });
105
+ });
106
+ };
107
+
108
+ this.getTokenMetadata = (args, headers) => {
109
+ return this.fetch(this.url('GetTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
110
+ return buildResponse(res).then(_data => {
111
+ return {
112
+ tokenMetadata: _data.tokenMetadata
113
+ };
114
+ });
115
+ });
116
+ };
117
+
118
+ this.getTokenMetadataBatch = (args, headers) => {
119
+ return this.fetch(this.url('GetTokenMetadataBatch'), createHTTPRequest(args, headers)).then(res => {
120
+ return buildResponse(res).then(_data => {
121
+ return {
122
+ contractTokenMetadata: _data.contractTokenMetadata
123
+ };
124
+ });
125
+ });
126
+ };
127
+
128
+ this.searchTokenMetadata = (args, headers) => {
129
+ return this.fetch(this.url('SearchTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
130
+ return buildResponse(res).then(_data => {
131
+ return {
132
+ page: _data.page,
133
+ tokenMetadata: _data.tokenMetadata
134
+ };
135
+ });
136
+ });
137
+ };
138
+
139
+ this.searchTokenIDs = (args, headers) => {
140
+ return this.fetch(this.url('SearchTokenIDs'), createHTTPRequest(args, headers)).then(res => {
141
+ return buildResponse(res).then(_data => {
142
+ return {
143
+ page: _data.page,
144
+ tokenIds: _data.tokenIds
145
+ };
146
+ });
147
+ });
148
+ };
149
+
150
+ this.getContractInfo = (args, headers) => {
151
+ return this.fetch(this.url('GetContractInfo'), createHTTPRequest(args, headers)).then(res => {
152
+ return buildResponse(res).then(_data => {
153
+ return {
154
+ contractInfo: _data.contractInfo
155
+ };
156
+ });
157
+ });
158
+ };
159
+
160
+ this.getContractInfoBatch = (args, headers) => {
161
+ return this.fetch(this.url('GetContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
162
+ return buildResponse(res).then(_data => {
163
+ return {
164
+ contractInfoMap: _data.contractInfoMap
165
+ };
166
+ });
167
+ });
168
+ };
169
+
170
+ this.searchContractInfo = (args, headers) => {
171
+ return this.fetch(this.url('SearchContractInfo'), createHTTPRequest(args, headers)).then(res => {
172
+ return buildResponse(res).then(_data => {
173
+ return {
174
+ contractInfoList: _data.contractInfoList
175
+ };
176
+ });
177
+ });
178
+ };
179
+
180
+ this.searchContractInfoBatch = (args, headers) => {
181
+ return this.fetch(this.url('SearchContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
182
+ return buildResponse(res).then(_data => {
183
+ return {
184
+ contractInfoByChain: _data.contractInfoByChain
185
+ };
186
+ });
187
+ });
188
+ };
189
+
190
+ this.getNiftyswapTokenQuantity = (args, headers) => {
191
+ return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers)).then(res => {
192
+ return buildResponse(res).then(_data => {
193
+ return {
194
+ quantity: _data.quantity
195
+ };
196
+ });
197
+ });
198
+ };
199
+
200
+ this.getNiftyswapUnitPrices = (args, headers) => {
201
+ return this.fetch(this.url('GetNiftyswapUnitPrices'), createHTTPRequest(args, headers)).then(res => {
202
+ return buildResponse(res).then(_data => {
203
+ return {
204
+ prices: _data.prices
205
+ };
206
+ });
207
+ });
208
+ };
209
+
210
+ this.hostname = hostname;
211
+ this.fetch = fetch;
212
+ }
213
+
214
+ url(name) {
215
+ return this.hostname + this.path + name;
216
+ }
217
+
218
+ }
219
+
220
+ const createHTTPRequest = (body = {}, headers = {}) => {
221
+ return {
222
+ method: 'POST',
223
+ headers: _extends({}, headers, {
224
+ 'Content-Type': 'application/json'
225
+ }),
226
+ body: JSON.stringify(body || {})
227
+ };
228
+ };
229
+
230
+ const buildResponse = res => {
231
+ return res.text().then(text => {
232
+ let data;
233
+
234
+ try {
235
+ data = JSON.parse(text);
236
+ } catch (err) {
237
+ throw {
238
+ code: 'unknown',
239
+ msg: `expecting JSON, got: ${text}`,
240
+ status: res.status
241
+ };
242
+ }
243
+
244
+ if (!res.ok) {
245
+ throw data; // webrpc error response
246
+ }
247
+
248
+ return data;
249
+ });
250
+ };
251
+
252
+ class SequenceMetadataClient extends Metadata {
253
+ constructor(hostname = 'https://metadata.sequence.app') {
254
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch__default["default"]);
255
+ }
256
+
257
+ }
258
+
259
+ exports.Metadata = Metadata;
260
+ exports.SequenceMetadataClient = SequenceMetadataClient;
261
+ exports.WebRPCSchemaHash = WebRPCSchemaHash;
262
+ exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
263
+ 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-metadata.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./0xsequence-metadata.cjs.dev.js");
7
+ }
@@ -0,0 +1,263 @@
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-metadata v0.4.0 376fc6f21f770a4d0457a039d13b6aca6d174e3f
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 = "376fc6f21f770a4d0457a039d13b6aca6d174e3f"; //
40
+ // Types
41
+ //
42
+
43
+ exports.ContractType = void 0;
44
+
45
+ (function (ContractType) {
46
+ ContractType["ERC20"] = "ERC20";
47
+ ContractType["ContractURI"] = "ContractURI";
48
+ ContractType["OpenSea"] = "OpenSea";
49
+ ContractType["ERC1155"] = "ERC1155";
50
+ ContractType["ERC721"] = "ERC721";
51
+ ContractType["UNKNOWN"] = "UNKNOWN";
52
+ })(exports.ContractType || (exports.ContractType = {}));
53
+
54
+ exports.SwapType = void 0;
55
+
56
+ (function (SwapType) {
57
+ SwapType["UNKNOWN"] = "UNKNOWN";
58
+ SwapType["BUY"] = "BUY";
59
+ SwapType["SELL"] = "SELL";
60
+ })(exports.SwapType || (exports.SwapType = {}));
61
+
62
+ exports.SortOrder = void 0;
63
+
64
+ (function (SortOrder) {
65
+ SortOrder["DESC"] = "DESC";
66
+ SortOrder["ASC"] = "ASC";
67
+ })(exports.SortOrder || (exports.SortOrder = {}));
68
+
69
+ //
70
+ // Client
71
+ //
72
+ class Metadata {
73
+ constructor(hostname, fetch) {
74
+ this.hostname = void 0;
75
+ this.fetch = void 0;
76
+ this.path = '/rpc/Metadata/';
77
+
78
+ this.ping = headers => {
79
+ return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
80
+ return buildResponse(res).then(_data => {
81
+ return {
82
+ status: _data.status
83
+ };
84
+ });
85
+ });
86
+ };
87
+
88
+ this.version = headers => {
89
+ return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
90
+ return buildResponse(res).then(_data => {
91
+ return {
92
+ version: _data.version
93
+ };
94
+ });
95
+ });
96
+ };
97
+
98
+ this.runtimeStatus = headers => {
99
+ return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
100
+ return buildResponse(res).then(_data => {
101
+ return {
102
+ status: _data.status
103
+ };
104
+ });
105
+ });
106
+ };
107
+
108
+ this.getTokenMetadata = (args, headers) => {
109
+ return this.fetch(this.url('GetTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
110
+ return buildResponse(res).then(_data => {
111
+ return {
112
+ tokenMetadata: _data.tokenMetadata
113
+ };
114
+ });
115
+ });
116
+ };
117
+
118
+ this.getTokenMetadataBatch = (args, headers) => {
119
+ return this.fetch(this.url('GetTokenMetadataBatch'), createHTTPRequest(args, headers)).then(res => {
120
+ return buildResponse(res).then(_data => {
121
+ return {
122
+ contractTokenMetadata: _data.contractTokenMetadata
123
+ };
124
+ });
125
+ });
126
+ };
127
+
128
+ this.searchTokenMetadata = (args, headers) => {
129
+ return this.fetch(this.url('SearchTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
130
+ return buildResponse(res).then(_data => {
131
+ return {
132
+ page: _data.page,
133
+ tokenMetadata: _data.tokenMetadata
134
+ };
135
+ });
136
+ });
137
+ };
138
+
139
+ this.searchTokenIDs = (args, headers) => {
140
+ return this.fetch(this.url('SearchTokenIDs'), createHTTPRequest(args, headers)).then(res => {
141
+ return buildResponse(res).then(_data => {
142
+ return {
143
+ page: _data.page,
144
+ tokenIds: _data.tokenIds
145
+ };
146
+ });
147
+ });
148
+ };
149
+
150
+ this.getContractInfo = (args, headers) => {
151
+ return this.fetch(this.url('GetContractInfo'), createHTTPRequest(args, headers)).then(res => {
152
+ return buildResponse(res).then(_data => {
153
+ return {
154
+ contractInfo: _data.contractInfo
155
+ };
156
+ });
157
+ });
158
+ };
159
+
160
+ this.getContractInfoBatch = (args, headers) => {
161
+ return this.fetch(this.url('GetContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
162
+ return buildResponse(res).then(_data => {
163
+ return {
164
+ contractInfoMap: _data.contractInfoMap
165
+ };
166
+ });
167
+ });
168
+ };
169
+
170
+ this.searchContractInfo = (args, headers) => {
171
+ return this.fetch(this.url('SearchContractInfo'), createHTTPRequest(args, headers)).then(res => {
172
+ return buildResponse(res).then(_data => {
173
+ return {
174
+ contractInfoList: _data.contractInfoList
175
+ };
176
+ });
177
+ });
178
+ };
179
+
180
+ this.searchContractInfoBatch = (args, headers) => {
181
+ return this.fetch(this.url('SearchContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
182
+ return buildResponse(res).then(_data => {
183
+ return {
184
+ contractInfoByChain: _data.contractInfoByChain
185
+ };
186
+ });
187
+ });
188
+ };
189
+
190
+ this.getNiftyswapTokenQuantity = (args, headers) => {
191
+ return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers)).then(res => {
192
+ return buildResponse(res).then(_data => {
193
+ return {
194
+ quantity: _data.quantity
195
+ };
196
+ });
197
+ });
198
+ };
199
+
200
+ this.getNiftyswapUnitPrices = (args, headers) => {
201
+ return this.fetch(this.url('GetNiftyswapUnitPrices'), createHTTPRequest(args, headers)).then(res => {
202
+ return buildResponse(res).then(_data => {
203
+ return {
204
+ prices: _data.prices
205
+ };
206
+ });
207
+ });
208
+ };
209
+
210
+ this.hostname = hostname;
211
+ this.fetch = fetch;
212
+ }
213
+
214
+ url(name) {
215
+ return this.hostname + this.path + name;
216
+ }
217
+
218
+ }
219
+
220
+ const createHTTPRequest = (body = {}, headers = {}) => {
221
+ return {
222
+ method: 'POST',
223
+ headers: _extends({}, headers, {
224
+ 'Content-Type': 'application/json'
225
+ }),
226
+ body: JSON.stringify(body || {})
227
+ };
228
+ };
229
+
230
+ const buildResponse = res => {
231
+ return res.text().then(text => {
232
+ let data;
233
+
234
+ try {
235
+ data = JSON.parse(text);
236
+ } catch (err) {
237
+ throw {
238
+ code: 'unknown',
239
+ msg: `expecting JSON, got: ${text}`,
240
+ status: res.status
241
+ };
242
+ }
243
+
244
+ if (!res.ok) {
245
+ throw data; // webrpc error response
246
+ }
247
+
248
+ return data;
249
+ });
250
+ };
251
+
252
+ class SequenceMetadataClient extends Metadata {
253
+ constructor(hostname = 'https://metadata.sequence.app') {
254
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch__default["default"]);
255
+ }
256
+
257
+ }
258
+
259
+ exports.Metadata = Metadata;
260
+ exports.SequenceMetadataClient = SequenceMetadataClient;
261
+ exports.WebRPCSchemaHash = WebRPCSchemaHash;
262
+ exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
263
+ exports.WebRPCVersion = WebRPCVersion;
@@ -0,0 +1,251 @@
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-metadata v0.4.0 376fc6f21f770a4d0457a039d13b6aca6d174e3f
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 = "376fc6f21f770a4d0457a039d13b6aca6d174e3f"; //
32
+ // Types
33
+ //
34
+
35
+ let ContractType;
36
+
37
+ (function (ContractType) {
38
+ ContractType["ERC20"] = "ERC20";
39
+ ContractType["ContractURI"] = "ContractURI";
40
+ ContractType["OpenSea"] = "OpenSea";
41
+ ContractType["ERC1155"] = "ERC1155";
42
+ ContractType["ERC721"] = "ERC721";
43
+ ContractType["UNKNOWN"] = "UNKNOWN";
44
+ })(ContractType || (ContractType = {}));
45
+
46
+ let SwapType;
47
+
48
+ (function (SwapType) {
49
+ SwapType["UNKNOWN"] = "UNKNOWN";
50
+ SwapType["BUY"] = "BUY";
51
+ SwapType["SELL"] = "SELL";
52
+ })(SwapType || (SwapType = {}));
53
+
54
+ let SortOrder;
55
+
56
+ (function (SortOrder) {
57
+ SortOrder["DESC"] = "DESC";
58
+ SortOrder["ASC"] = "ASC";
59
+ })(SortOrder || (SortOrder = {}));
60
+
61
+ //
62
+ // Client
63
+ //
64
+ class Metadata {
65
+ constructor(hostname, fetch) {
66
+ this.hostname = void 0;
67
+ this.fetch = void 0;
68
+ this.path = '/rpc/Metadata/';
69
+
70
+ this.ping = headers => {
71
+ return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
72
+ return buildResponse(res).then(_data => {
73
+ return {
74
+ status: _data.status
75
+ };
76
+ });
77
+ });
78
+ };
79
+
80
+ this.version = headers => {
81
+ return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
82
+ return buildResponse(res).then(_data => {
83
+ return {
84
+ version: _data.version
85
+ };
86
+ });
87
+ });
88
+ };
89
+
90
+ this.runtimeStatus = headers => {
91
+ return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
92
+ return buildResponse(res).then(_data => {
93
+ return {
94
+ status: _data.status
95
+ };
96
+ });
97
+ });
98
+ };
99
+
100
+ this.getTokenMetadata = (args, headers) => {
101
+ return this.fetch(this.url('GetTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
102
+ return buildResponse(res).then(_data => {
103
+ return {
104
+ tokenMetadata: _data.tokenMetadata
105
+ };
106
+ });
107
+ });
108
+ };
109
+
110
+ this.getTokenMetadataBatch = (args, headers) => {
111
+ return this.fetch(this.url('GetTokenMetadataBatch'), createHTTPRequest(args, headers)).then(res => {
112
+ return buildResponse(res).then(_data => {
113
+ return {
114
+ contractTokenMetadata: _data.contractTokenMetadata
115
+ };
116
+ });
117
+ });
118
+ };
119
+
120
+ this.searchTokenMetadata = (args, headers) => {
121
+ return this.fetch(this.url('SearchTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
122
+ return buildResponse(res).then(_data => {
123
+ return {
124
+ page: _data.page,
125
+ tokenMetadata: _data.tokenMetadata
126
+ };
127
+ });
128
+ });
129
+ };
130
+
131
+ this.searchTokenIDs = (args, headers) => {
132
+ return this.fetch(this.url('SearchTokenIDs'), createHTTPRequest(args, headers)).then(res => {
133
+ return buildResponse(res).then(_data => {
134
+ return {
135
+ page: _data.page,
136
+ tokenIds: _data.tokenIds
137
+ };
138
+ });
139
+ });
140
+ };
141
+
142
+ this.getContractInfo = (args, headers) => {
143
+ return this.fetch(this.url('GetContractInfo'), createHTTPRequest(args, headers)).then(res => {
144
+ return buildResponse(res).then(_data => {
145
+ return {
146
+ contractInfo: _data.contractInfo
147
+ };
148
+ });
149
+ });
150
+ };
151
+
152
+ this.getContractInfoBatch = (args, headers) => {
153
+ return this.fetch(this.url('GetContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
154
+ return buildResponse(res).then(_data => {
155
+ return {
156
+ contractInfoMap: _data.contractInfoMap
157
+ };
158
+ });
159
+ });
160
+ };
161
+
162
+ this.searchContractInfo = (args, headers) => {
163
+ return this.fetch(this.url('SearchContractInfo'), createHTTPRequest(args, headers)).then(res => {
164
+ return buildResponse(res).then(_data => {
165
+ return {
166
+ contractInfoList: _data.contractInfoList
167
+ };
168
+ });
169
+ });
170
+ };
171
+
172
+ this.searchContractInfoBatch = (args, headers) => {
173
+ return this.fetch(this.url('SearchContractInfoBatch'), createHTTPRequest(args, headers)).then(res => {
174
+ return buildResponse(res).then(_data => {
175
+ return {
176
+ contractInfoByChain: _data.contractInfoByChain
177
+ };
178
+ });
179
+ });
180
+ };
181
+
182
+ this.getNiftyswapTokenQuantity = (args, headers) => {
183
+ return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers)).then(res => {
184
+ return buildResponse(res).then(_data => {
185
+ return {
186
+ quantity: _data.quantity
187
+ };
188
+ });
189
+ });
190
+ };
191
+
192
+ this.getNiftyswapUnitPrices = (args, headers) => {
193
+ return this.fetch(this.url('GetNiftyswapUnitPrices'), createHTTPRequest(args, headers)).then(res => {
194
+ return buildResponse(res).then(_data => {
195
+ return {
196
+ prices: _data.prices
197
+ };
198
+ });
199
+ });
200
+ };
201
+
202
+ this.hostname = hostname;
203
+ this.fetch = fetch;
204
+ }
205
+
206
+ url(name) {
207
+ return this.hostname + this.path + name;
208
+ }
209
+
210
+ }
211
+
212
+ const createHTTPRequest = (body = {}, headers = {}) => {
213
+ return {
214
+ method: 'POST',
215
+ headers: _extends({}, headers, {
216
+ 'Content-Type': 'application/json'
217
+ }),
218
+ body: JSON.stringify(body || {})
219
+ };
220
+ };
221
+
222
+ const buildResponse = res => {
223
+ return res.text().then(text => {
224
+ let data;
225
+
226
+ try {
227
+ data = JSON.parse(text);
228
+ } catch (err) {
229
+ throw {
230
+ code: 'unknown',
231
+ msg: `expecting JSON, got: ${text}`,
232
+ status: res.status
233
+ };
234
+ }
235
+
236
+ if (!res.ok) {
237
+ throw data; // webrpc error response
238
+ }
239
+
240
+ return data;
241
+ });
242
+ };
243
+
244
+ class SequenceMetadataClient extends Metadata {
245
+ constructor(hostname = 'https://metadata.sequence.app') {
246
+ super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
247
+ }
248
+
249
+ }
250
+
251
+ export { ContractType, Metadata, SequenceMetadataClient, SortOrder, SwapType, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion };
@@ -0,0 +1,5 @@
1
+ export * from './metadata.gen';
2
+ import { Metadata as BaseSequenceMetadata } from './metadata.gen';
3
+ export declare class SequenceMetadataClient extends BaseSequenceMetadata {
4
+ constructor(hostname?: string);
5
+ }
@@ -0,0 +1,249 @@
1
+ export declare const WebRPCVersion = "v1";
2
+ export declare const WebRPCSchemaVersion = "v0.4.0";
3
+ export declare const WebRPCSchemaHash = "376fc6f21f770a4d0457a039d13b6aca6d174e3f";
4
+ export declare enum ContractType {
5
+ ERC20 = "ERC20",
6
+ ContractURI = "ContractURI",
7
+ OpenSea = "OpenSea",
8
+ ERC1155 = "ERC1155",
9
+ ERC721 = "ERC721",
10
+ UNKNOWN = "UNKNOWN"
11
+ }
12
+ export declare enum SwapType {
13
+ UNKNOWN = "UNKNOWN",
14
+ BUY = "BUY",
15
+ SELL = "SELL"
16
+ }
17
+ export declare enum SortOrder {
18
+ DESC = "DESC",
19
+ ASC = "ASC"
20
+ }
21
+ export interface Version {
22
+ webrpcVersion: string;
23
+ schemaVersion: string;
24
+ schemaHash: string;
25
+ appVersion: string;
26
+ }
27
+ export interface RuntimeStatus {
28
+ healthOK: boolean;
29
+ startTime: string;
30
+ uptime: number;
31
+ ver: string;
32
+ branch: string;
33
+ commitHash: string;
34
+ checks: RuntimeChecks;
35
+ }
36
+ export interface RuntimeChecks {
37
+ }
38
+ export interface ContractIndex {
39
+ chainId: string;
40
+ address: string;
41
+ type: ContractType;
42
+ metadata: {
43
+ [key: string]: any;
44
+ };
45
+ }
46
+ export interface ContractInfo {
47
+ chainId: number;
48
+ address: string;
49
+ name: string;
50
+ type: string;
51
+ symbol: string;
52
+ decimals?: number;
53
+ logoURI: string;
54
+ extensions: ContractInfoExtensions;
55
+ }
56
+ export interface ContractInfoExtensions {
57
+ link: string;
58
+ description: string;
59
+ ogImage: string;
60
+ originChainId: number;
61
+ originAddress: string;
62
+ blacklist: boolean;
63
+ }
64
+ export interface TokenIndex {
65
+ chainId: string;
66
+ contractAddress: string;
67
+ tokenId: string;
68
+ metadata: {
69
+ [key: string]: any;
70
+ };
71
+ }
72
+ export interface TokenMetadata {
73
+ tokenId: string;
74
+ contractAddress: string;
75
+ name: string;
76
+ description: string;
77
+ image: string;
78
+ decimals: number;
79
+ properties: {
80
+ [key: string]: any;
81
+ };
82
+ video: string;
83
+ audio: string;
84
+ image_data: string;
85
+ external_url: string;
86
+ background_color: string;
87
+ animation_url: string;
88
+ attributes: Array<{
89
+ [key: string]: any;
90
+ }>;
91
+ }
92
+ export interface GetNiftyswapUnitPricesRequest {
93
+ swapType: SwapType;
94
+ ids: Array<string>;
95
+ amounts: Array<string>;
96
+ }
97
+ export interface Page {
98
+ pageSize?: number;
99
+ page?: number;
100
+ }
101
+ export interface SortBy {
102
+ column: string;
103
+ order: SortOrder;
104
+ }
105
+ export interface Metadata {
106
+ ping(headers?: object): Promise<PingReturn>;
107
+ version(headers?: object): Promise<VersionReturn>;
108
+ runtimeStatus(headers?: object): Promise<RuntimeStatusReturn>;
109
+ getTokenMetadata(args: GetTokenMetadataArgs, headers?: object): Promise<GetTokenMetadataReturn>;
110
+ getTokenMetadataBatch(args: GetTokenMetadataBatchArgs, headers?: object): Promise<GetTokenMetadataBatchReturn>;
111
+ searchTokenMetadata(args: SearchTokenMetadataArgs, headers?: object): Promise<SearchTokenMetadataReturn>;
112
+ searchTokenIDs(args: SearchTokenIDsArgs, headers?: object): Promise<SearchTokenIDsReturn>;
113
+ getContractInfo(args: GetContractInfoArgs, headers?: object): Promise<GetContractInfoReturn>;
114
+ getContractInfoBatch(args: GetContractInfoBatchArgs, headers?: object): Promise<GetContractInfoBatchReturn>;
115
+ searchContractInfo(args: SearchContractInfoArgs, headers?: object): Promise<SearchContractInfoReturn>;
116
+ searchContractInfoBatch(args: SearchContractInfoBatchArgs, headers?: object): Promise<SearchContractInfoBatchReturn>;
117
+ getNiftyswapTokenQuantity(args: GetNiftyswapTokenQuantityArgs, headers?: object): Promise<GetNiftyswapTokenQuantityReturn>;
118
+ getNiftyswapUnitPrices(args: GetNiftyswapUnitPricesArgs, headers?: object): Promise<GetNiftyswapUnitPricesReturn>;
119
+ }
120
+ export interface PingArgs {
121
+ }
122
+ export interface PingReturn {
123
+ status: boolean;
124
+ }
125
+ export interface VersionArgs {
126
+ }
127
+ export interface VersionReturn {
128
+ version: Version;
129
+ }
130
+ export interface RuntimeStatusArgs {
131
+ }
132
+ export interface RuntimeStatusReturn {
133
+ status: RuntimeStatus;
134
+ }
135
+ export interface GetTokenMetadataArgs {
136
+ chainID: string;
137
+ contractAddress: string;
138
+ tokenIDs: Array<string>;
139
+ }
140
+ export interface GetTokenMetadataReturn {
141
+ tokenMetadata: Array<TokenMetadata>;
142
+ }
143
+ export interface GetTokenMetadataBatchArgs {
144
+ chainID: string;
145
+ contractTokenMap: {
146
+ [key: string]: Array<string>;
147
+ };
148
+ }
149
+ export interface GetTokenMetadataBatchReturn {
150
+ contractTokenMetadata: {
151
+ [key: string]: Array<TokenMetadata>;
152
+ };
153
+ }
154
+ export interface SearchTokenMetadataArgs {
155
+ chainID: string;
156
+ contractAddress: string;
157
+ filter: string;
158
+ page?: Page;
159
+ }
160
+ export interface SearchTokenMetadataReturn {
161
+ page: Page;
162
+ tokenMetadata: Array<TokenMetadata>;
163
+ }
164
+ export interface SearchTokenIDsArgs {
165
+ chainID: string;
166
+ contractAddress: string;
167
+ filter: string;
168
+ page?: Page;
169
+ }
170
+ export interface SearchTokenIDsReturn {
171
+ page: Page;
172
+ tokenIds: Array<string>;
173
+ }
174
+ export interface GetContractInfoArgs {
175
+ chainID: string;
176
+ contractAddress: string;
177
+ }
178
+ export interface GetContractInfoReturn {
179
+ contractInfo: ContractInfo;
180
+ }
181
+ export interface GetContractInfoBatchArgs {
182
+ chainID: string;
183
+ contractAddresses: Array<string>;
184
+ }
185
+ export interface GetContractInfoBatchReturn {
186
+ contractInfoMap: {
187
+ [key: string]: ContractInfo;
188
+ };
189
+ }
190
+ export interface SearchContractInfoArgs {
191
+ contractAddress: string;
192
+ }
193
+ export interface SearchContractInfoReturn {
194
+ contractInfoList: Array<ContractInfo>;
195
+ }
196
+ export interface SearchContractInfoBatchArgs {
197
+ contractAddresses: Array<string>;
198
+ }
199
+ export interface SearchContractInfoBatchReturn {
200
+ contractInfoByChain: {
201
+ [key: string]: Array<ContractInfo>;
202
+ };
203
+ }
204
+ export interface GetNiftyswapTokenQuantityArgs {
205
+ chainID: string;
206
+ contractAddress: string;
207
+ tokenIDs: Array<string>;
208
+ }
209
+ export interface GetNiftyswapTokenQuantityReturn {
210
+ quantity: {
211
+ [key: string]: string;
212
+ };
213
+ }
214
+ export interface GetNiftyswapUnitPricesArgs {
215
+ chainID: string;
216
+ contractAddress: string;
217
+ req: GetNiftyswapUnitPricesRequest;
218
+ }
219
+ export interface GetNiftyswapUnitPricesReturn {
220
+ prices: {
221
+ [key: string]: string;
222
+ };
223
+ }
224
+ export declare class Metadata implements Metadata {
225
+ protected hostname: string;
226
+ protected fetch: Fetch;
227
+ protected path: string;
228
+ constructor(hostname: string, fetch: Fetch);
229
+ private url;
230
+ ping: (headers?: object | undefined) => Promise<PingReturn>;
231
+ version: (headers?: object | undefined) => Promise<VersionReturn>;
232
+ runtimeStatus: (headers?: object | undefined) => Promise<RuntimeStatusReturn>;
233
+ getTokenMetadata: (args: GetTokenMetadataArgs, headers?: object | undefined) => Promise<GetTokenMetadataReturn>;
234
+ getTokenMetadataBatch: (args: GetTokenMetadataBatchArgs, headers?: object | undefined) => Promise<GetTokenMetadataBatchReturn>;
235
+ searchTokenMetadata: (args: SearchTokenMetadataArgs, headers?: object | undefined) => Promise<SearchTokenMetadataReturn>;
236
+ searchTokenIDs: (args: SearchTokenIDsArgs, headers?: object | undefined) => Promise<SearchTokenIDsReturn>;
237
+ getContractInfo: (args: GetContractInfoArgs, headers?: object | undefined) => Promise<GetContractInfoReturn>;
238
+ getContractInfoBatch: (args: GetContractInfoBatchArgs, headers?: object | undefined) => Promise<GetContractInfoBatchReturn>;
239
+ searchContractInfo: (args: SearchContractInfoArgs, headers?: object | undefined) => Promise<SearchContractInfoReturn>;
240
+ searchContractInfoBatch: (args: SearchContractInfoBatchArgs, headers?: object | undefined) => Promise<SearchContractInfoBatchReturn>;
241
+ getNiftyswapTokenQuantity: (args: GetNiftyswapTokenQuantityArgs, headers?: object | undefined) => Promise<GetNiftyswapTokenQuantityReturn>;
242
+ getNiftyswapUnitPrices: (args: GetNiftyswapUnitPricesArgs, headers?: object | undefined) => Promise<GetNiftyswapUnitPricesReturn>;
243
+ }
244
+ export interface WebRPCError extends Error {
245
+ code: string;
246
+ msg: string;
247
+ status: number;
248
+ }
249
+ export declare type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xsequence/metadata",
3
- "version": "0.0.0-20220412184039",
3
+ "version": "0.0.0-20220413180329",
4
4
  "description": "metadata sub-package for Sequence",
5
5
  "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/metadata",
6
6
  "source": "src/index.ts",