meshjs 1.2.0-beta.4 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +14 -25
  2. package/bin/create-mesh-app +2 -0
  3. package/dist/meshjs.cjs.d.ts +2 -0
  4. package/dist/meshjs.cjs.dev.js +214 -0
  5. package/dist/meshjs.cjs.js +7 -0
  6. package/dist/meshjs.cjs.prod.js +214 -0
  7. package/package.json +22 -56
  8. package/src/actions/create.ts +101 -0
  9. package/src/actions/index.ts +1 -0
  10. package/src/helpers/index.ts +3 -0
  11. package/src/helpers/resolvePkgManager.ts +24 -0
  12. package/src/helpers/setProjectName.ts +15 -0
  13. package/src/helpers/tryGitInit.ts +37 -0
  14. package/src/index.ts +77 -0
  15. package/src/utils/index.ts +1 -0
  16. package/src/utils/logger.ts +13 -0
  17. package/tsconfig.json +109 -0
  18. package/dist/common/constants.d.ts +0 -27
  19. package/dist/common/contracts/fetcher.d.ts +0 -8
  20. package/dist/common/contracts/index.d.ts +0 -5
  21. package/dist/common/contracts/initiator.d.ts +0 -8
  22. package/dist/common/contracts/signer.d.ts +0 -7
  23. package/dist/common/contracts/submitter.d.ts +0 -3
  24. package/dist/common/contracts/uploader.d.ts +0 -3
  25. package/dist/common/decorators.d.ts +0 -19
  26. package/dist/common/helpers/index.d.ts +0 -1
  27. package/dist/common/helpers/mergeSignatures.d.ts +0 -3
  28. package/dist/common/types/Account.d.ts +0 -5
  29. package/dist/common/types/AccountInfo.d.ts +0 -7
  30. package/dist/common/types/Action.d.ts +0 -12
  31. package/dist/common/types/Asset.d.ts +0 -6
  32. package/dist/common/types/AssetExtended.d.ts +0 -8
  33. package/dist/common/types/AssetMetadata.d.ts +0 -24
  34. package/dist/common/types/Data.d.ts +0 -4
  35. package/dist/common/types/DataSignature.d.ts +0 -4
  36. package/dist/common/types/Era.d.ts +0 -1
  37. package/dist/common/types/Mint.d.ts +0 -10
  38. package/dist/common/types/NativeScript.d.ts +0 -14
  39. package/dist/common/types/Network.d.ts +0 -1
  40. package/dist/common/types/PlutusScript.d.ts +0 -6
  41. package/dist/common/types/PoolParams.d.ts +0 -16
  42. package/dist/common/types/Protocol.d.ts +0 -22
  43. package/dist/common/types/Recipient.d.ts +0 -11
  44. package/dist/common/types/Relay.d.ts +0 -13
  45. package/dist/common/types/UTxO.d.ts +0 -14
  46. package/dist/common/types/Wallet.d.ts +0 -5
  47. package/dist/common/types/index.d.ts +0 -19
  48. package/dist/common/utils/builder.d.ts +0 -17
  49. package/dist/common/utils/converter.d.ts +0 -26
  50. package/dist/common/utils/deserializer.d.ts +0 -17
  51. package/dist/common/utils/index.d.ts +0 -5
  52. package/dist/common/utils/parser.d.ts +0 -1
  53. package/dist/common/utils/resolver.d.ts +0 -17
  54. package/dist/core/CIP14.d.ts +0 -2
  55. package/dist/core/CIP1852.d.ts +0 -4
  56. package/dist/core/CIP1853.d.ts +0 -1
  57. package/dist/core/CIP1855.d.ts +0 -1
  58. package/dist/core/CIP2.d.ts +0 -3
  59. package/dist/core/CIP25.d.ts +0 -19
  60. package/dist/core/CIP8.d.ts +0 -13
  61. package/dist/core/CSL.d.ts +0 -144
  62. package/dist/core/index.d.ts +0 -8
  63. package/dist/index.d.ts +0 -8
  64. package/dist/meshjs.cjs +0 -1
  65. package/dist/meshjs.js +0 -2188
  66. package/dist/providers/blockfrost.provider.d.ts +0 -14
  67. package/dist/providers/index.d.ts +0 -4
  68. package/dist/providers/infura.provider.d.ts +0 -12
  69. package/dist/providers/koios.provider.d.ts +0 -12
  70. package/dist/providers/tango.provider.d.ts +0 -12
  71. package/dist/scripts/forge.script.d.ts +0 -8
  72. package/dist/scripts/index.d.ts +0 -1
  73. package/dist/transaction/index.d.ts +0 -1
  74. package/dist/transaction/transaction.service.d.ts +0 -61
  75. package/dist/wallet/app.service.d.ts +0 -34
  76. package/dist/wallet/app.service.spec.d.ts +0 -1
  77. package/dist/wallet/browser.service.d.ts +0 -58
  78. package/dist/wallet/browser.service.spec.d.ts +0 -1
  79. package/dist/wallet/embedded.service.d.ts +0 -20
  80. package/dist/wallet/embedded.service.spec.d.ts +0 -1
  81. package/dist/wallet/index.d.ts +0 -4
  82. package/dist/wallet/mina.service.d.ts +0 -11
  83. package/dist/wallet/mina.service.spec.d.ts +0 -1
  84. /package/dist/{transaction/transaction.service.spec.d.ts → declarations/src/index.d.ts} +0 -0
@@ -1,22 +0,0 @@
1
- export declare type Protocol = {
2
- epoch: number;
3
- minFeeA: number;
4
- minFeeB: number;
5
- maxBlockSize: number;
6
- maxTxSize: number;
7
- maxBlockHeaderSize: number;
8
- keyDeposit: string;
9
- poolDeposit: string;
10
- decentralisation: number;
11
- minPoolCost: string;
12
- priceMem: number;
13
- priceStep: number;
14
- maxTxExMem: string;
15
- maxTxExSteps: string;
16
- maxBlockExMem: string;
17
- maxBlockExSteps: string;
18
- maxValSize: string;
19
- collateralPercent: number;
20
- maxCollateralInputs: number;
21
- coinsPerUTxOSize: string;
22
- };
@@ -1,11 +0,0 @@
1
- import { Data } from './Data';
2
- import { NativeScript } from './NativeScript';
3
- import { PlutusScript } from './PlutusScript';
4
- export declare type Recipient = string | {
5
- address: string;
6
- datum?: {
7
- value: Data;
8
- inline?: boolean;
9
- };
10
- script?: PlutusScript | NativeScript;
11
- };
@@ -1,13 +0,0 @@
1
- export declare type Relay = {
2
- type: 'SingleHostAddr';
3
- IPV4?: string;
4
- IPV6?: string;
5
- port?: number;
6
- } | {
7
- type: 'SingleHostName';
8
- domainName: string;
9
- port?: number;
10
- } | {
11
- type: 'MultiHostName';
12
- domainName: string;
13
- };
@@ -1,14 +0,0 @@
1
- import { Asset } from './Asset';
2
- export declare type UTxO = {
3
- input: {
4
- outputIndex: number;
5
- txHash: string;
6
- };
7
- output: {
8
- address: string;
9
- amount: Asset[];
10
- dataHash?: string;
11
- plutusData?: string;
12
- scriptRef?: string;
13
- };
14
- };
@@ -1,5 +0,0 @@
1
- export declare type Wallet = {
2
- name: string;
3
- icon: string;
4
- version: string;
5
- };
@@ -1,19 +0,0 @@
1
- export * from './Account';
2
- export * from './AccountInfo';
3
- export * from './Action';
4
- export * from './Asset';
5
- export * from './AssetExtended';
6
- export * from './AssetMetadata';
7
- export * from './Data';
8
- export * from './DataSignature';
9
- export * from './Era';
10
- export * from './Mint';
11
- export * from './NativeScript';
12
- export * from './Network';
13
- export * from './PlutusScript';
14
- export * from './PoolParams';
15
- export * from './Protocol';
16
- export * from './Recipient';
17
- export * from './Relay';
18
- export * from './UTxO';
19
- export * from './Wallet';
@@ -1,17 +0,0 @@
1
- import { csl } from '@mesh/core';
2
- import type { BaseAddress, Bip32PrivateKey, DataCost, DatumSource, Ed25519KeyHash, EnterpriseAddress, PlutusScriptSource, RewardAddress, TransactionBuilder, TransactionOutputBuilder, TxInputsBuilder } from '@mesh/core';
3
- import type { Data, PlutusScript, Recipient, UTxO } from '@mesh/common/types';
4
- export declare const buildBaseAddress: (networkId: number, paymentKeyHash: Ed25519KeyHash, stakeKeyHash: Ed25519KeyHash) => BaseAddress;
5
- export declare const buildBip32PrivateKey: (entropy: string, password?: string) => Bip32PrivateKey;
6
- export declare const buildDataCost: (coinsPerByte: string) => DataCost;
7
- export declare const buildDatumSource: (datum: Data | UTxO) => DatumSource;
8
- export declare const buildEnterpriseAddress: (networkId: number, paymentKeyHash: Ed25519KeyHash) => EnterpriseAddress;
9
- export declare const buildGeneralTxMetadata: (metadata: Record<string, unknown>) => csl.GeneralTransactionMetadata;
10
- export declare const buildRewardAddress: (networkId: number, stakeKeyHash: Ed25519KeyHash) => RewardAddress;
11
- export declare const buildPlutusScriptSource: (script: PlutusScript | UTxO) => PlutusScriptSource;
12
- export declare const buildScriptPubkey: (keyHash: Ed25519KeyHash) => csl.NativeScript;
13
- export declare const buildTimelockExpiry: (slot: string) => csl.NativeScript;
14
- export declare const buildTimelockStart: (slot: string) => csl.NativeScript;
15
- export declare const buildTxBuilder: (parameters?: import("@mesh/common/types").Protocol) => TransactionBuilder;
16
- export declare const buildTxInputsBuilder: (utxos: unknown[]) => TxInputsBuilder;
17
- export declare const buildTxOutputBuilder: (recipient: Recipient) => TransactionOutputBuilder;
@@ -1,26 +0,0 @@
1
- import { csl } from '@mesh/core';
2
- import type { ScriptRef, TransactionUnspentOutput, Value } from '@mesh/core';
3
- import type { Action, Asset, Data, NativeScript, PlutusScript, PoolParams, Relay, UTxO } from '@mesh/common/types';
4
- export declare const toAddress: (bech32: string) => csl.Address;
5
- export declare const toBaseAddress: (bech32: string) => csl.BaseAddress | undefined;
6
- export declare const toEnterpriseAddress: (bech32: string) => csl.EnterpriseAddress | undefined;
7
- export declare const toRewardAddress: (bech32: string) => csl.RewardAddress | undefined;
8
- export declare const fromBytes: (bytes: Uint8Array) => string;
9
- export declare const toBytes: (hex: string) => Uint8Array;
10
- export declare const fromLovelace: (lovelace: number) => number;
11
- export declare const toLovelace: (ada: number) => number;
12
- export declare const fromNativeScript: (script: csl.NativeScript) => NativeScript;
13
- export declare const toNativeScript: (script: NativeScript) => csl.NativeScript;
14
- export declare const toPlutusData: (data: Data) => csl.PlutusData;
15
- export declare const toPoolParams: (params: PoolParams) => never;
16
- export declare const toRedeemer: (action: Action) => csl.Redeemer;
17
- export declare const toRelay: (relay: Relay) => csl.Relay;
18
- export declare const fromScriptRef: (scriptRef: ScriptRef) => NativeScript | PlutusScript;
19
- export declare const toScriptRef: (script: PlutusScript | NativeScript) => csl.ScriptRef;
20
- export declare const fromTxUnspentOutput: (txUnspentOutput: TransactionUnspentOutput) => UTxO;
21
- export declare const toTxUnspentOutput: (utxo: UTxO) => csl.TransactionUnspentOutput;
22
- export declare const toUnitInterval: (float: string) => csl.UnitInterval;
23
- export declare const fromUTF8: (utf8: string) => string;
24
- export declare const toUTF8: (hex: string) => string;
25
- export declare const fromValue: (value: Value) => Asset[];
26
- export declare const toValue: (assets: Asset[]) => csl.Value;
@@ -1,17 +0,0 @@
1
- import { csl } from '@mesh/core';
2
- import type { LanguageVersion } from '@mesh/common/types';
3
- export declare const deserializeAddress: (address: string) => csl.Address;
4
- export declare const deserializeBip32PrivateKey: (bip32PrivateKey: string) => csl.Bip32PrivateKey;
5
- export declare const deserializeDataHash: (dataHash: string) => csl.DataHash;
6
- export declare const deserializeEd25519KeyHash: (ed25519KeyHash: string) => csl.Ed25519KeyHash;
7
- export declare const deserializeNativeScript: (nativeScript: string) => csl.NativeScript;
8
- export declare const deserializePlutusData: (plutusData: string) => csl.PlutusData;
9
- export declare const deserializePlutusScript: (plutusScript: string, version: LanguageVersion) => csl.PlutusScript;
10
- export declare const deserializeScriptRef: (scriptRef: string) => csl.ScriptRef;
11
- export declare const deserializeScriptHash: (scriptHash: string) => csl.ScriptHash;
12
- export declare const deserializeTx: (tx: string) => csl.Transaction;
13
- export declare const deserializeTxBody: (txBody: string) => csl.TransactionBody;
14
- export declare const deserializeTxHash: (txHash: string) => csl.TransactionHash;
15
- export declare const deserializeTxUnspentOutput: (txUnspentOutput: string) => csl.TransactionUnspentOutput;
16
- export declare const deserializeTxWitnessSet: (txWitnessSet: string) => csl.TransactionWitnessSet;
17
- export declare const deserializeValue: (value: string) => csl.Value;
@@ -1,5 +0,0 @@
1
- export * from './builder';
2
- export * from './converter';
3
- export * from './deserializer';
4
- export * from './parser';
5
- export * from './resolver';
@@ -1 +0,0 @@
1
- export declare const parseHttpError: (error: unknown) => string;
@@ -1,17 +0,0 @@
1
- import type { Data, Era, LanguageVersion, NativeScript, Network, PlutusScript } from '@mesh/common/types';
2
- export declare const resolveDataHash: (data: Data) => string;
3
- export declare const resolveEpochNo: (network: Network, milliseconds?: number) => number;
4
- export declare const resolveFingerprint: (policyId: string, assetName: string) => string;
5
- export declare const resolveLanguageView: (era: Era, version: LanguageVersion) => string | undefined;
6
- export declare const resolveNativeScriptHash: (script: NativeScript) => string;
7
- export declare const resolvePaymentKeyHash: (bech32: string) => string;
8
- export declare const resolvePlutusScriptAddress: (script: PlutusScript, networkId?: number) => string;
9
- export declare const resolvePlutusScriptHash: (bech32: string) => string;
10
- export declare const resolvePoolId: (hash: string) => string;
11
- export declare const resolvePrivateKey: (words: string[]) => string;
12
- export declare const resolveScriptRef: (script: PlutusScript | NativeScript) => string;
13
- export declare const resolveSlotNo: (network: Network, milliseconds?: number) => string;
14
- export declare const resolveRewardAddress: (bech32: string) => string;
15
- export declare const resolveStakeKeyHash: (bech32: string) => string;
16
- export declare const resolveTxFees: (txSize: number, minFeeA?: number, minFeeB?: number) => string;
17
- export declare const resolveTxHash: (txHex: string) => string;
@@ -1,2 +0,0 @@
1
- import CIP14 from '@emurgo/cip14-js';
2
- export declare const AssetFingerprint: typeof CIP14;
@@ -1,4 +0,0 @@
1
- export declare const deriveAccountKeys: (rootKey: string, accountIndex: number) => {
2
- paymentKey: import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
3
- stakeKey: import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
4
- };
@@ -1 +0,0 @@
1
- export declare const deriveStakePoolColdKey: (rootKey: string, coldIndex: number) => import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
@@ -1 +0,0 @@
1
- export declare const deriveForgingPolicyKey: (rootKey: string, policyIndex: number) => import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
@@ -1,3 +0,0 @@
1
- import type { Quantity, Unit, UTxO } from '@mesh/common/types';
2
- export declare const largestFirst: (lovelace: Quantity, initialUTxOSet: UTxO[], includeTxFees?: boolean, { maxTxSize, minFeeA, minFeeB }?: import("@mesh/common/types").Protocol) => UTxO[];
3
- export declare const largestFirstMultiAsset: (requestedOutputSet: Map<Unit, Quantity>, initialUTxOSet: UTxO[], includeTxFees?: boolean, parameters?: import("@mesh/common/types").Protocol) => UTxO[];
@@ -1,19 +0,0 @@
1
- export declare type MetadataStandard = {
2
- name: string;
3
- image: `${string}://${string}`;
4
- mediaType?: `image/${string}`;
5
- description?: string | string[];
6
- instagram?: `https://instagram.com/${string}`;
7
- twitter?: `https://twitter.com/${string}`;
8
- discord?: `https://discord.gg/${string}`;
9
- website?: `https://${string}`;
10
- };
11
- export declare type Files = {
12
- files?: [
13
- {
14
- name: string;
15
- src: `${string}://${string}`;
16
- mediaType: `${string}/${string}`;
17
- }
18
- ];
19
- };
@@ -1,13 +0,0 @@
1
- import type { Address, PrivateKey } from './CSL';
2
- export declare const signMessage: (message: Message, signer: Signer) => {
3
- coseKey: string;
4
- coseSign1: string;
5
- };
6
- export declare type Message = {
7
- payload: string;
8
- externalAAD?: string;
9
- };
10
- export declare type Signer = {
11
- address: Address;
12
- key: PrivateKey;
13
- };
@@ -1,144 +0,0 @@
1
- import { csl } from '.';
2
- export * as csl from '@emurgo/cardano-serialization-lib-nodejs';
3
- export declare type Address = InstanceType<typeof csl.Address>;
4
- export declare type AssetName = InstanceType<typeof csl.AssetName>;
5
- export declare type AssetNames = InstanceType<typeof csl.AssetNames>;
6
- export declare type Assets = InstanceType<typeof csl.Assets>;
7
- export declare type AuxiliaryData = InstanceType<typeof csl.AuxiliaryData>;
8
- export declare type AuxiliaryDataHash = InstanceType<typeof csl.AuxiliaryDataHash>;
9
- export declare type AuxiliaryDataSet = InstanceType<typeof csl.AuxiliaryDataSet>;
10
- export declare type BaseAddress = InstanceType<typeof csl.BaseAddress>;
11
- export declare type BigInt = InstanceType<typeof csl.BigInt>;
12
- export declare type BigNum = InstanceType<typeof csl.BigNum>;
13
- export declare type Bip32PrivateKey = InstanceType<typeof csl.Bip32PrivateKey>;
14
- export declare type Bip32PublicKey = InstanceType<typeof csl.Bip32PublicKey>;
15
- export declare type Block = InstanceType<typeof csl.Block>;
16
- export declare type BlockHash = InstanceType<typeof csl.BlockHash>;
17
- export declare type BootstrapWitness = InstanceType<typeof csl.BootstrapWitness>;
18
- export declare type BootstrapWitnesses = InstanceType<typeof csl.BootstrapWitnesses>;
19
- export declare type ByronAddress = InstanceType<typeof csl.ByronAddress>;
20
- export declare type Certificate = InstanceType<typeof csl.Certificate>;
21
- export declare type Certificates = InstanceType<typeof csl.Certificates>;
22
- export declare type ConstrPlutusData = InstanceType<typeof csl.ConstrPlutusData>;
23
- export declare type CostModel = InstanceType<typeof csl.CostModel>;
24
- export declare type Costmdls = InstanceType<typeof csl.Costmdls>;
25
- export declare type DNSRecordAorAAAA = InstanceType<typeof csl.DNSRecordAorAAAA>;
26
- export declare type DNSRecordSRV = InstanceType<typeof csl.DNSRecordSRV>;
27
- export declare type DataCost = InstanceType<typeof csl.DataCost>;
28
- export declare type DataHash = InstanceType<typeof csl.DataHash>;
29
- export declare type DatumSource = InstanceType<typeof csl.DatumSource>;
30
- export declare type Ed25519KeyHash = InstanceType<typeof csl.Ed25519KeyHash>;
31
- export declare type Ed25519KeyHashes = InstanceType<typeof csl.Ed25519KeyHashes>;
32
- export declare type Ed25519Signature = InstanceType<typeof csl.Ed25519Signature>;
33
- export declare type EnterpriseAddress = InstanceType<typeof csl.EnterpriseAddress>;
34
- export declare type ExUnitPrices = InstanceType<typeof csl.ExUnitPrices>;
35
- export declare type ExUnits = InstanceType<typeof csl.ExUnits>;
36
- export declare type GeneralTransactionMetadata = InstanceType<typeof csl.GeneralTransactionMetadata>;
37
- export declare type GenesisDelegateHash = InstanceType<typeof csl.GenesisDelegateHash>;
38
- export declare type GenesisHash = InstanceType<typeof csl.GenesisHash>;
39
- export declare type GenesisHashes = InstanceType<typeof csl.GenesisHashes>;
40
- export declare type GenesisKeyDelegation = InstanceType<typeof csl.GenesisKeyDelegation>;
41
- export declare type Header = InstanceType<typeof csl.Header>;
42
- export declare type HeaderBody = InstanceType<typeof csl.HeaderBody>;
43
- export declare type Int = InstanceType<typeof csl.Int>;
44
- export declare type Ipv4 = InstanceType<typeof csl.Ipv4>;
45
- export declare type Ipv6 = InstanceType<typeof csl.Ipv6>;
46
- export declare type KESSignature = InstanceType<typeof csl.KESSignature>;
47
- export declare type KESVKey = InstanceType<typeof csl.KESVKey>;
48
- export declare type Language = InstanceType<typeof csl.Language>;
49
- export declare type Languages = InstanceType<typeof csl.Languages>;
50
- export declare type LegacyDaedalusPrivateKey = InstanceType<typeof csl.LegacyDaedalusPrivateKey>;
51
- export declare type LinearFee = InstanceType<typeof csl.LinearFee>;
52
- export declare type MIRToStakeCredentials = InstanceType<typeof csl.MIRToStakeCredentials>;
53
- export declare type MetadataList = InstanceType<typeof csl.MetadataList>;
54
- export declare type MetadataMap = InstanceType<typeof csl.MetadataMap>;
55
- export declare type Mint = InstanceType<typeof csl.Mint>;
56
- export declare type MintAssets = InstanceType<typeof csl.MintAssets>;
57
- export declare type MoveInstantaneousReward = InstanceType<typeof csl.MoveInstantaneousReward>;
58
- export declare type MoveInstantaneousRewardsCert = InstanceType<typeof csl.MoveInstantaneousRewardsCert>;
59
- export declare type MultiAsset = InstanceType<typeof csl.MultiAsset>;
60
- export declare type MultiHostName = InstanceType<typeof csl.MultiHostName>;
61
- export declare type NativeScript = InstanceType<typeof csl.NativeScript>;
62
- export declare type NativeScripts = InstanceType<typeof csl.NativeScripts>;
63
- export declare type NetworkId = InstanceType<typeof csl.NetworkId>;
64
- export declare type NetworkInfo = InstanceType<typeof csl.NetworkInfo>;
65
- export declare type Nonce = InstanceType<typeof csl.Nonce>;
66
- export declare type OperationalCert = InstanceType<typeof csl.OperationalCert>;
67
- export declare type PlutusData = InstanceType<typeof csl.PlutusData>;
68
- export declare type PlutusList = InstanceType<typeof csl.PlutusList>;
69
- export declare type PlutusMap = InstanceType<typeof csl.PlutusMap>;
70
- export declare type PlutusScript = InstanceType<typeof csl.PlutusScript>;
71
- export declare type PlutusScripts = InstanceType<typeof csl.PlutusScripts>;
72
- export declare type PlutusScriptSource = InstanceType<typeof csl.PlutusScriptSource>;
73
- export declare type PlutusWitness = InstanceType<typeof csl.PlutusWitness>;
74
- export declare type PlutusWitnesses = InstanceType<typeof csl.PlutusWitnesses>;
75
- export declare type Pointer = InstanceType<typeof csl.Pointer>;
76
- export declare type PointerAddress = InstanceType<typeof csl.PointerAddress>;
77
- export declare type PoolMetadata = InstanceType<typeof csl.PoolMetadata>;
78
- export declare type PoolMetadataHash = InstanceType<typeof csl.PoolMetadataHash>;
79
- export declare type PoolParams = InstanceType<typeof csl.PoolParams>;
80
- export declare type PoolRegistration = InstanceType<typeof csl.PoolRegistration>;
81
- export declare type PoolRetirement = InstanceType<typeof csl.PoolRetirement>;
82
- export declare type PrivateKey = InstanceType<typeof csl.PrivateKey>;
83
- export declare type ProposedProtocolParameterUpdates = InstanceType<typeof csl.ProposedProtocolParameterUpdates>;
84
- export declare type ProtocolParamUpdate = InstanceType<typeof csl.ProtocolParamUpdate>;
85
- export declare type ProtocolVersion = InstanceType<typeof csl.ProtocolVersion>;
86
- export declare type PublicKey = InstanceType<typeof csl.PublicKey>;
87
- export declare type PublicKeys = InstanceType<typeof csl.PublicKeys>;
88
- export declare type Redeemer = InstanceType<typeof csl.Redeemer>;
89
- export declare type RedeemerTag = InstanceType<typeof csl.RedeemerTag>;
90
- export declare type Redeemers = InstanceType<typeof csl.Redeemers>;
91
- export declare type Relay = InstanceType<typeof csl.Relay>;
92
- export declare type Relays = InstanceType<typeof csl.Relays>;
93
- export declare type RewardAddress = InstanceType<typeof csl.RewardAddress>;
94
- export declare type RewardAddresses = InstanceType<typeof csl.RewardAddresses>;
95
- export declare type ScriptAll = InstanceType<typeof csl.ScriptAll>;
96
- export declare type ScriptAny = InstanceType<typeof csl.ScriptAny>;
97
- export declare type ScriptDataHash = InstanceType<typeof csl.ScriptDataHash>;
98
- export declare type ScriptHash = InstanceType<typeof csl.ScriptHash>;
99
- export declare type ScriptHashes = InstanceType<typeof csl.ScriptHashes>;
100
- export declare type ScriptNOfK = InstanceType<typeof csl.ScriptNOfK>;
101
- export declare type ScriptPubkey = InstanceType<typeof csl.ScriptPubkey>;
102
- export declare type ScriptRef = InstanceType<typeof csl.ScriptRef>;
103
- export declare type SingleHostAddr = InstanceType<typeof csl.SingleHostAddr>;
104
- export declare type SingleHostName = InstanceType<typeof csl.SingleHostName>;
105
- export declare type StakeCredential = InstanceType<typeof csl.StakeCredential>;
106
- export declare type StakeCredentials = InstanceType<typeof csl.StakeCredentials>;
107
- export declare type StakeDelegation = InstanceType<typeof csl.StakeDelegation>;
108
- export declare type StakeRegistration = InstanceType<typeof csl.StakeRegistration>;
109
- export declare type Strings = InstanceType<typeof csl.Strings>;
110
- export declare type TimelockExpiry = InstanceType<typeof csl.TimelockExpiry>;
111
- export declare type TimelockStart = InstanceType<typeof csl.TimelockStart>;
112
- export declare type Transaction = InstanceType<typeof csl.Transaction>;
113
- export declare type TransactionBodies = InstanceType<typeof csl.TransactionBodies>;
114
- export declare type TransactionBody = InstanceType<typeof csl.TransactionBody>;
115
- export declare type TransactionBuilder = InstanceType<typeof csl.TransactionBuilder>;
116
- export declare type TransactionBuilderConfig = InstanceType<typeof csl.TransactionBuilderConfig>;
117
- export declare type TransactionBuilderConfigBuilder = InstanceType<typeof csl.TransactionBuilderConfigBuilder>;
118
- export declare type TransactionHash = InstanceType<typeof csl.TransactionHash>;
119
- export declare type TransactionInput = InstanceType<typeof csl.TransactionInput>;
120
- export declare type TransactionInputs = InstanceType<typeof csl.TransactionInputs>;
121
- export declare type TransactionMetadatum = InstanceType<typeof csl.TransactionMetadatum>;
122
- export declare type TransactionMetadatumLabels = InstanceType<typeof csl.TransactionMetadatumLabels>;
123
- export declare type TransactionOutput = InstanceType<typeof csl.TransactionOutput>;
124
- export declare type TransactionOutputAmountBuilder = InstanceType<typeof csl.TransactionOutputAmountBuilder>;
125
- export declare type TransactionOutputBuilder = InstanceType<typeof csl.TransactionOutputBuilder>;
126
- export declare type TransactionOutputs = InstanceType<typeof csl.TransactionOutputs>;
127
- export declare type TransactionUnspentOutput = InstanceType<typeof csl.TransactionUnspentOutput>;
128
- export declare type TransactionUnspentOutputs = InstanceType<typeof csl.TransactionUnspentOutputs>;
129
- export declare type TransactionWitnessSet = InstanceType<typeof csl.TransactionWitnessSet>;
130
- export declare type TransactionWitnessSets = InstanceType<typeof csl.TransactionWitnessSets>;
131
- export declare type TxBuilderConstants = InstanceType<typeof csl.TxBuilderConstants>;
132
- export declare type TxInputsBuilder = InstanceType<typeof csl.TxInputsBuilder>;
133
- export declare type URL = InstanceType<typeof csl.URL>;
134
- export declare type UnitInterval = InstanceType<typeof csl.UnitInterval>;
135
- export declare type Update = InstanceType<typeof csl.Update>;
136
- export declare type VRFCert = InstanceType<typeof csl.VRFCert>;
137
- export declare type VRFKeyHash = InstanceType<typeof csl.VRFKeyHash>;
138
- export declare type VRFVKey = InstanceType<typeof csl.VRFVKey>;
139
- export declare type Value = InstanceType<typeof csl.Value>;
140
- export declare type Vkey = InstanceType<typeof csl.Vkey>;
141
- export declare type Vkeys = InstanceType<typeof csl.Vkeys>;
142
- export declare type Vkeywitness = InstanceType<typeof csl.Vkeywitness>;
143
- export declare type Vkeywitnesses = InstanceType<typeof csl.Vkeywitnesses>;
144
- export declare type Withdrawals = InstanceType<typeof csl.Withdrawals>;
@@ -1,8 +0,0 @@
1
- export * from './CIP2';
2
- export * from './CIP8';
3
- export * from './CIP14';
4
- export * from './CIP25';
5
- export * from './CIP1852';
6
- export * from './CIP1853';
7
- export * from './CIP1855';
8
- export * from './CSL';
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export * from './common/contracts';
2
- export * from './common/types';
3
- export * from './common/utils/resolver';
4
- export * from './core/CIP2';
5
- export * from './providers';
6
- export * from './scripts';
7
- export * from './transaction';
8
- export * from './wallet';
package/dist/meshjs.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const vt=require("bip39"),ke=require("@emurgo/cardano-serialization-lib-nodejs"),Fe=require("axios"),_=require("@emurgo/cardano-message-signing-nodejs"),He=require("nanoid"),Ne=s=>s&&typeof s=="object"&&"default"in s?s:{default:s};function Pe(s){if(s&&s.__esModule)return s;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const a=Pe(ke),rt=Ne(Fe),Me={mem:7e6,steps:3e9},M={epoch:0,coinsPerUTxOSize:"4310",priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:"2000000",maxTxSize:16384,maxValSize:"5000",poolDeposit:"500000000",maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},St=2147483648,bt={V1:a.Language.new_plutus_v1(),V2:a.Language.new_plutus_v2()},L=56,Te={CERT:a.RedeemerTag.new_cert(),MINT:a.RedeemerTag.new_mint(),REWARD:a.RedeemerTag.new_reward(),SPEND:a.RedeemerTag.new_spend()},_t={testnet:["74","1598400","1595967616","432000"],preview:["0","0","1660003200","86400"],preprod:["0","0","1654041600","432000"],mainnet:["208","4492800","1596059091","432000"]},Yt={ALONZO:a.TxBuilderConstants.plutus_alonzo_cost_models(),BABBAGE:a.TxBuilderConstants.plutus_vasil_cost_models()},Ve={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}};a.NetworkInfo.testnet().network_id()+"",a.NetworkInfo.mainnet().network_id()+"";const Gt=["begin","eternl","flint","nami","nufi","gerowallet","typhoncip30"],at=s=>a.Address.from_bytes(g(s)),Oe=s=>a.Bip32PrivateKey.from_bytes(g(s)),Ye=s=>a.DataHash.from_bytes(g(s)),U=s=>a.Ed25519KeyHash.from_bytes(g(s)),gt=s=>a.NativeScript.from_bytes(g(s)),Ge=s=>a.PlutusData.from_bytes(g(s)),pt=(s,e)=>a.PlutusScript.from_bytes_with_version(g(s),bt[e]),Re=s=>a.ScriptRef.from_bytes(g(s)),Le=s=>a.ScriptHash.from_bytes(g(s)),q=s=>a.Transaction.from_bytes(g(s)),he=s=>a.TransactionHash.from_bytes(g(s)),Rt=s=>a.TransactionUnspentOutput.from_bytes(g(s)),qe=s=>a.TransactionWitnessSet.from_bytes(g(s)),ze=s=>a.Value.from_bytes(g(s)),k=s=>a.Address.from_bech32(s),Ut=s=>a.BaseAddress.from_address(k(s)),ue=s=>a.EnterpriseAddress.from_address(k(s)),de=s=>a.RewardAddress.from_address(k(s)),j=s=>Buffer.from(s).toString("hex"),g=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?Buffer.from(s,"hex"):Buffer.from(s,"utf-8"),kt=s=>{const e=t=>{const r=new Array;for(let i=0;i<t.len();i+=1)r.push(kt(t.get(i)));return r};switch(s.kind()){case a.NativeScriptKind.ScriptAll:{const t=s.as_script_all();return{type:"all",scripts:e(t.native_scripts())}}case a.NativeScriptKind.ScriptAny:{const t=s.as_script_any();return{type:"any",scripts:e(t.native_scripts())}}case a.NativeScriptKind.ScriptNOfK:{const t=s.as_script_n_of_k();return{type:"atLeast",required:t.n(),scripts:e(t.native_scripts())}}case a.NativeScriptKind.TimelockStart:{const t=s.as_timelock_start();return{type:"after",slot:t.slot_bignum().to_str()}}case a.NativeScriptKind.TimelockExpiry:{const t=s.as_timelock_expiry();return{type:"before",slot:t.slot_bignum().to_str()}}case a.NativeScriptKind.ScriptPubkey:{const t=s.as_script_pubkey();return{type:"sig",keyHash:t.addr_keyhash().to_hex()}}default:throw new Error(`Script Kind: ${s.kind()}, is not supported`)}},Bt=s=>{const e=t=>{const r=a.NativeScripts.new();return t.forEach(i=>{r.add(Bt(i))}),r};switch(s.type){case"all":return a.NativeScript.new_script_all(a.ScriptAll.new(e(s.scripts)));case"any":return a.NativeScript.new_script_any(a.ScriptAny.new(e(s.scripts)));case"atLeast":return a.NativeScript.new_script_n_of_k(a.ScriptNOfK.new(s.required,e(s.scripts)));case"after":return a.NativeScript.new_timelock_start(a.TimelockStart.new_timelockstart(a.BigNum.from_str(s.slot)));case"before":return a.NativeScript.new_timelock_expiry(a.TimelockExpiry.new_timelockexpiry(a.BigNum.from_str(s.slot)));case"sig":return a.NativeScript.new_script_pubkey(a.ScriptPubkey.new(U(s.keyHash)))}},W=s=>{const e=t=>{const r=a.PlutusList.new();return t.forEach(i=>{r.add(W(i))}),r};switch(typeof s){case"string":return a.PlutusData.new_bytes(g(s));case"number":return a.PlutusData.new_integer(a.BigInt.from_str(s.toString()));case"object":if(s instanceof Array){const t=e(s);return a.PlutusData.new_list(t)}else if(s instanceof Map){const t=a.PlutusMap.new();return s.forEach((r,i)=>{t.insert(W(i),W(r))}),a.PlutusData.new_map(t)}else return a.PlutusData.new_constr_plutus_data(a.ConstrPlutusData.new(a.BigNum.from_str(s.alternative.toString()),e(s.fields)))}},$e=s=>{const e=a.Relays.new();throw s.relays.forEach(t=>{e.add(We(t))}),new Error("toPoolParams not implemented.")},Je=s=>{const e=t=>Te[t];return a.Redeemer.new(e(s.tag),a.BigNum.from_str(s.index.toString()),W(s.data),a.ExUnits.new(a.BigNum.from_str(s.budget.mem.toString()),a.BigNum.from_str(s.budget.steps.toString())))},We=s=>{switch(s.type){case"SingleHostAddr":{const e=s.IPV4?a.Ipv4.new(new Uint8Array(s.IPV4.split(".").map(r=>parseInt(r)))):void 0,t=s.IPV6?a.Ipv6.new(g(s.IPV6.replaceAll(":",""))):void 0;return a.Relay.new_single_host_addr(a.SingleHostAddr.new(s.port,e,t))}case"SingleHostName":return a.Relay.new_single_host_name(a.SingleHostName.new(s.port,a.DNSRecordAorAAAA.new(s.domainName)));case"MultiHostName":return a.Relay.new_multi_host_name(a.MultiHostName.new(a.DNSRecordSRV.new(s.domainName)))}},je=s=>{if(s.is_plutus_script()){const t=s.plutus_script();return{code:t.to_hex(),version:Object.keys(bt).find(r=>bt[r].to_hex()===t.language_version().to_hex())}}const e=s.native_script();return kt(e)},Qt=s=>{if("code"in s){const e=pt(s.code,s.version);return a.ScriptRef.new_plutus_script(e)}return a.ScriptRef.new_native_script(Bt(s))},wt=s=>{var i,n,o;const e=s.output().has_data_hash()?(i=s.output().data_hash())==null?void 0:i.to_hex():void 0,t=s.output().has_plutus_data()?(n=s.output().plutus_data())==null?void 0:n.to_hex():void 0,r=s.output().has_script_ref()?(o=s.output().script_ref())==null?void 0:o.to_hex():void 0;return{input:{outputIndex:s.input().index(),txHash:s.input().transaction_id().to_hex()},output:{address:s.output().address().to_bech32(),amount:le(s.output().amount()),dataHash:e,plutusData:t,scriptRef:r}}},R=s=>{const e=a.TransactionInput.new(he(s.input.txHash),s.input.outputIndex),t=a.TransactionOutput.new(k(s.output.address),ft(s.output.amount));return s.output.dataHash!==void 0&&t.set_data_hash(Ye(s.output.dataHash)),s.output.plutusData!==void 0&&t.set_plutus_data(Ge(s.output.plutusData)),s.output.scriptRef!==void 0&&t.set_script_ref(Re(s.output.scriptRef)),a.TransactionUnspentOutput.new(e,t)},Lt=s=>{const e=s.split(".")[1]??"0",t=`${parseInt(e,10)}`,r="1"+"0".repeat(e.length);return a.UnitInterval.new(a.BigNum.from_str(t),a.BigNum.from_str(r))},X=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?s:j(Buffer.from(s,"utf-8")),Xe=s=>Buffer.from(s,"hex").toString("utf-8"),le=s=>{const e=[{unit:"lovelace",quantity:s.coin().to_str()}],t=s.multiasset();if(t!==void 0){const r=t.keys();for(let i=0;i<r.len();i+=1){const n=r.get(i),o=t.get(n);if(o!==void 0){const c=o.keys();for(let A=0;A<c.len();A+=1){const u=c.get(A),I=o.get(u)??a.BigNum.from_str("0"),h=n.to_hex()+j(u.name());e.push({unit:h,quantity:I.to_str()})}}}}return e},ft=s=>{const e=s.find(n=>n.unit==="lovelace"),t=Array.from(new Set(s.filter(n=>n.unit!=="lovelace").map(n=>n.unit.slice(0,L)))),r=a.MultiAsset.new();t.forEach(n=>{const o=a.Assets.new();s.filter(c=>c.unit.slice(0,L)===n).forEach(c=>{o.insert(a.AssetName.new(g(c.unit.slice(L))),a.BigNum.from_str(c.quantity))}),r.insert(Le(n),o)});const i=a.Value.new(a.BigNum.from_str(e?e.quantity:"0"));return(s.length>1||!e)&&i.set_multiasset(r),i},qt=(s,e,t)=>a.BaseAddress.new(s,a.StakeCredential.from_keyhash(e),a.StakeCredential.from_keyhash(t)),ge=(s,e="")=>a.Bip32PrivateKey.from_bip39_entropy(g(s),g(X(e))),zt=s=>a.DataCost.new_coins_per_byte(a.BigNum.from_str(s)),Ze=s=>{if(typeof s!="object"||!("input"in s))return a.DatumSource.new(W(s));const e=R(s);if(e.output().has_plutus_data())return a.DatumSource.new_ref_input(e.input());throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`)},$t=(s,e)=>a.EnterpriseAddress.new(s,a.StakeCredential.from_keyhash(e)),Kt=(s,e)=>a.RewardAddress.new(s,a.StakeCredential.from_keyhash(e)),ts=s=>{if("code"in s)return a.PlutusScriptSource.new(pt(s.code,s.version));const e=R(s);if(e.output().has_script_ref()){const t=e.output().script_ref();if(t.is_plutus_script()){const r=je(t),i=pt(r.code,r.version).hash();return a.PlutusScriptSource.new_ref_input(i,e.input())}}throw new Error(`No plutus script reference found in UTxO: ${e.input().transaction_id().to_hex()}`)},ht=s=>{const e=a.ScriptPubkey.new(s);return a.NativeScript.new_script_pubkey(e)},es=(s=M)=>{const e=a.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(a.BigNum.from_str(s.coinsPerUTxOSize)).ex_unit_prices(a.ExUnitPrices.new(Lt(s.priceMem.toString()),Lt(s.priceStep.toString()))).fee_algo(a.LinearFee.new(a.BigNum.from_str(s.minFeeA.toString()),a.BigNum.from_str(s.minFeeB.toString()))).key_deposit(a.BigNum.from_str(s.keyDeposit)).max_tx_size(s.maxTxSize).max_value_size(parseInt(s.maxValSize,10)).pool_deposit(a.BigNum.from_str(s.poolDeposit)).build();return a.TransactionBuilder.new(e)},Jt=s=>{const e=a.TxInputsBuilder.new();return s.map(t=>t instanceof a.TransactionUnspentOutput?t:R(t)).forEach(t=>{e.add_input(t.output().address(),t.input(),t.output().amount())}),e},ut=s=>{if(typeof s=="string")return a.TransactionOutputBuilder.new().with_address(k(s));let e=a.TransactionOutputBuilder.new().with_address(k(s.address));if(s.datum){const{value:t,inline:r}=s.datum,i=W(t);e=e.with_data_hash(a.hash_plutus_data(i)),r&&(e=e.with_plutus_data(i))}if(s.script){const t=Qt(s.script);e=e.with_script_ref(t)}return e},C=s=>rt.default.isAxiosError(s)?s.response?JSON.stringify({data:s.response.data,headers:s.response.headers,status:s.response.status}):s.request?JSON.stringify(s.request):s.message:JSON.stringify(s),fe=(s,e,t=!1,{maxTxSize:r,minFeeA:i,minFeeB:n}=M)=>{const o=e.filter(h=>pe(h)===!1).sort(_e),c=a.BigNum.from_str(Nt(r,i,n)),A=t?a.BigNum.from_str(s).checked_add(c).to_str():s;return yt(o,new Map([["lovelace",A]]))},Ce=(s,e,t=!1,r=M)=>{const i=e.filter(pe).sort(_e),n=s.get("lovelace")??"0",{maxTxSize:o,minFeeA:c,minFeeB:A}=r,u=a.BigNum.from_str(Nt(o,c,A)),I=t?a.BigNum.from_str(n).checked_add(u).to_str():n;return s.set("lovelace",I),yt(i,s)},ss=(s,e)=>Array.from(e,t=>({unit:t[0],quantity:a.BigNum.from_str(t[1])})).every(t=>s.filter(r=>r.output.amount.find(i=>i.unit===t.unit)!==void 0).reduce((r,i)=>{const n=i.output.amount.reduce((o,c)=>o.checked_add(a.BigNum.from_str(c.quantity)),a.BigNum.from_str("0"));return r.checked_add(n)},a.BigNum.from_str("0")).less_than(t.quantity)===!1),_e=(s,e)=>{var i,n;const t=a.BigNum.from_str(((i=s.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:i.quantity)??"0");return a.BigNum.from_str(((n=e.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:n.quantity)??"0").compare(t)},pe=s=>s.output.amount.length>1,yt=(s,e,t=[])=>s.length===0||ss(t,e)?t:rs(s[0],e)?yt(s.slice(1),e,[...t,s[0]]):yt(s.slice(1),e,t),rs=(s,e)=>Array.from(e.keys()).some(t=>s.output.amount.find(r=>r.unit===t)!==void 0),is=(s,e)=>{const t=as(e),r=ns(s,e);return{coseKey:j(t.to_bytes()),coseSign1:j(r.to_bytes())}},as=s=>{const e=_.COSEKey.new(_.Label.from_key_type(_.KeyType.OKP));return e.set_algorithm_id(_.Label.from_algorithm_id(_.AlgorithmId.EdDSA)),e.set_header(_.Label.new_int(_.Int.new_negative(_.BigNum.from_str("1"))),_.CBORValue.new_int(_.Int.new_i32(6))),e.set_header(_.Label.new_int(_.Int.new_negative(_.BigNum.from_str("2"))),_.CBORValue.new_bytes(s.key.to_public().as_bytes())),e},ns=(s,e)=>{const t=_.HeaderMap.new(),r=_.HeaderMap.new();t.set_algorithm_id(_.Label.from_algorithm_id(_.AlgorithmId.EdDSA)),t.set_header(_.Label.new_text("address"),_.CBORValue.new_bytes(e.address.to_bytes()));const i=_.Headers.new(_.ProtectedHeaderMap.new(t),r),n=_.COSESign1Builder.new(i,g(s.payload),!1);s.externalAAD!==void 0&&n.set_external_aad(g(s.externalAAD));const o=n.make_data_to_sign(),c=e.key.sign(o.to_bytes());return n.build(c.to_bytes())};var Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},we={},Q={exports:{}};T.notEqual=As;T.notOk=cs;T.equal=os;T.ok=T;var ye=T;function os(s,e,t){T(s==e,t)}function As(s,e,t){T(s!=e,t)}function cs(s,e){T(!s,e)}function T(s,e){if(!s)throw new Error(e||"AssertionError")}var F={exports:{}};function Is(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var hs=Ft;Ft.supported=typeof WebAssembly<"u";function Ft(s){if(!Ft.supported)return null;var e=s&&s.imports,t=us("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMK00AElgMAIABCADcDACAAQQhqQgA3AwAgAEEQakIANwMAIABBGGpCADcDACAAQSBqQgA3AwAgAEEoakIANwMAIABBMGpCADcDACAAQThqQgA3AwAgAEHAAGpCADcDACAAQcgAakIANwMAIABB0ABqQgA3AwAgAEHYAGpCADcDACAAQeAAakIANwMAIABB6ABqQgA3AwAgAEHwAGpCADcDACAAQfgAakIANwMAIABBgAFqQoiS853/zPmE6gBBACkDAIU3AwAgAEGIAWpCu86qptjQ67O7f0EIKQMAhTcDACAAQZABakKr8NP0r+68tzxBECkDAIU3AwAgAEGYAWpC8e30+KWn/aelf0EYKQMAhTcDACAAQaABakLRhZrv+s+Uh9EAQSApAwCFNwMAIABBqAFqQp/Y+dnCkdqCm39BKCkDAIU3AwAgAEGwAWpC6/qG2r+19sEfQTApAwCFNwMAIABBuAFqQvnC+JuRo7Pw2wBBOCkDAIU3AwAgAEHAAWpCADcDACAAQcgBakIANwMAIABB0AFqQgA3AwALbQEDfyAAQcABaiEDIABByAFqIQQgBCkDAKchBQJAA0AgASACRg0BIAVBgAFGBEAgAyADKQMAIAWtfDcDAEEAIQUgABADCyAAIAVqIAEtAAA6AAAgBUEBaiEFIAFBAWohAQwACwsgBCAFrTcDAAtkAQN/IABBwAFqIQEgAEHIAWohAiABIAEpAwAgAikDAHw3AwAgAEHQAWpCfzcDACACKQMApyEDAkADQCADQYABRg0BIAAgA2pBADoAACADQQFqIQMMAAsLIAIgA603AwAgABADC+U7AiB+CX8gAEGAAWohISAAQYgBaiEiIABBkAFqISMgAEGYAWohJCAAQaABaiElIABBqAFqISYgAEGwAWohJyAAQbgBaiEoICEpAwAhASAiKQMAIQIgIykDACEDICQpAwAhBCAlKQMAIQUgJikDACEGICcpAwAhByAoKQMAIQhCiJLznf/M+YTqACEJQrvOqqbY0Ouzu38hCkKr8NP0r+68tzwhC0Lx7fT4paf9p6V/IQxC0YWa7/rPlIfRACENQp/Y+dnCkdqCm38hDkLr+obav7X2wR8hD0L5wvibkaOz8NsAIRAgACkDACERIABBCGopAwAhEiAAQRBqKQMAIRMgAEEYaikDACEUIABBIGopAwAhFSAAQShqKQMAIRYgAEEwaikDACEXIABBOGopAwAhGCAAQcAAaikDACEZIABByABqKQMAIRogAEHQAGopAwAhGyAAQdgAaikDACEcIABB4ABqKQMAIR0gAEHoAGopAwAhHiAAQfAAaikDACEfIABB+ABqKQMAISAgDSAAQcABaikDAIUhDSAPIABB0AFqKQMAhSEPIAEgBSARfHwhASANIAGFQiCKIQ0gCSANfC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bfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgFXx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBl8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAafHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgIHx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIB58fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAXfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgEnx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIB18fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByARfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgE3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBx8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAYfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgFnx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBR8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFICEgISkDACABIAmFhTcDACAiICIpAwAgAiAKhYU3AwAgIyAjKQMAIAMgC4WFNwMAICQgJCkDACAEIAyFhTcDACAlICUpAwAgBSANhYU3AwAgJiAmKQMAIAYgDoWFNwMAICcgJykDACAHIA+FhTcDACAoICgpAwAgCCAQhYU3AwAL"),r=null,i={buffer:t,memory:null,exports:null,realloc:n,onload:o};return o(function(){}),i;function n(A){i.exports.memory.grow(Math.ceil(Math.abs(A-i.memory.length)/65536)),i.memory=new Uint8Array(i.exports.memory.buffer)}function o(A){if(i.exports)return A();if(r){r.then(A.bind(null,null)).catch(A);return}try{if(s&&s.async)throw new Error("async");c({instance:new WebAssembly.Instance(new WebAssembly.Module(t),e)})}catch{r=WebAssembly.instantiate(t,e).then(c)}o(A)}function c(A){i.exports=A.instance.exports,i.memory=i.exports.memory&&i.exports.memory.buffer&&new Uint8Array(i.exports.memory.buffer)}}function us(s){return typeof atob=="function"?new Uint8Array(atob(s).split("").map(ds)):new(Is("buffer")).Buffer(s,"base64")}function ds(s){return s.charCodeAt(0)}var K=ye,f=hs(),P=64,Ct=[];F.exports=x;var jt=F.exports.BYTES_MIN=16,Xt=F.exports.BYTES_MAX=64;F.exports.BYTES=32;var Zt=F.exports.KEYBYTES_MIN=16,te=F.exports.KEYBYTES_MAX=64;F.exports.KEYBYTES=32;var ee=F.exports.SALTBYTES=16,se=F.exports.PERSONALBYTES=16;function x(s,e,t,r,i){if(!(this instanceof x))return new x(s,e,t,r,i);if(!(f&&f.exports))throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");s||(s=32),i!==!0&&(K(s>=jt,"digestLength must be at least "+jt+", was given "+s),K(s<=Xt,"digestLength must be at most "+Xt+", was given "+s),e!=null&&K(e.length>=Zt,"key must be at least "+Zt+", was given "+e.length),e!=null&&K(e.length<=te,"key must be at least "+te+", was given "+e.length),t!=null&&K(t.length===ee,"salt must be exactly "+ee+", was given "+t.length),r!=null&&K(r.length===se,"personal must be exactly "+se+", was given "+r.length)),Ct.length||(Ct.push(P),P+=216),this.digestLength=s,this.finalized=!1,this.pointer=Ct.pop(),f.memory.fill(0,0,64),f.memory[0]=this.digestLength,f.memory[1]=e?e.length:0,f.memory[2]=1,f.memory[3]=1,t&&f.memory.set(t,32),r&&f.memory.set(r,48),this.pointer+216>f.memory.length&&f.realloc(this.pointer+216),f.exports.blake2b_init(this.pointer,this.digestLength),e&&(this.update(e),f.memory.fill(0,P,P+e.length),f.memory[this.pointer+200]=128)}x.prototype.update=function(s){return K(this.finalized===!1,"Hash instance finalized"),K(s,"input must be TypedArray or Buffer"),P+s.length>f.memory.length&&f.realloc(P+s.length),f.memory.set(s,P),f.exports.blake2b_update(this.pointer,P,P+s.length),this};x.prototype.digest=function(s){if(K(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,Ct.push(this.pointer),f.exports.blake2b_final(this.pointer),!s||s==="binary")return f.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(s==="hex")return gs(f.memory,this.pointer+128,this.digestLength);K(s.length>=this.digestLength,"input must be TypedArray or Buffer");for(var e=0;e<this.digestLength;e++)s[e]=f.memory[this.pointer+128+e];return s};x.prototype.final=x.prototype.digest;x.WASM=f&&f.buffer;x.SUPPORTED=typeof WebAssembly<"u";x.ready=function(s){if(s||(s=ls),!f)return s(new Error("WebAssembly not supported"));var e=new Promise(function(t,r){f.onload(function(i){i?r():t(),s(i)})});return e};x.prototype.ready=x.ready;function ls(){}function gs(s,e,t){for(var r="",i=0;i<t;i++)r+=fs(s[e+i]);return r}function fs(s){return s<16?"0"+s.toString(16):s.toString(16)}var G=ye,ct=F.exports;function dt(s,e,t){var r=s[e]+s[t],i=s[e+1]+s[t+1];r>=4294967296&&i++,s[e]=r,s[e+1]=i}function re(s,e,t,r){var i=s[e]+t;t<0&&(i+=4294967296);var n=s[e+1]+r;i>=4294967296&&n++,s[e]=i,s[e+1]=n}function Ee(s,e){return s[e]^s[e+1]<<8^s[e+2]<<16^s[e+3]<<24}function O(s,e,t,r,i,n){var o=nt[i],c=nt[i+1],A=nt[n],u=nt[n+1];dt(d,s,e),re(d,s,o,c);var I=d[r]^d[s],h=d[r+1]^d[s+1];d[r]=h,d[r+1]=I,dt(d,t,r),I=d[e]^d[t],h=d[e+1]^d[t+1],d[e]=I>>>24^h<<8,d[e+1]=h>>>24^I<<8,dt(d,s,e),re(d,s,A,u),I=d[r]^d[s],h=d[r+1]^d[s+1],d[r]=I>>>16^h<<16,d[r+1]=h>>>16^I<<16,dt(d,t,r),I=d[e]^d[t],h=d[e+1]^d[t+1],d[e]=h>>>31^I<<1,d[e+1]=I>>>31^h<<1}var me=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Cs=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],m=new Uint8Array(Cs.map(function(s){return s*2})),d=new Uint32Array(32),nt=new Uint32Array(32);function Be(s,e){var t=0;for(t=0;t<16;t++)d[t]=s.h[t],d[t+16]=me[t];for(d[24]=d[24]^s.t,d[25]=d[25]^s.t/4294967296,e&&(d[28]=~d[28],d[29]=~d[29]),t=0;t<32;t++)nt[t]=Ee(s.b,4*t);for(t=0;t<12;t++)O(0,8,16,24,m[t*16+0],m[t*16+1]),O(2,10,18,26,m[t*16+2],m[t*16+3]),O(4,12,20,28,m[t*16+4],m[t*16+5]),O(6,14,22,30,m[t*16+6],m[t*16+7]),O(0,10,20,30,m[t*16+8],m[t*16+9]),O(2,12,22,24,m[t*16+10],m[t*16+11]),O(4,14,16,26,m[t*16+12],m[t*16+13]),O(6,8,18,28,m[t*16+14],m[t*16+15]);for(t=0;t<16;t++)s.h[t]=s.h[t]^d[t]^d[t+16]}var Y=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function et(s,e,t,r){Y.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=s,Y[0]=s,e&&(Y[1]=e.length),Y[2]=1,Y[3]=1,t&&Y.set(t,32),r&&Y.set(r,48);for(var i=0;i<16;i++)this.h[i]=me[i]^Ee(Y,i*4);e&&(Qe(this,e),this.c=128)}et.prototype.update=function(s){return G(s!=null,"input must be Uint8Array or Buffer"),Qe(this,s),this};et.prototype.digest=function(s){var e=!s||s==="binary"||s==="hex"?new Uint8Array(this.outlen):s;return G(e.length>=this.outlen,"out must have at least outlen bytes of space"),_s(this,e),s==="hex"?ps(e):e};et.prototype.final=et.prototype.digest;et.ready=function(s){ct.ready(function(){s()})};function Qe(s,e){for(var t=0;t<e.length;t++)s.c===128&&(s.t+=s.c,Be(s,!1),s.c=0),s.b[s.c++]=e[t]}function _s(s,e){for(s.t+=s.c;s.c<128;)s.b[s.c++]=0;Be(s,!0);for(var t=0;t<s.outlen;t++)e[t]=s.h[t>>2]>>8*(t&3);return e}function ps(s){for(var e="",t=0;t<s.length;t++)e+=ws(s[t]);return e}function ws(s){return s<16?"0"+s.toString(16):s.toString(16)}var xe=et;Q.exports=function(e,t,r,i,n){return n!==!0&&(G(e>=ie,"outlen must be at least "+ie+", was given "+e),G(e<=ae,"outlen must be at most "+ae+", was given "+e),t!=null&&G(t.length>=ne,"key must be at least "+ne+", was given "+t.length),t!=null&&G(t.length<=oe,"key must be at most "+oe+", was given "+t.length),r!=null&&G(r.length===Ae,"salt must be exactly "+Ae+", was given "+r.length),i!=null&&G(i.length===ce,"personal must be exactly "+ce+", was given "+i.length)),new xe(e,t,r,i)};Q.exports.ready=function(s){ct.ready(function(){s()})};Q.exports.WASM_SUPPORTED=ct.SUPPORTED;Q.exports.WASM_LOADED=!1;var ie=Q.exports.BYTES_MIN=16,ae=Q.exports.BYTES_MAX=64;Q.exports.BYTES=32;var ne=Q.exports.KEYBYTES_MIN=16,oe=Q.exports.KEYBYTES_MAX=64;Q.exports.KEYBYTES=32;var Ae=Q.exports.SALTBYTES=16,ce=Q.exports.PERSONALBYTES=16;ct.ready(function(s){s||(Q.exports.WASM_LOADED=!0,xe=ct)});var st={};Object.defineProperty(st,"__esModule",{value:!0});st.bech32m=st.bech32=void 0;const Et="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Se={};for(let s=0;s<Et.length;s++){const e=Et.charAt(s);Se[e]=s}function tt(s){const e=s>>25;return(s&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Ie(s){let e=1;for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);if(r<33||r>126)return"Invalid prefix ("+s+")";e=tt(e)^r>>5}e=tt(e);for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);e=tt(e)^r&31}return e}function Ht(s,e,t,r){let i=0,n=0;const o=(1<<t)-1,c=[];for(let A=0;A<s.length;++A)for(i=i<<e|s[A],n+=e;n>=t;)n-=t,c.push(i>>n&o);if(r)n>0&&c.push(i<<t-n&o);else{if(n>=e)return"Excess padding";if(i<<t-n&o)return"Non-zero padding"}return c}function ys(s){return Ht(s,8,5,!0)}function Es(s){const e=Ht(s,5,8,!1);if(Array.isArray(e))return e}function ms(s){const e=Ht(s,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function De(s){let e;s==="bech32"?e=1:e=734539939;function t(o,c,A){if(A=A||90,o.length+7+c.length>A)throw new TypeError("Exceeds length limit");o=o.toLowerCase();let u=Ie(o);if(typeof u=="string")throw new Error(u);let I=o+"1";for(let h=0;h<c.length;++h){const p=c[h];if(p>>5!==0)throw new Error("Non 5-bit word");u=tt(u)^p,I+=Et.charAt(p)}for(let h=0;h<6;++h)u=tt(u);u^=e;for(let h=0;h<6;++h){const p=u>>(5-h)*5&31;I+=Et.charAt(p)}return I}function r(o,c){if(c=c||90,o.length<8)return o+" too short";if(o.length>c)return"Exceeds length limit";const A=o.toLowerCase(),u=o.toUpperCase();if(o!==A&&o!==u)return"Mixed-case string "+o;o=A;const I=o.lastIndexOf("1");if(I===-1)return"No separator character for "+o;if(I===0)return"Missing prefix for "+o;const h=o.slice(0,I),p=o.slice(I+1);if(p.length<6)return"Data too short";let v=Ie(h);if(typeof v=="string")return v;const $=[];for(let H=0;H<p.length;++H){const V=p.charAt(H),l=Se[V];if(l===void 0)return"Unknown character "+V;v=tt(v)^l,!(H+6>=p.length)&&$.push(l)}return v!==e?"Invalid checksum for "+o:{prefix:h,words:$}}function i(o,c){const A=r(o,c);if(typeof A=="object")return A}function n(o,c){const A=r(o,c);if(typeof A=="object")return A;throw new Error(A)}return{decodeUnsafe:i,decode:n,encode:t,toWords:ys,fromWordsUnsafe:Es,fromWords:ms}}st.bech32=De("bech32");st.bech32m=De("bech32m");var Bs=Wt&&Wt.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(we,"__esModule",{value:!0});const Qs=Bs(Q.exports),lt=st,Dt="asset";class At{constructor(e){this.hashBuf=e}static fromHash(e){return new At(e)}static fromParts(e,t){const r=(0,Qs.default)(20).update(new Uint8Array([...e,...t])).digest("binary");return At.fromHash(r)}static fromBech32(e){const{prefix:t,words:r}=lt.bech32.decode(e);if(t!==Dt)throw new Error("Invalid asset fingerprint");const i=Buffer.from(lt.bech32.fromWords(r));return At.fromHash(i)}fingerprint(){const e=lt.bech32.toWords(this.hashBuf);return lt.bech32.encode(Dt,e)}hash(){return Buffer.from(this.hashBuf).toString("hex")}prefix(){return Dt}checksum(){return this.fingerprint().slice(-6)}}var xs=we.default=At;const Ss=xs,Ds=(s,e)=>{const t=Oe(s),r=t.derive(St+1852).derive(St+1815).derive(St+e),i=r.derive(0).derive(0).to_raw_key(),n=r.derive(2).derive(0).to_raw_key();return r.free(),t.free(),{paymentKey:i,stakeKey:n}},vs=s=>{const e=W(s);return a.hash_plutus_data(e).to_hex()},bs=(s,e=Date.now())=>{if(_t[s]){const[t,r,i,n]=_t[s];return parseInt(a.BigNum.from_str(e.toString()).div_floor(a.BigNum.from_str("1000")).checked_sub(a.BigNum.from_str(i)).div_floor(a.BigNum.from_str(n)).checked_add(a.BigNum.from_str(t)).to_str(),10)}throw new Error(`Couldn't resolve EpochNo for network: ${s}`)},ve=(s,e)=>Ss.fromParts(g(s),g(e)).fingerprint(),Ks=(s,e)=>Ve[s][e],Us=s=>Bt(s).hash().to_hex(),J=s=>{var e,t;try{const r=[(e=Ut(s))==null?void 0:e.payment_cred().to_keyhash(),(t=ue(s))==null?void 0:t.payment_cred().to_keyhash()].find(i=>i!==void 0);if(r!==void 0)return r.to_hex();throw new Error(`Couldn't resolve payment key hash from address: ${s}`)}catch(r){throw new Error(`An error occurred during resolvePaymentKeyHash: ${r}.`)}},ks=(s,e=0)=>{const t=pt(s.code,s.version);return a.EnterpriseAddress.new(e,a.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32()},Fs=s=>{try{const e=ue(s),t=e==null?void 0:e.payment_cred().to_scripthash();if(t!==void 0)return t.to_hex();throw new Error(`Couldn't resolve script hash from address: ${s}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},Hs=s=>a.Ed25519KeyHash.from_hex(s).to_bech32("pool1"),Ns=s=>{const e=vt.mnemonicToEntropy(s.join(" ")),t=ge(e),r=t.to_bech32();return t.free(),r},Ps=s=>Qt(s).to_hex(),Ms=(s,e=Date.now())=>{if(_t[s]){const[t,r,i]=_t[s];return a.BigNum.from_str(e.toString()).div_floor(a.BigNum.from_str("1000")).checked_sub(a.BigNum.from_str(i)).checked_add(a.BigNum.from_str(r)).to_str()}throw new Error(`Couldn't resolve SlotNo for network: ${s}`)},xt=s=>{try{const e=k(s),t=Ut(s),r=t==null?void 0:t.stake_cred().to_keyhash();if(r!==void 0)return Kt(e.network_id(),r).to_address().to_bech32();throw new Error(`Couldn't resolve reward address from address: ${s}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},ot=s=>{var e,t;try{const r=[(e=Ut(s))==null?void 0:e.stake_cred().to_keyhash(),(t=de(s))==null?void 0:t.payment_cred().to_keyhash()].find(i=>i!==void 0);if(r!==void 0)return r.to_hex();throw new Error(`Couldn't resolve stake key hash from address: ${s}`)}catch(r){throw new Error(`An error occurred during resolveStakeKeyHash: ${r}.`)}},Nt=(s,e=M.minFeeA,t=M.minFeeB)=>(BigInt(e)*BigInt(s)+BigInt(t)).toString(),be=s=>{const e=q(s).body();return a.hash_transaction(e).to_hex()};class Ts{_axiosInstance;constructor(e,t=0){const r=e.slice(0,7);this._axiosInstance=rt.default.create({baseURL:`https://cardano-${r}.blockfrost.io/api/v${t}`,headers:{project_id:e}})}async fetchAccountInfo(e){const t=e.startsWith("addr")?xt(e):e;try{const{data:r,status:i}=await this._axiosInstance.get(`accounts/${t}`);if(i===200)return{active:r.active||r.active_epoch!==null,poolId:r.pool_id,balance:r.controlled_amount,rewards:r.withdrawable_amount,withdrawals:r.withdrawals_sum};throw C(r)}catch(r){throw C(r)}}async fetchAddressUTxOs(e,t){const r=t!==void 0?`/${t}`:"",i=`addresses/${e}/utxos`+r,n=async(A=1,u=[])=>{const{data:I,status:h}=await this._axiosInstance.get(`${i}?page=${A}`);if(h===200)return I.length>0?n(A+1,[...u,...await Promise.all(I.map(c))]):u;throw C(I)},o=async A=>{if(A){const{data:u,status:I}=await this._axiosInstance.get(`scripts/${A}`);if(I===200){const h=u.type.startsWith("plutus")?{code:await this.fetchPlutusScriptCBOR(A),version:u.type.replace("plutus","")}:await this.fetchNativeScriptJSON(A);return Qt(h).to_hex()}throw C(u)}},c=async A=>({input:{outputIndex:A.output_index,txHash:A.tx_hash},output:{address:e,amount:A.amount,dataHash:A.data_hash??void 0,plutusData:A.inline_datum??void 0,scriptRef:await o(A.reference_script_hash)}});try{return await n()}catch{return[]}}async fetchAssetMetadata(e){throw new Error("fetchAssetMetadata not implemented.")}async fetchHandleAddress(e){throw new Error("fetchHandleAddress not implemented.")}async fetchProtocolParameters(e=Number.NaN){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${isNaN(e)?"latest":e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_word,collateralPercent:t.collateral_percent,decentralisation:t.decentralisation_param,epoch:t.epoch,keyDeposit:t.key_deposit,maxBlockExMem:t.max_block_ex_mem,maxBlockExSteps:t.max_block_ex_steps,maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem,maxTxExSteps:t.max_tx_ex_steps,maxTxSize:t.max_tx_size,maxValSize:t.max_val_size,minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost,poolDeposit:t.pool_deposit,priceMem:t.price_mem,priceStep:t.price_step};throw C(t)}catch(t){throw C(t)}}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:i}=await this._axiosInstance.post("tx/submit",g(e),{headers:t});if(i===200)return r;throw C(r)}catch(t){throw C(t)}}async fetchPlutusScriptCBOR(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/cbor`);if(r===200)return t.cbor;throw C(t)}async fetchNativeScriptJSON(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/json`);if(r===200)return t.json;throw C(t)}}class Vs{_axiosInstance;constructor(e,t,r){const i=r.host??"ipfs.infura.io",n=r.port??5001,o=r.version??0;this._axiosInstance=rt.default.create({baseURL:`https://${i}:${n}/api/v${o}`,auth:{username:e,password:t}})}async uploadContent(e,t=!1){try{const r={"Content-Type":"multipart/form-data"},{data:i,status:n}=await this._axiosInstance.post(`add?recursive=${t}`,e,{headers:r});if(n===200)return i;throw C(i)}catch(r){throw C(r)}}}class Os{_axiosInstance;constructor(e,t=0){this._axiosInstance=rt.default.create({baseURL:`https://${e}.koios.rest/api/v${t}`})}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?xt(e):e,{data:r,status:i}=await this._axiosInstance.post("account_info",{_stake_addresses:[t]});if(i===200)return{poolId:r[0].delegated_pool,active:r[0].status==="registered",balance:r[0].total_balance.toString(),rewards:r[0].rewards_available,withdrawals:r[0].withdrawals};throw C(r)}catch(t){throw C(t)}}async fetchAddressUTxOs(e,t){const r=i=>{if(i){const n=i.type.startsWith("plutus")?{code:i.bytes,version:i.type.replace("plutus","")}:kt(gt(i.bytes));return Qt(n).to_hex()}};try{const{data:i,status:n}=await this._axiosInstance.post("address_info",{_addresses:[e]});if(n===200){const o=i.flatMap(c=>c.utxo_set).map(c=>({input:{outputIndex:c.tx_index,txHash:c.tx_hash},output:{address:e,amount:[{unit:"lovelace",quantity:c.value},...c.asset_list.map(A=>({unit:`${A.policy_id}${A.asset_name}`,quantity:`${A.quantity}`}))],dataHash:c.datum_hash??void 0,plutusData:c.inline_datum.bytes??void 0,scriptRef:r(c.reference_script)}}));return t!==void 0?o.filter(c=>c.output.amount.find(A=>A.unit===t)!==void 0):o}throw C(i)}catch{return[]}}async fetchAssetMetadata(e){throw new Error("fetchAssetMetadata not implemented.")}async fetchHandleAddress(e){throw new Error("fetchHandleAddress not implemented.")}async fetchProtocolParameters(e){try{const{data:t,status:r}=await this._axiosInstance.get(`epoch_params?_epoch_no=${e}`);if(r===200)return{coinsPerUTxOSize:t[0].coins_per_utxo_size,collateralPercent:t[0].collateral_percent,decentralisation:t[0].decentralisation,epoch:t[0].epoch_no,keyDeposit:t[0].key_deposit,maxBlockExMem:t[0].max_block_ex_mem.toString(),maxBlockExSteps:t[0].max_block_ex_steps.toString(),maxBlockHeaderSize:t[0].max_bh_size,maxBlockSize:t[0].max_block_size,maxCollateralInputs:t[0].max_collateral_inputs,maxTxExMem:t[0].max_tx_ex_mem.toString(),maxTxExSteps:t[0].max_tx_ex_steps.toString(),maxTxSize:t[0].max_tx_size,maxValSize:t[0].max_val_size.toString(),minFeeA:t[0].min_fee_a,minFeeB:t[0].min_fee_b,minPoolCost:t[0].min_pool_cost,poolDeposit:t[0].pool_deposit,priceMem:t[0].price_mem,priceStep:t[0].price_step};throw C(t)}catch(t){throw C(t)}}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:i}=await this._axiosInstance.post("submittx",g(e),{headers:t});if(i===202)return r;throw C(r)}catch(t){throw C(t)}}}class Ys{_axiosInstance;constructor(e,t,r,i=1){this._axiosInstance=rt.default.create({baseURL:`https://cardano-${e}.tangocrypto.com/${t}/v${i}`,headers:{"x-api-key":r}})}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?xt(e):e,{data:r,status:i}=await this._axiosInstance.get(`wallets/${t}`);if(i===200)return{poolId:r.pool_id,active:r.active,balance:r.controlled_total_stake,rewards:r.rewards_sum,withdrawals:r.withdrawals_sum};throw C(r)}catch(t){throw C(t)}}async fetchAddressUTxOs(e,t){const r=t!==void 0?`/assets/${t}`:"",i=`addresses/${e}${r}/utxos?size=50`,n=async(A="",u=[])=>{var p;const{data:I,status:h}=await this._axiosInstance.get(`${i}&cursor=${A}`);if(h===200)return I.cursor!==null&&((p=I.cursor)==null?void 0:p.length)>0?n(I.cursor,[...u,...I.data.map(c)]):I.data.map(c);throw C(I)},o=(A,u)=>{const I=[{unit:"lovelace",quantity:A.toString()}];return u.forEach(h=>{const p=X(h.asset_name);I.push({unit:`${h.policy_id}${p}`,quantity:h.quantity.toString()})}),I},c=A=>({input:{outputIndex:A.index,txHash:A.hash},output:{address:e,amount:o(A.value,A.assets)}});try{return await n()}catch{return[]}}async fetchAssetMetadata(e){throw new Error("fetchAssetMetadata not implemented.")}async fetchHandleAddress(e){throw new Error("fetchHandleAddress not implemented.")}async fetchProtocolParameters(e){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_size.toString(),collateralPercent:t.collateral_percent,decentralisation:t.decentralisation,epoch:t.epoch_no,keyDeposit:t.key_deposit.toString(),maxBlockExMem:t.max_block_ex_mem.toString(),maxBlockExSteps:t.max_block_ex_steps.toString(),maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem.toString(),maxTxExSteps:t.max_tx_ex_steps.toString(),maxTxSize:t.max_tx_size,maxValSize:t.max_val_size.toString(),minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost.toString(),poolDeposit:t.pool_deposit.toString(),priceMem:t.price_mem,priceStep:t.price_step};throw C(t)}catch(t){throw C(t)}}async submitTx(e){try{const t={"Content-Type":"application/json"},{data:r,status:i}=await this._axiosInstance.post("transactions/submit",{tx:e},{headers:t});if(i===200)return r.tx_id;throw C(r)}catch(t){throw C(t)}}}class Gs{static withOneSignature(e){const t=U(J(e));return ht(t).to_hex()}static withAtLeastNSignatures(e,t){const r=a.NativeScripts.new();e.forEach(n=>{const o=U(J(n));r.add(ht(o))});const i=a.ScriptNOfK.new(t,r);return a.NativeScript.new_script_any(i).to_hex()}static withAnySignature(e){const t=a.NativeScripts.new();e.forEach(i=>{const n=U(J(i));t.add(ht(n))});const r=a.ScriptAny.new(t);return a.NativeScript.new_script_any(r).to_hex()}static withAllSignatures(e){const t=a.NativeScripts.new();e.forEach(i=>{const n=U(J(i));t.add(ht(n))});const r=a.ScriptAll.new(t);return a.NativeScript.new_script_any(r).to_hex()}static fromNativeScript(e){return Bt(e).to_hex()}}function z(s,e,t,r){var i=arguments.length,n=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,r);else for(var c=s.length-1;c>=0;c--)(o=s[c])&&(n=(i<3?o(n):i>3?o(e,t,n):o(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n}const Rs=s=>class extends s{__visits=[]},Z=()=>function(s,e,t){const r=t.value;t.value=function(...i){const n=r.call(this,...i);return this.__visits&&this.__visits.push(e),n}};exports.Transaction=class{_changeAddress;_recipients=new Map;_totalBurns=new Map;_totalMints=new Map;_era;_initiator;_protocolParameters;_txBuilder;_txCertificates;_txInputsBuilder;_txWithdrawals;constructor(e={}){this._era=e.era,this._initiator=e.initiator,this._protocolParameters=e.parameters??M,this._txBuilder=es(e.parameters),this._txCertificates=a.Certificates.new(),this._txInputsBuilder=a.TxInputsBuilder.new(),this._txWithdrawals=a.Withdrawals.new()}static maskMetadata(e){var i;const t=q(e),r=(i=t.auxiliary_data())==null?void 0:i.metadata();if(r!==void 0){const n=a.GeneralTransactionMetadata.new();for(let c=0;c<r.len();c+=1){const A=r.keys().get(c),u=r.get(A);n.insert(A,a.TransactionMetadatum.from_hex("0".repeat(((u==null?void 0:u.to_hex())??"").length)))}const o=t.auxiliary_data();return o==null||o.set_metadata(n),a.Transaction.new(t.body(),t.witness_set(),o).to_hex()}return e}static readMetadata(e){var r,i;return((i=(r=q(e).auxiliary_data())==null?void 0:r.metadata())==null?void 0:i.to_hex())??""}static writeMetadata(e,t){const r=q(e),i=r.auxiliary_data()??a.AuxiliaryData.new();return i.set_metadata(a.GeneralTransactionMetadata.from_hex(t)),a.Transaction.new(r.body(),r.witness_set(),i).to_hex()}get size(){return this._txBuilder.full_size()}async build(){try{return this.notVisited("redeemValue")===!1&&(await this.addRequiredSignersIfNeeded(),await this.addCollateralIfNeeded()),await this.forgeAssetsIfNeeded(),await this.addTxInputsAsNeeded(),await this.addChangeAddress(),this._txBuilder.build_tx().to_hex()}catch(e){throw new Error(`[Transaction] An error occurred during build: ${e}.`)}}burnAsset(e,t){const r=this._totalBurns.has(t.unit)?a.BigNum.from_str(this._totalBurns.get(t.unit)??"0").checked_add(a.BigNum.from_str(t.quantity)).to_str():t.quantity;return this._txBuilder.add_mint_asset(gt(e),a.AssetName.new(g(t.unit.slice(L))),a.Int.new_negative(a.BigNum.from_str(t.quantity))),this._totalBurns.set(t.unit,r),this}delegateStake(e,t){const r=a.Certificate.new_stake_delegation(a.StakeDelegation.new(a.StakeCredential.from_keyhash(U(ot(e))),a.Ed25519KeyHash.from_bech32(t)));return this._txCertificates.add(r),this}deregisterStake(e){const t=a.Certificate.new_stake_deregistration(a.StakeDeregistration.new(a.StakeCredential.from_keyhash(U(ot(e)))));return this._txCertificates.add(t),this}mintAsset(e,t){var c,A;const i=((u,I)=>{const h=gt(u).hash().to_hex(),p=X(I.assetName);return{unit:`${h}${p}`,quantity:I.assetQuantity}})(e,t),o=a.BigNum.from_str(((c=this._totalMints.get(i.unit))==null?void 0:c.assetQuantity)??"0").checked_add(a.BigNum.from_str(i.quantity));return this._txBuilder.add_mint_asset(gt(e),a.AssetName.new(g(X(t.assetName))),a.Int.new(a.BigNum.from_str(i.quantity))),this._recipients.has(t.recipient)?(A=this._recipients.get(t.recipient))==null||A.push(i):this._recipients.set(t.recipient,[i]),this._totalMints.set(i.unit,{...t,assetQuantity:o.to_str()}),this}redeemValue(e){if("assetName"in e.value)throw new Error("Plutus Minting is not implemented yet...");const t={tag:"SPEND",budget:Me,index:this._txInputsBuilder.inputs().len(),data:{alternative:0,fields:[]},...e.redeemer},r=R(e.value),i=a.PlutusWitness.new_with_ref(ts(e.script),Ze(e.datum),Je(t));return this._txInputsBuilder.add_plutus_script_input(i,r.input(),r.output().amount()),this}registerStake(e){const t=a.Certificate.new_stake_registration(a.StakeRegistration.new(a.StakeCredential.from_keyhash(U(ot(e)))));return this._txCertificates.add(t),this}registerPool(e){const t=a.Certificate.new_pool_registration(a.PoolRegistration.new($e(e)));return this._txCertificates.add(t),this}retirePool(e,t){const r=a.Certificate.new_pool_retirement(a.PoolRetirement.new(a.Ed25519KeyHash.from_bech32(e),t));return this._txCertificates.add(r),this}sendAssets(e,t){const r=ft(t),i=r.multiasset();if(r.is_zero()||i===void 0)return this;const o=ut(e).next().with_asset_and_min_required_coin_by_utxo_cost(i,zt(this._protocolParameters.coinsPerUTxOSize)).build();return this._txBuilder.add_output(o),this}sendLovelace(e,t){const i=ut(e).next().with_coin(a.BigNum.from_str(t)).build();return this._txBuilder.add_output(i),this}sendValue(e,t){const r=ft(t.output.amount),n=ut(e).next().with_value(r).build();return this._txBuilder.add_output(n),this}setChangeAddress(e){return this._changeAddress=k(e),this}setCollateral(e){const t=Jt(e);return this._txBuilder.set_collateral(t),this}setMetadata(e,t){return this._txBuilder.add_json_metadatum_with_schema(a.BigNum.from_str(e.toString()),JSON.stringify(t),a.MetadataJsonSchema.NoConversions),this}setRequiredSigners(e){return Array.from(new Set(e.map(r=>r.startsWith("addr")?J(r):ot(r)).map(r=>U(r)))).forEach(r=>{this._txBuilder.add_required_signer(r)}),this}setTimeToStart(e){return this._txBuilder.set_validity_start_interval_bignum(a.BigNum.from_str(e)),this}setTimeToExpire(e){return this._txBuilder.set_ttl_bignum(a.BigNum.from_str(e)),this}setTxInputs(e){return e.map(t=>R(t)).forEach(t=>{this._txInputsBuilder.add_input(t.output().address(),t.input(),t.output().amount())}),this}withdrawRewards(e,t){const r=de(e);return r!==void 0&&this._txWithdrawals.insert(r,a.BigNum.from_str(t)),this}async addBurnInputsIfNeeded(){if(this._initiator&&this._totalBurns.size>0&&this.notVisited("setTxInputs")){const e=await this._initiator.getUsedUTxOs();Ce(this._totalBurns,e.map(r=>wt(r))).map(r=>R(r)).forEach(r=>{this._txInputsBuilder.add_input(r.output().address(),r.input(),r.output().amount())})}}async addChangeAddress(){if(this._initiator&&this._changeAddress===void 0){const e=await this._initiator.getUsedAddress();this._txBuilder.add_change_if_needed(e)}else this._changeAddress!==void 0&&this._txBuilder.add_change_if_needed(this._changeAddress)}async addCollateralIfNeeded(){if(this._initiator&&this.notVisited("setCollateral")){const e=await this._initiator.getUsedCollateral();this._txBuilder.set_collateral(Jt(e))}}async addRequiredSignersIfNeeded(){if(this._initiator&&this.notVisited("setRequiredSigners")){const e=await this._initiator.getUsedAddress(),t=J(e.to_bech32());this._txBuilder.add_required_signer(U(t))}}async addTxInputsAsNeeded(){if(this._txBuilder.set_inputs(this._txInputsBuilder),this._txCertificates.len()>0&&this._txBuilder.set_certs(this._txCertificates),this._txWithdrawals.len()>0&&this._txBuilder.set_withdrawals(this._txWithdrawals),this.notVisited("setTxInputs")){const e=!this.notVisited("mintAsset")||!this.notVisited("sendAssets")||!this.notVisited("sendValue"),t=await this.selectLovelaceUTxOs(!1),r=await this.filterAvailableUTxOs(t),i=e?a.CoinSelectionStrategyCIP2.LargestFirstMultiAsset:a.CoinSelectionStrategyCIP2.LargestFirst;this._txBuilder.add_inputs_from(r,i)}if(this.notVisited("redeemValue")===!1){const e=this._era!==void 0?Yt[this._era]:Yt.BABBAGE;this._txBuilder.calc_script_data_hash(e)}}async forgeAssetsIfNeeded(){const e=(t,r)=>{const i=t.data.assetName,n=t.data.metadata,o=t.unit.slice(0,L);if(r&&r[o]){const{[o]:c,...A}=r,u={[i]:n,...c};return{[o]:{...u},...A}}return r!==void 0?{[o]:{[i]:n},...r}:{[o]:{[i]:n}}};await this.addBurnInputsIfNeeded(),Array.from(this._totalMints,t=>({unit:t[0],data:t[1]})).reduce((t,r)=>t.set(r.data.label,e(r,t.get(r.data.label))),new Map).forEach((t,r)=>{this._txBuilder.add_json_metadatum(a.BigNum.from_str(r),JSON.stringify(t))}),this.addMintOutputs()}async filterAvailableUTxOs(e=[]){const t=a.TransactionUnspentOutputs.new();return this._initiator===void 0||(await this._initiator.getUsedUTxOs()).filter(i=>e.find(n=>n.input.txHash===i.input().transaction_id().to_hex())===void 0).forEach(i=>{t.add(i)}),t}async selectLovelaceUTxOs(e){if(this._initiator===void 0||e===!1)return[];const t=await this._initiator.getUsedUTxOs(),r=fe("5000000",t.map(n=>wt(n)));return r.map(n=>R(n)).forEach(n=>{this._txBuilder.add_input(n.output().address(),n.input(),n.output().amount())}),r}addMintOutputs(){this._recipients.forEach((e,t)=>{const i=ft(e).multiasset();if(i!==void 0){const o=ut(t).next().with_asset_and_min_required_coin_by_utxo_cost(i,zt(this._protocolParameters.coinsPerUTxOSize)).build();this._txBuilder.add_output(o)}})}notVisited(e){return this.__visits.includes(e)===!1}};z([Z()],exports.Transaction.prototype,"mintAsset",null);z([Z()],exports.Transaction.prototype,"redeemValue",null);z([Z()],exports.Transaction.prototype,"sendAssets",null);z([Z()],exports.Transaction.prototype,"sendValue",null);z([Z()],exports.Transaction.prototype,"setCollateral",null);z([Z()],exports.Transaction.prototype,"setRequiredSigners",null);z([Z()],exports.Transaction.prototype,"setTxInputs",null);exports.Transaction=z([Rs],exports.Transaction);const Ke=(s,e)=>{const t=s.vkeys();if(t!==void 0){const r=new Set;for(let n=0;n<t.len();n+=1)r.add(t.get(n).to_hex());for(let n=0;n<e.len();n+=1)r.add(e.get(n).to_hex());const i=a.Vkeywitnesses.new();return r.forEach(n=>{i.add(a.Vkeywitness.from_hex(n))}),i}return e};class w{_networkId;_encryptedSecret;constructor(e,t){this._networkId=e,this._encryptedSecret=t}getAccount(e,t){return this.accountContext(e,t,(r,i)=>{const n=qt(this._networkId,r.to_public().hash(),i.to_public().hash()).to_address().to_bech32(),o=$t(this._networkId,r.to_public().hash()).to_address().to_bech32(),c=Kt(this._networkId,i.to_public().hash()).to_address().to_bech32();return{baseAddress:n,enterpriseAddress:o,rewardAddress:c}})}signData(e,t,r,i){try{return this.accountContext(e,t,(n,o)=>{const c={payload:i},A={address:w.resolveAddress(this._networkId,r,n,o),key:r.startsWith("stake")?o:n},{coseSign1:u,coseKey:I}=is(c,A);return{signature:u,key:I}})}catch(n){throw new Error(`An error occurred during signData: ${n}.`)}}signTx(e,t,r,i,n){try{const o=he(be(i));return this.accountContext(e,t,(c,A)=>{const u=a.Vkeywitnesses.new();return w.resolveSigners(i,r,c.to_public().hash().to_hex()).forEach(h=>{if(h===c.to_public().hash().to_hex())u.add(a.make_vkey_witness(o,c));else if(h===A.to_public().hash().to_hex())u.add(a.make_vkey_witness(o,A));else if(n===!1)throw new Error(`Missing key witness for: ${h}`)}),u})}catch(o){throw new Error(`An error occurred during signTx: ${o}.`)}}static encryptMnemonic(e,t){const r=vt.mnemonicToEntropy(e.join(" ")),i=ge(r),n=j(i.as_bytes());return i.free(),w.encrypt(n,t)}static encryptPrivateKey(e,t){const r=a.Bip32PrivateKey.from_bech32(e),i=j(r.as_bytes());return r.free(),w.encrypt(i,t)}static encryptSigningKeys(e,t,r){const i=w.encrypt(e.slice(4),r),n=w.encrypt(t.slice(4),r);return[i,n]}static generateMnemonic(e=256){return vt.generateMnemonic(e).split(" ")}accountContext(e,t,r){const{paymentKey:i,stakeKey:n}=w.resolveKeys(e,t,this._encryptedSecret),o=r(i,n);return i.free(),n.free(),o}static decrypt(e,t){try{return a.decrypt_with_password(X(t),e)}catch{throw new Error("The password is incorrect.")}}static encrypt(e,t){const r=He.customAlphabet("0123456789abcdef"),i=r(64),n=r(24);return a.encrypt_with_password(X(t),i,n,e)}static resolveAddress(e,t,r,i){const n=[qt(e,r.to_public().hash(),i.to_public().hash()),$t(e,r.to_public().hash()),Kt(e,i.to_public().hash())].find(o=>o.to_address().to_bech32()===t);if(n!==void 0)return n.to_address();throw new Error(`Address: ${t} doesn't belong to this account.`)}static resolveKeys(e,t,r){if(typeof r=="string"){const o=w.decrypt(r,t);return Ds(o,e)}const i=w.decrypt(r[0],t),n=w.decrypt(r[1],t);return{paymentKey:a.PrivateKey.from_hex(i),stakeKey:a.PrivateKey.from_hex(n)}}static resolveSigners(e,t,r){const i=c=>{const A=(l,B=[],E=0)=>{var It,it,Pt,Mt,Tt;if(l===void 0||E>=l.len())return B;const S=l.get(E),D=new Array;switch(S.kind()){case a.CertificateKind.StakeDeregistration:{const y=(It=S.as_stake_deregistration())==null?void 0:It.stake_credential(),N=(y==null?void 0:y.kind())===a.StakeCredKind.Key?y.to_keyhash():void 0;N&&D.push(N.to_hex());break}case a.CertificateKind.StakeDelegation:{const y=(it=S.as_stake_delegation())==null?void 0:it.stake_credential(),N=(y==null?void 0:y.kind())===a.StakeCredKind.Key?y.to_keyhash():void 0;N&&D.push(N.to_hex());break}case a.CertificateKind.PoolRegistration:{const y=(Pt=S.as_pool_registration())==null?void 0:Pt.pool_params().pool_owners();D.push(...I(y));break}case a.CertificateKind.PoolRetirement:{const y=(Mt=S.as_pool_retirement())==null?void 0:Mt.pool_keyhash();y&&D.push(y.to_hex());break}case a.CertificateKind.MoveInstantaneousRewardsCert:{const y=(Tt=S.as_move_instantaneous_rewards_cert())==null?void 0:Tt.move_instantaneous_reward().as_to_stake_creds();if(y)for(let N=0;N<y.len();N+=1){const Vt=y.keys().get(N),Ot=Vt.kind()===a.StakeCredKind.Key?Vt.to_keyhash():void 0;Ot&&D.push(Ot.to_hex())}break}}return A(l,[...B,...D],E+1)},u=(l,B=[],E=0)=>{if(l===void 0||E>=l.len())return B;const S=l.get(E).index(),D=l.get(E).transaction_id(),It=t.find(it=>it.input.outputIndex===S&&it.input.txHash===D.to_hex())!==void 0?r:"OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";return u(l,[...B,It],E+1)},I=(l,B=[],E=0)=>l===void 0||E>=l.len()?B:I(l,[...B,l.get(E).to_hex()],E+1),h=(l,B=[],E=0)=>{if(l===void 0||E>=l.len())return B;const S=l.keys().get(E).payment_cred(),D=S.kind()===a.StakeCredKind.Key?S.to_keyhash():void 0;return h(l,D?[...B,D.to_hex()]:B,E+1)},p=c.certs(),v=c.collateral(),$=c.inputs(),H=c.required_signers(),V=c.withdrawals();return[...A(p),...u(v),...u($),...I(H),...h(V)]},n=c=>{const A=(I,h=[])=>{var p,v,$,H;if(I)for(let V=0;V<I.len();V+=1){const l=I.get(V);switch(l.kind()){case a.NativeScriptKind.ScriptPubkey:{const B=(p=l.as_script_pubkey())==null?void 0:p.addr_keyhash().to_hex();return B?[...h,B]:h}case a.NativeScriptKind.ScriptAll:return A((v=l.as_script_all())==null?void 0:v.native_scripts(),h);case a.NativeScriptKind.ScriptAny:return A(($=l.as_script_any())==null?void 0:$.native_scripts(),h);case a.NativeScriptKind.ScriptNOfK:return A((H=l.as_script_n_of_k())==null?void 0:H.native_scripts(),h)}}return h},u=c.native_scripts();return[...A(u)]},o=q(e);return new Set([...i(o.body()),...n(o.witness_set())])}}const b="MARI0TIME";class Ls{_fetcher;_submitter;_wallet;constructor(e){switch(this._fetcher=e.fetcher,this._submitter=e.submitter,e.key.type){case"mnemonic":this._wallet=new w(e.networkId,w.encryptMnemonic(e.key.words,b));break;case"root":this._wallet=new w(e.networkId,w.encryptPrivateKey(e.key.bech32,b));break;case"cli":this._wallet=new w(e.networkId,w.encryptSigningKeys(e.key.payment,e.key.stake??"f0".repeat(34),b))}}getPaymentAddress(e=0){return this._wallet.getAccount(e,b).enterpriseAddress}getRewardAddress(e=0){return this._wallet.getAccount(e,b).rewardAddress}getUsedAddress(e=0){const t=this._wallet.getAccount(e,b);return k(t.enterpriseAddress)}getUsedCollateral(e=M.maxCollateralInputs){throw new Error("getUsedCollateral not implemented.")}async getUsedUTxOs(e=0){const t=this._wallet.getAccount(e,b);return(await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map(i=>R(i))}signData(e,t,r=0){try{return this._wallet.signData(r,b,e,t)}catch(i){throw new Error(`[AppWallet] An error occurred during signData: ${i}.`)}}async signTx(e,t=!1,r=0){try{const i=this._wallet.getAccount(r,b),n=await this._fetcher.fetchAddressUTxOs(i.enterpriseAddress),o=this._wallet.signTx(r,b,n,e,t),c=q(e),A=c.witness_set(),u=Ke(A,o);return A.set_vkeys(u),a.Transaction.new(c.body(),A,c.auxiliary_data()).to_hex()}catch(i){throw new Error(`[AppWallet] An error occurred during signTx: ${i}.`)}}submitTx(e){return this._submitter.submitTx(e)}static brew(e=256){return w.generateMnemonic(e)}}class mt{_walletInstance;constructor(e){this._walletInstance=e}static getInstalledWallets(){return window.cardano===void 0?[]:Gt.filter(e=>window.cardano[e]!==void 0).map(e=>({name:window.cardano[e].name,icon:window.cardano[e].icon,version:window.cardano[e].apiVersion}))}static async enable(e){try{const t=await mt.resolveInstance(e);if(t!==void 0)return new mt(t);throw new Error(`Couldn't create an instance of wallet: ${e}`)}catch(t){throw new Error(`[BrowserWallet] An error occurred during enable: ${t}.`)}}async getBalance(){const e=await this._walletInstance.getBalance();return le(ze(e))}async getChangeAddress(){const e=await this._walletInstance.getChangeAddress();return at(e).to_bech32()}async getCollateral(e=M.maxCollateralInputs){return(await this.getUsedCollateral(e)).map(r=>wt(r))}getNetworkId(){return this._walletInstance.getNetworkId()}async getRewardAddresses(){return(await this._walletInstance.getRewardAddresses()).map(t=>at(t).to_bech32())}async getUnusedAddresses(){return(await this._walletInstance.getUnusedAddresses()).map(t=>at(t).to_bech32())}async getUsedAddresses(){return(await this._walletInstance.getUsedAddresses()).map(t=>at(t).to_bech32())}async getUtxos(){return(await this.getUsedUTxOs()).map(t=>wt(t))}signData(e,t){const r=k(e).to_hex();return this._walletInstance.signData(r,X(t))}async signTx(e,t=!1){try{const r=q(e),i=r.witness_set(),n=await this._walletInstance.signTx(e,t),o=qe(n).vkeys()??a.Vkeywitnesses.new(),c=Ke(i,o);return i.set_vkeys(c),j(a.Transaction.new(r.body(),i,r.auxiliary_data()).to_bytes())}catch(r){throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(r)}.`)}}submitTx(e){return this._walletInstance.submitTx(e)}async getUsedAddress(){const e=await this._walletInstance.getUsedAddresses();return at(e[0])}async getUsedCollateral(e=M.maxCollateralInputs){return(await this._walletInstance.experimental.getCollateral()??[]).map(r=>Rt(r)).slice(0,e)}async getUsedUTxOs(){return(await this._walletInstance.getUtxos()??[]).map(t=>Rt(t))}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{const r=t.unit.slice(0,L),i=t.unit.slice(L),n=ve(r,i);return{unit:t.unit,policyId:r,assetName:Xe(i),fingerprint:n,quantity:t.quantity}})}async getLovelace(){const t=(await this.getBalance()).find(r=>r.unit==="lovelace");return t!==void 0?t.quantity:"0"}async getPolicyIdAssets(e){return(await this.getAssets()).filter(r=>r.policyId===e)}async getPolicyIds(){const e=await this.getBalance();return Array.from(new Set(e.map(t=>t.unit.slice(0,L)))).filter(t=>t!=="lovelace")}static resolveInstance(e){if(window.cardano===void 0)return;const t=Gt.map(r=>window.cardano[r]).filter(r=>r!==void 0).find(r=>r.name.toLowerCase()===e.toLowerCase());return t==null?void 0:t.enable()}}const Ue="http://localhost:4000/",qs="http://localhost:5000/",zs=`${Ue}access`,$s=`${Ue}transaction/signtx`;class Js{static getAxiosInstance(){return rt.default.create({baseURL:qs,withCredentials:!0})}static getAppId(){return window.location.hostname}static async openMinaFrontend(e){const t=this.getAppId();e.includes("?")?e=`${e}&appId=${t}`:e=`${e}?appId=${t}`;const r="left=100,top=100,width=540,height=540",i=window.open(e,"meshWindow",r);return i||console.error("the window did not open",i),await(async()=>new Promise(n=>{window.addEventListener("message",async o=>{o.data.target=="minaWallet"&&n(o.data)})}))()}static async get(e,t={}){const r=this.getAppId();t={...t,appId:r};try{return(await this.getAxiosInstance().get(e,{params:t})).data}catch{console.error("Not logged in");return}}static async enable(){return await this.get("wallet/getuserwalletsmeta")===void 0?await this.openMinaFrontend(zs):!0}static async getChangeAddress(e=void 0,t=void 0){return await this.get("wallet/getchangeaddress",{walletId:e,accountIndex:t})}static async getUtxos(e=void 0,t=void 0){return await this.get("wallet/getutxo",{walletId:e,accountIndex:t})}static async signTx(e,t=!1){const r=await this.get("wallet/getuserwalletsmeta");if(console.log("userWalletsMeta",r),r){const i=await this.openMinaFrontend(`${$s}?unsignedTx=${e}&partialSign=${t}`);if(i instanceof a.Vkeywitnesses){const n=q(e),o=n.witness_set();o.set_vkeys(i);const c=a.Transaction.new(n.body(),o,n.auxiliary_data()).to_hex();return console.log("signedTx",c),c}}else return}}exports.AppWallet=Ls;exports.BlockfrostProvider=Ts;exports.BrowserWallet=mt;exports.EmbeddedWallet=w;exports.ForgeScript=Gs;exports.InfuraProvider=Vs;exports.KoiosProvider=Os;exports.MinaWallet=Js;exports.TangoProvider=Ys;exports.largestFirst=fe;exports.largestFirstMultiAsset=Ce;exports.resolveDataHash=vs;exports.resolveEpochNo=bs;exports.resolveFingerprint=ve;exports.resolveLanguageView=Ks;exports.resolveNativeScriptHash=Us;exports.resolvePaymentKeyHash=J;exports.resolvePlutusScriptAddress=ks;exports.resolvePlutusScriptHash=Fs;exports.resolvePoolId=Hs;exports.resolvePrivateKey=Ns;exports.resolveRewardAddress=xt;exports.resolveScriptRef=Ps;exports.resolveSlotNo=Ms;exports.resolveStakeKeyHash=ot;exports.resolveTxFees=Nt;exports.resolveTxHash=be;