@meshsdk/core-csl 1.6.0-alpha.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 (74) hide show
  1. package/README.md +9 -0
  2. package/dist/cjs/core/builder.d.ts +38 -0
  3. package/dist/cjs/core/builder.js +389 -0
  4. package/dist/cjs/core/index.d.ts +1 -0
  5. package/dist/cjs/core/index.js +17 -0
  6. package/dist/cjs/deser/builder.d.ts +18 -0
  7. package/dist/cjs/deser/builder.js +130 -0
  8. package/dist/cjs/deser/constants.d.ts +12 -0
  9. package/dist/cjs/deser/constants.js +15 -0
  10. package/dist/cjs/deser/converter.d.ts +27 -0
  11. package/dist/cjs/deser/converter.js +352 -0
  12. package/dist/cjs/deser/csl.d.ts +1 -0
  13. package/dist/cjs/deser/csl.js +27 -0
  14. package/dist/cjs/deser/deserializer.d.ts +19 -0
  15. package/dist/cjs/deser/deserializer.js +40 -0
  16. package/dist/cjs/deser/index.d.ts +6 -0
  17. package/dist/cjs/deser/index.js +22 -0
  18. package/dist/cjs/deser/types.d.ts +146 -0
  19. package/dist/cjs/deser/types.js +2 -0
  20. package/dist/cjs/index.d.ts +3 -0
  21. package/dist/cjs/index.js +19 -0
  22. package/dist/cjs/utils/address.d.ts +12 -0
  23. package/dist/cjs/utils/address.js +60 -0
  24. package/dist/cjs/utils/aiken.d.ts +2 -0
  25. package/dist/cjs/utils/aiken.js +20 -0
  26. package/dist/cjs/utils/credentials.d.ts +1 -0
  27. package/dist/cjs/utils/credentials.js +10 -0
  28. package/dist/cjs/utils/datum.d.ts +4 -0
  29. package/dist/cjs/utils/datum.js +18 -0
  30. package/dist/cjs/utils/index.d.ts +7 -0
  31. package/dist/cjs/utils/index.js +23 -0
  32. package/dist/cjs/utils/scripts.d.ts +1 -0
  33. package/dist/cjs/utils/scripts.js +6 -0
  34. package/dist/cjs/utils/staking.d.ts +3 -0
  35. package/dist/cjs/utils/staking.js +25 -0
  36. package/dist/cjs/utils/transaction.d.ts +2 -0
  37. package/dist/cjs/utils/transaction.js +15 -0
  38. package/dist/mjs/core/builder.d.ts +38 -0
  39. package/dist/mjs/core/builder.js +380 -0
  40. package/dist/mjs/core/index.d.ts +1 -0
  41. package/dist/mjs/core/index.js +1 -0
  42. package/dist/mjs/deser/builder.d.ts +18 -0
  43. package/dist/mjs/deser/builder.js +118 -0
  44. package/dist/mjs/deser/constants.d.ts +12 -0
  45. package/dist/mjs/deser/constants.js +12 -0
  46. package/dist/mjs/deser/converter.d.ts +27 -0
  47. package/dist/mjs/deser/converter.js +321 -0
  48. package/dist/mjs/deser/csl.d.ts +1 -0
  49. package/dist/mjs/deser/csl.js +1 -0
  50. package/dist/mjs/deser/deserializer.d.ts +19 -0
  51. package/dist/mjs/deser/deserializer.js +20 -0
  52. package/dist/mjs/deser/index.d.ts +6 -0
  53. package/dist/mjs/deser/index.js +6 -0
  54. package/dist/mjs/deser/types.d.ts +146 -0
  55. package/dist/mjs/deser/types.js +1 -0
  56. package/dist/mjs/index.d.ts +3 -0
  57. package/dist/mjs/index.js +3 -0
  58. package/dist/mjs/utils/address.d.ts +12 -0
  59. package/dist/mjs/utils/address.js +50 -0
  60. package/dist/mjs/utils/aiken.d.ts +2 -0
  61. package/dist/mjs/utils/aiken.js +15 -0
  62. package/dist/mjs/utils/credentials.d.ts +1 -0
  63. package/dist/mjs/utils/credentials.js +6 -0
  64. package/dist/mjs/utils/datum.d.ts +4 -0
  65. package/dist/mjs/utils/datum.js +13 -0
  66. package/dist/mjs/utils/index.d.ts +7 -0
  67. package/dist/mjs/utils/index.js +7 -0
  68. package/dist/mjs/utils/scripts.d.ts +1 -0
  69. package/dist/mjs/utils/scripts.js +2 -0
  70. package/dist/mjs/utils/staking.d.ts +3 -0
  71. package/dist/mjs/utils/staking.js +18 -0
  72. package/dist/mjs/utils/transaction.d.ts +2 -0
  73. package/dist/mjs/utils/transaction.js +10 -0
  74. package/package.json +53 -0
@@ -0,0 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { csl } from '../deser';
3
+ export const parseInlineDatum = (utxo) => {
4
+ const datumCbor = utxo.inline_datum || '';
5
+ const parsedDatum = csl.PlutusData.from_hex(datumCbor);
6
+ const datum = JSON.parse(parsedDatum.to_json(1));
7
+ return datum;
8
+ };
9
+ export const parseDatumCbor = (datumCbor) => {
10
+ const parsedDatum = csl.PlutusData.from_hex(datumCbor);
11
+ const datum = JSON.parse(parsedDatum.to_json(1));
12
+ return datum;
13
+ };
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1 @@
1
+ export declare const getV2ScriptHash: (script: string) => string;
@@ -0,0 +1,2 @@
1
+ import { csl } from '../deser';
2
+ export const getV2ScriptHash = (script) => csl.get_v2_script_hash(script);
@@ -0,0 +1,3 @@
1
+ export declare const poolIdHexToBech32: (poolIdHash: string) => string;
2
+ export declare const poolIdBech32ToHex: (poolIdBech32: string) => string;
3
+ export declare const baseAddressToStakeAddress: (baseAddressBech32: string, network?: number) => string;
@@ -0,0 +1,18 @@
1
+ import { csl } from '../deser';
2
+ export const poolIdHexToBech32 = (poolIdHash) => {
3
+ const cslPoolIdHash = csl.Ed25519KeyHash.from_hex(poolIdHash);
4
+ return cslPoolIdHash.to_bech32('pool');
5
+ };
6
+ export const poolIdBech32ToHex = (poolIdBech32) => {
7
+ const cslPoolIdHash = csl.Ed25519KeyHash.from_bech32(poolIdBech32);
8
+ return Buffer.from(cslPoolIdHash.to_bytes()).toString('hex');
9
+ };
10
+ export const baseAddressToStakeAddress = (baseAddressBech32, network = 1) => {
11
+ const networkId = network === 1 ? csl.NetworkId.mainnet().kind() : csl.NetworkId.testnet().kind();
12
+ const stakeCred = csl.BaseAddress.from_address(csl.Address.from_bech32(baseAddressBech32))?.stake_cred();
13
+ if (stakeCred) {
14
+ const stakeAddress = csl.RewardAddress.new(networkId, stakeCred).to_address().to_bech32();
15
+ return stakeAddress;
16
+ }
17
+ return '';
18
+ };
@@ -0,0 +1,2 @@
1
+ export declare const calculateTxHash: (txHex: string) => string;
2
+ export declare const signTransaction: (txHex: string, signingKeys: string[]) => string;
@@ -0,0 +1,10 @@
1
+ import { csl } from '../deser';
2
+ export const calculateTxHash = (txHex) => csl.calculate_tx_hash(txHex);
3
+ export const signTransaction = (txHex, signingKeys) => {
4
+ const cslSigningKeys = csl.JsVecString.new();
5
+ signingKeys.forEach((key) => {
6
+ cslSigningKeys.add(key);
7
+ });
8
+ const signedTx = csl.sign_transaction(txHex, cslSigningKeys);
9
+ return signedTx;
10
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@meshsdk/core-csl",
3
+ "description": "Cardano Off-chain Code APIs built on cardano-serialization-lib",
4
+ "version": "1.6.0-alpha.1",
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
+ "@meshsdk/common": "^1.0.0-alpha.3",
42
+ "@sidan-lab/sidan-csl-rs-browser": "^0.3.6",
43
+ "@sidan-lab/sidan-csl-rs-nodejs": "^0.3.6",
44
+ "blakejs": "^1.2.1",
45
+ "json-bigint": "^1.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/json-bigint": "^1.0.4",
49
+ "@types/node": "^18.16.3",
50
+ "ts-node": "^10.9.2",
51
+ "typescript": "^5.0.4"
52
+ }
53
+ }