@solana-mobile/dapp-store-cli 0.4.2 → 0.5.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 +1 -1
- package/lib/CliSetup.js +730 -0
- package/lib/CliUtils.js +309 -0
- package/lib/__tests__/CliSetupTest.js +140 -0
- package/lib/commands/ValidateCommand.js +201 -0
- package/lib/commands/create/CreateCliApp.js +240 -0
- package/lib/commands/create/CreateCliPublisher.js +238 -0
- package/lib/commands/create/CreateCliRelease.js +270 -0
- package/lib/commands/create/index.js +41 -0
- package/lib/{esm/commands → commands}/index.js +0 -1
- package/lib/commands/publish/PublishCliRemove.js +186 -0
- package/lib/commands/publish/PublishCliSubmit.js +192 -0
- package/lib/commands/publish/PublishCliSupport.js +186 -0
- package/lib/commands/publish/PublishCliUpdate.js +193 -0
- package/lib/commands/publish/index.js +22 -0
- package/lib/{esm/commands → commands}/scaffolding/ScaffoldInit.js +7 -6
- package/lib/{esm/commands → commands}/scaffolding/index.js +0 -1
- package/lib/config/EnvVariables.js +59 -0
- package/lib/config/PublishDetails.js +591 -0
- package/lib/config/S3StorageManager.js +93 -0
- package/lib/config/index.js +2 -0
- package/lib/generated/config_obj.json +1 -0
- package/lib/generated/config_schema.json +1 -0
- package/lib/index.js +148 -0
- package/lib/package.json +74 -0
- package/lib/prebuild_schema/publishing_source.yaml +46 -0
- package/lib/prebuild_schema/schemagen.js +20 -0
- package/lib/upload/CachedStorageDriver.js +307 -0
- package/lib/{esm/upload → upload}/index.js +0 -1
- package/package.json +21 -7
- package/src/CliSetup.ts +511 -0
- package/src/CliUtils.ts +64 -19
- package/src/__tests__/CliSetupTest.ts +212 -0
- package/src/commands/create/CreateCliApp.ts +6 -1
- package/src/commands/create/CreateCliPublisher.ts +6 -1
- package/src/commands/create/CreateCliRelease.ts +6 -1
- package/src/config/EnvVariables.ts +39 -0
- package/src/config/PublishDetails.ts +16 -2
- package/src/config/S3StorageManager.ts +47 -0
- package/src/config/index.ts +2 -0
- package/src/index.ts +3 -510
- package/lib/esm/CliUtils.js +0 -108
- package/lib/esm/CliUtils.js.map +0 -1
- package/lib/esm/commands/ValidateCommand.js +0 -42
- package/lib/esm/commands/ValidateCommand.js.map +0 -1
- package/lib/esm/commands/create/CreateCliApp.js +0 -41
- package/lib/esm/commands/create/CreateCliApp.js.map +0 -1
- package/lib/esm/commands/create/CreateCliPublisher.js +0 -36
- package/lib/esm/commands/create/CreateCliPublisher.js.map +0 -1
- package/lib/esm/commands/create/CreateCliRelease.js +0 -50
- package/lib/esm/commands/create/CreateCliRelease.js.map +0 -1
- package/lib/esm/commands/create/index.js +0 -44
- package/lib/esm/commands/create/index.js.map +0 -1
- package/lib/esm/commands/index.js.map +0 -1
- package/lib/esm/commands/publish/PublishCliRemove.js +0 -26
- package/lib/esm/commands/publish/PublishCliRemove.js.map +0 -1
- package/lib/esm/commands/publish/PublishCliSubmit.js +0 -31
- package/lib/esm/commands/publish/PublishCliSubmit.js.map +0 -1
- package/lib/esm/commands/publish/PublishCliSupport.js +0 -26
- package/lib/esm/commands/publish/PublishCliSupport.js.map +0 -1
- package/lib/esm/commands/publish/PublishCliUpdate.js +0 -32
- package/lib/esm/commands/publish/PublishCliUpdate.js.map +0 -1
- package/lib/esm/commands/publish/index.js +0 -25
- package/lib/esm/commands/publish/index.js.map +0 -1
- package/lib/esm/commands/scaffolding/ScaffoldInit.js.map +0 -1
- package/lib/esm/commands/scaffolding/index.js.map +0 -1
- package/lib/esm/config/PublishDetails.js +0 -177
- package/lib/esm/config/PublishDetails.js.map +0 -1
- package/lib/esm/generated/config_obj.json +0 -1
- package/lib/esm/generated/config_schema.json +0 -1
- package/lib/esm/index.js +0 -307
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/package.json +0 -60
- package/lib/esm/upload/CachedStorageDriver.js +0 -66
- package/lib/esm/upload/CachedStorageDriver.js.map +0 -1
- package/lib/esm/upload/index.js.map +0 -1
- package/lib/types/CliUtils.d.ts +0 -21
- package/lib/types/CliUtils.d.ts.map +0 -1
- package/lib/types/commands/ValidateCommand.d.ts +0 -6
- package/lib/types/commands/ValidateCommand.d.ts.map +0 -1
- package/lib/types/commands/create/CreateCliApp.d.ts +0 -12
- package/lib/types/commands/create/CreateCliApp.d.ts.map +0 -1
- package/lib/types/commands/create/CreateCliPublisher.d.ts +0 -9
- package/lib/types/commands/create/CreateCliPublisher.d.ts.map +0 -1
- package/lib/types/commands/create/CreateCliRelease.d.ts +0 -13
- package/lib/types/commands/create/CreateCliRelease.d.ts.map +0 -1
- package/lib/types/commands/create/index.d.ts +0 -4
- package/lib/types/commands/create/index.d.ts.map +0 -1
- package/lib/types/commands/index.d.ts +0 -4
- package/lib/types/commands/index.d.ts.map +0 -1
- package/lib/types/commands/publish/PublishCliRemove.d.ts +0 -13
- package/lib/types/commands/publish/PublishCliRemove.d.ts.map +0 -1
- package/lib/types/commands/publish/PublishCliSubmit.d.ts +0 -13
- package/lib/types/commands/publish/PublishCliSubmit.d.ts.map +0 -1
- package/lib/types/commands/publish/PublishCliSupport.d.ts +0 -13
- package/lib/types/commands/publish/PublishCliSupport.d.ts.map +0 -1
- package/lib/types/commands/publish/PublishCliUpdate.d.ts +0 -14
- package/lib/types/commands/publish/PublishCliUpdate.d.ts.map +0 -1
- package/lib/types/commands/publish/index.d.ts +0 -5
- package/lib/types/commands/publish/index.d.ts.map +0 -1
- package/lib/types/commands/scaffolding/ScaffoldInit.d.ts +0 -2
- package/lib/types/commands/scaffolding/ScaffoldInit.d.ts.map +0 -1
- package/lib/types/commands/scaffolding/index.d.ts +0 -2
- package/lib/types/commands/scaffolding/index.d.ts.map +0 -1
- package/lib/types/config/PublishDetails.d.ts +0 -17
- package/lib/types/config/PublishDetails.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/upload/CachedStorageDriver.d.ts +0 -30
- package/lib/types/upload/CachedStorageDriver.d.ts.map +0 -1
- package/lib/types/upload/index.d.ts +0 -2
- package/lib/types/upload/index.d.ts.map +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
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, g, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
};
|
|
40
|
+
return(g = {
|
|
41
|
+
next: verb(0),
|
|
42
|
+
"throw": verb(1),
|
|
43
|
+
"return": verb(2)
|
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
+
return this;
|
|
46
|
+
}), g);
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([
|
|
50
|
+
n,
|
|
51
|
+
v
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while(_)try {
|
|
58
|
+
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;
|
|
59
|
+
if (y = 0, t) op = [
|
|
60
|
+
op[0] & 2,
|
|
61
|
+
t.value
|
|
62
|
+
];
|
|
63
|
+
switch(op[0]){
|
|
64
|
+
case 0:
|
|
65
|
+
case 1:
|
|
66
|
+
t = op;
|
|
67
|
+
break;
|
|
68
|
+
case 4:
|
|
69
|
+
_.label++;
|
|
70
|
+
return {
|
|
71
|
+
value: op[1],
|
|
72
|
+
done: false
|
|
73
|
+
};
|
|
74
|
+
case 5:
|
|
75
|
+
_.label++;
|
|
76
|
+
y = op[1];
|
|
77
|
+
op = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
continue;
|
|
81
|
+
case 7:
|
|
82
|
+
op = _.ops.pop();
|
|
83
|
+
_.trys.pop();
|
|
84
|
+
continue;
|
|
85
|
+
default:
|
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
+
_ = 0;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
+
_.label = op[1];
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
+
_.label = t[1];
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t && _.label < t[2]) {
|
|
100
|
+
_.label = t[2];
|
|
101
|
+
_.ops.push(op);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t[2]) _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
op = body.call(thisArg, _);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
op = [
|
|
111
|
+
6,
|
|
112
|
+
e
|
|
113
|
+
];
|
|
114
|
+
y = 0;
|
|
115
|
+
} finally{
|
|
116
|
+
f = t = 0;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] & 5) throw op[1];
|
|
119
|
+
return {
|
|
120
|
+
value: op[0] ? op[1] : void 0,
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
import { createApp } from "@solana-mobile/dapp-store-publishing-tools";
|
|
126
|
+
import { Connection, Keypair, PublicKey, sendAndConfirmTransaction } from "@solana/web3.js";
|
|
127
|
+
import { getMetaplexInstance } from "../../CliUtils.js";
|
|
128
|
+
import { loadPublishDetailsWithChecks, writeToPublishDetails } from "../../config/PublishDetails.js";
|
|
129
|
+
var createAppNft = function() {
|
|
130
|
+
var _ref = _async_to_generator(function(param, param1) {
|
|
131
|
+
var appDetails, connection, publisherMintAddress, publisher, storageParams, dryRun, mintAddress, metaplex, txBuilder, blockhash, tx, txSig;
|
|
132
|
+
return _ts_generator(this, function(_state) {
|
|
133
|
+
switch(_state.label){
|
|
134
|
+
case 0:
|
|
135
|
+
appDetails = param.appDetails, connection = param.connection, publisherMintAddress = param.publisherMintAddress, publisher = param.publisher, storageParams = param.storageParams, dryRun = param1.dryRun;
|
|
136
|
+
mintAddress = Keypair.generate();
|
|
137
|
+
metaplex = getMetaplexInstance(connection, publisher, storageParams);
|
|
138
|
+
return [
|
|
139
|
+
4,
|
|
140
|
+
createApp({
|
|
141
|
+
publisherMintAddress: new PublicKey(publisherMintAddress),
|
|
142
|
+
mintAddress: mintAddress,
|
|
143
|
+
appDetails: appDetails
|
|
144
|
+
}, {
|
|
145
|
+
metaplex: metaplex,
|
|
146
|
+
publisher: publisher
|
|
147
|
+
})
|
|
148
|
+
];
|
|
149
|
+
case 1:
|
|
150
|
+
txBuilder = _state.sent();
|
|
151
|
+
return [
|
|
152
|
+
4,
|
|
153
|
+
connection.getLatestBlockhashAndContext()
|
|
154
|
+
];
|
|
155
|
+
case 2:
|
|
156
|
+
blockhash = _state.sent();
|
|
157
|
+
tx = txBuilder.toTransaction(blockhash.value);
|
|
158
|
+
tx.sign(mintAddress, publisher);
|
|
159
|
+
if (!!dryRun) return [
|
|
160
|
+
3,
|
|
161
|
+
4
|
|
162
|
+
];
|
|
163
|
+
return [
|
|
164
|
+
4,
|
|
165
|
+
sendAndConfirmTransaction(connection, tx, [
|
|
166
|
+
publisher,
|
|
167
|
+
mintAddress
|
|
168
|
+
], {
|
|
169
|
+
minContextSlot: blockhash.context.slot
|
|
170
|
+
})
|
|
171
|
+
];
|
|
172
|
+
case 3:
|
|
173
|
+
txSig = _state.sent();
|
|
174
|
+
console.info({
|
|
175
|
+
txSig: txSig,
|
|
176
|
+
mintAddress: mintAddress.publicKey.toBase58()
|
|
177
|
+
});
|
|
178
|
+
_state.label = 4;
|
|
179
|
+
case 4:
|
|
180
|
+
return [
|
|
181
|
+
2,
|
|
182
|
+
{
|
|
183
|
+
appAddress: mintAddress.publicKey.toBase58()
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
return function createAppNft(_, _1) {
|
|
190
|
+
return _ref.apply(this, arguments);
|
|
191
|
+
};
|
|
192
|
+
}();
|
|
193
|
+
export var createAppCommand = function() {
|
|
194
|
+
var _ref = _async_to_generator(function(param) {
|
|
195
|
+
var signer, url, dryRun, publisherMintAddress, storageParams, connection, _ref, appDetails, publisherDetails, _publisherDetails_address, appAddress;
|
|
196
|
+
return _ts_generator(this, function(_state) {
|
|
197
|
+
switch(_state.label){
|
|
198
|
+
case 0:
|
|
199
|
+
signer = param.signer, url = param.url, dryRun = param.dryRun, publisherMintAddress = param.publisherMintAddress, storageParams = param.storageParams;
|
|
200
|
+
connection = new Connection(url);
|
|
201
|
+
return [
|
|
202
|
+
4,
|
|
203
|
+
loadPublishDetailsWithChecks()
|
|
204
|
+
];
|
|
205
|
+
case 1:
|
|
206
|
+
_ref = _state.sent(), appDetails = _ref.app, publisherDetails = _ref.publisher;
|
|
207
|
+
return [
|
|
208
|
+
4,
|
|
209
|
+
createAppNft({
|
|
210
|
+
connection: connection,
|
|
211
|
+
publisher: signer,
|
|
212
|
+
publisherMintAddress: (_publisherDetails_address = publisherDetails.address) !== null && _publisherDetails_address !== void 0 ? _publisherDetails_address : publisherMintAddress,
|
|
213
|
+
appDetails: appDetails,
|
|
214
|
+
storageParams: storageParams
|
|
215
|
+
}, {
|
|
216
|
+
dryRun: dryRun
|
|
217
|
+
})
|
|
218
|
+
];
|
|
219
|
+
case 2:
|
|
220
|
+
appAddress = _state.sent().appAddress;
|
|
221
|
+
if (!dryRun) {
|
|
222
|
+
writeToPublishDetails({
|
|
223
|
+
app: {
|
|
224
|
+
address: appAddress
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return [
|
|
229
|
+
2,
|
|
230
|
+
{
|
|
231
|
+
appAddress: appAddress
|
|
232
|
+
}
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
return function createAppCommand(_) {
|
|
238
|
+
return _ref.apply(this, arguments);
|
|
239
|
+
};
|
|
240
|
+
}();
|
|
@@ -0,0 +1,238 @@
|
|
|
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, g, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
};
|
|
40
|
+
return(g = {
|
|
41
|
+
next: verb(0),
|
|
42
|
+
"throw": verb(1),
|
|
43
|
+
"return": verb(2)
|
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
+
return this;
|
|
46
|
+
}), g);
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([
|
|
50
|
+
n,
|
|
51
|
+
v
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while(_)try {
|
|
58
|
+
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;
|
|
59
|
+
if (y = 0, t) op = [
|
|
60
|
+
op[0] & 2,
|
|
61
|
+
t.value
|
|
62
|
+
];
|
|
63
|
+
switch(op[0]){
|
|
64
|
+
case 0:
|
|
65
|
+
case 1:
|
|
66
|
+
t = op;
|
|
67
|
+
break;
|
|
68
|
+
case 4:
|
|
69
|
+
_.label++;
|
|
70
|
+
return {
|
|
71
|
+
value: op[1],
|
|
72
|
+
done: false
|
|
73
|
+
};
|
|
74
|
+
case 5:
|
|
75
|
+
_.label++;
|
|
76
|
+
y = op[1];
|
|
77
|
+
op = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
continue;
|
|
81
|
+
case 7:
|
|
82
|
+
op = _.ops.pop();
|
|
83
|
+
_.trys.pop();
|
|
84
|
+
continue;
|
|
85
|
+
default:
|
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
+
_ = 0;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
+
_.label = op[1];
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
+
_.label = t[1];
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t && _.label < t[2]) {
|
|
100
|
+
_.label = t[2];
|
|
101
|
+
_.ops.push(op);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t[2]) _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
op = body.call(thisArg, _);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
op = [
|
|
111
|
+
6,
|
|
112
|
+
e
|
|
113
|
+
];
|
|
114
|
+
y = 0;
|
|
115
|
+
} finally{
|
|
116
|
+
f = t = 0;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] & 5) throw op[1];
|
|
119
|
+
return {
|
|
120
|
+
value: op[0] ? op[1] : void 0,
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
import { createPublisher } from "@solana-mobile/dapp-store-publishing-tools";
|
|
126
|
+
import { Connection, Keypair, sendAndConfirmTransaction } from "@solana/web3.js";
|
|
127
|
+
import { getMetaplexInstance } from "../../CliUtils.js";
|
|
128
|
+
import { loadPublishDetailsWithChecks, writeToPublishDetails } from "../../config/PublishDetails.js";
|
|
129
|
+
var createPublisherNft = function() {
|
|
130
|
+
var _ref = _async_to_generator(function(param, param1) {
|
|
131
|
+
var connection, publisher, publisherDetails, storageParams, dryRun, mintAddress, metaplex, txBuilder, blockhash, tx, txSig;
|
|
132
|
+
return _ts_generator(this, function(_state) {
|
|
133
|
+
switch(_state.label){
|
|
134
|
+
case 0:
|
|
135
|
+
connection = param.connection, publisher = param.publisher, publisherDetails = param.publisherDetails, storageParams = param.storageParams, dryRun = param1.dryRun;
|
|
136
|
+
mintAddress = Keypair.generate();
|
|
137
|
+
metaplex = getMetaplexInstance(connection, publisher, storageParams);
|
|
138
|
+
console.info("Creating publisher at address: ".concat(mintAddress.publicKey.toBase58()));
|
|
139
|
+
return [
|
|
140
|
+
4,
|
|
141
|
+
createPublisher({
|
|
142
|
+
mintAddress: mintAddress,
|
|
143
|
+
publisherDetails: publisherDetails
|
|
144
|
+
}, {
|
|
145
|
+
metaplex: metaplex,
|
|
146
|
+
publisher: publisher
|
|
147
|
+
})
|
|
148
|
+
];
|
|
149
|
+
case 1:
|
|
150
|
+
txBuilder = _state.sent();
|
|
151
|
+
return [
|
|
152
|
+
4,
|
|
153
|
+
connection.getLatestBlockhashAndContext()
|
|
154
|
+
];
|
|
155
|
+
case 2:
|
|
156
|
+
blockhash = _state.sent();
|
|
157
|
+
tx = txBuilder.toTransaction(blockhash.value);
|
|
158
|
+
tx.sign(mintAddress, publisher);
|
|
159
|
+
if (!!dryRun) return [
|
|
160
|
+
3,
|
|
161
|
+
4
|
|
162
|
+
];
|
|
163
|
+
return [
|
|
164
|
+
4,
|
|
165
|
+
sendAndConfirmTransaction(connection, tx, [
|
|
166
|
+
publisher,
|
|
167
|
+
mintAddress
|
|
168
|
+
], {
|
|
169
|
+
minContextSlot: blockhash.context.slot
|
|
170
|
+
})
|
|
171
|
+
];
|
|
172
|
+
case 3:
|
|
173
|
+
txSig = _state.sent();
|
|
174
|
+
console.info({
|
|
175
|
+
txSig: txSig,
|
|
176
|
+
mintAddress: mintAddress.publicKey.toBase58()
|
|
177
|
+
});
|
|
178
|
+
_state.label = 4;
|
|
179
|
+
case 4:
|
|
180
|
+
return [
|
|
181
|
+
2,
|
|
182
|
+
{
|
|
183
|
+
publisherAddress: mintAddress.publicKey.toBase58()
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
return function createPublisherNft(_, _1) {
|
|
190
|
+
return _ref.apply(this, arguments);
|
|
191
|
+
};
|
|
192
|
+
}();
|
|
193
|
+
export var createPublisherCommand = function() {
|
|
194
|
+
var _ref = _async_to_generator(function(param) {
|
|
195
|
+
var signer, url, dryRun, storageParams, connection, _ref, publisherDetails, publisherAddress;
|
|
196
|
+
return _ts_generator(this, function(_state) {
|
|
197
|
+
switch(_state.label){
|
|
198
|
+
case 0:
|
|
199
|
+
signer = param.signer, url = param.url, dryRun = param.dryRun, storageParams = param.storageParams;
|
|
200
|
+
connection = new Connection(url);
|
|
201
|
+
return [
|
|
202
|
+
4,
|
|
203
|
+
loadPublishDetailsWithChecks()
|
|
204
|
+
];
|
|
205
|
+
case 1:
|
|
206
|
+
_ref = _state.sent(), publisherDetails = _ref.publisher;
|
|
207
|
+
return [
|
|
208
|
+
4,
|
|
209
|
+
createPublisherNft({
|
|
210
|
+
connection: connection,
|
|
211
|
+
publisher: signer,
|
|
212
|
+
publisherDetails: publisherDetails,
|
|
213
|
+
storageParams: storageParams
|
|
214
|
+
}, {
|
|
215
|
+
dryRun: dryRun
|
|
216
|
+
})
|
|
217
|
+
];
|
|
218
|
+
case 2:
|
|
219
|
+
publisherAddress = _state.sent().publisherAddress;
|
|
220
|
+
// TODO(sdlaver): dry-run should not modify config
|
|
221
|
+
writeToPublishDetails({
|
|
222
|
+
publisher: {
|
|
223
|
+
address: publisherAddress
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return [
|
|
227
|
+
2,
|
|
228
|
+
{
|
|
229
|
+
publisherAddress: publisherAddress
|
|
230
|
+
}
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
return function createPublisherCommand(_) {
|
|
236
|
+
return _ref.apply(this, arguments);
|
|
237
|
+
};
|
|
238
|
+
}();
|