@swapkit/wallets 4.3.10 → 4.6.0
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/LICENSE +246 -0
- package/dist/chunk-1m30h0t9.js +4 -0
- package/dist/{chunk-vb4wtm2w.js.map → chunk-1m30h0t9.js.map} +1 -1
- package/dist/chunk-5jj4jvy9.js +5 -0
- package/dist/{chunk-78m70510.js.map → chunk-5jj4jvy9.js.map} +1 -1
- package/dist/chunk-ae6bkfs5.js +3 -0
- package/dist/chunk-ae6bkfs5.js.map +9 -0
- package/dist/chunk-dx5r3mz1.js +5 -0
- package/dist/chunk-dx5r3mz1.js.map +10 -0
- package/dist/chunk-ewwx4745.js +4 -0
- package/dist/chunk-ewwx4745.js.map +9 -0
- package/dist/chunk-qv7snmdv.js +5 -0
- package/dist/chunk-qv7snmdv.js.map +10 -0
- package/dist/chunk-ttryb513.js +4 -0
- package/dist/chunk-ttryb513.js.map +10 -0
- package/dist/chunk-zrqsb6ng.js +4 -0
- package/dist/chunk-zrqsb6ng.js.map +10 -0
- package/dist/src/coinbase/index.cjs +2 -2
- package/dist/src/coinbase/index.cjs.map +4 -4
- package/dist/src/coinbase/index.js +2 -2
- package/dist/src/coinbase/index.js.map +4 -4
- package/dist/src/index.cjs +2 -2
- package/dist/src/index.cjs.map +4 -5
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +4 -5
- package/dist/src/keystore.cjs +2 -2
- package/dist/src/keystore.cjs.map +5 -4
- package/dist/src/keystore.js +2 -2
- package/dist/src/keystore.js.map +5 -4
- package/dist/src/near-wallet-selector/index.cjs +2 -2
- package/dist/src/near-wallet-selector/index.cjs.map +3 -3
- package/dist/src/near-wallet-selector/index.js +2 -2
- package/dist/src/near-wallet-selector/index.js.map +3 -3
- package/dist/src/passkeys/index.cjs +2 -2
- package/dist/src/passkeys/index.cjs.map +3 -3
- package/dist/src/passkeys/index.js +2 -2
- package/dist/src/passkeys/index.js.map +3 -3
- package/dist/src/radix/index.cjs +2 -2
- package/dist/src/radix/index.cjs.map +3 -3
- package/dist/src/radix/index.js +2 -2
- package/dist/src/radix/index.js.map +3 -3
- package/dist/src/walletconnect/index.cjs +2 -2
- package/dist/src/walletconnect/index.cjs.map +4 -4
- package/dist/src/walletconnect/index.js +2 -2
- package/dist/src/walletconnect/index.js.map +4 -4
- package/dist/src/xaman/index.cjs +2 -2
- package/dist/src/xaman/index.cjs.map +5 -5
- package/dist/src/xaman/index.js +2 -2
- package/dist/src/xaman/index.js.map +5 -5
- package/dist/types/coinbase/signer.d.ts +58 -23
- package/dist/types/coinbase/signer.d.ts.map +1 -1
- package/dist/types/core.d.ts +18 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/keystore-helpers.d.ts +42 -0
- package/dist/types/keystore-helpers.d.ts.map +1 -0
- package/dist/types/keystore.d.ts +66 -1
- package/dist/types/keystore.d.ts.map +1 -1
- package/dist/types/passkeys/index.d.ts +2 -2
- package/dist/types/passkeys/index.d.ts.map +1 -1
- package/dist/types/radix/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +6 -4
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/walletconnect/constants.d.ts +2 -1
- package/dist/types/walletconnect/constants.d.ts.map +1 -1
- package/dist/types/walletconnect/evmSigner.d.ts +2 -2
- package/dist/types/walletconnect/evmSigner.d.ts.map +1 -1
- package/dist/types/walletconnect/index.d.ts +2 -2
- package/dist/types/walletconnect/index.d.ts.map +1 -1
- package/dist/types/xaman/helpers.d.ts +22 -20
- package/dist/types/xaman/helpers.d.ts.map +1 -1
- package/dist/types/xaman/index.d.ts +1 -1
- package/dist/types/xaman/index.d.ts.map +1 -1
- package/dist/types/xaman/types.d.ts +8 -0
- package/dist/types/xaman/types.d.ts.map +1 -1
- package/dist/types/xaman/walletMethods.d.ts +14 -2
- package/dist/types/xaman/walletMethods.d.ts.map +1 -1
- package/package.json +26 -16
- package/dist/chunk-78m70510.js +0 -5
- package/dist/chunk-7jmqkkhs.js +0 -4
- package/dist/chunk-7jmqkkhs.js.map +0 -10
- package/dist/chunk-9acqzpjy.js +0 -5
- package/dist/chunk-9acqzpjy.js.map +0 -10
- package/dist/chunk-vb4wtm2w.js +0 -4
- package/src/bitget.ts +0 -1
- package/src/coinbase/index.ts +0 -44
- package/src/coinbase/signer.ts +0 -77
- package/src/cosmostation.ts +0 -1
- package/src/ctrl.ts +0 -1
- package/src/evm-extensions.ts +0 -1
- package/src/index.ts +0 -3
- package/src/keepkey-bex.ts +0 -1
- package/src/keepkey.ts +0 -1
- package/src/keplr.ts +0 -1
- package/src/keystore.ts +0 -1
- package/src/ledger.ts +0 -1
- package/src/near-wallet-selector/index.ts +0 -115
- package/src/okx.ts +0 -1
- package/src/onekey.ts +0 -1
- package/src/passkeys/index.ts +0 -183
- package/src/phantom.ts +0 -1
- package/src/polkadotjs.ts +0 -1
- package/src/radix/index.ts +0 -194
- package/src/talisman.ts +0 -1
- package/src/trezor.ts +0 -1
- package/src/tronlink.ts +0 -1
- package/src/types.ts +0 -94
- package/src/utils.ts +0 -59
- package/src/vultisig.ts +0 -1
- package/src/walletconnect/constants.ts +0 -103
- package/src/walletconnect/evmSigner.ts +0 -125
- package/src/walletconnect/helpers.ts +0 -73
- package/src/walletconnect/index.ts +0 -392
- package/src/walletconnect/namespaces.ts +0 -80
- package/src/walletconnect/types.ts +0 -6
- package/src/xaman/helpers.ts +0 -54
- package/src/xaman/index.ts +0 -62
- package/src/xaman/types.ts +0 -26
- package/src/xaman/walletMethods.ts +0 -110
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { SwapKitError } from "@swapkit/helpers";
|
|
2
|
-
import type { Xumm } from "xumm";
|
|
3
|
-
import type { XamanPaymentParams } from "./types";
|
|
4
|
-
|
|
5
|
-
export const connectXamanWallet = async (xumm: Xumm) => {
|
|
6
|
-
if (!xumm) {
|
|
7
|
-
throw new SwapKitError("wallet_xaman_not_configured");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const user = await xumm.user;
|
|
12
|
-
const account = await user?.account;
|
|
13
|
-
|
|
14
|
-
if (account) {
|
|
15
|
-
return account;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
throw new SwapKitError("wallet_xaman_auth_failed");
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error("Xaman wallet connection failed:", error);
|
|
21
|
-
throw new SwapKitError("wallet_xaman_connection_failed");
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const sendXamanTransaction = async (xumm: Xumm, params: XamanPaymentParams) => {
|
|
26
|
-
try {
|
|
27
|
-
// Validate required parameters
|
|
28
|
-
if (!(params.destination && params.amount && params.from)) {
|
|
29
|
-
throw new SwapKitError("wallet_xaman_connection_failed");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Convert XRP to drops (1 XRP = 1,000,000 drops)
|
|
33
|
-
const amountInDrops = (Number.parseFloat(params.amount) * 1000000).toString();
|
|
34
|
-
|
|
35
|
-
// Create transaction object
|
|
36
|
-
const transaction = {
|
|
37
|
-
Account: params.from,
|
|
38
|
-
Amount: amountInDrops,
|
|
39
|
-
Destination: params.destination,
|
|
40
|
-
TransactionType: "Payment" as const,
|
|
41
|
-
...(params.destinationTag !== undefined && { DestinationTag: params.destinationTag }),
|
|
42
|
-
...(params.memo && {
|
|
43
|
-
Memos: [{ Memo: { MemoData: Buffer.from(params.memo, "utf8").toString("hex").toUpperCase() } }],
|
|
44
|
-
}),
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Create and subscribe to payload following the official example
|
|
48
|
-
const subscription = await xumm.payload?.createAndSubscribe(transaction, (event) => {
|
|
49
|
-
if ("signed" in event.data) {
|
|
50
|
-
// Return event.data to close subscription and resolve promise
|
|
51
|
-
return event.data; // { signed: true|false, payload_uuidv4: '...' }
|
|
52
|
-
}
|
|
53
|
-
return undefined;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (!subscription) {
|
|
57
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const { created } = subscription;
|
|
61
|
-
|
|
62
|
-
// Handle payload presentation based on runtime environment
|
|
63
|
-
if (xumm.runtime?.xapp) {
|
|
64
|
-
xumm.xapp?.openSignRequest(created);
|
|
65
|
-
} else if (typeof window !== "undefined") {
|
|
66
|
-
const url =
|
|
67
|
-
created.pushed && created.next?.no_push_msg_received ? created.next.no_push_msg_received : created.next?.always;
|
|
68
|
-
if (url) window.open(url);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Wait until the user signed/rejected
|
|
72
|
-
const resolved = await subscription.resolved;
|
|
73
|
-
|
|
74
|
-
if (!resolved || typeof resolved !== "object" || !("signed" in resolved) || !resolved.signed) {
|
|
75
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Fetch the full payload result using the UUID from resolved data
|
|
79
|
-
const payloadDetails = await xumm.payload?.get((resolved as any).payload_uuidv4);
|
|
80
|
-
|
|
81
|
-
if (!payloadDetails) {
|
|
82
|
-
throw new SwapKitError("wallet_xaman_monitoring_failed");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Extract transaction ID from response
|
|
86
|
-
const transactionId = payloadDetails.response?.txid || "";
|
|
87
|
-
const account = payloadDetails.response?.account || "";
|
|
88
|
-
|
|
89
|
-
if (!transactionId) {
|
|
90
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Return comprehensive result
|
|
94
|
-
return {
|
|
95
|
-
deepLink: created.next?.always || "",
|
|
96
|
-
// Initial payload info for QR codes, deep links, etc.
|
|
97
|
-
payloadId: created.uuid || "",
|
|
98
|
-
qrCode: created.refs?.qr_png || "",
|
|
99
|
-
// Final transaction result - SUCCESS with tx hash
|
|
100
|
-
result: { account, reason: undefined, success: true, transactionId },
|
|
101
|
-
websocketUrl: created.refs?.websocket_status || "",
|
|
102
|
-
};
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.error("Xaman payment creation and subscription failed:", error);
|
|
105
|
-
if (error instanceof SwapKitError) {
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
109
|
-
}
|
|
110
|
-
};
|