diff --git a/rust/pkg/cardano_serialization_lib.js.flow b/rust/pkg/cardano_serialization_lib.js.flow index 85e423d5..ba623ef2 100644 --- a/rust/pkg/cardano_serialization_lib.js.flow +++ b/rust/pkg/cardano_serialization_lib.js.flow @@ -17,6 +17,30 @@ declare export function create_send_all( config: TransactionBuilderConfig ): TransactionBatchList; +/** + * @param {string} password + * @param {string} salt + * @param {string} nonce + * @param {string} data + * @returns {string} + */ +declare export function encrypt_with_password( + password: string, + salt: string, + nonce: string, + data: string +): string; + +/** + * @param {string} password + * @param {string} data + * @returns {string} + */ +declare export function decrypt_with_password( + password: string, + data: string +): string; + /** * @param {Transaction} tx * @param {LinearFee} linear_fee @@ -54,6 +78,70 @@ declare export function min_ref_script_fee( ref_script_coins_per_byte: UnitInterval ): BigNum; +/** + * @param {string} json + * @param {$Values< + typeof + PlutusDatumSchema>} schema + * @returns {PlutusData} + */ +declare export function encode_json_str_to_plutus_datum( + json: string, + schema: $Values +): PlutusData; + +/** + * @param {PlutusData} datum + * @param {$Values< + typeof + PlutusDatumSchema>} schema + * @returns {string} + */ +declare export function decode_plutus_datum_to_json_str( + datum: PlutusData, + schema: $Values +): string; + +/** + * @param {Uint8Array} bytes + * @returns {TransactionMetadatum} + */ +declare export function encode_arbitrary_bytes_as_metadatum( + bytes: Uint8Array +): TransactionMetadatum; + +/** + * @param {TransactionMetadatum} metadata + * @returns {Uint8Array} + */ +declare export function decode_arbitrary_bytes_from_metadatum( + metadata: TransactionMetadatum +): Uint8Array; + +/** + * @param {string} json + * @param {$Values< + typeof + MetadataJsonSchema>} schema + * @returns {TransactionMetadatum} + */ +declare export function encode_json_str_to_metadatum( + json: string, + schema: $Values +): TransactionMetadatum; + +/** + * @param {TransactionMetadatum} metadatum + * @param {$Values< + typeof + MetadataJsonSchema>} schema + * @returns {string} + */ +declare export function decode_metadatum_to_json_str( + metadatum: TransactionMetadatum, + schema: $Values +): string; + /** * @param {TransactionHash} tx_body_hash * @param {ByronAddress} addr @@ -180,216 +268,148 @@ declare export function encode_json_str_to_native_script( ): NativeScript; /** - * @param {string} password - * @param {string} salt - * @param {string} nonce - * @param {string} data - * @returns {string} - */ -declare export function encrypt_with_password( - password: string, - salt: string, - nonce: string, - data: string -): string; - -/** - * @param {string} password - * @param {string} data - * @returns {string} - */ -declare export function decrypt_with_password( - password: string, - data: string -): string; - -/** - * @param {string} json - * @param {$Values< - typeof - PlutusDatumSchema>} schema - * @returns {PlutusData} - */ -declare export function encode_json_str_to_plutus_datum( - json: string, - schema: $Values -): PlutusData; - -/** - * @param {PlutusData} datum - * @param {$Values< - typeof - PlutusDatumSchema>} schema - * @returns {string} - */ -declare export function decode_plutus_datum_to_json_str( - datum: PlutusData, - schema: $Values -): string; - -/** - * @param {Uint8Array} bytes - * @returns {TransactionMetadatum} */ -declare export function encode_arbitrary_bytes_as_metadatum( - bytes: Uint8Array -): TransactionMetadatum; -/** - * @param {TransactionMetadatum} metadata - * @returns {Uint8Array} - */ -declare export function decode_arbitrary_bytes_from_metadatum( - metadata: TransactionMetadatum -): Uint8Array; +declare export var MetadataJsonSchema: {| + +NoConversions: 0, // 0 + +BasicConversions: 1, // 1 + +DetailedSchema: 2, // 2 +|}; /** - * @param {string} json - * @param {$Values< - typeof - MetadataJsonSchema>} schema - * @returns {TransactionMetadatum} */ -declare export function encode_json_str_to_metadatum( - json: string, - schema: $Values -): TransactionMetadatum; -/** - * @param {TransactionMetadatum} metadatum - * @param {$Values< - typeof - MetadataJsonSchema>} schema - * @returns {string} - */ -declare export function decode_metadatum_to_json_str( - metadatum: TransactionMetadatum, - schema: $Values -): string; +declare export var VoterKind: {| + +ConstitutionalCommitteeHotKeyHash: 0, // 0 + +ConstitutionalCommitteeHotScriptHash: 1, // 1 + +DRepKeyHash: 2, // 2 + +DRepScriptHash: 3, // 3 + +StakingPoolKeyHash: 4, // 4 +|}; /** - * Each new language uses a different namespace for hashing its script - * This is because you could have a language where the same bytes have different semantics - * So this avoids scripts in different languages mapping to the same hash - * Note that the enum value here is different than the enum value for deciding the cost model of a script */ -declare export var ScriptHashNamespace: {| - +NativeScript: 0, // 0 - +PlutusScript: 1, // 1 - +PlutusScriptV2: 2, // 2 - +PlutusScriptV3: 3, // 3 +declare export var CoinSelectionStrategyCIP2: {| + +LargestFirst: 0, // 0 + +RandomImprove: 1, // 1 + +LargestFirstMultiAsset: 2, // 2 + +RandomImproveMultiAsset: 3, // 3 |}; /** */ -declare export var PlutusDataKind: {| - +ConstrPlutusData: 0, // 0 - +Map: 1, // 1 - +List: 2, // 2 - +Integer: 3, // 3 - +Bytes: 4, // 4 +declare export var NetworkIdKind: {| + +Testnet: 0, // 0 + +Mainnet: 1, // 1 |}; /** - * JSON <-> PlutusData conversion schemas. - * Follows ScriptDataJsonSchema in cardano-cli defined at: - * https://github.com/input-output-hk/cardano-node/blob/master/cardano-api/src/Cardano/Api/ScriptData.hs#L254 - * - * All methods here have the following restrictions due to limitations on dependencies: - * * JSON numbers above u64::MAX (positive) or below i64::MIN (negative) will throw errors - * * Hex strings for bytes don't accept odd-length (half-byte) strings. - * cardano-cli seems to support these however but it seems to be different than just 0-padding - * on either side when tested so proceed with caution */ -declare export var PlutusDatumSchema: {| - +BasicConversions: 0, // 0 - +DetailedSchema: 1, // 1 +declare export var NativeScriptKind: {| + +ScriptPubkey: 0, // 0 + +ScriptAll: 1, // 1 + +ScriptAny: 2, // 2 + +ScriptNOfK: 3, // 3 + +TimelockStart: 4, // 4 + +TimelockExpiry: 5, // 5 |}; /** */ -declare export var TransactionMetadatumKind: {| - +MetadataMap: 0, // 0 - +MetadataList: 1, // 1 - +Int: 2, // 2 - +Bytes: 3, // 3 - +Text: 4, // 4 +declare export var VoteKind: {| + +No: 0, // 0 + +Yes: 1, // 1 + +Abstain: 2, // 2 |}; /** */ -declare export var DRepKind: {| - +KeyHash: 0, // 0 - +ScriptHash: 1, // 1 - +AlwaysAbstain: 2, // 2 - +AlwaysNoConfidence: 3, // 3 +declare export var CertificateKind: {| + +StakeRegistration: 0, // 0 + +StakeDeregistration: 1, // 1 + +StakeDelegation: 2, // 2 + +PoolRegistration: 3, // 3 + +PoolRetirement: 4, // 4 + +GenesisKeyDelegation: 5, // 5 + +MoveInstantaneousRewardsCert: 6, // 6 + +CommitteeHotAuth: 7, // 7 + +CommitteeColdResign: 8, // 8 + +DRepDeregistration: 9, // 9 + +DRepRegistration: 10, // 10 + +DRepUpdate: 11, // 11 + +StakeAndVoteDelegation: 12, // 12 + +StakeRegistrationAndDelegation: 13, // 13 + +StakeVoteRegistrationAndDelegation: 14, // 14 + +VoteDelegation: 15, // 15 + +VoteRegistrationAndDelegation: 16, // 16 |}; /** */ -declare export var NetworkIdKind: {| - +Testnet: 0, // 0 - +Mainnet: 1, // 1 +declare export var AddressKind: {| + +Base: 0, // 0 + +Pointer: 1, // 1 + +Enterprise: 2, // 2 + +Reward: 3, // 3 + +Byron: 4, // 4 + +Malformed: 5, // 5 |}; /** + * Each new language uses a different namespace for hashing its script + * This is because you could have a language where the same bytes have different semantics + * So this avoids scripts in different languages mapping to the same hash + * Note that the enum value here is different than the enum value for deciding the cost model of a script */ -declare export var NativeScriptKind: {| - +ScriptPubkey: 0, // 0 - +ScriptAll: 1, // 1 - +ScriptAny: 2, // 2 - +ScriptNOfK: 3, // 3 - +TimelockStart: 4, // 4 - +TimelockExpiry: 5, // 5 +declare export var ScriptHashNamespace: {| + +NativeScript: 0, // 0 + +PlutusScript: 1, // 1 + +PlutusScriptV2: 2, // 2 + +PlutusScriptV3: 3, // 3 |}; /** */ -declare export var GovernanceActionKind: {| - +ParameterChangeAction: 0, // 0 - +HardForkInitiationAction: 1, // 1 - +TreasuryWithdrawalsAction: 2, // 2 - +NoConfidenceAction: 3, // 3 - +UpdateCommitteeAction: 4, // 4 - +NewConstitutionAction: 5, // 5 - +InfoAction: 6, // 6 +declare export var LanguageKind: {| + +PlutusV1: 0, // 0 + +PlutusV2: 1, // 1 + +PlutusV3: 2, // 2 |}; /** */ -declare export var VoterKind: {| - +ConstitutionalCommitteeHotKeyHash: 0, // 0 - +ConstitutionalCommitteeHotScriptHash: 1, // 1 - +DRepKeyHash: 2, // 2 - +DRepScriptHash: 3, // 3 - +StakingPoolKeyHash: 4, // 4 +declare export var MIRPot: {| + +Reserves: 0, // 0 + +Treasury: 1, // 1 |}; /** + * Used to choosed the schema for a script JSON string */ -declare export var LanguageKind: {| - +PlutusV1: 0, // 0 - +PlutusV2: 1, // 1 - +PlutusV3: 2, // 2 +declare export var ScriptSchema: {| + +Wallet: 0, // 0 + +Node: 1, // 1 |}; /** */ -declare export var RelayKind: {| - +SingleHostAddr: 0, // 0 - +SingleHostName: 1, // 1 - +MultiHostName: 2, // 2 +declare export var TransactionMetadatumKind: {| + +MetadataMap: 0, // 0 + +MetadataList: 1, // 1 + +Int: 2, // 2 + +Bytes: 3, // 3 + +Text: 4, // 4 |}; /** @@ -403,18 +423,22 @@ declare export var CborContainerType: {| /** */ -declare export var VoteKind: {| - +No: 0, // 0 - +Yes: 1, // 1 - +Abstain: 2, // 2 +declare export var PlutusDataKind: {| + +ConstrPlutusData: 0, // 0 + +Map: 1, // 1 + +List: 2, // 2 + +Integer: 3, // 3 + +Bytes: 4, // 4 |}; /** */ -declare export var MIRKind: {| - +ToOtherPot: 0, // 0 - +ToStakeCredentials: 1, // 1 +declare export var DRepKind: {| + +KeyHash: 0, // 0 + +ScriptHash: 1, // 1 + +AlwaysAbstain: 2, // 2 + +AlwaysNoConfidence: 3, // 3 |}; /** @@ -425,29 +449,6 @@ declare export var CredKind: {| +Script: 1, // 1 |}; -/** - */ - -declare export var CertificateKind: {| - +StakeRegistration: 0, // 0 - +StakeDeregistration: 1, // 1 - +StakeDelegation: 2, // 2 - +PoolRegistration: 3, // 3 - +PoolRetirement: 4, // 4 - +GenesisKeyDelegation: 5, // 5 - +MoveInstantaneousRewardsCert: 6, // 6 - +CommitteeHotAuth: 7, // 7 - +CommitteeColdResign: 8, // 8 - +DRepDeregistration: 9, // 9 - +DRepRegistration: 10, // 10 - +DRepUpdate: 11, // 11 - +StakeAndVoteDelegation: 12, // 12 - +StakeRegistrationAndDelegation: 13, // 13 - +StakeVoteRegistrationAndDelegation: 14, // 14 - +VoteDelegation: 15, // 15 - +VoteRegistrationAndDelegation: 16, // 16 -|}; - /** */ @@ -465,39 +466,40 @@ declare export var BlockEra: {| /** */ -declare export var MIRPot: {| - +Reserves: 0, // 0 - +Treasury: 1, // 1 -|}; - -/** - */ - -declare export var MetadataJsonSchema: {| - +NoConversions: 0, // 0 - +BasicConversions: 1, // 1 - +DetailedSchema: 2, // 2 +declare export var GovernanceActionKind: {| + +ParameterChangeAction: 0, // 0 + +HardForkInitiationAction: 1, // 1 + +TreasuryWithdrawalsAction: 2, // 2 + +NoConfidenceAction: 3, // 3 + +UpdateCommitteeAction: 4, // 4 + +NewConstitutionAction: 5, // 5 + +InfoAction: 6, // 6 |}; /** */ -declare export var AddressKind: {| - +Base: 0, // 0 - +Pointer: 1, // 1 - +Enterprise: 2, // 2 - +Reward: 3, // 3 - +Byron: 4, // 4 - +Malformed: 5, // 5 +declare export var RelayKind: {| + +SingleHostAddr: 0, // 0 + +SingleHostName: 1, // 1 + +MultiHostName: 2, // 2 |}; /** - * Used to choosed the schema for a script JSON string + * JSON <-> PlutusData conversion schemas. + * Follows ScriptDataJsonSchema in cardano-cli defined at: + * https://github.com/input-output-hk/cardano-node/blob/master/cardano-api/src/Cardano/Api/ScriptData.hs#L254 + * + * All methods here have the following restrictions due to limitations on dependencies: + * * JSON numbers above u64::MAX (positive) or below i64::MIN (negative) will throw errors + * * Hex strings for bytes don't accept odd-length (half-byte) strings. + * cardano-cli seems to support these however but it seems to be different than just 0-padding + * on either side when tested so proceed with caution */ -declare export var ScriptSchema: {| - +Wallet: 0, // 0 - +Node: 1, // 1 +declare export var PlutusDatumSchema: {| + +BasicConversions: 0, // 0 + +DetailedSchema: 1, // 1 |}; /** @@ -515,11 +517,9 @@ declare export var RedeemerTagKind: {| /** */ -declare export var CoinSelectionStrategyCIP2: {| - +LargestFirst: 0, // 0 - +RandomImprove: 1, // 1 - +LargestFirstMultiAsset: 2, // 2 - +RandomImproveMultiAsset: 3, // 3 +declare export var MIRKind: {| + +ToOtherPot: 0, // 0 + +ToStakeCredentials: 1, // 1 |}; /** @@ -13664,19 +13664,19 @@ declare export class Voter { * @param {Credential} cred * @returns {Voter} */ - static new_constitutional_committee_hot_key(cred: Credential): Voter; + static new_constitutional_committee_hot_credential(cred: Credential): Voter; /** * @param {Credential} cred * @returns {Voter} */ - static new_drep(cred: Credential): Voter; + static new_drep_credential(cred: Credential): Voter; /** * @param {Ed25519KeyHash} key_hash * @returns {Voter} */ - static new_staking_pool(key_hash: Ed25519KeyHash): Voter; + static new_stake_pool_key_hash(key_hash: Ed25519KeyHash): Voter; /** * @returns {$Values< @@ -13688,17 +13688,17 @@ declare export class Voter { /** * @returns {Credential | void} */ - to_constitutional_committee_hot_key(): Credential | void; + to_constitutional_committee_hot_credential(): Credential | void; /** * @returns {Credential | void} */ - to_drep_cred(): Credential | void; + to_drep_credential(): Credential | void; /** * @returns {Ed25519KeyHash | void} */ - to_staking_pool_key_hash(): Ed25519KeyHash | void; + to_stake_pool_key_hash(): Ed25519KeyHash | void; /** * @returns {boolean} @@ -14557,7 +14557,7 @@ export type TransactionOutputsJSON = TransactionOutputJSON[]; export type CostModelJSON = string[]; export type VoterJSON = | { - ConstitutionalCommitteeHotKey: CredTypeJSON, + ConstitutionalCommitteeHotCred: CredTypeJSON, ... } | { @@ -15215,7 +15215,7 @@ export interface VersionedBlockJSON { export type VkeywitnessesJSON = VkeywitnessJSON[]; export type VoterEnumJSON = | { - ConstitutionalCommitteeHotKey: CredTypeJSON, + ConstitutionalCommitteeHotCred: CredTypeJSON, ... } | {