@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
@@ -0,0 +1,436 @@
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 _ts_generator(thisArg, body) {
31
+ var f, y, t, _ = {
32
+ label: 0,
33
+ sent: function() {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
39
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
40
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
41
+ return this;
42
+ }), g;
43
+ function verb(n) {
44
+ return function(v) {
45
+ return step([
46
+ n,
47
+ v
48
+ ]);
49
+ };
50
+ }
51
+ function step(op) {
52
+ if (f) throw new TypeError("Generator is already executing.");
53
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
54
+ 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;
55
+ if (y = 0, t) op = [
56
+ op[0] & 2,
57
+ t.value
58
+ ];
59
+ switch(op[0]){
60
+ case 0:
61
+ case 1:
62
+ t = op;
63
+ break;
64
+ case 4:
65
+ _.label++;
66
+ return {
67
+ value: op[1],
68
+ done: false
69
+ };
70
+ case 5:
71
+ _.label++;
72
+ y = op[1];
73
+ op = [
74
+ 0
75
+ ];
76
+ continue;
77
+ case 7:
78
+ op = _.ops.pop();
79
+ _.trys.pop();
80
+ continue;
81
+ default:
82
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
+ _ = 0;
84
+ continue;
85
+ }
86
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
+ _.label = op[1];
88
+ break;
89
+ }
90
+ if (op[0] === 6 && _.label < t[1]) {
91
+ _.label = t[1];
92
+ t = op;
93
+ break;
94
+ }
95
+ if (t && _.label < t[2]) {
96
+ _.label = t[2];
97
+ _.ops.push(op);
98
+ break;
99
+ }
100
+ if (t[2]) _.ops.pop();
101
+ _.trys.pop();
102
+ continue;
103
+ }
104
+ op = body.call(thisArg, _);
105
+ } catch (e) {
106
+ op = [
107
+ 6,
108
+ e
109
+ ];
110
+ y = 0;
111
+ } finally{
112
+ f = t = 0;
113
+ }
114
+ if (op[0] & 5) throw op[1];
115
+ return {
116
+ value: op[0] ? op[1] : void 0,
117
+ done: true
118
+ };
119
+ }
120
+ }
121
+ import fs from "node:fs";
122
+ import os from "node:os";
123
+ import path from "node:path";
124
+ import { afterEach, expect, jest, test } from "@jest/globals";
125
+ import { createCreateInstruction, createVerifyInstruction, VerificationArgs } from "@metaplex-foundation/mpl-token-metadata";
126
+ import { ComputeBudgetProgram, Keypair, PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, Transaction, TransactionInstruction } from "@solana/web3.js";
127
+ import { signSerializedTransaction } from "../../../../core/src/portal/signer.js";
128
+ import { createPublicationSignerFromKeypair, parseKeypair } from "../signer.js";
129
+ var tempDirs = [];
130
+ var TOKEN_METADATA_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
131
+ var TOKEN_METADATA_SEED = Buffer.from("metadata");
132
+ var TOKEN_METADATA_EDITION_SEED = Buffer.from("edition");
133
+ afterEach(function() {
134
+ while(tempDirs.length > 0){
135
+ fs.rmSync(tempDirs.pop(), {
136
+ recursive: true,
137
+ force: true
138
+ });
139
+ }
140
+ });
141
+ function createReleaseMintTransaction(options) {
142
+ var _options_signer;
143
+ var signer = (_options_signer = options === null || options === void 0 ? void 0 : options.signer) !== null && _options_signer !== void 0 ? _options_signer : Keypair.generate();
144
+ var _options_mint;
145
+ var mint = (_options_mint = options === null || options === void 0 ? void 0 : options.mint) !== null && _options_mint !== void 0 ? _options_mint : Keypair.generate();
146
+ var _options_appMintAddress;
147
+ var appMintAddress = (_options_appMintAddress = options === null || options === void 0 ? void 0 : options.appMintAddress) !== null && _options_appMintAddress !== void 0 ? _options_appMintAddress : Keypair.generate().publicKey;
148
+ var transaction = new Transaction();
149
+ transaction.feePayer = signer.publicKey;
150
+ transaction.recentBlockhash = Keypair.generate().publicKey.toBase58();
151
+ transaction.add(ComputeBudgetProgram.setComputeUnitLimit({
152
+ units: 500000
153
+ }));
154
+ transaction.add(function() {
155
+ var instruction = createCreateInstruction({
156
+ metadata: Keypair.generate().publicKey,
157
+ masterEdition: Keypair.generate().publicKey,
158
+ mint: mint.publicKey,
159
+ authority: signer.publicKey,
160
+ payer: signer.publicKey,
161
+ updateAuthority: signer.publicKey,
162
+ sysvarInstructions: Keypair.generate().publicKey,
163
+ splTokenProgram: Keypair.generate().publicKey
164
+ }, {
165
+ createArgs: {
166
+ __kind: "V1",
167
+ assetData: {
168
+ name: "Example release",
169
+ symbol: "",
170
+ uri: "https://example.com/release.json",
171
+ sellerFeeBasisPoints: 0,
172
+ creators: null,
173
+ primarySaleHappened: false,
174
+ isMutable: false,
175
+ tokenStandard: 0,
176
+ collection: {
177
+ verified: false,
178
+ key: appMintAddress
179
+ },
180
+ uses: null,
181
+ collectionDetails: null,
182
+ ruleSet: null
183
+ },
184
+ decimals: null,
185
+ printSupply: null
186
+ }
187
+ });
188
+ instruction.keys[2].isSigner = true;
189
+ instruction.keys[5].isSigner = true;
190
+ return instruction;
191
+ }());
192
+ if (options === null || options === void 0 ? void 0 : options.addUnexpectedProgram) {
193
+ transaction.add(SystemProgram.transfer({
194
+ fromPubkey: signer.publicKey,
195
+ toPubkey: Keypair.generate().publicKey,
196
+ lamports: 1
197
+ }));
198
+ }
199
+ transaction.partialSign(mint);
200
+ if (options === null || options === void 0 ? void 0 : options.tamperAfterMintSignature) {
201
+ transaction.instructions[1] = new TransactionInstruction({
202
+ programId: TOKEN_METADATA_PROGRAM_ID,
203
+ keys: transaction.instructions[1].keys,
204
+ data: Buffer.from([
205
+ 9,
206
+ 9,
207
+ 9
208
+ ])
209
+ });
210
+ }
211
+ return {
212
+ signer: signer,
213
+ mint: mint,
214
+ appMintAddress: appMintAddress,
215
+ blockhash: transaction.recentBlockhash,
216
+ serialized: transaction.serialize({
217
+ requireAllSignatures: false,
218
+ verifySignatures: false
219
+ }).toString("base64")
220
+ };
221
+ }
222
+ function getMetadataPda(mintAddress) {
223
+ return PublicKey.findProgramAddressSync([
224
+ TOKEN_METADATA_SEED,
225
+ TOKEN_METADATA_PROGRAM_ID.toBuffer(),
226
+ mintAddress.toBuffer()
227
+ ], TOKEN_METADATA_PROGRAM_ID)[0];
228
+ }
229
+ function getMasterEditionPda(mintAddress) {
230
+ return PublicKey.findProgramAddressSync([
231
+ TOKEN_METADATA_SEED,
232
+ TOKEN_METADATA_PROGRAM_ID.toBuffer(),
233
+ mintAddress.toBuffer(),
234
+ TOKEN_METADATA_EDITION_SEED
235
+ ], TOKEN_METADATA_PROGRAM_ID)[0];
236
+ }
237
+ function createVerifyCollectionTransaction(options) {
238
+ var _options_signer;
239
+ var signer = (_options_signer = options === null || options === void 0 ? void 0 : options.signer) !== null && _options_signer !== void 0 ? _options_signer : Keypair.generate();
240
+ var _options_nftMintAddress;
241
+ var nftMintAddress = (_options_nftMintAddress = options === null || options === void 0 ? void 0 : options.nftMintAddress) !== null && _options_nftMintAddress !== void 0 ? _options_nftMintAddress : Keypair.generate().publicKey;
242
+ var _options_collectionMintAddress;
243
+ var collectionMintAddress = (_options_collectionMintAddress = options === null || options === void 0 ? void 0 : options.collectionMintAddress) !== null && _options_collectionMintAddress !== void 0 ? _options_collectionMintAddress : Keypair.generate().publicKey;
244
+ var transaction = new Transaction();
245
+ transaction.feePayer = signer.publicKey;
246
+ transaction.recentBlockhash = Keypair.generate().publicKey.toBase58();
247
+ transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
248
+ microLamports: 1000
249
+ }));
250
+ transaction.add(createVerifyInstruction({
251
+ authority: signer.publicKey,
252
+ metadata: getMetadataPda(nftMintAddress),
253
+ collectionMint: collectionMintAddress,
254
+ collectionMetadata: getMetadataPda(collectionMintAddress),
255
+ collectionMasterEdition: getMasterEditionPda(collectionMintAddress),
256
+ systemProgram: SystemProgram.programId,
257
+ sysvarInstructions: SYSVAR_INSTRUCTIONS_PUBKEY
258
+ }, {
259
+ verificationArgs: VerificationArgs.CollectionV1
260
+ }));
261
+ return {
262
+ signer: signer,
263
+ nftMintAddress: nftMintAddress,
264
+ collectionMintAddress: collectionMintAddress,
265
+ blockhash: transaction.recentBlockhash,
266
+ serialized: transaction.serialize({
267
+ requireAllSignatures: false,
268
+ verifySignatures: false
269
+ }).toString("base64")
270
+ };
271
+ }
272
+ test("parseKeypair loads a Solana keypair from a JSON array file", function() {
273
+ var keypair = Keypair.generate();
274
+ var tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "dapp-store-signer-"));
275
+ var keypairPath = path.join(tempDir, "signer.json");
276
+ tempDirs.push(tempDir);
277
+ fs.writeFileSync(keypairPath, JSON.stringify(Array.from(keypair.secretKey)));
278
+ var parsedKeypair = parseKeypair(keypairPath);
279
+ expect(parsedKeypair === null || parsedKeypair === void 0 ? void 0 : parsedKeypair.publicKey.toBase58()).toBe(keypair.publicKey.toBase58());
280
+ });
281
+ test("parseKeypair returns undefined and logs an error when the file is missing", function() {
282
+ var logSpy = jest.spyOn(console, "log").mockImplementation(function() {});
283
+ try {
284
+ expect(parseKeypair("/tmp/does-not-exist.json")).toBeUndefined();
285
+ expect(logSpy).toHaveBeenCalled();
286
+ } finally{
287
+ logSpy.mockRestore();
288
+ }
289
+ });
290
+ test("signSerializedTransaction signs a validated release mint transaction", function() {
291
+ return _async_to_generator(function() {
292
+ var _createReleaseMintTransaction, signer, mint, appMintAddress, blockhash, serialized, accountAddresses, signedTransaction;
293
+ return _ts_generator(this, function(_state) {
294
+ switch(_state.label){
295
+ case 0:
296
+ _createReleaseMintTransaction = createReleaseMintTransaction(), signer = _createReleaseMintTransaction.signer, mint = _createReleaseMintTransaction.mint, appMintAddress = _createReleaseMintTransaction.appMintAddress, blockhash = _createReleaseMintTransaction.blockhash, serialized = _createReleaseMintTransaction.serialized;
297
+ accountAddresses = Transaction.from(Buffer.from(serialized, "base64")).compileMessage().accountKeys.map(function(key) {
298
+ return key.toBase58();
299
+ });
300
+ expect(accountAddresses).not.toContain(appMintAddress.toBase58());
301
+ return [
302
+ 4,
303
+ signSerializedTransaction(createPublicationSignerFromKeypair(signer), serialized, {
304
+ kind: "release-mint",
305
+ expectedBlockhash: blockhash,
306
+ expectedFeePayerAddress: signer.publicKey.toBase58(),
307
+ expectedSignerAddress: signer.publicKey.toBase58(),
308
+ expectedMintAddress: mint.publicKey.toBase58(),
309
+ expectedAppMintAddress: appMintAddress.toBase58()
310
+ })
311
+ ];
312
+ case 1:
313
+ signedTransaction = _state.sent();
314
+ expect(Transaction.from(Buffer.from(signedTransaction, "base64")).verifySignatures()).toBe(true);
315
+ return [
316
+ 2
317
+ ];
318
+ }
319
+ });
320
+ })();
321
+ });
322
+ test("signSerializedTransaction rejects release mint transactions with unexpected programs", function() {
323
+ return _async_to_generator(function() {
324
+ var _createReleaseMintTransaction, signer, mint, appMintAddress, blockhash, serialized;
325
+ return _ts_generator(this, function(_state) {
326
+ switch(_state.label){
327
+ case 0:
328
+ _createReleaseMintTransaction = createReleaseMintTransaction({
329
+ addUnexpectedProgram: true
330
+ }), signer = _createReleaseMintTransaction.signer, mint = _createReleaseMintTransaction.mint, appMintAddress = _createReleaseMintTransaction.appMintAddress, blockhash = _createReleaseMintTransaction.blockhash, serialized = _createReleaseMintTransaction.serialized;
331
+ return [
332
+ 4,
333
+ expect(signSerializedTransaction(createPublicationSignerFromKeypair(signer), serialized, {
334
+ kind: "release-mint",
335
+ expectedBlockhash: blockhash,
336
+ expectedFeePayerAddress: signer.publicKey.toBase58(),
337
+ expectedSignerAddress: signer.publicKey.toBase58(),
338
+ expectedMintAddress: mint.publicKey.toBase58(),
339
+ expectedAppMintAddress: appMintAddress.toBase58()
340
+ })).rejects.toThrow("unexpected program ids")
341
+ ];
342
+ case 1:
343
+ _state.sent();
344
+ return [
345
+ 2
346
+ ];
347
+ }
348
+ });
349
+ })();
350
+ });
351
+ test("signSerializedTransaction rejects release mint transactions with invalid pre-existing signatures", function() {
352
+ return _async_to_generator(function() {
353
+ var _createReleaseMintTransaction, signer, mint, appMintAddress, blockhash, serialized;
354
+ return _ts_generator(this, function(_state) {
355
+ switch(_state.label){
356
+ case 0:
357
+ _createReleaseMintTransaction = createReleaseMintTransaction({
358
+ tamperAfterMintSignature: true
359
+ }), signer = _createReleaseMintTransaction.signer, mint = _createReleaseMintTransaction.mint, appMintAddress = _createReleaseMintTransaction.appMintAddress, blockhash = _createReleaseMintTransaction.blockhash, serialized = _createReleaseMintTransaction.serialized;
360
+ return [
361
+ 4,
362
+ expect(signSerializedTransaction(createPublicationSignerFromKeypair(signer), serialized, {
363
+ kind: "release-mint",
364
+ expectedBlockhash: blockhash,
365
+ expectedFeePayerAddress: signer.publicKey.toBase58(),
366
+ expectedSignerAddress: signer.publicKey.toBase58(),
367
+ expectedMintAddress: mint.publicKey.toBase58(),
368
+ expectedAppMintAddress: appMintAddress.toBase58()
369
+ })).rejects.toThrow("invalid existing signatures")
370
+ ];
371
+ case 1:
372
+ _state.sent();
373
+ return [
374
+ 2
375
+ ];
376
+ }
377
+ });
378
+ })();
379
+ });
380
+ test("signSerializedTransaction rejects release mint transactions with a mismatched collection encoded in metadata", function() {
381
+ return _async_to_generator(function() {
382
+ var _createReleaseMintTransaction, signer, mint, blockhash, serialized, unexpectedAppMintAddress;
383
+ return _ts_generator(this, function(_state) {
384
+ switch(_state.label){
385
+ case 0:
386
+ _createReleaseMintTransaction = createReleaseMintTransaction(), signer = _createReleaseMintTransaction.signer, mint = _createReleaseMintTransaction.mint, blockhash = _createReleaseMintTransaction.blockhash, serialized = _createReleaseMintTransaction.serialized;
387
+ unexpectedAppMintAddress = Keypair.generate().publicKey;
388
+ return [
389
+ 4,
390
+ expect(signSerializedTransaction(createPublicationSignerFromKeypair(signer), serialized, {
391
+ kind: "release-mint",
392
+ expectedBlockhash: blockhash,
393
+ expectedFeePayerAddress: signer.publicKey.toBase58(),
394
+ expectedSignerAddress: signer.publicKey.toBase58(),
395
+ expectedMintAddress: mint.publicKey.toBase58(),
396
+ expectedAppMintAddress: unexpectedAppMintAddress.toBase58()
397
+ })).rejects.toThrow("collection mismatch")
398
+ ];
399
+ case 1:
400
+ _state.sent();
401
+ return [
402
+ 2
403
+ ];
404
+ }
405
+ });
406
+ })();
407
+ });
408
+ test("signSerializedTransaction signs a validated collection verification transaction", function() {
409
+ return _async_to_generator(function() {
410
+ var _createVerifyCollectionTransaction, signer, nftMintAddress, collectionMintAddress, blockhash, serialized, signedTransaction;
411
+ return _ts_generator(this, function(_state) {
412
+ switch(_state.label){
413
+ case 0:
414
+ _createVerifyCollectionTransaction = createVerifyCollectionTransaction(), signer = _createVerifyCollectionTransaction.signer, nftMintAddress = _createVerifyCollectionTransaction.nftMintAddress, collectionMintAddress = _createVerifyCollectionTransaction.collectionMintAddress, blockhash = _createVerifyCollectionTransaction.blockhash, serialized = _createVerifyCollectionTransaction.serialized;
415
+ return [
416
+ 4,
417
+ signSerializedTransaction(createPublicationSignerFromKeypair(signer), serialized, {
418
+ kind: "verify-collection",
419
+ expectedBlockhash: blockhash,
420
+ expectedFeePayerAddress: signer.publicKey.toBase58(),
421
+ expectedSignerAddress: signer.publicKey.toBase58(),
422
+ expectedNftMintAddress: nftMintAddress.toBase58(),
423
+ expectedCollectionMintAddress: collectionMintAddress.toBase58(),
424
+ expectedCollectionAuthority: signer.publicKey.toBase58()
425
+ })
426
+ ];
427
+ case 1:
428
+ signedTransaction = _state.sent();
429
+ expect(Transaction.from(Buffer.from(signedTransaction, "base64")).verifySignatures()).toBe(true);
430
+ return [
431
+ 2
432
+ ];
433
+ }
434
+ });
435
+ })();
436
+ });
@@ -0,0 +1,23 @@
1
+ function _class_call_check(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _define_property(obj, key, value) {
7
+ if (key in obj) {
8
+ Object.defineProperty(obj, key, {
9
+ value: value,
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true
13
+ });
14
+ } else {
15
+ obj[key] = value;
16
+ }
17
+ return obj;
18
+ }
19
+ export var Constants = function Constants() {
20
+ "use strict";
21
+ _class_call_check(this, Constants);
22
+ };
23
+ _define_property(Constants, "CLI_VERSION", '0.16.1');
@@ -0,0 +1,21 @@
1
+ import boxen from 'boxen';
2
+ export var showMessage = function() {
3
+ 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';
4
+ var color = 'cyan';
5
+ if (type === 'error') {
6
+ color = 'redBright';
7
+ } else if (type === 'warning') {
8
+ color = 'yellow';
9
+ }
10
+ var message = boxen(contentMessage, {
11
+ title: titleMessage,
12
+ padding: 1,
13
+ margin: 1,
14
+ borderStyle: 'single',
15
+ borderColor: color,
16
+ textAlignment: 'left',
17
+ titleAlignment: 'center'
18
+ });
19
+ console.log(message);
20
+ return message;
21
+ };
@@ -0,0 +1,41 @@
1
+ function _type_of(obj) {
2
+ "@swc/helpers - typeof";
3
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4
+ }
5
+ import { formatUpdatedCliUsageError } from "../publication/cliValidation.js";
6
+ var COMMANDER_EXIT_CODES_TO_IGNORE = new Set([
7
+ "commander.help",
8
+ "commander.helpDisplayed",
9
+ "commander.version"
10
+ ]);
11
+ var UPDATED_DOCS_PARSE_ERROR_CODES = new Set([
12
+ "commander.excessArguments",
13
+ "commander.unknownCommand",
14
+ "commander.unknownOption"
15
+ ]);
16
+ export function isCommanderLifecycleExit(error) {
17
+ var _error_code;
18
+ return isCommanderError(error) && COMMANDER_EXIT_CODES_TO_IGNORE.has((_error_code = error.code) !== null && _error_code !== void 0 ? _error_code : "");
19
+ }
20
+ export function getCommanderUserFacingError(error) {
21
+ if (!isCommanderError(error)) {
22
+ return null;
23
+ }
24
+ var _error_message;
25
+ var message = (_error_message = error.message) !== null && _error_message !== void 0 ? _error_message : "Invalid CLI arguments.";
26
+ var _error_exitCode, _error_code;
27
+ return {
28
+ exitCode: (_error_exitCode = error.exitCode) !== null && _error_exitCode !== void 0 ? _error_exitCode : 1,
29
+ message: UPDATED_DOCS_PARSE_ERROR_CODES.has((_error_code = error.code) !== null && _error_code !== void 0 ? _error_code : "") ? formatUpdatedCliUsageError(message) : normalizeCommanderErrorMessage(message)
30
+ };
31
+ }
32
+ function isCommanderError(error) {
33
+ return (typeof error === "undefined" ? "undefined" : _type_of(error)) === "object" && error !== null && "code" in error && "message" in error;
34
+ }
35
+ function normalizeCommanderErrorMessage(message) {
36
+ var normalized = message.replace(/^error:\s*/i, "").trim();
37
+ if (normalized.length === 0) {
38
+ return "Invalid CLI arguments.";
39
+ }
40
+ return normalized.endsWith(".") ? normalized : "".concat(normalized, ".");
41
+ }
@@ -27,6 +27,10 @@ function _async_to_generator(fn) {
27
27
  });
28
28
  };
29
29
  }
30
+ function _type_of(obj) {
31
+ "@swc/helpers - typeof";
32
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
33
+ }
30
34
  function _ts_generator(thisArg, body) {
31
35
  var f, y, t, _ = {
32
36
  label: 0,
@@ -118,59 +122,89 @@ function _ts_generator(thisArg, body) {
118
122
  };
119
123
  }
120
124
  }
121
- import { Connection } from "@solana/web3.js";
122
- import { publishSupport } from "@solana-mobile/dapp-store-publishing-tools";
123
- import { checkMintedStatus } from "../../CliUtils.js";
124
- import nacl from "tweetnacl";
125
- import { loadPublishDetailsWithChecks } from "../../config/PublishDetails.js";
126
- export var publishSupportCommand = function(param) {
127
- var appMintAddress = param.appMintAddress, releaseMintAddress = param.releaseMintAddress, signer = param.signer, url = param.url, _param_dryRun = param.dryRun, dryRun = _param_dryRun === void 0 ? false : _param_dryRun, _param_requestorIsAuthorized = param.requestorIsAuthorized, requestorIsAuthorized = _param_requestorIsAuthorized === void 0 ? false : _param_requestorIsAuthorized, requestDetails = param.requestDetails;
125
+ import { readFile } from "node:fs/promises";
126
+ import semver from "semver";
127
+ import updateNotifier from "update-notifier";
128
+ import { Constants } from "./constants.js";
129
+ var FALLBACK_CLI_PACKAGE = {
130
+ name: "@solana-mobile/dapp-store-cli",
131
+ version: Constants.CLI_VERSION
132
+ };
133
+ function loadCliPackageMetadata() {
128
134
  return _async_to_generator(function() {
129
- var connection, _ref, publisherDetails, appDetails, releaseDetails, sign, appAddr, releaseAddr;
135
+ var packageContents, parsed, e;
130
136
  return _ts_generator(this, function(_state) {
131
137
  switch(_state.label){
132
138
  case 0:
133
- if (!requestorIsAuthorized) {
134
- console.error("ERROR: Cannot submit a request for which the requestor does not attest they are authorized to do so");
139
+ _state.trys.push([
140
+ 0,
141
+ 2,
142
+ ,
143
+ 3
144
+ ]);
145
+ return [
146
+ 4,
147
+ readFile(new URL("../../package.json", import.meta.url), {
148
+ encoding: "utf8"
149
+ })
150
+ ];
151
+ case 1:
152
+ packageContents = _state.sent();
153
+ parsed = JSON.parse(packageContents);
154
+ if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === "object" && parsed !== null && typeof parsed.name === "string" && typeof parsed.version === "string") {
135
155
  return [
136
- 2
156
+ 2,
157
+ {
158
+ name: String(parsed.name),
159
+ version: String(parsed.version)
160
+ }
137
161
  ];
138
162
  }
139
- connection = new Connection(url, {
140
- commitment: "confirmed"
141
- });
142
163
  return [
143
- 4,
144
- loadPublishDetailsWithChecks()
164
+ 3,
165
+ 3
145
166
  ];
146
- case 1:
147
- _ref = _state.sent(), publisherDetails = _ref.publisher, appDetails = _ref.app, releaseDetails = _ref.release;
148
- sign = function(buf) {
149
- return nacl.sign(buf, signer.secretKey);
150
- };
151
- appAddr = appMintAddress !== null && appMintAddress !== void 0 ? appMintAddress : appDetails.address;
152
- releaseAddr = releaseMintAddress !== null && releaseMintAddress !== void 0 ? releaseMintAddress : releaseDetails.address;
167
+ case 2:
168
+ e = _state.sent();
169
+ return [
170
+ 2,
171
+ FALLBACK_CLI_PACKAGE
172
+ ];
173
+ case 3:
174
+ return [
175
+ 2,
176
+ FALLBACK_CLI_PACKAGE
177
+ ];
178
+ }
179
+ });
180
+ })();
181
+ }
182
+ export var checkForSelfUpdate = function() {
183
+ return _async_to_generator(function() {
184
+ var notifier, _tmp, updateInfo, latestVersion, currentVersion;
185
+ return _ts_generator(this, function(_state) {
186
+ switch(_state.label){
187
+ case 0:
188
+ _tmp = {};
153
189
  return [
154
190
  4,
155
- checkMintedStatus(connection, appAddr, releaseAddr)
191
+ loadCliPackageMetadata()
156
192
  ];
157
- case 2:
158
- _state.sent();
193
+ case 1:
194
+ notifier = updateNotifier.apply(void 0, [
195
+ (_tmp.pkg = _state.sent(), _tmp)
196
+ ]);
159
197
  return [
160
198
  4,
161
- publishSupport({
162
- connection: connection,
163
- sign: sign
164
- }, {
165
- appMintAddress: appMintAddress !== null && appMintAddress !== void 0 ? appMintAddress : appDetails.address,
166
- releaseMintAddress: releaseMintAddress !== null && releaseMintAddress !== void 0 ? releaseMintAddress : releaseDetails.address,
167
- publisherDetails: publisherDetails,
168
- requestorIsAuthorized: requestorIsAuthorized,
169
- requestDetails: requestDetails
170
- }, dryRun)
199
+ notifier.fetchInfo()
171
200
  ];
172
- case 3:
173
- _state.sent();
201
+ case 2:
202
+ updateInfo = _state.sent();
203
+ latestVersion = new semver.SemVer(updateInfo.latest);
204
+ currentVersion = new semver.SemVer(updateInfo.current);
205
+ if (latestVersion.major > currentVersion.major || latestVersion.minor > currentVersion.minor) {
206
+ throw new Error("Please update to the latest version of the dApp Store CLI before proceeding.\nCurrent version is ".concat(currentVersion.raw, "\nLatest version is ").concat(latestVersion.raw));
207
+ }
174
208
  return [
175
209
  2
176
210
  ];