@meshsdk/common 1.5.30 → 1.6.0-alpha.20
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.
- package/package.json +3 -9
- package/src/constants/cost-models.ts +30 -0
- package/src/constants/index.ts +86 -0
- package/src/constants/language-views.ts +19 -0
- package/src/constants/protocol-parameters.ts +34 -0
- package/src/constants/supported-wallets.ts +12 -0
- package/src/data/index.ts +5 -0
- package/src/data/json/aliases.ts +218 -0
- package/src/data/json/constructors.ts +56 -0
- package/src/data/json/credentials.ts +77 -0
- package/src/data/json/index.ts +33 -0
- package/src/data/json/primitives.ts +154 -0
- package/src/data/mesh/aliases.ts +85 -0
- package/src/data/mesh/constructors.ts +68 -0
- package/src/data/mesh/credentials.ts +77 -0
- package/src/data/mesh/index.ts +4 -0
- package/src/data/mesh/primitives.ts +37 -0
- package/src/data/parser.ts +36 -0
- package/src/data/time.ts +92 -0
- package/src/data/value.ts +70 -0
- package/src/index.ts +7 -0
- package/src/interfaces/evaluator.ts +5 -0
- package/src/interfaces/fetcher.ts +31 -0
- package/src/interfaces/index.ts +7 -0
- package/src/interfaces/initiator.ts +9 -0
- package/src/interfaces/listener.ts +3 -0
- package/src/interfaces/serializer.ts +53 -0
- package/src/interfaces/signer.ts +12 -0
- package/src/interfaces/submitter.ts +3 -0
- package/src/types/account-info.ts +7 -0
- package/src/types/action.ts +15 -0
- package/src/types/asset-extended.ts +9 -0
- package/src/types/asset-metadata.ts +102 -0
- package/src/types/asset.ts +23 -0
- package/src/types/block-info.ts +17 -0
- package/src/types/data-signature.ts +4 -0
- package/src/types/data.ts +10 -0
- package/src/types/deserialized/deserialized-address.ts +6 -0
- package/src/types/deserialized/deserialized-script.ts +4 -0
- package/src/types/deserialized/index.ts +2 -0
- package/src/types/era.ts +1 -0
- package/src/types/index.ts +24 -0
- package/src/types/message.ts +4 -0
- package/src/types/mint.ts +12 -0
- package/src/types/native-script.ts +18 -0
- package/src/types/network.ts +7 -0
- package/src/types/plutus-script.ts +8 -0
- package/src/types/pool-params.ts +41 -0
- package/src/types/protocol.ts +22 -0
- package/src/types/recipient.ts +15 -0
- package/src/types/relay.ts +42 -0
- package/src/types/token.ts +3 -0
- package/src/types/transaction-builder/data.ts +31 -0
- package/src/types/transaction-builder/index.ts +73 -0
- package/src/types/transaction-builder/mint.ts +11 -0
- package/src/types/transaction-builder/output.ts +12 -0
- package/src/types/transaction-builder/script.ts +27 -0
- package/src/types/transaction-builder/txin.ts +46 -0
- package/src/types/transaction-builder/withdrawal.ts +207 -0
- package/src/types/transaction-info.ts +11 -0
- package/src/types/utxo.ts +16 -0
- package/src/types/wallet.ts +6 -0
- package/src/utils/asset-fingerprint.ts +11 -0
- package/src/utils/bigNum.ts +61 -0
- package/src/utils/index.ts +2 -0
- package/test/data/json/aliases.test.ts +135 -0
- package/test/data/json/constructors.test.ts +38 -0
- package/test/data/json/credentials.test.ts +84 -0
- package/test/data/json/primitives.test.ts +133 -0
- package/test/data/mesh/aliases.test.ts +45 -0
- package/test/data/mesh/common.ts +14 -0
- package/test/data/mesh/constructors.test.ts +53 -0
- package/test/data/mesh/credentials.test.ts +74 -0
- package/test/data/mesh/primitives.test.ts +41 -0
- package/test/data/value.test.ts +108 -0
- package/tsconfig.json +5 -0
- package/dist/index.d.mts +0 -1176
- package/dist/index.d.ts +0 -1176
- package/dist/index.js +0 -1
- package/dist/index.mjs +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
package/src/types/era.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Era = "ALONZO" | "BABBAGE";
|
|
@@ -0,0 +1,24 @@
|
|
|
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";
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
};
|