@arkade-os/sdk 0.3.10 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/cjs/arkfee/celenv.js +43 -0
- package/dist/cjs/arkfee/estimator.js +143 -0
- package/dist/cjs/arkfee/index.js +5 -0
- package/dist/cjs/arkfee/types.js +25 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/intent/index.js +21 -0
- package/dist/cjs/providers/ark.js +2 -9
- package/dist/cjs/providers/indexer.js +1 -0
- package/dist/cjs/utils/transactionHistory.js +120 -156
- package/dist/cjs/wallet/ramps.js +96 -11
- package/dist/cjs/wallet/serviceWorker/worker.js +4 -31
- package/dist/cjs/wallet/wallet.js +54 -34
- package/dist/esm/arkfee/celenv.js +40 -0
- package/dist/esm/arkfee/estimator.js +139 -0
- package/dist/esm/arkfee/index.js +1 -0
- package/dist/esm/arkfee/types.js +21 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/intent/index.js +21 -0
- package/dist/esm/providers/ark.js +2 -9
- package/dist/esm/providers/indexer.js +1 -0
- package/dist/esm/utils/transactionHistory.js +119 -155
- package/dist/esm/wallet/ramps.js +96 -11
- package/dist/esm/wallet/serviceWorker/worker.js +4 -31
- package/dist/esm/wallet/wallet.js +54 -34
- package/dist/types/arkfee/celenv.d.ts +25 -0
- package/dist/types/arkfee/estimator.d.ts +49 -0
- package/dist/types/arkfee/index.d.ts +2 -0
- package/dist/types/arkfee/types.d.ts +37 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/intent/index.d.ts +1 -0
- package/dist/types/providers/ark.d.ts +3 -8
- package/dist/types/utils/transactionHistory.d.ts +12 -5
- package/dist/types/wallet/index.d.ts +1 -0
- package/dist/types/wallet/ramps.d.ts +2 -1
- package/dist/types/wallet/serviceWorker/worker.d.ts +0 -1
- package/package.json +3 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Environment } from "@marcbachmann/cel-js";
|
|
2
|
+
/**
|
|
3
|
+
* Variable names used in CEL expressions
|
|
4
|
+
*/
|
|
5
|
+
export declare const AmountVariableName = "amount";
|
|
6
|
+
export declare const ExpiryVariableName = "expiry";
|
|
7
|
+
export declare const BirthVariableName = "birth";
|
|
8
|
+
export declare const WeightVariableName = "weight";
|
|
9
|
+
export declare const InputTypeVariableName = "inputType";
|
|
10
|
+
export declare const OutputScriptVariableName = "script";
|
|
11
|
+
/**
|
|
12
|
+
* IntentOutputEnv is the CEL environment for output fee calculation
|
|
13
|
+
* Variables: amount, script
|
|
14
|
+
*/
|
|
15
|
+
export declare const IntentOutputEnv: Environment;
|
|
16
|
+
/**
|
|
17
|
+
* IntentOffchainInputEnv is the CEL environment for offchain input fee calculation
|
|
18
|
+
* Variables: amount, expiry, birth, weight, inputType
|
|
19
|
+
*/
|
|
20
|
+
export declare const IntentOffchainInputEnv: Environment;
|
|
21
|
+
/**
|
|
22
|
+
* IntentOnchainInputEnv is the CEL environment for onchain input fee calculation
|
|
23
|
+
* Variables: amount
|
|
24
|
+
*/
|
|
25
|
+
export declare const IntentOnchainInputEnv: Environment;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IntentFeeConfig, OffchainInput, OnchainInput, FeeOutput, FeeAmount } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Estimator evaluates CEL expressions to calculate fees for Ark intents
|
|
4
|
+
*/
|
|
5
|
+
export declare class Estimator {
|
|
6
|
+
readonly config: IntentFeeConfig;
|
|
7
|
+
private intentOffchainInput?;
|
|
8
|
+
private intentOnchainInput?;
|
|
9
|
+
private intentOffchainOutput?;
|
|
10
|
+
private intentOnchainOutput?;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Estimator with the given config
|
|
13
|
+
* @param config - Configuration containing CEL programs for fee calculation
|
|
14
|
+
*/
|
|
15
|
+
constructor(config: IntentFeeConfig);
|
|
16
|
+
/**
|
|
17
|
+
* Evaluates the fee for a given vtxo input
|
|
18
|
+
* @param input - The offchain input to evaluate
|
|
19
|
+
* @returns The fee amount for this input
|
|
20
|
+
*/
|
|
21
|
+
evalOffchainInput(input: OffchainInput): FeeAmount;
|
|
22
|
+
/**
|
|
23
|
+
* Evaluates the fee for a given boarding input
|
|
24
|
+
* @param input - The onchain input to evaluate
|
|
25
|
+
* @returns The fee amount for this input
|
|
26
|
+
*/
|
|
27
|
+
evalOnchainInput(input: OnchainInput): FeeAmount;
|
|
28
|
+
/**
|
|
29
|
+
* Evaluates the fee for a given vtxo output
|
|
30
|
+
* @param output - The output to evaluate
|
|
31
|
+
* @returns The fee amount for this output
|
|
32
|
+
*/
|
|
33
|
+
evalOffchainOutput(output: FeeOutput): FeeAmount;
|
|
34
|
+
/**
|
|
35
|
+
* Evaluates the fee for a given collaborative exit output
|
|
36
|
+
* @param output - The output to evaluate
|
|
37
|
+
* @returns The fee amount for this output
|
|
38
|
+
*/
|
|
39
|
+
evalOnchainOutput(output: FeeOutput): FeeAmount;
|
|
40
|
+
/**
|
|
41
|
+
* Evaluates the fee for a given set of inputs and outputs
|
|
42
|
+
* @param offchainInputs - Array of offchain inputs to evaluate
|
|
43
|
+
* @param onchainInputs - Array of onchain inputs to evaluate
|
|
44
|
+
* @param offchainOutputs - Array of offchain outputs to evaluate
|
|
45
|
+
* @param onchainOutputs - Array of onchain outputs to evaluate
|
|
46
|
+
* @returns The total fee amount
|
|
47
|
+
*/
|
|
48
|
+
eval(offchainInputs: OffchainInput[], onchainInputs: OnchainInput[], offchainOutputs: FeeOutput[], onchainOutputs: FeeOutput[]): FeeAmount;
|
|
49
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FeeAmount is a wrapper around a number that represents a fee amount in satoshis floating point.
|
|
3
|
+
* @param value - The fee amount in floating point.
|
|
4
|
+
* @method satoshis - Returns the fee amount in satoshis as a integer.
|
|
5
|
+
* @example
|
|
6
|
+
* const fee = new FeeAmount(1.23456789);
|
|
7
|
+
* console.log(fee.value); // 1.23456789
|
|
8
|
+
* console.log(fee.satoshis); // 2
|
|
9
|
+
*/
|
|
10
|
+
export declare class FeeAmount {
|
|
11
|
+
readonly value: number;
|
|
12
|
+
static ZERO: FeeAmount;
|
|
13
|
+
constructor(value: number);
|
|
14
|
+
get satoshis(): number;
|
|
15
|
+
add(other: FeeAmount): FeeAmount;
|
|
16
|
+
}
|
|
17
|
+
export interface IntentFeeConfig {
|
|
18
|
+
offchainInput?: string;
|
|
19
|
+
onchainInput?: string;
|
|
20
|
+
offchainOutput?: string;
|
|
21
|
+
onchainOutput?: string;
|
|
22
|
+
}
|
|
23
|
+
export type VtxoType = "recoverable" | "vtxo" | "note";
|
|
24
|
+
export interface OffchainInput {
|
|
25
|
+
amount: bigint;
|
|
26
|
+
expiry?: Date;
|
|
27
|
+
birth?: Date;
|
|
28
|
+
type: VtxoType;
|
|
29
|
+
weight: number;
|
|
30
|
+
}
|
|
31
|
+
export interface OnchainInput {
|
|
32
|
+
amount: bigint;
|
|
33
|
+
}
|
|
34
|
+
export interface FeeOutput {
|
|
35
|
+
amount: bigint;
|
|
36
|
+
script: string;
|
|
37
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -36,5 +36,6 @@ import { ContractRepositoryImpl } from "./repositories/contractRepository";
|
|
|
36
36
|
import { ArkError, maybeArkError } from "./providers/errors";
|
|
37
37
|
import { validateVtxoTxGraph, validateConnectorsTxGraph } from "./tree/validation";
|
|
38
38
|
import { buildForfeitTx } from "./forfeit";
|
|
39
|
+
export * from "./arkfee";
|
|
39
40
|
export { Wallet, ReadonlyWallet, SingleKey, ReadonlySingleKey, OnchainWallet, Ramps, VtxoManager, ESPLORA_URL, EsploraProvider, RestArkProvider, RestIndexerProvider, ArkAddress, DefaultVtxo, VtxoScript, VHTLC, TxType, IndexerTxType, ChainTxType, SettlementEventType, setupServiceWorker, Worker, ServiceWorkerWallet, ServiceWorkerReadonlyWallet, Request, Response, decodeTapscript, MultisigTapscript, CSVMultisigTapscript, ConditionCSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, TapTreeCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, setArkPsbtField, getArkPsbtFields, CosignerPublicKey, VtxoTreeExpiry, VtxoTaprootTree, ConditionWitness, buildOffchainTx, verifyTapscriptSignatures, waitForIncomingFunds, hasBoardingTxExpired, combineTapscriptSigs, isVtxoExpiringSoon, ArkNote, networks, WalletRepositoryImpl, ContractRepositoryImpl, Intent, TxTree, P2A, Unroll, Transaction, ArkError, maybeArkError, Batch, validateVtxoTxGraph, validateConnectorsTxGraph, buildForfeitTx, isRecoverable, isSpendable, isSubdust, isExpired, getSequence, };
|
|
40
41
|
export type { Identity, ReadonlyIdentity, IWallet, IReadonlyWallet, BaseWalletConfig, WalletConfig, ReadonlyWalletConfig, ProviderClass, ArkTransaction, Coin, ExtendedCoin, ExtendedVirtualCoin, WalletBalance, SendBitcoinParams, Recipient, SettleParams, Status, VirtualStatus, Outpoint, VirtualCoin, TxKey, TapscriptType, ArkTxInput, OffchainTx, TapLeaves, IncomingFunds, IndexerProvider, PageResponse, BatchInfo, ChainTx, CommitmentTx, TxHistoryRecord, Vtxo, VtxoChain, Tx, OnchainProvider, ArkProvider, SettlementEvent, FeeInfo, ArkInfo, SignedIntent, Output, TxNotification, ExplorerTransaction, BatchFinalizationEvent, BatchFinalizedEvent, BatchFailedEvent, TreeSigningStartedEvent, TreeNoncesEvent, BatchStartedEvent, TreeTxEvent, TreeSignatureEvent, ScheduledSession, PaginationOptions, SubscriptionResponse, SubscriptionHeartbeat, SubscriptionEvent, Network, NetworkName, ArkTapscript, RelativeTimelock, EncodedVtxoScript, TapLeafScript, SignerSession, TreeNonces, TreePartialSigs, GetVtxosFilter, Nonces, PartialSig, ArkPsbtFieldCoder, TxTreeNode, AnchorBumper, };
|
|
@@ -38,6 +38,7 @@ export declare namespace Intent {
|
|
|
38
38
|
* @returns An unsigned Intent proof transaction
|
|
39
39
|
*/
|
|
40
40
|
function create(message: string | Message, inputs: TransactionInput[], outputs?: TransactionOutput[]): Proof;
|
|
41
|
+
function fee(proof: Proof): number;
|
|
41
42
|
type RegisterMessage = {
|
|
42
43
|
type: "register";
|
|
43
44
|
onchain_output_indexes: number[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TxTreeNode } from "../tree/txTree";
|
|
2
2
|
import { TreeNonces, TreePartialSigs } from "../tree/signingSession";
|
|
3
3
|
import { Vtxo } from "./indexer";
|
|
4
|
+
import type { IntentFeeConfig } from "../arkfee";
|
|
4
5
|
import { Intent } from "../intent";
|
|
5
6
|
export type Output = {
|
|
6
7
|
address: string;
|
|
@@ -73,14 +74,8 @@ export interface ScheduledSession {
|
|
|
73
74
|
nextStartTime: bigint;
|
|
74
75
|
period: bigint;
|
|
75
76
|
}
|
|
76
|
-
export interface IntentFeeInfo {
|
|
77
|
-
offchainInput: string;
|
|
78
|
-
offchainOutput: string;
|
|
79
|
-
onchainInput: bigint;
|
|
80
|
-
onchainOutput: bigint;
|
|
81
|
-
}
|
|
82
77
|
export interface FeeInfo {
|
|
83
|
-
intentFee:
|
|
78
|
+
intentFee: IntentFeeConfig;
|
|
84
79
|
txFeeRate: string;
|
|
85
80
|
}
|
|
86
81
|
export interface PendingTx {
|
|
@@ -103,7 +98,7 @@ export interface ArkInfo {
|
|
|
103
98
|
forfeitAddress: string;
|
|
104
99
|
forfeitPubkey: string;
|
|
105
100
|
network: string;
|
|
106
|
-
scheduledSession
|
|
101
|
+
scheduledSession?: ScheduledSession;
|
|
107
102
|
serviceStatus: ServiceStatus;
|
|
108
103
|
sessionDuration: bigint;
|
|
109
104
|
signerPubkey: string;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { ArkTransaction, VirtualCoin } from "../wallet";
|
|
2
|
+
type ExtendedArkTransaction = ArkTransaction & {
|
|
3
|
+
tag: "offchain" | "boarding" | "exit" | "batch";
|
|
4
|
+
};
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
6
|
+
* Builds the transaction history by analyzing virtual coins (VTXOs), boarding transactions, and ignored commitments.
|
|
7
|
+
* History is sorted from newest to oldest and is composed only of SENT and RECEIVED transactions.
|
|
8
|
+
*
|
|
9
|
+
* @param {VirtualCoin[]} vtxos - An array of virtual coins representing the user's transactions and balances.
|
|
10
|
+
* @param {ArkTransaction[]} allBoardingTxs - An array of boarding transactions to include in the history.
|
|
11
|
+
* @param {Set<string>} commitmentsToIgnore - A set of commitment IDs that should be excluded from processing.
|
|
12
|
+
* @return {ExtendedArkTransaction[]} A sorted array of extended Ark transactions, representing the transaction history.
|
|
7
13
|
*/
|
|
8
|
-
export declare function
|
|
14
|
+
export declare function buildTransactionHistory(vtxos: VirtualCoin[], allBoardingTxs: ArkTransaction[], commitmentsToIgnore: Set<string>, getTxCreatedAt?: (txid: string) => Promise<number>): Promise<ExtendedArkTransaction[]>;
|
|
15
|
+
export {};
|
|
@@ -16,11 +16,12 @@ export declare class Ramps {
|
|
|
16
16
|
/**
|
|
17
17
|
* Onboard boarding utxos.
|
|
18
18
|
*
|
|
19
|
+
* @param feeInfo - The fee info to deduct from the onboard amount.
|
|
19
20
|
* @param boardingUtxos - The boarding utxos to onboard. If not provided, all boarding utxos will be used.
|
|
20
21
|
* @param amount - The amount to onboard. If not provided, the total amount of boarding utxos will be onboarded.
|
|
21
22
|
* @param eventCallback - The callback to receive settlement events. optional.
|
|
22
23
|
*/
|
|
23
|
-
onboard(boardingUtxos?: ExtendedCoin[], amount?: bigint, eventCallback?: (event: SettlementEvent) => void): ReturnType<IWallet["settle"]>;
|
|
24
|
+
onboard(feeInfo: FeeInfo, boardingUtxos?: ExtendedCoin[], amount?: bigint, eventCallback?: (event: SettlementEvent) => void): ReturnType<IWallet["settle"]>;
|
|
24
25
|
/**
|
|
25
26
|
* Offboard vtxos, or "collaborative exit" vtxos to onchain address.
|
|
26
27
|
*
|
|
@@ -32,7 +32,6 @@ export declare class Worker {
|
|
|
32
32
|
* Get all boarding utxos from wallet repository
|
|
33
33
|
*/
|
|
34
34
|
private getAllBoardingUtxos;
|
|
35
|
-
private getTransactionHistory;
|
|
36
35
|
start(withServiceWorkerUpdate?: boolean): Promise<void>;
|
|
37
36
|
clear(): Promise<void>;
|
|
38
37
|
reload(): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkade-os/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "Bitcoin wallet SDK with Taproot and Ark integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"@noble/secp256k1": "3.0.0",
|
|
58
58
|
"@scure/base": "2.0.0",
|
|
59
59
|
"@scure/btc-signer": "2.0.1",
|
|
60
|
-
"bip68": "1.0.4"
|
|
60
|
+
"bip68": "1.0.4",
|
|
61
|
+
"@marcbachmann/cel-js": "7.0.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@types/node": "24.3.1",
|