@originals/sdk 1.1.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/.eslintrc.json +33 -0
- package/.turbo/turbo-build.log +1 -0
- package/.turbo/turbo-test.log +68353 -0
- package/dist/adapters/FeeOracleMock.d.ts +6 -0
- package/dist/adapters/FeeOracleMock.js +8 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/providers/OrdHttpProvider.d.ts +56 -0
- package/dist/adapters/providers/OrdHttpProvider.js +110 -0
- package/dist/adapters/providers/OrdMockProvider.d.ts +70 -0
- package/dist/adapters/providers/OrdMockProvider.js +75 -0
- package/dist/adapters/types.d.ts +71 -0
- package/dist/adapters/types.js +1 -0
- package/dist/bitcoin/BitcoinManager.d.ts +15 -0
- package/dist/bitcoin/BitcoinManager.js +262 -0
- package/dist/bitcoin/BroadcastClient.d.ts +30 -0
- package/dist/bitcoin/BroadcastClient.js +35 -0
- package/dist/bitcoin/OrdinalsClient.d.ts +21 -0
- package/dist/bitcoin/OrdinalsClient.js +105 -0
- package/dist/bitcoin/PSBTBuilder.d.ts +24 -0
- package/dist/bitcoin/PSBTBuilder.js +80 -0
- package/dist/bitcoin/fee-calculation.d.ts +14 -0
- package/dist/bitcoin/fee-calculation.js +31 -0
- package/dist/bitcoin/providers/OrdNodeProvider.d.ts +38 -0
- package/dist/bitcoin/providers/OrdNodeProvider.js +67 -0
- package/dist/bitcoin/providers/OrdinalsProvider.d.ts +33 -0
- package/dist/bitcoin/providers/OrdinalsProvider.js +50 -0
- package/dist/bitcoin/providers/types.d.ts +63 -0
- package/dist/bitcoin/providers/types.js +1 -0
- package/dist/bitcoin/transactions/commit.d.ts +89 -0
- package/dist/bitcoin/transactions/commit.js +311 -0
- package/dist/bitcoin/transactions/index.d.ts +7 -0
- package/dist/bitcoin/transactions/index.js +8 -0
- package/dist/bitcoin/transfer.d.ts +9 -0
- package/dist/bitcoin/transfer.js +26 -0
- package/dist/bitcoin/utxo-selection.d.ts +78 -0
- package/dist/bitcoin/utxo-selection.js +237 -0
- package/dist/bitcoin/utxo.d.ts +26 -0
- package/dist/bitcoin/utxo.js +78 -0
- package/dist/contexts/credentials-v1.json +195 -0
- package/dist/contexts/credentials-v2-examples.json +5 -0
- package/dist/contexts/credentials-v2.json +301 -0
- package/dist/contexts/credentials.json +195 -0
- package/dist/contexts/data-integrity-v2.json +81 -0
- package/dist/contexts/dids.json +57 -0
- package/dist/contexts/ed255192020.json +93 -0
- package/dist/contexts/ordinals-plus.json +23 -0
- package/dist/contexts/originals.json +22 -0
- package/dist/core/OriginalsSDK.d.ts +158 -0
- package/dist/core/OriginalsSDK.js +274 -0
- package/dist/crypto/Multikey.d.ts +30 -0
- package/dist/crypto/Multikey.js +149 -0
- package/dist/crypto/Signer.d.ts +21 -0
- package/dist/crypto/Signer.js +196 -0
- package/dist/crypto/noble-init.d.ts +18 -0
- package/dist/crypto/noble-init.js +106 -0
- package/dist/did/BtcoDidResolver.d.ts +57 -0
- package/dist/did/BtcoDidResolver.js +166 -0
- package/dist/did/DIDManager.d.ts +101 -0
- package/dist/did/DIDManager.js +493 -0
- package/dist/did/Ed25519Verifier.d.ts +30 -0
- package/dist/did/Ed25519Verifier.js +59 -0
- package/dist/did/KeyManager.d.ts +17 -0
- package/dist/did/KeyManager.js +207 -0
- package/dist/did/WebVHManager.d.ts +100 -0
- package/dist/did/WebVHManager.js +304 -0
- package/dist/did/createBtcoDidDocument.d.ts +10 -0
- package/dist/did/createBtcoDidDocument.js +42 -0
- package/dist/did/providers/OrdinalsClientProviderAdapter.d.ts +23 -0
- package/dist/did/providers/OrdinalsClientProviderAdapter.js +51 -0
- package/dist/events/EventEmitter.d.ts +115 -0
- package/dist/events/EventEmitter.js +198 -0
- package/dist/events/index.d.ts +7 -0
- package/dist/events/index.js +6 -0
- package/dist/events/types.d.ts +286 -0
- package/dist/events/types.js +9 -0
- package/dist/examples/basic-usage.d.ts +3 -0
- package/dist/examples/basic-usage.js +62 -0
- package/dist/examples/run.d.ts +1 -0
- package/dist/examples/run.js +4 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +47 -0
- package/dist/lifecycle/BatchOperations.d.ts +147 -0
- package/dist/lifecycle/BatchOperations.js +251 -0
- package/dist/lifecycle/LifecycleManager.d.ts +116 -0
- package/dist/lifecycle/LifecycleManager.js +971 -0
- package/dist/lifecycle/OriginalsAsset.d.ts +164 -0
- package/dist/lifecycle/OriginalsAsset.js +380 -0
- package/dist/lifecycle/ProvenanceQuery.d.ts +126 -0
- package/dist/lifecycle/ProvenanceQuery.js +220 -0
- package/dist/lifecycle/ResourceVersioning.d.ts +73 -0
- package/dist/lifecycle/ResourceVersioning.js +127 -0
- package/dist/migration/MigrationManager.d.ts +86 -0
- package/dist/migration/MigrationManager.js +412 -0
- package/dist/migration/audit/AuditLogger.d.ts +51 -0
- package/dist/migration/audit/AuditLogger.js +156 -0
- package/dist/migration/checkpoint/CheckpointManager.d.ts +31 -0
- package/dist/migration/checkpoint/CheckpointManager.js +96 -0
- package/dist/migration/checkpoint/CheckpointStorage.d.ts +26 -0
- package/dist/migration/checkpoint/CheckpointStorage.js +89 -0
- package/dist/migration/index.d.ts +22 -0
- package/dist/migration/index.js +27 -0
- package/dist/migration/operations/BaseMigration.d.ts +48 -0
- package/dist/migration/operations/BaseMigration.js +83 -0
- package/dist/migration/operations/PeerToBtcoMigration.d.ts +25 -0
- package/dist/migration/operations/PeerToBtcoMigration.js +67 -0
- package/dist/migration/operations/PeerToWebvhMigration.d.ts +19 -0
- package/dist/migration/operations/PeerToWebvhMigration.js +46 -0
- package/dist/migration/operations/WebvhToBtcoMigration.d.ts +25 -0
- package/dist/migration/operations/WebvhToBtcoMigration.js +67 -0
- package/dist/migration/rollback/RollbackManager.d.ts +29 -0
- package/dist/migration/rollback/RollbackManager.js +146 -0
- package/dist/migration/state/StateMachine.d.ts +25 -0
- package/dist/migration/state/StateMachine.js +76 -0
- package/dist/migration/state/StateTracker.d.ts +36 -0
- package/dist/migration/state/StateTracker.js +123 -0
- package/dist/migration/types.d.ts +306 -0
- package/dist/migration/types.js +33 -0
- package/dist/migration/validation/BitcoinValidator.d.ts +13 -0
- package/dist/migration/validation/BitcoinValidator.js +83 -0
- package/dist/migration/validation/CredentialValidator.d.ts +13 -0
- package/dist/migration/validation/CredentialValidator.js +46 -0
- package/dist/migration/validation/DIDCompatibilityValidator.d.ts +16 -0
- package/dist/migration/validation/DIDCompatibilityValidator.js +127 -0
- package/dist/migration/validation/LifecycleValidator.d.ts +10 -0
- package/dist/migration/validation/LifecycleValidator.js +52 -0
- package/dist/migration/validation/StorageValidator.d.ts +10 -0
- package/dist/migration/validation/StorageValidator.js +65 -0
- package/dist/migration/validation/ValidationPipeline.d.ts +29 -0
- package/dist/migration/validation/ValidationPipeline.js +180 -0
- package/dist/storage/LocalStorageAdapter.d.ts +11 -0
- package/dist/storage/LocalStorageAdapter.js +53 -0
- package/dist/storage/MemoryStorageAdapter.d.ts +6 -0
- package/dist/storage/MemoryStorageAdapter.js +21 -0
- package/dist/storage/StorageAdapter.d.ts +16 -0
- package/dist/storage/StorageAdapter.js +1 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +2 -0
- package/dist/types/bitcoin.d.ts +84 -0
- package/dist/types/bitcoin.js +1 -0
- package/dist/types/common.d.ts +82 -0
- package/dist/types/common.js +1 -0
- package/dist/types/credentials.d.ts +75 -0
- package/dist/types/credentials.js +1 -0
- package/dist/types/did.d.ts +26 -0
- package/dist/types/did.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +5 -0
- package/dist/types/network.d.ts +78 -0
- package/dist/types/network.js +145 -0
- package/dist/utils/EventLogger.d.ts +71 -0
- package/dist/utils/EventLogger.js +232 -0
- package/dist/utils/Logger.d.ts +106 -0
- package/dist/utils/Logger.js +257 -0
- package/dist/utils/MetricsCollector.d.ts +110 -0
- package/dist/utils/MetricsCollector.js +264 -0
- package/dist/utils/bitcoin-address.d.ts +38 -0
- package/dist/utils/bitcoin-address.js +113 -0
- package/dist/utils/cbor.d.ts +2 -0
- package/dist/utils/cbor.js +9 -0
- package/dist/utils/encoding.d.ts +37 -0
- package/dist/utils/encoding.js +120 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +5 -0
- package/dist/utils/retry.d.ts +10 -0
- package/dist/utils/retry.js +35 -0
- package/dist/utils/satoshi-validation.d.ts +60 -0
- package/dist/utils/satoshi-validation.js +156 -0
- package/dist/utils/serialization.d.ts +14 -0
- package/dist/utils/serialization.js +76 -0
- package/dist/utils/telemetry.d.ts +17 -0
- package/dist/utils/telemetry.js +24 -0
- package/dist/utils/validation.d.ts +5 -0
- package/dist/utils/validation.js +98 -0
- package/dist/vc/CredentialManager.d.ts +22 -0
- package/dist/vc/CredentialManager.js +227 -0
- package/dist/vc/Issuer.d.ts +27 -0
- package/dist/vc/Issuer.js +70 -0
- package/dist/vc/Verifier.d.ts +16 -0
- package/dist/vc/Verifier.js +50 -0
- package/dist/vc/cryptosuites/bbs.d.ts +44 -0
- package/dist/vc/cryptosuites/bbs.js +213 -0
- package/dist/vc/cryptosuites/bbsSimple.d.ts +9 -0
- package/dist/vc/cryptosuites/bbsSimple.js +12 -0
- package/dist/vc/cryptosuites/eddsa.d.ts +30 -0
- package/dist/vc/cryptosuites/eddsa.js +81 -0
- package/dist/vc/documentLoader.d.ts +16 -0
- package/dist/vc/documentLoader.js +59 -0
- package/dist/vc/proofs/data-integrity.d.ts +21 -0
- package/dist/vc/proofs/data-integrity.js +15 -0
- package/dist/vc/utils/jsonld.d.ts +2 -0
- package/dist/vc/utils/jsonld.js +15 -0
- package/package.json +79 -0
- package/src/adapters/FeeOracleMock.ts +9 -0
- package/src/adapters/index.ts +5 -0
- package/src/adapters/providers/OrdHttpProvider.ts +126 -0
- package/src/adapters/providers/OrdMockProvider.ts +101 -0
- package/src/adapters/types.ts +66 -0
- package/src/bitcoin/BitcoinManager.ts +330 -0
- package/src/bitcoin/BroadcastClient.ts +54 -0
- package/src/bitcoin/OrdinalsClient.ts +119 -0
- package/src/bitcoin/PSBTBuilder.ts +106 -0
- package/src/bitcoin/fee-calculation.ts +38 -0
- package/src/bitcoin/providers/OrdNodeProvider.ts +92 -0
- package/src/bitcoin/providers/OrdinalsProvider.ts +56 -0
- package/src/bitcoin/providers/types.ts +59 -0
- package/src/bitcoin/transactions/commit.ts +465 -0
- package/src/bitcoin/transactions/index.ts +13 -0
- package/src/bitcoin/transfer.ts +43 -0
- package/src/bitcoin/utxo-selection.ts +322 -0
- package/src/bitcoin/utxo.ts +113 -0
- package/src/contexts/credentials-v1.json +237 -0
- package/src/contexts/credentials-v2-examples.json +5 -0
- package/src/contexts/credentials-v2.json +340 -0
- package/src/contexts/credentials.json +237 -0
- package/src/contexts/data-integrity-v2.json +81 -0
- package/src/contexts/dids.json +58 -0
- package/src/contexts/ed255192020.json +93 -0
- package/src/contexts/ordinals-plus.json +23 -0
- package/src/contexts/originals.json +22 -0
- package/src/core/OriginalsSDK.ts +416 -0
- package/src/crypto/Multikey.ts +194 -0
- package/src/crypto/Signer.ts +254 -0
- package/src/crypto/noble-init.ts +121 -0
- package/src/did/BtcoDidResolver.ts +227 -0
- package/src/did/DIDManager.ts +694 -0
- package/src/did/Ed25519Verifier.ts +68 -0
- package/src/did/KeyManager.ts +236 -0
- package/src/did/WebVHManager.ts +489 -0
- package/src/did/createBtcoDidDocument.ts +59 -0
- package/src/did/providers/OrdinalsClientProviderAdapter.ts +68 -0
- package/src/events/EventEmitter.ts +222 -0
- package/src/events/index.ts +19 -0
- package/src/events/types.ts +331 -0
- package/src/examples/basic-usage.ts +78 -0
- package/src/examples/run.ts +5 -0
- package/src/index.ts +84 -0
- package/src/lifecycle/BatchOperations.ts +373 -0
- package/src/lifecycle/LifecycleManager.ts +1218 -0
- package/src/lifecycle/OriginalsAsset.ts +524 -0
- package/src/lifecycle/ProvenanceQuery.ts +280 -0
- package/src/lifecycle/ResourceVersioning.ts +163 -0
- package/src/migration/MigrationManager.ts +527 -0
- package/src/migration/audit/AuditLogger.ts +176 -0
- package/src/migration/checkpoint/CheckpointManager.ts +112 -0
- package/src/migration/checkpoint/CheckpointStorage.ts +101 -0
- package/src/migration/index.ts +33 -0
- package/src/migration/operations/BaseMigration.ts +126 -0
- package/src/migration/operations/PeerToBtcoMigration.ts +105 -0
- package/src/migration/operations/PeerToWebvhMigration.ts +62 -0
- package/src/migration/operations/WebvhToBtcoMigration.ts +105 -0
- package/src/migration/rollback/RollbackManager.ts +170 -0
- package/src/migration/state/StateMachine.ts +92 -0
- package/src/migration/state/StateTracker.ts +156 -0
- package/src/migration/types.ts +344 -0
- package/src/migration/validation/BitcoinValidator.ts +107 -0
- package/src/migration/validation/CredentialValidator.ts +62 -0
- package/src/migration/validation/DIDCompatibilityValidator.ts +151 -0
- package/src/migration/validation/LifecycleValidator.ts +64 -0
- package/src/migration/validation/StorageValidator.ts +79 -0
- package/src/migration/validation/ValidationPipeline.ts +213 -0
- package/src/storage/LocalStorageAdapter.ts +61 -0
- package/src/storage/MemoryStorageAdapter.ts +29 -0
- package/src/storage/StorageAdapter.ts +25 -0
- package/src/storage/index.ts +3 -0
- package/src/types/bitcoin.ts +98 -0
- package/src/types/common.ts +92 -0
- package/src/types/credentials.ts +88 -0
- package/src/types/did.ts +31 -0
- package/src/types/external-shims.d.ts +53 -0
- package/src/types/index.ts +7 -0
- package/src/types/network.ts +175 -0
- package/src/utils/EventLogger.ts +298 -0
- package/src/utils/Logger.ts +322 -0
- package/src/utils/MetricsCollector.ts +358 -0
- package/src/utils/bitcoin-address.ts +130 -0
- package/src/utils/cbor.ts +12 -0
- package/src/utils/encoding.ts +127 -0
- package/src/utils/hash.ts +6 -0
- package/src/utils/retry.ts +46 -0
- package/src/utils/satoshi-validation.ts +196 -0
- package/src/utils/serialization.ts +96 -0
- package/src/utils/telemetry.ts +40 -0
- package/src/utils/validation.ts +119 -0
- package/src/vc/CredentialManager.ts +273 -0
- package/src/vc/Issuer.ts +100 -0
- package/src/vc/Verifier.ts +47 -0
- package/src/vc/cryptosuites/bbs.ts +253 -0
- package/src/vc/cryptosuites/bbsSimple.ts +21 -0
- package/src/vc/cryptosuites/eddsa.ts +99 -0
- package/src/vc/documentLoader.ts +67 -0
- package/src/vc/proofs/data-integrity.ts +33 -0
- package/src/vc/utils/jsonld.ts +18 -0
- package/test/logs/did_webvh_QmQsRNhXxPSCSeLjpbKYcNMZj8b1kBQAoC6cZmkFAgmpHt_example_com.jsonl +1 -0
- package/test/logs/did_webvh_QmSQkpD58qxcqMWHYcEmDUn3wk7hHvJwzYTrZmhh6zjPQ8_example_com_users_alice123_profile.jsonl +1 -0
- package/test/logs/did_webvh_QmTMda6VW3cUPdKk5Yc3onnv1vdgEumvWWdP2noAYFSjeG_example_com.jsonl +1 -0
- package/test/logs/did_webvh_QmTkb8KnCYcsnKKDCY4eUQuKQdKJLrCinvhw13v3zETxpE_example_com_users_etc_passwd.jsonl +1 -0
- package/test/logs/did_webvh_QmTn9FdCfpXFDrxHH52pwB4iNrDFVvNDjJ5FQTcDbmM3Fg_example_com.jsonl +1 -0
- package/test/logs/did_webvh_QmUCQUi1xjtJjnSQ1XJZgKqcWgErx1v7E2dz4DAPraAyJP_example_com_etc_passwd.jsonl +1 -0
- package/test/logs/did_webvh_QmUENQJCDKBJVRS5BkL6zjaUvcRjkb9xHmy7foCgRjmv3W_example_com.jsonl +1 -0
- package/test/logs/did_webvh_QmUPdGyjYBEnQ3aQUkmqyyBKTyjvCP5RZQGiaEDeTtf6dc_example_com.jsonl +1 -0
- package/test/logs/did_webvh_QmUoHTuHMWzQM29ZFrE9VLtMxkZ5u869yqee8LwcCLN39M_example_com.jsonl +1 -0
- package/test/logs/did_webvh_QmUrnms8G65ggVKsr9oQeWrLUBuGChwQPPb2LCFvaoNxaw_example_com_users_alice.jsonl +1 -0
- package/test/logs/did_webvh_QmUwiw3eSXdHG1hPvoAGu3cuK5jF4aXRYDLBAjPXfv1qzb_example_com_level1_level2.jsonl +1 -0
- package/test/logs/did_webvh_QmW7bzKh6yFEKNAtmVsrPGvvsMHTUQdzJSNsTZkbuGFpbj_example_com_secret.jsonl +1 -0
- package/test/logs/did_webvh_QmXbFTFBBJ8zpjdz9WE1DNN44A2wprFmdvAubjSffeyoAG_example_com.jsonl +1 -0
- package/test/logs/did_webvh_QmXyVXFPCTffGb2mTUFDeMCsScjnpLWkyUkVkB6q6QoeBf_example_com_C_Windows_System32.jsonl +1 -0
- package/test/logs/did_webvh_QmZK9B81gxZtvo5fYHYKDtKt8zZfZZPhmCMhbujBJuRRzE_example_com_etc_passwd.jsonl +1 -0
- package/test/logs/did_webvh_QmbNLCVSdXSVLrwFBvCBQPAabjtRb1SGHjkGVyw3QUbfBL_example_com_users_etc_passwd.jsonl +1 -0
- package/test/logs/did_webvh_QmbeaicmGW3Q7Yzbqmftc8a9jLBngokveb5A2KVKfVGZRb_example_com_my_org_user_name_test_123.jsonl +1 -0
- package/test/logs/did_webvh_Qmdv7c7AjUreUfoKyvkN2UpAWTozxKsv99srQetPJMJEnp_example_com_users_etc_passwd.jsonl +1 -0
- package/test/logs/did_webvh_QmeioWY3uypYLkYpCXe9eCYnn4xBVruP9C1d79azMrTEHG_example_com.jsonl +1 -0
- package/test/logs/did_webvh_Qmf4QH5dsA6Ecr5HJ6KaJL9uJRyY8RxrQdqoRCM25DzvPi_example_com_users_alice.jsonl +1 -0
- package/tests/__mocks__/bbs-signatures.js +17 -0
- package/tests/__mocks__/mf-base58.js +24 -0
- package/tests/e2e/README.md +97 -0
- package/tests/e2e/example.spec.ts +78 -0
- package/tests/fixtures/did-documents.ts +247 -0
- package/tests/index.test.ts +21 -0
- package/tests/integration/BatchOperations.test.ts +531 -0
- package/tests/integration/CompleteLifecycle.e2e.test.ts +735 -0
- package/tests/integration/CredentialManager.test.ts +42 -0
- package/tests/integration/DIDManager.test.ts +41 -0
- package/tests/integration/DidPeerToWebVhFlow.test.ts +351 -0
- package/tests/integration/Events.test.ts +435 -0
- package/tests/integration/Lifecycle.transfer.btco.integration.test.ts +25 -0
- package/tests/integration/LifecycleManager.test.ts +21 -0
- package/tests/integration/MultikeyFlow.test.ts +52 -0
- package/tests/integration/TelemetryIntegration.test.ts +395 -0
- package/tests/integration/WebVhPublish.test.ts +48 -0
- package/tests/integration/migration/peer-to-webvh.test.ts +172 -0
- package/tests/manual/test-commit-creation.ts +323 -0
- package/tests/mocks/MockKeyStore.ts +38 -0
- package/tests/mocks/adapters/MemoryStorageAdapter.ts +24 -0
- package/tests/mocks/adapters/MockFeeOracle.ts +11 -0
- package/tests/mocks/adapters/MockOrdinalsProvider.ts +76 -0
- package/tests/mocks/adapters/OrdMockProvider.test.ts +176 -0
- package/tests/mocks/adapters/index.ts +6 -0
- package/tests/performance/BatchOperations.perf.test.ts +403 -0
- package/tests/performance/logging.perf.test.ts +336 -0
- package/tests/sdk.test.ts +43 -0
- package/tests/security/bitcoin-penetration-tests.test.ts +622 -0
- package/tests/setup.bun.ts +69 -0
- package/tests/setup.jest.ts +23 -0
- package/tests/stress/batch-operations-stress.test.ts +571 -0
- package/tests/unit/adapters/FeeOracleMock.test.ts +40 -0
- package/tests/unit/bitcoin/BitcoinManager.test.ts +293 -0
- package/tests/unit/bitcoin/BroadcastClient.test.ts +52 -0
- package/tests/unit/bitcoin/OrdNodeProvider.test.ts +53 -0
- package/tests/unit/bitcoin/OrdinalsClient.test.ts +381 -0
- package/tests/unit/bitcoin/OrdinalsClientProvider.test.ts +102 -0
- package/tests/unit/bitcoin/PSBTBuilder.test.ts +84 -0
- package/tests/unit/bitcoin/fee-calculation.test.ts +261 -0
- package/tests/unit/bitcoin/transactions/commit.test.ts +649 -0
- package/tests/unit/bitcoin/transfer.test.ts +31 -0
- package/tests/unit/bitcoin/utxo-selection-new.test.ts +502 -0
- package/tests/unit/bitcoin/utxo.more.test.ts +39 -0
- package/tests/unit/bitcoin/utxo.selection.test.ts +38 -0
- package/tests/unit/core/OriginalsSDK.test.ts +152 -0
- package/tests/unit/crypto/Multikey.test.ts +206 -0
- package/tests/unit/crypto/Signer.test.ts +408 -0
- package/tests/unit/did/BtcoDidResolver.test.ts +611 -0
- package/tests/unit/did/DIDManager.more.test.ts +43 -0
- package/tests/unit/did/DIDManager.test.ts +185 -0
- package/tests/unit/did/Ed25519Verifier.test.ts +160 -0
- package/tests/unit/did/KeyManager.test.ts +452 -0
- package/tests/unit/did/OrdinalsClientProviderAdapter.test.ts +45 -0
- package/tests/unit/did/WebVHManager.test.ts +435 -0
- package/tests/unit/did/createBtcoDidDocument.test.ts +67 -0
- package/tests/unit/did/providers/OrdinalsClientProviderAdapter.test.ts +159 -0
- package/tests/unit/events/EventEmitter.test.ts +407 -0
- package/tests/unit/lifecycle/BatchOperations.test.ts +527 -0
- package/tests/unit/lifecycle/LifecycleManager.keymanagement.test.ts +312 -0
- package/tests/unit/lifecycle/LifecycleManager.prov.test.ts +18 -0
- package/tests/unit/lifecycle/LifecycleManager.test.ts +213 -0
- package/tests/unit/lifecycle/LifecycleManager.transfer.unit.test.ts +30 -0
- package/tests/unit/lifecycle/OriginalsAsset.test.ts +176 -0
- package/tests/unit/lifecycle/ProvenanceQuery.test.ts +577 -0
- package/tests/unit/lifecycle/ResourceVersioning.test.ts +651 -0
- package/tests/unit/storage/MemoryStorageAdapter.test.ts +93 -0
- package/tests/unit/types/network.test.ts +255 -0
- package/tests/unit/utils/EventIntegration.test.ts +384 -0
- package/tests/unit/utils/Logger.test.ts +473 -0
- package/tests/unit/utils/MetricsCollector.test.ts +358 -0
- package/tests/unit/utils/bitcoin-address.test.ts +250 -0
- package/tests/unit/utils/cbor.test.ts +35 -0
- package/tests/unit/utils/encoding.test.ts +318 -0
- package/tests/unit/utils/hash.test.ts +12 -0
- package/tests/unit/utils/retry.test.ts +100 -0
- package/tests/unit/utils/satoshi-validation.test.ts +354 -0
- package/tests/unit/utils/serialization.test.ts +124 -0
- package/tests/unit/utils/telemetry.test.ts +52 -0
- package/tests/unit/utils/validation.test.ts +141 -0
- package/tests/unit/vc/CredentialManager.test.ts +487 -0
- package/tests/unit/vc/Issuer.test.ts +107 -0
- package/tests/unit/vc/Verifier.test.ts +525 -0
- package/tests/unit/vc/bbs.test.ts +282 -0
- package/tests/unit/vc/cryptosuites/eddsa.test.ts +398 -0
- package/tests/unit/vc/documentLoader.test.ts +121 -0
- package/tests/unit/vc/proofs/data-integrity.test.ts +24 -0
- package/tsconfig.json +32 -0
- package/tsconfig.test.json +15 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* End-to-End Integration Test Suite for Complete Lifecycle Flow
|
|
3
|
+
*
|
|
4
|
+
* This test suite validates the complete lifecycle flow:
|
|
5
|
+
* peer → webvh → btco → transfer
|
|
6
|
+
*
|
|
7
|
+
* Key aspects tested:
|
|
8
|
+
* - Real storage adapter (MemoryStorageAdapter)
|
|
9
|
+
* - Real fee oracle (FeeOracleMock)
|
|
10
|
+
* - Real ordinals provider (OrdMockProvider)
|
|
11
|
+
* - Complete provenance tracking across all layers
|
|
12
|
+
* - Resource integrity and URL generation
|
|
13
|
+
* - Credential issuance and verification
|
|
14
|
+
* - Transfer ownership on Bitcoin layer
|
|
15
|
+
*
|
|
16
|
+
* Rationale: Found individual integration tests but no end-to-end test covering
|
|
17
|
+
* the full lifecycle. Current tests use mocks extensively. This suite provides
|
|
18
|
+
* confidence that all adapter interfaces work correctly together in a realistic flow.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { describe, test, expect, beforeEach } from 'bun:test';
|
|
22
|
+
import { OriginalsSDK } from '../../src/core/OriginalsSDK';
|
|
23
|
+
import { OriginalsAsset } from '../../src/lifecycle/OriginalsAsset';
|
|
24
|
+
import { AssetResource, OriginalsConfig } from '../../src/types';
|
|
25
|
+
import { MemoryStorageAdapter } from '../../src/storage/MemoryStorageAdapter';
|
|
26
|
+
import { FeeOracleMock } from '../../src/adapters/FeeOracleMock';
|
|
27
|
+
import { OrdMockProvider } from '../../src/adapters/providers/OrdMockProvider';
|
|
28
|
+
import { StorageAdapter as ConfigStorageAdapter } from '../../src/adapters/types';
|
|
29
|
+
import { MockKeyStore } from '../mocks/MockKeyStore';
|
|
30
|
+
import { KeyManager } from '../../src/did/KeyManager';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Helper to generate valid SHA-256 hashes (64 hex characters)
|
|
34
|
+
* Replaces non-hex characters with hex equivalents to ensure valid hash format
|
|
35
|
+
*/
|
|
36
|
+
function makeHash(prefix: string): string {
|
|
37
|
+
// Replace non-hex characters with their hex representation or '0'
|
|
38
|
+
const hexOnly = prefix.split('').map(c => {
|
|
39
|
+
if (/[0-9a-f]/i.test(c)) return c;
|
|
40
|
+
// Convert to hex char code and take last character, or use '0'
|
|
41
|
+
return c.charCodeAt(0).toString(16).slice(-1);
|
|
42
|
+
}).join('');
|
|
43
|
+
|
|
44
|
+
return hexOnly.padEnd(64, '0');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Adapter wrapper to bridge MemoryStorageAdapter to the StorageAdapter interface
|
|
49
|
+
* expected by OriginalsConfig. The main difference is method naming:
|
|
50
|
+
* - MemoryStorageAdapter uses putObject/getObject
|
|
51
|
+
* - Config expects put/get
|
|
52
|
+
*/
|
|
53
|
+
class StorageAdapterBridge implements ConfigStorageAdapter {
|
|
54
|
+
constructor(private memoryAdapter: MemoryStorageAdapter) {}
|
|
55
|
+
|
|
56
|
+
async put(objectKey: string, data: Buffer | string, options?: { contentType?: string }): Promise<string> {
|
|
57
|
+
// objectKey is in format "domain/path"
|
|
58
|
+
const firstSlash = objectKey.indexOf('/');
|
|
59
|
+
const domain = firstSlash >= 0 ? objectKey.substring(0, firstSlash) : objectKey;
|
|
60
|
+
const path = firstSlash >= 0 ? objectKey.substring(firstSlash + 1) : '';
|
|
61
|
+
|
|
62
|
+
const content = typeof data === 'string' ? Buffer.from(data) : data;
|
|
63
|
+
return await this.memoryAdapter.putObject(domain, path, new Uint8Array(content));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async get(objectKey: string): Promise<{ content: Buffer; contentType: string } | null> {
|
|
67
|
+
const firstSlash = objectKey.indexOf('/');
|
|
68
|
+
const domain = firstSlash >= 0 ? objectKey.substring(0, firstSlash) : objectKey;
|
|
69
|
+
const path = firstSlash >= 0 ? objectKey.substring(firstSlash + 1) : '';
|
|
70
|
+
|
|
71
|
+
const result = await this.memoryAdapter.getObject(domain, path);
|
|
72
|
+
if (!result) return null;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
content: Buffer.from(result.content),
|
|
76
|
+
contentType: result.contentType || 'application/octet-stream'
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async delete(objectKey: string): Promise<boolean> {
|
|
81
|
+
// Optional method, not implemented in MemoryStorageAdapter
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
describe('E2E Integration: Complete Lifecycle Flow', () => {
|
|
87
|
+
let sdk: OriginalsSDK;
|
|
88
|
+
let memoryStorage: MemoryStorageAdapter;
|
|
89
|
+
let storageAdapter: ConfigStorageAdapter;
|
|
90
|
+
let feeOracle: FeeOracleMock;
|
|
91
|
+
let ordinalsProvider: OrdMockProvider;
|
|
92
|
+
let keyStore: MockKeyStore;
|
|
93
|
+
|
|
94
|
+
beforeEach(async () => {
|
|
95
|
+
// Setup real adapters (not mocks in the sense of jest.mock, but functional test doubles)
|
|
96
|
+
memoryStorage = new MemoryStorageAdapter();
|
|
97
|
+
storageAdapter = new StorageAdapterBridge(memoryStorage);
|
|
98
|
+
feeOracle = new FeeOracleMock(7); // 7 sats/vB
|
|
99
|
+
ordinalsProvider = new OrdMockProvider();
|
|
100
|
+
keyStore = new MockKeyStore();
|
|
101
|
+
|
|
102
|
+
const config: OriginalsConfig = {
|
|
103
|
+
network: 'regtest',
|
|
104
|
+
defaultKeyType: 'Ed25519', // Use Ed25519 for did:webvh compatibility
|
|
105
|
+
enableLogging: false,
|
|
106
|
+
storageAdapter,
|
|
107
|
+
feeOracle,
|
|
108
|
+
ordinalsProvider
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
sdk = new OriginalsSDK(config, keyStore);
|
|
112
|
+
|
|
113
|
+
// Set up publisher DID keys for various test domains
|
|
114
|
+
const keyManager = new KeyManager();
|
|
115
|
+
const domains = ['domain.test', 'integrity.test', 'multi-type.test', 'large.test', 'many.test',
|
|
116
|
+
'audit.test', 'time.test', 'binding.test', 'error.test', 'adapter-test.com', 'example.com'];
|
|
117
|
+
for (const domain of domains) {
|
|
118
|
+
const publisherKey = await keyManager.generateKeyPair('Ed25519');
|
|
119
|
+
await keyStore.setPrivateKey(`did:webvh:${domain}:user#key-0`, publisherKey.privateKey);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('Complete Lifecycle: peer → webvh → btco → transfer', () => {
|
|
124
|
+
test('successfully executes full lifecycle with provenance tracking', async () => {
|
|
125
|
+
// ===== PHASE 1: Create Asset (did:peer) =====
|
|
126
|
+
const resources: AssetResource[] = [
|
|
127
|
+
{
|
|
128
|
+
id: 'resource-1',
|
|
129
|
+
type: 'image',
|
|
130
|
+
contentType: 'image/png',
|
|
131
|
+
hash: 'deadbeef1234567890abcdef1234567890abcdef1234567890abcdef12345678',
|
|
132
|
+
content: 'mock-image-data'
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: 'resource-2',
|
|
136
|
+
type: 'text',
|
|
137
|
+
contentType: 'text/plain',
|
|
138
|
+
hash: 'cafebabe1234567890abcdef1234567890abcdef1234567890abcdef12345678',
|
|
139
|
+
content: 'Hello, Originals Protocol!'
|
|
140
|
+
}
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
const asset = await sdk.lifecycle.createAsset(resources);
|
|
144
|
+
|
|
145
|
+
// Verify asset creation
|
|
146
|
+
expect(asset).toBeInstanceOf(OriginalsAsset);
|
|
147
|
+
expect(asset.currentLayer).toBe('did:peer');
|
|
148
|
+
expect(asset.id).toMatch(/^did:peer:/);
|
|
149
|
+
expect(asset.resources).toHaveLength(2);
|
|
150
|
+
expect(asset.resources[0].id).toBe('resource-1');
|
|
151
|
+
expect(asset.resources[1].id).toBe('resource-2');
|
|
152
|
+
|
|
153
|
+
// Verify initial provenance
|
|
154
|
+
const initialProvenance = asset.getProvenance();
|
|
155
|
+
expect(initialProvenance.creator).toBe(asset.id);
|
|
156
|
+
expect(initialProvenance.migrations).toHaveLength(0);
|
|
157
|
+
expect(initialProvenance.transfers).toHaveLength(0);
|
|
158
|
+
expect(initialProvenance.createdAt).toBeDefined();
|
|
159
|
+
|
|
160
|
+
// ===== PHASE 2: Publish to Web (did:webvh) =====
|
|
161
|
+
const domain = 'example.com';
|
|
162
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, domain);
|
|
163
|
+
|
|
164
|
+
// Verify web publication
|
|
165
|
+
expect(webAsset.currentLayer).toBe('did:webvh');
|
|
166
|
+
expect(webAsset.id).toBe(asset.id); // Asset ID should remain the same
|
|
167
|
+
|
|
168
|
+
// Verify did:webvh binding
|
|
169
|
+
const bindings = (webAsset as any).bindings;
|
|
170
|
+
expect(bindings).toBeDefined();
|
|
171
|
+
expect(bindings['did:webvh']).toMatch(new RegExp(`^did:webvh:${domain}:`));
|
|
172
|
+
|
|
173
|
+
// Verify resources have URLs from storage adapter
|
|
174
|
+
for (const resource of webAsset.resources) {
|
|
175
|
+
expect(resource.url).toBeDefined();
|
|
176
|
+
expect(resource.url).toMatch(/^did:webvh:/); // DID-based URL format
|
|
177
|
+
expect(resource.url).toContain('/resources/');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Verify storage adapter actually stored the resources
|
|
181
|
+
for (const resource of webAsset.resources) {
|
|
182
|
+
const url = resource.url as string;
|
|
183
|
+
// URL format is: did:webvh:domain:path/resources/hash
|
|
184
|
+
const urlParts = url.split(':');
|
|
185
|
+
const path = urlParts.slice(3).join(':');
|
|
186
|
+
const stored = await memoryStorage.getObject(domain, path);
|
|
187
|
+
expect(stored).not.toBeNull();
|
|
188
|
+
expect(stored?.content).toBeDefined();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Verify provenance after web migration
|
|
192
|
+
const webProvenance = webAsset.getProvenance();
|
|
193
|
+
expect(webProvenance.migrations).toHaveLength(1);
|
|
194
|
+
expect(webProvenance.migrations[0].from).toBe('did:peer');
|
|
195
|
+
expect(webProvenance.migrations[0].to).toBe('did:webvh');
|
|
196
|
+
expect(webProvenance.migrations[0].timestamp).toBeDefined();
|
|
197
|
+
|
|
198
|
+
// Verify publication credential was issued
|
|
199
|
+
const credentials = (webAsset as any).credentials;
|
|
200
|
+
expect(Array.isArray(credentials)).toBe(true);
|
|
201
|
+
expect(credentials.length).toBeGreaterThan(0);
|
|
202
|
+
|
|
203
|
+
const publicationCred = credentials.find((c: any) =>
|
|
204
|
+
Array.isArray(c.type) && (c.type.includes('ResourceMigrated') || c.type.includes('ResourceCreated'))
|
|
205
|
+
);
|
|
206
|
+
expect(publicationCred).toBeDefined();
|
|
207
|
+
expect(publicationCred.credentialSubject).toBeDefined();
|
|
208
|
+
expect(publicationCred.credentialSubject.fromLayer).toBe('did:peer');
|
|
209
|
+
expect(publicationCred.credentialSubject.toLayer).toBe('did:webvh');
|
|
210
|
+
|
|
211
|
+
// ===== PHASE 3: Inscribe on Bitcoin (did:btco) =====
|
|
212
|
+
const requestedFeeRate = 5; // sats/vB (will be overridden by fee oracle)
|
|
213
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(webAsset, requestedFeeRate);
|
|
214
|
+
|
|
215
|
+
// Verify Bitcoin inscription
|
|
216
|
+
expect(btcoAsset.currentLayer).toBe('did:btco');
|
|
217
|
+
expect(btcoAsset.id).toBe(asset.id); // Asset ID should remain the same
|
|
218
|
+
|
|
219
|
+
// Verify did:btco binding
|
|
220
|
+
const btcoBindings = (btcoAsset as any).bindings;
|
|
221
|
+
expect(btcoBindings).toBeDefined();
|
|
222
|
+
expect(btcoBindings['did:btco']).toMatch(/^did:btco:/);
|
|
223
|
+
expect(btcoBindings['did:webvh']).toBe(bindings['did:webvh']); // Previous binding preserved
|
|
224
|
+
|
|
225
|
+
// Verify provenance after Bitcoin migration
|
|
226
|
+
const btcoProvenance = btcoAsset.getProvenance();
|
|
227
|
+
expect(btcoProvenance.migrations).toHaveLength(2);
|
|
228
|
+
expect(btcoProvenance.migrations[1].from).toBe('did:webvh');
|
|
229
|
+
expect(btcoProvenance.migrations[1].to).toBe('did:btco');
|
|
230
|
+
expect(btcoProvenance.migrations[1].transactionId).toBeDefined();
|
|
231
|
+
expect(btcoProvenance.migrations[1].inscriptionId).toBeDefined();
|
|
232
|
+
expect(btcoProvenance.migrations[1].satoshi).toBeDefined();
|
|
233
|
+
expect(btcoProvenance.migrations[1].revealTxId).toBeDefined();
|
|
234
|
+
|
|
235
|
+
// Verify fee oracle was used (should be 7 from oracle, not 5 from request)
|
|
236
|
+
expect(btcoProvenance.migrations[1].feeRate).toBe(7); // Fee oracle value takes precedence
|
|
237
|
+
expect(typeof btcoProvenance.migrations[1].feeRate).toBe('number');
|
|
238
|
+
|
|
239
|
+
// Verify the inscription exists in the ordinals provider
|
|
240
|
+
const inscriptionId = btcoProvenance.migrations[1].inscriptionId;
|
|
241
|
+
const inscription = await ordinalsProvider.getInscriptionById(inscriptionId!);
|
|
242
|
+
expect(inscription).not.toBeNull();
|
|
243
|
+
expect(inscription?.inscriptionId).toBe(inscriptionId);
|
|
244
|
+
expect(inscription?.contentType).toBe('application/json');
|
|
245
|
+
|
|
246
|
+
// ===== PHASE 4: Transfer Ownership =====
|
|
247
|
+
const recipientAddress = 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx';
|
|
248
|
+
const transferResult = await sdk.lifecycle.transferOwnership(btcoAsset, recipientAddress);
|
|
249
|
+
|
|
250
|
+
// Verify transfer transaction
|
|
251
|
+
expect(transferResult.txid).toBeDefined();
|
|
252
|
+
expect(typeof transferResult.txid).toBe('string');
|
|
253
|
+
expect(transferResult.txid.length).toBeGreaterThan(0);
|
|
254
|
+
expect(transferResult.vin).toBeDefined();
|
|
255
|
+
expect(transferResult.vout).toBeDefined();
|
|
256
|
+
expect(transferResult.fee).toBeDefined();
|
|
257
|
+
|
|
258
|
+
// Verify provenance after transfer
|
|
259
|
+
const finalProvenance = btcoAsset.getProvenance();
|
|
260
|
+
expect(finalProvenance.transfers).toHaveLength(1);
|
|
261
|
+
expect(finalProvenance.transfers[0].from).toBe(btcoAsset.id);
|
|
262
|
+
expect(finalProvenance.transfers[0].to).toBe(recipientAddress);
|
|
263
|
+
expect(finalProvenance.transfers[0].transactionId).toBe(transferResult.txid);
|
|
264
|
+
expect(finalProvenance.transfers[0].timestamp).toBeDefined();
|
|
265
|
+
expect(finalProvenance.txid).toBe(transferResult.txid);
|
|
266
|
+
|
|
267
|
+
// ===== FINAL VERIFICATION: Complete provenance chain =====
|
|
268
|
+
expect(finalProvenance.creator).toBe(asset.id);
|
|
269
|
+
expect(finalProvenance.migrations).toHaveLength(2);
|
|
270
|
+
expect(finalProvenance.transfers).toHaveLength(1);
|
|
271
|
+
|
|
272
|
+
// Verify migration chain
|
|
273
|
+
expect(finalProvenance.migrations[0].from).toBe('did:peer');
|
|
274
|
+
expect(finalProvenance.migrations[0].to).toBe('did:webvh');
|
|
275
|
+
expect(finalProvenance.migrations[1].from).toBe('did:webvh');
|
|
276
|
+
expect(finalProvenance.migrations[1].to).toBe('did:btco');
|
|
277
|
+
|
|
278
|
+
// Verify all timestamps are in correct order
|
|
279
|
+
const createdAt = new Date(finalProvenance.createdAt).getTime();
|
|
280
|
+
const migration1Time = new Date(finalProvenance.migrations[0].timestamp).getTime();
|
|
281
|
+
const migration2Time = new Date(finalProvenance.migrations[1].timestamp).getTime();
|
|
282
|
+
const transferTime = new Date(finalProvenance.transfers[0].timestamp).getTime();
|
|
283
|
+
|
|
284
|
+
expect(migration1Time).toBeGreaterThanOrEqual(createdAt);
|
|
285
|
+
expect(migration2Time).toBeGreaterThanOrEqual(migration1Time);
|
|
286
|
+
expect(transferTime).toBeGreaterThanOrEqual(migration2Time);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('handles peer → btco direct migration (skipping webvh)', async () => {
|
|
290
|
+
// Create asset
|
|
291
|
+
const resources: AssetResource[] = [
|
|
292
|
+
{
|
|
293
|
+
id: 'resource-direct',
|
|
294
|
+
type: 'data',
|
|
295
|
+
contentType: 'application/json',
|
|
296
|
+
hash: 'abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890',
|
|
297
|
+
content: '{"test": "data"}'
|
|
298
|
+
}
|
|
299
|
+
];
|
|
300
|
+
|
|
301
|
+
const asset = await sdk.lifecycle.createAsset(resources);
|
|
302
|
+
expect(asset.currentLayer).toBe('did:peer');
|
|
303
|
+
|
|
304
|
+
// Inscribe directly to Bitcoin (skip webvh)
|
|
305
|
+
const requestedFeeRate = 10;
|
|
306
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(asset, requestedFeeRate);
|
|
307
|
+
|
|
308
|
+
// Verify direct migration
|
|
309
|
+
expect(btcoAsset.currentLayer).toBe('did:btco');
|
|
310
|
+
|
|
311
|
+
const provenance = btcoAsset.getProvenance();
|
|
312
|
+
expect(provenance.migrations).toHaveLength(1);
|
|
313
|
+
expect(provenance.migrations[0].from).toBe('did:peer');
|
|
314
|
+
expect(provenance.migrations[0].to).toBe('did:btco');
|
|
315
|
+
expect(provenance.migrations[0].feeRate).toBe(7); // Fee oracle takes precedence
|
|
316
|
+
|
|
317
|
+
// Verify can transfer after direct migration
|
|
318
|
+
const transferResult = await sdk.lifecycle.transferOwnership(
|
|
319
|
+
btcoAsset,
|
|
320
|
+
'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7'
|
|
321
|
+
);
|
|
322
|
+
expect(transferResult.txid).toBeDefined();
|
|
323
|
+
expect(provenance.transfers).toHaveLength(1);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
test('validates complete asset integrity throughout lifecycle', async () => {
|
|
327
|
+
// Create resources without inline content (hash-only)
|
|
328
|
+
// This way verify() only checks structural integrity, not content hashes
|
|
329
|
+
const resources: AssetResource[] = [
|
|
330
|
+
{
|
|
331
|
+
id: 'integrity-test',
|
|
332
|
+
type: 'text',
|
|
333
|
+
contentType: 'text/plain',
|
|
334
|
+
hash: 'aaaa5678901234567890abcdef1234567890abcdef1234567890abcdef1234'
|
|
335
|
+
// No content property - verify will skip content hash check
|
|
336
|
+
}
|
|
337
|
+
];
|
|
338
|
+
|
|
339
|
+
const asset = await sdk.lifecycle.createAsset(resources);
|
|
340
|
+
|
|
341
|
+
// Verify at each stage (structural only)
|
|
342
|
+
expect(await asset.verify()).toBe(true);
|
|
343
|
+
|
|
344
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'integrity.test');
|
|
345
|
+
expect(await webAsset.verify()).toBe(true);
|
|
346
|
+
|
|
347
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(webAsset, 5);
|
|
348
|
+
expect(await btcoAsset.verify()).toBe(true);
|
|
349
|
+
|
|
350
|
+
await sdk.lifecycle.transferOwnership(btcoAsset, 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');
|
|
351
|
+
expect(await btcoAsset.verify()).toBe(true);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
describe('Adapter Interface Validation', () => {
|
|
356
|
+
test('storage adapter interface works correctly', async () => {
|
|
357
|
+
const testDomain = 'test.example.com';
|
|
358
|
+
const testPath = '.well-known/test/resource.txt';
|
|
359
|
+
const testContent = 'Test storage content';
|
|
360
|
+
|
|
361
|
+
// Test put operation
|
|
362
|
+
const url = await memoryStorage.putObject(testDomain, testPath, testContent);
|
|
363
|
+
expect(url).toMatch(/^mem:\/\//);
|
|
364
|
+
expect(url).toContain(testDomain);
|
|
365
|
+
|
|
366
|
+
// Test exists operation
|
|
367
|
+
const exists = await memoryStorage.exists(testDomain, testPath);
|
|
368
|
+
expect(exists).toBe(true);
|
|
369
|
+
|
|
370
|
+
// Test get operation
|
|
371
|
+
const retrieved = await memoryStorage.getObject(testDomain, testPath);
|
|
372
|
+
expect(retrieved).not.toBeNull();
|
|
373
|
+
expect(retrieved?.content).toBeDefined();
|
|
374
|
+
|
|
375
|
+
const retrievedText = new TextDecoder().decode(retrieved!.content);
|
|
376
|
+
expect(retrievedText).toBe(testContent);
|
|
377
|
+
|
|
378
|
+
// Test non-existent resource
|
|
379
|
+
const notFound = await memoryStorage.getObject(testDomain, 'nonexistent.txt');
|
|
380
|
+
expect(notFound).toBeNull();
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
test('fee oracle adapter interface works correctly', async () => {
|
|
384
|
+
// Test fee estimation
|
|
385
|
+
const fee1Block = await feeOracle.estimateFeeRate(1);
|
|
386
|
+
expect(fee1Block).toBe(7); // Configured base rate
|
|
387
|
+
|
|
388
|
+
const fee2Block = await feeOracle.estimateFeeRate(2);
|
|
389
|
+
expect(fee2Block).toBe(6); // Decreases by 1 per block
|
|
390
|
+
|
|
391
|
+
const fee10Block = await feeOracle.estimateFeeRate(10);
|
|
392
|
+
expect(fee10Block).toBe(1); // Math.max(1, 7 - (10 - 1)) = Math.max(1, -2) = 1
|
|
393
|
+
|
|
394
|
+
// Verify fee oracle is used in lifecycle
|
|
395
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
396
|
+
{ id: 'fee-test', type: 'data', contentType: 'text/plain', hash: makeHash('fee123'), content: 'test' }
|
|
397
|
+
]);
|
|
398
|
+
|
|
399
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(asset, undefined);
|
|
400
|
+
const provenance = btcoAsset.getProvenance();
|
|
401
|
+
|
|
402
|
+
// Should use fee oracle since no feeRate provided
|
|
403
|
+
expect(provenance.migrations[0].feeRate).toBeDefined();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
test('ordinals provider adapter interface works correctly', async () => {
|
|
407
|
+
// Test inscription creation
|
|
408
|
+
const testData = Buffer.from('Test inscription data');
|
|
409
|
+
const inscription = await ordinalsProvider.createInscription({
|
|
410
|
+
data: testData,
|
|
411
|
+
contentType: 'text/plain',
|
|
412
|
+
feeRate: 5
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
expect(inscription.inscriptionId).toBeDefined();
|
|
416
|
+
expect(inscription.revealTxId).toBeDefined();
|
|
417
|
+
expect(inscription.satoshi).toBeDefined();
|
|
418
|
+
expect(inscription.feeRate).toBe(5);
|
|
419
|
+
|
|
420
|
+
// Test inscription retrieval
|
|
421
|
+
const retrieved = await ordinalsProvider.getInscriptionById(inscription.inscriptionId);
|
|
422
|
+
expect(retrieved).not.toBeNull();
|
|
423
|
+
expect(retrieved?.inscriptionId).toBe(inscription.inscriptionId);
|
|
424
|
+
expect(retrieved?.contentType).toBe('text/plain');
|
|
425
|
+
|
|
426
|
+
// Test satoshi lookup
|
|
427
|
+
const bySatoshi = await ordinalsProvider.getInscriptionsBySatoshi(inscription.satoshi!);
|
|
428
|
+
expect(bySatoshi).toHaveLength(1);
|
|
429
|
+
expect(bySatoshi[0].inscriptionId).toBe(inscription.inscriptionId);
|
|
430
|
+
|
|
431
|
+
// Test transfer
|
|
432
|
+
const transferResult = await ordinalsProvider.transferInscription(
|
|
433
|
+
inscription.inscriptionId,
|
|
434
|
+
'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx',
|
|
435
|
+
{ feeRate: 6 }
|
|
436
|
+
);
|
|
437
|
+
expect(transferResult.txid).toBeDefined();
|
|
438
|
+
expect(transferResult.vin).toHaveLength(1);
|
|
439
|
+
expect(transferResult.vout).toHaveLength(1);
|
|
440
|
+
expect(transferResult.fee).toBeDefined();
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
test('adapters work together in publishToWeb', async () => {
|
|
444
|
+
// Verify storage adapter receives correct data during publication
|
|
445
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
446
|
+
{
|
|
447
|
+
id: 'adapter-integration',
|
|
448
|
+
type: 'text',
|
|
449
|
+
contentType: 'text/html',
|
|
450
|
+
hash: makeHash('html123456789abcdef1234567890abcdef1234567890abcdef12'),
|
|
451
|
+
content: '<html><body>Test</body></html>'
|
|
452
|
+
}
|
|
453
|
+
]);
|
|
454
|
+
|
|
455
|
+
const domain = 'adapter-test.com';
|
|
456
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, domain);
|
|
457
|
+
|
|
458
|
+
// Verify resource URL uses DID-based format
|
|
459
|
+
const resourceUrl = webAsset.resources[0].url;
|
|
460
|
+
expect(resourceUrl).toBeDefined();
|
|
461
|
+
expect(resourceUrl).toMatch(/^did:webvh:/);
|
|
462
|
+
|
|
463
|
+
// Verify content is retrievable through adapter
|
|
464
|
+
// URL format is: did:webvh:domain:path/resources/hash
|
|
465
|
+
const urlParts = (resourceUrl as string).split(':');
|
|
466
|
+
const pathPart = urlParts.slice(3).join(':');
|
|
467
|
+
const stored = await memoryStorage.getObject(domain, pathPart);
|
|
468
|
+
expect(stored).not.toBeNull();
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
test('adapters work together in inscribeOnBitcoin', async () => {
|
|
472
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
473
|
+
{ id: 'btc-test', type: 'data', contentType: 'application/json', hash: makeHash('btc123'), content: '{}' }
|
|
474
|
+
]);
|
|
475
|
+
|
|
476
|
+
// Inscribe without specifying fee rate - should use oracle
|
|
477
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(asset, undefined);
|
|
478
|
+
const provenance = btcoAsset.getProvenance();
|
|
479
|
+
|
|
480
|
+
// Verify fee from oracle was used
|
|
481
|
+
expect(provenance.migrations[0].feeRate).toBeDefined();
|
|
482
|
+
|
|
483
|
+
// Verify inscription is in provider
|
|
484
|
+
const inscriptionId = provenance.migrations[0].inscriptionId;
|
|
485
|
+
const inscription = await ordinalsProvider.getInscriptionById(inscriptionId!);
|
|
486
|
+
expect(inscription).not.toBeNull();
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
describe('Error Handling and Edge Cases', () => {
|
|
491
|
+
test('throws error when transferring non-btco asset', async () => {
|
|
492
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
493
|
+
{ id: 'error-test', type: 'data', contentType: 'text/plain', hash: makeHash('err123'), content: 'test' }
|
|
494
|
+
]);
|
|
495
|
+
|
|
496
|
+
// Try to transfer peer layer asset
|
|
497
|
+
await expect(
|
|
498
|
+
sdk.lifecycle.transferOwnership(asset, 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx')
|
|
499
|
+
).rejects.toThrow('Asset must be inscribed on Bitcoin before transfer');
|
|
500
|
+
|
|
501
|
+
// Try to transfer webvh layer asset
|
|
502
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'error.test');
|
|
503
|
+
await expect(
|
|
504
|
+
sdk.lifecycle.transferOwnership(webAsset, 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx')
|
|
505
|
+
).rejects.toThrow('Asset must be inscribed on Bitcoin before transfer');
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
test('handles multiple transfers correctly', async () => {
|
|
509
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
510
|
+
{ id: 'multi-transfer', type: 'data', contentType: 'text/plain', hash: makeHash('multi123'), content: 'test' }
|
|
511
|
+
]);
|
|
512
|
+
|
|
513
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(asset, 5);
|
|
514
|
+
|
|
515
|
+
// First transfer
|
|
516
|
+
const recipient1 = 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx';
|
|
517
|
+
const tx1 = await sdk.lifecycle.transferOwnership(btcoAsset, recipient1);
|
|
518
|
+
expect(tx1.txid).toBeDefined();
|
|
519
|
+
|
|
520
|
+
// Second transfer
|
|
521
|
+
const recipient2 = 'tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7';
|
|
522
|
+
const tx2 = await sdk.lifecycle.transferOwnership(btcoAsset, recipient2);
|
|
523
|
+
expect(tx2.txid).toBeDefined();
|
|
524
|
+
expect(tx2.txid).not.toBe(tx1.txid);
|
|
525
|
+
|
|
526
|
+
// Verify both transfers in provenance
|
|
527
|
+
const provenance = btcoAsset.getProvenance();
|
|
528
|
+
expect(provenance.transfers).toHaveLength(2);
|
|
529
|
+
expect(provenance.transfers[0].to).toBe(recipient1);
|
|
530
|
+
expect(provenance.transfers[1].to).toBe(recipient2);
|
|
531
|
+
expect(provenance.txid).toBe(tx2.txid); // Latest txid
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
test('handles empty resources array', async () => {
|
|
535
|
+
// Empty resources should throw an error per validation rules
|
|
536
|
+
await expect(sdk.lifecycle.createAsset([])).rejects.toThrow('At least one resource is required');
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
test('handles multiple resources with different content types', async () => {
|
|
540
|
+
const resources: AssetResource[] = [
|
|
541
|
+
{ id: 'img', type: 'image', contentType: 'image/jpeg', hash: makeHash('img123'), content: 'jpeg-data' },
|
|
542
|
+
{ id: 'txt', type: 'text', contentType: 'text/plain', hash: makeHash('txt123'), content: 'text-data' },
|
|
543
|
+
{ id: 'json', type: 'data', contentType: 'application/json', hash: makeHash('json123'), content: '{"key":"value"}' },
|
|
544
|
+
{ id: 'html', type: 'document', contentType: 'text/html', hash: makeHash('html123'), content: '<div>test</div>' }
|
|
545
|
+
];
|
|
546
|
+
|
|
547
|
+
const asset = await sdk.lifecycle.createAsset(resources);
|
|
548
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'multi-type.test');
|
|
549
|
+
|
|
550
|
+
// Verify all resources get URLs
|
|
551
|
+
expect(webAsset.resources).toHaveLength(4);
|
|
552
|
+
for (const resource of webAsset.resources) {
|
|
553
|
+
expect(resource.url).toBeDefined();
|
|
554
|
+
expect(resource.url).toMatch(/^did:webvh:/);
|
|
555
|
+
expect(resource.url).toContain('/resources/');
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// Verify all are stored
|
|
559
|
+
for (const resource of webAsset.resources) {
|
|
560
|
+
const url = resource.url!;
|
|
561
|
+
// URL format is now: did:webvh:domain:path/resources/hash
|
|
562
|
+
const urlParts = url.split(':');
|
|
563
|
+
const path = urlParts.slice(3).join(':'); // Get everything after did:webvh:domain
|
|
564
|
+
const stored = await memoryStorage.getObject('multi-type.test', path);
|
|
565
|
+
expect(stored).not.toBeNull();
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
test('preserves bindings throughout lifecycle', async () => {
|
|
570
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
571
|
+
{ id: 'binding-test', type: 'data', contentType: 'text/plain', hash: makeHash('bind123'), content: 'test' }
|
|
572
|
+
]);
|
|
573
|
+
|
|
574
|
+
// After webvh
|
|
575
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'binding.test');
|
|
576
|
+
const webBindings = (webAsset as any).bindings;
|
|
577
|
+
expect(Object.keys(webBindings)).toContain('did:webvh');
|
|
578
|
+
|
|
579
|
+
// After btco
|
|
580
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(webAsset, 5);
|
|
581
|
+
const btcoBindings = (btcoAsset as any).bindings;
|
|
582
|
+
expect(Object.keys(btcoBindings)).toContain('did:webvh');
|
|
583
|
+
expect(Object.keys(btcoBindings)).toContain('did:btco');
|
|
584
|
+
expect(btcoBindings['did:webvh']).toBe(webBindings['did:webvh']);
|
|
585
|
+
|
|
586
|
+
// After transfer (bindings should still exist)
|
|
587
|
+
await sdk.lifecycle.transferOwnership(btcoAsset, 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');
|
|
588
|
+
const finalBindings = (btcoAsset as any).bindings;
|
|
589
|
+
expect(finalBindings['did:webvh']).toBe(webBindings['did:webvh']);
|
|
590
|
+
expect(finalBindings['did:btco']).toBe(btcoBindings['did:btco']);
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
describe('Performance and Scalability', () => {
|
|
595
|
+
test('handles large resource payloads', async () => {
|
|
596
|
+
// Create a large resource (simulating a large image or document)
|
|
597
|
+
const largeContent = 'x'.repeat(100000); // 100KB
|
|
598
|
+
const resources: AssetResource[] = [
|
|
599
|
+
{
|
|
600
|
+
id: 'large-resource',
|
|
601
|
+
type: 'data',
|
|
602
|
+
contentType: 'application/octet-stream',
|
|
603
|
+
hash: makeHash('large123456789abcdef1234567890abcdef1234567890abcdef1'),
|
|
604
|
+
content: largeContent
|
|
605
|
+
}
|
|
606
|
+
];
|
|
607
|
+
|
|
608
|
+
const asset = await sdk.lifecycle.createAsset(resources);
|
|
609
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'large.test');
|
|
610
|
+
|
|
611
|
+
// Verify storage
|
|
612
|
+
const url = webAsset.resources[0].url!;
|
|
613
|
+
// URL format is now: did:webvh:domain:path/resources/hash
|
|
614
|
+
const urlParts = url.split(':');
|
|
615
|
+
const path = urlParts.slice(3).join(':'); // Get everything after did:webvh:domain
|
|
616
|
+
const stored = await memoryStorage.getObject('large.test', path);
|
|
617
|
+
expect(stored?.content.length).toBeGreaterThan(99000);
|
|
618
|
+
|
|
619
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(webAsset, 5);
|
|
620
|
+
expect(btcoAsset.currentLayer).toBe('did:btco');
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
test('handles many resources efficiently', async () => {
|
|
624
|
+
// Create an asset with many resources
|
|
625
|
+
const resources: AssetResource[] = Array.from({ length: 50 }, (_, i) => ({
|
|
626
|
+
id: `resource-${i}`,
|
|
627
|
+
type: 'data',
|
|
628
|
+
contentType: 'text/plain',
|
|
629
|
+
hash: makeHash(`res${i}`),
|
|
630
|
+
content: `Content ${i}`
|
|
631
|
+
}));
|
|
632
|
+
|
|
633
|
+
const asset = await sdk.lifecycle.createAsset(resources);
|
|
634
|
+
expect(asset.resources).toHaveLength(50);
|
|
635
|
+
|
|
636
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'many.test');
|
|
637
|
+
|
|
638
|
+
// Verify all resources have URLs
|
|
639
|
+
expect(webAsset.resources.every(r => r.url !== undefined)).toBe(true);
|
|
640
|
+
|
|
641
|
+
// Verify all are stored
|
|
642
|
+
for (const resource of webAsset.resources) {
|
|
643
|
+
const url = resource.url!;
|
|
644
|
+
// URL format is now: did:webvh:domain:path/resources/hash
|
|
645
|
+
// Extract the path part after the domain
|
|
646
|
+
const urlParts = url.split(':');
|
|
647
|
+
const pathPart = urlParts.slice(3).join(':'); // Get everything after did:webvh:domain
|
|
648
|
+
const stored = await memoryStorage.getObject('many.test', pathPart);
|
|
649
|
+
expect(stored).not.toBeNull();
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(webAsset, 5);
|
|
653
|
+
expect(btcoAsset.currentLayer).toBe('did:btco');
|
|
654
|
+
|
|
655
|
+
const provenance = btcoAsset.getProvenance();
|
|
656
|
+
expect(provenance.migrations).toHaveLength(2);
|
|
657
|
+
});
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
describe('Provenance Chain Validation', () => {
|
|
661
|
+
test('maintains complete audit trail with all metadata', async () => {
|
|
662
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
663
|
+
{ id: 'audit-test', type: 'data', contentType: 'text/plain', hash: makeHash('audit123'), content: 'test' }
|
|
664
|
+
]);
|
|
665
|
+
|
|
666
|
+
const startTime = Date.now();
|
|
667
|
+
|
|
668
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'audit.test');
|
|
669
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(webAsset, 8); // Request 8, but oracle returns 7
|
|
670
|
+
await sdk.lifecycle.transferOwnership(btcoAsset, 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');
|
|
671
|
+
|
|
672
|
+
const provenance = btcoAsset.getProvenance();
|
|
673
|
+
|
|
674
|
+
// Verify complete metadata
|
|
675
|
+
expect(provenance.createdAt).toBeDefined();
|
|
676
|
+
expect(provenance.creator).toBeDefined();
|
|
677
|
+
expect(provenance.txid).toBeDefined();
|
|
678
|
+
|
|
679
|
+
// Verify migration metadata
|
|
680
|
+
expect(provenance.migrations).toHaveLength(2);
|
|
681
|
+
|
|
682
|
+
const webMigration = provenance.migrations[0];
|
|
683
|
+
expect(webMigration.from).toBe('did:peer');
|
|
684
|
+
expect(webMigration.to).toBe('did:webvh');
|
|
685
|
+
expect(webMigration.timestamp).toBeDefined();
|
|
686
|
+
expect(new Date(webMigration.timestamp).getTime()).toBeGreaterThanOrEqual(startTime);
|
|
687
|
+
|
|
688
|
+
const btcoMigration = provenance.migrations[1];
|
|
689
|
+
expect(btcoMigration.from).toBe('did:webvh');
|
|
690
|
+
expect(btcoMigration.to).toBe('did:btco');
|
|
691
|
+
expect(btcoMigration.timestamp).toBeDefined();
|
|
692
|
+
expect(btcoMigration.transactionId).toBeDefined();
|
|
693
|
+
expect(btcoMigration.inscriptionId).toBeDefined();
|
|
694
|
+
expect(btcoMigration.satoshi).toBeDefined();
|
|
695
|
+
expect(btcoMigration.revealTxId).toBeDefined();
|
|
696
|
+
expect(btcoMigration.feeRate).toBe(7); // Fee oracle overrides requested rate
|
|
697
|
+
|
|
698
|
+
// Verify transfer metadata
|
|
699
|
+
expect(provenance.transfers).toHaveLength(1);
|
|
700
|
+
const transfer = provenance.transfers[0];
|
|
701
|
+
expect(transfer.from).toBeDefined();
|
|
702
|
+
expect(transfer.to).toBe('tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');
|
|
703
|
+
expect(transfer.timestamp).toBeDefined();
|
|
704
|
+
expect(transfer.transactionId).toBeDefined();
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
test('timestamps are monotonically increasing', async () => {
|
|
708
|
+
const asset = await sdk.lifecycle.createAsset([
|
|
709
|
+
{ id: 'time-test', type: 'data', contentType: 'text/plain', hash: makeHash('time123'), content: 'test' }
|
|
710
|
+
]);
|
|
711
|
+
|
|
712
|
+
await new Promise(resolve => setTimeout(resolve, 10)); // Small delay
|
|
713
|
+
const webAsset = await sdk.lifecycle.publishToWeb(asset, 'time.test');
|
|
714
|
+
|
|
715
|
+
await new Promise(resolve => setTimeout(resolve, 10)); // Small delay
|
|
716
|
+
const btcoAsset = await sdk.lifecycle.inscribeOnBitcoin(webAsset, 5);
|
|
717
|
+
|
|
718
|
+
await new Promise(resolve => setTimeout(resolve, 10)); // Small delay
|
|
719
|
+
await sdk.lifecycle.transferOwnership(btcoAsset, 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');
|
|
720
|
+
|
|
721
|
+
const provenance = btcoAsset.getProvenance();
|
|
722
|
+
|
|
723
|
+
const times = [
|
|
724
|
+
new Date(provenance.createdAt).getTime(),
|
|
725
|
+
new Date(provenance.migrations[0].timestamp).getTime(),
|
|
726
|
+
new Date(provenance.migrations[1].timestamp).getTime(),
|
|
727
|
+
new Date(provenance.transfers[0].timestamp).getTime()
|
|
728
|
+
];
|
|
729
|
+
|
|
730
|
+
for (let i = 1; i < times.length; i++) {
|
|
731
|
+
expect(times[i]).toBeGreaterThanOrEqual(times[i - 1]);
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
});
|