@meshsdk/common 1.6.4 → 1.6.5
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 +46 -7
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +46 -7
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -934,18 +934,18 @@ var SLOT_CONFIG_NETWORK = {
|
|
|
934
934
|
},
|
|
935
935
|
// Starting at Shelley era
|
|
936
936
|
preview: {
|
|
937
|
-
zeroTime:
|
|
937
|
+
zeroTime: 1666656e6,
|
|
938
938
|
zeroSlot: 0,
|
|
939
939
|
slotLength: 1e3,
|
|
940
|
-
startEpoch:
|
|
940
|
+
startEpoch: 0,
|
|
941
941
|
epochLength: 86400
|
|
942
942
|
},
|
|
943
943
|
// Starting at Shelley era
|
|
944
944
|
preprod: {
|
|
945
|
-
zeroTime:
|
|
945
|
+
zeroTime: 16540416e5 + 1728e6,
|
|
946
946
|
zeroSlot: 86400,
|
|
947
947
|
slotLength: 1e3,
|
|
948
|
-
startEpoch:
|
|
948
|
+
startEpoch: 4,
|
|
949
949
|
epochLength: 432e3
|
|
950
950
|
},
|
|
951
951
|
// Starting at Shelley era
|
|
@@ -981,10 +981,49 @@ var resolveEpochNo = (network, milliseconds = Date.now()) => {
|
|
|
981
981
|
};
|
|
982
982
|
|
|
983
983
|
// src/utils/asset-fingerprint.ts
|
|
984
|
-
var
|
|
985
|
-
var
|
|
984
|
+
var import_bech32 = require("bech32");
|
|
985
|
+
var import_blake2b = __toESM(require("blake2b"), 1);
|
|
986
986
|
var resolveFingerprint = (policyId2, assetName2) => {
|
|
987
|
-
return AssetFingerprint.
|
|
987
|
+
return AssetFingerprint.fromParts(
|
|
988
|
+
toBytes(policyId2),
|
|
989
|
+
toBytes(assetName2)
|
|
990
|
+
).fingerprint();
|
|
991
|
+
};
|
|
992
|
+
var DATA = "asset";
|
|
993
|
+
var AssetFingerprint = class _AssetFingerprint {
|
|
994
|
+
hashBuf;
|
|
995
|
+
constructor(hashBuf) {
|
|
996
|
+
this.hashBuf = hashBuf;
|
|
997
|
+
}
|
|
998
|
+
static fromHash(hash) {
|
|
999
|
+
return new _AssetFingerprint(hash);
|
|
1000
|
+
}
|
|
1001
|
+
static fromParts(policyId2, assetName2) {
|
|
1002
|
+
const hashBuf = (0, import_blake2b.default)(20).update(new Uint8Array([...policyId2, ...assetName2])).digest("binary");
|
|
1003
|
+
return _AssetFingerprint.fromHash(hashBuf);
|
|
1004
|
+
}
|
|
1005
|
+
static fromBech32(fingerprint) {
|
|
1006
|
+
const { prefix, words } = import_bech32.bech32.decode(fingerprint);
|
|
1007
|
+
if (prefix !== DATA) {
|
|
1008
|
+
throw new Error("Invalid asset fingerprint");
|
|
1009
|
+
}
|
|
1010
|
+
const hashBuf = Buffer.from(import_bech32.bech32.fromWords(words));
|
|
1011
|
+
return _AssetFingerprint.fromHash(hashBuf);
|
|
1012
|
+
}
|
|
1013
|
+
fingerprint() {
|
|
1014
|
+
const words = import_bech32.bech32.toWords(this.hashBuf);
|
|
1015
|
+
return import_bech32.bech32.encode(DATA, words);
|
|
1016
|
+
}
|
|
1017
|
+
hash() {
|
|
1018
|
+
return Buffer.from(this.hashBuf).toString("hex");
|
|
1019
|
+
}
|
|
1020
|
+
prefix() {
|
|
1021
|
+
return DATA;
|
|
1022
|
+
}
|
|
1023
|
+
// The last six characters of the data part form a checksum and contain no information
|
|
1024
|
+
checksum() {
|
|
1025
|
+
return this.fingerprint().slice(-6);
|
|
1026
|
+
}
|
|
988
1027
|
};
|
|
989
1028
|
|
|
990
1029
|
// src/utils/bigNum.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import CIP14 from '@emurgo/cip14-js';
|
|
2
1
|
export { generateMnemonic, mnemonicToEntropy } from 'bip39';
|
|
3
2
|
|
|
4
3
|
type AccountInfo = {
|
|
@@ -1408,8 +1407,18 @@ declare class MeshValue {
|
|
|
1408
1407
|
toJSON: () => Value;
|
|
1409
1408
|
}
|
|
1410
1409
|
|
|
1411
|
-
declare const
|
|
1412
|
-
declare
|
|
1410
|
+
declare const resolveFingerprint: (policyId: string, assetName: string) => string;
|
|
1411
|
+
declare class AssetFingerprint {
|
|
1412
|
+
readonly hashBuf: Uint8Array;
|
|
1413
|
+
private constructor();
|
|
1414
|
+
static fromHash(hash: Uint8Array): AssetFingerprint;
|
|
1415
|
+
static fromParts(policyId: Uint8Array, assetName: Uint8Array): AssetFingerprint;
|
|
1416
|
+
static fromBech32(fingerprint: string): AssetFingerprint;
|
|
1417
|
+
fingerprint(): string;
|
|
1418
|
+
hash(): string;
|
|
1419
|
+
prefix(): string;
|
|
1420
|
+
checksum(): string;
|
|
1421
|
+
}
|
|
1413
1422
|
|
|
1414
1423
|
declare class BigNum {
|
|
1415
1424
|
value: bigint;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import CIP14 from '@emurgo/cip14-js';
|
|
2
1
|
export { generateMnemonic, mnemonicToEntropy } from 'bip39';
|
|
3
2
|
|
|
4
3
|
type AccountInfo = {
|
|
@@ -1408,8 +1407,18 @@ declare class MeshValue {
|
|
|
1408
1407
|
toJSON: () => Value;
|
|
1409
1408
|
}
|
|
1410
1409
|
|
|
1411
|
-
declare const
|
|
1412
|
-
declare
|
|
1410
|
+
declare const resolveFingerprint: (policyId: string, assetName: string) => string;
|
|
1411
|
+
declare class AssetFingerprint {
|
|
1412
|
+
readonly hashBuf: Uint8Array;
|
|
1413
|
+
private constructor();
|
|
1414
|
+
static fromHash(hash: Uint8Array): AssetFingerprint;
|
|
1415
|
+
static fromParts(policyId: Uint8Array, assetName: Uint8Array): AssetFingerprint;
|
|
1416
|
+
static fromBech32(fingerprint: string): AssetFingerprint;
|
|
1417
|
+
fingerprint(): string;
|
|
1418
|
+
hash(): string;
|
|
1419
|
+
prefix(): string;
|
|
1420
|
+
checksum(): string;
|
|
1421
|
+
}
|
|
1413
1422
|
|
|
1414
1423
|
declare class BigNum {
|
|
1415
1424
|
value: bigint;
|
package/dist/index.js
CHANGED
|
@@ -805,18 +805,18 @@ var SLOT_CONFIG_NETWORK = {
|
|
|
805
805
|
},
|
|
806
806
|
// Starting at Shelley era
|
|
807
807
|
preview: {
|
|
808
|
-
zeroTime:
|
|
808
|
+
zeroTime: 1666656e6,
|
|
809
809
|
zeroSlot: 0,
|
|
810
810
|
slotLength: 1e3,
|
|
811
|
-
startEpoch:
|
|
811
|
+
startEpoch: 0,
|
|
812
812
|
epochLength: 86400
|
|
813
813
|
},
|
|
814
814
|
// Starting at Shelley era
|
|
815
815
|
preprod: {
|
|
816
|
-
zeroTime:
|
|
816
|
+
zeroTime: 16540416e5 + 1728e6,
|
|
817
817
|
zeroSlot: 86400,
|
|
818
818
|
slotLength: 1e3,
|
|
819
|
-
startEpoch:
|
|
819
|
+
startEpoch: 4,
|
|
820
820
|
epochLength: 432e3
|
|
821
821
|
},
|
|
822
822
|
// Starting at Shelley era
|
|
@@ -852,10 +852,49 @@ var resolveEpochNo = (network, milliseconds = Date.now()) => {
|
|
|
852
852
|
};
|
|
853
853
|
|
|
854
854
|
// src/utils/asset-fingerprint.ts
|
|
855
|
-
import
|
|
856
|
-
|
|
855
|
+
import { bech32 } from "bech32";
|
|
856
|
+
import blake2b from "blake2b";
|
|
857
857
|
var resolveFingerprint = (policyId2, assetName2) => {
|
|
858
|
-
return AssetFingerprint.
|
|
858
|
+
return AssetFingerprint.fromParts(
|
|
859
|
+
toBytes(policyId2),
|
|
860
|
+
toBytes(assetName2)
|
|
861
|
+
).fingerprint();
|
|
862
|
+
};
|
|
863
|
+
var DATA = "asset";
|
|
864
|
+
var AssetFingerprint = class _AssetFingerprint {
|
|
865
|
+
hashBuf;
|
|
866
|
+
constructor(hashBuf) {
|
|
867
|
+
this.hashBuf = hashBuf;
|
|
868
|
+
}
|
|
869
|
+
static fromHash(hash) {
|
|
870
|
+
return new _AssetFingerprint(hash);
|
|
871
|
+
}
|
|
872
|
+
static fromParts(policyId2, assetName2) {
|
|
873
|
+
const hashBuf = blake2b(20).update(new Uint8Array([...policyId2, ...assetName2])).digest("binary");
|
|
874
|
+
return _AssetFingerprint.fromHash(hashBuf);
|
|
875
|
+
}
|
|
876
|
+
static fromBech32(fingerprint) {
|
|
877
|
+
const { prefix, words } = bech32.decode(fingerprint);
|
|
878
|
+
if (prefix !== DATA) {
|
|
879
|
+
throw new Error("Invalid asset fingerprint");
|
|
880
|
+
}
|
|
881
|
+
const hashBuf = Buffer.from(bech32.fromWords(words));
|
|
882
|
+
return _AssetFingerprint.fromHash(hashBuf);
|
|
883
|
+
}
|
|
884
|
+
fingerprint() {
|
|
885
|
+
const words = bech32.toWords(this.hashBuf);
|
|
886
|
+
return bech32.encode(DATA, words);
|
|
887
|
+
}
|
|
888
|
+
hash() {
|
|
889
|
+
return Buffer.from(this.hashBuf).toString("hex");
|
|
890
|
+
}
|
|
891
|
+
prefix() {
|
|
892
|
+
return DATA;
|
|
893
|
+
}
|
|
894
|
+
// The last six characters of the data part form a checksum and contain no information
|
|
895
|
+
checksum() {
|
|
896
|
+
return this.fingerprint().slice(-6);
|
|
897
|
+
}
|
|
859
898
|
};
|
|
860
899
|
|
|
861
900
|
// src/utils/bigNum.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/common",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -27,11 +27,13 @@
|
|
|
27
27
|
"test": "jest"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
"bip39": "3.1.0"
|
|
30
|
+
"bech32": "^2.0.0",
|
|
31
|
+
"bip39": "3.1.0",
|
|
32
|
+
"blake2b": "^2.1.4"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@meshsdk/configs": "*",
|
|
36
|
+
"@types/blake2b": "^2.1.3",
|
|
35
37
|
"eslint": "^8.57.0",
|
|
36
38
|
"tsup": "^8.0.2",
|
|
37
39
|
"typescript": "^5.3.3"
|
|
@@ -48,4 +50,4 @@
|
|
|
48
50
|
"blockchain",
|
|
49
51
|
"sdk"
|
|
50
52
|
]
|
|
51
|
-
}
|
|
53
|
+
}
|