@solana-mobile/dapp-store-cli 0.15.0 → 0.16.1

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.
Files changed (105) hide show
  1. package/bin/dapp-store.js +3 -1
  2. package/lib/CliSetup.js +304 -505
  3. package/lib/CliUtils.js +6 -376
  4. package/lib/__tests__/CliSetupTest.js +484 -74
  5. package/lib/cli/__tests__/parseErrors.test.js +25 -0
  6. package/lib/cli/__tests__/signer.test.js +436 -0
  7. package/lib/cli/constants.js +23 -0
  8. package/lib/cli/messages.js +21 -0
  9. package/lib/cli/parseErrors.js +41 -0
  10. package/lib/{commands/publish/PublishCliSupport.js → cli/selfUpdate.js} +72 -38
  11. package/lib/{commands/publish/PublishCliRemove.js → cli/signer.js} +35 -56
  12. package/lib/index.js +96 -5
  13. package/lib/package.json +5 -24
  14. package/lib/portal/__tests__/releaseMetadata.test.js +647 -0
  15. package/lib/portal/__tests__/translators.test.js +76 -0
  16. package/lib/portal/__tests__/workflowClient.test.js +457 -0
  17. package/lib/portal/attestationClient.js +143 -0
  18. package/lib/portal/files.js +64 -0
  19. package/lib/portal/http.js +364 -0
  20. package/lib/portal/records.js +64 -0
  21. package/lib/portal/releaseMetadata.js +748 -0
  22. package/lib/portal/translators.js +460 -0
  23. package/lib/portal/types.js +1 -0
  24. package/lib/portal/workflowClient.js +704 -0
  25. package/lib/publication/PublicationProgressReporter.js +1051 -0
  26. package/lib/publication/__tests__/PublicationProgressReporter.test.js +174 -0
  27. package/lib/{commands/ValidateCommand.js → publication/__tests__/fundingPreflight.test.js} +90 -66
  28. package/lib/publication/__tests__/publicationSummary.test.js +26 -0
  29. package/lib/publication/cliValidation.js +482 -0
  30. package/lib/publication/fundingPreflight.js +246 -0
  31. package/lib/publication/publicationSummary.js +99 -0
  32. package/lib/{commands/utils.js → publication/runPublicationWorkflow.js} +16 -46
  33. package/package.json +5 -24
  34. package/src/CliSetup.ts +370 -505
  35. package/src/CliUtils.ts +9 -233
  36. package/src/__tests__/CliSetupTest.ts +272 -120
  37. package/src/cli/__tests__/parseErrors.test.ts +34 -0
  38. package/src/cli/__tests__/signer.test.ts +359 -0
  39. package/src/cli/constants.ts +3 -0
  40. package/src/cli/messages.ts +27 -0
  41. package/src/cli/parseErrors.ts +62 -0
  42. package/src/cli/selfUpdate.ts +59 -0
  43. package/src/cli/signer.ts +38 -0
  44. package/src/index.ts +31 -4
  45. package/src/portal/__tests__/releaseMetadata.test.ts +508 -0
  46. package/src/portal/__tests__/translators.test.ts +82 -0
  47. package/src/portal/__tests__/workflowClient.test.ts +278 -0
  48. package/src/portal/attestationClient.ts +19 -0
  49. package/src/portal/files.ts +73 -0
  50. package/src/portal/http.ts +170 -0
  51. package/src/portal/records.ts +38 -0
  52. package/src/portal/releaseMetadata.ts +489 -0
  53. package/src/portal/translators.ts +750 -0
  54. package/src/portal/types.ts +27 -0
  55. package/src/portal/workflowClient.ts +575 -0
  56. package/src/publication/PublicationProgressReporter.ts +1026 -0
  57. package/src/publication/__tests__/PublicationProgressReporter.test.ts +210 -0
  58. package/src/publication/__tests__/fundingPreflight.test.ts +78 -0
  59. package/src/publication/__tests__/publicationSummary.test.ts +30 -0
  60. package/src/publication/cliValidation.ts +264 -0
  61. package/src/publication/fundingPreflight.ts +123 -0
  62. package/src/publication/publicationSummary.ts +26 -0
  63. package/src/publication/runPublicationWorkflow.ts +46 -0
  64. package/lib/commands/create/CreateCliApp.js +0 -223
  65. package/lib/commands/create/CreateCliRelease.js +0 -290
  66. package/lib/commands/create/index.js +0 -40
  67. package/lib/commands/index.js +0 -3
  68. package/lib/commands/publish/PublishCliSubmit.js +0 -208
  69. package/lib/commands/publish/PublishCliUpdate.js +0 -211
  70. package/lib/commands/publish/index.js +0 -22
  71. package/lib/commands/scaffolding/ScaffoldInit.js +0 -15
  72. package/lib/commands/scaffolding/index.js +0 -1
  73. package/lib/config/EnvVariables.js +0 -59
  74. package/lib/config/PublishDetails.js +0 -915
  75. package/lib/config/S3StorageManager.js +0 -93
  76. package/lib/config/index.js +0 -2
  77. package/lib/generated/config_obj.json +0 -1
  78. package/lib/generated/config_schema.json +0 -1
  79. package/lib/prebuild_schema/publishing_source.yaml +0 -64
  80. package/lib/prebuild_schema/schemagen.js +0 -25
  81. package/lib/upload/CachedStorageDriver.js +0 -293
  82. package/lib/upload/TurboStorageDriver.js +0 -718
  83. package/lib/upload/index.js +0 -2
  84. package/src/commands/ValidateCommand.ts +0 -82
  85. package/src/commands/create/CreateCliApp.ts +0 -93
  86. package/src/commands/create/CreateCliRelease.ts +0 -149
  87. package/src/commands/create/index.ts +0 -47
  88. package/src/commands/index.ts +0 -3
  89. package/src/commands/publish/PublishCliRemove.ts +0 -66
  90. package/src/commands/publish/PublishCliSubmit.ts +0 -93
  91. package/src/commands/publish/PublishCliSupport.ts +0 -66
  92. package/src/commands/publish/PublishCliUpdate.ts +0 -101
  93. package/src/commands/publish/index.ts +0 -29
  94. package/src/commands/scaffolding/ScaffoldInit.ts +0 -20
  95. package/src/commands/scaffolding/index.ts +0 -1
  96. package/src/commands/utils.ts +0 -33
  97. package/src/config/EnvVariables.ts +0 -39
  98. package/src/config/PublishDetails.ts +0 -456
  99. package/src/config/S3StorageManager.ts +0 -47
  100. package/src/config/index.ts +0 -2
  101. package/src/prebuild_schema/publishing_source.yaml +0 -64
  102. package/src/prebuild_schema/schemagen.js +0 -31
  103. package/src/upload/CachedStorageDriver.ts +0 -99
  104. package/src/upload/TurboStorageDriver.ts +0 -277
  105. package/src/upload/index.ts +0 -2
package/lib/CliUtils.js CHANGED
@@ -1,376 +1,6 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _async_to_generator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _class_call_check(instance, Constructor) {
31
- if (!(instance instanceof Constructor)) {
32
- throw new TypeError("Cannot call a class as a function");
33
- }
34
- }
35
- function _define_property(obj, key, value) {
36
- if (key in obj) {
37
- Object.defineProperty(obj, key, {
38
- value: value,
39
- enumerable: true,
40
- configurable: true,
41
- writable: true
42
- });
43
- } else {
44
- obj[key] = value;
45
- }
46
- return obj;
47
- }
48
- function _ts_generator(thisArg, body) {
49
- var f, y, t, _ = {
50
- label: 0,
51
- sent: function() {
52
- if (t[0] & 1) throw t[1];
53
- return t[1];
54
- },
55
- trys: [],
56
- ops: []
57
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
58
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
59
- return this;
60
- }), g;
61
- function verb(n) {
62
- return function(v) {
63
- return step([
64
- n,
65
- v
66
- ]);
67
- };
68
- }
69
- function step(op) {
70
- if (f) throw new TypeError("Generator is already executing.");
71
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
72
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
73
- if (y = 0, t) op = [
74
- op[0] & 2,
75
- t.value
76
- ];
77
- switch(op[0]){
78
- case 0:
79
- case 1:
80
- t = op;
81
- break;
82
- case 4:
83
- _.label++;
84
- return {
85
- value: op[1],
86
- done: false
87
- };
88
- case 5:
89
- _.label++;
90
- y = op[1];
91
- op = [
92
- 0
93
- ];
94
- continue;
95
- case 7:
96
- op = _.ops.pop();
97
- _.trys.pop();
98
- continue;
99
- default:
100
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
101
- _ = 0;
102
- continue;
103
- }
104
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
105
- _.label = op[1];
106
- break;
107
- }
108
- if (op[0] === 6 && _.label < t[1]) {
109
- _.label = t[1];
110
- t = op;
111
- break;
112
- }
113
- if (t && _.label < t[2]) {
114
- _.label = t[2];
115
- _.ops.push(op);
116
- break;
117
- }
118
- if (t[2]) _.ops.pop();
119
- _.trys.pop();
120
- continue;
121
- }
122
- op = body.call(thisArg, _);
123
- } catch (e) {
124
- op = [
125
- 6,
126
- e
127
- ];
128
- y = 0;
129
- } finally{
130
- f = t = 0;
131
- }
132
- if (op[0] & 5) throw op[1];
133
- return {
134
- value: op[0] ? op[1] : void 0,
135
- done: true
136
- };
137
- }
138
- }
139
- import fs from "fs";
140
- import { Keypair, PublicKey } from "@solana/web3.js";
141
- import debugModule from "debug";
142
- import { keypairIdentity, Metaplex, lamports } from "@metaplex-foundation/js";
143
- import updateNotifier from "update-notifier";
144
- import { readFile } from 'fs/promises';
145
- var cliPackage = JSON.parse((await readFile(new URL("./package.json", import.meta.url))).toString());
146
- import boxen from "boxen";
147
- import ver from "semver";
148
- import path from "path";
149
- import { CachedStorageDriver } from "./upload/CachedStorageDriver.js";
150
- import { TurboStorageDriver } from "./upload/TurboStorageDriver.js";
151
- import { EnvVariables } from "./config/index.js";
152
- import { S3Client } from "@aws-sdk/client-s3";
153
- import { awsStorage } from "@metaplex-foundation/js-plugin-aws";
154
- import { S3StorageManager } from "./config/index.js";
155
- export var Constants = function Constants() {
156
- "use strict";
157
- _class_call_check(this, Constants);
158
- };
159
- _define_property(Constants, "CLI_VERSION", "0.15.0");
160
- _define_property(Constants, "CONFIG_FILE_NAME", "config.yaml");
161
- _define_property(Constants, "DEFAULT_RPC_DEVNET", "https://api.devnet.solana.com");
162
- _define_property(Constants, "DEFAULT_PRIORITY_FEE", 500000);
163
- _define_property(Constants, "getConfigFilePath", function() {
164
- return path.join(process.cwd(), Constants.CONFIG_FILE_NAME);
165
- });
166
- export var debug = debugModule("CLI");
167
- export var checkForSelfUpdate = function() {
168
- return _async_to_generator(function() {
169
- var notifier, updateInfo, latestVer, currentVer;
170
- return _ts_generator(this, function(_state) {
171
- switch(_state.label){
172
- case 0:
173
- notifier = updateNotifier({
174
- pkg: cliPackage
175
- });
176
- return [
177
- 4,
178
- notifier.fetchInfo()
179
- ];
180
- case 1:
181
- updateInfo = _state.sent();
182
- latestVer = new ver.SemVer(updateInfo.latest);
183
- currentVer = new ver.SemVer(updateInfo.current);
184
- if (latestVer.major > currentVer.major || latestVer.minor > currentVer.minor) {
185
- throw new Error("Please update to the latest version of the dApp Store CLI before proceeding.\nCurrent version is ".concat(currentVer.raw, "\nLatest version is ").concat(latestVer.raw));
186
- }
187
- return [
188
- 2
189
- ];
190
- }
191
- });
192
- })();
193
- };
194
- export var checkMintedStatus = function(conn, appAddr, releaseAddr) {
195
- return _async_to_generator(function() {
196
- var i, _results_, _results_1, results, isAppMinted, isReleaseMinted, errorMessage;
197
- return _ts_generator(this, function(_state) {
198
- switch(_state.label){
199
- case 0:
200
- i = 0;
201
- _state.label = 1;
202
- case 1:
203
- if (!(i < 5)) return [
204
- 3,
205
- 4
206
- ];
207
- return [
208
- 4,
209
- conn.getMultipleAccountsInfo([
210
- new PublicKey(appAddr),
211
- new PublicKey(releaseAddr)
212
- ])
213
- ];
214
- case 2:
215
- results = _state.sent();
216
- isAppMinted = results[0] != undefined && ((_results_ = results[0]) === null || _results_ === void 0 ? void 0 : _results_.lamports) > 0;
217
- isReleaseMinted = results[1] != undefined && ((_results_1 = results[1]) === null || _results_1 === void 0 ? void 0 : _results_1.lamports) > 0;
218
- if (isAppMinted && isReleaseMinted) {
219
- return [
220
- 2
221
- ];
222
- } else {
223
- errorMessage = "";
224
- if (!isAppMinted) {
225
- errorMessage = errorMessage + "App NFT fetch at address ".concat(appAddr, " failed.\n");
226
- }
227
- if (!isReleaseMinted) {
228
- errorMessage = errorMessage + "Release NFT fetch at address ".concat(releaseAddr, " failed.\n");
229
- }
230
- if (i == 4) {
231
- throw new Error("Expected App :: ".concat(appAddr, " and Release :: ").concat(releaseAddr, " to be minted before submission.\n\n but ").concat(errorMessage, "\n\n Please ensure you have minted all of your NFTs before submitting to the Solana Mobile dApp publisher portal."));
232
- } else {
233
- sleep(2000);
234
- }
235
- }
236
- _state.label = 3;
237
- case 3:
238
- i++;
239
- return [
240
- 3,
241
- 1
242
- ];
243
- case 4:
244
- return [
245
- 2
246
- ];
247
- }
248
- });
249
- })();
250
- };
251
- export var sleep = function(ms) {
252
- return new Promise(function(resolve) {
253
- return setTimeout(resolve, ms);
254
- });
255
- };
256
- export var parseKeypair = function(pathToKeypairFile) {
257
- try {
258
- var keypairFile = fs.readFileSync(pathToKeypairFile, "utf-8");
259
- return Keypair.fromSecretKey(Buffer.from(JSON.parse(keypairFile)));
260
- } catch (e) {
261
- showMessage("KeyPair Error", "Something went wrong when attempting to retrieve the keypair at " + pathToKeypairFile, "error");
262
- }
263
- };
264
- export var isDevnet = function(rpcUrl) {
265
- return rpcUrl.indexOf("devnet") != -1;
266
- };
267
- export var isTestnet = function(rpcUrl) {
268
- return rpcUrl.indexOf("testnet") != -1;
269
- };
270
- export var checkSubmissionNetwork = function(rpcUrl) {
271
- if (isDevnet(rpcUrl) || isTestnet(rpcUrl)) {
272
- throw new Error("It looks like you are attempting to submit a request with a devnet or testnet RPC endpoint. Please ensure that your NFTs are minted on mainnet beta, and re-run with a mainnet beta RPC endpoint.");
273
- }
274
- };
275
- export var generateNetworkSuffix = function(rpcUrl) {
276
- var suffix = "";
277
- if (isDevnet(rpcUrl)) {
278
- suffix = "?cluster=devnet";
279
- } else if (isTestnet(rpcUrl)) {
280
- suffix = "?cluster=testnet";
281
- } else {
282
- suffix = "?cluster=mainnet";
283
- }
284
- return suffix;
285
- };
286
- export var dryRunSuccessMessage = function() {
287
- showMessage("Dry run", "Dry run was successful", "standard");
288
- };
289
- export var alphaAppSubmissionMessage = function() {
290
- showMessage("Alpha release", "Alpha releases are not reviewed on dApp store and are meant for internal testing only.\n" + "Run the `npx dapp-store publish submit ...` command again without the `--alpha` param to publish the app", "warning");
291
- };
292
- export var showNetworkWarningIfApplicable = function(rpcUrl) {
293
- if (isDevnet(rpcUrl)) {
294
- showMessage("Devnet Mode", "Running on Devnet", "warning");
295
- } else if (isTestnet(rpcUrl)) {
296
- showMessage("Testnet Mode", "Running on Testnet", "warning");
297
- }
298
- };
299
- export var showMessage = function() {
300
- var titleMessage = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", contentMessage = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "standard";
301
- var color = "cyan";
302
- if (type == "error") {
303
- color = "redBright";
304
- } else if (type == "warning") {
305
- color = "yellow";
306
- }
307
- var msg = boxen(contentMessage, {
308
- title: titleMessage,
309
- padding: 1,
310
- margin: 1,
311
- borderStyle: "single",
312
- borderColor: color,
313
- textAlignment: "left",
314
- titleAlignment: "center"
315
- });
316
- console.log(msg);
317
- return msg;
318
- };
319
- export var getMetaplexInstance = function(connection, keypair) {
320
- var storageParams = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
321
- var metaplex = Metaplex.make(connection).use(keypairIdentity(keypair));
322
- var isDevnet = connection.rpcEndpoint.includes("devnet");
323
- //TODO: Use DI for this
324
- var s3Mgr = new S3StorageManager(new EnvVariables());
325
- s3Mgr.parseCmdArg(storageParams);
326
- if (s3Mgr.hasS3Config) {
327
- var awsClient = new S3Client({
328
- region: s3Mgr.s3Config.regionName,
329
- credentials: {
330
- accessKeyId: s3Mgr.s3Config.accessKey,
331
- secretAccessKey: s3Mgr.s3Config.secretKey
332
- }
333
- });
334
- var bucketPlugin = awsStorage(awsClient, s3Mgr.s3Config.bucketName);
335
- metaplex.use(bucketPlugin);
336
- } else {
337
- var turboDriver = new TurboStorageDriver(keypair, isDevnet ? "devnet" : "mainnet", Number(process.env.TURBO_BUFFER_PERCENTAGE || 20));
338
- var metaplexAdapter = {
339
- upload: function upload(file) {
340
- return _async_to_generator(function() {
341
- return _ts_generator(this, function(_state) {
342
- return [
343
- 2,
344
- turboDriver.upload(file)
345
- ];
346
- });
347
- })();
348
- },
349
- getUploadPrice: function getUploadPrice(bytes) {
350
- return _async_to_generator(function() {
351
- var price;
352
- return _ts_generator(this, function(_state) {
353
- switch(_state.label){
354
- case 0:
355
- return [
356
- 4,
357
- turboDriver.getUploadPrice(bytes)
358
- ];
359
- case 1:
360
- price = _state.sent();
361
- return [
362
- 2,
363
- lamports(price)
364
- ];
365
- }
366
- });
367
- })();
368
- }
369
- };
370
- metaplex.storage().setDriver(metaplexAdapter);
371
- }
372
- metaplex.storage().setDriver(new CachedStorageDriver(metaplex.storage().driver(), {
373
- assetManifestPath: isDevnet ? "./.asset-manifest-devnet.json" : "./.asset-manifest.json"
374
- }));
375
- return metaplex;
376
- };
1
+ export { Constants } from "./cli/constants.js";
2
+ export { showMessage } from "./cli/messages.js";
3
+ export { checkForSelfUpdate } from "./cli/selfUpdate.js";
4
+ export { createPublicationSignerFromKeypair, parseKeypair } from "./cli/signer.js";
5
+ export { createPortalAttestationClient } from "./portal/attestationClient.js";
6
+ export { createPortalWorkflowClient } from "./portal/workflowClient.js";