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

bump csl #491

Merged
merged 2 commits into from
Jan 31, 2025
Merged
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
463 changes: 225 additions & 238 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.9.0-beta.0",
"version": "1.9.0-beta.1",
"description": "Contains constants, types and interfaces used across the SDK and different serialization libraries",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down
6 changes: 3 additions & 3 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.9.0-beta.0",
"version": "1.9.0-beta.1",
"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,8 +34,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.0",
"@meshsdk/core": "1.9.0-beta.0"
"@meshsdk/common": "1.9.0-beta.1",
"@meshsdk/core": "1.9.0-beta.1"
},
"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.9.0-beta.0",
"version": "1.9.0-beta.1",
"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.9.0-beta.0",
"@meshsdk/provider": "1.9.0-beta.1",
"@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.9.0-beta.0",
"@sidan-lab/sidan-csl-rs-browser": "0.9.16",
"@sidan-lab/sidan-csl-rs-nodejs": "0.9.16",
"@meshsdk/common": "1.9.0-beta.1",
"@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
56 changes: 3 additions & 53 deletions packages/mesh-core-csl/src/utils/drep.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import base32 from "base32-encoding";
import { bech32 } from "bech32";

import { csl } from "../deser";
Expand All @@ -9,59 +8,10 @@ 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;
};
10 changes: 6 additions & 4 deletions packages/mesh-core-csl/test/utils/drep.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDRepIds } from "@meshsdk/core-cst";
import { getDRepIds } from "@meshsdk/core-csl";

describe("DRep", () => {
test("Get DRepIds of a CIP105 script", () => {
Expand All @@ -23,9 +23,11 @@ describe("DRep", () => {

test("Get DRepIds of a CIP105 key hash", () => {
expect(
getDRepIds("drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud"),
getDRepIds(
"drep_vkh100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djkq8f4h",
),
).toEqual({
cip105: "drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud",
cip105: "drep_vkh100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djkq8f4h",
cip129: "drep1yfaaqfzaukju6pr5wa4nhzqglv57p46cjlws424m6hhj3kg2k9vj7",
});
});
Expand All @@ -34,7 +36,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.9.0-beta.0",
"version": "1.9.0-beta.1",
"description": "Types and utilities functions between Mesh and cardano-js-sdk",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -46,7 +46,7 @@
"@harmoniclabs/crypto": "0.2.4",
"@harmoniclabs/pair": "1.0.0",
"@harmoniclabs/bytestring": "1.0.0",
"@meshsdk/common": "1.9.0-beta.0",
"@meshsdk/common": "1.9.0-beta.1",
"@stricahq/bip32ed25519": "^1.1.0",
"@stricahq/cbors": "^1.0.0",
"@types/base32-encoding": "^1.0.2",
Expand Down
41 changes: 41 additions & 0 deletions packages/mesh-core-cst/test/utils/drep.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { getDRepIds } from "@meshsdk/core-cst";

describe("DRep", () => {
test("Get DRepIds of a CIP105 script", () => {
expect(
getDRepIds(
"drep_script190xv8v32n43luhu9ag05s5mvcs6079lg4zghzyg3j9vlgle68y3",
),
).toEqual({
cip105: "drep_script190xv8v32n43luhu9ag05s5mvcs6079lg4zghzyg3j9vlgle68y3",
cip129: "drep1yv4uesaj92wk8ljlsh4p7jzndnzrflchaz5fzug3zxg4naqkpeas3",
});
});

test("Get DRepIds of a CIP129 script", () => {
expect(
getDRepIds("drep1yv4uesaj92wk8ljlsh4p7jzndnzrflchaz5fzug3zxg4naqkpeas3"),
).toEqual({
cip105: "drep_script190xv8v32n43luhu9ag05s5mvcs6079lg4zghzyg3j9vlgle68y3",
cip129: "drep1yv4uesaj92wk8ljlsh4p7jzndnzrflchaz5fzug3zxg4naqkpeas3",
});
});

test("Get DRepIds of a CIP105 key hash", () => {
expect(
getDRepIds("drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud"),
).toEqual({
cip105: "drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud",
cip129: "drep1yfaaqfzaukju6pr5wa4nhzqglv57p46cjlws424m6hhj3kg2k9vj7",
});
});

test("Get DRepIds of a CIP129 key hash", () => {
expect(
getDRepIds("drep1yfaaqfzaukju6pr5wa4nhzqglv57p46cjlws424m6hhj3kg2k9vj7"),
).toEqual({
cip105: "drep100gzgh095hxsgarhdvacsz8m98sdwkyhm5924w74au5djs8u5ud",
cip129: "drep1yfaaqfzaukju6pr5wa4nhzqglv57p46cjlws424m6hhj3kg2k9vj7",
});
});
});
14 changes: 7 additions & 7 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.9.0-beta.0",
"version": "1.9.0-beta.1",
"description": "Mesh SDK Core - https://meshjs.dev/",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -33,12 +33,12 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.0",
"@meshsdk/core-cst": "1.9.0-beta.0",
"@meshsdk/provider": "1.9.0-beta.0",
"@meshsdk/react": "1.9.0-beta.0",
"@meshsdk/transaction": "1.9.0-beta.0",
"@meshsdk/wallet": "1.9.0-beta.0"
"@meshsdk/common": "1.9.0-beta.1",
"@meshsdk/core-cst": "1.9.0-beta.1",
"@meshsdk/provider": "1.9.0-beta.1",
"@meshsdk/react": "1.9.0-beta.1",
"@meshsdk/transaction": "1.9.0-beta.1",
"@meshsdk/wallet": "1.9.0-beta.1"
},
"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.9.0-beta.0",
"version": "1.9.0-beta.1",
"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.9.0-beta.0",
"@meshsdk/core-cst": "1.9.0-beta.0",
"@meshsdk/common": "1.9.0-beta.1",
"@meshsdk/core-cst": "1.9.0-beta.1",
"@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.9.0-beta.0",
"version": "1.9.0-beta.1",
"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.9.0-beta.0",
"@meshsdk/transaction": "1.9.0-beta.0",
"@meshsdk/wallet": "1.9.0-beta.0",
"@meshsdk/common": "1.9.0-beta.1",
"@meshsdk/transaction": "1.9.0-beta.1",
"@meshsdk/wallet": "1.9.0-beta.1",
"@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.9.0-beta.0",
"version": "1.9.0-beta.1",
"description": "Svelte component library - https://meshjs.dev/svelte",
"type": "module",
"exports": {
Expand All @@ -26,7 +26,7 @@
"dev": "vite dev"
},
"dependencies": {
"@meshsdk/core": "1.9.0-beta.0",
"@meshsdk/core": "1.9.0-beta.1",
"bits-ui": "1.0.0-next.65"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 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.9.0-beta.0",
"version": "1.9.0-beta.1",
"description": "Transactions - https://meshjs.dev/apis/transaction",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,8 +35,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.0",
"@meshsdk/core-cst": "1.9.0-beta.0",
"@meshsdk/common": "1.9.0-beta.1",
"@meshsdk/core-cst": "1.9.0-beta.1",
"json-bigint": "^1.0.0"
},
"prettier": "@meshsdk/configs/prettier",
Expand Down
8 changes: 4 additions & 4 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.9.0-beta.0",
"version": "1.9.0-beta.1",
"description": "Wallets - https://meshjs.dev/apis/wallets",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,9 +35,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.9.0-beta.0",
"@meshsdk/core-cst": "1.9.0-beta.0",
"@meshsdk/transaction": "1.9.0-beta.0",
"@meshsdk/common": "1.9.0-beta.1",
"@meshsdk/core-cst": "1.9.0-beta.1",
"@meshsdk/transaction": "1.9.0-beta.1",
"@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.9.0-beta.0",
"version": "1.9.0-beta.1",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/index.cjs",
Expand Down