@gardenfi/wallet-connectors 3.0.0-beta.21 → 3.0.0-beta.22
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/dist/index10.cjs +1 -1
- package/dist/index10.js +57 -36
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +80 -55
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +74 -101
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +56 -71
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +83 -45
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +3 -35
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +2 -3
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +2 -2
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +5 -5
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +35 -2
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +43 -85
- package/package.json +3 -3
package/dist/index9.js
CHANGED
|
@@ -1,106 +1,64 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y = (e) => {
|
|
2
2
|
throw TypeError(e);
|
|
3
3
|
};
|
|
4
|
-
var g = (e, t, r) => t.has(e) ||
|
|
5
|
-
var
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function N(e, t, r = []) {
|
|
15
|
-
return new Promise((s, a) => {
|
|
16
|
-
e.request({ method: t, params: r }, (h, T) => {
|
|
17
|
-
h ? a(h) : s(T);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
var c, n;
|
|
22
|
-
class q {
|
|
23
|
-
constructor(t) {
|
|
24
|
-
w(this, c);
|
|
25
|
-
w(this, n);
|
|
26
|
-
this.address = "", this.id = f.Ctrl.id, this.name = f.Ctrl.name, this.icon = f.Ctrl.icon, this.sendLitecoin = async (r, s) => {
|
|
27
|
-
try {
|
|
28
|
-
if (!this.address) {
|
|
29
|
-
const h = await this.requestAccounts();
|
|
30
|
-
if (!h.ok || h.val.length === 0)
|
|
31
|
-
return o("No connected account to send from");
|
|
32
|
-
}
|
|
33
|
-
const a = await N(
|
|
34
|
-
i(this, c),
|
|
35
|
-
"transfer",
|
|
36
|
-
[
|
|
37
|
-
{
|
|
38
|
-
feeRate: 10,
|
|
39
|
-
from: this.address,
|
|
40
|
-
recipient: r,
|
|
41
|
-
amount: {
|
|
42
|
-
amount: s,
|
|
43
|
-
decimals: 8
|
|
44
|
-
},
|
|
45
|
-
memo: ""
|
|
46
|
-
}
|
|
47
|
-
]
|
|
48
|
-
);
|
|
49
|
-
return u(a);
|
|
50
|
-
} catch (a) {
|
|
51
|
-
return o(
|
|
52
|
-
`Error while sending Litecoin: ${a instanceof Error ? a.message : String(a)}`
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
}, this.on = (r, s) => i(this, c).on(r, s), this.off = (r, s) => i(this, c).off(r, s), this.disconnect = () => (this.address = "", Promise.resolve(u("Disconnected CTRL wallet"))), d(this, c, t), d(this, n, l.MAINNET);
|
|
4
|
+
var g = (e, t, r) => t.has(e) || y("Cannot " + r);
|
|
5
|
+
var n = (e, t, r) => (g(e, t, "read from private field"), r ? r.call(e) : t.get(e)), d = (e, t, r) => t.has(e) ? y("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), a = (e, t, r, w) => (g(e, t, "write to private field"), w ? w.call(e, r) : t.set(e, r), r);
|
|
6
|
+
import { Ok as c, Err as o, executeWithTryCatch as h, Network as l } from "@gardenfi/utils";
|
|
7
|
+
import { WALLET_CONFIG as u } from "./index3.js";
|
|
8
|
+
var i, s;
|
|
9
|
+
class E {
|
|
10
|
+
constructor(t, r) {
|
|
11
|
+
d(this, i);
|
|
12
|
+
d(this, s);
|
|
13
|
+
this.address = "", this.id = u.OKX.id, this.name = u.OKX.name, this.icon = u.OKX.icon, this.disconnect = () => (this.address = "", n(this, i).disconnect(), Promise.resolve(c("Disconnected OKX wallet"))), a(this, i, t), a(this, s, r);
|
|
56
14
|
}
|
|
57
|
-
async connect(
|
|
15
|
+
async connect() {
|
|
58
16
|
try {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
return o("CTRL wallet Litecoin provider not found");
|
|
62
|
-
d(this, c, r), t || (t = l.MAINNET), d(this, n, t);
|
|
63
|
-
const s = await this.requestAccounts();
|
|
64
|
-
return s.ok ? s.val.length === 0 ? o("No accounts found in CTRL wallet") : (this.address = s.val[0], u({
|
|
17
|
+
const t = await n(this, i).connect();
|
|
18
|
+
return !t || !t.address ? o("Failed to connect to OKX wallet") : (this.address = t.address, c({
|
|
65
19
|
address: this.address,
|
|
66
20
|
provider: this,
|
|
67
|
-
network:
|
|
68
|
-
id:
|
|
69
|
-
}))
|
|
70
|
-
} catch (
|
|
71
|
-
return o("Error while connecting to the
|
|
21
|
+
network: n(this, s),
|
|
22
|
+
id: u.OKX.id
|
|
23
|
+
}));
|
|
24
|
+
} catch (t) {
|
|
25
|
+
return o("Error while connecting to the OKX wallet", t);
|
|
72
26
|
}
|
|
73
27
|
}
|
|
28
|
+
async getPublicKey() {
|
|
29
|
+
return await h(async () => await n(this, i).getPublicKey(), "Error while getting public key from OKX wallet");
|
|
30
|
+
}
|
|
74
31
|
async requestAccounts() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
i(this, c),
|
|
78
|
-
"request_accounts"
|
|
79
|
-
);
|
|
80
|
-
return t && t.length > 0 && (this.address = t[0]), u(t);
|
|
81
|
-
} catch {
|
|
82
|
-
return o("Error while requesting accounts from the CTRL wallet");
|
|
83
|
-
}
|
|
32
|
+
const t = await this.connect();
|
|
33
|
+
return t.ok ? c([t.val.address]) : o(t.error);
|
|
84
34
|
}
|
|
85
35
|
async getAccounts() {
|
|
86
|
-
return this.requestAccounts();
|
|
36
|
+
return n(this, s) === l.TESTNET ? await this.requestAccounts() : await h(async () => await n(this, i).getAccounts(), "Error while getting accounts from OKX wallet");
|
|
87
37
|
}
|
|
88
38
|
async getNetwork() {
|
|
89
|
-
return
|
|
39
|
+
return c(n(this, s));
|
|
90
40
|
}
|
|
91
41
|
async switchNetwork() {
|
|
92
|
-
|
|
93
|
-
const t = await this.
|
|
94
|
-
return t.
|
|
42
|
+
a(this, s, n(this, s) === l.MAINNET ? l.TESTNET : l.MAINNET);
|
|
43
|
+
const t = await this.connect();
|
|
44
|
+
return t.error ? o(
|
|
45
|
+
`Failed to connect to ${n(this, s)}: ${t.error}`
|
|
46
|
+
) : c(n(this, s));
|
|
95
47
|
}
|
|
96
48
|
async getBalance() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return
|
|
49
|
+
return await h(async () => await n(this, i).getBalance(), "Error while getting balance from OKX wallet");
|
|
50
|
+
}
|
|
51
|
+
async sendBitcoin(t, r) {
|
|
52
|
+
return await h(async () => await n(this, i).sendBitcoin(t, r), "Error while sending bitcoin from OKX wallet");
|
|
53
|
+
}
|
|
54
|
+
on(t, r) {
|
|
55
|
+
n(this, i).on(t, r);
|
|
56
|
+
}
|
|
57
|
+
off(t, r) {
|
|
58
|
+
n(this, i).off(t, r);
|
|
101
59
|
}
|
|
102
60
|
}
|
|
103
|
-
|
|
61
|
+
i = new WeakMap(), s = new WeakMap();
|
|
104
62
|
export {
|
|
105
|
-
|
|
63
|
+
E as OKXProvider
|
|
106
64
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/wallet-connectors",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@gardenfi/core": "3.1.3-beta.
|
|
41
|
-
"@gardenfi/utils": "3.1.1-beta.
|
|
40
|
+
"@gardenfi/core": "3.1.3-beta.10",
|
|
41
|
+
"@gardenfi/utils": "3.1.1-beta.8",
|
|
42
42
|
"axios": "^1.7.9",
|
|
43
43
|
"bitcoinjs-lib": "^6.1.7",
|
|
44
44
|
"bitcore-lib-ltc": "^10.10.5",
|