@arkade-os/sdk 0.1.2 → 0.1.4
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.
|
@@ -6,28 +6,10 @@ async function setupServiceWorker(path) {
|
|
|
6
6
|
if (!("serviceWorker" in navigator)) {
|
|
7
7
|
throw new Error("Service workers are not supported in this browser");
|
|
8
8
|
}
|
|
9
|
-
//
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
registration = existingRegistration;
|
|
14
|
-
// Force unregister and re-register to ensure we get the latest version
|
|
15
|
-
await existingRegistration.unregister();
|
|
16
|
-
}
|
|
17
|
-
registration = await navigator.serviceWorker.register(path);
|
|
18
|
-
// Handle updates
|
|
19
|
-
registration.addEventListener("updatefound", () => {
|
|
20
|
-
const newWorker = registration.installing;
|
|
21
|
-
if (!newWorker)
|
|
22
|
-
return;
|
|
23
|
-
newWorker.addEventListener("statechange", () => {
|
|
24
|
-
if (newWorker.state === "activated" &&
|
|
25
|
-
navigator.serviceWorker.controller) {
|
|
26
|
-
console.info("Service worker activated, reloading...");
|
|
27
|
-
window.location.reload();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
9
|
+
// register service worker
|
|
10
|
+
const registration = await navigator.serviceWorker.register(path);
|
|
11
|
+
// force update to ensure the service worker is active
|
|
12
|
+
registration.update();
|
|
31
13
|
const serviceWorker = registration.active || registration.waiting || registration.installing;
|
|
32
14
|
if (!serviceWorker) {
|
|
33
15
|
throw new Error("Failed to get service worker instance");
|
|
@@ -37,11 +19,7 @@ async function setupServiceWorker(path) {
|
|
|
37
19
|
await new Promise((resolve) => {
|
|
38
20
|
if (!serviceWorker)
|
|
39
21
|
return resolve();
|
|
40
|
-
serviceWorker.addEventListener("
|
|
41
|
-
if (serviceWorker.state === "activated") {
|
|
42
|
-
resolve();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
22
|
+
serviceWorker.addEventListener("activate", () => resolve());
|
|
45
23
|
});
|
|
46
24
|
}
|
|
47
25
|
return serviceWorker;
|
|
@@ -327,9 +327,6 @@ class Wallet {
|
|
|
327
327
|
if (params.amount <= 0) {
|
|
328
328
|
throw new Error("Amount must be positive");
|
|
329
329
|
}
|
|
330
|
-
if (params.amount < Wallet.DUST_AMOUNT) {
|
|
331
|
-
throw new Error("Amount is below dust limit");
|
|
332
|
-
}
|
|
333
330
|
// If Ark is configured and amount is suitable, send via offchain
|
|
334
331
|
if (this.arkProvider && this.isOffchainSuitable(params.address)) {
|
|
335
332
|
return this.sendOffchain(params, zeroFee);
|
|
@@ -756,6 +753,4 @@ class Wallet {
|
|
|
756
753
|
}
|
|
757
754
|
}
|
|
758
755
|
exports.Wallet = Wallet;
|
|
759
|
-
// TODO get dust from ark server?
|
|
760
|
-
Wallet.DUST_AMOUNT = BigInt(546); // Bitcoin dust limit in satoshis = 546
|
|
761
756
|
Wallet.FEE_RATE = 1; // sats/vbyte
|
|
@@ -3,28 +3,10 @@ export async function setupServiceWorker(path) {
|
|
|
3
3
|
if (!("serviceWorker" in navigator)) {
|
|
4
4
|
throw new Error("Service workers are not supported in this browser");
|
|
5
5
|
}
|
|
6
|
-
//
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
registration = existingRegistration;
|
|
11
|
-
// Force unregister and re-register to ensure we get the latest version
|
|
12
|
-
await existingRegistration.unregister();
|
|
13
|
-
}
|
|
14
|
-
registration = await navigator.serviceWorker.register(path);
|
|
15
|
-
// Handle updates
|
|
16
|
-
registration.addEventListener("updatefound", () => {
|
|
17
|
-
const newWorker = registration.installing;
|
|
18
|
-
if (!newWorker)
|
|
19
|
-
return;
|
|
20
|
-
newWorker.addEventListener("statechange", () => {
|
|
21
|
-
if (newWorker.state === "activated" &&
|
|
22
|
-
navigator.serviceWorker.controller) {
|
|
23
|
-
console.info("Service worker activated, reloading...");
|
|
24
|
-
window.location.reload();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
6
|
+
// register service worker
|
|
7
|
+
const registration = await navigator.serviceWorker.register(path);
|
|
8
|
+
// force update to ensure the service worker is active
|
|
9
|
+
registration.update();
|
|
28
10
|
const serviceWorker = registration.active || registration.waiting || registration.installing;
|
|
29
11
|
if (!serviceWorker) {
|
|
30
12
|
throw new Error("Failed to get service worker instance");
|
|
@@ -34,11 +16,7 @@ export async function setupServiceWorker(path) {
|
|
|
34
16
|
await new Promise((resolve) => {
|
|
35
17
|
if (!serviceWorker)
|
|
36
18
|
return resolve();
|
|
37
|
-
serviceWorker.addEventListener("
|
|
38
|
-
if (serviceWorker.state === "activated") {
|
|
39
|
-
resolve();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
19
|
+
serviceWorker.addEventListener("activate", () => resolve());
|
|
42
20
|
});
|
|
43
21
|
}
|
|
44
22
|
return serviceWorker;
|
|
@@ -324,9 +324,6 @@ export class Wallet {
|
|
|
324
324
|
if (params.amount <= 0) {
|
|
325
325
|
throw new Error("Amount must be positive");
|
|
326
326
|
}
|
|
327
|
-
if (params.amount < Wallet.DUST_AMOUNT) {
|
|
328
|
-
throw new Error("Amount is below dust limit");
|
|
329
|
-
}
|
|
330
327
|
// If Ark is configured and amount is suitable, send via offchain
|
|
331
328
|
if (this.arkProvider && this.isOffchainSuitable(params.address)) {
|
|
332
329
|
return this.sendOffchain(params, zeroFee);
|
|
@@ -752,6 +749,4 @@ export class Wallet {
|
|
|
752
749
|
: undefined);
|
|
753
750
|
}
|
|
754
751
|
}
|
|
755
|
-
// TODO get dust from ark server?
|
|
756
|
-
Wallet.DUST_AMOUNT = BigInt(546); // Bitcoin dust limit in satoshis = 546
|
|
757
752
|
Wallet.FEE_RATE = 1; // sats/vbyte
|
|
@@ -11,7 +11,6 @@ export declare class Wallet implements IWallet {
|
|
|
11
11
|
private arkServerPublicKey?;
|
|
12
12
|
readonly offchainTapscript?: DefaultVtxo.Script | undefined;
|
|
13
13
|
readonly boardingTapscript?: DefaultVtxo.Script | undefined;
|
|
14
|
-
static DUST_AMOUNT: bigint;
|
|
15
14
|
static FEE_RATE: number;
|
|
16
15
|
private constructor();
|
|
17
16
|
static create(config: WalletConfig): Promise<Wallet>;
|