EOSIO / eosjs

General purpose library for the EOSIO blockchain.
http://eosio.github.io/eosjs
MIT License
1.43k stars 463 forks source link

eosjs: missing table_def.indexes #493

Open MikkySnow opened 5 years ago

MikkySnow commented 5 years ago

I'm trying to deploy contract using eosjs. setcode part is working, but I'm having trouble with setabi. When I deploy abi without any tables, it works. But if there will be at least one table, the error Error: missing table_def.indexes (type=index_def[]) appears

`async function deploy(deployer, contract) { const buffer = new Serialize.SerialBuffer({ textEncoder: api().textEncoder, textDecoder: api().textDecoder, });

let abiDefinition = api().abiTypes.get('abi_def');
let abi = abiDefinition.fields.reduce(
    (acc, {name: fieldName}) => Object.assign(acc, {[fieldName]: acc[fieldName] || []}),
    contract.abi,
);
abiDefinition.serialize(buffer, abi);
let forSend = Buffer.from(buffer.asUint8Array()).toString(`hex`);

await api([deployer.private_key]).transact({
    actions: [{
        account: network.system_account,
        name: 'setabi',
        authorization: [{
            actor: deployer.name,
            permission: 'active',
        }],
        data: {
            account: deployer.name,
            abi: forSend
        }
    }]
}, transact_conf);

}`

contract is object containing abi and wasm for contract eosjs version is 20.0.0-beta3

tbfleming commented 5 years ago

The reducer above probably needs additional rules to add the missing fields.

tbfleming commented 5 years ago

588 is related