Skip to content
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
10 changes: 10 additions & 0 deletions packages/mesh-core-csl/src/core/adaptor/toObj/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const certificateToObj = (certificate: Certificate): object => {
basicCertificate: baseCertToObj(baseCert),
};
case "ScriptCertificate":
if (baseCert.type === "RegisterStake") {
return {
basicCertificate: baseCertToObj(baseCert),
};
}
return {
scriptCertificate: {
cert: baseCertToObj(baseCert),
Expand All @@ -29,6 +34,11 @@ export const certificateToObj = (certificate: Certificate): object => {
},
};
case "SimpleScriptCertificate":
if (baseCert.type === "RegisterStake") {
return {
basicCertificate: baseCertToObj(baseCert),
};
}
return {
simpleScriptCertificate: {
cert: baseCertToObj(baseCert),
Expand Down
39 changes: 39 additions & 0 deletions run-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { CSLSerializer } from "./packages/mesh-core-csl/src/core/serializer";
import { MeshTxBuilderBody, emptyTxBuilderBody, Certificate, DEFAULT_PROTOCOL_PARAMETERS } from "./packages/mesh-common/src/index";

async function runTests() {
const body: MeshTxBuilderBody = emptyTxBuilderBody();
body.changeAddress = "addr_test1qr3a9rrclgf9rx90lmll2qnfzfwgrw35ukvgjrk36pmlzu0jemqwylc286744g0tnqkrvu0dkl8r48k0upkfmg7mncpqf0672w";

const cert: Certificate = {
type: "ScriptCertificate",
certType: {
type: "RegisterStake",
stakeKeyAddress: "stake_test17ryje2rawy9d7m2fwn4nrxgch8st3anccre32g885gu232snvhvu7",
},
redeemer: {
data: { type: "Mesh", content: [] },
exUnits: { mem: 1000000, steps: 1000000 }
},
scriptSource: {
type: "Inline",
txHash: "2cb57168ee66b68bd04a0d595060b546edf30c04ae1031b883c9ac797967dd85",
txIndex: 0,
scriptHash: "e3d28c78fa125198affefff50269125c81ba34e598890ed1d077f171",
scriptSize: "1234"
}
};
body.certificates.push(cert);

const cslSerializer = new CSLSerializer(DEFAULT_PROTOCOL_PARAMETERS as any);
let builtTxHex = "";
try {
builtTxHex = cslSerializer.serializeTxBody(body);
console.log("SUCCESS! CSL serializeTxBody successfully compiled.");
console.log("Tx Hex Output:", builtTxHex);
} catch (e: any) {
console.log("FAILED! CSL serializeTxBody threw:", e.message);
}
}

runTests();
Loading