@dropfi/xrpl-react 0.1.5 โ 0.1.6
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 +119 -24
- package/package.json +56 -55
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
## ๐ Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- โ
Auto-initializes the injected `window.xrpl` provider (extension or mobile)
|
|
8
|
+
- โ
Provides `connect`, `disconnect`, `sendTransaction`, and `signMessage`
|
|
9
|
+
- โ
React hook with `address`, `network`, `connectedAccounts`, and more
|
|
10
|
+
- โ
Compatible with both browser extension and mobile webview injection
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -27,23 +27,23 @@ pnpm add @dropfi/xrpl-react
|
|
|
27
27
|
import { XrplProvider, useXrplReact } from '@dropfi/xrpl-react';
|
|
28
28
|
|
|
29
29
|
export default function App() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
return (
|
|
31
|
+
<XrplProvider>
|
|
32
|
+
<SomeComponent />
|
|
33
|
+
</XrplProvider>
|
|
34
|
+
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function SomeComponent() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
const { address, connect, disconnect } = useXrplReact();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<p>Address: {address ?? 'Not connected'}</p>
|
|
43
|
+
<button onClick={connect}>Connect Wallet</button>
|
|
44
|
+
<button onClick={disconnect}>Disconnect</button>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
@@ -79,10 +79,10 @@ Returns:
|
|
|
79
79
|
|
|
80
80
|
These are internally emitted and listened to:
|
|
81
81
|
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
82
|
+
- `xrpl_selectedAddress`
|
|
83
|
+
- `xrpl_connectedAccounts`
|
|
84
|
+
- `xrpl_selectedNetwork`
|
|
85
|
+
- `xrpl_disconnect`
|
|
86
86
|
|
|
87
87
|
---
|
|
88
88
|
|
|
@@ -90,11 +90,106 @@ These are internally emitted and listened to:
|
|
|
90
90
|
|
|
91
91
|
Make sure your app runs in an environment where `window.xrpl` is available. This is injected by the DropFi wallet:
|
|
92
92
|
|
|
93
|
-
-
|
|
94
|
-
-
|
|
93
|
+
- Chrome extension
|
|
94
|
+
- React Native mobile app via WebView
|
|
95
95
|
|
|
96
96
|
---
|
|
97
97
|
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
title: XRPL Transactions
|
|
101
|
+
description: How to use `sendTransaction` and supported XRPL transaction types in @dropfi/xrpl-react.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
import { Highlight } from '@theme-ui/components'
|
|
106
|
+
|
|
107
|
+
# ๐ค Sending XRPL Transactions
|
|
108
|
+
|
|
109
|
+
The `useXrpl` hook provided by `@dropfi/xrpl-react` includes a powerful `sendTransaction` function that allows you to send XRPL transactions directly from your React app using the connected wallet.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
const { sendTransaction } = useXrpl();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## โ๏ธ Supported Transaction Types
|
|
118
|
+
|
|
119
|
+
You can send any valid XRPL transaction using `sendTransaction`. Common supported types include:
|
|
120
|
+
|
|
121
|
+
- `Payment`
|
|
122
|
+
- `TrustSet`
|
|
123
|
+
- `AccountSet`
|
|
124
|
+
- `OfferCreate`
|
|
125
|
+
- `OfferCancel`
|
|
126
|
+
- `NFTokenMint`
|
|
127
|
+
- `NFTokenBurn`
|
|
128
|
+
- `NFTokenCreateOffer`
|
|
129
|
+
- `NFTokenCancelOffer`
|
|
130
|
+
- `NFTokenAcceptOffer`
|
|
131
|
+
- `SetRegularKey`
|
|
132
|
+
- `SignerListSet`
|
|
133
|
+
- `EscrowCreate`
|
|
134
|
+
- `EscrowCancel`
|
|
135
|
+
- `EscrowFinish`
|
|
136
|
+
- `DepositPreauth`
|
|
137
|
+
- `CheckCreate`
|
|
138
|
+
- `CheckCash`
|
|
139
|
+
- `CheckCancel`
|
|
140
|
+
- `TicketCreate`
|
|
141
|
+
- `AccountDelete`
|
|
142
|
+
- `PaymentChannelCreate`
|
|
143
|
+
- `PaymentChannelFund`
|
|
144
|
+
- `PaymentChannelClaim`
|
|
145
|
+
- `AMMCreate`
|
|
146
|
+
- `AMMDeposit`
|
|
147
|
+
- `AMMWithdraw`
|
|
148
|
+
- `AMMVote`
|
|
149
|
+
|
|
150
|
+
_For full documentation, see the [XRPL Transaction Types](https://xrpl.org/transaction-types.html)._
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## ๐ธ Example: Sending a Payment
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const tx: Payment = {
|
|
158
|
+
TransactionType: 'Payment',
|
|
159
|
+
Account: wallet.address,
|
|
160
|
+
Destination: 'rDestinationAddressHere',
|
|
161
|
+
Amount: '1000000', // 1 XRP in drops
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
await sendTransaction(tx);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## ๐งพ Example: NFTokenCreateOffer
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
const tx: NFTokenCreateOffer = {
|
|
173
|
+
TransactionType: 'NFTokenCreateOffer',
|
|
174
|
+
Account: nft.owner,
|
|
175
|
+
NFTokenID: nft.NftId,
|
|
176
|
+
Destination: 'rBrokerAccountHere',
|
|
177
|
+
Flags: 0x00000001, // 1 = sell offer
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
await sendTransaction(tx);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## ๐ Notes
|
|
186
|
+
|
|
187
|
+
- Every transaction must include the `TransactionType` and `Account` fields.
|
|
188
|
+
- Amounts must be specified in **drops** for XRP or as `{ currency, issuer, value }` for tokens.
|
|
189
|
+
- You must be connected with a valid XRPL-compatible wallet like **DropFi** to sign and submit.
|
|
190
|
+
|
|
191
|
+
> Need more examples? Check the [xrpl.org transaction explorer](https://xrpl.org/transaction-types.html) or open an issue.
|
|
192
|
+
|
|
98
193
|
## ๐ License
|
|
99
194
|
|
|
100
195
|
MIT ยฉ [Travis Delly](https://github.com/dellybro)
|
package/package.json
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist"
|
|
17
|
-
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "rollup -c",
|
|
20
|
-
"clean": "rm -rf dist",
|
|
21
|
-
"prepublishOnly": "pnpm run clean && pnpm run build"
|
|
22
|
-
},
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"react": "^18.0.0",
|
|
25
|
-
"react-dom": "^18.0.0"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@rollup/plugin-commonjs": "^25.0.0",
|
|
29
|
-
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
30
|
-
"@rollup/plugin-typescript": "^11.1.2",
|
|
31
|
-
"@types/react": "^19.1.8",
|
|
32
|
-
"@types/react-dom": "^19.1.6",
|
|
33
|
-
"rollup": "^4.0.0",
|
|
34
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
35
|
-
"typescript": "^5.0.0"
|
|
36
|
-
},
|
|
37
|
-
"author": "DropFi",
|
|
38
|
-
"license": "MIT",
|
|
39
|
-
"repository": {
|
|
40
|
-
"type": "git",
|
|
41
|
-
"url": "https://github.com/Dellybro/XrplReact"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://github.com/DropFi/xrpl-react#readme",
|
|
44
|
-
"bugs": {
|
|
45
|
-
"url": "https://github.com/Dellybro/XrplReact/issues"
|
|
46
|
-
},
|
|
47
|
-
"keywords": [
|
|
48
|
-
"xrpl",
|
|
49
|
-
"dropfi",
|
|
50
|
-
"react",
|
|
51
|
-
"wallet",
|
|
52
|
-
"provider",
|
|
53
|
-
"hook"
|
|
54
|
-
],
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"tslib": "^2.8.1"
|
|
2
|
+
"name": "@dropfi/xrpl-react",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "React provider and hook for XRPL dApps using DropFi wallet",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"import": "./dist/index.mjs"
|
|
57
14
|
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rollup -c",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"prepublishOnly": "pnpm run clean && pnpm run build"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^18.0.0",
|
|
26
|
+
"react-dom": "^18.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@rollup/plugin-commonjs": "^25.0.0",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
31
|
+
"@rollup/plugin-typescript": "^11.1.2",
|
|
32
|
+
"@types/react": "^19.1.8",
|
|
33
|
+
"@types/react-dom": "^19.1.6",
|
|
34
|
+
"rollup": "^4.0.0",
|
|
35
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
36
|
+
"typescript": "^5.0.0"
|
|
37
|
+
},
|
|
38
|
+
"author": "DropFi",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/Dellybro/XrplReact"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/DropFi/xrpl-react#readme",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/Dellybro/XrplReact/issues"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"xrpl",
|
|
50
|
+
"dropfi",
|
|
51
|
+
"react",
|
|
52
|
+
"wallet",
|
|
53
|
+
"provider",
|
|
54
|
+
"hook"
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"tslib": "^2.8.1"
|
|
58
|
+
}
|
|
58
59
|
}
|