turing-wallet-provider 1.0.1 → 1.0.4
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 +182 -54
- package/dist/context/TuringWalletContext.d.ts +8 -8
- package/dist/context/TuringWalletContext.js +24 -24
- package/dist/hook/useTuringWallet.d.ts +1 -1
- package/dist/hook/useTuringWallet.js +13 -13
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -19
- package/dist/types/providerTypes.d.ts +252 -252
- package/dist/types/providerTypes.js +9 -9
- package/package.json +33 -33
package/README.md
CHANGED
|
@@ -1,54 +1,182 @@
|
|
|
1
|
-
# Turing Wallet Provider
|
|
2
|
-
|
|
3
|
-
## Description
|
|
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.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Install the package using npm:
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm install turing-wallet-provider
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
# Turing Wallet Provider
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the package using npm/yarn:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install turing-wallet-provider
|
|
13
|
+
yarn add turing-wallet-provider
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Setup the Provider
|
|
19
|
+
|
|
20
|
+
First, wrap your application with the TuringProvider.
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
//... other imports
|
|
24
|
+
import { TuringProvider } from "turing-wallet-provider";
|
|
25
|
+
|
|
26
|
+
const root = ReactDOM.createRoot(
|
|
27
|
+
document.getElementById("root") as HTMLElement
|
|
28
|
+
);
|
|
29
|
+
root.render(
|
|
30
|
+
<TuringProvider>
|
|
31
|
+
<App />
|
|
32
|
+
</TuringProvider>
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Use the Wallet Hook
|
|
37
|
+
|
|
38
|
+
You can now use the useTuringWallet hook to interact with the wallet.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { useTuringWallet } from 'turing-wallet-provider';
|
|
42
|
+
|
|
43
|
+
function YourComponent() {
|
|
44
|
+
const wallet = useTuringWallet();
|
|
45
|
+
const isReady = wallet.isReady;
|
|
46
|
+
console.log(isReady);
|
|
47
|
+
// true
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
// Your TSX
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Provider Api
|
|
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 paymentParams: = [
|
|
72
|
+
{
|
|
73
|
+
satoshis: 10000,
|
|
74
|
+
address: "18izL7Wtm2fx3ALoRY3MkY2VFSMjArP62D",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
satoshis: 54000,
|
|
78
|
+
address: "1q6td54oZU8EPM1PwJcB1Z6upPyMe3Vy2",
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
const { txid, rawtx } = await wallet.sendTbc(paymentParams);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
##### Get UTXOs
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
const utxos = await wallet.getPaymentUtxos();
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
##### Get Social Profile
|
|
91
|
+
|
|
92
|
+
After establishing a connection, your application may want to pull in certain social preferences like a user Display Name or Avatar.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
const { displayName, avatar } = await wallet.getSocialProfile();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
##### Get Balance
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
const { tbc, satoshis, usdInCents } = await wallet.getBalance();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
##### Get Exchange Rate
|
|
105
|
+
|
|
106
|
+
Fetch the TBC exchange rate in USD.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
const rate = await wallet.getExchangeRate();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
##### Disconnect the Provider
|
|
113
|
+
|
|
114
|
+
Turing Wallet will whitelist the requesting applications domain. To sever this connection you can simply call `disconnect()`.
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
await wallet.disconnect()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
##### Broadcast Raw Tx
|
|
121
|
+
|
|
122
|
+
You will need to pass an object that contains the rawtx:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
{
|
|
126
|
+
rawtx: string
|
|
127
|
+
fund?: boolean;
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
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.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
const param = {
|
|
135
|
+
rawtx:"xxx",
|
|
136
|
+
};
|
|
137
|
+
const txid = await wallet.broadcast(param);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
##### Sign Message
|
|
141
|
+
|
|
142
|
+
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:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
{
|
|
146
|
+
message: string;
|
|
147
|
+
encoding?: "utf8" | "hex" | "base64" ;
|
|
148
|
+
};
|
|
149
|
+
const message = { message: "Hello world" };
|
|
150
|
+
const response = await panda.signMessage(message);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
##### Get Signatures
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
const sigRequests: SignatureRequest[] = [
|
|
157
|
+
{
|
|
158
|
+
prevTxid:
|
|
159
|
+
outputIndex: 0,
|
|
160
|
+
inputIndex: 0,
|
|
161
|
+
satoshis: 1,
|
|
162
|
+
address:
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
prevTxid:
|
|
166
|
+
outputIndex: 0,
|
|
167
|
+
inputIndex: 1,
|
|
168
|
+
satoshis: 1000,
|
|
169
|
+
address:
|
|
170
|
+
script:
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
const sigResponses: SignatureResponse[] = await wallet.getSignatures({
|
|
175
|
+
rawtx:
|
|
176
|
+
sigRequests
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
# Demo
|
|
181
|
+
|
|
182
|
+
[turing-wallet-sample](https://github.com/TuringBitChain/turing-wallet-sample)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import { TuringProviderType } from "
|
|
3
|
-
export declare const TuringContext: import("react").Context<TuringProviderType | undefined>;
|
|
4
|
-
interface TuringProviderProps {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const TuringProvider: (props:TuringProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export {};
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { TuringProviderType } from "../types/providerTypes"
|
|
3
|
+
export declare const TuringContext: import("react").Context<TuringProviderType | undefined>;
|
|
4
|
+
interface TuringProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const TuringProvider: (props: TuringProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export { };
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TuringProvider = exports.TuringContext = void 0;
|
|
4
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
var react_1 = require("react");
|
|
6
|
-
exports.TuringContext = (0, react_1.createContext)(undefined);
|
|
7
|
-
var TuringProvider = function (props) {
|
|
8
|
-
var children = props.children;
|
|
9
|
-
// It takes a moment for the Turing wallet to get injected into the DOM. To use context we need an initial state;
|
|
10
|
-
var _a = (0, react_1.useState)({ isReady: false }), TuringWallet = _a[0], setTuringWallet = _a[1];
|
|
11
|
-
(0, react_1.useEffect)(function () {
|
|
12
|
-
var checkTuringWallet = function () {
|
|
13
|
-
var _a;
|
|
14
|
-
if ("Turing" in window && ((_a = window.Turing) === null || _a === void 0 ? void 0 : _a.isReady)) {
|
|
15
|
-
setTuringWallet(window.Turing);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
checkTuringWallet();
|
|
19
|
-
var intervalId = setInterval(checkTuringWallet, 1000);
|
|
20
|
-
return function () { return clearInterval(intervalId); };
|
|
21
|
-
}, []);
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(exports.TuringContext.Provider, { value: TuringWallet, children: children }));
|
|
23
|
-
};
|
|
24
|
-
exports.TuringProvider = TuringProvider;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TuringProvider = exports.TuringContext = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
exports.TuringContext = (0, react_1.createContext)(undefined);
|
|
7
|
+
var TuringProvider = function (props) {
|
|
8
|
+
var children = props.children;
|
|
9
|
+
// It takes a moment for the Turing wallet to get injected into the DOM. To use context we need an initial state;
|
|
10
|
+
var _a = (0, react_1.useState)({ isReady: false }), TuringWallet = _a[0], setTuringWallet = _a[1];
|
|
11
|
+
(0, react_1.useEffect)(function () {
|
|
12
|
+
var checkTuringWallet = function () {
|
|
13
|
+
var _a;
|
|
14
|
+
if ("Turing" in window && ((_a = window.Turing) === null || _a === void 0 ? void 0 : _a.isReady)) {
|
|
15
|
+
setTuringWallet(window.Turing);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
checkTuringWallet();
|
|
19
|
+
var intervalId = setInterval(checkTuringWallet, 1000);
|
|
20
|
+
return function () { return clearInterval(intervalId); };
|
|
21
|
+
}, []);
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(exports.TuringContext.Provider, { value: TuringWallet, children: children }));
|
|
23
|
+
};
|
|
24
|
+
exports.TuringProvider = TuringProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useTuringWallet: () => import("..").TuringProviderType;
|
|
1
|
+
export declare const useTuringWallet: () => import("..").TuringProviderType;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useTuringWallet = void 0;
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var TuringWalletContext_1 = require("../context/TuringWalletContext");
|
|
6
|
-
var useTuringWallet = function () {
|
|
7
|
-
var context = (0, react_1.useContext)(TuringWalletContext_1.TuringContext);
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useTuringWallet must be used within a TuringProvider");
|
|
10
|
-
}
|
|
11
|
-
return context;
|
|
12
|
-
};
|
|
13
|
-
exports.useTuringWallet = useTuringWallet;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTuringWallet = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var TuringWalletContext_1 = require("../context/TuringWalletContext");
|
|
6
|
+
var useTuringWallet = function () {
|
|
7
|
+
var context = (0, react_1.useContext)(TuringWalletContext_1.TuringContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("useTuringWallet must be used within a TuringProvider");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
13
|
+
exports.useTuringWallet = useTuringWallet;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./context/TuringWalletContext";
|
|
2
|
-
export * from "./hook/useTuringWallet";
|
|
3
|
-
export * from "./types/providerTypes";
|
|
1
|
+
export * from "./context/TuringWalletContext";
|
|
2
|
+
export * from "./hook/useTuringWallet";
|
|
3
|
+
export * from "./types/providerTypes";
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./context/TuringWalletContext"), exports);
|
|
18
|
-
__exportStar(require("./hook/useTuringWallet"), exports);
|
|
19
|
-
__exportStar(require("./types/providerTypes"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./context/TuringWalletContext"), exports);
|
|
18
|
+
__exportStar(require("./hook/useTuringWallet"), exports);
|
|
19
|
+
__exportStar(require("./types/providerTypes"), exports);
|
|
@@ -1,252 +1,252 @@
|
|
|
1
|
-
export type PubKeys = {
|
|
2
|
-
|
|
3
|
-
ordPubKey: string;
|
|
4
|
-
identityPubKey: string;
|
|
5
|
-
};
|
|
6
|
-
export type Addresses = {
|
|
7
|
-
|
|
8
|
-
ordAddress: string;
|
|
9
|
-
identityAddress: string;
|
|
10
|
-
};
|
|
11
|
-
export type Balance = {
|
|
12
|
-
|
|
13
|
-
satoshis: number;
|
|
14
|
-
usdInCents: number;
|
|
15
|
-
};
|
|
16
|
-
export type SocialProfile = {
|
|
17
|
-
displayName: string;
|
|
18
|
-
avatar: string;
|
|
19
|
-
};
|
|
20
|
-
export type OrdinalData = {
|
|
21
|
-
types?: string[];
|
|
22
|
-
insc?: Inscription;
|
|
23
|
-
map?: {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
};
|
|
26
|
-
b?: File;
|
|
27
|
-
sigma?: Sigma[];
|
|
28
|
-
list?: Listing;
|
|
29
|
-
|
|
30
|
-
lock?: Lock;
|
|
31
|
-
};
|
|
32
|
-
export type Lock = {
|
|
33
|
-
address: string;
|
|
34
|
-
until: number;
|
|
35
|
-
};
|
|
36
|
-
export type Sigma = {
|
|
37
|
-
algorithm: string;
|
|
38
|
-
address: string;
|
|
39
|
-
signature: string;
|
|
40
|
-
vin: number;
|
|
41
|
-
};
|
|
42
|
-
export type Listing = {
|
|
43
|
-
price: number;
|
|
44
|
-
payout: string;
|
|
45
|
-
};
|
|
46
|
-
export type
|
|
47
|
-
id?: string;
|
|
48
|
-
p: string;
|
|
49
|
-
op: string;
|
|
50
|
-
tick?: string;
|
|
51
|
-
amt: string;
|
|
52
|
-
status?:
|
|
53
|
-
};
|
|
54
|
-
export type Origin = {
|
|
55
|
-
outpoint: string;
|
|
56
|
-
data?: OrdinalData;
|
|
57
|
-
num?: number;
|
|
58
|
-
};
|
|
59
|
-
export declare enum
|
|
60
|
-
Invalid = -1,
|
|
61
|
-
Pending = 0,
|
|
62
|
-
Valid = 1
|
|
63
|
-
}
|
|
64
|
-
export type File = {
|
|
65
|
-
type: string;
|
|
66
|
-
size: number;
|
|
67
|
-
hash: string;
|
|
68
|
-
};
|
|
69
|
-
export type Inscription = {
|
|
70
|
-
json?: any;
|
|
71
|
-
text?: string;
|
|
72
|
-
words?: string[];
|
|
73
|
-
file: File;
|
|
74
|
-
};
|
|
75
|
-
export type Ordinal = {
|
|
76
|
-
txid: string;
|
|
77
|
-
vout: number;
|
|
78
|
-
outpoint: string;
|
|
79
|
-
satoshis: number;
|
|
80
|
-
owner: string;
|
|
81
|
-
script: string;
|
|
82
|
-
spend: string;
|
|
83
|
-
origin: Origin;
|
|
84
|
-
height: number;
|
|
85
|
-
idx: number;
|
|
86
|
-
data: OrdinalData;
|
|
87
|
-
};
|
|
88
|
-
export type SignedMessage = {
|
|
89
|
-
address: string;
|
|
90
|
-
pubKey: string;
|
|
91
|
-
sig: string;
|
|
92
|
-
message: string;
|
|
93
|
-
derivationTag: DerivationTag;
|
|
94
|
-
};
|
|
95
|
-
export type
|
|
96
|
-
address?: string;
|
|
97
|
-
satoshis: number;
|
|
98
|
-
data?: string[];
|
|
99
|
-
script?: string;
|
|
100
|
-
inscription?: RawInscription;
|
|
101
|
-
};
|
|
102
|
-
export type TransferOrdinal = {
|
|
103
|
-
address: string;
|
|
104
|
-
origin: string;
|
|
105
|
-
outpoint: string;
|
|
106
|
-
};
|
|
107
|
-
export type InternalTuringTags = {
|
|
108
|
-
label: "Turing";
|
|
109
|
-
id: "
|
|
110
|
-
domain: "";
|
|
111
|
-
meta: {};
|
|
112
|
-
} | {
|
|
113
|
-
label: "Turing";
|
|
114
|
-
id: "ord";
|
|
115
|
-
domain: "";
|
|
116
|
-
meta: {};
|
|
117
|
-
} | {
|
|
118
|
-
label: "Turing";
|
|
119
|
-
id: "identity";
|
|
120
|
-
domain: "";
|
|
121
|
-
meta: {};
|
|
122
|
-
};
|
|
123
|
-
export type DerivationTag = InternalTuringTags | {
|
|
124
|
-
label: string;
|
|
125
|
-
id: string;
|
|
126
|
-
domain: string;
|
|
127
|
-
meta?: Record<string, any>;
|
|
128
|
-
};
|
|
129
|
-
export type SignMessage = {
|
|
130
|
-
message: string;
|
|
131
|
-
encoding?: "utf8" | "hex" | "base64";
|
|
132
|
-
};
|
|
133
|
-
export type KeyTypes = "
|
|
134
|
-
export type Broadcast = {
|
|
135
|
-
rawtx: string;
|
|
136
|
-
fund?: boolean;
|
|
137
|
-
};
|
|
138
|
-
export type PurchaseOrdinal = {
|
|
139
|
-
outpoint: string;
|
|
140
|
-
marketplaceRate?: number;
|
|
141
|
-
marketplaceAddress?: string;
|
|
142
|
-
};
|
|
143
|
-
export type Utxos = {
|
|
144
|
-
satoshis: number;
|
|
145
|
-
script: string;
|
|
146
|
-
txid: string;
|
|
147
|
-
vout: number;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* `SignatureRequest` contains required informations for a signer to sign a certain input of a transaction.
|
|
151
|
-
*/
|
|
152
|
-
export type SignatureRequest = {
|
|
153
|
-
prevTxid: string;
|
|
154
|
-
outputIndex: number;
|
|
155
|
-
/** The index of input to sign. */
|
|
156
|
-
inputIndex: number;
|
|
157
|
-
/** The previous output satoshis value of the input to spend. */
|
|
158
|
-
satoshis: number;
|
|
159
|
-
/** The address(es) of corresponding private key(s) required to sign the input. */
|
|
160
|
-
address: string | string[];
|
|
161
|
-
/** The previous output script of input, default value is a P2PKH locking script for the `address` if omitted. */
|
|
162
|
-
script?: string;
|
|
163
|
-
/** The sighash type, default value is `SIGHASH_ALL | SIGHASH_FORKID` if omitted. */
|
|
164
|
-
sigHashType?: number;
|
|
165
|
-
/**
|
|
166
|
-
* Index of the OP_CODESEPARATOR to split the previous output script at during verification.
|
|
167
|
-
* If undefined, the whole script is used.
|
|
168
|
-
* */
|
|
169
|
-
csIdx?: number;
|
|
170
|
-
/** The extra information for signing. */
|
|
171
|
-
data?: unknown;
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* `SignatureResponse` contains the signing result corresponding to a `SignatureRequest`.
|
|
175
|
-
*/
|
|
176
|
-
export type SignatureResponse = {
|
|
177
|
-
/** The index of input. */
|
|
178
|
-
inputIndex: number;
|
|
179
|
-
/** The signature.*/
|
|
180
|
-
sig: string;
|
|
181
|
-
/** The public key bound with the `sig`. */
|
|
182
|
-
pubKey: string;
|
|
183
|
-
/** The sighash type, default value is `SIGHASH_ALL | SIGHASH_FORKID` if omitted. */
|
|
184
|
-
sigHashType: number;
|
|
185
|
-
/** The index of the OP_CODESEPARATOR to split the previous output script at.*/
|
|
186
|
-
csIdx?: number;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* `
|
|
190
|
-
*/
|
|
191
|
-
export type
|
|
192
|
-
txid: string;
|
|
193
|
-
rawtx: string;
|
|
194
|
-
};
|
|
195
|
-
export type GetSignatures = {
|
|
196
|
-
rawtx: string;
|
|
197
|
-
sigRequests: SignatureRequest[];
|
|
198
|
-
};
|
|
199
|
-
export type TaggedDerivationRequest = {
|
|
200
|
-
label: string;
|
|
201
|
-
id: string;
|
|
202
|
-
meta?: Record<string, any>;
|
|
203
|
-
};
|
|
204
|
-
export type TaggedDerivationResponse = {
|
|
205
|
-
address: string;
|
|
206
|
-
pubKey: string;
|
|
207
|
-
tag: DerivationTag;
|
|
208
|
-
};
|
|
209
|
-
export type MimeTypes = "text/plain" | "text/html" | "text/css" | "application/javascript" | "application/json" | "application/xml" | "image/jpeg" | "image/png" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/wav" | "audio/wave" | "video/mp4" | "application/pdf" | "application/msword" | "application/vnd.ms-excel" | "application/vnd.ms-powerpoint" | "application/zip" | "application/x-7z-compressed" | "application/x-gzip" | "application/x-tar" | "application/x-bzip2";
|
|
210
|
-
export type MAP = {
|
|
211
|
-
app: string;
|
|
212
|
-
type: string;
|
|
213
|
-
[prop: string]: string;
|
|
214
|
-
};
|
|
215
|
-
export type RawInscription = {
|
|
216
|
-
base64Data: string;
|
|
217
|
-
mimeType: MimeTypes;
|
|
218
|
-
map?: MAP;
|
|
219
|
-
};
|
|
220
|
-
export type InscribeRequest = {
|
|
221
|
-
address: string;
|
|
222
|
-
base64Data: string;
|
|
223
|
-
mimeType: MimeTypes;
|
|
224
|
-
map?: MAP;
|
|
225
|
-
satoshis?: number;
|
|
226
|
-
};
|
|
227
|
-
export type GetTaggedKeysRequest = {
|
|
228
|
-
label: string;
|
|
229
|
-
ids?: string[];
|
|
230
|
-
};
|
|
231
|
-
export type TuringProviderType = {
|
|
232
|
-
isReady: boolean;
|
|
233
|
-
connect: () => Promise<string | undefined>;
|
|
234
|
-
disconnect: () => Promise<boolean>;
|
|
235
|
-
isConnected: () => Promise<boolean>;
|
|
236
|
-
getPubKeys: () => Promise<PubKeys | undefined>;
|
|
237
|
-
getAddresses: () => Promise<Addresses | undefined>;
|
|
238
|
-
getSocialProfile: () => Promise<SocialProfile | undefined>;
|
|
239
|
-
getBalance: () => Promise<Balance | undefined>;
|
|
240
|
-
getOrdinals: () => Promise<Ordinal[] | undefined>;
|
|
241
|
-
|
|
242
|
-
transferOrdinal: (params: TransferOrdinal) => Promise<string | undefined>;
|
|
243
|
-
purchaseOrdinal: (params: PurchaseOrdinal) => Promise<string | undefined>;
|
|
244
|
-
signMessage: (params: SignMessage) => Promise<SignedMessage | undefined>;
|
|
245
|
-
getSignatures: (params: GetSignatures) => Promise<SignatureResponse[] | undefined>;
|
|
246
|
-
broadcast: (params: Broadcast) => Promise<string | undefined>;
|
|
247
|
-
getExchangeRate: () => Promise<number | undefined>;
|
|
248
|
-
getPaymentUtxos: () => Promise<Utxos[] | undefined>;
|
|
249
|
-
generateTaggedKeys: (params: TaggedDerivationRequest) => Promise<TaggedDerivationResponse>;
|
|
250
|
-
getTaggedKeys: (params: GetTaggedKeysRequest) => Promise<TaggedDerivationResponse[] | undefined>;
|
|
251
|
-
inscribe: (params: InscribeRequest[]) => Promise<
|
|
252
|
-
};
|
|
1
|
+
export type PubKeys = {
|
|
2
|
+
tbcPubKey: string;
|
|
3
|
+
ordPubKey: string;
|
|
4
|
+
identityPubKey: string;
|
|
5
|
+
};
|
|
6
|
+
export type Addresses = {
|
|
7
|
+
tbcAddress: string;
|
|
8
|
+
ordAddress: string;
|
|
9
|
+
identityAddress: string;
|
|
10
|
+
};
|
|
11
|
+
export type Balance = {
|
|
12
|
+
tbc: number;
|
|
13
|
+
satoshis: number;
|
|
14
|
+
usdInCents: number;
|
|
15
|
+
};
|
|
16
|
+
export type SocialProfile = {
|
|
17
|
+
displayName: string;
|
|
18
|
+
avatar: string;
|
|
19
|
+
};
|
|
20
|
+
export type OrdinalData = {
|
|
21
|
+
types?: string[];
|
|
22
|
+
insc?: Inscription;
|
|
23
|
+
map?: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
b?: File;
|
|
27
|
+
sigma?: Sigma[];
|
|
28
|
+
list?: Listing;
|
|
29
|
+
tbc20?: Tbc20;
|
|
30
|
+
lock?: Lock;
|
|
31
|
+
};
|
|
32
|
+
export type Lock = {
|
|
33
|
+
address: string;
|
|
34
|
+
until: number;
|
|
35
|
+
};
|
|
36
|
+
export type Sigma = {
|
|
37
|
+
algorithm: string;
|
|
38
|
+
address: string;
|
|
39
|
+
signature: string;
|
|
40
|
+
vin: number;
|
|
41
|
+
};
|
|
42
|
+
export type Listing = {
|
|
43
|
+
price: number;
|
|
44
|
+
payout: string;
|
|
45
|
+
};
|
|
46
|
+
export type Tbc20 = {
|
|
47
|
+
id?: string;
|
|
48
|
+
p: string;
|
|
49
|
+
op: string;
|
|
50
|
+
tick?: string;
|
|
51
|
+
amt: string;
|
|
52
|
+
status?: Tbc20Status;
|
|
53
|
+
};
|
|
54
|
+
export type Origin = {
|
|
55
|
+
outpoint: string;
|
|
56
|
+
data?: OrdinalData;
|
|
57
|
+
num?: number;
|
|
58
|
+
};
|
|
59
|
+
export declare enum Tbc20Status {
|
|
60
|
+
Invalid = -1,
|
|
61
|
+
Pending = 0,
|
|
62
|
+
Valid = 1
|
|
63
|
+
}
|
|
64
|
+
export type File = {
|
|
65
|
+
type: string;
|
|
66
|
+
size: number;
|
|
67
|
+
hash: string;
|
|
68
|
+
};
|
|
69
|
+
export type Inscription = {
|
|
70
|
+
json?: any;
|
|
71
|
+
text?: string;
|
|
72
|
+
words?: string[];
|
|
73
|
+
file: File;
|
|
74
|
+
};
|
|
75
|
+
export type Ordinal = {
|
|
76
|
+
txid: string;
|
|
77
|
+
vout: number;
|
|
78
|
+
outpoint: string;
|
|
79
|
+
satoshis: number;
|
|
80
|
+
owner: string;
|
|
81
|
+
script: string;
|
|
82
|
+
spend: string;
|
|
83
|
+
origin: Origin;
|
|
84
|
+
height: number;
|
|
85
|
+
idx: number;
|
|
86
|
+
data: OrdinalData;
|
|
87
|
+
};
|
|
88
|
+
export type SignedMessage = {
|
|
89
|
+
address: string;
|
|
90
|
+
pubKey: string;
|
|
91
|
+
sig: string;
|
|
92
|
+
message: string;
|
|
93
|
+
derivationTag: DerivationTag;
|
|
94
|
+
};
|
|
95
|
+
export type SendTbc = {
|
|
96
|
+
address?: string;
|
|
97
|
+
satoshis: number;
|
|
98
|
+
data?: string[];
|
|
99
|
+
script?: string;
|
|
100
|
+
inscription?: RawInscription;
|
|
101
|
+
};
|
|
102
|
+
export type TransferOrdinal = {
|
|
103
|
+
address: string;
|
|
104
|
+
origin: string;
|
|
105
|
+
outpoint: string;
|
|
106
|
+
};
|
|
107
|
+
export type InternalTuringTags = {
|
|
108
|
+
label: "Turing";
|
|
109
|
+
id: "tbc";
|
|
110
|
+
domain: "";
|
|
111
|
+
meta: {};
|
|
112
|
+
} | {
|
|
113
|
+
label: "Turing";
|
|
114
|
+
id: "ord";
|
|
115
|
+
domain: "";
|
|
116
|
+
meta: {};
|
|
117
|
+
} | {
|
|
118
|
+
label: "Turing";
|
|
119
|
+
id: "identity";
|
|
120
|
+
domain: "";
|
|
121
|
+
meta: {};
|
|
122
|
+
};
|
|
123
|
+
export type DerivationTag = InternalTuringTags | {
|
|
124
|
+
label: string;
|
|
125
|
+
id: string;
|
|
126
|
+
domain: string;
|
|
127
|
+
meta?: Record<string, any>;
|
|
128
|
+
};
|
|
129
|
+
export type SignMessage = {
|
|
130
|
+
message: string;
|
|
131
|
+
encoding?: "utf8" | "hex" | "base64";
|
|
132
|
+
};
|
|
133
|
+
export type KeyTypes = "tbc" | "ord";
|
|
134
|
+
export type Broadcast = {
|
|
135
|
+
rawtx: string;
|
|
136
|
+
fund?: boolean;
|
|
137
|
+
};
|
|
138
|
+
export type PurchaseOrdinal = {
|
|
139
|
+
outpoint: string;
|
|
140
|
+
marketplaceRate?: number;
|
|
141
|
+
marketplaceAddress?: string;
|
|
142
|
+
};
|
|
143
|
+
export type Utxos = {
|
|
144
|
+
satoshis: number;
|
|
145
|
+
script: string;
|
|
146
|
+
txid: string;
|
|
147
|
+
vout: number;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* `SignatureRequest` contains required informations for a signer to sign a certain input of a transaction.
|
|
151
|
+
*/
|
|
152
|
+
export type SignatureRequest = {
|
|
153
|
+
prevTxid: string;
|
|
154
|
+
outputIndex: number;
|
|
155
|
+
/** The index of input to sign. */
|
|
156
|
+
inputIndex: number;
|
|
157
|
+
/** The previous output satoshis value of the input to spend. */
|
|
158
|
+
satoshis: number;
|
|
159
|
+
/** The address(es) of corresponding private key(s) required to sign the input. */
|
|
160
|
+
address: string | string[];
|
|
161
|
+
/** The previous output script of input, default value is a P2PKH locking script for the `address` if omitted. */
|
|
162
|
+
script?: string;
|
|
163
|
+
/** The sighash type, default value is `SIGHASH_ALL | SIGHASH_FORKID` if omitted. */
|
|
164
|
+
sigHashType?: number;
|
|
165
|
+
/**
|
|
166
|
+
* Index of the OP_CODESEPARATOR to split the previous output script at during verification.
|
|
167
|
+
* If undefined, the whole script is used.
|
|
168
|
+
* */
|
|
169
|
+
csIdx?: number;
|
|
170
|
+
/** The extra information for signing. */
|
|
171
|
+
data?: unknown;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* `SignatureResponse` contains the signing result corresponding to a `SignatureRequest`.
|
|
175
|
+
*/
|
|
176
|
+
export type SignatureResponse = {
|
|
177
|
+
/** The index of input. */
|
|
178
|
+
inputIndex: number;
|
|
179
|
+
/** The signature.*/
|
|
180
|
+
sig: string;
|
|
181
|
+
/** The public key bound with the `sig`. */
|
|
182
|
+
pubKey: string;
|
|
183
|
+
/** The sighash type, default value is `SIGHASH_ALL | SIGHASH_FORKID` if omitted. */
|
|
184
|
+
sigHashType: number;
|
|
185
|
+
/** The index of the OP_CODESEPARATOR to split the previous output script at.*/
|
|
186
|
+
csIdx?: number;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* `SendTbcResponse` contains the result of sendTbc.
|
|
190
|
+
*/
|
|
191
|
+
export type SendTbcResponse = {
|
|
192
|
+
txid: string;
|
|
193
|
+
rawtx: string;
|
|
194
|
+
};
|
|
195
|
+
export type GetSignatures = {
|
|
196
|
+
rawtx: string;
|
|
197
|
+
sigRequests: SignatureRequest[];
|
|
198
|
+
};
|
|
199
|
+
export type TaggedDerivationRequest = {
|
|
200
|
+
label: string;
|
|
201
|
+
id: string;
|
|
202
|
+
meta?: Record<string, any>;
|
|
203
|
+
};
|
|
204
|
+
export type TaggedDerivationResponse = {
|
|
205
|
+
address: string;
|
|
206
|
+
pubKey: string;
|
|
207
|
+
tag: DerivationTag;
|
|
208
|
+
};
|
|
209
|
+
export type MimeTypes = "text/plain" | "text/html" | "text/css" | "application/javascript" | "application/json" | "application/xml" | "image/jpeg" | "image/png" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/wav" | "audio/wave" | "video/mp4" | "application/pdf" | "application/msword" | "application/vnd.ms-excel" | "application/vnd.ms-powerpoint" | "application/zip" | "application/x-7z-compressed" | "application/x-gzip" | "application/x-tar" | "application/x-bzip2";
|
|
210
|
+
export type MAP = {
|
|
211
|
+
app: string;
|
|
212
|
+
type: string;
|
|
213
|
+
[prop: string]: string;
|
|
214
|
+
};
|
|
215
|
+
export type RawInscription = {
|
|
216
|
+
base64Data: string;
|
|
217
|
+
mimeType: MimeTypes;
|
|
218
|
+
map?: MAP;
|
|
219
|
+
};
|
|
220
|
+
export type InscribeRequest = {
|
|
221
|
+
address: string;
|
|
222
|
+
base64Data: string;
|
|
223
|
+
mimeType: MimeTypes;
|
|
224
|
+
map?: MAP;
|
|
225
|
+
satoshis?: number;
|
|
226
|
+
};
|
|
227
|
+
export type GetTaggedKeysRequest = {
|
|
228
|
+
label: string;
|
|
229
|
+
ids?: string[];
|
|
230
|
+
};
|
|
231
|
+
export type TuringProviderType = {
|
|
232
|
+
isReady: boolean;
|
|
233
|
+
connect: () => Promise<string | undefined>;
|
|
234
|
+
disconnect: () => Promise<boolean>;
|
|
235
|
+
isConnected: () => Promise<boolean>;
|
|
236
|
+
getPubKeys: () => Promise<PubKeys | undefined>;
|
|
237
|
+
getAddresses: () => Promise<Addresses | undefined>;
|
|
238
|
+
getSocialProfile: () => Promise<SocialProfile | undefined>;
|
|
239
|
+
getBalance: () => Promise<Balance | undefined>;
|
|
240
|
+
getOrdinals: () => Promise<Ordinal[] | undefined>;
|
|
241
|
+
sendTbc: (params: SendTbc[]) => Promise<SendTbcResponse | undefined>;
|
|
242
|
+
transferOrdinal: (params: TransferOrdinal) => Promise<string | undefined>;
|
|
243
|
+
purchaseOrdinal: (params: PurchaseOrdinal) => Promise<string | undefined>;
|
|
244
|
+
signMessage: (params: SignMessage) => Promise<SignedMessage | undefined>;
|
|
245
|
+
getSignatures: (params: GetSignatures) => Promise<SignatureResponse[] | undefined>;
|
|
246
|
+
broadcast: (params: Broadcast) => Promise<string | undefined>;
|
|
247
|
+
getExchangeRate: () => Promise<number | undefined>;
|
|
248
|
+
getPaymentUtxos: () => Promise<Utxos[] | undefined>;
|
|
249
|
+
generateTaggedKeys: (params: TaggedDerivationRequest) => Promise<TaggedDerivationResponse>;
|
|
250
|
+
getTaggedKeys: (params: GetTaggedKeysRequest) => Promise<TaggedDerivationResponse[] | undefined>;
|
|
251
|
+
inscribe: (params: InscribeRequest[]) => Promise<SendTbcResponse | undefined>;
|
|
252
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})(
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tbc20Status = void 0;
|
|
4
|
+
var Tbc20Status;
|
|
5
|
+
(function (Tbc20Status) {
|
|
6
|
+
Tbc20Status[Tbc20Status["Invalid"] = -1] = "Invalid";
|
|
7
|
+
Tbc20Status[Tbc20Status["Pending"] = 0] = "Pending";
|
|
8
|
+
Tbc20Status[Tbc20Status["Valid"] = 1] = "Valid";
|
|
9
|
+
})(Tbc20Status || (exports.Tbc20Status = Tbc20Status = {}));
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "turing-wallet-provider",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "tsc"
|
|
11
|
-
},
|
|
12
|
-
"peerDependencies": {
|
|
13
|
-
"react": ">=17.0.0",
|
|
14
|
-
"react-dom": ">=17.0.0"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"typescript": "^4.5.0",
|
|
18
|
-
"react": "^17.0.0",
|
|
19
|
-
"react-dom": "^17.0.0",
|
|
20
|
-
"@types/react": "^17.0.0",
|
|
21
|
-
"@types/react-dom": "^17.0.0"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"wallet",
|
|
25
|
-
"turing",
|
|
26
|
-
"
|
|
27
|
-
"bitcoin",
|
|
28
|
-
"turing wallet"
|
|
29
|
-
],
|
|
30
|
-
"author": "Joer",
|
|
31
|
-
"license": "ISC",
|
|
32
|
-
"description": "A provider that makes interacting with Turing Wallet a walk in the park."
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "turing-wallet-provider",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"react": ">=17.0.0",
|
|
14
|
+
"react-dom": ">=17.0.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"typescript": "^4.5.0",
|
|
18
|
+
"react": "^17.0.0",
|
|
19
|
+
"react-dom": "^17.0.0",
|
|
20
|
+
"@types/react": "^17.0.0",
|
|
21
|
+
"@types/react-dom": "^17.0.0"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"wallet",
|
|
25
|
+
"turing",
|
|
26
|
+
"tbc",
|
|
27
|
+
"bitcoin",
|
|
28
|
+
"turing wallet"
|
|
29
|
+
],
|
|
30
|
+
"author": "Joer",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"description": "A provider that makes interacting with Turing Wallet a walk in the park."
|
|
33
|
+
}
|