Skip to content

Commit 899f026

Browse files
committed
feat: upgrade modules
1 parent a9fef80 commit 899f026

Some content is hidden

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

55 files changed

+2381
-1740
lines changed

packages/evolution/src/core/AddressStructure.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class AddressStructureError extends Data.TaggedError("AddressStructureErr
2525
*/
2626
export class AddressStructure extends Schema.Class<AddressStructure>("AddressStructure")({
2727
networkId: NetworkId.NetworkId,
28-
paymentCredential: Credential.Credential,
29-
stakingCredential: Schema.optional(Credential.Credential)
28+
paymentCredential: Credential.CredentialSchema,
29+
stakingCredential: Schema.optional(Credential.CredentialSchema)
3030
}) {
3131
toString(): string {
3232
const staking = this.stakingCredential ? `, stakingCredential: ${this.stakingCredential}` : ""
@@ -84,12 +84,12 @@ export const FromBytes = Schema.transformOrFail(
8484
if (fromA.length === 57) {
8585
// BaseAddress (with staking credential)
8686
const isPaymentKey = (addressTypeBits & 0b0001) === 0
87-
const paymentCredential: Credential.Credential = isPaymentKey
87+
const paymentCredential: Credential.CredentialSchema = isPaymentKey
8888
? new KeyHash.KeyHash({ hash: fromA.slice(1, 29) })
8989
: new ScriptHash.ScriptHash({ hash: fromA.slice(1, 29) })
9090

9191
const isStakeKey = (addressTypeBits & 0b0010) === 0
92-
const stakingCredential: Credential.Credential = isStakeKey
92+
const stakingCredential: Credential.CredentialSchema = isStakeKey
9393
? new KeyHash.KeyHash({ hash: fromA.slice(29, 57) })
9494
: new ScriptHash.ScriptHash({ hash: fromA.slice(29, 57) })
9595

@@ -101,7 +101,7 @@ export const FromBytes = Schema.transformOrFail(
101101
} else if (fromA.length === 29) {
102102
// EnterpriseAddress (no staking credential)
103103
const isPaymentKey = (addressTypeBits & 0b0001) === 0
104-
const paymentCredential: Credential.Credential = isPaymentKey
104+
const paymentCredential: Credential.CredentialSchema = isPaymentKey
105105
? new KeyHash.KeyHash({ hash: fromA.slice(1, 29) })
106106
: new ScriptHash.ScriptHash({ hash: fromA.slice(1, 29) })
107107

packages/evolution/src/core/AssetName.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ export class AssetName extends Schema.TaggedClass<AssetName>()("AssetName", {
3131
* @since 2.0.0
3232
* @category schemas
3333
*/
34-
export const FromBytes = Schema.transform(Schema.typeSchema(Bytes32.VariableBytesFromHex), Schema.typeSchema(AssetName), {
35-
strict: true,
36-
decode: (bytes) => new AssetName({ bytes }, { disableValidation: true }),
37-
encode: (assetName) => assetName.bytes
38-
}).annotations({
34+
export const FromBytes = Schema.transform(
35+
Schema.typeSchema(Bytes32.VariableBytesFromHex),
36+
Schema.typeSchema(AssetName),
37+
{
38+
strict: true,
39+
decode: (bytes) => new AssetName({ bytes }, { disableValidation: true }),
40+
encode: (assetName) => assetName.bytes
41+
}
42+
).annotations({
3943
identifier: "AssetName.FromBytes"
4044
})
4145

packages/evolution/src/core/AuxiliaryData.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class ConwayAuxiliaryData extends Schema.TaggedClass<ConwayAuxiliaryData>
4343
"ConwayAuxiliaryData",
4444
{
4545
metadata: Schema.optional(Metadata.Metadata),
46-
nativeScripts: Schema.optional(Schema.Array(NativeScripts.Native)),
46+
nativeScripts: Schema.optional(Schema.Array(NativeScripts.NativeScript)),
4747
plutusV1Scripts: Schema.optional(Schema.Array(PlutusV1.PlutusV1)),
4848
plutusV2Scripts: Schema.optional(Schema.Array(PlutusV2.PlutusV2)),
4949
plutusV3Scripts: Schema.optional(Schema.Array(PlutusV3.PlutusV3))
@@ -65,7 +65,7 @@ export class ShelleyMAAuxiliaryData extends Schema.TaggedClass<ShelleyMAAuxiliar
6565
"ShelleyMAAuxiliaryData",
6666
{
6767
metadata: Schema.optional(Metadata.Metadata),
68-
nativeScripts: Schema.optional(Schema.Array(NativeScripts.Native))
68+
nativeScripts: Schema.optional(Schema.Array(NativeScripts.NativeScript))
6969
}
7070
) {}
7171

@@ -240,7 +240,7 @@ export const FromCDDL = Schema.transformOrFail(AnyEraCDDL, Schema.typeSchema(Aux
240240
if (Array.isArray(input)) {
241241
const arr = input
242242
let metadata: Metadata.Metadata | undefined
243-
let nativeScripts: Array<NativeScripts.Native> | undefined
243+
let nativeScripts: Array<NativeScripts.NativeScript> | undefined
244244

245245
if (arr.length >= 1 && arr[0] !== undefined) {
246246
const m = yield* ParseResult.decodeEither(Metadata.FromCDDL)(arr[0])
@@ -325,7 +325,7 @@ export const empty = (): AuxiliaryData => new ConwayAuxiliaryData({})
325325
*/
326326
export const conway = (input: {
327327
metadata?: Metadata.Metadata
328-
nativeScripts?: Array<NativeScripts.Native>
328+
nativeScripts?: Array<NativeScripts.NativeScript>
329329
plutusV1Scripts?: Array<PlutusV1.PlutusV1>
330330
plutusV2Scripts?: Array<PlutusV2.PlutusV2>
331331
plutusV3Scripts?: Array<PlutusV3.PlutusV3>
@@ -339,7 +339,7 @@ export const conway = (input: {
339339
*/
340340
export const shelleyMA = (input: {
341341
metadata?: Metadata.Metadata
342-
nativeScripts?: Array<NativeScripts.Native>
342+
nativeScripts?: Array<NativeScripts.NativeScript>
343343
}): AuxiliaryData => new ShelleyMAAuxiliaryData({ ...input })
344344

345345
/**

packages/evolution/src/core/AuxiliaryDataHash.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ export class AuxiliaryDataHash extends Schema.TaggedClass<AuxiliaryDataHash>()("
3434
bytes: Bytes32.BytesFromHex
3535
}) {}
3636

37-
export const FromBytes = Schema.transform(Schema.typeSchema(Bytes32.BytesFromHex), Schema.typeSchema(AuxiliaryDataHash), {
38-
strict: true,
39-
decode: (bytes) => new AuxiliaryDataHash({ bytes }, { disableValidation: true }),
40-
encode: (a) => a.bytes
41-
}).annotations({
37+
export const FromBytes = Schema.transform(
38+
Schema.typeSchema(Bytes32.BytesFromHex),
39+
Schema.typeSchema(AuxiliaryDataHash),
40+
{
41+
strict: true,
42+
decode: (bytes) => new AuxiliaryDataHash({ bytes }, { disableValidation: true }),
43+
encode: (a) => a.bytes
44+
}
45+
).annotations({
4246
identifier: "AuxiliaryDataHash.FromBytes"
4347
})
4448

packages/evolution/src/core/BaseAddress.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export class BaseAddressError extends Data.TaggedError("BaseAddressError")<{
2121
*/
2222
export class BaseAddress extends Schema.TaggedClass<BaseAddress>("BaseAddress")("BaseAddress", {
2323
networkId: NetworkId.NetworkId,
24-
paymentCredential: Credential.Credential,
25-
stakeCredential: Credential.Credential
24+
paymentCredential: Credential.CredentialSchema,
25+
stakeCredential: Credential.CredentialSchema
2626
}) {
2727
toString(): string {
2828
return `BaseAddress { networkId: ${this.networkId}, paymentCredential: ${this.paymentCredential}, stakeCredential: ${this.stakeCredential} }`
@@ -57,15 +57,15 @@ export const FromBytes = Schema.transformOrFail(Bytes57.BytesSchema, Schema.type
5757
const addressType = header >> 4
5858
// Script payment, Script stake
5959
const isPaymentKey = (addressType & 0b0001) === 0
60-
const paymentCredential: Credential.Credential = isPaymentKey
60+
const paymentCredential: Credential.CredentialSchema = isPaymentKey
6161
? new KeyHash.KeyHash({
6262
hash: fromA.slice(1, 29)
6363
})
6464
: new ScriptHash.ScriptHash({
6565
hash: fromA.slice(1, 29)
6666
})
6767
const isStakeKey = (addressType & 0b0010) === 0
68-
const stakeCredential: Credential.Credential = isStakeKey
68+
const stakeCredential: Credential.CredentialSchema = isStakeKey
6969
? new KeyHash.KeyHash({
7070
hash: fromA.slice(29, 57)
7171
})

packages/evolution/src/core/BootstrapWitness.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Effect as Eff, FastCheck, ParseResult, Schema } from "effect"
22

3+
import * as Bytes32 from "./Bytes32.js"
34
import * as CBOR from "./CBOR.js"
45
import * as Ed25519Signature from "./Ed25519Signature.js"
56
import * as Function from "./Function.js"
@@ -21,12 +22,8 @@ import * as VKey from "./VKey.js"
2122
export class BootstrapWitness extends Schema.Class<BootstrapWitness>("BootstrapWitness")({
2223
publicKey: VKey.VKey,
2324
signature: Ed25519Signature.Ed25519Signature,
24-
chainCode: Schema.Uint8ArrayFromSelf.pipe(
25-
Schema.filter((bytes) => bytes.length === 32, {
26-
message: () => "Chain code must be exactly 32 bytes"
27-
})
28-
),
29-
attributes: Schema.Uint8ArrayFromSelf
25+
chainCode: Bytes32.BytesFromHex,
26+
attributes: Schema.Uint8ArrayFromHex
3027
}) {}
3128

3229
// Tuple schema as per CDDL

packages/evolution/src/core/Bytes32.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export const BytesFromHex = Schema.Uint8ArrayFromHex.pipe(Bytes.bytesLengthEqual
3131

3232
export const VariableBytesFromHex = Schema.Uint8ArrayFromHex.pipe(Bytes.bytesLengthBetween(0, BYTES_LENGTH))
3333

34-
3534
export const equals = Bytes.equals
3635

3736
// =============================================================================

packages/evolution/src/core/Bytes64.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const BYTES_LENGTH = 64
1818

1919
export const BytesFromHex = Schema.Uint8ArrayFromHex.pipe(Bytes.bytesLengthEquals(BYTES_LENGTH))
2020

21-
2221
export const VariableBytesFromHex = Schema.Uint8ArrayFromSelf.pipe(Bytes.bytesLengthBetween(0, BYTES_LENGTH))
2322

2423
// =============================================================================

packages/evolution/src/core/CBOR.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ export const CBORSchema: Schema.Schema<CBOR> = Schema.Union(
392392
Tag,
393393
Simple,
394394
Float
395-
)
395+
).annotations({ identifier: "CBOR", description: "CBOR value schema" })
396396

397397
/**
398398
* Schema for encoding/decoding CBOR bytes using internal functions

packages/evolution/src/core/Certificate.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ export class CertificateError extends Data.TaggedError("CertificateError")<{
2626
}> {}
2727

2828
export class StakeRegistration extends Schema.TaggedClass<StakeRegistration>("StakeRegistration")("StakeRegistration", {
29-
stakeCredential: Credential.Credential
29+
stakeCredential: Credential.CredentialSchema
3030
}) {}
3131

3232
export class StakeDeregistration extends Schema.TaggedClass<StakeDeregistration>("StakeDeregistration")(
3333
"StakeDeregistration",
3434
{
35-
stakeCredential: Credential.Credential
35+
stakeCredential: Credential.CredentialSchema
3636
}
3737
) {}
3838

3939
export class StakeDelegation extends Schema.TaggedClass<StakeDelegation>("StakeDelegation")("StakeDelegation", {
40-
stakeCredential: Credential.Credential,
40+
stakeCredential: Credential.CredentialSchema,
4141
poolKeyHash: PoolKeyHash.PoolKeyHash
4242
}) {}
4343

@@ -51,45 +51,45 @@ export class PoolRetirement extends Schema.TaggedClass<PoolRetirement>("PoolReti
5151
}) {}
5252

5353
export class RegCert extends Schema.TaggedClass<RegCert>("RegCert")("RegCert", {
54-
stakeCredential: Credential.Credential,
54+
stakeCredential: Credential.CredentialSchema,
5555
coin: Coin.Coin
5656
}) {}
5757

5858
export class UnregCert extends Schema.TaggedClass<UnregCert>("UnregCert")("UnregCert", {
59-
stakeCredential: Credential.Credential,
59+
stakeCredential: Credential.CredentialSchema,
6060
coin: Coin.Coin
6161
}) {}
6262

6363
export class VoteDelegCert extends Schema.TaggedClass<VoteDelegCert>("VoteDelegCert")("VoteDelegCert", {
64-
stakeCredential: Credential.Credential,
64+
stakeCredential: Credential.CredentialSchema,
6565
drep: DRep.DRep
6666
}) {}
6767

6868
export class StakeVoteDelegCert extends Schema.TaggedClass<StakeVoteDelegCert>("StakeVoteDelegCert")(
6969
"StakeVoteDelegCert",
7070
{
71-
stakeCredential: Credential.Credential,
71+
stakeCredential: Credential.CredentialSchema,
7272
poolKeyHash: PoolKeyHash.PoolKeyHash,
7373
drep: DRep.DRep
7474
}
7575
) {}
7676

7777
export class StakeRegDelegCert extends Schema.TaggedClass<StakeRegDelegCert>("StakeRegDelegCert")("StakeRegDelegCert", {
78-
stakeCredential: Credential.Credential,
78+
stakeCredential: Credential.CredentialSchema,
7979
poolKeyHash: PoolKeyHash.PoolKeyHash,
8080
coin: Coin.Coin
8181
}) {}
8282

8383
export class VoteRegDelegCert extends Schema.TaggedClass<VoteRegDelegCert>("VoteRegDelegCert")("VoteRegDelegCert", {
84-
stakeCredential: Credential.Credential,
84+
stakeCredential: Credential.CredentialSchema,
8585
drep: DRep.DRep,
8686
coin: Coin.Coin
8787
}) {}
8888

8989
export class StakeVoteRegDelegCert extends Schema.TaggedClass<StakeVoteRegDelegCert>("StakeVoteRegDelegCert")(
9090
"StakeVoteRegDelegCert",
9191
{
92-
stakeCredential: Credential.Credential,
92+
stakeCredential: Credential.CredentialSchema,
9393
poolKeyHash: PoolKeyHash.PoolKeyHash,
9494
drep: DRep.DRep,
9595
coin: Coin.Coin
@@ -99,32 +99,32 @@ export class StakeVoteRegDelegCert extends Schema.TaggedClass<StakeVoteRegDelegC
9999
export class AuthCommitteeHotCert extends Schema.TaggedClass<AuthCommitteeHotCert>("AuthCommitteeHotCert")(
100100
"AuthCommitteeHotCert",
101101
{
102-
committeeColdCredential: Credential.Credential,
103-
committeeHotCredential: Credential.Credential
102+
committeeColdCredential: Credential.CredentialSchema,
103+
committeeHotCredential: Credential.CredentialSchema
104104
}
105105
) {}
106106

107107
export class ResignCommitteeColdCert extends Schema.TaggedClass<ResignCommitteeColdCert>("ResignCommitteeColdCert")(
108108
"ResignCommitteeColdCert",
109109
{
110-
committeeColdCredential: Credential.Credential,
110+
committeeColdCredential: Credential.CredentialSchema,
111111
anchor: Schema.NullishOr(Anchor.Anchor)
112112
}
113113
) {}
114114

115115
export class RegDrepCert extends Schema.TaggedClass<RegDrepCert>("RegDrepCert")("RegDrepCert", {
116-
drepCredential: Credential.Credential,
116+
drepCredential: Credential.CredentialSchema,
117117
coin: Coin.Coin,
118118
anchor: Schema.NullishOr(Anchor.Anchor)
119119
}) {}
120120

121121
export class UnregDrepCert extends Schema.TaggedClass<UnregDrepCert>("UnregDrepCert")("UnregDrepCert", {
122-
drepCredential: Credential.Credential,
122+
drepCredential: Credential.CredentialSchema,
123123
coin: Coin.Coin
124124
}) {}
125125

126126
export class UpdateDrepCert extends Schema.TaggedClass<UpdateDrepCert>("UpdateDrepCert")("UpdateDrepCert", {
127-
drepCredential: Credential.Credential,
127+
drepCredential: Credential.CredentialSchema,
128128
anchor: Schema.NullishOr(Anchor.Anchor)
129129
}) {}
130130

0 commit comments

Comments
 (0)