@solana-mobile/dapp-store-cli 0.16.0 → 1.0.0
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/bin/dapp-store.js +3 -1
- package/lib/CliSetup.js +304 -505
- package/lib/CliUtils.js +6 -376
- package/lib/__tests__/CliSetupTest.js +484 -74
- package/lib/cli/__tests__/parseErrors.test.js +25 -0
- package/lib/cli/__tests__/signer.test.js +436 -0
- package/lib/cli/constants.js +23 -0
- package/lib/cli/messages.js +21 -0
- package/lib/cli/parseErrors.js +41 -0
- package/lib/{commands/publish/PublishCliSupport.js → cli/selfUpdate.js} +72 -38
- package/lib/{commands/publish/PublishCliRemove.js → cli/signer.js} +35 -56
- package/lib/index.js +96 -5
- package/lib/package.json +5 -24
- package/lib/portal/__tests__/releaseMetadata.test.js +647 -0
- package/lib/portal/__tests__/translators.test.js +76 -0
- package/lib/portal/__tests__/workflowClient.test.js +457 -0
- package/lib/portal/attestationClient.js +143 -0
- package/lib/portal/files.js +64 -0
- package/lib/portal/http.js +364 -0
- package/lib/portal/records.js +64 -0
- package/lib/portal/releaseMetadata.js +748 -0
- package/lib/portal/translators.js +460 -0
- package/lib/portal/types.js +1 -0
- package/lib/portal/workflowClient.js +704 -0
- package/lib/publication/PublicationProgressReporter.js +1051 -0
- package/lib/publication/__tests__/PublicationProgressReporter.test.js +174 -0
- package/lib/{commands/ValidateCommand.js → publication/__tests__/fundingPreflight.test.js} +90 -66
- package/lib/publication/__tests__/publicationSummary.test.js +26 -0
- package/lib/publication/cliValidation.js +482 -0
- package/lib/publication/fundingPreflight.js +246 -0
- package/lib/publication/publicationSummary.js +99 -0
- package/lib/{commands/utils.js → publication/runPublicationWorkflow.js} +16 -46
- package/package.json +5 -24
- package/src/CliSetup.ts +370 -505
- package/src/CliUtils.ts +9 -233
- package/src/__tests__/CliSetupTest.ts +272 -120
- package/src/cli/__tests__/parseErrors.test.ts +34 -0
- package/src/cli/__tests__/signer.test.ts +359 -0
- package/src/cli/constants.ts +3 -0
- package/src/cli/messages.ts +27 -0
- package/src/cli/parseErrors.ts +62 -0
- package/src/cli/selfUpdate.ts +59 -0
- package/src/cli/signer.ts +38 -0
- package/src/index.ts +31 -4
- package/src/portal/__tests__/releaseMetadata.test.ts +508 -0
- package/src/portal/__tests__/translators.test.ts +82 -0
- package/src/portal/__tests__/workflowClient.test.ts +278 -0
- package/src/portal/attestationClient.ts +19 -0
- package/src/portal/files.ts +73 -0
- package/src/portal/http.ts +170 -0
- package/src/portal/records.ts +38 -0
- package/src/portal/releaseMetadata.ts +489 -0
- package/src/portal/translators.ts +750 -0
- package/src/portal/types.ts +27 -0
- package/src/portal/workflowClient.ts +575 -0
- package/src/publication/PublicationProgressReporter.ts +1026 -0
- package/src/publication/__tests__/PublicationProgressReporter.test.ts +210 -0
- package/src/publication/__tests__/fundingPreflight.test.ts +78 -0
- package/src/publication/__tests__/publicationSummary.test.ts +30 -0
- package/src/publication/cliValidation.ts +264 -0
- package/src/publication/fundingPreflight.ts +123 -0
- package/src/publication/publicationSummary.ts +26 -0
- package/src/publication/runPublicationWorkflow.ts +46 -0
- package/lib/commands/create/CreateCliApp.js +0 -223
- package/lib/commands/create/CreateCliRelease.js +0 -290
- package/lib/commands/create/index.js +0 -40
- package/lib/commands/index.js +0 -3
- package/lib/commands/publish/PublishCliSubmit.js +0 -208
- package/lib/commands/publish/PublishCliUpdate.js +0 -211
- package/lib/commands/publish/index.js +0 -22
- package/lib/commands/scaffolding/ScaffoldInit.js +0 -15
- package/lib/commands/scaffolding/index.js +0 -1
- package/lib/config/EnvVariables.js +0 -59
- package/lib/config/PublishDetails.js +0 -915
- package/lib/config/S3StorageManager.js +0 -93
- package/lib/config/index.js +0 -2
- package/lib/generated/config_obj.json +0 -1
- package/lib/generated/config_schema.json +0 -1
- package/lib/prebuild_schema/publishing_source.yaml +0 -64
- package/lib/prebuild_schema/schemagen.js +0 -25
- package/lib/upload/CachedStorageDriver.js +0 -458
- package/lib/upload/TurboStorageDriver.js +0 -718
- package/lib/upload/__tests__/CachedStorageDriver.test.js +0 -437
- package/lib/upload/__tests__/TurboStorageDriver.test.js +0 -17
- package/lib/upload/__tests__/contentGateway.test.js +0 -17
- package/lib/upload/contentGateway.js +0 -23
- package/lib/upload/index.js +0 -2
- package/src/commands/ValidateCommand.ts +0 -82
- package/src/commands/create/CreateCliApp.ts +0 -93
- package/src/commands/create/CreateCliRelease.ts +0 -149
- package/src/commands/create/index.ts +0 -47
- package/src/commands/index.ts +0 -3
- package/src/commands/publish/PublishCliRemove.ts +0 -66
- package/src/commands/publish/PublishCliSubmit.ts +0 -93
- package/src/commands/publish/PublishCliSupport.ts +0 -66
- package/src/commands/publish/PublishCliUpdate.ts +0 -101
- package/src/commands/publish/index.ts +0 -29
- package/src/commands/scaffolding/ScaffoldInit.ts +0 -20
- package/src/commands/scaffolding/index.ts +0 -1
- package/src/commands/utils.ts +0 -33
- package/src/config/EnvVariables.ts +0 -39
- package/src/config/PublishDetails.ts +0 -456
- package/src/config/S3StorageManager.ts +0 -47
- package/src/config/index.ts +0 -2
- package/src/prebuild_schema/publishing_source.yaml +0 -64
- package/src/prebuild_schema/schemagen.js +0 -31
- package/src/upload/CachedStorageDriver.ts +0 -179
- package/src/upload/TurboStorageDriver.ts +0 -283
- package/src/upload/__tests__/CachedStorageDriver.test.ts +0 -246
- package/src/upload/__tests__/TurboStorageDriver.test.ts +0 -15
- package/src/upload/__tests__/contentGateway.test.ts +0 -31
- package/src/upload/contentGateway.ts +0 -37
- package/src/upload/index.ts +0 -2
package/src/CliUtils.ts
CHANGED
|
@@ -1,233 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import ver from "semver";
|
|
11
|
-
import path from "path";
|
|
12
|
-
import { CachedStorageDriver } from "./upload/CachedStorageDriver.js";
|
|
13
|
-
import { TurboStorageDriver } from "./upload/TurboStorageDriver.js";
|
|
14
|
-
import { EnvVariables } from "./config/index.js";
|
|
15
|
-
import { S3Client } from "@aws-sdk/client-s3";
|
|
16
|
-
import { awsStorage } from "@metaplex-foundation/js-plugin-aws";
|
|
17
|
-
import { S3StorageManager } from "./config/index.js";
|
|
18
|
-
|
|
19
|
-
export class Constants {
|
|
20
|
-
static CLI_VERSION = "0.16.0";
|
|
21
|
-
static CONFIG_FILE_NAME = "config.yaml";
|
|
22
|
-
static DEFAULT_RPC_DEVNET = "https://api.devnet.solana.com";
|
|
23
|
-
static DEFAULT_PRIORITY_FEE = 500000;
|
|
24
|
-
|
|
25
|
-
static getConfigFilePath = () => {
|
|
26
|
-
return path.join(process.cwd(), Constants.CONFIG_FILE_NAME);
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const debug = debugModule("CLI");
|
|
31
|
-
|
|
32
|
-
export const checkForSelfUpdate = async () => {
|
|
33
|
-
const notifier = updateNotifier({ pkg: cliPackage });
|
|
34
|
-
const updateInfo = await notifier.fetchInfo();
|
|
35
|
-
|
|
36
|
-
const latestVer = new ver.SemVer(updateInfo.latest);
|
|
37
|
-
const currentVer = new ver.SemVer(updateInfo.current);
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
latestVer.major > currentVer.major ||
|
|
41
|
-
latestVer.minor > currentVer.minor
|
|
42
|
-
) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
`Please update to the latest version of the dApp Store CLI before proceeding.\nCurrent version is ${currentVer.raw}\nLatest version is ${latestVer.raw}`
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const checkMintedStatus = async (
|
|
50
|
-
conn: Connection,
|
|
51
|
-
appAddr: string,
|
|
52
|
-
releaseAddr: string
|
|
53
|
-
) => {
|
|
54
|
-
for (let i = 0; i < 5; i++) {
|
|
55
|
-
const results = await conn.getMultipleAccountsInfo([
|
|
56
|
-
new PublicKey(appAddr),
|
|
57
|
-
new PublicKey(releaseAddr),
|
|
58
|
-
]);
|
|
59
|
-
|
|
60
|
-
const isAppMinted = results[0] != undefined && results[0]?.lamports > 0
|
|
61
|
-
const isReleaseMinted = results[1] != undefined && results[1]?.lamports > 0
|
|
62
|
-
|
|
63
|
-
if (isAppMinted && isReleaseMinted) {
|
|
64
|
-
return
|
|
65
|
-
} else {
|
|
66
|
-
let errorMessage = ``
|
|
67
|
-
if (!isAppMinted) {
|
|
68
|
-
errorMessage = errorMessage + `App NFT fetch at address ${appAddr} failed.\n`
|
|
69
|
-
}
|
|
70
|
-
if (!isReleaseMinted) {
|
|
71
|
-
errorMessage = errorMessage + `Release NFT fetch at address ${releaseAddr} failed.\n`
|
|
72
|
-
}
|
|
73
|
-
if (i == 4) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
`Expected App :: ${appAddr} and Release :: ${releaseAddr} to be minted before submission.\n
|
|
76
|
-
but ${errorMessage}\n
|
|
77
|
-
Please ensure you have minted all of your NFTs before submitting to the Solana Mobile dApp publisher portal.`
|
|
78
|
-
);
|
|
79
|
-
} else {
|
|
80
|
-
sleep(2000)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const sleep = (ms: number):Promise<void> => {
|
|
87
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const parseKeypair = (pathToKeypairFile: string) => {
|
|
91
|
-
try {
|
|
92
|
-
const keypairFile = fs.readFileSync(pathToKeypairFile, "utf-8");
|
|
93
|
-
return Keypair.fromSecretKey(Buffer.from(JSON.parse(keypairFile)));
|
|
94
|
-
} catch (e) {
|
|
95
|
-
showMessage(
|
|
96
|
-
"KeyPair Error",
|
|
97
|
-
"Something went wrong when attempting to retrieve the keypair at " +
|
|
98
|
-
pathToKeypairFile,
|
|
99
|
-
"error"
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export const isDevnet = (rpcUrl: string): boolean => {
|
|
105
|
-
return rpcUrl.indexOf("devnet") != -1;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const isTestnet = (rpcUrl: string): boolean => {
|
|
109
|
-
return rpcUrl.indexOf("testnet") != -1;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const checkSubmissionNetwork = (rpcUrl: string) => {
|
|
113
|
-
if (isDevnet(rpcUrl) || isTestnet(rpcUrl)) {
|
|
114
|
-
throw new Error(
|
|
115
|
-
"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."
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export const generateNetworkSuffix = (rpcUrl: string): string => {
|
|
121
|
-
let suffix = "";
|
|
122
|
-
|
|
123
|
-
if (isDevnet(rpcUrl)) {
|
|
124
|
-
suffix = "?cluster=devnet";
|
|
125
|
-
} else if (isTestnet(rpcUrl)) {
|
|
126
|
-
suffix = "?cluster=testnet";
|
|
127
|
-
} else {
|
|
128
|
-
suffix = "?cluster=mainnet";
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return suffix;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const dryRunSuccessMessage = () => {
|
|
135
|
-
showMessage("Dry run", "Dry run was successful", "standard")
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export const alphaAppSubmissionMessage = () => {
|
|
139
|
-
showMessage(
|
|
140
|
-
"Alpha release",
|
|
141
|
-
"Alpha releases are not reviewed on dApp store and are meant for internal testing only.\n" +
|
|
142
|
-
"Run the `npx dapp-store publish submit ...` command again without the `--alpha` param to publish the app",
|
|
143
|
-
"warning"
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export const showNetworkWarningIfApplicable = (rpcUrl: string) => {
|
|
148
|
-
if (isDevnet(rpcUrl)) {
|
|
149
|
-
showMessage("Devnet Mode", "Running on Devnet", "warning")
|
|
150
|
-
} else if (isTestnet(rpcUrl)) {
|
|
151
|
-
showMessage("Testnet Mode", "Running on Testnet", "warning")
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export const showMessage = (
|
|
156
|
-
titleMessage = "",
|
|
157
|
-
contentMessage = "",
|
|
158
|
-
type: "standard" | "error" | "warning" = "standard"
|
|
159
|
-
): string => {
|
|
160
|
-
let color = "cyan";
|
|
161
|
-
if (type == "error") {
|
|
162
|
-
color = "redBright";
|
|
163
|
-
} else if (type == "warning") {
|
|
164
|
-
color = "yellow";
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const msg = boxen(contentMessage, {
|
|
168
|
-
title: titleMessage,
|
|
169
|
-
padding: 1,
|
|
170
|
-
margin: 1,
|
|
171
|
-
borderStyle: "single",
|
|
172
|
-
borderColor: color,
|
|
173
|
-
textAlignment: "left",
|
|
174
|
-
titleAlignment: "center",
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
console.log(msg);
|
|
178
|
-
return msg;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
export const getMetaplexInstance = (
|
|
182
|
-
connection: Connection,
|
|
183
|
-
keypair: Keypair,
|
|
184
|
-
storageParams: string = ""
|
|
185
|
-
) => {
|
|
186
|
-
const metaplex = Metaplex.make(connection).use(keypairIdentity(keypair));
|
|
187
|
-
const isDevnet = connection.rpcEndpoint.includes("devnet");
|
|
188
|
-
|
|
189
|
-
//TODO: Use DI for this
|
|
190
|
-
const s3Mgr = new S3StorageManager(new EnvVariables());
|
|
191
|
-
s3Mgr.parseCmdArg(storageParams);
|
|
192
|
-
|
|
193
|
-
if (s3Mgr.hasS3Config) {
|
|
194
|
-
const awsClient = new S3Client({
|
|
195
|
-
region: s3Mgr.s3Config.regionName,
|
|
196
|
-
credentials: {
|
|
197
|
-
accessKeyId: s3Mgr.s3Config.accessKey,
|
|
198
|
-
secretAccessKey: s3Mgr.s3Config.secretKey,
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
const bucketPlugin = awsStorage(awsClient, s3Mgr.s3Config.bucketName);
|
|
203
|
-
metaplex.use(bucketPlugin);
|
|
204
|
-
} else {
|
|
205
|
-
const turboDriver = new TurboStorageDriver(
|
|
206
|
-
keypair,
|
|
207
|
-
isDevnet ? "devnet" : "mainnet",
|
|
208
|
-
Number(process.env.TURBO_BUFFER_PERCENTAGE || 20)
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
const metaplexAdapter = {
|
|
212
|
-
async upload(file: MetaplexFile): Promise<string> {
|
|
213
|
-
return turboDriver.upload(file);
|
|
214
|
-
},
|
|
215
|
-
async getUploadPrice(bytes: number): Promise<Amount> {
|
|
216
|
-
const price = await turboDriver.getUploadPrice(bytes);
|
|
217
|
-
return lamports(price);
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
metaplex.storage().setDriver(metaplexAdapter);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
metaplex.storage().setDriver(
|
|
225
|
-
new CachedStorageDriver(metaplex.storage().driver(), {
|
|
226
|
-
assetManifestPath: isDevnet
|
|
227
|
-
? "./.asset-manifest-devnet.json"
|
|
228
|
-
: "./.asset-manifest.json",
|
|
229
|
-
})
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
return metaplex;
|
|
233
|
-
};
|
|
1
|
+
export { Constants } from "./cli/constants.js";
|
|
2
|
+
export { showMessage } from "./cli/messages.js";
|
|
3
|
+
export { checkForSelfUpdate } from "./cli/selfUpdate.js";
|
|
4
|
+
export {
|
|
5
|
+
createPublicationSignerFromKeypair,
|
|
6
|
+
parseKeypair,
|
|
7
|
+
} from "./cli/signer.js";
|
|
8
|
+
export { createPortalAttestationClient } from "./portal/attestationClient.js";
|
|
9
|
+
export { createPortalWorkflowClient } from "./portal/workflowClient.js";
|