Francium-DeFi / francium-sdk

The Francium SDK.
https://francium.io/
30 stars 18 forks source link

Opening a position pair containing SOL with no wsol account breaks #9

Closed nourel closed 2 years ago

nourel commented 2 years ago

When you have a wallet without a wrapped SOL account address and try to open a position with sol in the pair, the program breaks.

Error:

Cannot read properties of undefined (reading 'tokenAccountAddress')
at francium-sdk/dist/model/farm/farm.js:60:95

source code snippet where the error is:

    if (isNativeMint(targetFarmInfo.tknMint0)) {
      userTknAccount0 = parsedTokenAccounts[NATIVE_MINT.toBase58()].tokenAccountAddress;
    } else if (isNativeMint(targetFarmInfo.tknMint1)) {
      userTknAccount1 = parsedTokenAccounts[NATIVE_MINT.toBase58()].tokenAccountAddress;
    } else {
      // not include SOL 
    }

since wallet does not have a wrapped sol account, it won't have an address. parsedTokenAccounts[NATIVE_MINT.toBase58()]. will be undefined.

Fix:

missrhyme commented 2 years ago

Fixed in the new version, thanks.