Socket
Socket
Sign inDemoInstall

caip

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.1 to 0.9.2

2

dist/cjs/account.d.ts

@@ -9,3 +9,3 @@ import { ChainID, ChainIDParams } from "./chain";

static spec: IdentifierSpec;
static parse(id: string): AccountID;
static parse(id: string): AccountIDParams;
static format(params: AccountIDParams): string;

@@ -12,0 +12,0 @@ chainId: ChainID;

@@ -18,3 +18,3 @@ "use strict";

}
return new AccountID(utils_1.getParams(id, this.spec));
return new AccountID(utils_1.getParams(id, this.spec)).toJson();
}

@@ -21,0 +21,0 @@ static format(params) {

@@ -8,3 +8,3 @@ import { IdentifierSpec } from "./types";

static spec: IdentifierSpec;
static parse(id: string): ChainID;
static parse(id: string): ChainIDParams;
static format(params: ChainIDParams): string;

@@ -11,0 +11,0 @@ namespace: string;

@@ -17,3 +17,3 @@ "use strict";

}
return new ChainID(utils_1.getParams(id, this.spec));
return new ChainID(utils_1.getParams(id, this.spec)).toJson();
}

@@ -20,0 +20,0 @@ static format(params) {

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("CAIP",[],t):"object"==typeof exports?exports.CAIP=t():e.CAIP=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(n,s,function(t){return e[t]}.bind(null,s));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),s=r(2);class a{constructor(e){"string"==typeof e&&(e=a.parse(e)),this.namespace=e.namespace,this.reference=e.reference}static parse(e){if(!s.isValidId(e,this.spec))throw new Error(`Invalid ${this.spec.name} provided: ${e}`);return new a(s.getParams(e,this.spec))}static format(e){return s.joinParams(e,this.spec)}toString(){return a.format(this.toJson())}toJson(){return{namespace:this.namespace,reference:this.reference}}}t.ChainID=a,a.spec=n.CAIP[2]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={name:"chainId",regex:"[-:a-zA-Z0-9]{5,64}",parameters:{delimiter:":",values:{0:{name:"namespace",regex:"[-a-z0-9]{3,16}"},1:{name:"reference",regex:"[-a-zA-Z0-9]{1,47}"}}}},s={name:"accountId",regex:"[-@:a-zA-Z0-9]{7,128}",parameters:{delimiter:"@",values:{0:{name:"address",regex:"[a-zA-Z0-9]{1,63}"},1:n}}};t.CAIP={2:n,10:s}},function(e,t,r){"use strict";function n(e,t){return e.split(t.parameters.delimiter)}Object.defineProperty(t,"__esModule",{value:!0}),t.splitParams=n,t.getParams=function(e,t){const r=n(e,t),s={};return r.forEach((e,r)=>{s[t.parameters.values[r].name]=e}),s},t.joinParams=function e(t,r){return Object.values(r.parameters.values).map(r=>{const n=t[r.name];return"string"==typeof n?n:e(n,r)}).join(r.parameters.delimiter)},t.isValidId=function(e,t){if(!new RegExp(t.regex).test(e))return!1;const r=n(e,t);return r.length===Object.keys(t.parameters.values).length&&r.map((e,r)=>new RegExp(t.parameters.values[r].regex).test(e)).filter(e=>!!e).length===r.length}},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(4)),n(r(0))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),s=r(1),a=r(2);class o{constructor(e){"string"==typeof e&&(e=o.parse(e)),this.chainId=new n.ChainID(e.chainId),this.address=e.address}static parse(e){if(!a.isValidId(e,this.spec))throw new Error(`Invalid ${this.spec.name} provided: ${e}`);return new o(a.getParams(e,this.spec))}static format(e){return a.joinParams(e,this.spec)}toString(){return o.format(this.toJson())}toJson(){return{chainId:this.chainId.toJson(),address:this.address}}}t.AccountID=o,o.spec=s.CAIP[10]}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("CAIP",[],t):"object"==typeof exports?exports.CAIP=t():e.CAIP=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(n,s,function(t){return e[t]}.bind(null,s));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),s=r(2);class a{constructor(e){"string"==typeof e&&(e=a.parse(e)),this.namespace=e.namespace,this.reference=e.reference}static parse(e){if(!s.isValidId(e,this.spec))throw new Error(`Invalid ${this.spec.name} provided: ${e}`);return new a(s.getParams(e,this.spec)).toJson()}static format(e){return s.joinParams(e,this.spec)}toString(){return a.format(this.toJson())}toJson(){return{namespace:this.namespace,reference:this.reference}}}t.ChainID=a,a.spec=n.CAIP[2]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n={name:"chainId",regex:"[-:a-zA-Z0-9]{5,64}",parameters:{delimiter:":",values:{0:{name:"namespace",regex:"[-a-z0-9]{3,16}"},1:{name:"reference",regex:"[-a-zA-Z0-9]{1,47}"}}}},s={name:"accountId",regex:"[-@:a-zA-Z0-9]{7,128}",parameters:{delimiter:"@",values:{0:{name:"address",regex:"[a-zA-Z0-9]{1,63}"},1:n}}};t.CAIP={2:n,10:s}},function(e,t,r){"use strict";function n(e,t){return e.split(t.parameters.delimiter)}Object.defineProperty(t,"__esModule",{value:!0}),t.splitParams=n,t.getParams=function(e,t){const r=n(e,t),s={};return r.forEach((e,r)=>{s[t.parameters.values[r].name]=e}),s},t.joinParams=function e(t,r){return Object.values(r.parameters.values).map(r=>{const n=t[r.name];return"string"==typeof n?n:e(n,r)}).join(r.parameters.delimiter)},t.isValidId=function(e,t){if(!new RegExp(t.regex).test(e))return!1;const r=n(e,t);return r.length===Object.keys(t.parameters.values).length&&r.map((e,r)=>new RegExp(t.parameters.values[r].regex).test(e)).filter(e=>!!e).length===r.length}},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(4)),n(r(0))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(0),s=r(1),a=r(2);class o{constructor(e){"string"==typeof e&&(e=o.parse(e)),this.chainId=new n.ChainID(e.chainId),this.address=e.address}static parse(e){if(!a.isValidId(e,this.spec))throw new Error(`Invalid ${this.spec.name} provided: ${e}`);return new o(a.getParams(e,this.spec)).toJson()}static format(e){return a.joinParams(e,this.spec)}toString(){return o.format(this.toJson())}toJson(){return{chainId:this.chainId.toJson(),address:this.address}}}t.AccountID=o,o.spec=s.CAIP[10]}])}));
{
"name": "caip",
"description": "CAIP standard utils",
"version": "0.9.1",
"version": "0.9.2",
"author": "Pedro Gomes <github.com/pedrouid>",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -7,3 +7,3 @@ # caip [![npm version](https://badge.fury.io/js/caip.svg)](https://badge.fury.io/js/caip)

### Using Classes
### Object-oriented

@@ -28,3 +28,3 @@ ```typescript

### Using Functions
### Functional

@@ -45,3 +45,3 @@ ```typescript

### Using Classes
### Object-oriented

@@ -62,2 +62,9 @@ ```typescript

// ALSO
const accountId = new AccountID({
address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
chainId: "eip155:1",
});
// THEN

@@ -72,3 +79,3 @@

### Using Functions
### Functional

@@ -88,2 +95,10 @@ ```typescript

//"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"
// OR
AccountID.format({
address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
chainId: "eip155:1",
});
//"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc