Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cosmos address support #83

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 64 additions & 31 deletions dist/wallet-address-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8335,7 +8335,7 @@ module.exports = {
}
};

},{"./bip173_validator":41,"./crypto/base58":44,"cbor-js":5,"crc":30}],38:[function(require,module,exports){
},{"./bip173_validator":42,"./crypto/base58":45,"cbor-js":5,"crc":30}],38:[function(require,module,exports){
const cryptoUtils = require('./crypto/utils');

const ALGORAND_CHECKSUM_BYTE_LENGTH = 4;
Expand Down Expand Up @@ -8365,7 +8365,34 @@ module.exports = {
}
}

},{"./crypto/utils":52}],39:[function(require,module,exports){
},{"./crypto/utils":53}],39:[function(require,module,exports){
var utils = require('./crypto/utils')

const ALLOWED_CHARS = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'

var regexp = new RegExp('^(cosmos)1([' + ALLOWED_CHARS + ']+)$') // cosmos + bech32 separated by '1'

module.exports = {
isValidAddress: function (address, currency, networkType) {
let match = regexp.exec(address)
if (match !== null) {
return this.verifyChecksum(address)
} else {
return false
}
},

verifyChecksum: function (address) {
var decoded = utils.bech32.decode(address)
if (decoded !== null) {
return decoded.data.length === 32
} else {
return false
}
}
}

},{"./crypto/utils":53}],40:[function(require,module,exports){
const base58 = require('./crypto/base58');

// simple base58 validator. Just checks if it can be decoded.
Expand Down Expand Up @@ -8399,7 +8426,7 @@ module.exports = {
}
};

},{"./crypto/base58":44}],40:[function(require,module,exports){
},{"./crypto/base58":45}],41:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');
var bech32 = require('./crypto/bech32');
var BTCValidator = require('./bitcoin_validator');
Expand Down Expand Up @@ -8449,7 +8476,7 @@ module.exports = {
}
}

},{"./bitcoin_validator":42,"./crypto/bech32":45,"./crypto/utils":52}],41:[function(require,module,exports){
},{"./bitcoin_validator":43,"./crypto/bech32":46,"./crypto/utils":53}],42:[function(require,module,exports){
var bech32 = require('./crypto/bech32');

// bip 173 bech 32 addresses (https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki)
Expand Down Expand Up @@ -8479,7 +8506,7 @@ module.exports = {
}
};

},{"./crypto/bech32":45}],42:[function(require,module,exports){
},{"./crypto/bech32":46}],43:[function(require,module,exports){
(function (Buffer){(function (){
var base58 = require('./crypto/base58');
var segwit = require('./crypto/segwit_addr');
Expand Down Expand Up @@ -8571,7 +8598,7 @@ module.exports = {
};

}).call(this)}).call(this,require("buffer").Buffer)
},{"./crypto/base58":44,"./crypto/segwit_addr":50,"./crypto/utils":52,"buffer":4}],43:[function(require,module,exports){
},{"./crypto/base58":45,"./crypto/segwit_addr":51,"./crypto/utils":53,"buffer":4}],44:[function(require,module,exports){
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";

/**
Expand Down Expand Up @@ -8638,7 +8665,7 @@ module.exports = {
b32decode: b32decode,
b32encode: b32encode
};
},{}],44:[function(require,module,exports){
},{}],45:[function(require,module,exports){
// Base58 encoding/decoding
// Originally written by Mike Hearn for BitcoinJ
// Copyright (c) 2011 Google Inc
Expand Down Expand Up @@ -8686,7 +8713,7 @@ module.exports = {
}
};

},{}],45:[function(require,module,exports){
},{}],46:[function(require,module,exports){
// Copyright (c) 2017, 2021 Pieter Wuille
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -8820,7 +8847,7 @@ function decode (bechString, enc) {
return {hrp: hrp, data: data.slice(0, data.length - 6)};
}

},{}],46:[function(require,module,exports){
},{}],47:[function(require,module,exports){
/*
JavaScript BigInteger library version 0.9.1
http://silentmatt.com/biginteger/
Expand Down Expand Up @@ -10271,7 +10298,7 @@ function decode (bechString, enc) {

exports.JSBigInt = BigInteger; // exports.BigInteger changed to exports.JSBigInt
})(typeof exports !== 'undefined' ? exports : this);
},{}],47:[function(require,module,exports){
},{}],48:[function(require,module,exports){
(function (Buffer){(function (){
'use strict';

Expand Down Expand Up @@ -10463,7 +10490,7 @@ Blake256.prototype.digest = function (encoding) {
module.exports = Blake256;

}).call(this)}).call(this,require("buffer").Buffer)
},{"buffer":4}],48:[function(require,module,exports){
},{"buffer":4}],49:[function(require,module,exports){
'use strict';

/**
Expand Down Expand Up @@ -10741,7 +10768,7 @@ function toHex (n) {

module.exports = Blake2b;

},{}],49:[function(require,module,exports){
},{}],50:[function(require,module,exports){
var JSBigInt = require('./biginteger')['JSBigInt'];

/**
Expand Down Expand Up @@ -10968,7 +10995,7 @@ var cnBase58 = (function () {
return b58;
})();
module.exports = cnBase58;
},{"./biginteger":46}],50:[function(require,module,exports){
},{"./biginteger":47}],51:[function(require,module,exports){
// Copyright (c) 2017, 2021 Pieter Wuille
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -11093,7 +11120,7 @@ module.exports = {
isValidAddress: isValidAddress,
};

},{"./bech32":45}],51:[function(require,module,exports){
},{"./bech32":46}],52:[function(require,module,exports){
(function (process,global){(function (){
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
Expand Down Expand Up @@ -11737,7 +11764,7 @@ var f = function (s) {
module.exports = methods;

}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":35}],52:[function(require,module,exports){
},{"_process":35}],53:[function(require,module,exports){
(function (Buffer){(function (){
var jsSHA = require('jssha');
var sha512256 = require('js-sha512').sha512_256
Expand Down Expand Up @@ -11873,7 +11900,7 @@ module.exports = {
}

}).call(this)}).call(this,require("buffer").Buffer)
},{"./base32":43,"./base58":44,"./blake256":47,"./blake2b":48,"./sha3":51,"browserify-bignum":3,"buffer":4,"js-sha512":32,"jssha":33}],53:[function(require,module,exports){
},{"./base32":44,"./base58":45,"./blake256":48,"./blake2b":49,"./sha3":52,"browserify-bignum":3,"buffer":4,"js-sha512":32,"jssha":33}],54:[function(require,module,exports){
var XRPValidator = require('./ripple_validator');
var ETHValidator = require('./ethereum_validator');
var BTCValidator = require('./bitcoin_validator');
Expand All @@ -11893,6 +11920,7 @@ var AlgoValidator = require('./algo_validator');
var DotValidator = require('./dot_validator');
var BIP173Validator = require('./bip173_validator')
var Base58Validator = require('./base58_validator')
var ATOMValidator = require('./atom_validator')

// defines P2PKH and P2SH address types for standard (prod) and testnet networks
var CURRENCIES = [{
Expand Down Expand Up @@ -12480,6 +12508,11 @@ var CURRENCIES = [{
symbol: 'avax',
validator: ETHValidator,
},
{
name: 'Cosmos',
symbol: 'atom',
validator: ATOMValidator
}
];


Expand Down Expand Up @@ -12507,7 +12540,7 @@ var CURRENCIES = [{
//


},{"./ada_validator":37,"./algo_validator":38,"./base58_validator":39,"./bch_validator":40,"./bip173_validator":41,"./bitcoin_validator":42,"./dot_validator":54,"./eos_validator":55,"./ethereum_validator":56,"./lisk_validator":57,"./monero_validator":58,"./nano_validator":59,"./nem_validator":60,"./ripple_validator":61,"./siacoin_validator":62,"./stellar_validator":63,"./tezos_validator":64,"./tron_validator":65,"./usdt_validator":66}],54:[function(require,module,exports){
},{"./ada_validator":37,"./algo_validator":38,"./atom_validator":39,"./base58_validator":40,"./bch_validator":41,"./bip173_validator":42,"./bitcoin_validator":43,"./dot_validator":55,"./eos_validator":56,"./ethereum_validator":57,"./lisk_validator":58,"./monero_validator":59,"./nano_validator":60,"./nem_validator":61,"./ripple_validator":62,"./siacoin_validator":63,"./stellar_validator":64,"./tezos_validator":65,"./tron_validator":66,"./usdt_validator":67}],55:[function(require,module,exports){
const cryptoUtils = require('./crypto/utils');

// from https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)
Expand Down Expand Up @@ -12568,7 +12601,7 @@ module.exports = {
}
}

},{"./crypto/utils":52}],55:[function(require,module,exports){
},{"./crypto/utils":53}],56:[function(require,module,exports){
function isValidEOSAddress (address, currency, networkType) {
var regex = /^[a-z0-9.]+$/g // Must be numbers, lowercase letters and decimal points only
if (address.search(regex) !== -1 && address.length === 12) {
Expand All @@ -12584,7 +12617,7 @@ module.exports = {
}
}

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

module.exports = {
Expand Down Expand Up @@ -12620,7 +12653,7 @@ module.exports = {
}
};

},{"./crypto/utils":52}],57:[function(require,module,exports){
},{"./crypto/utils":53}],58:[function(require,module,exports){
(function (Buffer){(function (){
var cryptoUtils = require('./crypto/utils');

Expand All @@ -12642,7 +12675,7 @@ module.exports = {
}
};
}).call(this)}).call(this,require("buffer").Buffer)
},{"./crypto/utils":52,"buffer":4}],58:[function(require,module,exports){
},{"./crypto/utils":53,"buffer":4}],59:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils')
var cnBase58 = require('./crypto/cnBase58')

Expand Down Expand Up @@ -12708,7 +12741,7 @@ module.exports = {
}
}

},{"./crypto/cnBase58":49,"./crypto/utils":52}],59:[function(require,module,exports){
},{"./crypto/cnBase58":50,"./crypto/utils":53}],60:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');
var baseX = require('base-x');

Expand Down Expand Up @@ -12737,7 +12770,7 @@ module.exports = {
}
};

},{"./crypto/utils":52,"base-x":1}],60:[function(require,module,exports){
},{"./crypto/utils":53,"base-x":1}],61:[function(require,module,exports){
(function (Buffer){(function (){
var cryptoUtils = require('./crypto/utils');

Expand All @@ -12764,7 +12797,7 @@ module.exports = {
}

}).call(this)}).call(this,require("buffer").Buffer)
},{"./crypto/utils":52,"buffer":4}],61:[function(require,module,exports){
},{"./crypto/utils":53,"buffer":4}],62:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');
var baseX = require('base-x');

Expand Down Expand Up @@ -12794,7 +12827,7 @@ module.exports = {
}
};

},{"./crypto/utils":52,"base-x":1}],62:[function(require,module,exports){
},{"./crypto/utils":53,"base-x":1}],63:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils')
var isEqual = require('lodash.isequal')

Expand Down Expand Up @@ -12824,7 +12857,7 @@ module.exports = {
}
}

},{"./crypto/utils":52,"lodash.isequal":34}],63:[function(require,module,exports){
},{"./crypto/utils":53,"lodash.isequal":34}],64:[function(require,module,exports){
var baseX = require('base-x');
var crc = require('crc');
var cryptoUtils = require('./crypto/utils');
Expand Down Expand Up @@ -12864,7 +12897,7 @@ module.exports = {
}
};

},{"./crypto/utils":52,"base-x":1,"crc":30}],64:[function(require,module,exports){
},{"./crypto/utils":53,"base-x":1,"crc":30}],65:[function(require,module,exports){
const base58 = require('./crypto/base58');
const cryptoUtils = require('./crypto/utils');

Expand Down Expand Up @@ -12902,7 +12935,7 @@ module.exports = {
isValidAddress
};

},{"./crypto/base58":44,"./crypto/utils":52}],65:[function(require,module,exports){
},{"./crypto/base58":45,"./crypto/utils":53}],66:[function(require,module,exports){
var cryptoUtils = require('./crypto/utils');

function decodeBase58Address(base58Sting) {
Expand Down Expand Up @@ -12966,7 +12999,7 @@ module.exports = {
}
};

},{"./crypto/utils":52}],66:[function(require,module,exports){
},{"./crypto/utils":53}],67:[function(require,module,exports){
var BTCValidator = require('./bitcoin_validator');
var ETHValidator = require('./ethereum_validator');

Expand All @@ -12989,7 +13022,7 @@ module.exports = {
}
};

},{"./bitcoin_validator":42,"./ethereum_validator":56}],67:[function(require,module,exports){
},{"./bitcoin_validator":43,"./ethereum_validator":57}],68:[function(require,module,exports){
var currencies = require('./currencies');

var DEFAULT_CURRENCY_NAME = 'bitcoin';
Expand All @@ -13016,5 +13049,5 @@ module.exports = {
}
};

},{"./currencies":53}]},{},[67])(67)
},{"./currencies":54}]},{},[68])(68)
});
2 changes: 1 addition & 1 deletion dist/wallet-address-validator.min.js

Large diffs are not rendered by default.

Loading