Anastasia-Labs / lucid-evolution

https://anastasia-labs.github.io/lucid-evolution/
35 stars 10 forks source link

Reference scripts don't work #106

Closed SynthLuvr closed 3 months ago

SynthLuvr commented 3 months ago

This works with the old Lucid:

const tx = lucid
  .newTx()
  .collectFrom(
    await lucid.provider.getUtxosByOutRef([
      {
        txHash:
          "9edf5d6cf3b38ad118d1fae6cb1a7a7f81902d482e8f269af4466043d369aa00",
        outputIndex: 0,
      },
    ]),
    Data.void()
  )
  .readFrom(
    await lucid.provider.getUtxosByOutRef([
      {
        txHash:
          "82e7912b2e498c01cee6e29c04049854829fe43b307a8a63d36b33ca5b3df0d1",
        outputIndex: 0,
      },
    ])
  );
const completed = await tx.complete();

And if I attach the script via Lucid Evolution:

const tx = lucid
  .newTx()
  .collectFrom(
    await lucid.config().provider.getUtxosByOutRef([
      {
        txHash:
          "9edf5d6cf3b38ad118d1fae6cb1a7a7f81902d482e8f269af4466043d369aa00",
        outputIndex: 0,
      },
    ]),
    Data.void()
  )
  .attach.SpendingValidator({
    type: "PlutusV2",
    script: "49480100002221200101",
  });
const completed = await tx.complete().unsafeRun();

But reference scripts don't work with Lucid Evolution:

const tx = lucid
  .newTx()
  .collectFrom(
    await lucid.config().provider.getUtxosByOutRef([
      {
        txHash:
          "9edf5d6cf3b38ad118d1fae6cb1a7a7f81902d482e8f269af4466043d369aa00",
        outputIndex: 0,
      },
    ]),
    Data.void()
  )
  .readFrom(
    await lucid.config().provider.getUtxosByOutRef([
      {
        txHash:
          "82e7912b2e498c01cee6e29c04049854829fe43b307a8a63d36b33ca5b3df0d1",
        outputIndex: 0,
      },
    ])
  );
const completed = await tx.complete().unsafeRun();

Error:

(FiberFailure) TxBuilderError (FiberFailureImpl) {
  message: 'No script found, script hash: 3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712, consider using attach modules',
  [Symbol.for(effect/Runtime/FiberFailure)]: Symbol.for(effect/Runtime/FiberFailure),
  [Symbol.for(effect/Runtime/FiberFailure/Cause)]: {
    _tag: 'Fail',
    error: TxBuilderError {
      _tag: 'TxBuilderError',
      cause: 'MissingScript',
      message: 'No script found, script hash: 3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712, consider using attach modules',
      module: 'Collect',
    },
  },
}
solidsnakedev commented 3 months ago

fix https://github.com/Anastasia-Labs/lucid-evolution/pull/107

SynthLuvr commented 3 months ago

Bug still present for me

SynthLuvr commented 3 months ago

Fixed by #114