Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature update/bump csl #490

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,809 changes: 905 additions & 904 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/mesh-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/common",
"version": "1.8.14",
"version": "1.8.15",
"description": "Contains constants, types and interfaces used across the SDK and different serialization libraries",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/contract",
"version": "1.8.14",
"version": "1.8.15",
"description": "List of open-source smart contracts, complete with documentation, live demos, and end-to-end source code. https://meshjs.dev/smart-contracts",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -34,9 +34,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.8.14",
"@meshsdk/core": "1.8.14",
"@meshsdk/core-csl": "1.8.14"
"@meshsdk/common": "1.8.15",
"@meshsdk/core": "1.8.15",
"@meshsdk/core-csl": "1.8.15"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
10 changes: 5 additions & 5 deletions packages/mesh-core-csl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-csl",
"version": "1.8.14",
"version": "1.8.15",
"description": "Types and utilities functions between Mesh and cardano-serialization-lib",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down Expand Up @@ -31,17 +31,17 @@
},
"devDependencies": {
"@meshsdk/configs": "*",
"@meshsdk/provider": "1.8.14",
"@meshsdk/provider": "1.8.15",
"@types/json-bigint": "^1.0.4",
"eslint": "^8.57.0",
"ts-jest": "^29.1.4",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.8.14",
"@sidan-lab/sidan-csl-rs-browser": "0.9.16",
"@sidan-lab/sidan-csl-rs-nodejs": "0.9.16",
"@meshsdk/common": "1.8.15",
"@sidan-lab/sidan-csl-rs-browser": "0.9.18",
"@sidan-lab/sidan-csl-rs-nodejs": "0.9.18",
"@types/base32-encoding": "^1.0.2",
"base32-encoding": "^1.0.0",
"bech32": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-core-csl/src/deser/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const resolveNativeScriptHash = (script: NativeScript) => {
export const resolveScriptHashDRepId = (scriptHash: string) => {
return csl.DRep.new_script_hash(
csl.ScriptHash.from_hex(scriptHash),
).to_bech32();
).to_bech32(true);
};

export const resolveRewardAddress = (bech32: string) => {
Expand Down
59 changes: 4 additions & 55 deletions packages/mesh-core-csl/src/utils/drep.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import base32 from "base32-encoding";
import { bech32 } from "bech32";

import { csl } from "../deser";

export const getDRepIds = (
Expand All @@ -9,59 +6,11 @@ export const getDRepIds = (
cip105: string;
cip129: string;
} => {
const cslDrep = csl.DRep.from_bech32(dRepId);
let result = {
cip105: "",
cip129: "",
cip105: cslDrep.to_bech32(false),
cip129: cslDrep.to_bech32(true),
};
if (dRepId.length === 58) {
result.cip129 = dRepId;
const { prefix, words } = bech32.decode(dRepId);
if (prefix !== "drep") {
throw new Error("Malformed CIP129 DRepId");
}
const bytes = base32.decode(new Uint8Array(words));
if (bytes[0] === 0x22) {
result.cip105 = csl.DRep.new_key_hash(
csl.Ed25519KeyHash.from_hex(bytes.subarray(1).toString("hex")),
).to_bech32();
} else if (bytes[0] === 0x23) {
result.cip105 = csl.DRep.new_script_hash(
csl.ScriptHash.from_hex(bytes.subarray(1).toString("hex")),
).to_bech32();
} else {
throw new Error("Malformed CIP129 DRepId");
}
} else {
result.cip105 = dRepId;
try {
const cslDRep = csl.DRep.from_bech32(dRepId);
if (cslDRep.kind() === csl.DRepKind.KeyHash) {
let rawBytes = cslDRep.to_key_hash()?.to_bytes();
if (!rawBytes) {
throw new Error("Malformed key hash in DRepId");
}
let rawBytesWithPrefix = new Uint8Array(rawBytes.length + 1);
rawBytesWithPrefix.set([0x22]);
rawBytesWithPrefix.set(rawBytes, 1);
let base32RawBytes = base32.encode(rawBytesWithPrefix);
result.cip129 = bech32.encode("drep", base32RawBytes);
} else if (cslDRep.kind() === csl.DRepKind.ScriptHash) {
let rawBytes = cslDRep.to_script_hash()?.to_bytes();
if (!rawBytes) {
throw new Error("Malformed script hash in DRepId");
}
let rawBytesWithPrefix = new Uint8Array(rawBytes.length + 1);
rawBytesWithPrefix.set([0x23]);
rawBytesWithPrefix.set(rawBytes, 1);
let base32RawBytes = base32.encode(rawBytesWithPrefix);
result.cip129 = bech32.encode("drep", base32RawBytes);
} else {
throw new Error("Can only calculate DRepIds for script/key DReps");
}
} catch (e) {
console.error(e);
throw new Error("Malformed DRepId");
}
}

return result;
};
4 changes: 2 additions & 2 deletions packages/mesh-core-csl/test/utils/drep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("DRep", () => {
expect(
getDRepIds("drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud"),
).toEqual({
cip105: "drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud",
cip105: "drep_vkh100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djkq8f4h",
cip129: "drep1yfaaqfzaukju6pr5wa4nhzqglv57p46cjlws424m6hhj3kg2k9vj7",
});
});
Expand All @@ -34,7 +34,7 @@ describe("DRep", () => {
expect(
getDRepIds("drep1yfaaqfzaukju6pr5wa4nhzqglv57p46cjlws424m6hhj3kg2k9vj7"),
).toEqual({
cip105: "drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud",
cip105: "drep_vkh100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djkq8f4h",
cip129: "drep1yfaaqfzaukju6pr5wa4nhzqglv57p46cjlws424m6hhj3kg2k9vj7",
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/mesh-core-cst/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-cst",
"version": "1.8.14",
"version": "1.8.15",
"description": "Types and utilities functions between Mesh and cardano-js-sdk",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -45,7 +45,7 @@
"@harmoniclabs/crypto": "0.2.4",
"@harmoniclabs/pair": "1.0.0",
"@harmoniclabs/bytestring": "1.0.0",
"@meshsdk/common": "1.8.14",
"@meshsdk/common": "1.8.15",
"@stricahq/bip32ed25519": "^1.1.0",
"@stricahq/cbors": "^1.0.3",
"pbkdf2": "^3.1.2"
Expand Down
16 changes: 8 additions & 8 deletions packages/mesh-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core",
"version": "1.8.14",
"version": "1.8.15",
"description": "Mesh SDK Core - https://meshjs.dev/",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -33,13 +33,13 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.8.14",
"@meshsdk/core-csl": "1.8.14",
"@meshsdk/core-cst": "1.8.14",
"@meshsdk/provider": "1.8.14",
"@meshsdk/react": "1.8.14",
"@meshsdk/transaction": "1.8.14",
"@meshsdk/wallet": "1.8.14"
"@meshsdk/common": "1.8.15",
"@meshsdk/core-csl": "1.8.15",
"@meshsdk/core-cst": "1.8.15",
"@meshsdk/provider": "1.8.15",
"@meshsdk/react": "1.8.15",
"@meshsdk/transaction": "1.8.15",
"@meshsdk/wallet": "1.8.15"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions packages/mesh-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/provider",
"version": "1.8.14",
"version": "1.8.15",
"description": "Blockchain data providers - https://meshjs.dev/providers",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,8 +35,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.8.14",
"@meshsdk/core-cst": "1.8.14",
"@meshsdk/common": "1.8.15",
"@meshsdk/core-cst": "1.8.15",
"@utxorpc/sdk": "0.6.2",
"@utxorpc/spec": "0.10.1",
"axios": "^1.7.2"
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/react",
"version": "1.8.14",
"version": "1.8.15",
"description": "React component library - https://meshjs.dev/react",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -30,9 +30,9 @@
},
"dependencies": {
"@fabianbormann/cardano-peer-connect": "^1.2.18",
"@meshsdk/common": "1.8.14",
"@meshsdk/transaction": "1.8.14",
"@meshsdk/wallet": "1.8.14",
"@meshsdk/common": "1.8.15",
"@meshsdk/transaction": "1.8.15",
"@meshsdk/wallet": "1.8.15",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-icons": "^1.3.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/mesh-svelte/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/svelte",
"version": "1.8.14",
"version": "1.8.15",
"description": "Svelte component library - https://meshjs.dev/svelte",
"type": "module",
"exports": {
Expand All @@ -26,7 +26,7 @@
"dev": "vite dev"
},
"dependencies": {
"@meshsdk/core": "1.8.14",
"@meshsdk/core": "1.8.15",
"bits-ui": "1.0.0-next.65"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-transaction/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/transaction",
"version": "1.8.14",
"version": "1.8.15",
"description": "Transactions - https://meshjs.dev/apis/transaction",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,9 +35,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.8.14",
"@meshsdk/core-csl": "1.8.14",
"@meshsdk/core-cst": "1.8.14",
"@meshsdk/common": "1.8.15",
"@meshsdk/core-csl": "1.8.15",
"@meshsdk/core-cst": "1.8.15",
"json-bigint": "^1.0.0"
},
"prettier": "@meshsdk/configs/prettier",
Expand Down
10 changes: 5 additions & 5 deletions packages/mesh-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/wallet",
"version": "1.8.14",
"version": "1.8.15",
"description": "Wallets - https://meshjs.dev/apis/wallets",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,10 +35,10 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.8.14",
"@meshsdk/core-csl": "1.8.14",
"@meshsdk/core-cst": "1.8.14",
"@meshsdk/transaction": "1.8.14",
"@meshsdk/common": "1.8.15",
"@meshsdk/core-csl": "1.8.15",
"@meshsdk/core-cst": "1.8.15",
"@meshsdk/transaction": "1.8.15",
"@simplewebauthn/browser": "^13.0.0"
},
"prettier": "@meshsdk/configs/prettier",
Expand Down
2 changes: 1 addition & 1 deletion scripts/mesh-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.",
"homepage": "https://meshjs.dev",
"author": "MeshJS",
"version": "1.8.14",
"version": "1.8.15",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/index.cjs",
Expand Down