Skip to content

Commit

Permalink
Support multiple publishers
Browse files Browse the repository at this point in the history
  • Loading branch information
zengxinhai committed Jun 28, 2023
1 parent 6f32ccc commit 3345daa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/advance/publish-package-empower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const publishPackageEmpower = async (
writeTomlForNetworkType(pkgPath, res.packageId, networkType);
}
if (publishResultParser) {
const defaultPublishResult = { packageId: res.packageId, upgradeCapId: res.upgradeCapId, publisherId: res.publisherId };
const defaultPublishResult = { packageId: res.packageId, upgradeCapId: res.upgradeCapId, publisherIds: res.publisherIds };
const parsedPublishResult = publishResultParser(res);
const output = { ...defaultPublishResult, ...parsedPublishResult };
writeAsJson(output, path.join(pkgPath, `publish-result.${networkType}.json`));
Expand Down
9 changes: 4 additions & 5 deletions src/lib/publish-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const defaultPublishOptions: PublishOptions = {
export type PackagePublishResult = {
packageId: string,
upgradeCapId: string,
publisherId?: string,
publisherIds: string[],
created: { type: string; objectId: string, owner: string }[],
publishTxn: SuiTransactionBlockResponse,
}
Expand Down Expand Up @@ -59,7 +59,7 @@ export const publishPackage = async (suiBinPath: string, packagePath: string, si
// If the publish transaction is successful, retrieve the packageId from the 'publish' event
// Otherwise, return empty data
if (getExecutionStatusType(publishTxn) === 'success') {
const { packageId, upgradeCapId, publisherId, created } = parsePublishTxn(publishTxn);
const { packageId, upgradeCapId, publisherIds, created } = parsePublishTxn(publishTxn);
console.log('Successfully published package\n'.green)
console.log('==============Created objects=============='.gray)
created.forEach(({ type, objectId , owner}) => {
Expand All @@ -70,10 +70,9 @@ export const publishPackage = async (suiBinPath: string, packagePath: string, si
console.log('==============Package info=============='.gray)
console.log('PackageId: '.gray, packageId.blue.bold)
console.log('UpgradeCapId: '.gray, upgradeCapId.blue.bold, '\n')
publisherId && console.log('PublisherId: '.gray, publisherId.blue.bold, '\n')
return { packageId, publishTxn, created, upgradeCapId, publisherId };
return { packageId, publishTxn, created, upgradeCapId, publisherIds };
} else {
console.error('Publish package failed!'.red)
return { packageId: '', publishTxn, created: [], upgradeCapId: '' };
return { packageId: '', publishTxn, created: [], upgradeCapId: '', publisherIds: [] };
}
}
4 changes: 2 additions & 2 deletions src/lib/sui-response-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ export const parsePublishTxn = (suiResponse: SuiTransactionBlockResponse) => {
const parseRes = {
packageId: '',
upgradeCapId: '',
publisherId: undefined as string | undefined,
publisherIds: [] as string[],
created: [] as { type: string; objectId: string, owner: string }[],
}
if (objectChanges) {
for (const change of objectChanges) {
if (change.type === 'created' && change.objectType.endsWith('package::UpgradeCap')) {
parseRes.upgradeCapId = change.objectId;
} else if (change.type === 'created' && change.objectType.endsWith('package::Publisher')) {
parseRes.publisherId = change.objectId;
parseRes.publisherIds.push(change.objectId);
} else if (change.type === 'published') {
parseRes.packageId = change.packageId;
} else if (change.type === 'created') {
Expand Down

0 comments on commit 3345daa

Please sign in to comment.