@swapkit/wallet-hardware 4.8.1 → 4.8.3

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 (34) hide show
  1. package/package.json +3 -3
  2. package/src/index.ts +1 -0
  3. package/src/keepkey/chains/cosmos.ts +69 -0
  4. package/src/keepkey/chains/evm.ts +141 -0
  5. package/src/keepkey/chains/mayachain.ts +98 -0
  6. package/src/keepkey/chains/ripple.ts +88 -0
  7. package/src/keepkey/chains/thorchain.ts +93 -0
  8. package/src/keepkey/chains/utxo.ts +364 -0
  9. package/src/keepkey/coins.ts +67 -0
  10. package/src/keepkey/index.ts +174 -0
  11. package/src/ledger/clients/cosmos.ts +84 -0
  12. package/src/ledger/clients/evm.ts +186 -0
  13. package/src/ledger/clients/near.ts +63 -0
  14. package/src/ledger/clients/sui.ts +130 -0
  15. package/src/ledger/clients/thorchain/common.ts +93 -0
  16. package/src/ledger/clients/thorchain/helpers.ts +120 -0
  17. package/src/ledger/clients/thorchain/index.ts +87 -0
  18. package/src/ledger/clients/thorchain/lib.ts +258 -0
  19. package/src/ledger/clients/thorchain/utils.ts +69 -0
  20. package/src/ledger/clients/tron.ts +85 -0
  21. package/src/ledger/clients/utxo-legacy-adapter.ts +71 -0
  22. package/src/ledger/clients/utxo-psbt.ts +145 -0
  23. package/src/ledger/clients/utxo.ts +359 -0
  24. package/src/ledger/clients/xrp.ts +50 -0
  25. package/src/ledger/cosmosTypes.ts +98 -0
  26. package/src/ledger/helpers/getLedgerAddress.ts +76 -0
  27. package/src/ledger/helpers/getLedgerClient.ts +124 -0
  28. package/src/ledger/helpers/getLedgerTransport.ts +102 -0
  29. package/src/ledger/helpers/index.ts +3 -0
  30. package/src/ledger/index.ts +546 -0
  31. package/src/ledger/interfaces/CosmosLedgerInterface.ts +54 -0
  32. package/src/ledger/types.ts +42 -0
  33. package/src/trezor/evmSigner.ts +210 -0
  34. package/src/trezor/index.ts +847 -0
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "@near-js/transactions": "~2.5.0",
23
23
  "@scure/base": "2.0.0",
24
24
  "@swapkit/helpers": "^4.13.0",
25
- "@swapkit/toolboxes": "^4.15.0",
25
+ "@swapkit/toolboxes": "^4.15.5",
26
26
  "@swapkit/utxo-signer": "^2.1.1",
27
27
  "@swapkit/wallet-core": "^4.2.0",
28
28
  "@trezor/connect-web": "~9.6.4",
@@ -89,7 +89,7 @@
89
89
  "types": "./dist/types/trezor/index.d.ts"
90
90
  }
91
91
  },
92
- "files": ["dist/"],
92
+ "files": ["dist/", "src/"],
93
93
  "homepage": "https://github.com/swapkit/wallets",
94
94
  "license": "SEE LICENSE IN LICENSE",
95
95
  "name": "@swapkit/wallet-hardware",
@@ -107,5 +107,5 @@
107
107
  "type-check:go": "tsgo"
108
108
  },
109
109
  "type": "module",
110
- "version": "4.8.1"
110
+ "version": "4.8.3"
111
111
  }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,69 @@
1
+ import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
+ import type { GenericTransferParams } from "@swapkit/helpers";
3
+ import {
4
+ Chain,
5
+ DerivationPath,
6
+ type DerivationPathArray,
7
+ derivationPathToString,
8
+ GAIAConfig,
9
+ getRPCUrl,
10
+ } from "@swapkit/helpers";
11
+
12
+ import { bip32ToAddressNList } from "../coins";
13
+
14
+ export async function cosmosWalletMethods({
15
+ sdk,
16
+ derivationPath,
17
+ }: {
18
+ sdk: KeepKeySdk;
19
+ derivationPath?: DerivationPathArray;
20
+ }): Promise<any> {
21
+ const { DEFAULT_COSMOS_FEE_MAINNET, getCosmosToolbox, getFeeRateFromSwapKit, createStargateClient } = await import(
22
+ "@swapkit/toolboxes/cosmos"
23
+ );
24
+ const derivationPathString = derivationPath ? derivationPathToString(derivationPath) : `${DerivationPath.GAIA}/0`;
25
+
26
+ const { address: fromAddress } = (await sdk.address.cosmosGetAddress({
27
+ address_n: bip32ToAddressNList(derivationPathString),
28
+ })) as { address: string };
29
+
30
+ const toolbox = await getCosmosToolbox(Chain.Cosmos);
31
+
32
+ if (DEFAULT_COSMOS_FEE_MAINNET.amount[0]) {
33
+ DEFAULT_COSMOS_FEE_MAINNET.amount[0].amount = String(await getFeeRateFromSwapKit(GAIAConfig.chainId, 500));
34
+ }
35
+
36
+ // TODO support other cosmos assets
37
+ const transfer = async ({ assetValue, recipient, memo }: GenericTransferParams) => {
38
+ const amount = assetValue.getBaseValue("string");
39
+ const accountInfo = await toolbox.getAccount(fromAddress);
40
+
41
+ const keepKeySignedTx = await sdk.cosmos.cosmosSignAmino({
42
+ signDoc: {
43
+ account_number: accountInfo?.accountNumber.toString() ?? "",
44
+ chain_id: GAIAConfig.chainId,
45
+ fee: DEFAULT_COSMOS_FEE_MAINNET,
46
+ memo: memo || "",
47
+ msgs: [
48
+ {
49
+ type: "cosmos-sdk/MsgSend",
50
+ value: { amount: [{ amount, denom: "uatom" }], from_address: fromAddress, to_address: recipient },
51
+ },
52
+ ],
53
+ sequence: accountInfo?.sequence.toString() ?? "",
54
+ },
55
+ signerAddress: fromAddress,
56
+ });
57
+
58
+ const decodedBytes = atob(keepKeySignedTx.serialized);
59
+ const uint8Array = new Uint8Array(decodedBytes.length).map((_, i) => decodedBytes.charCodeAt(i));
60
+
61
+ const rpcUrl = await getRPCUrl(Chain.Cosmos);
62
+ const client = await createStargateClient(rpcUrl);
63
+ const response = await client.broadcastTx(uint8Array);
64
+
65
+ return response.transactionHash;
66
+ };
67
+
68
+ return { ...toolbox, address: fromAddress, transfer };
69
+ }
@@ -0,0 +1,141 @@
1
+ import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
+ import {
3
+ type Chain,
4
+ ChainToChainId,
5
+ type DerivationPathArray,
6
+ derivationPathToString,
7
+ NetworkDerivationPath,
8
+ SwapKitError,
9
+ } from "@swapkit/helpers";
10
+ import type { JsonRpcProvider, Provider, TransactionRequest, TypedDataDomain, TypedDataField } 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 = async (
39
+ domain: TypedDataDomain,
40
+ types: Record<string, TypedDataField[]>,
41
+ value: Record<string, unknown>,
42
+ explicitPrimaryType?: string,
43
+ ) => {
44
+ const { buildEIP712DomainType } = await import("@swapkit/toolboxes/evm");
45
+ const { TypedDataEncoder } = await import("ethers");
46
+
47
+ const { EIP712Domain: _, ...filteredTypes } = types;
48
+ const primaryType = explicitPrimaryType ?? TypedDataEncoder.from(filteredTypes).primaryType;
49
+ const domainTypes = buildEIP712DomainType(domain);
50
+
51
+ const address = await this.getAddress();
52
+ const result = await this.sdk.eth.ethSignTypedData({
53
+ address,
54
+ typedData: {
55
+ domain: domain as Record<string, unknown>,
56
+ message: value,
57
+ primaryType,
58
+ types: { EIP712Domain: domainTypes, ...filteredTypes },
59
+ },
60
+ });
61
+
62
+ if (typeof result !== "string") {
63
+ throw new SwapKitError("wallet_keepkey_method_not_supported", { method: "signTypedData" });
64
+ }
65
+
66
+ return result.startsWith("0x") ? result : `0x${result}`;
67
+ };
68
+
69
+ getAddress = async () => {
70
+ if (this.address) return this.address;
71
+ const { address } = await this.sdk.address.ethereumGetAddress({
72
+ address_n: bip32ToAddressNList(derivationPathToString(this.derivationPath)),
73
+ });
74
+
75
+ this.address = address;
76
+ return address;
77
+ };
78
+
79
+ signMessage = (message: string) => this.sdk.eth.ethSign({ address: this.address, message }) as Promise<string>;
80
+
81
+ signTransaction = async ({
82
+ to,
83
+ value,
84
+ gasLimit,
85
+ nonce,
86
+ data,
87
+ maxFeePerGas,
88
+ maxPriorityFeePerGas,
89
+ gasPrice,
90
+ }: TransactionRequest) => {
91
+ if (!to) throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing to address" });
92
+ if (!gasLimit) throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing gasLimit" });
93
+ if (!data) throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing data" });
94
+
95
+ const isEIP1559 = !!((maxFeePerGas || maxPriorityFeePerGas) && !gasPrice);
96
+ if (isEIP1559 && !maxFeePerGas)
97
+ throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing maxFeePerGas" });
98
+ if (isEIP1559 && !maxPriorityFeePerGas)
99
+ throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing maxPriorityFeePerGas" });
100
+ if (!(isEIP1559 || gasPrice))
101
+ throw new SwapKitError("wallet_keepkey_invalid_params", { reason: "Missing gasPrice" });
102
+
103
+ const { toHexString } = await import("@swapkit/toolboxes/evm");
104
+
105
+ const nonceValue = nonce
106
+ ? BigInt(nonce)
107
+ : BigInt(await this.provider.getTransactionCount(await this.getAddress(), "pending"));
108
+
109
+ const input = {
110
+ addressNList: [2147483692, 2147483708, 2147483648, 0, 0],
111
+ chainId: toHexString(BigInt(ChainToChainId[this.chain])),
112
+ data,
113
+ from: this.address,
114
+ gas: toHexString(BigInt(gasLimit)),
115
+ nonce: toHexString(nonceValue),
116
+ to: to.toString(),
117
+ value: toHexString(BigInt(value || 0)),
118
+ ...(isEIP1559 && {
119
+ maxFeePerGas: toHexString(BigInt(maxFeePerGas?.toString() || "0")),
120
+ maxPriorityFeePerGas: toHexString(BigInt(maxPriorityFeePerGas?.toString() || "0")),
121
+ }),
122
+ ...(!isEIP1559 && {
123
+ // Fixed syntax error and structure here
124
+ gasPrice: toHexString(BigInt(gasPrice?.toString() || "0")),
125
+ }),
126
+ };
127
+ const responseSign = await this.sdk.eth.ethSignTransaction(input);
128
+ return responseSign.serialized;
129
+ };
130
+
131
+ sendTransaction = async (tx: TransactionRequest): Promise<any> => {
132
+ if (!this.provider) throw new SwapKitError("wallet_keepkey_no_provider");
133
+
134
+ const signedTxHex = await this.signTransaction(tx);
135
+
136
+ return await this.provider.broadcastTransaction(signedTxHex);
137
+ };
138
+
139
+ connect = (provider: Provider) =>
140
+ new KeepKeySigner({ chain: this.chain, derivationPath: this.derivationPath, provider, sdk: this.sdk });
141
+ }
@@ -0,0 +1,98 @@
1
+ import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
+ import {
3
+ type AssetValue,
4
+ Chain,
5
+ DerivationPath,
6
+ type DerivationPathArray,
7
+ derivationPathToString,
8
+ type GenericTransferParams,
9
+ getRPCUrl,
10
+ MAYAConfig,
11
+ SwapKitError,
12
+ } from "@swapkit/helpers";
13
+ import type { ThorchainDepositParams } from "@swapkit/toolboxes/cosmos";
14
+
15
+ import { bip32ToAddressNList } from "../coins";
16
+
17
+ type SignTransactionParams = { assetValue: AssetValue; recipient?: string; sender: string; memo: string | undefined };
18
+
19
+ export async function mayachainWalletMethods({
20
+ sdk,
21
+ derivationPath,
22
+ }: {
23
+ sdk: KeepKeySdk;
24
+ derivationPath?: DerivationPathArray;
25
+ }): Promise<any> {
26
+ const { createStargateClient, getCosmosToolbox } = await import("@swapkit/toolboxes/cosmos");
27
+
28
+ const toolbox = await getCosmosToolbox(Chain.Maya);
29
+ const derivationPathString = derivationPath ? derivationPathToString(derivationPath) : `${DerivationPath.MAYA}/0`;
30
+
31
+ const { address: fromAddress } = (await sdk.address.mayachainGetAddress({
32
+ address_n: bip32ToAddressNList(derivationPathString),
33
+ })) as { address: string };
34
+
35
+ const signTransaction = async ({ assetValue, recipient, sender, memo }: SignTransactionParams) => {
36
+ const importedAmino = await import("@cosmjs/amino");
37
+ const makeSignDoc = importedAmino.makeSignDoc ?? importedAmino.default?.makeSignDoc;
38
+ const { getDenomWithChain } = await import("@swapkit/toolboxes/cosmos");
39
+
40
+ const account = await toolbox.getAccount(sender);
41
+ if (!account) throw new SwapKitError("wallet_keepkey_account_not_found");
42
+ const { accountNumber, sequence = 0 } = account;
43
+ const amount = assetValue.getBaseValue("string");
44
+
45
+ const isTransfer = recipient && recipient !== "";
46
+
47
+ // TODO check if we can move to toolbox created msg
48
+ const msg = isTransfer
49
+ ? {
50
+ type: "mayachain/MsgSend",
51
+ value: {
52
+ amount: [{ amount, denom: assetValue.symbol.toLowerCase() }],
53
+ from_address: sender,
54
+ to_address: recipient,
55
+ },
56
+ }
57
+ : {
58
+ type: "mayachain/MsgDeposit",
59
+ value: { coins: [{ amount, asset: getDenomWithChain(assetValue) }], memo, signer: sender },
60
+ };
61
+
62
+ const signDoc = makeSignDoc(
63
+ [msg],
64
+ { amount: [], gas: "500000000" },
65
+ MAYAConfig.chainId,
66
+ memo,
67
+ accountNumber?.toString(),
68
+ sequence,
69
+ );
70
+
71
+ const sdkMethod = isTransfer ? sdk.mayachain.mayachainSignAminoTransfer : sdk.mayachain.mayachainSignAminoDeposit;
72
+
73
+ // @ts-expect-error TC
74
+ const signedTx = await sdkMethod({ signDoc, signerAddress: sender });
75
+ const decodedBytes = atob(signedTx.serialized);
76
+ return new Uint8Array(decodedBytes.length).map((_, i) => decodedBytes.charCodeAt(i));
77
+ };
78
+
79
+ const transfer = async ({ assetValue, recipient, memo }: GenericTransferParams) => {
80
+ const rpcUrl = await getRPCUrl(Chain.Maya);
81
+ const stargateClient = await createStargateClient(rpcUrl);
82
+ const signedTransaction = await signTransaction({ assetValue, memo, recipient, sender: fromAddress });
83
+ const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
84
+
85
+ return transactionHash;
86
+ };
87
+
88
+ const deposit = async ({ assetValue, memo }: ThorchainDepositParams) => {
89
+ const rpcUrl = await getRPCUrl(Chain.Maya);
90
+ const stargateClient = await createStargateClient(rpcUrl);
91
+ const signedTransaction = await signTransaction({ assetValue, memo, sender: fromAddress });
92
+ const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
93
+
94
+ return transactionHash;
95
+ };
96
+
97
+ return { ...toolbox, address: fromAddress, deposit, transfer };
98
+ }
@@ -0,0 +1,88 @@
1
+ import type { KeepKeySdk } from "@keepkey/keepkey-sdk";
2
+ import {
3
+ Chain,
4
+ DerivationPath,
5
+ type DerivationPathArray,
6
+ derivationPathToString,
7
+ type GenericTransferParams,
8
+ } from "@swapkit/helpers";
9
+ import { getRippleToolbox } from "@swapkit/toolboxes/ripple";
10
+ import { bip32ToAddressNList } from "../coins";
11
+
12
+ export const rippleWalletMethods = async ({
13
+ sdk,
14
+ derivationPath,
15
+ }: {
16
+ sdk: KeepKeySdk;
17
+ derivationPath?: DerivationPathArray;
18
+ }) => {
19
+ // Derivation path handling (default to standard XRP 44'/144'/0'/0/0)
20
+ const derivationPathString = derivationPath
21
+ ? derivationPathToString(derivationPath)
22
+ : `${DerivationPath[Chain.Ripple]}/0`;
23
+
24
+ // Fetch address from KeepKey
25
+ const { address } = await (sdk as any).address.xrpGetAddress({
26
+ address_n: bip32ToAddressNList(derivationPathString),
27
+ });
28
+
29
+ // Inject minimal signer so toolbox's address helpers work
30
+ const signer = {
31
+ getAddress: () => Promise.resolve(address),
32
+ signTransaction: () => {
33
+ throw new Error("signTransaction not supported via toolbox");
34
+ },
35
+ };
36
+
37
+ const toolbox = await getRippleToolbox({ signer });
38
+
39
+ const transfer = async ({ recipient, assetValue, memo }: GenericTransferParams) => {
40
+ // Build XRPL Payment tx using toolbox helper
41
+ const tx = await toolbox.createTransaction({ assetValue, memo, recipient, sender: address });
42
+
43
+ // Convert toolbox Payment tx into KeepKey StdTx wrapper (KeepKey-specific format)
44
+ const stdTx = {
45
+ type: "auth/StdTx",
46
+ value: {
47
+ fee: { amount: [{ amount: "1000", denom: "drop" }], gas: "28000" },
48
+ memo: memo && memo.length > 0 ? memo : "",
49
+ msg: [
50
+ {
51
+ type: "ripple-sdk/MsgSend",
52
+ value: { amount: [{ amount: tx.Amount, denom: "drop" }], from_address: address, to_address: recipient },
53
+ },
54
+ ],
55
+ signatures: null,
56
+ },
57
+ };
58
+
59
+ const unsignedTx = {
60
+ addressNList: bip32ToAddressNList(derivationPathString),
61
+ flags: tx.Flags === 0 ? undefined : tx.Flags,
62
+ lastLedgerSequence: tx.LastLedgerSequence?.toString(),
63
+ payment: {
64
+ amount: tx.Amount,
65
+ destination: tx.Destination,
66
+ destinationTag: (tx.DestinationTag ?? "0").toString(),
67
+ },
68
+ sequence: (tx.Sequence ?? 0).toString(),
69
+ tx: stdTx,
70
+ } as any;
71
+
72
+ // Sign with KeepKey
73
+ const responseSign = JSON.parse(await (sdk as any).xrp.xrpSignTransaction(unsignedTx));
74
+
75
+ // keepkey-sdk may return either { tx_blob } or StdTx with Base64 serializedTx
76
+ const txBlob: string | undefined =
77
+ (responseSign as any).tx_blob ?? (responseSign as any).value?.signatures?.[0]?.serializedTx;
78
+ if (!txBlob) throw new Error("KeepKey XRP sign failed");
79
+
80
+ const buffer = Buffer.from(txBlob, "base64");
81
+ const txBlobHex = buffer.toString("hex");
82
+
83
+ // Broadcast signed tx via toolbox
84
+ return toolbox.broadcastTransaction(txBlobHex);
85
+ };
86
+
87
+ return { ...toolbox, address, getAddress: () => address, transfer };
88
+ };
@@ -0,0 +1,93 @@
1
+ import type { KeepKeySdk, TypesThorchainSignDocDeposit, TypesThorchainSignDocTransfer } from "@keepkey/keepkey-sdk";
2
+ import {
3
+ type AssetValue,
4
+ Chain,
5
+ DerivationPath,
6
+ type DerivationPathArray,
7
+ derivationPathToString,
8
+ type GenericTransferParams,
9
+ getRPCUrl,
10
+ SwapKitError,
11
+ THORConfig,
12
+ } from "@swapkit/helpers";
13
+ import type { ThorchainDepositParams } from "@swapkit/toolboxes/cosmos";
14
+
15
+ import { bip32ToAddressNList } from "../coins";
16
+
17
+ type SignTransactionParams = { assetValue: AssetValue; recipient?: string; sender: string; memo: string | undefined };
18
+
19
+ export async function thorchainWalletMethods({
20
+ sdk,
21
+ derivationPath,
22
+ }: {
23
+ sdk: KeepKeySdk;
24
+ derivationPath?: DerivationPathArray;
25
+ }): Promise<any> {
26
+ const importedAmino = await import("@cosmjs/amino");
27
+ const makeSignDoc = importedAmino.makeSignDoc ?? importedAmino.default?.makeSignDoc;
28
+ const { buildAminoMsg, getDefaultChainFee, createStargateClient, getCosmosToolbox } = await import(
29
+ "@swapkit/toolboxes/cosmos"
30
+ );
31
+
32
+ const toolbox = await getCosmosToolbox(Chain.THORChain);
33
+ const derivationPathString = derivationPath ? derivationPathToString(derivationPath) : `${DerivationPath.THOR}/0`;
34
+
35
+ const { address: fromAddress } = (await sdk.address.thorchainGetAddress({
36
+ address_n: bip32ToAddressNList(derivationPathString),
37
+ })) as { address: string };
38
+
39
+ const signTransaction = async ({ assetValue, recipient, sender, memo }: SignTransactionParams) => {
40
+ const account = await toolbox.getAccount(sender);
41
+ if (!account) throw new SwapKitError("wallet_keepkey_account_not_found");
42
+ const { accountNumber, sequence = 0 } = account;
43
+
44
+ const isTransfer = recipient && recipient !== "";
45
+ const msg = buildAminoMsg({ assetValue, memo, recipient, sender });
46
+
47
+ const signDoc = makeSignDoc(
48
+ [msg],
49
+ getDefaultChainFee(Chain.THORChain),
50
+ THORConfig.chainId,
51
+ memo,
52
+ accountNumber?.toString(),
53
+ sequence,
54
+ );
55
+
56
+ const signedTx = isTransfer
57
+ ? await sdk.thorchain.thorchainSignAminoTransfer({
58
+ signDoc: signDoc as TypesThorchainSignDocTransfer,
59
+ signerAddress: sender,
60
+ })
61
+ : await sdk.thorchain.thorchainSignAminoDeposit({
62
+ signDoc: signDoc as TypesThorchainSignDocDeposit,
63
+ signerAddress: sender,
64
+ });
65
+ const decodedBytes = atob(signedTx.serialized);
66
+ return new Uint8Array(decodedBytes.length).map((_, i) => decodedBytes.charCodeAt(i));
67
+ };
68
+
69
+ const transfer = async ({ assetValue, recipient, memo }: GenericTransferParams) => {
70
+ const rpcUrl = await getRPCUrl(Chain.THORChain);
71
+ const stargateClient = await createStargateClient(rpcUrl);
72
+ const signedTransaction = await signTransaction({ assetValue, memo, recipient, sender: fromAddress });
73
+ const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
74
+
75
+ return transactionHash;
76
+ };
77
+
78
+ const deposit = async ({ assetValue, memo }: ThorchainDepositParams) => {
79
+ const rpcUrl = await getRPCUrl(Chain.THORChain);
80
+ const stargateClient = await createStargateClient(rpcUrl);
81
+ const signedTransaction = await signTransaction({ assetValue, memo, sender: fromAddress });
82
+ const { transactionHash } = await stargateClient.broadcastTx(signedTransaction);
83
+
84
+ return transactionHash;
85
+ };
86
+
87
+ // const signMessage = async (message: string) => {
88
+ // const stargateClient = await createStargateClient(RPCUrl.THORChain);
89
+ // // return signedTx;
90
+ // };
91
+
92
+ return { ...toolbox, address: fromAddress, deposit, transfer };
93
+ }