@ellipticltd/aml-utils 0.14.3 → 0.14.4
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.
|
@@ -182,3 +182,9 @@ export namespace polygon {
|
|
|
182
182
|
function isTxHash(str: any): any;
|
|
183
183
|
function isTxHash(str: any): any;
|
|
184
184
|
}
|
|
185
|
+
export namespace filecoin {
|
|
186
|
+
function isAddress(str: any): boolean;
|
|
187
|
+
function isAddress(str: any): boolean;
|
|
188
|
+
function isTxHash(str: any): boolean;
|
|
189
|
+
function isTxHash(str: any): boolean;
|
|
190
|
+
}
|
|
@@ -386,6 +386,14 @@ const validations = {
|
|
|
386
386
|
return str.length === 66 && web3.isHexStrict(str);
|
|
387
387
|
},
|
|
388
388
|
},
|
|
389
|
+
filecoin: {
|
|
390
|
+
isAddress(str) {
|
|
391
|
+
return /^(f0|f1|f2|f3)/.test(str);
|
|
392
|
+
},
|
|
393
|
+
isTxHash(str) {
|
|
394
|
+
return str.length === 62 && /^bafy2bza/.test(str);
|
|
395
|
+
},
|
|
396
|
+
},
|
|
389
397
|
};
|
|
390
398
|
Object.keys(V).forEach((k) => {
|
|
391
399
|
const v = V[k];
|
|
@@ -353,4 +353,18 @@ describe('Validations', () => {
|
|
|
353
353
|
it('should correctly validate an incorrect Polygon hash', () => validations_1.default.polygon.isTxHash('0x45a491048477568dd2047a0a9b6be9cc491382e74823e').should.be.false);
|
|
354
354
|
});
|
|
355
355
|
});
|
|
356
|
+
describe('Filecoin', () => {
|
|
357
|
+
describe('isAddress', () => {
|
|
358
|
+
it('should correctly validate a valid Filecoin f0 address', () => validations_1.default.filecoin.isAddress('f01825161').should.be.true);
|
|
359
|
+
it('should correctly validate a valid Filecoin f1 address', () => validations_1.default.filecoin.isAddress('f1xafi3wsh7q553efnumhgeomathrehwwd2mye7oy').should.be.true);
|
|
360
|
+
it('should correctly validate a valid Filecoin f2 address', () => validations_1.default.filecoin.isAddress('f2vrab2ft4qc22mgfxgdrphd7ovvz6zs3nq3fv4oy').should.be.true);
|
|
361
|
+
it('should correctly validate a valid Filecoin f3 address', () => validations_1.default.filecoin.isAddress('f3ug2ti4finql5bxyl5q56udn5lt462miuadjg3ur467wrj6bvbrksglxyv65zoxyz4mgte3joyce3oxkk4q7q').should.be.true);
|
|
362
|
+
it('should correctly validate an invalid Filecoin address', () => validations_1.default.filecoin.isAddress('f4zvcxzvcxzvczvcasdgwere').should.be.false);
|
|
363
|
+
});
|
|
364
|
+
describe('isTxHash', () => {
|
|
365
|
+
it('should correctly validate a valid Filecoin hash', () => validations_1.default.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.true);
|
|
366
|
+
it('should correctly validate an invalid Filecoin hash', () => validations_1.default.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7').should.be.false);
|
|
367
|
+
it('should correctly validate an invalid Filecoin hash', () => validations_1.default.filecoin.isTxHash('fafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.false);
|
|
368
|
+
});
|
|
369
|
+
});
|
|
356
370
|
});
|
|
@@ -391,6 +391,14 @@ const validations = {
|
|
|
391
391
|
return str.length === 66 && web3.isHexStrict(str);
|
|
392
392
|
},
|
|
393
393
|
},
|
|
394
|
+
filecoin: {
|
|
395
|
+
isAddress(str) {
|
|
396
|
+
return /^(f0|f1|f2|f3)/.test(str);
|
|
397
|
+
},
|
|
398
|
+
isTxHash(str) {
|
|
399
|
+
return str.length === 62 && /^bafy2bza/.test(str);
|
|
400
|
+
},
|
|
401
|
+
},
|
|
394
402
|
};
|
|
395
403
|
|
|
396
404
|
Object.keys(V).forEach((k) => {
|
|
@@ -464,4 +464,26 @@ describe('Validations', () => {
|
|
|
464
464
|
it('should correctly validate an incorrect Polygon hash', () => validations.polygon.isTxHash('0x45a491048477568dd2047a0a9b6be9cc491382e74823e').should.be.false);
|
|
465
465
|
});
|
|
466
466
|
});
|
|
467
|
+
|
|
468
|
+
describe('Filecoin', () => {
|
|
469
|
+
describe('isAddress', () => {
|
|
470
|
+
it('should correctly validate a valid Filecoin f0 address', () => validations.filecoin.isAddress('f01825161').should.be.true);
|
|
471
|
+
|
|
472
|
+
it('should correctly validate a valid Filecoin f1 address', () => validations.filecoin.isAddress('f1xafi3wsh7q553efnumhgeomathrehwwd2mye7oy').should.be.true);
|
|
473
|
+
|
|
474
|
+
it('should correctly validate a valid Filecoin f2 address', () => validations.filecoin.isAddress('f2vrab2ft4qc22mgfxgdrphd7ovvz6zs3nq3fv4oy').should.be.true);
|
|
475
|
+
|
|
476
|
+
it('should correctly validate a valid Filecoin f3 address', () => validations.filecoin.isAddress('f3ug2ti4finql5bxyl5q56udn5lt462miuadjg3ur467wrj6bvbrksglxyv65zoxyz4mgte3joyce3oxkk4q7q').should.be.true);
|
|
477
|
+
|
|
478
|
+
it('should correctly validate an invalid Filecoin address', () => validations.filecoin.isAddress('f4zvcxzvcxzvczvcasdgwere').should.be.false);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
describe('isTxHash', () => {
|
|
482
|
+
it('should correctly validate a valid Filecoin hash', () => validations.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.true);
|
|
483
|
+
|
|
484
|
+
it('should correctly validate an invalid Filecoin hash', () => validations.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7').should.be.false);
|
|
485
|
+
|
|
486
|
+
it('should correctly validate an invalid Filecoin hash', () => validations.filecoin.isTxHash('fafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.false);
|
|
487
|
+
});
|
|
488
|
+
});
|
|
467
489
|
});
|