@emurgo/yoroi-lib-core
Advanced tools
Comparing version 0.0.1-alpha.5 to 0.0.1-alpha.6
@@ -1,15 +0,8 @@ | ||
import { Axios } from 'axios' | ||
import { | ||
AccountApi, | ||
AccountApiConfig, | ||
AccountApiResponse, | ||
AddressesUsedApiRequest | ||
} from './models' | ||
import { Axios } from 'axios'; | ||
import { AccountApi, AccountApiConfig, AccountApiResponse, AddressesUsedApiRequest } from './models'; | ||
export declare class EmurgoAccountApi implements AccountApi { | ||
readonly _axios: Axios | ||
readonly _apiConfig: AccountApiConfig | ||
constructor(apiConfig: AccountApiConfig, axios?: Axios) | ||
getAddressesUsed( | ||
req: AddressesUsedApiRequest | ||
): Promise<AccountApiResponse<string[]>> | ||
readonly _axios: Axios; | ||
readonly _apiConfig: AccountApiConfig; | ||
constructor(apiConfig: AccountApiConfig, axios?: Axios); | ||
getAddressesUsed(req: AddressesUsedApiRequest): Promise<AccountApiResponse<string[]>>; | ||
} |
@@ -1,55 +0,36 @@ | ||
import { | ||
AccountApi, | ||
AccountApiConfig, | ||
AccountChainProtocols, | ||
AccountStorage, | ||
AddressRecord | ||
} from './models' | ||
import { AccountApi, AccountApiConfig, AccountChainProtocols, AccountStorage, AddressRecord } from './models'; | ||
declare type AddressChainMetadata = { | ||
highestAddressIndexUsed: number | ||
addresses: Map<number, number> | ||
} | ||
highestAddressIndexUsed: number; | ||
addresses: Map<number, number>; | ||
}; | ||
export declare class AccountService { | ||
readonly _api: AccountApi | ||
readonly _storage: AccountStorage | ||
readonly _chainProtocols: AccountChainProtocols | ||
_initialized: boolean | ||
readonly _storageData: AddressRecord[] | ||
readonly _indexByAddress: Map<string, number> | ||
readonly _indexByHash: Map<string, number> | ||
readonly _accounts: Map<number, Map<number, AddressChainMetadata>> | ||
_lastWrite: number | ||
_lastWriteSaved: number | ||
static metadataDefault(): AddressChainMetadata | ||
constructor( | ||
api: AccountApi, | ||
storage: AccountStorage, | ||
chainProtocols: AccountChainProtocols | ||
) | ||
static fromConfig( | ||
apiConfig: AccountApiConfig, | ||
storage: AccountStorage, | ||
protocol: AccountChainProtocols | ||
): AccountService | ||
_addToAccounts(account: number): Map<number, AddressChainMetadata> | undefined | ||
_saveMetadata(addressRecord: Readonly<AddressRecord>, index: number): void | ||
_saveIndexes(addressRecord: Readonly<AddressRecord>, index: number): void | ||
_saveRecord( | ||
addressRecord: Readonly<AddressRecord>, | ||
isHidrating?: boolean | ||
): void | ||
get accounts(): Map<number, Map<number, AddressChainMetadata>> | ||
_fillAccount(account: number): Promise<boolean> | ||
address(addressOrHash: string): AddressRecord | undefined | ||
addresses(account: number, chain: number): AddressRecord[] | ||
_updateUsedAddresses(account: number): Promise<boolean> | ||
_checkInitilization(): Promise<void> | ||
synchronize(account: number, isHidrating?: boolean): Promise<void> | ||
create( | ||
account: number | ||
): Promise<Map<number, AddressChainMetadata> | undefined> | ||
initialize(): Promise<void> | ||
save(): Promise<void> | ||
logMetadata(): void | ||
readonly _api: AccountApi; | ||
readonly _storage: AccountStorage; | ||
readonly _chainProtocols: AccountChainProtocols; | ||
_initialized: boolean; | ||
readonly _storageData: AddressRecord[]; | ||
readonly _indexByAddress: Map<string, number>; | ||
readonly _indexByHash: Map<string, number>; | ||
readonly _accounts: Map<number, Map<number, AddressChainMetadata>>; | ||
_lastWrite: number; | ||
_lastWriteSaved: number; | ||
static metadataDefault(): AddressChainMetadata; | ||
constructor(api: AccountApi, storage: AccountStorage, chainProtocols: AccountChainProtocols); | ||
static fromConfig(apiConfig: AccountApiConfig, storage: AccountStorage, protocol: AccountChainProtocols): AccountService; | ||
_addToAccounts(account: number): Map<number, AddressChainMetadata> | undefined; | ||
_saveMetadata(addressRecord: Readonly<AddressRecord>, index: number): void; | ||
_saveIndexes(addressRecord: Readonly<AddressRecord>, index: number): void; | ||
_saveRecord(addressRecord: Readonly<AddressRecord>, isHidrating?: boolean): void; | ||
get accounts(): Map<number, Map<number, AddressChainMetadata>>; | ||
_fillAccount(account: number): Promise<boolean>; | ||
address(addressOrHash: string): AddressRecord | undefined; | ||
addresses(account: number, chain: number): AddressRecord[]; | ||
_updateUsedAddresses(account: number): Promise<boolean>; | ||
_checkInitilization(): Promise<void>; | ||
synchronize(account: number, isHidrating?: boolean): Promise<void>; | ||
create(account: number): Promise<Map<number, AddressChainMetadata> | undefined>; | ||
initialize(): Promise<void>; | ||
save(): Promise<void>; | ||
logMetadata(): void; | ||
} | ||
export {} | ||
export {}; |
export declare enum EmurgoApiResult { | ||
SUCCESS = 'SUCCESS' | ||
SUCCESS = "SUCCESS" | ||
} | ||
export declare type AccountApiResponse<T> = { | ||
result: EmurgoApiResult | ||
data?: T | ||
} | ||
result: EmurgoApiResult; | ||
data?: T; | ||
}; | ||
export declare type AddressPath = { | ||
account: number | ||
chain: number | ||
addressIndex: number | ||
} | ||
export declare type AddressRecord = Pick< | ||
AddressPath, | ||
'account' | 'chain' | 'addressIndex' | ||
> & { | ||
address: string | ||
hash: string | ||
firstBlock: number | ||
} | ||
account: number; | ||
chain: number; | ||
addressIndex: number; | ||
}; | ||
export declare type AddressRecord = Pick<AddressPath, 'account' | 'chain' | 'addressIndex'> & { | ||
address: string; | ||
hash: string; | ||
firstBlock: number; | ||
}; | ||
export declare type AddressesUsedApiRequest = Readonly<{ | ||
addresses: string[] | ||
}> | ||
export declare type AddressesUsedApiResponse = Array<string> | ||
addresses: string[]; | ||
}>; | ||
export declare type AddressesUsedApiResponse = Array<string>; | ||
export interface AccountApi { | ||
getAddressesUsed( | ||
req: AddressesUsedApiRequest | ||
): Promise<AccountApiResponse<string[]>> | ||
getAddressesUsed(req: AddressesUsedApiRequest): Promise<AccountApiResponse<string[]>>; | ||
} | ||
export declare type AccountApiConfig = Readonly<{ | ||
url: string | ||
maxAddressesPerRequest: number | ||
}> | ||
url: string; | ||
maxAddressesPerRequest: number; | ||
}>; | ||
export interface AccountStorage { | ||
readAccounts(): Promise<AddressRecord[]> | ||
saveAccounts(addresses: AddressRecord[]): Promise<boolean> | ||
readAccounts(): Promise<AddressRecord[]>; | ||
saveAccounts(addresses: AddressRecord[]): Promise<boolean>; | ||
} | ||
export interface AccountChainProtocolRecord { | ||
readonly gapLimit: number | ||
readonly bufferSize: number | ||
readonly queryUsedBy: 'none' | 'hash' | 'address' | ||
derive: (path: AddressPath) => Promise<AddressRecord> | ||
readonly gapLimit: number; | ||
readonly bufferSize: number; | ||
readonly queryUsedBy: 'none' | 'hash' | 'address'; | ||
derive: (path: AddressPath) => Promise<AddressRecord>; | ||
} | ||
export declare type AccountChainProtocols = Map< | ||
number, | ||
AccountChainProtocolRecord | ||
> | ||
export declare type AccountChainProtocols = Map<number, AccountChainProtocolRecord>; |
export declare abstract class BaseError extends Error { | ||
private _id | ||
get id(): string | ||
constructor(id: string, message: string) | ||
private _id; | ||
get id(): string; | ||
constructor(id: string, message: string); | ||
} | ||
export declare class NotEnoughMoneyToSendError extends BaseError { | ||
constructor() | ||
constructor(); | ||
} | ||
export declare class AssetOverflowError extends BaseError { | ||
constructor() | ||
constructor(); | ||
} | ||
export declare class NoOutputsError extends BaseError { | ||
constructor() | ||
constructor(); | ||
} | ||
export declare class GenericError extends BaseError { | ||
constructor() | ||
constructor(); | ||
} |
@@ -1,18 +0,11 @@ | ||
import { BigNumber } from 'bignumber.js' | ||
import { | ||
AddressingAddress, | ||
AddressingUtxo, | ||
CardanoHaskellConfig, | ||
DefaultTokenEntry, | ||
SendToken, | ||
TxOptions | ||
} from './internals/models' | ||
import { UnsignedTx } from './internals/tx' | ||
import * as WasmContract from './internals/wasm-contract' | ||
export { AccountService } from './account' | ||
export { AccountChainProtocols, AccountStorage } from './account/models' | ||
export * from './internals/models' | ||
export * from './internals/tx' | ||
export * as WasmContract from './internals/wasm-contract' | ||
export { init as initUtxo, UtxoService, UtxoStorage } from './utxo' | ||
import { BigNumber } from 'bignumber.js'; | ||
import { AddressingAddress, AddressingUtxo, CardanoHaskellConfig, DefaultTokenEntry, SendToken, TxOptions } from './internals/models'; | ||
import { UnsignedTx } from './internals/tx'; | ||
import * as WasmContract from './internals/wasm-contract'; | ||
export { AccountService } from './account'; | ||
export { AccountChainProtocols, AccountStorage } from './account/models'; | ||
export * from './internals/models'; | ||
export * from './internals/tx'; | ||
export * as WasmContract from './internals/wasm-contract'; | ||
export { init as initUtxo, UtxoService, UtxoStorage } from './utxo'; | ||
/** | ||
@@ -22,30 +15,14 @@ * Currently, the @emurgo/react-native-haskell-shelley lib defines some variables as the type `u32`, which have a max value of `4294967295`. | ||
*/ | ||
export declare const RUST_u32_MAX = 4294967295 | ||
export declare const createYoroiLib: ( | ||
wasmV4: WasmContract.WasmModuleProxy | ||
) => IYoroiLib | ||
export declare const RUST_u32_MAX = 4294967295; | ||
export declare const createYoroiLib: (wasmV4: WasmContract.WasmModuleProxy) => IYoroiLib; | ||
export interface YoroiLibLogger { | ||
debug: (msg: string, ...args: any[]) => void | ||
error: (msg: string, ...args: any[]) => void | ||
debug: (msg: string, ...args: any[]) => void; | ||
error: (msg: string, ...args: any[]) => void; | ||
} | ||
export interface IYoroiLib { | ||
readonly Wasm: WasmContract.WasmModuleProxy | ||
calculateTxId(encodedTx: string, encoding: 'base64' | 'hex'): Promise<string> | ||
encryptWithPassword( | ||
password: string, | ||
salt: string, | ||
nonce: string, | ||
data: string | ||
): Promise<string> | ||
decryptWithPassword(password: string, data: string): Promise<string> | ||
createUnsignedTx( | ||
absSlotNumber: BigNumber, | ||
utxos: Array<AddressingUtxo>, | ||
receiver: string, | ||
changeAddr: AddressingAddress, | ||
tokens: Array<SendToken>, | ||
config: CardanoHaskellConfig, | ||
defaultToken: DefaultTokenEntry, | ||
txOptions: TxOptions | ||
): Promise<UnsignedTx> | ||
readonly Wasm: WasmContract.WasmModuleProxy; | ||
calculateTxId(encodedTx: string, encoding: 'base64' | 'hex'): Promise<string>; | ||
encryptWithPassword(password: string, salt: string, nonce: string, data: string): Promise<string>; | ||
decryptWithPassword(password: string, data: string): Promise<string>; | ||
createUnsignedTx(absSlotNumber: BigNumber, utxos: Array<AddressingUtxo>, receiver: string, changeAddr: AddressingAddress, tokens: Array<SendToken>, config: CardanoHaskellConfig, defaultToken: DefaultTokenEntry, txOptions: TxOptions): Promise<UnsignedTx>; | ||
} |
@@ -1,104 +0,104 @@ | ||
import { BigNumber } from 'bignumber.js' | ||
import { MultiToken } from './multi-token' | ||
import { BigNumber } from 'bignumber.js'; | ||
import { MultiToken } from './multi-token'; | ||
export declare const PRIMARY_ASSET_CONSTANTS: { | ||
Cardano: string | ||
Ergo: string | ||
Jormungandr: string | ||
} | ||
Cardano: string; | ||
Ergo: string; | ||
Jormungandr: string; | ||
}; | ||
export declare type Transaction = { | ||
hash: string | ||
} | ||
hash: string; | ||
}; | ||
export declare type UtxoTransactionOutput = { | ||
outputIndex: number | ||
} | ||
outputIndex: number; | ||
}; | ||
export declare type UtxoTxOutput = { | ||
transaction: Transaction | ||
utxoTransactionOutput: UtxoTransactionOutput | ||
tokens: Array<{ | ||
tokenList: TokenList | ||
token: Token | ||
}> | ||
} | ||
transaction: Transaction; | ||
utxoTransactionOutput: UtxoTransactionOutput; | ||
tokens: Array<{ | ||
tokenList: TokenList; | ||
token: Token; | ||
}>; | ||
}; | ||
export declare type AddressingUtxo = AddressingAddress & { | ||
output: UtxoTxOutput | ||
} | ||
export declare type CardanoAddressedUtxo = RemoteUnspentOutput & Addressing | ||
output: UtxoTxOutput; | ||
}; | ||
export declare type CardanoAddressedUtxo = RemoteUnspentOutput & Addressing; | ||
export declare type Value = { | ||
values: MultiToken | ||
} | ||
export declare type Change = AddressingAddress & Value | ||
export declare type AddressingAddress = Address & Addressing | ||
values: MultiToken; | ||
}; | ||
export declare type Change = AddressingAddress & Value; | ||
export declare type AddressingAddress = Address & Addressing; | ||
export declare type Address = { | ||
address: string | ||
} | ||
address: string; | ||
}; | ||
export declare type Addressing = { | ||
addressing: { | ||
path: number[] | ||
startLevel: number | ||
} | ||
} | ||
addressing: { | ||
path: number[]; | ||
startLevel: number; | ||
}; | ||
}; | ||
export declare type TxOutput = { | ||
address: string | ||
amount: MultiToken | ||
} | ||
address: string; | ||
amount: MultiToken; | ||
}; | ||
export declare type RemoteUnspentOutput = { | ||
amount: string | ||
receiver: string | ||
txHash: string | ||
txIndex: number | ||
utxoId: string | ||
assets: ReadonlyArray<UtxoAsset> | ||
} | ||
amount: string; | ||
receiver: string; | ||
txHash: string; | ||
txIndex: number; | ||
utxoId: string; | ||
assets: ReadonlyArray<UtxoAsset>; | ||
}; | ||
export declare type UtxoAsset = { | ||
assetId: string | ||
amount: string | ||
} | ||
assetId: string; | ||
amount: string; | ||
}; | ||
export declare type SendToken = { | ||
amount: BigNumber | ||
token: Token | ||
shouldSendAll: boolean | ||
} | ||
amount: BigNumber; | ||
token: Token; | ||
shouldSendAll: boolean; | ||
}; | ||
export declare type TokenList = { | ||
amount: string | ||
} | ||
amount: string; | ||
}; | ||
export declare type Token = { | ||
identifier: string | ||
networkId: number | ||
isDefault: boolean | ||
} | ||
identifier: string; | ||
networkId: number; | ||
isDefault: boolean; | ||
}; | ||
export declare type DefaultTokenEntry = { | ||
defaultNetworkId: number | ||
defaultIdentifier: string | ||
} | ||
defaultNetworkId: number; | ||
defaultIdentifier: string; | ||
}; | ||
export declare type TokenEntry = { | ||
amount: BigNumber | ||
identifier: string | ||
networkId: number | ||
} | ||
amount: BigNumber; | ||
identifier: string; | ||
networkId: number; | ||
}; | ||
export declare type MultiTokenConstruct = { | ||
values: Array<TokenEntry> | ||
defaults: DefaultTokenEntry | ||
} | ||
values: Array<TokenEntry>; | ||
defaults: DefaultTokenEntry; | ||
}; | ||
export declare type TxOptions = { | ||
metadata?: ReadonlyArray<TxMetadata> | ||
} | ||
metadata?: ReadonlyArray<TxMetadata>; | ||
}; | ||
export declare type TxMetadata = { | ||
label: string | ||
data: any | ||
} | ||
label: string; | ||
data: any; | ||
}; | ||
export declare type CardanoHaskellConfig = { | ||
keyDeposit: string | ||
linearFee: LinearFee | ||
minimumUtxoVal: string | ||
poolDeposit: string | ||
networkId: number | ||
} | ||
keyDeposit: string; | ||
linearFee: LinearFee; | ||
minimumUtxoVal: string; | ||
poolDeposit: string; | ||
networkId: number; | ||
}; | ||
export declare type LinearFee = { | ||
coefficient: string | ||
constant: string | ||
} | ||
coefficient: string; | ||
constant: string; | ||
}; | ||
export declare enum MetadataJsonSchema { | ||
NoConversions = 0, | ||
BasicConversions = 1, | ||
DetailedSchema = 2 | ||
NoConversions = 0, | ||
BasicConversions = 1, | ||
DetailedSchema = 2 | ||
} |
@@ -1,25 +0,25 @@ | ||
import { BigNumber } from 'bignumber.js' | ||
import { DefaultTokenEntry, TokenEntry } from './models' | ||
import { BigNumber } from 'bignumber.js'; | ||
import { DefaultTokenEntry, TokenEntry } from './models'; | ||
export declare class MultiToken { | ||
values: Array<TokenEntry> | ||
defaults: DefaultTokenEntry | ||
constructor(values: Array<TokenEntry>, defaults: DefaultTokenEntry) | ||
_checkNetworkId(networkId: number): void | ||
get(identifier: string): BigNumber | undefined | ||
add(entry: TokenEntry): MultiToken | ||
_removeIfZero(identifier: string): void | ||
subtract(entry: TokenEntry): MultiToken | ||
joinAddMutable(target: MultiToken): MultiToken | ||
joinSubtractMutable(target: MultiToken): MultiToken | ||
joinAddCopy(target: MultiToken): MultiToken | ||
joinSubtractCopy(target: MultiToken): MultiToken | ||
absCopy(): MultiToken | ||
negatedCopy(): MultiToken | ||
getDefault(): BigNumber | ||
getDefaultEntry(): TokenEntry | ||
nonDefaultEntries(): Array<TokenEntry> | ||
asMap(): Map<string, BigNumber> | ||
isEqualTo(tokens: MultiToken): boolean | ||
size(): number | ||
isEmpty(): boolean | ||
values: Array<TokenEntry>; | ||
defaults: DefaultTokenEntry; | ||
constructor(values: Array<TokenEntry>, defaults: DefaultTokenEntry); | ||
_checkNetworkId(networkId: number): void; | ||
get(identifier: string): BigNumber | undefined; | ||
add(entry: TokenEntry): MultiToken; | ||
_removeIfZero(identifier: string): void; | ||
subtract(entry: TokenEntry): MultiToken; | ||
joinAddMutable(target: MultiToken): MultiToken; | ||
joinSubtractMutable(target: MultiToken): MultiToken; | ||
joinAddCopy(target: MultiToken): MultiToken; | ||
joinSubtractCopy(target: MultiToken): MultiToken; | ||
absCopy(): MultiToken; | ||
negatedCopy(): MultiToken; | ||
getDefault(): BigNumber; | ||
getDefaultEntry(): TokenEntry; | ||
nonDefaultEntries(): Array<TokenEntry>; | ||
asMap(): Map<string, BigNumber>; | ||
isEqualTo(tokens: MultiToken): boolean; | ||
size(): number; | ||
isEmpty(): boolean; | ||
} |
@@ -1,106 +0,69 @@ | ||
import * as WasmContract from './wasm-contract' | ||
import { | ||
CardanoAddressedUtxo, | ||
Change, | ||
DefaultTokenEntry, | ||
MultiTokenConstruct, | ||
TxMetadata | ||
} from './models' | ||
import * as WasmContract from './wasm-contract'; | ||
import { CardanoAddressedUtxo, Change, DefaultTokenEntry, MultiTokenConstruct, TxMetadata } from './models'; | ||
export interface SignedTx { | ||
id: string | ||
encodedTx: Uint8Array | ||
id: string; | ||
encodedTx: Uint8Array; | ||
} | ||
export declare class WasmUnsignedTx implements UnsignedTx { | ||
private _wasm | ||
private _txBuilder | ||
private _certificates | ||
private _senderUtxos | ||
private _inputs | ||
private _totalInput | ||
private _outputs | ||
private _totalOutput | ||
private _fee | ||
private _change | ||
private _metadata | ||
private _encodedTx | ||
get senderUtxos(): ReadonlyArray<CardanoAddressedUtxo> | ||
get inputs(): ReadonlyArray<{ | ||
address: string | ||
value: MultiTokenConstruct | ||
}> | ||
get totalInput(): MultiTokenConstruct | ||
get outputs(): ReadonlyArray<{ | ||
address: string | ||
value: MultiTokenConstruct | ||
}> | ||
get totalOutput(): MultiTokenConstruct | ||
get fee(): MultiTokenConstruct | ||
get change(): ReadonlyArray<Change> | ||
get metadata(): ReadonlyArray<TxMetadata> | ||
get encodedTx(): string | ||
/** | ||
* 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 | ||
*/ | ||
private constructor() | ||
static new( | ||
wasm: WasmContract.WasmModuleProxy, | ||
txBuilder: WasmContract.TransactionBuilder, | ||
certificates: ReadonlyArray<WasmContract.Certificate>, | ||
senderUtxos: CardanoAddressedUtxo[], | ||
inputs: ReadonlyArray<{ | ||
address: string | ||
value: MultiTokenConstruct | ||
}>, | ||
totalInput: MultiTokenConstruct, | ||
outputs: ReadonlyArray<{ | ||
address: string | ||
value: MultiTokenConstruct | ||
}>, | ||
totalOutput: MultiTokenConstruct, | ||
fee: MultiTokenConstruct, | ||
change: ReadonlyArray<Change>, | ||
metadata: ReadonlyArray<TxMetadata> | ||
): Promise<WasmUnsignedTx> | ||
sign( | ||
keyLevel: number, | ||
privateKey: string, | ||
stakingKeyWits: Set<string>, | ||
extraMetadata: TxMetadata[] | ||
): Promise<SignedTx> | ||
private addWitnesses | ||
private _wasm; | ||
private _txBuilder; | ||
private _certificates; | ||
private _senderUtxos; | ||
private _inputs; | ||
private _totalInput; | ||
private _outputs; | ||
private _totalOutput; | ||
private _fee; | ||
private _change; | ||
private _metadata; | ||
private _encodedTx; | ||
get senderUtxos(): ReadonlyArray<CardanoAddressedUtxo>; | ||
get inputs(): ReadonlyArray<{ | ||
address: string; | ||
value: MultiTokenConstruct; | ||
}>; | ||
get totalInput(): MultiTokenConstruct; | ||
get outputs(): ReadonlyArray<{ | ||
address: string; | ||
value: MultiTokenConstruct; | ||
}>; | ||
get totalOutput(): MultiTokenConstruct; | ||
get fee(): MultiTokenConstruct; | ||
get change(): ReadonlyArray<Change>; | ||
get metadata(): ReadonlyArray<TxMetadata>; | ||
get encodedTx(): string; | ||
/** | ||
* 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 | ||
*/ | ||
private constructor(); | ||
static new(wasm: WasmContract.WasmModuleProxy, txBuilder: WasmContract.TransactionBuilder, certificates: ReadonlyArray<WasmContract.Certificate>, senderUtxos: CardanoAddressedUtxo[], inputs: ReadonlyArray<{ | ||
address: string; | ||
value: MultiTokenConstruct; | ||
}>, totalInput: MultiTokenConstruct, outputs: ReadonlyArray<{ | ||
address: string; | ||
value: MultiTokenConstruct; | ||
}>, totalOutput: MultiTokenConstruct, fee: MultiTokenConstruct, change: ReadonlyArray<Change>, metadata: ReadonlyArray<TxMetadata>): Promise<WasmUnsignedTx>; | ||
sign(keyLevel: number, privateKey: string, stakingKeyWits: Set<string>, extraMetadata: TxMetadata[]): Promise<SignedTx>; | ||
private addWitnesses; | ||
} | ||
export interface UnsignedTx { | ||
readonly senderUtxos: ReadonlyArray<CardanoAddressedUtxo> | ||
readonly inputs: ReadonlyArray<{ | ||
address: string | ||
value: MultiTokenConstruct | ||
}> | ||
readonly totalInput: MultiTokenConstruct | ||
readonly outputs: ReadonlyArray<{ | ||
address: string | ||
value: MultiTokenConstruct | ||
}> | ||
readonly totalOutput: MultiTokenConstruct | ||
readonly fee: MultiTokenConstruct | ||
readonly change: ReadonlyArray<Change> | ||
readonly metadata: ReadonlyArray<TxMetadata> | ||
readonly encodedTx: string | ||
sign( | ||
keyLevel: number, | ||
privateKey: string, | ||
stakingKeyWits: Set<string>, | ||
metadata: ReadonlyArray<TxMetadata> | ||
): Promise<SignedTx> | ||
readonly senderUtxos: ReadonlyArray<CardanoAddressedUtxo>; | ||
readonly inputs: ReadonlyArray<{ | ||
address: string; | ||
value: MultiTokenConstruct; | ||
}>; | ||
readonly totalInput: MultiTokenConstruct; | ||
readonly outputs: ReadonlyArray<{ | ||
address: string; | ||
value: MultiTokenConstruct; | ||
}>; | ||
readonly totalOutput: MultiTokenConstruct; | ||
readonly fee: MultiTokenConstruct; | ||
readonly change: ReadonlyArray<Change>; | ||
readonly metadata: ReadonlyArray<TxMetadata>; | ||
readonly encodedTx: string; | ||
sign(keyLevel: number, privateKey: string, stakingKeyWits: Set<string>, metadata: ReadonlyArray<TxMetadata>): Promise<SignedTx>; | ||
} | ||
export declare function genWasmUnsignedTx( | ||
wasm: WasmContract.WasmModuleProxy, | ||
txBuilder: WasmContract.TransactionBuilder, | ||
certificates: ReadonlyArray<WasmContract.Certificate>, | ||
senderUtxos: CardanoAddressedUtxo[], | ||
change: ReadonlyArray<Change>, | ||
defaults: DefaultTokenEntry, | ||
networkId: number, | ||
metadata: ReadonlyArray<TxMetadata> | ||
): Promise<WasmUnsignedTx> | ||
export declare function genWasmUnsignedTx(wasm: WasmContract.WasmModuleProxy, txBuilder: WasmContract.TransactionBuilder, certificates: ReadonlyArray<WasmContract.Certificate>, senderUtxos: CardanoAddressedUtxo[], change: ReadonlyArray<Change>, defaults: DefaultTokenEntry, networkId: number, metadata: ReadonlyArray<TxMetadata>): Promise<WasmUnsignedTx>; |
@@ -89,3 +89,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const txBytes = yield txBuilder.build().then(x => x.toBytes()); | ||
const txBytes = yield txBuilder.build().then((x) => x.toBytes()); | ||
return new WasmUnsignedTx(wasm, txBuilder, certificates, senderUtxos, inputs, totalInput, outputs, totalOutput, fee, change, metadata, Buffer.from(txBytes).toString('hex')); | ||
@@ -171,3 +171,3 @@ }); | ||
level: keyLevel, | ||
key: signingKey, | ||
key: signingKey | ||
}); | ||
@@ -208,8 +208,8 @@ }))); | ||
const input = yield inputs.get(i); | ||
const txIdBytes = yield input.transactionId().then(x => x.toBytes()); | ||
const txIdBytes = yield input.transactionId().then((x) => x.toBytes()); | ||
const key = { | ||
hash: Buffer.from(txIdBytes).toString('hex'), | ||
index: yield input.index(), | ||
index: yield input.index() | ||
}; | ||
const utxoEntry = senderUtxos.find(utxo => utxo.txHash === key.hash && utxo.txIndex === key.index); | ||
const utxoEntry = senderUtxos.find((utxo) => utxo.txHash === key.hash && utxo.txIndex === key.index); | ||
if (!utxoEntry) { | ||
@@ -224,3 +224,3 @@ throw new Error(`missing input for ${JSON.stringify(key)}`); | ||
}, | ||
address: utxoEntry.receiver, | ||
address: utxoEntry.receiver | ||
}); | ||
@@ -252,3 +252,3 @@ } | ||
const output = yield outputs.get(i); | ||
const outputAddressBytes = yield output.address().then(x => x.toBytes()); | ||
const outputAddressBytes = yield output.address().then((x) => x.toBytes()); | ||
const ma = yield (0, assets_1.multiTokenFromCardanoValue)(yield output.amount(), { | ||
@@ -263,3 +263,3 @@ defaultIdentifier: models_1.PRIMARY_ASSET_CONSTANTS.Cardano, | ||
}, | ||
address: Buffer.from(outputAddressBytes).toString('hex'), | ||
address: Buffer.from(outputAddressBytes).toString('hex') | ||
}); | ||
@@ -288,4 +288,4 @@ } | ||
identifier: models_1.PRIMARY_ASSET_CONSTANTS.Cardano, | ||
amount: fee.plus(yield txBuilder.getDeposit().then(x => x.toStr())), | ||
networkId: networkId, | ||
amount: fee.plus(yield txBuilder.getDeposit().then((x) => x.toStr())), | ||
networkId: networkId | ||
}); | ||
@@ -292,0 +292,0 @@ return { |
@@ -1,9 +0,3 @@ | ||
import * as WasmContract from '../wasm-contract' | ||
export declare function normalizeToAddress( | ||
wasm: WasmContract.WasmModuleProxy, | ||
addr: string | ||
): Promise<WasmContract.Address | undefined> | ||
export declare function toHexOrBase58( | ||
wasm: WasmContract.WasmModuleProxy, | ||
address: WasmContract.Address | ||
): Promise<string> | ||
import * as WasmContract from '../wasm-contract'; | ||
export declare function normalizeToAddress(wasm: WasmContract.WasmModuleProxy, addr: string): Promise<WasmContract.Address | undefined>; | ||
export declare function toHexOrBase58(wasm: WasmContract.WasmModuleProxy, address: WasmContract.Address): Promise<string>; |
@@ -26,3 +26,5 @@ "use strict"; | ||
} | ||
catch (_e) { /* ignore error */ } | ||
catch (_e) { | ||
/* ignore error */ | ||
} | ||
// 3) Try converting from base32 | ||
@@ -32,3 +34,5 @@ try { | ||
} | ||
catch (_e) { /* ignore error */ } | ||
catch (_e) { | ||
/* ignore error */ | ||
} | ||
return undefined; | ||
@@ -35,0 +39,0 @@ }); |
@@ -1,42 +0,19 @@ | ||
import { MultiToken } from '../multi-token' | ||
import { DefaultTokenEntry, RemoteUnspentOutput, SendToken } from '../models' | ||
import * as WasmContract from '../wasm-contract' | ||
export declare function cardanoValueFromMultiToken( | ||
wasm: WasmContract.WasmModuleProxy, | ||
tokens: MultiToken | ||
): Promise<WasmContract.Value> | ||
export declare function multiTokenFromCardanoValue( | ||
value: WasmContract.Value, | ||
defaults: DefaultTokenEntry | ||
): Promise<MultiToken> | ||
export declare function cardanoAssetToIdentifier( | ||
policyId: WasmContract.ScriptHash, | ||
name: WasmContract.AssetName | ||
): Promise<string> | ||
export declare function identifierToCardanoAsset( | ||
wasm: WasmContract.WasmModuleProxy, | ||
identifier: string | ||
): Promise<{ | ||
policyId: WasmContract.ScriptHash | ||
name: WasmContract.AssetName | ||
}> | ||
export declare function buildSendTokenList( | ||
defaultToken: DefaultTokenEntry, | ||
tokens: SendToken[], | ||
utxos: Array<MultiToken> | ||
): MultiToken | ||
export declare function multiTokenFromRemote( | ||
utxo: RemoteUnspentOutput, | ||
networkId: number | ||
): MultiToken | ||
export declare function hasSendAllDefault(tokens: Array<SendToken>): boolean | ||
export declare function parseTokenList( | ||
assets: WasmContract.MultiAsset | ||
): Promise< | ||
Array<{ | ||
assetId: string | ||
policyId: string | ||
name: string | ||
amount: string | ||
}> | ||
> | ||
import { MultiToken } from '../multi-token'; | ||
import { DefaultTokenEntry, RemoteUnspentOutput, SendToken } from '../models'; | ||
import * as WasmContract from '../wasm-contract'; | ||
export declare function cardanoValueFromMultiToken(wasm: WasmContract.WasmModuleProxy, tokens: MultiToken): Promise<WasmContract.Value>; | ||
export declare function multiTokenFromCardanoValue(value: WasmContract.Value, defaults: DefaultTokenEntry): Promise<MultiToken>; | ||
export declare function cardanoAssetToIdentifier(policyId: WasmContract.ScriptHash, name: WasmContract.AssetName): Promise<string>; | ||
export declare function identifierToCardanoAsset(wasm: WasmContract.WasmModuleProxy, identifier: string): Promise<{ | ||
policyId: WasmContract.ScriptHash; | ||
name: WasmContract.AssetName; | ||
}>; | ||
export declare function buildSendTokenList(defaultToken: DefaultTokenEntry, tokens: SendToken[], utxos: Array<MultiToken>): MultiToken; | ||
export declare function multiTokenFromRemote(utxo: RemoteUnspentOutput, networkId: number): MultiToken; | ||
export declare function hasSendAllDefault(tokens: Array<SendToken>): boolean; | ||
export declare function parseTokenList(assets: WasmContract.MultiAsset): Promise<Array<{ | ||
assetId: string; | ||
policyId: string; | ||
name: string; | ||
amount: string; | ||
}>>; |
@@ -1,14 +0,8 @@ | ||
import { Addressing } from '../models' | ||
import * as WasmContract from '../wasm-contract' | ||
export declare function getCardanoSpendingKeyHash( | ||
wasm: WasmContract.WasmModuleProxy, | ||
addr: WasmContract.Address | ||
): Promise<WasmContract.Ed25519KeyHash | undefined> | ||
export declare function derivePrivateByAddressing( | ||
addressing: Addressing, | ||
startingFrom: { | ||
key: WasmContract.Bip32PrivateKey | ||
level: number | ||
} | ||
): Promise<WasmContract.Bip32PrivateKey> | ||
export declare const harden: (num: number) => number | ||
import { Addressing } from '../models'; | ||
import * as WasmContract from '../wasm-contract'; | ||
export declare function getCardanoSpendingKeyHash(wasm: WasmContract.WasmModuleProxy, addr: WasmContract.Address): Promise<WasmContract.Ed25519KeyHash | undefined>; | ||
export declare function derivePrivateByAddressing(addressing: Addressing, startingFrom: { | ||
key: WasmContract.Bip32PrivateKey; | ||
level: number; | ||
}): Promise<WasmContract.Bip32PrivateKey>; | ||
export declare const harden: (num: number) => number; |
@@ -1,16 +0,11 @@ | ||
import { TxMetadata } from '../models' | ||
import * as WasmContract from '../wasm-contract' | ||
export declare const ERROR_NOT_IMPLEMENTED = 'ERROR HANDLING NOT IMPLEMENTED' | ||
import { TxMetadata } from '../models'; | ||
import * as WasmContract from '../wasm-contract'; | ||
export declare const ERROR_NOT_IMPLEMENTED = "ERROR HANDLING NOT IMPLEMENTED"; | ||
export declare enum AddInputResult { | ||
VALID = 0, | ||
TOO_SMALL = 1, | ||
OVERFLOW = 2, | ||
NO_NEED = 3 | ||
VALID = 0, | ||
TOO_SMALL = 1, | ||
OVERFLOW = 2, | ||
NO_NEED = 3 | ||
} | ||
export declare function firstWithValue<T extends WasmContract.WasmProxy>( | ||
...objs: T[] | ||
): T | ||
export declare function createMetadata( | ||
wasm: WasmContract.WasmModuleProxy, | ||
txMetadata: ReadonlyArray<TxMetadata> | ||
): Promise<WasmContract.AuxiliaryData> | ||
export declare function firstWithValue<T extends WasmContract.WasmProxy>(...objs: T[]): T; | ||
export declare function createMetadata(wasm: WasmContract.WasmModuleProxy, txMetadata: ReadonlyArray<TxMetadata>): Promise<WasmContract.AuxiliaryData>; |
@@ -1,8 +0,5 @@ | ||
export declare const groupBy: <T, K extends string | number | symbol>( | ||
list: T[], | ||
getKey: (item: T) => K | ||
) => Record<K, T[]> | ||
export declare const sliceArrayUntilItem: <T>(arr: T[], item: T) => T[] | ||
export declare const removeItemFromArray: <T>(arr: T[], item: T) => void | ||
export declare const chunk: <T>(arr: T[], size: number) => T[][] | ||
export declare const flatten: <T>(arr: T[][]) => T[] | ||
export declare const groupBy: <T, K extends string | number | symbol>(list: T[], getKey: (item: T) => K) => Record<K, T[]>; | ||
export declare const sliceArrayUntilItem: <T>(arr: T[], item: T) => T[]; | ||
export declare const removeItemFromArray: <T>(arr: T[], item: T) => void; | ||
export declare const chunk: <T>(arr: T[], size: number) => T[][]; | ||
export declare const flatten: <T>(arr: T[][]) => T[]; |
@@ -1,45 +0,16 @@ | ||
import * as WasmContract from '../wasm-contract' | ||
import { | ||
AddressingAddress, | ||
AddressingUtxo, | ||
CardanoAddressedUtxo, | ||
RemoteUnspentOutput | ||
} from '../models' | ||
import { AddInputResult } from './index' | ||
export declare function minRequiredForChange( | ||
wasm: WasmContract.WasmModuleProxy, | ||
txBuilder: WasmContract.TransactionBuilder, | ||
changeAdaAddr: AddressingAddress, | ||
value: WasmContract.Value, | ||
protocolParams: { | ||
linearFee: WasmContract.LinearFee | ||
minimumUtxoVal: WasmContract.BigNum | ||
} | ||
): Promise<WasmContract.BigNum> | ||
export declare function addUtxoInput( | ||
wasm: WasmContract.WasmModuleProxy, | ||
txBuilder: WasmContract.TransactionBuilder, | ||
remaining: | ||
| { | ||
hasInput: boolean | ||
value: WasmContract.Value | ||
} | ||
| undefined, | ||
input: RemoteUnspentOutput, | ||
excludeIfSmall: boolean, | ||
protocolParams: { | ||
networkId: number | ||
} | ||
): Promise<AddInputResult> | ||
export declare function cardanoValueFromRemoteFormat( | ||
wasm: WasmContract.WasmModuleProxy, | ||
utxo: RemoteUnspentOutput | ||
): Promise<WasmContract.Value> | ||
export declare function asAddressedUtxo( | ||
wasm: WasmContract.WasmModuleProxy, | ||
utxos: Array<AddressingUtxo> | ||
): Promise<Array<CardanoAddressedUtxo>> | ||
export declare function isBigNumZero( | ||
wasm: WasmContract.WasmModuleProxy, | ||
b: WasmContract.BigNum | ||
): Promise<boolean> | ||
import * as WasmContract from '../wasm-contract'; | ||
import { AddressingAddress, AddressingUtxo, CardanoAddressedUtxo, RemoteUnspentOutput } from '../models'; | ||
import { AddInputResult } from './index'; | ||
export declare function minRequiredForChange(wasm: WasmContract.WasmModuleProxy, txBuilder: WasmContract.TransactionBuilder, changeAdaAddr: AddressingAddress, value: WasmContract.Value, protocolParams: { | ||
linearFee: WasmContract.LinearFee; | ||
minimumUtxoVal: WasmContract.BigNum; | ||
}): Promise<WasmContract.BigNum>; | ||
export declare function addUtxoInput(wasm: WasmContract.WasmModuleProxy, txBuilder: WasmContract.TransactionBuilder, remaining: { | ||
hasInput: boolean; | ||
value: WasmContract.Value; | ||
} | undefined, input: RemoteUnspentOutput, excludeIfSmall: boolean, protocolParams: { | ||
networkId: number; | ||
}): Promise<AddInputResult>; | ||
export declare function cardanoValueFromRemoteFormat(wasm: WasmContract.WasmModuleProxy, utxo: RemoteUnspentOutput): Promise<WasmContract.Value>; | ||
export declare function asAddressedUtxo(wasm: WasmContract.WasmModuleProxy, utxos: Array<AddressingUtxo>): Promise<Array<CardanoAddressedUtxo>>; | ||
export declare function isBigNumZero(wasm: WasmContract.WasmModuleProxy, b: WasmContract.BigNum): Promise<boolean>; |
export declare const EXCEPTIONS: { | ||
NOT_IMPLEMENTED: string | ||
SHOULD_BE_OVERWRITTEN: string | ||
} | ||
NOT_IMPLEMENTED: string; | ||
SHOULD_BE_OVERWRITTEN: string; | ||
}; | ||
export interface WasmModuleProxy { | ||
encryptWithPassword( | ||
password: string, | ||
salt: string, | ||
nonce: string, | ||
data: string | ||
): Promise<string> | ||
decryptWithPassword(password: string, data: string): Promise<string> | ||
encodeJsonStrToMetadatum( | ||
json: string, | ||
schema: number | ||
): Promise<TransactionMetadatum> | ||
minAdaRequired(value: Value, minimumUtxoVal: BigNum): Promise<BigNum> | ||
hashTransaction(txBody: TransactionBody): Promise<TransactionHash> | ||
makeVkeyWitness( | ||
txBodyHash: TransactionHash, | ||
sk: PrivateKey | ||
): Promise<Vkeywitness> | ||
makeIcarusBootstrapWitness( | ||
txBodyHash: TransactionHash, | ||
addr: ByronAddress, | ||
key: Bip32PrivateKey | ||
): Promise<BootstrapWitness> | ||
decodeMetadatumToJsonStr( | ||
metadatum: TransactionMetadatum, | ||
schema: number | ||
): Promise<string> | ||
BigNum: typeof BigNum | ||
LinearFee: typeof LinearFee | ||
GeneralTransactionMetadata: typeof GeneralTransactionMetadata | ||
TransactionMetadatum: typeof TransactionMetadatum | ||
AuxiliaryData: typeof AuxiliaryData | ||
AssetName: typeof AssetName | ||
AssetNames: typeof AssetNames | ||
Assets: typeof Assets | ||
ScriptHash: typeof ScriptHash | ||
ScriptHashes: typeof ScriptHashes | ||
MultiAsset: typeof MultiAsset | ||
Ed25519KeyHash: typeof Ed25519KeyHash | ||
TransactionHash: typeof TransactionHash | ||
TransactionInput: typeof TransactionInput | ||
Value: typeof Value | ||
Address: typeof Address | ||
PublicKey: typeof PublicKey | ||
Bip32PublicKey: typeof Bip32PublicKey | ||
PrivateKey: typeof PrivateKey | ||
Bip32PrivateKey: typeof Bip32PrivateKey | ||
ByronAddress: typeof ByronAddress | ||
TransactionOutput: typeof TransactionOutput | ||
StakeCredential: typeof StakeCredential | ||
StakeRegistration: typeof StakeRegistration | ||
StakeDeregistration: typeof StakeDeregistration | ||
StakeDelegation: typeof StakeDelegation | ||
Certificate: typeof Certificate | ||
Certificates: typeof Certificates | ||
RewardAddress: typeof RewardAddress | ||
RewardAddresses: typeof RewardAddresses | ||
Withdrawals: typeof Withdrawals | ||
TransactionInputs: typeof TransactionInputs | ||
TransactionOutputs: typeof TransactionOutputs | ||
TransactionBody: typeof TransactionBody | ||
TransactionBuilder: typeof TransactionBuilder | ||
BaseAddress: typeof BaseAddress | ||
PointerAddress: typeof PointerAddress | ||
EnterpriseAddress: typeof EnterpriseAddress | ||
Pointer: typeof Pointer | ||
Vkey: typeof Vkey | ||
Ed25519Signature: typeof Ed25519Signature | ||
Vkeywitness: typeof Vkeywitness | ||
Vkeywitnesses: typeof Vkeywitnesses | ||
BootstrapWitness: typeof BootstrapWitness | ||
BootstrapWitnesses: typeof BootstrapWitnesses | ||
TransactionWitnessSet: typeof TransactionWitnessSet | ||
Transaction: typeof Transaction | ||
NetworkInfo: typeof NetworkInfo | ||
encryptWithPassword(password: string, salt: string, nonce: string, data: string): Promise<string>; | ||
decryptWithPassword(password: string, data: string): Promise<string>; | ||
encodeJsonStrToMetadatum(json: string, schema: number): Promise<TransactionMetadatum>; | ||
minAdaRequired(value: Value, minimumUtxoVal: BigNum): Promise<BigNum>; | ||
hashTransaction(txBody: TransactionBody): Promise<TransactionHash>; | ||
makeVkeyWitness(txBodyHash: TransactionHash, sk: PrivateKey): Promise<Vkeywitness>; | ||
makeIcarusBootstrapWitness(txBodyHash: TransactionHash, addr: ByronAddress, key: Bip32PrivateKey): Promise<BootstrapWitness>; | ||
decodeMetadatumToJsonStr(metadatum: TransactionMetadatum, schema: number): Promise<string>; | ||
BigNum: typeof BigNum; | ||
LinearFee: typeof LinearFee; | ||
GeneralTransactionMetadata: typeof GeneralTransactionMetadata; | ||
TransactionMetadatum: typeof TransactionMetadatum; | ||
AuxiliaryData: typeof AuxiliaryData; | ||
AssetName: typeof AssetName; | ||
AssetNames: typeof AssetNames; | ||
Assets: typeof Assets; | ||
ScriptHash: typeof ScriptHash; | ||
ScriptHashes: typeof ScriptHashes; | ||
MultiAsset: typeof MultiAsset; | ||
Ed25519KeyHash: typeof Ed25519KeyHash; | ||
TransactionHash: typeof TransactionHash; | ||
TransactionInput: typeof TransactionInput; | ||
Value: typeof Value; | ||
Address: typeof Address; | ||
PublicKey: typeof PublicKey; | ||
Bip32PublicKey: typeof Bip32PublicKey; | ||
PrivateKey: typeof PrivateKey; | ||
Bip32PrivateKey: typeof Bip32PrivateKey; | ||
ByronAddress: typeof ByronAddress; | ||
TransactionOutput: typeof TransactionOutput; | ||
StakeCredential: typeof StakeCredential; | ||
StakeRegistration: typeof StakeRegistration; | ||
StakeDeregistration: typeof StakeDeregistration; | ||
StakeDelegation: typeof StakeDelegation; | ||
Certificate: typeof Certificate; | ||
Certificates: typeof Certificates; | ||
RewardAddress: typeof RewardAddress; | ||
RewardAddresses: typeof RewardAddresses; | ||
Withdrawals: typeof Withdrawals; | ||
TransactionInputs: typeof TransactionInputs; | ||
TransactionOutputs: typeof TransactionOutputs; | ||
TransactionBody: typeof TransactionBody; | ||
TransactionBuilder: typeof TransactionBuilder; | ||
BaseAddress: typeof BaseAddress; | ||
PointerAddress: typeof PointerAddress; | ||
EnterpriseAddress: typeof EnterpriseAddress; | ||
Pointer: typeof Pointer; | ||
Vkey: typeof Vkey; | ||
Ed25519Signature: typeof Ed25519Signature; | ||
Vkeywitness: typeof Vkeywitness; | ||
Vkeywitnesses: typeof Vkeywitnesses; | ||
BootstrapWitness: typeof BootstrapWitness; | ||
BootstrapWitnesses: typeof BootstrapWitnesses; | ||
TransactionWitnessSet: typeof TransactionWitnessSet; | ||
Transaction: typeof Transaction; | ||
NetworkInfo: typeof NetworkInfo; | ||
MetadataList: typeof MetadataList; | ||
TransactionMetadatumLabels: typeof TransactionMetadatumLabels; | ||
MetadataMap: typeof MetadataMap; | ||
Int: typeof Int; | ||
} | ||
export declare abstract class WasmProxy { | ||
constructor(wasm: any | undefined) | ||
abstract hasValue(): boolean | ||
constructor(wasm: any | undefined); | ||
abstract hasValue(): boolean; | ||
} | ||
export declare abstract class Ptr extends WasmProxy { | ||
constructor(wasm: any | undefined) | ||
/** | ||
* Frees the pointer | ||
* @returns {Promise<void>} | ||
*/ | ||
abstract free(): Promise<void> | ||
constructor(wasm: any | undefined); | ||
/** | ||
* Frees the pointer | ||
* @returns {Promise<void>} | ||
*/ | ||
abstract free(): Promise<void>; | ||
} | ||
export declare abstract class BigNum extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
/** | ||
* @returns {string} | ||
*/ | ||
abstract toStr(): Promise<string> | ||
/** | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract checkedMul(other: BigNum): Promise<BigNum> | ||
/** | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract checkedAdd(other: BigNum): Promise<BigNum> | ||
/** | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract checkedSub(other: BigNum): Promise<BigNum> | ||
/** | ||
* returns 0 if it would otherwise underflow | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract clampedSub(other: BigNum): Promise<BigNum> | ||
/** | ||
* @param {BigNum} rhs_value | ||
* @returns {number} | ||
*/ | ||
abstract compare(rhs_value: BigNum): Promise<number> | ||
/** | ||
* @param {Uint8Array} bytes | ||
* @returns {BigNum} | ||
*/ | ||
static fromBytes(bytes: Uint8Array): Promise<BigNum> | ||
/** | ||
* @param {string} string | ||
* @returns {BigNum} | ||
*/ | ||
static fromStr(string: string): Promise<BigNum> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
/** | ||
* @returns {string} | ||
*/ | ||
abstract toStr(): Promise<string>; | ||
/** | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract checkedMul(other: BigNum): Promise<BigNum>; | ||
/** | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract checkedAdd(other: BigNum): Promise<BigNum>; | ||
/** | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract checkedSub(other: BigNum): Promise<BigNum>; | ||
/** | ||
* returns 0 if it would otherwise underflow | ||
* @param {BigNum} other | ||
* @returns {BigNum} | ||
*/ | ||
abstract clampedSub(other: BigNum): Promise<BigNum>; | ||
/** | ||
* @param {BigNum} rhs_value | ||
* @returns {number} | ||
*/ | ||
abstract compare(rhs_value: BigNum): Promise<number>; | ||
/** | ||
* @param {Uint8Array} bytes | ||
* @returns {BigNum} | ||
*/ | ||
static fromBytes(bytes: Uint8Array): Promise<BigNum>; | ||
/** | ||
* @param {string} string | ||
* @returns {BigNum} | ||
*/ | ||
static fromStr(string: string): Promise<BigNum>; | ||
} | ||
export declare abstract class LinearFee extends Ptr { | ||
/** | ||
* @returns {Promise<BigNum>} | ||
*/ | ||
abstract constant(): Promise<BigNum> | ||
/** | ||
* @returns {Promise<BigNum>} | ||
*/ | ||
abstract coefficient(): Promise<BigNum> | ||
/** | ||
* @param {BigNum} coefficient | ||
* @param {BigNum} constant | ||
* @returns {Promise<LinearFee>} | ||
*/ | ||
static new(coefficient: BigNum, constant: BigNum): Promise<LinearFee> | ||
/** | ||
* @returns {Promise<BigNum>} | ||
*/ | ||
abstract constant(): Promise<BigNum>; | ||
/** | ||
* @returns {Promise<BigNum>} | ||
*/ | ||
abstract coefficient(): Promise<BigNum>; | ||
/** | ||
* @param {BigNum} coefficient | ||
* @param {BigNum} constant | ||
* @returns {Promise<LinearFee>} | ||
*/ | ||
static new(coefficient: BigNum, constant: BigNum): Promise<LinearFee>; | ||
} | ||
export declare abstract class GeneralTransactionMetadata extends Ptr { | ||
abstract insert( | ||
key: BigNum, | ||
value: TransactionMetadatum | ||
): Promise<TransactionMetadatum> | ||
abstract get(key: BigNum): Promise<TransactionMetadatum> | ||
static new(): Promise<GeneralTransactionMetadata> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract len(): Promise<number>; | ||
abstract insert(key: BigNum, value: TransactionMetadatum): Promise<TransactionMetadatum>; | ||
abstract get(key: BigNum): Promise<TransactionMetadatum>; | ||
abstract keys(): Promise<TransactionMetadatumLabels>; | ||
static new(): Promise<GeneralTransactionMetadata>; | ||
static fromBytes(bytes: Uint8Array): Promise<GeneralTransactionMetadata>; | ||
} | ||
export declare abstract class TransactionMetadatumLabels extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<BigNum>; | ||
abstract add(elem: BigNum): Promise<void>; | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionMetadatumLabels>; | ||
static new(): Promise<TransactionMetadatumLabels>; | ||
} | ||
export declare abstract class MetadataMap extends Ptr { | ||
abstract free(): Promise<void>; | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract len(): Promise<number>; | ||
abstract insert(key: TransactionMetadatum, value: TransactionMetadatum): Promise<TransactionMetadatum | undefined>; | ||
abstract insertStr(key: string, value: TransactionMetadatum): Promise<TransactionMetadatum | undefined>; | ||
abstract insertI32(key: number, value: TransactionMetadatum): Promise<TransactionMetadatum | undefined>; | ||
abstract get(key: TransactionMetadatum): Promise<TransactionMetadatum>; | ||
abstract getStr(key: string): Promise<TransactionMetadatum>; | ||
abstract getI32(key: number): Promise<TransactionMetadatum>; | ||
abstract has(key: TransactionMetadatum): Promise<boolean>; | ||
abstract keys(): Promise<MetadataList>; | ||
static fromBytes(bytes: Uint8Array): Promise<MetadataMap>; | ||
static new(): Promise<MetadataMap>; | ||
} | ||
export declare abstract class Int extends Ptr { | ||
abstract isPositive(): Promise<boolean>; | ||
abstract asPositive(): Promise<BigNum | undefined>; | ||
abstract asNegative(): Promise<BigNum | undefined>; | ||
abstract asI32(): Promise<number | undefined>; | ||
static new(x: BigNum): Promise<Int>; | ||
static newNegative(x: BigNum): Promise<Int>; | ||
static newI32(x: number): Promise<Int>; | ||
} | ||
export declare abstract class TransactionMetadatum extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract kind(): Promise<number>; | ||
abstract asMap(): Promise<MetadataMap>; | ||
abstract asList(): Promise<MetadataList>; | ||
abstract asInt(): Promise<Int>; | ||
abstract asBytes(): Promise<Uint8Array>; | ||
abstract asText(): Promise<string>; | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionMetadatum>; | ||
static newMap(map: MetadataMap): Promise<TransactionMetadatum>; | ||
static newList(list: MetadataList): Promise<TransactionMetadatum>; | ||
static newInt(int: Int): Promise<TransactionMetadatum>; | ||
static newBytes(bytes: Uint8Array): Promise<TransactionMetadatum>; | ||
static newText(text: string): Promise<TransactionMetadatum>; | ||
} | ||
export declare abstract class AuxiliaryData extends Ptr { | ||
abstract metadata(): Promise<GeneralTransactionMetadata> | ||
static new(metadata: GeneralTransactionMetadata): Promise<AuxiliaryData> | ||
static empty(): Promise<AuxiliaryData> | ||
abstract metadata(): Promise<GeneralTransactionMetadata>; | ||
static new(metadata: GeneralTransactionMetadata): Promise<AuxiliaryData>; | ||
static empty(): Promise<AuxiliaryData>; | ||
} | ||
export declare abstract class AssetName extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract name(): Promise<Uint8Array> | ||
static fromBytes(bytes: Uint8Array): Promise<AssetName> | ||
static new(name: Uint8Array): Promise<AssetName> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract name(): Promise<Uint8Array>; | ||
static fromBytes(bytes: Uint8Array): Promise<AssetName>; | ||
static new(name: Uint8Array): Promise<AssetName>; | ||
} | ||
export declare abstract class AssetNames extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract get(index: number): Promise<AssetName> | ||
abstract add(item: AssetName): Promise<void> | ||
static new(): Promise<AssetNames> | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<AssetName>; | ||
abstract add(item: AssetName): Promise<void>; | ||
static new(): Promise<AssetNames>; | ||
} | ||
export declare abstract class Assets extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract insert(key: AssetName, value: BigNum): Promise<BigNum> | ||
abstract get(key: AssetName): Promise<BigNum> | ||
abstract keys(): Promise<AssetNames> | ||
static new(): Promise<Assets> | ||
abstract len(): Promise<number>; | ||
abstract insert(key: AssetName, value: BigNum): Promise<BigNum>; | ||
abstract get(key: AssetName): Promise<BigNum>; | ||
abstract keys(): Promise<AssetNames>; | ||
static new(): Promise<Assets>; | ||
} | ||
export declare abstract class ScriptHash extends WasmProxy { | ||
abstract toBytes(): Promise<Uint8Array> | ||
static fromBytes(bytes: Uint8Array): Promise<ScriptHash> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
static fromBytes(bytes: Uint8Array): Promise<ScriptHash>; | ||
} | ||
export declare abstract class ScriptHashes extends WasmProxy { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract len(): Promise<number> | ||
abstract get(index: number): Promise<ScriptHash> | ||
abstract add(item: ScriptHash): Promise<void> | ||
static fromBytes(bytes: Uint8Array): Promise<ScriptHashes> | ||
static new(): Promise<ScriptHashes> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<ScriptHash>; | ||
abstract add(item: ScriptHash): Promise<void>; | ||
static fromBytes(bytes: Uint8Array): Promise<ScriptHashes>; | ||
static new(): Promise<ScriptHashes>; | ||
} | ||
export declare type PolicyID = ScriptHash | ||
export declare type PolicyIDs = ScriptHashes | ||
export declare type PolicyID = ScriptHash; | ||
export declare type PolicyIDs = ScriptHashes; | ||
export declare abstract class MultiAsset extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract insert(key: PolicyID, value: Assets): Promise<Assets> | ||
abstract get(key: PolicyID): Promise<Assets> | ||
abstract keys(): Promise<PolicyIDs> | ||
abstract sub(rhs: MultiAsset): Promise<MultiAsset> | ||
static new(): Promise<MultiAsset> | ||
abstract len(): Promise<number>; | ||
abstract insert(key: PolicyID, value: Assets): Promise<Assets>; | ||
abstract get(key: PolicyID): Promise<Assets>; | ||
abstract keys(): Promise<PolicyIDs>; | ||
abstract sub(rhs: MultiAsset): Promise<MultiAsset>; | ||
static new(): Promise<MultiAsset>; | ||
} | ||
export declare abstract class Ed25519KeyHash extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
static fromBytes(bytes: Uint8Array): Promise<Ed25519KeyHash> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
static fromBytes(bytes: Uint8Array): Promise<Ed25519KeyHash>; | ||
} | ||
export declare abstract class TransactionHash extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionHash> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionHash>; | ||
} | ||
export declare abstract class TransactionInput extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract transactionId(): Promise<TransactionHash> | ||
abstract index(): Promise<number> | ||
static new( | ||
transactionId: TransactionHash, | ||
index: number | ||
): Promise<TransactionInput> | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionInput> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract transactionId(): Promise<TransactionHash>; | ||
abstract index(): Promise<number>; | ||
static new(transactionId: TransactionHash, index: number): Promise<TransactionInput>; | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionInput>; | ||
} | ||
export declare abstract class Value extends Ptr { | ||
abstract coin(): Promise<BigNum> | ||
abstract setCoin(coin: BigNum): Promise<void> | ||
abstract multiasset(): Promise<MultiAsset> | ||
abstract setMultiasset(multiasset: MultiAsset): Promise<void> | ||
abstract checkedAdd(rhs: Value): Promise<Value> | ||
abstract checkedSub(rhs: Value): Promise<Value> | ||
abstract clampedSub(rhs: Value): Promise<Value> | ||
abstract compare(rhs: Value): Promise<number | undefined> | ||
static new(coin: BigNum): Promise<Value> | ||
abstract coin(): Promise<BigNum>; | ||
abstract setCoin(coin: BigNum): Promise<void>; | ||
abstract multiasset(): Promise<MultiAsset>; | ||
abstract setMultiasset(multiasset: MultiAsset): Promise<void>; | ||
abstract checkedAdd(rhs: Value): Promise<Value>; | ||
abstract checkedSub(rhs: Value): Promise<Value>; | ||
abstract clampedSub(rhs: Value): Promise<Value>; | ||
abstract compare(rhs: Value): Promise<number | undefined>; | ||
static new(coin: BigNum): Promise<Value>; | ||
} | ||
export declare abstract class Address extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract toBech32(prefix?: string): Promise<string> | ||
abstract networkId(): Promise<number> | ||
static fromBytes(bytes: Uint8Array): Promise<Address> | ||
static fromBech32(string: string): Promise<Address> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract toBech32(prefix?: string): Promise<string>; | ||
abstract networkId(): Promise<number>; | ||
static fromBytes(bytes: Uint8Array): Promise<Address>; | ||
static fromBech32(string: string): Promise<Address>; | ||
} | ||
export declare abstract class PublicKey extends Ptr { | ||
abstract toBech32(): Promise<string> | ||
abstract asBytes(): Promise<Uint8Array> | ||
abstract hash(): Promise<Ed25519KeyHash> | ||
static fromBech32(bech32_str: string): Promise<PublicKey> | ||
static fromBytes(bytes: Uint8Array): Promise<PublicKey> | ||
abstract toBech32(): Promise<string>; | ||
abstract asBytes(): Promise<Uint8Array>; | ||
abstract hash(): Promise<Ed25519KeyHash>; | ||
static fromBech32(bech32_str: string): Promise<PublicKey>; | ||
static fromBytes(bytes: Uint8Array): Promise<PublicKey>; | ||
} | ||
export declare abstract class Bip32PublicKey extends Ptr { | ||
/** | ||
* derive this private key with the given index. | ||
* | ||
* # Security considerations | ||
* | ||
* * hard derivation index cannot be soft derived with the public key | ||
* | ||
* # Hard derivation vs Soft derivation | ||
* | ||
* If you pass an index below 0x80000000 then it is a soft derivation. | ||
* The advantage of soft derivation is that it is possible to derive the | ||
* public key too. I.e. derivation the private key with a soft derivation | ||
* index and then retrieving the associated public key is equivalent to | ||
* deriving the public key associated to the parent private key. | ||
* | ||
* Hard derivation index does not allow public key derivation. | ||
* | ||
* This is why deriving the private key should not fail while deriving | ||
* the public key may fail (if the derivation index is invalid). | ||
* @param {number} index | ||
* @returns {Promise<Bip32PublicKey>} | ||
*/ | ||
abstract derive(index: number): Promise<Bip32PublicKey> | ||
abstract toRawKey(): Promise<PublicKey> | ||
abstract asBytes(): Promise<Uint8Array> | ||
abstract toBech32(): Promise<string> | ||
abstract chaincode(): Promise<Uint8Array> | ||
static fromBech32(bech32_str: string): Promise<Bip32PublicKey> | ||
static fromBytes(bytes: Uint8Array): Promise<Bip32PublicKey> | ||
/** | ||
* derive this private key with the given index. | ||
* | ||
* # Security considerations | ||
* | ||
* * hard derivation index cannot be soft derived with the public key | ||
* | ||
* # Hard derivation vs Soft derivation | ||
* | ||
* If you pass an index below 0x80000000 then it is a soft derivation. | ||
* The advantage of soft derivation is that it is possible to derive the | ||
* public key too. I.e. derivation the private key with a soft derivation | ||
* index and then retrieving the associated public key is equivalent to | ||
* deriving the public key associated to the parent private key. | ||
* | ||
* Hard derivation index does not allow public key derivation. | ||
* | ||
* This is why deriving the private key should not fail while deriving | ||
* the public key may fail (if the derivation index is invalid). | ||
* @param {number} index | ||
* @returns {Promise<Bip32PublicKey>} | ||
*/ | ||
abstract derive(index: number): Promise<Bip32PublicKey>; | ||
abstract toRawKey(): Promise<PublicKey>; | ||
abstract asBytes(): Promise<Uint8Array>; | ||
abstract toBech32(): Promise<string>; | ||
abstract chaincode(): Promise<Uint8Array>; | ||
static fromBech32(bech32_str: string): Promise<Bip32PublicKey>; | ||
static fromBytes(bytes: Uint8Array): Promise<Bip32PublicKey>; | ||
} | ||
export declare abstract class PrivateKey extends Ptr { | ||
abstract toPublic(): Promise<PublicKey> | ||
abstract asBytes(): Promise<Uint8Array> | ||
abstract sign(message: Uint8Array): Promise<Ed25519Signature> | ||
static fromExtendedBytes(bytes: Uint8Array): Promise<PrivateKey> | ||
static fromNormalBytes(bytes: Uint8Array): Promise<PrivateKey> | ||
abstract toPublic(): Promise<PublicKey>; | ||
abstract asBytes(): Promise<Uint8Array>; | ||
abstract sign(message: Uint8Array): Promise<Ed25519Signature>; | ||
static fromExtendedBytes(bytes: Uint8Array): Promise<PrivateKey>; | ||
static fromNormalBytes(bytes: Uint8Array): Promise<PrivateKey>; | ||
} | ||
export declare abstract class Bip32PrivateKey extends Ptr { | ||
/** | ||
* derive this private key with the given index. | ||
* | ||
* # Security considerations | ||
* | ||
* * hard derivation index cannot be soft derived with the public key | ||
* | ||
* # Hard derivation vs Soft derivation | ||
* | ||
* If you pass an index below 0x80000000 then it is a soft derivation. | ||
* The advantage of soft derivation is that it is possible to derive the | ||
* public key too. I.e. derivation the private key with a soft derivation | ||
* index and then retrieving the associated public key is equivalent to | ||
* deriving the public key associated to the parent private key. | ||
* | ||
* Hard derivation index does not allow public key derivation. | ||
* | ||
* This is why deriving the private key should not fail while deriving | ||
* the public key may fail (if the derivation index is invalid). | ||
* @param {number} index | ||
* @returns {Promise<Bip32PrivateKey>} | ||
*/ | ||
abstract derive(index: number): Promise<Bip32PrivateKey> | ||
abstract toRawKey(): Promise<PrivateKey> | ||
abstract toPublic(): Promise<Bip32PublicKey> | ||
abstract asBytes(): Promise<Uint8Array> | ||
abstract toBech32(): Promise<string> | ||
static fromBip39Entropy( | ||
entropy: Uint8Array, | ||
password: Uint8Array | ||
): Promise<Bip32PrivateKey> | ||
static fromBech32(bech32Str: string): Promise<Bip32PrivateKey> | ||
static fromBytes(bytes: Uint8Array): Promise<Bip32PrivateKey> | ||
static generateEd25519Bip32(): Promise<Bip32PrivateKey> | ||
/** | ||
* derive this private key with the given index. | ||
* | ||
* # Security considerations | ||
* | ||
* * hard derivation index cannot be soft derived with the public key | ||
* | ||
* # Hard derivation vs Soft derivation | ||
* | ||
* If you pass an index below 0x80000000 then it is a soft derivation. | ||
* The advantage of soft derivation is that it is possible to derive the | ||
* public key too. I.e. derivation the private key with a soft derivation | ||
* index and then retrieving the associated public key is equivalent to | ||
* deriving the public key associated to the parent private key. | ||
* | ||
* Hard derivation index does not allow public key derivation. | ||
* | ||
* This is why deriving the private key should not fail while deriving | ||
* the public key may fail (if the derivation index is invalid). | ||
* @param {number} index | ||
* @returns {Promise<Bip32PrivateKey>} | ||
*/ | ||
abstract derive(index: number): Promise<Bip32PrivateKey>; | ||
abstract toRawKey(): Promise<PrivateKey>; | ||
abstract toPublic(): Promise<Bip32PublicKey>; | ||
abstract asBytes(): Promise<Uint8Array>; | ||
abstract toBech32(): Promise<string>; | ||
static fromBip39Entropy(entropy: Uint8Array, password: Uint8Array): Promise<Bip32PrivateKey>; | ||
static fromBech32(bech32Str: string): Promise<Bip32PrivateKey>; | ||
static fromBytes(bytes: Uint8Array): Promise<Bip32PrivateKey>; | ||
static generateEd25519Bip32(): Promise<Bip32PrivateKey>; | ||
} | ||
export declare abstract class ByronAddress extends Ptr { | ||
abstract toBase58(): Promise<string> | ||
abstract toAddress(): Promise<Address> | ||
abstract byronProtocolMagic(): Promise<number> | ||
abstract attributes(): Promise<Uint8Array> | ||
static icarusFromKey( | ||
key: Bip32PublicKey, | ||
protocolMagic: number | ||
): Promise<ByronAddress> | ||
static fromBase58(string: string): Promise<ByronAddress> | ||
static isValid(string: string): Promise<boolean> | ||
static fromAddress(addr: Address): Promise<ByronAddress> | ||
abstract toBase58(): Promise<string>; | ||
abstract toAddress(): Promise<Address>; | ||
abstract byronProtocolMagic(): Promise<number>; | ||
abstract attributes(): Promise<Uint8Array>; | ||
static icarusFromKey(key: Bip32PublicKey, protocolMagic: number): Promise<ByronAddress>; | ||
static fromBase58(string: string): Promise<ByronAddress>; | ||
static isValid(string: string): Promise<boolean>; | ||
static fromAddress(addr: Address): Promise<ByronAddress>; | ||
} | ||
export declare abstract class TransactionOutput extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract address(): Promise<Address> | ||
abstract amount(): Promise<Value> | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionOutput> | ||
static new(address: Address, amount: Value): Promise<TransactionOutput> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract address(): Promise<Address>; | ||
abstract amount(): Promise<Value>; | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionOutput>; | ||
static new(address: Address, amount: Value): Promise<TransactionOutput>; | ||
} | ||
export declare abstract class StakeCredential extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract toKeyhash(): Promise<Ed25519KeyHash> | ||
abstract toScripthash(): Promise<ScriptHash> | ||
abstract kind(): Promise<number> | ||
static fromBytes(bytes: Uint8Array): Promise<StakeCredential> | ||
static fromKeyhash(hash: Ed25519KeyHash): Promise<StakeCredential> | ||
static fromScripthash(hash: ScriptHash): Promise<StakeCredential> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract toKeyhash(): Promise<Ed25519KeyHash>; | ||
abstract toScripthash(): Promise<ScriptHash>; | ||
abstract kind(): Promise<number>; | ||
static fromBytes(bytes: Uint8Array): Promise<StakeCredential>; | ||
static fromKeyhash(hash: Ed25519KeyHash): Promise<StakeCredential>; | ||
static fromScripthash(hash: ScriptHash): Promise<StakeCredential>; | ||
} | ||
export declare abstract class StakeRegistration extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract stakeCredential(): Promise<StakeCredential> | ||
static new(stakeCredential: StakeCredential): Promise<StakeRegistration> | ||
static fromBytes(bytes: Uint8Array): Promise<StakeRegistration> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract stakeCredential(): Promise<StakeCredential>; | ||
static new(stakeCredential: StakeCredential): Promise<StakeRegistration>; | ||
static fromBytes(bytes: Uint8Array): Promise<StakeRegistration>; | ||
} | ||
export declare abstract class StakeDeregistration extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract stakeCredential(): Promise<StakeCredential> | ||
static new(stakeCredential: StakeCredential): Promise<StakeDeregistration> | ||
static fromBytes(bytes: Uint8Array): Promise<StakeDeregistration> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract stakeCredential(): Promise<StakeCredential>; | ||
static new(stakeCredential: StakeCredential): Promise<StakeDeregistration>; | ||
static fromBytes(bytes: Uint8Array): Promise<StakeDeregistration>; | ||
} | ||
export declare abstract class StakeDelegation extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract stakeCredential(): Promise<StakeCredential> | ||
abstract poolKeyhash(): Promise<Ed25519KeyHash> | ||
static new( | ||
stakeCredential: StakeCredential, | ||
poolKeyHash: Ed25519KeyHash | ||
): Promise<StakeDelegation> | ||
static fromBytes(bytes: Uint8Array): Promise<StakeDelegation> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract stakeCredential(): Promise<StakeCredential>; | ||
abstract poolKeyhash(): Promise<Ed25519KeyHash>; | ||
static new(stakeCredential: StakeCredential, poolKeyHash: Ed25519KeyHash): Promise<StakeDelegation>; | ||
static fromBytes(bytes: Uint8Array): Promise<StakeDelegation>; | ||
} | ||
export declare abstract class Certificate extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract asStakeRegistration(): Promise<StakeRegistration> | ||
abstract asStakeDeregistration(): Promise<StakeDeregistration> | ||
abstract asStakeDelegation(): Promise<StakeDelegation> | ||
static fromBytes(bytes: Uint8Array): Promise<Certificate> | ||
static newStakeRegistration( | ||
stakeRegistration: StakeRegistration | ||
): Promise<Certificate> | ||
static newStakeDeregistration( | ||
stakeDeregistration: StakeDeregistration | ||
): Promise<Certificate> | ||
static newStakeDelegation( | ||
stakeDelegation: StakeDelegation | ||
): Promise<Certificate> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract asStakeRegistration(): Promise<StakeRegistration>; | ||
abstract asStakeDeregistration(): Promise<StakeDeregistration>; | ||
abstract asStakeDelegation(): Promise<StakeDelegation>; | ||
static fromBytes(bytes: Uint8Array): Promise<Certificate>; | ||
static newStakeRegistration(stakeRegistration: StakeRegistration): Promise<Certificate>; | ||
static newStakeDeregistration(stakeDeregistration: StakeDeregistration): Promise<Certificate>; | ||
static newStakeDelegation(stakeDelegation: StakeDelegation): Promise<Certificate>; | ||
} | ||
export declare abstract class Certificates extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract len(): Promise<number> | ||
abstract get(index: number): Promise<Certificate> | ||
abstract add(item: Certificate): Promise<void> | ||
static fromBytes(bytes: Uint8Array): Promise<Certificates> | ||
static new(): Promise<Certificates> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<Certificate>; | ||
abstract add(item: Certificate): Promise<void>; | ||
static fromBytes(bytes: Uint8Array): Promise<Certificates>; | ||
static new(): Promise<Certificates>; | ||
} | ||
export declare abstract class RewardAddress extends Ptr { | ||
abstract paymentCred(): Promise<StakeCredential> | ||
abstract toAddress(): Promise<Address> | ||
static fromAddress(addr: Address): Promise<RewardAddress> | ||
static new(network: number, payment: StakeCredential): Promise<RewardAddress> | ||
abstract paymentCred(): Promise<StakeCredential>; | ||
abstract toAddress(): Promise<Address>; | ||
static fromAddress(addr: Address): Promise<RewardAddress>; | ||
static new(network: number, payment: StakeCredential): Promise<RewardAddress>; | ||
} | ||
export declare abstract class RewardAddresses extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract get(index: number): Promise<RewardAddress> | ||
abstract add(item: RewardAddress): Promise<void> | ||
static new(): Promise<RewardAddresses> | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<RewardAddress>; | ||
abstract add(item: RewardAddress): Promise<void>; | ||
static new(): Promise<RewardAddresses>; | ||
} | ||
export declare abstract class Withdrawals extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract insert(key: RewardAddress, value: BigNum): Promise<BigNum> | ||
abstract get(key: RewardAddress): Promise<BigNum> | ||
abstract keys(): Promise<RewardAddresses> | ||
static new(): Promise<Withdrawals> | ||
abstract len(): Promise<number>; | ||
abstract insert(key: RewardAddress, value: BigNum): Promise<BigNum>; | ||
abstract get(key: RewardAddress): Promise<BigNum>; | ||
abstract keys(): Promise<RewardAddresses>; | ||
static new(): Promise<Withdrawals>; | ||
} | ||
export declare abstract class TransactionInputs extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract get(index: number): Promise<TransactionInput> | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<TransactionInput>; | ||
} | ||
export declare abstract class TransactionOutputs extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract get(index: number): Promise<TransactionOutput> | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<TransactionOutput>; | ||
} | ||
export declare type Optional<T> = T | ||
export declare type Optional<T> = T; | ||
export declare abstract class TransactionBody extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract inputs(): Promise<TransactionInputs> | ||
abstract outputs(): Promise<TransactionOutputs> | ||
abstract fee(): Promise<BigNum> | ||
abstract ttl(): Promise<Optional<number | undefined>> | ||
abstract certs(): Promise<Certificates> | ||
abstract withdrawals(): Promise<Withdrawals> | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionBody> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract inputs(): Promise<TransactionInputs>; | ||
abstract outputs(): Promise<TransactionOutputs>; | ||
abstract fee(): Promise<BigNum>; | ||
abstract ttl(): Promise<Optional<number | undefined>>; | ||
abstract certs(): Promise<Certificates>; | ||
abstract withdrawals(): Promise<Withdrawals>; | ||
static fromBytes(bytes: Uint8Array): Promise<TransactionBody>; | ||
} | ||
export declare abstract class TransactionBuilder extends Ptr { | ||
abstract addKeyInput( | ||
hash: Ed25519KeyHash, | ||
input: TransactionInput, | ||
amount: Value | ||
): Promise<void> | ||
abstract addBootstrapInput( | ||
hash: ByronAddress, | ||
input: TransactionInput, | ||
amount: Value | ||
): Promise<void> | ||
abstract addInput( | ||
address: Address, | ||
input: TransactionInput, | ||
amount: Value | ||
): Promise<void> | ||
abstract feeForInput( | ||
address: Address, | ||
input: TransactionInput, | ||
amount: Value | ||
): Promise<BigNum> | ||
abstract addOutput(output: TransactionOutput): Promise<void> | ||
abstract feeForOutput(output: TransactionOutput): Promise<BigNum> | ||
abstract setFee(fee: BigNum): Promise<void> | ||
abstract setTtl(ttl: number): Promise<void> | ||
abstract setValidityStartInterval( | ||
validityStartInterval: number | ||
): Promise<void> | ||
abstract setCerts(certs: Certificates): Promise<void> | ||
abstract setWithdrawals(withdrawals: Withdrawals): Promise<void> | ||
abstract setAuxiliaryData(auxiliary: AuxiliaryData): Promise<void> | ||
abstract getExplicitInput(): Promise<Value> | ||
abstract getImplicitInput(): Promise<Value> | ||
abstract getExplicitOutput(): Promise<Value> | ||
abstract getDeposit(): Promise<BigNum> | ||
abstract getFeeIfSet(): Promise<BigNum> | ||
abstract addChangeIfNeeded(address: Address): Promise<boolean> | ||
abstract build(): Promise<TransactionBody> | ||
abstract minFee(): Promise<BigNum> | ||
static new( | ||
linearFee: LinearFee, | ||
minimumUtxoVal: BigNum, | ||
poolDeposit: BigNum, | ||
keyDeposit: BigNum | ||
): Promise<TransactionBuilder> | ||
abstract addKeyInput(hash: Ed25519KeyHash, input: TransactionInput, amount: Value): Promise<void>; | ||
abstract addBootstrapInput(hash: ByronAddress, input: TransactionInput, amount: Value): Promise<void>; | ||
abstract addInput(address: Address, input: TransactionInput, amount: Value): Promise<void>; | ||
abstract feeForInput(address: Address, input: TransactionInput, amount: Value): Promise<BigNum>; | ||
abstract addOutput(output: TransactionOutput): Promise<void>; | ||
abstract feeForOutput(output: TransactionOutput): Promise<BigNum>; | ||
abstract setFee(fee: BigNum): Promise<void>; | ||
abstract setTtl(ttl: number): Promise<void>; | ||
abstract setValidityStartInterval(validityStartInterval: number): Promise<void>; | ||
abstract setCerts(certs: Certificates): Promise<void>; | ||
abstract setWithdrawals(withdrawals: Withdrawals): Promise<void>; | ||
abstract setAuxiliaryData(auxiliary: AuxiliaryData): Promise<void>; | ||
abstract getExplicitInput(): Promise<Value>; | ||
abstract getImplicitInput(): Promise<Value>; | ||
abstract getExplicitOutput(): Promise<Value>; | ||
abstract getDeposit(): Promise<BigNum>; | ||
abstract getFeeIfSet(): Promise<BigNum>; | ||
abstract addChangeIfNeeded(address: Address): Promise<boolean>; | ||
abstract build(): Promise<TransactionBody>; | ||
abstract minFee(): Promise<BigNum>; | ||
static new(linearFee: LinearFee, minimumUtxoVal: BigNum, poolDeposit: BigNum, keyDeposit: BigNum): Promise<TransactionBuilder>; | ||
} | ||
export declare abstract class BaseAddress extends Ptr { | ||
abstract paymentCred(): Promise<StakeCredential> | ||
abstract stakeCred(): Promise<StakeCredential> | ||
abstract toAddress(): Promise<Address> | ||
static fromAddress(addr: Address): Promise<BaseAddress> | ||
static new( | ||
network: number, | ||
payment: StakeCredential, | ||
stake: StakeCredential | ||
): Promise<BaseAddress> | ||
abstract paymentCred(): Promise<StakeCredential>; | ||
abstract stakeCred(): Promise<StakeCredential>; | ||
abstract toAddress(): Promise<Address>; | ||
static fromAddress(addr: Address): Promise<BaseAddress>; | ||
static new(network: number, payment: StakeCredential, stake: StakeCredential): Promise<BaseAddress>; | ||
} | ||
export declare abstract class PointerAddress extends Ptr { | ||
abstract paymentCred(): Promise<StakeCredential> | ||
abstract stakePointer(): Promise<Pointer> | ||
abstract toAddress(): Promise<Address> | ||
static fromAddress(addr: Address): Promise<PointerAddress> | ||
static new( | ||
network: number, | ||
payment: StakeCredential, | ||
stake: Pointer | ||
): Promise<PointerAddress> | ||
abstract paymentCred(): Promise<StakeCredential>; | ||
abstract stakePointer(): Promise<Pointer>; | ||
abstract toAddress(): Promise<Address>; | ||
static fromAddress(addr: Address): Promise<PointerAddress>; | ||
static new(network: number, payment: StakeCredential, stake: Pointer): Promise<PointerAddress>; | ||
} | ||
export declare abstract class EnterpriseAddress extends Ptr { | ||
abstract paymentCred(): Promise<StakeCredential> | ||
abstract toAddress(): Promise<Address> | ||
static fromAddress(addr: Address): Promise<EnterpriseAddress> | ||
static new( | ||
network: number, | ||
payment: StakeCredential | ||
): Promise<EnterpriseAddress> | ||
abstract paymentCred(): Promise<StakeCredential>; | ||
abstract toAddress(): Promise<Address>; | ||
static fromAddress(addr: Address): Promise<EnterpriseAddress>; | ||
static new(network: number, payment: StakeCredential): Promise<EnterpriseAddress>; | ||
} | ||
export declare abstract class Pointer extends Ptr { | ||
abstract slot(): Promise<number> | ||
abstract txIndex(): Promise<number> | ||
abstract certIndex(): Promise<number> | ||
static new(slot: number, txIndex: number, certIndex: number): Promise<Pointer> | ||
abstract slot(): Promise<number>; | ||
abstract txIndex(): Promise<number>; | ||
abstract certIndex(): Promise<number>; | ||
static new(slot: number, txIndex: number, certIndex: number): Promise<Pointer>; | ||
} | ||
export declare abstract class Vkey extends Ptr { | ||
static new(pk: PublicKey): Promise<Vkey> | ||
static new(pk: PublicKey): Promise<Vkey>; | ||
} | ||
export declare abstract class Ed25519Signature extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract toHex(): Promise<string> | ||
static fromBytes(bytes: Uint8Array): Promise<Ed25519Signature> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract toHex(): Promise<string>; | ||
static fromBytes(bytes: Uint8Array): Promise<Ed25519Signature>; | ||
} | ||
export declare abstract class Vkeywitness extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
abstract signature(): Promise<Ed25519Signature> | ||
static fromBytes(bytes: Uint8Array): Promise<Vkeywitness> | ||
static new(vkey: Vkey, signature: Ed25519Signature): Promise<Vkeywitness> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
abstract signature(): Promise<Ed25519Signature>; | ||
static fromBytes(bytes: Uint8Array): Promise<Vkeywitness>; | ||
static new(vkey: Vkey, signature: Ed25519Signature): Promise<Vkeywitness>; | ||
} | ||
export declare abstract class Vkeywitnesses extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract add(item: Vkeywitness): Promise<void> | ||
static new(): Promise<Vkeywitnesses> | ||
abstract len(): Promise<number>; | ||
abstract add(item: Vkeywitness): Promise<void>; | ||
static new(): Promise<Vkeywitnesses>; | ||
} | ||
export declare abstract class BootstrapWitness extends Ptr { | ||
abstract toBytes(): Promise<Uint8Array> | ||
static fromBytes(bytes: Uint8Array): Promise<BootstrapWitness> | ||
static new( | ||
vkey: Vkey, | ||
signature: Ed25519Signature, | ||
chainCode: Uint8Array, | ||
attributes: Uint8Array | ||
): Promise<BootstrapWitness> | ||
abstract toBytes(): Promise<Uint8Array>; | ||
static fromBytes(bytes: Uint8Array): Promise<BootstrapWitness>; | ||
static new(vkey: Vkey, signature: Ed25519Signature, chainCode: Uint8Array, attributes: Uint8Array): Promise<BootstrapWitness>; | ||
} | ||
export declare abstract class BootstrapWitnesses extends Ptr { | ||
abstract len(): Promise<number> | ||
abstract add(item: BootstrapWitness): Promise<void> | ||
static new(): Promise<BootstrapWitnesses> | ||
abstract len(): Promise<number>; | ||
abstract add(item: BootstrapWitness): Promise<void>; | ||
static new(): Promise<BootstrapWitnesses>; | ||
} | ||
export declare abstract class TransactionWitnessSet extends Ptr { | ||
abstract setBootstraps(bootstraps: BootstrapWitnesses): Promise<void> | ||
abstract setVkeys(vkeywitnesses: Vkeywitnesses): Promise<void> | ||
static new(): Promise<TransactionWitnessSet> | ||
abstract setBootstraps(bootstraps: BootstrapWitnesses): Promise<void>; | ||
abstract setVkeys(vkeywitnesses: Vkeywitnesses): Promise<void>; | ||
static new(): Promise<TransactionWitnessSet>; | ||
} | ||
export declare abstract class Transaction extends Ptr { | ||
abstract body(): Promise<TransactionBody> | ||
abstract toBytes(): Promise<Uint8Array> | ||
static new( | ||
body: TransactionBody, | ||
witnessSet: TransactionWitnessSet, | ||
auxiliary: AuxiliaryData | ||
): Promise<Transaction> | ||
static fromBytes(bytes: Uint8Array): Promise<Transaction> | ||
abstract body(): Promise<TransactionBody>; | ||
abstract toBytes(): Promise<Uint8Array>; | ||
static new(body: TransactionBody, witnessSet: TransactionWitnessSet, auxiliary: AuxiliaryData): Promise<Transaction>; | ||
static fromBytes(bytes: Uint8Array): Promise<Transaction>; | ||
} | ||
export declare abstract class NetworkInfo extends Ptr { | ||
abstract networkId(): Promise<number> | ||
abstract protocolMagic(): Promise<number> | ||
static new(networkId: number, protocolMagic: number): Promise<NetworkInfo> | ||
static testnet(): Promise<NetworkInfo> | ||
static mainnet(): Promise<NetworkInfo> | ||
abstract networkId(): Promise<number>; | ||
abstract protocolMagic(): Promise<number>; | ||
static new(networkId: number, protocolMagic: number): Promise<NetworkInfo>; | ||
static testnet(): Promise<NetworkInfo>; | ||
static mainnet(): Promise<NetworkInfo>; | ||
} | ||
export declare abstract class MetadataList extends Ptr { | ||
static new(): Promise<MetadataList>; | ||
static fromBytes(bytes: Uint8Array): Promise<MetadataList>; | ||
abstract len(): Promise<number>; | ||
abstract get(index: number): Promise<TransactionMetadatum>; | ||
abstract add(item: TransactionMetadatum): Promise<void>; | ||
abstract toBytes(): Promise<Uint8Array>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Transaction = exports.TransactionWitnessSet = exports.BootstrapWitnesses = exports.BootstrapWitness = exports.Vkeywitnesses = exports.Vkeywitness = exports.Ed25519Signature = exports.Vkey = exports.Pointer = exports.EnterpriseAddress = exports.PointerAddress = exports.BaseAddress = exports.TransactionBuilder = exports.TransactionBody = exports.TransactionOutputs = exports.TransactionInputs = exports.Withdrawals = exports.RewardAddresses = exports.RewardAddress = exports.Certificates = exports.Certificate = exports.StakeDelegation = exports.StakeDeregistration = exports.StakeRegistration = exports.StakeCredential = exports.TransactionOutput = exports.ByronAddress = exports.Bip32PrivateKey = exports.PrivateKey = exports.Bip32PublicKey = exports.PublicKey = exports.Address = exports.Value = exports.TransactionInput = exports.TransactionHash = exports.Ed25519KeyHash = exports.MultiAsset = exports.ScriptHashes = exports.ScriptHash = exports.Assets = exports.AssetNames = exports.AssetName = exports.AuxiliaryData = exports.TransactionMetadatum = exports.GeneralTransactionMetadata = exports.LinearFee = exports.BigNum = exports.Ptr = exports.WasmProxy = exports.EXCEPTIONS = void 0; | ||
exports.NetworkInfo = void 0; | ||
exports.BootstrapWitness = exports.Vkeywitnesses = exports.Vkeywitness = exports.Ed25519Signature = exports.Vkey = exports.Pointer = exports.EnterpriseAddress = exports.PointerAddress = exports.BaseAddress = exports.TransactionBuilder = exports.TransactionBody = exports.TransactionOutputs = exports.TransactionInputs = exports.Withdrawals = exports.RewardAddresses = exports.RewardAddress = exports.Certificates = exports.Certificate = exports.StakeDelegation = exports.StakeDeregistration = exports.StakeRegistration = exports.StakeCredential = exports.TransactionOutput = exports.ByronAddress = exports.Bip32PrivateKey = exports.PrivateKey = exports.Bip32PublicKey = exports.PublicKey = exports.Address = exports.Value = exports.TransactionInput = exports.TransactionHash = exports.Ed25519KeyHash = exports.MultiAsset = exports.ScriptHashes = exports.ScriptHash = exports.Assets = exports.AssetNames = exports.AssetName = exports.AuxiliaryData = exports.TransactionMetadatum = exports.Int = exports.MetadataMap = exports.TransactionMetadatumLabels = exports.GeneralTransactionMetadata = exports.LinearFee = exports.BigNum = exports.Ptr = exports.WasmProxy = exports.EXCEPTIONS = void 0; | ||
exports.MetadataList = exports.NetworkInfo = exports.Transaction = exports.TransactionWitnessSet = exports.BootstrapWitnesses = void 0; | ||
// this file contains several "abstract static" methods. | ||
@@ -70,5 +70,56 @@ // This is not an actual feature of TS, but we define the static methods in the abstract classes | ||
} | ||
static fromBytes(bytes) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
} | ||
exports.GeneralTransactionMetadata = GeneralTransactionMetadata; | ||
class TransactionMetadatumLabels extends Ptr { | ||
static fromBytes(bytes) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static new() { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
} | ||
exports.TransactionMetadatumLabels = TransactionMetadatumLabels; | ||
class MetadataMap extends Ptr { | ||
static fromBytes(bytes) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static new() { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
} | ||
exports.MetadataMap = MetadataMap; | ||
class Int extends Ptr { | ||
static new(x) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static newNegative(x) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static newI32(x) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
} | ||
exports.Int = Int; | ||
class TransactionMetadatum extends Ptr { | ||
static fromBytes(bytes) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static newMap(map) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static newList(list) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static newInt(int) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static newBytes(bytes) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static newText(text) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
} | ||
@@ -433,1 +484,10 @@ exports.TransactionMetadatum = TransactionMetadatum; | ||
exports.NetworkInfo = NetworkInfo; | ||
class MetadataList extends Ptr { | ||
static new() { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
static fromBytes(bytes) { | ||
throw exports.EXCEPTIONS.SHOULD_BE_OVERWRITTEN; | ||
} | ||
} | ||
exports.MetadataList = MetadataList; |
@@ -1,19 +0,8 @@ | ||
import { | ||
TipStatusReference, | ||
Utxo, | ||
UtxoApiResponse, | ||
UtxoAtPointRequest, | ||
UtxoDiff, | ||
UtxoDiffSincePointRequest | ||
} from './models' | ||
import { TipStatusReference, Utxo, UtxoApiResponse, UtxoAtPointRequest, UtxoDiff, UtxoDiffSincePointRequest } from './models'; | ||
export interface UtxoApiContract { | ||
getBestBlock(): Promise<string> | ||
getSafeBlock(): Promise<string> | ||
getTipStatusWithReference( | ||
bestBlocks: string[] | ||
): Promise<UtxoApiResponse<TipStatusReference>> | ||
getUtxoAtPoint(req: UtxoAtPointRequest): Promise<UtxoApiResponse<Utxo[]>> | ||
getUtxoDiffSincePoint( | ||
req: UtxoDiffSincePointRequest | ||
): Promise<UtxoApiResponse<UtxoDiff>> | ||
getBestBlock(): Promise<string>; | ||
getSafeBlock(): Promise<string>; | ||
getTipStatusWithReference(bestBlocks: string[]): Promise<UtxoApiResponse<TipStatusReference>>; | ||
getUtxoAtPoint(req: UtxoAtPointRequest): Promise<UtxoApiResponse<Utxo[]>>; | ||
getUtxoDiffSincePoint(req: UtxoDiffSincePointRequest): Promise<UtxoApiResponse<UtxoDiff>>; | ||
} |
@@ -1,75 +0,57 @@ | ||
import { Axios } from 'axios' | ||
import { UtxoApiContract } from './api' | ||
import { | ||
Asset, | ||
DiffPoint, | ||
DiffType, | ||
TipStatusReference, | ||
Utxo, | ||
UtxoApiResponse, | ||
UtxoAtPointRequest, | ||
UtxoDiff, | ||
UtxoDiffSincePointRequest | ||
} from './models' | ||
import { Axios } from 'axios'; | ||
import { UtxoApiContract } from './api'; | ||
import { Asset, DiffPoint, DiffType, TipStatusReference, Utxo, UtxoApiResponse, UtxoAtPointRequest, UtxoDiff, UtxoDiffSincePointRequest } from './models'; | ||
export declare type UtxoAtPointItemResponse = { | ||
utxo_id: string | ||
tx_hash: string | ||
tx_index: number | ||
receiver: string | ||
amount: string | ||
assets: Asset[] | ||
block_num: number | ||
} | ||
utxo_id: string; | ||
tx_hash: string; | ||
tx_index: number; | ||
receiver: string; | ||
amount: string; | ||
assets: Asset[]; | ||
block_num: number; | ||
}; | ||
export declare type UtxoDiffSincePointItemResponse = { | ||
type: DiffType | ||
id: string | ||
receiver: string | ||
amount: string | ||
assets: Asset[] | ||
block_num: number | ||
tx_hash: string | ||
tx_index: number | ||
} | ||
type: DiffType; | ||
id: string; | ||
receiver: string; | ||
amount: string; | ||
assets: Asset[]; | ||
block_num: number; | ||
tx_hash: string; | ||
tx_index: number; | ||
}; | ||
export declare type UtxoDiffSincePointResponse = { | ||
lastDiffPointSelected: DiffPoint | ||
diffItems: UtxoDiffSincePointItemResponse[] | ||
} | ||
lastDiffPointSelected: DiffPoint; | ||
diffItems: UtxoDiffSincePointItemResponse[]; | ||
}; | ||
export declare type TipStatusResponse = { | ||
reference: { | ||
lastFoundSafeBlock: string | ||
lastFoundBestBlock: string | ||
} | ||
} | ||
reference: { | ||
lastFoundSafeBlock: string; | ||
lastFoundBestBlock: string; | ||
}; | ||
}; | ||
export declare type GetTipStatusResponse = { | ||
safeBlock: string | ||
bestBlock: string | ||
} | ||
safeBlock: string; | ||
bestBlock: string; | ||
}; | ||
export declare class BatchedEmurgoUtxoApi implements UtxoApiContract { | ||
private _base | ||
constructor(base: UtxoApiContract) | ||
getSafeBlock(): Promise<string> | ||
getBestBlock(): Promise<string> | ||
getTipStatusWithReference( | ||
bestBlocks: string[] | ||
): Promise<UtxoApiResponse<TipStatusReference>> | ||
getUtxoAtPoint(req: UtxoAtPointRequest): Promise<UtxoApiResponse<Utxo[]>> | ||
getUtxoDiffSincePoint( | ||
req: UtxoDiffSincePointRequest | ||
): Promise<UtxoApiResponse<UtxoDiff>> | ||
private _base; | ||
constructor(base: UtxoApiContract); | ||
getSafeBlock(): Promise<string>; | ||
getBestBlock(): Promise<string>; | ||
getTipStatusWithReference(bestBlocks: string[]): Promise<UtxoApiResponse<TipStatusReference>>; | ||
getUtxoAtPoint(req: UtxoAtPointRequest): Promise<UtxoApiResponse<Utxo[]>>; | ||
getUtxoDiffSincePoint(req: UtxoDiffSincePointRequest): Promise<UtxoApiResponse<UtxoDiff>>; | ||
} | ||
export declare class EmurgoUtxoApi implements UtxoApiContract { | ||
private _axios | ||
private _apiUrl | ||
private _throwRequestErrors | ||
constructor(axios: Axios, apiUrl: string, throwRequestErrors: boolean) | ||
getSafeBlock(): Promise<string> | ||
getBestBlock(): Promise<string> | ||
getTipStatusWithReference( | ||
bestBlocks: string[] | ||
): Promise<UtxoApiResponse<TipStatusReference>> | ||
getUtxoAtPoint(req: UtxoAtPointRequest): Promise<UtxoApiResponse<Utxo[]>> | ||
getUtxoDiffSincePoint( | ||
req: UtxoDiffSincePointRequest | ||
): Promise<UtxoApiResponse<UtxoDiff>> | ||
private getUtxoAtPointPage | ||
private _axios; | ||
private _apiUrl; | ||
private _throwRequestErrors; | ||
constructor(axios: Axios, apiUrl: string, throwRequestErrors: boolean); | ||
getSafeBlock(): Promise<string>; | ||
getBestBlock(): Promise<string>; | ||
getTipStatusWithReference(bestBlocks: string[]): Promise<UtxoApiResponse<TipStatusReference>>; | ||
getUtxoAtPoint(req: UtxoAtPointRequest): Promise<UtxoApiResponse<Utxo[]>>; | ||
getUtxoDiffSincePoint(req: UtxoDiffSincePointRequest): Promise<UtxoApiResponse<UtxoDiff>>; | ||
private getUtxoAtPointPage; | ||
} |
@@ -17,3 +17,6 @@ "use strict"; | ||
const handleReferencePointErrors = (err) => { | ||
if (err.response && err.response.data && err.response.data.error && err.response.data.response) { | ||
if (err.response && | ||
err.response.data && | ||
err.response.data.error && | ||
err.response.data.response) { | ||
const errResponse = err.response.data.response; | ||
@@ -25,3 +28,4 @@ switch (errResponse) { | ||
}; | ||
default: throw err; | ||
default: | ||
throw err; | ||
} | ||
@@ -34,3 +38,6 @@ } | ||
const handleReferencePointAndBestBlockErrors = (err) => { | ||
if (err.response && err.response.data && err.response.data.error && err.response.data.response) { | ||
if (err.response && | ||
err.response.data && | ||
err.response.data.error && | ||
err.response.data.response) { | ||
const errResponse = err.response.data.response; | ||
@@ -46,3 +53,4 @@ switch (errResponse) { | ||
}; | ||
default: throw err; | ||
default: | ||
throw err; | ||
} | ||
@@ -83,3 +91,3 @@ } | ||
})); | ||
const values = (yield Promise.all(promises)).map(x => x.value); | ||
const values = (yield Promise.all(promises)).map((x) => x.value); | ||
return { | ||
@@ -106,7 +114,7 @@ result: models_1.UtxoApiResult.SUCCESS, | ||
})); | ||
const values = (yield Promise.all(promises)).map(x => x.value); | ||
const values = (yield Promise.all(promises)).map((x) => x.value); | ||
return { | ||
result: models_1.UtxoApiResult.SUCCESS, | ||
value: { | ||
diffItems: (0, js_1.flatten)(values.map(x => x.diffItems)) | ||
diffItems: (0, js_1.flatten)(values.map((x) => x.diffItems)) | ||
} | ||
@@ -162,3 +170,6 @@ }; | ||
catch (err) { | ||
if (err.response && err.response.data && err.response.data.error && err.response.data.response) { | ||
if (err.response && | ||
err.response.data && | ||
err.response.data.error && | ||
err.response.data.response) { | ||
const errResponse = err.response.data.response; | ||
@@ -170,3 +181,4 @@ switch (errResponse) { | ||
}; | ||
default: throw err; | ||
default: | ||
throw err; | ||
} | ||
@@ -194,3 +206,3 @@ } | ||
result: models_1.UtxoApiResult.SUCCESS, | ||
value: allUtxos.map(u => { | ||
value: allUtxos.map((u) => { | ||
return { | ||
@@ -241,3 +253,3 @@ utxoId: u.utxo_id, | ||
value: { | ||
diffItems: allDiffItems.map(u => { | ||
diffItems: allDiffItems.map((u) => { | ||
if (u.type === models_1.DiffType.INPUT) { | ||
@@ -247,3 +259,3 @@ return { | ||
id: u.id, | ||
type: u.type, | ||
type: u.type | ||
}; | ||
@@ -250,0 +262,0 @@ } |
@@ -1,26 +0,23 @@ | ||
import { UtxoApiContract } from './api' | ||
import { Utxo, UtxoAtSafePoint, UtxoDiffToBestBlock } from './models' | ||
import { UtxoApiContract } from './api'; | ||
import { Utxo, UtxoAtSafePoint, UtxoDiffToBestBlock } from './models'; | ||
export interface UtxoStorage { | ||
getUtxoAtSafePoint(): Promise<UtxoAtSafePoint | undefined> | ||
getUtxoDiffToBestBlock(): Promise<UtxoDiffToBestBlock[]> | ||
replaceUtxoAtSafePoint(utxos: Utxo[], safeBlockHash: string): Promise<void> | ||
clearUtxoState(): Promise<void> | ||
appendUtxoDiffToBestBlock(diff: UtxoDiffToBestBlock): Promise<void> | ||
removeDiffWithBestBlock(blockHash: string): Promise<void> | ||
getUtxoAtSafePoint(): Promise<UtxoAtSafePoint | undefined>; | ||
getUtxoDiffToBestBlock(): Promise<UtxoDiffToBestBlock[]>; | ||
replaceUtxoAtSafePoint(utxos: Utxo[], safeBlockHash: string): Promise<void>; | ||
clearUtxoState(): Promise<void>; | ||
appendUtxoDiffToBestBlock(diff: UtxoDiffToBestBlock): Promise<void>; | ||
removeDiffWithBestBlock(blockHash: string): Promise<void>; | ||
} | ||
export declare class UtxoService { | ||
private _api | ||
private _utxoStorage | ||
constructor(api: UtxoApiContract, utxoStorage: UtxoStorage) | ||
getAvailableUtxos(): Promise<Utxo[]> | ||
syncUtxoState(addresses: string[]): Promise<void> | ||
private syncSafeStateAndGetDiff | ||
private getUtxoDiffSincePoint | ||
private mergeDiffsIntoSafeUtxoSet | ||
private getUtxoSafePoint | ||
private getUtxoAtSafePointFromApi | ||
private _api; | ||
private _utxoStorage; | ||
constructor(api: UtxoApiContract, utxoStorage: UtxoStorage); | ||
getAvailableUtxos(): Promise<Utxo[]>; | ||
syncUtxoState(addresses: string[]): Promise<void>; | ||
private syncSafeStateAndGetDiff; | ||
private getUtxoDiffSincePoint; | ||
private mergeDiffsIntoSafeUtxoSet; | ||
private getUtxoSafePoint; | ||
private getUtxoAtSafePointFromApi; | ||
} | ||
export declare const init: ( | ||
utxoStorage: UtxoStorage, | ||
apiUrl: string | ||
) => UtxoService | ||
export declare const init: (utxoStorage: UtxoStorage, apiUrl: string) => UtxoService; |
@@ -48,7 +48,6 @@ "use strict"; | ||
const diffs = yield this._utxoStorage.getUtxoDiffToBestBlock(); | ||
const utxos = safeUtxos | ||
.concat((0, js_1.flatten)(diffs.map(d => d.newUtxos))); | ||
const allSpentUtxoId = (0, js_1.flatten)(diffs.map(d => d.spentUtxoIds)); | ||
const utxos = safeUtxos.concat((0, js_1.flatten)(diffs.map((d) => d.newUtxos))); | ||
const allSpentUtxoId = (0, js_1.flatten)(diffs.map((d) => d.spentUtxoIds)); | ||
for (const spendUtxoId of allSpentUtxoId) { | ||
const utxoToRemove = utxos.find(u => u.utxoId === spendUtxoId); | ||
const utxoToRemove = utxos.find((u) => u.utxoId === spendUtxoId); | ||
if (utxoToRemove) { | ||
@@ -64,15 +63,18 @@ (0, js_1.removeItemFromArray)(utxos, utxoToRemove); | ||
const { safeUtxos, diff, bestBlock, localDiff, tipStatus } = yield this.syncSafeStateAndGetDiff(addresses); | ||
const groups = (0, js_1.groupBy)(diff.diffItems, i => i.type); | ||
const groups = (0, js_1.groupBy)(diff.diffItems, (i) => i.type); | ||
const diffToBestBlock = { | ||
lastBestBlockHash: bestBlock, | ||
spentUtxoIds: groups[models_1.DiffType.INPUT] ? groups[models_1.DiffType.INPUT].map(d => d.id) : [], | ||
newUtxos: groups[models_1.DiffType.OUTPUT] ? groups[models_1.DiffType.OUTPUT].map(d => d.utxo) : [] | ||
spentUtxoIds: groups[models_1.DiffType.INPUT] | ||
? groups[models_1.DiffType.INPUT].map((d) => d.id) | ||
: [], | ||
newUtxos: groups[models_1.DiffType.OUTPUT] | ||
? groups[models_1.DiffType.OUTPUT].map((d) => d.utxo) | ||
: [] | ||
}; | ||
if (localDiff && localDiff.length > 0) { | ||
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.'; | ||
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) | ||
@@ -87,4 +89,3 @@ throw new Error(diffFromBestBlockNotFoundError); | ||
} | ||
const diffWhichIsNowSafe = localDiff | ||
.find(d => d.lastBestBlockHash === tipStatus.reference.lastFoundSafeBlock); | ||
const diffWhichIsNowSafe = localDiff.find((d) => d.lastBestBlockHash === tipStatus.reference.lastFoundSafeBlock); | ||
if (diffWhichIsNowSafe) { | ||
@@ -103,3 +104,3 @@ yield this.mergeDiffsIntoSafeUtxoSet(safeUtxos, localDiff, diffWhichIsNowSafe, tipStatus.reference.lastFoundSafeBlock); | ||
if (localDiff && localDiff.length > 0) { | ||
referenceBlocks = referenceBlocks.concat(localDiff.map(d => d.lastBestBlockHash)); | ||
referenceBlocks = referenceBlocks.concat(localDiff.map((d) => d.lastBestBlockHash)); | ||
} | ||
@@ -178,3 +179,3 @@ const tipStatusResponse = yield this._api.getTipStatusWithReference(referenceBlocks); | ||
} | ||
const newSafeUtxos = Object.keys(utxoMap).map(k => utxoMap[k]); | ||
const newSafeUtxos = Object.keys(utxoMap).map((k) => utxoMap[k]); | ||
yield this._utxoStorage.replaceUtxoAtSafePoint(newSafeUtxos, lastFoundSafeBlock); | ||
@@ -181,0 +182,0 @@ }); |
@@ -1,75 +0,75 @@ | ||
import BigNumber from 'bignumber.js' | ||
import BigNumber from 'bignumber.js'; | ||
export declare enum UtxoApiResult { | ||
SUCCESS = 'SUCCESS', | ||
BESTBLOCK_ROLLBACK = 'BESTBLOCK_ROLLBACK', | ||
SAFEBLOCK_ROLLBACK = 'SAFEBLOCK_ROLLBACK' | ||
SUCCESS = "SUCCESS", | ||
BESTBLOCK_ROLLBACK = "BESTBLOCK_ROLLBACK", | ||
SAFEBLOCK_ROLLBACK = "SAFEBLOCK_ROLLBACK" | ||
} | ||
export declare type Block = { | ||
number: number | ||
hash: string | ||
epochNo: number | ||
slotNo: number | ||
} | ||
number: number; | ||
hash: string; | ||
epochNo: number; | ||
slotNo: number; | ||
}; | ||
export declare type UtxoAtPointRequest = { | ||
addresses: string[] | ||
referenceBlockHash: string | ||
} | ||
addresses: string[]; | ||
referenceBlockHash: string; | ||
}; | ||
export declare type UtxoDiffSincePointRequest = { | ||
addresses: string[] | ||
untilBlockHash: string | ||
afterBestBlock: string | ||
} | ||
addresses: string[]; | ||
untilBlockHash: string; | ||
afterBestBlock: string; | ||
}; | ||
export declare type Asset = { | ||
assetId: string | ||
policyId: string | ||
name: string | ||
amount: string | ||
} | ||
assetId: string; | ||
policyId: string; | ||
name: string; | ||
amount: string; | ||
}; | ||
export declare type Utxo = { | ||
utxoId: string | ||
txHash: string | ||
txIndex: number | ||
receiver: string | ||
amount: BigNumber | ||
assets: Asset[] | ||
blockNum: number | ||
} | ||
utxoId: string; | ||
txHash: string; | ||
txIndex: number; | ||
receiver: string; | ||
amount: BigNumber; | ||
assets: Asset[]; | ||
blockNum: number; | ||
}; | ||
export declare enum DiffType { | ||
INPUT = 'input', | ||
OUTPUT = 'output' | ||
INPUT = "input", | ||
OUTPUT = "output" | ||
} | ||
export declare type UtxoDiffItem = { | ||
type: DiffType | ||
id: string | ||
amount: BigNumber | ||
} | ||
type: DiffType; | ||
id: string; | ||
amount: BigNumber; | ||
}; | ||
export declare type UtxoDiffItemOutput = UtxoDiffItem & { | ||
utxo: Utxo | ||
} | ||
utxo: Utxo; | ||
}; | ||
export declare type DiffPoint = { | ||
blockHash: string | ||
txHash: string | ||
itemIndex: number | ||
} | ||
blockHash: string; | ||
txHash: string; | ||
itemIndex: number; | ||
}; | ||
export declare type UtxoDiff = { | ||
diffItems: Array<UtxoDiffItem | UtxoDiffItemOutput> | ||
} | ||
diffItems: Array<UtxoDiffItem | UtxoDiffItemOutput>; | ||
}; | ||
export declare type UtxoDiffToBestBlock = { | ||
lastBestBlockHash: string | ||
spentUtxoIds: string[] | ||
newUtxos: Utxo[] | ||
} | ||
lastBestBlockHash: string; | ||
spentUtxoIds: string[]; | ||
newUtxos: Utxo[]; | ||
}; | ||
export declare type UtxoAtSafePoint = { | ||
lastSafeBlockHash: string | ||
utxos: Utxo[] | ||
} | ||
lastSafeBlockHash: string; | ||
utxos: Utxo[]; | ||
}; | ||
export declare type UtxoApiResponse<T> = { | ||
result: UtxoApiResult | ||
value?: T | ||
} | ||
result: UtxoApiResult; | ||
value?: T; | ||
}; | ||
export declare type TipStatusReference = { | ||
reference: { | ||
lastFoundSafeBlock: string | ||
lastFoundBestBlock: string | ||
} | ||
} | ||
reference: { | ||
lastFoundSafeBlock: string; | ||
lastFoundBestBlock: string; | ||
}; | ||
}; |
{ | ||
"name": "@emurgo/yoroi-lib-core", | ||
"version": "0.0.1-alpha.5", | ||
"version": "0.0.1-alpha.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
222786
0
4018