forked from butaneprotocol/translucent-compat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split translucent and blueprint.ts into distinct packages / first pas…
…s at monorepo setup
- Loading branch information
Showing
59 changed files
with
177 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ uplc/target | |
.env.* | ||
seed.txt | ||
package-lock.json | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,6 @@ | ||
{ | ||
"name": "translucent-cardano", | ||
"module": "index.ts", | ||
"type": "module", | ||
"version": "0.0.2", | ||
"scripts": { | ||
"build:wasm": "cd ./uplc && ./build.sh && rm pkg-node/.gitignore && rm pkg-web/.gitignore && cd .. && npm i" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.5", | ||
"@types/sha256": "^0.2.2", | ||
"bun-types": "latest", | ||
"eslint": "^8.50.0", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.3.3", | ||
"@cardano-ogmios/schema": "^6.0.0-rc6" | ||
}, | ||
"dependencies": { | ||
"@dcspark/cardano-multiplatform-lib-browser": "^3.1.2", | ||
"@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.2", | ||
"@emurgo/cardano-message-signing-browser": "^1.0.1", | ||
"@emurgo/cardano-message-signing-nodejs": "^1.0.1", | ||
"@sinclair/typebox": "^0.31.28", | ||
"fast-check": "^3.14.0", | ||
"mathjs": "^12.2.1", | ||
"prettier": "^3.1.1", | ||
"sha256": "^0.2.0", | ||
"uplc-node": "^0.0.2", | ||
"uplc-web": "^0.0.2" | ||
}, | ||
"browser": { | ||
"./core/core.ts": "./core/core-browser.ts" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
"name": "translucent-monorepo", | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { parseBlueprint } from "."; | ||
|
||
const args = Bun.argv.slice(2); | ||
|
||
parseBlueprint(args[0], args[1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./src/blueprint"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "translucent-blueprint", | ||
"module": "index.ts", | ||
"bin": { | ||
"translucent-blueprint": "cli.ts" | ||
}, | ||
"type": "module", | ||
"version": "0.0.2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { parseBlueprint } from "../src/blueprint"; | ||
import path from "path"; | ||
import expectedResult from "./fixtures/plutus-vesting.ts.txt"; | ||
|
||
jest.spyOn(Bun, "write").mockImplementation((path, data) => { | ||
return Promise.resolve(data.toString().length); | ||
}); | ||
|
||
it("should successfully parse any plutus.json", async () => { | ||
const TARGET_FILENAME = "plutus.ts"; | ||
|
||
const plutusLocation = path.join( | ||
import.meta.dir, | ||
"./fixtures/plutus-vesting.json", | ||
); | ||
await parseBlueprint(plutusLocation, TARGET_FILENAME); | ||
|
||
const writeMock = Bun.write as jest.MockedFunction<typeof Bun.write>; | ||
|
||
expect(writeMock).toHaveBeenCalled(); | ||
|
||
const [writePath, writeData] = writeMock.mock.calls[0]; | ||
|
||
expect(writePath).toContain(TARGET_FILENAME); | ||
expect(writeData).toEqual(expectedResult); | ||
}); |
72 changes: 72 additions & 0 deletions
72
packages/translucent-blueprint/test/fixtures/plutus-vesting.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"preamble": { | ||
"title": "aiken-lang/vesting", | ||
"description": "Aiken contracts for project 'aiken-lang/vesting'", | ||
"version": "0.0.0", | ||
"plutusVersion": "v2", | ||
"license": "Apache-2.0" | ||
}, | ||
"validators": [ | ||
{ | ||
"title": "vesting.vesting", | ||
"datum": { | ||
"title": "datum", | ||
"schema": { | ||
"$ref": "#/definitions/vesting~1Datum" | ||
} | ||
}, | ||
"redeemer": { | ||
"title": "_redeemer", | ||
"schema": { | ||
"$ref": "#/definitions/Void" | ||
} | ||
}, | ||
"compiledCode": "59020c01000032323232323232323232322223253330093232533300b3370e900100089919918008009129998088008a5013232533301000214a2266008008002602a00466e1d2002300f375460260026464646602666601e6600266016601a01090001bae3300b300d0074800930103d87a80004c0103d87980003301333300f332300100122533301400114a226464a6660260042660080080022940c060008cdc3a400460246ea8c058004cc04cccc03ccc004cc02cc0340212000375c66016601a00e900226103d87a80004c0103d87980003301333300f3322323253330133370e90010008991919b89005001375a603200260220042940c044004cc034c03ccc034c03c009200048000cc02cc034cc02cc034021200048038dd6998059806803a400098103d87a80004c0103d87980004bd7026103d87a80004c0103d87980004bd7011198019bac3300c300e00248040004c0040048894ccc04800852809919299980899b8f00200314a2266600a00a002006602c0066eb8c050008c0240085281804800998029803801240042930b1900219299980499b87480000044c8c8c8c8c8c94ccc048c05400852616375c602600260260046eb8c044004c044008dd6980780098038020b180380199800800a40004444666600e66e1c00400c0308cccc014014cdc000224004601c0020040044600a6ea80048c00cdd5000ab9a5573aaae7955cfaba05742ae881", | ||
"hash": "9955364493da365b0e972b6bd28e20970b509a8f4d31016ee8976274" | ||
} | ||
], | ||
"definitions": { | ||
"ByteArray": { | ||
"dataType": "bytes" | ||
}, | ||
"Int": { | ||
"dataType": "integer" | ||
}, | ||
"Void": { | ||
"title": "Unit", | ||
"description": "The nullary constructor.", | ||
"anyOf": [ | ||
{ | ||
"dataType": "constructor", | ||
"index": 0, | ||
"fields": [] | ||
} | ||
] | ||
}, | ||
"vesting/Datum": { | ||
"title": "Datum", | ||
"anyOf": [ | ||
{ | ||
"title": "Datum", | ||
"dataType": "constructor", | ||
"index": 0, | ||
"fields": [ | ||
{ | ||
"title": "lock_until", | ||
"description": "POSIX time in second, e.g. 1672843961000", | ||
"$ref": "#/definitions/Int" | ||
}, | ||
{ | ||
"title": "owner", | ||
"$ref": "#/definitions/ByteArray" | ||
}, | ||
{ | ||
"title": "beneficiary", | ||
"$ref": "#/definitions/ByteArray" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/translucent-blueprint/test/fixtures/plutus-vesting.ts.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
import { applyParamsToScript, Data, Validator } from "../translucent/index.ts" | ||
|
||
export interface VestingVesting { | ||
new (): Validator; | ||
datum: {lockUntil:bigint;owner:string;beneficiary:string}; | ||
_redeemer: undefined; | ||
}; | ||
|
||
export const VestingVesting = Object.assign( | ||
function () {return {type: "PlutusV2", script: "59020c01000032323232323232323232322223253330093232533300b3370e900100089919918008009129998088008a5013232533301000214a2266008008002602a00466e1d2002300f375460260026464646602666601e6600266016601a01090001bae3300b300d0074800930103d87a80004c0103d87980003301333300f332300100122533301400114a226464a6660260042660080080022940c060008cdc3a400460246ea8c058004cc04cccc03ccc004cc02cc0340212000375c66016601a00e900226103d87a80004c0103d87980003301333300f3322323253330133370e90010008991919b89005001375a603200260220042940c044004cc034c03ccc034c03c009200048000cc02cc034cc02cc034021200048038dd6998059806803a400098103d87a80004c0103d87980004bd7026103d87a80004c0103d87980004bd7011198019bac3300c300e00248040004c0040048894ccc04800852809919299980899b8f00200314a2266600a00a002006602c0066eb8c050008c0240085281804800998029803801240042930b1900219299980499b87480000044c8c8c8c8c8c94ccc048c05400852616375c602600260260046eb8c044004c044008dd6980780098038020b180380199800800a40004444666600e66e1c00400c0308cccc014014cdc000224004601c0020040044600a6ea80048c00cdd5000ab9a5573aaae7955cfaba05742ae881"};}, | ||
{datum: {"title":"Datum","anyOf":[{"title":"Datum","dataType":"constructor","index":0,"fields":[{"dataType":"integer","title":"lockUntil"},{"dataType":"bytes","title":"owner"},{"dataType":"bytes","title":"beneficiary"}]}]}}, | ||
{_redeemer: {"title":"Unit","description":"The nullary constructor.","anyOf":[{"dataType":"constructor","index":0,"fields":[]}]}}, | ||
) as unknown as VestingVesting; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "translucent-cardano", | ||
"module": "index.ts", | ||
"type": "module", | ||
"version": "0.0.2", | ||
"scripts": { | ||
"build:wasm": "cd ./uplc && ./build.sh && rm pkg-node/.gitignore && rm pkg-web/.gitignore && cd .. && npm i" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^29.5.5", | ||
"@types/sha256": "^0.2.2", | ||
"bun-types": "latest", | ||
"eslint": "^8.50.0", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.3.3", | ||
"@cardano-ogmios/schema": "^6.0.0-rc6" | ||
}, | ||
"dependencies": { | ||
"@dcspark/cardano-multiplatform-lib-browser": "^3.1.2", | ||
"@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.2", | ||
"@emurgo/cardano-message-signing-browser": "^1.0.1", | ||
"@emurgo/cardano-message-signing-nodejs": "^1.0.1", | ||
"@sinclair/typebox": "^0.31.28", | ||
"fast-check": "^3.14.0", | ||
"mathjs": "^12.2.1", | ||
"prettier": "^3.1.1", | ||
"sha256": "^0.2.0", | ||
"uplc-node": "^0.0.2", | ||
"uplc-web": "^0.0.2" | ||
}, | ||
"browser": { | ||
"./core/core.ts": "./core/core-browser.ts" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
} |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters