Skip to content

Commit

Permalink
change package name and set nimiq as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Developer committed Apr 18, 2020
1 parent 2daed26 commit bd08bf1
Show file tree
Hide file tree
Showing 9 changed files with 1,045 additions and 994 deletions.
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) Roman Shtylman
Copyright (c) Rhody Lugo 2020
Copyright (c) Roman Shtylman 2014-2020

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# wallet-address-validator
Simple wallet address validator for validating Bitcoin and other altcoins addresses in **Node.js and browser**.
# crypto-wallet-address-validator
Simple wallet address validator for validating Nimiq and other cryptocurrency addresses in **Node.js and browser**.

Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-address).

Expand All @@ -9,21 +9,21 @@ Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-add

### NPM
```
npm install wallet-address-validator
npm install crypto-wallet-address-validator
```

### Browser
```html
<script src="wallet-address-validator.min.js"></script>
<script src="crypto-wallet-address-validator.min.js"></script>
```

## API

##### validate (address [, currency = 'bitcoin'[, networkType = 'prod']])
##### validate (address [, currency = 'cryptocurrency'[, networkType = 'prod']])

###### Parameters
* address - Wallet address to validate.
* currency - Optional. Currency name or symbol, e.g. `'bitcoin'` (default), `'litecoin'` or `'LTC'`
* currency - Optional. Currency name or symbol, e.g. `'nimiq'` (default), `'bitcoin'` or `'ETH'`
* networkType - Optional. Use `'prod'` (default) to enforce standard address, `'testnet'` to enforce testnet address and `'both'` to enforce nothing.

> Returns true if the address (string) is a valid wallet address for the crypto currency specified, see below for supported currencies.
Expand Down Expand Up @@ -99,7 +99,7 @@ npm install wallet-address-validator

#### Node
```javascript
var WAValidator = require('wallet-address-validator');
var WAValidator = require('crypto-wallet-address-validator');

var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC');
if(valid)
Expand All @@ -111,7 +111,7 @@ else
```

```javascript
var WAValidator = require('wallet-address-validator');
var WAValidator = require('crypto-wallet-address-validator');

var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'litecoin', 'testnet');
if(valid)
Expand All @@ -124,12 +124,12 @@ else

#### Browser
```html
<script src="wallet-address-validator.min.js"></script>
<script src="crypto-wallet-address-validator.min.js"></script>
```

```javascript
// WAValidator is exposed as a global (window.WAValidator)
var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'bitcoin');
var valid = WAValidator.validate('NQXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX', 'nimiq');
if(valid)
alert('This is a valid address');
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5536,6 +5536,23 @@ module.exports = {
};

},{"./blake256":12,"./blake2b":13,"./sha3":16,"jssha/src/sha256":5}],18:[function(require,module,exports){
var currencies = require('./currencies');

var DEFAULT_CURRENCY_NAME = 'nimiq';

module.exports = {
validate: function (address, currencyNameOrSymbol, networkType) {
var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME);

if (currency.validator) {
return currency.validator.isValidAddress(address, currency, networkType);
}

throw new Error('Missing validator for currency: ' + currencyNameOrSymbol);
},
};

},{"./currencies":19}],19:[function(require,module,exports){
var XRPValidator = require('./ripple_validator');
var ETHValidator = require('./ethereum_validator');
var BTCValidator = require('./bitcoin_validator');
Expand Down Expand Up @@ -5770,7 +5787,7 @@ module.exports = {
}
};

},{"./bitcoin_validator":8,"./ethereum_validator":19,"./iban_validator":20,"./monero_validator":21,"./nano_validator":22,"./ripple_validator":23}],19:[function(require,module,exports){
},{"./bitcoin_validator":8,"./ethereum_validator":20,"./iban_validator":21,"./monero_validator":22,"./nano_validator":23,"./ripple_validator":24}],20:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');

module.exports = {
Expand Down Expand Up @@ -5806,7 +5823,7 @@ module.exports = {
}
};

},{"./crypto/utils":17}],20:[function(require,module,exports){
},{"./crypto/utils":17}],21:[function(require,module,exports){
function ibanCheck(address) {
var num = address.split('').map(function(c) {
var code = c.toUpperCase().charCodeAt(0);
Expand Down Expand Up @@ -5840,7 +5857,7 @@ module.exports = {
}
};

},{}],21:[function(require,module,exports){
},{}],22:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');
var cnBase58 = require('./crypto/cnBase58');

Expand Down Expand Up @@ -5902,7 +5919,7 @@ module.exports = {
}
};

},{"./crypto/cnBase58":14,"./crypto/utils":17}],22:[function(require,module,exports){
},{"./crypto/cnBase58":14,"./crypto/utils":17}],23:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');
var baseX = require('base-x');

Expand Down Expand Up @@ -5931,7 +5948,7 @@ module.exports = {
}
};

},{"./crypto/utils":17,"base-x":1}],23:[function(require,module,exports){
},{"./crypto/utils":17,"base-x":1}],24:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');
var baseX = require('base-x');

Expand Down Expand Up @@ -5961,22 +5978,5 @@ module.exports = {
}
};

},{"./crypto/utils":17,"base-x":1}],24:[function(require,module,exports){
var currencies = require('./currencies');

var DEFAULT_CURRENCY_NAME = 'bitcoin';

module.exports = {
validate: function (address, currencyNameOrSymbol, networkType) {
var currency = currencies.getByNameOrSymbol(currencyNameOrSymbol || DEFAULT_CURRENCY_NAME);

if (currency.validator) {
return currency.validator.isValidAddress(address, currency, networkType);
}

throw new Error('Missing validator for currency: ' + currencyNameOrSymbol);
},
};

},{"./currencies":18}]},{},[24])(24)
},{"./crypto/utils":17,"base-x":1}]},{},[18])(18)
});

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function (config) {
frameworks: ['mocha', 'chai'],

files: [
'dist/wallet-address-validator.min.js',
'dist/crypto-wallet-address-validator.min.js',
'test/**/*.js'
],

Expand Down
Loading

0 comments on commit bd08bf1

Please sign in to comment.