@meshsdk/core 1.5.16 → 1.5.18

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.
@@ -2,5 +2,5 @@ export * from './blockfrost.provider';
2
2
  export * from './infura.provider';
3
3
  export * from './koios.provider';
4
4
  export * from './ogmios.provider';
5
- export * from './tango.provider';
6
5
  export * from './maestro.provider';
6
+ export * from './yaci.provider';
@@ -0,0 +1,32 @@
1
+ import { IFetcher, IListener, ISubmitter } from '@mesh/common/contracts';
2
+ import type { AccountInfo, Asset, AssetMetadata, BlockInfo, Protocol, TransactionInfo, UTxO } from '@mesh/common/types';
3
+ export declare class YaciProvider implements IFetcher, IListener, ISubmitter {
4
+ private readonly _axiosInstance;
5
+ /**
6
+ * Set the URL of the instance.
7
+ * @param baseUrl The base URL of the instance.
8
+ */
9
+ constructor(baseUrl?: string);
10
+ fetchAccountInfo(address: string): Promise<AccountInfo>;
11
+ private resolveScriptRef;
12
+ private toUTxO;
13
+ fetchAddressUTxOs(address: string, asset?: string): Promise<UTxO[]>;
14
+ fetchAssetAddresses(asset: string): Promise<{
15
+ address: string;
16
+ quantity: string;
17
+ }[]>;
18
+ fetchAssetMetadata(asset: string): Promise<AssetMetadata>;
19
+ fetchBlockInfo(hash: string): Promise<BlockInfo>;
20
+ fetchCollectionAssets(policyId: string, cursor?: number): Promise<{
21
+ assets: Asset[];
22
+ next: string | number | null;
23
+ }>;
24
+ fetchHandleAddress(handle: string): Promise<string>;
25
+ fetchProtocolParameters(epoch?: number): Promise<Protocol>;
26
+ fetchTxInfo(hash: string): Promise<TransactionInfo>;
27
+ fetchUTxOs(hash: string): Promise<UTxO[]>;
28
+ onTxConfirmed(txHash: string, callback: () => void, limit?: number): void;
29
+ submitTx(txHex: string): Promise<string>;
30
+ private fetchPlutusScriptCBOR;
31
+ private fetchNativeScriptJSON;
32
+ }
@@ -1,3 +1,4 @@
1
+ import { csl } from '@mesh/core';
1
2
  import { IFetcher, IInitiator, ISigner, ISubmitter } from '@mesh/common/contracts';
2
3
  import type { Address, TransactionUnspentOutput } from '@mesh/core';
3
4
  import type { DataSignature } from '@mesh/common/types';
@@ -33,4 +34,10 @@ export declare class AppWallet implements IInitiator, ISigner, ISubmitter {
33
34
  signTxs(unsignedTxs: string[], partialSign: boolean): Promise<string[]>;
34
35
  submitTx(tx: string): Promise<string>;
35
36
  static brew(strength?: number): string[];
37
+ /**
38
+ * development: browser wallets apis
39
+ */
40
+ getUtxos(): Promise<TransactionUnspentOutput[]>;
41
+ getCollateral(): Promise<csl.TransactionUnspentOutput>;
42
+ getUsedAddresses(): Promise<string[]>;
36
43
  }
@@ -1,37 +1,180 @@
1
1
  import { IInitiator, ISigner, ISubmitter } from '@mesh/common/contracts';
2
2
  import type { Address, TransactionUnspentOutput } from '@mesh/core';
3
3
  import type { Asset, AssetExtended, DataSignature, UTxO, Wallet } from '@mesh/common/types';
4
+ /**
5
+ * These wallets APIs are in accordance to CIP-30, which defines the API for dApps to communicate with the user's wallet. Additional utility functions provided for developers that are useful for building dApps.
6
+ *
7
+ * ```javascript
8
+ * // import BrowserWallet
9
+ * import { BrowserWallet } from '@meshsdk/core';
10
+ *
11
+ * // connect to a wallet
12
+ * const wallet = await BrowserWallet.enable('eternl');
13
+ *
14
+ * // get assets in wallet
15
+ * const assets = await wallet.getAssets();
16
+ * ```
17
+ */
4
18
  export declare class BrowserWallet implements IInitiator, ISigner, ISubmitter {
5
19
  readonly _walletInstance: WalletInstance;
6
20
  readonly _walletName: string;
7
21
  walletInstance: WalletInstance;
8
22
  private constructor();
23
+ /**
24
+ * Returns a list of wallets installed on user's device. Each wallet is an object with the following properties:
25
+ * - A name is provided to display wallet's name on the user interface.
26
+ * - A version is provided to display wallet's version on the user interface.
27
+ * - An icon is provided to display wallet's icon on the user interface.
28
+ *
29
+ * @returns a list of wallet names
30
+ */
9
31
  static getInstalledWallets(): Wallet[];
32
+ /**
33
+ * This is the entrypoint to start communication with the user's wallet. The wallet should request the user's permission to connect the web page to the user's wallet, and if permission has been granted, the wallet will be returned and exposing the full API for the dApp to use.
34
+ *
35
+ * Query BrowserWallet.getInstalledWallets() to get a list of available wallets, then provide the wallet name for which wallet the user would like to connect with.
36
+ *
37
+ * @param walletName
38
+ * @returns WalletInstance
39
+ */
10
40
  static enable(walletName: string): Promise<BrowserWallet>;
41
+ /**
42
+ * Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
43
+ * - A unit is provided to display asset's name on the user interface.
44
+ * - A quantity is provided to display asset's quantity on the user interface.
45
+ *
46
+ * @returns a list of assets and their quantities
47
+ */
11
48
  getBalance(): Promise<Asset[]>;
49
+ /**
50
+ * Returns an address owned by the wallet that should be used as a change address to return leftover assets during transaction creation back to the connected wallet.
51
+ *
52
+ * @returns an address
53
+ */
12
54
  getChangeAddress(): Promise<string>;
55
+ /**
56
+ * This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
57
+ *
58
+ * If this cannot be attained, an error message with an explanation of the blocking problem shall be returned. NOTE: wallets are free to return UTXOs that add up to a greater total ADA value than requested in the amount parameter, but wallets must never return any result where UTXOs would sum up to a smaller total ADA value, instead in a case like that an error message must be returned.
59
+ *
60
+ * @param limit
61
+ * @returns a list of UTXOs
62
+ */
13
63
  getCollateral(limit?: number): Promise<UTxO[]>;
64
+ /**
65
+ * Returns the network ID of the currently connected account. 0 is testnet and 1 is mainnet but other networks can possibly be returned by wallets. Those other network ID values are not governed by CIP-30. This result will stay the same unless the connected account has changed.
66
+ *
67
+ * @returns network ID
68
+ */
14
69
  getNetworkId(): Promise<number>;
70
+ /**
71
+ * Returns a list of reward addresses owned by the wallet. A reward address is a stake address that is used to receive rewards from staking, generally starts from `stake` prefix.
72
+ *
73
+ * @returns a list of reward addresses
74
+ */
15
75
  getRewardAddresses(): Promise<string[]>;
76
+ /**
77
+ * Returns a list of unused addresses controlled by the wallet.
78
+ *
79
+ * @returns a list of unused addresses
80
+ */
16
81
  getUnusedAddresses(): Promise<string[]>;
82
+ /**
83
+ * Returns a list of used addresses controlled by the wallet.
84
+ *
85
+ * @returns a list of used addresses
86
+ */
17
87
  getUsedAddresses(): Promise<string[]>;
88
+ /**
89
+ * Return a list of all UTXOs (unspent transaction outputs) controlled by the wallet.
90
+ *
91
+ * @param amount
92
+ * @returns a list of UTXOs
93
+ */
18
94
  getUtxos(amount?: Asset[] | undefined): Promise<UTxO[]>;
95
+ /**
96
+ * This endpoint utilizes the [CIP-8 - Message Signing](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) to sign arbitrary data, to verify the data was signed by the owner of the private key.
97
+ *
98
+ * Here, we get the first wallet's address with wallet.getUsedAddresses(), alternativelly you can use reward addresses (getRewardAddresses()) too. It's really up to you as the developer which address you want to use in your application.
99
+ *
100
+ * @param address
101
+ * @param payload
102
+ * @returns a signature
103
+ */
19
104
  signData(address: string, payload: string): Promise<DataSignature>;
105
+ /**
106
+ * Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
107
+ *
108
+ * @param unsignedTx
109
+ * @param partialSign
110
+ * @returns a signed transaction in CBOR
111
+ */
20
112
  signTx(unsignedTx: string, partialSign?: boolean): Promise<string>;
21
113
  /**
22
114
  * Experimental feature - sign multiple transactions at once (Supported wallet(s): Typhon)
115
+ *
23
116
  * @param unsignedTxs - array of unsigned transactions in CborHex string
24
117
  * @param partialSign - if the transactions are signed partially
25
118
  * @returns array of signed transactions CborHex string
26
119
  */
27
120
  signTxs(unsignedTxs: string[], partialSign?: boolean): Promise<string[]>;
121
+ /**
122
+ * Submits the signed transaction to the blockchain network.
123
+ *
124
+ * As wallets should already have this ability to submit transaction, we allow dApps to request that a transaction be sent through it. If the wallet accepts the transaction and tries to send it, it shall return the transaction ID for the dApp to track. The wallet can return error messages or failure if there was an error in sending it.
125
+ *
126
+ * @param tx
127
+ * @returns a transaction hash
128
+ */
28
129
  submitTx(tx: string): Promise<string>;
130
+ /**
131
+ * Get a used address of type Address from the wallet.
132
+ *
133
+ * This is used in transaction building.
134
+ *
135
+ * @returns an Address object
136
+ */
29
137
  getUsedAddress(): Promise<Address>;
138
+ /**
139
+ * Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
140
+ *
141
+ * This is used in transaction building.
142
+ *
143
+ * @returns a list of UTXOs
144
+ */
30
145
  getUsedCollateral(limit?: number): Promise<TransactionUnspentOutput[]>;
146
+ /**
147
+ * Get a list of UTXOs to be used for transaction building.
148
+ *
149
+ * This is used in transaction building.
150
+ *
151
+ * @returns a list of UTXOs
152
+ */
31
153
  getUsedUTxOs(amount?: Asset[] | undefined): Promise<TransactionUnspentOutput[]>;
154
+ /**
155
+ * A helper function to get the assets in the wallet.
156
+ *
157
+ * @returns a list of assets
158
+ */
32
159
  getAssets(): Promise<AssetExtended[]>;
160
+ /**
161
+ * A helper function to get the lovelace balance in the wallet.
162
+ *
163
+ * @returns lovelace balance
164
+ */
33
165
  getLovelace(): Promise<string>;
166
+ /**
167
+ * A helper function to get the assets of a specific policy ID in the wallet.
168
+ *
169
+ * @param policyId
170
+ * @returns a list of assets
171
+ */
34
172
  getPolicyIdAssets(policyId: string): Promise<AssetExtended[]>;
173
+ /**
174
+ * A helper function to get the policy IDs of all the assets in the wallet.
175
+ *
176
+ * @returns a list of policy IDs
177
+ */
35
178
  getPolicyIds(): Promise<string[]>;
36
179
  private static resolveInstance;
37
180
  }
@@ -1,3 +1,4 @@
1
1
  export * from './app.service';
2
2
  export * from './browser.service';
3
3
  export * from './embedded.service';
4
+ export * from './mesh.service';
@@ -0,0 +1,188 @@
1
+ import { IFetcher, IInitiator, ISigner, ISubmitter } from '@mesh/common/contracts';
2
+ import type { Address, TransactionUnspentOutput } from '@mesh/core';
3
+ import type { Asset, AssetExtended, DataSignature, UTxO } from '@mesh/common/types';
4
+ export declare type CreateMeshWalletOptions = {
5
+ networkId: number;
6
+ fetcher: IFetcher;
7
+ submitter: ISubmitter;
8
+ key: {
9
+ type: 'root';
10
+ bech32: string;
11
+ } | {
12
+ type: 'cli';
13
+ payment: string;
14
+ stake?: string;
15
+ } | {
16
+ type: 'mnemonic';
17
+ words: string[];
18
+ };
19
+ };
20
+ /**
21
+ * Mesh Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.
22
+ *
23
+ * It is a single address wallet, a wrapper around the AppWallet class.
24
+ *
25
+ * ```javascript
26
+ * import { MeshWallet, BlockfrostProvider } from '@meshsdk/core';
27
+ *
28
+ * const blockchainProvider = new BlockfrostProvider('<BLOCKFROST_API_KEY>');
29
+ *
30
+ * const wallet = new MeshWallet({
31
+ * networkId: 0,
32
+ * fetcher: blockchainProvider,
33
+ * submitter: blockchainProvider,
34
+ * key: {
35
+ * type: 'mnemonic',
36
+ * words: ["solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution","solution"],
37
+ * },
38
+ * });
39
+ * ```
40
+ */
41
+ export declare class MeshWallet implements IInitiator, ISigner, ISubmitter {
42
+ private readonly _wallet;
43
+ private readonly _network;
44
+ constructor(options: CreateMeshWalletOptions);
45
+ /**
46
+ * Returns a list of assets in the wallet. This API will return every assets in the wallet. Each asset is an object with the following properties:
47
+ * - A unit is provided to display asset's name on the user interface.
48
+ * - A quantity is provided to display asset's quantity on the user interface.
49
+ *
50
+ * @returns a list of assets and their quantities
51
+ */
52
+ getBalance(): Promise<Asset[]>;
53
+ /**
54
+ * Returns an address owned by the wallet that should be used as a change address to return leftover assets during transaction creation back to the connected wallet.
55
+ *
56
+ * @returns an address
57
+ */
58
+ getChangeAddress(): string;
59
+ /**
60
+ * This function shall return a list of one or more UTXOs (unspent transaction outputs) controlled by the wallet that are required to reach AT LEAST the combined ADA value target specified in amount AND the best suitable to be used as collateral inputs for transactions with plutus script inputs (pure ADA-only UTXOs).
61
+ *
62
+ * If this cannot be attained, an error message with an explanation of the blocking problem shall be returned. NOTE: wallets are free to return UTXOs that add up to a greater total ADA value than requested in the amount parameter, but wallets must never return any result where UTXOs would sum up to a smaller total ADA value, instead in a case like that an error message must be returned.
63
+ *
64
+ * @returns a list of UTXOs
65
+ */
66
+ getCollateral(): Promise<UTxO[]>;
67
+ /**
68
+ * Returns the network ID of the currently connected account. 0 is testnet and 1 is mainnet but other networks can possibly be returned by wallets. Those other network ID values are not governed by CIP-30. This result will stay the same unless the connected account has changed.
69
+ *
70
+ * @returns network ID
71
+ */
72
+ getNetworkId(): number;
73
+ /**
74
+ * Returns a list of reward addresses owned by the wallet. A reward address is a stake address that is used to receive rewards from staking, generally starts from `stake` prefix.
75
+ *
76
+ * @returns a list of reward addresses
77
+ */
78
+ getRewardAddresses(): Promise<string[]>;
79
+ /**
80
+ * Returns a list of unused addresses controlled by the wallet.
81
+ *
82
+ * @returns a list of unused addresses
83
+ */
84
+ getUnusedAddresses(): string[];
85
+ /**
86
+ * Returns a list of used addresses controlled by the wallet.
87
+ *
88
+ * @returns a list of used addresses
89
+ */
90
+ getUsedAddresses(): Promise<string[]>;
91
+ /**
92
+ * Return a list of all UTXOs (unspent transaction outputs) controlled by the wallet.
93
+ *
94
+ * @returns a list of UTXOs
95
+ */
96
+ getUtxos(): Promise<UTxO[]>;
97
+ /**
98
+ * This endpoint utilizes the [CIP-8 - Message Signing](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) to sign arbitrary data, to verify the data was signed by the owner of the private key.
99
+ *
100
+ * Here, we get the first wallet's address with wallet.getUsedAddresses(), alternativelly you can use reward addresses (getRewardAddresses()) too. It's really up to you as the developer which address you want to use in your application.
101
+ *
102
+ * @param address
103
+ * @param payload
104
+ * @returns a signature
105
+ */
106
+ signData(payload: string): DataSignature;
107
+ /**
108
+ * Requests user to sign the provided transaction (tx). The wallet should ask the user for permission, and if given, try to sign the supplied body and return a signed transaction. partialSign should be true if the transaction provided requires multiple signatures.
109
+ *
110
+ * @param unsignedTx
111
+ * @param partialSign
112
+ * @returns a signed transaction in CBOR
113
+ */
114
+ signTx(unsignedTx: string, partialSign?: boolean): Promise<string>;
115
+ /**
116
+ * Experimental feature - sign multiple transactions at once.
117
+ *
118
+ * @param unsignedTxs - array of unsigned transactions in CborHex string
119
+ * @param partialSign - if the transactions are signed partially
120
+ * @returns array of signed transactions CborHex string
121
+ */
122
+ signTxs(unsignedTxs: string[], partialSign?: boolean): Promise<string[]>;
123
+ /**
124
+ * Submits the signed transaction to the blockchain network.
125
+ *
126
+ * As wallets should already have this ability to submit transaction, we allow dApps to request that a transaction be sent through it. If the wallet accepts the transaction and tries to send it, it shall return the transaction ID for the dApp to track. The wallet can return error messages or failure if there was an error in sending it.
127
+ *
128
+ * @param tx
129
+ * @returns a transaction hash
130
+ */
131
+ submitTx(tx: string): Promise<string>;
132
+ /**
133
+ * Get a used address of type Address from the wallet.
134
+ *
135
+ * This is used in transaction building.
136
+ *
137
+ * @returns an Address object
138
+ */
139
+ getUsedAddress(): Address;
140
+ /**
141
+ * Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
142
+ *
143
+ * This is used in transaction building.
144
+ *
145
+ * @returns a list of UTXOs
146
+ */
147
+ getUsedCollateral(): Promise<TransactionUnspentOutput[]>;
148
+ /**
149
+ * Get a list of UTXOs to be used for transaction building.
150
+ *
151
+ * This is used in transaction building.
152
+ *
153
+ * @returns a list of UTXOs
154
+ */
155
+ getUsedUTxOs(): Promise<TransactionUnspentOutput[]>;
156
+ /**
157
+ * A helper function to get the assets in the wallet.
158
+ *
159
+ * @returns a list of assets
160
+ */
161
+ getAssets(): Promise<AssetExtended[]>;
162
+ /**
163
+ * A helper function to get the lovelace balance in the wallet.
164
+ *
165
+ * @returns lovelace balance
166
+ */
167
+ getLovelace(): Promise<string>;
168
+ /**
169
+ * A helper function to get the assets of a specific policy ID in the wallet.
170
+ *
171
+ * @param policyId
172
+ * @returns a list of assets
173
+ */
174
+ getPolicyIdAssets(policyId: string): Promise<AssetExtended[]>;
175
+ /**
176
+ * A helper function to get the policy IDs of all the assets in the wallet.
177
+ *
178
+ * @returns a list of policy IDs
179
+ */
180
+ getPolicyIds(): Promise<string[]>;
181
+ /**
182
+ * A helper function to create a collateral input for a transaction.
183
+ *
184
+ * @returns a transaction hash
185
+ */
186
+ createCollateral(): Promise<string>;
187
+ static brew(privateKey?: boolean, strength?: number): string[] | string;
188
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Rapidly build Web3 apps on the Cardano Blockchain.",
4
4
  "homepage": "https://meshjs.dev",
5
5
  "author": "MeshJS",
6
- "version": "1.5.16",
6
+ "version": "1.5.18",
7
7
  "license": "Apache-2.0",
8
8
  "type": "module",
9
9
  "repository": {