@seedprotocol/sdk 0.4.16 → 0.4.18
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/{ArweaveClient-Zz6VwCkj.js → ArweaveClient-CpShI0B0.js} +3 -3
- package/dist/{ArweaveClient-Zz6VwCkj.js.map → ArweaveClient-CpShI0B0.js.map} +1 -1
- package/dist/{ArweaveClient-DPeCeRMF.js → ArweaveClient-WfxkMgxb.js} +3 -3
- package/dist/{ArweaveClient-DPeCeRMF.js.map → ArweaveClient-WfxkMgxb.js.map} +1 -1
- package/dist/{Db-Cvoi9q3N.js → Db-29bu0gJx.js} +4 -4
- package/dist/{Db-Cvoi9q3N.js.map → Db-29bu0gJx.js.map} +1 -1
- package/dist/{Db-DsFElL33.js → Db-DWvxJG22.js} +4 -4
- package/dist/{Db-DsFElL33.js.map → Db-DWvxJG22.js.map} +1 -1
- package/dist/{EasClient-B2N8bc3C.js → EasClient-BwBg9Kkd.js} +2 -2
- package/dist/{EasClient-D5Nn1WBF.js.map → EasClient-BwBg9Kkd.js.map} +1 -1
- package/dist/{EasClient-D5Nn1WBF.js → EasClient-CtLqK_qz.js} +2 -2
- package/dist/{EasClient-B2N8bc3C.js.map → EasClient-CtLqK_qz.js.map} +1 -1
- package/dist/{FileManager-Cqy_Lq46.js → FileManager-DSihj6Sj.js} +2 -2
- package/dist/{FileManager-Cqy_Lq46.js.map → FileManager-DSihj6Sj.js.map} +1 -1
- package/dist/{FileManager-Bk-JeMoA.js → FileManager-DgraLHZS.js} +2 -2
- package/dist/{FileManager-Bk-JeMoA.js.map → FileManager-DgraLHZS.js.map} +1 -1
- package/dist/{ModelProperty-CkQaEsBu.js → ModelProperty-Bz3V3LoI.js} +24 -24
- package/dist/{ModelProperty-CkQaEsBu.js.map → ModelProperty-Bz3V3LoI.js.map} +1 -1
- package/dist/{PathResolver-DF1QFI1d.js → PathResolver-DOu-0k75.js} +2 -2
- package/dist/{PathResolver-DF1QFI1d.js.map → PathResolver-DOu-0k75.js.map} +1 -1
- package/dist/{PathResolver-C3sdR5LL.js → PathResolver-DQ5hyu8X.js} +2 -2
- package/dist/{PathResolver-C3sdR5LL.js.map → PathResolver-DQ5hyu8X.js.map} +1 -1
- package/dist/{QueryClient-CnONLIkA.js → QueryClient-CJV1m2rc.js} +2 -2
- package/dist/{QueryClient-CnONLIkA.js.map → QueryClient-CJV1m2rc.js.map} +1 -1
- package/dist/{QueryClient-Ctgd0tDn.js → QueryClient-DYaqIx7e.js} +2 -2
- package/dist/{QueryClient-Ctgd0tDn.js.map → QueryClient-DYaqIx7e.js.map} +1 -1
- package/dist/{Schema-Bnim4hAF.js → Schema-CFMbnImW.js} +38 -38
- package/dist/{Schema-Bnim4hAF.js.map → Schema-CFMbnImW.js.map} +1 -1
- package/dist/{SchemaValidationService-DXxRk-9Q.js → SchemaValidationService-D4ZVetLE.js} +2 -2
- package/dist/{SchemaValidationService-DXxRk-9Q.js.map → SchemaValidationService-D4ZVetLE.js.map} +1 -1
- package/dist/{backfillMetadataPropertyIds-dzwzz4dA.js → backfillMetadataPropertyIds-DptGKVzG.js} +2 -2
- package/dist/{backfillMetadataPropertyIds-dzwzz4dA.js.map → backfillMetadataPropertyIds-DptGKVzG.js.map} +1 -1
- package/dist/cjs/{ModelProperty-C80601ai.js → ModelProperty-TPey_B4m.js} +17 -17
- package/dist/cjs/{ModelProperty-C80601ai.js.map → ModelProperty-TPey_B4m.js.map} +1 -1
- package/dist/cjs/{Schema-6BQKp7hO.js → Schema-B-IQEtpX.js} +20 -20
- package/dist/cjs/{Schema-6BQKp7hO.js.map → Schema-B-IQEtpX.js.map} +1 -1
- package/dist/cjs/{SchemaValidationService-BySF1P0v.js → SchemaValidationService-IQ0Gc9HM.js} +2 -2
- package/dist/cjs/{SchemaValidationService-BySF1P0v.js.map → SchemaValidationService-IQ0Gc9HM.js.map} +1 -1
- package/dist/cjs/{backfillMetadataPropertyIds-D9uzW5bW.js → backfillMetadataPropertyIds-BBPgBc2W.js} +2 -2
- package/dist/cjs/{backfillMetadataPropertyIds-D9uzW5bW.js.map → backfillMetadataPropertyIds-BBPgBc2W.js.map} +1 -1
- package/dist/cjs/{getItem-Dj49AjWB.js → getItem-CWf0OO0F.js} +2 -2
- package/dist/cjs/{getItem-Dj49AjWB.js.map → getItem-CWf0OO0F.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-dR9co4rH.js → getPublishPayload-muuS1j0F.js} +519 -79
- package/dist/cjs/getPublishPayload-muuS1j0F.js.map +1 -0
- package/dist/cjs/{getPublishUploads-g61mgXaA.js → getPublishUploads-CONYV9QQ.js} +14 -8
- package/dist/cjs/getPublishUploads-CONYV9QQ.js.map +1 -0
- package/dist/cjs/{getSegmentedItemProperties-NFvOHlAi.js → getSegmentedItemProperties-Dl3J_uCe.js} +5 -4
- package/dist/cjs/getSegmentedItemProperties-Dl3J_uCe.js.map +1 -0
- package/dist/cjs/{index-9O_Ji1kY.js → index-Bte-I6OD.js} +119 -59
- package/dist/cjs/index-Bte-I6OD.js.map +1 -0
- package/dist/cjs/{index-ud9i9fpp.js → index-D7a8oFJP.js} +3 -3
- package/dist/cjs/index-D7a8oFJP.js.map +1 -0
- package/dist/cjs/{ownership-CyLRNReQ.js → ownership-Bxv6CUrH.js} +2 -2
- package/dist/cjs/{ownership-CyLRNReQ.js.map → ownership-Bxv6CUrH.js.map} +1 -1
- package/dist/cjs/{property-Hj-RhQVX.js → property-xOF5k4ka.js} +4 -4
- package/dist/cjs/{property-Hj-RhQVX.js.map → property-xOF5k4ka.js.map} +1 -1
- package/dist/{getItem-ClK0UZqi.js → getItem-Hubs_yxu.js} +2 -2
- package/dist/{getItem-ClK0UZqi.js.map → getItem-Hubs_yxu.js.map} +1 -1
- package/dist/{getPublishPayload-CdfPTl8l.js → getPublishPayload-CqUCIlu1.js} +522 -82
- package/dist/getPublishPayload-CqUCIlu1.js.map +1 -0
- package/dist/{getPublishUploads-CGBky9q9.js → getPublishUploads-QgfPyhcs.js} +14 -8
- package/dist/getPublishUploads-QgfPyhcs.js.map +1 -0
- package/dist/{getSegmentedItemProperties-CJWdYH9W.js → getSegmentedItemProperties-Dzscmm_m.js} +5 -4
- package/dist/getSegmentedItemProperties-Dzscmm_m.js.map +1 -0
- package/dist/{index-uPXtq2cf.js → index-CtzvJMAE.js} +131 -73
- package/dist/index-CtzvJMAE.js.map +1 -0
- package/dist/{index-C74KrwXN.js → index-QSl4EYun.js} +2 -2
- package/dist/index-QSl4EYun.js.map +1 -0
- package/dist/{index-CgmWq1sF.js → index-VmIdPfTW.js} +3 -3
- package/dist/index-VmIdPfTW.js.map +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +114 -18
- package/dist/main.js.map +1 -1
- package/dist/node.js +10 -10
- package/dist/{ownership-QK5haR3-.js → ownership-loPNh3_a.js} +2 -2
- package/dist/{ownership-QK5haR3-.js.map → ownership-loPNh3_a.js.map} +1 -1
- package/dist/{property-Dt0U3UXJ.js → property-D8HimAKw.js} +6 -6
- package/dist/{property-Dt0U3UXJ.js.map → property-D8HimAKw.js.map} +1 -1
- package/dist/{queries-BUB-vUBm.js → queries-DPADHnwy.js} +2 -2
- package/dist/{queries-BUB-vUBm.js.map → queries-DPADHnwy.js.map} +1 -1
- package/dist/src/Item/Item.d.ts +12 -9
- package/dist/src/Item/Item.d.ts.map +1 -1
- package/dist/src/Item/queries.d.ts +3 -3
- package/dist/src/Item/service/actors/fetchDataFromEas.d.ts +1 -1
- package/dist/src/Item/service/actors/fetchDataFromEas.d.ts.map +1 -1
- package/dist/src/Item/service/actors/hydrateExistingItem.d.ts +1 -1
- package/dist/src/Item/service/actors/hydrateNewItem.d.ts +1 -1
- package/dist/src/Item/service/actors/initialize.d.ts +1 -1
- package/dist/src/Item/service/actors/loadOrCreateItem.d.ts +2 -2
- package/dist/src/Item/service/actors/reload.d.ts +2 -2
- package/dist/src/Item/service/actors/runPublish.d.ts +2 -2
- package/dist/src/Item/service/actors/saveDataToDb.d.ts +1 -1
- package/dist/src/Item/service/actors/waitForDb.d.ts +1 -1
- package/dist/src/Item/service/itemMachineSingle.d.ts +11 -11
- package/dist/src/ItemProperty/ItemProperty.d.ts +5 -5
- package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/initialize.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/loadOrCreateProperty.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveFile.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveHtml.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts +2 -2
- package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +1 -1
- package/dist/src/ItemProperty/service/propertyMachine.d.ts +14 -14
- package/dist/src/Model/Model.d.ts +2 -2
- package/dist/src/Model/service/actors/createModelProperties.d.ts +1 -1
- package/dist/src/Model/service/actors/loadOrCreateModel.d.ts +1 -1
- package/dist/src/Model/service/actors/validateModel.d.ts +1 -1
- package/dist/src/Model/service/modelMachine.d.ts +6 -6
- package/dist/src/ModelProperty/ModelProperty.d.ts +3 -3
- package/dist/src/ModelProperty/service/actors/compareAndMarkDraft.d.ts +1 -1
- package/dist/src/ModelProperty/service/actors/saveToSchema.d.ts +1 -1
- package/dist/src/ModelProperty/service/actors/validateProperty.d.ts +1 -1
- package/dist/src/ModelProperty/service/modelPropertyMachine.d.ts +7 -7
- package/dist/src/Schema/Schema.d.ts +1 -1
- package/dist/src/Schema/service/actors/checkExistingSchema.d.ts +1 -1
- package/dist/src/Schema/service/actors/loadOrCreateSchema.d.ts +1 -1
- package/dist/src/Schema/service/actors/validateSchema.d.ts +1 -1
- package/dist/src/Schema/service/actors/writeModelsToDb.d.ts +1 -1
- package/dist/src/Schema/service/actors/writeSchemaToDb.d.ts +1 -1
- package/dist/src/Schema/service/addModelsMachine.d.ts +1 -1
- package/dist/src/Schema/service/schemaMachine.d.ts +7 -7
- package/dist/src/Schema/service/validation/SchemaValidationService.d.ts +4 -4
- package/dist/src/browser/db/Db.d.ts +2 -2
- package/dist/src/browser/helpers/ArweaveClient.d.ts +2 -2
- package/dist/src/browser/helpers/EasClient.d.ts +1 -1
- package/dist/src/browser/helpers/FileManager.d.ts +1 -1
- package/dist/src/browser/helpers/PathResolver.d.ts +1 -1
- package/dist/src/browser/helpers/QueryClient.d.ts +2 -2
- package/dist/src/browser/seed.d.ts +1 -1
- package/dist/src/client/BaseClientManager.d.ts +1 -1
- package/dist/src/client/ClientManager.d.ts +41 -41
- package/dist/src/client/actors/addModelsToDb.d.ts +1 -1
- package/dist/src/client/actors/addModelsToStore.d.ts +1 -1
- package/dist/src/client/actors/dbInit.d.ts +1 -1
- package/dist/src/client/actors/fileSystemInit.d.ts +1 -1
- package/dist/src/client/actors/platformClassesInit.d.ts +1 -1
- package/dist/src/client/actors/processSchemaFiles.d.ts +1 -1
- package/dist/src/client/actors/saveConfig.d.ts +1 -1
- package/dist/src/client/clientManagerMachine.d.ts +11 -11
- package/dist/src/client/constants.d.ts +2 -2
- package/dist/src/db/Db/BaseDb.d.ts +1 -1
- package/dist/src/db/read/getItem.d.ts +1 -1
- package/dist/src/db/read/getItemData.d.ts +1 -1
- package/dist/src/db/read/getItemProperties.d.ts +1 -1
- package/dist/src/db/read/getItemProperty.d.ts +1 -1
- package/dist/src/db/read/getItems.d.ts +1 -1
- package/dist/src/db/read/getMetadata.d.ts +1 -1
- package/dist/src/db/read/getModels.d.ts +1 -1
- package/dist/src/db/read/getPropertyData.d.ts +2 -2
- package/dist/src/db/read/getPublishPayload.d.ts +12 -4
- package/dist/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/src/db/read/getPublishPendingDiff.d.ts +25 -0
- package/dist/src/db/read/getPublishPendingDiff.d.ts.map +1 -0
- package/dist/src/db/read/getPublishUploads.d.ts +3 -3
- package/dist/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts +1 -1
- package/dist/src/db/read/getRelatedItemsForPublish.d.ts.map +1 -1
- package/dist/src/db/read/getRelationValueData.d.ts +1 -1
- package/dist/src/db/read/getSeedData.d.ts +1 -1
- package/dist/src/db/read/getVersionData.d.ts +1 -1
- package/dist/src/db/write/createMetadata.d.ts +2 -2
- package/dist/src/db/write/createNewItem.d.ts +1 -1
- package/dist/src/db/write/createSeeds.d.ts +1 -1
- package/dist/src/db/write/saveMetadata.d.ts +1 -1
- package/dist/src/db/write/updateItemPropertyValue.d.ts +1 -1
- package/dist/src/db/write/updateMetadata.d.ts +2 -2
- package/dist/src/eas.d.ts +6 -1
- package/dist/src/eas.d.ts.map +1 -1
- package/dist/src/events/files/download.d.ts +1 -1
- package/dist/src/helpers/ArweaveClient/BaseArweaveClient.d.ts +1 -1
- package/dist/src/helpers/ArweaveClient/uploadApiVerification.d.ts +1 -1
- package/dist/src/helpers/EasClient/BaseEasClient.d.ts +1 -1
- package/dist/src/helpers/QueryClient/BaseQueryClient.d.ts +1 -1
- package/dist/src/helpers/addresses.d.ts +1 -1
- package/dist/src/helpers/db.d.ts +4 -4
- package/dist/src/helpers/easPropertyCanonical.d.ts +15 -0
- package/dist/src/helpers/easPropertyCanonical.d.ts.map +1 -0
- package/dist/src/helpers/file/fetchAll/index.d.ts +1 -1
- package/dist/src/helpers/getSchemaForItemProperty.d.ts +1 -1
- package/dist/src/helpers/getSegmentedItemProperties.d.ts +6 -6
- package/dist/src/helpers/getSegmentedItemProperties.d.ts.map +1 -1
- package/dist/src/helpers/index.d.ts +3 -1
- package/dist/src/helpers/index.d.ts.map +1 -1
- package/dist/src/helpers/model.d.ts +1 -1
- package/dist/src/helpers/ownership.d.ts +1 -1
- package/dist/src/helpers/property/index.d.ts +1 -1
- package/dist/src/helpers/property.d.ts +1 -1
- package/dist/src/helpers/publishConfig.d.ts +1 -1
- package/dist/src/helpers/relationSeedRef.d.ts +8 -0
- package/dist/src/helpers/relationSeedRef.d.ts.map +1 -0
- package/dist/src/helpers/schema.d.ts +2 -2
- package/dist/src/helpers/updateSchema.d.ts +2 -2
- package/dist/src/imports/json.d.ts +1 -1
- package/dist/src/imports/markdown.d.ts +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/interfaces/IItem.d.ts +5 -3
- package/dist/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/src/interfaces/IItemProperty.d.ts +3 -3
- package/dist/src/node/codegen/drizzle.d.ts +1 -1
- package/dist/src/node/db/Db.d.ts +3 -3
- package/dist/src/node/helpers/ArweaveClient.d.ts +2 -2
- package/dist/src/node/helpers/EasClient.d.ts +1 -1
- package/dist/src/node/helpers/FileManager.d.ts +1 -1
- package/dist/src/node/helpers/PathResolver.d.ts +1 -1
- package/dist/src/node/helpers/QueryClient.d.ts +2 -2
- package/dist/src/services/publish/actors/createPublishAttempt.d.ts +1 -1
- package/dist/src/services/publish/actors/preparePublishRequestData.d.ts +1 -1
- package/dist/src/services/publish/actors/upload.d.ts +1 -1
- package/dist/src/services/publish/actors/validateItemData.d.ts +1 -1
- package/dist/src/services/publish/publishMachine.d.ts +7 -7
- package/dist/src/services/write/writeProcessMachine.d.ts +1 -1
- package/dist/src/types/db.d.ts +1 -1
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/item.d.ts +6 -6
- package/dist/src/types/machines.d.ts +2 -2
- package/dist/src/types/model.d.ts +3 -3
- package/dist/src/types/property.d.ts +3 -3
- package/dist/src/types/publish.d.ts +1 -1
- package/dist/src/types/seedProtocol.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/getPublishPayload-dR9co4rH.js.map +0 -1
- package/dist/cjs/getPublishUploads-g61mgXaA.js.map +0 -1
- package/dist/cjs/getSegmentedItemProperties-NFvOHlAi.js.map +0 -1
- package/dist/cjs/index-9O_Ji1kY.js.map +0 -1
- package/dist/cjs/index-ud9i9fpp.js.map +0 -1
- package/dist/getPublishPayload-CdfPTl8l.js.map +0 -1
- package/dist/getPublishUploads-CGBky9q9.js.map +0 -1
- package/dist/getSegmentedItemProperties-CJWdYH9W.js.map +0 -1
- package/dist/index-C74KrwXN.js.map +0 -1
- package/dist/index-CgmWq1sF.js.map +0 -1
- package/dist/index-uPXtq2cf.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var main_cjs = require('./index-
|
|
3
|
+
var main_cjs = require('./index-Bte-I6OD.js');
|
|
4
4
|
var casing = require('drizzle-orm/casing');
|
|
5
5
|
var pluralize = require('pluralize');
|
|
6
|
-
var getSegmentedItemProperties = require('./getSegmentedItemProperties-
|
|
7
|
-
var property = require('./property-
|
|
6
|
+
var getSegmentedItemProperties = require('./getSegmentedItemProperties-Dl3J_uCe.js');
|
|
7
|
+
var property = require('./property-xOF5k4ka.js');
|
|
8
8
|
var lodashEs = require('lodash-es');
|
|
9
9
|
var drizzleOrm = require('drizzle-orm');
|
|
10
10
|
var debug = require('debug');
|
|
@@ -40,6 +40,52 @@ debug('seedSdk:db:getPublishPayload');
|
|
|
40
40
|
function addValidationError(ctx, message, field, code = 'publish_validation') {
|
|
41
41
|
ctx.errors.push({ field: field ?? '', message, code });
|
|
42
42
|
}
|
|
43
|
+
function isStorageTransactionPropertyName(name) {
|
|
44
|
+
return name === 'storageTransactionId' || name === 'storage_transaction_id';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Segmentation or naming variants can leave two rows for the same logical field; keep one
|
|
48
|
+
* resolved slot so processBasicProperties emits a single storage tx attestation.
|
|
49
|
+
*/
|
|
50
|
+
function replaceStorageTransactionInBasicProperties(itemBasicProperties, resolved) {
|
|
51
|
+
const filtered = itemBasicProperties.filter((p) => !isStorageTransactionPropertyName(p.propertyName));
|
|
52
|
+
itemBasicProperties.length = 0;
|
|
53
|
+
itemBasicProperties.push(...filtered, resolved);
|
|
54
|
+
}
|
|
55
|
+
/** If multiple storageTransactionId ItemProperty rows slipped in, keep one (last wins). */
|
|
56
|
+
function dedupeOneStorageTransactionPropertyInList(itemBasicProperties) {
|
|
57
|
+
const nonStorage = [];
|
|
58
|
+
const storage = [];
|
|
59
|
+
for (const p of itemBasicProperties) {
|
|
60
|
+
if (isStorageTransactionPropertyName(p.propertyName)) {
|
|
61
|
+
storage.push(p);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
nonStorage.push(p);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (storage.length <= 1)
|
|
68
|
+
return;
|
|
69
|
+
itemBasicProperties.length = 0;
|
|
70
|
+
itemBasicProperties.push(...nonStorage, storage[storage.length - 1]);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Two relation/image props (e.g. content + featureImage) can reference the same File/Image seed.
|
|
74
|
+
* Only one child PublishPayload should exist per related seedLocalId; merge propertiesToUpdate instead.
|
|
75
|
+
*/
|
|
76
|
+
function mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedSeedLocalId, publishLocalId, propertySchemaUid) {
|
|
77
|
+
const existing = multiPublishPayload.find((p) => p.localId === relatedSeedLocalId);
|
|
78
|
+
if (!existing)
|
|
79
|
+
return false;
|
|
80
|
+
const pts = existing.propertiesToUpdate ?? [];
|
|
81
|
+
const already = pts.some((e) => e.publishLocalId === publishLocalId &&
|
|
82
|
+
String(e.propertySchemaUid ?? '').toLowerCase() ===
|
|
83
|
+
String(propertySchemaUid ?? '').toLowerCase());
|
|
84
|
+
if (!already) {
|
|
85
|
+
pts.push({ publishLocalId, propertySchemaUid });
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
43
89
|
const getVersionUid = (item) => {
|
|
44
90
|
const latestVersion = item.latestVersionUid;
|
|
45
91
|
if (latestVersion && typeof latestVersion === 'object' && latestVersion.uid) {
|
|
@@ -71,7 +117,7 @@ async function resolveVersionUid(seedLocalId, seedUid) {
|
|
|
71
117
|
return uid;
|
|
72
118
|
}
|
|
73
119
|
try {
|
|
74
|
-
const { getItemVersionsFromEas } = await Promise.resolve().then(function () { return require('./index-
|
|
120
|
+
const { getItemVersionsFromEas } = await Promise.resolve().then(function () { return require('./index-Bte-I6OD.js'); }).then(function (n) { return n.eas; });
|
|
75
121
|
const attestations = await getItemVersionsFromEas({ seedUids: [seedUid] });
|
|
76
122
|
const latest = attestations?.[0];
|
|
77
123
|
if (latest?.id)
|
|
@@ -94,9 +140,20 @@ const getPropertyData = async (itemProperty, ctx) => {
|
|
|
94
140
|
}
|
|
95
141
|
let schemaUid = itemProperty.schemaUid;
|
|
96
142
|
const ip = itemProperty;
|
|
97
|
-
const
|
|
143
|
+
const propertyDefForName = itemProperty.propertyDef;
|
|
144
|
+
let nameForEas = ip.storagePropertyName && ip.storagePropertyName.length > 0
|
|
98
145
|
? ip.storagePropertyName
|
|
99
146
|
: itemProperty.propertyName;
|
|
147
|
+
// Align List-of-relation EAS field name with processListProperty (authorIdentityIds for authors → Identity)
|
|
148
|
+
if (propertyDefForName?.dataType === main_cjs.ModelPropertyDataTypes.List &&
|
|
149
|
+
(propertyDefForName.ref || propertyDefForName.refModelName) &&
|
|
150
|
+
!(ip.storagePropertyName && ip.storagePropertyName.length > 0)) {
|
|
151
|
+
const ref = propertyDefForName.ref ?? propertyDefForName.refModelName;
|
|
152
|
+
if (ref) {
|
|
153
|
+
const singular = pluralize.singular(itemProperty.propertyName);
|
|
154
|
+
nameForEas = `${singular}${ref}Ids`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
100
157
|
const propertyNameForSchema = main_cjs.toSnakeCase(nameForEas);
|
|
101
158
|
const schemaDef = `${easDataType} ${propertyNameForSchema}`;
|
|
102
159
|
if (!schemaUid) {
|
|
@@ -130,7 +187,7 @@ const ensurePropertyDefs = async (targetItem) => {
|
|
|
130
187
|
schema = await property.getPropertySchema(targetItem.modelName, itemProperty.propertyName);
|
|
131
188
|
if (!schema) {
|
|
132
189
|
try {
|
|
133
|
-
const { Model } = await Promise.resolve().then(function () { return require('./index-
|
|
190
|
+
const { Model } = await Promise.resolve().then(function () { return require('./index-Bte-I6OD.js'); }).then(function (n) { return n.Model$1; });
|
|
134
191
|
const normalizedModelName = lodashEs.upperFirst(lodashEs.camelCase(targetItem.modelName));
|
|
135
192
|
let model = Model.getByName(normalizedModelName);
|
|
136
193
|
if (!model?.properties?.length) {
|
|
@@ -211,7 +268,8 @@ const getSchemaEncoder = async () => {
|
|
|
211
268
|
}
|
|
212
269
|
return SchemaEncoderClass;
|
|
213
270
|
};
|
|
214
|
-
const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx) => {
|
|
271
|
+
const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx, buildOpts) => {
|
|
272
|
+
const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
|
|
215
273
|
for (const basicProperty of itemBasicProperties) {
|
|
216
274
|
// Skip SDK-internal properties (e.g. publisher) - never attest to EAS
|
|
217
275
|
if (main_cjs.INTERNAL_PROPERTY_NAMES.includes(basicProperty.propertyName)) {
|
|
@@ -223,9 +281,15 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
|
|
|
223
281
|
const isFileImageHtml = propertyDef?.dataType === main_cjs.ModelPropertyDataTypes.File ||
|
|
224
282
|
propertyDef?.dataType === main_cjs.ModelPropertyDataTypes.Image ||
|
|
225
283
|
propertyDef?.dataType === main_cjs.ModelPropertyDataTypes.Html;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
284
|
+
const isJsonStorage = propertyDef?.dataType === main_cjs.ModelPropertyDataTypes.Json ||
|
|
285
|
+
propertyDef?.refValueType === main_cjs.ModelPropertyDataTypes.Json;
|
|
286
|
+
const isRelation = propertyDef?.dataType === main_cjs.ModelPropertyDataTypes.Relation;
|
|
287
|
+
// storageTransactionId is usually Text in the schema; .value still prefers renderValue (URL, label).
|
|
288
|
+
const isStorageTransactionIdProp = isStorageTransactionPropertyName(basicProperty.propertyName);
|
|
289
|
+
// File/Image/Html + Relation + Json storage + storage tx id: use propertyValue (canonical).
|
|
290
|
+
// basicProperty.value prefers renderValue (filename, blob URL, display text)—never use that for publish.
|
|
291
|
+
const preferPropertyValueForPublish = isFileImageHtml || isRelation || isJsonStorage || isStorageTransactionIdProp;
|
|
292
|
+
let value = preferPropertyValueForPublish && context
|
|
229
293
|
? context.propertyValue
|
|
230
294
|
: (basicProperty.value ??
|
|
231
295
|
(context ? context.propertyValue : undefined));
|
|
@@ -233,9 +297,31 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
|
|
|
233
297
|
if (!context) {
|
|
234
298
|
continue;
|
|
235
299
|
}
|
|
236
|
-
|
|
300
|
+
// Relation + Image/File/Html/Json refs often expose seedLocalId on context.propertyValue while .value is an object — align for encode + resolve hints
|
|
301
|
+
if (propertyDef?.dataType === main_cjs.ModelPropertyDataTypes.Relation ||
|
|
302
|
+
isFileImageHtml ||
|
|
303
|
+
isJsonStorage) {
|
|
304
|
+
const pv = context.propertyValue;
|
|
305
|
+
if (typeof value === 'object' || value == null) {
|
|
306
|
+
if (typeof pv === 'string' && pv.trim())
|
|
307
|
+
value = pv.trim();
|
|
308
|
+
else if (pv && typeof pv === 'object' && typeof pv.seedLocalId === 'string')
|
|
309
|
+
value = pv.seedLocalId;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (!value) {
|
|
237
313
|
continue;
|
|
238
314
|
}
|
|
315
|
+
// Patch mode skips properties that already have an EAS uid. storageTransactionId must still
|
|
316
|
+
// attest after Arweave upload when we have a tx id; metadata uid can be stale or set without a chain attestation.
|
|
317
|
+
if (basicProperty.uid && !forceFullSnapshot) {
|
|
318
|
+
const allowStorageTxAttestation = isStorageTransactionIdProp &&
|
|
319
|
+
typeof value === 'string' &&
|
|
320
|
+
value.trim() !== '';
|
|
321
|
+
if (!allowStorageTxAttestation) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
239
325
|
const propertyData = await getPropertyData(basicProperty, ctx);
|
|
240
326
|
if (!propertyData)
|
|
241
327
|
continue;
|
|
@@ -267,7 +353,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
|
|
|
267
353
|
}
|
|
268
354
|
// Validate against property validation rules (enum, pattern, minLength, maxLength) before encoding
|
|
269
355
|
if (propertyDef?.validation) {
|
|
270
|
-
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-
|
|
356
|
+
const { SchemaValidationService } = await Promise.resolve().then(function () { return require('./SchemaValidationService-IQ0Gc9HM.js'); });
|
|
271
357
|
const validationService = new SchemaValidationService();
|
|
272
358
|
const validationResult = validationService.validatePropertyValue(value, propertyDef.dataType, propertyDef.validation, propertyDef.refValueType);
|
|
273
359
|
if (!validationResult.isValid && validationResult.errors.length > 0) {
|
|
@@ -276,19 +362,42 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
|
|
|
276
362
|
continue;
|
|
277
363
|
}
|
|
278
364
|
}
|
|
365
|
+
/** Raw id per list slot (nanoid local id or 0x… uid) for resolvePublishPayloadValues after sequential publish */
|
|
366
|
+
let rawListIdsForResolve;
|
|
279
367
|
if (schemaDef.startsWith('bytes32[]')) {
|
|
280
368
|
const newValues = [];
|
|
369
|
+
const rawIds = [];
|
|
281
370
|
const iterableValue = Array.isArray(value) ? value
|
|
282
371
|
: value != null && typeof value[Symbol.iterator] === 'function' ? value
|
|
283
372
|
: [];
|
|
284
373
|
for (const seedId of iterableValue) {
|
|
285
|
-
|
|
286
|
-
|
|
374
|
+
const idStr = typeof seedId === 'string'
|
|
375
|
+
? seedId
|
|
376
|
+
: seedId &&
|
|
377
|
+
typeof seedId === 'object' &&
|
|
378
|
+
(seedId.seedLocalId ?? seedId.seedUid ?? seedId.localId ?? seedId.uid)
|
|
379
|
+
? String(seedId.seedLocalId ??
|
|
380
|
+
seedId.seedUid ??
|
|
381
|
+
'')
|
|
382
|
+
: '';
|
|
383
|
+
if (!idStr)
|
|
384
|
+
continue;
|
|
385
|
+
const trimmed = idStr.trim();
|
|
386
|
+
if (!trimmed)
|
|
287
387
|
continue;
|
|
388
|
+
rawIds.push(trimmed);
|
|
389
|
+
if (trimmed.length !== 66 && !trimmed.startsWith('0x')) {
|
|
390
|
+
newValues.push(ethers.ethers.encodeBytes32String(trimmed));
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
newValues.push(trimmed);
|
|
288
394
|
}
|
|
289
|
-
newValues.push(seedId);
|
|
290
395
|
}
|
|
291
396
|
value = newValues;
|
|
397
|
+
const needsUidResolve = rawIds.some((id) => id.length !== 66 || !id.startsWith('0x'));
|
|
398
|
+
if (needsUidResolve && rawIds.length > 0) {
|
|
399
|
+
rawListIdsForResolve = rawIds;
|
|
400
|
+
}
|
|
292
401
|
}
|
|
293
402
|
// uint256 (Date) must be numeric/BigInt; normalize ISO strings to Unix seconds
|
|
294
403
|
if (easDataType === 'uint256' && (typeof value === 'string' || value instanceof Date)) {
|
|
@@ -313,7 +422,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
|
|
|
313
422
|
continue;
|
|
314
423
|
}
|
|
315
424
|
// For storageTransactionId, set refUID to versionUid so it references the Version attestation (contract may use when supported)
|
|
316
|
-
const refUid =
|
|
425
|
+
const refUid = isStorageTransactionIdProp
|
|
317
426
|
? itemPublishData.versionUid
|
|
318
427
|
: main_cjs.defaultAttestationData.refUID;
|
|
319
428
|
const attestationEntry = {
|
|
@@ -327,19 +436,31 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData, ctx)
|
|
|
327
436
|
],
|
|
328
437
|
};
|
|
329
438
|
// For relation/image properties with seedLocalId, store resolution hints for resolvePublishPayloadValues
|
|
330
|
-
|
|
331
|
-
value.
|
|
439
|
+
const looksLikeLocalSeedRef = typeof value === 'string' &&
|
|
440
|
+
!value.startsWith('0x') &&
|
|
441
|
+
value.length !== 66 &&
|
|
442
|
+
/^[a-zA-Z0-9_-]{10,21}$/.test(value.trim());
|
|
443
|
+
if (looksLikeLocalSeedRef &&
|
|
332
444
|
(easDataType === 'bytes32' || easDataType === 'string')) {
|
|
333
445
|
attestationEntry._propertyName = basicProperty.propertyName;
|
|
446
|
+
attestationEntry._propertyNameForSchema = propertyNameForSchema;
|
|
334
447
|
attestationEntry._schemaDef = schemaDef;
|
|
335
|
-
attestationEntry._unresolvedValue = value;
|
|
448
|
+
attestationEntry._unresolvedValue = value.trim();
|
|
336
449
|
attestationEntry._easDataType = easDataType;
|
|
337
450
|
}
|
|
451
|
+
if (rawListIdsForResolve && rawListIdsForResolve.length > 0) {
|
|
452
|
+
attestationEntry._propertyName = basicProperty.propertyName;
|
|
453
|
+
attestationEntry._propertyNameForSchema = propertyNameForSchema;
|
|
454
|
+
attestationEntry._schemaDef = schemaDef;
|
|
455
|
+
attestationEntry._easDataType = 'bytes32[]';
|
|
456
|
+
attestationEntry._rawListIdsForResolve = rawListIdsForResolve;
|
|
457
|
+
}
|
|
338
458
|
itemPublishData.listOfAttestations.push(attestationEntry);
|
|
339
459
|
}
|
|
340
460
|
return itemPublishData;
|
|
341
461
|
};
|
|
342
|
-
const processRelationOrImageProperty = async (relationOrImageProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId, ctx) => {
|
|
462
|
+
const processRelationOrImageProperty = async (relationOrImageProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId, ctx, buildOpts) => {
|
|
463
|
+
const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
|
|
343
464
|
let relationOrImageSchemaUid = relationOrImageProperty.schemaUid;
|
|
344
465
|
if (!relationOrImageSchemaUid && relationOrImageProperty.propertyDef) {
|
|
345
466
|
const propertyData = await getPropertyData(relationOrImageProperty, ctx);
|
|
@@ -368,16 +489,23 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
368
489
|
relationOrImageProperty.propertyDef?.refValueType === main_cjs.ModelPropertyDataTypes.Image ||
|
|
369
490
|
relationOrImageProperty.propertyDef?.refValueType === main_cjs.ModelPropertyDataTypes.Html ||
|
|
370
491
|
relationOrImageProperty.propertyDef?.refValueType === main_cjs.ModelPropertyDataTypes.Json));
|
|
371
|
-
if (
|
|
372
|
-
const { getPropertyData: getPropertyDataFromDb } = await Promise.resolve().then(function () { return require('./index-
|
|
492
|
+
if (isStorageSeed && (context.seedLocalId || context.seedUid)) {
|
|
493
|
+
const { getPropertyData: getPropertyDataFromDb } = await Promise.resolve().then(function () { return require('./index-Bte-I6OD.js'); }).then(function (n) { return n.getPropertyData; });
|
|
373
494
|
const metaRow = await getPropertyDataFromDb({
|
|
374
495
|
propertyName: relationOrImageProperty.propertyName,
|
|
375
496
|
seedLocalId: context.seedLocalId,
|
|
376
497
|
seedUid: context.seedUid,
|
|
377
498
|
});
|
|
378
499
|
const fromMeta = metaRow?.propertyValue;
|
|
379
|
-
if (
|
|
380
|
-
|
|
500
|
+
if (typeof fromMeta === 'string' && fromMeta.trim() !== '') {
|
|
501
|
+
const idsCtx = main_cjs.resolveSeedIdsFromRefString(main_cjs.normalizeRelationPropertyValue(value) ?? '');
|
|
502
|
+
const idsDb = main_cjs.resolveSeedIdsFromRefString(main_cjs.normalizeRelationPropertyValue(fromMeta) ?? '');
|
|
503
|
+
if (!value) {
|
|
504
|
+
value = fromMeta;
|
|
505
|
+
}
|
|
506
|
+
else if (!idsCtx.seedLocalId && !idsCtx.seedUid && (idsDb.seedLocalId || idsDb.seedUid)) {
|
|
507
|
+
value = fromMeta;
|
|
508
|
+
}
|
|
381
509
|
}
|
|
382
510
|
}
|
|
383
511
|
const propertyDef = relationOrImageProperty.propertyDef;
|
|
@@ -431,11 +559,15 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
431
559
|
`A value pointing to a valid ${refLabel} item is required to publish.`, relationOrImageProperty.propertyName);
|
|
432
560
|
return multiPublishPayload;
|
|
433
561
|
}
|
|
434
|
-
if (!value
|
|
562
|
+
if (!value) {
|
|
563
|
+
return multiPublishPayload;
|
|
564
|
+
}
|
|
565
|
+
if (relationOrImageProperty.uid && !forceFullSnapshot) {
|
|
435
566
|
return multiPublishPayload;
|
|
436
567
|
}
|
|
437
|
-
const
|
|
438
|
-
|
|
568
|
+
const normalizedRef = main_cjs.normalizeRelationPropertyValue(value);
|
|
569
|
+
const { seedLocalId, seedUid } = main_cjs.resolveSeedIdsFromRefString(normalizedRef ?? '');
|
|
570
|
+
// Value is not a valid seed reference (local id or 0x uid)
|
|
439
571
|
if (!seedLocalId && !seedUid) {
|
|
440
572
|
if (isRequired) {
|
|
441
573
|
addValidationError(ctx, `Required relation ${relationOrImageProperty.propertyName} has invalid value: ${JSON.stringify(value)}. ` +
|
|
@@ -444,7 +576,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
444
576
|
return multiPublishPayload;
|
|
445
577
|
}
|
|
446
578
|
// Use dynamic import to break circular dependency
|
|
447
|
-
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-
|
|
579
|
+
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-CWf0OO0F.js'); });
|
|
448
580
|
const { getItem } = getItemMod;
|
|
449
581
|
const relatedItem = await getItem({
|
|
450
582
|
seedLocalId,
|
|
@@ -460,7 +592,7 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
460
592
|
return multiPublishPayload;
|
|
461
593
|
}
|
|
462
594
|
// When Image/Relation already has seedUid (published), skip creating its payload—only add the property to parent
|
|
463
|
-
if (relatedItem.seedUid) {
|
|
595
|
+
if (relatedItem.seedUid && relatedItem.seedUid !== main_cjs.ZERO_BYTES32) {
|
|
464
596
|
return multiPublishPayload;
|
|
465
597
|
}
|
|
466
598
|
const versionUid = getVersionUid(relatedItem);
|
|
@@ -487,6 +619,9 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
487
619
|
addValidationError(ctx, `Schema UID not found for model: ${modelName}`, relationOrImageProperty.propertyName);
|
|
488
620
|
return multiPublishPayload;
|
|
489
621
|
}
|
|
622
|
+
if (mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedItem.seedLocalId, originalSeedLocalId, relationOrImageSchemaUid)) {
|
|
623
|
+
return multiPublishPayload;
|
|
624
|
+
}
|
|
490
625
|
let publishPayload = {
|
|
491
626
|
localId: relatedItem.seedLocalId,
|
|
492
627
|
seedIsRevocable: true,
|
|
@@ -504,21 +639,40 @@ const processRelationOrImageProperty = async (relationOrImageProperty, multiPubl
|
|
|
504
639
|
};
|
|
505
640
|
await ensurePropertyDefs(relatedItem);
|
|
506
641
|
const { itemBasicProperties, itemUploadProperties } = await getSegmentedItemProperties.getSegmentedItemProperties(relatedItem);
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
const transactionData = uploadedTransactions.find((transaction) => transaction.seedLocalId === relatedItem.seedLocalId);
|
|
642
|
+
const relatedStorageUpload = resolveStorageTransactionUploadSlot(relatedItem, itemUploadProperties);
|
|
643
|
+
if (relatedStorageUpload) {
|
|
644
|
+
const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, relatedItem.seedLocalId);
|
|
511
645
|
if (transactionData) {
|
|
512
|
-
itemProperty
|
|
513
|
-
await
|
|
514
|
-
|
|
646
|
+
const itemProperty = relatedStorageUpload.itemProperty;
|
|
647
|
+
// Publish encoding reads context.propertyValue; do not await ItemProperty.save() here — it
|
|
648
|
+
// uses xstate waitFor(10s) for idle and can time out while the machine is busy or still loading.
|
|
649
|
+
itemProperty.getService().send({
|
|
650
|
+
type: 'updateContext',
|
|
651
|
+
propertyValue: transactionData.txId,
|
|
652
|
+
renderValue: transactionData.txId,
|
|
653
|
+
});
|
|
654
|
+
replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
|
|
515
655
|
}
|
|
516
656
|
}
|
|
517
|
-
|
|
657
|
+
for (const p of itemBasicProperties) {
|
|
658
|
+
if (isStorageTransactionPropertyName(p.propertyName) &&
|
|
659
|
+
!p.propertyDef &&
|
|
660
|
+
relatedItem.modelName) {
|
|
661
|
+
const schema = await property.getPropertySchema(relatedItem.modelName, 'storageTransactionId');
|
|
662
|
+
if (schema) {
|
|
663
|
+
p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
|
|
668
|
+
publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
|
|
669
|
+
forceFullSnapshot,
|
|
670
|
+
});
|
|
518
671
|
multiPublishPayload.push(publishPayload);
|
|
519
672
|
return multiPublishPayload;
|
|
520
673
|
};
|
|
521
|
-
const processListProperty = async (listProperty, multiPublishPayload, originalSeedLocalId, ctx) => {
|
|
674
|
+
const processListProperty = async (listProperty, multiPublishPayload, originalSeedLocalId, ctx, buildOpts) => {
|
|
675
|
+
const forceFullSnapshot = buildOpts?.forceFullSnapshot === true;
|
|
522
676
|
// processListProperty only handles list-of-relations; list-of-primitives go to itemBasicProperties
|
|
523
677
|
if (!listProperty.propertyDef?.ref) {
|
|
524
678
|
addValidationError(ctx, `processListProperty requires ref (list of relations). List property "${listProperty.propertyName}" has no ref. List-of-primitives should be in itemBasicProperties.`, listProperty.propertyName);
|
|
@@ -541,7 +695,10 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
541
695
|
return multiPublishPayload;
|
|
542
696
|
}
|
|
543
697
|
let value = context.propertyValue;
|
|
544
|
-
if (!value
|
|
698
|
+
if (!value) {
|
|
699
|
+
return multiPublishPayload;
|
|
700
|
+
}
|
|
701
|
+
if (listProperty.uid && !forceFullSnapshot) {
|
|
545
702
|
return multiPublishPayload;
|
|
546
703
|
}
|
|
547
704
|
const singularPropertyName = pluralize.singular(listProperty.propertyName);
|
|
@@ -566,7 +723,7 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
566
723
|
if (!seedLocalId && !seedUid)
|
|
567
724
|
continue;
|
|
568
725
|
// Use dynamic import to break circular dependency
|
|
569
|
-
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-
|
|
726
|
+
const getItemMod = await Promise.resolve().then(function () { return require('./getItem-CWf0OO0F.js'); });
|
|
570
727
|
const { getItem } = getItemMod;
|
|
571
728
|
const relatedItem = await getItem({
|
|
572
729
|
seedLocalId,
|
|
@@ -576,7 +733,7 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
576
733
|
console.error(`No related item found for list property: ${listProperty.propertyName}`);
|
|
577
734
|
continue;
|
|
578
735
|
}
|
|
579
|
-
if (relatedItem.seedUid) {
|
|
736
|
+
if (relatedItem.seedUid && relatedItem.seedUid !== main_cjs.ZERO_BYTES32) {
|
|
580
737
|
continue;
|
|
581
738
|
}
|
|
582
739
|
const versionUid = getVersionUid(relatedItem);
|
|
@@ -603,6 +760,9 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
603
760
|
addValidationError(ctx, `Schema UID not found for model: ${modelName}`, listProperty.propertyName);
|
|
604
761
|
continue;
|
|
605
762
|
}
|
|
763
|
+
if (mergeChildPublishPayloadIfDuplicateInBatch(multiPublishPayload, relatedItem.seedLocalId, originalSeedLocalId, listPropertySchemaUid)) {
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
606
766
|
let publishPayload = {
|
|
607
767
|
localId: relatedItem.seedLocalId,
|
|
608
768
|
seedIsRevocable: true,
|
|
@@ -620,11 +780,141 @@ const processListProperty = async (listProperty, multiPublishPayload, originalSe
|
|
|
620
780
|
};
|
|
621
781
|
await ensurePropertyDefs(relatedItem);
|
|
622
782
|
const { itemBasicProperties } = await getSegmentedItemProperties.getSegmentedItemProperties(relatedItem);
|
|
623
|
-
|
|
783
|
+
dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
|
|
784
|
+
publishPayload = await processBasicProperties(itemBasicProperties, publishPayload, ctx, {
|
|
785
|
+
forceFullSnapshot,
|
|
786
|
+
});
|
|
624
787
|
multiPublishPayload.push(publishPayload);
|
|
625
788
|
}
|
|
626
789
|
return multiPublishPayload;
|
|
627
790
|
};
|
|
791
|
+
/**
|
|
792
|
+
* Same EAS schema + same encoded attestation bytes (data field). Intentionally ignores refUID so
|
|
793
|
+
* duplicate storageTransactionId rows that only differ by ref (e.g. 0x0 vs version uid) collapse.
|
|
794
|
+
*/
|
|
795
|
+
function attestationPayloadDedupeKey(att) {
|
|
796
|
+
const schema = String(att.schema ?? '').toLowerCase();
|
|
797
|
+
const dataArr = att.data;
|
|
798
|
+
const d0 = Array.isArray(dataArr) ? dataArr[0] : undefined;
|
|
799
|
+
const dataHex = d0 && typeof d0 === 'object' && d0 !== null && 'data' in d0
|
|
800
|
+
? String(d0.data ?? '').toLowerCase()
|
|
801
|
+
: '';
|
|
802
|
+
return `${schema}:${dataHex}`;
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Collapse duplicate rows in listOfAttestations (same schema + encoded payload).
|
|
806
|
+
*/
|
|
807
|
+
function dedupeListOfAttestationsInEachPayload(payload) {
|
|
808
|
+
for (const p of payload) {
|
|
809
|
+
const list = p.listOfAttestations ?? [];
|
|
810
|
+
if (list.length <= 1)
|
|
811
|
+
continue;
|
|
812
|
+
const seen = new Set();
|
|
813
|
+
const out = [];
|
|
814
|
+
for (const a of list) {
|
|
815
|
+
const k = attestationPayloadDedupeKey(a);
|
|
816
|
+
if (seen.has(k))
|
|
817
|
+
continue;
|
|
818
|
+
seen.add(k);
|
|
819
|
+
out.push(a);
|
|
820
|
+
}
|
|
821
|
+
p.listOfAttestations = out;
|
|
822
|
+
}
|
|
823
|
+
return payload;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Merge duplicate PublishPayload rows with the same localId (ordering / batch edge cases).
|
|
827
|
+
* Dedupe listOfAttestations so identical storage tx attestations are not emitted twice.
|
|
828
|
+
*/
|
|
829
|
+
function dedupeMultiPublishPayloadByLocalId(payload) {
|
|
830
|
+
const map = new Map();
|
|
831
|
+
const order = [];
|
|
832
|
+
for (const p of payload) {
|
|
833
|
+
const id = p.localId;
|
|
834
|
+
const existing = map.get(id);
|
|
835
|
+
if (!existing) {
|
|
836
|
+
map.set(id, p);
|
|
837
|
+
order.push(id);
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
840
|
+
const ptu = [...(existing.propertiesToUpdate ?? [])];
|
|
841
|
+
for (const u of p.propertiesToUpdate ?? []) {
|
|
842
|
+
if (!ptu.some((e) => e.publishLocalId === u.publishLocalId &&
|
|
843
|
+
String(e.propertySchemaUid ?? '').toLowerCase() ===
|
|
844
|
+
String(u.propertySchemaUid ?? '').toLowerCase())) {
|
|
845
|
+
ptu.push(u);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
existing.propertiesToUpdate = ptu;
|
|
849
|
+
const seenKeys = new Set((existing.listOfAttestations ?? []).map((a) => attestationPayloadDedupeKey(a)));
|
|
850
|
+
const merged = [...(existing.listOfAttestations ?? [])];
|
|
851
|
+
for (const a of p.listOfAttestations ?? []) {
|
|
852
|
+
const k = attestationPayloadDedupeKey(a);
|
|
853
|
+
if (seenKeys.has(k))
|
|
854
|
+
continue;
|
|
855
|
+
seenKeys.add(k);
|
|
856
|
+
merged.push(a);
|
|
857
|
+
}
|
|
858
|
+
existing.listOfAttestations = merged;
|
|
859
|
+
}
|
|
860
|
+
return order.map((id) => map.get(id)).filter(Boolean);
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* Child File/Image items may keep storageTransactionId only on the item machine's
|
|
864
|
+
* propertyInstances map; allProperties / item.properties can omit it during publish.
|
|
865
|
+
*/
|
|
866
|
+
function getStorageTransactionPropertyFromItemInstances(item) {
|
|
867
|
+
try {
|
|
868
|
+
const svc = item.getService?.();
|
|
869
|
+
if (!svc)
|
|
870
|
+
return undefined;
|
|
871
|
+
const snap = svc.getSnapshot();
|
|
872
|
+
const instances = snap.context?.propertyInstances;
|
|
873
|
+
if (!instances || !(instances instanceof Map))
|
|
874
|
+
return undefined;
|
|
875
|
+
const direct = instances.get('storageTransactionId') ?? instances.get('storage_transaction_id');
|
|
876
|
+
if (direct)
|
|
877
|
+
return direct;
|
|
878
|
+
for (const [, p] of instances) {
|
|
879
|
+
if (p && isStorageTransactionPropertyName(p.propertyName))
|
|
880
|
+
return p;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
catch {
|
|
884
|
+
return undefined;
|
|
885
|
+
}
|
|
886
|
+
return undefined;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Resolve storageTransactionId (+ ItemStorage children) for publish.
|
|
890
|
+
* getSegmentedItemProperties can yield empty itemUploadProperties when the child Item never
|
|
891
|
+
* hydrated storageTransactionId into the upload bucket (e.g. only uri/metadata rows), while
|
|
892
|
+
* getStorageSeedUploads still creates an Arweave upload keyed by child seedLocalId.
|
|
893
|
+
*/
|
|
894
|
+
function resolveStorageTransactionUploadSlot(item, itemUploadProperties) {
|
|
895
|
+
const named = itemUploadProperties.find((u) => isStorageTransactionPropertyName(u.itemProperty.propertyName));
|
|
896
|
+
if (named)
|
|
897
|
+
return named;
|
|
898
|
+
if (itemUploadProperties.length === 1)
|
|
899
|
+
return itemUploadProperties[0];
|
|
900
|
+
const all = item.allProperties;
|
|
901
|
+
const fromInstances = getStorageTransactionPropertyFromItemInstances(item);
|
|
902
|
+
const storagePropEarly = all?.['storageTransactionId'] ??
|
|
903
|
+
all?.['storage_transaction_id'] ??
|
|
904
|
+
Object.values(all ?? {}).find((p) => !!p && isStorageTransactionPropertyName(p.propertyName)) ??
|
|
905
|
+
item.properties?.find((p) => isStorageTransactionPropertyName(p.propertyName));
|
|
906
|
+
const storageProp = storagePropEarly ?? fromInstances;
|
|
907
|
+
if (!storageProp)
|
|
908
|
+
return undefined;
|
|
909
|
+
const childProps = item.properties?.filter((p) => p.propertyDef &&
|
|
910
|
+
p.propertyDef.storageType === 'ItemStorage') ?? [];
|
|
911
|
+
return { itemProperty: storageProp, childProperties: childProps };
|
|
912
|
+
}
|
|
913
|
+
function findUploadedTxForSeedLocalId(uploadedTransactions, seedLocalId) {
|
|
914
|
+
const t = seedLocalId.trim();
|
|
915
|
+
return (uploadedTransactions.find((u) => u.seedLocalId === t) ??
|
|
916
|
+
uploadedTransactions.find((u) => u.seedLocalId != null && u.seedLocalId.trim() === t));
|
|
917
|
+
}
|
|
628
918
|
/** Error thrown when publish validation fails. Includes all validation errors for user to fix. */
|
|
629
919
|
class PublishValidationFailedError extends Error {
|
|
630
920
|
constructor(message, validationErrors) {
|
|
@@ -633,8 +923,13 @@ class PublishValidationFailedError extends Error {
|
|
|
633
923
|
this.name = 'PublishValidationFailedError';
|
|
634
924
|
}
|
|
635
925
|
}
|
|
636
|
-
const getPublishPayload = async (item, uploadedTransactions) => {
|
|
926
|
+
const getPublishPayload = async (item, uploadedTransactions, options) => {
|
|
637
927
|
const validationCtx = { errors: [] };
|
|
928
|
+
const publishMode = options?.publishMode ?? 'patch';
|
|
929
|
+
const forceFullSnapshot = publishMode === 'new_version';
|
|
930
|
+
if (publishMode === 'new_version' && (!item.seedUid || item.seedUid === main_cjs.ZERO_BYTES32)) {
|
|
931
|
+
addValidationError(validationCtx, 'Publishing as a new version requires the item to already have a published Seed attestation (seed UID).', 'seedUid', 'publish_new_version_requires_seed');
|
|
932
|
+
}
|
|
638
933
|
let multiPublishPayload = [];
|
|
639
934
|
// Each PublishPayload is generated from a Seed that needs publishing
|
|
640
935
|
// First we need to determine all Seeds to publish
|
|
@@ -655,6 +950,9 @@ const getPublishPayload = async (item, uploadedTransactions) => {
|
|
|
655
950
|
if (versionUid === main_cjs.ZERO_BYTES32 && item.seedUid && item.seedUid !== main_cjs.ZERO_BYTES32) {
|
|
656
951
|
versionUid = await resolveVersionUid(item.seedLocalId, item.seedUid);
|
|
657
952
|
}
|
|
953
|
+
if (forceFullSnapshot && item.seedUid && item.seedUid !== main_cjs.ZERO_BYTES32) {
|
|
954
|
+
versionUid = main_cjs.ZERO_BYTES32;
|
|
955
|
+
}
|
|
658
956
|
let itemPublishData = {
|
|
659
957
|
localId: item.seedLocalId,
|
|
660
958
|
seedUid: item.seedUid || main_cjs.ZERO_BYTES32,
|
|
@@ -701,33 +999,47 @@ const getPublishPayload = async (item, uploadedTransactions) => {
|
|
|
701
999
|
`A value pointing to a valid ${refModel} item is required to publish.`, relProp.propertyName);
|
|
702
1000
|
}
|
|
703
1001
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const
|
|
707
|
-
const transactionData = uploadedTransactions.find((transaction) => transaction.seedLocalId === item.seedLocalId);
|
|
1002
|
+
const rootStorageUpload = resolveStorageTransactionUploadSlot(item, itemUploadProperties);
|
|
1003
|
+
if (rootStorageUpload) {
|
|
1004
|
+
const transactionData = findUploadedTxForSeedLocalId(uploadedTransactions, item.seedLocalId);
|
|
708
1005
|
if (transactionData) {
|
|
709
|
-
itemProperty
|
|
710
|
-
|
|
711
|
-
|
|
1006
|
+
const itemProperty = rootStorageUpload.itemProperty;
|
|
1007
|
+
itemProperty.getService().send({
|
|
1008
|
+
type: 'updateContext',
|
|
1009
|
+
propertyValue: transactionData.txId,
|
|
1010
|
+
renderValue: transactionData.txId,
|
|
1011
|
+
});
|
|
1012
|
+
replaceStorageTransactionInBasicProperties(itemBasicProperties, itemProperty);
|
|
712
1013
|
}
|
|
713
1014
|
}
|
|
714
1015
|
for (const relationProperty of relationAndImageProperties) {
|
|
715
|
-
multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx);
|
|
1016
|
+
multiPublishPayload = await processRelationOrImageProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId, validationCtx, { forceFullSnapshot });
|
|
716
1017
|
itemBasicProperties.push(relationProperty);
|
|
717
1018
|
}
|
|
718
1019
|
for (const listProperty of itemListProperties) {
|
|
719
|
-
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, item.seedLocalId, validationCtx);
|
|
1020
|
+
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, item.seedLocalId, validationCtx, { forceFullSnapshot });
|
|
720
1021
|
itemBasicProperties.push(listProperty);
|
|
721
1022
|
}
|
|
722
|
-
|
|
1023
|
+
for (const p of itemBasicProperties) {
|
|
1024
|
+
if (isStorageTransactionPropertyName(p.propertyName) && !p.propertyDef && item.modelName) {
|
|
1025
|
+
const schema = await property.getPropertySchema(item.modelName, 'storageTransactionId');
|
|
1026
|
+
if (schema) {
|
|
1027
|
+
p.getService().send({ type: 'updateContext', propertyRecordSchema: schema });
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
dedupeOneStorageTransactionPropertyInList(itemBasicProperties);
|
|
1032
|
+
itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData, validationCtx, { forceFullSnapshot });
|
|
723
1033
|
multiPublishPayload.push(itemPublishData);
|
|
724
1034
|
// Ensure requests are ordered so that when A has propertiesToUpdate pointing to B (publishLocalId),
|
|
725
1035
|
// A (the updater) is published before B (the updatee). The contract injects A's seedUid into B's
|
|
726
1036
|
// attestation before B is sent to EAS.
|
|
1037
|
+
multiPublishPayload = dedupeMultiPublishPayloadByLocalId(multiPublishPayload);
|
|
727
1038
|
multiPublishPayload = orderPayloadByDependencies(multiPublishPayload);
|
|
728
1039
|
// Ensure attestations referenced in propertiesToUpdate have at least one data element.
|
|
729
1040
|
// The contract writes the seed UID into data[0].data; empty data causes Panic 50.
|
|
730
1041
|
multiPublishPayload = ensurePropertiesToUpdateAttestationsHaveData(multiPublishPayload);
|
|
1042
|
+
multiPublishPayload = dedupeListOfAttestationsInEachPayload(multiPublishPayload);
|
|
731
1043
|
if (validationCtx.errors.length > 0) {
|
|
732
1044
|
const combinedMessage = validationCtx.errors.map((e) => e.message).join('\n');
|
|
733
1045
|
throw new PublishValidationFailedError(`Validation failed (${validationCtx.errors.length} error${validationCtx.errors.length === 1 ? '' : 's'}):\n${combinedMessage}`, validationCtx.errors);
|
|
@@ -739,9 +1051,9 @@ const getPublishPayload = async (item, uploadedTransactions) => {
|
|
|
739
1051
|
* Use in the checking step to fail fast before creating transactions.
|
|
740
1052
|
* Pass empty array for uploadedTransactions when validating before Arweave upload.
|
|
741
1053
|
*/
|
|
742
|
-
const validateItemForPublish = async (item, uploadedTransactions = []) => {
|
|
1054
|
+
const validateItemForPublish = async (item, uploadedTransactions = [], options) => {
|
|
743
1055
|
try {
|
|
744
|
-
await getPublishPayload(item, uploadedTransactions);
|
|
1056
|
+
await getPublishPayload(item, uploadedTransactions, options);
|
|
745
1057
|
return { isValid: true, errors: [] };
|
|
746
1058
|
}
|
|
747
1059
|
catch (err) {
|
|
@@ -796,37 +1108,110 @@ function ensurePropertiesToUpdateAttestationsHaveData(payload) {
|
|
|
796
1108
|
return payload;
|
|
797
1109
|
}
|
|
798
1110
|
/**
|
|
799
|
-
*
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1111
|
+
* LocalIds in this batch referenced by attestations (bytes32 / bytes32[]) that must publish before this request.
|
|
1112
|
+
*/
|
|
1113
|
+
function collectAttestationLocalRefIds(req, allLocalIds) {
|
|
1114
|
+
const refs = [];
|
|
1115
|
+
for (const a of req.listOfAttestations ?? []) {
|
|
1116
|
+
const att = a;
|
|
1117
|
+
if (att._unresolvedValue && allLocalIds.has(att._unresolvedValue)) {
|
|
1118
|
+
refs.push(att._unresolvedValue);
|
|
1119
|
+
}
|
|
1120
|
+
if (Array.isArray(att._rawListIdsForResolve)) {
|
|
1121
|
+
for (const id of att._rawListIdsForResolve) {
|
|
1122
|
+
const t = id != null ? String(id).trim() : '';
|
|
1123
|
+
if (t && allLocalIds.has(t))
|
|
1124
|
+
refs.push(t);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return refs;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Topological sort (Kahn): edge `from → to` means `from` must publish before `to`.
|
|
1132
|
+
* - propertiesToUpdate: updater before updatee (contract injection).
|
|
1133
|
+
* - _unresolvedValue / _rawListIdsForResolve: referenced seed before request that encodes the ref.
|
|
1134
|
+
* The previous DFS visit could order [Post, Image] when Post appeared first in the input array,
|
|
1135
|
+
* so resolvedUids was empty when Post was published and attestations kept local ids.
|
|
803
1136
|
*/
|
|
804
1137
|
function orderPayloadByDependencies(payload) {
|
|
1138
|
+
if (payload.length <= 1)
|
|
1139
|
+
return payload;
|
|
805
1140
|
const byLocalId = new Map();
|
|
806
|
-
|
|
1141
|
+
const allIds = new Set();
|
|
1142
|
+
const indexOrder = new Map();
|
|
1143
|
+
for (let i = 0; i < payload.length; i++) {
|
|
1144
|
+
const p = payload[i];
|
|
807
1145
|
byLocalId.set(p.localId, p);
|
|
1146
|
+
allIds.add(p.localId);
|
|
1147
|
+
indexOrder.set(p.localId, i);
|
|
808
1148
|
}
|
|
809
|
-
const
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
|
|
1149
|
+
const indegree = new Map();
|
|
1150
|
+
for (const id of allIds)
|
|
1151
|
+
indegree.set(id, 0);
|
|
1152
|
+
const adj = new Map();
|
|
1153
|
+
const addEdge = (from, to) => {
|
|
1154
|
+
if (from === to || !allIds.has(from) || !allIds.has(to))
|
|
813
1155
|
return;
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
1156
|
+
if (!adj.has(from))
|
|
1157
|
+
adj.set(from, new Set());
|
|
1158
|
+
const set = adj.get(from);
|
|
1159
|
+
if (set.has(to))
|
|
817
1160
|
return;
|
|
818
|
-
|
|
1161
|
+
set.add(to);
|
|
1162
|
+
indegree.set(to, (indegree.get(to) ?? 0) + 1);
|
|
1163
|
+
};
|
|
1164
|
+
for (const p of payload) {
|
|
819
1165
|
for (const u of p.propertiesToUpdate ?? []) {
|
|
820
1166
|
const targetId = u.publishLocalId;
|
|
821
|
-
if (targetId && targetId !== localId)
|
|
822
|
-
|
|
1167
|
+
if (targetId && targetId !== p.localId)
|
|
1168
|
+
addEdge(p.localId, targetId);
|
|
1169
|
+
}
|
|
1170
|
+
for (const refId of collectAttestationLocalRefIds(p, allIds)) {
|
|
1171
|
+
addEdge(refId, p.localId);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
const zero = [];
|
|
1175
|
+
for (const id of allIds) {
|
|
1176
|
+
if ((indegree.get(id) ?? 0) === 0)
|
|
1177
|
+
zero.push(id);
|
|
1178
|
+
}
|
|
1179
|
+
zero.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0));
|
|
1180
|
+
const result = [];
|
|
1181
|
+
const queue = zero;
|
|
1182
|
+
while (queue.length > 0) {
|
|
1183
|
+
const id = queue.shift();
|
|
1184
|
+
const p = byLocalId.get(id);
|
|
1185
|
+
if (p)
|
|
1186
|
+
result.push(p);
|
|
1187
|
+
for (const to of adj.get(id) ?? []) {
|
|
1188
|
+
const next = (indegree.get(to) ?? 0) - 1;
|
|
1189
|
+
indegree.set(to, next);
|
|
1190
|
+
if (next === 0) {
|
|
1191
|
+
queue.push(to);
|
|
1192
|
+
queue.sort((a, b) => (indexOrder.get(a) ?? 0) - (indexOrder.get(b) ?? 0));
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
if (result.length !== payload.length) {
|
|
1197
|
+
const seen = new Set(result.map((r) => r.localId));
|
|
1198
|
+
for (const p of payload) {
|
|
1199
|
+
if (!seen.has(p.localId))
|
|
1200
|
+
result.push(p);
|
|
823
1201
|
}
|
|
824
|
-
};
|
|
825
|
-
for (const p of payload) {
|
|
826
|
-
visit(p.localId);
|
|
827
1202
|
}
|
|
828
1203
|
return result;
|
|
829
1204
|
}
|
|
1205
|
+
/** Normalize attestation UID to 32-byte hex for SchemaEncoder bytes32 fields. */
|
|
1206
|
+
function padUidForBytes32Schema(uid) {
|
|
1207
|
+
const t = uid.trim();
|
|
1208
|
+
if (!t.startsWith('0x'))
|
|
1209
|
+
return uid;
|
|
1210
|
+
const hex = t.slice(2).replace(/[^0-9a-fA-F]/g, '');
|
|
1211
|
+
if (hex.length === 0)
|
|
1212
|
+
return uid;
|
|
1213
|
+
return ('0x' + hex.padStart(64, '0').slice(-64)).toLowerCase();
|
|
1214
|
+
}
|
|
830
1215
|
/**
|
|
831
1216
|
* Resolves relation/image property values (seedLocalId) to attestation uids after dependent seeds are published.
|
|
832
1217
|
* Call after each payload is published, passing the returned attestation uid for that seed's localId.
|
|
@@ -842,15 +1227,70 @@ const resolvePublishPayloadValues = async (multiPayload, resolvedUids) => {
|
|
|
842
1227
|
const updatedAttestations = [];
|
|
843
1228
|
for (const attestation of payload.listOfAttestations) {
|
|
844
1229
|
const entry = attestation;
|
|
1230
|
+
const rawList = entry._rawListIdsForResolve;
|
|
1231
|
+
if (rawList &&
|
|
1232
|
+
rawList.length > 0 &&
|
|
1233
|
+
entry._schemaDef &&
|
|
1234
|
+
(entry._propertyNameForSchema || entry._propertyName)) {
|
|
1235
|
+
const fieldName = entry._propertyNameForSchema ?? main_cjs.toSnakeCase(entry._propertyName);
|
|
1236
|
+
const resolvedValues = [];
|
|
1237
|
+
let allSlotsResolved = true;
|
|
1238
|
+
for (const id of rawList) {
|
|
1239
|
+
const trimmed = id.trim();
|
|
1240
|
+
if (trimmed.length === 66 && trimmed.startsWith('0x')) {
|
|
1241
|
+
resolvedValues.push(padUidForBytes32Schema(trimmed));
|
|
1242
|
+
continue;
|
|
1243
|
+
}
|
|
1244
|
+
const r = resolvedUids[trimmed];
|
|
1245
|
+
if (r) {
|
|
1246
|
+
resolvedValues.push(padUidForBytes32Schema(r));
|
|
1247
|
+
continue;
|
|
1248
|
+
}
|
|
1249
|
+
allSlotsResolved = false;
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
// Do not encode or clear hints until every slot has a real uid — otherwise sequential
|
|
1253
|
+
// publish burns encodeBytes32String(localId) into data and drops _rawListIdsForResolve.
|
|
1254
|
+
if (!allSlotsResolved) {
|
|
1255
|
+
updatedAttestations.push({
|
|
1256
|
+
...entry,
|
|
1257
|
+
data: Array.isArray(entry.data) ? entry.data : [entry.data],
|
|
1258
|
+
});
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
const dataEncoder = new SchemaEncoder(entry._schemaDef);
|
|
1262
|
+
const encodedData = dataEncoder.encodeData([
|
|
1263
|
+
{
|
|
1264
|
+
name: fieldName,
|
|
1265
|
+
type: 'bytes32[]',
|
|
1266
|
+
value: resolvedValues,
|
|
1267
|
+
},
|
|
1268
|
+
]);
|
|
1269
|
+
const baseData = Array.isArray(entry.data) ? entry.data[0] : entry.data;
|
|
1270
|
+
updatedAttestations.push({
|
|
1271
|
+
...entry,
|
|
1272
|
+
data: [
|
|
1273
|
+
{
|
|
1274
|
+
...baseData,
|
|
1275
|
+
data: encodedData,
|
|
1276
|
+
},
|
|
1277
|
+
],
|
|
1278
|
+
_rawListIdsForResolve: undefined,
|
|
1279
|
+
_easDataType: undefined,
|
|
1280
|
+
});
|
|
1281
|
+
continue;
|
|
1282
|
+
}
|
|
845
1283
|
const resolvedUid = entry._unresolvedValue && resolvedUids[entry._unresolvedValue];
|
|
846
|
-
|
|
847
|
-
|
|
1284
|
+
const easType = entry._easDataType || 'bytes32';
|
|
1285
|
+
if (resolvedUid && entry._schemaDef && (entry._propertyNameForSchema || entry._propertyName)) {
|
|
1286
|
+
const fieldName = entry._propertyNameForSchema ?? main_cjs.toSnakeCase(entry._propertyName);
|
|
1287
|
+
const valueForEncode = easType === 'bytes32' ? padUidForBytes32Schema(resolvedUid) : resolvedUid;
|
|
848
1288
|
const dataEncoder = new SchemaEncoder(entry._schemaDef);
|
|
849
1289
|
const encodedData = dataEncoder.encodeData([
|
|
850
1290
|
{
|
|
851
|
-
name:
|
|
852
|
-
type:
|
|
853
|
-
value:
|
|
1291
|
+
name: fieldName,
|
|
1292
|
+
type: easType,
|
|
1293
|
+
value: valueForEncode,
|
|
854
1294
|
},
|
|
855
1295
|
]);
|
|
856
1296
|
const baseData = Array.isArray(entry.data) ? entry.data[0] : entry.data;
|
|
@@ -885,4 +1325,4 @@ exports.PublishValidationFailedError = PublishValidationFailedError;
|
|
|
885
1325
|
exports.getPublishPayload = getPublishPayload;
|
|
886
1326
|
exports.resolvePublishPayloadValues = resolvePublishPayloadValues;
|
|
887
1327
|
exports.validateItemForPublish = validateItemForPublish;
|
|
888
|
-
//# sourceMappingURL=getPublishPayload-
|
|
1328
|
+
//# sourceMappingURL=getPublishPayload-muuS1j0F.js.map
|