Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: transaction.providerData.tx.sign #48

Closed
danielNg25 opened this issue Jul 13, 2023 · 13 comments
Closed

[Bug]: transaction.providerData.tx.sign #48

danielNg25 opened this issue Jul 13, 2023 · 13 comments
Labels
bug Something isn't working

Comments

@danielNg25
Copy link

Data Provider

Blockfrost

DEX

All

Description

I'm getting error TypeError: transaction.providerData.tx.sign is not a function when call swapRequest.submit. even I set the lucid wallet provider to the dexter
I found that, transaction.providerData.tx has type of Tx in lucid-cardano, but Tx doesn't have any function named sign

@danielNg25 danielNg25 added the bug Something isn't working label Jul 13, 2023
@Sluder
Copy link
Member

Sluder commented Jul 13, 2023

@ndtr2000 Would you sharing how you are initializing Dexter with the LucidProvider?

@danielNg25
Copy link
Author

This is how I did @Sluder

const dexterConfig: DexterConfig = {
        shouldFetchMetadata: true,
        shouldFallbackToApi: false,
        shouldSubmitOrders: true,
        metadataMsgBranding: 'Dexter',
    };
    const requestConfig: RequestConfig = {
        timeout: 5000,
        proxyUrl: '',
        retries: 3,
    };

    const blockfrostConfig: BlockfrostConfig = {
        url: 'https://cardano-mainnet.blockfrost.io/api/v0/',
        projectId: '<< MY BLOCKFROST KEY >>',
    };

    const blockfrostAdapter = new BlockfrostProvider(
        blockfrostConfig,
        requestConfig
    );

    const lucidProvider = await new LucidProvider().loadWalletFromSeedPhrase(
        seed, // MY SEED PHRASE
        undefined,
        blockfrostConfig
    );

    const dexter: Dexter = new Dexter(dexterConfig, requestConfig)
        .withDataProvider(blockfrostAdapter)
        .withWalletProvider(lucidProvider);

    const liquidityPool = new LiquidityPool(
        Minswap.name,
        'lovelace',
        new Asset(
            'e16c2dc8ae937e8d3790c7fd7168d7b994621ba14ca11415f39fed72',
            '4d494e'
        ),
        10000000000000n,
        100000000000000n,
        'addr1'
    );

    const swapRequest: SwapRequest = dexter
        .newSwapRequest()
        .forLiquidityPool(liquidityPool)
        .withSwapInToken('lovelace')
        .withSwapInAmount(1000000n)
        .withSlippagePercent(100);

    const tx = swapRequest.submit();

@Sluder
Copy link
Member

Sluder commented Jul 13, 2023

Hmm that all looks fine.. I am wondering if the .withSlippagePercent(100) is causing issues with the min receive calculations & something is failing silently. Do you get the same error if you use a slippage under 100%?

@danielNg25
Copy link
Author

Hmm that all looks fine.. I am wondering if the .withSlippagePercent(100) is causing issues with the min receive calculations & something is failing silently. Do you get the same error if you use a slippage under 100%?

I just changed it to 1 and retried, but still get the same error.

@Sluder
Copy link
Member

Sluder commented Jul 13, 2023

I just changed it to 1 and retried, but still get the same error.

Very weird, I don't see how this could occur if everything works fine up to that point. And I would assume all users would have this issue by the looks of it. Ill take a look.
You also don't have any other lucid versions installed? Just the one Dexter requires. Might also be helpful to check you are using Dexter 2.0 just to make sure we are looking at the same thing

@danielNg25
Copy link
Author

this is my dependencies

    "dependencies": {
        "@indigo-labs/dexter": "^2.0.0"
    },
  "devDependencies": {
      "@babel/core": "^7.17.9",
      "@babel/preset-env": "^7.16.11",
      "@babel/preset-typescript": "^7.16.7",
      "babel-jest": "^28.0.1",
      "esbuild": "^0.14.38",
      "ts-node": "^10.7.0",
      "typescript": "^4.6.3"
  }

And the lucid-cardano version is 0.8.9
I changed it to 0.8.7 (the version in dexter's package.json) but it still doesn't work

@danielNg25
Copy link
Author

I think I found the problem
It should be transaction.providerData.tx.complete().sign().complete() instead of transaction.providerData.tx.sign().complete() in the lucid-provider.
Because transaction.providerData.tx first has type of Tx, and Tx must be complete() to become TxComplete before calling sign()

@Sluder
Copy link
Member

Sluder commented Jul 13, 2023

I was looking that over, and if the paymentsForTransaction() in the lucid provider completes correctly, then signTransaction() should have the Tx complete instance. I'm still not sure how you are hitting that case just yet

@ItsDaveB
Copy link
Collaborator

ItsDaveB commented Jul 13, 2023

Transactions work fine for me if it helps, I use the default slippage though

@Sluder
Copy link
Member

Sluder commented Jul 13, 2023

@ndtr2000 I think the issue is before the signing. I opened this PR #49 to allow those failures to bubble up so the real error isn't masked. Would you mind checking that PR out & seeing what error you actually get? Seems to be some edge case I haven't been able to replicate in my environment

@danielNg25
Copy link
Author

Sorry guys. I found the problem is that my wallet doesn't has enough lovelace.
Thank you guys for your support. I close my issue right here!

@Sluder
Copy link
Member

Sluder commented Jul 14, 2023

@ndtr2000 Appreciate you letting us know - we will work on better error handling & messages so the failures are more clear

@TwilightDuck
Copy link

Hi,

I'm running into the same issue. But I have enough lovelace in my wallet.

`file:///Users/nick/code/lp-sniper/node_modules/@indigo-labs/dexter/build/providers/wallet/lucid-provider.js:95
return transaction.providerData.tx.sign().complete()
^

TypeError: transaction.providerData.tx.sign is not a function
at LucidProvider.signTransaction (file:///Users/nick/code/lp-sniper/node_modules/@indigo-labs/dexter/build/providers/wallet/lucid-provider.js:95:44)
at DexTransaction.sign (file:///Users/nick/code/lp-sniper/node_modules/@indigo-labs/dexter/build/dex/models/dex-transaction.js:44:37)
at Timeout._onTimeout (file:///Users/nick/code/lp-sniper/build/src/index.js:248:40)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)`

Here's my build code:

`  const swapRequest: SwapRequest = new Dexter(dexterConfig, requestConfig)
.withDataProvider(kupoProvider)
.withWalletProvider(lucidProvider)
.newSwapRequest()
.forLiquidityPool(pool)
.withSwapInToken('lovelace')
.withSwapInAmount(1_000_000n)
.withSlippagePercent(20);

const submitted = swapRequest.submit();

logger.info(TX Status: ${submitted.status});
logger.info(TX Hash ${submitted.hash});

let complete = await submitted.sign();

logger.info(`TX Status: ${submitted.status}`);
logger.info(`TX Hash ${submitted.hash}`)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants