Skip to content

Commit 2edb617

Browse files
Merge pull request #101 from IntersectMBO/feat/add-mint-builder
feat/add mint builder
2 parents 1678790 + aaf0882 commit 2edb617

File tree

115 files changed

+1517
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1517
-430
lines changed

.changeset/nice-tips-learn.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
"@evolution-sdk/devnet": patch
3+
"@evolution-sdk/evolution": patch
4+
---
5+
6+
### Core Module Enhancements
7+
8+
**Mint Module**
9+
- Added `Mint.getByHex()` and `Mint.getAssetsByPolicyHex()` utilities for hex-based lookups
10+
- Fixed `Mint.insert`, `removePolicy`, `removeAsset`, and `get` to use content-based equality (`Equal.equals`) instead of reference equality for PolicyId/AssetName lookups
11+
12+
**Fee Calculation**
13+
- Fixed `calculateFeeIteratively` to include mint field in fee calculation via TxContext access
14+
- Removed unnecessary 5000n fee buffer that caused fee overpayment
15+
16+
**Transaction Builder**
17+
- Added `.mint()` method to TransactionBuilder for native token minting/burning
18+
- `.attachScript()` now accepts `{ script: CoreScript }` parameter format
19+
- Improved type safety by using Core types directly instead of SDK wrappers
20+
21+
### Devnet Package
22+
23+
**Test Infrastructure**
24+
- Added `TxBuilder.Mint.test.ts` with devnet submit tests for minting and burning
25+
- Updated `TxBuilder.Scripts.test.ts` to use Core types (`PlutusV2.PlutusV2`) instead of SDK format
26+
- Refactored `createCoreTestUtxo` helper to accept Core `Script` types directly
27+
- Removed unused `createTestUtxo` (SDK format) helper
28+
- Added `Genesis.calculateUtxosFromConfig()` for retrieving initial UTxOs from genesis config
29+
- Replaced all `Buffer.from().toString("hex")` with `Text.toHex()` in tests
30+
31+
### Breaking Changes
32+
- `attachScript()` now requires `{ script: ... }` object format instead of passing script directly
33+
- Test helpers now use Core types exclusively

docs/content/docs/modules/core/Mint.mdx

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ parent: Modules
1919
- [encoding](#encoding)
2020
- [toCBORBytes](#tocborbytes)
2121
- [toCBORHex](#tocborhex)
22+
- [lookup](#lookup)
23+
- [getAssetsByPolicyHex](#getassetsbypolicyhex)
24+
- [getByHex](#getbyhex)
2225
- [model](#model)
2326
- [Mint (class)](#mint-class)
2427
- [toJSON (method)](#tojson-method)
@@ -42,11 +45,11 @@ parent: Modules
4245
- [get](#get)
4346
- [insert](#insert)
4447
- [policyCount](#policycount)
48+
- [removeAsset](#removeasset)
4549
- [removePolicy](#removepolicy)
4650
- [utils](#utils)
4751
- [AssetMap (type alias)](#assetmap-type-alias)
4852
- [CDDLSchema](#cddlschema)
49-
- [removeAsset](#removeasset)
5053

5154
---
5255

@@ -134,6 +137,41 @@ export declare const toCBORHex: (mint: Mint, options?: CBOR.CodecOptions) => str
134137
135138
Added in v2.0.0
136139
140+
# lookup
141+
142+
## getAssetsByPolicyHex
143+
144+
Get the asset map for a specific policy by hex string.
145+
Uses content-based equality (Equal.equals) to find matching PolicyId.
146+
147+
**Signature**
148+
149+
```ts
150+
export declare const getAssetsByPolicyHex: (
151+
mint: Mint,
152+
policyIdHex: string
153+
) => Map<AssetName.AssetName, NonZeroInt64.NonZeroInt64> | undefined
154+
```
155+
156+
Added in v2.0.0
157+
158+
## getByHex
159+
160+
Get an asset amount by policy ID hex and asset name hex strings.
161+
Convenience function for tests and lookups using hex strings.
162+
163+
**Signature**
164+
165+
```ts
166+
export declare const getByHex: (
167+
mint: Mint,
168+
policyIdHex: string,
169+
assetNameHex: string
170+
) => NonZeroInt64.NonZeroInt64 | undefined
171+
```
172+
173+
Added in v2.0.0
174+
137175
# model
138176
139177
## Mint (class)
@@ -393,6 +431,7 @@ Added in v2.0.0
393431
## get
394432
395433
Get the amount for a specific policy and asset.
434+
Uses content-based equality (Equal.equals) to find matching PolicyId and AssetName.
396435
397436
**Signature**
398437
@@ -409,6 +448,8 @@ Added in v2.0.0
409448
## insert
410449
411450
Add or update an asset in the Mint.
451+
Uses content-based equality (Equal.equals) to find matching PolicyId and AssetName
452+
since JavaScript Maps use reference equality by default.
412453
413454
**Signature**
414455
@@ -435,9 +476,23 @@ export declare const policyCount: (mint: Mint) => number
435476
436477
Added in v2.0.0
437478
438-
## removePolicy
479+
## removeAsset
439480
440481
Remove an asset from the Mint.
482+
Uses content-based equality (Equal.equals) to find matching PolicyId and AssetName.
483+
484+
**Signature**
485+
486+
```ts
487+
export declare const removeAsset: (mint: Mint, policyId: PolicyId.PolicyId, assetName: AssetName.AssetName) => Mint
488+
```
489+
490+
Added in v2.0.0
491+
492+
## removePolicy
493+
494+
Remove a policy from the Mint.
495+
Uses content-based equality (Equal.equals) to find matching PolicyId.
441496
442497
**Signature**
443498
@@ -467,11 +522,3 @@ export declare const CDDLSchema: Schema.MapFromSelf<
467522
Schema.MapFromSelf<typeof Schema.Uint8ArrayFromSelf, typeof Schema.BigIntFromSelf>
468523
>
469524
```
470-
471-
## removeAsset
472-
473-
**Signature**
474-
475-
```ts
476-
export declare const removeAsset: (mint: Mint, policyId: PolicyId.PolicyId, assetName: AssetName.AssetName) => Mint
477-
```

docs/content/docs/modules/core/NativeScripts.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ parent: Modules
4141
- [NativeScriptVariants](#nativescriptvariants)
4242
- [testing](#testing)
4343
- [arbitrary](#arbitrary)
44+
- [utilities](#utilities)
45+
- [countRequiredSigners](#countrequiredsigners)
4446
- [utils](#utils)
4547
- [CDDLSchema](#cddlschema)
4648
- [FromCBORBytes](#fromcborbytes-1)
@@ -349,6 +351,29 @@ export declare const arbitrary: FastCheck.Arbitrary<NativeScript>
349351

350352
Added in v2.0.0
351353

354+
# utilities
355+
356+
## countRequiredSigners
357+
358+
Count the maximum number of key hashes (signers) required to satisfy a native script.
359+
This is used for fee calculation to ensure the fake witness set has the correct size.
360+
361+
Algorithm:
362+
363+
- ScriptPubKey: 1 signer required
364+
- ScriptAll: sum of all nested scripts (all must be satisfied)
365+
- ScriptAny: maximum of nested scripts (pessimistic - assume most expensive path)
366+
- ScriptNOfK: sum of top N most expensive nested scripts
367+
- InvalidBefore/InvalidHereafter: 0 signers (time-based only)
368+
369+
**Signature**
370+
371+
```ts
372+
export declare const countRequiredSigners: (script: NativeScriptVariants) => number
373+
```
374+
375+
Added in v2.0.0
376+
352377
# utils
353378

354379
## CDDLSchema

docs/content/docs/modules/sdk/Credential.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sdk/Credential.ts
3-
nav_order: 175
3+
nav_order: 176
44
parent: Modules
55
---
66

docs/content/docs/modules/sdk/Datum.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sdk/Datum.ts
3-
nav_order: 176
3+
nav_order: 177
44
parent: Modules
55
---
66

docs/content/docs/modules/sdk/Delegation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sdk/Delegation.ts
3-
nav_order: 177
3+
nav_order: 178
44
parent: Modules
55
---
66

docs/content/docs/modules/sdk/EvalRedeemer.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sdk/EvalRedeemer.ts
3-
nav_order: 178
3+
nav_order: 179
44
parent: Modules
55
---
66

docs/content/docs/modules/sdk/Network.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sdk/Network.ts
3-
nav_order: 179
3+
nav_order: 180
44
parent: Modules
55
---
66

docs/content/docs/modules/sdk/OutRef.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sdk/OutRef.ts
3-
nav_order: 180
3+
nav_order: 181
44
parent: Modules
55
---
66

docs/content/docs/modules/sdk/PolicyId.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: sdk/PolicyId.ts
3-
nav_order: 181
3+
nav_order: 182
44
parent: Modules
55
---
66

0 commit comments

Comments
 (0)