@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
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type DerivationPathArray,
|
|
3
|
-
LedgerErrorCode,
|
|
4
|
-
NetworkDerivationPath,
|
|
5
|
-
SwapKitError,
|
|
6
|
-
} from "@swapkit/helpers";
|
|
7
|
-
|
|
8
|
-
import { THORChainApp } from "../clients/thorchain/lib";
|
|
9
|
-
import { getLedgerTransport } from "../helpers/getLedgerTransport";
|
|
10
|
-
|
|
11
|
-
export abstract class CosmosLedgerInterface {
|
|
12
|
-
ledgerTimeout = 50000;
|
|
13
|
-
derivationPath: DerivationPathArray | string = NetworkDerivationPath.GAIA;
|
|
14
|
-
transport: any;
|
|
15
|
-
ledgerApp: any;
|
|
16
|
-
chain: "thor" | "cosmos" = "thor";
|
|
17
|
-
|
|
18
|
-
checkOrCreateTransportAndLedger = async (forceReconnect = false) => {
|
|
19
|
-
if (!forceReconnect && this.transport && this.ledgerApp) return;
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
this.transport =
|
|
23
|
-
forceReconnect || !this.transport ? await getLedgerTransport() : this.transport;
|
|
24
|
-
|
|
25
|
-
// biome-ignore lint/style/useDefaultSwitchClause: default will never be hit
|
|
26
|
-
switch (this.chain) {
|
|
27
|
-
case "thor": {
|
|
28
|
-
this.ledgerApp =
|
|
29
|
-
forceReconnect || !this.ledgerApp ? new THORChainApp(this.transport) : this.ledgerApp;
|
|
30
|
-
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
case "cosmos": {
|
|
35
|
-
const CosmosApp = (await import("@ledgerhq/hw-app-cosmos")).default;
|
|
36
|
-
this.ledgerApp =
|
|
37
|
-
forceReconnect || !this.ledgerApp ? new CosmosApp(this.transport) : this.ledgerApp;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return this.ledgerApp;
|
|
42
|
-
} catch (error: unknown) {
|
|
43
|
-
throw new SwapKitError("wallet_ledger_connection_error", error);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
validateResponse = (errorCode: LedgerErrorCode, message?: string) => {
|
|
48
|
-
switch (errorCode) {
|
|
49
|
-
case LedgerErrorCode.NoError:
|
|
50
|
-
return;
|
|
51
|
-
|
|
52
|
-
case LedgerErrorCode.LockedDevice:
|
|
53
|
-
throw new SwapKitError("wallet_ledger_device_locked", {
|
|
54
|
-
message: `Ledger is locked: ${message}`,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
case LedgerErrorCode.TC_NotFound:
|
|
58
|
-
throw new SwapKitError("wallet_ledger_device_not_found");
|
|
59
|
-
|
|
60
|
-
default: {
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
package/src/ledger/types.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { CosmosLedger } from "./clients/cosmos";
|
|
2
|
-
import type {
|
|
3
|
-
ArbitrumLedger,
|
|
4
|
-
AuroraLedger,
|
|
5
|
-
AvalancheLedger,
|
|
6
|
-
BaseLedger,
|
|
7
|
-
BinanceSmartChainLedger,
|
|
8
|
-
EthereumLedger,
|
|
9
|
-
GnosisLedger,
|
|
10
|
-
OptimismLedger,
|
|
11
|
-
PolygonLedger,
|
|
12
|
-
} from "./clients/evm";
|
|
13
|
-
import type { THORChainLedger } from "./clients/thorchain";
|
|
14
|
-
import type { TronLedger } from "./clients/tron";
|
|
15
|
-
import type {
|
|
16
|
-
BitcoinCashLedger,
|
|
17
|
-
BitcoinLedger,
|
|
18
|
-
DogecoinLedger,
|
|
19
|
-
LitecoinLedger,
|
|
20
|
-
} from "./clients/utxo";
|
|
21
|
-
|
|
22
|
-
export type UTXOLedgerClients =
|
|
23
|
-
| ReturnType<typeof BitcoinLedger>
|
|
24
|
-
| ReturnType<typeof BitcoinCashLedger>
|
|
25
|
-
| ReturnType<typeof DogecoinLedger>
|
|
26
|
-
| ReturnType<typeof LitecoinLedger>;
|
|
27
|
-
export type CosmosLedgerClients = CosmosLedger | THORChainLedger;
|
|
28
|
-
export type EVMLedgerClients =
|
|
29
|
-
| ReturnType<typeof ArbitrumLedger>
|
|
30
|
-
| ReturnType<typeof AuroraLedger>
|
|
31
|
-
| ReturnType<typeof AvalancheLedger>
|
|
32
|
-
| ReturnType<typeof BaseLedger>
|
|
33
|
-
| ReturnType<typeof BinanceSmartChainLedger>
|
|
34
|
-
| ReturnType<typeof GnosisLedger>
|
|
35
|
-
| ReturnType<typeof EthereumLedger>
|
|
36
|
-
| ReturnType<typeof OptimismLedger>
|
|
37
|
-
| ReturnType<typeof PolygonLedger>;
|
|
38
|
-
export type TronLedgerClient = ReturnType<typeof TronLedger>;
|
|
39
|
-
|
|
40
|
-
export type GetAddressAndPubKeyResponse = {
|
|
41
|
-
bech32_address: string;
|
|
42
|
-
compressed_pk: any;
|
|
43
|
-
error_message: string;
|
|
44
|
-
return_code: number;
|
|
45
|
-
};
|
package/src/okx/helpers.ts
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Chain,
|
|
3
|
-
ChainId,
|
|
4
|
-
type EVMChain,
|
|
5
|
-
type GenericTransferParams,
|
|
6
|
-
SKConfig,
|
|
7
|
-
SwapKitError,
|
|
8
|
-
prepareNetworkSwitch,
|
|
9
|
-
switchEVMWalletNetwork,
|
|
10
|
-
} from "@swapkit/helpers";
|
|
11
|
-
import type { TronSigner, TronTransaction } from "@swapkit/toolboxes/tron";
|
|
12
|
-
import { Psbt } from "bitcoinjs-lib";
|
|
13
|
-
import type { Eip1193Provider } from "ethers";
|
|
14
|
-
|
|
15
|
-
const cosmosTransfer =
|
|
16
|
-
(sender: string) =>
|
|
17
|
-
async ({ recipient, assetValue, memo }: GenericTransferParams) => {
|
|
18
|
-
if (!(window.okxwallet && "keplr" in window.okxwallet)) {
|
|
19
|
-
throw new SwapKitError("wallet_okx_not_found", { chain: Chain.Cosmos });
|
|
20
|
-
}
|
|
21
|
-
const { createSigningStargateClient } = await import("@swapkit/toolboxes/cosmos");
|
|
22
|
-
|
|
23
|
-
const { keplr: wallet } = window.okxwallet;
|
|
24
|
-
const offlineSigner = wallet?.getOfflineSignerOnlyAmino(ChainId.Cosmos);
|
|
25
|
-
|
|
26
|
-
const cosmJS = await createSigningStargateClient(SKConfig.get("rpcUrls").GAIA, offlineSigner);
|
|
27
|
-
|
|
28
|
-
const coins = [
|
|
29
|
-
{
|
|
30
|
-
denom: assetValue?.symbol === "MUON" ? "umuon" : "uatom",
|
|
31
|
-
amount: assetValue.getBaseValue("string"),
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
const { transactionHash } = await cosmJS.sendTokens(sender, recipient, coins, 1.6, memo);
|
|
36
|
-
return transactionHash;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
async function getWeb3WalletMethods({
|
|
40
|
-
walletProvider,
|
|
41
|
-
chain,
|
|
42
|
-
}: { walletProvider: Eip1193Provider | undefined; chain: EVMChain }) {
|
|
43
|
-
const { getEvmToolbox } = await import("@swapkit/toolboxes/evm");
|
|
44
|
-
const { BrowserProvider } = await import("ethers");
|
|
45
|
-
if (!walletProvider) throw new SwapKitError("wallet_okx_not_found");
|
|
46
|
-
|
|
47
|
-
const provider = new BrowserProvider(walletProvider, "any");
|
|
48
|
-
const signer = await provider.getSigner();
|
|
49
|
-
const toolbox = await getEvmToolbox(chain, { provider, signer });
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
if (chain !== Chain.Ethereum && "getNetworkParams" in toolbox) {
|
|
53
|
-
await switchEVMWalletNetwork(provider, chain, toolbox.getNetworkParams());
|
|
54
|
-
}
|
|
55
|
-
} catch (_error) {
|
|
56
|
-
throw new SwapKitError("wallet_okx_failed_to_switch_network", { chain });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return prepareNetworkSwitch({ toolbox, provider, chain });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export async function getWalletMethods(chain: Chain) {
|
|
63
|
-
const { match, P } = await import("ts-pattern");
|
|
64
|
-
|
|
65
|
-
return match(chain)
|
|
66
|
-
.with(
|
|
67
|
-
P.union(
|
|
68
|
-
Chain.Arbitrum,
|
|
69
|
-
Chain.Aurora,
|
|
70
|
-
Chain.Avalanche,
|
|
71
|
-
Chain.Base,
|
|
72
|
-
Chain.Berachain,
|
|
73
|
-
Chain.BinanceSmartChain,
|
|
74
|
-
Chain.Ethereum,
|
|
75
|
-
Chain.Gnosis,
|
|
76
|
-
Chain.Optimism,
|
|
77
|
-
Chain.Polygon,
|
|
78
|
-
),
|
|
79
|
-
async () => {
|
|
80
|
-
if (!(window.okxwallet && "send" in window.okxwallet)) {
|
|
81
|
-
throw new SwapKitError("wallet_okx_not_found", { chain });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const evmWallet = await getWeb3WalletMethods({
|
|
85
|
-
chain: chain as EVMChain,
|
|
86
|
-
walletProvider: window.okxwallet,
|
|
87
|
-
});
|
|
88
|
-
const address: string = (await window.okxwallet.send("eth_requestAccounts", [])).result[0];
|
|
89
|
-
|
|
90
|
-
return { ...evmWallet, address };
|
|
91
|
-
},
|
|
92
|
-
)
|
|
93
|
-
.with(Chain.Bitcoin, async () => {
|
|
94
|
-
if (!(window.okxwallet && "bitcoin" in window.okxwallet)) {
|
|
95
|
-
throw new SwapKitError("wallet_okx_not_found", { chain: Chain.Bitcoin });
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const { getUtxoToolbox } = await import("@swapkit/toolboxes/utxo");
|
|
99
|
-
|
|
100
|
-
const { bitcoin: wallet } = window.okxwallet;
|
|
101
|
-
const address = (await wallet.connect()).address;
|
|
102
|
-
|
|
103
|
-
const signer = {
|
|
104
|
-
signTransaction: async (psbt: InstanceType<typeof Psbt>) => {
|
|
105
|
-
const signedPsbt = await wallet.signPsbt(psbt.toHex(), {
|
|
106
|
-
from: address,
|
|
107
|
-
type: "list",
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
return Psbt.fromHex(signedPsbt);
|
|
111
|
-
},
|
|
112
|
-
getAddress: async () => Promise.resolve(address),
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const toolbox = await getUtxoToolbox(Chain.Bitcoin, { signer });
|
|
116
|
-
|
|
117
|
-
return { ...toolbox, address };
|
|
118
|
-
})
|
|
119
|
-
.with(Chain.Cosmos, async () => {
|
|
120
|
-
if (!(window.okxwallet && "keplr" in window.okxwallet)) {
|
|
121
|
-
throw new SwapKitError("wallet_okx_not_found", { chain: Chain.Cosmos });
|
|
122
|
-
}
|
|
123
|
-
const { keplr: wallet } = window.okxwallet;
|
|
124
|
-
|
|
125
|
-
await wallet.enable(ChainId.Cosmos);
|
|
126
|
-
const accounts = await wallet.getOfflineSignerOnlyAmino(ChainId.Cosmos).getAccounts();
|
|
127
|
-
if (!accounts?.[0]) throw new SwapKitError("wallet_okx_no_accounts", { chain: Chain.Cosmos });
|
|
128
|
-
|
|
129
|
-
const { getCosmosToolbox } = await import("@swapkit/toolboxes/cosmos");
|
|
130
|
-
const [{ address }] = accounts;
|
|
131
|
-
const toolbox = getCosmosToolbox(Chain.Cosmos);
|
|
132
|
-
|
|
133
|
-
return { ...toolbox, address, transfer: cosmosTransfer(address) };
|
|
134
|
-
})
|
|
135
|
-
.with(Chain.Near, async () => {
|
|
136
|
-
if (!(window.okxwallet && "near" in window.okxwallet)) {
|
|
137
|
-
throw new SwapKitError("wallet_okx_not_found", { chain: Chain.Near });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const { createNearSignerFromProvider } = await import("../helpers/near");
|
|
141
|
-
const { getNearToolbox } = await import("@swapkit/toolboxes/near");
|
|
142
|
-
|
|
143
|
-
const provider = window.okxwallet.near;
|
|
144
|
-
const signer = await createNearSignerFromProvider(provider, "OKX");
|
|
145
|
-
const accountId = await signer.getAddress();
|
|
146
|
-
const toolbox = await getNearToolbox({ signer });
|
|
147
|
-
|
|
148
|
-
return { ...toolbox, address: accountId };
|
|
149
|
-
})
|
|
150
|
-
.with(Chain.Tron, async () => {
|
|
151
|
-
if (!(window.okxwallet && "tronLink" in window.okxwallet)) {
|
|
152
|
-
throw new SwapKitError("wallet_okx_not_found", { chain: Chain.Tron });
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const { createTronToolbox } = await import("@swapkit/toolboxes/tron");
|
|
156
|
-
|
|
157
|
-
const tronLink = window.okxwallet.tronLink;
|
|
158
|
-
|
|
159
|
-
// Request account access
|
|
160
|
-
const accounts = await tronLink.request({ method: "tron_requestAccounts" });
|
|
161
|
-
if (!accounts || accounts.length === 0) {
|
|
162
|
-
throw new SwapKitError("wallet_okx_no_accounts", { chain: Chain.Tron });
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const address = tronLink.tronWeb.defaultAddress.base58;
|
|
166
|
-
|
|
167
|
-
const signer: TronSigner = {
|
|
168
|
-
getAddress: async () => address,
|
|
169
|
-
signTransaction: async (transaction: TronTransaction) => {
|
|
170
|
-
return await tronLink.tronWeb.trx.sign(transaction);
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const toolbox = await createTronToolbox({ signer });
|
|
175
|
-
|
|
176
|
-
return { ...toolbox, address };
|
|
177
|
-
})
|
|
178
|
-
.otherwise(() => {
|
|
179
|
-
throw new SwapKitError("wallet_okx_chain_not_supported", { chain });
|
|
180
|
-
});
|
|
181
|
-
}
|
package/src/okx/index.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Chain, WalletOption, createWallet, filterSupportedChains } from "@swapkit/helpers";
|
|
2
|
-
|
|
3
|
-
import { getWalletSupportedChains } from "../utils";
|
|
4
|
-
import { getWalletMethods } from "./helpers";
|
|
5
|
-
|
|
6
|
-
export const okxWallet = createWallet({
|
|
7
|
-
name: "connectOkx",
|
|
8
|
-
walletType: WalletOption.OKX,
|
|
9
|
-
supportedChains: [
|
|
10
|
-
Chain.Arbitrum,
|
|
11
|
-
Chain.Aurora,
|
|
12
|
-
Chain.Avalanche,
|
|
13
|
-
Chain.Base,
|
|
14
|
-
Chain.Berachain,
|
|
15
|
-
Chain.BinanceSmartChain,
|
|
16
|
-
Chain.Bitcoin,
|
|
17
|
-
Chain.Cosmos,
|
|
18
|
-
Chain.Ethereum,
|
|
19
|
-
Chain.Gnosis,
|
|
20
|
-
Chain.Near,
|
|
21
|
-
Chain.Optimism,
|
|
22
|
-
Chain.Polygon,
|
|
23
|
-
Chain.Tron,
|
|
24
|
-
],
|
|
25
|
-
connect: ({ addChain, supportedChains, walletType }) =>
|
|
26
|
-
async function connectOkx(chains: Chain[]) {
|
|
27
|
-
const filteredChains = filterSupportedChains({ chains, supportedChains, walletType });
|
|
28
|
-
|
|
29
|
-
await Promise.all(
|
|
30
|
-
filteredChains.map(async (chain) => {
|
|
31
|
-
const walletMethods = await getWalletMethods(chain);
|
|
32
|
-
|
|
33
|
-
const address = (await walletMethods.getAddress()) || "";
|
|
34
|
-
|
|
35
|
-
addChain({ ...walletMethods, address, chain, walletType });
|
|
36
|
-
}),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return true;
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export const OKX_SUPPORTED_CHAINS = getWalletSupportedChains(okxWallet);
|
package/src/okx/types.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { StdSignDoc } from "@cosmjs/amino";
|
|
2
|
-
|
|
3
|
-
export enum BroadcastMode {
|
|
4
|
-
/** Return after tx commit */
|
|
5
|
-
Block = "block",
|
|
6
|
-
/** Return after CheckTx */
|
|
7
|
-
Sync = "sync",
|
|
8
|
-
/** Return right away */
|
|
9
|
-
Async = "async",
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface Coin {
|
|
13
|
-
readonly denom: string;
|
|
14
|
-
readonly amount: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface StdFee {
|
|
18
|
-
readonly amount: readonly Coin[];
|
|
19
|
-
readonly gas: string;
|
|
20
|
-
readonly payer?: string;
|
|
21
|
-
readonly granter?: string;
|
|
22
|
-
readonly feePayer?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface Msg {
|
|
26
|
-
readonly type: string;
|
|
27
|
-
readonly value: any;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface PubKey {
|
|
31
|
-
readonly type: string;
|
|
32
|
-
readonly value: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface StdSignature {
|
|
36
|
-
readonly pub_key: PubKey;
|
|
37
|
-
readonly signature: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface StdTx {
|
|
41
|
-
readonly msg: readonly Msg[];
|
|
42
|
-
readonly fee: StdFee;
|
|
43
|
-
readonly signatures: readonly StdSignature[];
|
|
44
|
-
readonly memo: string | undefined;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface AminoSignResponse {
|
|
48
|
-
readonly signed: StdSignDoc;
|
|
49
|
-
readonly signature: StdSignature;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface SignDoc {
|
|
53
|
-
/**
|
|
54
|
-
* body_bytes is protobuf serialization of a TxBody that matches the
|
|
55
|
-
* representation in TxRaw.
|
|
56
|
-
*/
|
|
57
|
-
bodyBytes: Uint8Array;
|
|
58
|
-
/**
|
|
59
|
-
* auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
|
|
60
|
-
* representation in TxRaw.
|
|
61
|
-
*/
|
|
62
|
-
authInfoBytes: Uint8Array;
|
|
63
|
-
/**
|
|
64
|
-
* chain_id is the unique identifier of the chain this transaction targets.
|
|
65
|
-
* It prevents signed transactions from being used on another chain by an
|
|
66
|
-
* attacker
|
|
67
|
-
*/
|
|
68
|
-
chainId: string;
|
|
69
|
-
/** account_number is the account number of the account in state */
|
|
70
|
-
accountNumber: any;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* This is the same as Algo from @cosmjs/launchpad but those might diverge in the future.
|
|
75
|
-
*/
|
|
76
|
-
export type Algo = "secp256k1" | "ed25519" | "sr25519";
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* This is the same as AccountData from @cosmjs/launchpad but those might diverge in the future.
|
|
80
|
-
*/
|
|
81
|
-
export interface AccountData {
|
|
82
|
-
/** A printable address (typically bech32 encoded) */
|
|
83
|
-
readonly address: string;
|
|
84
|
-
readonly algo: Algo;
|
|
85
|
-
readonly pubkey: Uint8Array;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface DirectSignResponse {
|
|
89
|
-
/**
|
|
90
|
-
* The sign doc that was signed.
|
|
91
|
-
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
|
92
|
-
*/
|
|
93
|
-
readonly signed: SignDoc;
|
|
94
|
-
readonly signature: StdSignature;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface OfflineDirectSigner {
|
|
98
|
-
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
|
99
|
-
readonly signDirect: (signerAddress: string, signDoc: SignDoc) => Promise<DirectSignResponse>;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface OfflineAminoSigner {
|
|
103
|
-
/**
|
|
104
|
-
* Get AccountData array from wallet. Rejects if not enabled.
|
|
105
|
-
*/
|
|
106
|
-
readonly getAccounts: () => Promise<readonly AccountData[]>;
|
|
107
|
-
/**
|
|
108
|
-
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
|
|
109
|
-
*
|
|
110
|
-
* The signer implementation may offer the user the ability to override parts of the signDoc. It must
|
|
111
|
-
* return the doc that was signed in the response.
|
|
112
|
-
*
|
|
113
|
-
* @param signerAddress The address of the account that should sign the transaction
|
|
114
|
-
* @param signDoc The content that should be signed
|
|
115
|
-
*/
|
|
116
|
-
readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>;
|
|
117
|
-
}
|
package/src/onekey/evmSigner.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import type { Chain, DerivationPathArray } from "@swapkit/helpers";
|
|
2
|
-
import { SwapKitError, WalletOption } from "@swapkit/helpers";
|
|
3
|
-
import type { JsonRpcProvider, Provider, Signer, TypedDataDomain, TypedDataField } from "ethers";
|
|
4
|
-
|
|
5
|
-
type OneKeyEVMSignerParams = {
|
|
6
|
-
chain: Chain;
|
|
7
|
-
derivationPath: DerivationPathArray;
|
|
8
|
-
provider: Provider | JsonRpcProvider;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export async function getEVMSigner({ chain, derivationPath, provider }: OneKeyEVMSignerParams) {
|
|
12
|
-
const { AbstractSigner, BrowserProvider } = await import("ethers");
|
|
13
|
-
|
|
14
|
-
class OneKeySigner extends AbstractSigner {
|
|
15
|
-
address: string;
|
|
16
|
-
chain: Chain;
|
|
17
|
-
derivationPath: DerivationPathArray;
|
|
18
|
-
readonly provider: Provider | JsonRpcProvider;
|
|
19
|
-
|
|
20
|
-
constructor({ chain, derivationPath, provider }: OneKeyEVMSignerParams) {
|
|
21
|
-
super(provider);
|
|
22
|
-
|
|
23
|
-
this.address = "";
|
|
24
|
-
this.chain = chain;
|
|
25
|
-
this.derivationPath = derivationPath;
|
|
26
|
-
this.provider = provider;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
connect(provider: null | Provider): Signer {
|
|
30
|
-
if (!provider) {
|
|
31
|
-
throw new SwapKitError({
|
|
32
|
-
errorKey: "wallet_provider_not_found",
|
|
33
|
-
info: { wallet: WalletOption.ONEKEY, chain: this.chain },
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return new OneKeySigner({
|
|
38
|
-
chain: this.chain,
|
|
39
|
-
derivationPath: this.derivationPath,
|
|
40
|
-
provider,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
signTypedData(
|
|
45
|
-
domain: TypedDataDomain,
|
|
46
|
-
types: Record<string, TypedDataField[]>,
|
|
47
|
-
value: Record<string, any>,
|
|
48
|
-
): Promise<string> {
|
|
49
|
-
if (!window.$onekey?.ethereum) {
|
|
50
|
-
throw new SwapKitError({
|
|
51
|
-
errorKey: "wallet_onekey_not_found",
|
|
52
|
-
info: { chain: this.chain },
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return this.getAddress().then(async (_address) => {
|
|
57
|
-
try {
|
|
58
|
-
const signer = await new BrowserProvider(window.$onekey.ethereum).getSigner();
|
|
59
|
-
return signer.signTypedData(domain, types, value);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
throw new SwapKitError({
|
|
62
|
-
errorKey: "core_wallet_sign_message_not_supported",
|
|
63
|
-
info: { wallet: WalletOption.ONEKEY, error },
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
getAddress = async () => {
|
|
70
|
-
if (this.address) return this.address;
|
|
71
|
-
|
|
72
|
-
if (!window.$onekey?.ethereum) {
|
|
73
|
-
throw new SwapKitError({
|
|
74
|
-
errorKey: "wallet_onekey_not_found",
|
|
75
|
-
info: { chain: this.chain },
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const signer = await new BrowserProvider(window.$onekey.ethereum).getSigner();
|
|
80
|
-
this.address = await signer.getAddress();
|
|
81
|
-
return this.address;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
signMessage = async (message: string) => {
|
|
85
|
-
if (!window.$onekey?.ethereum) {
|
|
86
|
-
throw new SwapKitError({
|
|
87
|
-
errorKey: "wallet_onekey_not_found",
|
|
88
|
-
info: { chain: this.chain },
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const signer = await new BrowserProvider(window.$onekey.ethereum).getSigner();
|
|
93
|
-
return signer.signMessage(message);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
signTransaction = async (transaction: any) => {
|
|
97
|
-
if (!window.$onekey?.ethereum) {
|
|
98
|
-
throw new SwapKitError({
|
|
99
|
-
errorKey: "wallet_onekey_not_found",
|
|
100
|
-
info: { chain: this.chain },
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const signer = await new BrowserProvider(window.$onekey.ethereum).getSigner();
|
|
105
|
-
const { to, value, gasLimit, gasPrice, data, maxFeePerGas, maxPriorityFeePerGas } =
|
|
106
|
-
transaction;
|
|
107
|
-
|
|
108
|
-
if (!to) throw new SwapKitError("toolbox_evm_no_to_address");
|
|
109
|
-
if (!gasLimit) throw new SwapKitError("toolbox_evm_no_gas_price");
|
|
110
|
-
|
|
111
|
-
const tx: any = {
|
|
112
|
-
to,
|
|
113
|
-
data,
|
|
114
|
-
gasLimit,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
if (value) {
|
|
118
|
-
tx.value = value;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (maxFeePerGas && maxPriorityFeePerGas) {
|
|
122
|
-
tx.maxFeePerGas = maxFeePerGas;
|
|
123
|
-
tx.maxPriorityFeePerGas = maxPriorityFeePerGas;
|
|
124
|
-
} else if (gasPrice) {
|
|
125
|
-
tx.gasPrice = gasPrice;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return signer.signTransaction(tx);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return new OneKeySigner({ chain, derivationPath, provider });
|
|
133
|
-
}
|