Comparing version 0.5.0 to 0.6.0
@@ -1,4 +0,4 @@ | ||
import { ChainID } from "./chain"; | ||
interface AccountIDParams { | ||
chainId: string; | ||
import { ChainID, ChainIDParams } from "./chain"; | ||
export interface AccountIDParams { | ||
chainId: string | ChainIDParams; | ||
address: string; | ||
@@ -14,7 +14,6 @@ } | ||
address: string; | ||
constructor(params: AccountIDParams); | ||
constructor(params: AccountIDParams | string); | ||
toString(): string; | ||
toJson(): AccountIDParams; | ||
} | ||
export {}; | ||
//# sourceMappingURL=account.d.ts.map |
@@ -6,4 +6,11 @@ "use strict"; | ||
constructor(params) { | ||
this.chainId = chain_1.ChainID.parse(params.chainId); | ||
this.address = params.address; | ||
if (typeof params === "string") { | ||
const accountId = AccountID.parse(params); | ||
this.chainId = accountId.chainId; | ||
this.address = accountId.address; | ||
} | ||
else { | ||
this.chainId = new chain_1.ChainID(params.chainId); | ||
this.address = params.address; | ||
} | ||
} | ||
@@ -10,0 +17,0 @@ static isValid(accountId) { |
@@ -1,2 +0,2 @@ | ||
interface ChainIDParams { | ||
export interface ChainIDParams { | ||
namespace: string; | ||
@@ -13,7 +13,6 @@ reference: string; | ||
reference: string; | ||
constructor(params: ChainIDParams); | ||
constructor(params: ChainIDParams | string); | ||
toString(): string; | ||
toJson(): ChainIDParams; | ||
} | ||
export {}; | ||
//# sourceMappingURL=chain.d.ts.map |
@@ -5,4 +5,11 @@ "use strict"; | ||
constructor(params) { | ||
this.namespace = params.namespace; | ||
this.reference = params.reference; | ||
if (typeof params === "string") { | ||
const chainId = ChainID.parse(params); | ||
this.namespace = chainId.namespace; | ||
this.reference = chainId.reference; | ||
} | ||
else { | ||
this.namespace = params.namespace; | ||
this.reference = params.reference; | ||
} | ||
} | ||
@@ -9,0 +16,0 @@ static isValid(chainId) { |
@@ -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 i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=1)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e){this.namespace=e.namespace,this.reference=e.reference}static isValid(e){return e.includes(this.delimiter)}static parse(e){if(!n.isValid(e))throw new Error("Invalid chainId provided: "+e);const t=e.split(this.delimiter);return new n({namespace:t[0],reference:t[1]})}static format(e){return e.namespace+this.delimiter+e.reference}toString(){return n.format(this.toJson())}toJson(){return{namespace:this.namespace,reference:this.reference}}}t.ChainID=n,n.standard="caip-2",n.delimiter=":"},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(2)),n(r(0))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);class i{constructor(e){this.chainId=n.ChainID.parse(e.chainId),this.address=e.address}static isValid(e){return e.includes(this.delimiter)}static parse(e){if(!i.isValid(e))throw new Error("Invalid accountId provided: "+e);const t=e.split(this.delimiter);return new i({chainId:t[1],address:t[0]})}static format(e){return e.address+this.delimiter+e.chainId}toString(){return i.format(this.toJson())}toJson(){return{chainId:this.chainId.toString(),address:this.address}}}t.AccountID=i,i.standard="caip-10",i.delimiter="@"}])})); | ||
!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 i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=1)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{constructor(e){if("string"==typeof e){const t=n.parse(e);this.namespace=t.namespace,this.reference=t.reference}else this.namespace=e.namespace,this.reference=e.reference}static isValid(e){return e.includes(this.delimiter)}static parse(e){if(!n.isValid(e))throw new Error("Invalid chainId provided: "+e);const t=e.split(this.delimiter);return new n({namespace:t[0],reference:t[1]})}static format(e){return e.namespace+this.delimiter+e.reference}toString(){return n.format(this.toJson())}toJson(){return{namespace:this.namespace,reference:this.reference}}}t.ChainID=n,n.standard="caip-2",n.delimiter=":"},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(2)),n(r(0))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);class i{constructor(e){if("string"==typeof e){const t=i.parse(e);this.chainId=t.chainId,this.address=t.address}else this.chainId=new n.ChainID(e.chainId),this.address=e.address}static isValid(e){return e.includes(this.delimiter)}static parse(e){if(!i.isValid(e))throw new Error("Invalid accountId provided: "+e);const t=e.split(this.delimiter);return new i({chainId:t[1],address:t[0]})}static format(e){return e.address+this.delimiter+e.chainId}toString(){return i.format(this.toJson())}toJson(){return{chainId:this.chainId.toString(),address:this.address}}}t.AccountID=i,i.standard="caip-10",i.delimiter="@"}])})); |
{ | ||
"name": "caip", | ||
"description": "CAIP standard utils", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"author": "Pedro Gomes <github.com/pedrouid>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118441
129