Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@emurgo/yoroi-lib-core

Package Overview
Dependencies
Maintainers
3
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emurgo/yoroi-lib-core - npm Package Compare versions

Comparing version 0.5.1-alpha.32 to 0.6.0-alpha.33

8

dist/index.d.ts
/// <reference types="node" />
import { BigNumber } from 'bignumber.js';
import { AccountStatePart, Addressing, AddressingAddress, CardanoAddressedUtxo, CardanoHaskellConfig, CreateDelegationTxResponse, MultiTokenValue, SendToken, Token, TxOptions, WithdrawalRequest } from './internals/models';
import { AccountStatePart, Addressing, AddressingAddress, CardanoAddressedUtxo, CardanoHaskellConfig, MultiTokenValue, SendToken, Token, TxOptions, WithdrawalRequest } from './internals/models';
import { UnsignedTx } from './internals/tx';

@@ -32,6 +32,6 @@ import * as WasmContract from './internals/wasm-contract';

[key: string]: null | AccountStatePart;
}, absSlotNumber: BigNumber, utxos: Array<CardanoAddressedUtxo>, withdrawalRequests: Array<WithdrawalRequest>, changeAddr: AddressingAddress, config: CardanoHaskellConfig, txOptions: TxOptions): Promise<UnsignedTx>;
createUnsignedVotingTx(absSlotNumber: BigNumber, votingPublicKey: PublicKey, stakingKeyPath: number[], stakingPublicKey: PublicKey, utxos: Array<CardanoAddressedUtxo>, changeAddr: AddressingAddress, config: CardanoHaskellConfig, txOptions: TxOptions, nonce: number, signer: (hashedMetadata: Buffer) => Promise<string>): Promise<UnsignedTx>;
createUnsignedDelegationTx(absSlotNumber: BigNumber, utxos: Array<CardanoAddressedUtxo>, stakingKey: PublicKey, registrationStatus: boolean, poolId: string | null, changeAddr: AddressingAddress, valueInAccount: MultiTokenValue, defaultToken: Token, txOptions: TxOptions, config: CardanoHaskellConfig): Promise<CreateDelegationTxResponse>;
}, defaultToken: Token, absSlotNumber: BigNumber, utxos: Array<CardanoAddressedUtxo>, withdrawalRequests: Array<WithdrawalRequest>, changeAddr: AddressingAddress, config: CardanoHaskellConfig, txOptions: TxOptions): Promise<UnsignedTx>;
createUnsignedVotingTx(absSlotNumber: BigNumber, defaultToken: Token, votingPublicKey: PublicKey, stakingKeyPath: number[], stakingPublicKey: PublicKey, utxos: Array<CardanoAddressedUtxo>, changeAddr: AddressingAddress, config: CardanoHaskellConfig, txOptions: TxOptions, nonce: number, signer: (hashedMetadata: Buffer) => Promise<string>): Promise<UnsignedTx>;
createUnsignedDelegationTx(absSlotNumber: BigNumber, utxos: Array<CardanoAddressedUtxo>, stakingKey: PublicKey, registrationStatus: boolean, poolId: string | null, changeAddr: AddressingAddress, valueInAccount: MultiTokenValue, defaultToken: Token, txOptions: TxOptions, config: CardanoHaskellConfig): Promise<UnsignedTx>;
buildLedgerPayload(unsignedTx: UnsignedTx, networkId: number, byronNetworkMagic: number, addressingMap: (addr: string) => Addressing): Promise<LedgerSignTransactionRequest>;
}

@@ -28,3 +28,2 @@ "use strict";

const models_1 = require("./internals/models");
const multi_token_1 = require("./internals/multi-token");
const tx_1 = require("./internals/tx");

@@ -131,6 +130,6 @@ const utils_1 = require("./internals/utils");

}
return yield this.createUnsignedTxForUtxos(absSlotNumber, receivers, defaultToken, tokens, utxos, config, txOptions);
return yield this.createUnsignedTxForUtxos(absSlotNumber, receivers, defaultToken, tokens, utxos, config, txOptions, undefined, undefined);
});
}
createUnsignedVotingTx(absSlotNumber, votingPublicKey, stakingKeyPath, stakingPublicKey, utxos, changeAddr, config, txOptions, nonce, signer) {
createUnsignedVotingTx(absSlotNumber, defaultToken, votingPublicKey, stakingKeyPath, stakingPublicKey, utxos, changeAddr, config, txOptions, nonce, signer) {
return __awaiter(this, void 0, void 0, function* () {

@@ -165,3 +164,3 @@ const rewardAddress = this.Wasm.RewardAddress.new(config.networkId, yield this.Wasm.StakeCredential.fromKeyhash(yield stakingPublicKey.hash()));

};
const unsignedTx = yield this.newAdaUnsignedTx([], changeAddr, utxos, absSlotNumber, protocolParams, [], [], auxData, {
const unsignedTx = yield this.newAdaUnsignedTx([], defaultToken, changeAddr, utxos, absSlotNumber, protocolParams, [], [], auxData, {
neededHashes: new Set(),

@@ -173,7 +172,7 @@ wits: new Set()

votingPublicKey: Buffer.from(yield stakingPublicKey.asBytes()).toString('hex')
});
}, stakingPublicKey, undefined);
return unsignedTx;
});
}
createUnsignedWithdrawalTx(accountState, absSlotNumber, utxos, withdrawalRequests, changeAddr, config, txOptions) {
createUnsignedWithdrawalTx(accountState, defaultToken, absSlotNumber, utxos, withdrawalRequests, changeAddr, config, txOptions) {
return __awaiter(this, void 0, void 0, function* () {

@@ -239,3 +238,3 @@ const certificates = [];

};
const unsignedTx = yield this.newAdaUnsignedTx([], changeAddr, utxos, absSlotNumber, protocolParams, certificates, finalWithdrawals, undefined, neededKeys, txOptions, false, undefined);
const unsignedTx = yield this.newAdaUnsignedTx([], defaultToken, changeAddr, utxos, absSlotNumber, protocolParams, certificates, finalWithdrawals, undefined, neededKeys, txOptions, false, undefined, undefined, undefined);
return unsignedTx;

@@ -255,16 +254,7 @@ });

const stakeDelegationCerts = yield (0, transactions_1.createDelegationCertificate)(this._wasmV4, stakingKey, registrationStatus, poolId);
const unsignedTx = (yield this.newAdaUnsignedTx([], changeAddr, utxos, absSlotNumber, protocolParams, stakeDelegationCerts, [], undefined, {
const unsignedTx = (yield this.newAdaUnsignedTx([], defaultToken, changeAddr, utxos, absSlotNumber, protocolParams, stakeDelegationCerts, [], undefined, {
neededHashes: new Set(),
wits: new Set()
}, txOptions, false, undefined));
const allUtxosForKey = yield (0, addresses_1.filterAddressesByStakingKey)(this._wasmV4, yield this._wasmV4.StakeCredential.fromKeyhash(yield stakingKey.hash()), utxos, false);
const utxoSum = allUtxosForKey.reduce((sum, utxo) => sum.joinAddMutable((0, assets_1.multiTokenFromRemote)(utxo, protocolParams.networkId)), new multi_token_1.MultiToken([], defaultToken));
const differenceAfterTx = yield (0, transactions_1.getDifferenceAfterTx)(this._wasmV4, unsignedTx, utxos, stakingKey, defaultToken);
const totalAmountToDelegate = utxoSum
.joinAddCopy(differenceAfterTx) // subtract any part of the fee that comes from UTXO
.joinAddCopy(new multi_token_1.MultiToken(valueInAccount.values, valueInAccount.defaults)); // recall: rewards are compounding
return {
unsignedTx,
totalAmountToDelegate
};
}, txOptions, false, undefined, stakingKey, valueInAccount));
return unsignedTx;
}

@@ -358,3 +348,3 @@ catch (error) {

}
createUnsignedTxForUtxos(absSlotNumber, receivers, defaultToken, tokens, utxos, config, txOptions) {
createUnsignedTxForUtxos(absSlotNumber, receivers, defaultToken, tokens, utxos, config, txOptions, stakingKey, valueInAccount) {
return __awaiter(this, void 0, void 0, function* () {

@@ -377,6 +367,6 @@ try {

const receiver = receivers[0];
return yield this.sendAllUnsignedTx(receiver, utxos, absSlotNumber, protocolParams, txMetadata, {
return yield this.sendAllUnsignedTx(receiver, defaultToken, utxos, absSlotNumber, protocolParams, txMetadata, {
neededHashes: new Set([]),
wits: new Set([])
}, txOptions);
}, txOptions, stakingKey, valueInAccount);
}

@@ -415,3 +405,3 @@ else {

]
: [], {
: [], defaultToken, {
address: changeAddr.address,

@@ -422,3 +412,3 @@ addressing: changeAddr.addressing

wits: new Set([])
}, txOptions, false, undefined);
}, txOptions, false, undefined, undefined, undefined);
YoroiLib.logger.debug(`createUnsignedTxForUtxos success`, unsignedTx);

@@ -436,3 +426,3 @@ return unsignedTx;

}
sendAllUnsignedTx(receiver, allUtxos, absSlotNumber, protocolParams, auxData, neededStakingKeyHashes, txOptions) {
sendAllUnsignedTx(receiver, defaultToken, allUtxos, absSlotNumber, protocolParams, auxData, neededStakingKeyHashes, txOptions, stakingKey, valueInAccount) {
var _a;

@@ -464,7 +454,7 @@ return __awaiter(this, void 0, void 0, function* () {

*/
return yield (0, tx_1.genWasmUnsignedTx)(this.Wasm, unsignedTxResponse.txBuilder, addressedUtxos, unsignedTxResponse.change, {
return yield (0, tx_1.genWasmUnsignedTx)(this.Wasm, defaultToken, unsignedTxResponse.txBuilder, addressedUtxos, allUtxos, unsignedTxResponse.change, {
networkId: protocolParams.networkId,
identifier: models_1.PRIMARY_ASSET_CONSTANTS.Cardano,
isDefault: true
}, protocolParams.networkId, neededStakingKeyHashes, (_a = txOptions.metadata) !== null && _a !== void 0 ? _a : [], auxData, undefined);
}, protocolParams.networkId, neededStakingKeyHashes, (_a = txOptions.metadata) !== null && _a !== void 0 ? _a : [], auxData, undefined, stakingKey, valueInAccount);
});

@@ -537,3 +527,3 @@ }

}
newAdaUnsignedTx(outputs, changeAdaAddr, allUtxos, absSlotNumber, protocolParams, certificates, withdrawals, auxData, neededStakingKeyHashes, txOptions, allowNoOutputs, catalystRegistrationData) {
newAdaUnsignedTx(outputs, defaultToken, changeAdaAddr, allUtxos, absSlotNumber, protocolParams, certificates, withdrawals, auxData, neededStakingKeyHashes, txOptions, allowNoOutputs, catalystRegistrationData, stakingKey, valueInAccount) {
var _a;

@@ -560,7 +550,7 @@ return __awaiter(this, void 0, void 0, function* () {

});
return yield (0, tx_1.genWasmUnsignedTx)(this.Wasm, unsignedTxResponse.txBuilder, addressedUtxos, unsignedTxResponse.change, {
return yield (0, tx_1.genWasmUnsignedTx)(this.Wasm, defaultToken, unsignedTxResponse.txBuilder, addressedUtxos, allUtxos, unsignedTxResponse.change, {
networkId: protocolParams.networkId,
identifier: models_1.PRIMARY_ASSET_CONSTANTS.Cardano,
isDefault: true
}, protocolParams.networkId, neededStakingKeyHashes, (_a = txOptions.metadata) !== null && _a !== void 0 ? _a : [], auxData, catalystRegistrationData);
}, protocolParams.networkId, neededStakingKeyHashes, (_a = txOptions.metadata) !== null && _a !== void 0 ? _a : [], auxData, catalystRegistrationData, stakingKey, valueInAccount);
});

@@ -567,0 +557,0 @@ }

import { BigNumber } from 'bignumber.js';
import { MultiToken } from './multi-token';
import { UnsignedTx } from './tx';
interface Bip44DerivationLevel {

@@ -20,6 +19,2 @@ level: number;

};
export declare type CreateDelegationTxResponse = {
unsignedTx: UnsignedTx;
totalAmountToDelegate: MultiTokenValue;
};
export declare type AccountStatePart = {

@@ -26,0 +21,0 @@ remainingAmount: string;

@@ -26,2 +26,3 @@ import * as WasmContract from './wasm-contract';

private _totalOutput;
private _totalAmountToDelegate;
private _fee;

@@ -40,2 +41,3 @@ private _change;

get totalInput(): MultiTokenValue;
get totalAmountToDelegate(): MultiTokenValue | undefined;
get outputs(): ReadonlyArray<{

@@ -77,4 +79,4 @@ address: string;

wits: Set<string>;
}, encodedTx: string, hash: WasmContract.TransactionHash, auxiliaryData: WasmContract.AuxiliaryData | undefined, catalystRegistrationData: CatalystRegistrationData | undefined);
static new(wasm: WasmContract.WasmModuleProxy, txBuilder: WasmContract.TransactionBuilder, senderUtxos: CardanoAddressedUtxo[], inputs: ReadonlyArray<{
}, encodedTx: string, hash: WasmContract.TransactionHash, auxiliaryData: WasmContract.AuxiliaryData | undefined, catalystRegistrationData: CatalystRegistrationData | undefined, totalAmountToDelegate: MultiTokenValue | undefined);
static new(wasm: WasmContract.WasmModuleProxy, networkId: number, defaultToken: Token, txBuilder: WasmContract.TransactionBuilder, senderUtxos: CardanoAddressedUtxo[], allUtxos: CardanoAddressedUtxo[], inputs: ReadonlyArray<{
address: string;

@@ -88,3 +90,3 @@ value: MultiTokenValue;

wits: Set<string>;
}, metadata: ReadonlyArray<TxMetadata>, auxiliaryData: WasmContract.AuxiliaryData | undefined, catalystRegistrationData: CatalystRegistrationData | undefined): Promise<WasmUnsignedTx>;
}, metadata: ReadonlyArray<TxMetadata>, auxiliaryData: WasmContract.AuxiliaryData | undefined, catalystRegistrationData: CatalystRegistrationData | undefined, stakingKey: WasmContract.PublicKey | undefined, valueInAccount: MultiTokenValue | undefined): Promise<WasmUnsignedTx>;
sign(keyLevel: number, privateKey: string, stakingKeyWits: Set<string>, extraMetadata: TxMetadata[]): Promise<SignedTx>;

@@ -107,2 +109,3 @@ private addWitnesses;

readonly totalInput: MultiTokenValue;
readonly totalAmountToDelegate?: MultiTokenValue;
readonly outputs: ReadonlyArray<{

@@ -132,5 +135,5 @@ address: string;

}
export declare function genWasmUnsignedTx(wasm: WasmContract.WasmModuleProxy, txBuilder: WasmContract.TransactionBuilder, senderUtxos: CardanoAddressedUtxo[], change: ReadonlyArray<Change>, defaults: Token, networkId: number, neededStakingKeyHashes: {
export declare function genWasmUnsignedTx(wasm: WasmContract.WasmModuleProxy, defaultToken: Token, txBuilder: WasmContract.TransactionBuilder, senderUtxos: CardanoAddressedUtxo[], allUtxos: CardanoAddressedUtxo[], change: ReadonlyArray<Change>, defaults: Token, networkId: number, neededStakingKeyHashes: {
neededHashes: Set<string>;
wits: Set<string>;
}, metadata: ReadonlyArray<TxMetadata>, auxiliaryData: WasmContract.AuxiliaryData | undefined, catalystRegistrationData: CatalystRegistrationData | undefined): Promise<WasmUnsignedTx>;
}, metadata: ReadonlyArray<TxMetadata>, auxiliaryData: WasmContract.AuxiliaryData | undefined, catalystRegistrationData: CatalystRegistrationData | undefined, stakingKey: WasmContract.PublicKey | undefined, valueInAccount: MultiTokenValue | undefined): Promise<WasmUnsignedTx>;

@@ -20,2 +20,3 @@ "use strict";

const multi_token_1 = require("./multi-token");
const transactions_1 = require("./utils/transactions");
class WasmUnsignedTx {

@@ -27,3 +28,3 @@ /**

*/
constructor(wasm, txBody, txBuilder, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, metadata, certificates, withdrawals, deregistrations, delegations, registrations, ttl, neededStakingKeyHashes, encodedTx, hash, auxiliaryData, catalystRegistrationData) {
constructor(wasm, txBody, txBuilder, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, metadata, certificates, withdrawals, deregistrations, delegations, registrations, ttl, neededStakingKeyHashes, encodedTx, hash, auxiliaryData, catalystRegistrationData, totalAmountToDelegate) {
this._wasm = wasm;

@@ -35,2 +36,3 @@ this._txBody = txBody;

this._totalInput = totalInput;
this._totalAmountToDelegate = totalAmountToDelegate;
this._outputs = outputs;

@@ -71,2 +73,5 @@ this._totalOutput = totalOutput;

}
get totalAmountToDelegate() {
return this._totalAmountToDelegate;
}
get outputs() {

@@ -120,3 +125,3 @@ return this._outputs;

}
static new(wasm, txBuilder, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, neededStakingKeyHashes, metadata, auxiliaryData, catalystRegistrationData) {
static new(wasm, networkId, defaultToken, txBuilder, senderUtxos, allUtxos, inputs, totalInput, outputs, totalOutput, fee, change, neededStakingKeyHashes, metadata, auxiliaryData, catalystRegistrationData, stakingKey, valueInAccount) {
return __awaiter(this, void 0, void 0, function* () {

@@ -164,3 +169,16 @@ const txBody = yield txBuilder.build();

}
return new WasmUnsignedTx(wasm, txBody, txBuilder, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, metadata, certs, withdrawals, deregistrations, delegations, registrations, ttl, neededStakingKeyHashes, Buffer.from(txBytes).toString('hex'), hash, auxiliaryData, catalystRegistrationData);
let totalAmountToDelegate;
if (stakingKey && valueInAccount) {
const allUtxosForKey = yield (0, addresses_1.filterAddressesByStakingKey)(wasm, yield wasm.StakeCredential.fromKeyhash(yield stakingKey.hash()), allUtxos, false);
const utxoSum = allUtxosForKey.reduce((sum, utxo) => sum.joinAddMutable((0, assets_1.multiTokenFromRemote)(utxo, networkId)), new multi_token_1.MultiToken([], defaultToken));
const differenceAfterTx = yield (0, transactions_1.getDifferenceAfterTx)(wasm, senderUtxos, txBody, allUtxos, stakingKey, defaultToken);
const totalAmountToDelegateMt = utxoSum
.joinAddCopy(differenceAfterTx) // subtract any part of the fee that comes from UTXO
.joinAddCopy(new multi_token_1.MultiToken(valueInAccount.values, valueInAccount.defaults)); // recall: rewards are compounding
totalAmountToDelegate = {
defaults: totalAmountToDelegateMt.defaults,
values: totalAmountToDelegateMt.values
};
}
return new WasmUnsignedTx(wasm, txBody, txBuilder, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, metadata, certs, withdrawals, deregistrations, delegations, registrations, ttl, neededStakingKeyHashes, Buffer.from(txBytes).toString('hex'), hash, auxiliaryData, catalystRegistrationData, totalAmountToDelegate);
});

@@ -267,5 +285,5 @@ }

exports.WasmUnsignedTx = WasmUnsignedTx;
function genWasmUnsignedTx(wasm, txBuilder, senderUtxos, change, defaults, networkId, neededStakingKeyHashes, metadata, auxiliaryData, catalystRegistrationData) {
function genWasmUnsignedTx(wasm, defaultToken, txBuilder, senderUtxos, allUtxos, change, defaults, networkId, neededStakingKeyHashes, metadata, auxiliaryData, catalystRegistrationData, stakingKey, valueInAccount) {
return __awaiter(this, void 0, void 0, function* () {
return yield WasmUnsignedTx.new(wasm, txBuilder, senderUtxos, yield genWasmUnsignedTxInputs(txBuilder, senderUtxos, networkId), yield genWasmUnsignedTxTotalInput(txBuilder, change, defaults), yield genWasmUnsignedTxOutputs(txBuilder, networkId), yield genWasmUnsignedTxTotalOutput(txBuilder, defaults), yield genWasmUnsignedTxFee(txBuilder, defaults, networkId), change, neededStakingKeyHashes, metadata, auxiliaryData, catalystRegistrationData);
return yield WasmUnsignedTx.new(wasm, networkId, defaultToken, txBuilder, senderUtxos, allUtxos, yield genWasmUnsignedTxInputs(txBuilder, senderUtxos, networkId), yield genWasmUnsignedTxTotalInput(txBuilder, change, defaults), yield genWasmUnsignedTxOutputs(txBuilder, networkId), yield genWasmUnsignedTxTotalOutput(txBuilder, defaults), yield genWasmUnsignedTxFee(txBuilder, defaults, networkId), change, neededStakingKeyHashes, metadata, auxiliaryData, catalystRegistrationData, stakingKey, valueInAccount);
});

@@ -272,0 +290,0 @@ }

import * as WasmContract from '../wasm-contract';
import { AddressingAddress, RemoteUnspentOutput, Token } from '../models';
import { AddressingAddress, CardanoAddressedUtxo, RemoteUnspentOutput, Token } from '../models';
import { AddInputResult } from './index';
import { Certificate, PublicKey } from '../wasm-contract';
import { MultiToken } from '../multi-token';
import { WasmUnsignedTx } from '../tx';
export declare function minRequiredForChange(wasm: WasmContract.WasmModuleProxy, txBuilder: WasmContract.TransactionBuilder, changeAdaAddr: AddressingAddress, value: WasmContract.Value, protocolParams: {

@@ -20,2 +19,2 @@ linearFee: WasmContract.LinearFee;

export declare function createDelegationCertificate(wasm: WasmContract.WasmModuleProxy, stakingKey: PublicKey, isRegistered: boolean, poolId: string | null): Promise<Array<Certificate>>;
export declare function getDifferenceAfterTx(wasm: WasmContract.WasmModuleProxy, unsignedTx: WasmUnsignedTx, allUtxos: RemoteUnspentOutput[], stakingKey: PublicKey, defaultToken: Token): Promise<MultiToken>;
export declare function getDifferenceAfterTx(wasm: WasmContract.WasmModuleProxy, senderUtxos: CardanoAddressedUtxo[], txBody: WasmContract.TransactionBody, allUtxos: RemoteUnspentOutput[], stakingKey: PublicKey, defaultToken: Token): Promise<MultiToken>;

@@ -176,3 +176,3 @@ "use strict";

exports.createDelegationCertificate = createDelegationCertificate;
function getDifferenceAfterTx(wasm, unsignedTx, allUtxos, stakingKey, defaultToken) {
function getDifferenceAfterTx(wasm, senderUtxos, txBody, allUtxos, stakingKey, defaultToken) {
return __awaiter(this, void 0, void 0, function* () {

@@ -185,3 +185,3 @@ const stakeCredential = yield wasm.StakeCredential.fromKeyhash(yield stakingKey.hash());

// so this for loop is faster than building a map
for (const senderUtxo of unsignedTx.senderUtxos) {
for (const senderUtxo of senderUtxos) {
const match = allUtxos.find((utxo) => utxo.txHash === senderUtxo.txHash &&

@@ -200,3 +200,2 @@ utxo.txIndex === senderUtxo.txIndex);

{
const txBody = unsignedTx.txBody;
const outputs = yield txBody.outputs();

@@ -203,0 +202,0 @@ for (let i = 0; i < (yield outputs.len()); i++) {

@@ -74,19 +74,22 @@ "use strict";

const diffFromBestBlock = localDiff.find((d) => d.lastBestBlockHash === tipStatus.reference.lastFoundBestBlock);
const diffFromBestBlockNotFoundError = 'This should never happen, ' +
'as we send the lastBestBlockHash from all diffs ' +
'to the API, and it should always respond with at least one of them, ' +
'or throw an error which should be handled somewhere else.';
if (!diffFromBestBlock)
throw new Error(diffFromBestBlockNotFoundError);
const indexOfDiffFromBestBlock = localDiff.indexOf(diffFromBestBlock);
if (indexOfDiffFromBestBlock === -1)
throw new Error(diffFromBestBlockNotFoundError);
for (let i = indexOfDiffFromBestBlock; i < localDiff.length - 1; i++) {
let indexOfDiffFromBestBlock;
if (diffFromBestBlock) {
indexOfDiffFromBestBlock = localDiff.indexOf(diffFromBestBlock) + 1;
}
else {
// `tipStatus.reference.lastFoundBestBlock` is not in `localDiff`
// the only possibility is that all txs in `localDiff` are reverted
// and `tipStatus.reference.lastFoundBestBlock` is current safe block hash
indexOfDiffFromBestBlock = 0;
}
for (let i = indexOfDiffFromBestBlock; i < localDiff.length; i++) {
const diffToRemove = localDiff[i];
yield this._utxoStorage.removeDiffWithBestBlock(diffToRemove.lastBestBlockHash);
}
const diffWhichIsNowSafe = localDiff.find((d) => d.lastBestBlockHash === tipStatus.reference.lastFoundSafeBlock);
if (diffWhichIsNowSafe) {
yield this.mergeDiffsIntoSafeUtxoSet(safeUtxos, localDiff, diffWhichIsNowSafe, tipStatus.reference.lastFoundSafeBlock);
}
if (diffFromBestBlock) {
const diffWhichIsNowSafe = localDiff.find((d) => d.lastBestBlockHash === tipStatus.reference.lastFoundSafeBlock);
if (diffWhichIsNowSafe) {
yield this.mergeDiffsIntoSafeUtxoSet(safeUtxos, localDiff, diffWhichIsNowSafe, tipStatus.reference.lastFoundSafeBlock);
}
} // else no need to merge
}

@@ -93,0 +96,0 @@ yield this._utxoStorage.appendUtxoDiffToBestBlock(diffToBestBlock);

{
"name": "@emurgo/yoroi-lib-core",
"version": "0.5.1-alpha.32",
"version": "0.6.0-alpha.33",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc