UNPKG

@stricahq/typhonjs

Version:

Pure JS Cardano Wallet library

481 lines (480 loc) 13.6 kB
/// <reference types="node" /> import { Buffer } from "buffer"; import BigNumber from "bignumber.js"; import BaseAddress from "./address/BaseAddress"; import ByronAddress from "./address/ByronAddress"; import EnterpriseAddress from "./address/EnterpriseAddress"; import PointerAddress from "./address/PointerAddress"; import RewardAddress from "./address/RewardAddress"; export declare type ShelleyAddress = BaseAddress | EnterpriseAddress | PointerAddress; export declare type CardanoAddress = ShelleyAddress | ByronAddress | RewardAddress; export declare type BipPath = { purpose: number; coin: number; account: number; chain: number; index: number; }; export declare enum HashType { ADDRESS = 0, SCRIPT = 1 } export declare enum PlutusScriptType { PlutusScriptV1 = "PlutusScriptV1", PlutusScriptV2 = "PlutusScriptV2", PlutusScriptV3 = "PlutusScriptV3" } export declare enum VoteType { NO = 0, YES = 1, ABSTAIN = 2 } export declare enum VoterType { CC_HOT_KEY = 0, CC_HOT_SCRIPT = 1, DREP_KEY = 2, DREP_SCRIPT = 3, POOL_KEY = 4 } export declare enum GovActionType { PARAM_CHANGE_ACTION = 0, HF_INIT_ACTION = 1, TREASURY_WITHDRAW_ACTION = 2, NO_CONFIDENCE_ACTION = 3, UPDATE_COMMITTEE_ACTION = 4, NEW_CONSTITUTION_ACTION = 5, INFO_ACTION = 6 } export declare type HashCredential = { hash: Buffer; type: HashType.ADDRESS; bipPath?: BipPath; }; export declare type NativeScriptPubKeyHash = { pubKeyHash: string; }; export declare type NativeScriptAll = { all: Array<NativeScript>; }; export declare type NativeScriptAny = { any: Array<NativeScript>; }; export declare type NativeScriptNOfK = { n: number; k: Array<NativeScript>; }; export declare type NativeScriptInvalidBefore = { invalidBefore: number; }; export declare type NativeScriptInvalidAfter = { invalidAfter: number; }; export declare type NativeScript = NativeScriptPubKeyHash | NativeScriptNOfK | NativeScriptInvalidBefore | NativeScriptInvalidAfter | NativeScriptAll | NativeScriptAny; export declare type PlutusScript = { cborHex: string; type: PlutusScriptType; }; export declare type ScriptCredential = { hash: Buffer; type: HashType.SCRIPT; plutusScript?: PlutusScript; nativeScript?: NativeScript; }; export declare type Credential = HashCredential | ScriptCredential; export declare type StakeCredential = Credential; export declare type DRepCredential = Credential; export declare type CommitteeHotCredential = Credential; export declare type CommitteeColdCredential = Credential; export declare enum CertificateType { STAKE_REGISTRATION = 0, STAKE_DE_REGISTRATION = 1, STAKE_DELEGATION = 2, STAKE_KEY_REGISTRATION = 7, STAKE_KEY_DE_REGISTRATION = 8, VOTE_DELEGATION = 9, STAKE_VOTE_DELEG = 10, STAKE_REG_DELEG = 11, VOTE_REG_DELEG = 12, STAKE_VOTE_REG_DELEG = 13, COMMITTEE_AUTH_HOT = 14, COMMITTEE_RESIGN_COLD = 15, DREP_REG = 16, DREP_DE_REG = 17, DREP_UPDATE = 18 } export declare enum WitnessType { V_KEY_WITNESS = 0, NATIVE_SCRIPT = 1, PLUTUS_SCRIPT_V1 = 3, PLUTUS_DATA = 4, REDEEMER = 5, PLUTUS_SCRIPT_V2 = 6 } export declare enum NetworkId { MAINNET = 1, TESTNET = 0 } export declare type Token = { policyId: string; assetName: string; amount: BigNumber; }; export declare type Input = { txId: string; index: number; amount: BigNumber; tokens: Array<Token>; address: ShelleyAddress; plutusData?: PlutusData; redeemer?: Redeemer; plutusScript?: PlutusScript; nativeScript?: NativeScript; }; export declare type ReferenceInput = { txId: string; index: number; amount?: BigNumber; tokens?: Array<Token>; address?: ShelleyAddress; plutusData?: PlutusData; plutusScript?: PlutusScript; nativeScript?: NativeScript; }; export declare type Asset = { assetName: string; amount: BigNumber; }; export declare type Mint = { policyId: string; assets: Array<Asset>; nativeScript?: NativeScript; plutusScript?: PlutusScript; redeemer?: Redeemer; }; export declare type CollateralInput = { txId: string; index: number; amount: BigNumber; address: ShelleyAddress; }; export declare type Output = { amount: BigNumber; address: CardanoAddress; tokens: Array<Token>; plutusData?: PlutusData; plutusDataHash?: string; plutusScript?: PlutusScript; nativeScript?: NativeScript; }; export declare enum DRepType { ADDRESS = 0, SCRIPT = 1, ABSTAIN = 2, NO_CONFIDENCE = 3 } export declare type DRep = { type: DRepType; key: Buffer | undefined; }; export declare type Anchor = { url: string; hash: Buffer; }; export declare type StakeRegistrationCertificate = { type: CertificateType.STAKE_REGISTRATION; cert: { stakeCredential: StakeCredential; }; }; export declare type StakeDeRegistrationCertificate = { type: CertificateType.STAKE_DE_REGISTRATION; cert: { stakeCredential: StakeCredential; }; }; export declare type StakeDelegationCertificate = { type: CertificateType.STAKE_DELEGATION; cert: { stakeCredential: StakeCredential; poolHash: string; }; }; export declare type StakeKeyRegistrationCertificate = { type: CertificateType.STAKE_KEY_REGISTRATION; cert: { stakeCredential: StakeCredential; deposit: BigNumber; }; }; export declare type StakeKeyDeRegistrationCertificate = { type: CertificateType.STAKE_KEY_DE_REGISTRATION; cert: { stakeCredential: StakeCredential; deposit: BigNumber; }; }; export declare type VoteDelegationCertificate = { type: CertificateType.VOTE_DELEGATION; cert: { stakeCredential: StakeCredential; dRep: DRep; }; }; export declare type StakeVoteDelegationCertificate = { type: CertificateType.STAKE_VOTE_DELEG; cert: { stakeCredential: StakeCredential; poolKeyHash: Buffer; dRep: DRep; }; }; export declare type StakeRegDelegationCertificate = { type: CertificateType.STAKE_REG_DELEG; cert: { stakeCredential: StakeCredential; poolKeyHash: Buffer; deposit: BigNumber; }; }; export declare type VoteRegDelegationCertificate = { type: CertificateType.VOTE_REG_DELEG; cert: { stakeCredential: StakeCredential; dRep: DRep; deposit: BigNumber; }; }; export declare type StakeVoteRegDelegationCertificate = { type: CertificateType.STAKE_VOTE_REG_DELEG; cert: { stakeCredential: StakeCredential; poolKeyHash: Buffer; dRep: DRep; deposit: BigNumber; }; }; export declare type CommitteeAuthHotCertificate = { type: CertificateType.COMMITTEE_AUTH_HOT; cert: { coldCredential: CommitteeColdCredential; hotCredential: CommitteeHotCredential; }; }; export declare type CommitteeResignColdCertificate = { type: CertificateType.COMMITTEE_RESIGN_COLD; cert: { coldCredential: CommitteeColdCredential; anchor: Anchor | null; }; }; export declare type DRepRegCertificate = { type: CertificateType.DREP_REG; cert: { dRepCredential: DRepCredential; deposit: BigNumber; anchor: Anchor | null; }; }; export declare type DRepDeRegCertificate = { type: CertificateType.DREP_DE_REG; cert: { dRepCredential: DRepCredential; deposit: BigNumber; }; }; export declare type DRepUpdateCertificate = { type: CertificateType.DREP_UPDATE; cert: { dRepCredential: DRepCredential; anchor: Anchor | null; }; }; export declare type Withdrawal = { rewardAccount: RewardAddress; amount: BigNumber; }; export declare type Certificate = StakeRegistrationCertificate | StakeDeRegistrationCertificate | StakeDelegationCertificate | StakeKeyRegistrationCertificate | StakeKeyDeRegistrationCertificate | VoteDelegationCertificate | StakeVoteDelegationCertificate | StakeRegDelegationCertificate | VoteRegDelegationCertificate | StakeVoteRegDelegationCertificate | CommitteeAuthHotCertificate | CommitteeResignColdCertificate | DRepRegCertificate | DRepDeRegCertificate | DRepUpdateCertificate; export declare type VKeyWitness = { publicKey: Buffer; signature: Buffer; }; export declare type MetaDatum = Map<MetaDatum, MetaDatum> | Array<MetaDatum> | number | Buffer | string; export declare type Metadata = { label: number; data: MetaDatum; }; export declare type AuxiliaryData = { metadata: Array<Metadata>; }; export declare type PlutusData = number | BigNumber | Buffer | PlutusDataConstructor | Array<PlutusData> | Map<PlutusData, PlutusData>; export declare type PlutusDataConstructor = { constructor: number; fields: Array<PlutusData>; }; export declare type ExUnits = { mem: number; steps: number; }; export declare type Redeemer = { plutusData: PlutusData; exUnits: ExUnits; }; export declare type LanguageView = { PlutusScriptV1: Array<number>; PlutusScriptV2: Array<number>; PlutusScriptV3: Array<number>; }; export declare type ProtocolParams = { minFeeA: BigNumber; minFeeB: BigNumber; stakeKeyDeposit: BigNumber; lovelacePerUtxoWord: BigNumber; utxoCostPerByte: BigNumber; collateralPercent: BigNumber; priceSteps: BigNumber; priceMem: BigNumber; languageView: LanguageView; maxTxSize?: number; maxValueSize: number; minFeeRefScriptCostPerByte: BigNumber; }; export declare type CostMdls = { plutusV1: Array<number> | undefined; plutusV2: Array<number> | undefined; plutusV3: Array<number> | undefined; }; export declare type ProtocolParamUpdate = { minFeeA?: BigNumber; minFeeB?: BigNumber; maxBlockBodySize?: number; maxTransactionSize?: number; maxBlockHeaderSize?: number; stakeKeyDeposit?: BigNumber; poolDeposit?: BigNumber; poolRetireMaxEpoch?: number; n?: number; pledgeInfluence?: [number, number]; expansionRate?: [number, number]; treasuryGrowthRate?: [number, number]; minPoolCost?: BigNumber; adaPerUtxoByte?: BigNumber; costMdls?: CostMdls; exUnitPrices?: { mem: [number, number]; steps: [number, number]; }; maxTxExUnits?: { mem: number; steps: number; }; maxBlockExUnits?: { mem: number; steps: number; }; maxValueSize?: BigNumber; collateralPercent?: number; maxCollateralInputs?: number; poolVotingThreshold?: { motionNoConfidence: number; committeeNormal: number; committeeNoConfidence: number; hfInitiation: number; securityParamVoting: number; }; dRepVotingThreshold?: { motionNoConfidence: number; committeeNormal: number; committeeNoConfidence: number; updateConstitution: number; hfInitiation: number; networkParamVoting: number; economicParamVoting: number; technicalParamVoting: number; govParamVoting: number; treasuryWithdrawal: number; }; minCommitteeSize?: number; committeeTermLimit?: number; govActionValidity?: number; govActionDeposit?: BigNumber; dRepDeposit?: BigNumber; dRepInactivity?: number; refScriptCostByte?: [number, number]; }; export declare type ParameterChangeAction = { type: GovActionType.PARAM_CHANGE_ACTION; action: { prevActionId: GovActionId | null; protocolParamUpdate: ProtocolParamUpdate; policyHash: Buffer | null; }; }; export declare type HardForkInitAction = { type: GovActionType.HF_INIT_ACTION; action: { prevActionId: GovActionId | null; protocolVersion: [number, number]; }; }; export declare type TreasuryWithdrawalsAction = { type: GovActionType.TREASURY_WITHDRAW_ACTION; action: { withdrawals: Array<Withdrawal>; policyHash: Buffer | null; }; }; export declare type NoConfidenceAction = { type: GovActionType.NO_CONFIDENCE_ACTION; action: { prevActionId: GovActionId | null; }; }; export declare type UpdateCommitteeAction = { type: GovActionType.UPDATE_COMMITTEE_ACTION; action: { prevActionId: GovActionId | null; removeColdCreds: Array<CommitteeColdCredential>; addColdCreds: Array<{ credential: CommitteeColdCredential; epoch: number; }>; threshold: [number, number]; }; }; export declare type NewConstitutionAction = { type: GovActionType.NEW_CONSTITUTION_ACTION; action: { prevActionId: GovActionId | null; constitution: { anchor: Anchor; scriptHash: Buffer | null; }; }; }; export declare type InfoAction = { type: GovActionType.INFO_ACTION; }; export declare type GovAction = ParameterChangeAction | HardForkInitAction | TreasuryWithdrawalsAction | NoConfidenceAction | UpdateCommitteeAction | NewConstitutionAction | InfoAction; export declare type GovActionId = { txId: Buffer; index: number; }; export declare type Vote = { govActionId: GovActionId; vote: VoteType; anchor: Anchor | null; }; export declare type Voter = { type: VoterType; key: Credential; }; export declare type VotingProcedure = { voter: Voter; votes: Array<Vote>; }; export declare type ProposalProcedure = { deposit: BigNumber; rewardAccount: Buffer; govAction: GovAction; anchor: Anchor; };