Skip to content

bankSend assumes the validator account is only possible sender #187

Open
@anilhelvaci

Description

@anilhelvaci

Problem Definition

Current bankSend only uses the validator account as its from account. There might be situations where an account other than the validator is needed to be the sender.

export const bankSend = (addr: string, wanted: string) => {
const chain = ['--chain-id', CHAINID];
const from = ['--from', VALIDATORADDR];
const testKeyring = ['--keyring-backend', 'test'];
const noise = [...from, ...chain, ...testKeyring, '--yes'];
return agd.tx('bank', 'send', VALIDATORADDR, addr, wanted, ...noise);
};

Solution

In order not to break any existing code, I suggest an implementation like below:

export const bankSend = (addr, wanted, from = VALIDATORADDR) => {
  const chain = ['--chain-id', CHAINID];
  const fromArg = ['--from', from];
  const testKeyring = ['--keyring-backend', 'test'];
  const noise = [...fromArg, ...chain, ...testKeyring, '--yes'];

  return agd.tx('bank', 'send', from, addr, wanted, ...noise);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions