@meshsdk/core-csl 1.6.0-alpha.8 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +3 -7
  2. package/dist/index.cjs +932 -0
  3. package/dist/index.d.cts +119 -0
  4. package/dist/index.d.ts +119 -0
  5. package/dist/index.js +839 -0
  6. package/package.json +55 -49
  7. package/dist/cjs/core/builder.d.ts +0 -10
  8. package/dist/cjs/core/builder.js +0 -56
  9. package/dist/cjs/core/index.d.ts +0 -1
  10. package/dist/cjs/core/index.js +0 -17
  11. package/dist/cjs/deser/constants.d.ts +0 -12
  12. package/dist/cjs/deser/constants.js +0 -15
  13. package/dist/cjs/deser/converter.d.ts +0 -13
  14. package/dist/cjs/deser/converter.js +0 -80
  15. package/dist/cjs/deser/csl.d.ts +0 -1
  16. package/dist/cjs/deser/csl.js +0 -27
  17. package/dist/cjs/deser/deserializer.d.ts +0 -19
  18. package/dist/cjs/deser/deserializer.js +0 -40
  19. package/dist/cjs/deser/index.d.ts +0 -4
  20. package/dist/cjs/deser/index.js +0 -20
  21. package/dist/cjs/index.d.ts +0 -3
  22. package/dist/cjs/index.js +0 -19
  23. package/dist/cjs/utils/address.d.ts +0 -13
  24. package/dist/cjs/utils/address.js +0 -44
  25. package/dist/cjs/utils/aiken.d.ts +0 -10
  26. package/dist/cjs/utils/aiken.js +0 -42
  27. package/dist/cjs/utils/credentials.d.ts +0 -1
  28. package/dist/cjs/utils/credentials.js +0 -10
  29. package/dist/cjs/utils/datum.d.ts +0 -4
  30. package/dist/cjs/utils/datum.js +0 -18
  31. package/dist/cjs/utils/index.d.ts +0 -7
  32. package/dist/cjs/utils/index.js +0 -23
  33. package/dist/cjs/utils/scripts.d.ts +0 -1
  34. package/dist/cjs/utils/scripts.js +0 -6
  35. package/dist/cjs/utils/staking.d.ts +0 -3
  36. package/dist/cjs/utils/staking.js +0 -25
  37. package/dist/cjs/utils/transaction.d.ts +0 -2
  38. package/dist/cjs/utils/transaction.js +0 -15
  39. package/dist/mjs/core/builder.d.ts +0 -10
  40. package/dist/mjs/core/builder.js +0 -52
  41. package/dist/mjs/core/index.d.ts +0 -1
  42. package/dist/mjs/core/index.js +0 -1
  43. package/dist/mjs/deser/constants.d.ts +0 -12
  44. package/dist/mjs/deser/constants.js +0 -12
  45. package/dist/mjs/deser/converter.d.ts +0 -13
  46. package/dist/mjs/deser/converter.js +0 -63
  47. package/dist/mjs/deser/csl.d.ts +0 -1
  48. package/dist/mjs/deser/csl.js +0 -1
  49. package/dist/mjs/deser/deserializer.d.ts +0 -19
  50. package/dist/mjs/deser/deserializer.js +0 -20
  51. package/dist/mjs/deser/index.d.ts +0 -4
  52. package/dist/mjs/deser/index.js +0 -4
  53. package/dist/mjs/index.d.ts +0 -3
  54. package/dist/mjs/index.js +0 -3
  55. package/dist/mjs/utils/address.d.ts +0 -13
  56. package/dist/mjs/utils/address.js +0 -34
  57. package/dist/mjs/utils/aiken.d.ts +0 -10
  58. package/dist/mjs/utils/aiken.js +0 -38
  59. package/dist/mjs/utils/credentials.d.ts +0 -1
  60. package/dist/mjs/utils/credentials.js +0 -6
  61. package/dist/mjs/utils/datum.d.ts +0 -4
  62. package/dist/mjs/utils/datum.js +0 -13
  63. package/dist/mjs/utils/index.d.ts +0 -7
  64. package/dist/mjs/utils/index.js +0 -7
  65. package/dist/mjs/utils/scripts.d.ts +0 -1
  66. package/dist/mjs/utils/scripts.js +0 -2
  67. package/dist/mjs/utils/staking.d.ts +0 -3
  68. package/dist/mjs/utils/staking.js +0 -18
  69. package/dist/mjs/utils/transaction.d.ts +0 -2
  70. package/dist/mjs/utils/transaction.js +0 -10
package/package.json CHANGED
@@ -1,52 +1,58 @@
1
1
  {
2
- "name": "@meshsdk/core-csl",
3
- "description": "Cardano Off-chain Code APIs built on cardano-serialization-lib",
4
- "version": "1.6.0-alpha.8",
5
- "license": "Apache-2.0",
6
- "main": "dist/cjs/index.js",
7
- "module": "dist/mjs/index.js",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/mjs/index.js",
11
- "require": "./dist/cjs/index.js"
12
- }
13
- },
14
- "homepage": "https://github.com/MeshJS/mesh-core",
15
- "author": {
16
- "name": "SIDAN Lab",
17
- "email": "contact@sidan.io"
18
- },
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/MeshJS/mesh-core.git"
22
- },
23
- "files": [
24
- "dist"
25
- ],
26
- "keywords": [
27
- "blockchain",
28
- "cardano",
29
- "plutus",
30
- "cardano-serialization-lib"
31
- ],
32
- "scripts": {
33
- "prepare": "cp ../../tsconfig-base.json ./ && cp ../../tsconfig-cjs.json ./ && cp ../../tsconfig.json ./",
34
- "build": "rm -fr dist/* && tsc -p ./tsconfig.json && tsc -p ./tsconfig-cjs.json",
35
- "ci": "yarn && yarn build"
36
- },
37
- "browser": {
38
- "@sidan-lab/sidan-csl-rs-nodejs": "@sidan-lab/sidan-csl-rs-browser"
39
- },
40
- "dependencies": {
41
- "@sidan-lab/sidan-csl-rs-browser": "^0.5.4",
42
- "@sidan-lab/sidan-csl-rs-nodejs": "^0.5.4",
43
- "blakejs": "^1.2.1",
44
- "json-bigint": "^1.0.0"
45
- },
46
- "devDependencies": {
47
- "@types/json-bigint": "^1.0.4",
48
- "@types/node": "^18.16.3",
49
- "ts-node": "^10.9.2",
50
- "typescript": "^5.0.4"
2
+ "name": "@meshsdk/core-csl",
3
+ "version": "1.6.1",
4
+ "description": "",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts"
51
14
  }
15
+ },
16
+ "files": [
17
+ "dist/**"
18
+ ],
19
+ "scripts": {
20
+ "build:mesh": "tsup src/index.ts --format esm,cjs --dts",
21
+ "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
22
+ "lint": "eslint",
23
+ "test": "jest --verbose",
24
+ "clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
25
+ "format": "prettier --check . --ignore-path ../../.gitignore",
26
+ "build:docs": "typedoc src/index.ts --json ../../apps/docs/src/data/mesh-core-csl.json"
27
+ },
28
+ "browser": {
29
+ "@sidan-lab/sidan-csl-rs-nodejs": "@sidan-lab/sidan-csl-rs-browser"
30
+ },
31
+ "devDependencies": {
32
+ "@meshsdk/eslint-config": "*",
33
+ "@meshsdk/typescript-config": "*",
34
+ "@types/json-bigint": "^1.0.4",
35
+ "eslint": "^8.57.0",
36
+ "ts-jest": "^29.1.4",
37
+ "tsup": "^8.0.2",
38
+ "typescript": "^5.3.3"
39
+ },
40
+ "dependencies": {
41
+ "@meshsdk/common": "*",
42
+ "@sidan-lab/sidan-csl-rs-browser": "^0.6.13",
43
+ "@sidan-lab/sidan-csl-rs-nodejs": "^0.6.13",
44
+ "json-bigint": "^1.0.0"
45
+ },
46
+ "prettier": "@meshsdk/prettier-config",
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "license": "Apache-2.0",
51
+ "keywords": [
52
+ "cardano",
53
+ "ada",
54
+ "web3",
55
+ "blockchain",
56
+ "sdk"
57
+ ]
52
58
  }
@@ -1,10 +0,0 @@
1
- import type { MeshTxBuilderBody, Protocol, IMeshSerializer } from '@meshsdk/common';
2
- export declare const emptyTxBuilderBody: () => MeshTxBuilderBody;
3
- export declare class CSLSerializer implements IMeshSerializer {
4
- protocolParams: Protocol;
5
- meshTxBuilderBody: MeshTxBuilderBody;
6
- constructor(protocolParams?: Protocol);
7
- serializeTxBody(txBody: MeshTxBuilderBody, protocolParams?: Protocol): string;
8
- addSigningKeys(txHex: string, signingKeys: string[]): string;
9
- protected removeDuplicateInputs: () => void;
10
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CSLSerializer = exports.emptyTxBuilderBody = void 0;
4
- const common_1 = require("@meshsdk/common");
5
- const utils_1 = require("../utils");
6
- const deser_1 = require("../deser");
7
- const emptyTxBuilderBody = () => ({
8
- inputs: [],
9
- outputs: [],
10
- extraInputs: [],
11
- selectionThreshold: 0,
12
- collaterals: [],
13
- requiredSignatures: [],
14
- referenceInputs: [],
15
- mints: [],
16
- changeAddress: '',
17
- metadata: [],
18
- validityRange: {},
19
- certificates: [],
20
- signingKey: [],
21
- withdrawals: [],
22
- });
23
- exports.emptyTxBuilderBody = emptyTxBuilderBody;
24
- class CSLSerializer {
25
- constructor(protocolParams) {
26
- this.meshTxBuilderBody = (0, exports.emptyTxBuilderBody)();
27
- // Below protected functions for completing tx building
28
- this.removeDuplicateInputs = () => {
29
- const { inputs } = this.meshTxBuilderBody;
30
- const getTxInId = (txIn) => `${txIn.txHash}#${txIn.txIndex}`;
31
- const addedInputs = [];
32
- for (let i = 0; i < inputs.length; i += 1) {
33
- const currentTxInId = getTxInId(inputs[i].txIn);
34
- if (addedInputs.includes(currentTxInId)) {
35
- inputs.splice(i, 1);
36
- i -= 1;
37
- }
38
- else {
39
- addedInputs.push(currentTxInId);
40
- }
41
- }
42
- };
43
- this.protocolParams = protocolParams || common_1.DEFAULT_PROTOCOL_PARAMETERS;
44
- }
45
- serializeTxBody(txBody, protocolParams) {
46
- const txHex = deser_1.csl.js_serialize_tx_body(JSON.stringify(txBody), JSON.stringify(protocolParams || this.protocolParams));
47
- return txHex;
48
- }
49
- addSigningKeys(txHex, signingKeys) {
50
- if (signingKeys.length > 0) {
51
- return (0, utils_1.signTransaction)(txHex, signingKeys);
52
- }
53
- return txHex;
54
- }
55
- }
56
- exports.CSLSerializer = CSLSerializer;
@@ -1 +0,0 @@
1
- export * from './builder';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./builder"), exports);
@@ -1,12 +0,0 @@
1
- import { csl } from './csl';
2
- export declare const LANGUAGE_VERSIONS: {
3
- V1: csl.Language;
4
- V2: csl.Language;
5
- };
6
- export declare const REDEEMER_TAGS: {
7
- CERT: csl.RedeemerTag;
8
- MINT: csl.RedeemerTag;
9
- REWARD: csl.RedeemerTag;
10
- SPEND: csl.RedeemerTag;
11
- };
12
- export declare const POLICY_ID_LENGTH = 56;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.POLICY_ID_LENGTH = exports.REDEEMER_TAGS = exports.LANGUAGE_VERSIONS = void 0;
4
- const csl_1 = require("./csl");
5
- exports.LANGUAGE_VERSIONS = {
6
- V1: csl_1.csl.Language.new_plutus_v1(),
7
- V2: csl_1.csl.Language.new_plutus_v2(),
8
- };
9
- exports.REDEEMER_TAGS = {
10
- CERT: csl_1.csl.RedeemerTag.new_cert(),
11
- MINT: csl_1.csl.RedeemerTag.new_mint(),
12
- REWARD: csl_1.csl.RedeemerTag.new_reward(),
13
- SPEND: csl_1.csl.RedeemerTag.new_spend(),
14
- };
15
- exports.POLICY_ID_LENGTH = 56;
@@ -1,13 +0,0 @@
1
- import type { BuilderData, Data } from '@meshsdk/common';
2
- import { csl } from './csl';
3
- export declare const toAddress: (bech32: string) => csl.Address;
4
- export declare const toBaseAddress: (bech32: string) => csl.BaseAddress | undefined;
5
- export declare const toEnterpriseAddress: (bech32: string) => csl.EnterpriseAddress | undefined;
6
- export declare const toRewardAddress: (bech32: string) => csl.RewardAddress | undefined;
7
- export declare const fromBytes: (bytes: Uint8Array) => string;
8
- export declare const toBytes: (hex: string) => Uint8Array;
9
- export declare const fromLovelace: (lovelace: number) => number;
10
- export declare const toLovelace: (ada: number) => number;
11
- export declare const toPlutusData: (data: Data) => csl.PlutusData;
12
- export declare const castRawDataToJsonString: (rawData: object | string) => string;
13
- export declare const castDataToPlutusData: ({ type, content }: BuilderData) => csl.PlutusData;
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.castDataToPlutusData = exports.castRawDataToJsonString = exports.toPlutusData = exports.toLovelace = exports.fromLovelace = exports.toBytes = exports.fromBytes = exports.toRewardAddress = exports.toEnterpriseAddress = exports.toBaseAddress = exports.toAddress = void 0;
7
- const json_bigint_1 = __importDefault(require("json-bigint"));
8
- const csl_1 = require("./csl");
9
- /* -----------------[ Address ]----------------- */
10
- const toAddress = (bech32) => csl_1.csl.Address.from_bech32(bech32);
11
- exports.toAddress = toAddress;
12
- const toBaseAddress = (bech32) => csl_1.csl.BaseAddress.from_address((0, exports.toAddress)(bech32));
13
- exports.toBaseAddress = toBaseAddress;
14
- const toEnterpriseAddress = (bech32) => csl_1.csl.EnterpriseAddress.from_address((0, exports.toAddress)(bech32));
15
- exports.toEnterpriseAddress = toEnterpriseAddress;
16
- const toRewardAddress = (bech32) => csl_1.csl.RewardAddress.from_address((0, exports.toAddress)(bech32));
17
- exports.toRewardAddress = toRewardAddress;
18
- /* -----------------[ Bytes ]----------------- */
19
- const fromBytes = (bytes) => Buffer.from(bytes).toString('hex');
20
- exports.fromBytes = fromBytes;
21
- const toBytes = (hex) => {
22
- if (hex.length % 2 === 0 && /^[0-9A-F]*$/i.test(hex))
23
- return Buffer.from(hex, 'hex');
24
- return Buffer.from(hex, 'utf-8');
25
- };
26
- exports.toBytes = toBytes;
27
- /* -----------------[ Lovelace ]----------------- */
28
- const fromLovelace = (lovelace) => lovelace / 1000000;
29
- exports.fromLovelace = fromLovelace;
30
- const toLovelace = (ada) => ada * 1000000;
31
- exports.toLovelace = toLovelace;
32
- /* -----------------[ PlutusData ]----------------- */
33
- const toPlutusData = (data) => {
34
- const toPlutusList = (dataArray) => {
35
- const plutusList = csl_1.csl.PlutusList.new();
36
- dataArray.forEach((element) => {
37
- plutusList.add((0, exports.toPlutusData)(element));
38
- });
39
- return plutusList;
40
- };
41
- switch (typeof data) {
42
- case 'string':
43
- return csl_1.csl.PlutusData.new_bytes((0, exports.toBytes)(data));
44
- case 'number':
45
- return csl_1.csl.PlutusData.new_integer(csl_1.csl.BigInt.from_str(data.toString()));
46
- case 'bigint':
47
- return csl_1.csl.PlutusData.new_integer(csl_1.csl.BigInt.from_str(data.toString()));
48
- case 'object':
49
- if (data instanceof Array) {
50
- const plutusList = toPlutusList(data);
51
- return csl_1.csl.PlutusData.new_list(plutusList);
52
- }
53
- if (data instanceof Map) {
54
- const plutusMap = csl_1.csl.PlutusMap.new();
55
- data.forEach((value, key) => {
56
- plutusMap.insert((0, exports.toPlutusData)(key), (0, exports.toPlutusData)(value));
57
- });
58
- return csl_1.csl.PlutusData.new_map(plutusMap);
59
- }
60
- return csl_1.csl.PlutusData.new_constr_plutus_data(csl_1.csl.ConstrPlutusData.new(csl_1.csl.BigNum.from_str(data.alternative.toString()), toPlutusList(data.fields)));
61
- }
62
- };
63
- exports.toPlutusData = toPlutusData;
64
- const castRawDataToJsonString = (rawData) => {
65
- if (typeof rawData === 'object') {
66
- return json_bigint_1.default.stringify(rawData);
67
- }
68
- return rawData;
69
- };
70
- exports.castRawDataToJsonString = castRawDataToJsonString;
71
- const castDataToPlutusData = ({ type, content }) => {
72
- if (type === 'Mesh') {
73
- return (0, exports.toPlutusData)(content);
74
- }
75
- if (type === 'CBOR') {
76
- return csl_1.csl.PlutusData.from_hex(content);
77
- }
78
- return csl_1.csl.PlutusData.from_json(content, csl_1.csl.PlutusDatumSchema.DetailedSchema);
79
- };
80
- exports.castDataToPlutusData = castDataToPlutusData;
@@ -1 +0,0 @@
1
- export * as csl from '@sidan-lab/sidan-csl-rs-nodejs';
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.csl = void 0;
27
- exports.csl = __importStar(require("@sidan-lab/sidan-csl-rs-nodejs"));
@@ -1,19 +0,0 @@
1
- import { LanguageVersion } from '@meshsdk/common';
2
- import { csl } from './csl';
3
- export declare const deserializeAddress: (address: string) => csl.Address;
4
- export declare const deserializeBip32PrivateKey: (bip32PrivateKey: string) => csl.Bip32PrivateKey;
5
- export declare const deserializeDataHash: (dataHash: string) => csl.DataHash;
6
- export declare const deserializeEd25519KeyHash: (ed25519KeyHash: string) => csl.Ed25519KeyHash;
7
- export declare const deserializeEd25519Signature: (ed25519Signature: string) => csl.Ed25519Signature;
8
- export declare const deserializeNativeScript: (nativeScript: string) => csl.NativeScript;
9
- export declare const deserializePublicKey: (publicKey: string) => csl.PublicKey;
10
- export declare const deserializePlutusData: (plutusData: string) => csl.PlutusData;
11
- export declare const deserializePlutusScript: (plutusScript: string, version: LanguageVersion) => csl.PlutusScript;
12
- export declare const deserializeScriptRef: (scriptRef: string) => csl.ScriptRef;
13
- export declare const deserializeScriptHash: (scriptHash: string) => csl.ScriptHash;
14
- export declare const deserializeTx: (tx: string) => csl.Transaction;
15
- export declare const deserializeTxBody: (txBody: string) => csl.TransactionBody;
16
- export declare const deserializeTxHash: (txHash: string) => csl.TransactionHash;
17
- export declare const deserializeTxUnspentOutput: (txUnspentOutput: string) => csl.TransactionUnspentOutput;
18
- export declare const deserializeTxWitnessSet: (txWitnessSet: string) => csl.TransactionWitnessSet;
19
- export declare const deserializeValue: (value: string) => csl.Value;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deserializeValue = exports.deserializeTxWitnessSet = exports.deserializeTxUnspentOutput = exports.deserializeTxHash = exports.deserializeTxBody = exports.deserializeTx = exports.deserializeScriptHash = exports.deserializeScriptRef = exports.deserializePlutusScript = exports.deserializePlutusData = exports.deserializePublicKey = exports.deserializeNativeScript = exports.deserializeEd25519Signature = exports.deserializeEd25519KeyHash = exports.deserializeDataHash = exports.deserializeBip32PrivateKey = exports.deserializeAddress = void 0;
4
- const constants_1 = require("./constants");
5
- const csl_1 = require("./csl");
6
- const converter_1 = require("./converter");
7
- const deserializeAddress = (address) => csl_1.csl.Address.from_bytes((0, converter_1.toBytes)(address));
8
- exports.deserializeAddress = deserializeAddress;
9
- const deserializeBip32PrivateKey = (bip32PrivateKey) => csl_1.csl.Bip32PrivateKey.from_bytes((0, converter_1.toBytes)(bip32PrivateKey));
10
- exports.deserializeBip32PrivateKey = deserializeBip32PrivateKey;
11
- const deserializeDataHash = (dataHash) => csl_1.csl.DataHash.from_bytes((0, converter_1.toBytes)(dataHash));
12
- exports.deserializeDataHash = deserializeDataHash;
13
- const deserializeEd25519KeyHash = (ed25519KeyHash) => csl_1.csl.Ed25519KeyHash.from_bytes((0, converter_1.toBytes)(ed25519KeyHash));
14
- exports.deserializeEd25519KeyHash = deserializeEd25519KeyHash;
15
- const deserializeEd25519Signature = (ed25519Signature) => csl_1.csl.Ed25519Signature.from_bytes((0, converter_1.toBytes)(ed25519Signature));
16
- exports.deserializeEd25519Signature = deserializeEd25519Signature;
17
- const deserializeNativeScript = (nativeScript) => csl_1.csl.NativeScript.from_bytes((0, converter_1.toBytes)(nativeScript));
18
- exports.deserializeNativeScript = deserializeNativeScript;
19
- const deserializePublicKey = (publicKey) => csl_1.csl.PublicKey.from_bytes((0, converter_1.toBytes)(publicKey));
20
- exports.deserializePublicKey = deserializePublicKey;
21
- const deserializePlutusData = (plutusData) => csl_1.csl.PlutusData.from_bytes((0, converter_1.toBytes)(plutusData));
22
- exports.deserializePlutusData = deserializePlutusData;
23
- const deserializePlutusScript = (plutusScript, version) => csl_1.csl.PlutusScript.from_bytes_with_version((0, converter_1.toBytes)(plutusScript), constants_1.LANGUAGE_VERSIONS[version]);
24
- exports.deserializePlutusScript = deserializePlutusScript;
25
- const deserializeScriptRef = (scriptRef) => csl_1.csl.ScriptRef.from_bytes((0, converter_1.toBytes)(scriptRef));
26
- exports.deserializeScriptRef = deserializeScriptRef;
27
- const deserializeScriptHash = (scriptHash) => csl_1.csl.ScriptHash.from_bytes((0, converter_1.toBytes)(scriptHash));
28
- exports.deserializeScriptHash = deserializeScriptHash;
29
- const deserializeTx = (tx) => csl_1.csl.Transaction.from_bytes((0, converter_1.toBytes)(tx));
30
- exports.deserializeTx = deserializeTx;
31
- const deserializeTxBody = (txBody) => csl_1.csl.TransactionBody.from_bytes((0, converter_1.toBytes)(txBody));
32
- exports.deserializeTxBody = deserializeTxBody;
33
- const deserializeTxHash = (txHash) => csl_1.csl.TransactionHash.from_bytes((0, converter_1.toBytes)(txHash));
34
- exports.deserializeTxHash = deserializeTxHash;
35
- const deserializeTxUnspentOutput = (txUnspentOutput) => csl_1.csl.TransactionUnspentOutput.from_bytes((0, converter_1.toBytes)(txUnspentOutput));
36
- exports.deserializeTxUnspentOutput = deserializeTxUnspentOutput;
37
- const deserializeTxWitnessSet = (txWitnessSet) => csl_1.csl.TransactionWitnessSet.from_bytes((0, converter_1.toBytes)(txWitnessSet));
38
- exports.deserializeTxWitnessSet = deserializeTxWitnessSet;
39
- const deserializeValue = (value) => csl_1.csl.Value.from_bytes((0, converter_1.toBytes)(value));
40
- exports.deserializeValue = deserializeValue;
@@ -1,4 +0,0 @@
1
- export * from './deserializer';
2
- export * from './converter';
3
- export * from './csl';
4
- export * from './constants';
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./deserializer"), exports);
18
- __exportStar(require("./converter"), exports);
19
- __exportStar(require("./csl"), exports);
20
- __exportStar(require("./constants"), exports);
@@ -1,3 +0,0 @@
1
- export * from './deser';
2
- export * from './utils';
3
- export * from './core';
package/dist/cjs/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./deser"), exports);
18
- __exportStar(require("./utils"), exports);
19
- __exportStar(require("./core"), exports);
@@ -1,13 +0,0 @@
1
- import { PubKeyAddress, ScriptAddress } from '@meshsdk/common';
2
- export declare const addrBech32ToHex: (bech32: string) => string;
3
- export declare const addrBech32ToObj: <T>(bech32: string) => T;
4
- export declare const parsePlutusAddressObjToBech32: (plutusDataAddressObject: PubKeyAddress | ScriptAddress, networkId?: number) => string;
5
- export declare const parsePlutusAddressToBech32: (plutusHex: string, networkId?: number) => string;
6
- export declare const serializeBech32Address: (bech32Addr: string) => {
7
- pubKeyHash: string;
8
- scriptHash: string;
9
- stakeCredential: string;
10
- stakeScriptCredential: string;
11
- };
12
- export declare const scriptHashToBech32: (scriptHash: string, stakeCredential?: string, networkId?: number, isScriptStakeCredential?: boolean) => string;
13
- export declare const v2ScriptToBech32: (scriptCbor: string, stakeCredential?: string, networkId?: number, isScriptStakeCredential?: boolean) => string;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.v2ScriptToBech32 = exports.scriptHashToBech32 = exports.serializeBech32Address = exports.parsePlutusAddressToBech32 = exports.parsePlutusAddressObjToBech32 = exports.addrBech32ToObj = exports.addrBech32ToHex = void 0;
4
- const deser_1 = require("../deser");
5
- const scripts_1 = require("./scripts");
6
- const addrBech32ToHex = (bech32) => {
7
- const hexAddress = deser_1.csl.Address.from_bech32(bech32).to_hex();
8
- const cslAddress = deser_1.csl.Address.from_hex(hexAddress);
9
- const hex = deser_1.csl.PlutusData.from_address(cslAddress).to_hex();
10
- return hex;
11
- };
12
- exports.addrBech32ToHex = addrBech32ToHex;
13
- const addrBech32ToObj = (bech32) => {
14
- const hexAddress = deser_1.csl.Address.from_bech32(bech32).to_hex();
15
- const cslAddress = deser_1.csl.Address.from_hex(hexAddress);
16
- const json = JSON.parse(deser_1.csl.PlutusData.from_address(cslAddress).to_json(1));
17
- return json;
18
- };
19
- exports.addrBech32ToObj = addrBech32ToObj;
20
- const parsePlutusAddressObjToBech32 = (plutusDataAddressObject, networkId = 0) => {
21
- const bech32Addr = deser_1.csl.parse_plutus_address_obj_to_bech32(JSON.stringify(plutusDataAddressObject), networkId);
22
- return bech32Addr;
23
- };
24
- exports.parsePlutusAddressObjToBech32 = parsePlutusAddressObjToBech32;
25
- const parsePlutusAddressToBech32 = (plutusHex, networkId = 0) => {
26
- const cslPlutusDataAddress = deser_1.csl.PlutusData.from_hex(plutusHex);
27
- const plutusDataAddressObject = JSON.parse(cslPlutusDataAddress.to_json(deser_1.csl.PlutusDatumSchema.DetailedSchema));
28
- return (0, exports.parsePlutusAddressObjToBech32)(plutusDataAddressObject, networkId);
29
- };
30
- exports.parsePlutusAddressToBech32 = parsePlutusAddressToBech32;
31
- const serializeBech32Address = (bech32Addr) => {
32
- const serializedAddress = deser_1.csl.serialize_bech32_address(bech32Addr);
33
- return {
34
- pubKeyHash: serializedAddress.get_pub_key_hash(),
35
- scriptHash: serializedAddress.get_script_hash(),
36
- stakeCredential: serializedAddress.get_stake_key_hash(),
37
- stakeScriptCredential: serializedAddress.get_stake_key_script_hash(),
38
- };
39
- };
40
- exports.serializeBech32Address = serializeBech32Address;
41
- const scriptHashToBech32 = (scriptHash, stakeCredential, networkId = 0, isScriptStakeCredential = false) => deser_1.csl.wasm_script_to_address(networkId, scriptHash, stakeCredential, isScriptStakeCredential);
42
- exports.scriptHashToBech32 = scriptHashToBech32;
43
- const v2ScriptToBech32 = (scriptCbor, stakeCredential, networkId = 0, isScriptStakeCredential = false) => (0, exports.scriptHashToBech32)((0, scripts_1.getV2ScriptHash)(scriptCbor), stakeCredential, networkId, isScriptStakeCredential);
44
- exports.v2ScriptToBech32 = v2ScriptToBech32;
@@ -1,10 +0,0 @@
1
- import { Data } from '@meshsdk/common';
2
- /**
3
- * Apply parameters to a given script blueprint.
4
- *
5
- * @param rawScript - The raw script CborHex from blueprint.
6
- * @param params - The parameters to apply, in an array.
7
- * @param type - The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
8
- * @returns The double-cbor encoded script CborHex with the parameters applied.
9
- */
10
- export declare const applyParamsToScript: (rawScript: string, params: object[] | Data[], type?: 'Mesh' | 'JSON' | 'CBOR') => string;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyParamsToScript = void 0;
4
- const deser_1 = require("../deser");
5
- /**
6
- * Apply parameters to a given script blueprint.
7
- *
8
- * @param rawScript - The raw script CborHex from blueprint.
9
- * @param params - The parameters to apply, in an array.
10
- * @param type - The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
11
- * @returns The double-cbor encoded script CborHex with the parameters applied.
12
- */
13
- const applyParamsToScript = (rawScript, params, type = 'Mesh') => {
14
- const cslParams = deser_1.csl.JsVecString.new();
15
- let paramType = deser_1.csl.BuilderDataType.CBOR;
16
- switch (type) {
17
- case 'JSON':
18
- paramType = deser_1.csl.BuilderDataType.JSON;
19
- params.forEach((param) => {
20
- if (typeof param === 'object') {
21
- cslParams.add(JSON.stringify(param));
22
- }
23
- else if (typeof param === 'string') {
24
- cslParams.add(param);
25
- }
26
- });
27
- break;
28
- case 'Mesh':
29
- params.forEach((param) => {
30
- const paramCbor = (0, deser_1.toPlutusData)(param);
31
- cslParams.add(paramCbor.to_hex());
32
- });
33
- break;
34
- default:
35
- params.forEach((param) => {
36
- cslParams.add(param);
37
- });
38
- break;
39
- }
40
- return deser_1.csl.apply_params_to_script(rawScript, cslParams, paramType);
41
- };
42
- exports.applyParamsToScript = applyParamsToScript;
@@ -1 +0,0 @@
1
- export declare const skeyToPubKeyHash: (skeyHex: string) => string;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.skeyToPubKeyHash = void 0;
4
- const deser_1 = require("../deser");
5
- const skeyToPubKeyHash = (skeyHex) => {
6
- const isHexUnclean = skeyHex.slice(0, 4) === '5820' && skeyHex.length === 68;
7
- const cleanHex = isHexUnclean ? skeyHex.slice(4) : skeyHex;
8
- return deser_1.csl.PrivateKey.from_hex(cleanHex).to_public().hash().to_hex();
9
- };
10
- exports.skeyToPubKeyHash = skeyToPubKeyHash;
@@ -1,4 +0,0 @@
1
- export declare const parseInlineDatum: <T extends {
2
- inline_datum?: string | undefined;
3
- }, X>(utxo: T) => X;
4
- export declare const parseDatumCbor: <T = any>(datumCbor: string) => T;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseDatumCbor = exports.parseInlineDatum = void 0;
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const deser_1 = require("../deser");
6
- const parseInlineDatum = (utxo) => {
7
- const datumCbor = utxo.inline_datum || '';
8
- const parsedDatum = deser_1.csl.PlutusData.from_hex(datumCbor);
9
- const datum = JSON.parse(parsedDatum.to_json(1));
10
- return datum;
11
- };
12
- exports.parseInlineDatum = parseInlineDatum;
13
- const parseDatumCbor = (datumCbor) => {
14
- const parsedDatum = deser_1.csl.PlutusData.from_hex(datumCbor);
15
- const datum = JSON.parse(parsedDatum.to_json(1));
16
- return datum;
17
- };
18
- exports.parseDatumCbor = parseDatumCbor;
@@ -1,7 +0,0 @@
1
- export * from './address';
2
- export * from './datum';
3
- export * from './scripts';
4
- export * from './credentials';
5
- export * from './staking';
6
- export * from './transaction';
7
- export * from './aiken';