tango-crypto / cardano-wallet-js

cardano-wallet javascript/typescript client
81 stars 34 forks source link

Post upgrade: Cannot read properties of undefined (reading 'minUTxOValue') #35

Open 34r7h opened 2 years ago

34r7h commented 2 years ago

Hi I just updated the cardano node 1.33.1 and wallet-js.

I'm getting an error from Seed.getMinUtxoValueWithAssets() when building a tx to send an asset. Checked that the holding address has the token

TypeError: Cannot read properties of undefined (reading 'minUTxOValue') 1|index | at Function.Seed.getMinUtxoValueWithAssets (/home/34r7h/cardano-api-server/node_modules/cardano-wallet-js/dist/utils.js:607:147) 1|index | at /home/34r7h/cardano-api-server/index.js:444:40 1|index | at /home/34r7h/cardano-api-server/index.js:472:19 1|index | at processTicksAndRejections (node:internal/process/task_queues:96:5) 1|index | }

(async () => {
                    let address = thisdata.selleraddress
                    let addresses = [new AddressWallet(thisdata.holdingaddress)]
                    let asset = new AssetWallet(thisdata.policy, thisdata.name, 1);
                    let assets = {}
                    assets[thisdata.holdingaddress] = [asset];
                    let minUtxo = Seed.getMinUtxoValueWithAssets([asset], cardanoconfig)
                    let meta = [thisdata.xmbl];
                    let coinSelection = await w.getCoinSelection(addresses, [minUtxo], meta, assets);
                    coinSelection.outputs[0].address = address
                    console.log(JSON.stringify(coinSelection, null, 2));
                    let info = await api.networkinfo().then(x => x)
                    let ttl = info.node_tip.absolute_slot_number * 12000;
                    const emsg = fs.readFileSync(`./crypto.hash`, { encoding: 'utf8', flag: 'r' })
                    let phrase = api.decryptphrase(emsg, thisdata.secret)
                    let rootKey = Seed.deriveRootKey(phrase);
                    let signingKeys = coinSelection.inputs.map(i => {
                        let privateKey = Seed.deriveKey(rootKey, i.derivation_path).to_raw_key();
                        return privateKey;
                    });
                    let metadata = Seed.buildTransactionMetadata(meta);
                    let txBuild = Seed.buildTransaction(coinSelection, ttl, { metadata: metadata, config: cconfig });
                    let txBody = Seed.sign(txBuild, signingKeys, metadata);
                    let signed = Buffer.from(txBody.to_bytes()).toString('hex');
                    return signed
                })

Did I miss an upgrade requirement/change? Please lmk how to troubleshoot.

btw, nice effort on multisigs!

34r7h commented 2 years ago

i made a pr with a fix around this. likely more places to apply config.protocolParams instead of config.protocols but not all

phillewis commented 2 years ago

I have the same issue.

Seems that Seed (in utils.ts) references config.protocols, however the supplied configurations (config.ts) use the key "protocolParams".

The workaround is to use your own config object with the key name "protocols", however it would be preferable if they were aligned. Haven't looked into whether there would be a conflict with this change elsewhere, so haven't submitted a PR.

Is this project still being maintained?

javiertc commented 2 years ago

Hi, yes this project is still maintained, it's just that we have limited resources and we have been focused on our API.