How to use the @colony/colony-js-utils.isValidAddress function in @colony/colony-js-utils

To help you get started, we’ve selected a few @colony/colony-js-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JoinColony / colonyJS / packages / colony-js-client / src / ColonyClient / index.js View on Github external
async getReputation({
    skillId,
    address,
  }: {
    skillId: number,
    address: Address,
  } = {}) {
    assert(Number.isFinite(skillId), 'skillId must be a number');
    assert(isValidAddress(address), 'address must be an address');

    // Throw error if private network
    if (typeof this.network === 'undefined') {
      throw new Error('This method is not supported on a private network');
    }

    // Throw error if not goerli or mainnet
    if (
      this.network !== 'goerli' &&
      this.network !== 'mainnet' &&
      this.network !== 'homestead'
    ) {
      throw new Error('This method is only supported on goerli or mainnet');
    }

    // Get the current reputation root hash
github JoinColony / colonyJS / packages / colony-js-contract-client / src / modules / getMethodReturnValue.js View on Github external
const parseReturnValue = (value: any, type: ParamTypes) => {
  switch (type) {
    case 'number':
      if (isBigNumber(value)) return value.toNumber();
      assert(Number(value) === value, `Unexpected value "${value}"`);
      return value;
    case 'address':
      // Filter out empty addresses
      return isValidAddress(value) ? value : null;
    default:
      return value;
  }
};
github JoinColony / colonyJS / packages / colony-js-client / src / MetaColonyClient / index.js View on Github external
async getReputation({
    skillId = 1,
    user,
  }: {
    skillId: number,
    user: Address,
  } = {}) {
    assert(Number.isFinite(skillId), 'skillId must be a number');
    assert(isValidAddress(user), 'user must be an address');

    if (this.network !== 'rinkeby')
      throw new Error(
        'Reputation is currently only supported for contracts on Rinkeby',
      );

    const response = await fetch(
      `https://colony.io/reputation/${this.network}/${
        this.contract.address
      }]/${skillId}/${user}`,
    );
    return response.json();
  }
}
github JoinColony / colonyJS / packages / colony-js-client / src / ColonyNetworkClient / index.js View on Github external
async getTokenLockingClient() {
    const { address } = await this.getTokenLockingAddress.call();

    if (!isValidAddress(address))
      throw new Error(`TokenLocking contract could not be found`);

    return this.getTokenLockingClientByAddress(address);
  }
github JoinColony / colonyJS / packages / colony-js-contract-client / src / modules / paramTypes.js View on Github external
convertOutput(value) {
      return isValidAddress(value) ? value : null;
    },
    convertInput: passThrough,
github JoinColony / colonyJS / packages / colony-js-client / src / ColonyClient / index.js View on Github external
makeExecuteTaskRoleChange('setTaskWorkerRole', async ({ taskId }) => {
      const { address } = await this.getTaskRole.call({
        taskId,
        role: TASK_ROLE_WORKER,
      });
      if (isValidAddress(address))
        throw new Error('Unable to set task role; worker is already set');
      return null;
    });
  }
github JoinColony / colonyJS / packages / colony-js-contract-client / src / modules / paramTypes.js View on Github external
      return value.map(element => (isValidAddress(element) ? element : null));
    },
github JoinColony / colonyJS / packages / colony-js-contract-client / src / classes / MultisigOperation.js View on Github external
static _validatePayload(payload: any) {
    const assert = makeAssert('Invalid payload');

    assert(isPlainObject(payload), 'Payload must be an object');

    const { data, destinationAddress, sourceAddress, value } = payload || {};

    assert(isHexStrict(data), 'data must be a hex string');

    assert(
      isValidAddress(destinationAddress),
      'destinationAddress must be a valid address',
    );

    assert(
      isValidAddress(sourceAddress),
      'sourceAddress must be a valid address',
    );

    return assert(
      Number(value) === value && value >= 0,
      'value must be a positive number',
    );
  }