Skip to content

Commit

Permalink
refactor; enable intellisense for rust via rs_lib
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Feb 7, 2025
1 parent 57bef49 commit 353c855
Show file tree
Hide file tree
Showing 62 changed files with 52 additions and 40 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img width="100px" src="./logo/lucid.svg" align="center"/>
<img width="100px" src="./assets/lucid.svg" align="center"/>
<h1 align="center">Lucid</h1>
<p align="center">Lucid is a library designed to simplify creating Cardano transactions and writing off-chain code for Plutus contracts.</p>

Expand Down
File renamed without changes
File renamed without changes
64 changes: 38 additions & 26 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import * as dnt from "jsr:@deno/dnt";
await dnt.emptyDir("./dist");

try {
moveSync("./src/core/core.backup.ts", "./src/core/core.ts", {
moveSync("./lib/core/core.backup.ts", "./lib/core/core.ts", {
overwrite: true,
});
} catch (_) {}
copySync("./src/core/core.ts", "./src/core/core.backup.ts");
const coreFile = await Deno.readTextFile("./src/core/core.ts");
copySync("./lib/core/core.ts", "./lib/core/core.backup.ts");
const coreFile = await Deno.readTextFile("./lib/core/core.ts");
Deno.writeTextFileSync(
"./src/core/core.ts",
"./lib/core/core.ts",
coreFile.replace(
`import * as Core from "./libs/lucid_core/pkg/lucid_core.js";`,
`import * as Core from "../../rs_lib/pkg/lucid_core.js";`,
"const Core = {};",
).replace(
`import * as MessageSigningInstance from "./libs/message_signing/pkg/message_signing.js";`,
`import * as MessageSigningInstance from "../../rs_lib/message_signing/pkg/message_signing.js";`,
"const MessageSigningInstance = {};",
),
);
Expand Down Expand Up @@ -47,38 +47,50 @@ try {
},
postBuild: async () => {
const coreFileEsm = await Deno.readTextFile(
"./dist/esm/src/core/core.js",
"./dist/esm/lib/core/core.js",
);
Deno.writeTextFileSync(
"./dist/esm/src/core/core.js",
coreFileEsm.replace(
"const Core = {};",
`import * as Core from "./libs/lucid_core/pkg/lucid_core.js";`,
).replace(
"const MessageSigningInstance = {};",
`import * as MessageSigningInstance from "./libs/message_signing/pkg/message_signing.js";`,
),
"./dist/esm/lib/core/core.js",
coreFileEsm
.replace(
"const Core = {};",
`import * as Core from "./libs/lucid_core/pkg/lucid_core.js";`,
)
.replace(
"const MessageSigningInstance = {};",
`import * as MessageSigningInstance from "./libs/message_signing/pkg/message_signing.js";`,
),
);

const coreTypesFileEsm = await Deno.readTextFile(
"./dist/esm/lib/core/core.d.ts",
);
Deno.writeTextFileSync(
"./dist/esm/lib/core/core.d.ts",
coreTypesFileEsm
.replaceAll(
"../../rs_lib/pkg/lucid_core",
"./libs/lucid_core/pkg/lucid_core",
)
.replace(
"../../rs_lib/message_signing/pkg/message_signing",
"./libs/message_signing/pkg/message_signing",
),
);

copySync(
"./src/core/libs/message_signing/pkg/",
"./dist/esm/src/core/libs/message_signing/pkg",
{
overwrite: true,
},
"./rs_lib/message_signing/pkg/",
"./dist/esm/lib/core/libs/message_signing/pkg",
);
copySync(
"./src/core/libs/lucid_core/pkg/",
"./dist/esm/src/core/libs/lucid_core/pkg",
{
overwrite: true,
},
"./rs_lib/pkg/",
"./dist/esm/lib/core/libs/lucid_core/pkg",
);
},
});
} catch (e) {
console.log(e);
}
moveSync("./src/core/core.backup.ts", "./src/core/core.ts", {
moveSync("./lib/core/core.backup.ts", "./lib/core/core.ts", {
overwrite: true,
});
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"tasks": {
"build": "deno run -A build.ts",
"build:core": "cd src/core/libs/lucid_core && wasm-pack build . --no-pack --weak-refs --release && rm ./pkg/.gitignore; cd ../message_signing && wasm-pack build . --no-pack --weak-refs --release && rm ./pkg/.gitignore",
"build:core": "cd ./rs_lib && wasm-pack build . --no-pack --weak-refs --release && rm ./pkg/.gitignore; cd ./message_signing && wasm-pack build . --no-pack --weak-refs --release && rm ./pkg/.gitignore",
"publish": "deno task build && deno task test && npm publish dist",
"test": "deno test --allow-env --allow-read --allow-net tests",
"test:core": "cd src/core/libs/lucid_core && cargo test; cd ../message_signing && RUSTFLAGS=-Awarnings cargo test"
"test:core": "cd ./rs_lib && cargo test; cd ./message_signing && RUSTFLAGS=-Awarnings cargo test"
},
"lint": {
"include": ["src/", "tests/", "blueprint.ts"],
Expand Down
10 changes: 5 additions & 5 deletions src/core/core.ts → lib/core/core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Core from "./libs/lucid_core/pkg/lucid_core.js";
import type * as CoreTypes from "./libs/lucid_core/pkg/lucid_core.d.ts";
import * as MessageSigningInstance from "./libs/message_signing/pkg/message_signing.js";
import type * as MessageSigningTypes from "./libs/message_signing/pkg/message_signing.d.ts";
import * as Core from "../../rs_lib/pkg/lucid_core.js";
import type * as CoreTypes from "../../rs_lib/pkg/lucid_core.d.ts";
import * as MessageSigningInstance from "../../rs_lib/message_signing/pkg/message_signing.js";
import type * as MessageSigningTypes from "../../rs_lib/message_signing/pkg/message_signing.d.ts";

export type Addresses = CoreTypes.Addresses;
export const Addresses: typeof CoreTypes.Addresses = Core.Addresses;
Expand Down Expand Up @@ -33,4 +33,4 @@ export type MessageSigning = typeof MessageSigningTypes;
export const MessageSigning: typeof MessageSigningTypes =
MessageSigningInstance;

export type * from "./libs/lucid_core/pkg/lucid_core.d.ts";
export type * from "../../rs_lib/pkg/lucid_core.d.ts";
File renamed without changes.
2 changes: 1 addition & 1 deletion src/core/types.ts → lib/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
RelevantProtocolParameters,
Script,
Utxo,
} from "./libs/lucid_core/pkg/lucid_core.d.ts";
} from "../../rs_lib/pkg/lucid_core.d.ts";

type OmitInstruction<T extends Instruction, K extends T["type"]> = T extends
{ type: K } ? never : T;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./src/mod.ts";
export * from "./lib/mod.ts";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ export const labels_new: () => number;
export const cosesignatures_new: () => number;
export const __wbg_countersignature_free: (a: number, b: number) => void;
export const countersignature_signatures: (a: number) => number;
export const __wbg_coserecipient_free: (a: number, b: number) => void;
export const __wbg_passwordencryption_free: (a: number, b: number) => void;
export const __wbg_pubkeyencryption_free: (a: number, b: number) => void;
export const __wbg_cosesignbuilder_free: (a: number, b: number) => void;
export const __wbg_pubkeyencryption_free: (a: number, b: number) => void;
export const __wbg_coserecipient_free: (a: number, b: number) => void;
export const cosesignbuilder_set_external_aad: (a: number, b: number, c: number) => void;
export const cosesignbuilder_hash_payload: (a: number) => void;
export const coserecipient_ciphertext: (a: number, b: number) => void;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ export const utils_applyParamsToScript: (a: number, b: number, c: number, d: num
export const utils_encodeBech32: (a: number, b: number, c: number, d: number) => [number, number, number, number];
export const utils_applySingleCborEncoding: (a: number, b: number) => [number, number, number, number];
export const utils_applyDoubleCborEncoding: (a: number, b: number) => [number, number, number, number];
export const __wbg_codec_free: (a: number, b: number) => void;
export const __wbg_hasher_free: (a: number, b: number) => void;
export const __wbg_crypto_free: (a: number, b: number) => void;
export const __wbg_utils_free: (a: number, b: number) => void;
export const __wbg_hasher_free: (a: number, b: number) => void;
export const __wbg_codec_free: (a: number, b: number) => void;
export const __wbindgen_malloc: (a: number, b: number) => number;
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
export const __wbindgen_exn_store: (a: number) => void;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 353c855

Please sign in to comment.