@meshconnect/uwc-types 0.2.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/dist/UWC-state.d.ts +62 -0
- package/dist/UWC-state.d.ts.map +1 -0
- package/dist/UWC-state.js +2 -0
- package/dist/UWC-state.js.map +1 -0
- package/dist/connection-mode.d.ts +2 -0
- package/dist/connection-mode.d.ts.map +1 -0
- package/dist/connection-mode.js +2 -0
- package/dist/connection-mode.js.map +1 -0
- package/dist/connector.d.ts +76 -0
- package/dist/connector.d.ts.map +1 -0
- package/dist/connector.js +2 -0
- package/dist/connector.js.map +1 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/network-rpc.d.ts +6 -0
- package/dist/network-rpc.d.ts.map +1 -0
- package/dist/network-rpc.js +2 -0
- package/dist/network-rpc.js.map +1 -0
- package/dist/networks.d.ts +33 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +2 -0
- package/dist/networks.js.map +1 -0
- package/dist/providers.d.ts +7 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +2 -0
- package/dist/providers.js.map +1 -0
- package/dist/react-hooks.d.ts +231 -0
- package/dist/react-hooks.d.ts.map +1 -0
- package/dist/react-hooks.js +2 -0
- package/dist/react-hooks.js.map +1 -0
- package/dist/session.d.ts +16 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +2 -0
- package/dist/session.js.map +1 -0
- package/dist/signature.d.ts +28 -0
- package/dist/signature.d.ts.map +1 -0
- package/dist/signature.js +2 -0
- package/dist/signature.js.map +1 -0
- package/dist/transactions.d.ts +109 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/transactions.js +5 -0
- package/dist/transactions.js.map +1 -0
- package/dist/wallet-connect-connector.d.ts +13 -0
- package/dist/wallet-connect-connector.d.ts.map +1 -0
- package/dist/wallet-connect-connector.js +2 -0
- package/dist/wallet-connect-connector.js.map +1 -0
- package/package.json +32 -0
- package/src/UWC-state.ts +77 -0
- package/src/connection-mode.ts +1 -0
- package/src/connector.ts +118 -0
- package/src/errors.ts +20 -0
- package/src/index.ts +12 -0
- package/src/network-rpc.ts +6 -0
- package/src/networks.ts +62 -0
- package/src/providers.ts +14 -0
- package/src/react-hooks.ts +256 -0
- package/src/session.ts +17 -0
- package/src/signature.ts +36 -0
- package/src/transactions.ts +127 -0
- package/src/wallet-connect-connector.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../src/signature.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EVM Transaction Types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Gas configuration for EVM transactions
|
|
6
|
+
*/
|
|
7
|
+
export interface EVMGasConfig {
|
|
8
|
+
gasLimit?: number | null;
|
|
9
|
+
maxFeePerGas?: number | null;
|
|
10
|
+
maxPriorityFeePerGas?: number | null;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Request for native EVM token transfer (ETH, BNB, MATIC, etc.)
|
|
14
|
+
*/
|
|
15
|
+
export interface EVMNativeTransferRequest {
|
|
16
|
+
to: string;
|
|
17
|
+
amount: bigint;
|
|
18
|
+
from: string;
|
|
19
|
+
gasConfig?: EVMGasConfig;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Request for EVM smart contract interaction
|
|
23
|
+
*/
|
|
24
|
+
export interface EVMContractCallRequest {
|
|
25
|
+
contractAddress: string;
|
|
26
|
+
abi: any[];
|
|
27
|
+
functionName: string;
|
|
28
|
+
args: unknown[];
|
|
29
|
+
from: string;
|
|
30
|
+
value?: string;
|
|
31
|
+
gasConfig?: EVMGasConfig;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Single call in a batch transaction
|
|
35
|
+
*/
|
|
36
|
+
export interface EVMBatchCall {
|
|
37
|
+
to: string;
|
|
38
|
+
value: string;
|
|
39
|
+
data?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Request for batch EVM transactions (EIP-5792)
|
|
43
|
+
*/
|
|
44
|
+
export interface EVMBatchTransactionRequest {
|
|
45
|
+
version: string;
|
|
46
|
+
from: string;
|
|
47
|
+
chainId: string;
|
|
48
|
+
atomicRequired: boolean;
|
|
49
|
+
calls: EVMBatchCall[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* EVM wallet capabilities
|
|
53
|
+
*/
|
|
54
|
+
export interface EVMCapabilities {
|
|
55
|
+
atomicBatch?: {
|
|
56
|
+
supported: boolean;
|
|
57
|
+
};
|
|
58
|
+
paymasterService?: {
|
|
59
|
+
supported: boolean;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Solana Transaction Types
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* Request for native SOL transfer
|
|
67
|
+
*/
|
|
68
|
+
export interface SolanaNativeTransferRequest {
|
|
69
|
+
from: string;
|
|
70
|
+
to: string;
|
|
71
|
+
amount: bigint;
|
|
72
|
+
blockhash: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Configuration for Solana transactions (internal use)
|
|
76
|
+
*/
|
|
77
|
+
export interface SolanaTransactionConfig {
|
|
78
|
+
fromAddress: string;
|
|
79
|
+
toAddress: string;
|
|
80
|
+
amount: string | number;
|
|
81
|
+
blockhash: string;
|
|
82
|
+
tokenMint?: string;
|
|
83
|
+
tokenDecimals?: number;
|
|
84
|
+
tokenProgram?: string;
|
|
85
|
+
createATA?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Common Transaction Types
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Result of a transaction
|
|
92
|
+
*/
|
|
93
|
+
export type TransactionResult = string;
|
|
94
|
+
/**
|
|
95
|
+
* Result of a batch transaction
|
|
96
|
+
*/
|
|
97
|
+
export interface BatchTransactionResult {
|
|
98
|
+
id: string;
|
|
99
|
+
status: number;
|
|
100
|
+
atomic: boolean;
|
|
101
|
+
receipts: Array<{
|
|
102
|
+
transactionHash: string;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Generic transaction request that can be either EVM or Solana
|
|
107
|
+
*/
|
|
108
|
+
export type TransactionRequest = EVMNativeTransferRequest | EVMContractCallRequest | EVMBatchTransactionRequest | SolanaNativeTransferRequest;
|
|
109
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,YAAY,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE,MAAM,CAAA;IAEvB,GAAG,EAAE,GAAG,EAAE,CAAA;IACV,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,YAAY,CAAA;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,OAAO,CAAA;IACvB,KAAK,EAAE,YAAY,EAAE,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE;QACZ,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,gBAAgB,CAAC,EAAE;QACjB,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;CACF;AAED;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IAEjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAEtC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,KAAK,CAAC;QACd,eAAe,EAAE,MAAM,CAAA;KACxB,CAAC,CAAA;CACH;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,wBAAwB,GACxB,sBAAsB,GACtB,0BAA0B,GAC1B,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../src/transactions.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for WalletConnect connector
|
|
3
|
+
*/
|
|
4
|
+
export interface WalletConnectConfig {
|
|
5
|
+
projectId?: string;
|
|
6
|
+
metadata?: {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
url: string;
|
|
10
|
+
icons: string[];
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=wallet-connect-connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-connect-connector.d.ts","sourceRoot":"","sources":["../src/wallet-connect-connector.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,EAAE,MAAM,CAAA;QACnB,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,EAAE,CAAA;KAChB,CAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-connect-connector.js","sourceRoot":"","sources":["../src/wallet-connect-connector.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meshconnect/uwc-types",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "TypeScript types for Universal Wallet Connector",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.9.2"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"dev": "tsc --watch",
|
|
28
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
29
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
30
|
+
"type-check": "tsc --noEmit"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/UWC-state.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { NetworkId, Namespace } from './networks'
|
|
2
|
+
import type { Session } from './session'
|
|
3
|
+
|
|
4
|
+
export interface UniversalWalletConnectorState {
|
|
5
|
+
session: Session
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DetectedEIP6963WalletInfo {
|
|
9
|
+
uuid: string
|
|
10
|
+
name: string
|
|
11
|
+
icon: string
|
|
12
|
+
rdns: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DetectedSolanaWalletInfo {
|
|
16
|
+
uuid: string
|
|
17
|
+
name: string
|
|
18
|
+
features: string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Eip155Metadata {
|
|
22
|
+
eip155Name: string
|
|
23
|
+
injectedId: string
|
|
24
|
+
supportsAddingNetworks: boolean
|
|
25
|
+
requiresUserApprovalOnNetworkSwitch: boolean
|
|
26
|
+
installed?: boolean
|
|
27
|
+
detectedWallet?: DetectedEIP6963WalletInfo
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SolanaMetadata {
|
|
31
|
+
walletStandardName?: string
|
|
32
|
+
injectedId?: string
|
|
33
|
+
ignoredInjectedIds?: string[]
|
|
34
|
+
installed?: boolean
|
|
35
|
+
detectedWallet?: DetectedSolanaWalletInfo
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type NamespaceMetaDataMap = {
|
|
39
|
+
[K in Namespace]?: K extends 'eip155'
|
|
40
|
+
? Eip155Metadata
|
|
41
|
+
: K extends 'solana'
|
|
42
|
+
? SolanaMetadata
|
|
43
|
+
: undefined
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ExtensionInjectedProvider {
|
|
47
|
+
supportedNetworkIds: NetworkId[]
|
|
48
|
+
namespaceMetaData: Partial<NamespaceMetaDataMap>
|
|
49
|
+
requiresUserApprovalOnNamespaceSwitch: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IntegratedBrowserInjectedProvider
|
|
53
|
+
extends ExtensionInjectedProvider {
|
|
54
|
+
integratedBrowserDeeplink: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type DeeplinkType = 'universal' | 'native'
|
|
58
|
+
|
|
59
|
+
export interface WalletConnectProvider {
|
|
60
|
+
supportedNetworkIds: NetworkId[]
|
|
61
|
+
deeplinks: {
|
|
62
|
+
universal: string
|
|
63
|
+
native: string
|
|
64
|
+
androidPreferredDeeplink?: DeeplinkType
|
|
65
|
+
iOSPreferredDeeplink?: DeeplinkType
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface WalletMetadata {
|
|
70
|
+
id: string
|
|
71
|
+
name: string
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
metadata: Record<string, any>
|
|
74
|
+
extensionInjectedProvider?: ExtensionInjectedProvider
|
|
75
|
+
integratedBrowserInjectedProvider?: IntegratedBrowserInjectedProvider
|
|
76
|
+
walletConnectProvider?: WalletConnectProvider
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ConnectionMode = 'injected' | 'walletConnect'
|
package/src/connector.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Network, NetworkId, Namespace } from './networks'
|
|
2
|
+
import type { AvailableAddress } from './session'
|
|
3
|
+
import type {
|
|
4
|
+
DetectedEIP6963WalletInfo,
|
|
5
|
+
DetectedSolanaWalletInfo,
|
|
6
|
+
ExtensionInjectedProvider,
|
|
7
|
+
IntegratedBrowserInjectedProvider,
|
|
8
|
+
WalletConnectProvider
|
|
9
|
+
} from './UWC-state'
|
|
10
|
+
import type { TransactionRequest, TransactionResult } from './transactions'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Result interface for connect operations
|
|
14
|
+
*/
|
|
15
|
+
export interface ConnectorResult {
|
|
16
|
+
networkId: NetworkId
|
|
17
|
+
address: string
|
|
18
|
+
availableAddresses: AvailableAddress[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Result interface for network switch operations
|
|
23
|
+
*/
|
|
24
|
+
export interface SwitchNetworkResult {
|
|
25
|
+
networkId: NetworkId
|
|
26
|
+
address: string
|
|
27
|
+
availableAddresses?: AvailableAddress[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Common interface for all wallet connectors
|
|
32
|
+
*/
|
|
33
|
+
export interface Connector {
|
|
34
|
+
/**
|
|
35
|
+
* Connect to a wallet on the specified network
|
|
36
|
+
* @param network The network to connect to
|
|
37
|
+
* @param args Additional arguments specific to the connector type
|
|
38
|
+
* @returns A promise that resolves to a ConnectorResult containing the network ID, wallet address, and available addresses
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
connect(
|
|
42
|
+
network: Network,
|
|
43
|
+
provider?:
|
|
44
|
+
| ExtensionInjectedProvider
|
|
45
|
+
| IntegratedBrowserInjectedProvider
|
|
46
|
+
| WalletConnectProvider
|
|
47
|
+
): Promise<ConnectorResult>
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get the connection URI for the wallet, if applicable
|
|
51
|
+
* This is typically used for WalletConnect or similar protocols
|
|
52
|
+
* to allow the user to scan a QR code or open a link
|
|
53
|
+
* to initiate the connection.
|
|
54
|
+
* @return A string representing the connection URI, or undefined if not applicable
|
|
55
|
+
* @remarks This method is optional and may not be implemented by all connectors.
|
|
56
|
+
*/
|
|
57
|
+
getConnectionURI?(): string
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Disconnect from the wallet
|
|
61
|
+
* This method is optional and may not be implemented by all connectors.
|
|
62
|
+
* @returns A promise that resolves when the disconnection is complete
|
|
63
|
+
*/
|
|
64
|
+
disconnect?(): Promise<void>
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Switch to a different network
|
|
68
|
+
* @param network The network to switch to
|
|
69
|
+
* @param args Additional arguments specific to the connector type
|
|
70
|
+
* @returns A promise that resolves to a SwitchNetworkResult containing the network ID and new wallet address
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
switchNetwork(
|
|
74
|
+
network: Network,
|
|
75
|
+
provider?:
|
|
76
|
+
| ExtensionInjectedProvider
|
|
77
|
+
| IntegratedBrowserInjectedProvider
|
|
78
|
+
| WalletConnectProvider
|
|
79
|
+
): Promise<SwitchNetworkResult>
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get available wallets for a specific namespace
|
|
83
|
+
* This method is optional and may not be implemented by all connectors.
|
|
84
|
+
* @param namespace The namespace to check for available wallets (e.g., 'eip155', 'solana')
|
|
85
|
+
* @returns A promise that resolves to an array of detected wallets, or undefined if not supported
|
|
86
|
+
*/
|
|
87
|
+
getAvailableWallets?(
|
|
88
|
+
namespace: Namespace
|
|
89
|
+
): Promise<DetectedEIP6963WalletInfo[] | DetectedSolanaWalletInfo[]>
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Sign a message with the connected wallet
|
|
93
|
+
* @param message The message to sign
|
|
94
|
+
* @param provider The wallet provider (required for injected connector)
|
|
95
|
+
* @returns A promise that resolves to the signature
|
|
96
|
+
*/
|
|
97
|
+
signMessage?(
|
|
98
|
+
message: string,
|
|
99
|
+
provider?:
|
|
100
|
+
| ExtensionInjectedProvider
|
|
101
|
+
| IntegratedBrowserInjectedProvider
|
|
102
|
+
| WalletConnectProvider
|
|
103
|
+
): Promise<string>
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Send a transaction with the connected wallet
|
|
107
|
+
* @param request The transaction request parameters
|
|
108
|
+
* @param provider The wallet provider (required for injected connector)
|
|
109
|
+
* @returns A promise that resolves to the transaction result
|
|
110
|
+
*/
|
|
111
|
+
sendTransaction?(
|
|
112
|
+
request: TransactionRequest,
|
|
113
|
+
provider?:
|
|
114
|
+
| ExtensionInjectedProvider
|
|
115
|
+
| IntegratedBrowserInjectedProvider
|
|
116
|
+
| WalletConnectProvider
|
|
117
|
+
): Promise<TransactionResult>
|
|
118
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ErrorType = 'unknown' | 'rejected'
|
|
2
|
+
|
|
3
|
+
export interface WalletError {
|
|
4
|
+
type: ErrorType
|
|
5
|
+
message: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Custom error class that includes wallet error metadata
|
|
10
|
+
* This is thrown by the connectors when operations fail
|
|
11
|
+
*/
|
|
12
|
+
export class WalletConnectorError extends Error {
|
|
13
|
+
type: ErrorType
|
|
14
|
+
|
|
15
|
+
constructor(walletError: WalletError) {
|
|
16
|
+
super(walletError.message)
|
|
17
|
+
this.name = 'WalletConnectorError'
|
|
18
|
+
this.type = walletError.type
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './networks'
|
|
2
|
+
export * from './network-rpc'
|
|
3
|
+
export * from './connection-mode'
|
|
4
|
+
export * from './session'
|
|
5
|
+
export * from './UWC-state'
|
|
6
|
+
export * from './connector'
|
|
7
|
+
export * from './providers'
|
|
8
|
+
export * from './wallet-connect-connector'
|
|
9
|
+
export * from './react-hooks'
|
|
10
|
+
export * from './signature'
|
|
11
|
+
export * from './transactions'
|
|
12
|
+
export * from './errors'
|
package/src/networks.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type NetworkId =
|
|
2
|
+
| 'eip155:1'
|
|
3
|
+
| 'eip155:11155111'
|
|
4
|
+
| 'solana:devnet'
|
|
5
|
+
| 'eip155:56'
|
|
6
|
+
| 'eip155:137'
|
|
7
|
+
| 'eip155:43114'
|
|
8
|
+
| 'eip155:42161'
|
|
9
|
+
| 'eip155:10'
|
|
10
|
+
| 'eip155:8453'
|
|
11
|
+
| 'bip122:000000000019d6689c085ae165831e93'
|
|
12
|
+
| 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'
|
|
13
|
+
| 'tron:0x2b6653dc'
|
|
14
|
+
| 'eip155:81457'
|
|
15
|
+
| 'bip122:1a91e3dace36e2be3bf030a65679fe82'
|
|
16
|
+
| 'xrpl:0'
|
|
17
|
+
| 'bip122:12a765e31ffd4059bada1e25190f6e98'
|
|
18
|
+
|
|
19
|
+
export type NetworkType =
|
|
20
|
+
| 'evm'
|
|
21
|
+
| 'solana'
|
|
22
|
+
| 'bitcoin'
|
|
23
|
+
| 'tron'
|
|
24
|
+
| 'dogecoin'
|
|
25
|
+
| 'litecoin'
|
|
26
|
+
| 'ripple'
|
|
27
|
+
|
|
28
|
+
export type Namespace = 'eip155' | 'solana' | 'bip122' | 'tron' | 'xrpl'
|
|
29
|
+
|
|
30
|
+
export interface NativeCurrency {
|
|
31
|
+
name: string
|
|
32
|
+
symbol: string
|
|
33
|
+
decimals: number
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RpcUrls {
|
|
37
|
+
default: {
|
|
38
|
+
http: string[]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface BlockExplorer {
|
|
43
|
+
name: string
|
|
44
|
+
url: string
|
|
45
|
+
apiUrl?: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface BlockExplorers {
|
|
49
|
+
default: BlockExplorer
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Network {
|
|
53
|
+
internalId: number
|
|
54
|
+
id: NetworkId
|
|
55
|
+
namespace: Namespace
|
|
56
|
+
name: string
|
|
57
|
+
logoUrl: string
|
|
58
|
+
nativeCurrency: NativeCurrency
|
|
59
|
+
rpcUrls?: RpcUrls
|
|
60
|
+
blockExplorers?: BlockExplorers
|
|
61
|
+
networkType: NetworkType
|
|
62
|
+
}
|
package/src/providers.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtensionInjectedProvider,
|
|
3
|
+
IntegratedBrowserInjectedProvider,
|
|
4
|
+
WalletConnectProvider
|
|
5
|
+
} from './UWC-state'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Union type of all supported provider types
|
|
9
|
+
* Used throughout the application to handle different wallet provider types
|
|
10
|
+
*/
|
|
11
|
+
export type SupportedProvider =
|
|
12
|
+
| ExtensionInjectedProvider
|
|
13
|
+
| IntegratedBrowserInjectedProvider
|
|
14
|
+
| WalletConnectProvider
|