Skip to content

Commit

Permalink
update collateral and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglescode committed Aug 17, 2024
1 parent 8e215a4 commit 2afe2ac
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Left() {
return (
<>
<p>Submit a serialized transaction to the network.</p>
<Codeblock data={`await blockchainProvider.submitTx(signedTx`} />
<Codeblock data={`await blockchainProvider.submitTx(signedTx);`} />
</>
);
}
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/mesh-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/common",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/contract",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-core-csl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-csl",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-core-cst/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-cst",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/provider",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/react",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-transaction/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/transaction",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/wallet",
"version": "1.6.8",
"version": "1.6.9",
"description": "",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down
36 changes: 16 additions & 20 deletions packages/mesh-wallet/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,6 @@ export class BrowserWallet implements IInitiator, ISigner, ISubmitter {
return usedAddresses.map((usa) => addressToBech32(deserializeAddress(usa)));
}

/**
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
*
* This is used in transaction building.
*
* @returns a list of UTXOs
*/
async getUsedCollateral(
limit = DEFAULT_PROTOCOL_PARAMETERS.maxCollateralInputs,
): Promise<TransactionUnspentOutput[]> {
const collateral =
(await this._walletInstance.experimental.getCollateral()) ?? [];
return collateral.map((c) => deserializeTxUnspentOutput(c)).slice(0, limit);
}

/**
* Return a list of all UTXOs (unspent transaction outputs) controlled by the wallet.
*
Expand Down Expand Up @@ -335,7 +320,7 @@ export class BrowserWallet implements IInitiator, ISigner, ISubmitter {
const unsignedTx = unsignedTxs[i]!;
const cWitness = witnessSets[i]!;
if (cWitness === "") {
// It's possible that txs are signed just to give
// It's possible that txs are signed just to give
// browser wallet the tx context
signedTxs.push(unsignedTx);
} else {
Expand Down Expand Up @@ -382,10 +367,21 @@ export class BrowserWallet implements IInitiator, ISigner, ISubmitter {
*
* @returns a list of UTXOs
*/
async getCollateralUnspentOutput(): Promise<TransactionUnspentOutput[]> {
const collateral =
(await this._walletInstance.experimental.getCollateral()) ?? [];
return collateral.map((c) => deserializeTxUnspentOutput(c));
async getCollateralUnspentOutput(
limit = DEFAULT_PROTOCOL_PARAMETERS.maxCollateralInputs,
): Promise<TransactionUnspentOutput[]> {
let collateral: string[] = [];
try {
collateral = (await this._walletInstance.getCollateral()) ?? [];
} catch (e) {
try {
collateral =
(await this._walletInstance.experimental.getCollateral()) ?? [];
} catch (e) {
console.error(e);
}
}
return collateral.map((c) => deserializeTxUnspentOutput(c)).slice(0, limit);
}

/**
Expand Down
17 changes: 0 additions & 17 deletions packages/mesh-wallet/src/mesh/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,6 @@ export class MeshWallet implements IInitiator, ISigner, ISubmitter {
return [this.getChangeAddress()];
}

/**
* Get a list of UTXOs to be used as collateral inputs for transactions with plutus script inputs.
*
* This is used in transaction building.
*
* @returns a list of UTXOs
*/
async getUsedCollateral(): Promise<TransactionUnspentOutput[]> {
const collateralUtxo = await this.getCollateral();

const unspentOutput = collateralUtxo.map((utxo) => {
return toTxUnspentOutput(utxo);
});

return unspentOutput;
}

/**
* Get a list of UTXOs to be used for transaction building.
*
Expand Down
1 change: 1 addition & 0 deletions packages/mesh-wallet/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface Cip30WalletApi {
getBalance(): Promise<string>;
getChangeAddress(): Promise<string>;
getExtensions(): Promise<{ cip: number }[]>;
getCollateral(): Promise<string[] | undefined>;
getNetworkId(): Promise<number>;
getRewardAddresses(): Promise<string[]>;
getUnusedAddresses(): Promise<string[]>;
Expand Down

0 comments on commit 2afe2ac

Please sign in to comment.