@stricahq/typhonjs
Version:
Pure JS Cardano Wallet library
180 lines (179 loc) • 7.77 kB
TypeScript
/// <reference types="node" />
import { Buffer } from "buffer";
import { CborTag } from "@stricahq/cbors";
import BigNumber from "bignumber.js";
import { CertificateType, HashType, VoterType, VoteType, WitnessType } from "./types";
export declare type TokenBundle = Record<string, // this is policy id
Array<{
assetName: string;
amount: BigNumber;
}>>;
export declare enum RedeemerTag {
SPEND = 0,
MINT = 1,
CERT = 2,
REWARD = 3
}
export declare enum TransactionBodyItemType {
INPUTS = 0,
OUTPUTS = 1,
FEE = 2,
TTL = 3,
CERTIFICATES = 4,
WITHDRAWALS = 5,
AUXILIARY_DATA_HASH = 7,
VALIDITY_INTERVAL_START = 8,
MINT = 9,
SCRIPT_DATA_HASH = 11,
COLLATERAL_INPUTS = 13,
REQUIRED_SIGNERS = 14,
NETWORK_ID = 15,
COLLATERAL_OUTPUT = 16,
TOTAL_COLLATERAL = 17,
REFERENCE_INPUTS = 18,
VOTING_PROCEDURES = 19,
PROPOSAL_PROCEDURES = 20,
TREASURY_AMOUNT = 21,
DONATION_AMOUNT = 22
}
export declare enum OutputItemType {
ADDRESS = 0,
VALUE = 1,
DATUM_OPTION = 2,
SCRIPT_REF = 3
}
export declare type EncodedInput = [Buffer, number];
export declare type EncodedCollateralInput = [Buffer, number];
export declare type EncodedTokens = Map<Buffer, Map<Buffer, BigNumber>>;
export declare type EncodedAmount = BigNumber | [BigNumber, EncodedTokens];
export declare type EncodedDatumOption = [0, Buffer] | [1, CborTag];
export declare type EncodedOutput = Map<OutputItemType, Buffer | EncodedAmount | EncodedDatumOption | CborTag>;
export declare type EncodedWithdrawals = Map<Buffer, BigNumber>;
export declare type EncodedCredential = [HashType, Buffer];
export declare type EncodedCommitteeHotCredential = EncodedCredential;
export declare type EncodedCommitteeColdCredential = EncodedCredential;
export declare type EncodedDRepCredential = EncodedCredential;
export declare type EncodedDRep = [0, Buffer] | [1, Buffer] | [2] | [3];
export declare type EncodedAnchor = [string, Buffer] | null;
export declare type EncodedStakeRegistrationCertificate = [
CertificateType.STAKE_REGISTRATION,
EncodedCredential
];
export declare type EncodedStakeDeRegistrationCertificate = [
CertificateType.STAKE_DE_REGISTRATION,
EncodedCredential
];
export declare type EncodedStakeDelegationCertificate = [
CertificateType.STAKE_DELEGATION,
EncodedCredential,
Buffer
];
export declare type EncodedStakeKeyRegistrationCertificate = [
CertificateType.STAKE_KEY_REGISTRATION,
EncodedCredential,
BigNumber
];
export declare type EncodedStakeKeyDeRegistrationCertificate = [
CertificateType.STAKE_KEY_DE_REGISTRATION,
EncodedCredential,
BigNumber
];
export declare type EncodedVoteDelegationCertificate = [
CertificateType.VOTE_DELEGATION,
EncodedCredential,
EncodedDRep
];
export declare type EncodedStakeVoteDelegationCertificate = [
CertificateType.STAKE_VOTE_DELEG,
EncodedCredential,
Buffer,
EncodedDRep
];
export declare type EncodedStakeRegDelegationCertificate = [
CertificateType.STAKE_REG_DELEG,
EncodedCredential,
Buffer,
BigNumber
];
export declare type EncodedVoteRegDelegationCertificate = [
CertificateType.VOTE_REG_DELEG,
EncodedCredential,
EncodedDRep,
BigNumber
];
export declare type EncodedStakeVoteRegDelegationCertificate = [
CertificateType.STAKE_VOTE_REG_DELEG,
EncodedCredential,
Buffer,
EncodedDRep,
BigNumber
];
export declare type EncodedCommitteeAuthHotCertificate = [
CertificateType.COMMITTEE_AUTH_HOT,
EncodedCommitteeColdCredential,
EncodedCommitteeHotCredential
];
export declare type EncodedCommitteeResignColdCertificate = [
CertificateType.COMMITTEE_RESIGN_COLD,
EncodedCommitteeColdCredential,
EncodedAnchor
];
export declare type EncodedDRepRegCertificate = [
CertificateType.DREP_REG,
EncodedDRepCredential,
BigNumber,
EncodedAnchor
];
export declare type EncodedDRepDeRegCertificate = [
CertificateType.DREP_DE_REG,
EncodedDRepCredential,
BigNumber
];
export declare type EncodedDRepUpdateCertificate = [
CertificateType.DREP_UPDATE,
EncodedDRepCredential,
EncodedAnchor
];
export declare type EncodedCertificate = EncodedStakeRegistrationCertificate | EncodedStakeDeRegistrationCertificate | EncodedStakeDelegationCertificate | EncodedStakeKeyRegistrationCertificate | EncodedStakeKeyDeRegistrationCertificate | EncodedVoteDelegationCertificate | EncodedStakeVoteDelegationCertificate | EncodedStakeRegDelegationCertificate | EncodedVoteRegDelegationCertificate | EncodedStakeVoteRegDelegationCertificate | EncodedCommitteeAuthHotCertificate | EncodedCommitteeResignColdCertificate | EncodedDRepRegCertificate | EncodedDRepDeRegCertificate | EncodedDRepUpdateCertificate;
export declare type EncodedExUnits = [number, number];
export declare type EncodedVKeyWitness = [Buffer, Buffer];
export declare type EncodedPlutusScript = Buffer;
export declare type EncodedPlutusData = number | BigNumber | Buffer | Array<EncodedPlutusData> | Map<EncodedPlutusData, EncodedPlutusData> | CborTag;
export declare type EncodedRedeemer = [number, number, EncodedPlutusData, EncodedExUnits];
export declare type EncodedWitnesses = Map<WitnessType.V_KEY_WITNESS, Array<EncodedVKeyWitness>> & Map<WitnessType.NATIVE_SCRIPT, Array<EncodedNativeScript>> & Map<WitnessType.PLUTUS_SCRIPT_V1, Array<EncodedPlutusScript>> & Map<WitnessType.PLUTUS_SCRIPT_V2, Array<EncodedPlutusScript>> & Map<WitnessType.PLUTUS_DATA, Array<EncodedPlutusData>> & Map<WitnessType.REDEEMER, Array<EncodedRedeemer>>;
declare type NativeScriptPubKeyHash = [0, Buffer];
declare type NativeScriptAll = [1, Array<EncodedNativeScript>];
declare type NativeScriptAny = [2, Array<EncodedNativeScript>];
declare type NativeScriptNOfK = [3, number, Array<EncodedNativeScript>];
declare type NativeScriptInvalidBefore = [4, number];
declare type NativeScriptInvalidAfter = [5, number];
export declare type EncodedNativeScript = NativeScriptPubKeyHash | NativeScriptAll | NativeScriptAny | NativeScriptNOfK | NativeScriptInvalidBefore | NativeScriptInvalidAfter;
export declare type EncodedConstitution = [EncodedAnchor, Buffer | null];
export declare type EncodedGovActionId = [Buffer, number];
export declare type EncodedVote = VoteType;
export declare type EncodedVoter = [VoterType, Buffer];
export declare type EncodedVotingProcedure = [EncodedVote, EncodedAnchor];
export declare type EncodedVotingProcedures = Map<EncodedVoter, Map<EncodedGovActionId, EncodedVotingProcedure>>;
export declare type EncodedProtocolParamUpdate = Map<number, unknown>;
export declare type EncodedProtocolVersion = [number, number];
export declare type EncodedParamChangeAction = [
0,
EncodedGovActionId | null,
EncodedProtocolParamUpdate,
Buffer | null
];
export declare type EncodedHFInitAction = [1, EncodedGovActionId | null, EncodedProtocolVersion];
export declare type EncodedTreasuryWithdrawalsAction = [2, Map<Buffer, BigNumber>, Buffer | null];
export declare type EncodedNoConfidenceAction = [3, EncodedGovActionId | null];
export declare type EncodedUpdateCommittee = [
4,
EncodedGovActionId | null,
Array<EncodedCommitteeColdCredential>,
Map<EncodedCommitteeColdCredential, number>,
CborTag
];
export declare type EncodedNewConstitution = [5, EncodedGovActionId | null, EncodedConstitution];
export declare type EncodedInfoAction = [6];
export declare type EncodedGovAction = EncodedParamChangeAction | EncodedHFInitAction | EncodedTreasuryWithdrawalsAction | EncodedNoConfidenceAction | EncodedUpdateCommittee | EncodedNewConstitution | EncodedInfoAction;
export declare type EncodedProposalProcedure = [BigNumber, Buffer, EncodedGovAction, EncodedAnchor];
export {};