@meshsdk/core 1.9.0-beta.9 → 1.9.0-beta.90
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 +39 -33
- package/dist/index.cjs +146 -4
- package/dist/index.d.cts +140 -7
- package/dist/index.d.ts +140 -7
- package/dist/index.js +142 -4
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
<h1 style="border-bottom: none"><a href='https://meshjs.dev/'>Mesh</a> TypeScript SDK</h1>
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
[](https://github.com/meshjs/mesh/blob/master/LICENSE)
|
|
12
|
+
[](https://github.com/meshjs/mesh/actions/workflows/build.yml)
|
|
13
|
+
[](https://github.com/meshjs/mesh/actions/workflows/publish.yml)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
[](https://x.com/meshsdk)
|
|
16
|
+
[](https://www.npmjs.com/package/@meshsdk/core)
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
<strong>All-in-one TypeScript SDK for Cardano apps</strong>
|
|
19
19
|
|
|
20
20
|
</div>
|
|
21
21
|
|
|
22
22
|
<hr />
|
|
23
23
|
|
|
24
|
-
Mesh is an open-source library designed to make building
|
|
24
|
+
Mesh is an open-source library designed to make building applications accessible. Whether you're a beginner developer, startup, web3 market leader, or a large enterprise, Mesh makes web3 development easy with reliable, scalable, and well-engineered APIs & developer tools.
|
|
25
25
|
|
|
26
26
|
Explore the features on [Mesh Playground](https://meshjs.dev/).
|
|
27
27
|
|
|
@@ -31,48 +31,54 @@ Instant setup a new project with a single command using Mesh CLI and start build
|
|
|
31
31
|
npx meshjs your-app-name
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
Or install the core package:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @meshsdk/core
|
|
38
|
+
```
|
|
39
|
+
|
|
34
40
|
## What's inside?
|
|
35
41
|
|
|
36
42
|
### Packages
|
|
37
43
|
|
|
38
44
|
A collection of packages that provide different functionalities to interact with the Cardano blockchain.
|
|
39
45
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
| [@meshsdk/common](https://github.com/MeshJS/mesh/tree/main/packages/mesh-common)
|
|
43
|
-
| [@meshsdk/contract](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract)
|
|
44
|
-
| [@meshsdk/core](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core)
|
|
45
|
-
| [@meshsdk/core-csl](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core-csl)
|
|
46
|
-
| [@meshsdk/core-cst](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core-cst)
|
|
47
|
-
| [@meshsdk/provider](https://github.com/MeshJS/mesh/tree/main/packages/mesh-provider)
|
|
48
|
-
| [@meshsdk/react](https://github.com/MeshJS/mesh/tree/main/packages/mesh-react)
|
|
49
|
-
| [@meshsdk/transaction](https://github.com/MeshJS/mesh/tree/main/packages/mesh-transaction) | Transactions to send assets, mint tokens, and interact with smart contracts
|
|
50
|
-
| [@meshsdk/wallet](https://github.com/MeshJS/mesh/tree/main/packages/mesh-wallet)
|
|
46
|
+
| | Description | Docs | Playground |
|
|
47
|
+
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------- |
|
|
48
|
+
| [@meshsdk/common](https://github.com/MeshJS/mesh/tree/main/packages/mesh-common) | Contains constants, types and interfaces used across the SDK and different serialization libraries | [:page_facing_up:](https://docs.meshjs.dev/common) | |
|
|
49
|
+
| [@meshsdk/contract](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract) | A collection of smart contracts and its transactions | [:page_facing_up:](https://docs.meshjs.dev/contracts) | [:shipit:](https://meshjs.dev/smart-contracts) |
|
|
50
|
+
| [@meshsdk/core](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core) | Exports all the functionalities including wallets, transactions, and providers | | [:shipit:](https://meshjs.dev/) |
|
|
51
|
+
| [@meshsdk/core-csl](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core-csl) | Types and utilities functions between Mesh and cardano-serialization-lib | [:page_facing_up:](https://docs.meshjs.dev/core-csl) | |
|
|
52
|
+
| [@meshsdk/core-cst](https://github.com/MeshJS/mesh/tree/main/packages/mesh-core-cst) | Types and utilities functions between Mesh and cardano-js-sdk | [:page_facing_up:](https://docs.meshjs.dev/core-cst) | |
|
|
53
|
+
| [@meshsdk/provider](https://github.com/MeshJS/mesh/tree/main/packages/mesh-provider) | Blockchain data providers | [:page_facing_up:](https://docs.meshjs.dev/providers) | [:shipit:](https://meshjs.dev/providers) |
|
|
54
|
+
| [@meshsdk/react](https://github.com/MeshJS/mesh/tree/main/packages/mesh-react) | React component library | | [:shipit:](https://meshjs.dev/react) |
|
|
55
|
+
| [@meshsdk/transaction](https://github.com/MeshJS/mesh/tree/main/packages/mesh-transaction) | Transactions to send assets, mint tokens, and interact with smart contracts | [:page_facing_up:](https://docs.meshjs.dev/transactions) | [:shipit:](https://meshjs.dev/apis/transaction) |
|
|
56
|
+
| [@meshsdk/wallet](https://github.com/MeshJS/mesh/tree/main/packages/mesh-wallet) | Wallets to manage assets and interact with the blockchain | [:page_facing_up:](https://docs.meshjs.dev/wallets) | [:shipit:](https://meshjs.dev/apis/wallets) |
|
|
51
57
|
|
|
52
58
|
### Apps
|
|
53
59
|
|
|
54
60
|
Frontend documentation and live demos for Mesh SDK.
|
|
55
61
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
| [apps/docs](https://github.com/MeshJS/mesh/tree/main/apps/docs)
|
|
59
|
-
| [apps/playground](https://github.com/MeshJS/mesh/tree/main/apps/playground) | Mesh homepage and live demos | [:shipit:](https://meshjs.dev/)
|
|
62
|
+
| | Description | Website |
|
|
63
|
+
| --------------------------------------------------------------------------- | ---------------------------- | ------------------------------------ |
|
|
64
|
+
| [apps/docs](https://github.com/MeshJS/mesh/tree/main/apps/docs) | Mesh technical docs | [:shipit:](https://docs.meshjs.dev/) |
|
|
65
|
+
| [apps/playground](https://github.com/MeshJS/mesh/tree/main/apps/playground) | Mesh homepage and live demos | [:shipit:](https://meshjs.dev/) |
|
|
60
66
|
|
|
61
67
|
### Mesh Smart Contracts Library
|
|
62
68
|
|
|
63
69
|
Here's a list of open-source smart contracts, complete with documentation, live demos, and end-to-end source code.
|
|
64
70
|
|
|
65
|
-
| Contract
|
|
66
|
-
|
|
|
67
|
-
| Content Ownership
|
|
68
|
-
| Escrow
|
|
69
|
-
| Giftcard
|
|
70
|
-
| Hello World
|
|
71
|
-
| Marketplace
|
|
72
|
-
| NFT Minting Machine | Mint NFTs with an automatically incremented index, which increases by one for each newly minted NFT
|
|
73
|
-
| Payment Splitter
|
|
74
|
-
| Swap
|
|
75
|
-
| Vesting
|
|
71
|
+
| Contract | Description | Links |
|
|
72
|
+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| Content Ownership | Create a content registry and users can create content that is stored in the registry | [[demo](https://meshjs.dev/smart-contracts/content-ownership)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/content-ownership)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshContentOwnershipContract)] |
|
|
74
|
+
| Escrow | Facilitates the secure exchange of assets between two parties by acting as a trusted intermediary that holds the assets until the conditions of the agreement are met | [[demo](https://meshjs.dev/smart-contracts/escrow)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/escrow)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshEscrowContract)] |
|
|
75
|
+
| Giftcard | Allows users to create a transactions to lock assets into the smart contract, which can be redeemed by any user | [[demo](https://meshjs.dev/smart-contracts/giftcard)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/giftcard)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshGiftcardContract)] |
|
|
76
|
+
| Hello World | A simple lock-and-unlock assets contract, providing a hands-on introduction to end-to-end smart contract validation and transaction building | [[demo](https://meshjs.dev/smart-contracts/hello-world)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/hello-world)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshHelloWorldContract)] |
|
|
77
|
+
| Marketplace | Allows anyone to buy and sell native assets such as NFTs | [[demo](https://meshjs.dev/smart-contracts/marketplace)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/marketplace)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshMarketplaceContract)] |
|
|
78
|
+
| NFT Minting Machine | Mint NFTs with an automatically incremented index, which increases by one for each newly minted NFT | [[demo](https://meshjs.dev/smart-contracts/plutus-nft)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/plutus-nft)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshPlutusNFTContract)] |
|
|
79
|
+
| Payment Splitter | Allows users to split incoming payments among a group of accounts | [[demo](https://meshjs.dev/smart-contracts/payment-splitter)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/payment-splitter)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshPaymentSplitterContract)] |
|
|
80
|
+
| Swap | Facilitates the exchange of assets between two parties | [[demo](https://meshjs.dev/smart-contracts/swap)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/swap)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshSwapContract)] |
|
|
81
|
+
| Vesting | Allows users to lock tokens for a period of time and withdraw the funds after the lockup period | [[demo](https://meshjs.dev/smart-contracts/vesting)] [[source](https://github.com/MeshJS/mesh/tree/main/packages/mesh-contract/src/vesting)] [[docs](https://docs.meshjs.dev/contracts/classes/MeshVestingContract)] |
|
|
76
82
|
|
|
77
83
|
## Usage
|
|
78
84
|
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var index_exports = {};
|
|
33
33
|
__export(index_exports, {
|
|
34
|
+
MintingBlueprint: () => MintingBlueprint,
|
|
35
|
+
SpendingBlueprint: () => SpendingBlueprint,
|
|
36
|
+
WithdrawalBlueprint: () => WithdrawalBlueprint,
|
|
34
37
|
applyCborEncoding: () => applyCborEncoding,
|
|
35
38
|
applyParamsToScript: () => applyParamsToScript2,
|
|
36
39
|
checkSignature: () => import_core_cst.checkSignature,
|
|
@@ -56,6 +59,7 @@ __export(index_exports, {
|
|
|
56
59
|
resolveStakeKeyHash: () => resolveStakeKeyHash,
|
|
57
60
|
resolveTxHash: () => resolveTxHash,
|
|
58
61
|
serializeAddressObj: () => serializeAddressObj,
|
|
62
|
+
serializeData: () => serializeData,
|
|
59
63
|
serializeNativeScript: () => serializeNativeScript,
|
|
60
64
|
serializePlutusScript: () => serializePlutusScript,
|
|
61
65
|
serializePoolId: () => serializePoolId,
|
|
@@ -66,17 +70,17 @@ module.exports = __toCommonJS(index_exports);
|
|
|
66
70
|
|
|
67
71
|
// src/core.ts
|
|
68
72
|
var core = __toESM(require("@meshsdk/core-cst"), 1);
|
|
69
|
-
var applyParamsToScript2 = core.applyParamsToScript;
|
|
70
|
-
var applyCborEncoding = (
|
|
73
|
+
var applyParamsToScript2 = (rawScript, params, type) => core.applyParamsToScript(rawScript, params, type);
|
|
74
|
+
var applyCborEncoding = (rawScript) => {
|
|
71
75
|
return Buffer.from(
|
|
72
|
-
core.applyEncoding(Buffer.from(
|
|
76
|
+
core.applyEncoding(Buffer.from(rawScript, "hex"), "SingleCBOR")
|
|
73
77
|
).toString("hex");
|
|
74
78
|
};
|
|
75
79
|
|
|
76
80
|
// src/utils/resolver.ts
|
|
77
81
|
var resolvePrivateKey = (words) => core.resolvePrivateKey(words);
|
|
78
82
|
var resolveTxHash = (txHex) => core.resolveTxHash(txHex);
|
|
79
|
-
var resolveDataHash = (
|
|
83
|
+
var resolveDataHash = (rawData, type = "Mesh") => core.resolveDataHash(rawData, type);
|
|
80
84
|
var resolveNativeScriptHash = (script) => core.resolveNativeScriptHash(script);
|
|
81
85
|
var resolveScriptHash = (scriptCode, version) => {
|
|
82
86
|
if (!version) {
|
|
@@ -135,6 +139,140 @@ var serializePoolId = (hash) => core.resolvePoolId(hash);
|
|
|
135
139
|
var serializeRewardAddress = (hash, isScriptHash = false, networkId = 0) => {
|
|
136
140
|
return isScriptHash ? core.scriptHashToRewardAddress(hash, networkId) : core.keyHashToRewardAddress(hash, networkId);
|
|
137
141
|
};
|
|
142
|
+
var serializeData = (rawData, type = "Mesh") => {
|
|
143
|
+
const serializer = new core.CardanoSDKSerializer();
|
|
144
|
+
const builderData = {
|
|
145
|
+
type,
|
|
146
|
+
content: rawData
|
|
147
|
+
};
|
|
148
|
+
return serializer.serializeData(builderData);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/utils/blueprint/minting.ts
|
|
152
|
+
var MintingBlueprint = class {
|
|
153
|
+
version;
|
|
154
|
+
cbor;
|
|
155
|
+
hash;
|
|
156
|
+
constructor(version) {
|
|
157
|
+
this.version = version;
|
|
158
|
+
this.cbor = "";
|
|
159
|
+
this.hash = "";
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
163
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
164
|
+
* @param params The parameters to apply, in an array.
|
|
165
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
166
|
+
* @returns The minting blueprint object
|
|
167
|
+
*/
|
|
168
|
+
paramScript(compiledCode, params, paramsType = "Mesh") {
|
|
169
|
+
const cbor = applyParamsToScript2(compiledCode, params, paramsType);
|
|
170
|
+
const hash = resolveScriptHash(cbor, this.version);
|
|
171
|
+
this.hash = hash;
|
|
172
|
+
this.cbor = cbor;
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Initialize the minting blueprint, with no parameters
|
|
177
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
178
|
+
* @returns The minting blueprint object
|
|
179
|
+
*/
|
|
180
|
+
noParamScript(compiledCode) {
|
|
181
|
+
return this.paramScript(compiledCode, []);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/utils/blueprint/spending.ts
|
|
186
|
+
var SpendingBlueprint = class {
|
|
187
|
+
version;
|
|
188
|
+
networkId;
|
|
189
|
+
cbor;
|
|
190
|
+
hash;
|
|
191
|
+
address;
|
|
192
|
+
stakeHash;
|
|
193
|
+
isStakeScriptCredential;
|
|
194
|
+
constructor(version, networkId, stakeHash, isStakeScriptCredential = false) {
|
|
195
|
+
this.version = version;
|
|
196
|
+
this.networkId = networkId;
|
|
197
|
+
this.stakeHash = stakeHash;
|
|
198
|
+
this.cbor = "";
|
|
199
|
+
this.hash = "";
|
|
200
|
+
this.address = "";
|
|
201
|
+
this.isStakeScriptCredential = isStakeScriptCredential;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
205
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
206
|
+
* @param params The parameters to apply, in an array.
|
|
207
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
paramScript(compiledCode, params, paramsType = "Mesh") {
|
|
211
|
+
const cbor = applyParamsToScript2(compiledCode, params, paramsType);
|
|
212
|
+
const hash = resolveScriptHash(cbor, this.version);
|
|
213
|
+
const plutusScript = {
|
|
214
|
+
code: cbor,
|
|
215
|
+
version: this.version
|
|
216
|
+
};
|
|
217
|
+
const address = serializePlutusScript(
|
|
218
|
+
plutusScript,
|
|
219
|
+
this.stakeHash,
|
|
220
|
+
this.networkId,
|
|
221
|
+
this.isStakeScriptCredential
|
|
222
|
+
).address;
|
|
223
|
+
this.hash = hash;
|
|
224
|
+
this.cbor = cbor;
|
|
225
|
+
this.address = address;
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Initialize the minting blueprint, with no parameters
|
|
230
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
231
|
+
* @returns The minting blueprint object
|
|
232
|
+
*/
|
|
233
|
+
noParamScript(compiledCode) {
|
|
234
|
+
return this.paramScript(compiledCode, []);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/utils/blueprint/withdrawal.ts
|
|
239
|
+
var WithdrawalBlueprint = class {
|
|
240
|
+
version;
|
|
241
|
+
networkId;
|
|
242
|
+
cbor;
|
|
243
|
+
hash;
|
|
244
|
+
address;
|
|
245
|
+
constructor(version, networkId) {
|
|
246
|
+
this.version = version;
|
|
247
|
+
this.networkId = networkId;
|
|
248
|
+
this.cbor = "";
|
|
249
|
+
this.hash = "";
|
|
250
|
+
this.address = "";
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Initialize the withdrawal blueprint, with the same parameters to `applyParamsToScript`
|
|
254
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
255
|
+
* @param params The parameters to apply, in an array.
|
|
256
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
257
|
+
* @returns The withdrawal blueprint object
|
|
258
|
+
*/
|
|
259
|
+
paramScript(compiledCode, params, paramsType = "Mesh") {
|
|
260
|
+
const cbor = applyParamsToScript2(compiledCode, params, paramsType);
|
|
261
|
+
const hash = resolveScriptHash(cbor, this.version);
|
|
262
|
+
this.address = serializeRewardAddress(hash, true, this.networkId);
|
|
263
|
+
this.hash = hash;
|
|
264
|
+
this.cbor = cbor;
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Initialize the withdrawal blueprint, with no parameters
|
|
269
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
270
|
+
* @returns The withdrawal blueprint object
|
|
271
|
+
*/
|
|
272
|
+
noParamScript(compiledCode) {
|
|
273
|
+
return this.paramScript(compiledCode, []);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
138
276
|
|
|
139
277
|
// src/index.ts
|
|
140
278
|
__reExport(index_exports, require("@meshsdk/common"), module.exports);
|
|
@@ -145,6 +283,9 @@ __reExport(index_exports, require("@meshsdk/wallet"), module.exports);
|
|
|
145
283
|
var import_core_cst = require("@meshsdk/core-cst");
|
|
146
284
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
285
|
0 && (module.exports = {
|
|
286
|
+
MintingBlueprint,
|
|
287
|
+
SpendingBlueprint,
|
|
288
|
+
WithdrawalBlueprint,
|
|
148
289
|
applyCborEncoding,
|
|
149
290
|
applyParamsToScript,
|
|
150
291
|
checkSignature,
|
|
@@ -170,6 +311,7 @@ var import_core_cst = require("@meshsdk/core-cst");
|
|
|
170
311
|
resolveStakeKeyHash,
|
|
171
312
|
resolveTxHash,
|
|
172
313
|
serializeAddressObj,
|
|
314
|
+
serializeData,
|
|
173
315
|
serializeNativeScript,
|
|
174
316
|
serializePlutusScript,
|
|
175
317
|
serializePoolId,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Data, NativeScript, LanguageVersion, PlutusScript, DeserializedAddress, PubKeyAddress, ScriptAddress } from '@meshsdk/common';
|
|
1
|
+
import { Data, PlutusDataType, BuilderData, NativeScript, LanguageVersion, PlutusScript, DeserializedAddress, PubKeyAddress, ScriptAddress, IMintingBlueprint, ISpendingBlueprint, IWithdrawalBlueprint } from '@meshsdk/common';
|
|
3
2
|
export * from '@meshsdk/common';
|
|
4
3
|
import * as coreCst from '@meshsdk/core-cst';
|
|
5
4
|
export { coreCst as core };
|
|
@@ -9,8 +8,24 @@ export * from '@meshsdk/provider';
|
|
|
9
8
|
export * from '@meshsdk/transaction';
|
|
10
9
|
export * from '@meshsdk/wallet';
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Apply parameters to a given CIP57 blueprint compiledCode,
|
|
13
|
+
* making it ready for use in transactions
|
|
14
|
+
*
|
|
15
|
+
* @param rawScript - The raw script CborHex from blueprint.
|
|
16
|
+
* @param params - The parameters to apply, in an array.
|
|
17
|
+
* @param type - The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
18
|
+
* @returns The double-cbor encoded script CborHex with the parameters applied.
|
|
19
|
+
*/
|
|
20
|
+
declare const applyParamsToScript: (rawScript: string, params: object[] | Data[], type?: PlutusDataType) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Apply Cbor encoding to rawScript from CIP57 blueprint compiledCode,
|
|
23
|
+
* making it ready for use in transactions
|
|
24
|
+
*
|
|
25
|
+
* @param rawScript - The raw script CborHex from blueprint.
|
|
26
|
+
* @returns The double-cbor encoded script CborHex.
|
|
27
|
+
*/
|
|
28
|
+
declare const applyCborEncoding: (rawScript: string) => string;
|
|
14
29
|
|
|
15
30
|
/**
|
|
16
31
|
* Resolve the private key from mnemonic words
|
|
@@ -29,10 +44,11 @@ declare const resolvePrivateKey: (words: string[]) => string;
|
|
|
29
44
|
declare const resolveTxHash: (txHex: string) => string;
|
|
30
45
|
/**
|
|
31
46
|
* Hash Cardano data
|
|
32
|
-
* @param
|
|
47
|
+
* @param rawData Cardano data in Mesh, JSON or CBOR type
|
|
48
|
+
* @param type The data type, either Mesh, JSON or CBOR
|
|
33
49
|
* @returns Cardano data hash
|
|
34
50
|
*/
|
|
35
|
-
declare const resolveDataHash: (
|
|
51
|
+
declare const resolveDataHash: (rawData: BuilderData["content"], type?: PlutusDataType) => string;
|
|
36
52
|
/**
|
|
37
53
|
* Hash Cardano native script
|
|
38
54
|
* @param script Cardano native script in Mesh NativeScript type
|
|
@@ -162,5 +178,122 @@ declare const serializePoolId: (hash: string) => string;
|
|
|
162
178
|
* @returns Bech32 reward address
|
|
163
179
|
*/
|
|
164
180
|
declare const serializeRewardAddress: (hash: string, isScriptHash?: boolean, networkId?: 0 | 1) => string;
|
|
181
|
+
/**
|
|
182
|
+
* Serialize the data from Mesh or JSON format into CBOR hex
|
|
183
|
+
* @param data The data in Mesh or JSON format
|
|
184
|
+
* @param type The data type. Default to be Mesh data type
|
|
185
|
+
* @returns The CBOR hex string
|
|
186
|
+
*/
|
|
187
|
+
declare const serializeData: (rawData: BuilderData["content"], type?: Omit<PlutusDataType, "CBOR">) => string;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Minting blueprint
|
|
191
|
+
* @category Blueprint
|
|
192
|
+
* @implements IMintingBlueprint
|
|
193
|
+
* @class
|
|
194
|
+
* @example
|
|
195
|
+
*
|
|
196
|
+
* const blueprint = new MintingBlueprint("V3");
|
|
197
|
+
* blueprint.paramScript("84xxxxxx", ["params"], "Mesh");
|
|
198
|
+
*
|
|
199
|
+
* const policyId = blueprint.hash;
|
|
200
|
+
* const scriptCbor = blueprint.cbor;
|
|
201
|
+
*/
|
|
202
|
+
declare class MintingBlueprint implements IMintingBlueprint {
|
|
203
|
+
version: LanguageVersion;
|
|
204
|
+
cbor: string;
|
|
205
|
+
hash: string;
|
|
206
|
+
constructor(version: LanguageVersion);
|
|
207
|
+
/**
|
|
208
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
209
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
210
|
+
* @param params The parameters to apply, in an array.
|
|
211
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
212
|
+
* @returns The minting blueprint object
|
|
213
|
+
*/
|
|
214
|
+
paramScript(compiledCode: string, params: object[] | Data[], paramsType?: PlutusDataType): this;
|
|
215
|
+
/**
|
|
216
|
+
* Initialize the minting blueprint, with no parameters
|
|
217
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
218
|
+
* @returns The minting blueprint object
|
|
219
|
+
*/
|
|
220
|
+
noParamScript(compiledCode: string): this;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Spending blueprint
|
|
225
|
+
* @category Blueprint
|
|
226
|
+
* @implements ISpendingBlueprint
|
|
227
|
+
* @class
|
|
228
|
+
* @example
|
|
229
|
+
*
|
|
230
|
+
* const blueprint = new SpendingBlueprint("V3", 0, stakeHash);
|
|
231
|
+
* blueprint.paramScript("84xxxxxx", ["params"], "Mesh");
|
|
232
|
+
*
|
|
233
|
+
* const scriptHash = blueprint.hash;
|
|
234
|
+
* const scriptCbor = blueprint.cbor;
|
|
235
|
+
* const scriptAddress = blueprint.address;
|
|
236
|
+
*/
|
|
237
|
+
declare class SpendingBlueprint implements ISpendingBlueprint {
|
|
238
|
+
version: LanguageVersion;
|
|
239
|
+
networkId: number;
|
|
240
|
+
cbor: string;
|
|
241
|
+
hash: string;
|
|
242
|
+
address: string;
|
|
243
|
+
stakeHash?: string;
|
|
244
|
+
isStakeScriptCredential: boolean;
|
|
245
|
+
constructor(version: LanguageVersion, networkId: number, stakeHash: string, isStakeScriptCredential?: boolean);
|
|
246
|
+
/**
|
|
247
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
248
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
249
|
+
* @param params The parameters to apply, in an array.
|
|
250
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
251
|
+
* @returns
|
|
252
|
+
*/
|
|
253
|
+
paramScript(compiledCode: string, params: object[] | Data[], paramsType?: PlutusDataType): this;
|
|
254
|
+
/**
|
|
255
|
+
* Initialize the minting blueprint, with no parameters
|
|
256
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
257
|
+
* @returns The minting blueprint object
|
|
258
|
+
*/
|
|
259
|
+
noParamScript(compiledCode: string): this;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Withdrawal blueprint
|
|
264
|
+
* @category Blueprint
|
|
265
|
+
* @implements IWithdrawalBlueprint
|
|
266
|
+
* @class
|
|
267
|
+
* @example
|
|
268
|
+
*
|
|
269
|
+
* const blueprint = new WithdrawalBlueprint("V3", 0);
|
|
270
|
+
* blueprint.paramScript("84xxxxxx", ["params"], "Mesh");
|
|
271
|
+
*
|
|
272
|
+
* const scriptHash = blueprint.hash;
|
|
273
|
+
* const scriptCbor = blueprint.cbor;
|
|
274
|
+
* const rewardAddress = blueprint.address;
|
|
275
|
+
*/
|
|
276
|
+
declare class WithdrawalBlueprint implements IWithdrawalBlueprint {
|
|
277
|
+
version: LanguageVersion;
|
|
278
|
+
networkId: number;
|
|
279
|
+
cbor: string;
|
|
280
|
+
hash: string;
|
|
281
|
+
address: string;
|
|
282
|
+
constructor(version: LanguageVersion, networkId: number);
|
|
283
|
+
/**
|
|
284
|
+
* Initialize the withdrawal blueprint, with the same parameters to `applyParamsToScript`
|
|
285
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
286
|
+
* @param params The parameters to apply, in an array.
|
|
287
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
288
|
+
* @returns The withdrawal blueprint object
|
|
289
|
+
*/
|
|
290
|
+
paramScript(compiledCode: string, params: object[] | Data[], paramsType?: PlutusDataType): this;
|
|
291
|
+
/**
|
|
292
|
+
* Initialize the withdrawal blueprint, with no parameters
|
|
293
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
294
|
+
* @returns The withdrawal blueprint object
|
|
295
|
+
*/
|
|
296
|
+
noParamScript(compiledCode: string): this;
|
|
297
|
+
}
|
|
165
298
|
|
|
166
|
-
export { applyCborEncoding, applyParamsToScript, deserializeAddress, deserializeDatum, deserializePoolId, resolveDataHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHash, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, serializeAddressObj, serializeNativeScript, serializePlutusScript, serializePoolId, serializeRewardAddress };
|
|
299
|
+
export { MintingBlueprint, SpendingBlueprint, WithdrawalBlueprint, applyCborEncoding, applyParamsToScript, deserializeAddress, deserializeDatum, deserializePoolId, resolveDataHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHash, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, serializeAddressObj, serializeData, serializeNativeScript, serializePlutusScript, serializePoolId, serializeRewardAddress };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Data, NativeScript, LanguageVersion, PlutusScript, DeserializedAddress, PubKeyAddress, ScriptAddress } from '@meshsdk/common';
|
|
1
|
+
import { Data, PlutusDataType, BuilderData, NativeScript, LanguageVersion, PlutusScript, DeserializedAddress, PubKeyAddress, ScriptAddress, IMintingBlueprint, ISpendingBlueprint, IWithdrawalBlueprint } from '@meshsdk/common';
|
|
3
2
|
export * from '@meshsdk/common';
|
|
4
3
|
import * as coreCst from '@meshsdk/core-cst';
|
|
5
4
|
export { coreCst as core };
|
|
@@ -9,8 +8,24 @@ export * from '@meshsdk/provider';
|
|
|
9
8
|
export * from '@meshsdk/transaction';
|
|
10
9
|
export * from '@meshsdk/wallet';
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Apply parameters to a given CIP57 blueprint compiledCode,
|
|
13
|
+
* making it ready for use in transactions
|
|
14
|
+
*
|
|
15
|
+
* @param rawScript - The raw script CborHex from blueprint.
|
|
16
|
+
* @param params - The parameters to apply, in an array.
|
|
17
|
+
* @param type - The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
18
|
+
* @returns The double-cbor encoded script CborHex with the parameters applied.
|
|
19
|
+
*/
|
|
20
|
+
declare const applyParamsToScript: (rawScript: string, params: object[] | Data[], type?: PlutusDataType) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Apply Cbor encoding to rawScript from CIP57 blueprint compiledCode,
|
|
23
|
+
* making it ready for use in transactions
|
|
24
|
+
*
|
|
25
|
+
* @param rawScript - The raw script CborHex from blueprint.
|
|
26
|
+
* @returns The double-cbor encoded script CborHex.
|
|
27
|
+
*/
|
|
28
|
+
declare const applyCborEncoding: (rawScript: string) => string;
|
|
14
29
|
|
|
15
30
|
/**
|
|
16
31
|
* Resolve the private key from mnemonic words
|
|
@@ -29,10 +44,11 @@ declare const resolvePrivateKey: (words: string[]) => string;
|
|
|
29
44
|
declare const resolveTxHash: (txHex: string) => string;
|
|
30
45
|
/**
|
|
31
46
|
* Hash Cardano data
|
|
32
|
-
* @param
|
|
47
|
+
* @param rawData Cardano data in Mesh, JSON or CBOR type
|
|
48
|
+
* @param type The data type, either Mesh, JSON or CBOR
|
|
33
49
|
* @returns Cardano data hash
|
|
34
50
|
*/
|
|
35
|
-
declare const resolveDataHash: (
|
|
51
|
+
declare const resolveDataHash: (rawData: BuilderData["content"], type?: PlutusDataType) => string;
|
|
36
52
|
/**
|
|
37
53
|
* Hash Cardano native script
|
|
38
54
|
* @param script Cardano native script in Mesh NativeScript type
|
|
@@ -162,5 +178,122 @@ declare const serializePoolId: (hash: string) => string;
|
|
|
162
178
|
* @returns Bech32 reward address
|
|
163
179
|
*/
|
|
164
180
|
declare const serializeRewardAddress: (hash: string, isScriptHash?: boolean, networkId?: 0 | 1) => string;
|
|
181
|
+
/**
|
|
182
|
+
* Serialize the data from Mesh or JSON format into CBOR hex
|
|
183
|
+
* @param data The data in Mesh or JSON format
|
|
184
|
+
* @param type The data type. Default to be Mesh data type
|
|
185
|
+
* @returns The CBOR hex string
|
|
186
|
+
*/
|
|
187
|
+
declare const serializeData: (rawData: BuilderData["content"], type?: Omit<PlutusDataType, "CBOR">) => string;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Minting blueprint
|
|
191
|
+
* @category Blueprint
|
|
192
|
+
* @implements IMintingBlueprint
|
|
193
|
+
* @class
|
|
194
|
+
* @example
|
|
195
|
+
*
|
|
196
|
+
* const blueprint = new MintingBlueprint("V3");
|
|
197
|
+
* blueprint.paramScript("84xxxxxx", ["params"], "Mesh");
|
|
198
|
+
*
|
|
199
|
+
* const policyId = blueprint.hash;
|
|
200
|
+
* const scriptCbor = blueprint.cbor;
|
|
201
|
+
*/
|
|
202
|
+
declare class MintingBlueprint implements IMintingBlueprint {
|
|
203
|
+
version: LanguageVersion;
|
|
204
|
+
cbor: string;
|
|
205
|
+
hash: string;
|
|
206
|
+
constructor(version: LanguageVersion);
|
|
207
|
+
/**
|
|
208
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
209
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
210
|
+
* @param params The parameters to apply, in an array.
|
|
211
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
212
|
+
* @returns The minting blueprint object
|
|
213
|
+
*/
|
|
214
|
+
paramScript(compiledCode: string, params: object[] | Data[], paramsType?: PlutusDataType): this;
|
|
215
|
+
/**
|
|
216
|
+
* Initialize the minting blueprint, with no parameters
|
|
217
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
218
|
+
* @returns The minting blueprint object
|
|
219
|
+
*/
|
|
220
|
+
noParamScript(compiledCode: string): this;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Spending blueprint
|
|
225
|
+
* @category Blueprint
|
|
226
|
+
* @implements ISpendingBlueprint
|
|
227
|
+
* @class
|
|
228
|
+
* @example
|
|
229
|
+
*
|
|
230
|
+
* const blueprint = new SpendingBlueprint("V3", 0, stakeHash);
|
|
231
|
+
* blueprint.paramScript("84xxxxxx", ["params"], "Mesh");
|
|
232
|
+
*
|
|
233
|
+
* const scriptHash = blueprint.hash;
|
|
234
|
+
* const scriptCbor = blueprint.cbor;
|
|
235
|
+
* const scriptAddress = blueprint.address;
|
|
236
|
+
*/
|
|
237
|
+
declare class SpendingBlueprint implements ISpendingBlueprint {
|
|
238
|
+
version: LanguageVersion;
|
|
239
|
+
networkId: number;
|
|
240
|
+
cbor: string;
|
|
241
|
+
hash: string;
|
|
242
|
+
address: string;
|
|
243
|
+
stakeHash?: string;
|
|
244
|
+
isStakeScriptCredential: boolean;
|
|
245
|
+
constructor(version: LanguageVersion, networkId: number, stakeHash: string, isStakeScriptCredential?: boolean);
|
|
246
|
+
/**
|
|
247
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
248
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
249
|
+
* @param params The parameters to apply, in an array.
|
|
250
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
251
|
+
* @returns
|
|
252
|
+
*/
|
|
253
|
+
paramScript(compiledCode: string, params: object[] | Data[], paramsType?: PlutusDataType): this;
|
|
254
|
+
/**
|
|
255
|
+
* Initialize the minting blueprint, with no parameters
|
|
256
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
257
|
+
* @returns The minting blueprint object
|
|
258
|
+
*/
|
|
259
|
+
noParamScript(compiledCode: string): this;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Withdrawal blueprint
|
|
264
|
+
* @category Blueprint
|
|
265
|
+
* @implements IWithdrawalBlueprint
|
|
266
|
+
* @class
|
|
267
|
+
* @example
|
|
268
|
+
*
|
|
269
|
+
* const blueprint = new WithdrawalBlueprint("V3", 0);
|
|
270
|
+
* blueprint.paramScript("84xxxxxx", ["params"], "Mesh");
|
|
271
|
+
*
|
|
272
|
+
* const scriptHash = blueprint.hash;
|
|
273
|
+
* const scriptCbor = blueprint.cbor;
|
|
274
|
+
* const rewardAddress = blueprint.address;
|
|
275
|
+
*/
|
|
276
|
+
declare class WithdrawalBlueprint implements IWithdrawalBlueprint {
|
|
277
|
+
version: LanguageVersion;
|
|
278
|
+
networkId: number;
|
|
279
|
+
cbor: string;
|
|
280
|
+
hash: string;
|
|
281
|
+
address: string;
|
|
282
|
+
constructor(version: LanguageVersion, networkId: number);
|
|
283
|
+
/**
|
|
284
|
+
* Initialize the withdrawal blueprint, with the same parameters to `applyParamsToScript`
|
|
285
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
286
|
+
* @param params The parameters to apply, in an array.
|
|
287
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
288
|
+
* @returns The withdrawal blueprint object
|
|
289
|
+
*/
|
|
290
|
+
paramScript(compiledCode: string, params: object[] | Data[], paramsType?: PlutusDataType): this;
|
|
291
|
+
/**
|
|
292
|
+
* Initialize the withdrawal blueprint, with no parameters
|
|
293
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
294
|
+
* @returns The withdrawal blueprint object
|
|
295
|
+
*/
|
|
296
|
+
noParamScript(compiledCode: string): this;
|
|
297
|
+
}
|
|
165
298
|
|
|
166
|
-
export { applyCborEncoding, applyParamsToScript, deserializeAddress, deserializeDatum, deserializePoolId, resolveDataHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHash, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, serializeAddressObj, serializeNativeScript, serializePlutusScript, serializePoolId, serializeRewardAddress };
|
|
299
|
+
export { MintingBlueprint, SpendingBlueprint, WithdrawalBlueprint, applyCborEncoding, applyParamsToScript, deserializeAddress, deserializeDatum, deserializePoolId, resolveDataHash, resolveNativeScriptAddress, resolveNativeScriptHash, resolveNativeScriptHex, resolvePaymentKeyHash, resolvePlutusScriptAddress, resolvePlutusScriptHash, resolvePoolId, resolvePrivateKey, resolveRewardAddress, resolveScriptHash, resolveScriptHashDRepId, resolveScriptRef, resolveStakeKeyHash, resolveTxHash, serializeAddressObj, serializeData, serializeNativeScript, serializePlutusScript, serializePoolId, serializeRewardAddress };
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// src/core.ts
|
|
2
2
|
import * as core from "@meshsdk/core-cst";
|
|
3
|
-
var applyParamsToScript2 = core.applyParamsToScript;
|
|
4
|
-
var applyCborEncoding = (
|
|
3
|
+
var applyParamsToScript2 = (rawScript, params, type) => core.applyParamsToScript(rawScript, params, type);
|
|
4
|
+
var applyCborEncoding = (rawScript) => {
|
|
5
5
|
return Buffer.from(
|
|
6
|
-
core.applyEncoding(Buffer.from(
|
|
6
|
+
core.applyEncoding(Buffer.from(rawScript, "hex"), "SingleCBOR")
|
|
7
7
|
).toString("hex");
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// src/utils/resolver.ts
|
|
11
11
|
var resolvePrivateKey = (words) => core.resolvePrivateKey(words);
|
|
12
12
|
var resolveTxHash = (txHex) => core.resolveTxHash(txHex);
|
|
13
|
-
var resolveDataHash = (
|
|
13
|
+
var resolveDataHash = (rawData, type = "Mesh") => core.resolveDataHash(rawData, type);
|
|
14
14
|
var resolveNativeScriptHash = (script) => core.resolveNativeScriptHash(script);
|
|
15
15
|
var resolveScriptHash = (scriptCode, version) => {
|
|
16
16
|
if (!version) {
|
|
@@ -69,6 +69,140 @@ var serializePoolId = (hash) => core.resolvePoolId(hash);
|
|
|
69
69
|
var serializeRewardAddress = (hash, isScriptHash = false, networkId = 0) => {
|
|
70
70
|
return isScriptHash ? core.scriptHashToRewardAddress(hash, networkId) : core.keyHashToRewardAddress(hash, networkId);
|
|
71
71
|
};
|
|
72
|
+
var serializeData = (rawData, type = "Mesh") => {
|
|
73
|
+
const serializer = new core.CardanoSDKSerializer();
|
|
74
|
+
const builderData = {
|
|
75
|
+
type,
|
|
76
|
+
content: rawData
|
|
77
|
+
};
|
|
78
|
+
return serializer.serializeData(builderData);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/utils/blueprint/minting.ts
|
|
82
|
+
var MintingBlueprint = class {
|
|
83
|
+
version;
|
|
84
|
+
cbor;
|
|
85
|
+
hash;
|
|
86
|
+
constructor(version) {
|
|
87
|
+
this.version = version;
|
|
88
|
+
this.cbor = "";
|
|
89
|
+
this.hash = "";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
93
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
94
|
+
* @param params The parameters to apply, in an array.
|
|
95
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
96
|
+
* @returns The minting blueprint object
|
|
97
|
+
*/
|
|
98
|
+
paramScript(compiledCode, params, paramsType = "Mesh") {
|
|
99
|
+
const cbor = applyParamsToScript2(compiledCode, params, paramsType);
|
|
100
|
+
const hash = resolveScriptHash(cbor, this.version);
|
|
101
|
+
this.hash = hash;
|
|
102
|
+
this.cbor = cbor;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Initialize the minting blueprint, with no parameters
|
|
107
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
108
|
+
* @returns The minting blueprint object
|
|
109
|
+
*/
|
|
110
|
+
noParamScript(compiledCode) {
|
|
111
|
+
return this.paramScript(compiledCode, []);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/utils/blueprint/spending.ts
|
|
116
|
+
var SpendingBlueprint = class {
|
|
117
|
+
version;
|
|
118
|
+
networkId;
|
|
119
|
+
cbor;
|
|
120
|
+
hash;
|
|
121
|
+
address;
|
|
122
|
+
stakeHash;
|
|
123
|
+
isStakeScriptCredential;
|
|
124
|
+
constructor(version, networkId, stakeHash, isStakeScriptCredential = false) {
|
|
125
|
+
this.version = version;
|
|
126
|
+
this.networkId = networkId;
|
|
127
|
+
this.stakeHash = stakeHash;
|
|
128
|
+
this.cbor = "";
|
|
129
|
+
this.hash = "";
|
|
130
|
+
this.address = "";
|
|
131
|
+
this.isStakeScriptCredential = isStakeScriptCredential;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Initialize the minting blueprint, with the same parameters to `applyParamsToScript`
|
|
135
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
136
|
+
* @param params The parameters to apply, in an array.
|
|
137
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
140
|
+
paramScript(compiledCode, params, paramsType = "Mesh") {
|
|
141
|
+
const cbor = applyParamsToScript2(compiledCode, params, paramsType);
|
|
142
|
+
const hash = resolveScriptHash(cbor, this.version);
|
|
143
|
+
const plutusScript = {
|
|
144
|
+
code: cbor,
|
|
145
|
+
version: this.version
|
|
146
|
+
};
|
|
147
|
+
const address = serializePlutusScript(
|
|
148
|
+
plutusScript,
|
|
149
|
+
this.stakeHash,
|
|
150
|
+
this.networkId,
|
|
151
|
+
this.isStakeScriptCredential
|
|
152
|
+
).address;
|
|
153
|
+
this.hash = hash;
|
|
154
|
+
this.cbor = cbor;
|
|
155
|
+
this.address = address;
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Initialize the minting blueprint, with no parameters
|
|
160
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
161
|
+
* @returns The minting blueprint object
|
|
162
|
+
*/
|
|
163
|
+
noParamScript(compiledCode) {
|
|
164
|
+
return this.paramScript(compiledCode, []);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/utils/blueprint/withdrawal.ts
|
|
169
|
+
var WithdrawalBlueprint = class {
|
|
170
|
+
version;
|
|
171
|
+
networkId;
|
|
172
|
+
cbor;
|
|
173
|
+
hash;
|
|
174
|
+
address;
|
|
175
|
+
constructor(version, networkId) {
|
|
176
|
+
this.version = version;
|
|
177
|
+
this.networkId = networkId;
|
|
178
|
+
this.cbor = "";
|
|
179
|
+
this.hash = "";
|
|
180
|
+
this.address = "";
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Initialize the withdrawal blueprint, with the same parameters to `applyParamsToScript`
|
|
184
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
185
|
+
* @param params The parameters to apply, in an array.
|
|
186
|
+
* @param paramsType The type of the parameters, default to be Mesh's Data type. It could also be in JSON and raw CBOR.
|
|
187
|
+
* @returns The withdrawal blueprint object
|
|
188
|
+
*/
|
|
189
|
+
paramScript(compiledCode, params, paramsType = "Mesh") {
|
|
190
|
+
const cbor = applyParamsToScript2(compiledCode, params, paramsType);
|
|
191
|
+
const hash = resolveScriptHash(cbor, this.version);
|
|
192
|
+
this.address = serializeRewardAddress(hash, true, this.networkId);
|
|
193
|
+
this.hash = hash;
|
|
194
|
+
this.cbor = cbor;
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Initialize the withdrawal blueprint, with no parameters
|
|
199
|
+
* @param compiledCode The raw script CborHex from blueprint.
|
|
200
|
+
* @returns The withdrawal blueprint object
|
|
201
|
+
*/
|
|
202
|
+
noParamScript(compiledCode) {
|
|
203
|
+
return this.paramScript(compiledCode, []);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
72
206
|
|
|
73
207
|
// src/index.ts
|
|
74
208
|
export * from "@meshsdk/common";
|
|
@@ -78,6 +212,9 @@ export * from "@meshsdk/transaction";
|
|
|
78
212
|
export * from "@meshsdk/wallet";
|
|
79
213
|
import { checkSignature, signData, generateNonce } from "@meshsdk/core-cst";
|
|
80
214
|
export {
|
|
215
|
+
MintingBlueprint,
|
|
216
|
+
SpendingBlueprint,
|
|
217
|
+
WithdrawalBlueprint,
|
|
81
218
|
applyCborEncoding,
|
|
82
219
|
applyParamsToScript2 as applyParamsToScript,
|
|
83
220
|
checkSignature,
|
|
@@ -103,6 +240,7 @@ export {
|
|
|
103
240
|
resolveStakeKeyHash,
|
|
104
241
|
resolveTxHash,
|
|
105
242
|
serializeAddressObj,
|
|
243
|
+
serializeData,
|
|
106
244
|
serializeNativeScript,
|
|
107
245
|
serializePlutusScript,
|
|
108
246
|
serializePoolId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshsdk/core",
|
|
3
|
-
"version": "1.9.0-beta.
|
|
3
|
+
"version": "1.9.0-beta.90",
|
|
4
4
|
"description": "Mesh SDK Core - https://meshjs.dev/",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"browser": "./dist/index.js",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"typescript": "^5.3.3"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@meshsdk/common": "1.9.0-beta.
|
|
37
|
-
"@meshsdk/core-cst": "1.9.0-beta.
|
|
38
|
-
"@meshsdk/provider": "1.9.0-beta.
|
|
39
|
-
"@meshsdk/react": "1.9.0-beta.
|
|
40
|
-
"@meshsdk/transaction": "1.9.0-beta.
|
|
41
|
-
"@meshsdk/wallet": "1.9.0-beta.
|
|
36
|
+
"@meshsdk/common": "1.9.0-beta.90",
|
|
37
|
+
"@meshsdk/core-cst": "1.9.0-beta.90",
|
|
38
|
+
"@meshsdk/provider": "1.9.0-beta.90",
|
|
39
|
+
"@meshsdk/react": "1.9.0-beta.90",
|
|
40
|
+
"@meshsdk/transaction": "1.9.0-beta.90",
|
|
41
|
+
"@meshsdk/wallet": "1.9.0-beta.90"
|
|
42
42
|
},
|
|
43
43
|
"prettier": "@meshsdk/configs/prettier",
|
|
44
44
|
"publishConfig": {
|
|
@@ -47,9 +47,10 @@
|
|
|
47
47
|
"license": "Apache-2.0",
|
|
48
48
|
"keywords": [
|
|
49
49
|
"cardano",
|
|
50
|
-
"ada",
|
|
51
50
|
"web3",
|
|
52
51
|
"blockchain",
|
|
53
|
-
"sdk"
|
|
52
|
+
"sdk",
|
|
53
|
+
"typescript",
|
|
54
|
+
"javascript"
|
|
54
55
|
]
|
|
55
|
-
}
|
|
56
|
+
}
|