@arkade-os/sdk 0.4.0-next.0 → 0.4.0-next.1
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 +127 -24
- package/dist/cjs/bip322/index.js +270 -0
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/intent/index.js +19 -9
- package/dist/cjs/repositories/indexedDB/contractRepository.js +1 -1
- package/dist/cjs/repositories/indexedDB/db.js +8 -46
- package/dist/cjs/repositories/indexedDB/walletRepository.js +1 -1
- package/dist/cjs/repositories/realm/contractRepository.js +120 -0
- package/dist/cjs/repositories/realm/index.js +9 -0
- package/dist/cjs/repositories/realm/schemas.js +108 -0
- package/dist/cjs/repositories/realm/types.js +7 -0
- package/dist/cjs/repositories/realm/walletRepository.js +273 -0
- package/dist/cjs/repositories/serialization.js +49 -0
- package/dist/cjs/repositories/sqlite/contractRepository.js +139 -0
- package/dist/cjs/repositories/sqlite/index.js +7 -0
- package/dist/cjs/repositories/sqlite/types.js +2 -0
- package/dist/cjs/repositories/sqlite/walletRepository.js +328 -0
- package/dist/cjs/wallet/vtxo-manager.js +7 -0
- package/dist/esm/bip322/index.js +267 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/intent/index.js +16 -7
- package/dist/esm/repositories/indexedDB/contractRepository.js +1 -1
- package/dist/esm/repositories/indexedDB/db.js +2 -40
- package/dist/esm/repositories/indexedDB/walletRepository.js +1 -1
- package/dist/esm/repositories/realm/contractRepository.js +116 -0
- package/dist/esm/repositories/realm/index.js +3 -0
- package/dist/esm/repositories/realm/schemas.js +105 -0
- package/dist/esm/repositories/realm/types.js +6 -0
- package/dist/esm/repositories/realm/walletRepository.js +269 -0
- package/dist/esm/repositories/serialization.js +40 -0
- package/dist/esm/repositories/sqlite/contractRepository.js +135 -0
- package/dist/esm/repositories/sqlite/index.js +2 -0
- package/dist/esm/repositories/sqlite/types.js +1 -0
- package/dist/esm/repositories/sqlite/walletRepository.js +324 -0
- package/dist/esm/wallet/vtxo-manager.js +7 -0
- package/dist/types/bip322/index.d.ts +55 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/intent/index.d.ts +13 -0
- package/dist/types/repositories/indexedDB/db.d.ts +2 -54
- package/dist/types/repositories/realm/contractRepository.d.ts +24 -0
- package/dist/types/repositories/realm/index.d.ts +4 -0
- package/dist/types/repositories/realm/schemas.d.ts +208 -0
- package/dist/types/repositories/realm/types.d.ts +16 -0
- package/dist/types/repositories/realm/walletRepository.d.ts +31 -0
- package/dist/types/repositories/serialization.d.ts +40 -0
- package/dist/types/repositories/sqlite/contractRepository.d.ts +33 -0
- package/dist/types/repositories/sqlite/index.d.ts +3 -0
- package/dist/types/repositories/sqlite/types.d.ts +18 -0
- package/dist/types/repositories/sqlite/walletRepository.d.ts +40 -0
- package/package.json +18 -14
- package/dist/cjs/adapters/expo-db.js +0 -35
- package/dist/esm/adapters/expo-db.js +0 -27
- package/dist/types/adapters/expo-db.d.ts +0 -7
- /package/dist/cjs/{db → repositories/indexedDB}/manager.js +0 -0
- /package/dist/esm/{db → repositories/indexedDB}/manager.js +0 -0
- /package/dist/types/{db → repositories/indexedDB}/manager.d.ts +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realm object schemas for the Ark wallet.
|
|
3
|
+
*
|
|
4
|
+
* All schema names are prefixed with "Ark" to avoid collisions with
|
|
5
|
+
* other Realm schemas in the consuming application.
|
|
6
|
+
*
|
|
7
|
+
* Since `realm` is a peer dependency (not installed in this package),
|
|
8
|
+
* schemas are defined as plain JS objects conforming to Realm's
|
|
9
|
+
* ObjectSchema shape.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ArkVtxoSchema: {
|
|
12
|
+
readonly name: "ArkVtxo";
|
|
13
|
+
readonly primaryKey: "pk";
|
|
14
|
+
readonly properties: {
|
|
15
|
+
readonly pk: "string";
|
|
16
|
+
readonly address: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly indexed: true;
|
|
19
|
+
};
|
|
20
|
+
readonly txid: "string";
|
|
21
|
+
readonly vout: "int";
|
|
22
|
+
readonly value: "int";
|
|
23
|
+
readonly tapTree: "string";
|
|
24
|
+
readonly forfeitCb: "string";
|
|
25
|
+
readonly forfeitS: "string";
|
|
26
|
+
readonly intentCb: "string";
|
|
27
|
+
readonly intentS: "string";
|
|
28
|
+
readonly extraWitnessJson: "string?";
|
|
29
|
+
readonly statusJson: "string";
|
|
30
|
+
readonly virtualStatusJson: "string";
|
|
31
|
+
readonly spentBy: "string?";
|
|
32
|
+
readonly settledBy: "string?";
|
|
33
|
+
readonly arkTxId: "string?";
|
|
34
|
+
readonly createdAt: "string";
|
|
35
|
+
readonly isUnrolled: "bool";
|
|
36
|
+
readonly isSpent: "bool?";
|
|
37
|
+
readonly assetsJson: "string?";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export declare const ArkUtxoSchema: {
|
|
41
|
+
readonly name: "ArkUtxo";
|
|
42
|
+
readonly primaryKey: "pk";
|
|
43
|
+
readonly properties: {
|
|
44
|
+
readonly pk: "string";
|
|
45
|
+
readonly address: {
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
readonly indexed: true;
|
|
48
|
+
};
|
|
49
|
+
readonly txid: "string";
|
|
50
|
+
readonly vout: "int";
|
|
51
|
+
readonly value: "int";
|
|
52
|
+
readonly tapTree: "string";
|
|
53
|
+
readonly forfeitCb: "string";
|
|
54
|
+
readonly forfeitS: "string";
|
|
55
|
+
readonly intentCb: "string";
|
|
56
|
+
readonly intentS: "string";
|
|
57
|
+
readonly extraWitnessJson: "string?";
|
|
58
|
+
readonly statusJson: "string";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare const ArkTransactionSchema: {
|
|
62
|
+
readonly name: "ArkTransaction";
|
|
63
|
+
readonly primaryKey: "pk";
|
|
64
|
+
readonly properties: {
|
|
65
|
+
readonly pk: "string";
|
|
66
|
+
readonly address: {
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
readonly indexed: true;
|
|
69
|
+
};
|
|
70
|
+
readonly boardingTxid: "string";
|
|
71
|
+
readonly commitmentTxid: "string";
|
|
72
|
+
readonly arkTxid: "string";
|
|
73
|
+
readonly type: "string";
|
|
74
|
+
readonly amount: "int";
|
|
75
|
+
readonly settled: "bool";
|
|
76
|
+
readonly createdAt: "int";
|
|
77
|
+
readonly assetsJson: "string?";
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export declare const ArkWalletStateSchema: {
|
|
81
|
+
readonly name: "ArkWalletState";
|
|
82
|
+
readonly primaryKey: "key";
|
|
83
|
+
readonly properties: {
|
|
84
|
+
readonly key: "string";
|
|
85
|
+
readonly lastSyncTime: "int?";
|
|
86
|
+
readonly settingsJson: "string?";
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export declare const ArkContractSchema: {
|
|
90
|
+
readonly name: "ArkContract";
|
|
91
|
+
readonly primaryKey: "script";
|
|
92
|
+
readonly properties: {
|
|
93
|
+
readonly script: "string";
|
|
94
|
+
readonly address: "string";
|
|
95
|
+
readonly type: {
|
|
96
|
+
readonly type: "string";
|
|
97
|
+
readonly indexed: true;
|
|
98
|
+
};
|
|
99
|
+
readonly state: {
|
|
100
|
+
readonly type: "string";
|
|
101
|
+
readonly indexed: true;
|
|
102
|
+
};
|
|
103
|
+
readonly paramsJson: "string";
|
|
104
|
+
readonly createdAt: "int";
|
|
105
|
+
readonly expiresAt: "int?";
|
|
106
|
+
readonly label: "string?";
|
|
107
|
+
readonly metadataJson: "string?";
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* All Realm schemas needed by the Ark wallet repositories.
|
|
112
|
+
* Pass this array to your Realm configuration's `schema` property.
|
|
113
|
+
*/
|
|
114
|
+
export declare const ArkRealmSchemas: ({
|
|
115
|
+
readonly name: "ArkVtxo";
|
|
116
|
+
readonly primaryKey: "pk";
|
|
117
|
+
readonly properties: {
|
|
118
|
+
readonly pk: "string";
|
|
119
|
+
readonly address: {
|
|
120
|
+
readonly type: "string";
|
|
121
|
+
readonly indexed: true;
|
|
122
|
+
};
|
|
123
|
+
readonly txid: "string";
|
|
124
|
+
readonly vout: "int";
|
|
125
|
+
readonly value: "int";
|
|
126
|
+
readonly tapTree: "string";
|
|
127
|
+
readonly forfeitCb: "string";
|
|
128
|
+
readonly forfeitS: "string";
|
|
129
|
+
readonly intentCb: "string";
|
|
130
|
+
readonly intentS: "string";
|
|
131
|
+
readonly extraWitnessJson: "string?";
|
|
132
|
+
readonly statusJson: "string";
|
|
133
|
+
readonly virtualStatusJson: "string";
|
|
134
|
+
readonly spentBy: "string?";
|
|
135
|
+
readonly settledBy: "string?";
|
|
136
|
+
readonly arkTxId: "string?";
|
|
137
|
+
readonly createdAt: "string";
|
|
138
|
+
readonly isUnrolled: "bool";
|
|
139
|
+
readonly isSpent: "bool?";
|
|
140
|
+
readonly assetsJson: "string?";
|
|
141
|
+
};
|
|
142
|
+
} | {
|
|
143
|
+
readonly name: "ArkUtxo";
|
|
144
|
+
readonly primaryKey: "pk";
|
|
145
|
+
readonly properties: {
|
|
146
|
+
readonly pk: "string";
|
|
147
|
+
readonly address: {
|
|
148
|
+
readonly type: "string";
|
|
149
|
+
readonly indexed: true;
|
|
150
|
+
};
|
|
151
|
+
readonly txid: "string";
|
|
152
|
+
readonly vout: "int";
|
|
153
|
+
readonly value: "int";
|
|
154
|
+
readonly tapTree: "string";
|
|
155
|
+
readonly forfeitCb: "string";
|
|
156
|
+
readonly forfeitS: "string";
|
|
157
|
+
readonly intentCb: "string";
|
|
158
|
+
readonly intentS: "string";
|
|
159
|
+
readonly extraWitnessJson: "string?";
|
|
160
|
+
readonly statusJson: "string";
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
readonly name: "ArkTransaction";
|
|
164
|
+
readonly primaryKey: "pk";
|
|
165
|
+
readonly properties: {
|
|
166
|
+
readonly pk: "string";
|
|
167
|
+
readonly address: {
|
|
168
|
+
readonly type: "string";
|
|
169
|
+
readonly indexed: true;
|
|
170
|
+
};
|
|
171
|
+
readonly boardingTxid: "string";
|
|
172
|
+
readonly commitmentTxid: "string";
|
|
173
|
+
readonly arkTxid: "string";
|
|
174
|
+
readonly type: "string";
|
|
175
|
+
readonly amount: "int";
|
|
176
|
+
readonly settled: "bool";
|
|
177
|
+
readonly createdAt: "int";
|
|
178
|
+
readonly assetsJson: "string?";
|
|
179
|
+
};
|
|
180
|
+
} | {
|
|
181
|
+
readonly name: "ArkWalletState";
|
|
182
|
+
readonly primaryKey: "key";
|
|
183
|
+
readonly properties: {
|
|
184
|
+
readonly key: "string";
|
|
185
|
+
readonly lastSyncTime: "int?";
|
|
186
|
+
readonly settingsJson: "string?";
|
|
187
|
+
};
|
|
188
|
+
} | {
|
|
189
|
+
readonly name: "ArkContract";
|
|
190
|
+
readonly primaryKey: "script";
|
|
191
|
+
readonly properties: {
|
|
192
|
+
readonly script: "string";
|
|
193
|
+
readonly address: "string";
|
|
194
|
+
readonly type: {
|
|
195
|
+
readonly type: "string";
|
|
196
|
+
readonly indexed: true;
|
|
197
|
+
};
|
|
198
|
+
readonly state: {
|
|
199
|
+
readonly type: "string";
|
|
200
|
+
readonly indexed: true;
|
|
201
|
+
};
|
|
202
|
+
readonly paramsJson: "string";
|
|
203
|
+
readonly createdAt: "int";
|
|
204
|
+
readonly expiresAt: "int?";
|
|
205
|
+
readonly label: "string?";
|
|
206
|
+
readonly metadataJson: "string?";
|
|
207
|
+
};
|
|
208
|
+
})[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal interface for the subset of the Realm API used by the
|
|
3
|
+
* Ark repositories. Consumers pass their real Realm instance and
|
|
4
|
+
* the compiler validates it satisfies this shape.
|
|
5
|
+
*/
|
|
6
|
+
/** Result set returned by `realm.objects()`. */
|
|
7
|
+
export interface RealmResults<T = Record<string, unknown>> extends Iterable<T> {
|
|
8
|
+
filtered(query: string, ...args: unknown[]): RealmResults<T>;
|
|
9
|
+
}
|
|
10
|
+
/** The Realm API surface used by Ark repositories. */
|
|
11
|
+
export interface RealmLike {
|
|
12
|
+
write(callback: () => void): void;
|
|
13
|
+
objects<T = Record<string, unknown>>(schemaName: string): RealmResults<T>;
|
|
14
|
+
create(schemaName: string, values: Record<string, any>, mode?: string): void;
|
|
15
|
+
delete(objects: unknown): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ArkTransaction, ExtendedCoin, ExtendedVirtualCoin } from "../../wallet";
|
|
2
|
+
import { WalletRepository, WalletState } from "../walletRepository";
|
|
3
|
+
import { RealmLike } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Realm-based implementation of WalletRepository.
|
|
6
|
+
*
|
|
7
|
+
* Consumers must open Realm with the schemas from `./schemas.ts` and pass
|
|
8
|
+
* the instance to the constructor.
|
|
9
|
+
*
|
|
10
|
+
* Realm handles schema creation on open, so `ensureInit()` is a no-op.
|
|
11
|
+
* The consumer owns the Realm lifecycle — `[Symbol.asyncDispose]` is a no-op.
|
|
12
|
+
*/
|
|
13
|
+
export declare class RealmWalletRepository implements WalletRepository {
|
|
14
|
+
private readonly realm;
|
|
15
|
+
readonly version: 1;
|
|
16
|
+
constructor(realm: RealmLike);
|
|
17
|
+
private ensureInit;
|
|
18
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
19
|
+
clear(): Promise<void>;
|
|
20
|
+
getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
|
|
21
|
+
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
22
|
+
deleteVtxos(address: string): Promise<void>;
|
|
23
|
+
getUtxos(address: string): Promise<ExtendedCoin[]>;
|
|
24
|
+
saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
|
|
25
|
+
deleteUtxos(address: string): Promise<void>;
|
|
26
|
+
getTransactionHistory(address: string): Promise<ArkTransaction[]>;
|
|
27
|
+
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
28
|
+
deleteTransactions(address: string): Promise<void>;
|
|
29
|
+
getWalletState(): Promise<WalletState | null>;
|
|
30
|
+
saveWalletState(state: WalletState): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TapLeafScript } from "../script/base";
|
|
2
|
+
import { ExtendedCoin, ExtendedVirtualCoin } from "../wallet";
|
|
3
|
+
export type SerializedTapLeaf = {
|
|
4
|
+
cb: string;
|
|
5
|
+
s: string;
|
|
6
|
+
};
|
|
7
|
+
export type SerializedVtxo = ReturnType<typeof serializeVtxo>;
|
|
8
|
+
export type SerializedUtxo = ReturnType<typeof serializeUtxo>;
|
|
9
|
+
export declare const serializeTapLeaf: ([cb, s,]: TapLeafScript) => SerializedTapLeaf;
|
|
10
|
+
export declare const serializeVtxo: (v: ExtendedVirtualCoin) => {
|
|
11
|
+
tapTree: string;
|
|
12
|
+
forfeitTapLeafScript: SerializedTapLeaf;
|
|
13
|
+
intentTapLeafScript: SerializedTapLeaf;
|
|
14
|
+
extraWitness: string[] | undefined;
|
|
15
|
+
virtualStatus: import("../wallet").VirtualStatus;
|
|
16
|
+
spentBy?: string;
|
|
17
|
+
settledBy?: string;
|
|
18
|
+
arkTxId?: string;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
isUnrolled: boolean;
|
|
21
|
+
isSpent?: boolean;
|
|
22
|
+
assets?: import("../wallet").Asset[];
|
|
23
|
+
value: number;
|
|
24
|
+
status: import("../wallet").Status;
|
|
25
|
+
txid: string;
|
|
26
|
+
vout: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const serializeUtxo: (u: ExtendedCoin) => {
|
|
29
|
+
tapTree: string;
|
|
30
|
+
forfeitTapLeafScript: SerializedTapLeaf;
|
|
31
|
+
intentTapLeafScript: SerializedTapLeaf;
|
|
32
|
+
extraWitness: string[] | undefined;
|
|
33
|
+
value: number;
|
|
34
|
+
status: import("../wallet").Status;
|
|
35
|
+
txid: string;
|
|
36
|
+
vout: number;
|
|
37
|
+
};
|
|
38
|
+
export declare const deserializeTapLeaf: (t: SerializedTapLeaf) => TapLeafScript;
|
|
39
|
+
export declare const deserializeVtxo: (o: SerializedVtxo) => ExtendedVirtualCoin;
|
|
40
|
+
export declare const deserializeUtxo: (o: SerializedUtxo) => ExtendedCoin;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Contract } from "../../contracts/types";
|
|
2
|
+
import { ContractFilter, ContractRepository } from "../contractRepository";
|
|
3
|
+
import { SQLExecutor } from "./types";
|
|
4
|
+
interface SQLiteContractRepositoryOptions {
|
|
5
|
+
/** Table name prefix (default: "ark_") */
|
|
6
|
+
prefix?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* SQLite-based implementation of ContractRepository.
|
|
10
|
+
*
|
|
11
|
+
* Uses the SQLExecutor interface so consumers can plug in any SQLite driver
|
|
12
|
+
* (expo-sqlite, better-sqlite3, etc.).
|
|
13
|
+
*
|
|
14
|
+
* Tables are created lazily on first operation via `ensureInit()`.
|
|
15
|
+
* The consumer owns the SQLExecutor lifecycle — `[Symbol.asyncDispose]` is a no-op.
|
|
16
|
+
*/
|
|
17
|
+
export declare class SQLiteContractRepository implements ContractRepository {
|
|
18
|
+
private readonly db;
|
|
19
|
+
readonly version: 1;
|
|
20
|
+
private initPromise;
|
|
21
|
+
private readonly prefix;
|
|
22
|
+
private readonly table;
|
|
23
|
+
constructor(db: SQLExecutor, options?: SQLiteContractRepositoryOptions);
|
|
24
|
+
private ensureInit;
|
|
25
|
+
private init;
|
|
26
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
27
|
+
clear(): Promise<void>;
|
|
28
|
+
getContracts(filter?: ContractFilter): Promise<Contract[]>;
|
|
29
|
+
saveContract(contract: Contract): Promise<void>;
|
|
30
|
+
deleteContract(script: string): Promise<void>;
|
|
31
|
+
private addFilterCondition;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal SQL execution interface that consumers implement
|
|
3
|
+
* to connect their SQLite (or any SQL) database to the SDK.
|
|
4
|
+
*
|
|
5
|
+
* Example for expo-sqlite:
|
|
6
|
+
* ```
|
|
7
|
+
* const executor: SQLExecutor = {
|
|
8
|
+
* run: (sql, params) => db.runAsync(sql, params ?? []),
|
|
9
|
+
* get: (sql, params) => db.getFirstAsync(sql, params ?? []),
|
|
10
|
+
* all: (sql, params) => db.getAllAsync(sql, params ?? []),
|
|
11
|
+
* };
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export interface SQLExecutor {
|
|
15
|
+
run(sql: string, params?: unknown[]): Promise<void>;
|
|
16
|
+
get<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T | undefined>;
|
|
17
|
+
all<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ArkTransaction, ExtendedCoin, ExtendedVirtualCoin } from "../../wallet";
|
|
2
|
+
import { WalletRepository, WalletState } from "../walletRepository";
|
|
3
|
+
import { SQLExecutor } from "./types";
|
|
4
|
+
interface SQLiteWalletRepositoryOptions {
|
|
5
|
+
/** Table name prefix (default: "ark_") */
|
|
6
|
+
prefix?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* SQLite-based implementation of WalletRepository.
|
|
10
|
+
*
|
|
11
|
+
* Uses the SQLExecutor interface so consumers can plug in any SQLite driver
|
|
12
|
+
* (expo-sqlite, better-sqlite3, etc.).
|
|
13
|
+
*
|
|
14
|
+
* Tables are created lazily on first operation via `ensureInit()`.
|
|
15
|
+
* The consumer owns the SQLExecutor lifecycle — `[Symbol.asyncDispose]` is a no-op.
|
|
16
|
+
*/
|
|
17
|
+
export declare class SQLiteWalletRepository implements WalletRepository {
|
|
18
|
+
private readonly db;
|
|
19
|
+
readonly version: 1;
|
|
20
|
+
private initPromise;
|
|
21
|
+
private readonly prefix;
|
|
22
|
+
private readonly tables;
|
|
23
|
+
constructor(db: SQLExecutor, options?: SQLiteWalletRepositoryOptions);
|
|
24
|
+
private ensureInit;
|
|
25
|
+
private init;
|
|
26
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
27
|
+
clear(): Promise<void>;
|
|
28
|
+
getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
|
|
29
|
+
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
30
|
+
deleteVtxos(address: string): Promise<void>;
|
|
31
|
+
getUtxos(address: string): Promise<ExtendedCoin[]>;
|
|
32
|
+
saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
|
|
33
|
+
deleteUtxos(address: string): Promise<void>;
|
|
34
|
+
getTransactionHistory(address: string): Promise<ArkTransaction[]>;
|
|
35
|
+
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
36
|
+
deleteTransactions(address: string): Promise<void>;
|
|
37
|
+
getWalletState(): Promise<WalletState | null>;
|
|
38
|
+
saveWalletState(state: WalletState): Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkade-os/sdk",
|
|
3
|
-
"version": "0.4.0-next.
|
|
3
|
+
"version": "0.4.0-next.1",
|
|
4
4
|
"description": "Bitcoin wallet SDK with Taproot and Ark integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -23,12 +23,6 @@
|
|
|
23
23
|
"require": "./dist/cjs/adapters/expo.js",
|
|
24
24
|
"default": "./dist/esm/adapters/expo.js"
|
|
25
25
|
},
|
|
26
|
-
"./adapters/expo-db": {
|
|
27
|
-
"types": "./dist/types/adapters/expo-db.d.ts",
|
|
28
|
-
"import": "./dist/esm/adapters/expo-db.js",
|
|
29
|
-
"require": "./dist/cjs/adapters/expo-db.js",
|
|
30
|
-
"default": "./dist/esm/adapters/expo-db.js"
|
|
31
|
-
},
|
|
32
26
|
"./adapters/localStorage": {
|
|
33
27
|
"types": "./dist/types/adapters/localStorage.d.ts",
|
|
34
28
|
"import": "./dist/esm/adapters/localStorage.js",
|
|
@@ -53,6 +47,18 @@
|
|
|
53
47
|
"require": "./dist/cjs/adapters/asyncStorage.js",
|
|
54
48
|
"default": "./dist/esm/adapters/asyncStorage.js"
|
|
55
49
|
},
|
|
50
|
+
"./repositories/sqlite": {
|
|
51
|
+
"types": "./dist/types/repositories/sqlite/index.d.ts",
|
|
52
|
+
"import": "./dist/esm/repositories/sqlite/index.js",
|
|
53
|
+
"require": "./dist/cjs/repositories/sqlite/index.js",
|
|
54
|
+
"default": "./dist/esm/repositories/sqlite/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./repositories/realm": {
|
|
57
|
+
"types": "./dist/types/repositories/realm/index.d.ts",
|
|
58
|
+
"import": "./dist/esm/repositories/realm/index.js",
|
|
59
|
+
"require": "./dist/cjs/repositories/realm/index.js",
|
|
60
|
+
"default": "./dist/esm/repositories/realm/index.js"
|
|
61
|
+
},
|
|
56
62
|
"./worker/expo": {
|
|
57
63
|
"types": "./dist/types/worker/expo/index.d.ts",
|
|
58
64
|
"import": "./dist/esm/worker/expo/index.js",
|
|
@@ -85,8 +91,10 @@
|
|
|
85
91
|
"bip68": "1.0.4"
|
|
86
92
|
},
|
|
87
93
|
"devDependencies": {
|
|
94
|
+
"@types/better-sqlite3": "7.6.13",
|
|
88
95
|
"@types/node": "24.3.1",
|
|
89
96
|
"@vitest/coverage-v8": "3.2.4",
|
|
97
|
+
"better-sqlite3": "12.6.2",
|
|
90
98
|
"esbuild": "^0.27.3",
|
|
91
99
|
"eventsource": "4.0.0",
|
|
92
100
|
"glob": "11.1.0",
|
|
@@ -99,17 +107,13 @@
|
|
|
99
107
|
"vitest": "3.2.4"
|
|
100
108
|
},
|
|
101
109
|
"peerDependencies": {
|
|
102
|
-
"
|
|
110
|
+
"@react-native-async-storage/async-storage": ">=1.0.0",
|
|
103
111
|
"expo": ">=54.0.0",
|
|
104
|
-
"expo-sqlite": "~16.0.10",
|
|
105
112
|
"expo-background-task": "~1.0.10",
|
|
106
|
-
"expo-
|
|
107
|
-
"
|
|
113
|
+
"expo-sqlite": "~16.0.10",
|
|
114
|
+
"expo-task-manager": "~14.0.9"
|
|
108
115
|
},
|
|
109
116
|
"peerDependenciesMeta": {
|
|
110
|
-
"indexeddbshim": {
|
|
111
|
-
"optional": true
|
|
112
|
-
},
|
|
113
117
|
"expo": {
|
|
114
118
|
"optional": true
|
|
115
119
|
},
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.openDatabase = void 0;
|
|
7
|
-
exports.setupExpoDb = setupExpoDb;
|
|
8
|
-
// Expo IndexedDB polyfill — requires expo-sqlite and indexeddbshim.
|
|
9
|
-
//
|
|
10
|
-
// Separated from ./expo so that consumers who only need the streaming
|
|
11
|
-
// providers (ExpoArkProvider, ExpoIndexerProvider) don't pull in a
|
|
12
|
-
// hard dependency on expo-sqlite at bundle time.
|
|
13
|
-
const indexeddbshim_1 = __importDefault(require("indexeddbshim"));
|
|
14
|
-
const websqlAdapter_1 = require("../repositories/indexedDB/websqlAdapter");
|
|
15
|
-
var websqlAdapter_2 = require("../repositories/indexedDB/websqlAdapter");
|
|
16
|
-
Object.defineProperty(exports, "openDatabase", { enumerable: true, get: function () { return websqlAdapter_2.openDatabase; } });
|
|
17
|
-
let _initialized = false;
|
|
18
|
-
function setupExpoDb(options) {
|
|
19
|
-
if (_initialized)
|
|
20
|
-
return;
|
|
21
|
-
const { origin = "expo://localhost", checkOrigin = false, cacheDatabaseInstances = true, } = options ?? {};
|
|
22
|
-
if (typeof globalThis.window === "undefined") {
|
|
23
|
-
globalThis.window = globalThis;
|
|
24
|
-
}
|
|
25
|
-
if (typeof globalThis.location === "undefined") {
|
|
26
|
-
globalThis.location = { origin };
|
|
27
|
-
}
|
|
28
|
-
globalThis.openDatabase = websqlAdapter_1.openDatabase;
|
|
29
|
-
(0, indexeddbshim_1.default)(globalThis, {
|
|
30
|
-
checkOrigin,
|
|
31
|
-
useSQLiteIndexes: true,
|
|
32
|
-
cacheDatabaseInstances,
|
|
33
|
-
});
|
|
34
|
-
_initialized = true;
|
|
35
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Expo IndexedDB polyfill — requires expo-sqlite and indexeddbshim.
|
|
2
|
-
//
|
|
3
|
-
// Separated from ./expo so that consumers who only need the streaming
|
|
4
|
-
// providers (ExpoArkProvider, ExpoIndexerProvider) don't pull in a
|
|
5
|
-
// hard dependency on expo-sqlite at bundle time.
|
|
6
|
-
import setGlobalVars from "indexeddbshim";
|
|
7
|
-
import { openDatabase } from '../repositories/indexedDB/websqlAdapter.js';
|
|
8
|
-
export { openDatabase } from '../repositories/indexedDB/websqlAdapter.js';
|
|
9
|
-
let _initialized = false;
|
|
10
|
-
export function setupExpoDb(options) {
|
|
11
|
-
if (_initialized)
|
|
12
|
-
return;
|
|
13
|
-
const { origin = "expo://localhost", checkOrigin = false, cacheDatabaseInstances = true, } = options ?? {};
|
|
14
|
-
if (typeof globalThis.window === "undefined") {
|
|
15
|
-
globalThis.window = globalThis;
|
|
16
|
-
}
|
|
17
|
-
if (typeof globalThis.location === "undefined") {
|
|
18
|
-
globalThis.location = { origin };
|
|
19
|
-
}
|
|
20
|
-
globalThis.openDatabase = openDatabase;
|
|
21
|
-
setGlobalVars(globalThis, {
|
|
22
|
-
checkOrigin,
|
|
23
|
-
useSQLiteIndexes: true,
|
|
24
|
-
cacheDatabaseInstances,
|
|
25
|
-
});
|
|
26
|
-
_initialized = true;
|
|
27
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { openDatabase } from "../repositories/indexedDB/websqlAdapter";
|
|
2
|
-
export interface SetupExpoDbOptions {
|
|
3
|
-
origin?: string;
|
|
4
|
-
checkOrigin?: boolean;
|
|
5
|
-
cacheDatabaseInstances?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function setupExpoDb(options?: SetupExpoDbOptions): void;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|