@meshsdk/core-csl 1.6.0-alpha.7 → 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.
- package/README.md +3 -7
- package/dist/index.cjs +932 -0
- package/dist/index.d.cts +119 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.js +839 -0
- package/package.json +55 -49
- package/dist/cjs/core/builder.d.ts +0 -10
- package/dist/cjs/core/builder.js +0 -55
- package/dist/cjs/core/index.d.ts +0 -1
- package/dist/cjs/core/index.js +0 -17
- package/dist/cjs/deser/constants.d.ts +0 -12
- package/dist/cjs/deser/constants.js +0 -15
- package/dist/cjs/deser/converter.d.ts +0 -13
- package/dist/cjs/deser/converter.js +0 -80
- package/dist/cjs/deser/csl.d.ts +0 -1
- package/dist/cjs/deser/csl.js +0 -27
- package/dist/cjs/deser/deserializer.d.ts +0 -19
- package/dist/cjs/deser/deserializer.js +0 -40
- package/dist/cjs/deser/index.d.ts +0 -4
- package/dist/cjs/deser/index.js +0 -20
- package/dist/cjs/index.d.ts +0 -3
- package/dist/cjs/index.js +0 -19
- package/dist/cjs/utils/address.d.ts +0 -12
- package/dist/cjs/utils/address.js +0 -43
- package/dist/cjs/utils/aiken.d.ts +0 -10
- package/dist/cjs/utils/aiken.js +0 -42
- package/dist/cjs/utils/credentials.d.ts +0 -1
- package/dist/cjs/utils/credentials.js +0 -10
- package/dist/cjs/utils/datum.d.ts +0 -4
- package/dist/cjs/utils/datum.js +0 -18
- package/dist/cjs/utils/index.d.ts +0 -7
- package/dist/cjs/utils/index.js +0 -23
- package/dist/cjs/utils/scripts.d.ts +0 -1
- package/dist/cjs/utils/scripts.js +0 -6
- package/dist/cjs/utils/staking.d.ts +0 -3
- package/dist/cjs/utils/staking.js +0 -25
- package/dist/cjs/utils/transaction.d.ts +0 -2
- package/dist/cjs/utils/transaction.js +0 -15
- package/dist/mjs/core/builder.d.ts +0 -10
- package/dist/mjs/core/builder.js +0 -51
- package/dist/mjs/core/index.d.ts +0 -1
- package/dist/mjs/core/index.js +0 -1
- package/dist/mjs/deser/constants.d.ts +0 -12
- package/dist/mjs/deser/constants.js +0 -12
- package/dist/mjs/deser/converter.d.ts +0 -13
- package/dist/mjs/deser/converter.js +0 -63
- package/dist/mjs/deser/csl.d.ts +0 -1
- package/dist/mjs/deser/csl.js +0 -1
- package/dist/mjs/deser/deserializer.d.ts +0 -19
- package/dist/mjs/deser/deserializer.js +0 -20
- package/dist/mjs/deser/index.d.ts +0 -4
- package/dist/mjs/deser/index.js +0 -4
- package/dist/mjs/index.d.ts +0 -3
- package/dist/mjs/index.js +0 -3
- package/dist/mjs/utils/address.d.ts +0 -12
- package/dist/mjs/utils/address.js +0 -33
- package/dist/mjs/utils/aiken.d.ts +0 -10
- package/dist/mjs/utils/aiken.js +0 -38
- package/dist/mjs/utils/credentials.d.ts +0 -1
- package/dist/mjs/utils/credentials.js +0 -6
- package/dist/mjs/utils/datum.d.ts +0 -4
- package/dist/mjs/utils/datum.js +0 -13
- package/dist/mjs/utils/index.d.ts +0 -7
- package/dist/mjs/utils/index.js +0 -7
- package/dist/mjs/utils/scripts.d.ts +0 -1
- package/dist/mjs/utils/scripts.js +0 -2
- package/dist/mjs/utils/staking.d.ts +0 -3
- package/dist/mjs/utils/staking.js +0 -18
- package/dist/mjs/utils/transaction.d.ts +0 -2
- package/dist/mjs/utils/transaction.js +0 -10
package/dist/cjs/utils/index.js
DELETED
|
@@ -1,23 +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("./address"), exports);
|
|
18
|
-
__exportStar(require("./datum"), exports);
|
|
19
|
-
__exportStar(require("./scripts"), exports);
|
|
20
|
-
__exportStar(require("./credentials"), exports);
|
|
21
|
-
__exportStar(require("./staking"), exports);
|
|
22
|
-
__exportStar(require("./transaction"), exports);
|
|
23
|
-
__exportStar(require("./aiken"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getV2ScriptHash: (script: string) => string;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getV2ScriptHash = void 0;
|
|
4
|
-
const deser_1 = require("../deser");
|
|
5
|
-
const getV2ScriptHash = (script) => deser_1.csl.get_v2_script_hash(script);
|
|
6
|
-
exports.getV2ScriptHash = getV2ScriptHash;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseAddressToStakeAddress = exports.poolIdBech32ToHex = exports.poolIdHexToBech32 = void 0;
|
|
4
|
-
const deser_1 = require("../deser");
|
|
5
|
-
const poolIdHexToBech32 = (poolIdHash) => {
|
|
6
|
-
const cslPoolIdHash = deser_1.csl.Ed25519KeyHash.from_hex(poolIdHash);
|
|
7
|
-
return cslPoolIdHash.to_bech32('pool');
|
|
8
|
-
};
|
|
9
|
-
exports.poolIdHexToBech32 = poolIdHexToBech32;
|
|
10
|
-
const poolIdBech32ToHex = (poolIdBech32) => {
|
|
11
|
-
const cslPoolIdHash = deser_1.csl.Ed25519KeyHash.from_bech32(poolIdBech32);
|
|
12
|
-
return Buffer.from(cslPoolIdHash.to_bytes()).toString('hex');
|
|
13
|
-
};
|
|
14
|
-
exports.poolIdBech32ToHex = poolIdBech32ToHex;
|
|
15
|
-
const baseAddressToStakeAddress = (baseAddressBech32, network = 1) => {
|
|
16
|
-
var _a;
|
|
17
|
-
const networkId = network === 1 ? deser_1.csl.NetworkId.mainnet().kind() : deser_1.csl.NetworkId.testnet().kind();
|
|
18
|
-
const stakeCred = (_a = deser_1.csl.BaseAddress.from_address(deser_1.csl.Address.from_bech32(baseAddressBech32))) === null || _a === void 0 ? void 0 : _a.stake_cred();
|
|
19
|
-
if (stakeCred) {
|
|
20
|
-
const stakeAddress = deser_1.csl.RewardAddress.new(networkId, stakeCred).to_address().to_bech32();
|
|
21
|
-
return stakeAddress;
|
|
22
|
-
}
|
|
23
|
-
return '';
|
|
24
|
-
};
|
|
25
|
-
exports.baseAddressToStakeAddress = baseAddressToStakeAddress;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signTransaction = exports.calculateTxHash = void 0;
|
|
4
|
-
const deser_1 = require("../deser");
|
|
5
|
-
const calculateTxHash = (txHex) => deser_1.csl.calculate_tx_hash(txHex);
|
|
6
|
-
exports.calculateTxHash = calculateTxHash;
|
|
7
|
-
const signTransaction = (txHex, signingKeys) => {
|
|
8
|
-
const cslSigningKeys = deser_1.csl.JsVecString.new();
|
|
9
|
-
signingKeys.forEach((key) => {
|
|
10
|
-
cslSigningKeys.add(key);
|
|
11
|
-
});
|
|
12
|
-
const signedTx = deser_1.csl.sign_transaction(txHex, cslSigningKeys);
|
|
13
|
-
return signedTx;
|
|
14
|
-
};
|
|
15
|
-
exports.signTransaction = signTransaction;
|
|
@@ -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
|
-
}
|
package/dist/mjs/core/builder.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_PROTOCOL_PARAMETERS } from '@meshsdk/common';
|
|
2
|
-
import { signTransaction } from '../utils';
|
|
3
|
-
import { csl } from '../deser';
|
|
4
|
-
export const emptyTxBuilderBody = () => ({
|
|
5
|
-
inputs: [],
|
|
6
|
-
outputs: [],
|
|
7
|
-
extraInputs: [],
|
|
8
|
-
selectionThreshold: 0,
|
|
9
|
-
collaterals: [],
|
|
10
|
-
requiredSignatures: [],
|
|
11
|
-
referenceInputs: [],
|
|
12
|
-
mints: [],
|
|
13
|
-
changeAddress: '',
|
|
14
|
-
metadata: [],
|
|
15
|
-
validityRange: {},
|
|
16
|
-
certificates: [],
|
|
17
|
-
signingKey: [],
|
|
18
|
-
});
|
|
19
|
-
export class CSLSerializer {
|
|
20
|
-
protocolParams;
|
|
21
|
-
meshTxBuilderBody = emptyTxBuilderBody();
|
|
22
|
-
constructor(protocolParams) {
|
|
23
|
-
this.protocolParams = protocolParams || DEFAULT_PROTOCOL_PARAMETERS;
|
|
24
|
-
}
|
|
25
|
-
serializeTxBody(txBody, protocolParams) {
|
|
26
|
-
const txHex = csl.js_serialize_tx_body(JSON.stringify(txBody), JSON.stringify(protocolParams || this.protocolParams));
|
|
27
|
-
return txHex;
|
|
28
|
-
}
|
|
29
|
-
addSigningKeys(txHex, signingKeys) {
|
|
30
|
-
if (signingKeys.length > 0) {
|
|
31
|
-
return signTransaction(txHex, signingKeys);
|
|
32
|
-
}
|
|
33
|
-
return txHex;
|
|
34
|
-
}
|
|
35
|
-
// Below protected functions for completing tx building
|
|
36
|
-
removeDuplicateInputs = () => {
|
|
37
|
-
const { inputs } = this.meshTxBuilderBody;
|
|
38
|
-
const getTxInId = (txIn) => `${txIn.txHash}#${txIn.txIndex}`;
|
|
39
|
-
const addedInputs = [];
|
|
40
|
-
for (let i = 0; i < inputs.length; i += 1) {
|
|
41
|
-
const currentTxInId = getTxInId(inputs[i].txIn);
|
|
42
|
-
if (addedInputs.includes(currentTxInId)) {
|
|
43
|
-
inputs.splice(i, 1);
|
|
44
|
-
i -= 1;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
addedInputs.push(currentTxInId);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
package/dist/mjs/core/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './builder';
|
package/dist/mjs/core/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './builder';
|
|
@@ -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,12 +0,0 @@
|
|
|
1
|
-
import { csl } from './csl';
|
|
2
|
-
export const LANGUAGE_VERSIONS = {
|
|
3
|
-
V1: csl.Language.new_plutus_v1(),
|
|
4
|
-
V2: csl.Language.new_plutus_v2(),
|
|
5
|
-
};
|
|
6
|
-
export const REDEEMER_TAGS = {
|
|
7
|
-
CERT: csl.RedeemerTag.new_cert(),
|
|
8
|
-
MINT: csl.RedeemerTag.new_mint(),
|
|
9
|
-
REWARD: csl.RedeemerTag.new_reward(),
|
|
10
|
-
SPEND: csl.RedeemerTag.new_spend(),
|
|
11
|
-
};
|
|
12
|
-
export const 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,63 +0,0 @@
|
|
|
1
|
-
import JSONbig from 'json-bigint';
|
|
2
|
-
import { csl } from './csl';
|
|
3
|
-
/* -----------------[ Address ]----------------- */
|
|
4
|
-
export const toAddress = (bech32) => csl.Address.from_bech32(bech32);
|
|
5
|
-
export const toBaseAddress = (bech32) => csl.BaseAddress.from_address(toAddress(bech32));
|
|
6
|
-
export const toEnterpriseAddress = (bech32) => csl.EnterpriseAddress.from_address(toAddress(bech32));
|
|
7
|
-
export const toRewardAddress = (bech32) => csl.RewardAddress.from_address(toAddress(bech32));
|
|
8
|
-
/* -----------------[ Bytes ]----------------- */
|
|
9
|
-
export const fromBytes = (bytes) => Buffer.from(bytes).toString('hex');
|
|
10
|
-
export const toBytes = (hex) => {
|
|
11
|
-
if (hex.length % 2 === 0 && /^[0-9A-F]*$/i.test(hex))
|
|
12
|
-
return Buffer.from(hex, 'hex');
|
|
13
|
-
return Buffer.from(hex, 'utf-8');
|
|
14
|
-
};
|
|
15
|
-
/* -----------------[ Lovelace ]----------------- */
|
|
16
|
-
export const fromLovelace = (lovelace) => lovelace / 1_000_000;
|
|
17
|
-
export const toLovelace = (ada) => ada * 1_000_000;
|
|
18
|
-
/* -----------------[ PlutusData ]----------------- */
|
|
19
|
-
export const toPlutusData = (data) => {
|
|
20
|
-
const toPlutusList = (dataArray) => {
|
|
21
|
-
const plutusList = csl.PlutusList.new();
|
|
22
|
-
dataArray.forEach((element) => {
|
|
23
|
-
plutusList.add(toPlutusData(element));
|
|
24
|
-
});
|
|
25
|
-
return plutusList;
|
|
26
|
-
};
|
|
27
|
-
switch (typeof data) {
|
|
28
|
-
case 'string':
|
|
29
|
-
return csl.PlutusData.new_bytes(toBytes(data));
|
|
30
|
-
case 'number':
|
|
31
|
-
return csl.PlutusData.new_integer(csl.BigInt.from_str(data.toString()));
|
|
32
|
-
case 'bigint':
|
|
33
|
-
return csl.PlutusData.new_integer(csl.BigInt.from_str(data.toString()));
|
|
34
|
-
case 'object':
|
|
35
|
-
if (data instanceof Array) {
|
|
36
|
-
const plutusList = toPlutusList(data);
|
|
37
|
-
return csl.PlutusData.new_list(plutusList);
|
|
38
|
-
}
|
|
39
|
-
if (data instanceof Map) {
|
|
40
|
-
const plutusMap = csl.PlutusMap.new();
|
|
41
|
-
data.forEach((value, key) => {
|
|
42
|
-
plutusMap.insert(toPlutusData(key), toPlutusData(value));
|
|
43
|
-
});
|
|
44
|
-
return csl.PlutusData.new_map(plutusMap);
|
|
45
|
-
}
|
|
46
|
-
return csl.PlutusData.new_constr_plutus_data(csl.ConstrPlutusData.new(csl.BigNum.from_str(data.alternative.toString()), toPlutusList(data.fields)));
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
export const castRawDataToJsonString = (rawData) => {
|
|
50
|
-
if (typeof rawData === 'object') {
|
|
51
|
-
return JSONbig.stringify(rawData);
|
|
52
|
-
}
|
|
53
|
-
return rawData;
|
|
54
|
-
};
|
|
55
|
-
export const castDataToPlutusData = ({ type, content }) => {
|
|
56
|
-
if (type === 'Mesh') {
|
|
57
|
-
return toPlutusData(content);
|
|
58
|
-
}
|
|
59
|
-
if (type === 'CBOR') {
|
|
60
|
-
return csl.PlutusData.from_hex(content);
|
|
61
|
-
}
|
|
62
|
-
return csl.PlutusData.from_json(content, csl.PlutusDatumSchema.DetailedSchema);
|
|
63
|
-
};
|
package/dist/mjs/deser/csl.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as csl from '@sidan-lab/sidan-csl-rs-nodejs';
|
package/dist/mjs/deser/csl.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as csl from '@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,20 +0,0 @@
|
|
|
1
|
-
import { LANGUAGE_VERSIONS } from './constants';
|
|
2
|
-
import { csl } from './csl';
|
|
3
|
-
import { toBytes } from './converter';
|
|
4
|
-
export const deserializeAddress = (address) => csl.Address.from_bytes(toBytes(address));
|
|
5
|
-
export const deserializeBip32PrivateKey = (bip32PrivateKey) => csl.Bip32PrivateKey.from_bytes(toBytes(bip32PrivateKey));
|
|
6
|
-
export const deserializeDataHash = (dataHash) => csl.DataHash.from_bytes(toBytes(dataHash));
|
|
7
|
-
export const deserializeEd25519KeyHash = (ed25519KeyHash) => csl.Ed25519KeyHash.from_bytes(toBytes(ed25519KeyHash));
|
|
8
|
-
export const deserializeEd25519Signature = (ed25519Signature) => csl.Ed25519Signature.from_bytes(toBytes(ed25519Signature));
|
|
9
|
-
export const deserializeNativeScript = (nativeScript) => csl.NativeScript.from_bytes(toBytes(nativeScript));
|
|
10
|
-
export const deserializePublicKey = (publicKey) => csl.PublicKey.from_bytes(toBytes(publicKey));
|
|
11
|
-
export const deserializePlutusData = (plutusData) => csl.PlutusData.from_bytes(toBytes(plutusData));
|
|
12
|
-
export const deserializePlutusScript = (plutusScript, version) => csl.PlutusScript.from_bytes_with_version(toBytes(plutusScript), LANGUAGE_VERSIONS[version]);
|
|
13
|
-
export const deserializeScriptRef = (scriptRef) => csl.ScriptRef.from_bytes(toBytes(scriptRef));
|
|
14
|
-
export const deserializeScriptHash = (scriptHash) => csl.ScriptHash.from_bytes(toBytes(scriptHash));
|
|
15
|
-
export const deserializeTx = (tx) => csl.Transaction.from_bytes(toBytes(tx));
|
|
16
|
-
export const deserializeTxBody = (txBody) => csl.TransactionBody.from_bytes(toBytes(txBody));
|
|
17
|
-
export const deserializeTxHash = (txHash) => csl.TransactionHash.from_bytes(toBytes(txHash));
|
|
18
|
-
export const deserializeTxUnspentOutput = (txUnspentOutput) => csl.TransactionUnspentOutput.from_bytes(toBytes(txUnspentOutput));
|
|
19
|
-
export const deserializeTxWitnessSet = (txWitnessSet) => csl.TransactionWitnessSet.from_bytes(toBytes(txWitnessSet));
|
|
20
|
-
export const deserializeValue = (value) => csl.Value.from_bytes(toBytes(value));
|
package/dist/mjs/deser/index.js
DELETED
package/dist/mjs/index.d.ts
DELETED
package/dist/mjs/index.js
DELETED
|
@@ -1,12 +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
|
-
};
|
|
11
|
-
export declare const scriptHashToBech32: (scriptHash: string, stakeCredential?: string, networkId?: number) => string;
|
|
12
|
-
export declare const v2ScriptToBech32: (scriptCbor: string, stakeCredential?: string, networkId?: number) => string;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { csl } from '../deser';
|
|
2
|
-
import { getV2ScriptHash } from './scripts';
|
|
3
|
-
export const addrBech32ToHex = (bech32) => {
|
|
4
|
-
const hexAddress = csl.Address.from_bech32(bech32).to_hex();
|
|
5
|
-
const cslAddress = csl.Address.from_hex(hexAddress);
|
|
6
|
-
const hex = csl.PlutusData.from_address(cslAddress).to_hex();
|
|
7
|
-
return hex;
|
|
8
|
-
};
|
|
9
|
-
export const addrBech32ToObj = (bech32) => {
|
|
10
|
-
const hexAddress = csl.Address.from_bech32(bech32).to_hex();
|
|
11
|
-
const cslAddress = csl.Address.from_hex(hexAddress);
|
|
12
|
-
const json = JSON.parse(csl.PlutusData.from_address(cslAddress).to_json(1));
|
|
13
|
-
return json;
|
|
14
|
-
};
|
|
15
|
-
export const parsePlutusAddressObjToBech32 = (plutusDataAddressObject, networkId = 0) => {
|
|
16
|
-
const bech32Addr = csl.parse_plutus_address_obj_to_bech32(JSON.stringify(plutusDataAddressObject), networkId);
|
|
17
|
-
return bech32Addr;
|
|
18
|
-
};
|
|
19
|
-
export const parsePlutusAddressToBech32 = (plutusHex, networkId = 0) => {
|
|
20
|
-
const cslPlutusDataAddress = csl.PlutusData.from_hex(plutusHex);
|
|
21
|
-
const plutusDataAddressObject = JSON.parse(cslPlutusDataAddress.to_json(csl.PlutusDatumSchema.DetailedSchema));
|
|
22
|
-
return parsePlutusAddressObjToBech32(plutusDataAddressObject, networkId);
|
|
23
|
-
};
|
|
24
|
-
export const serializeBech32Address = (bech32Addr) => {
|
|
25
|
-
const serializedAddress = csl.serialize_bech32_address(bech32Addr);
|
|
26
|
-
return {
|
|
27
|
-
pubKeyHash: serializedAddress.get_pub_key_hash(),
|
|
28
|
-
scriptHash: serializedAddress.get_script_hash(),
|
|
29
|
-
stakeCredential: serializedAddress.get_stake_key_hash(),
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export const scriptHashToBech32 = (scriptHash, stakeCredential, networkId = 0) => csl.script_to_address(networkId, scriptHash, stakeCredential);
|
|
33
|
-
export const v2ScriptToBech32 = (scriptCbor, stakeCredential, networkId = 0) => scriptHashToBech32(getV2ScriptHash(scriptCbor), stakeCredential, networkId);
|
|
@@ -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;
|
package/dist/mjs/utils/aiken.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { csl, toPlutusData } from '../deser';
|
|
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 const applyParamsToScript = (rawScript, params, type = 'Mesh') => {
|
|
11
|
-
const cslParams = csl.JsVecString.new();
|
|
12
|
-
let paramType = csl.BuilderDataType.CBOR;
|
|
13
|
-
switch (type) {
|
|
14
|
-
case 'JSON':
|
|
15
|
-
paramType = csl.BuilderDataType.JSON;
|
|
16
|
-
params.forEach((param) => {
|
|
17
|
-
if (typeof param === 'object') {
|
|
18
|
-
cslParams.add(JSON.stringify(param));
|
|
19
|
-
}
|
|
20
|
-
else if (typeof param === 'string') {
|
|
21
|
-
cslParams.add(param);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
break;
|
|
25
|
-
case 'Mesh':
|
|
26
|
-
params.forEach((param) => {
|
|
27
|
-
const paramCbor = toPlutusData(param);
|
|
28
|
-
cslParams.add(paramCbor.to_hex());
|
|
29
|
-
});
|
|
30
|
-
break;
|
|
31
|
-
default:
|
|
32
|
-
params.forEach((param) => {
|
|
33
|
-
cslParams.add(param);
|
|
34
|
-
});
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
return csl.apply_params_to_script(rawScript, cslParams, paramType);
|
|
38
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const skeyToPubKeyHash: (skeyHex: string) => string;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { csl } from '../deser';
|
|
2
|
-
export const skeyToPubKeyHash = (skeyHex) => {
|
|
3
|
-
const isHexUnclean = skeyHex.slice(0, 4) === '5820' && skeyHex.length === 68;
|
|
4
|
-
const cleanHex = isHexUnclean ? skeyHex.slice(4) : skeyHex;
|
|
5
|
-
return csl.PrivateKey.from_hex(cleanHex).to_public().hash().to_hex();
|
|
6
|
-
};
|
package/dist/mjs/utils/datum.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/mjs/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getV2ScriptHash: (script: string) => string;
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
};
|