@ellipticltd/aml-utils 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -188,3 +188,9 @@ export namespace filecoin {
|
|
|
188
188
|
function isTxHash(str: any): boolean;
|
|
189
189
|
function isTxHash(str: any): boolean;
|
|
190
190
|
}
|
|
191
|
+
export namespace optimism {
|
|
192
|
+
function isAddress(str: any): any;
|
|
193
|
+
function isAddress(str: any): any;
|
|
194
|
+
function isTxHash(str: any): any;
|
|
195
|
+
function isTxHash(str: any): any;
|
|
196
|
+
}
|
|
@@ -348,7 +348,7 @@ const validations = {
|
|
|
348
348
|
},
|
|
349
349
|
doge: {
|
|
350
350
|
isAddress(str) {
|
|
351
|
-
return /^
|
|
351
|
+
return /^[a-zA-Z\d]{34}$/.test(str);
|
|
352
352
|
},
|
|
353
353
|
isTxHash(str) {
|
|
354
354
|
return str.length === 64;
|
|
@@ -394,6 +394,14 @@ const validations = {
|
|
|
394
394
|
return str.length === 62 && /^bafy2bza/.test(str);
|
|
395
395
|
},
|
|
396
396
|
},
|
|
397
|
+
optimism: {
|
|
398
|
+
isAddress(str) {
|
|
399
|
+
return web3.isAddress(str);
|
|
400
|
+
},
|
|
401
|
+
isTxHash(str) {
|
|
402
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
403
|
+
},
|
|
404
|
+
},
|
|
397
405
|
};
|
|
398
406
|
Object.keys(V).forEach((k) => {
|
|
399
407
|
const v = V[k];
|
|
@@ -342,6 +342,20 @@ describe('Validations', () => {
|
|
|
342
342
|
it('should correctly validate an incorrect BSC hash', () => validations_1.default.binanceSmartChain.isTxHash('0x1a17145af3bec32f653d8ebd4c2c1b800214b17').should.be.false);
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
|
+
describe('Doge', () => {
|
|
346
|
+
describe('isAddress', () => {
|
|
347
|
+
it('should correctly validate valid Doge addresses', () => {
|
|
348
|
+
validations_1.default.doge.isAddress('9t3fCHSQz3j7XERcopTCUwMF3bZxJW99As').should.be.true;
|
|
349
|
+
validations_1.default.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBv').should.be.true;
|
|
350
|
+
});
|
|
351
|
+
it('should correctly validate an incorrect Doge address', () => validations_1.default.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dB_').should.be.false);
|
|
352
|
+
it('should correctly validate an incorrect (too long) Doge address', () => validations_1.default.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBvQ').should.be.false);
|
|
353
|
+
});
|
|
354
|
+
describe('isTxHash', () => {
|
|
355
|
+
it('should correctly validate a valid Doge hash', () => validations_1.default.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d418').should.be.true);
|
|
356
|
+
it('should correctly validate an incorrect Doge hash', () => validations_1.default.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d41').should.be.false);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
345
359
|
describe('Polygon', () => {
|
|
346
360
|
describe('isAddress', () => {
|
|
347
361
|
it('should correctly validate valid Polygon addresses', () => validations_1.default.polygon.isAddress('0x286c2bd6e0585f396647cbfdbfe14b92600365bb').should.be.true);
|
|
@@ -367,4 +381,16 @@ describe('Validations', () => {
|
|
|
367
381
|
it('should correctly validate an invalid Filecoin hash', () => validations_1.default.filecoin.isTxHash('fafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.false);
|
|
368
382
|
});
|
|
369
383
|
});
|
|
384
|
+
describe('Optimism', () => {
|
|
385
|
+
describe('isAddress', () => {
|
|
386
|
+
describe('isAddress', () => {
|
|
387
|
+
it('should return true if the address evaluates as a web3 address', () => validations_1.default.optimism.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
388
|
+
it('should return false if the address does not evaluate to a web3 address', () => validations_1.default.optimism.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.false);
|
|
389
|
+
});
|
|
390
|
+
describe('isTxHash', () => {
|
|
391
|
+
it('should correctly validate a valid OP hash', () => validations_1.default.optimism.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
392
|
+
it('should correctly validate an incorrect OP hash', () => validations_1.default.optimism.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.false);
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
});
|
|
370
396
|
});
|
|
@@ -353,7 +353,7 @@ const validations = {
|
|
|
353
353
|
},
|
|
354
354
|
doge: {
|
|
355
355
|
isAddress(str) {
|
|
356
|
-
return /^
|
|
356
|
+
return /^[a-zA-Z\d]{34}$/.test(str);
|
|
357
357
|
},
|
|
358
358
|
isTxHash(str) {
|
|
359
359
|
return str.length === 64;
|
|
@@ -399,6 +399,14 @@ const validations = {
|
|
|
399
399
|
return str.length === 62 && /^bafy2bza/.test(str);
|
|
400
400
|
},
|
|
401
401
|
},
|
|
402
|
+
optimism: {
|
|
403
|
+
isAddress(str) {
|
|
404
|
+
return web3.isAddress(str);
|
|
405
|
+
},
|
|
406
|
+
isTxHash(str) {
|
|
407
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
408
|
+
},
|
|
409
|
+
},
|
|
402
410
|
};
|
|
403
411
|
|
|
404
412
|
Object.keys(V).forEach((k) => {
|
|
@@ -449,6 +449,25 @@ describe('Validations', () => {
|
|
|
449
449
|
});
|
|
450
450
|
});
|
|
451
451
|
|
|
452
|
+
describe('Doge', () => {
|
|
453
|
+
describe('isAddress', () => {
|
|
454
|
+
it('should correctly validate valid Doge addresses', () => {
|
|
455
|
+
validations.doge.isAddress('9t3fCHSQz3j7XERcopTCUwMF3bZxJW99As').should.be.true;
|
|
456
|
+
validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBv').should.be.true;
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it('should correctly validate an incorrect Doge address', () => validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dB_').should.be.false);
|
|
460
|
+
|
|
461
|
+
it('should correctly validate an incorrect (too long) Doge address', () => validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBvQ').should.be.false);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
describe('isTxHash', () => {
|
|
465
|
+
it('should correctly validate a valid Doge hash', () => validations.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d418').should.be.true);
|
|
466
|
+
|
|
467
|
+
it('should correctly validate an incorrect Doge hash', () => validations.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d41').should.be.false);
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
|
|
452
471
|
describe('Polygon', () => {
|
|
453
472
|
describe('isAddress', () => {
|
|
454
473
|
it('should correctly validate valid Polygon addresses', () => validations.polygon.isAddress('0x286c2bd6e0585f396647cbfdbfe14b92600365bb').should.be.true);
|
|
@@ -486,4 +505,17 @@ describe('Validations', () => {
|
|
|
486
505
|
it('should correctly validate an invalid Filecoin hash', () => validations.filecoin.isTxHash('fafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.false);
|
|
487
506
|
});
|
|
488
507
|
});
|
|
508
|
+
describe('Optimism', () => {
|
|
509
|
+
describe('isAddress', () => {
|
|
510
|
+
describe('isAddress', () => {
|
|
511
|
+
it('should return true if the address evaluates as a web3 address', () => validations.optimism.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
512
|
+
it('should return false if the address does not evaluate to a web3 address', () => validations.optimism.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.false);
|
|
513
|
+
});
|
|
514
|
+
describe('isTxHash', () => {
|
|
515
|
+
it('should correctly validate a valid OP hash', () => validations.optimism.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
516
|
+
|
|
517
|
+
it('should correctly validate an incorrect OP hash', () => validations.optimism.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.false);
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
});
|
|
489
521
|
});
|