turing-wallet-provider 1.0.0 → 1.0.2

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 CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
3
  ## Description
4
4
 
5
- The Turing Wallet Provider simplifies the process of integrating Turing Wallet into your react application by creating a provider that wraps your application.
5
+ The Turing Wallet Provider simplifies the process of integrating [Turing Wallet](https://chromewebstore.google.com/detail/turing-wallet/hmodlkcjggjgfalgdgbflhefijojdjen?hl=zh-CN&utm_source=ext_sidebar) into your react application by creating a provider that wraps your application.
6
6
 
7
7
  ## Installation
8
8
 
9
- Install the package using npm:
9
+ Install the package using npm/yarn:
10
10
 
11
11
  ```sh
12
12
  npm install turing-wallet-provider
13
+ yarn add turing-wallet-provider
13
14
  ```
14
15
 
15
16
  ## Usage
@@ -51,4 +52,121 @@ function YourComponent() {
51
52
  }
52
53
  ```
53
54
 
55
+ ### Provider Api
54
56
 
57
+ ##### GettingAdresses & Public Keys
58
+
59
+ After establishing a connection, you'll likely need to know the user's addresses and public keys at some point.
60
+
61
+ ```tsx
62
+ const { tbcAddress, ordAddress, identityAddress } = await wallet.getAddresses();
63
+ const { tbcPubKey, ordPubKey, identityPubKey } = await wallet.getPubKeys();
64
+ ```
65
+
66
+ ##### Send TBC
67
+
68
+ Before send TBC to a Bitcoin address(es), you may simply pass an `array` of payment objects.
69
+
70
+ ```tsx
71
+ const { txid, rawtx } = await wallet.sendBsv(paymentParams);
72
+ ```
73
+
74
+ ##### Get UTXOs
75
+
76
+ ```tsx
77
+ const utxos = await wallet.getPaymentUtxos();
78
+ ```
79
+
80
+ ##### Get Social Profile
81
+
82
+ After establishing a connection, your application may want to pull in certain social preferences like a user Display Name or Avatar.
83
+
84
+ ```tsx
85
+ const { displayName, avatar } = await wallet.getSocialProfile();
86
+ ```
87
+
88
+ ##### Get Balance
89
+
90
+ ```tsx
91
+ const { tbc, satoshis, usdInCents } = await wallet.getBalance();
92
+ ```
93
+
94
+ ##### Get Exchange Rate
95
+
96
+ Fetch the TBC exchange rate in USD.
97
+
98
+ ```tsx
99
+ const rate = await wallet.getExchangeRate();
100
+ ```
101
+
102
+ ##### Disconnect the Provider
103
+
104
+ Turing Wallet will whitelist the requesting applications domain. To sever this connection you can simply call `disconnect()`.
105
+
106
+ ```tsx
107
+ await wallet.disconnect()
108
+ ```
109
+
110
+ ##### Broadcast Raw Tx
111
+
112
+ You will need to pass an object that contains the rawtx:
113
+
114
+ ```tsx
115
+ {
116
+ rawtx: string
117
+ fund?: boolean;
118
+ }
119
+ ```
120
+
121
+ Passing the optional fund param will add and sign inputs from the user's Turing Wallet along with calculating and applying the appropriate change for the tx.
122
+
123
+ ```tsx
124
+ const param = {
125
+ rawtx:"xxx",
126
+ };
127
+ const txid = await wallet.broadcast(param);
128
+ ```
129
+
130
+ ##### Sign Message
131
+
132
+ To transmit a message for user signing you must pass an object that contains a message. You can also pass an optional encoding param for more advanced signings:
133
+
134
+ ```tsx
135
+ {
136
+ message: string;
137
+ encoding?: "utf8" | "hex" | "base64" ;
138
+ };
139
+ const message = { message: "Hello world" };
140
+ const response = await panda.signMessage(message);
141
+ ```
142
+
143
+ ##### Get Signatures
144
+
145
+ ```tsx
146
+ const sigRequests: SignatureRequest[] = [
147
+ {
148
+ prevTxid:
149
+ outputIndex: 0,
150
+ inputIndex: 0,
151
+ satoshis: 1,
152
+ address:
153
+ },
154
+ {
155
+ prevTxid:
156
+ outputIndex: 0,
157
+ inputIndex: 1,
158
+ satoshis: 1000,
159
+ address:
160
+ script:
161
+ }
162
+ ];
163
+
164
+ const sigResponses: SignatureResponse[] = await wallet.getSignatures({
165
+ rawtx:
166
+ sigRequests
167
+ });
168
+ ```
169
+
170
+ # Demo
171
+
172
+ [turing-wallet-sample](https://github.com/TuringBitChain/turing-wallet-sample)
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useTuringWallet = void 0;
4
4
  var react_1 = require("react");
5
- var TuringWalletContext_1 = require("/dist/context/TuringWalletContext");
5
+ var TuringWalletContext_1 = require("../context/TuringWalletContext");
6
6
  var useTuringWallet = function () {
7
7
  var context = (0, react_1.useContext)(TuringWalletContext_1.TuringContext);
8
8
  if (!context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turing-wallet-provider",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [