@swapkit/wallets 4.0.0-beta.54 → 4.0.0-beta.55
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/{chunk-e674mh4n.js → chunk-mcrgqfr9.js} +3 -3
- package/dist/{chunk-e674mh4n.js.map → chunk-mcrgqfr9.js.map} +1 -1
- package/dist/{chunk-mvbb9fwb.js → chunk-sbf0f2p4.js} +2 -2
- package/dist/{chunk-p2ca0j1v.js → chunk-yqaz2d25.js} +3 -3
- package/dist/{chunk-p2ca0j1v.js.map → chunk-yqaz2d25.js.map} +1 -1
- package/dist/src/bitget/index.cjs +2 -2
- package/dist/src/bitget/index.cjs.map +3 -3
- package/dist/src/bitget/index.js +2 -2
- package/dist/src/bitget/index.js.map +3 -3
- package/dist/src/coinbase/index.cjs +2 -2
- package/dist/src/coinbase/index.cjs.map +3 -3
- package/dist/src/coinbase/index.js +2 -2
- package/dist/src/coinbase/index.js.map +3 -3
- package/dist/src/cosmostation/index.cjs +2 -2
- package/dist/src/cosmostation/index.cjs.map +3 -3
- package/dist/src/cosmostation/index.js +2 -2
- package/dist/src/cosmostation/index.js.map +3 -3
- package/dist/src/ctrl/index.cjs +2 -2
- package/dist/src/ctrl/index.cjs.map +3 -3
- package/dist/src/ctrl/index.js +2 -2
- package/dist/src/ctrl/index.js.map +3 -3
- package/dist/src/evm-extensions/index.cjs +2 -2
- package/dist/src/evm-extensions/index.cjs.map +3 -3
- package/dist/src/evm-extensions/index.js +2 -2
- package/dist/src/evm-extensions/index.js.map +3 -3
- package/dist/src/exodus/index.cjs +2 -2
- package/dist/src/exodus/index.cjs.map +3 -3
- package/dist/src/exodus/index.js +2 -2
- package/dist/src/exodus/index.js.map +3 -3
- package/dist/src/index.cjs +2 -2
- package/dist/src/index.cjs.map +5 -3
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +5 -3
- package/dist/src/keepkey-bex/index.cjs +2 -2
- package/dist/src/keepkey-bex/index.cjs.map +3 -3
- package/dist/src/keepkey-bex/index.js +2 -2
- package/dist/src/keepkey-bex/index.js.map +3 -3
- package/dist/src/keepkey.cjs +4 -0
- package/dist/src/keepkey.cjs.map +10 -0
- package/dist/src/keepkey.js +4 -0
- package/dist/src/keepkey.js.map +10 -0
- package/dist/src/keplr/index.cjs +2 -2
- package/dist/src/keplr/index.cjs.map +3 -3
- package/dist/src/keplr/index.js +2 -2
- package/dist/src/keplr/index.js.map +3 -3
- package/dist/src/keystore.cjs +4 -0
- package/dist/src/keystore.cjs.map +10 -0
- package/dist/src/keystore.js +4 -0
- package/dist/src/keystore.js.map +10 -0
- package/dist/src/ledger.cjs +4 -0
- package/dist/src/ledger.cjs.map +10 -0
- package/dist/src/ledger.js +4 -0
- package/dist/src/ledger.js.map +10 -0
- package/dist/src/okx/index.cjs +2 -2
- package/dist/src/okx/index.cjs.map +4 -4
- package/dist/src/okx/index.js +2 -2
- package/dist/src/okx/index.js.map +4 -4
- package/dist/src/onekey/index.cjs +2 -2
- package/dist/src/onekey/index.cjs.map +3 -3
- package/dist/src/onekey/index.js +2 -2
- package/dist/src/onekey/index.js.map +3 -3
- package/dist/src/phantom/index.cjs +2 -2
- package/dist/src/phantom/index.cjs.map +3 -3
- package/dist/src/phantom/index.js +2 -2
- package/dist/src/phantom/index.js.map +3 -3
- package/dist/src/polkadotjs/index.cjs +2 -2
- package/dist/src/polkadotjs/index.cjs.map +3 -3
- package/dist/src/polkadotjs/index.js +2 -2
- package/dist/src/polkadotjs/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/talisman/index.cjs +2 -2
- package/dist/src/talisman/index.cjs.map +3 -3
- package/dist/src/talisman/index.js +2 -2
- package/dist/src/talisman/index.js.map +3 -3
- package/dist/src/trezor.cjs +4 -0
- package/dist/src/trezor.cjs.map +10 -0
- package/dist/src/trezor.js +4 -0
- package/dist/src/trezor.js.map +10 -0
- package/dist/src/vultisig/index.cjs +2 -2
- package/dist/src/vultisig/index.cjs.map +3 -3
- package/dist/src/vultisig/index.js +2 -2
- package/dist/src/vultisig/index.js.map +3 -3
- package/dist/src/walletconnect/index.cjs +2 -2
- package/dist/src/walletconnect/index.cjs.map +3 -3
- package/dist/src/walletconnect/index.js +2 -2
- package/dist/src/walletconnect/index.js.map +3 -3
- 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/bitget/helpers.d.ts +330 -0
- package/dist/types/bitget/helpers.d.ts.map +1 -0
- package/dist/types/bitget/index.d.ts +11 -0
- package/dist/types/bitget/index.d.ts.map +1 -0
- package/dist/types/coinbase/index.d.ts +11 -0
- package/dist/types/coinbase/index.d.ts.map +1 -0
- package/dist/types/coinbase/signer.d.ts +91 -0
- package/dist/types/coinbase/signer.d.ts.map +1 -0
- package/dist/types/cosmostation/index.d.ts +21 -0
- package/dist/types/cosmostation/index.d.ts.map +1 -0
- package/dist/types/ctrl/index.d.ts +11 -0
- package/dist/types/ctrl/index.d.ts.map +1 -0
- package/dist/types/ctrl/walletHelpers.d.ts +24 -0
- package/dist/types/ctrl/walletHelpers.d.ts.map +1 -0
- package/dist/types/evm-extensions/index.d.ts +101 -0
- package/dist/types/evm-extensions/index.d.ts.map +1 -0
- package/{src/evm-extensions/types.ts → dist/types/evm-extensions/types.d.ts} +11 -13
- package/dist/types/evm-extensions/types.d.ts.map +1 -0
- package/dist/types/exodus/index.d.ts +14 -0
- package/dist/types/exodus/index.d.ts.map +1 -0
- package/dist/types/helpers/near.d.ts +57 -0
- package/dist/types/helpers/near.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/keepkey-bex/index.d.ts +11 -0
- package/dist/types/keepkey-bex/index.d.ts.map +1 -0
- package/dist/types/keepkey-bex/walletHelpers.d.ts +45 -0
- package/dist/types/keepkey-bex/walletHelpers.d.ts.map +1 -0
- package/dist/types/keepkey.d.ts +2 -0
- package/dist/types/keepkey.d.ts.map +1 -0
- package/dist/types/keplr/chainRegistry.d.ts +4 -0
- package/dist/types/keplr/chainRegistry.d.ts.map +1 -0
- package/dist/types/keplr/index.d.ts +11 -0
- package/dist/types/keplr/index.d.ts.map +1 -0
- package/dist/types/keystore.d.ts +2 -0
- package/dist/types/keystore.d.ts.map +1 -0
- package/dist/types/ledger.d.ts +2 -0
- package/dist/types/ledger.d.ts.map +1 -0
- package/dist/types/okx/helpers.d.ts +227 -0
- package/dist/types/okx/helpers.d.ts.map +1 -0
- package/dist/types/okx/index.d.ts +11 -0
- package/dist/types/okx/index.d.ts.map +1 -0
- package/dist/types/okx/types.d.ts +104 -0
- package/dist/types/okx/types.d.ts.map +1 -0
- package/dist/types/onekey/evmSigner.d.ts +29 -0
- package/dist/types/onekey/evmSigner.d.ts.map +1 -0
- package/dist/types/onekey/index.d.ts +11 -0
- package/dist/types/onekey/index.d.ts.map +1 -0
- package/dist/types/phantom/index.d.ts +12 -0
- package/dist/types/phantom/index.d.ts.map +1 -0
- package/dist/types/polkadotjs/index.d.ts +11 -0
- package/dist/types/polkadotjs/index.d.ts.map +1 -0
- package/dist/types/radix/index.d.ts +11 -0
- package/dist/types/radix/index.d.ts.map +1 -0
- package/dist/types/talisman/index.d.ts +11 -0
- package/dist/types/talisman/index.d.ts.map +1 -0
- package/dist/types/trezor.d.ts +2 -0
- package/dist/types/trezor.d.ts.map +1 -0
- package/dist/types/types.d.ts +246 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/vultisig/index.d.ts +11 -0
- package/dist/types/vultisig/index.d.ts.map +1 -0
- package/dist/types/vultisig/walletHelpers.d.ts +34 -0
- package/dist/types/vultisig/walletHelpers.d.ts.map +1 -0
- package/dist/types/walletconnect/constants.d.ts +85 -0
- package/dist/types/walletconnect/constants.d.ts.map +1 -0
- package/dist/types/walletconnect/evmSigner.d.ts +25 -0
- package/dist/types/walletconnect/evmSigner.d.ts.map +1 -0
- package/dist/types/walletconnect/helpers.d.ts +4 -0
- package/dist/types/walletconnect/helpers.d.ts.map +1 -0
- package/dist/types/walletconnect/index.d.ts +22 -0
- package/dist/types/walletconnect/index.d.ts.map +1 -0
- package/dist/types/walletconnect/namespaces.d.ts +7 -0
- package/dist/types/walletconnect/namespaces.d.ts.map +1 -0
- package/dist/types/walletconnect/types.d.ts +7 -0
- package/dist/types/walletconnect/types.d.ts.map +1 -0
- package/dist/types/xaman/helpers.d.ts +54 -0
- package/dist/types/xaman/helpers.d.ts.map +1 -0
- package/dist/types/xaman/index.d.ts +14 -0
- package/dist/types/xaman/index.d.ts.map +1 -0
- package/dist/types/xaman/types.d.ts +24 -0
- package/dist/types/xaman/types.d.ts.map +1 -0
- package/dist/types/xaman/walletMethods.d.ts +16 -0
- package/dist/types/xaman/walletMethods.d.ts.map +1 -0
- package/package.json +44 -68
- package/dist/chunk-2aa1w78q.js +0 -4
- package/dist/chunk-2aa1w78q.js.map +0 -10
- package/dist/chunk-31bmhjxx.js +0 -4
- package/dist/chunk-31bmhjxx.js.map +0 -10
- package/dist/chunk-3etn0w20.js +0 -4
- package/dist/chunk-3etn0w20.js.map +0 -10
- package/dist/chunk-bk58smyr.js +0 -4
- package/dist/chunk-bk58smyr.js.map +0 -10
- package/dist/chunk-etm8zfkk.js +0 -4
- package/dist/chunk-etm8zfkk.js.map +0 -10
- package/dist/chunk-h7myvxxm.js +0 -5
- package/dist/chunk-h7myvxxm.js.map +0 -10
- package/dist/chunk-htvthkj1.js +0 -5
- package/dist/chunk-htvthkj1.js.map +0 -10
- package/dist/chunk-nfas79hz.js +0 -4
- package/dist/chunk-nfas79hz.js.map +0 -10
- package/dist/src/keepkey/index.cjs +0 -4
- package/dist/src/keepkey/index.cjs.map +0 -15
- package/dist/src/keepkey/index.js +0 -4
- package/dist/src/keepkey/index.js.map +0 -15
- package/dist/src/keystore/index.cjs +0 -4
- package/dist/src/keystore/index.cjs.map +0 -11
- package/dist/src/keystore/index.js +0 -4
- package/dist/src/keystore/index.js.map +0 -11
- package/dist/src/ledger/index.cjs +0 -5
- package/dist/src/ledger/index.cjs.map +0 -25
- package/dist/src/ledger/index.js +0 -5
- package/dist/src/ledger/index.js.map +0 -25
- package/dist/src/trezor/index.cjs +0 -4
- package/dist/src/trezor/index.cjs.map +0 -10
- package/dist/src/trezor/index.js +0 -4
- package/dist/src/trezor/index.js.map +0 -10
- package/src/bitget/helpers.ts +0 -167
- package/src/bitget/index.ts +0 -34
- package/src/coinbase/index.ts +0 -52
- package/src/coinbase/signer.ts +0 -83
- package/src/cosmostation/index.ts +0 -142
- package/src/ctrl/index.ts +0 -248
- package/src/ctrl/walletHelpers.ts +0 -297
- package/src/evm-extensions/index.ts +0 -134
- package/src/exodus/index.ts +0 -179
- package/src/helpers/near-browser-provider.d.ts +0 -286
- package/src/helpers/near.ts +0 -206
- package/src/index.ts +0 -2
- package/src/keepkey/chains/cosmos.ts +0 -78
- package/src/keepkey/chains/evm.ts +0 -125
- package/src/keepkey/chains/mayachain.ts +0 -123
- package/src/keepkey/chains/ripple.ts +0 -118
- package/src/keepkey/chains/thorchain.ts +0 -118
- package/src/keepkey/chains/utxo.ts +0 -147
- package/src/keepkey/coins.ts +0 -71
- package/src/keepkey/index.ts +0 -153
- package/src/keepkey-bex/index.ts +0 -162
- package/src/keepkey-bex/walletHelpers.ts +0 -255
- package/src/keplr/chainRegistry.ts +0 -211
- package/src/keplr/index.ts +0 -55
- package/src/keystore/helpers.ts +0 -102
- package/src/keystore/index.ts +0 -73
- package/src/ledger/clients/cosmos.ts +0 -102
- package/src/ledger/clients/evm.ts +0 -183
- package/src/ledger/clients/near.ts +0 -86
- package/src/ledger/clients/thorchain/common.ts +0 -117
- package/src/ledger/clients/thorchain/helpers.ts +0 -149
- package/src/ledger/clients/thorchain/index.ts +0 -94
- package/src/ledger/clients/thorchain/lib.ts +0 -300
- package/src/ledger/clients/thorchain/utils.ts +0 -76
- package/src/ledger/clients/tron.ts +0 -92
- package/src/ledger/clients/utxo.ts +0 -148
- package/src/ledger/clients/xrp.ts +0 -66
- package/src/ledger/cosmosTypes.ts +0 -101
- package/src/ledger/helpers/getLedgerAddress.ts +0 -67
- package/src/ledger/helpers/getLedgerClient.ts +0 -124
- package/src/ledger/helpers/getLedgerTransport.ts +0 -80
- package/src/ledger/helpers/index.ts +0 -3
- package/src/ledger/index.ts +0 -311
- package/src/ledger/interfaces/CosmosLedgerInterface.ts +0 -65
- package/src/ledger/types.ts +0 -45
- package/src/okx/helpers.ts +0 -181
- package/src/okx/index.ts +0 -43
- package/src/okx/types.ts +0 -117
- package/src/onekey/evmSigner.ts +0 -133
- package/src/onekey/index.ts +0 -213
- package/src/phantom/index.ts +0 -126
- package/src/polkadotjs/index.ts +0 -67
- package/src/radix/index.ts +0 -202
- package/src/talisman/index.ts +0 -130
- package/src/trezor/evmSigner.ts +0 -197
- package/src/trezor/index.ts +0 -260
- package/src/types.ts +0 -280
- package/src/utils.ts +0 -60
- package/src/vultisig/index.ts +0 -199
- package/src/vultisig/walletHelpers.ts +0 -359
- package/src/walletconnect/constants.ts +0 -104
- package/src/walletconnect/evmSigner.ts +0 -147
- package/src/walletconnect/helpers.ts +0 -77
- package/src/walletconnect/index.ts +0 -460
- package/src/walletconnect/namespaces.ts +0 -87
- package/src/walletconnect/types.ts +0 -6
- package/src/xaman/README.md +0 -66
- package/src/xaman/helpers.ts +0 -59
- package/src/xaman/index.ts +0 -79
- package/src/xaman/types.ts +0 -26
- package/src/xaman/walletMethods.ts +0 -126
- /package/dist/{chunk-mvbb9fwb.js.map → chunk-sbf0f2p4.js.map} +0 -0
package/src/xaman/index.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Chain,
|
|
3
|
-
SKConfig,
|
|
4
|
-
SwapKitError,
|
|
5
|
-
WalletOption,
|
|
6
|
-
createWallet,
|
|
7
|
-
filterSupportedChains,
|
|
8
|
-
} from "@swapkit/helpers";
|
|
9
|
-
import { Xumm } from "xumm";
|
|
10
|
-
import { getWalletSupportedChains } from "../utils";
|
|
11
|
-
import { getWalletForChain } from "./helpers.js";
|
|
12
|
-
import type { XamanConfig } from "./types.js";
|
|
13
|
-
import { connectXamanWallet as connectXamanWalletMethod } from "./walletMethods.js";
|
|
14
|
-
|
|
15
|
-
export const xamanWallet = createWallet({
|
|
16
|
-
name: "connectXaman",
|
|
17
|
-
walletType: WalletOption.XAMAN,
|
|
18
|
-
supportedChains: [Chain.Ripple],
|
|
19
|
-
connect: ({ addChain, supportedChains: walletSupportedChains, walletType }) =>
|
|
20
|
-
async function connectXamanWallet(chains: Chain[], xamanConfigOverwrite?: XamanConfig) {
|
|
21
|
-
const supportedChains = filterSupportedChains({
|
|
22
|
-
chains,
|
|
23
|
-
supportedChains: walletSupportedChains,
|
|
24
|
-
walletType,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const { xaman: xamanApiKey } = SKConfig.get("apiKeys");
|
|
28
|
-
const apiKey = xamanConfigOverwrite?.apiKey || xamanApiKey;
|
|
29
|
-
|
|
30
|
-
if (!apiKey) {
|
|
31
|
-
throw new SwapKitError("wallet_missing_api_key", { wallet: "Xaman" });
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const xumm = new Xumm(apiKey);
|
|
35
|
-
|
|
36
|
-
return new Promise<boolean>((resolve, reject) => {
|
|
37
|
-
xumm.on("success", async () => {
|
|
38
|
-
try {
|
|
39
|
-
const address = await connectXamanWalletMethod(xumm);
|
|
40
|
-
|
|
41
|
-
const promises = supportedChains.map(async (chain) => {
|
|
42
|
-
const rpcUrl = SKConfig.get("rpcUrls")[chain];
|
|
43
|
-
const walletMethods = await getWalletForChain({
|
|
44
|
-
xumm,
|
|
45
|
-
chain,
|
|
46
|
-
address,
|
|
47
|
-
rpcUrl,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
addChain({
|
|
51
|
-
...walletMethods,
|
|
52
|
-
chain,
|
|
53
|
-
balance: [],
|
|
54
|
-
walletType: WalletOption.XAMAN,
|
|
55
|
-
address,
|
|
56
|
-
disconnect: xumm.logout,
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
await Promise.all(promises);
|
|
61
|
-
resolve(true);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
reject(error);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
xumm.on("error", (error) => {
|
|
68
|
-
reject(error);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
xumm.authorize();
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
export const XAMAN_SUPPORTED_CHAINS = getWalletSupportedChains(xamanWallet);
|
|
77
|
-
export type XamanSupportedChain = (typeof XAMAN_SUPPORTED_CHAINS)[number];
|
|
78
|
-
|
|
79
|
-
export type { XamanConfig } from "./types.js";
|
package/src/xaman/types.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface XamanConfig {
|
|
2
|
-
apiKey: string;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export interface XamanPaymentParams {
|
|
6
|
-
destination: string;
|
|
7
|
-
from: string;
|
|
8
|
-
amount: string;
|
|
9
|
-
memo?: string;
|
|
10
|
-
destinationTag?: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface XamanPaymentResult {
|
|
14
|
-
payloadId: string;
|
|
15
|
-
qrCode: string;
|
|
16
|
-
deepLink: string;
|
|
17
|
-
websocketUrl: string;
|
|
18
|
-
result: XamanTransactionResult;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface XamanTransactionResult {
|
|
22
|
-
success: boolean;
|
|
23
|
-
transactionId?: string;
|
|
24
|
-
account?: string;
|
|
25
|
-
reason?: string;
|
|
26
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { SwapKitError } from "@swapkit/helpers";
|
|
2
|
-
import type { Xumm } from "xumm";
|
|
3
|
-
import type { XamanPaymentParams } from "./types.js";
|
|
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
|
-
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: might need refactoring later
|
|
26
|
-
export const sendXamanTransaction = async (xumm: Xumm, params: XamanPaymentParams) => {
|
|
27
|
-
try {
|
|
28
|
-
// Validate required parameters
|
|
29
|
-
if (!(params.destination && params.amount && params.from)) {
|
|
30
|
-
throw new SwapKitError("wallet_xaman_connection_failed");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Convert XRP to drops (1 XRP = 1,000,000 drops)
|
|
34
|
-
const amountInDrops = (Number.parseFloat(params.amount) * 1000000).toString();
|
|
35
|
-
|
|
36
|
-
// Create transaction object
|
|
37
|
-
const transaction = {
|
|
38
|
-
TransactionType: "Payment" as const,
|
|
39
|
-
Destination: params.destination,
|
|
40
|
-
Amount: amountInDrops,
|
|
41
|
-
Account: params.from,
|
|
42
|
-
...(params.destinationTag !== undefined && {
|
|
43
|
-
DestinationTag: params.destinationTag,
|
|
44
|
-
}),
|
|
45
|
-
...(params.memo && {
|
|
46
|
-
Memos: [
|
|
47
|
-
{
|
|
48
|
-
Memo: {
|
|
49
|
-
MemoData: Buffer.from(params.memo, "utf8").toString("hex").toUpperCase(),
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
}),
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Create and subscribe to payload following the official example
|
|
57
|
-
const subscription = await xumm.payload?.createAndSubscribe(transaction, (event) => {
|
|
58
|
-
if ("signed" in event.data) {
|
|
59
|
-
// Return event.data to close subscription and resolve promise
|
|
60
|
-
return event.data; // { signed: true|false, payload_uuidv4: '...' }
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
if (!subscription) {
|
|
66
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const { created } = subscription;
|
|
70
|
-
|
|
71
|
-
// Handle payload presentation based on runtime environment
|
|
72
|
-
if (xumm.runtime?.xapp) {
|
|
73
|
-
xumm.xapp?.openSignRequest(created);
|
|
74
|
-
} else if (typeof window !== "undefined") {
|
|
75
|
-
const url =
|
|
76
|
-
created.pushed && created.next?.no_push_msg_received
|
|
77
|
-
? created.next.no_push_msg_received
|
|
78
|
-
: created.next?.always;
|
|
79
|
-
if (url) window.open(url);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Wait until the user signed/rejected
|
|
83
|
-
const resolved = await subscription.resolved;
|
|
84
|
-
|
|
85
|
-
if (!resolved || typeof resolved !== "object" || !("signed" in resolved) || !resolved.signed) {
|
|
86
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Fetch the full payload result using the UUID from resolved data
|
|
90
|
-
const payloadDetails = await xumm.payload?.get((resolved as any).payload_uuidv4);
|
|
91
|
-
|
|
92
|
-
if (!payloadDetails) {
|
|
93
|
-
throw new SwapKitError("wallet_xaman_monitoring_failed");
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Extract transaction ID from response
|
|
97
|
-
const transactionId = payloadDetails.response?.txid || "";
|
|
98
|
-
const account = payloadDetails.response?.account || "";
|
|
99
|
-
|
|
100
|
-
if (!transactionId) {
|
|
101
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Return comprehensive result
|
|
105
|
-
return {
|
|
106
|
-
// Initial payload info for QR codes, deep links, etc.
|
|
107
|
-
payloadId: created.uuid || "",
|
|
108
|
-
qrCode: created.refs?.qr_png || "",
|
|
109
|
-
deepLink: created.next?.always || "",
|
|
110
|
-
websocketUrl: created.refs?.websocket_status || "",
|
|
111
|
-
// Final transaction result - SUCCESS with tx hash
|
|
112
|
-
result: {
|
|
113
|
-
success: true,
|
|
114
|
-
transactionId,
|
|
115
|
-
account,
|
|
116
|
-
reason: undefined,
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error("Xaman payment creation and subscription failed:", error);
|
|
121
|
-
if (error instanceof SwapKitError) {
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
throw new SwapKitError("wallet_xaman_transaction_failed");
|
|
125
|
-
}
|
|
126
|
-
};
|
|
File without changes
|