@swapkit/wallets 4.0.0-beta.53 → 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.
Files changed (284) hide show
  1. package/dist/{chunk-e674mh4n.js → chunk-mcrgqfr9.js} +3 -3
  2. package/dist/{chunk-e674mh4n.js.map → chunk-mcrgqfr9.js.map} +1 -1
  3. package/dist/{chunk-mvbb9fwb.js → chunk-sbf0f2p4.js} +2 -2
  4. package/dist/{chunk-p2ca0j1v.js → chunk-yqaz2d25.js} +3 -3
  5. package/dist/{chunk-p2ca0j1v.js.map → chunk-yqaz2d25.js.map} +1 -1
  6. package/dist/src/bitget/index.cjs +2 -2
  7. package/dist/src/bitget/index.cjs.map +3 -3
  8. package/dist/src/bitget/index.js +2 -2
  9. package/dist/src/bitget/index.js.map +3 -3
  10. package/dist/src/coinbase/index.cjs +2 -2
  11. package/dist/src/coinbase/index.cjs.map +3 -3
  12. package/dist/src/coinbase/index.js +2 -2
  13. package/dist/src/coinbase/index.js.map +3 -3
  14. package/dist/src/cosmostation/index.cjs +2 -2
  15. package/dist/src/cosmostation/index.cjs.map +3 -3
  16. package/dist/src/cosmostation/index.js +2 -2
  17. package/dist/src/cosmostation/index.js.map +3 -3
  18. package/dist/src/ctrl/index.cjs +2 -2
  19. package/dist/src/ctrl/index.cjs.map +3 -3
  20. package/dist/src/ctrl/index.js +2 -2
  21. package/dist/src/ctrl/index.js.map +3 -3
  22. package/dist/src/evm-extensions/index.cjs +2 -2
  23. package/dist/src/evm-extensions/index.cjs.map +3 -3
  24. package/dist/src/evm-extensions/index.js +2 -2
  25. package/dist/src/evm-extensions/index.js.map +3 -3
  26. package/dist/src/exodus/index.cjs +2 -2
  27. package/dist/src/exodus/index.cjs.map +3 -3
  28. package/dist/src/exodus/index.js +2 -2
  29. package/dist/src/exodus/index.js.map +3 -3
  30. package/dist/src/index.cjs +2 -2
  31. package/dist/src/index.cjs.map +5 -3
  32. package/dist/src/index.js +2 -2
  33. package/dist/src/index.js.map +5 -3
  34. package/dist/src/keepkey-bex/index.cjs +2 -2
  35. package/dist/src/keepkey-bex/index.cjs.map +3 -3
  36. package/dist/src/keepkey-bex/index.js +2 -2
  37. package/dist/src/keepkey-bex/index.js.map +3 -3
  38. package/dist/src/keepkey.cjs +4 -0
  39. package/dist/src/keepkey.cjs.map +10 -0
  40. package/dist/src/keepkey.js +4 -0
  41. package/dist/src/keepkey.js.map +10 -0
  42. package/dist/src/keplr/index.cjs +2 -2
  43. package/dist/src/keplr/index.cjs.map +3 -3
  44. package/dist/src/keplr/index.js +2 -2
  45. package/dist/src/keplr/index.js.map +3 -3
  46. package/dist/src/keystore.cjs +4 -0
  47. package/dist/src/keystore.cjs.map +10 -0
  48. package/dist/src/keystore.js +4 -0
  49. package/dist/src/keystore.js.map +10 -0
  50. package/dist/src/ledger.cjs +4 -0
  51. package/dist/src/ledger.cjs.map +10 -0
  52. package/dist/src/ledger.js +4 -0
  53. package/dist/src/ledger.js.map +10 -0
  54. package/dist/src/okx/index.cjs +2 -2
  55. package/dist/src/okx/index.cjs.map +4 -4
  56. package/dist/src/okx/index.js +2 -2
  57. package/dist/src/okx/index.js.map +4 -4
  58. package/dist/src/onekey/index.cjs +2 -2
  59. package/dist/src/onekey/index.cjs.map +3 -3
  60. package/dist/src/onekey/index.js +2 -2
  61. package/dist/src/onekey/index.js.map +3 -3
  62. package/dist/src/phantom/index.cjs +2 -2
  63. package/dist/src/phantom/index.cjs.map +3 -3
  64. package/dist/src/phantom/index.js +2 -2
  65. package/dist/src/phantom/index.js.map +3 -3
  66. package/dist/src/polkadotjs/index.cjs +2 -2
  67. package/dist/src/polkadotjs/index.cjs.map +3 -3
  68. package/dist/src/polkadotjs/index.js +2 -2
  69. package/dist/src/polkadotjs/index.js.map +3 -3
  70. package/dist/src/radix/index.cjs +2 -2
  71. package/dist/src/radix/index.cjs.map +3 -3
  72. package/dist/src/radix/index.js +2 -2
  73. package/dist/src/radix/index.js.map +3 -3
  74. package/dist/src/talisman/index.cjs +2 -2
  75. package/dist/src/talisman/index.cjs.map +3 -3
  76. package/dist/src/talisman/index.js +2 -2
  77. package/dist/src/talisman/index.js.map +3 -3
  78. package/dist/src/trezor.cjs +4 -0
  79. package/dist/src/trezor.cjs.map +10 -0
  80. package/dist/src/trezor.js +4 -0
  81. package/dist/src/trezor.js.map +10 -0
  82. package/dist/src/vultisig/index.cjs +2 -2
  83. package/dist/src/vultisig/index.cjs.map +3 -3
  84. package/dist/src/vultisig/index.js +2 -2
  85. package/dist/src/vultisig/index.js.map +3 -3
  86. package/dist/src/walletconnect/index.cjs +2 -2
  87. package/dist/src/walletconnect/index.cjs.map +3 -3
  88. package/dist/src/walletconnect/index.js +2 -2
  89. package/dist/src/walletconnect/index.js.map +3 -3
  90. package/dist/src/xaman/index.cjs +2 -2
  91. package/dist/src/xaman/index.cjs.map +5 -5
  92. package/dist/src/xaman/index.js +2 -2
  93. package/dist/src/xaman/index.js.map +5 -5
  94. package/dist/types/bitget/helpers.d.ts +330 -0
  95. package/dist/types/bitget/helpers.d.ts.map +1 -0
  96. package/dist/types/bitget/index.d.ts +11 -0
  97. package/dist/types/bitget/index.d.ts.map +1 -0
  98. package/dist/types/coinbase/index.d.ts +11 -0
  99. package/dist/types/coinbase/index.d.ts.map +1 -0
  100. package/dist/types/coinbase/signer.d.ts +91 -0
  101. package/dist/types/coinbase/signer.d.ts.map +1 -0
  102. package/dist/types/cosmostation/index.d.ts +21 -0
  103. package/dist/types/cosmostation/index.d.ts.map +1 -0
  104. package/dist/types/ctrl/index.d.ts +11 -0
  105. package/dist/types/ctrl/index.d.ts.map +1 -0
  106. package/dist/types/ctrl/walletHelpers.d.ts +24 -0
  107. package/dist/types/ctrl/walletHelpers.d.ts.map +1 -0
  108. package/dist/types/evm-extensions/index.d.ts +101 -0
  109. package/dist/types/evm-extensions/index.d.ts.map +1 -0
  110. package/{src/evm-extensions/types.ts → dist/types/evm-extensions/types.d.ts} +11 -13
  111. package/dist/types/evm-extensions/types.d.ts.map +1 -0
  112. package/dist/types/exodus/index.d.ts +14 -0
  113. package/dist/types/exodus/index.d.ts.map +1 -0
  114. package/dist/types/helpers/near.d.ts +57 -0
  115. package/dist/types/helpers/near.d.ts.map +1 -0
  116. package/dist/types/index.d.ts +4 -0
  117. package/dist/types/index.d.ts.map +1 -0
  118. package/dist/types/keepkey-bex/index.d.ts +11 -0
  119. package/dist/types/keepkey-bex/index.d.ts.map +1 -0
  120. package/dist/types/keepkey-bex/walletHelpers.d.ts +45 -0
  121. package/dist/types/keepkey-bex/walletHelpers.d.ts.map +1 -0
  122. package/dist/types/keepkey.d.ts +2 -0
  123. package/dist/types/keepkey.d.ts.map +1 -0
  124. package/dist/types/keplr/chainRegistry.d.ts +4 -0
  125. package/dist/types/keplr/chainRegistry.d.ts.map +1 -0
  126. package/dist/types/keplr/index.d.ts +11 -0
  127. package/dist/types/keplr/index.d.ts.map +1 -0
  128. package/dist/types/keystore.d.ts +2 -0
  129. package/dist/types/keystore.d.ts.map +1 -0
  130. package/dist/types/ledger.d.ts +2 -0
  131. package/dist/types/ledger.d.ts.map +1 -0
  132. package/dist/types/okx/helpers.d.ts +227 -0
  133. package/dist/types/okx/helpers.d.ts.map +1 -0
  134. package/dist/types/okx/index.d.ts +11 -0
  135. package/dist/types/okx/index.d.ts.map +1 -0
  136. package/dist/types/okx/types.d.ts +104 -0
  137. package/dist/types/okx/types.d.ts.map +1 -0
  138. package/dist/types/onekey/evmSigner.d.ts +29 -0
  139. package/dist/types/onekey/evmSigner.d.ts.map +1 -0
  140. package/dist/types/onekey/index.d.ts +11 -0
  141. package/dist/types/onekey/index.d.ts.map +1 -0
  142. package/dist/types/phantom/index.d.ts +12 -0
  143. package/dist/types/phantom/index.d.ts.map +1 -0
  144. package/dist/types/polkadotjs/index.d.ts +11 -0
  145. package/dist/types/polkadotjs/index.d.ts.map +1 -0
  146. package/dist/types/radix/index.d.ts +11 -0
  147. package/dist/types/radix/index.d.ts.map +1 -0
  148. package/dist/types/talisman/index.d.ts +11 -0
  149. package/dist/types/talisman/index.d.ts.map +1 -0
  150. package/dist/types/trezor.d.ts +2 -0
  151. package/dist/types/trezor.d.ts.map +1 -0
  152. package/dist/types/types.d.ts +246 -0
  153. package/dist/types/types.d.ts.map +1 -0
  154. package/dist/types/utils.d.ts +4 -0
  155. package/dist/types/utils.d.ts.map +1 -0
  156. package/dist/types/vultisig/index.d.ts +11 -0
  157. package/dist/types/vultisig/index.d.ts.map +1 -0
  158. package/dist/types/vultisig/walletHelpers.d.ts +34 -0
  159. package/dist/types/vultisig/walletHelpers.d.ts.map +1 -0
  160. package/dist/types/walletconnect/constants.d.ts +85 -0
  161. package/dist/types/walletconnect/constants.d.ts.map +1 -0
  162. package/dist/types/walletconnect/evmSigner.d.ts +25 -0
  163. package/dist/types/walletconnect/evmSigner.d.ts.map +1 -0
  164. package/dist/types/walletconnect/helpers.d.ts +4 -0
  165. package/dist/types/walletconnect/helpers.d.ts.map +1 -0
  166. package/dist/types/walletconnect/index.d.ts +22 -0
  167. package/dist/types/walletconnect/index.d.ts.map +1 -0
  168. package/dist/types/walletconnect/namespaces.d.ts +7 -0
  169. package/dist/types/walletconnect/namespaces.d.ts.map +1 -0
  170. package/dist/types/walletconnect/types.d.ts +7 -0
  171. package/dist/types/walletconnect/types.d.ts.map +1 -0
  172. package/dist/types/xaman/helpers.d.ts +54 -0
  173. package/dist/types/xaman/helpers.d.ts.map +1 -0
  174. package/dist/types/xaman/index.d.ts +14 -0
  175. package/dist/types/xaman/index.d.ts.map +1 -0
  176. package/dist/types/xaman/types.d.ts +24 -0
  177. package/dist/types/xaman/types.d.ts.map +1 -0
  178. package/dist/types/xaman/walletMethods.d.ts +16 -0
  179. package/dist/types/xaman/walletMethods.d.ts.map +1 -0
  180. package/package.json +44 -68
  181. package/dist/chunk-2aa1w78q.js +0 -4
  182. package/dist/chunk-2aa1w78q.js.map +0 -10
  183. package/dist/chunk-31bmhjxx.js +0 -4
  184. package/dist/chunk-31bmhjxx.js.map +0 -10
  185. package/dist/chunk-3etn0w20.js +0 -4
  186. package/dist/chunk-3etn0w20.js.map +0 -10
  187. package/dist/chunk-bk58smyr.js +0 -4
  188. package/dist/chunk-bk58smyr.js.map +0 -10
  189. package/dist/chunk-etm8zfkk.js +0 -4
  190. package/dist/chunk-etm8zfkk.js.map +0 -10
  191. package/dist/chunk-h7myvxxm.js +0 -5
  192. package/dist/chunk-h7myvxxm.js.map +0 -10
  193. package/dist/chunk-htvthkj1.js +0 -5
  194. package/dist/chunk-htvthkj1.js.map +0 -10
  195. package/dist/chunk-nfas79hz.js +0 -4
  196. package/dist/chunk-nfas79hz.js.map +0 -10
  197. package/dist/src/keepkey/index.cjs +0 -4
  198. package/dist/src/keepkey/index.cjs.map +0 -15
  199. package/dist/src/keepkey/index.js +0 -4
  200. package/dist/src/keepkey/index.js.map +0 -15
  201. package/dist/src/keystore/index.cjs +0 -4
  202. package/dist/src/keystore/index.cjs.map +0 -11
  203. package/dist/src/keystore/index.js +0 -4
  204. package/dist/src/keystore/index.js.map +0 -11
  205. package/dist/src/ledger/index.cjs +0 -5
  206. package/dist/src/ledger/index.cjs.map +0 -25
  207. package/dist/src/ledger/index.js +0 -5
  208. package/dist/src/ledger/index.js.map +0 -25
  209. package/dist/src/trezor/index.cjs +0 -4
  210. package/dist/src/trezor/index.cjs.map +0 -10
  211. package/dist/src/trezor/index.js +0 -4
  212. package/dist/src/trezor/index.js.map +0 -10
  213. package/src/bitget/helpers.ts +0 -167
  214. package/src/bitget/index.ts +0 -34
  215. package/src/coinbase/index.ts +0 -52
  216. package/src/coinbase/signer.ts +0 -83
  217. package/src/cosmostation/index.ts +0 -142
  218. package/src/ctrl/index.ts +0 -248
  219. package/src/ctrl/walletHelpers.ts +0 -297
  220. package/src/evm-extensions/index.ts +0 -134
  221. package/src/exodus/index.ts +0 -179
  222. package/src/helpers/near-browser-provider.d.ts +0 -286
  223. package/src/helpers/near.ts +0 -206
  224. package/src/index.ts +0 -2
  225. package/src/keepkey/chains/cosmos.ts +0 -78
  226. package/src/keepkey/chains/evm.ts +0 -125
  227. package/src/keepkey/chains/mayachain.ts +0 -123
  228. package/src/keepkey/chains/ripple.ts +0 -118
  229. package/src/keepkey/chains/thorchain.ts +0 -118
  230. package/src/keepkey/chains/utxo.ts +0 -147
  231. package/src/keepkey/coins.ts +0 -71
  232. package/src/keepkey/index.ts +0 -153
  233. package/src/keepkey-bex/index.ts +0 -162
  234. package/src/keepkey-bex/walletHelpers.ts +0 -255
  235. package/src/keplr/chainRegistry.ts +0 -211
  236. package/src/keplr/index.ts +0 -55
  237. package/src/keystore/helpers.ts +0 -102
  238. package/src/keystore/index.ts +0 -73
  239. package/src/ledger/clients/cosmos.ts +0 -102
  240. package/src/ledger/clients/evm.ts +0 -183
  241. package/src/ledger/clients/near.ts +0 -86
  242. package/src/ledger/clients/thorchain/common.ts +0 -117
  243. package/src/ledger/clients/thorchain/helpers.ts +0 -149
  244. package/src/ledger/clients/thorchain/index.ts +0 -94
  245. package/src/ledger/clients/thorchain/lib.ts +0 -300
  246. package/src/ledger/clients/thorchain/utils.ts +0 -76
  247. package/src/ledger/clients/tron.ts +0 -92
  248. package/src/ledger/clients/utxo.ts +0 -148
  249. package/src/ledger/clients/xrp.ts +0 -66
  250. package/src/ledger/cosmosTypes.ts +0 -101
  251. package/src/ledger/helpers/getLedgerAddress.ts +0 -67
  252. package/src/ledger/helpers/getLedgerClient.ts +0 -124
  253. package/src/ledger/helpers/getLedgerTransport.ts +0 -80
  254. package/src/ledger/helpers/index.ts +0 -3
  255. package/src/ledger/index.ts +0 -311
  256. package/src/ledger/interfaces/CosmosLedgerInterface.ts +0 -65
  257. package/src/ledger/types.ts +0 -45
  258. package/src/okx/helpers.ts +0 -181
  259. package/src/okx/index.ts +0 -43
  260. package/src/okx/types.ts +0 -117
  261. package/src/onekey/evmSigner.ts +0 -133
  262. package/src/onekey/index.ts +0 -213
  263. package/src/phantom/index.ts +0 -126
  264. package/src/polkadotjs/index.ts +0 -67
  265. package/src/radix/index.ts +0 -202
  266. package/src/talisman/index.ts +0 -130
  267. package/src/trezor/evmSigner.ts +0 -197
  268. package/src/trezor/index.ts +0 -260
  269. package/src/types.ts +0 -280
  270. package/src/utils.ts +0 -60
  271. package/src/vultisig/index.ts +0 -199
  272. package/src/vultisig/walletHelpers.ts +0 -359
  273. package/src/walletconnect/constants.ts +0 -104
  274. package/src/walletconnect/evmSigner.ts +0 -147
  275. package/src/walletconnect/helpers.ts +0 -77
  276. package/src/walletconnect/index.ts +0 -460
  277. package/src/walletconnect/namespaces.ts +0 -87
  278. package/src/walletconnect/types.ts +0 -6
  279. package/src/xaman/README.md +0 -66
  280. package/src/xaman/helpers.ts +0 -59
  281. package/src/xaman/index.ts +0 -79
  282. package/src/xaman/types.ts +0 -26
  283. package/src/xaman/walletMethods.ts +0 -126
  284. /package/dist/{chunk-mvbb9fwb.js.map → chunk-sbf0f2p4.js.map} +0 -0
@@ -1,78 +0,0 @@
1
- import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
- import {
3
- Chain,
4
- ChainId,
5
- DerivationPath,
6
- type DerivationPathArray,
7
- SKConfig,
8
- derivationPathToString,
9
- } from "@swapkit/helpers";
10
- import type { GenericTransferParams } from "@swapkit/helpers";
11
-
12
- import { bip32ToAddressNList } from "../coins";
13
-
14
- export const cosmosWalletMethods = async ({
15
- sdk,
16
- derivationPath,
17
- }: { sdk: KeepKeySdk; derivationPath?: DerivationPathArray }) => {
18
- const {
19
- DEFAULT_COSMOS_FEE_MAINNET,
20
- getCosmosToolbox,
21
- getFeeRateFromSwapKit,
22
- createStargateClient,
23
- } = await import("@swapkit/toolboxes/cosmos");
24
- const derivationPathString = derivationPath
25
- ? derivationPathToString(derivationPath)
26
- : `${DerivationPath.GAIA}/0`;
27
-
28
- const { address: fromAddress } = (await sdk.address.cosmosGetAddress({
29
- address_n: bip32ToAddressNList(derivationPathString),
30
- })) as { address: string };
31
-
32
- const toolbox = await getCosmosToolbox(Chain.Cosmos);
33
-
34
- if (DEFAULT_COSMOS_FEE_MAINNET.amount[0]) {
35
- DEFAULT_COSMOS_FEE_MAINNET.amount[0].amount = String(
36
- await getFeeRateFromSwapKit(ChainId.Cosmos, 500),
37
- );
38
- }
39
-
40
- // TODO support other cosmos assets
41
- const transfer = async ({ assetValue, recipient, memo }: GenericTransferParams) => {
42
- const amount = assetValue.getBaseValue("string");
43
- const accountInfo = await toolbox.getAccount(fromAddress);
44
-
45
- const keepKeySignedTx = await sdk.cosmos.cosmosSignAmino({
46
- signerAddress: fromAddress,
47
- signDoc: {
48
- fee: DEFAULT_COSMOS_FEE_MAINNET,
49
- memo: memo || "",
50
- sequence: accountInfo?.sequence.toString() ?? "",
51
- chain_id: ChainId.Cosmos,
52
- account_number: accountInfo?.accountNumber.toString() ?? "",
53
- msgs: [
54
- {
55
- value: {
56
- amount: [{ denom: "uatom", amount }],
57
- to_address: recipient,
58
- from_address: fromAddress,
59
- },
60
- type: "cosmos-sdk/MsgSend",
61
- },
62
- ],
63
- },
64
- });
65
-
66
- const decodedBytes = atob(keepKeySignedTx.serialized);
67
- const uint8Array = new Uint8Array(decodedBytes.length).map((_, i) =>
68
- decodedBytes.charCodeAt(i),
69
- );
70
-
71
- const client = await createStargateClient(SKConfig.get("rpcUrls")[Chain.Cosmos]);
72
- const response = await client.broadcastTx(uint8Array);
73
-
74
- return response.transactionHash;
75
- };
76
-
77
- return { ...toolbox, transfer, address: fromAddress };
78
- };
@@ -1,125 +0,0 @@
1
- import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
- import {
3
- type Chain,
4
- ChainToChainId,
5
- type DerivationPathArray,
6
- NetworkDerivationPath,
7
- SwapKitError,
8
- derivationPathToString,
9
- } from "@swapkit/helpers";
10
- import type { JsonRpcProvider, Provider, TransactionRequest } from "ethers";
11
- import { AbstractSigner } from "ethers";
12
-
13
- import { bip32ToAddressNList } from "../coins";
14
-
15
- interface KeepKeyEVMSignerParams {
16
- sdk: KeepKeySdk;
17
- chain: Chain;
18
- derivationPath?: DerivationPathArray;
19
- provider: Provider | JsonRpcProvider;
20
- }
21
-
22
- export class KeepKeySigner extends AbstractSigner {
23
- private sdk: KeepKeySdk;
24
- private chain: Chain;
25
- private derivationPath: DerivationPathArray;
26
- private address: string;
27
- readonly provider: Provider | JsonRpcProvider;
28
-
29
- constructor({ sdk, chain, derivationPath, provider }: KeepKeyEVMSignerParams) {
30
- super();
31
- this.sdk = sdk;
32
- this.chain = chain;
33
- this.derivationPath = derivationPath || NetworkDerivationPath.ETH;
34
- this.address = "";
35
- this.provider = provider;
36
- }
37
-
38
- signTypedData(): Promise<string> {
39
- throw new SwapKitError("wallet_keepkey_method_not_supported", { method: "signTypedData" });
40
- }
41
-
42
- getAddress = async () => {
43
- if (this.address) return this.address;
44
- const { address } = await this.sdk.address.ethereumGetAddress({
45
- address_n: bip32ToAddressNList(derivationPathToString(this.derivationPath)),
46
- });
47
-
48
- this.address = address;
49
- return address;
50
- };
51
-
52
- signMessage = (message: string) =>
53
- this.sdk.eth.ethSign({ address: this.address, message }) as Promise<string>;
54
-
55
- signTransaction = async ({
56
- to,
57
- value,
58
- gasLimit,
59
- nonce,
60
- data,
61
- maxFeePerGas,
62
- maxPriorityFeePerGas,
63
- gasPrice,
64
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
65
- }: TransactionRequest) => {
66
- if (!to)
67
- throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing to address" });
68
- if (!gasLimit)
69
- throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing gasLimit" });
70
- if (!data) throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing data" });
71
-
72
- const isEIP1559 = !!((maxFeePerGas || maxPriorityFeePerGas) && !gasPrice);
73
- if (isEIP1559 && !maxFeePerGas)
74
- throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing maxFeePerGas" });
75
- if (isEIP1559 && !maxPriorityFeePerGas)
76
- throw new SwapKitError("wallet_keepkey_invalid_params", {
77
- reason: "Missing maxPriorityFeePerGas",
78
- });
79
- if (!(isEIP1559 || gasPrice))
80
- throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing gasPrice" });
81
-
82
- const { toHexString } = await import("@swapkit/toolboxes/evm");
83
-
84
- const nonceValue = nonce
85
- ? BigInt(nonce)
86
- : BigInt(await this.provider.getTransactionCount(await this.getAddress(), "pending"));
87
-
88
- const input = {
89
- gas: toHexString(BigInt(gasLimit)),
90
- addressNList: [2147483692, 2147483708, 2147483648, 0, 0],
91
- from: this.address,
92
- chainId: toHexString(BigInt(ChainToChainId[this.chain])),
93
- to: to.toString(),
94
- value: toHexString(BigInt(value || 0)),
95
- nonce: toHexString(nonceValue),
96
- data,
97
- ...(isEIP1559 && {
98
- maxFeePerGas: toHexString(BigInt(maxFeePerGas?.toString() || "0")),
99
- maxPriorityFeePerGas: toHexString(BigInt(maxPriorityFeePerGas?.toString() || "0")),
100
- }),
101
- ...(!isEIP1559 && {
102
- // Fixed syntax error and structure here
103
- gasPrice: toHexString(BigInt(gasPrice?.toString() || "0")),
104
- }),
105
- };
106
- const responseSign = await this.sdk.eth.ethSignTransaction(input);
107
- return responseSign.serialized;
108
- };
109
-
110
- sendTransaction = async (tx: TransactionRequest): Promise<any> => {
111
- if (!this.provider) throw new SwapKitError("wallet_keepkey_no_provider");
112
-
113
- const signedTxHex = await this.signTransaction(tx);
114
-
115
- return await this.provider.broadcastTransaction(signedTxHex);
116
- };
117
-
118
- connect = (provider: Provider) =>
119
- new KeepKeySigner({
120
- sdk: this.sdk,
121
- chain: this.chain,
122
- derivationPath: this.derivationPath,
123
- provider,
124
- });
125
- }
@@ -1,123 +0,0 @@
1
- import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
- import {
3
- type AssetValue,
4
- Chain,
5
- ChainId,
6
- DerivationPath,
7
- type DerivationPathArray,
8
- type GenericTransferParams,
9
- SKConfig,
10
- SwapKitError,
11
- derivationPathToString,
12
- } from "@swapkit/helpers";
13
- import type { ThorchainDepositParams } from "@swapkit/toolboxes/cosmos";
14
-
15
- import { bip32ToAddressNList } from "../coins";
16
-
17
- type SignTransactionParams = {
18
- assetValue: AssetValue;
19
- recipient?: string;
20
- sender: string;
21
- memo: string | undefined;
22
- };
23
-
24
- export const mayachainWalletMethods = async ({
25
- sdk,
26
- derivationPath,
27
- }: {
28
- sdk: KeepKeySdk;
29
- derivationPath?: DerivationPathArray;
30
- }) => {
31
- const { createStargateClient, getCosmosToolbox } = await import("@swapkit/toolboxes/cosmos");
32
-
33
- const toolbox = await getCosmosToolbox(Chain.Maya);
34
- const derivationPathString = derivationPath
35
- ? derivationPathToString(derivationPath)
36
- : `${DerivationPath.MAYA}/0`;
37
-
38
- const { address: fromAddress } = (await sdk.address.mayachainGetAddress({
39
- address_n: bip32ToAddressNList(derivationPathString),
40
- })) as { address: string };
41
-
42
- const signTransaction = async ({
43
- assetValue,
44
- recipient,
45
- sender,
46
- memo,
47
- }: SignTransactionParams) => {
48
- const importedAmino = await import("@cosmjs/amino");
49
- const makeSignDoc = importedAmino.makeSignDoc ?? importedAmino.default?.makeSignDoc;
50
- const { getDenomWithChain } = await import("@swapkit/toolboxes/cosmos");
51
-
52
- const account = await toolbox.getAccount(sender);
53
- if (!account) throw new SwapKitError("wallet_keepkey_account_not_found");
54
- const { accountNumber, sequence = 0 } = account;
55
- const amount = assetValue.getBaseValue("string");
56
-
57
- const isTransfer = recipient && recipient !== "";
58
-
59
- // TODO check if we can move to toolbox created msg
60
- const msg = isTransfer
61
- ? {
62
- type: "mayachain/MsgSend",
63
- value: {
64
- amount: [{ amount, denom: assetValue.symbol.toLowerCase() }],
65
- from_address: sender,
66
- to_address: recipient,
67
- },
68
- }
69
- : {
70
- type: "mayachain/MsgDeposit",
71
- value: {
72
- coins: [{ amount, asset: getDenomWithChain(assetValue) }],
73
- memo,
74
- signer: sender,
75
- },
76
- };
77
-
78
- const signDoc = makeSignDoc(
79
- [msg],
80
- { gas: "500000000", amount: [] },
81
- ChainId.Maya,
82
- memo,
83
- accountNumber?.toString(),
84
- sequence,
85
- );
86
-
87
- const sdkMethod = isTransfer
88
- ? sdk.mayachain.mayachainSignAminoTransfer
89
- : sdk.mayachain.mayachainSignAminoDeposit;
90
-
91
- // @ts-expect-error TC
92
- const signedTx = await sdkMethod({ signDoc, signerAddress: sender });
93
- const decodedBytes = atob(signedTx.serialized);
94
- return new Uint8Array(decodedBytes.length).map((_, i) => decodedBytes.charCodeAt(i));
95
- };
96
-
97
- const transfer = async ({ assetValue, recipient, memo }: GenericTransferParams) => {
98
- const stargateClient = await createStargateClient(SKConfig.get("rpcUrls")[Chain.Maya]);
99
- const signedTransaction = await signTransaction({
100
- assetValue,
101
- recipient,
102
- memo,
103
- sender: fromAddress,
104
- });
105
- const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
106
-
107
- return transactionHash;
108
- };
109
-
110
- const deposit = async ({ assetValue, memo }: ThorchainDepositParams) => {
111
- const stargateClient = await createStargateClient(SKConfig.get("rpcUrls")[Chain.Maya]);
112
- const signedTransaction = await signTransaction({
113
- assetValue,
114
- memo,
115
- sender: fromAddress,
116
- });
117
- const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
118
-
119
- return transactionHash;
120
- };
121
-
122
- return { ...toolbox, transfer, deposit, address: fromAddress };
123
- };
@@ -1,118 +0,0 @@
1
- import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
- import {
3
- Chain,
4
- DerivationPath,
5
- type DerivationPathArray,
6
- type GenericTransferParams,
7
- derivationPathToString,
8
- } from "@swapkit/helpers";
9
- import { bip32ToAddressNList } from "../coins";
10
-
11
- import { getRippleToolbox } from "@swapkit/toolboxes/ripple";
12
-
13
- export const rippleWalletMethods = async ({
14
- sdk,
15
- derivationPath,
16
- }: {
17
- sdk: KeepKeySdk;
18
- derivationPath?: DerivationPathArray;
19
- }) => {
20
- // Derivation path handling (default to standard XRP 44'/144'/0'/0/0)
21
- const derivationPathString = derivationPath
22
- ? derivationPathToString(derivationPath)
23
- : `${DerivationPath[Chain.Ripple]}/0`;
24
-
25
- // Fetch address from KeepKey
26
- // @ts-ignore - keepkey-sdk typings may not yet include xrpGetAddress
27
- const { address } = await (sdk as any).address.xrpGetAddress({
28
- address_n: bip32ToAddressNList(derivationPathString),
29
- });
30
-
31
- // Inject minimal signer so toolbox's address helpers work
32
- const signer = {
33
- getAddress: () => Promise.resolve(address),
34
- signTransaction: () => {
35
- throw new Error("signTransaction not supported via toolbox");
36
- },
37
- };
38
-
39
- const toolbox = await getRippleToolbox({ signer });
40
-
41
- const transfer = async ({ recipient, assetValue, memo }: GenericTransferParams) => {
42
- // Build XRPL Payment tx using toolbox helper
43
- const tx = await toolbox.createTransaction({
44
- assetValue,
45
- recipient,
46
- memo,
47
- sender: address,
48
- });
49
-
50
- // Convert toolbox Payment tx into KeepKey StdTx wrapper (KeepKey-specific format)
51
- const stdTx = {
52
- type: "auth/StdTx",
53
- value: {
54
- fee: {
55
- amount: [
56
- {
57
- amount: "1000",
58
- denom: "drop",
59
- },
60
- ],
61
- gas: "28000",
62
- },
63
- memo: memo && memo.length > 0 ? memo : "",
64
- msg: [
65
- {
66
- type: "ripple-sdk/MsgSend",
67
- value: {
68
- amount: [
69
- {
70
- amount: tx.Amount,
71
- denom: "drop",
72
- },
73
- ],
74
- from_address: address,
75
- to_address: recipient,
76
- },
77
- },
78
- ],
79
- signatures: null,
80
- },
81
- };
82
-
83
- const unsignedTx = {
84
- addressNList: bip32ToAddressNList(derivationPathString),
85
- tx: stdTx,
86
- flags: tx.Flags === 0 ? undefined : tx.Flags,
87
- lastLedgerSequence: tx.LastLedgerSequence?.toString(),
88
- sequence: (tx.Sequence ?? 0).toString(),
89
- payment: {
90
- amount: tx.Amount,
91
- destination: tx.Destination,
92
- destinationTag: (tx.DestinationTag ?? "0").toString(),
93
- },
94
- } as any;
95
-
96
- // Sign with KeepKey
97
- // @ts-ignore - typings missing
98
- const responseSign = JSON.parse(await (sdk as any).xrp.xrpSignTransaction(unsignedTx));
99
-
100
- // keepkey-sdk may return either { tx_blob } or StdTx with Base64 serializedTx
101
- const txBlob: string | undefined =
102
- (responseSign as any).tx_blob ?? (responseSign as any).value?.signatures?.[0]?.serializedTx;
103
- if (!txBlob) throw new Error("KeepKey XRP sign failed");
104
-
105
- const buffer = Buffer.from(txBlob, "base64");
106
- const txBlobHex = buffer.toString("hex");
107
-
108
- // Broadcast signed tx via toolbox
109
- return toolbox.broadcastTransaction(txBlobHex);
110
- };
111
-
112
- return {
113
- ...toolbox,
114
- address,
115
- getAddress: () => address,
116
- transfer,
117
- };
118
- };
@@ -1,118 +0,0 @@
1
- import type {
2
- KeepKeySdk,
3
- TypesThorchainSignDocDeposit,
4
- TypesThorchainSignDocTransfer,
5
- } from "@keepkey/keepkey-sdk";
6
- import {
7
- type AssetValue,
8
- Chain,
9
- ChainId,
10
- DerivationPath,
11
- type DerivationPathArray,
12
- type GenericTransferParams,
13
- SKConfig,
14
- SwapKitError,
15
- derivationPathToString,
16
- } from "@swapkit/helpers";
17
- import type { ThorchainDepositParams } from "@swapkit/toolboxes/cosmos";
18
-
19
- import { bip32ToAddressNList } from "../coins";
20
-
21
- type SignTransactionParams = {
22
- assetValue: AssetValue;
23
- recipient?: string;
24
- sender: string;
25
- memo: string | undefined;
26
- };
27
-
28
- export const thorchainWalletMethods = async ({
29
- sdk,
30
- derivationPath,
31
- }: {
32
- sdk: KeepKeySdk;
33
- derivationPath?: DerivationPathArray;
34
- }) => {
35
- const importedAmino = await import("@cosmjs/amino");
36
- const makeSignDoc = importedAmino.makeSignDoc ?? importedAmino.default?.makeSignDoc;
37
- const { buildAminoMsg, getDefaultChainFee, createStargateClient, getCosmosToolbox } =
38
- await import("@swapkit/toolboxes/cosmos");
39
-
40
- const toolbox = await getCosmosToolbox(Chain.THORChain);
41
- const derivationPathString = derivationPath
42
- ? derivationPathToString(derivationPath)
43
- : `${DerivationPath.THOR}/0`;
44
-
45
- const { address: fromAddress } = (await sdk.address.thorchainGetAddress({
46
- address_n: bip32ToAddressNList(derivationPathString),
47
- })) as { address: string };
48
-
49
- const signTransaction = async ({
50
- assetValue,
51
- recipient,
52
- sender,
53
- memo,
54
- }: SignTransactionParams) => {
55
- const account = await toolbox.getAccount(sender);
56
- if (!account) throw new SwapKitError("wallet_keepkey_account_not_found");
57
- const { accountNumber, sequence = 0 } = account;
58
-
59
- const isTransfer = recipient && recipient !== "";
60
-
61
- const msg = buildAminoMsg({ sender, recipient, assetValue, memo });
62
-
63
- const chainId = ChainId.THORChain;
64
-
65
- const signDoc = makeSignDoc(
66
- [msg],
67
- getDefaultChainFee(Chain.THORChain),
68
- chainId,
69
- memo,
70
- accountNumber?.toString(),
71
- sequence,
72
- );
73
-
74
- const signedTx = isTransfer
75
- ? await sdk.thorchain.thorchainSignAminoTransfer({
76
- signDoc: signDoc as TypesThorchainSignDocTransfer,
77
- signerAddress: sender,
78
- })
79
- : await sdk.thorchain.thorchainSignAminoDeposit({
80
- signDoc: signDoc as TypesThorchainSignDocDeposit,
81
- signerAddress: sender,
82
- });
83
- const decodedBytes = atob(signedTx.serialized);
84
- return new Uint8Array(decodedBytes.length).map((_, i) => decodedBytes.charCodeAt(i));
85
- };
86
-
87
- const transfer = async ({ assetValue, recipient, memo }: GenericTransferParams) => {
88
- const stargateClient = await createStargateClient(SKConfig.get("rpcUrls")[Chain.THORChain]);
89
- const signedTransaction = await signTransaction({
90
- assetValue,
91
- recipient,
92
- memo,
93
- sender: fromAddress,
94
- });
95
- const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
96
-
97
- return transactionHash;
98
- };
99
-
100
- const deposit = async ({ assetValue, memo }: ThorchainDepositParams) => {
101
- const stargateClient = await createStargateClient(SKConfig.get("rpcUrls")[Chain.THORChain]);
102
- const signedTransaction = await signTransaction({
103
- assetValue,
104
- memo,
105
- sender: fromAddress,
106
- });
107
- const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
108
-
109
- return transactionHash;
110
- };
111
-
112
- // const signMessage = async (message: string) => {
113
- // const stargateClient = await createStargateClient(RPCUrl.THORChain);
114
- // // return signedTx;
115
- // };
116
-
117
- return { ...toolbox, transfer, deposit, address: fromAddress };
118
- };
@@ -1,147 +0,0 @@
1
- import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
- import {
3
- Chain,
4
- DerivationPath,
5
- type DerivationPathArray,
6
- FeeOption,
7
- type GenericTransferParams,
8
- SwapKitError,
9
- type UTXOChain,
10
- derivationPathToString,
11
- } from "@swapkit/helpers";
12
- import type { Psbt } from "bitcoinjs-lib";
13
-
14
- import type { UTXOToolboxes } from "@swapkit/toolboxes/utxo";
15
- import { ChainToKeepKeyName, bip32ToAddressNList } from "../coins";
16
-
17
- interface KeepKeyInputObject {
18
- addressNList: number[];
19
- scriptType: string;
20
- amount: string;
21
- vout: number;
22
- txid: string;
23
- hex: string;
24
- }
25
-
26
- export const utxoWalletMethods = async ({
27
- sdk,
28
- chain,
29
- derivationPath,
30
- }: {
31
- sdk: KeepKeySdk;
32
- chain: Exclude<UTXOChain, Chain.Zcash>;
33
- derivationPath?: DerivationPathArray;
34
- }) => {
35
- const { getUtxoToolbox } = await import("@swapkit/toolboxes/utxo");
36
- // This might not work for BCH
37
- const toolbox = await getUtxoToolbox(chain);
38
- const scriptType = [Chain.Bitcoin, Chain.Litecoin].includes(chain)
39
- ? ("p2wpkh" as const)
40
- : ("p2pkh" as const);
41
-
42
- const derivationPathString = derivationPath
43
- ? derivationPathToString(derivationPath)
44
- : `${DerivationPath[chain]}/0`;
45
-
46
- const addressInfo = {
47
- coin: ChainToKeepKeyName[chain],
48
- script_type: scriptType,
49
- address_n: bip32ToAddressNList(derivationPathString),
50
- };
51
-
52
- const walletAddress: string = (await sdk.address.utxoGetAddress(addressInfo)).address;
53
-
54
- const signTransaction = async (psbt: Psbt, inputs: KeepKeyInputObject[], memo = "") => {
55
- const outputs = psbt.txOutputs
56
- .map((output) => {
57
- const { value, address, change } = output as {
58
- address: string;
59
- script: Buffer;
60
- value: number;
61
- change?: boolean;
62
- };
63
-
64
- const outputAddress =
65
- // @ts-expect-error - stripToCashAddress is not defined in the UTXO toolbox just only on BCH
66
- chain === Chain.BitcoinCash ? toolbox.stripToCashAddress(address) : address;
67
-
68
- if (change || address === walletAddress) {
69
- return {
70
- addressNList: addressInfo.address_n,
71
- isChange: true,
72
- addressType: "change",
73
- amount: value,
74
- scriptType,
75
- };
76
- }
77
-
78
- if (outputAddress) {
79
- return { address: outputAddress, amount: value, addressType: "spend" };
80
- }
81
-
82
- return null;
83
- })
84
- .filter(Boolean);
85
-
86
- const removeNullAndEmptyObjectsFromArray = (arr: any[]) => {
87
- return arr.filter(
88
- (item) => item !== null && typeof item === "object" && Object.keys(item).length > 0,
89
- );
90
- };
91
-
92
- const responseSign = await sdk.utxo.utxoSignTransaction({
93
- coin: ChainToKeepKeyName[chain],
94
- inputs,
95
- outputs: removeNullAndEmptyObjectsFromArray(outputs),
96
- opReturnData: memo,
97
- });
98
-
99
- return responseSign.serializedTx?.toString();
100
- };
101
-
102
- const transfer = async ({
103
- recipient,
104
- feeOptionKey,
105
- feeRate,
106
- memo,
107
- ...rest
108
- }: GenericTransferParams) => {
109
- if (!walletAddress)
110
- throw new SwapKitError("wallet_keepkey_invalid_params", {
111
- reason: "From address must be provided",
112
- });
113
- if (!recipient)
114
- throw new SwapKitError("wallet_keepkey_invalid_params", {
115
- reason: "Recipient address must be provided",
116
- });
117
-
118
- const createTxMethod =
119
- chain === Chain.BitcoinCash
120
- ? (toolbox as UTXOToolboxes["BCH"]).buildTx
121
- : (toolbox as UTXOToolboxes["BTC"]).createTransaction;
122
-
123
- const { psbt, inputs: rawInputs } = await createTxMethod({
124
- ...rest,
125
- memo,
126
- recipient,
127
- feeRate: feeRate || (await toolbox.getFeeRates())[feeOptionKey || FeeOption.Fast],
128
- sender: walletAddress,
129
- fetchTxHex: true,
130
- });
131
-
132
- const inputs = rawInputs.map(({ value, index, hash, txHex }) => ({
133
- //@TODO don't hardcode master, lookup on blockbook what input this is for and what path that address is!
134
- addressNList: addressInfo.address_n,
135
- amount: value.toString(),
136
- hex: txHex || "",
137
- scriptType,
138
- txid: hash,
139
- vout: index,
140
- }));
141
-
142
- const txHex = await signTransaction(psbt, inputs, memo);
143
- return toolbox.broadcastTx(txHex);
144
- };
145
-
146
- return { ...toolbox, signTransaction, transfer, address: walletAddress };
147
- };