helius-wallet-kit 0.1.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/README.md +96 -0
- package/dist/core/index.cjs +461 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +170 -0
- package/dist/core/index.d.ts +170 -0
- package/dist/core/index.js +456 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.cjs +461 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +456 -0
- package/dist/index.js.map +1 -0
- package/dist/next/index.cjs +240 -0
- package/dist/next/index.cjs.map +1 -0
- package/dist/next/index.d.cts +53 -0
- package/dist/next/index.d.ts +53 -0
- package/dist/next/index.js +238 -0
- package/dist/next/index.js.map +1 -0
- package/dist/ui/index.cjs +4 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +2 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/styles.css +58 -0
- package/package.json +83 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Connection } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
interface HeliusWalletConfig {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Helius project id. Required — stamped as the Turnkey sub-org name on every
|
|
9
|
+
* end-user wallet so signatures can be attributed to your project for usage
|
|
10
|
+
* billing (resolved server-side via getSubOrgIds by name).
|
|
11
|
+
*/
|
|
12
|
+
projectId: string;
|
|
13
|
+
planTier?: HeliusPlan;
|
|
14
|
+
rpcProxyPath?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Base URL for the Helius WaaS control-plane API (the `/waas/config`
|
|
17
|
+
* bootstrap). Defaults to Helius production; override for local/staging.
|
|
18
|
+
*/
|
|
19
|
+
apiBaseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Per-cluster Helius Secure RPC URL (key-less, safe in the browser). When set
|
|
22
|
+
* for the active cluster, the wallet's Solana connection, priority-fee lookups,
|
|
23
|
+
* and transaction sends go directly to it — no route handler needed. Sends use
|
|
24
|
+
* standard RPC (not Helius Sender), so they forgo Sender's optimized landing;
|
|
25
|
+
* use proxy mode for best mainnet landing. Falls back to the same-origin
|
|
26
|
+
* `rpcProxyPath` proxy when unset. Pass a stable reference (memoize it) to
|
|
27
|
+
* avoid unnecessary re-renders.
|
|
28
|
+
*/
|
|
29
|
+
secureRpcUrl?: Partial<Record<Cluster, string>>;
|
|
30
|
+
cluster?: Cluster;
|
|
31
|
+
authMethods?: {
|
|
32
|
+
passkey?: boolean;
|
|
33
|
+
email?: boolean;
|
|
34
|
+
sms?: boolean;
|
|
35
|
+
wallet?: boolean;
|
|
36
|
+
google?: boolean;
|
|
37
|
+
apple?: boolean;
|
|
38
|
+
discord?: boolean;
|
|
39
|
+
x?: boolean;
|
|
40
|
+
};
|
|
41
|
+
theme?: {
|
|
42
|
+
darkMode?: boolean;
|
|
43
|
+
primaryColor?: string;
|
|
44
|
+
borderRadius?: string;
|
|
45
|
+
logoLight?: string;
|
|
46
|
+
logoDark?: string;
|
|
47
|
+
};
|
|
48
|
+
onError?: (error: Error) => void;
|
|
49
|
+
}
|
|
50
|
+
type Cluster = "devnet" | "mainnet-beta";
|
|
51
|
+
type HeliusPlan = "basic" | "developer" | "business" | "professional";
|
|
52
|
+
declare function isWaasEligible(plan: HeliusPlan): boolean;
|
|
53
|
+
type AuthStatus = "loading" | "unauthenticated" | "authenticated";
|
|
54
|
+
type PriorityLevel = "Min" | "Low" | "Medium" | "High" | "VeryHigh" | "UnsafeMax";
|
|
55
|
+
/**
|
|
56
|
+
* All six priority-fee levels (in micro-lamports per compute unit) returned by
|
|
57
|
+
* Helius's `getPriorityFeeEstimate` when called with
|
|
58
|
+
* `includeAllPriorityFeeLevels: true`. The lowercase keys match the upstream
|
|
59
|
+
* RPC response shape — intentionally distinct from the PascalCase
|
|
60
|
+
* `PriorityLevel` union which is what the RPC accepts as input.
|
|
61
|
+
*/
|
|
62
|
+
interface PriorityFeeLevels {
|
|
63
|
+
min: number;
|
|
64
|
+
low: number;
|
|
65
|
+
medium: number;
|
|
66
|
+
high: number;
|
|
67
|
+
veryHigh: number;
|
|
68
|
+
unsafeMax: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* One row of Helius Enhanced Transactions API response. Fields beyond the
|
|
72
|
+
* common set are passed through verbatim via the index signature — Helius's
|
|
73
|
+
* parsed-tx schema is evolving, and consumers rendering UI off specific fields
|
|
74
|
+
* should cast at their call site rather than wait for us to widen this type.
|
|
75
|
+
*/
|
|
76
|
+
interface EnhancedTransaction {
|
|
77
|
+
signature: string;
|
|
78
|
+
slot: number;
|
|
79
|
+
timestamp: number;
|
|
80
|
+
type: string;
|
|
81
|
+
source: string;
|
|
82
|
+
fee: number;
|
|
83
|
+
feePayer: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
nativeTransfers?: Array<{
|
|
86
|
+
fromUserAccount: string;
|
|
87
|
+
toUserAccount: string;
|
|
88
|
+
amount: number;
|
|
89
|
+
}>;
|
|
90
|
+
tokenTransfers?: Array<{
|
|
91
|
+
fromUserAccount: string;
|
|
92
|
+
toUserAccount: string;
|
|
93
|
+
mint: string;
|
|
94
|
+
tokenAmount: number;
|
|
95
|
+
}>;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
interface HeliusWallet {
|
|
99
|
+
address: string | null;
|
|
100
|
+
status: AuthStatus;
|
|
101
|
+
user: {
|
|
102
|
+
userId: string;
|
|
103
|
+
username: string;
|
|
104
|
+
email?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Turnkey sub-organization id for this end-user. Each authenticated user
|
|
107
|
+
* gets their own sub-org, fully isolated. Useful for server-side audit
|
|
108
|
+
* trails and admin observability. Always defined when status is
|
|
109
|
+
* "authenticated".
|
|
110
|
+
*/
|
|
111
|
+
subOrgId: string;
|
|
112
|
+
/**
|
|
113
|
+
* Turnkey wallet id (the wallet container holding this user's accounts).
|
|
114
|
+
* May be undefined for a brief window post-signup before the wallet
|
|
115
|
+
* provisioning completes.
|
|
116
|
+
*/
|
|
117
|
+
walletId: string | null;
|
|
118
|
+
} | null;
|
|
119
|
+
login: () => Promise<void>;
|
|
120
|
+
logout: () => Promise<void>;
|
|
121
|
+
signTransaction: (transaction: Uint8Array | Buffer) => Promise<Buffer>;
|
|
122
|
+
signAndSendTransaction: (transaction: Uint8Array | Buffer) => Promise<string>;
|
|
123
|
+
signMessage: (message: string) => Promise<string>;
|
|
124
|
+
exportWallet: () => Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Fetch parsed transaction history for the connected wallet via Helius
|
|
127
|
+
* Enhanced Transactions API. Returns empty array if no wallet is connected.
|
|
128
|
+
*/
|
|
129
|
+
getTransactions: (options?: {
|
|
130
|
+
limit?: number;
|
|
131
|
+
}) => Promise<EnhancedTransaction[]>;
|
|
132
|
+
/**
|
|
133
|
+
* Estimate priority fee in micro-lamports for a transaction touching the
|
|
134
|
+
* given writable accounts. `priorityLevel` defaults to "Medium". Uses
|
|
135
|
+
* Helius's `getPriorityFeeEstimate` RPC method.
|
|
136
|
+
*/
|
|
137
|
+
getPriorityFee: (accountKeys: string[], priorityLevel?: PriorityLevel) => Promise<number>;
|
|
138
|
+
/**
|
|
139
|
+
* Like `getPriorityFee`, but returns every level Helius reports
|
|
140
|
+
* (min/low/medium/high/veryHigh/unsafeMax). Use when rendering a fee
|
|
141
|
+
* picker; otherwise prefer `getPriorityFee` for the single-value case.
|
|
142
|
+
*/
|
|
143
|
+
getPriorityFeeLevels: (accountKeys: string[]) => Promise<PriorityFeeLevels>;
|
|
144
|
+
connection: Connection;
|
|
145
|
+
rpcUrl: string;
|
|
146
|
+
cluster: Cluster;
|
|
147
|
+
setCluster: (cluster: Cluster) => void;
|
|
148
|
+
apiKey: string | null;
|
|
149
|
+
projectId: string | null;
|
|
150
|
+
planTier: HeliusPlan | null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare const HeliusWalletContext: React.Context<{
|
|
154
|
+
rpcProxyPath: string;
|
|
155
|
+
secureRpcUrl?: Partial<Record<Cluster, string>>;
|
|
156
|
+
cluster: Cluster;
|
|
157
|
+
setCluster: (cluster: Cluster) => void;
|
|
158
|
+
apiKey: string | null;
|
|
159
|
+
projectId: string | null;
|
|
160
|
+
planTier: HeliusPlan | null;
|
|
161
|
+
waasEligible: boolean;
|
|
162
|
+
}>;
|
|
163
|
+
declare function HeliusWalletProvider({ config, children, }: {
|
|
164
|
+
config: HeliusWalletConfig;
|
|
165
|
+
children: React.ReactNode;
|
|
166
|
+
}): react_jsx_runtime.JSX.Element;
|
|
167
|
+
|
|
168
|
+
declare function useHeliusWallet(): HeliusWallet;
|
|
169
|
+
|
|
170
|
+
export { type AuthStatus, type Cluster, type EnhancedTransaction, type HeliusPlan, type HeliusWallet, type HeliusWalletConfig, HeliusWalletContext, HeliusWalletProvider, type PriorityFeeLevels, type PriorityLevel, isWaasEligible, useHeliusWallet };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Connection } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
interface HeliusWalletConfig {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Helius project id. Required — stamped as the Turnkey sub-org name on every
|
|
9
|
+
* end-user wallet so signatures can be attributed to your project for usage
|
|
10
|
+
* billing (resolved server-side via getSubOrgIds by name).
|
|
11
|
+
*/
|
|
12
|
+
projectId: string;
|
|
13
|
+
planTier?: HeliusPlan;
|
|
14
|
+
rpcProxyPath?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Base URL for the Helius WaaS control-plane API (the `/waas/config`
|
|
17
|
+
* bootstrap). Defaults to Helius production; override for local/staging.
|
|
18
|
+
*/
|
|
19
|
+
apiBaseUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Per-cluster Helius Secure RPC URL (key-less, safe in the browser). When set
|
|
22
|
+
* for the active cluster, the wallet's Solana connection, priority-fee lookups,
|
|
23
|
+
* and transaction sends go directly to it — no route handler needed. Sends use
|
|
24
|
+
* standard RPC (not Helius Sender), so they forgo Sender's optimized landing;
|
|
25
|
+
* use proxy mode for best mainnet landing. Falls back to the same-origin
|
|
26
|
+
* `rpcProxyPath` proxy when unset. Pass a stable reference (memoize it) to
|
|
27
|
+
* avoid unnecessary re-renders.
|
|
28
|
+
*/
|
|
29
|
+
secureRpcUrl?: Partial<Record<Cluster, string>>;
|
|
30
|
+
cluster?: Cluster;
|
|
31
|
+
authMethods?: {
|
|
32
|
+
passkey?: boolean;
|
|
33
|
+
email?: boolean;
|
|
34
|
+
sms?: boolean;
|
|
35
|
+
wallet?: boolean;
|
|
36
|
+
google?: boolean;
|
|
37
|
+
apple?: boolean;
|
|
38
|
+
discord?: boolean;
|
|
39
|
+
x?: boolean;
|
|
40
|
+
};
|
|
41
|
+
theme?: {
|
|
42
|
+
darkMode?: boolean;
|
|
43
|
+
primaryColor?: string;
|
|
44
|
+
borderRadius?: string;
|
|
45
|
+
logoLight?: string;
|
|
46
|
+
logoDark?: string;
|
|
47
|
+
};
|
|
48
|
+
onError?: (error: Error) => void;
|
|
49
|
+
}
|
|
50
|
+
type Cluster = "devnet" | "mainnet-beta";
|
|
51
|
+
type HeliusPlan = "basic" | "developer" | "business" | "professional";
|
|
52
|
+
declare function isWaasEligible(plan: HeliusPlan): boolean;
|
|
53
|
+
type AuthStatus = "loading" | "unauthenticated" | "authenticated";
|
|
54
|
+
type PriorityLevel = "Min" | "Low" | "Medium" | "High" | "VeryHigh" | "UnsafeMax";
|
|
55
|
+
/**
|
|
56
|
+
* All six priority-fee levels (in micro-lamports per compute unit) returned by
|
|
57
|
+
* Helius's `getPriorityFeeEstimate` when called with
|
|
58
|
+
* `includeAllPriorityFeeLevels: true`. The lowercase keys match the upstream
|
|
59
|
+
* RPC response shape — intentionally distinct from the PascalCase
|
|
60
|
+
* `PriorityLevel` union which is what the RPC accepts as input.
|
|
61
|
+
*/
|
|
62
|
+
interface PriorityFeeLevels {
|
|
63
|
+
min: number;
|
|
64
|
+
low: number;
|
|
65
|
+
medium: number;
|
|
66
|
+
high: number;
|
|
67
|
+
veryHigh: number;
|
|
68
|
+
unsafeMax: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* One row of Helius Enhanced Transactions API response. Fields beyond the
|
|
72
|
+
* common set are passed through verbatim via the index signature — Helius's
|
|
73
|
+
* parsed-tx schema is evolving, and consumers rendering UI off specific fields
|
|
74
|
+
* should cast at their call site rather than wait for us to widen this type.
|
|
75
|
+
*/
|
|
76
|
+
interface EnhancedTransaction {
|
|
77
|
+
signature: string;
|
|
78
|
+
slot: number;
|
|
79
|
+
timestamp: number;
|
|
80
|
+
type: string;
|
|
81
|
+
source: string;
|
|
82
|
+
fee: number;
|
|
83
|
+
feePayer: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
nativeTransfers?: Array<{
|
|
86
|
+
fromUserAccount: string;
|
|
87
|
+
toUserAccount: string;
|
|
88
|
+
amount: number;
|
|
89
|
+
}>;
|
|
90
|
+
tokenTransfers?: Array<{
|
|
91
|
+
fromUserAccount: string;
|
|
92
|
+
toUserAccount: string;
|
|
93
|
+
mint: string;
|
|
94
|
+
tokenAmount: number;
|
|
95
|
+
}>;
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
}
|
|
98
|
+
interface HeliusWallet {
|
|
99
|
+
address: string | null;
|
|
100
|
+
status: AuthStatus;
|
|
101
|
+
user: {
|
|
102
|
+
userId: string;
|
|
103
|
+
username: string;
|
|
104
|
+
email?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Turnkey sub-organization id for this end-user. Each authenticated user
|
|
107
|
+
* gets their own sub-org, fully isolated. Useful for server-side audit
|
|
108
|
+
* trails and admin observability. Always defined when status is
|
|
109
|
+
* "authenticated".
|
|
110
|
+
*/
|
|
111
|
+
subOrgId: string;
|
|
112
|
+
/**
|
|
113
|
+
* Turnkey wallet id (the wallet container holding this user's accounts).
|
|
114
|
+
* May be undefined for a brief window post-signup before the wallet
|
|
115
|
+
* provisioning completes.
|
|
116
|
+
*/
|
|
117
|
+
walletId: string | null;
|
|
118
|
+
} | null;
|
|
119
|
+
login: () => Promise<void>;
|
|
120
|
+
logout: () => Promise<void>;
|
|
121
|
+
signTransaction: (transaction: Uint8Array | Buffer) => Promise<Buffer>;
|
|
122
|
+
signAndSendTransaction: (transaction: Uint8Array | Buffer) => Promise<string>;
|
|
123
|
+
signMessage: (message: string) => Promise<string>;
|
|
124
|
+
exportWallet: () => Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Fetch parsed transaction history for the connected wallet via Helius
|
|
127
|
+
* Enhanced Transactions API. Returns empty array if no wallet is connected.
|
|
128
|
+
*/
|
|
129
|
+
getTransactions: (options?: {
|
|
130
|
+
limit?: number;
|
|
131
|
+
}) => Promise<EnhancedTransaction[]>;
|
|
132
|
+
/**
|
|
133
|
+
* Estimate priority fee in micro-lamports for a transaction touching the
|
|
134
|
+
* given writable accounts. `priorityLevel` defaults to "Medium". Uses
|
|
135
|
+
* Helius's `getPriorityFeeEstimate` RPC method.
|
|
136
|
+
*/
|
|
137
|
+
getPriorityFee: (accountKeys: string[], priorityLevel?: PriorityLevel) => Promise<number>;
|
|
138
|
+
/**
|
|
139
|
+
* Like `getPriorityFee`, but returns every level Helius reports
|
|
140
|
+
* (min/low/medium/high/veryHigh/unsafeMax). Use when rendering a fee
|
|
141
|
+
* picker; otherwise prefer `getPriorityFee` for the single-value case.
|
|
142
|
+
*/
|
|
143
|
+
getPriorityFeeLevels: (accountKeys: string[]) => Promise<PriorityFeeLevels>;
|
|
144
|
+
connection: Connection;
|
|
145
|
+
rpcUrl: string;
|
|
146
|
+
cluster: Cluster;
|
|
147
|
+
setCluster: (cluster: Cluster) => void;
|
|
148
|
+
apiKey: string | null;
|
|
149
|
+
projectId: string | null;
|
|
150
|
+
planTier: HeliusPlan | null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare const HeliusWalletContext: React.Context<{
|
|
154
|
+
rpcProxyPath: string;
|
|
155
|
+
secureRpcUrl?: Partial<Record<Cluster, string>>;
|
|
156
|
+
cluster: Cluster;
|
|
157
|
+
setCluster: (cluster: Cluster) => void;
|
|
158
|
+
apiKey: string | null;
|
|
159
|
+
projectId: string | null;
|
|
160
|
+
planTier: HeliusPlan | null;
|
|
161
|
+
waasEligible: boolean;
|
|
162
|
+
}>;
|
|
163
|
+
declare function HeliusWalletProvider({ config, children, }: {
|
|
164
|
+
config: HeliusWalletConfig;
|
|
165
|
+
children: React.ReactNode;
|
|
166
|
+
}): react_jsx_runtime.JSX.Element;
|
|
167
|
+
|
|
168
|
+
declare function useHeliusWallet(): HeliusWallet;
|
|
169
|
+
|
|
170
|
+
export { type AuthStatus, type Cluster, type EnhancedTransaction, type HeliusPlan, type HeliusWallet, type HeliusWalletConfig, HeliusWalletContext, HeliusWalletProvider, type PriorityFeeLevels, type PriorityLevel, isWaasEligible, useHeliusWallet };
|