@solana-mobile/dapp-store-publishing-tools 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/lib/CoreUtils.js +0 -3
- package/lib/index.js +1 -0
- package/lib/portal/attestation.js +189 -0
- package/lib/portal/compat.js +3 -0
- package/lib/portal/index.js +5 -0
- package/lib/portal/signer.js +432 -0
- package/lib/portal/types.js +1 -0
- package/lib/portal/workflow/contracts.js +1 -0
- package/lib/portal/workflow/execution.js +493 -0
- package/lib/portal/workflow/ingestion.js +265 -0
- package/lib/portal/workflow/lifecycle.js +616 -0
- package/lib/portal/workflow/logging.js +8 -0
- package/lib/portal/workflow/source/files.js +304 -0
- package/lib/portal/workflow/source/preparation.js +318 -0
- package/lib/portal/workflow/state/bundle.js +260 -0
- package/lib/portal/workflow/state/checkpoints.js +53 -0
- package/lib/portal/workflow/state/session.js +100 -0
- package/lib/portal/workflow.js +1 -0
- package/lib/publish/PublishCoreAttestation.js +18 -17
- package/lib/publish/PublishCoreRemove.js +7 -89
- package/lib/publish/PublishCoreSubmit.js +7 -117
- package/lib/publish/PublishCoreSupport.js +7 -86
- package/lib/publish/PublishCoreUpdate.js +7 -117
- package/lib/publish/index.js +1 -0
- package/lib/schemas/releaseJsonMetadata.json +1 -2
- package/package.json +2 -4
- package/src/CoreUtils.ts +0 -6
- package/src/index.ts +1 -0
- package/src/portal/attestation.ts +76 -0
- package/src/portal/compat.ts +5 -0
- package/src/portal/index.ts +5 -0
- package/src/portal/signer.ts +327 -0
- package/src/portal/types.ts +447 -0
- package/src/portal/workflow/contracts.ts +108 -0
- package/src/portal/workflow/execution.ts +412 -0
- package/src/portal/workflow/ingestion.ts +187 -0
- package/src/portal/workflow/lifecycle.ts +435 -0
- package/src/portal/workflow/logging.ts +17 -0
- package/src/portal/workflow/source/files.ts +49 -0
- package/src/portal/workflow/source/preparation.ts +189 -0
- package/src/portal/workflow/state/bundle.ts +193 -0
- package/src/portal/workflow/state/checkpoints.ts +70 -0
- package/src/portal/workflow/state/session.ts +87 -0
- package/src/portal/workflow.ts +9 -0
- package/src/publish/PublishCoreAttestation.ts +21 -26
- package/src/publish/PublishCoreRemove.ts +13 -109
- package/src/publish/PublishCoreSubmit.ts +18 -150
- package/src/publish/PublishCoreSupport.ts +13 -102
- package/src/publish/PublishCoreUpdate.ts +17 -155
- package/src/publish/index.ts +2 -1
- package/src/schemas/releaseJsonMetadata.json +1 -2
- package/lib/publish/dapp_publisher_portal.js +0 -206
- package/src/publish/dapp_publisher_portal.ts +0 -81
|
@@ -0,0 +1,493 @@
|
|
|
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 { createAttestationPayloadFromClient } from "../attestation.js";
|
|
122
|
+
import { signSerializedTransaction } from "../signer.js";
|
|
123
|
+
import { logWorkflowInfo } from "./logging.js";
|
|
124
|
+
import { checkpointAtLeast, publicationStageToCheckpoint } from "./state/checkpoints.js";
|
|
125
|
+
import { normalizePublicationBundle, resolvePublicationFeePayer, resolvePublicationSignerAddress, resolveReleaseDisplayName, resolveReleaseMetadataUri, validatePublicationBundle } from "./state/bundle.js";
|
|
126
|
+
import { normalizePublicationSession, resolveReleaseMintAddress } from "./state/session.js";
|
|
127
|
+
function signPreparedTransaction(signer, serializedTransaction, validation) {
|
|
128
|
+
return _async_to_generator(function() {
|
|
129
|
+
return _ts_generator(this, function(_state) {
|
|
130
|
+
return [
|
|
131
|
+
2,
|
|
132
|
+
signSerializedTransaction(signer, serializedTransaction, validation)
|
|
133
|
+
];
|
|
134
|
+
});
|
|
135
|
+
})();
|
|
136
|
+
}
|
|
137
|
+
function submitReleaseMintIfNeeded(context, state) {
|
|
138
|
+
return _async_to_generator(function() {
|
|
139
|
+
var preparedReleaseTransaction, signedTransactionResult;
|
|
140
|
+
return _ts_generator(this, function(_state) {
|
|
141
|
+
switch(_state.label){
|
|
142
|
+
case 0:
|
|
143
|
+
if (checkpointAtLeast(context.publicationCheckpoint, "mint-submitted")) {
|
|
144
|
+
return [
|
|
145
|
+
2
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
logWorkflowInfo(context.logger, "Preparing release NFT transaction", {
|
|
149
|
+
step: "mint.prepare",
|
|
150
|
+
status: "running",
|
|
151
|
+
releaseId: context.bundle.releaseId,
|
|
152
|
+
publicationSessionId: context.publicationSession.id
|
|
153
|
+
});
|
|
154
|
+
return [
|
|
155
|
+
4,
|
|
156
|
+
context.client.prepareReleaseNftTransaction({
|
|
157
|
+
releaseId: context.bundle.releaseId,
|
|
158
|
+
releaseName: resolveReleaseDisplayName(context.bundle),
|
|
159
|
+
releaseMetadataUri: context.releaseMetadataUri,
|
|
160
|
+
appMintAddress: context.bundle.signerAuthority.appMintAddress,
|
|
161
|
+
publisherAddress: context.publisherAddress,
|
|
162
|
+
payerAddress: context.payerAddress
|
|
163
|
+
})
|
|
164
|
+
];
|
|
165
|
+
case 1:
|
|
166
|
+
preparedReleaseTransaction = _state.sent();
|
|
167
|
+
state.releaseMintAddress = preparedReleaseTransaction.mintAddress;
|
|
168
|
+
return [
|
|
169
|
+
4,
|
|
170
|
+
signPreparedTransaction(context.signer, preparedReleaseTransaction.transaction, {
|
|
171
|
+
kind: "release-mint",
|
|
172
|
+
expectedBlockhash: preparedReleaseTransaction.blockhash,
|
|
173
|
+
expectedFeePayerAddress: context.payerAddress,
|
|
174
|
+
expectedSignerAddress: context.publisherAddress,
|
|
175
|
+
expectedMintAddress: preparedReleaseTransaction.mintAddress,
|
|
176
|
+
expectedAppMintAddress: context.bundle.signerAuthority.appMintAddress
|
|
177
|
+
})
|
|
178
|
+
];
|
|
179
|
+
case 2:
|
|
180
|
+
state.releaseTransactionSignature = _state.sent();
|
|
181
|
+
return [
|
|
182
|
+
4,
|
|
183
|
+
context.client.submitSignedTransaction({
|
|
184
|
+
signedTransaction: state.releaseTransactionSignature,
|
|
185
|
+
publicationSessionId: context.publicationSession.id
|
|
186
|
+
})
|
|
187
|
+
];
|
|
188
|
+
case 3:
|
|
189
|
+
signedTransactionResult = _state.sent();
|
|
190
|
+
state.releaseTransactionSignature = signedTransactionResult.transactionSignature;
|
|
191
|
+
logWorkflowInfo(context.logger, "Release NFT transaction submitted", {
|
|
192
|
+
step: "mint.submit",
|
|
193
|
+
status: "complete",
|
|
194
|
+
releaseId: context.bundle.releaseId,
|
|
195
|
+
publicationSessionId: context.publicationSession.id,
|
|
196
|
+
transactionSignature: state.releaseTransactionSignature
|
|
197
|
+
});
|
|
198
|
+
return [
|
|
199
|
+
2
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
})();
|
|
204
|
+
}
|
|
205
|
+
function saveReleaseMintIfNeeded(context, state) {
|
|
206
|
+
return _async_to_generator(function() {
|
|
207
|
+
var _context_publicationSession_releaseMintAddress, _ref, _ref1, mintAddress;
|
|
208
|
+
return _ts_generator(this, function(_state) {
|
|
209
|
+
switch(_state.label){
|
|
210
|
+
case 0:
|
|
211
|
+
if (checkpointAtLeast(context.publicationCheckpoint, "mint-saved")) {
|
|
212
|
+
return [
|
|
213
|
+
2
|
|
214
|
+
];
|
|
215
|
+
}
|
|
216
|
+
mintAddress = (_ref1 = (_ref = (_context_publicationSession_releaseMintAddress = context.publicationSession.releaseMintAddress) !== null && _context_publicationSession_releaseMintAddress !== void 0 ? _context_publicationSession_releaseMintAddress : context.publicationSession.expectedMintAddress) !== null && _ref !== void 0 ? _ref : context.bundle.release.releaseMintAddress) !== null && _ref1 !== void 0 ? _ref1 : state.releaseMintAddress;
|
|
217
|
+
if (!mintAddress) {
|
|
218
|
+
throw new Error("Publication bundle did not include a release mint address");
|
|
219
|
+
}
|
|
220
|
+
if (!state.releaseTransactionSignature) {
|
|
221
|
+
throw new Error("Release transaction signature is missing");
|
|
222
|
+
}
|
|
223
|
+
logWorkflowInfo(context.logger, "Saving release NFT data", {
|
|
224
|
+
step: "mint.save",
|
|
225
|
+
status: "running",
|
|
226
|
+
releaseId: context.bundle.releaseId,
|
|
227
|
+
publicationSessionId: context.publicationSession.id,
|
|
228
|
+
mintAddress: mintAddress
|
|
229
|
+
});
|
|
230
|
+
return [
|
|
231
|
+
4,
|
|
232
|
+
context.client.saveReleaseNftData({
|
|
233
|
+
releaseId: context.bundle.releaseId,
|
|
234
|
+
mintAddress: mintAddress,
|
|
235
|
+
transactionSignature: state.releaseTransactionSignature,
|
|
236
|
+
metadataUri: context.releaseMetadataUri,
|
|
237
|
+
ownerAddress: context.publisherAddress,
|
|
238
|
+
releaseName: resolveReleaseDisplayName(context.bundle),
|
|
239
|
+
releaseVersion: context.bundle.release.versionName,
|
|
240
|
+
androidPackage: context.bundle.release.androidPackage,
|
|
241
|
+
appMintAddress: context.bundle.signerAuthority.appMintAddress
|
|
242
|
+
})
|
|
243
|
+
];
|
|
244
|
+
case 1:
|
|
245
|
+
_state.sent();
|
|
246
|
+
state.releaseMintAddress = mintAddress;
|
|
247
|
+
logWorkflowInfo(context.logger, "Release NFT data saved", {
|
|
248
|
+
step: "mint.save",
|
|
249
|
+
status: "complete",
|
|
250
|
+
releaseId: context.bundle.releaseId,
|
|
251
|
+
publicationSessionId: context.publicationSession.id,
|
|
252
|
+
mintAddress: mintAddress
|
|
253
|
+
});
|
|
254
|
+
return [
|
|
255
|
+
2
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
})();
|
|
260
|
+
}
|
|
261
|
+
function verifyReleaseCollectionIfNeeded(context, state) {
|
|
262
|
+
return _async_to_generator(function() {
|
|
263
|
+
var _context_bundle_signerAuthority_dappId, preparedVerifyTransaction, signedVerifyTransactionResult;
|
|
264
|
+
return _ts_generator(this, function(_state) {
|
|
265
|
+
switch(_state.label){
|
|
266
|
+
case 0:
|
|
267
|
+
if (checkpointAtLeast(context.publicationCheckpoint, "verification-submitted")) {
|
|
268
|
+
return [
|
|
269
|
+
2
|
|
270
|
+
];
|
|
271
|
+
}
|
|
272
|
+
if (!state.releaseMintAddress) {
|
|
273
|
+
throw new Error("Publication bundle did not include a release mint address for collection verification");
|
|
274
|
+
}
|
|
275
|
+
logWorkflowInfo(context.logger, "Preparing collection verification transaction", {
|
|
276
|
+
step: "verify.prepare",
|
|
277
|
+
status: "running",
|
|
278
|
+
releaseId: context.bundle.releaseId,
|
|
279
|
+
publicationSessionId: context.publicationSession.id,
|
|
280
|
+
mintAddress: state.releaseMintAddress
|
|
281
|
+
});
|
|
282
|
+
return [
|
|
283
|
+
4,
|
|
284
|
+
context.client.prepareVerifyCollectionTransaction({
|
|
285
|
+
dappId: (_context_bundle_signerAuthority_dappId = context.bundle.signerAuthority.dappId) !== null && _context_bundle_signerAuthority_dappId !== void 0 ? _context_bundle_signerAuthority_dappId : context.bundle.dapp.id,
|
|
286
|
+
nftMintAddress: state.releaseMintAddress,
|
|
287
|
+
collectionMintAddress: context.bundle.signerAuthority.appMintAddress,
|
|
288
|
+
collectionAuthority: context.bundle.signerAuthority.collectionAuthority,
|
|
289
|
+
payerAddress: context.payerAddress
|
|
290
|
+
})
|
|
291
|
+
];
|
|
292
|
+
case 1:
|
|
293
|
+
preparedVerifyTransaction = _state.sent();
|
|
294
|
+
return [
|
|
295
|
+
4,
|
|
296
|
+
signPreparedTransaction(context.signer, preparedVerifyTransaction.transaction, {
|
|
297
|
+
kind: "verify-collection",
|
|
298
|
+
expectedBlockhash: preparedVerifyTransaction.blockhash,
|
|
299
|
+
expectedFeePayerAddress: context.payerAddress,
|
|
300
|
+
expectedSignerAddress: context.publisherAddress,
|
|
301
|
+
expectedNftMintAddress: state.releaseMintAddress,
|
|
302
|
+
expectedCollectionMintAddress: context.bundle.signerAuthority.appMintAddress,
|
|
303
|
+
expectedCollectionAuthority: context.bundle.signerAuthority.collectionAuthority
|
|
304
|
+
})
|
|
305
|
+
];
|
|
306
|
+
case 2:
|
|
307
|
+
state.collectionTransactionSignature = _state.sent();
|
|
308
|
+
logWorkflowInfo(context.logger, "Submitting collection verification transaction", {
|
|
309
|
+
step: "verify.submit",
|
|
310
|
+
status: "running",
|
|
311
|
+
releaseId: context.bundle.releaseId,
|
|
312
|
+
publicationSessionId: context.publicationSession.id,
|
|
313
|
+
mintAddress: state.releaseMintAddress
|
|
314
|
+
});
|
|
315
|
+
return [
|
|
316
|
+
4,
|
|
317
|
+
context.client.submitSignedTransaction({
|
|
318
|
+
signedTransaction: state.collectionTransactionSignature,
|
|
319
|
+
publicationSessionId: context.publicationSession.id
|
|
320
|
+
})
|
|
321
|
+
];
|
|
322
|
+
case 3:
|
|
323
|
+
signedVerifyTransactionResult = _state.sent();
|
|
324
|
+
state.collectionTransactionSignature = signedVerifyTransactionResult.transactionSignature;
|
|
325
|
+
return [
|
|
326
|
+
4,
|
|
327
|
+
context.client.markReleaseCollectionAsVerified({
|
|
328
|
+
releaseId: context.bundle.releaseId
|
|
329
|
+
})
|
|
330
|
+
];
|
|
331
|
+
case 4:
|
|
332
|
+
_state.sent();
|
|
333
|
+
logWorkflowInfo(context.logger, "Release collection verified", {
|
|
334
|
+
step: "verify.submit",
|
|
335
|
+
status: "complete",
|
|
336
|
+
releaseId: context.bundle.releaseId,
|
|
337
|
+
publicationSessionId: context.publicationSession.id,
|
|
338
|
+
transactionSignature: state.collectionTransactionSignature
|
|
339
|
+
});
|
|
340
|
+
return [
|
|
341
|
+
2
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
})();
|
|
346
|
+
}
|
|
347
|
+
function attestAndSubmitIfNeeded(context, state) {
|
|
348
|
+
return _async_to_generator(function() {
|
|
349
|
+
var submissionResult, _submissionResult_hubspotTicketId;
|
|
350
|
+
return _ts_generator(this, function(_state) {
|
|
351
|
+
switch(_state.label){
|
|
352
|
+
case 0:
|
|
353
|
+
if (checkpointAtLeast(context.publicationCheckpoint, "submitted")) {
|
|
354
|
+
return [
|
|
355
|
+
2
|
|
356
|
+
];
|
|
357
|
+
}
|
|
358
|
+
logWorkflowInfo(context.logger, "Creating attestation payload", {
|
|
359
|
+
step: "attestation.create",
|
|
360
|
+
status: "running",
|
|
361
|
+
releaseId: context.bundle.releaseId,
|
|
362
|
+
publicationSessionId: context.publicationSession.id
|
|
363
|
+
});
|
|
364
|
+
return [
|
|
365
|
+
4,
|
|
366
|
+
createAttestationPayloadFromClient(context.attestationClient, context.signer)
|
|
367
|
+
];
|
|
368
|
+
case 1:
|
|
369
|
+
state.attestationResult = _state.sent();
|
|
370
|
+
logWorkflowInfo(context.logger, "Attestation payload created", {
|
|
371
|
+
step: "attestation.create",
|
|
372
|
+
status: "complete",
|
|
373
|
+
releaseId: context.bundle.releaseId,
|
|
374
|
+
publicationSessionId: context.publicationSession.id,
|
|
375
|
+
requestUniqueId: state.attestationResult.requestUniqueId
|
|
376
|
+
});
|
|
377
|
+
logWorkflowInfo(context.logger, "Submitting release to store", {
|
|
378
|
+
step: "submit.store",
|
|
379
|
+
status: "running",
|
|
380
|
+
releaseId: context.bundle.releaseId,
|
|
381
|
+
publicationSessionId: context.publicationSession.id
|
|
382
|
+
});
|
|
383
|
+
return [
|
|
384
|
+
4,
|
|
385
|
+
context.client.submitToStore({
|
|
386
|
+
releaseId: context.bundle.releaseId,
|
|
387
|
+
whatsNew: context.bundle.release.newInVersion,
|
|
388
|
+
attestation: {
|
|
389
|
+
payload: state.attestationResult.payload,
|
|
390
|
+
requestUniqueId: state.attestationResult.requestUniqueId
|
|
391
|
+
}
|
|
392
|
+
})
|
|
393
|
+
];
|
|
394
|
+
case 2:
|
|
395
|
+
submissionResult = _state.sent();
|
|
396
|
+
state.hubspotTicketId = (_submissionResult_hubspotTicketId = submissionResult.hubspotTicketId) !== null && _submissionResult_hubspotTicketId !== void 0 ? _submissionResult_hubspotTicketId : state.hubspotTicketId;
|
|
397
|
+
logWorkflowInfo(context.logger, "Release submitted to store", {
|
|
398
|
+
step: "submit.store",
|
|
399
|
+
status: "complete",
|
|
400
|
+
releaseId: context.bundle.releaseId,
|
|
401
|
+
publicationSessionId: context.publicationSession.id,
|
|
402
|
+
hubspotTicketId: state.hubspotTicketId
|
|
403
|
+
});
|
|
404
|
+
return [
|
|
405
|
+
2
|
|
406
|
+
];
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
})();
|
|
410
|
+
}
|
|
411
|
+
export function runPublicationWorkflow(client, bundle, signer, attestationClient, session, logger) {
|
|
412
|
+
return _async_to_generator(function() {
|
|
413
|
+
var _state_attestationResult, normalizedBundle, normalizedSession, requiredSignerAddress, publicationSession, _publicationSession_checkpoint, publicationCheckpoint, _publicationSession_mintTransactionSignature, _publicationSession_verifyTransactionSignature, _ref, _publicationSession_hubspotTicketId, state, context, _publicationSession_ingestionSessionId, _ref1, _state_attestationResult_requestUniqueId, _ref2;
|
|
414
|
+
return _ts_generator(this, function(_state) {
|
|
415
|
+
switch(_state.label){
|
|
416
|
+
case 0:
|
|
417
|
+
normalizedBundle = normalizePublicationBundle(bundle);
|
|
418
|
+
normalizedSession = normalizePublicationSession(session);
|
|
419
|
+
validatePublicationBundle(normalizedBundle);
|
|
420
|
+
requiredSignerAddress = resolvePublicationSignerAddress(normalizedBundle);
|
|
421
|
+
if (signer.publicKey !== requiredSignerAddress) {
|
|
422
|
+
throw new Error("Publication signer mismatch. Expected ".concat(requiredSignerAddress, "; received ").concat(signer.publicKey, "."));
|
|
423
|
+
}
|
|
424
|
+
if (normalizedSession.stage === "Failed") {
|
|
425
|
+
throw new Error(normalizedSession.lastError || normalizedSession.error || "Publication session failed");
|
|
426
|
+
}
|
|
427
|
+
publicationSession = normalizedSession;
|
|
428
|
+
publicationCheckpoint = (_publicationSession_checkpoint = publicationSession.checkpoint) !== null && _publicationSession_checkpoint !== void 0 ? _publicationSession_checkpoint : publicationStageToCheckpoint(publicationSession.stage);
|
|
429
|
+
state = {
|
|
430
|
+
releaseTransactionSignature: (_publicationSession_mintTransactionSignature = publicationSession.mintTransactionSignature) !== null && _publicationSession_mintTransactionSignature !== void 0 ? _publicationSession_mintTransactionSignature : undefined,
|
|
431
|
+
collectionTransactionSignature: (_ref = (_publicationSession_verifyTransactionSignature = publicationSession.verifyTransactionSignature) !== null && _publicationSession_verifyTransactionSignature !== void 0 ? _publicationSession_verifyTransactionSignature : publicationSession.verificationTransactionSignature) !== null && _ref !== void 0 ? _ref : undefined,
|
|
432
|
+
hubspotTicketId: (_publicationSession_hubspotTicketId = publicationSession.hubspotTicketId) !== null && _publicationSession_hubspotTicketId !== void 0 ? _publicationSession_hubspotTicketId : undefined,
|
|
433
|
+
releaseMintAddress: resolveReleaseMintAddress(normalizedBundle, publicationSession)
|
|
434
|
+
};
|
|
435
|
+
context = {
|
|
436
|
+
client: client,
|
|
437
|
+
bundle: normalizedBundle,
|
|
438
|
+
signer: signer,
|
|
439
|
+
attestationClient: attestationClient,
|
|
440
|
+
publicationSession: publicationSession,
|
|
441
|
+
publicationCheckpoint: publicationCheckpoint,
|
|
442
|
+
logger: logger,
|
|
443
|
+
releaseMetadataUri: resolveReleaseMetadataUri(normalizedBundle, publicationSession),
|
|
444
|
+
publisherAddress: resolvePublicationSignerAddress(normalizedBundle),
|
|
445
|
+
payerAddress: resolvePublicationFeePayer(normalizedBundle, signer)
|
|
446
|
+
};
|
|
447
|
+
return [
|
|
448
|
+
4,
|
|
449
|
+
submitReleaseMintIfNeeded(context, state)
|
|
450
|
+
];
|
|
451
|
+
case 1:
|
|
452
|
+
_state.sent();
|
|
453
|
+
return [
|
|
454
|
+
4,
|
|
455
|
+
saveReleaseMintIfNeeded(context, state)
|
|
456
|
+
];
|
|
457
|
+
case 2:
|
|
458
|
+
_state.sent();
|
|
459
|
+
return [
|
|
460
|
+
4,
|
|
461
|
+
verifyReleaseCollectionIfNeeded(context, state)
|
|
462
|
+
];
|
|
463
|
+
case 3:
|
|
464
|
+
_state.sent();
|
|
465
|
+
return [
|
|
466
|
+
4,
|
|
467
|
+
attestAndSubmitIfNeeded(context, state)
|
|
468
|
+
];
|
|
469
|
+
case 4:
|
|
470
|
+
_state.sent();
|
|
471
|
+
if (!state.releaseMintAddress) {
|
|
472
|
+
throw new Error("Publication session did not resolve a release mint address");
|
|
473
|
+
}
|
|
474
|
+
return [
|
|
475
|
+
2,
|
|
476
|
+
{
|
|
477
|
+
ingestionSessionId: (_ref1 = (_publicationSession_ingestionSessionId = publicationSession.ingestionSessionId) !== null && _publicationSession_ingestionSessionId !== void 0 ? _publicationSession_ingestionSessionId : normalizedBundle.ingestionSessionId) !== null && _ref1 !== void 0 ? _ref1 : "",
|
|
478
|
+
publicationSessionId: publicationSession.id || normalizedBundle.publicationSessionId || "",
|
|
479
|
+
releaseId: normalizedBundle.releaseId || publicationSession.releaseId || "",
|
|
480
|
+
releaseMintAddress: state.releaseMintAddress,
|
|
481
|
+
collectionMintAddress: normalizedBundle.signerAuthority.appMintAddress,
|
|
482
|
+
releaseTransactionSignature: state.releaseTransactionSignature,
|
|
483
|
+
collectionTransactionSignature: state.collectionTransactionSignature,
|
|
484
|
+
attestationRequestUniqueId: (_ref2 = (_state_attestationResult_requestUniqueId = (_state_attestationResult = state.attestationResult) === null || _state_attestationResult === void 0 ? void 0 : _state_attestationResult.requestUniqueId) !== null && _state_attestationResult_requestUniqueId !== void 0 ? _state_attestationResult_requestUniqueId : publicationSession.attestationRequestUniqueId) !== null && _ref2 !== void 0 ? _ref2 : undefined,
|
|
485
|
+
hubspotTicketId: state.hubspotTicketId,
|
|
486
|
+
publicationBundle: normalizedBundle,
|
|
487
|
+
publicationSession: publicationSession
|
|
488
|
+
}
|
|
489
|
+
];
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
})();
|
|
493
|
+
}
|