Skip to content

Commit 3bcf5cc

Browse files
Merge pull request #116 from IntersectMBO/feat/aiken-uplc-plugin
feat/aiken uplc plugin
2 parents 5fa81cb + 59b6187 commit 3bcf5cc

34 files changed

+2322
-316
lines changed

.changeset/cruel-wasps-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@evolution-sdk/aiken-uplc": patch
3+
---
4+
5+
Initial release of Aiken UPLC evaluator - a WASM-based plugin for local script evaluation in the Evolution SDK

docs/content/docs/modules/sdk/builders/TransactionBuilder.mdx

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ double-spending. UTxOs can come from any source (wallet, DeFi protocols, other p
5555
- [formatFailures (method)](#formatfailures-method)
5656
- [ScriptFailure (interface)](#scriptfailure-interface)
5757
- [TransactionBuilderError (class)](#transactionbuildererror-class)
58-
- [evaluators](#evaluators)
59-
- [createUPLCEvaluator](#createuplcevaluator)
6058
- [model](#model)
6159
- [ChainResult (interface)](#chainresult-interface)
6260
- [EvaluationContext (interface)](#evaluationcontext-interface)
@@ -67,7 +65,6 @@ double-spending. UTxOs can come from any source (wallet, DeFi protocols, other p
6765
- [TxBuilderState (interface)](#txbuilderstate-interface)
6866
- [types](#types)
6967
- [ProgramStep (type alias)](#programstep-type-alias)
70-
- [UPLCEvalFunction (type alias)](#uplcevalfunction-type-alias)
7168
- [utils](#utils)
7269
- [BuildOptions (interface)](#buildoptions-interface)
7370
- [PhaseContextTag (class)](#phasecontexttag-class)
@@ -1129,23 +1126,6 @@ export declare class TransactionBuilderError
11291126

11301127
Added in v2.0.0
11311128

1132-
# evaluators
1133-
1134-
## createUPLCEvaluator
1135-
1136-
Creates an evaluator from a standard UPLC evaluation function.
1137-
1138-
**NOTE: NOT YET IMPLEMENTED** - This function currently returns an evaluator
1139-
that produces dummy data. Reserved for future UPLC script evaluation support.
1140-
1141-
**Signature**
1142-
1143-
```ts
1144-
export declare const createUPLCEvaluator: (_evalFunction: UPLCEvalFunction) => Evaluator
1145-
```
1146-
1147-
Added in v2.0.0
1148-
11491129
# model
11501130

11511131
## ChainResult (interface)
@@ -1218,7 +1198,7 @@ export interface Evaluator {
12181198
* @category methods
12191199
*/
12201200
evaluate: (
1221-
tx: string,
1201+
tx: Transaction.Transaction,
12221202
additionalUtxos: ReadonlyArray<CoreUTxO.UTxO> | undefined,
12231203
context: EvaluationContext
12241204
) => Effect.Effect<ReadonlyArray<EvalRedeemer>, EvaluationError>
@@ -1351,30 +1331,6 @@ export type ProgramStep = Effect.Effect<void, TransactionBuilderError, TxContext
13511331

13521332
Added in v2.0.0
13531333

1354-
## UPLCEvalFunction (type alias)
1355-
1356-
Standard UPLC evaluation function signature (matches UPLC.eval_phase_two_raw).
1357-
1358-
**NOTE: NOT YET IMPLEMENTED** - Reserved for future UPLC evaluation support.
1359-
1360-
**Signature**
1361-
1362-
```ts
1363-
export type UPLCEvalFunction = (
1364-
tx_bytes: Uint8Array,
1365-
utxos_bytes_x: Array<Uint8Array>,
1366-
utxos_bytes_y: Array<Uint8Array>,
1367-
cost_mdls_bytes: Uint8Array,
1368-
initial_budget_n: bigint,
1369-
initial_budget_d: bigint,
1370-
slot_config_x: bigint,
1371-
slot_config_y: bigint,
1372-
slot_config_z: number
1373-
) => Array<Uint8Array>
1374-
```
1375-
1376-
Added in v2.0.0
1377-
13781334
# utils
13791335

13801336
## BuildOptions (interface)

packages/aiken-uplc/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rust/target

packages/aiken-uplc/flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/aiken-uplc/flake.nix

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
description = "A Nix-flake-based Rust development environment";
3+
4+
nixConfig = {
5+
bash-prompt = "\\[\\e[0;92m\\][\\[\\e[0;92m\\]nix develop:\\[\\e[0;92m\\]\\w\\[\\e[0;92m\\]]\\[\\e[0;92m\\]$ \\[\\e[0m\\]";
6+
};
7+
8+
inputs = {
9+
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
10+
11+
12+
rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix
13+
};
14+
15+
outputs = { self, nixpkgs, rust-overlay }:
16+
let
17+
overlays = [
18+
rust-overlay.overlays.default
19+
(final: prev: {
20+
rustToolchain =
21+
let
22+
rust = prev.rust-bin;
23+
in
24+
if builtins.pathExists ./rust-toolchain.toml then
25+
rust.fromRustupToolchainFile ./rust-toolchain.toml
26+
else if builtins.pathExists ./rust-toolchain then
27+
rust.fromRustupToolchainFile ./rust-toolchain
28+
else
29+
rust.stable.latest.default;
30+
})
31+
];
32+
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
33+
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
34+
pkgs = import nixpkgs { inherit overlays system; };
35+
});
36+
in
37+
{
38+
devShells = forEachSupportedSystem ({ pkgs }:
39+
let
40+
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
41+
extensions = [ "rust-src" ];
42+
targets = [ "wasm32-unknown-unknown" ];
43+
};
44+
in
45+
{
46+
default = pkgs.mkShell {
47+
buildInputs = with pkgs; [
48+
rustToolchain
49+
openssl
50+
pkg-config
51+
cargo-deny
52+
cargo-edit
53+
cargo-watch
54+
rust-analyzer
55+
wasm-pack
56+
bun
57+
nodejs
58+
pnpm
59+
# C/C++ Libraries
60+
clang-tools
61+
cmake
62+
codespell
63+
conan
64+
cppcheck
65+
doxygen
66+
gtest
67+
lcov
68+
vcpkg
69+
vcpkg-tool
70+
]
71+
++ (if system == "aarch64-darwin" then [ ] else [ gdb ]);
72+
shellHook = ''
73+
export LIBCLANG_PATH=${pkgs.libclang.lib}/lib/
74+
export LD_LIBRARY_PATH=${pkgs.openssl}/lib:$LD_LIBRARY_PATH
75+
export CC_wasm32_unknown_unknown=${pkgs.llvmPackages.clang-unwrapped}/bin/clang
76+
export CFLAGS_wasm32_unknown_unknown="-I ${pkgs.llvmPackages.libclang.lib}/lib/clang/include/"
77+
'';
78+
};
79+
});
80+
};
81+
}

packages/aiken-uplc/package.json

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"name": "@evolution-sdk/aiken-uplc",
3+
"version": "0.0.0",
4+
"description": "Aiken UPLC evaluator for Evolution SDK with WASM-based local script evaluation",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"module": "./dist/index.js",
8+
"types": "./dist/index.d.ts",
9+
"sideEffects": [],
10+
"tags": [
11+
"typescript",
12+
"cardano",
13+
"aiken",
14+
"uplc",
15+
"evaluator",
16+
"wasm"
17+
],
18+
"exports": {
19+
".": {
20+
"types": "./src/index.node.ts",
21+
"node": "./src/index.node.ts",
22+
"browser": "./src/index.browser.ts",
23+
"default": "./src/index.node.ts"
24+
},
25+
"./package.json": "./package.json"
26+
},
27+
"files": [
28+
"src/**/*.ts",
29+
"dist/**/*.js",
30+
"dist/**/*.js.map",
31+
"dist/**/*.d.ts",
32+
"dist/**/*.d.ts.map",
33+
"dist/**/*.wasm"
34+
],
35+
"scripts": {
36+
"build:wasm": "rm -rf src/browser src/node && cd rust && wasm-pack build --target bundler --out-dir ../src/browser && wasm-pack build --target nodejs --out-dir ../src/node && pnpm clean-wasm",
37+
"clean-wasm": "rm -f src/browser/.gitignore src/browser/package.json src/node/.gitignore src/node/package.json",
38+
"build": "tsc -b tsconfig.build.json",
39+
"dev": "tsc -b tsconfig.build.json --watch",
40+
"type-check": "tsc --noEmit",
41+
"lint": "eslint \"src/**/*.{ts,mjs}\"",
42+
"clean": "rm -rf dist .turbo .tsbuildinfo"
43+
},
44+
"devDependencies": {
45+
"typescript": "^5.9.2"
46+
},
47+
"dependencies": {
48+
"effect": "^3.19.3"
49+
},
50+
"peerDependencies": {
51+
"@evolution-sdk/evolution": "workspace:*"
52+
},
53+
"keywords": [
54+
"cardano",
55+
"blockchain",
56+
"aiken",
57+
"uplc",
58+
"evaluator",
59+
"wasm",
60+
"typescript",
61+
"effect"
62+
],
63+
"homepage": "https://github.com/IntersectMBO/evolution-sdk",
64+
"repository": {
65+
"type": "git",
66+
"url": "git+https://github.com/IntersectMBO/evolution-sdk.git",
67+
"directory": "packages/aiken-uplc"
68+
},
69+
"bugs": {
70+
"url": "https://github.com/IntersectMBO/evolution-sdk/issues"
71+
},
72+
"license": "MIT",
73+
"publishConfig": {
74+
"access": "public",
75+
"provenance": true,
76+
"exports": {
77+
".": {
78+
"node": {
79+
"types": "./dist/index.node.d.ts",
80+
"default": "./dist/index.node.js"
81+
},
82+
"browser": {
83+
"types": "./dist/index.browser.d.ts",
84+
"default": "./dist/index.browser.js"
85+
},
86+
"default": {
87+
"types": "./dist/index.node.d.ts",
88+
"default": "./dist/index.node.js"
89+
}
90+
},
91+
"./package.json": "./package.json"
92+
}
93+
}
94+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "stable"
3+
targets = [ "wasm32-unknown-unknown" ]

0 commit comments

Comments
 (0)