@reown/appkit-adapter-bitcoin 1.6.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/dist/esm/exports/index.js +2 -0
- package/dist/esm/exports/index.js.map +1 -0
- package/dist/esm/src/adapter.js +220 -0
- package/dist/esm/src/adapter.js.map +1 -0
- package/dist/esm/src/connectors/LeatherConnector.js +63 -0
- package/dist/esm/src/connectors/LeatherConnector.js.map +1 -0
- package/dist/esm/src/connectors/OKXConnector.js +101 -0
- package/dist/esm/src/connectors/OKXConnector.js.map +1 -0
- package/dist/esm/src/connectors/SatsConnectConnector.js +123 -0
- package/dist/esm/src/connectors/SatsConnectConnector.js.map +1 -0
- package/dist/esm/src/connectors/WalletStandardConnector.js +159 -0
- package/dist/esm/src/connectors/WalletStandardConnector.js.map +1 -0
- package/dist/esm/src/errors/MethodNotSupportedError.js +11 -0
- package/dist/esm/src/errors/MethodNotSupportedError.js.map +1 -0
- package/dist/esm/src/index.js +3 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/utils/BitcoinApi.js +13 -0
- package/dist/esm/src/utils/BitcoinApi.js.map +1 -0
- package/dist/esm/src/utils/BitcoinConnector.js +2 -0
- package/dist/esm/src/utils/BitcoinConnector.js.map +1 -0
- package/dist/esm/src/utils/ProviderEventEmitter.js +28 -0
- package/dist/esm/src/utils/ProviderEventEmitter.js.map +1 -0
- package/dist/esm/src/utils/UnitsUtil.js +10 -0
- package/dist/esm/src/utils/UnitsUtil.js.map +1 -0
- package/dist/esm/src/utils/WalletConnectProvider.js +115 -0
- package/dist/esm/src/utils/WalletConnectProvider.js.map +1 -0
- package/dist/esm/src/utils/wallet-standard/SignMessage.js +7 -0
- package/dist/esm/src/utils/wallet-standard/SignMessage.js.map +1 -0
- package/dist/esm/src/utils/wallet-standard/SignTransaction.js +7 -0
- package/dist/esm/src/utils/wallet-standard/SignTransaction.js.map +1 -0
- package/dist/esm/src/utils/wallet-standard/WalletFeatures.js +2 -0
- package/dist/esm/src/utils/wallet-standard/WalletFeatures.js.map +1 -0
- package/dist/esm/tests/BitcoinAdapter.test.js +96 -0
- package/dist/esm/tests/BitcoinAdapter.test.js.map +1 -0
- package/dist/esm/tests/connectors/LeatherConnector.test.js +138 -0
- package/dist/esm/tests/connectors/LeatherConnector.test.js.map +1 -0
- package/dist/esm/tests/connectors/OKXConnector.test.js +157 -0
- package/dist/esm/tests/connectors/OKXConnector.test.js.map +1 -0
- package/dist/esm/tests/connectors/SatsConnectConnector.test.js +238 -0
- package/dist/esm/tests/connectors/SatsConnectConnector.test.js.map +1 -0
- package/dist/esm/tests/connectors/WalletStandardConnector.test.js +296 -0
- package/dist/esm/tests/connectors/WalletStandardConnector.test.js.map +1 -0
- package/dist/esm/tests/mocks/mockSatsConnect.js +60 -0
- package/dist/esm/tests/mocks/mockSatsConnect.js.map +1 -0
- package/dist/esm/tests/mocks/mockUTXO.js +15 -0
- package/dist/esm/tests/mocks/mockUTXO.js.map +1 -0
- package/dist/esm/tests/mocks/mockUniversalProvider.js +54 -0
- package/dist/esm/tests/mocks/mockUniversalProvider.js.map +1 -0
- package/dist/esm/tests/mocks/mockWalletStandard.js +47 -0
- package/dist/esm/tests/mocks/mockWalletStandard.js.map +1 -0
- package/dist/esm/tests/utils/BitcoinApi.test.js +48 -0
- package/dist/esm/tests/utils/BitcoinApi.test.js.map +1 -0
- package/dist/esm/tests/utils/UnitsUtils.test.js +21 -0
- package/dist/esm/tests/utils/UnitsUtils.test.js.map +1 -0
- package/dist/esm/tests/utils/WalletConnectProvider.test.js +268 -0
- package/dist/esm/tests/utils/WalletConnectProvider.test.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/types/exports/index.d.ts +1 -0
- package/dist/types/src/adapter.d.ts +36 -0
- package/dist/types/src/connectors/LeatherConnector.d.ts +23 -0
- package/dist/types/src/connectors/OKXConnector.d.ts +59 -0
- package/dist/types/src/connectors/SatsConnectConnector.d.ts +42 -0
- package/dist/types/src/connectors/WalletStandardConnector.d.ts +39 -0
- package/dist/types/src/errors/MethodNotSupportedError.d.ts +6 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/utils/BitcoinApi.d.ts +22 -0
- package/dist/types/src/utils/BitcoinConnector.d.ts +85 -0
- package/dist/types/src/utils/ProviderEventEmitter.d.ts +11 -0
- package/dist/types/src/utils/UnitsUtil.d.ts +4 -0
- package/dist/types/src/utils/WalletConnectProvider.d.ts +90 -0
- package/dist/types/src/utils/wallet-standard/SignMessage.d.ts +64 -0
- package/dist/types/src/utils/wallet-standard/SignTransaction.d.ts +72 -0
- package/dist/types/src/utils/wallet-standard/WalletFeatures.d.ts +9 -0
- package/dist/types/tests/BitcoinAdapter.test.d.ts +1 -0
- package/dist/types/tests/connectors/LeatherConnector.test.d.ts +1 -0
- package/dist/types/tests/connectors/OKXConnector.test.d.ts +1 -0
- package/dist/types/tests/connectors/SatsConnectConnector.test.d.ts +1 -0
- package/dist/types/tests/connectors/WalletStandardConnector.test.d.ts +1 -0
- package/dist/types/tests/mocks/mockSatsConnect.d.ts +22 -0
- package/dist/types/tests/mocks/mockUTXO.d.ts +2 -0
- package/dist/types/tests/mocks/mockUniversalProvider.d.ts +6 -0
- package/dist/types/tests/mocks/mockWalletStandard.d.ts +7 -0
- package/dist/types/tests/utils/BitcoinApi.test.d.ts +1 -0
- package/dist/types/tests/utils/UnitsUtils.test.d.ts +1 -0
- package/dist/types/tests/utils/WalletConnectProvider.test.d.ts +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../src/index.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type AppKit, type AppKitOptions } from '@reown/appkit';
|
|
2
|
+
import { AdapterBlueprint } from '@reown/appkit/adapters';
|
|
3
|
+
import type { BitcoinConnector } from './utils/BitcoinConnector.js';
|
|
4
|
+
import { BitcoinApi } from './utils/BitcoinApi.js';
|
|
5
|
+
export declare class BitcoinAdapter extends AdapterBlueprint<BitcoinConnector> {
|
|
6
|
+
private eventsToUnbind;
|
|
7
|
+
private api;
|
|
8
|
+
constructor({ api, ...params }?: BitcoinAdapter.ConstructorParams);
|
|
9
|
+
connectWalletConnect(onUri: (uri: string) => void): Promise<void>;
|
|
10
|
+
connect(params: AdapterBlueprint.ConnectParams): Promise<AdapterBlueprint.ConnectResult>;
|
|
11
|
+
getAccounts(_params: AdapterBlueprint.GetAccountsParams): Promise<AdapterBlueprint.GetAccountsResult>;
|
|
12
|
+
syncConnectors(_options?: AppKitOptions, appKit?: AppKit): void;
|
|
13
|
+
syncConnection(params: AdapterBlueprint.SyncConnectionParams): Promise<AdapterBlueprint.ConnectResult>;
|
|
14
|
+
signMessage(params: AdapterBlueprint.SignMessageParams): Promise<AdapterBlueprint.SignMessageResult>;
|
|
15
|
+
getWalletConnectProvider(params: AdapterBlueprint.GetWalletConnectProviderParams): AdapterBlueprint.GetWalletConnectProviderResult;
|
|
16
|
+
switchNetwork(_params: AdapterBlueprint.SwitchNetworkParams): Promise<void>;
|
|
17
|
+
disconnect(params: AdapterBlueprint.DisconnectParams): Promise<void>;
|
|
18
|
+
getBalance(params: AdapterBlueprint.GetBalanceParams): Promise<AdapterBlueprint.GetBalanceResult>;
|
|
19
|
+
getProfile(_params: AdapterBlueprint.GetProfileParams): Promise<AdapterBlueprint.GetProfileResult>;
|
|
20
|
+
estimateGas(_params: AdapterBlueprint.EstimateGasTransactionArgs): Promise<AdapterBlueprint.EstimateGasTransactionResult>;
|
|
21
|
+
sendTransaction(_params: AdapterBlueprint.SendTransactionParams): Promise<AdapterBlueprint.SendTransactionResult>;
|
|
22
|
+
writeContract(_params: AdapterBlueprint.WriteContractParams): Promise<AdapterBlueprint.WriteContractResult>;
|
|
23
|
+
getEnsAddress(_params: AdapterBlueprint.GetEnsAddressParams): Promise<AdapterBlueprint.GetEnsAddressResult>;
|
|
24
|
+
parseUnits(_params: AdapterBlueprint.ParseUnitsParams): bigint;
|
|
25
|
+
formatUnits(_params: AdapterBlueprint.FormatUnitsParams): string;
|
|
26
|
+
grantPermissions(_params: AdapterBlueprint.GrantPermissionsParams): Promise<unknown>;
|
|
27
|
+
getCapabilities(_params: AdapterBlueprint.GetCapabilitiesParams): Promise<unknown>;
|
|
28
|
+
revokePermissions(_params: AdapterBlueprint.RevokePermissionsParams): Promise<`0x${string}`>;
|
|
29
|
+
private bindEvents;
|
|
30
|
+
private unbindEvents;
|
|
31
|
+
}
|
|
32
|
+
export declare namespace BitcoinAdapter {
|
|
33
|
+
type ConstructorParams = Omit<AdapterBlueprint.Params, 'namespace'> & {
|
|
34
|
+
api?: Partial<BitcoinApi.Interface>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BitcoinConnector } from '../index.js';
|
|
2
|
+
import { SatsConnectConnector } from './SatsConnectConnector.js';
|
|
3
|
+
import type { SendTransferRequestParams, SendTransferResponseBody, SignPsbtRequestParams, SignPsbtResponseBody } from '@leather.io/rpc';
|
|
4
|
+
export declare class LeatherConnector extends SatsConnectConnector {
|
|
5
|
+
static readonly ProviderId = "LeatherProvider";
|
|
6
|
+
private connectedAccounts?;
|
|
7
|
+
constructor({ connector }: LeatherConnector.ConstructorParams);
|
|
8
|
+
getAccountAddresses(): Promise<BitcoinConnector.AccountAddress[]>;
|
|
9
|
+
disconnect(): Promise<void>;
|
|
10
|
+
sendTransfer({ amount, recipient }: BitcoinConnector.SendTransferParams): Promise<string>;
|
|
11
|
+
signPSBT({ psbt, broadcast }: BitcoinConnector.SignPSBTParams): Promise<BitcoinConnector.SignPSBTResponse>;
|
|
12
|
+
private getNetwork;
|
|
13
|
+
}
|
|
14
|
+
export declare namespace LeatherConnector {
|
|
15
|
+
type ConstructorParams = {
|
|
16
|
+
connector: SatsConnectConnector;
|
|
17
|
+
};
|
|
18
|
+
type Network = 'mainnet' | 'testnet' | 'signet' | 'sbtcDevenv' | 'devnet';
|
|
19
|
+
type SendTransferParams = SendTransferRequestParams;
|
|
20
|
+
type SendTransferResponse = SendTransferResponseBody;
|
|
21
|
+
type SignPSBTParams = SignPsbtRequestParams;
|
|
22
|
+
type SignPSBTResponse = SignPsbtResponseBody;
|
|
23
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CaipNetwork } from '@reown/appkit-common';
|
|
2
|
+
import type { BitcoinConnector } from '../utils/BitcoinConnector.js';
|
|
3
|
+
import { ProviderEventEmitter } from '../utils/ProviderEventEmitter.js';
|
|
4
|
+
import type { RequestArguments } from '@reown/appkit-core';
|
|
5
|
+
export declare class OKXConnector extends ProviderEventEmitter implements BitcoinConnector {
|
|
6
|
+
readonly id = "OKX";
|
|
7
|
+
readonly name = "OKX Wallet";
|
|
8
|
+
readonly chain = "bip122";
|
|
9
|
+
readonly type = "ANNOUNCED";
|
|
10
|
+
readonly imageUrl: string;
|
|
11
|
+
readonly provider: this;
|
|
12
|
+
private readonly wallet;
|
|
13
|
+
private readonly requestedChains;
|
|
14
|
+
private readonly getActiveNetwork;
|
|
15
|
+
constructor({ wallet, requestedChains, getActiveNetwork, imageUrl }: OKXConnector.ConstructorParams);
|
|
16
|
+
get chains(): CaipNetwork[];
|
|
17
|
+
connect(): Promise<string>;
|
|
18
|
+
disconnect(): Promise<void>;
|
|
19
|
+
getAccountAddresses(): Promise<BitcoinConnector.AccountAddress[]>;
|
|
20
|
+
signMessage(params: BitcoinConnector.SignMessageParams): Promise<string>;
|
|
21
|
+
sendTransfer(params: BitcoinConnector.SendTransferParams): Promise<string>;
|
|
22
|
+
signPSBT(params: BitcoinConnector.SignPSBTParams): Promise<BitcoinConnector.SignPSBTResponse>;
|
|
23
|
+
request<T>(_args: RequestArguments): Promise<T>;
|
|
24
|
+
private bindEvents;
|
|
25
|
+
private unbindEvents;
|
|
26
|
+
static getWallet(params: OKXConnector.GetWalletParams): OKXConnector | undefined;
|
|
27
|
+
}
|
|
28
|
+
export declare namespace OKXConnector {
|
|
29
|
+
type ConstructorParams = {
|
|
30
|
+
wallet: Wallet;
|
|
31
|
+
requestedChains: CaipNetwork[];
|
|
32
|
+
getActiveNetwork: () => CaipNetwork | undefined;
|
|
33
|
+
imageUrl: string;
|
|
34
|
+
};
|
|
35
|
+
type Wallet = {
|
|
36
|
+
connect(): Promise<{
|
|
37
|
+
address: string;
|
|
38
|
+
publicKey: string;
|
|
39
|
+
}>;
|
|
40
|
+
disconnect(): Promise<void>;
|
|
41
|
+
getAccounts(): Promise<string[]>;
|
|
42
|
+
signMessage(signStr: string, type?: 'ecdsa' | 'bip322-simple'): Promise<string>;
|
|
43
|
+
signPsbt(psbtHex: string): Promise<string>;
|
|
44
|
+
pushPsbt(psbtHex: string): Promise<string>;
|
|
45
|
+
send(params: {
|
|
46
|
+
from: string;
|
|
47
|
+
to: string;
|
|
48
|
+
value: string;
|
|
49
|
+
satBytes?: string;
|
|
50
|
+
memo?: string;
|
|
51
|
+
memoPos?: number;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
txhash: string;
|
|
54
|
+
}>;
|
|
55
|
+
on(event: string, listener: (param?: unknown) => void): void;
|
|
56
|
+
removeAllListeners(): void;
|
|
57
|
+
};
|
|
58
|
+
type GetWalletParams = Omit<ConstructorParams, 'wallet' | 'imageUrl'>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { BitcoinConnector } from '../utils/BitcoinConnector.js';
|
|
2
|
+
import type { CaipNetwork } from '@reown/appkit-common';
|
|
3
|
+
import { type Params, type Provider as SatsConnectProvider, type BitcoinProvider, type Requests as SatsConnectRequests, type RpcSuccessResponse } from 'sats-connect';
|
|
4
|
+
import type { RequestArguments } from '@reown/appkit-core';
|
|
5
|
+
import { ProviderEventEmitter } from '../utils/ProviderEventEmitter.js';
|
|
6
|
+
export declare class SatsConnectConnector extends ProviderEventEmitter implements BitcoinConnector {
|
|
7
|
+
readonly chain = "bip122";
|
|
8
|
+
readonly type = "ANNOUNCED";
|
|
9
|
+
readonly wallet: SatsConnectProvider;
|
|
10
|
+
readonly provider: BitcoinConnector;
|
|
11
|
+
readonly requestedChains: CaipNetwork[];
|
|
12
|
+
readonly getActiveNetwork: () => CaipNetwork | undefined;
|
|
13
|
+
private walletUnsubscribes;
|
|
14
|
+
constructor({ provider, requestedChains, getActiveNetwork }: SatsConnectConnector.ConstructorParams);
|
|
15
|
+
get id(): string;
|
|
16
|
+
get name(): string;
|
|
17
|
+
get imageUrl(): string;
|
|
18
|
+
get chains(): CaipNetwork[];
|
|
19
|
+
request<T>(args: RequestArguments): Promise<T>;
|
|
20
|
+
connect(): Promise<string>;
|
|
21
|
+
disconnect(): Promise<void>;
|
|
22
|
+
getAccountAddresses(): Promise<BitcoinConnector.AccountAddress[]>;
|
|
23
|
+
static getWallets({ requestedChains, getActiveNetwork }: SatsConnectConnector.GetWalletsParams): SatsConnectConnector[];
|
|
24
|
+
signMessage(params: BitcoinConnector.SignMessageParams): Promise<string>;
|
|
25
|
+
signPSBT(params: BitcoinConnector.SignPSBTParams): Promise<BitcoinConnector.SignPSBTResponse>;
|
|
26
|
+
sendTransfer({ amount, recipient }: BitcoinConnector.SendTransferParams): Promise<string>;
|
|
27
|
+
protected getWalletProvider(): BitcoinProvider;
|
|
28
|
+
protected internalRequest<Method extends keyof SatsConnectRequests>(method: Method, options: Params<Method>): Promise<RpcSuccessResponse<Method>['result']>;
|
|
29
|
+
private bindEvents;
|
|
30
|
+
private unbindEvents;
|
|
31
|
+
}
|
|
32
|
+
export declare namespace SatsConnectConnector {
|
|
33
|
+
type ConstructorParams = {
|
|
34
|
+
provider: SatsConnectProvider;
|
|
35
|
+
requestedChains: CaipNetwork[];
|
|
36
|
+
getActiveNetwork: () => CaipNetwork | undefined;
|
|
37
|
+
};
|
|
38
|
+
type GetWalletsParams = {
|
|
39
|
+
requestedChains: CaipNetwork[];
|
|
40
|
+
getActiveNetwork: ConstructorParams['getActiveNetwork'];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BitcoinConnector } from '../utils/BitcoinConnector.js';
|
|
2
|
+
import type { Wallet } from '@wallet-standard/base';
|
|
3
|
+
import type { CaipNetwork } from '@reown/appkit-common';
|
|
4
|
+
import type { Provider, RequestArguments } from '@reown/appkit-core';
|
|
5
|
+
import { ProviderEventEmitter } from '../utils/ProviderEventEmitter.js';
|
|
6
|
+
export declare class WalletStandardConnector extends ProviderEventEmitter implements BitcoinConnector {
|
|
7
|
+
readonly chain = "bip122";
|
|
8
|
+
readonly type = "ANNOUNCED";
|
|
9
|
+
readonly provider: Provider;
|
|
10
|
+
readonly wallet: Wallet;
|
|
11
|
+
private requestedChains;
|
|
12
|
+
private walletUnsubscribes;
|
|
13
|
+
constructor({ wallet, requestedChains }: WalletStandardConnector.ConstructorParams);
|
|
14
|
+
get id(): string;
|
|
15
|
+
get name(): string;
|
|
16
|
+
get imageUrl(): string;
|
|
17
|
+
get chains(): CaipNetwork[];
|
|
18
|
+
connect(): Promise<string>;
|
|
19
|
+
getAccountAddresses(): Promise<BitcoinConnector.AccountAddress[]>;
|
|
20
|
+
signMessage(params: BitcoinConnector.SignMessageParams): Promise<string>;
|
|
21
|
+
signPSBT(params: BitcoinConnector.SignPSBTParams): Promise<BitcoinConnector.SignPSBTResponse>;
|
|
22
|
+
sendTransfer(_params: BitcoinConnector.SendTransferParams): Promise<string>;
|
|
23
|
+
disconnect(): Promise<void>;
|
|
24
|
+
request<T>(_args: RequestArguments): Promise<T>;
|
|
25
|
+
private getWalletFeature;
|
|
26
|
+
private bindEvents;
|
|
27
|
+
private unbindEvents;
|
|
28
|
+
static watchWallets({ callback, requestedChains }: WalletStandardConnector.WatchWalletsParams): () => void;
|
|
29
|
+
}
|
|
30
|
+
export declare namespace WalletStandardConnector {
|
|
31
|
+
type ConstructorParams = {
|
|
32
|
+
wallet: Wallet;
|
|
33
|
+
requestedChains: CaipNetwork[];
|
|
34
|
+
};
|
|
35
|
+
type WatchWalletsParams = {
|
|
36
|
+
callback: (...connectors: WalletStandardConnector[]) => void;
|
|
37
|
+
requestedChains: CaipNetwork[];
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CaipNetwork } from '@reown/appkit-common';
|
|
2
|
+
export declare const BitcoinApi: BitcoinApi.Interface;
|
|
3
|
+
export declare namespace BitcoinApi {
|
|
4
|
+
type Interface = {
|
|
5
|
+
getUTXOs: (params: GetUTXOsParams) => Promise<UTXO[]>;
|
|
6
|
+
};
|
|
7
|
+
type GetUTXOsParams = {
|
|
8
|
+
network: CaipNetwork;
|
|
9
|
+
address: string;
|
|
10
|
+
};
|
|
11
|
+
type UTXO = {
|
|
12
|
+
txid: string;
|
|
13
|
+
vout: number;
|
|
14
|
+
value: number;
|
|
15
|
+
status: {
|
|
16
|
+
confirmed: boolean;
|
|
17
|
+
block_height: number;
|
|
18
|
+
block_hash: string;
|
|
19
|
+
block_time: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ChainAdapterConnector } from '../../../../appkit/dist/types/src/adapters/ChainAdapterConnector.js';
|
|
2
|
+
import type { Provider } from '@reown/appkit-core';
|
|
3
|
+
/**
|
|
4
|
+
* This is the interface for a Bitcoin connector.
|
|
5
|
+
*/
|
|
6
|
+
export interface BitcoinConnector extends ChainAdapterConnector, Provider {
|
|
7
|
+
getAccountAddresses(): Promise<BitcoinConnector.AccountAddress[]>;
|
|
8
|
+
signMessage(params: BitcoinConnector.SignMessageParams): Promise<string>;
|
|
9
|
+
sendTransfer(params: BitcoinConnector.SendTransferParams): Promise<string>;
|
|
10
|
+
signPSBT(params: BitcoinConnector.SignPSBTParams): Promise<BitcoinConnector.SignPSBTResponse>;
|
|
11
|
+
}
|
|
12
|
+
export declare namespace BitcoinConnector {
|
|
13
|
+
type AccountAddress = {
|
|
14
|
+
/**
|
|
15
|
+
* Public address belonging to the account.
|
|
16
|
+
*/
|
|
17
|
+
address: string;
|
|
18
|
+
/**
|
|
19
|
+
* Public key for the derivation path in hex, without 0x prefix
|
|
20
|
+
*/
|
|
21
|
+
publicKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The derivation path of the address e.g. "m/84'/0'/0'/0/0"
|
|
24
|
+
*/
|
|
25
|
+
path?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The purpose of the address
|
|
28
|
+
*/
|
|
29
|
+
purpose: 'payment' | 'ordinal' | 'stx';
|
|
30
|
+
};
|
|
31
|
+
type SignMessageParams = {
|
|
32
|
+
/**
|
|
33
|
+
* The message to be signed
|
|
34
|
+
*/
|
|
35
|
+
message: string;
|
|
36
|
+
/**
|
|
37
|
+
* The address to sign the message with
|
|
38
|
+
*/
|
|
39
|
+
address: string;
|
|
40
|
+
};
|
|
41
|
+
type SendTransferParams = {
|
|
42
|
+
/**
|
|
43
|
+
* The amount to be sent in satoshis
|
|
44
|
+
*/
|
|
45
|
+
amount: string;
|
|
46
|
+
/**
|
|
47
|
+
* The address to send the transfer to
|
|
48
|
+
*/
|
|
49
|
+
recipient: string;
|
|
50
|
+
};
|
|
51
|
+
type SignPSBTParams = {
|
|
52
|
+
/**
|
|
53
|
+
* The PSBT to be signed, string base64 encoded
|
|
54
|
+
*/
|
|
55
|
+
psbt: string;
|
|
56
|
+
signInputs: {
|
|
57
|
+
/**
|
|
58
|
+
* The address whose private key to use for signing.
|
|
59
|
+
*/
|
|
60
|
+
address: string;
|
|
61
|
+
/**
|
|
62
|
+
* Specifies which input to sign
|
|
63
|
+
*/
|
|
64
|
+
index: number;
|
|
65
|
+
/**
|
|
66
|
+
* Specifies which part(s) of the transaction the signature commits to
|
|
67
|
+
*/
|
|
68
|
+
sighashTypes: number[];
|
|
69
|
+
}[];
|
|
70
|
+
/**
|
|
71
|
+
* If `true`, the PSBT will be broadcasted after signing. Default is `false`.
|
|
72
|
+
*/
|
|
73
|
+
broadcast?: boolean;
|
|
74
|
+
};
|
|
75
|
+
type SignPSBTResponse = {
|
|
76
|
+
/**
|
|
77
|
+
* The signed PSBT, string base64 encoded
|
|
78
|
+
*/
|
|
79
|
+
psbt: string;
|
|
80
|
+
/**
|
|
81
|
+
* The `string` transaction id of the broadcasted transaction or `undefined` if not broadcasted
|
|
82
|
+
*/
|
|
83
|
+
txid?: string;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProviderEventListener, Provider } from '@reown/appkit-core';
|
|
2
|
+
type ProviderEventEmitterMethods = Pick<Provider, 'on' | 'removeListener' | 'emit'>;
|
|
3
|
+
type Events = keyof ProviderEventListener;
|
|
4
|
+
type Listener<Event extends Events> = ProviderEventListener[Event];
|
|
5
|
+
export declare class ProviderEventEmitter implements ProviderEventEmitterMethods {
|
|
6
|
+
private listeners;
|
|
7
|
+
on<Event extends Events>(event: Event, listener: Listener<Event>): void;
|
|
8
|
+
removeListener<T>(event: string, listener: (data: T) => void): void;
|
|
9
|
+
emit(event: string, data?: unknown): void;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import UniversalProvider from '@walletconnect/universal-provider';
|
|
2
|
+
import type { CaipNetwork } from '@reown/appkit-common';
|
|
3
|
+
import { type RequestArguments } from '@reown/appkit';
|
|
4
|
+
import type { BitcoinConnector } from './BitcoinConnector.js';
|
|
5
|
+
import { ProviderEventEmitter } from './ProviderEventEmitter.js';
|
|
6
|
+
export type WalletConnectProviderConfig = {
|
|
7
|
+
provider: UniversalProvider;
|
|
8
|
+
chains: CaipNetwork[];
|
|
9
|
+
getActiveChain: () => CaipNetwork | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare class WalletConnectProvider extends ProviderEventEmitter implements BitcoinConnector {
|
|
12
|
+
readonly id = "WalletConnect";
|
|
13
|
+
readonly name = "WalletConnect";
|
|
14
|
+
readonly type = "WALLET_CONNECT";
|
|
15
|
+
readonly chain = "bip122";
|
|
16
|
+
readonly icon = "https://imagedelivery.net/_aTEfDRm7z3tKgu9JhfeKA/05338e12-4f75-4982-4e8a-83c67b826b00/md";
|
|
17
|
+
provider: UniversalProvider;
|
|
18
|
+
private readonly requestedChains;
|
|
19
|
+
private readonly getActiveChain;
|
|
20
|
+
constructor({ provider, chains, getActiveChain }: WalletConnectProviderConfig);
|
|
21
|
+
get chains(): CaipNetwork[];
|
|
22
|
+
connect(): Promise<never>;
|
|
23
|
+
disconnect(): Promise<void>;
|
|
24
|
+
signMessage({ message, address }: BitcoinConnector.SignMessageParams): Promise<string>;
|
|
25
|
+
sendTransfer({ recipient, amount }: BitcoinConnector.SendTransferParams): Promise<string>;
|
|
26
|
+
getAccountAddresses(): Promise<BitcoinConnector.AccountAddress[]>;
|
|
27
|
+
signPSBT(params: BitcoinConnector.SignPSBTParams): Promise<BitcoinConnector.SignPSBTResponse>;
|
|
28
|
+
request<T>(args: RequestArguments): T;
|
|
29
|
+
private get sessionChains();
|
|
30
|
+
private getAccount;
|
|
31
|
+
private checkIfMethodIsSupported;
|
|
32
|
+
private internalRequest;
|
|
33
|
+
}
|
|
34
|
+
export declare namespace WalletConnectProvider {
|
|
35
|
+
type Request<Params, Result> = {
|
|
36
|
+
params: Params;
|
|
37
|
+
returns: Result;
|
|
38
|
+
};
|
|
39
|
+
type WCSignMessageParams = {
|
|
40
|
+
message: string;
|
|
41
|
+
account: string;
|
|
42
|
+
address: string;
|
|
43
|
+
};
|
|
44
|
+
type WCSignMessageResponse = {
|
|
45
|
+
signature: string;
|
|
46
|
+
address: string;
|
|
47
|
+
messageHash: string;
|
|
48
|
+
};
|
|
49
|
+
type WCSendTransferParams = {
|
|
50
|
+
account: string;
|
|
51
|
+
recipientAddress: string;
|
|
52
|
+
amount: string;
|
|
53
|
+
changeAddress?: string;
|
|
54
|
+
memo?: string;
|
|
55
|
+
};
|
|
56
|
+
type WCGetAccountAddressesResponse = {
|
|
57
|
+
address: string;
|
|
58
|
+
publicKey: Uint8Array;
|
|
59
|
+
path: string;
|
|
60
|
+
intention: 'payment' | 'ordinal';
|
|
61
|
+
}[];
|
|
62
|
+
type WCSendTransferResponse = {
|
|
63
|
+
txid: string;
|
|
64
|
+
};
|
|
65
|
+
type WCSignPSBTParams = {
|
|
66
|
+
account: string;
|
|
67
|
+
psbt: string;
|
|
68
|
+
signInputs: {
|
|
69
|
+
address: string;
|
|
70
|
+
index: number;
|
|
71
|
+
sighashTypes?: number[];
|
|
72
|
+
}[];
|
|
73
|
+
broadcast?: boolean;
|
|
74
|
+
};
|
|
75
|
+
type WCSignPSBTResponse = {
|
|
76
|
+
psbt: string;
|
|
77
|
+
txid?: string;
|
|
78
|
+
};
|
|
79
|
+
type RequestMethods = {
|
|
80
|
+
signMessage: Request<WCSignMessageParams, WCSignMessageResponse>;
|
|
81
|
+
sendTransfer: Request<WCSendTransferParams, WCSendTransferResponse>;
|
|
82
|
+
getAccountAddresses: Request<undefined, string[]>;
|
|
83
|
+
signPsbt: Request<WCSignPSBTParams, WCSignPSBTResponse>;
|
|
84
|
+
};
|
|
85
|
+
type RequestMethod = keyof RequestMethods;
|
|
86
|
+
type InternalRequestParams<Method extends RequestMethod> = {
|
|
87
|
+
method: Method;
|
|
88
|
+
params: RequestMethods[Method]['params'];
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { WalletAccount } from '@wallet-standard/base';
|
|
2
|
+
/**
|
|
3
|
+
* This should be in the package `@exodus/bitcoin-wallet-standard`, but as it is outdated we have it here.
|
|
4
|
+
* References to https://github.com/ExodusMovement/bitcoin-wallet-standard/blob/master/packages/core/features/src/signMessage.ts
|
|
5
|
+
*/
|
|
6
|
+
/** Name of the feature. */
|
|
7
|
+
export declare const BitcoinSignMessage = "bitcoin:signMessage";
|
|
8
|
+
/**
|
|
9
|
+
* `bitcoin:signMessage` is a {@link "@wallet-standard/base".Wallet.features | feature} that may be implemented by a
|
|
10
|
+
* {@link "@wallet-standard/base".Wallet} to allow the app to request to sign a message with the specified
|
|
11
|
+
* {@link "@wallet-standard/base".Wallet.accounts | account}.
|
|
12
|
+
*
|
|
13
|
+
* The wallet should prefix the message to be signed to avoid signing a valid transaction.
|
|
14
|
+
* For an example of the prefix (and hashing algorithm), see:
|
|
15
|
+
* https://github.com/bitcoinjs/bitcoinjs-message/blob/c43430f4c03c292c719e7801e425d887cbdf7464/index.js#L57.
|
|
16
|
+
*
|
|
17
|
+
* @group SignMessage
|
|
18
|
+
*/
|
|
19
|
+
export type BitcoinSignMessageFeature = {
|
|
20
|
+
/** Name of the feature. */
|
|
21
|
+
readonly [BitcoinSignMessage]: {
|
|
22
|
+
/** Version of the feature implemented by the Wallet. */
|
|
23
|
+
readonly version: BitcoinSignMessageVersion;
|
|
24
|
+
/** Method to call to use the feature. */
|
|
25
|
+
readonly signMessage: BitcoinSignMessageMethod;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Version of the {@link BitcoinSignMessageFeature} implemented by a {@link "@wallet-standard/base".Wallet}.
|
|
30
|
+
*
|
|
31
|
+
* @group SignMessage
|
|
32
|
+
*/
|
|
33
|
+
export type BitcoinSignMessageVersion = '1.0.0';
|
|
34
|
+
/**
|
|
35
|
+
* Method to call to use the {@link BitcoinSignMessageFeature}.
|
|
36
|
+
*
|
|
37
|
+
* @group SignMessage
|
|
38
|
+
*/
|
|
39
|
+
export type BitcoinSignMessageMethod = (...inputs: readonly BitcoinSignMessageInput[]) => Promise<readonly BitcoinSignMessageOutput[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Input for the {@link BitcoinSignMessageMethod}.
|
|
42
|
+
*
|
|
43
|
+
* @group SignMessage
|
|
44
|
+
*/
|
|
45
|
+
export interface BitcoinSignMessageInput {
|
|
46
|
+
/** Account to use. */
|
|
47
|
+
readonly account: WalletAccount;
|
|
48
|
+
/** Message to sign, as raw bytes. */
|
|
49
|
+
readonly message: Uint8Array;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Output of the {@link BitcoinSignMessageMethod}.
|
|
53
|
+
*
|
|
54
|
+
* @group SignMessage
|
|
55
|
+
*/
|
|
56
|
+
export interface BitcoinSignMessageOutput {
|
|
57
|
+
/**
|
|
58
|
+
* Message bytes that were signed.
|
|
59
|
+
* The wallet may prefix or otherwise modify the message before signing it.
|
|
60
|
+
*/
|
|
61
|
+
readonly signedMessage: Uint8Array;
|
|
62
|
+
/** Message signature produced. */
|
|
63
|
+
readonly signature: Uint8Array;
|
|
64
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { IdentifierString, WalletAccount } from '@wallet-standard/base';
|
|
2
|
+
/**
|
|
3
|
+
* This should be in the package `@exodus/bitcoin-wallet-standard`, but as it is outdated we have it here.
|
|
4
|
+
* References to https://github.com/ExodusMovement/bitcoin-wallet-standard/blob/master/packages/core/features/src/signTransaction.ts
|
|
5
|
+
*/
|
|
6
|
+
/** Name of the feature. */
|
|
7
|
+
export declare const BitcoinSignTransaction = "bitcoin:signTransaction";
|
|
8
|
+
/**
|
|
9
|
+
* `bitcoin:signTransaction` is a {@link "@wallet-standard/base".Wallet.features | feature} that may be implemented by a
|
|
10
|
+
* {@link "@wallet-standard/base".Wallet} to allow the app to request to sign transactions with the specified
|
|
11
|
+
* {@link "@wallet-standard/base".Wallet.accounts}.
|
|
12
|
+
*
|
|
13
|
+
* @group SignTransaction
|
|
14
|
+
*/
|
|
15
|
+
export type BitcoinSignTransactionFeature = {
|
|
16
|
+
/** Name of the feature. */
|
|
17
|
+
readonly [BitcoinSignTransaction]: {
|
|
18
|
+
/** Version of the feature implemented by the Wallet. */
|
|
19
|
+
readonly version: BitcoinSignTransactionVersion;
|
|
20
|
+
/** Method to call to use the feature. */
|
|
21
|
+
readonly signTransaction: BitcoinSignTransactionMethod;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Version of the {@link BitcoinSignTransactionFeature} implemented by a {@link "@wallet-standard/base".Wallet}.
|
|
26
|
+
*
|
|
27
|
+
* @group SignTransaction
|
|
28
|
+
*/
|
|
29
|
+
export type BitcoinSignTransactionVersion = '1.0.0';
|
|
30
|
+
/**
|
|
31
|
+
* Method to call to use the {@link BitcoinSignTransactionFeature}.
|
|
32
|
+
*
|
|
33
|
+
* @group SignTransaction
|
|
34
|
+
*/
|
|
35
|
+
export type BitcoinSignTransactionMethod = (...inputs: readonly BitcoinSignTransactionInput[]) => Promise<readonly BitcoinSignTransactionOutput[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Input for the {@link BitcoinSignTransactionMethod}.
|
|
38
|
+
*
|
|
39
|
+
* @group SignTransaction
|
|
40
|
+
*/
|
|
41
|
+
export interface BitcoinSignTransactionInput {
|
|
42
|
+
/** Partially Signed Bitcoin Transaction (PSBT), as raw bytes. */
|
|
43
|
+
readonly psbt: Uint8Array;
|
|
44
|
+
/** Transaction inputs to sign. */
|
|
45
|
+
readonly inputsToSign: InputToSign[];
|
|
46
|
+
/** Chain to use. */
|
|
47
|
+
readonly chain?: IdentifierString;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Transaction input to be signed with the specified {@link "@wallet-standard/base".WalletAccount | account}.
|
|
51
|
+
*
|
|
52
|
+
* @group SignTransaction
|
|
53
|
+
*/
|
|
54
|
+
export interface InputToSign {
|
|
55
|
+
/** Account to use. */
|
|
56
|
+
readonly account: WalletAccount;
|
|
57
|
+
/** List of input indexes that should be signed by the account. */
|
|
58
|
+
readonly signingIndexes: number[];
|
|
59
|
+
/** A SIGHASH flag. */
|
|
60
|
+
readonly sigHash?: BitcoinSigHashFlag;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Output of the {@link BitcoinSignTransactionMethod}.
|
|
64
|
+
*
|
|
65
|
+
* @group SignTransaction
|
|
66
|
+
*/
|
|
67
|
+
export interface BitcoinSignTransactionOutput {
|
|
68
|
+
/** Signed Partially Signed Bitcoin Transaction (PSBT), as raw bytes. */
|
|
69
|
+
readonly signedPsbt: Uint8Array;
|
|
70
|
+
}
|
|
71
|
+
/** SIGHASH flag. */
|
|
72
|
+
export type BitcoinSigHashFlag = 'ALL' | 'NONE' | 'SINGLE' | 'ALL|ANYONECANPAY' | 'NONE|ANYONECANPAY' | 'SINGLE|ANYONECANPAY';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WalletWithFeatures } from '@wallet-standard/base';
|
|
2
|
+
import type { BitcoinConnectFeature } from '@exodus/bitcoin-wallet-standard';
|
|
3
|
+
import type { BitcoinSignTransactionFeature } from './SignTransaction.js';
|
|
4
|
+
import type { BitcoinSignMessageFeature } from './SignMessage.js';
|
|
5
|
+
import type { StandardEventsFeature } from '@wallet-standard/features';
|
|
6
|
+
/** Type of all Bitcoin features. */
|
|
7
|
+
export type BitcoinFeatures = BitcoinConnectFeature & BitcoinSignTransactionFeature & BitcoinSignMessageFeature & StandardEventsFeature;
|
|
8
|
+
/** Wallet with Bitcoin features. */
|
|
9
|
+
export type WalletWithBitcoinFeatures = WalletWithFeatures<BitcoinFeatures>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Provider as SatsConnectProvider, BitcoinProvider, RpcError } from 'sats-connect';
|
|
2
|
+
export declare function mockSatsConnectProvider(replaces?: Partial<SatsConnectProvider>): {
|
|
3
|
+
provider: SatsConnectProvider;
|
|
4
|
+
wallet: BitcoinProvider;
|
|
5
|
+
};
|
|
6
|
+
export declare namespace mockSatsConnectProvider {
|
|
7
|
+
var mockRequestResolve: <T>(result: T) => {
|
|
8
|
+
id: string;
|
|
9
|
+
jsonrpc: "2.0";
|
|
10
|
+
result: T;
|
|
11
|
+
};
|
|
12
|
+
var mockRequestReject: (error?: Partial<RpcError>) => {
|
|
13
|
+
id: string;
|
|
14
|
+
jsonrpc: "2.0";
|
|
15
|
+
error: {
|
|
16
|
+
code: number;
|
|
17
|
+
message: string;
|
|
18
|
+
data?: any;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare function mockSatsConnectWindowProvider(id: string): BitcoinProvider;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type UniversalProvider from '@walletconnect/universal-provider';
|
|
2
|
+
import type { SessionTypes } from '@walletconnect/types';
|
|
3
|
+
export declare function mockUniversalProvider(replaces?: Partial<UniversalProvider>): UniversalProvider;
|
|
4
|
+
export declare namespace mockUniversalProvider {
|
|
5
|
+
var mockSession: (replaces?: Partial<SessionTypes.Struct>) => SessionTypes.Struct;
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Wallet, WalletAccount } from '@wallet-standard/base';
|
|
2
|
+
import type { BitcoinFeatures } from '../../src/utils/wallet-standard/WalletFeatures.js';
|
|
3
|
+
export declare function mockWalletStandardProvider(replaces?: Partial<Wallet>): Wallet;
|
|
4
|
+
export declare namespace mockWalletStandardProvider {
|
|
5
|
+
var mockFeatures: (replaces?: Partial<BitcoinFeatures>) => BitcoinFeatures;
|
|
6
|
+
var mockAccount: (replaces?: Partial<WalletAccount>) => WalletAccount;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|