@meshsdk/common 1.0.0-alpha.8 → 1.5.28

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 (158) hide show
  1. package/README.md +5 -0
  2. package/dist/index.d.mts +1176 -0
  3. package/dist/index.d.ts +1176 -0
  4. package/dist/index.js +1316 -0
  5. package/dist/index.mjs +1189 -0
  6. package/package.json +23 -31
  7. package/dist/cjs/builder/data/index.d.ts +0 -4
  8. package/dist/cjs/builder/data/index.js +0 -20
  9. package/dist/cjs/builder/data/mesh.d.ts +0 -8
  10. package/dist/cjs/builder/data/mesh.js +0 -34
  11. package/dist/cjs/builder/data/parser.d.ts +0 -5
  12. package/dist/cjs/builder/data/parser.js +0 -11
  13. package/dist/cjs/builder/data/plutus.d.ts +0 -69
  14. package/dist/cjs/builder/data/plutus.js +0 -105
  15. package/dist/cjs/builder/data/plutus.spec.d.ts +0 -1
  16. package/dist/cjs/builder/data/plutus.spec.js +0 -98
  17. package/dist/cjs/builder/data/time.d.ts +0 -11
  18. package/dist/cjs/builder/data/time.js +0 -32
  19. package/dist/cjs/builder/index.d.ts +0 -3
  20. package/dist/cjs/builder/index.js +0 -19
  21. package/dist/cjs/builder/serializer.d.ts +0 -7
  22. package/dist/cjs/builder/serializer.js +0 -19
  23. package/dist/cjs/builder/types.d.ts +0 -128
  24. package/dist/cjs/builder/types.js +0 -2
  25. package/dist/cjs/cip/CIP25.d.ts +0 -19
  26. package/dist/cjs/cip/CIP25.js +0 -2
  27. package/dist/cjs/cip/CIP27.d.ts +0 -4
  28. package/dist/cjs/cip/CIP27.js +0 -2
  29. package/dist/cjs/cip/CPS9.d.ts +0 -2
  30. package/dist/cjs/cip/CPS9.js +0 -115
  31. package/dist/cjs/cip/index.d.ts +0 -3
  32. package/dist/cjs/cip/index.js +0 -19
  33. package/dist/cjs/constants.d.ts +0 -43
  34. package/dist/cjs/constants.js +0 -93
  35. package/dist/cjs/index.d.ts +0 -4
  36. package/dist/cjs/index.js +0 -20
  37. package/dist/cjs/types/Account.d.ts +0 -5
  38. package/dist/cjs/types/Account.js +0 -2
  39. package/dist/cjs/types/AccountInfo.d.ts +0 -7
  40. package/dist/cjs/types/AccountInfo.js +0 -2
  41. package/dist/cjs/types/Action.d.ts +0 -12
  42. package/dist/cjs/types/Action.js +0 -2
  43. package/dist/cjs/types/Asset.d.ts +0 -7
  44. package/dist/cjs/types/Asset.js +0 -17
  45. package/dist/cjs/types/AssetExtended.d.ts +0 -8
  46. package/dist/cjs/types/AssetExtended.js +0 -2
  47. package/dist/cjs/types/AssetMetadata.d.ts +0 -24
  48. package/dist/cjs/types/AssetMetadata.js +0 -2
  49. package/dist/cjs/types/BlockInfo.d.ts +0 -17
  50. package/dist/cjs/types/BlockInfo.js +0 -2
  51. package/dist/cjs/types/Data.d.ts +0 -4
  52. package/dist/cjs/types/Data.js +0 -2
  53. package/dist/cjs/types/DataSignature.d.ts +0 -4
  54. package/dist/cjs/types/DataSignature.js +0 -2
  55. package/dist/cjs/types/Era.d.ts +0 -1
  56. package/dist/cjs/types/Era.js +0 -2
  57. package/dist/cjs/types/Mint.d.ts +0 -10
  58. package/dist/cjs/types/Mint.js +0 -2
  59. package/dist/cjs/types/NativeScript.d.ts +0 -14
  60. package/dist/cjs/types/NativeScript.js +0 -2
  61. package/dist/cjs/types/Network.d.ts +0 -4
  62. package/dist/cjs/types/Network.js +0 -8
  63. package/dist/cjs/types/PlutusScript.d.ts +0 -5
  64. package/dist/cjs/types/PlutusScript.js +0 -2
  65. package/dist/cjs/types/PoolParams.d.ts +0 -16
  66. package/dist/cjs/types/PoolParams.js +0 -2
  67. package/dist/cjs/types/Protocol.d.ts +0 -22
  68. package/dist/cjs/types/Protocol.js +0 -2
  69. package/dist/cjs/types/Recipient.d.ts +0 -11
  70. package/dist/cjs/types/Recipient.js +0 -2
  71. package/dist/cjs/types/Relay.d.ts +0 -13
  72. package/dist/cjs/types/Relay.js +0 -2
  73. package/dist/cjs/types/Token.d.ts +0 -2
  74. package/dist/cjs/types/Token.js +0 -2
  75. package/dist/cjs/types/TransactionInfo.d.ts +0 -11
  76. package/dist/cjs/types/TransactionInfo.js +0 -2
  77. package/dist/cjs/types/UTxO.d.ts +0 -15
  78. package/dist/cjs/types/UTxO.js +0 -2
  79. package/dist/cjs/types/Wallet.d.ts +0 -5
  80. package/dist/cjs/types/Wallet.js +0 -2
  81. package/dist/cjs/types/index.d.ts +0 -22
  82. package/dist/cjs/types/index.js +0 -38
  83. package/dist/mjs/builder/data/index.d.ts +0 -4
  84. package/dist/mjs/builder/data/index.js +0 -4
  85. package/dist/mjs/builder/data/mesh.d.ts +0 -8
  86. package/dist/mjs/builder/data/mesh.js +0 -24
  87. package/dist/mjs/builder/data/parser.d.ts +0 -5
  88. package/dist/mjs/builder/data/parser.js +0 -4
  89. package/dist/mjs/builder/data/plutus.d.ts +0 -69
  90. package/dist/mjs/builder/data/plutus.js +0 -79
  91. package/dist/mjs/builder/data/plutus.spec.d.ts +0 -1
  92. package/dist/mjs/builder/data/plutus.spec.js +0 -96
  93. package/dist/mjs/builder/data/time.d.ts +0 -11
  94. package/dist/mjs/builder/data/time.js +0 -27
  95. package/dist/mjs/builder/index.d.ts +0 -3
  96. package/dist/mjs/builder/index.js +0 -3
  97. package/dist/mjs/builder/serializer.d.ts +0 -7
  98. package/dist/mjs/builder/serializer.js +0 -15
  99. package/dist/mjs/builder/types.d.ts +0 -128
  100. package/dist/mjs/builder/types.js +0 -1
  101. package/dist/mjs/cip/CIP25.d.ts +0 -19
  102. package/dist/mjs/cip/CIP25.js +0 -1
  103. package/dist/mjs/cip/CIP27.d.ts +0 -4
  104. package/dist/mjs/cip/CIP27.js +0 -1
  105. package/dist/mjs/cip/CPS9.d.ts +0 -2
  106. package/dist/mjs/cip/CPS9.js +0 -111
  107. package/dist/mjs/cip/index.d.ts +0 -3
  108. package/dist/mjs/cip/index.js +0 -3
  109. package/dist/mjs/constants.d.ts +0 -43
  110. package/dist/mjs/constants.js +0 -90
  111. package/dist/mjs/index.d.ts +0 -4
  112. package/dist/mjs/index.js +0 -4
  113. package/dist/mjs/types/Account.d.ts +0 -5
  114. package/dist/mjs/types/Account.js +0 -1
  115. package/dist/mjs/types/AccountInfo.d.ts +0 -7
  116. package/dist/mjs/types/AccountInfo.js +0 -1
  117. package/dist/mjs/types/Action.d.ts +0 -12
  118. package/dist/mjs/types/Action.js +0 -1
  119. package/dist/mjs/types/Asset.d.ts +0 -7
  120. package/dist/mjs/types/Asset.js +0 -13
  121. package/dist/mjs/types/AssetExtended.d.ts +0 -8
  122. package/dist/mjs/types/AssetExtended.js +0 -1
  123. package/dist/mjs/types/AssetMetadata.d.ts +0 -24
  124. package/dist/mjs/types/AssetMetadata.js +0 -1
  125. package/dist/mjs/types/BlockInfo.d.ts +0 -17
  126. package/dist/mjs/types/BlockInfo.js +0 -1
  127. package/dist/mjs/types/Data.d.ts +0 -4
  128. package/dist/mjs/types/Data.js +0 -1
  129. package/dist/mjs/types/DataSignature.d.ts +0 -4
  130. package/dist/mjs/types/DataSignature.js +0 -1
  131. package/dist/mjs/types/Era.d.ts +0 -1
  132. package/dist/mjs/types/Era.js +0 -1
  133. package/dist/mjs/types/Mint.d.ts +0 -10
  134. package/dist/mjs/types/Mint.js +0 -1
  135. package/dist/mjs/types/NativeScript.d.ts +0 -14
  136. package/dist/mjs/types/NativeScript.js +0 -1
  137. package/dist/mjs/types/Network.d.ts +0 -4
  138. package/dist/mjs/types/Network.js +0 -4
  139. package/dist/mjs/types/PlutusScript.d.ts +0 -5
  140. package/dist/mjs/types/PlutusScript.js +0 -1
  141. package/dist/mjs/types/PoolParams.d.ts +0 -16
  142. package/dist/mjs/types/PoolParams.js +0 -1
  143. package/dist/mjs/types/Protocol.d.ts +0 -22
  144. package/dist/mjs/types/Protocol.js +0 -1
  145. package/dist/mjs/types/Recipient.d.ts +0 -11
  146. package/dist/mjs/types/Recipient.js +0 -1
  147. package/dist/mjs/types/Relay.d.ts +0 -13
  148. package/dist/mjs/types/Relay.js +0 -1
  149. package/dist/mjs/types/Token.d.ts +0 -2
  150. package/dist/mjs/types/Token.js +0 -1
  151. package/dist/mjs/types/TransactionInfo.d.ts +0 -11
  152. package/dist/mjs/types/TransactionInfo.js +0 -1
  153. package/dist/mjs/types/UTxO.d.ts +0 -15
  154. package/dist/mjs/types/UTxO.js +0 -1
  155. package/dist/mjs/types/Wallet.d.ts +0 -5
  156. package/dist/mjs/types/Wallet.js +0 -1
  157. package/dist/mjs/types/index.d.ts +0 -22
  158. package/dist/mjs/types/index.js +0 -22
@@ -1,13 +0,0 @@
1
- export 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,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- import { SUPPORTED_TOKENS } from '../constants';
2
- export type Token = keyof typeof SUPPORTED_TOKENS;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- export type TransactionInfo = {
2
- index: number;
3
- block: string;
4
- hash: string;
5
- slot: string;
6
- fees: string;
7
- size: number;
8
- deposit: string;
9
- invalidBefore: string;
10
- invalidAfter: string;
11
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,15 +0,0 @@
1
- import { Asset } from './Asset';
2
- export 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
- scriptHash?: string;
14
- };
15
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export type Wallet = {
2
- name: string;
3
- icon: string;
4
- version: string;
5
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +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 './BlockInfo';
8
- export * from './Data';
9
- export * from './DataSignature';
10
- export * from './Era';
11
- export * from './Mint';
12
- export * from './NativeScript';
13
- export * from './Network';
14
- export * from './PlutusScript';
15
- export * from './PoolParams';
16
- export * from './Protocol';
17
- export * from './Recipient';
18
- export * from './Relay';
19
- export * from './Token';
20
- export * from './TransactionInfo';
21
- export * from './UTxO';
22
- export * from './Wallet';
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Account"), exports);
18
- __exportStar(require("./AccountInfo"), exports);
19
- __exportStar(require("./Action"), exports);
20
- __exportStar(require("./Asset"), exports);
21
- __exportStar(require("./AssetExtended"), exports);
22
- __exportStar(require("./AssetMetadata"), exports);
23
- __exportStar(require("./BlockInfo"), exports);
24
- __exportStar(require("./Data"), exports);
25
- __exportStar(require("./DataSignature"), exports);
26
- __exportStar(require("./Era"), exports);
27
- __exportStar(require("./Mint"), exports);
28
- __exportStar(require("./NativeScript"), exports);
29
- __exportStar(require("./Network"), exports);
30
- __exportStar(require("./PlutusScript"), exports);
31
- __exportStar(require("./PoolParams"), exports);
32
- __exportStar(require("./Protocol"), exports);
33
- __exportStar(require("./Recipient"), exports);
34
- __exportStar(require("./Relay"), exports);
35
- __exportStar(require("./Token"), exports);
36
- __exportStar(require("./TransactionInfo"), exports);
37
- __exportStar(require("./UTxO"), exports);
38
- __exportStar(require("./Wallet"), exports);
@@ -1,4 +0,0 @@
1
- export * from './mesh';
2
- export * from './plutus';
3
- export * from './parser';
4
- export * from './time';
@@ -1,4 +0,0 @@
1
- export * from './mesh';
2
- export * from './plutus';
3
- export * from './parser';
4
- export * from './time';
@@ -1,8 +0,0 @@
1
- import { Data } from '../../types';
2
- export declare const mConStr: <T extends Data[]>(alternative: number, fields: T) => Data;
3
- export declare const mConStr0: <T extends Data[]>(fields: T) => Data;
4
- export declare const mConStr1: <T extends Data[]>(fields: T) => Data;
5
- export declare const mConStr2: <T extends Data[]>(fields: T) => Data;
6
- export declare const mMaybeStakingHash: (stakeCredential: string) => Data;
7
- export declare const mPubKeyAddress: (bytes: string, stakeCredential?: string) => Data;
8
- export declare const mScriptAddress: (bytes: string, stakeCredential?: string) => Data;
@@ -1,24 +0,0 @@
1
- export const mConStr = (alternative, fields) => ({
2
- alternative,
3
- fields,
4
- });
5
- export const mConStr0 = (fields) => ({
6
- alternative: 0,
7
- fields,
8
- });
9
- export const mConStr1 = (fields) => ({
10
- alternative: 1,
11
- fields,
12
- });
13
- export const mConStr2 = (fields) => ({
14
- alternative: 2,
15
- fields,
16
- });
17
- export const mMaybeStakingHash = (stakeCredential) => {
18
- if (stakeCredential === '') {
19
- return mConStr1([]);
20
- }
21
- return mConStr0([mConStr0([mConStr0([stakeCredential])])]);
22
- };
23
- export const mPubKeyAddress = (bytes, stakeCredential) => mConStr0([{ alternative: 0, fields: [bytes] }, mMaybeStakingHash(stakeCredential || '')]);
24
- export const mScriptAddress = (bytes, stakeCredential) => mConStr0([{ alternative: 1, fields: [bytes] }, mMaybeStakingHash(stakeCredential || '')]);
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- export declare const bytesToHex: (bytes: ArrayBuffer) => string;
3
- export declare const hexToBytes: (hex: string) => Buffer;
4
- export declare const stringToHex: (str: string) => string;
5
- export declare const hexToString: (hex: string) => string;
@@ -1,4 +0,0 @@
1
- export const bytesToHex = (bytes) => Buffer.from(bytes).toString('hex');
2
- export const hexToBytes = (hex) => Buffer.from(hex, 'hex');
3
- export const stringToHex = (str) => Buffer.from(str, 'utf8').toString('hex');
4
- export const hexToString = (hex) => Buffer.from(hex, 'hex').toString('utf8');
@@ -1,69 +0,0 @@
1
- import { Asset } from '../../types';
2
- export type ConStr<N = any, T = any> = {
3
- constructor: N;
4
- fields: T;
5
- };
6
- export type ConStr0<T = any> = ConStr<0, T>;
7
- export type ConStr1<T = any> = ConStr<1, T>;
8
- export type ConStr2<T = any> = ConStr<2, T>;
9
- export type Bool = ConStr0<[]> | ConStr1<[]>;
10
- export type BuiltinByteString = {
11
- bytes: string;
12
- };
13
- export type Integer = {
14
- int: number;
15
- };
16
- export type List = {
17
- list: PlutusData[];
18
- };
19
- export type ValidatorHash = BuiltinByteString;
20
- export type PaymentPubKeyHash = BuiltinByteString;
21
- export type PubKeyHash = PaymentPubKeyHash;
22
- export type POSIXTime = Integer;
23
- export type CurrencySymbol = BuiltinByteString;
24
- export type TokenName = BuiltinByteString;
25
- export type MaybeStakingHash = ConStr1<[]> | ConStr0<[ConStr0<[ConStr0<[BuiltinByteString]>]>]>;
26
- export type PubKeyAddress = ConStr0<[ConStr0<[PubKeyHash]>, MaybeStakingHash]>;
27
- export type ScriptAddress = ConStr0<[ConStr1<[ValidatorHash]>, MaybeStakingHash]>;
28
- export type AssetClass = ConStr0<[CurrencySymbol, TokenName]>;
29
- export type TxOutRef = ConStr0<[ConStr0<[BuiltinByteString]>, Integer]>;
30
- export type AssocMapItem<K, V> = {
31
- k: K;
32
- v: V;
33
- };
34
- export type DictItem<K, V> = {
35
- k: K;
36
- v: V;
37
- };
38
- export type AssocMap<K, V> = {
39
- map: AssocMapItem<K, V>[];
40
- };
41
- export type Dict<K, V> = {
42
- map: DictItem<K, V>[];
43
- };
44
- export type Tuple<K, V> = ConStr0<[K, V]>;
45
- export type Value = AssocMap<CurrencySymbol, AssocMap<TokenName, Integer>>;
46
- export type PlutusData = BuiltinByteString | Integer | MaybeStakingHash | PubKeyAddress | ScriptAddress | AssetClass | PaymentPubKeyHash | PubKeyHash | POSIXTime | TxOutRef;
47
- export declare const conStr: <N, T>(constructor: N, fields: T) => ConStr<N, T>;
48
- export declare const conStr0: <T>(fields: T) => ConStr0<T>;
49
- export declare const conStr1: <T>(fields: T) => ConStr1<T>;
50
- export declare const conStr2: <T>(fields: T) => ConStr2<T>;
51
- export declare const bool: (b: boolean) => Bool;
52
- export declare const builtinByteString: (bytes: string) => BuiltinByteString;
53
- export declare const integer: (int: number) => Integer;
54
- export declare const list: (pList: PlutusData[]) => List;
55
- export declare const currencySymbol: (bytes: string) => CurrencySymbol;
56
- export declare const tokenName: (bytes: string) => TokenName;
57
- export declare const maybeStakingHash: (stakeCredential: string) => MaybeStakingHash;
58
- export declare const pubKeyAddress: (bytes: string, stakeCredential?: string) => PubKeyAddress;
59
- export declare const scriptAddress: (bytes: string, stakeCredential?: string) => ScriptAddress;
60
- export declare const assetClass: (policyId: string, assetName: string) => AssetClass;
61
- export declare const txOutRef: (txHash: string, index: number) => TxOutRef;
62
- export declare const paymentPubKeyHash: (bytes: string) => PaymentPubKeyHash;
63
- export declare const pubKeyHash: (bytes: string) => PubKeyHash;
64
- export declare const posixTime: (int: number) => POSIXTime;
65
- export declare const assocMap: <K, V>(itemsMap: [K, V][]) => AssocMap<K, V>;
66
- export declare const dict: <K, V>(itemsMap: [K, V][]) => AssocMap<K, V>;
67
- export declare const tuple: <K, V>(key: K, value: V) => Tuple<K, V>;
68
- export declare const value: (assets: Asset[]) => Value;
69
- export declare const parsePlutusValueToAssets: (plutusValue: Value) => Asset[];
@@ -1,79 +0,0 @@
1
- export const conStr = (constructor, fields) => ({
2
- constructor,
3
- fields,
4
- });
5
- export const conStr0 = (fields) => conStr(0, fields);
6
- export const conStr1 = (fields) => conStr(1, fields);
7
- export const conStr2 = (fields) => conStr(2, fields);
8
- export const bool = (b) => (b ? conStr1([]) : conStr0([]));
9
- export const builtinByteString = (bytes) => ({
10
- bytes,
11
- });
12
- export const integer = (int) => ({ int });
13
- export const list = (pList) => ({ list: pList });
14
- export const currencySymbol = (bytes) => builtinByteString(bytes);
15
- export const tokenName = (bytes) => builtinByteString(bytes);
16
- export const maybeStakingHash = (stakeCredential) => {
17
- if (stakeCredential === '') {
18
- return conStr1([]);
19
- }
20
- return conStr0([
21
- conStr0([conStr0([builtinByteString(stakeCredential)])]),
22
- ]);
23
- };
24
- export const pubKeyAddress = (bytes, stakeCredential) => conStr0([conStr0([builtinByteString(bytes)]), maybeStakingHash(stakeCredential || '')]);
25
- export const scriptAddress = (bytes, stakeCredential) => conStr0([conStr1([builtinByteString(bytes)]), maybeStakingHash(stakeCredential || '')]);
26
- export const assetClass = (policyId, assetName) => conStr0([currencySymbol(policyId), tokenName(assetName)]);
27
- export const txOutRef = (txHash, index) => conStr0([conStr0([builtinByteString(txHash)]), integer(index)]);
28
- export const paymentPubKeyHash = (bytes) => builtinByteString(bytes);
29
- export const pubKeyHash = (bytes) => builtinByteString(bytes);
30
- export const posixTime = (int) => ({ int });
31
- export const assocMap = (itemsMap) => ({
32
- map: itemsMap.map(([k, v]) => ({ k, v })),
33
- });
34
- export const dict = (itemsMap) => ({
35
- map: itemsMap.map(([k, v]) => ({ k, v })),
36
- });
37
- export const tuple = (key, value) => conStr0([key, value]);
38
- export const value = (assets) => {
39
- const valueMapToParse = [];
40
- const valueMap = {};
41
- assets.forEach((asset) => {
42
- const sanitizedName = asset.unit.replace('lovelace', '');
43
- const policy = sanitizedName.slice(0, 56) || '';
44
- const token = sanitizedName.slice(56) || '';
45
- if (!valueMap[policy]) {
46
- valueMap[policy] = {};
47
- }
48
- if (!valueMap[policy][token]) {
49
- valueMap[policy][token] = Number(asset.quantity);
50
- }
51
- else {
52
- valueMap[policy][token] += Number(asset.quantity);
53
- }
54
- });
55
- Object.keys(valueMap).forEach((policy) => {
56
- const policyByte = currencySymbol(policy);
57
- const tokens = Object.keys(valueMap[policy]).map((name) => [
58
- tokenName(name),
59
- integer(valueMap[policy][name]),
60
- ]);
61
- const policyMap = assocMap(tokens);
62
- valueMapToParse.push([policyByte, policyMap]);
63
- });
64
- return assocMap(valueMapToParse);
65
- };
66
- export const parsePlutusValueToAssets = (plutusValue) => {
67
- const assets = [];
68
- plutusValue.map.forEach((policyMap) => {
69
- const policy = policyMap.k.bytes;
70
- policyMap.v.map.forEach((tokenMap) => {
71
- const token = tokenMap.k.bytes;
72
- const quantity = tokenMap.v.int.toString();
73
- const unsanitizedUnit = policy + token;
74
- const unit = unsanitizedUnit === '' ? 'lovelace' : unsanitizedUnit;
75
- assets.push({ unit, quantity });
76
- });
77
- });
78
- return assets;
79
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,96 +0,0 @@
1
- import { value, dict, builtinByteString, integer, parsePlutusValueToAssets, } from '.';
2
- describe('Plutus data type', () => {
3
- describe('Value', () => {
4
- test('Simple ADA Value', () => {
5
- const val = [{ unit: 'lovelace', quantity: '1000000' }];
6
- const datum = value(val);
7
- const nameMap = dict([
8
- [builtinByteString(''), integer(1000000)],
9
- ]);
10
- const valMap = dict([
11
- [builtinByteString(''), nameMap],
12
- ]);
13
- expect(JSON.stringify(datum)).toBe(JSON.stringify(valMap));
14
- });
15
- test('Simple token Value', () => {
16
- const val = [
17
- {
18
- unit: 'baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461',
19
- quantity: '345',
20
- },
21
- ];
22
- const datum = value(val);
23
- const nameMap = dict([
24
- [builtinByteString('74657374696e676e657777616c2e616461'), integer(345)],
25
- ]);
26
- const valMap = dict([
27
- [
28
- builtinByteString('baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc81700'),
29
- nameMap,
30
- ],
31
- ]);
32
- expect(JSON.stringify(datum)).toBe(JSON.stringify(valMap));
33
- });
34
- test('Complex Value', () => {
35
- const val = [
36
- { unit: 'lovelace', quantity: '1000000' },
37
- {
38
- unit: 'baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461',
39
- quantity: '345',
40
- },
41
- {
42
- unit: 'baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc817001234',
43
- quantity: '567',
44
- },
45
- ];
46
- const datum = value(val);
47
- const nameMap = dict([
48
- [builtinByteString('1234'), integer(567)],
49
- [builtinByteString('74657374696e676e657777616c2e616461'), integer(345)],
50
- ]);
51
- const valMap = dict([
52
- [builtinByteString(''), dict([[builtinByteString(''), integer(1000000)]])],
53
- [
54
- builtinByteString('baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc81700'),
55
- nameMap,
56
- ],
57
- ]);
58
- expect(JSON.stringify(datum)).toBe(JSON.stringify(valMap));
59
- });
60
- });
61
- });
62
- describe('Value', () => {
63
- test('Simple ADA Value', () => {
64
- const val = [{ unit: 'lovelace', quantity: '1000000' }];
65
- const plutusValue = value(val);
66
- const assets = parsePlutusValueToAssets(plutusValue);
67
- expect(JSON.stringify(val)).toBe(JSON.stringify(assets));
68
- });
69
- test('Simple token Value', () => {
70
- const val = [
71
- {
72
- unit: 'baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461',
73
- quantity: '345',
74
- },
75
- ];
76
- const plutusValue = value(val);
77
- const assets = parsePlutusValueToAssets(plutusValue);
78
- expect(JSON.stringify(val)).toBe(JSON.stringify(assets));
79
- });
80
- test('Complex Value', () => {
81
- const val = [
82
- { unit: 'lovelace', quantity: '1000000' },
83
- {
84
- unit: 'baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc817001234',
85
- quantity: '567',
86
- },
87
- {
88
- unit: 'baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc8170074657374696e676e657777616c2e616461',
89
- quantity: '345',
90
- },
91
- ];
92
- const plutusValue = value(val);
93
- const assets = parsePlutusValueToAssets(plutusValue);
94
- expect(JSON.stringify(val)).toBe(JSON.stringify(assets));
95
- });
96
- });
@@ -1,11 +0,0 @@
1
- import { Network } from '../../types';
2
- export type Slot = number;
3
- export type UnixTime = number;
4
- export type SlotConfig = {
5
- zeroTime: UnixTime;
6
- zeroSlot: Slot;
7
- slotLength: number;
8
- };
9
- export declare const SLOT_CONFIG_NETWORK: Record<Network, SlotConfig>;
10
- export declare const slotToBeginUnixTime: (slot: Slot, slotConfig: SlotConfig) => UnixTime;
11
- export declare const unixTimeToEnclosingSlot: (unixTime: UnixTime, slotConfig: SlotConfig) => Slot;
@@ -1,27 +0,0 @@
1
- export const SLOT_CONFIG_NETWORK = {
2
- mainnet: { zeroTime: 1596059091000, zeroSlot: 4492800, slotLength: 1000 }, // Starting at Shelley era
3
- preview: { zeroTime: 1666656000000, zeroSlot: 0, slotLength: 1000 }, // Starting at Shelley era
4
- preprod: {
5
- zeroTime: 1654041600000 + 1728000000,
6
- zeroSlot: 86400,
7
- slotLength: 1000,
8
- }, // Starting at Shelley era
9
- /** Customizable slot config (Initialized with 0 values). */
10
- testnet: { zeroTime: 0, zeroSlot: 0, slotLength: 0 },
11
- };
12
- export const slotToBeginUnixTime = (slot, slotConfig) => {
13
- const msAfterBegin = (slot - slotConfig.zeroSlot) * slotConfig.slotLength;
14
- return slotConfig.zeroTime + msAfterBegin;
15
- };
16
- // slotToBeginUnixTime and slotToEndUnixTime are identical when slotLength == 1. So we don't need to worry about this now.
17
- // function slotToEndUnixTime(slot: Slot, slotConfig: SlotConfig): UnixTime {
18
- // return slotToBeginUnixTime(slot, slotConfig) + (slotConfig.slotLength - 1);
19
- // }
20
- export const unixTimeToEnclosingSlot = (unixTime, slotConfig) => {
21
- const timePassed = unixTime - slotConfig.zeroTime;
22
- const slotsPassed = Math.floor(timePassed / slotConfig.slotLength);
23
- return slotsPassed + slotConfig.zeroSlot;
24
- };
25
- // const timeNow = new Date().getTime();
26
- // console.log(timeNow);
27
- // console.log(unixTimeToEnclosingSlot(timeNow, SLOT_CONFIG_NETWORK.Preprod));
@@ -1,3 +0,0 @@
1
- export * from './serializer';
2
- export * from './types';
3
- export * from './data';
@@ -1,3 +0,0 @@
1
- export * from './serializer';
2
- export * from './types';
3
- export * from './data';
@@ -1,7 +0,0 @@
1
- import { MeshTxBuilderBody } from './types';
2
- import { Protocol } from '../types';
3
- export declare const emptyTxBuilderBody: () => MeshTxBuilderBody;
4
- export interface IMeshSerializer {
5
- serializeTxBody(txBody: MeshTxBuilderBody, protocolParams: Protocol): string;
6
- addSigningKeys(txHex: string, signingKeys: string[]): string;
7
- }
@@ -1,15 +0,0 @@
1
- export const emptyTxBuilderBody = () => ({
2
- inputs: [],
3
- outputs: [],
4
- extraInputs: [],
5
- selectionThreshold: 0,
6
- collaterals: [],
7
- requiredSignatures: [],
8
- referenceInputs: [],
9
- mints: [],
10
- changeAddress: '',
11
- metadata: [],
12
- validityRange: {},
13
- certificates: [],
14
- signingKey: [],
15
- });
@@ -1,128 +0,0 @@
1
- import { Asset, Budget, Data, LanguageVersion, PlutusScript, UTxO, PoolParams } from '../types';
2
- export type MeshTxBuilderBody = {
3
- inputs: TxIn[];
4
- outputs: Output[];
5
- extraInputs: UTxO[];
6
- selectionThreshold: number;
7
- collaterals: PubKeyTxIn[];
8
- requiredSignatures: string[];
9
- referenceInputs: RefTxIn[];
10
- mints: MintItem[];
11
- changeAddress: string;
12
- metadata: Metadata[];
13
- validityRange: ValidityRange;
14
- certificates: Certificate[];
15
- signingKey: string[];
16
- };
17
- export type TxIn = PubKeyTxIn | ScriptTxIn;
18
- export type PubKeyTxIn = {
19
- type: 'PubKey';
20
- txIn: TxInParameter;
21
- };
22
- export type TxInParameter = {
23
- txHash: string;
24
- txIndex: number;
25
- amount?: Asset[];
26
- address?: string;
27
- };
28
- export type ScriptTxIn = {
29
- type: 'Script';
30
- txIn: TxInParameter;
31
- scriptTxIn: ScriptTxInParameter;
32
- };
33
- export type ScriptTxInParameter = {
34
- scriptSource?: {
35
- type: 'Provided';
36
- script: PlutusScript;
37
- } | {
38
- type: 'Inline';
39
- txInInfo: ScriptSourceInfo;
40
- };
41
- datumSource?: {
42
- type: 'Provided';
43
- data: BuilderData;
44
- } | {
45
- type: 'Inline';
46
- txHash: string;
47
- txIndex: number;
48
- };
49
- redeemer?: Redeemer;
50
- };
51
- export type ScriptSourceInfo = {
52
- txHash: string;
53
- txIndex: number;
54
- spendingScriptHash?: string;
55
- version: LanguageVersion;
56
- };
57
- export type RefTxIn = {
58
- txHash: string;
59
- txIndex: number;
60
- };
61
- export type Output = {
62
- address: string;
63
- amount: Asset[];
64
- datum?: {
65
- type: 'Hash' | 'Inline';
66
- data: BuilderData;
67
- };
68
- referenceScript?: PlutusScript;
69
- };
70
- export type MintItem = {
71
- type: 'Plutus' | 'Native';
72
- policyId: string;
73
- assetName: string;
74
- amount: string;
75
- redeemer?: Redeemer;
76
- scriptSource?: {
77
- type: 'Provided';
78
- script: PlutusScript;
79
- } | {
80
- type: 'Reference Script';
81
- txHash: string;
82
- txIndex: number;
83
- version: LanguageVersion;
84
- };
85
- };
86
- export type ValidityRange = {
87
- invalidBefore?: number;
88
- invalidHereafter?: number;
89
- };
90
- export type BuilderData = {
91
- type: 'Mesh';
92
- content: Data;
93
- } | {
94
- type: 'JSON';
95
- content: string;
96
- } | {
97
- type: 'CBOR';
98
- content: string;
99
- };
100
- export type Redeemer = {
101
- data: BuilderData;
102
- exUnits: Budget;
103
- };
104
- export type Metadata = {
105
- tag: string;
106
- metadata: object;
107
- };
108
- export type Certificate = {
109
- type: 'RegisterPool';
110
- poolParams: PoolParams;
111
- } | {
112
- type: 'RegisterStake';
113
- stakeKeyHash: string;
114
- } | {
115
- type: 'DelegateStake';
116
- stakeKeyHash: string;
117
- poolId: string;
118
- } | {
119
- type: 'DeregisterStake';
120
- stakeKeyHash: string;
121
- } | {
122
- type: 'RetirePool';
123
- poolId: string;
124
- epoch: number;
125
- };
126
- export type RequiredWith<T, K extends keyof T> = Required<T> & {
127
- [P in K]: Required<T[P]>;
128
- };
@@ -1 +0,0 @@
1
- export {};