@airmoney-degn/airmoney-cli 0.21.0 → 0.22.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/dist/cli/upload.js +20 -36
- package/dist/config.json +1 -1
- package/package.json +1 -1
package/dist/cli/upload.js
CHANGED
|
@@ -121,51 +121,37 @@ async function preparePackage(meta, projectPath) {
|
|
|
121
121
|
/**
|
|
122
122
|
* Creates the JSON-RPC request body for upload
|
|
123
123
|
*/
|
|
124
|
-
|
|
125
|
-
const metaJson = JSON.stringify(meta);
|
|
126
|
-
return JSON.stringify({
|
|
127
|
-
jsonrpc: '2.0',
|
|
128
|
-
id: 1,
|
|
129
|
-
method: 'uploadPackage',
|
|
130
|
-
params: [userId, apiKey, metaJson, encodedFile],
|
|
131
|
-
});
|
|
132
|
-
}
|
|
124
|
+
// no longer needed: JSON-RPC upload replaced by streaming HTTP upload
|
|
133
125
|
/**
|
|
134
126
|
* Handles the upload response
|
|
135
127
|
*/
|
|
136
|
-
|
|
137
|
-
if (json.result === true) {
|
|
138
|
-
(0, LogService_1.log)('Package uploaded successfully').green();
|
|
139
|
-
(0, LogService_1.log)('Open : https://dash-devnet.degn.com/').white();
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
(0, LogService_1.log)('Error uploding package').red();
|
|
143
|
-
if (json.error?.code === -32602) {
|
|
144
|
-
(0, LogService_1.log)('invalid api key, please visit https://dash-devnet.degn.com/ and setup env with the new key').red();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
(0, LogService_1.log)('unknow error, please contact support').red();
|
|
148
|
-
(0, LogService_1.log)(JSON.stringify(json.error)).red();
|
|
149
|
-
}
|
|
128
|
+
// handled inline with plain-text response from /upload
|
|
150
129
|
/**
|
|
151
130
|
* Uploads the package to the server
|
|
152
131
|
*/
|
|
153
|
-
async function uploadPackageToServer(network,
|
|
154
|
-
const
|
|
155
|
-
const
|
|
132
|
+
async function uploadPackageToServer(network, userId, apiKey, meta, fileBuffer) {
|
|
133
|
+
const origin = (0, network_1.networkToRpcUrl)(network).replace(/\/+$/, '');
|
|
134
|
+
const metaParam = encodeURIComponent(JSON.stringify(meta));
|
|
135
|
+
const url = `${origin}/upload?user=${userId}&apiKey=${apiKey}&meta=${metaParam}`;
|
|
136
|
+
const res = await (0, node_fetch_1.default)(url, {
|
|
156
137
|
method: 'POST',
|
|
157
|
-
|
|
138
|
+
// raw bytes, no base64 overhead
|
|
139
|
+
body: fileBuffer,
|
|
158
140
|
headers: {
|
|
159
|
-
'Content-Type': 'application/
|
|
141
|
+
'Content-Type': 'application/octet-stream',
|
|
160
142
|
},
|
|
161
143
|
});
|
|
144
|
+
const text = await res.text();
|
|
162
145
|
if (!res.ok) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
146
|
+
(0, LogService_1.log)(`Error uploading package: ${text}`).red();
|
|
147
|
+
throw new Error(`Upload failed: ${text}`);
|
|
148
|
+
}
|
|
149
|
+
if (text.trim() === 'ok') {
|
|
150
|
+
(0, LogService_1.log)('Package uploaded successfully').green();
|
|
151
|
+
(0, LogService_1.log)('Open : https://dash-devnet.degn.com/').white();
|
|
152
|
+
return;
|
|
166
153
|
}
|
|
167
|
-
|
|
168
|
-
handleUploadResponse(json);
|
|
154
|
+
(0, LogService_1.log)(`Unexpected response: ${text}`);
|
|
169
155
|
}
|
|
170
156
|
/**
|
|
171
157
|
* Cleans up the package file
|
|
@@ -200,9 +186,7 @@ async function uploadCommand({ network, locationFolder, }) {
|
|
|
200
186
|
const meta = await loadAndValidateMetadata(locationFolder);
|
|
201
187
|
packageData = await preparePackage(meta, projectPath);
|
|
202
188
|
(0, LogService_1.log)('Publishing package to DEGN Dapp Store...').white();
|
|
203
|
-
|
|
204
|
-
const body = createUploadRequestBody(userId, apiKey, meta, encoded);
|
|
205
|
-
await uploadPackageToServer(network || "devnet", body);
|
|
189
|
+
await uploadPackageToServer(network || "devnet", userId, apiKey, meta, packageData.fileBuffer);
|
|
206
190
|
}
|
|
207
191
|
catch (err) {
|
|
208
192
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
package/dist/config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airmoney-degn/airmoney-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "airmoney-cli is a command-line interface tool designed to facilitate the development and management of decentralized applications (DApps) for Airmoney.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|