@tezos-x/octez.connect-sdk 0.9.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/LICENCE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2021 Papers AG
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19
+ OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # octez.connect SDK
2
+
3
+ [![npm](https://img.shields.io/npm/v/@tezos-x/octez.connect-sdk.svg?colorB=brightgreen)](https://www.npmjs.com/package/@tezos-x/octez.connect-sdk)
4
+ [![documentation](https://img.shields.io/badge/documentation-online-brightgreen.svg)](https://trilitech.github.io/octez.connect-sdk/)
5
+ [![GitHub Action](https://github.com/trilitech/octez.connect-sdk/workflows/Build%2C%20Test%20and%20Analyze/badge.svg)](https://github.com/trilitech/octez.connect-sdk/actions?query=workflow%3A%22Build%2C+Test+and+Analyze%22+branch%3Amain)
6
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
7
+
8
+ ## Intro
9
+
10
+ The `octez.connect-sdk` simplifies and abstracts the communication between dApps and wallets over different transport layers.
11
+
12
+ Developers that plan to develop complex smart contract interactions can use [Taquito](https://github.com/ecadlabs/taquito) with the `BeaconWallet`, which uses this SDK under the hood, but provides helpful methods to interact with contracts.
13
+
14
+
15
+ ## Installation
16
+
17
+ ```
18
+ npm i --save @tezos-x/octez.connect-sdk
19
+ ```
20
+
21
+ ## Example DApp integration
22
+
23
+ ```ts
24
+ const client = new DAppClient({ name: 'My Sample DApp' })
25
+
26
+ client
27
+ .requestPermissions() // Send a permission request and automatically show UI to the user to select his favorite wallet
28
+ .then((permissions) => {
29
+ // Account that has been shared by the wallet
30
+ console.log('got permissions', permissions)
31
+ })
32
+ .catch((error) => console.log(error))
33
+ ```
34
+
35
+ For a more complete example, take a look at the `example-dapp.html` file.
36
+
37
+ ## Example Wallet integration
38
+
39
+ ```ts
40
+ const client = new WalletClient({ name: 'My Wallet' })
41
+ await client.init() // Establish P2P connection
42
+
43
+ client
44
+ .connect(async (message) => {
45
+ // Example: Handle PermissionRequest. A wallet should handle all request types
46
+ if (message.type === BeaconMessageType.PermissionRequest) {
47
+ // Show a UI to the user where he can confirm sharing an account with the DApp
48
+
49
+ const response: PermissionResponseInput = {
50
+ type: BeaconMessageType.PermissionResponse,
51
+ network: message.network, // Use the same network that the user requested
52
+ scopes: [PermissionScope.OPERATION_REQUEST], // Ignore the scopes that have been requested and instead give only operation permissions
53
+ id: message.id,
54
+ publicKey: 'tezos public key'
55
+ }
56
+
57
+ // Send response back to DApp
58
+ await client.respond(response)
59
+ }
60
+ })
61
+ .catch((error) => console.error('connect error', error))
62
+ ```
63
+
64
+ For a more complete example, take a look at the `example-wallet.html` file.
65
+
66
+ ## Adding a wallet to octez.connect-sdk
67
+
68
+ Please create a PR and add your wallet [here](https://github.com/trilitech/octez.connect-sdk/blob/master/scripts/generate-wallet-list.ts).
69
+
70
+ For iOS wallets, the wallet needs to define a custom url scheme to support the same-device functionality.
71
+
72
+ ## Development
73
+
74
+ ```
75
+ $ npm i
76
+ $ npm run build
77
+ $ npm run test
78
+ ```
79
+
80
+ Once the SDK is built, you can open the `example-dapp.html` file in your browser and try out the basic functionality. To support browser extensions as well, the file should be viewed over a webserver. You can easily start one with `python -m SimpleHTTPServer 8000` and then open the file with `http://localhost:8000/example-dapp.html`.
@@ -0,0 +1,10 @@
1
+ export * from '@tezos-x/octez.connect-blockchain-substrate';
2
+ export * from '@tezos-x/octez.connect-blockchain-tezos';
3
+ export * from '@tezos-x/octez.connect-core';
4
+ export * from '@tezos-x/octez.connect-dapp';
5
+ export * from '@tezos-x/octez.connect-transport-matrix';
6
+ export * from '@tezos-x/octez.connect-transport-postmessage';
7
+ export * from '@tezos-x/octez.connect-transport-walletconnect';
8
+ export * from '@tezos-x/octez.connect-types';
9
+ export * from '@tezos-x/octez.connect-utils';
10
+ export * from '@tezos-x/octez.connect-wallet';
@@ -0,0 +1,28 @@
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("@tezos-x/octez.connect-blockchain-substrate"), exports);
18
+ __exportStar(require("@tezos-x/octez.connect-blockchain-tezos"), exports);
19
+ __exportStar(require("@tezos-x/octez.connect-core"), exports);
20
+ __exportStar(require("@tezos-x/octez.connect-dapp"), exports);
21
+ __exportStar(require("@tezos-x/octez.connect-transport-matrix"), exports);
22
+ __exportStar(require("@tezos-x/octez.connect-transport-postmessage"), exports);
23
+ __exportStar(require("@tezos-x/octez.connect-transport-walletconnect"), exports);
24
+ __exportStar(require("@tezos-x/octez.connect-types"), exports);
25
+ // export * from '@tezos-x/octez.connect-ui'
26
+ __exportStar(require("@tezos-x/octez.connect-utils"), exports);
27
+ __exportStar(require("@tezos-x/octez.connect-wallet"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8EAA2D;AAC3D,0EAAuD;AACvD,8DAA2C;AAC3C,8DAA2C;AAC3C,0EAAuD;AACvD,+EAA4D;AAC5D,iFAA8D;AAC9D,+DAA4C;AAC5C,4CAA4C;AAC5C,+DAA4C;AAC5C,gEAA6C"}
@@ -0,0 +1,10 @@
1
+ export * from '@tezos-x/octez.connect-blockchain-substrate';
2
+ export * from '@tezos-x/octez.connect-blockchain-tezos';
3
+ export * from '@tezos-x/octez.connect-core';
4
+ export * from '@tezos-x/octez.connect-dapp';
5
+ export * from '@tezos-x/octez.connect-transport-matrix';
6
+ export * from '@tezos-x/octez.connect-transport-postmessage';
7
+ export * from '@tezos-x/octez.connect-transport-walletconnect';
8
+ export * from '@tezos-x/octez.connect-types';
9
+ export * from '@tezos-x/octez.connect-utils';
10
+ export * from '@tezos-x/octez.connect-wallet';
@@ -0,0 +1,12 @@
1
+ export * from '@tezos-x/octez.connect-blockchain-substrate';
2
+ export * from '@tezos-x/octez.connect-blockchain-tezos';
3
+ export * from '@tezos-x/octez.connect-core';
4
+ export * from '@tezos-x/octez.connect-dapp';
5
+ export * from '@tezos-x/octez.connect-transport-matrix';
6
+ export * from '@tezos-x/octez.connect-transport-postmessage';
7
+ export * from '@tezos-x/octez.connect-transport-walletconnect';
8
+ export * from '@tezos-x/octez.connect-types';
9
+ // export * from '@tezos-x/octez.connect-ui'
10
+ export * from '@tezos-x/octez.connect-utils';
11
+ export * from '@tezos-x/octez.connect-wallet';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAA;AAC3D,cAAc,yCAAyC,CAAA;AACvD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,yCAAyC,CAAA;AACvD,cAAc,8CAA8C,CAAA;AAC5D,cAAc,gDAAgD,CAAA;AAC9D,cAAc,8BAA8B,CAAA;AAC5C,4CAA4C;AAC5C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA"}