edit
Republish an asset with changed metadata, services or credentials.
Usage
const = await .('did:ope:2a6ebce0af...')
const = new ()
.('A better name')
.()
const { } = await .() The builder must be constructed from a resolved asset — that is what supplies the baseline to merge over. Passing a freshly built asset throws.
Indexer-derived fields — datatokens, event, stats, and anything a client decorated the
asset with — are stripped before signing, so a republish cannot bake in a stale snapshot of
chain state.
Only services carrying a new pricing config get a new datatoken. Everything else is merged over the published services by id. A service whose files or endpoint changed gets a new id, because the id is the hash of the encrypted file object; nautilus removes the old entry so the two do not linger side by side.
Like publish, the edited DDO is signed, node-encrypted into
an envelope and stored in the remote store, and only the encrypted pointer is written on
chain.
Before any datatoken is minted, edit() runs the remote store's check(), like publish().
After put() and right before the metadata transaction it runs the store's verify(), when
the store has one, which reads the stored envelope back and checks its hash. A store that
still fails during an edit leaves the published version in place, but any datatokens already
created for re-priced services stay behind: the error names them as error.datatokens.
Within one instance, edit() waits for any publish(), completePublish(), edit() or
setAssetLifecycleState() of the same NFT still running, but it does not wait for the
previous change to be indexed. ocean-node indexes only the first metadata event of an asset
per block, so when another metadata transaction for the NFT landed in the same block (from
another instance or process), edit() throws a MetadataConflictError — see
one metadata event per block.
edit() refuses encrypt: false and, before anything is spent, a signer without the NFT's
updateMetadata permission (and deployERC20, when a re-priced service needs a datatoken),
an asset whose NFT is DEPRECATED or REVOKED_BY_PUBLISHER (read under the same per-NFT
lock, so a revoke this instance started first is seen), and an edit that sets either state
through
setLifecycleState: ocean-node does not decrypt or
index metadata for such an asset, and both states are one-way. Use
setAssetLifecycleState to move an asset there.
See lifecycle states.
The lifecycle state written with the metadata is the one the NFT has on chain when edit()
reads it, unless the builder sets one with setLifecycleState(). The state an
AssetBuilder takes over from the fetched asset is not written back, so an edit built from a
copy fetched before a setAssetLifecycleState
(or one the index has not caught up with) does not undo that change.
To change a price without touching the DDO, use
setServicePrice instead.
Returns
- Type:
PublishResponse
services contains only the services that were re-priced.
Parameters
asset
- Type:
NautilusAsset
Built from an AssetBuilder constructed with a resolved asset.
options (optional)
- Type:
PublishOptions
Same as publish.
Warnings
The same as publish, and they are printed the same
way. An edit has the asset's DID, so the missing-allow-list warning
(publish.preflight.denies_all) is printed once per node and DID, whatever the asset is named.
Editing the same asset again without an address allow list does not repeat it. The publish
that created the asset had no DID yet and was keyed by its name, so an edit after it warns
once more.
Throws
- Before any transaction: an asset not built from a resolved DDO,
encrypt: false, aDEPRECATEDorREVOKED_BY_PUBLISHERstate (requested or on chain), a missingupdateMetadataordeployERC20permission, a missing or unsupported remote store, an invalid DDO, a DDO too large for the node to decrypt, an unreachable service endpoint or file, a failing storecheck(), or anIndexerNonceStuckError(seecheckIndexerNonce). - After a datatoken was minted but before the metadata transaction: a signed DDO too
large for the node to decrypt (checked before it is stored), a failing
put(), pointer validation orverify(), a failing pricing for a re-priced service, or a metadata transaction the wallet rejected or that was mined and reverted. The error is thrown as is, witherror.datatokenslisting the datatokens this call created. Once the envelope was stored it carrieserror.stored(typeStoredBeforeFailure): the redacted pointer, the hash, and whether nautilus removed the unused object again (cleanup: 'removed'), could not ('not-removed'), or kept it because the metadata transaction had been sent and may be mined ('kept'), with the transaction's hash astxHashwhen it is known. A transaction the wallet sped up is not a failure: the replacement's receipt is the result. A metadata transaction refused for its nonce (NONCE_EXPIRED,REPLACEMENT_UNDERPRICED, "already known") that the nonce guard did not get through throws itsNonceGuardErroror the RPC's refusal; its envelope is removed only when the transaction is proven never mined, else kept. A refused transaction the chain already has (mined, its answer lost) is no failure: nautilus waits for it. See when a write fails and Concurrency and nonces. - After the metadata transaction was mined: a
MetadataConflictError, or theIndexingError/OceanNodeErrorofwaitForIndexer. Each carries the fullPublishResponseaserror.published(typePublishedNotIndexed) — seePublishResponse.