@0xtrails/svm 1.0.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 +202 -0
- package/README.md +175 -0
- package/dist/index.d.ts +179 -0
- package/dist/index.js +962 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# @0xtrails/svm
|
|
2
|
+
|
|
3
|
+
Solana (SVM) adapter for the Trails SDK. Enables funding from a Solana wallet into any EVM chain via Relay edge payments.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install 0xtrails @0xtrails/svm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { TrailsWidget, evmAdapter } from '0xtrails'
|
|
15
|
+
import { svmAdapter } from '@0xtrails/svm'
|
|
16
|
+
|
|
17
|
+
const adapters = [
|
|
18
|
+
evmAdapter({ wallets: [{ id: 'injected', name: 'MetaMask' }] }),
|
|
19
|
+
// Auto-detect Wallet Standard Solana wallets.
|
|
20
|
+
svmAdapter({ rpcUrls: ['https://api.mainnet-beta.solana.com'] }),
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
export function App() {
|
|
24
|
+
return (
|
|
25
|
+
<TrailsWidget
|
|
26
|
+
apiKey="YOUR_TRAILS_API_KEY"
|
|
27
|
+
adapters={adapters}
|
|
28
|
+
fundOptions={{ fundMethodsList: ['connected-wallet'] }}
|
|
29
|
+
renderInline
|
|
30
|
+
/>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## `svmAdapter`
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { svmAdapter } from '@0xtrails/svm'
|
|
39
|
+
|
|
40
|
+
svmAdapter(options: SvmAdapterOptions): TrailsAdapterConfig
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Returns a `TrailsAdapterConfig` for use in the `adapters` prop of `TrailsWidget` or `TrailsProvider`.
|
|
44
|
+
|
|
45
|
+
### Options
|
|
46
|
+
|
|
47
|
+
| Option | Type | Description |
|
|
48
|
+
|--------|------|-------------|
|
|
49
|
+
| `wallet` | Wallet Standard wallet, standard-compatible wallet-adapter value, Kit-style wallet session, or serialized signer wallet | Optional connected Solana wallet source. Omit to auto-detect Wallet Standard wallets. Pass `null` to disable auto-detection. |
|
|
50
|
+
| `rpcUrls` | `readonly string[]` | Optional RPC endpoints for auto-detection / wallet connection fallback |
|
|
51
|
+
| `preferredWalletId` | `string` | Optional auto-detected wallet id to prefer |
|
|
52
|
+
| `silentReconnect` | `boolean` | Whether to silently reconnect previously trusted wallets. Defaults to `true`. |
|
|
53
|
+
| `account` | Wallet Standard account | Optional explicit account |
|
|
54
|
+
| `connection` | Solana RPC connection helpers | Optional RPC helpers |
|
|
55
|
+
| `chain` | `string` | Optional Wallet Standard chain, e.g. `solana:mainnet` |
|
|
56
|
+
|
|
57
|
+
### Serialized signer wallet
|
|
58
|
+
|
|
59
|
+
For legacy wallet libraries that require app-level bridging, pass a wallet object with Wallet Standard-style serialized transaction signing:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
interface SolanaWalletContextValue {
|
|
63
|
+
connected: boolean
|
|
64
|
+
publicKey?: { toBase58(): string } | null
|
|
65
|
+
signSerializedTransaction?: (transactionBytes: Uint8Array) => Promise<Uint8Array>
|
|
66
|
+
connection?: {
|
|
67
|
+
rpcEndpoint?: string
|
|
68
|
+
rpcUrls?: string[] // fallback RPC endpoints
|
|
69
|
+
getLatestBlockhash?: (commitment?: string) => Promise<{ blockhash: string; lastValidBlockHeight: number }>
|
|
70
|
+
sendRawTransaction: (serializedTransaction: unknown, options?: unknown) => Promise<string>
|
|
71
|
+
} | null
|
|
72
|
+
walletId?: string
|
|
73
|
+
walletName?: string
|
|
74
|
+
walletIcon?: string
|
|
75
|
+
connect?: (() => Promise<void> | void) | null
|
|
76
|
+
disconnect?: (() => Promise<void> | void) | null
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
This shape can be passed as `svmAdapter({ wallet })`. It is also compatible with wallets that expose the Wallet Standard `solana:signTransaction` feature.
|
|
81
|
+
|
|
82
|
+
## Enabling Solana funding
|
|
83
|
+
|
|
84
|
+
Solana funding is available through the connected-wallet funding path when `svmAdapter` is configured:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<TrailsWidget
|
|
88
|
+
apiKey={apiKey}
|
|
89
|
+
adapters={[svmAdapter({ rpcUrls: ['https://api.mainnet-beta.solana.com'] })]}
|
|
90
|
+
fundOptions={{
|
|
91
|
+
fundMethodsList: ['connected-wallet', 'crypto-transfer'],
|
|
92
|
+
}}
|
|
93
|
+
renderInline
|
|
94
|
+
/>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Supported origin tokens: **SOL, USDC, USDT, PYUSD**.
|
|
98
|
+
|
|
99
|
+
## With wagmi
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { TrailsProvider } from '0xtrails'
|
|
103
|
+
import { wagmiAdapter } from '@0xtrails/adapter-wagmi'
|
|
104
|
+
import { svmAdapter } from '@0xtrails/svm'
|
|
105
|
+
import { WagmiProvider } from 'wagmi'
|
|
106
|
+
|
|
107
|
+
const adapters = [
|
|
108
|
+
wagmiAdapter({ wagmiConfig }),
|
|
109
|
+
svmAdapter({ wallet }),
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
export function App() {
|
|
113
|
+
return (
|
|
114
|
+
<WagmiProvider config={wagmiConfig}>
|
|
115
|
+
<TrailsProvider config={{ trailsApiKey: apiKey, adapters }}>
|
|
116
|
+
<YourRoutes />
|
|
117
|
+
</TrailsProvider>
|
|
118
|
+
</WagmiProvider>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Wallet inputs
|
|
124
|
+
|
|
125
|
+
Usually pass the host wallet directly to `svmAdapter`:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
svmAdapter({ wallet })
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`wallet` may be a Wallet Standard wallet, standard-compatible wallet-adapter value, Kit-style wallet session such as the `wallet` returned by `@solana/react-hooks`' `useWalletConnection()`, or a serialized signer wallet.
|
|
132
|
+
|
|
133
|
+
Use `createSolanaWallet` only when you need the adapted wallet shape yourself:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { createSolanaWallet } from '@0xtrails/svm'
|
|
137
|
+
|
|
138
|
+
const solanaWallet = createSolanaWallet({
|
|
139
|
+
wallet,
|
|
140
|
+
account, // optional if the wallet already exposes accounts
|
|
141
|
+
connection,
|
|
142
|
+
chain: 'solana:mainnet',
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
For legacy `@solana/wallet-adapter-react` integrations, keep the `@solana/web3.js` bridge in your app and pass the resulting serialized signer as `wallet`:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
const wallet = {
|
|
150
|
+
connected,
|
|
151
|
+
publicKey,
|
|
152
|
+
signSerializedTransaction: async (bytes: Uint8Array) => {
|
|
153
|
+
const tx = VersionedTransaction.deserialize(bytes)
|
|
154
|
+
const signed = await signTransaction(tx)
|
|
155
|
+
return signed.serialize()
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const adapters = [svmAdapter({ wallet })]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
See `apps/examples/solana-legacy-wallet-adapter` for the full bridge.
|
|
163
|
+
|
|
164
|
+
For `@solana/react-hooks`, pass the connected session directly:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
const { wallet } = useWalletConnection()
|
|
168
|
+
const adapters = [svmAdapter({ wallet })]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Wallet Standard inputs must expose `solana:signTransaction`. Kit-style wallet sessions must expose `signTransaction`. No `@solana/web3.js` transaction classes are required by `@0xtrails/svm`; legacy apps can bridge them before passing `wallet`.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { TrailsAdapterConfig } from "0xtrails";
|
|
5
|
+
import { SolanaWalletContextValue } from "0xtrails/widget";
|
|
6
|
+
|
|
7
|
+
//#region src/walletHelpers.d.ts
|
|
8
|
+
type SolanaRpcConnection = NonNullable<SolanaWalletContextValue["connection"]>;
|
|
9
|
+
type WalletStandardAccountLike = {
|
|
10
|
+
address: string;
|
|
11
|
+
chains?: readonly string[];
|
|
12
|
+
};
|
|
13
|
+
type WalletStandardSignTransactionFeature = {
|
|
14
|
+
signTransaction: (...inputs: Array<{
|
|
15
|
+
account: WalletStandardAccountLike;
|
|
16
|
+
transaction: Uint8Array;
|
|
17
|
+
chain?: string;
|
|
18
|
+
}>) => Promise<Array<{
|
|
19
|
+
signedTransaction: Uint8Array;
|
|
20
|
+
}>>;
|
|
21
|
+
};
|
|
22
|
+
type WalletStandardSolanaWalletLike = {
|
|
23
|
+
name?: string;
|
|
24
|
+
icon?: string;
|
|
25
|
+
accounts?: readonly WalletStandardAccountLike[];
|
|
26
|
+
features?: {
|
|
27
|
+
"solana:signTransaction"?: WalletStandardSignTransactionFeature;
|
|
28
|
+
} & Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
type WalletAdapterStandardLike = {
|
|
31
|
+
standard?: boolean;
|
|
32
|
+
connected?: boolean;
|
|
33
|
+
wallet?: WalletStandardSolanaWalletLike;
|
|
34
|
+
};
|
|
35
|
+
type WalletAdapterReactWalletLike = {
|
|
36
|
+
adapter?: WalletAdapterStandardLike;
|
|
37
|
+
};
|
|
38
|
+
type KitWalletSessionLike = {
|
|
39
|
+
account?: {
|
|
40
|
+
address?: {
|
|
41
|
+
toString(): string;
|
|
42
|
+
} | string;
|
|
43
|
+
};
|
|
44
|
+
connector?: {
|
|
45
|
+
icon?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
};
|
|
48
|
+
signTransaction?: (transaction: never) => Promise<unknown>;
|
|
49
|
+
};
|
|
50
|
+
type SerializedSolanaWalletLike = SolanaWalletContextValue;
|
|
51
|
+
type CreateSolanaWalletInput = WalletStandardSolanaWalletLike | WalletAdapterStandardLike | WalletAdapterReactWalletLike | KitWalletSessionLike | SerializedSolanaWalletLike | null | undefined;
|
|
52
|
+
type CreateSolanaWalletOptions = {
|
|
53
|
+
/** Wallet Standard wallet, standard-compatible wallet adapter, or Kit-style wallet session. */wallet: CreateSolanaWalletInput; /** Optional explicit Wallet Standard account. Defaults to the first Solana account exposed by the wallet. */
|
|
54
|
+
account?: WalletStandardAccountLike | null;
|
|
55
|
+
connection?: SolanaRpcConnection | null;
|
|
56
|
+
connected?: boolean;
|
|
57
|
+
chain?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Creates a Trails Solana wallet from a Wallet Standard wallet,
|
|
61
|
+
* standard-compatible `@solana/wallet-adapter` adapter, or Kit-style wallet
|
|
62
|
+
* session such as `@solana/react-hooks`' connected `wallet` value.
|
|
63
|
+
*
|
|
64
|
+
* This helper signs serialized Solana transaction bytes without requiring
|
|
65
|
+
* `@solana/web3.js` transaction classes.
|
|
66
|
+
*/
|
|
67
|
+
declare function createSolanaWallet({
|
|
68
|
+
wallet: inputWallet,
|
|
69
|
+
account: inputAccount,
|
|
70
|
+
connection,
|
|
71
|
+
connected,
|
|
72
|
+
chain
|
|
73
|
+
}: CreateSolanaWalletOptions): SolanaWalletContextValue | null;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/walletDetection/useDetectedSolanaWallet.d.ts
|
|
76
|
+
interface SvmWalletDetectionOptions {
|
|
77
|
+
preferredWalletId?: string;
|
|
78
|
+
rpcUrls?: readonly string[];
|
|
79
|
+
silentReconnect?: boolean;
|
|
80
|
+
}
|
|
81
|
+
interface UseDetectedSolanaWalletOptions extends SvmWalletDetectionOptions {
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
}
|
|
84
|
+
declare function useDetectedSolanaWallet(options?: UseDetectedSolanaWalletOptions): SolanaWalletContextValue | null;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/walletDetection/disconnectPersistence.d.ts
|
|
87
|
+
declare function readDisconnectedWalletIds(): Set<string>;
|
|
88
|
+
/** Clear persisted disconnect state after an explicit reconnect. */
|
|
89
|
+
declare function clearWalletDisconnected(walletId: string): void;
|
|
90
|
+
/** Wrap disconnect so explicit widget disconnects survive page refresh. */
|
|
91
|
+
declare function withPersistentSolanaDisconnect(wallet: SolanaWalletContextValue | null | undefined): SolanaWalletContextValue | null | undefined;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/plugin.d.ts
|
|
94
|
+
interface SvmPluginProviderProps {
|
|
95
|
+
account?: CreateSolanaWalletOptions["account"];
|
|
96
|
+
chain?: string;
|
|
97
|
+
connected?: boolean;
|
|
98
|
+
connection?: CreateSolanaWalletOptions["connection"];
|
|
99
|
+
wallet?: CreateSolanaWalletInput;
|
|
100
|
+
/** RPC endpoints used by the built-in Wallet Standard auto-detection flow. */
|
|
101
|
+
rpcUrls?: SvmWalletDetectionOptions["rpcUrls"];
|
|
102
|
+
/** Preferred Wallet Standard wallet id to select/connect first. */
|
|
103
|
+
preferredWalletId?: SvmWalletDetectionOptions["preferredWalletId"];
|
|
104
|
+
/** Whether to silently reconnect previously trusted wallets. Defaults to true. */
|
|
105
|
+
silentReconnect?: SvmWalletDetectionOptions["silentReconnect"];
|
|
106
|
+
children: ReactNode;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Registers the SVM plugin and provides the Solana wallet context.
|
|
110
|
+
* Wrap your app (or TrailsWidget) with this provider to enable Solana edge payments.
|
|
111
|
+
* Composes with other EdgePlugin providers — each appends to the shared registry.
|
|
112
|
+
*/
|
|
113
|
+
declare function SvmPluginProvider({
|
|
114
|
+
account,
|
|
115
|
+
chain,
|
|
116
|
+
connected,
|
|
117
|
+
connection,
|
|
118
|
+
wallet,
|
|
119
|
+
rpcUrls,
|
|
120
|
+
preferredWalletId,
|
|
121
|
+
silentReconnect,
|
|
122
|
+
children
|
|
123
|
+
}: SvmPluginProviderProps): import("react").JSX.Element;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/edge/executeRelaySolanaQuote.d.ts
|
|
126
|
+
declare class ErrEVMStepInSolanaQuote extends Error {
|
|
127
|
+
constructor();
|
|
128
|
+
}
|
|
129
|
+
type RelaySolanaQuoteParams = {
|
|
130
|
+
rpcUrls: readonly string[];
|
|
131
|
+
signerPublicKeyBase58: string;
|
|
132
|
+
signSerializedTransaction: (transactionBytes: Uint8Array) => Promise<Uint8Array>;
|
|
133
|
+
providerQuote: unknown;
|
|
134
|
+
walletConnection?: {
|
|
135
|
+
getLatestBlockhash?: (commitment?: string) => Promise<{
|
|
136
|
+
blockhash: string;
|
|
137
|
+
lastValidBlockHeight: number;
|
|
138
|
+
}>;
|
|
139
|
+
sendRawTransaction: (serializedTransaction: unknown, options?: unknown) => Promise<string>;
|
|
140
|
+
} | null;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Signs and submits Solana txs from Relay edge.providerQuote.
|
|
144
|
+
* Uses Wallet Standard-style serialized transaction signing so the SVM package does not need web3.js transaction classes.
|
|
145
|
+
* Returns the submitted transaction signatures.
|
|
146
|
+
*/
|
|
147
|
+
declare function executeRelaySolanaQuote(params: RelaySolanaQuoteParams): Promise<string[]>;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/svmAdapter.d.ts
|
|
150
|
+
interface SvmAdapterOptions {
|
|
151
|
+
account?: CreateSolanaWalletOptions["account"];
|
|
152
|
+
chain?: string;
|
|
153
|
+
connected?: boolean;
|
|
154
|
+
connection?: CreateSolanaWalletOptions["connection"];
|
|
155
|
+
wallet?: CreateSolanaWalletInput;
|
|
156
|
+
/** RPC endpoints used by the built-in Wallet Standard auto-detection flow. */
|
|
157
|
+
rpcUrls?: SvmWalletDetectionOptions["rpcUrls"];
|
|
158
|
+
/** Preferred Wallet Standard wallet id to select/connect first. */
|
|
159
|
+
preferredWalletId?: SvmWalletDetectionOptions["preferredWalletId"];
|
|
160
|
+
/** Whether to silently reconnect previously trusted wallets. Defaults to true. */
|
|
161
|
+
silentReconnect?: SvmWalletDetectionOptions["silentReconnect"];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creates a Trails wallet adapter for Solana (SVM) edge payments.
|
|
165
|
+
*
|
|
166
|
+
* Provides the Solana wallet context and auto-registers the SVM edge plugin
|
|
167
|
+
* when passed to `TrailsWidget` or `TrailsProvider` via the `adapters` prop.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```tsx
|
|
171
|
+
* import { evmAdapter } from "0xtrails"
|
|
172
|
+
* import { svmAdapter } from "@0xtrails/svm"
|
|
173
|
+
*
|
|
174
|
+
* <TrailsWidget adapters={[evmAdapter({ wallets: [...] }), svmAdapter({ wallet })]} />
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function svmAdapter(options: SvmAdapterOptions): TrailsAdapterConfig;
|
|
178
|
+
//#endregion
|
|
179
|
+
export { type CreateSolanaWalletInput, type CreateSolanaWalletOptions, ErrEVMStepInSolanaQuote, type SerializedSolanaWalletLike, type SvmAdapterOptions, SvmPluginProvider, type SvmPluginProviderProps, type SvmWalletDetectionOptions, type WalletStandardAccountLike, type WalletStandardSolanaWalletLike, clearWalletDisconnected, createSolanaWallet, executeRelaySolanaQuote, readDisconnectedWalletIds, svmAdapter, useDetectedSolanaWallet, withPersistentSolanaDisconnect };
|