@meshsdk/common 1.6.0-alpha.21 → 1.6.1

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/dist/index.cjs +1 -0
  2. package/dist/{index.d.mts → index.d.cts} +96 -8
  3. package/dist/index.d.ts +96 -8
  4. package/dist/index.js +1 -1316
  5. package/package.json +28 -9
  6. package/.turbo/turbo-build$colon$docs.log +0 -17
  7. package/.turbo/turbo-build$colon$mesh.log +0 -19
  8. package/.turbo/turbo-build.log +0 -19
  9. package/dist/index.mjs +0 -1189
  10. package/src/constants/cost-models.ts +0 -30
  11. package/src/constants/index.ts +0 -86
  12. package/src/constants/language-views.ts +0 -19
  13. package/src/constants/protocol-parameters.ts +0 -34
  14. package/src/constants/supported-wallets.ts +0 -12
  15. package/src/data/index.ts +0 -5
  16. package/src/data/json/aliases.ts +0 -218
  17. package/src/data/json/constructors.ts +0 -56
  18. package/src/data/json/credentials.ts +0 -77
  19. package/src/data/json/index.ts +0 -33
  20. package/src/data/json/primitives.ts +0 -154
  21. package/src/data/mesh/aliases.ts +0 -85
  22. package/src/data/mesh/constructors.ts +0 -68
  23. package/src/data/mesh/credentials.ts +0 -77
  24. package/src/data/mesh/index.ts +0 -4
  25. package/src/data/mesh/primitives.ts +0 -37
  26. package/src/data/parser.ts +0 -36
  27. package/src/data/time.ts +0 -92
  28. package/src/data/value.ts +0 -70
  29. package/src/index.ts +0 -7
  30. package/src/interfaces/evaluator.ts +0 -5
  31. package/src/interfaces/fetcher.ts +0 -31
  32. package/src/interfaces/index.ts +0 -7
  33. package/src/interfaces/initiator.ts +0 -9
  34. package/src/interfaces/listener.ts +0 -3
  35. package/src/interfaces/serializer.ts +0 -53
  36. package/src/interfaces/signer.ts +0 -12
  37. package/src/interfaces/submitter.ts +0 -3
  38. package/src/types/account-info.ts +0 -7
  39. package/src/types/action.ts +0 -15
  40. package/src/types/asset-extended.ts +0 -9
  41. package/src/types/asset-metadata.ts +0 -102
  42. package/src/types/asset.ts +0 -23
  43. package/src/types/block-info.ts +0 -17
  44. package/src/types/data-signature.ts +0 -4
  45. package/src/types/data.ts +0 -10
  46. package/src/types/deserialized/deserialized-address.ts +0 -6
  47. package/src/types/deserialized/deserialized-script.ts +0 -4
  48. package/src/types/deserialized/index.ts +0 -2
  49. package/src/types/era.ts +0 -1
  50. package/src/types/index.ts +0 -24
  51. package/src/types/message.ts +0 -4
  52. package/src/types/mint.ts +0 -12
  53. package/src/types/native-script.ts +0 -18
  54. package/src/types/network.ts +0 -7
  55. package/src/types/plutus-script.ts +0 -8
  56. package/src/types/pool-params.ts +0 -41
  57. package/src/types/protocol.ts +0 -22
  58. package/src/types/recipient.ts +0 -15
  59. package/src/types/relay.ts +0 -42
  60. package/src/types/token.ts +0 -3
  61. package/src/types/transaction-builder/data.ts +0 -31
  62. package/src/types/transaction-builder/index.ts +0 -73
  63. package/src/types/transaction-builder/mint.ts +0 -11
  64. package/src/types/transaction-builder/output.ts +0 -12
  65. package/src/types/transaction-builder/script.ts +0 -27
  66. package/src/types/transaction-builder/txin.ts +0 -46
  67. package/src/types/transaction-builder/withdrawal.ts +0 -207
  68. package/src/types/transaction-info.ts +0 -11
  69. package/src/types/utxo.ts +0 -16
  70. package/src/types/wallet.ts +0 -6
  71. package/src/utils/asset-fingerprint.ts +0 -11
  72. package/src/utils/bigNum.ts +0 -61
  73. package/src/utils/index.ts +0 -2
  74. package/test/data/json/aliases.test.ts +0 -135
  75. package/test/data/json/constructors.test.ts +0 -38
  76. package/test/data/json/credentials.test.ts +0 -84
  77. package/test/data/json/primitives.test.ts +0 -133
  78. package/test/data/mesh/aliases.test.ts +0 -45
  79. package/test/data/mesh/common.ts +0 -14
  80. package/test/data/mesh/constructors.test.ts +0 -53
  81. package/test/data/mesh/credentials.test.ts +0 -74
  82. package/test/data/mesh/primitives.test.ts +0 -41
  83. package/test/data/value.test.ts +0 -108
  84. package/tsconfig.json +0 -5
@@ -1,3 +0,0 @@
1
- export interface IListener {
2
- onTxConfirmed(txHash: string, callback: () => void, limit?: number): void;
3
- }
@@ -1,53 +0,0 @@
1
- import {
2
- BuilderData,
3
- Data,
4
- DeserializedAddress,
5
- DeserializedScript,
6
- MeshTxBuilderBody,
7
- NativeScript,
8
- Network,
9
- PlutusScript,
10
- Protocol,
11
- } from "../types";
12
-
13
- export interface IMeshTxSerializer {
14
- serializeTxBody(
15
- txBuilderBody: MeshTxBuilderBody,
16
- protocolParams: Protocol,
17
- ): string;
18
- addSigningKeys(txHex: string, signingKeys: string[]): string;
19
- resolver: IResolver;
20
- deserializer: IDeserializer;
21
- serializeData(data: BuilderData): string;
22
- serializeAddress(address: DeserializedAddress, networkId?: 0 | 1): string;
23
- }
24
- export interface IResolver {
25
- keys: {
26
- resolvePrivateKey(words: string[]): string;
27
- resolveRewardAddress(bech32: string): string;
28
- resolveEd25519KeyHash(bech32: string): string;
29
- resolveStakeKeyHash(bech32: string): string;
30
- };
31
- tx: {
32
- resolveTxHash(txHex: string): string;
33
- };
34
- data: {
35
- resolveDataHash(data: Data): string;
36
- };
37
- script: {
38
- resolveScriptRef(script: NativeScript | PlutusScript): string;
39
- };
40
- pool: {
41
- resolvePoolId(hash: string): string;
42
- };
43
- }
44
-
45
- export interface IDeserializer {
46
- key: {
47
- deserializeAddress(bech32: string): DeserializedAddress;
48
- };
49
- script: {
50
- deserializeNativeScript(script: NativeScript): DeserializedScript;
51
- deserializePlutusScript(script: PlutusScript): DeserializedScript;
52
- };
53
- }
@@ -1,12 +0,0 @@
1
- import { DataSignature } from "../types";
2
-
3
- export interface ISigner {
4
- signData(address: string, payload: string): SometimesPromise<DataSignature>;
5
- signTx(unsignedTx: string, partialSign: boolean): SometimesPromise<string>;
6
- signTxs(
7
- unsignedTxs: string[],
8
- partialSign: boolean,
9
- ): SometimesPromise<string[]>;
10
- }
11
-
12
- type SometimesPromise<T> = Promise<T> | T;
@@ -1,3 +0,0 @@
1
- export interface ISubmitter {
2
- submitTx(tx: string): Promise<string>;
3
- }
@@ -1,7 +0,0 @@
1
- export type AccountInfo = {
2
- active: boolean;
3
- poolId?: string;
4
- balance: string;
5
- rewards: string;
6
- withdrawals: string;
7
- };
@@ -1,15 +0,0 @@
1
- import { Data } from "./data";
2
-
3
- export type RedeemerTagType = "CERT" | "MINT" | "REWARD" | "SPEND";
4
-
5
- export type Action = {
6
- data: Data;
7
- index: number;
8
- budget: Budget;
9
- tag: RedeemerTagType;
10
- };
11
-
12
- export type Budget = {
13
- mem: number;
14
- steps: number;
15
- };
@@ -1,9 +0,0 @@
1
- import { Quantity, Unit } from "./asset";
2
-
3
- export type AssetExtended = {
4
- unit: Unit;
5
- policyId: string;
6
- assetName: string;
7
- fingerprint: string;
8
- quantity: Quantity;
9
- };
@@ -1,102 +0,0 @@
1
- import { Data } from "./data";
2
-
3
- export type RoyaltiesStandard = {
4
- rate: string;
5
- address: string;
6
- };
7
-
8
- export const royaltiesStandardKeys = ["rate", "address"];
9
-
10
- // export type MetadataStandard = {
11
- // name: string;
12
- // image: `${string}://${string}`;
13
- // mediaType?: `image/${string}`;
14
- // description?: string | string[];
15
- // instagram?: `https://instagram.com/${string}`;
16
- // twitter?: `https://twitter.com/${string}`;
17
- // discord?: `https://discord.gg/${string}`;
18
- // website?: `https://${string}`;
19
- // metadata?: object;
20
- // };
21
- type MetadataStandard = any;
22
-
23
- export const metadataStandardKeys = [
24
- "name",
25
- "image",
26
- "mediaType",
27
- "description",
28
- "instagram",
29
- "twitter",
30
- "discord",
31
- "website",
32
- ];
33
-
34
- export type Files = {
35
- files?: [
36
- {
37
- name: string;
38
- src: `${string}://${string}`;
39
- mediaType: `${string}/${string}`;
40
- },
41
- ];
42
- };
43
-
44
- export type AssetMetadata =
45
- | FungibleAssetMetadata
46
- | NonFungibleAssetMetadata
47
- | RoyaltiesStandard;
48
-
49
- export type FungibleAssetMetadata = MetadataStandard & {
50
- ticker: string;
51
- decimals: number;
52
- version: `${number}.${number}`;
53
- };
54
-
55
- export const fungibleAssetKeys = ["ticker", "decimals"];
56
-
57
- export type NonFungibleAssetMetadata =
58
- | AudioAssetMetadata
59
- | ImageAssetMetadata
60
- | SmartAssetMetadata
61
- | VideoAssetMetadata;
62
-
63
- type AudioAssetMetadata = MetadataStandard & Files;
64
-
65
- export type ImageAssetMetadata = MetadataStandard &
66
- Files & {
67
- artists?: [
68
- {
69
- name: string;
70
- twitter?: `https://twitter.com/${string}`;
71
- },
72
- ];
73
- attributes?: {
74
- [key: string]: string;
75
- };
76
- traits?: string[];
77
- };
78
-
79
- type SmartAssetMetadata = MetadataStandard & Files;
80
-
81
- type VideoAssetMetadata = MetadataStandard & Files;
82
-
83
- export const metadataToCip68 = (metadata: any): Data => {
84
- switch (typeof metadata) {
85
- case "object":
86
- if (metadata instanceof Array) {
87
- return metadata.map((item) => metadataToCip68(item));
88
- }
89
- const metadataMap = new Map();
90
- const keys = Object.keys(metadata);
91
- keys.forEach((key) => {
92
- metadataMap.set(key, metadataToCip68(metadata[key]));
93
- });
94
- return {
95
- alternative: 0,
96
- fields: [metadataMap, 1],
97
- };
98
-
99
- default:
100
- return metadata;
101
- }
102
- };
@@ -1,23 +0,0 @@
1
- export type Asset = {
2
- unit: Unit;
3
- quantity: Quantity;
4
- };
5
-
6
- export type Unit = string;
7
-
8
- export type Quantity = string;
9
-
10
- export const mergeAssets = (assets: Asset[]): Asset[] => {
11
- const merged: Asset[] = [];
12
- assets.forEach((asset) => {
13
- const existing = merged.find((a) => a.unit === asset.unit);
14
- if (existing) {
15
- existing.quantity = (
16
- BigInt(existing.quantity) + BigInt(asset.quantity)
17
- ).toString();
18
- } else {
19
- merged.push(asset);
20
- }
21
- });
22
- return merged;
23
- };
@@ -1,17 +0,0 @@
1
- export type BlockInfo = {
2
- time: number;
3
- hash: string;
4
- slot: string;
5
- epoch: number;
6
- epochSlot: string;
7
- slotLeader: string;
8
- size: number;
9
- txCount: number;
10
- output: string;
11
- fees: string;
12
- previousBlock: string;
13
- nextBlock: string;
14
- confirmations: number;
15
- operationalCertificate: string;
16
- VRFKey: string;
17
- };
@@ -1,4 +0,0 @@
1
- export type DataSignature = {
2
- signature: string;
3
- key: string;
4
- };
package/src/types/data.ts DELETED
@@ -1,10 +0,0 @@
1
- export type Data =
2
- | string
3
- | number
4
- | bigint
5
- | Array<Data>
6
- | Map<Data, Data>
7
- | {
8
- alternative: number;
9
- fields: Array<Data>;
10
- };
@@ -1,6 +0,0 @@
1
- export type DeserializedAddress = {
2
- pubKeyHash: string;
3
- scriptHash: string;
4
- stakeCredentialHash: string;
5
- stakeScriptCredentialHash: string;
6
- };
@@ -1,4 +0,0 @@
1
- export type DeserializedScript = {
2
- scriptHash: string;
3
- scriptCbor?: string;
4
- };
@@ -1,2 +0,0 @@
1
- export * from "./deserialized-address";
2
- export * from "./deserialized-script";
package/src/types/era.ts DELETED
@@ -1 +0,0 @@
1
- export type Era = "ALONZO" | "BABBAGE";
@@ -1,24 +0,0 @@
1
- export * from "./account-info";
2
- export * from "./action";
3
- export * from "./asset";
4
- export * from "./asset-extended";
5
- export * from "./asset-metadata";
6
- export * from "./block-info";
7
- export * from "./data";
8
- export * from "./data-signature";
9
- export * from "./era";
10
- export * from "./message";
11
- export * from "./mint";
12
- export * from "./native-script";
13
- export * from "./network";
14
- export * from "./plutus-script";
15
- export * from "./pool-params";
16
- export * from "./protocol";
17
- export * from "./recipient";
18
- export * from "./relay";
19
- export * from "./token";
20
- export * from "./transaction-info";
21
- export * from "./utxo";
22
- export * from "./wallet";
23
- export * from "./transaction-builder";
24
- export * from "./deserialized";
@@ -1,4 +0,0 @@
1
- export type Message = {
2
- payload: string;
3
- externalAAD?: string;
4
- };
package/src/types/mint.ts DELETED
@@ -1,12 +0,0 @@
1
- import { Quantity } from "./asset";
2
- import { AssetMetadata } from "./asset-metadata";
3
- import { Recipient } from "./recipient";
4
-
5
- export type Mint = {
6
- assetName: string;
7
- assetQuantity: Quantity;
8
- recipient?: Recipient;
9
- metadata?: AssetMetadata;
10
- label?: "20" | "721" | "777" | `${number}`;
11
- cip68ScriptAddress?: string;
12
- };
@@ -1,18 +0,0 @@
1
- export type NativeScript =
2
- | {
3
- type: "after" | "before";
4
- slot: string;
5
- }
6
- | {
7
- type: "all" | "any";
8
- scripts: NativeScript[];
9
- }
10
- | {
11
- type: "atLeast";
12
- required: number;
13
- scripts: NativeScript[];
14
- }
15
- | {
16
- type: "sig";
17
- keyHash: string;
18
- };
@@ -1,7 +0,0 @@
1
- const ALL_NETWORKS = ["testnet", "preview", "preprod", "mainnet"] as const;
2
-
3
- export type Network = (typeof ALL_NETWORKS)[number];
4
-
5
- export const isNetwork = (value: unknown): value is Network => {
6
- return ALL_NETWORKS.includes(value as Network);
7
- };
@@ -1,8 +0,0 @@
1
- import { LANGUAGE_VERSIONS } from "../constants";
2
-
3
- export type PlutusScript = {
4
- version: LanguageVersion;
5
- code: string;
6
- };
7
-
8
- export type LanguageVersion = keyof typeof LANGUAGE_VERSIONS;
@@ -1,41 +0,0 @@
1
- import { Relay, relayToObj } from "./relay";
2
-
3
- export type PoolParams = {
4
- vrfKeyHash: string;
5
- operator: string;
6
- pledge: string;
7
- cost: string;
8
- margin: [number, number];
9
- relays: Relay[];
10
- owners: string[];
11
- rewardAddress: string;
12
- metadata?: PoolMetadata;
13
- };
14
-
15
- export const poolParamsToObj = (poolParams: PoolParams): object => {
16
- return {
17
- vrfKeyHash: poolParams.vrfKeyHash,
18
- operator: poolParams.operator,
19
- pledge: poolParams.pledge,
20
- cost: poolParams.cost,
21
- margin: poolParams.margin,
22
- relays: poolParams.relays.map((relay) => relayToObj(relay)),
23
- owners: poolParams.owners,
24
- rewardAddress: poolParams.rewardAddress,
25
- metadata: poolParams.metadata
26
- ? poolMetadataToObj(poolParams.metadata)
27
- : undefined,
28
- };
29
- };
30
-
31
- export type PoolMetadata = {
32
- URL: string;
33
- hash: string;
34
- };
35
-
36
- export const poolMetadataToObj = (poolMetadata: PoolMetadata): object => {
37
- return {
38
- url: poolMetadata.URL,
39
- metadata: poolMetadata.hash,
40
- };
41
- };
@@ -1,22 +0,0 @@
1
- export type Protocol = {
2
- epoch: number;
3
- minFeeA: number;
4
- minFeeB: number;
5
- maxBlockSize: number;
6
- maxTxSize: number;
7
- maxBlockHeaderSize: number;
8
- keyDeposit: number;
9
- poolDeposit: number;
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: number;
19
- collateralPercent: number;
20
- maxCollateralInputs: number;
21
- coinsPerUtxoSize: number;
22
- };
@@ -1,15 +0,0 @@
1
- import { Data } from "./data";
2
-
3
- // import { NativeScript } from './native-script';
4
- // import { PlutusScript } from './plutus-script';
5
-
6
- export type Recipient =
7
- | string
8
- | {
9
- address: string;
10
- datum?: {
11
- value: Data;
12
- inline?: boolean;
13
- };
14
- // script?: PlutusScript | NativeScript;
15
- };
@@ -1,42 +0,0 @@
1
- export type Relay =
2
- | {
3
- type: "SingleHostAddr";
4
- IPV4?: string;
5
- IPV6?: string;
6
- port?: number;
7
- }
8
- | {
9
- type: "SingleHostName";
10
- domainName: string;
11
- port?: number;
12
- }
13
- | {
14
- type: "MultiHostName";
15
- domainName: string;
16
- };
17
-
18
- export const relayToObj = (relay: Relay): object => {
19
- switch (relay.type) {
20
- case "SingleHostAddr":
21
- return {
22
- singleHostAddr: {
23
- ipv4: relay.IPV4,
24
- ipv6: relay.IPV6,
25
- port: relay.port,
26
- },
27
- };
28
- case "SingleHostName":
29
- return {
30
- singleHostName: {
31
- hostname: relay.domainName,
32
- port: relay.port,
33
- },
34
- };
35
- case "MultiHostName":
36
- return {
37
- multiHostName: {
38
- dnsName: relay.domainName,
39
- },
40
- };
41
- }
42
- };
@@ -1,3 +0,0 @@
1
- import { SUPPORTED_TOKENS } from "../constants";
2
-
3
- export type Token = keyof typeof SUPPORTED_TOKENS;
@@ -1,31 +0,0 @@
1
- import { Budget, Data } from "..";
2
-
3
- export type BuilderData =
4
- | {
5
- type: "Mesh";
6
- content: Data;
7
- }
8
- | {
9
- type: "JSON";
10
- content: object | string;
11
- }
12
- | {
13
- type: "CBOR";
14
- content: string;
15
- };
16
-
17
- export type Redeemer = {
18
- data: BuilderData;
19
- exUnits: Budget;
20
- };
21
-
22
- export type DatumSource =
23
- | {
24
- type: "Provided";
25
- data: BuilderData;
26
- }
27
- | {
28
- type: "Inline";
29
- txHash: string;
30
- txIndex: number;
31
- };
@@ -1,73 +0,0 @@
1
- import { UTxO } from "../utxo";
2
- import { MintItem } from "./mint";
3
- import { Output } from "./output";
4
- import { PubKeyTxIn, RefTxIn, TxIn } from "./txin";
5
- import { Certificate, Withdrawal } from "./withdrawal";
6
-
7
- export * from "./data";
8
- export * from "./mint";
9
- export * from "./output";
10
- export * from "./script";
11
- export * from "./txin";
12
- export * from "./withdrawal";
13
-
14
- export type MeshTxBuilderBody = {
15
- inputs: TxIn[];
16
- outputs: Output[];
17
- extraInputs: UTxO[];
18
- selectionThreshold: number;
19
- collaterals: PubKeyTxIn[];
20
- requiredSignatures: string[];
21
- referenceInputs: RefTxIn[];
22
- mints: MintItem[];
23
- changeAddress: string;
24
- metadata: Metadata[];
25
- validityRange: ValidityRange;
26
- certificates: Certificate[];
27
- withdrawals: Withdrawal[];
28
- signingKey: string[];
29
- };
30
-
31
- export const emptyTxBuilderBody = (): MeshTxBuilderBody => ({
32
- inputs: [],
33
- outputs: [],
34
- extraInputs: [],
35
- selectionThreshold: 0,
36
- collaterals: [],
37
- requiredSignatures: [],
38
- referenceInputs: [],
39
- mints: [],
40
- changeAddress: "",
41
- metadata: [],
42
- validityRange: {},
43
- certificates: [],
44
- withdrawals: [],
45
- signingKey: [],
46
- });
47
-
48
- // Here
49
-
50
- export type ValidityRange = {
51
- invalidBefore?: number;
52
- invalidHereafter?: number;
53
- };
54
-
55
- // Mint Types
56
-
57
- export type Metadata = {
58
- tag: string;
59
- metadata: string;
60
- };
61
-
62
- // Utilities
63
-
64
- export type RequiredWith<T, K extends keyof T> = Required<T> & {
65
- [P in K]: Required<T[P]>;
66
- };
67
-
68
- export const validityRangeToObj = (validityRange: ValidityRange): object => {
69
- return {
70
- invalidBefore: validityRange.invalidBefore ?? null,
71
- invalidHereafter: validityRange.invalidHereafter ?? null,
72
- };
73
- };
@@ -1,11 +0,0 @@
1
- import { Redeemer } from "./data";
2
- import { ScriptSource, SimpleScriptSourceInfo } from "./script";
3
-
4
- export type MintItem = {
5
- type: "Plutus" | "Native";
6
- policyId: string;
7
- assetName: string;
8
- amount: string;
9
- redeemer?: Redeemer;
10
- scriptSource?: ScriptSource | SimpleScriptSourceInfo;
11
- };
@@ -1,12 +0,0 @@
1
- import { Asset, PlutusScript } from "..";
2
- import { BuilderData } from "./data";
3
-
4
- export type Output = {
5
- address: string;
6
- amount: Asset[];
7
- datum?: {
8
- type: "Hash" | "Inline";
9
- data: BuilderData;
10
- };
11
- referenceScript?: PlutusScript;
12
- };
@@ -1,27 +0,0 @@
1
- import { LanguageVersion, PlutusScript } from "..";
2
-
3
- export type ScriptSource =
4
- | {
5
- type: "Provided";
6
- script: PlutusScript;
7
- }
8
- | {
9
- type: "Inline";
10
- txHash: string;
11
- txIndex: number;
12
- scriptHash?: string;
13
- scriptSize?: string;
14
- version?: LanguageVersion;
15
- };
16
-
17
- export type SimpleScriptSourceInfo =
18
- | {
19
- type: "Provided";
20
- scriptCode: string;
21
- }
22
- | {
23
- type: "Inline";
24
- txHash: string;
25
- txIndex: number;
26
- simpleScriptHash: string;
27
- };