@hybrd/utils 0.3.6 → 0.3.8
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.
- package/dist/index.cjs +2 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.js +1 -14
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -22,13 +22,11 @@ __export(src_exports, {
|
|
|
22
22
|
bipsToDecimal: () => bipsToDecimal,
|
|
23
23
|
bipsToPercent: () => bipsToPercent,
|
|
24
24
|
chainName: () => chainName,
|
|
25
|
-
ethToWei: () => ethToWei,
|
|
26
25
|
etherscanAddressURL: () => etherscanAddressURL,
|
|
27
26
|
etherscanHost: () => etherscanHost,
|
|
28
27
|
etherscanTxURL: () => etherscanTxURL,
|
|
29
28
|
percentToBips: () => percentToBips,
|
|
30
|
-
truncateEthAddress: () => truncateEthAddress
|
|
31
|
-
weiToEth: () => weiToEth
|
|
29
|
+
truncateEthAddress: () => truncateEthAddress
|
|
32
30
|
});
|
|
33
31
|
module.exports = __toCommonJS(src_exports);
|
|
34
32
|
|
|
@@ -65,17 +63,6 @@ function chainName(chainId) {
|
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
// src/conversion.ts
|
|
69
|
-
var import_ethers = require("ethers");
|
|
70
|
-
function weiToEth(wei) {
|
|
71
|
-
return parseFloat(import_ethers.utils.formatEther(wei.toString()));
|
|
72
|
-
}
|
|
73
|
-
function ethToWei(eth) {
|
|
74
|
-
if (typeof eth === "undefined")
|
|
75
|
-
return null;
|
|
76
|
-
return import_ethers.ethers.utils.parseUnits(eth.toString(), "ether");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
66
|
// src/etherscan.ts
|
|
80
67
|
function etherscanAddressURL(address, chainId = 1) {
|
|
81
68
|
return etherscanHost(chainId) + "/address/" + address;
|
|
@@ -113,12 +100,10 @@ function truncateEthAddress(address) {
|
|
|
113
100
|
bipsToDecimal,
|
|
114
101
|
bipsToPercent,
|
|
115
102
|
chainName,
|
|
116
|
-
ethToWei,
|
|
117
103
|
etherscanAddressURL,
|
|
118
104
|
etherscanHost,
|
|
119
105
|
etherscanTxURL,
|
|
120
106
|
percentToBips,
|
|
121
|
-
truncateEthAddress
|
|
122
|
-
weiToEth
|
|
107
|
+
truncateEthAddress
|
|
123
108
|
});
|
|
124
109
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/basisPoints.ts","../src/chains.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/basisPoints.ts","../src/chains.ts","../src/etherscan.ts","../src/formatting.ts"],"sourcesContent":["export * from \"./basisPoints\"\nexport * from \"./chains\"\nexport * from \"./etherscan\"\nexport * from \"./formatting\"\n","export function bipsToPercent(bp: number | string) {\n if (typeof bp !== \"number\") return null\n return parseInt(bp.toString()) / 100\n}\n\nexport function percentToBips(percent: number) {\n return percent * 100\n}\n\nexport function bipsToDecimal(bp: number | string) {\n if (typeof bp !== \"number\") return 0\n return parseInt(bp.toString()) / 10000\n}\n","export function chainName(chainId: number | string) {\n switch (parseInt(chainId.toString())) {\n case 1:\n return `Ethereum`\n case 3:\n return `Ropsten`\n case 4:\n return `Rinkeby`\n case 5:\n return `Goerli`\n case 137:\n return `Polygon`\n case 80001:\n return `Mumbai`\n }\n}\n","export function etherscanAddressURL(address: string, chainId = 1) {\n return etherscanHost(chainId) + \"/address/\" + address\n}\n\nexport function etherscanTxURL(hash: string, chainId = 1) {\n return etherscanHost(chainId) + \"/tx/\" + hash\n}\n\nexport function etherscanHost(chainId = 1) {\n switch (chainId) {\n case 1:\n return `https://etherscan.io`\n case 3:\n return `https://ropsten.etherscan.io`\n case 4:\n return `https://rinkeby.etherscan.io`\n case 5:\n return `https://goerli.etherscan.io`\n case 137:\n return `https://polygonscan.com`\n case 80001:\n return `https://mumbai.polygonscan.com`\n default:\n throw new Error(\"Etherscan: Unknown chain id \" + chainId)\n }\n}\n","export function truncateEthAddress(address: string | undefined) {\n if (!address) return null\n return address.slice(0, 6) + \"…\" + address.slice(38, 42)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,cAAc,IAAqB;AACjD,MAAI,OAAO,OAAO;AAAU,WAAO;AACnC,SAAO,SAAS,GAAG,SAAS,CAAC,IAAI;AACnC;AAEO,SAAS,cAAc,SAAiB;AAC7C,SAAO,UAAU;AACnB;AAEO,SAAS,cAAc,IAAqB;AACjD,MAAI,OAAO,OAAO;AAAU,WAAO;AACnC,SAAO,SAAS,GAAG,SAAS,CAAC,IAAI;AACnC;;;ACZO,SAAS,UAAU,SAA0B;AAClD,UAAQ,SAAS,QAAQ,SAAS,CAAC,GAAG;AAAA,IACpC,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;;;ACfO,SAAS,oBAAoB,SAAiB,UAAU,GAAG;AAChE,SAAO,cAAc,OAAO,IAAI,cAAc;AAChD;AAEO,SAAS,eAAe,MAAc,UAAU,GAAG;AACxD,SAAO,cAAc,OAAO,IAAI,SAAS;AAC3C;AAEO,SAAS,cAAc,UAAU,GAAG;AACzC,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,iCAAiC,OAAO;AAAA,EAC5D;AACF;;;ACzBO,SAAS,mBAAmB,SAA6B;AAC9D,MAAI,CAAC;AAAS,WAAO;AACrB,SAAO,QAAQ,MAAM,GAAG,CAAC,IAAI,WAAM,QAAQ,MAAM,IAAI,EAAE;AACzD;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import { BigNumberish, BigNumber } from 'ethers';
|
|
2
|
-
|
|
3
1
|
declare function bipsToPercent(bp: number | string): number;
|
|
4
2
|
declare function percentToBips(percent: number): number;
|
|
5
3
|
declare function bipsToDecimal(bp: number | string): number;
|
|
6
4
|
|
|
7
5
|
declare function chainName(chainId: number | string): "Ethereum" | "Ropsten" | "Rinkeby" | "Goerli" | "Polygon" | "Mumbai";
|
|
8
6
|
|
|
9
|
-
declare function weiToEth(wei: BigNumberish): number;
|
|
10
|
-
declare function ethToWei(eth: number): BigNumber | null;
|
|
11
|
-
|
|
12
7
|
declare function etherscanAddressURL(address: string, chainId?: number): string;
|
|
13
8
|
declare function etherscanTxURL(hash: string, chainId?: number): string;
|
|
14
9
|
declare function etherscanHost(chainId?: number): "https://etherscan.io" | "https://ropsten.etherscan.io" | "https://rinkeby.etherscan.io" | "https://goerli.etherscan.io" | "https://polygonscan.com" | "https://mumbai.polygonscan.com";
|
|
15
10
|
|
|
16
11
|
declare function truncateEthAddress(address: string | undefined): string;
|
|
17
12
|
|
|
18
|
-
export { bipsToDecimal, bipsToPercent, chainName,
|
|
13
|
+
export { bipsToDecimal, bipsToPercent, chainName, etherscanAddressURL, etherscanHost, etherscanTxURL, percentToBips, truncateEthAddress };
|
package/dist/index.js
CHANGED
|
@@ -31,17 +31,6 @@ function chainName(chainId) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
// src/conversion.ts
|
|
35
|
-
import { ethers, utils } from "ethers";
|
|
36
|
-
function weiToEth(wei) {
|
|
37
|
-
return parseFloat(utils.formatEther(wei.toString()));
|
|
38
|
-
}
|
|
39
|
-
function ethToWei(eth) {
|
|
40
|
-
if (typeof eth === "undefined")
|
|
41
|
-
return null;
|
|
42
|
-
return ethers.utils.parseUnits(eth.toString(), "ether");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
34
|
// src/etherscan.ts
|
|
46
35
|
function etherscanAddressURL(address, chainId = 1) {
|
|
47
36
|
return etherscanHost(chainId) + "/address/" + address;
|
|
@@ -78,12 +67,10 @@ export {
|
|
|
78
67
|
bipsToDecimal,
|
|
79
68
|
bipsToPercent,
|
|
80
69
|
chainName,
|
|
81
|
-
ethToWei,
|
|
82
70
|
etherscanAddressURL,
|
|
83
71
|
etherscanHost,
|
|
84
72
|
etherscanTxURL,
|
|
85
73
|
percentToBips,
|
|
86
|
-
truncateEthAddress
|
|
87
|
-
weiToEth
|
|
74
|
+
truncateEthAddress
|
|
88
75
|
};
|
|
89
76
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/basisPoints.ts","../src/chains.ts","../src/
|
|
1
|
+
{"version":3,"sources":["../src/basisPoints.ts","../src/chains.ts","../src/etherscan.ts","../src/formatting.ts"],"sourcesContent":["export function bipsToPercent(bp: number | string) {\n if (typeof bp !== \"number\") return null\n return parseInt(bp.toString()) / 100\n}\n\nexport function percentToBips(percent: number) {\n return percent * 100\n}\n\nexport function bipsToDecimal(bp: number | string) {\n if (typeof bp !== \"number\") return 0\n return parseInt(bp.toString()) / 10000\n}\n","export function chainName(chainId: number | string) {\n switch (parseInt(chainId.toString())) {\n case 1:\n return `Ethereum`\n case 3:\n return `Ropsten`\n case 4:\n return `Rinkeby`\n case 5:\n return `Goerli`\n case 137:\n return `Polygon`\n case 80001:\n return `Mumbai`\n }\n}\n","export function etherscanAddressURL(address: string, chainId = 1) {\n return etherscanHost(chainId) + \"/address/\" + address\n}\n\nexport function etherscanTxURL(hash: string, chainId = 1) {\n return etherscanHost(chainId) + \"/tx/\" + hash\n}\n\nexport function etherscanHost(chainId = 1) {\n switch (chainId) {\n case 1:\n return `https://etherscan.io`\n case 3:\n return `https://ropsten.etherscan.io`\n case 4:\n return `https://rinkeby.etherscan.io`\n case 5:\n return `https://goerli.etherscan.io`\n case 137:\n return `https://polygonscan.com`\n case 80001:\n return `https://mumbai.polygonscan.com`\n default:\n throw new Error(\"Etherscan: Unknown chain id \" + chainId)\n }\n}\n","export function truncateEthAddress(address: string | undefined) {\n if (!address) return null\n return address.slice(0, 6) + \"…\" + address.slice(38, 42)\n}\n"],"mappings":";AAAO,SAAS,cAAc,IAAqB;AACjD,MAAI,OAAO,OAAO;AAAU,WAAO;AACnC,SAAO,SAAS,GAAG,SAAS,CAAC,IAAI;AACnC;AAEO,SAAS,cAAc,SAAiB;AAC7C,SAAO,UAAU;AACnB;AAEO,SAAS,cAAc,IAAqB;AACjD,MAAI,OAAO,OAAO;AAAU,WAAO;AACnC,SAAO,SAAS,GAAG,SAAS,CAAC,IAAI;AACnC;;;ACZO,SAAS,UAAU,SAA0B;AAClD,UAAQ,SAAS,QAAQ,SAAS,CAAC,GAAG;AAAA,IACpC,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;;;ACfO,SAAS,oBAAoB,SAAiB,UAAU,GAAG;AAChE,SAAO,cAAc,OAAO,IAAI,cAAc;AAChD;AAEO,SAAS,eAAe,MAAc,UAAU,GAAG;AACxD,SAAO,cAAc,OAAO,IAAI,SAAS;AAC3C;AAEO,SAAS,cAAc,UAAU,GAAG;AACzC,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,YAAM,IAAI,MAAM,iCAAiC,OAAO;AAAA,EAC5D;AACF;;;ACzBO,SAAS,mBAAmB,SAA6B;AAC9D,MAAI,CAAC;AAAS,WAAO;AACrB,SAAO,QAAQ,MAAM,GAAG,CAAC,IAAI,WAAM,QAAQ,MAAM,IAAI,EAAE;AACzD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hybrd/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Solidity + TypeScript Framework for Web3 Development",
|
|
5
5
|
"author": "Ian Hunter <ian@ianh.xyz>",
|
|
6
6
|
"homepage": "https://github.com/ian/hybrid#readme",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"viem": "^0.1.10"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@hybrd/types": "^0.3.
|
|
49
|
+
"@hybrd/types": "^0.3.8",
|
|
50
50
|
"@types/inquirer": "^9.0.3",
|
|
51
51
|
"@types/node": "^18.14.6",
|
|
52
52
|
"nodemon": "^2.0.21",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"tsx": "^3.12.3",
|
|
55
55
|
"typescript": "^4.9.5"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "9ec562a3b6629a9b2aa55703ea7063db07d7716c"
|
|
58
58
|
}
|