@emurgo/yoroi-lib
Advanced tools
Comparing version 0.14.0 to 0.14.1
import { AccountApi, AccountApiConfig, AccountChainProtocols, AccountStorage, AddressRecord } from './models'; | ||
type AddressChainMetadata = { | ||
declare type AddressChainMetadata = { | ||
highestAddressIndexUsed: number; | ||
@@ -4,0 +4,0 @@ addresses: Map<number, number>; |
@@ -16,8 +16,2 @@ "use strict"; | ||
class AccountService { | ||
static metadataDefault() { | ||
return { | ||
highestAddressIndexUsed: -1, | ||
addresses: new Map() | ||
}; | ||
} | ||
constructor(api, storage, chainProtocols) { | ||
@@ -35,2 +29,8 @@ this._api = api; | ||
} | ||
static metadataDefault() { | ||
return { | ||
highestAddressIndexUsed: -1, | ||
addresses: new Map() | ||
}; | ||
} | ||
static fromConfig(apiConfig, storage, protocol) { | ||
@@ -37,0 +37,0 @@ const api = new emurgo_api_1.EmurgoAccountApi(apiConfig); |
export declare enum EmurgoApiResult { | ||
SUCCESS = "SUCCESS" | ||
} | ||
export type AccountApiResponse<T> = { | ||
export declare type AccountApiResponse<T> = { | ||
result: EmurgoApiResult; | ||
data?: T; | ||
}; | ||
export type AddressPath = { | ||
export declare type AddressPath = { | ||
account: number; | ||
@@ -13,3 +13,3 @@ chain: number; | ||
}; | ||
export type AddressRecord = Pick<AddressPath, 'account' | 'chain' | 'addressIndex'> & { | ||
export declare type AddressRecord = Pick<AddressPath, 'account' | 'chain' | 'addressIndex'> & { | ||
address: string; | ||
@@ -19,10 +19,10 @@ hash: string; | ||
}; | ||
export type AddressesUsedApiRequest = Readonly<{ | ||
export declare type AddressesUsedApiRequest = Readonly<{ | ||
addresses: string[]; | ||
}>; | ||
export type AddressesUsedApiResponse = Array<string>; | ||
export declare type AddressesUsedApiResponse = Array<string>; | ||
export interface AccountApi { | ||
getAddressesUsed(req: AddressesUsedApiRequest): Promise<AccountApiResponse<string[]>>; | ||
} | ||
export type AccountApiConfig = Readonly<{ | ||
export declare type AccountApiConfig = Readonly<{ | ||
url: string; | ||
@@ -41,2 +41,2 @@ maxAddressesPerRequest: number; | ||
} | ||
export type AccountChainProtocols = Map<number, AccountChainProtocolRecord>; | ||
export declare type AccountChainProtocols = Map<number, AccountChainProtocolRecord>; |
@@ -5,5 +5,2 @@ "use strict"; | ||
class BaseError extends Error { | ||
get id() { | ||
return this._id; | ||
} | ||
constructor(id, message) { | ||
@@ -13,2 +10,5 @@ super(message); | ||
} | ||
get id() { | ||
return this._id; | ||
} | ||
} | ||
@@ -15,0 +15,0 @@ exports.BaseError = BaseError; |
@@ -34,3 +34,3 @@ import { BigNumber } from 'bignumber.js'; | ||
datum?: Datum; | ||
}>, changeAddr: AddressingAddress, config: CardanoHaskellConfig, defaultToken: Token, txOptions: TxOptions): Promise<UnsignedTx>; | ||
}>, changeAddr: AddressingAddress, config: CardanoHaskellConfig, defaultToken: Token, txOptions: TxOptions, certificates?: WasmContract.Certificate[]): Promise<UnsignedTx>; | ||
createUnsignedWithdrawalTx(accountState: { | ||
@@ -37,0 +37,0 @@ [key: string]: null | AccountStatePart; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
@@ -75,2 +71,5 @@ if (k2 === undefined) k2 = k; | ||
class YoroiLib { | ||
constructor(wasmV4) { | ||
this._wasmV4 = wasmV4; | ||
} | ||
// Not much tought was given to this logging solution, so it's likely to change | ||
@@ -95,5 +94,2 @@ static set logger(val) { | ||
} | ||
constructor(wasmV4) { | ||
this._wasmV4 = wasmV4; | ||
} | ||
calculateTxId(encodedTx, encoding) { | ||
@@ -118,5 +114,5 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
createUnsignedTx(absSlotNumber, utxos, recipients, changeAddr, config, defaultToken, txOptions) { | ||
createUnsignedTx(absSlotNumber, utxos, recipients, changeAddr, config, defaultToken, txOptions, certificates) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield this.createUnsignedTxForUtxos(absSlotNumber, defaultToken, recipients, changeAddr, utxos, config, txOptions, undefined, undefined, []); | ||
return yield this.createUnsignedTxForUtxos(absSlotNumber, defaultToken, recipients, changeAddr, utxos, config, txOptions, undefined, undefined, [], certificates); | ||
}); | ||
@@ -516,3 +512,3 @@ } | ||
} | ||
createUnsignedTxForUtxos(absSlotNumber, defaultToken, recipients, changeAddress, utxos, config, txOptions, stakingKey, valueInAccount, withdrawalRequests) { | ||
createUnsignedTxForUtxos(absSlotNumber, defaultToken, recipients, changeAddress, utxos, config, txOptions, stakingKey, valueInAccount, withdrawalRequests, certificates = []) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -548,3 +544,3 @@ try { | ||
addressing: changeAddr.addressing | ||
}, utxos, absSlotNumber, protocolParams, [], [], txMetadata, { | ||
}, utxos, absSlotNumber, protocolParams, certificates, [], txMetadata, { | ||
neededHashes: new Set([]), | ||
@@ -551,0 +547,0 @@ wits: new Set([]) |
@@ -6,7 +6,7 @@ import { BigNumber } from 'bignumber.js'; | ||
} | ||
export type AmountWithReceiver = { | ||
export declare type AmountWithReceiver = { | ||
receiver: string; | ||
amount: string; | ||
}; | ||
export type StakingKeyBalances = { | ||
export declare type StakingKeyBalances = { | ||
[key: string]: string; | ||
@@ -32,3 +32,3 @@ }; | ||
}; | ||
export type AccountStatePart = { | ||
export declare type AccountStatePart = { | ||
remainingAmount: string; | ||
@@ -38,3 +38,3 @@ rewards: string; | ||
}; | ||
export type WithdrawalRequest = { | ||
export declare type WithdrawalRequest = { | ||
addressing: Addressing; | ||
@@ -44,6 +44,6 @@ rewardAddress: string; | ||
}; | ||
export type Transaction = { | ||
export declare type Transaction = { | ||
hash: string; | ||
}; | ||
export type Utxo = { | ||
export declare type Utxo = { | ||
transaction: Transaction; | ||
@@ -56,18 +56,18 @@ index: number; | ||
}; | ||
export type CardanoAddressedUtxo = RemoteUnspentOutput & { | ||
export declare type CardanoAddressedUtxo = RemoteUnspentOutput & { | ||
addressing: Addressing; | ||
}; | ||
export type Change = AddressingAddress & { | ||
export declare type Change = AddressingAddress & { | ||
values: MultiToken; | ||
}; | ||
export type AddressingAddress = { | ||
export declare type AddressingAddress = { | ||
address: Address; | ||
addressing?: Addressing; | ||
}; | ||
export type Address = string; | ||
export type Addressing = { | ||
export declare type Address = string; | ||
export declare type Addressing = { | ||
path: number[]; | ||
startLevel: number; | ||
}; | ||
export type TxOutput = { | ||
export declare type TxOutput = { | ||
address: string; | ||
@@ -77,3 +77,3 @@ amount: MultiToken; | ||
}; | ||
export type Datum = { | ||
export declare type Datum = { | ||
hash: string; | ||
@@ -83,3 +83,3 @@ } | { | ||
}; | ||
export type RemoteUnspentOutput = { | ||
export declare type RemoteUnspentOutput = { | ||
amount: string; | ||
@@ -92,7 +92,7 @@ receiver: string; | ||
}; | ||
export type UtxoAsset = { | ||
export declare type UtxoAsset = { | ||
assetId: string; | ||
amount: string; | ||
}; | ||
export type SendToken = { | ||
export declare type SendToken = { | ||
amount: BigNumber; | ||
@@ -102,3 +102,3 @@ token: Token; | ||
}; | ||
export type Token = { | ||
export declare type Token = { | ||
identifier: string; | ||
@@ -108,3 +108,3 @@ networkId: number; | ||
}; | ||
export type TokenEntry = { | ||
export declare type TokenEntry = { | ||
amount: BigNumber; | ||
@@ -114,14 +114,14 @@ identifier: string; | ||
}; | ||
export type MultiTokenValue = { | ||
export declare type MultiTokenValue = { | ||
values: Array<TokenEntry>; | ||
defaults: Token; | ||
}; | ||
export type TxOptions = { | ||
export declare type TxOptions = { | ||
metadata?: ReadonlyArray<TxMetadata>; | ||
}; | ||
export type TxMetadata = { | ||
export declare type TxMetadata = { | ||
label: string; | ||
data: any; | ||
}; | ||
export type CardanoHaskellConfig = { | ||
export declare type CardanoHaskellConfig = { | ||
keyDeposit: string; | ||
@@ -134,3 +134,3 @@ linearFee: LinearFee; | ||
}; | ||
export type LinearFee = { | ||
export declare type LinearFee = { | ||
coefficient: string; | ||
@@ -137,0 +137,0 @@ constant: string; |
@@ -5,3 +5,3 @@ import { SignTransactionRequest } from "@cardano-foundation/ledgerjs-hw-app-cardano"; | ||
import { Ed25519KeyHash } from "@emurgo/cross-csl-core"; | ||
type CreateLedgerPlutusPayloadParams = { | ||
declare type CreateLedgerPlutusPayloadParams = { | ||
wasm: WasmContract.WasmModuleProxy; | ||
@@ -8,0 +8,0 @@ cbor: string; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
@@ -10,0 +6,0 @@ if (k2 === undefined) k2 = k; |
@@ -100,3 +100,3 @@ import * as WasmContract from '@emurgo/cross-csl-core'; | ||
} | ||
export type CatalystRegistrationData = { | ||
export declare type CatalystRegistrationData = { | ||
votingPublicKeyHex: string; | ||
@@ -103,0 +103,0 @@ stakingPublicKeyHex: string; |
@@ -22,2 +22,34 @@ "use strict"; | ||
class WasmUnsignedTx { | ||
/** | ||
* Initializes the class with the specific wasm types, outputs and change. | ||
* Even though this class can be instantiated directly, you should probably be getting | ||
* an instance of it through its abstraction UnsignedTx by calling YoroiLib.createUnsignedTx | ||
*/ | ||
constructor(wasm, txBody, txBuilder, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, metadata, certificates, withdrawals, deregistrations, delegations, registrations, ttl, neededStakingKeyHashes, encodedTx, hash, auxiliaryData, catalystRegistrationData, totalAmountToDelegate, withdrawalRequests, scriptDataHash) { | ||
this._wasm = wasm; | ||
this._txBody = txBody; | ||
this._txBuilder = txBuilder; | ||
this._senderUtxos = senderUtxos; | ||
this._inputs = inputs; | ||
this._totalInput = totalInput; | ||
this._totalAmountToDelegate = totalAmountToDelegate; | ||
this._outputs = outputs; | ||
this._totalOutput = totalOutput; | ||
this._fee = fee; | ||
this._change = change; | ||
this._metadata = metadata; | ||
this._certificates = certificates; | ||
this._withdrawals = withdrawals; | ||
this._deregistrations = deregistrations; | ||
this._delegations = delegations; | ||
this._registrations = registrations; | ||
this._ttl = ttl; | ||
this._neededStakingKeyHashes = neededStakingKeyHashes; | ||
this._encodedTx = encodedTx; | ||
this._hash = hash; | ||
this._auxiliaryData = auxiliaryData; | ||
this._catalystRegistrationData = catalystRegistrationData; | ||
this._withdrawalRequests = withdrawalRequests; | ||
this._scriptDataHash = scriptDataHash; | ||
} | ||
get wasm() { | ||
@@ -98,34 +130,2 @@ return this._wasm; | ||
} | ||
/** | ||
* Initializes the class with the specific wasm types, outputs and change. | ||
* Even though this class can be instantiated directly, you should probably be getting | ||
* an instance of it through its abstraction UnsignedTx by calling YoroiLib.createUnsignedTx | ||
*/ | ||
constructor(wasm, txBody, txBuilder, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, metadata, certificates, withdrawals, deregistrations, delegations, registrations, ttl, neededStakingKeyHashes, encodedTx, hash, auxiliaryData, catalystRegistrationData, totalAmountToDelegate, withdrawalRequests, scriptDataHash) { | ||
this._wasm = wasm; | ||
this._txBody = txBody; | ||
this._txBuilder = txBuilder; | ||
this._senderUtxos = senderUtxos; | ||
this._inputs = inputs; | ||
this._totalInput = totalInput; | ||
this._totalAmountToDelegate = totalAmountToDelegate; | ||
this._outputs = outputs; | ||
this._totalOutput = totalOutput; | ||
this._fee = fee; | ||
this._change = change; | ||
this._metadata = metadata; | ||
this._certificates = certificates; | ||
this._withdrawals = withdrawals; | ||
this._deregistrations = deregistrations; | ||
this._delegations = delegations; | ||
this._registrations = registrations; | ||
this._ttl = ttl; | ||
this._neededStakingKeyHashes = neededStakingKeyHashes; | ||
this._encodedTx = encodedTx; | ||
this._hash = hash; | ||
this._auxiliaryData = auxiliaryData; | ||
this._catalystRegistrationData = catalystRegistrationData; | ||
this._withdrawalRequests = withdrawalRequests; | ||
this._scriptDataHash = scriptDataHash; | ||
} | ||
static new(wasm, networkId, defaultToken, txBuilder, senderUtxos, allUtxos, inputs, totalInput, outputs, totalOutput, fee, change, neededStakingKeyHashes, metadata, auxiliaryData, catalystRegistrationData, stakingKey, valueInAccount, withdrawalRequests) { | ||
@@ -280,3 +280,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
? auxData | ||
: yield this.wasm.AuxiliaryData.new()); | ||
: undefined); | ||
const signedTxBody = yield signedTx.body(); | ||
@@ -283,0 +283,0 @@ const signedTxHash = yield this._wasm.hashTransaction(signedTxBody); |
import { Axios } from 'axios'; | ||
import { UtxoApiContract } from './api'; | ||
import { Asset, DiffType, TipStatusReference, Utxo, UtxoApiResponse, UtxoAtPointRequest, UtxoDiff, UtxoDiffSincePointRequest } from './models'; | ||
export type UtxoAtPointItemResponse = { | ||
export declare type UtxoAtPointItemResponse = { | ||
utxo_id: string; | ||
@@ -13,3 +13,3 @@ tx_hash: string; | ||
}; | ||
export type UtxoDiffSincePointItemResponse = { | ||
export declare type UtxoDiffSincePointItemResponse = { | ||
type: DiffType; | ||
@@ -24,3 +24,3 @@ id: string; | ||
}; | ||
export type UtxoDiffSincePointResponse = { | ||
export declare type UtxoDiffSincePointResponse = { | ||
lastDiffPointSelected: any; | ||
@@ -31,3 +31,3 @@ diffItems: UtxoDiffSincePointItemResponse[]; | ||
}; | ||
export type TipStatusResponse = { | ||
export declare type TipStatusResponse = { | ||
reference: { | ||
@@ -38,3 +38,3 @@ lastFoundSafeBlock: string; | ||
}; | ||
export type GetTipStatusResponse = { | ||
export declare type GetTipStatusResponse = { | ||
safeBlock: { | ||
@@ -41,0 +41,0 @@ hash: string; |
@@ -115,10 +115,10 @@ "use strict"; | ||
const values = (yield Promise.all(promises)).map((x) => x.value); | ||
const uniqueMatchedBestBlocks = new Set(values.map(e => e.reference.lastFoundBestBlock)); | ||
const uniqueMatchedBestBlocks = new Set(values.map((e) => e.reference.lastFoundBestBlock)); | ||
if (uniqueMatchedBestBlocks.size > 1) { | ||
return { result: models_1.UtxoApiResult.BESTBLOCK_ROLLBACK }; | ||
} | ||
const latestMatchedSafeBlockIndex = Math.max(...(values.map(e => { | ||
const latestMatchedSafeBlockIndex = Math.max(...values.map((e) => { | ||
const v = e.reference.lastFoundSafeBlock; | ||
return v == null ? -1 : req.afterBestBlocks.indexOf(v); | ||
}))); | ||
})); | ||
if (latestMatchedSafeBlockIndex < 0) { | ||
@@ -133,3 +133,3 @@ return { result: models_1.UtxoApiResult.SAFEBLOCK_ROLLBACK }; | ||
lastFoundBestBlock: values[0].reference.lastFoundBestBlock, | ||
lastFoundSafeBlock: req.afterBestBlocks[latestMatchedSafeBlockIndex], | ||
lastFoundSafeBlock: req.afterBestBlocks[latestMatchedSafeBlockIndex] | ||
} | ||
@@ -181,3 +181,3 @@ } | ||
lastFoundBestBlock: resp.data.reference.lastFoundBestBlock, | ||
lastFoundSafeBlock: resp.data.reference.lastFoundSafeBlock, | ||
lastFoundSafeBlock: resp.data.reference.lastFoundSafeBlock | ||
} | ||
@@ -251,3 +251,3 @@ } | ||
afterBestblocks: req.afterBestBlocks, | ||
diffLimit: this._pageSize, | ||
diffLimit: this._pageSize | ||
}); | ||
@@ -259,5 +259,7 @@ if (response.data.lastFoundBestblock == null) { | ||
lastFoundBestBlock: response.data.lastFoundBestblock, | ||
lastFoundSafeBlock: response.data.lastFoundSafeblock, | ||
lastFoundSafeBlock: response.data.lastFoundSafeblock | ||
}; | ||
let allDiffItems = [...response.data.diffItems]; | ||
let allDiffItems = [ | ||
...response.data.diffItems | ||
]; | ||
while (response.data.diffItems.length === this._pageSize) { | ||
@@ -268,3 +270,3 @@ response = yield this._axios.post(url, { | ||
afterPoint: response.data.lastDiffPointSelected, | ||
diffLimit: this._pageSize, | ||
diffLimit: this._pageSize | ||
}); | ||
@@ -301,3 +303,3 @@ allDiffItems = allDiffItems.concat(response.data.diffItems); | ||
}), | ||
reference: reference, | ||
reference: reference | ||
} | ||
@@ -320,4 +322,4 @@ }; | ||
referenceBlockHash: req.referenceBlockHash, | ||
page: page, | ||
pageSize: this._pageSize, | ||
page, | ||
pageSize: this._pageSize | ||
}); | ||
@@ -324,0 +326,0 @@ return resp.data; |
@@ -7,3 +7,3 @@ import BigNumber from 'bignumber.js'; | ||
} | ||
export type Block = { | ||
export declare type Block = { | ||
number: number; | ||
@@ -14,7 +14,7 @@ hash: string; | ||
}; | ||
export type UtxoAtPointRequest = { | ||
export declare type UtxoAtPointRequest = { | ||
addresses: string[]; | ||
referenceBlockHash: string; | ||
}; | ||
export type UtxoDiffSincePointRequest = { | ||
export declare type UtxoDiffSincePointRequest = { | ||
addresses: string[]; | ||
@@ -24,3 +24,3 @@ untilBlockHash: string; | ||
}; | ||
export type Asset = { | ||
export declare type Asset = { | ||
assetId: string; | ||
@@ -31,3 +31,3 @@ policyId: string; | ||
}; | ||
export type Utxo = { | ||
export declare type Utxo = { | ||
utxoId: string; | ||
@@ -45,3 +45,3 @@ txHash: string; | ||
} | ||
export type UtxoDiffItem = { | ||
export declare type UtxoDiffItem = { | ||
type: DiffType; | ||
@@ -51,6 +51,6 @@ id: string; | ||
}; | ||
export type UtxoDiffItemOutput = UtxoDiffItem & { | ||
export declare type UtxoDiffItemOutput = UtxoDiffItem & { | ||
utxo: Utxo; | ||
}; | ||
export type UtxoDiff = { | ||
export declare type UtxoDiff = { | ||
diffItems: Array<UtxoDiffItem | UtxoDiffItemOutput>; | ||
@@ -62,3 +62,3 @@ reference: { | ||
}; | ||
export type UtxoDiffToBestBlock = { | ||
export declare type UtxoDiffToBestBlock = { | ||
lastBestBlockHash: string; | ||
@@ -68,11 +68,11 @@ spentUtxoIds: string[]; | ||
}; | ||
export type UtxoAtSafePoint = { | ||
export declare type UtxoAtSafePoint = { | ||
lastSafeBlockHash: string; | ||
utxos: Utxo[]; | ||
}; | ||
export type UtxoApiResponse<T> = { | ||
export declare type UtxoApiResponse<T> = { | ||
result: UtxoApiResult; | ||
value?: T; | ||
}; | ||
export type TipStatusReference = { | ||
export declare type TipStatusReference = { | ||
reference: { | ||
@@ -79,0 +79,0 @@ lastFoundSafeBlock: string; |
{ | ||
"name": "@emurgo/yoroi-lib", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
286489
80
5142
1